mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-18 04:51:01 +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
@@ -23,7 +23,7 @@ use client::backend::AuxStore;
|
||||
use client::error::{Result as ClientResult, Error as ClientError};
|
||||
use fork_tree::ForkTree;
|
||||
use grandpa::round::State as RoundState;
|
||||
use runtime_primitives::traits::{Block as BlockT, NumberFor};
|
||||
use sr_primitives::traits::{Block as BlockT, NumberFor};
|
||||
use log::{info, warn};
|
||||
use substrate_telemetry::{telemetry, CONSENSUS_INFO};
|
||||
use fg_primitives::AuthorityId;
|
||||
@@ -456,7 +456,7 @@ pub(crate) fn load_authorities<B: AuxStore, H: Decode, N: Decode>(backend: &B)
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use substrate_primitives::H256;
|
||||
use primitives::H256;
|
||||
use test_client;
|
||||
use super::*;
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
//!
|
||||
//! We only send polite messages to peers,
|
||||
|
||||
use runtime_primitives::traits::{NumberFor, Block as BlockT, Zero};
|
||||
use sr_primitives::traits::{NumberFor, Block as BlockT, Zero};
|
||||
use network::consensus_gossip::{self as network_gossip, MessageIntent, ValidatorContext};
|
||||
use network::{config::Roles, PeerId};
|
||||
use parity_codec::{Encode, Decode};
|
||||
@@ -1249,7 +1249,7 @@ mod tests {
|
||||
use crate::authorities::AuthoritySet;
|
||||
use crate::environment::{CompletedRound, CompletedRounds, HasVoted, VoterSetState};
|
||||
use grandpa::round::State as RoundState;
|
||||
use substrate_primitives::H256;
|
||||
use primitives::H256;
|
||||
|
||||
let state = RoundState::genesis((H256::zero(), 0));
|
||||
let base = state.prevote_ghost.unwrap();
|
||||
|
||||
@@ -36,9 +36,9 @@ use futures::sync::{oneshot, mpsc};
|
||||
use log::{debug, trace};
|
||||
use tokio_executor::Executor;
|
||||
use parity_codec::{Encode, Decode};
|
||||
use substrate_primitives::{ed25519, Pair};
|
||||
use primitives::{ed25519, Pair};
|
||||
use substrate_telemetry::{telemetry, CONSENSUS_DEBUG, CONSENSUS_INFO};
|
||||
use runtime_primitives::traits::{Block as BlockT, Hash as HashT, Header as HeaderT};
|
||||
use sr_primitives::traits::{Block as BlockT, Hash as HashT, Header as HeaderT};
|
||||
use network::{consensus_gossip as network_gossip, NetworkService};
|
||||
use network_gossip::ConsensusMessage;
|
||||
|
||||
@@ -50,7 +50,7 @@ use crate::environment::HasVoted;
|
||||
use gossip::{
|
||||
GossipMessage, FullCatchUpMessage, FullCommitMessage, VoteOrPrecommitMessage, GossipValidator
|
||||
};
|
||||
use substrate_primitives::ed25519::{Public as AuthorityId, Signature as AuthoritySignature};
|
||||
use primitives::ed25519::{Public as AuthorityId, Signature as AuthoritySignature};
|
||||
|
||||
pub mod gossip;
|
||||
mod periodic;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
use super::{gossip::{NeighborPacket, GossipMessage}, Network};
|
||||
use futures::prelude::*;
|
||||
use futures::sync::mpsc;
|
||||
use runtime_primitives::traits::{NumberFor, Block as BlockT};
|
||||
use sr_primitives::traits::{NumberFor, Block as BlockT};
|
||||
use network::PeerId;
|
||||
use tokio_timer::Delay;
|
||||
use log::warn;
|
||||
|
||||
@@ -143,7 +143,7 @@ fn voter_set_state() -> SharedVoterSetState<Block> {
|
||||
use crate::authorities::AuthoritySet;
|
||||
use crate::environment::{CompletedRound, CompletedRounds, HasVoted, VoterSetState};
|
||||
use grandpa::round::State as RoundState;
|
||||
use substrate_primitives::H256;
|
||||
use primitives::H256;
|
||||
|
||||
let state = RoundState::genesis((H256::zero(), 0));
|
||||
let base = state.prevote_ghost.unwrap();
|
||||
|
||||
@@ -33,11 +33,11 @@ use grandpa::{
|
||||
BlockNumberOps, Equivocation, Error as GrandpaError, round::State as RoundState,
|
||||
voter, voter_set::VoterSet,
|
||||
};
|
||||
use runtime_primitives::generic::BlockId;
|
||||
use runtime_primitives::traits::{
|
||||
use sr_primitives::generic::BlockId;
|
||||
use sr_primitives::traits::{
|
||||
Block as BlockT, Header as HeaderT, NumberFor, One, Zero, BlockNumberToHash,
|
||||
};
|
||||
use substrate_primitives::{Blake2Hasher, ed25519, H256, Pair};
|
||||
use primitives::{Blake2Hasher, ed25519, H256, Pair};
|
||||
use substrate_telemetry::{telemetry, CONSENSUS_INFO};
|
||||
|
||||
use crate::{
|
||||
|
||||
@@ -45,11 +45,11 @@ use client::{
|
||||
};
|
||||
use parity_codec::{Encode, Decode};
|
||||
use grandpa::BlockNumberOps;
|
||||
use runtime_primitives::{Justification, generic::BlockId};
|
||||
use runtime_primitives::traits::{
|
||||
use sr_primitives::{Justification, generic::BlockId};
|
||||
use sr_primitives::traits::{
|
||||
NumberFor, Block as BlockT, Header as HeaderT, One,
|
||||
};
|
||||
use substrate_primitives::{H256, Blake2Hasher};
|
||||
use primitives::{H256, Blake2Hasher};
|
||||
use substrate_telemetry::{telemetry, CONSENSUS_INFO};
|
||||
use fg_primitives::AuthorityId;
|
||||
|
||||
|
||||
@@ -32,13 +32,13 @@ use consensus_common::{
|
||||
SelectChain,
|
||||
};
|
||||
use fg_primitives::GrandpaApi;
|
||||
use runtime_primitives::Justification;
|
||||
use runtime_primitives::generic::BlockId;
|
||||
use runtime_primitives::traits::{
|
||||
use sr_primitives::Justification;
|
||||
use sr_primitives::generic::BlockId;
|
||||
use sr_primitives::traits::{
|
||||
Block as BlockT, DigestFor,
|
||||
Header as HeaderT, NumberFor, ProvideRuntimeApi,
|
||||
};
|
||||
use substrate_primitives::{H256, Blake2Hasher};
|
||||
use primitives::{H256, Blake2Hasher};
|
||||
|
||||
use crate::{Error, CommandOrError, NewAuthoritySet, VoterCommand};
|
||||
use crate::authorities::{AuthoritySet, SharedAuthoritySet, DelayKind, PendingChange};
|
||||
|
||||
@@ -23,9 +23,9 @@ use client::error::Error as ClientError;
|
||||
use parity_codec::{Encode, Decode};
|
||||
use grandpa::voter_set::VoterSet;
|
||||
use grandpa::{Error as GrandpaError};
|
||||
use runtime_primitives::generic::BlockId;
|
||||
use runtime_primitives::traits::{NumberFor, Block as BlockT, Header as HeaderT};
|
||||
use substrate_primitives::{H256, Blake2Hasher};
|
||||
use sr_primitives::generic::BlockId;
|
||||
use sr_primitives::traits::{NumberFor, Block as BlockT, Header as HeaderT};
|
||||
use primitives::{H256, Blake2Hasher};
|
||||
use fg_primitives::AuthorityId;
|
||||
|
||||
use crate::{Commit, Error};
|
||||
|
||||
@@ -58,14 +58,14 @@ use futures::sync::mpsc;
|
||||
use client::{BlockchainEvents, CallExecutor, Client, backend::Backend, error::Error as ClientError};
|
||||
use client::blockchain::HeaderBackend;
|
||||
use parity_codec::Encode;
|
||||
use runtime_primitives::traits::{
|
||||
use sr_primitives::traits::{
|
||||
NumberFor, Block as BlockT, DigestFor, ProvideRuntimeApi,
|
||||
};
|
||||
use fg_primitives::GrandpaApi;
|
||||
use inherents::InherentDataProviders;
|
||||
use runtime_primitives::generic::BlockId;
|
||||
use sr_primitives::generic::BlockId;
|
||||
use consensus_common::SelectChain;
|
||||
use substrate_primitives::{ed25519, H256, Pair, Blake2Hasher};
|
||||
use primitives::{ed25519, H256, Pair, Blake2Hasher};
|
||||
use substrate_telemetry::{telemetry, CONSENSUS_INFO, CONSENSUS_DEBUG, CONSENSUS_WARN};
|
||||
use serde_json;
|
||||
|
||||
@@ -355,7 +355,7 @@ where
|
||||
PRA::Api: GrandpaApi<Block>,
|
||||
SC: SelectChain<Block>,
|
||||
{
|
||||
use runtime_primitives::traits::Zero;
|
||||
use sr_primitives::traits::Zero;
|
||||
|
||||
let chain_info = client.info();
|
||||
let genesis_hash = chain_info.chain.genesis_hash;
|
||||
|
||||
@@ -32,13 +32,13 @@ use consensus_common::{
|
||||
Error as ConsensusError,
|
||||
};
|
||||
use network::config::{BoxFinalityProofRequestBuilder, FinalityProofRequestBuilder};
|
||||
use runtime_primitives::Justification;
|
||||
use runtime_primitives::traits::{
|
||||
use sr_primitives::Justification;
|
||||
use sr_primitives::traits::{
|
||||
NumberFor, Block as BlockT, Header as HeaderT, ProvideRuntimeApi, DigestFor,
|
||||
};
|
||||
use fg_primitives::{GrandpaApi, AuthorityId};
|
||||
use runtime_primitives::generic::BlockId;
|
||||
use substrate_primitives::{H256, Blake2Hasher};
|
||||
use sr_primitives::generic::BlockId;
|
||||
use primitives::{H256, Blake2Hasher};
|
||||
|
||||
use crate::aux_schema::load_decode;
|
||||
use crate::consensus_changes::ConsensusChanges;
|
||||
@@ -468,7 +468,7 @@ fn load_aux_import_data<B, Block: BlockT<Hash=H256>, PRA>(
|
||||
PRA: ProvideRuntimeApi,
|
||||
PRA::Api: GrandpaApi<Block>,
|
||||
{
|
||||
use runtime_primitives::traits::Zero;
|
||||
use sr_primitives::traits::Zero;
|
||||
let authority_set = match load_decode(aux_store, LIGHT_AUTHORITY_SET_KEY)? {
|
||||
Some(authority_set) => authority_set,
|
||||
None => {
|
||||
@@ -538,7 +538,7 @@ fn on_post_finalization_error(error: ClientError, value_type: &str) -> Consensus
|
||||
pub mod tests {
|
||||
use super::*;
|
||||
use consensus_common::ForkChoiceStrategy;
|
||||
use substrate_primitives::H256;
|
||||
use primitives::H256;
|
||||
use test_client::client::in_mem::Blockchain as InMemoryAuxStore;
|
||||
use test_client::runtime::{Block, Header};
|
||||
use crate::tests::TestApi;
|
||||
|
||||
@@ -26,8 +26,8 @@ use log::{debug, info, warn};
|
||||
|
||||
use consensus_common::SelectChain;
|
||||
use client::{CallExecutor, Client, backend::Backend};
|
||||
use runtime_primitives::traits::{NumberFor, Block as BlockT};
|
||||
use substrate_primitives::{H256, Blake2Hasher};
|
||||
use sr_primitives::traits::{NumberFor, Block as BlockT};
|
||||
use primitives::{H256, Blake2Hasher};
|
||||
|
||||
use crate::{
|
||||
global_communication, CommandOrError, CommunicationIn, Config, environment,
|
||||
|
||||
@@ -35,9 +35,9 @@ use consensus_common::import_queue::{BoxBlockImport, BoxJustificationImport, Box
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::result;
|
||||
use parity_codec::Decode;
|
||||
use runtime_primitives::traits::{ApiRef, ProvideRuntimeApi, Header as HeaderT};
|
||||
use runtime_primitives::generic::BlockId;
|
||||
use substrate_primitives::{NativeOrEncoded, ExecutionContext};
|
||||
use sr_primitives::traits::{ApiRef, ProvideRuntimeApi, Header as HeaderT};
|
||||
use sr_primitives::generic::BlockId;
|
||||
use primitives::{NativeOrEncoded, ExecutionContext};
|
||||
use fg_primitives::AuthorityId;
|
||||
|
||||
use authorities::AuthoritySet;
|
||||
@@ -273,7 +273,7 @@ impl GrandpaApi<Block> for RuntimeApi {
|
||||
_: ExecutionContext,
|
||||
_: Option<()>,
|
||||
_: Vec<u8>,
|
||||
) -> Result<NativeOrEncoded<Vec<(substrate_primitives::ed25519::Public, u64)>>> {
|
||||
) -> Result<NativeOrEncoded<Vec<(primitives::ed25519::Public, u64)>>> {
|
||||
Ok(self.inner.genesis_authorities.clone()).map(NativeOrEncoded::Native)
|
||||
}
|
||||
|
||||
@@ -342,7 +342,7 @@ impl AuthoritySetForFinalityChecker<Block> for TestApi {
|
||||
|
||||
const TEST_GOSSIP_DURATION: Duration = Duration::from_millis(500);
|
||||
|
||||
fn make_ids(keys: &[Ed25519Keyring]) -> Vec<(substrate_primitives::ed25519::Public, u64)> {
|
||||
fn make_ids(keys: &[Ed25519Keyring]) -> Vec<(primitives::ed25519::Public, u64)> {
|
||||
keys.iter()
|
||||
.map(|key| AuthorityId::from_raw(key.to_raw_public()))
|
||||
.map(|id| (id, 1))
|
||||
@@ -704,7 +704,7 @@ fn justification_is_emitted_when_consensus_data_changes() {
|
||||
let mut net = GrandpaTestNet::new(TestApi::new(make_ids(peers)), 3);
|
||||
|
||||
// import block#1 WITH consensus data change
|
||||
let new_authorities = vec![substrate_primitives::sr25519::Public::from_raw([42; 32])];
|
||||
let new_authorities = vec![primitives::sr25519::Public::from_raw([42; 32])];
|
||||
net.peer(0).push_authorities_change_block(new_authorities);
|
||||
net.block_until_sync(&mut runtime);
|
||||
let net = Arc::new(Mutex::new(net));
|
||||
@@ -1320,7 +1320,7 @@ fn finality_proof_is_fetched_by_light_client_when_consensus_data_changes() {
|
||||
|
||||
// import block#1 WITH consensus data change. Light client ignores justification
|
||||
// && instead fetches finality proof for block #1
|
||||
net.peer(0).push_authorities_change_block(vec![substrate_primitives::sr25519::Public::from_raw([42; 32])]);
|
||||
net.peer(0).push_authorities_change_block(vec![primitives::sr25519::Public::from_raw([42; 32])]);
|
||||
let net = Arc::new(Mutex::new(net));
|
||||
run_to_completion(&mut runtime, 1, net.clone(), peers);
|
||||
net.lock().block_until_sync(&mut runtime);
|
||||
@@ -1383,7 +1383,7 @@ fn empty_finality_proof_is_returned_to_light_client_when_authority_set_is_differ
|
||||
// normally it will reach light client, but because of the forced change, it will not
|
||||
net.lock().peer(0).push_blocks(8, false); // best is #9
|
||||
net.lock().peer(0).push_authorities_change_block(
|
||||
vec![substrate_primitives::sr25519::Public::from_raw([42; 32])]
|
||||
vec![primitives::sr25519::Public::from_raw([42; 32])]
|
||||
); // #10
|
||||
net.lock().peer(0).push_blocks(1, false); // best is #11
|
||||
net.lock().block_until_sync(&mut runtime);
|
||||
|
||||
@@ -29,7 +29,7 @@ use futures::stream::Fuse;
|
||||
use futures03::{StreamExt as _, TryStreamExt as _};
|
||||
use grandpa::voter;
|
||||
use parking_lot::Mutex;
|
||||
use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, NumberFor};
|
||||
use sr_primitives::traits::{Block as BlockT, Header as HeaderT, NumberFor};
|
||||
use tokio_timer::Interval;
|
||||
|
||||
use std::collections::{HashMap, VecDeque};
|
||||
|
||||
Reference in New Issue
Block a user