[big refactor] Remove crate aliasing. (#4395)

* Rename: Phase 1.

* Unify codec.

* Fixing: Phase 2

* Fixing: Phase 3.

* Fixing: Phase 4.

* Fixing: Phase 5.

* Fixing: Phase 6.

* Fixing: Phase 7.

* Fixing: Phase 8. Tests

* Fixing: Phase 9. Tests!!!

* Fixing: Phase 10. Moar tests!

* Finally done!

* More fixes.

* Rename primitives:: to sp_core::

* Apply renames in finality-grandpa.

* Fix benches.

* Fix benches 2.

* Revert node-template.

* Fix frame-system in our modules.
This commit is contained in:
Tomasz Drwięga
2019-12-16 13:36:49 +01:00
committed by Gavin Wood
parent f14d98a439
commit 8778ca7dc8
485 changed files with 4023 additions and 4005 deletions
+31 -31
View File
@@ -20,26 +20,26 @@ use super::*;
use environment::HasVoted;
use sc_network_test::{Block, DummySpecialization, Hash, TestNetFactory, Peer, PeersClient};
use sc_network_test::{PassThroughVerifier};
use network::config::{ProtocolConfig, Roles, BoxFinalityProofRequestBuilder};
use sc_network::config::{ProtocolConfig, Roles, BoxFinalityProofRequestBuilder};
use parking_lot::Mutex;
use futures_timer::Delay;
use futures03::{StreamExt as _, TryStreamExt as _};
use tokio::runtime::current_thread;
use keyring::Ed25519Keyring;
use client::LongestChain;
use sp_keyring::Ed25519Keyring;
use sc_client::LongestChain;
use sp_blockchain::Result;
use sp_api::{Core, RuntimeVersion, ApiExt, StorageProof};
use test_client::{self, runtime::BlockNumber};
use consensus_common::{BlockOrigin, ForkChoiceStrategy, ImportedAux, BlockImportParams, ImportResult};
use consensus_common::import_queue::{BoxBlockImport, BoxJustificationImport, BoxFinalityProofImport};
use substrate_test_runtime_client::{self, runtime::BlockNumber};
use sp_consensus::{BlockOrigin, ForkChoiceStrategy, ImportedAux, BlockImportParams, ImportResult};
use sp_consensus::import_queue::{BoxBlockImport, BoxJustificationImport, BoxFinalityProofImport};
use std::collections::{HashMap, HashSet};
use std::result;
use codec::Decode;
use parity_scale_codec::Decode;
use sp_runtime::traits::{ApiRef, ProvideRuntimeApi, Header as HeaderT};
use sp_runtime::generic::{BlockId, DigestItem};
use primitives::{NativeOrEncoded, ExecutionContext, crypto::Public};
use fg_primitives::{GRANDPA_ENGINE_ID, AuthorityList, GrandpaApi};
use state_machine::{backend::InMemory, prove_read, read_proof_check};
use sp_core::{NativeOrEncoded, ExecutionContext, crypto::Public};
use sp_finality_grandpa::{GRANDPA_ENGINE_ID, AuthorityList, GrandpaApi};
use sp_state_machine::{backend::InMemory, prove_read, read_proof_check};
use std::{pin::Pin, task};
use authorities::AuthoritySet;
@@ -50,11 +50,11 @@ type PeerData =
Mutex<
Option<
LinkHalf<
test_client::Backend,
test_client::Executor,
substrate_test_runtime_client::Backend,
substrate_test_runtime_client::Executor,
Block,
test_client::runtime::RuntimeApi,
LongestChain<test_client::Backend, Block>
substrate_test_runtime_client::runtime::RuntimeApi,
LongestChain<substrate_test_runtime_client::Backend, Block>
>
>
>;
@@ -151,7 +151,7 @@ impl TestNetFactory for GrandpaTestNet {
fn make_finality_proof_provider(
&self,
client: PeersClient
) -> Option<Arc<dyn network::FinalityProofProvider<Block>>> {
) -> Option<Arc<dyn sc_network::FinalityProofProvider<Block>>> {
match client {
PeersClient::Full(_, ref backend) => {
let authorities_provider = Arc::new(self.test_config.clone());
@@ -328,7 +328,7 @@ fn make_ids(keys: &[Ed25519Keyring]) -> AuthorityList {
fn create_keystore(authority: Ed25519Keyring) -> (KeyStorePtr, tempfile::TempDir) {
let keystore_path = tempfile::tempdir().expect("Creates keystore path");
let keystore = keystore::Store::open(keystore_path.path(), None).expect("Creates keystore");
let keystore = sc_keystore::Store::open(keystore_path.path(), None).expect("Creates keystore");
keystore.write().insert_ephemeral_from_seed::<AuthorityPair>(&authority.to_seed())
.expect("Creates authority key");
@@ -441,7 +441,7 @@ fn run_to_completion(
fn add_scheduled_change(block: &mut Block, change: ScheduledChange<BlockNumber>) {
block.header.digest_mut().push(DigestItem::Consensus(
GRANDPA_ENGINE_ID,
fg_primitives::ConsensusLog::ScheduledChange(change).encode(),
sp_finality_grandpa::ConsensusLog::ScheduledChange(change).encode(),
));
}
@@ -452,7 +452,7 @@ fn add_forced_change(
) {
block.header.digest_mut().push(DigestItem::Consensus(
GRANDPA_ENGINE_ID,
fg_primitives::ConsensusLog::ForcedChange(median_last_finalized, change).encode(),
sp_finality_grandpa::ConsensusLog::ForcedChange(median_last_finalized, change).encode(),
));
}
@@ -740,7 +740,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![babe_primitives::AuthorityId::from_slice(&[42; 32])];
let new_authorities = vec![sp_consensus_babe::AuthorityId::from_slice(&[42; 32])];
net.peer(0).push_authorities_change_block(new_authorities);
net.block_until_sync(&mut runtime);
let net = Arc::new(Mutex::new(net));
@@ -1241,7 +1241,7 @@ fn voter_persists_its_votes() {
if state.compare_and_swap(0, 1, Ordering::SeqCst) == 0 {
// the first message we receive should be a prevote from alice.
let prevote = match signed.message {
grandpa::Message::Prevote(prevote) => prevote,
finality_grandpa::Message::Prevote(prevote) => prevote,
_ => panic!("voter should prevote."),
};
@@ -1276,19 +1276,19 @@ fn voter_persists_its_votes() {
voter_tx.unbounded_send(()).unwrap();
// and we push our own prevote for block 30
let prevote = grandpa::Prevote {
let prevote = finality_grandpa::Prevote {
target_number: 30,
target_hash: block_30_hash,
};
round_tx.lock().start_send(grandpa::Message::Prevote(prevote)).unwrap();
round_tx.lock().start_send(finality_grandpa::Message::Prevote(prevote)).unwrap();
Ok(())
}).map_err(|_| panic!()))
} else if state.compare_and_swap(1, 2, Ordering::SeqCst) == 1 {
// the next message we receive should be our own prevote
let prevote = match signed.message {
grandpa::Message::Prevote(prevote) => prevote,
finality_grandpa::Message::Prevote(prevote) => prevote,
_ => panic!("We should receive our own prevote."),
};
@@ -1305,7 +1305,7 @@ fn voter_persists_its_votes() {
// we then receive a precommit from alice for block 15
// even though we casted a prevote for block 30
let precommit = match signed.message {
grandpa::Message::Precommit(precommit) => precommit,
finality_grandpa::Message::Precommit(precommit) => precommit,
_ => panic!("voter should precommit."),
};
@@ -1388,7 +1388,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![babe_primitives::AuthorityId::from_slice(&[42; 32])]);
net.peer(0).push_authorities_change_block(vec![sp_consensus_babe::AuthorityId::from_slice(&[42; 32])]);
let net = Arc::new(Mutex::new(net));
run_to_completion(&mut runtime, &threads_pool, 1, net.clone(), peers);
net.lock().block_until_sync(&mut runtime);
@@ -1453,7 +1453,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![babe_primitives::AuthorityId::from_slice(&[42; 32])]
vec![sp_consensus_babe::AuthorityId::from_slice(&[42; 32])]
); // #10
net.lock().peer(0).push_blocks(1, false); // best is #11
net.lock().block_until_sync(&mut runtime);
@@ -1589,7 +1589,7 @@ fn voter_catches_up_to_latest_round_when_behind() {
#[test]
fn grandpa_environment_respects_voting_rules() {
use grandpa::Chain;
use finality_grandpa::Chain;
use sc_network_test::TestClient;
let threads_pool = futures03::executor::ThreadPool::new().unwrap();
@@ -1741,22 +1741,22 @@ fn imports_justification_for_regular_blocks_on_import() {
let round = 1;
let set_id = 0;
let precommit = grandpa::Precommit {
let precommit = finality_grandpa::Precommit {
target_hash: block_hash,
target_number: *block.header.number(),
};
let msg = grandpa::Message::Precommit(precommit.clone());
let msg = finality_grandpa::Message::Precommit(precommit.clone());
let encoded = communication::localized_payload(round, set_id, &msg);
let signature = peers[0].sign(&encoded[..]).into();
let precommit = grandpa::SignedPrecommit {
let precommit = finality_grandpa::SignedPrecommit {
precommit,
signature,
id: peers[0].public().into(),
};
let commit = grandpa::Commit {
let commit = finality_grandpa::Commit {
target_hash: block_hash,
target_number: *block.header.number(),
precommits: vec![precommit],