[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
@@ -18,11 +18,11 @@
use fork_tree::ForkTree;
use parking_lot::RwLock;
use grandpa::voter_set::VoterSet;
use codec::{Encode, Decode};
use finality_grandpa::voter_set::VoterSet;
use parity_scale_codec::{Encode, Decode};
use log::{debug, info};
use sc_telemetry::{telemetry, CONSENSUS_INFO};
use fg_primitives::{AuthorityId, AuthorityList};
use sp_finality_grandpa::{AuthorityId, AuthorityList};
use std::cmp::Ord;
use std::fmt::Debug;
@@ -403,7 +403,7 @@ pub(crate) struct PendingChange<H, N> {
}
impl<H: Decode, N: Decode> Decode for PendingChange<H, N> {
fn decode<I: codec::Input>(value: &mut I) -> Result<Self, codec::Error> {
fn decode<I: parity_scale_codec::Input>(value: &mut I) -> Result<Self, parity_scale_codec::Error> {
let next_authorities = Decode::decode(value)?;
let delay = Decode::decode(value)?;
let canon_height = Decode::decode(value)?;
@@ -431,7 +431,7 @@ impl<H, N: Add<Output=N> + Clone> PendingChange<H, N> {
#[cfg(test)]
mod tests {
use super::*;
use primitives::crypto::Public;
use sp_core::crypto::Public;
fn static_is_descendent_of<A>(value: bool)
-> impl Fn(&A, &A) -> Result<bool, std::io::Error>
@@ -18,14 +18,14 @@
use std::fmt::Debug;
use std::sync::Arc;
use codec::{Encode, Decode};
use client_api::backend::AuxStore;
use parity_scale_codec::{Encode, Decode};
use sc_client_api::backend::AuxStore;
use sp_blockchain::{Result as ClientResult, Error as ClientError};
use fork_tree::ForkTree;
use grandpa::round::State as RoundState;
use finality_grandpa::round::State as RoundState;
use sp_runtime::traits::{Block as BlockT, NumberFor};
use log::{info, warn};
use fg_primitives::{AuthorityList, SetId, RoundNumber};
use sp_finality_grandpa::{AuthorityList, SetId, RoundNumber};
use crate::authorities::{AuthoritySet, SharedAuthoritySet, PendingChange, DelayKind};
use crate::consensus_changes::{SharedConsensusChanges, ConsensusChanges};
@@ -439,14 +439,14 @@ pub(crate) fn load_authorities<B: AuxStore, H: Decode, N: Decode>(backend: &B)
#[cfg(test)]
mod test {
use fg_primitives::AuthorityId;
use primitives::H256;
use test_client;
use sp_finality_grandpa::AuthorityId;
use sp_core::H256;
use substrate_test_runtime_client;
use super::*;
#[test]
fn load_decode_from_v0_migrates_data_format() {
let client = test_client::new();
let client = substrate_test_runtime_client::new();
let authorities = vec![(AuthorityId::default(), 100)];
let set_id = 3;
@@ -482,7 +482,7 @@ mod test {
);
// should perform the migration
load_persistent::<test_client::runtime::Block, _, _>(
load_persistent::<substrate_test_runtime_client::runtime::Block, _, _>(
&client,
H256::random(),
0,
@@ -494,7 +494,7 @@ mod test {
Some(2),
);
let PersistentData { authority_set, set_state, .. } = load_persistent::<test_client::runtime::Block, _, _>(
let PersistentData { authority_set, set_state, .. } = load_persistent::<substrate_test_runtime_client::runtime::Block, _, _>(
&client,
H256::random(),
0,
@@ -534,7 +534,7 @@ mod test {
#[test]
fn load_decode_from_v1_migrates_data_format() {
let client = test_client::new();
let client = substrate_test_runtime_client::new();
let authorities = vec![(AuthorityId::default(), 100)];
let set_id = 3;
@@ -572,7 +572,7 @@ mod test {
);
// should perform the migration
load_persistent::<test_client::runtime::Block, _, _>(
load_persistent::<substrate_test_runtime_client::runtime::Block, _, _>(
&client,
H256::random(),
0,
@@ -584,7 +584,7 @@ mod test {
Some(2),
);
let PersistentData { authority_set, set_state, .. } = load_persistent::<test_client::runtime::Block, _, _>(
let PersistentData { authority_set, set_state, .. } = load_persistent::<substrate_test_runtime_client::runtime::Block, _, _>(
&client,
H256::random(),
0,
@@ -624,11 +624,11 @@ mod test {
#[test]
fn write_read_concluded_rounds() {
let client = test_client::new();
let client = substrate_test_runtime_client::new();
let hash = H256::random();
let round_state = RoundState::genesis((hash, 0));
let completed_round = CompletedRound::<test_client::runtime::Block> {
let completed_round = CompletedRound::<substrate_test_runtime_client::runtime::Block> {
number: 42,
state: round_state.clone(),
base: round_state.prevote_ghost.unwrap(),
@@ -642,7 +642,7 @@ mod test {
round_number.using_encoded(|n| key.extend(n));
assert_eq!(
load_decode::<_, CompletedRound::<test_client::runtime::Block>>(&client, &key).unwrap(),
load_decode::<_, CompletedRound::<substrate_test_runtime_client::runtime::Block>>(&client, &key).unwrap(),
Some(completed_round),
);
}
@@ -83,10 +83,10 @@
//! We only send polite messages to peers,
use sp_runtime::traits::{NumberFor, Block as BlockT, Zero};
use network_gossip::{GossipEngine, MessageIntent, ValidatorContext};
use network::{config::Roles, PeerId, ReputationChange};
use codec::{Encode, Decode};
use fg_primitives::AuthorityId;
use sc_network_gossip::{GossipEngine, MessageIntent, ValidatorContext};
use sc_network::{config::Roles, PeerId, ReputationChange};
use parity_scale_codec::{Encode, Decode};
use sp_finality_grandpa::AuthorityId;
use sc_telemetry::{telemetry, CONSENSUS_DEBUG};
use log::{trace, debug, warn};
@@ -908,15 +908,15 @@ impl<Block: BlockT> Inner<Block> {
// too many equivocations (we exceed the fault-tolerance bound).
for vote in last_completed_round.votes {
match vote.message {
grandpa::Message::Prevote(prevote) => {
prevotes.push(grandpa::SignedPrevote {
finality_grandpa::Message::Prevote(prevote) => {
prevotes.push(finality_grandpa::SignedPrevote {
prevote,
signature: vote.signature,
id: vote.id,
});
},
grandpa::Message::Precommit(precommit) => {
precommits.push(grandpa::SignedPrecommit {
finality_grandpa::Message::Precommit(precommit) => {
precommits.push(finality_grandpa::SignedPrecommit {
precommit,
signature: vote.signature,
id: vote.id,
@@ -1280,7 +1280,7 @@ impl<Block: BlockT> GossipValidator<Block> {
}
}
impl<Block: BlockT> network_gossip::Validator<Block> for GossipValidator<Block> {
impl<Block: BlockT> sc_network_gossip::Validator<Block> for GossipValidator<Block> {
fn new_peer(&self, context: &mut dyn ValidatorContext<Block>, who: &PeerId, roles: Roles) {
let packet = {
let mut inner = self.inner.write();
@@ -1306,7 +1306,7 @@ impl<Block: BlockT> network_gossip::Validator<Block> for GossipValidator<Block>
}
fn validate(&self, context: &mut dyn ValidatorContext<Block>, who: &PeerId, data: &[u8])
-> network_gossip::ValidationResult<Block::Hash>
-> sc_network_gossip::ValidationResult<Block::Hash>
{
let (action, broadcast_topics, peer_reply) = self.do_validate(who, data);
@@ -1323,15 +1323,15 @@ impl<Block: BlockT> network_gossip::Validator<Block> for GossipValidator<Block>
Action::Keep(topic, cb) => {
self.report(who.clone(), cb);
context.broadcast_message(topic, data.to_vec(), false);
network_gossip::ValidationResult::ProcessAndKeep(topic)
sc_network_gossip::ValidationResult::ProcessAndKeep(topic)
}
Action::ProcessAndDiscard(topic, cb) => {
self.report(who.clone(), cb);
network_gossip::ValidationResult::ProcessAndDiscard(topic)
sc_network_gossip::ValidationResult::ProcessAndDiscard(topic)
}
Action::Discard(cb) => {
self.report(who.clone(), cb);
network_gossip::ValidationResult::Discard
sc_network_gossip::ValidationResult::Discard
}
}
}
@@ -1502,9 +1502,9 @@ impl<B: BlockT> Future for ReportingTask<B> {
mod tests {
use super::*;
use super::environment::SharedVoterSetState;
use network_gossip::Validator as GossipValidatorT;
use sc_network_gossip::Validator as GossipValidatorT;
use sc_network_test::Block;
use primitives::{crypto::Public, H256};
use sp_core::{crypto::Public, H256};
// some random config (not really needed)
fn config() -> crate::Config {
@@ -1726,7 +1726,7 @@ mod tests {
round: Round(1),
set_id: SetId(set_id),
message: SignedMessage::<Block> {
message: grandpa::Message::Prevote(grandpa::Prevote {
message: finality_grandpa::Message::Prevote(finality_grandpa::Prevote {
target_hash: Default::default(),
target_number: 10,
}),
@@ -1739,7 +1739,7 @@ mod tests {
round: Round(1),
set_id: SetId(set_id),
message: SignedMessage::<Block> {
message: grandpa::Message::Prevote(grandpa::Prevote {
message: finality_grandpa::Message::Prevote(finality_grandpa::Prevote {
target_hash: Default::default(),
target_number: 10,
}),
@@ -1770,7 +1770,7 @@ mod tests {
let mut inner = val.inner.write();
inner.validate_catch_up_message(&peer, &FullCatchUpMessage {
set_id: SetId(set_id),
message: grandpa::CatchUp {
message: finality_grandpa::CatchUp {
round_number: 10,
prevotes: Default::default(),
precommits: Default::default(),
@@ -1806,7 +1806,7 @@ mod tests {
completed_rounds.push(environment::CompletedRound {
number: 2,
state: grandpa::round::State::genesis(Default::default()),
state: finality_grandpa::round::State::genesis(Default::default()),
base: Default::default(),
votes: Default::default(),
});
@@ -31,13 +31,13 @@ use std::sync::Arc;
use futures::{prelude::*, future::Executor as _, sync::mpsc};
use futures03::{compat::Compat, stream::StreamExt, future::FutureExt as _, future::TryFutureExt as _};
use grandpa::Message::{Prevote, Precommit, PrimaryPropose};
use grandpa::{voter, voter_set::VoterSet};
use finality_grandpa::Message::{Prevote, Precommit, PrimaryPropose};
use finality_grandpa::{voter, voter_set::VoterSet};
use log::{debug, trace};
use network::ReputationChange;
use network_gossip::{GossipEngine, Network};
use codec::{Encode, Decode};
use primitives::Pair;
use sc_network::ReputationChange;
use sc_network_gossip::{GossipEngine, Network};
use parity_scale_codec::{Encode, Decode};
use sp_core::Pair;
use sp_runtime::traits::{Block as BlockT, Hash as HashT, Header as HeaderT, NumberFor};
use sc_telemetry::{telemetry, CONSENSUS_DEBUG, CONSENSUS_INFO};
@@ -49,7 +49,7 @@ use crate::environment::HasVoted;
use gossip::{
GossipMessage, FullCatchUpMessage, FullCommitMessage, VoteMessage, GossipValidator
};
use fg_primitives::{
use sp_finality_grandpa::{
AuthorityPair, AuthorityId, AuthoritySignature, SetId as SetIdNumber, RoundNumber,
};
@@ -59,11 +59,11 @@ mod periodic;
#[cfg(test)]
mod tests;
pub use fg_primitives::GRANDPA_ENGINE_ID;
pub use sp_finality_grandpa::GRANDPA_ENGINE_ID;
// cost scalars for reporting peers.
mod cost {
use network::ReputationChange as Rep;
use sc_network::ReputationChange as Rep;
pub(super) const PAST_REJECTION: Rep = Rep::new(-50, "Grandpa: Past message");
pub(super) const BAD_SIGNATURE: Rep = Rep::new(-100, "Grandpa: Bad signature");
pub(super) const MALFORMED_CATCH_UP: Rep = Rep::new(-1000, "Grandpa: Malformed cath-up");
@@ -87,7 +87,7 @@ mod cost {
// benefit scalars for reporting peers.
mod benefit {
use network::ReputationChange as Rep;
use sc_network::ReputationChange as Rep;
pub(super) const NEIGHBOR_MESSAGE: Rep = Rep::new(100, "Grandpa: Neighbor message");
pub(super) const ROUND_MESSAGE: Rep = Rep::new(100, "Grandpa: Round message");
pub(super) const BASIC_VALIDATED_CATCH_UP: Rep = Rep::new(200, "Grandpa: Catch-up message");
@@ -356,7 +356,7 @@ impl<B: BlockT> NetworkBridge<B> {
/// If the given vector of peers is empty then the underlying implementation
/// should make a best effort to fetch the block from any peers it is
/// connected to (NOTE: this assumption will change in the future #3629).
pub(crate) fn set_sync_fork_request(&self, peers: Vec<network::PeerId>, hash: B::Hash, number: NumberFor<B>) {
pub(crate) fn set_sync_fork_request(&self, peers: Vec<sc_network::PeerId>, hash: B::Hash, number: NumberFor<B>) {
self.gossip_engine.set_sync_fork_request(peers, hash, number)
}
}
@@ -370,7 +370,7 @@ fn incoming_global<B: BlockT>(
) -> impl Stream<Item = CommunicationIn<B>, Error = Error> {
let process_commit = move |
msg: FullCommitMessage<B>,
mut notification: network_gossip::TopicNotification,
mut notification: sc_network_gossip::TopicNotification,
gossip_engine: &mut GossipEngine<B>,
gossip_validator: &Arc<GossipValidator<B>>,
voters: &VoterSet<AuthorityId>,
@@ -432,7 +432,7 @@ fn incoming_global<B: BlockT>(
let process_catch_up = move |
msg: FullCatchUpMessage<B>,
mut notification: network_gossip::TopicNotification,
mut notification: sc_network_gossip::TopicNotification,
gossip_engine: &mut GossipEngine<B>,
gossip_validator: &Arc<GossipValidator<B>>,
voters: &VoterSet<AuthorityId>,
@@ -557,15 +557,15 @@ impl<Block: BlockT> Sink for OutgoingMessages<Block>
fn start_send(&mut self, mut msg: Message<Block>) -> StartSend<Message<Block>, Error> {
// if we've voted on this round previously under the same key, send that vote instead
match &mut msg {
grandpa::Message::PrimaryPropose(ref mut vote) =>
finality_grandpa::Message::PrimaryPropose(ref mut vote) =>
if let Some(propose) = self.has_voted.propose() {
*vote = propose.clone();
},
grandpa::Message::Prevote(ref mut vote) =>
finality_grandpa::Message::Prevote(ref mut vote) =>
if let Some(prevote) = self.has_voted.prevote() {
*vote = prevote.clone();
},
grandpa::Message::Precommit(ref mut vote) =>
finality_grandpa::Message::Precommit(ref mut vote) =>
if let Some(precommit) = self.has_voted.precommit() {
*vote = precommit.clone();
},
@@ -660,7 +660,7 @@ fn check_compact_commit<Block: BlockT>(
.enumerate()
{
use crate::communication::gossip::Misbehavior;
use grandpa::Message as GrandpaMessage;
use finality_grandpa::Message as GrandpaMessage;
if let Err(()) = check_message_sig::<Block>(
&GrandpaMessage::Precommit(precommit.clone()),
@@ -772,7 +772,7 @@ fn check_catch_up<Block: BlockT>(
// check signatures on all contained prevotes.
let signatures_checked = check_signatures::<Block, _>(
msg.prevotes.iter().map(|vote| {
(grandpa::Message::Prevote(vote.prevote.clone()), &vote.id, &vote.signature)
(finality_grandpa::Message::Prevote(vote.prevote.clone()), &vote.id, &vote.signature)
}),
msg.round_number,
set_id.0,
@@ -782,7 +782,7 @@ fn check_catch_up<Block: BlockT>(
// check signatures on all contained precommits.
let _ = check_signatures::<Block, _>(
msg.precommits.iter().map(|vote| {
(grandpa::Message::Precommit(vote.precommit.clone()), &vote.id, &vote.signature)
(finality_grandpa::Message::Precommit(vote.precommit.clone()), &vote.id, &vote.signature)
}),
msg.round_number,
set_id.0,
@@ -18,15 +18,15 @@
use std::time::{Instant, Duration};
use codec::Encode;
use parity_scale_codec::Encode;
use futures::prelude::*;
use futures::sync::mpsc;
use futures_timer::Delay;
use futures03::future::{FutureExt as _, TryFutureExt as _};
use log::{debug, warn};
use network::PeerId;
use network_gossip::GossipEngine;
use sc_network::PeerId;
use sc_network_gossip::GossipEngine;
use sp_runtime::traits::{NumberFor, Block as BlockT};
use super::gossip::{NeighborPacket, GossipMessage};
@@ -47,7 +47,7 @@ impl<B: BlockT> NeighborPacketSender<B> {
/// Send a neighbor packet for the background worker to gossip to peers.
pub fn send(
&self,
who: Vec<network::PeerId>,
who: Vec<sc_network::PeerId>,
neighbor_packet: NeighborPacket<NumberFor<B>>,
) {
if let Err(err) = self.0.unbounded_send((who, neighbor_packet)) {
@@ -18,24 +18,24 @@
use futures::sync::mpsc;
use futures::prelude::*;
use network::{Event as NetworkEvent, PeerId, config::Roles};
use sc_network::{Event as NetworkEvent, PeerId, config::Roles};
use sc_network_test::{Block, Hash};
use network_gossip::Validator;
use sc_network_gossip::Validator;
use tokio::runtime::current_thread;
use std::sync::Arc;
use keyring::Ed25519Keyring;
use codec::Encode;
use sp_keyring::Ed25519Keyring;
use parity_scale_codec::Encode;
use sp_runtime::{ConsensusEngineId, traits::NumberFor};
use std::{pin::Pin, task::{Context, Poll}};
use crate::environment::SharedVoterSetState;
use fg_primitives::{AuthorityList, GRANDPA_ENGINE_ID};
use sp_finality_grandpa::{AuthorityList, GRANDPA_ENGINE_ID};
use super::gossip::{self, GossipValidator};
use super::{AuthorityId, VoterSet, Round, SetId};
enum Event {
EventStream(mpsc::UnboundedSender<NetworkEvent>),
WriteNotification(network::PeerId, Vec<u8>),
Report(network::PeerId, network::ReputationChange),
WriteNotification(sc_network::PeerId, Vec<u8>),
Report(sc_network::PeerId, sc_network::ReputationChange),
Announce(Hash),
}
@@ -44,7 +44,7 @@ struct TestNetwork {
sender: mpsc::UnboundedSender<Event>,
}
impl network_gossip::Network<Block> for TestNetwork {
impl sc_network_gossip::Network<Block> for TestNetwork {
fn event_stream(&self)
-> Box<dyn futures::Stream<Item = NetworkEvent, Error = ()> + Send> {
let (tx, rx) = mpsc::unbounded();
@@ -52,7 +52,7 @@ impl network_gossip::Network<Block> for TestNetwork {
Box::new(rx)
}
fn report_peer(&self, who: network::PeerId, cost_benefit: network::ReputationChange) {
fn report_peer(&self, who: sc_network::PeerId, cost_benefit: sc_network::ReputationChange) {
let _ = self.sender.unbounded_send(Event::Report(who, cost_benefit));
}
@@ -70,19 +70,19 @@ impl network_gossip::Network<Block> for TestNetwork {
fn set_sync_fork_request(
&self,
_peers: Vec<network::PeerId>,
_peers: Vec<sc_network::PeerId>,
_hash: Hash,
_number: NumberFor<Block>,
) {}
}
impl network_gossip::ValidatorContext<Block> for TestNetwork {
impl sc_network_gossip::ValidatorContext<Block> for TestNetwork {
fn broadcast_topic(&mut self, _: Hash, _: bool) { }
fn broadcast_message(&mut self, _: Hash, _: Vec<u8>, _: bool) { }
fn send_message(&mut self, who: &network::PeerId, data: Vec<u8>) {
<Self as network_gossip::Network<Block>>::write_notification(
fn send_message(&mut self, who: &sc_network::PeerId, data: Vec<u8>) {
<Self as sc_network_gossip::Network<Block>>::write_notification(
self,
who.clone(),
GRANDPA_ENGINE_ID,
@@ -90,7 +90,7 @@ impl network_gossip::ValidatorContext<Block> for TestNetwork {
);
}
fn send_topic(&mut self, _: &network::PeerId, _: Hash, _: bool) { }
fn send_topic(&mut self, _: &sc_network::PeerId, _: Hash, _: bool) { }
}
struct Tester {
@@ -132,8 +132,8 @@ fn config() -> crate::Config {
fn voter_set_state() -> SharedVoterSetState<Block> {
use crate::authorities::AuthoritySet;
use crate::environment::VoterSetState;
use grandpa::round::State as RoundState;
use primitives::H256;
use finality_grandpa::round::State as RoundState;
use sp_core::H256;
let state = RoundState::genesis((H256::zero(), 0));
let base = state.prevote_ghost.unwrap();
@@ -193,11 +193,11 @@ fn make_ids(keys: &[Ed25519Keyring]) -> AuthorityList {
struct NoopContext;
impl network_gossip::ValidatorContext<Block> for NoopContext {
impl sc_network_gossip::ValidatorContext<Block> for NoopContext {
fn broadcast_topic(&mut self, _: Hash, _: bool) { }
fn broadcast_message(&mut self, _: Hash, _: Vec<u8>, _: bool) { }
fn send_message(&mut self, _: &network::PeerId, _: Vec<u8>) { }
fn send_topic(&mut self, _: &network::PeerId, _: Hash, _: bool) { }
fn send_message(&mut self, _: &sc_network::PeerId, _: Vec<u8>) { }
fn send_topic(&mut self, _: &sc_network::PeerId, _: Hash, _: bool) { }
}
#[test]
@@ -213,9 +213,9 @@ fn good_commit_leads_to_relay() {
let target_hash: Hash = [1; 32].into();
let target_number = 500;
let precommit = grandpa::Precommit { target_hash: target_hash.clone(), target_number };
let precommit = finality_grandpa::Precommit { target_hash: target_hash.clone(), target_number };
let payload = super::localized_payload(
round, set_id, &grandpa::Message::Precommit(precommit.clone())
round, set_id, &finality_grandpa::Message::Precommit(precommit.clone())
);
let mut precommits = Vec::new();
@@ -224,11 +224,11 @@ fn good_commit_leads_to_relay() {
for (i, key) in private.iter().enumerate() {
precommits.push(precommit.clone());
let signature = fg_primitives::AuthoritySignature::from(key.sign(&payload[..]));
let signature = sp_finality_grandpa::AuthoritySignature::from(key.sign(&payload[..]));
auth_data.push((signature, public[i].0.clone()))
}
grandpa::CompactCommit {
finality_grandpa::CompactCommit {
target_hash,
target_number,
precommits,
@@ -242,14 +242,14 @@ fn good_commit_leads_to_relay() {
message: commit,
}).encode();
let id = network::PeerId::random();
let id = sc_network::PeerId::random();
let global_topic = super::global_topic::<Block>(set_id);
let threads_pool = futures03::executor::ThreadPool::new().unwrap();
let test = make_test_network(&threads_pool).0
.and_then(move |tester| {
// register a peer.
tester.gossip_validator.new_peer(&mut NoopContext, &id, network::config::Roles::FULL);
tester.gossip_validator.new_peer(&mut NoopContext, &id, sc_network::config::Roles::FULL);
Ok((tester, id))
})
.and_then(move |(tester, id)| {
@@ -291,8 +291,8 @@ fn good_commit_leads_to_relay() {
let handle_commit = commits_in.into_future()
.map(|(item, _)| {
match item.unwrap() {
grandpa::voter::CommunicationIn::Commit(_, _, mut callback) => {
callback.run(grandpa::voter::CommitProcessingOutcome::good());
finality_grandpa::voter::CommunicationIn::Commit(_, _, mut callback) => {
callback.run(finality_grandpa::voter::CommitProcessingOutcome::good());
},
_ => panic!("commit expected"),
}
@@ -330,9 +330,9 @@ fn bad_commit_leads_to_report() {
let target_hash: Hash = [1; 32].into();
let target_number = 500;
let precommit = grandpa::Precommit { target_hash: target_hash.clone(), target_number };
let precommit = finality_grandpa::Precommit { target_hash: target_hash.clone(), target_number };
let payload = super::localized_payload(
round, set_id, &grandpa::Message::Precommit(precommit.clone())
round, set_id, &finality_grandpa::Message::Precommit(precommit.clone())
);
let mut precommits = Vec::new();
@@ -341,11 +341,11 @@ fn bad_commit_leads_to_report() {
for (i, key) in private.iter().enumerate() {
precommits.push(precommit.clone());
let signature = fg_primitives::AuthoritySignature::from(key.sign(&payload[..]));
let signature = sp_finality_grandpa::AuthoritySignature::from(key.sign(&payload[..]));
auth_data.push((signature, public[i].0.clone()))
}
grandpa::CompactCommit {
finality_grandpa::CompactCommit {
target_hash,
target_number,
precommits,
@@ -359,14 +359,14 @@ fn bad_commit_leads_to_report() {
message: commit,
}).encode();
let id = network::PeerId::random();
let id = sc_network::PeerId::random();
let global_topic = super::global_topic::<Block>(set_id);
let threads_pool = futures03::executor::ThreadPool::new().unwrap();
let test = make_test_network(&threads_pool).0
.and_then(move |tester| {
// register a peer.
tester.gossip_validator.new_peer(&mut NoopContext, &id, network::config::Roles::FULL);
tester.gossip_validator.new_peer(&mut NoopContext, &id, sc_network::config::Roles::FULL);
Ok((tester, id))
})
.and_then(move |(tester, id)| {
@@ -408,8 +408,8 @@ fn bad_commit_leads_to_report() {
let handle_commit = commits_in.into_future()
.map(|(item, _)| {
match item.unwrap() {
grandpa::voter::CommunicationIn::Commit(_, _, mut callback) => {
callback.run(grandpa::voter::CommitProcessingOutcome::bad());
finality_grandpa::voter::CommunicationIn::Commit(_, _, mut callback) => {
callback.run(finality_grandpa::voter::CommitProcessingOutcome::bad());
},
_ => panic!("commit expected"),
}
@@ -435,14 +435,14 @@ fn bad_commit_leads_to_report() {
#[test]
fn peer_with_higher_view_leads_to_catch_up_request() {
let id = network::PeerId::random();
let id = sc_network::PeerId::random();
let threads_pool = futures03::executor::ThreadPool::new().unwrap();
let (tester, mut net) = make_test_network(&threads_pool);
let test = tester
.and_then(move |tester| {
// register a peer with authority role.
tester.gossip_validator.new_peer(&mut NoopContext, &id, network::config::Roles::AUTHORITY);
tester.gossip_validator.new_peer(&mut NoopContext, &id, sc_network::config::Roles::AUTHORITY);
Ok((tester, id))
})
.and_then(move |(tester, id)| {
@@ -459,7 +459,7 @@ fn peer_with_higher_view_leads_to_catch_up_request() {
// neighbor packets are always discard
match result {
network_gossip::ValidationResult::Discard => {},
sc_network_gossip::ValidationResult::Discard => {},
_ => panic!("wrong expected outcome from neighbor validation"),
}
@@ -15,7 +15,7 @@
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
use std::sync::Arc;
use codec::{Encode, Decode};
use parity_scale_codec::{Encode, Decode};
/// Consensus-related data changes tracker.
#[derive(Clone, Debug, Encode, Decode)]
@@ -20,28 +20,28 @@ use std::sync::Arc;
use std::time::Duration;
use log::{debug, warn, info};
use codec::{Decode, Encode};
use parity_scale_codec::{Decode, Encode};
use futures::prelude::*;
use futures03::future::{FutureExt as _, TryFutureExt as _};
use futures_timer::Delay;
use parking_lot::RwLock;
use sp_blockchain::{HeaderBackend, Error as ClientError};
use client_api::{
use sc_client_api::{
BlockchainEvents,
backend::{Backend},
Finalizer,
call_executor::CallExecutor,
utils::is_descendent_of,
};
use client::{
use sc_client::{
apply_aux, Client,
};
use grandpa::{
use finality_grandpa::{
BlockNumberOps, Equivocation, Error as GrandpaError, round::State as RoundState,
voter, voter_set::VoterSet,
};
use primitives::{Blake2Hasher, H256, Pair};
use sp_core::{Blake2Hasher, H256, Pair};
use sp_runtime::generic::BlockId;
use sp_runtime::traits::{
Block as BlockT, Header as HeaderT, NumberFor, One, Zero,
@@ -53,16 +53,16 @@ use crate::{
PrimaryPropose, SignedMessage, NewAuthoritySet, VoterCommand,
};
use consensus_common::SelectChain;
use sp_consensus::SelectChain;
use crate::authorities::{AuthoritySet, SharedAuthoritySet};
use crate::consensus_changes::SharedConsensusChanges;
use crate::justification::GrandpaJustification;
use crate::until_imported::UntilVoteTargetImported;
use crate::voting_rule::VotingRule;
use fg_primitives::{AuthorityId, AuthoritySignature, SetId, RoundNumber};
use sp_finality_grandpa::{AuthorityId, AuthoritySignature, SetId, RoundNumber};
type HistoricalVotes<Block> = grandpa::HistoricalVotes<
type HistoricalVotes<Block> = finality_grandpa::HistoricalVotes<
<Block as BlockT>::Hash,
NumberFor<Block>,
AuthoritySignature,
@@ -105,10 +105,10 @@ impl<Block: BlockT> Encode for CompletedRounds<Block> {
}
}
impl<Block: BlockT> codec::EncodeLike for CompletedRounds<Block> {}
impl<Block: BlockT> parity_scale_codec::EncodeLike for CompletedRounds<Block> {}
impl<Block: BlockT> Decode for CompletedRounds<Block> {
fn decode<I: codec::Input>(value: &mut I) -> Result<Self, codec::Error> {
fn decode<I: parity_scale_codec::Input>(value: &mut I) -> Result<Self, parity_scale_codec::Error> {
<(Vec<CompletedRound<Block>>, SetId, Vec<AuthorityId>)>::decode(value)
.map(|(rounds, set_id, voters)| CompletedRounds {
rounds: rounds.into(),
@@ -406,7 +406,7 @@ impl<B, E, Block: BlockT, RA, SC, VR> Environment<B, E, Block, RA, SC, VR> {
}
impl<Block: BlockT<Hash=H256>, B, E, RA, SC, VR>
grandpa::Chain<Block::Hash, NumberFor<Block>>
finality_grandpa::Chain<Block::Hash, NumberFor<Block>>
for Environment<B, E, Block, RA, SC, VR>
where
Block: 'static,
@@ -572,11 +572,11 @@ where
// regular round message streams
type In = Box<dyn Stream<
Item = ::grandpa::SignedMessage<Block::Hash, NumberFor<Block>, Self::Signature, Self::Id>,
Item = ::finality_grandpa::SignedMessage<Block::Hash, NumberFor<Block>, Self::Signature, Self::Id>,
Error = Self::Error,
> + Send>;
type Out = Box<dyn Sink<
SinkItem = ::grandpa::Message<Block::Hash, NumberFor<Block>>,
SinkItem = ::finality_grandpa::Message<Block::Hash, NumberFor<Block>>,
SinkError = Self::Error,
> + Send>;
@@ -906,7 +906,7 @@ where
fn prevote_equivocation(
&self,
_round: RoundNumber,
equivocation: ::grandpa::Equivocation<Self::Id, Prevote<Block>, Self::Signature>
equivocation: ::finality_grandpa::Equivocation<Self::Id, Prevote<Block>, Self::Signature>
) {
warn!(target: "afg", "Detected prevote equivocation in the finality worker: {:?}", equivocation);
// nothing yet; this could craft misbehavior reports of some kind.
@@ -39,20 +39,20 @@ use std::sync::Arc;
use log::{trace, warn};
use sp_blockchain::{Backend as BlockchainBackend, Error as ClientError, Result as ClientResult};
use client_api::{
use sc_client_api::{
backend::Backend, CallExecutor, StorageProof,
light::{FetchChecker, RemoteReadRequest},
};
use client::Client;
use codec::{Encode, Decode};
use grandpa::BlockNumberOps;
use sc_client::Client;
use parity_scale_codec::{Encode, Decode};
use finality_grandpa::BlockNumberOps;
use sp_runtime::{
Justification, generic::BlockId,
traits::{NumberFor, Block as BlockT, Header as HeaderT, One},
};
use primitives::{H256, Blake2Hasher, storage::StorageKey};
use sp_core::{H256, Blake2Hasher, storage::StorageKey};
use sc_telemetry::{telemetry, CONSENSUS_INFO};
use fg_primitives::{AuthorityId, AuthorityList, VersionedAuthorityList, GRANDPA_AUTHORITIES_KEY};
use sp_finality_grandpa::{AuthorityId, AuthorityList, VersionedAuthorityList, GRANDPA_AUTHORITIES_KEY};
use crate::justification::GrandpaJustification;
@@ -154,7 +154,7 @@ impl<B, Block: BlockT<Hash=H256>> FinalityProofProvider<B, Block>
}
}
impl<B, Block> network::FinalityProofProvider<Block> for FinalityProofProvider<B, Block>
impl<B, Block> sc_network::FinalityProofProvider<Block> for FinalityProofProvider<B, Block>
where
Block: BlockT<Hash=H256>,
NumberFor<Block>: BlockNumberOps,
@@ -580,11 +580,11 @@ impl<Block: BlockT<Hash=H256>> ProvableJustification<Block::Header> for GrandpaJ
#[cfg(test)]
pub(crate) mod tests {
use test_client::runtime::{Block, Header, H256};
use client_api::NewBlockState;
use test_client::client::in_mem::Blockchain as InMemoryBlockchain;
use substrate_test_runtime_client::runtime::{Block, Header, H256};
use sc_client_api::NewBlockState;
use substrate_test_runtime_client::sc_client::in_mem::Blockchain as InMemoryBlockchain;
use super::*;
use primitives::crypto::Public;
use sp_core::crypto::Public;
type FinalityProof = super::FinalityProof<Header>;
+10 -10
View File
@@ -17,25 +17,25 @@
use std::{sync::Arc, collections::HashMap};
use log::{debug, trace, info};
use codec::Encode;
use parity_scale_codec::Encode;
use futures::sync::mpsc;
use parking_lot::RwLockWriteGuard;
use sp_blockchain::{HeaderBackend, BlockStatus, well_known_cache_keys};
use client_api::{backend::Backend, CallExecutor, utils::is_descendent_of};
use client::Client;
use consensus_common::{
use sc_client_api::{backend::Backend, CallExecutor, utils::is_descendent_of};
use sc_client::Client;
use sp_consensus::{
BlockImport, Error as ConsensusError,
BlockCheckParams, BlockImportParams, ImportResult, JustificationImport,
SelectChain,
};
use fg_primitives::{GRANDPA_ENGINE_ID, ScheduledChange, ConsensusLog};
use sp_finality_grandpa::{GRANDPA_ENGINE_ID, ScheduledChange, ConsensusLog};
use sp_runtime::Justification;
use sp_runtime::generic::{BlockId, OpaqueDigestItemId};
use sp_runtime::traits::{
Block as BlockT, DigestFor, Header as HeaderT, NumberFor, Zero,
};
use primitives::{H256, Blake2Hasher};
use sp_core::{H256, Blake2Hasher};
use crate::{Error, CommandOrError, NewAuthoritySet, VoterCommand};
use crate::authorities::{AuthoritySet, SharedAuthoritySet, DelayKind, PendingChange};
@@ -76,7 +76,7 @@ impl<B, E, Block: BlockT<Hash=H256>, RA, SC: Clone> Clone for
impl<B, E, Block: BlockT<Hash=H256>, RA, SC> JustificationImport<Block>
for GrandpaBlockImport<B, E, Block, RA, SC> where
NumberFor<Block>: grandpa::BlockNumberOps,
NumberFor<Block>: finality_grandpa::BlockNumberOps,
B: Backend<Block, Blake2Hasher> + 'static,
E: CallExecutor<Block, Blake2Hasher> + 'static + Clone + Send + Sync,
DigestFor<Block>: Encode,
@@ -204,7 +204,7 @@ fn find_forced_change<B: BlockT>(header: &B::Header)
impl<B, E, Block: BlockT<Hash=H256>, RA, SC>
GrandpaBlockImport<B, E, Block, RA, SC>
where
NumberFor<Block>: grandpa::BlockNumberOps,
NumberFor<Block>: finality_grandpa::BlockNumberOps,
B: Backend<Block, Blake2Hasher> + 'static,
E: CallExecutor<Block, Blake2Hasher> + 'static + Clone + Send + Sync,
DigestFor<Block>: Encode,
@@ -381,7 +381,7 @@ where
impl<B, E, Block: BlockT<Hash=H256>, RA, SC> BlockImport<Block>
for GrandpaBlockImport<B, E, Block, RA, SC> where
NumberFor<Block>: grandpa::BlockNumberOps,
NumberFor<Block>: finality_grandpa::BlockNumberOps,
B: Backend<Block, Blake2Hasher> + 'static,
E: CallExecutor<Block, Blake2Hasher> + 'static + Clone + Send + Sync,
DigestFor<Block>: Encode,
@@ -532,7 +532,7 @@ impl<B, E, Block: BlockT<Hash=H256>, RA, SC>
impl<B, E, Block: BlockT<Hash=H256>, RA, SC>
GrandpaBlockImport<B, E, Block, RA, SC>
where
NumberFor<Block>: grandpa::BlockNumberOps,
NumberFor<Block>: finality_grandpa::BlockNumberOps,
B: Backend<Block, Blake2Hasher> + 'static,
E: CallExecutor<Block, Blake2Hasher> + 'static + Clone + Send + Sync,
RA: Send + Sync,
@@ -16,16 +16,16 @@
use std::collections::{HashMap, HashSet};
use client::Client;
use client_api::{CallExecutor, backend::Backend};
use sc_client::Client;
use sc_client_api::{CallExecutor, backend::Backend};
use sp_blockchain::Error as ClientError;
use codec::{Encode, Decode};
use grandpa::voter_set::VoterSet;
use grandpa::{Error as GrandpaError};
use parity_scale_codec::{Encode, Decode};
use finality_grandpa::voter_set::VoterSet;
use finality_grandpa::{Error as GrandpaError};
use sp_runtime::generic::BlockId;
use sp_runtime::traits::{NumberFor, Block as BlockT, Header as HeaderT};
use primitives::{H256, Blake2Hasher};
use fg_primitives::AuthorityId;
use sp_core::{H256, Blake2Hasher};
use sp_finality_grandpa::AuthorityId;
use crate::{Commit, Error};
use crate::communication;
@@ -98,7 +98,7 @@ impl<Block: BlockT<Hash=H256>> GrandpaJustification<Block> {
set_id: u64,
voters: &VoterSet<AuthorityId>,
) -> Result<GrandpaJustification<Block>, ClientError> where
NumberFor<Block>: grandpa::BlockNumberOps,
NumberFor<Block>: finality_grandpa::BlockNumberOps,
{
let justification = GrandpaJustification::<Block>::decode(&mut &*encoded)
@@ -115,13 +115,13 @@ impl<Block: BlockT<Hash=H256>> GrandpaJustification<Block> {
/// Validate the commit and the votes' ancestry proofs.
pub(crate) fn verify(&self, set_id: u64, voters: &VoterSet<AuthorityId>) -> Result<(), ClientError>
where
NumberFor<Block>: grandpa::BlockNumberOps,
NumberFor<Block>: finality_grandpa::BlockNumberOps,
{
use grandpa::Chain;
use finality_grandpa::Chain;
let ancestry_chain = AncestryChain::<Block>::new(&self.votes_ancestries);
match grandpa::validate_commit(
match finality_grandpa::validate_commit(
&self.commit,
voters,
&ancestry_chain,
@@ -136,7 +136,7 @@ impl<Block: BlockT<Hash=H256>> GrandpaJustification<Block> {
let mut visited_hashes = HashSet::new();
for signed in self.commit.precommits.iter() {
if let Err(_) = communication::check_message_sig::<Block>(
&grandpa::Message::Precommit(signed.precommit.clone()),
&finality_grandpa::Message::Precommit(signed.precommit.clone()),
&signed.id,
&signed.signature,
self.round,
@@ -179,7 +179,7 @@ impl<Block: BlockT<Hash=H256>> GrandpaJustification<Block> {
}
}
/// A utility trait implementing `grandpa::Chain` using a given set of headers.
/// A utility trait implementing `finality_grandpa::Chain` using a given set of headers.
/// This is useful when validating commits, using the given set of headers to
/// verify a valid ancestry route to the target commit block.
struct AncestryChain<Block: BlockT> {
@@ -198,8 +198,8 @@ impl<Block: BlockT> AncestryChain<Block> {
}
}
impl<Block: BlockT> grandpa::Chain<Block::Hash, NumberFor<Block>> for AncestryChain<Block> where
NumberFor<Block>: grandpa::BlockNumberOps
impl<Block: BlockT> finality_grandpa::Chain<Block::Hash, NumberFor<Block>> for AncestryChain<Block> where
NumberFor<Block>: finality_grandpa::BlockNumberOps
{
fn ancestry(&self, base: Block::Hash, block: Block::Hash) -> Result<Vec<Block::Hash>, GrandpaError> {
let mut route = Vec::new();
+32 -32
View File
@@ -55,23 +55,23 @@
use futures::prelude::*;
use log::{debug, error, info};
use futures::sync::mpsc;
use client_api::{BlockchainEvents, CallExecutor, backend::Backend, ExecutionStrategy};
use sc_client_api::{BlockchainEvents, CallExecutor, backend::Backend, ExecutionStrategy};
use sp_blockchain::{HeaderBackend, Error as ClientError};
use client::Client;
use codec::{Decode, Encode};
use sc_client::Client;
use parity_scale_codec::{Decode, Encode};
use sp_runtime::generic::BlockId;
use sp_runtime::traits::{NumberFor, Block as BlockT, DigestFor, Zero};
use keystore::KeyStorePtr;
use inherents::InherentDataProviders;
use consensus_common::SelectChain;
use primitives::{H256, Blake2Hasher, Pair};
use sc_keystore::KeyStorePtr;
use sp_inherents::InherentDataProviders;
use sp_consensus::SelectChain;
use sp_core::{H256, Blake2Hasher, Pair};
use sc_telemetry::{telemetry, CONSENSUS_INFO, CONSENSUS_DEBUG, CONSENSUS_WARN};
use serde_json;
use sp_finality_tracker;
use grandpa::Error as GrandpaError;
use grandpa::{voter, BlockNumberOps, voter_set::VoterSet};
use finality_grandpa::Error as GrandpaError;
use finality_grandpa::{voter, BlockNumberOps, voter_set::VoterSet};
use std::{fmt, io};
use std::sync::Arc;
@@ -90,7 +90,7 @@ mod observer;
mod until_imported;
mod voting_rule;
pub use network_gossip::Network;
pub use sc_network_gossip::Network;
pub use finality_proof::FinalityProofProvider;
pub use justification::GrandpaJustification;
pub use light_import::light_block_import;
@@ -104,18 +104,18 @@ use environment::{Environment, VoterSetState};
use import::GrandpaBlockImport;
use until_imported::UntilGlobalMessageBlocksImported;
use communication::NetworkBridge;
use fg_primitives::{AuthorityList, AuthorityPair, AuthoritySignature, SetId};
use sp_finality_grandpa::{AuthorityList, AuthorityPair, AuthoritySignature, SetId};
// Re-export these two because it's just so damn convenient.
pub use fg_primitives::{AuthorityId, ScheduledChange};
pub use sp_finality_grandpa::{AuthorityId, ScheduledChange};
#[cfg(test)]
mod tests;
/// A GRANDPA message for a substrate chain.
pub type Message<Block> = grandpa::Message<<Block as BlockT>::Hash, NumberFor<Block>>;
pub type Message<Block> = finality_grandpa::Message<<Block as BlockT>::Hash, NumberFor<Block>>;
/// A signed message.
pub type SignedMessage<Block> = grandpa::SignedMessage<
pub type SignedMessage<Block> = finality_grandpa::SignedMessage<
<Block as BlockT>::Hash,
NumberFor<Block>,
AuthoritySignature,
@@ -123,27 +123,27 @@ pub type SignedMessage<Block> = grandpa::SignedMessage<
>;
/// A primary propose message for this chain's block type.
pub type PrimaryPropose<Block> = grandpa::PrimaryPropose<<Block as BlockT>::Hash, NumberFor<Block>>;
pub type PrimaryPropose<Block> = finality_grandpa::PrimaryPropose<<Block as BlockT>::Hash, NumberFor<Block>>;
/// A prevote message for this chain's block type.
pub type Prevote<Block> = grandpa::Prevote<<Block as BlockT>::Hash, NumberFor<Block>>;
pub type Prevote<Block> = finality_grandpa::Prevote<<Block as BlockT>::Hash, NumberFor<Block>>;
/// A precommit message for this chain's block type.
pub type Precommit<Block> = grandpa::Precommit<<Block as BlockT>::Hash, NumberFor<Block>>;
pub type Precommit<Block> = finality_grandpa::Precommit<<Block as BlockT>::Hash, NumberFor<Block>>;
/// A catch up message for this chain's block type.
pub type CatchUp<Block> = grandpa::CatchUp<
pub type CatchUp<Block> = finality_grandpa::CatchUp<
<Block as BlockT>::Hash,
NumberFor<Block>,
AuthoritySignature,
AuthorityId,
>;
/// A commit message for this chain's block type.
pub type Commit<Block> = grandpa::Commit<
pub type Commit<Block> = finality_grandpa::Commit<
<Block as BlockT>::Hash,
NumberFor<Block>,
AuthoritySignature,
AuthorityId,
>;
/// A compact commit message for this chain's block type.
pub type CompactCommit<Block> = grandpa::CompactCommit<
pub type CompactCommit<Block> = finality_grandpa::CompactCommit<
<Block as BlockT>::Hash,
NumberFor<Block>,
AuthoritySignature,
@@ -152,7 +152,7 @@ pub type CompactCommit<Block> = grandpa::CompactCommit<
/// A global communication input stream for commits and catch up messages. Not
/// exposed publicly, used internally to simplify types in the communication
/// layer.
type CommunicationIn<Block> = grandpa::voter::CommunicationIn<
type CommunicationIn<Block> = finality_grandpa::voter::CommunicationIn<
<Block as BlockT>::Hash,
NumberFor<Block>,
AuthoritySignature,
@@ -162,7 +162,7 @@ type CommunicationIn<Block> = grandpa::voter::CommunicationIn<
/// Global communication input stream for commits and catch up messages, with
/// the hash type not being derived from the block, useful for forcing the hash
/// to some type (e.g. `H256`) when the compiler can't do the inference.
type CommunicationInH<Block, H> = grandpa::voter::CommunicationIn<
type CommunicationInH<Block, H> = finality_grandpa::voter::CommunicationIn<
H,
NumberFor<Block>,
AuthoritySignature,
@@ -171,7 +171,7 @@ type CommunicationInH<Block, H> = grandpa::voter::CommunicationIn<
/// A global communication sink for commits. Not exposed publicly, used
/// internally to simplify types in the communication layer.
type CommunicationOut<Block> = grandpa::voter::CommunicationOut<
type CommunicationOut<Block> = finality_grandpa::voter::CommunicationOut<
<Block as BlockT>::Hash,
NumberFor<Block>,
AuthoritySignature,
@@ -181,7 +181,7 @@ type CommunicationOut<Block> = grandpa::voter::CommunicationOut<
/// Global communication sink for commits with the hash type not being derived
/// from the block, useful for forcing the hash to some type (e.g. `H256`) when
/// the compiler can't do the inference.
type CommunicationOutH<Block, H> = grandpa::voter::CommunicationOut<
type CommunicationOutH<Block, H> = finality_grandpa::voter::CommunicationOut<
H,
NumberFor<Block>,
AuthoritySignature,
@@ -207,7 +207,7 @@ pub struct Config {
/// Some local identifier of the voter.
pub name: Option<String>,
/// The keystore that manages the keys of this node.
pub keystore: Option<keystore::KeyStorePtr>,
pub keystore: Option<sc_keystore::KeyStorePtr>,
}
impl Config {
@@ -273,13 +273,13 @@ pub(crate) trait BlockSyncRequester<Block: BlockT> {
/// If the given vector of peers is empty then the underlying implementation
/// should make a best effort to fetch the block from any peers it is
/// connected to (NOTE: this assumption will change in the future #3629).
fn set_sync_fork_request(&self, peers: Vec<network::PeerId>, hash: Block::Hash, number: NumberFor<Block>);
fn set_sync_fork_request(&self, peers: Vec<sc_network::PeerId>, hash: Block::Hash, number: NumberFor<Block>);
}
impl<Block> BlockSyncRequester<Block> for NetworkBridge<Block> where
Block: BlockT,
{
fn set_sync_fork_request(&self, peers: Vec<network::PeerId>, hash: Block::Hash, number: NumberFor<Block>) {
fn set_sync_fork_request(&self, peers: Vec<sc_network::PeerId>, hash: Block::Hash, number: NumberFor<Block>) {
NetworkBridge::set_sync_fork_request(self, peers, hash, number)
}
}
@@ -332,8 +332,8 @@ impl<H, N> From<ClientError> for CommandOrError<H, N> {
}
}
impl<H, N> From<grandpa::Error> for CommandOrError<H, N> {
fn from(e: grandpa::Error) -> Self {
impl<H, N> From<finality_grandpa::Error> for CommandOrError<H, N> {
fn from(e: finality_grandpa::Error) -> Self {
CommandOrError::Error(Error::from(e))
}
}
@@ -496,7 +496,7 @@ fn global_communication<Block: BlockT<Hash=H256>, B, E, RA>(
fn register_finality_tracker_inherent_data_provider<B, E, Block: BlockT<Hash=H256>, RA>(
client: Arc<Client<B, E, Block, RA>>,
inherent_data_providers: &InherentDataProviders,
) -> Result<(), consensus_common::Error> where
) -> Result<(), sp_consensus::Error> where
B: Backend<Block, Blake2Hasher> + 'static,
E: CallExecutor<Block, Blake2Hasher> + Send + Sync + 'static,
RA: Send + Sync + 'static,
@@ -514,7 +514,7 @@ fn register_finality_tracker_inherent_data_provider<B, E, Block: BlockT<Hash=H25
Ok(info.finalized_number)
}
}))
.map_err(|err| consensus_common::Error::InherentData(err.into()))
.map_err(|err| sp_consensus::Error::InherentData(err.into()))
} else {
Ok(())
}
@@ -902,7 +902,7 @@ pub fn setup_disabled_grandpa<B, E, Block: BlockT<Hash=H256>, RA, N>(
client: Arc<Client<B, E, Block, RA>>,
inherent_data_providers: &InherentDataProviders,
network: N,
) -> Result<(), consensus_common::Error> where
) -> Result<(), sp_consensus::Error> where
B: Backend<Block, Blake2Hasher> + 'static,
E: CallExecutor<Block, Blake2Hasher> + Send + Sync + 'static,
RA: Send + Sync + 'static,
@@ -18,21 +18,21 @@ use std::collections::HashMap;
use std::sync::Arc;
use log::{info, trace, warn};
use parking_lot::RwLock;
use client::Client;
use client_api::{CallExecutor, backend::{AuxStore, Backend, Finalizer}};
use sc_client::Client;
use sc_client_api::{CallExecutor, backend::{AuxStore, Backend, Finalizer}};
use sp_blockchain::{HeaderBackend, Error as ClientError, well_known_cache_keys};
use codec::{Encode, Decode};
use consensus_common::{
use parity_scale_codec::{Encode, Decode};
use sp_consensus::{
import_queue::Verifier,
BlockOrigin, BlockImport, FinalityProofImport, BlockImportParams, ImportResult, ImportedAux,
BlockCheckParams, Error as ConsensusError,
};
use network::config::{BoxFinalityProofRequestBuilder, FinalityProofRequestBuilder};
use sc_network::config::{BoxFinalityProofRequestBuilder, FinalityProofRequestBuilder};
use sp_runtime::Justification;
use sp_runtime::traits::{NumberFor, Block as BlockT, Header as HeaderT, DigestFor};
use fg_primitives::{self, AuthorityList};
use sp_finality_grandpa::{self, AuthorityList};
use sp_runtime::generic::BlockId;
use primitives::{H256, Blake2Hasher};
use sp_core::{H256, Blake2Hasher};
use crate::GenesisAuthoritySetProvider;
use crate::aux_schema::load_decode;
@@ -120,7 +120,7 @@ impl<B, E, Block: BlockT<Hash=H256>, RA> GrandpaLightBlockImport<B, E, Block, RA
impl<B, E, Block: BlockT<Hash=H256>, RA> BlockImport<Block>
for GrandpaLightBlockImport<B, E, Block, RA> where
NumberFor<Block>: grandpa::BlockNumberOps,
NumberFor<Block>: finality_grandpa::BlockNumberOps,
B: Backend<Block, Blake2Hasher> + 'static,
E: CallExecutor<Block, Blake2Hasher> + 'static + Clone + Send + Sync,
DigestFor<Block>: Encode,
@@ -148,7 +148,7 @@ impl<B, E, Block: BlockT<Hash=H256>, RA> BlockImport<Block>
impl<B, E, Block: BlockT<Hash=H256>, RA> FinalityProofImport<Block>
for GrandpaLightBlockImport<B, E, Block, RA> where
NumberFor<Block>: grandpa::BlockNumberOps,
NumberFor<Block>: finality_grandpa::BlockNumberOps,
B: Backend<Block, Blake2Hasher> + 'static,
E: CallExecutor<Block, Blake2Hasher> + 'static + Clone + Send + Sync,
DigestFor<Block>: Encode,
@@ -194,7 +194,7 @@ impl LightAuthoritySet {
/// Get a genesis set with given authorities.
pub fn genesis(initial: AuthorityList) -> Self {
LightAuthoritySet {
set_id: fg_primitives::SetId::default(),
set_id: sp_finality_grandpa::SetId::default(),
authorities: initial,
}
}
@@ -242,7 +242,7 @@ fn do_import_block<B, C, Block: BlockT<Hash=H256>, J>(
+ BlockImport<Block>
+ Clone,
B: Backend<Block, Blake2Hasher> + 'static,
NumberFor<Block>: grandpa::BlockNumberOps,
NumberFor<Block>: finality_grandpa::BlockNumberOps,
DigestFor<Block>: Encode,
J: ProvableJustification<Block::Header>,
{
@@ -306,7 +306,7 @@ fn do_import_finality_proof<B, C, Block: BlockT<Hash=H256>, J>(
+ Clone,
B: Backend<Block, Blake2Hasher> + 'static,
DigestFor<Block>: Encode,
NumberFor<Block>: grandpa::BlockNumberOps,
NumberFor<Block>: finality_grandpa::BlockNumberOps,
J: ProvableJustification<Block::Header>,
{
let authority_set_id = data.authority_set.set_id();
@@ -369,7 +369,7 @@ fn do_import_justification<B, C, Block: BlockT<Hash=H256>, J>(
+ Finalizer<Block, Blake2Hasher, B>
+ Clone,
B: Backend<Block, Blake2Hasher> + 'static,
NumberFor<Block>: grandpa::BlockNumberOps,
NumberFor<Block>: finality_grandpa::BlockNumberOps,
J: ProvableJustification<Block::Header>,
{
// with justification, we have two cases
@@ -440,7 +440,7 @@ fn do_finalize_block<B, C, Block: BlockT<Hash=H256>>(
+ Finalizer<Block, Blake2Hasher, B>
+ Clone,
B: Backend<Block, Blake2Hasher> + 'static,
NumberFor<Block>: grandpa::BlockNumberOps,
NumberFor<Block>: finality_grandpa::BlockNumberOps,
{
// finalize the block
client.finalize_block(BlockId::Hash(hash), Some(justification), true).map_err(|e| {
@@ -540,11 +540,11 @@ fn on_post_finalization_error(error: ClientError, value_type: &str) -> Consensus
#[cfg(test)]
pub mod tests {
use super::*;
use consensus_common::ForkChoiceStrategy;
use fg_primitives::AuthorityId;
use primitives::{H256, crypto::Public};
use test_client::client::in_mem::Blockchain as InMemoryAuxStore;
use test_client::runtime::{Block, Header};
use sp_consensus::ForkChoiceStrategy;
use sp_finality_grandpa::AuthorityId;
use sp_core::{H256, crypto::Public};
use substrate_test_runtime_client::sc_client::in_mem::Blockchain as InMemoryAuxStore;
use substrate_test_runtime_client::runtime::{Block, Header};
use crate::tests::TestApi;
use crate::finality_proof::tests::TestJustification;
@@ -554,7 +554,7 @@ pub mod tests {
impl<B, E, Block: BlockT<Hash=H256>, RA> Clone
for NoJustificationsImport<B, E, Block, RA> where
NumberFor<Block>: grandpa::BlockNumberOps,
NumberFor<Block>: finality_grandpa::BlockNumberOps,
B: Backend<Block, Blake2Hasher> + 'static,
E: CallExecutor<Block, Blake2Hasher> + 'static + Clone + Send + Sync,
DigestFor<Block>: Encode,
@@ -567,7 +567,7 @@ pub mod tests {
impl<B, E, Block: BlockT<Hash=H256>, RA> BlockImport<Block>
for NoJustificationsImport<B, E, Block, RA> where
NumberFor<Block>: grandpa::BlockNumberOps,
NumberFor<Block>: finality_grandpa::BlockNumberOps,
B: Backend<Block, Blake2Hasher> + 'static,
E: CallExecutor<Block, Blake2Hasher> + 'static + Clone + Send + Sync,
DigestFor<Block>: Encode,
@@ -594,7 +594,7 @@ pub mod tests {
impl<B, E, Block: BlockT<Hash=H256>, RA> FinalityProofImport<Block>
for NoJustificationsImport<B, E, Block, RA> where
NumberFor<Block>: grandpa::BlockNumberOps,
NumberFor<Block>: finality_grandpa::BlockNumberOps,
B: Backend<Block, Blake2Hasher> + 'static,
E: CallExecutor<Block, Blake2Hasher> + 'static + Clone + Send + Sync,
DigestFor<Block>: Encode,
@@ -637,7 +637,7 @@ pub mod tests {
new_cache: HashMap<well_known_cache_keys::Id, Vec<u8>>,
justification: Option<Justification>,
) -> ImportResult {
let (client, _backend) = test_client::new_light();
let (client, _backend) = substrate_test_runtime_client::new_light();
let mut import_data = LightImportData {
last_finalized: Default::default(),
authority_set: LightAuthoritySet::genesis(vec![(AuthorityId::from_slice(&[1; 32]), 1)]),
@@ -19,16 +19,16 @@ use std::sync::Arc;
use futures::prelude::*;
use futures::{future, sync::mpsc};
use grandpa::{
use finality_grandpa::{
BlockNumberOps, Error as GrandpaError, voter, voter_set::VoterSet
};
use log::{debug, info, warn};
use consensus_common::SelectChain;
use client_api::{CallExecutor, backend::Backend};
use client::Client;
use sp_consensus::SelectChain;
use sc_client_api::{CallExecutor, backend::Backend};
use sc_client::Client;
use sp_runtime::traits::{NumberFor, Block as BlockT};
use primitives::{H256, Blake2Hasher};
use sp_core::{H256, Blake2Hasher};
use crate::{
global_communication, CommandOrError, CommunicationIn, Config, environment,
@@ -37,11 +37,11 @@ use crate::{
use crate::authorities::SharedAuthoritySet;
use crate::communication::NetworkBridge;
use crate::consensus_changes::SharedConsensusChanges;
use fg_primitives::AuthorityId;
use sp_finality_grandpa::AuthorityId;
struct ObserverChain<'a, Block: BlockT, B, E, RA>(&'a Client<B, E, Block, RA>);
impl<'a, Block: BlockT<Hash=H256>, B, E, RA> grandpa::Chain<Block::Hash, NumberFor<Block>>
impl<'a, Block: BlockT<Hash=H256>, B, E, RA> finality_grandpa::Chain<Block::Hash, NumberFor<Block>>
for ObserverChain<'a, Block, B, E, RA> where
B: Backend<Block, Blake2Hasher>,
E: CallExecutor<Block, Blake2Hasher>,
@@ -84,7 +84,7 @@ fn grandpa_observer<B, E, Block: BlockT<Hash=H256>, RA, S, F>(
let observer = commits.fold(last_finalized_number, move |last_finalized_number, global| {
let (round, commit, callback) = match global {
voter::CommunicationIn::Commit(round, commit, callback) => {
let commit = grandpa::Commit::from(commit);
let commit = finality_grandpa::Commit::from(commit);
(round, commit, callback)
},
voter::CommunicationIn::CatchUp(..) => {
@@ -99,7 +99,7 @@ fn grandpa_observer<B, E, Block: BlockT<Hash=H256>, RA, S, F>(
return future::ok(last_finalized_number);
}
let validation_result = match grandpa::validate_commit(
let validation_result = match finality_grandpa::validate_commit(
&commit,
&voters,
&ObserverChain(&*client),
@@ -130,14 +130,14 @@ fn grandpa_observer<B, E, Block: BlockT<Hash=H256>, RA, S, F>(
// and that implies that the next round has started.
note_round(round + 1);
grandpa::process_commit_validation_result(validation_result, callback);
finality_grandpa::process_commit_validation_result(validation_result, callback);
// proceed processing with new finalized block number
future::ok(finalized_number)
} else {
debug!(target: "afg", "Received invalid commit: ({:?}, {:?})", round, commit);
grandpa::process_commit_validation_result(validation_result, callback);
finality_grandpa::process_commit_validation_result(validation_result, callback);
// commit is invalid, continue processing commits with the current state
future::ok(last_finalized_number)
@@ -207,7 +207,7 @@ struct ObserverWork<B: BlockT<Hash=H256>, E, Backend, RA> {
client: Arc<Client<Backend, E, B, RA>>,
network: NetworkBridge<B>,
persistent_data: PersistentData<B>,
keystore: Option<keystore::KeyStorePtr>,
keystore: Option<sc_keystore::KeyStorePtr>,
voter_commands_rx: mpsc::UnboundedReceiver<VoterCommand<B::Hash, NumberFor<B>>>,
}
@@ -223,7 +223,7 @@ where
client: Arc<Client<Bk, E, B, RA>>,
network: NetworkBridge<B>,
persistent_data: PersistentData<B>,
keystore: Option<keystore::KeyStorePtr>,
keystore: Option<sc_keystore::KeyStorePtr>,
voter_commands_rx: mpsc::UnboundedReceiver<VoterCommand<B::Hash, NumberFor<B>>>,
) -> Self {
+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],
@@ -29,19 +29,19 @@ use super::{
};
use log::{debug, warn};
use client_api::{BlockImportNotification, ImportNotifications};
use sc_client_api::{BlockImportNotification, ImportNotifications};
use futures::prelude::*;
use futures::stream::Fuse;
use futures_timer::Delay;
use futures03::{StreamExt as _, TryStreamExt as _};
use grandpa::voter;
use finality_grandpa::voter;
use parking_lot::Mutex;
use sp_runtime::traits::{Block as BlockT, Header as HeaderT, NumberFor};
use std::collections::{HashMap, VecDeque};
use std::sync::{atomic::{AtomicUsize, Ordering}, Arc};
use std::time::{Duration, Instant};
use fg_primitives::AuthorityId;
use sp_finality_grandpa::AuthorityId;
const LOG_PENDING_INTERVAL: Duration = Duration::from_secs(15);
@@ -475,13 +475,13 @@ mod tests {
use super::*;
use crate::{CatchUp, CompactCommit};
use tokio::runtime::current_thread::Runtime;
use test_client::runtime::{Block, Hash, Header};
use consensus_common::BlockOrigin;
use client_api::BlockImportNotification;
use substrate_test_runtime_client::runtime::{Block, Hash, Header};
use sp_consensus::BlockOrigin;
use sc_client_api::BlockImportNotification;
use futures::future::Either;
use futures_timer::Delay;
use futures03::{channel::mpsc, future::FutureExt as _, future::TryFutureExt as _};
use grandpa::Precommit;
use finality_grandpa::Precommit;
#[derive(Clone)]
struct TestChainState {
@@ -543,7 +543,7 @@ mod tests {
}
impl BlockSyncRequesterT<Block> for TestBlockSyncRequester {
fn set_sync_fork_request(&self, _peers: Vec<network::PeerId>, hash: Hash, number: NumberFor<Block>) {
fn set_sync_fork_request(&self, _peers: Vec<sc_network::PeerId>, hash: Hash, number: NumberFor<Block>) {
self.requests.lock().push((hash, number));
}
}
@@ -741,10 +741,10 @@ mod tests {
let h3 = make_header(7);
let signed_prevote = |header: &Header| {
grandpa::SignedPrevote {
finality_grandpa::SignedPrevote {
id: Default::default(),
signature: Default::default(),
prevote: grandpa::Prevote {
prevote: finality_grandpa::Prevote {
target_hash: header.hash(),
target_number: *header.number(),
},
@@ -752,10 +752,10 @@ mod tests {
};
let signed_precommit = |header: &Header| {
grandpa::SignedPrecommit {
finality_grandpa::SignedPrecommit {
id: Default::default(),
signature: Default::default(),
precommit: grandpa::Precommit {
precommit: finality_grandpa::Precommit {
target_hash: header.hash(),
target_number: *header.number(),
},
@@ -772,7 +772,7 @@ mod tests {
signed_precommit(&h2),
];
let unknown_catch_up = grandpa::CatchUp {
let unknown_catch_up = finality_grandpa::CatchUp {
round_number: 1,
prevotes,
precommits,
@@ -807,10 +807,10 @@ mod tests {
let h3 = make_header(7);
let signed_prevote = |header: &Header| {
grandpa::SignedPrevote {
finality_grandpa::SignedPrevote {
id: Default::default(),
signature: Default::default(),
prevote: grandpa::Prevote {
prevote: finality_grandpa::Prevote {
target_hash: header.hash(),
target_number: *header.number(),
},
@@ -818,10 +818,10 @@ mod tests {
};
let signed_precommit = |header: &Header| {
grandpa::SignedPrecommit {
finality_grandpa::SignedPrecommit {
id: Default::default(),
signature: Default::default(),
precommit: grandpa::Precommit {
precommit: finality_grandpa::Precommit {
target_hash: header.hash(),
target_number: *header.number(),
},
@@ -838,7 +838,7 @@ mod tests {
signed_precommit(&h2),
];
let unknown_catch_up = grandpa::CatchUp {
let unknown_catch_up = finality_grandpa::CatchUp {
round_number: 1,
prevotes,
precommits,
@@ -22,7 +22,7 @@
use std::sync::Arc;
use client_api::blockchain::HeaderBackend;
use sc_client_api::blockchain::HeaderBackend;
use sp_runtime::generic::BlockId;
use sp_runtime::traits::{Block as BlockT, Header, NumberFor, One, Zero};