mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 03:31:05 +00:00
grandpa: cleanup sync bounds (#9127)
* grandpa: cleanup sync bounds * grandpa: cleanup imports * remove cargo patch
This commit is contained in:
Generated
+2
-2
@@ -1679,9 +1679,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "finality-grandpa"
|
||||
version = "0.14.0"
|
||||
version = "0.14.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c6447e2f8178843749e8c8003206def83ec124a7859475395777a28b5338647c"
|
||||
checksum = "74a1bfdcc776e63e49f741c7ce6116fa1b887e8ac2e3ccb14dd4aa113e54feb9"
|
||||
dependencies = [
|
||||
"either",
|
||||
"futures 0.3.15",
|
||||
|
||||
@@ -28,7 +28,7 @@ sp-finality-grandpa = { version = "3.0.0", path = "../../primitives/finality-gra
|
||||
sp-runtime = { version = "3.0.0", path = "../../primitives/runtime" }
|
||||
|
||||
[dev-dependencies]
|
||||
finality-grandpa = { version = "0.14.0" }
|
||||
finality-grandpa = { version = "0.14.1" }
|
||||
rand = "0.8"
|
||||
sc-block-builder = { version = "0.9.0", path = "../block-builder" }
|
||||
sp-consensus = { version = "0.9.0", path = "../../primitives/consensus/common" }
|
||||
|
||||
@@ -40,7 +40,8 @@ pub fn request_response_config_for_chain<TBlock: BlockT, TBackend: Backend<TBloc
|
||||
backend: Arc<TBackend>,
|
||||
authority_set: SharedAuthoritySet<TBlock::Hash, NumberFor<TBlock>>,
|
||||
) -> RequestResponseConfig
|
||||
where NumberFor<TBlock>: sc_finality_grandpa::BlockNumberOps,
|
||||
where
|
||||
NumberFor<TBlock>: sc_finality_grandpa::BlockNumberOps,
|
||||
{
|
||||
let protocol_id = config.protocol_id();
|
||||
|
||||
@@ -54,7 +55,7 @@ pub fn request_response_config_for_chain<TBlock: BlockT, TBackend: Backend<TBloc
|
||||
backend.clone(),
|
||||
authority_set,
|
||||
);
|
||||
spawn_handle.spawn("grandpa_warp_sync_request_handler", handler.run());
|
||||
spawn_handle.spawn("grandpa-warp-sync", handler.run());
|
||||
request_response_config
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ sc-network-gossip = { version = "0.9.0", path = "../network-gossip" }
|
||||
sp-finality-grandpa = { version = "3.0.0", path = "../../primitives/finality-grandpa" }
|
||||
prometheus-endpoint = { package = "substrate-prometheus-endpoint", path = "../../utils/prometheus", version = "0.9.0"}
|
||||
sc-block-builder = { version = "0.9.0", path = "../block-builder" }
|
||||
finality-grandpa = { version = "0.14.0", features = ["derive-codec"] }
|
||||
finality-grandpa = { version = "0.14.1", features = ["derive-codec"] }
|
||||
pin-project = "1.0.4"
|
||||
linked-hash-map = "0.5.2"
|
||||
async-trait = "0.1.42"
|
||||
@@ -52,7 +52,7 @@ wasm-timer = "0.2"
|
||||
|
||||
[dev-dependencies]
|
||||
assert_matches = "1.3.0"
|
||||
finality-grandpa = { version = "0.14.0", features = ["derive-codec", "test-helpers"] }
|
||||
finality-grandpa = { version = "0.14.1", features = ["derive-codec", "test-helpers"] }
|
||||
sc-network = { version = "0.9.0", path = "../network" }
|
||||
sc-network-test = { version = "0.8.0", path = "../network/test" }
|
||||
sp-keyring = { version = "3.0.0", path = "../../primitives/keyring" }
|
||||
|
||||
@@ -14,7 +14,7 @@ sc-rpc = { version = "3.0.0", path = "../../rpc" }
|
||||
sp-blockchain = { version = "3.0.0", path = "../../../primitives/blockchain" }
|
||||
sp-core = { version = "3.0.0", path = "../../../primitives/core" }
|
||||
sp-runtime = { version = "3.0.0", path = "../../../primitives/runtime" }
|
||||
finality-grandpa = { version = "0.14.0", features = ["derive-codec"] }
|
||||
finality-grandpa = { version = "0.14.1", features = ["derive-codec"] }
|
||||
jsonrpc-core = "15.1.0"
|
||||
jsonrpc-core-client = "15.1.0"
|
||||
jsonrpc-derive = "15.1.0"
|
||||
|
||||
@@ -117,7 +117,7 @@ impl LocalIdKeystore {
|
||||
}
|
||||
|
||||
/// Returns a reference to the keystore.
|
||||
fn keystore(&self) -> SyncCryptoStorePtr{
|
||||
fn keystore(&self) -> SyncCryptoStorePtr {
|
||||
(self.0).1.clone()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,43 +23,42 @@ use std::pin::Pin;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
||||
use finality_grandpa::{
|
||||
round::State as RoundState, voter, voter_set::VoterSet, BlockNumberOps, Error as GrandpaError,
|
||||
};
|
||||
use futures::prelude::*;
|
||||
use futures_timer::Delay;
|
||||
use log::{debug, warn};
|
||||
use parity_scale_codec::{Decode, Encode};
|
||||
use parking_lot::RwLock;
|
||||
use prometheus_endpoint::{register, Counter, Gauge, PrometheusError, U64};
|
||||
|
||||
use sc_client_api::{backend::{Backend, apply_aux}, utils::is_descendent_of};
|
||||
use finality_grandpa::{
|
||||
BlockNumberOps, Error as GrandpaError, round::State as RoundState,
|
||||
voter, voter_set::VoterSet,
|
||||
};
|
||||
use sp_blockchain::HeaderMetadata;
|
||||
use sp_runtime::generic::BlockId;
|
||||
use sp_runtime::traits::{
|
||||
Block as BlockT, Header as HeaderT, NumberFor, Zero,
|
||||
use sc_client_api::{
|
||||
backend::{apply_aux, Backend},
|
||||
utils::is_descendent_of,
|
||||
};
|
||||
use sc_telemetry::{telemetry, TelemetryHandle, CONSENSUS_DEBUG, CONSENSUS_INFO};
|
||||
use sp_blockchain::HeaderMetadata;
|
||||
use sp_consensus::SelectChain;
|
||||
use sp_finality_grandpa::{
|
||||
AuthorityId, AuthoritySignature, Equivocation, EquivocationProof, GrandpaApi, RoundNumber,
|
||||
SetId, GRANDPA_ENGINE_ID,
|
||||
};
|
||||
use sp_runtime::generic::BlockId;
|
||||
use sp_runtime::traits::{Block as BlockT, Header as HeaderT, NumberFor, Zero};
|
||||
|
||||
use crate::{
|
||||
local_authority_id, CommandOrError, Commit, Config, Error, NewAuthoritySet, Precommit, Prevote,
|
||||
authorities::{AuthoritySet, SharedAuthoritySet},
|
||||
communication::Network as NetworkT,
|
||||
justification::GrandpaJustification,
|
||||
local_authority_id,
|
||||
notification::GrandpaJustificationSender,
|
||||
until_imported::UntilVoteTargetImported,
|
||||
voting_rule::VotingRule,
|
||||
ClientForGrandpa, CommandOrError, Commit, Config, Error, NewAuthoritySet, Precommit, Prevote,
|
||||
PrimaryPropose, SignedMessage, VoterCommand,
|
||||
};
|
||||
|
||||
use sp_consensus::SelectChain;
|
||||
|
||||
use crate::authorities::{AuthoritySet, SharedAuthoritySet};
|
||||
use crate::communication::Network as NetworkT;
|
||||
use crate::notification::GrandpaJustificationSender;
|
||||
use crate::justification::GrandpaJustification;
|
||||
use crate::until_imported::UntilVoteTargetImported;
|
||||
use crate::voting_rule::VotingRule;
|
||||
use sp_finality_grandpa::{
|
||||
AuthorityId, AuthoritySignature, Equivocation, EquivocationProof, GRANDPA_ENGINE_ID,
|
||||
GrandpaApi, RoundNumber, SetId,
|
||||
};
|
||||
use prometheus_endpoint::{register, Counter, Gauge, PrometheusError, U64};
|
||||
|
||||
type HistoricalVotes<Block> = finality_grandpa::HistoricalVotes<
|
||||
<Block as BlockT>::Hash,
|
||||
NumberFor<Block>,
|
||||
@@ -480,10 +479,10 @@ impl<BE, Block, C, N, SC, VR> Environment<BE, Block, C, N, SC, VR>
|
||||
where
|
||||
Block: BlockT,
|
||||
BE: Backend<Block>,
|
||||
C: crate::ClientForGrandpa<Block, BE>,
|
||||
C: ClientForGrandpa<Block, BE>,
|
||||
C::Api: GrandpaApi<Block>,
|
||||
N: NetworkT<Block>,
|
||||
SC: SelectChain<Block> + 'static,
|
||||
SC: SelectChain<Block>,
|
||||
{
|
||||
/// Report the given equivocation to the GRANDPA runtime module. This method
|
||||
/// generates a session membership proof of the offender and then submits an
|
||||
@@ -578,24 +577,26 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<BE, Block: BlockT, C, N, SC, VR>
|
||||
finality_grandpa::Chain<Block::Hash, NumberFor<Block>>
|
||||
for Environment<BE, Block, C, N, SC, VR>
|
||||
impl<BE, Block, C, N, SC, VR> finality_grandpa::Chain<Block::Hash, NumberFor<Block>>
|
||||
for Environment<BE, Block, C, N, SC, VR>
|
||||
where
|
||||
Block: 'static,
|
||||
Block: BlockT,
|
||||
BE: Backend<Block>,
|
||||
C: crate::ClientForGrandpa<Block, BE>,
|
||||
N: NetworkT<Block> + 'static + Send,
|
||||
SC: SelectChain<Block> + 'static,
|
||||
C: ClientForGrandpa<Block, BE>,
|
||||
N: NetworkT<Block>,
|
||||
SC: SelectChain<Block>,
|
||||
VR: VotingRule<Block, C>,
|
||||
NumberFor<Block>: BlockNumberOps,
|
||||
{
|
||||
fn ancestry(&self, base: Block::Hash, block: Block::Hash) -> Result<Vec<Block::Hash>, GrandpaError> {
|
||||
fn ancestry(
|
||||
&self,
|
||||
base: Block::Hash,
|
||||
block: Block::Hash,
|
||||
) -> Result<Vec<Block::Hash>, GrandpaError> {
|
||||
ancestry(&self.client, base, block)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pub(crate) fn ancestry<Block: BlockT, Client>(
|
||||
client: &Arc<Client>,
|
||||
base: Block::Hash,
|
||||
@@ -624,27 +625,31 @@ where
|
||||
|
||||
// skip one because our ancestry is meant to start from the parent of `block`,
|
||||
// and `tree_route` includes it.
|
||||
Ok(tree_route.retracted().iter().skip(1).map(|e| e.hash).collect())
|
||||
Ok(tree_route
|
||||
.retracted()
|
||||
.iter()
|
||||
.skip(1)
|
||||
.map(|e| e.hash)
|
||||
.collect())
|
||||
}
|
||||
|
||||
impl<B, Block: BlockT, C, N, SC, VR> voter::Environment<Block::Hash, NumberFor<Block>>
|
||||
impl<B, Block, C, N, SC, VR> voter::Environment<Block::Hash, NumberFor<Block>>
|
||||
for Environment<B, Block, C, N, SC, VR>
|
||||
where
|
||||
Block: 'static,
|
||||
Block: BlockT,
|
||||
B: Backend<Block>,
|
||||
C: crate::ClientForGrandpa<Block, B> + 'static,
|
||||
C: ClientForGrandpa<Block, B> + 'static,
|
||||
C::Api: GrandpaApi<Block>,
|
||||
N: NetworkT<Block> + 'static + Send + Sync,
|
||||
SC: SelectChain<Block> + 'static,
|
||||
N: NetworkT<Block>,
|
||||
SC: SelectChain<Block>,
|
||||
VR: VotingRule<Block, C>,
|
||||
NumberFor<Block>: BlockNumberOps,
|
||||
{
|
||||
type Timer = Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + Sync>>;
|
||||
type Timer = Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send>>;
|
||||
type BestChain = Pin<
|
||||
Box<
|
||||
dyn Future<Output = Result<Option<(Block::Hash, NumberFor<Block>)>, Self::Error>>
|
||||
+ Send
|
||||
+ Sync
|
||||
+ Send,
|
||||
>,
|
||||
>;
|
||||
|
||||
@@ -652,13 +657,29 @@ where
|
||||
type Signature = AuthoritySignature;
|
||||
|
||||
// regular round message streams
|
||||
type In = Pin<Box<dyn Stream<
|
||||
Item = Result<::finality_grandpa::SignedMessage<Block::Hash, NumberFor<Block>, Self::Signature, Self::Id>, Self::Error>
|
||||
> + Send + Sync>>;
|
||||
type Out = Pin<Box<dyn Sink<
|
||||
type In = Pin<
|
||||
Box<
|
||||
dyn Stream<
|
||||
Item = Result<
|
||||
::finality_grandpa::SignedMessage<
|
||||
Block::Hash,
|
||||
NumberFor<Block>,
|
||||
Self::Signature,
|
||||
Self::Id,
|
||||
>,
|
||||
Self::Error,
|
||||
>,
|
||||
> + Send,
|
||||
>,
|
||||
>;
|
||||
type Out = Pin<
|
||||
Box<
|
||||
dyn Sink<
|
||||
::finality_grandpa::Message<Block::Hash, NumberFor<Block>>,
|
||||
Error = Self::Error,
|
||||
> + Send + Sync>>;
|
||||
> + Send,
|
||||
>,
|
||||
>;
|
||||
|
||||
type Error = CommandOrError<Block::Hash, NumberFor<Block>>;
|
||||
|
||||
@@ -1223,7 +1244,7 @@ pub(crate) fn finalize_block<BE, Block, Client>(
|
||||
where
|
||||
Block: BlockT,
|
||||
BE: Backend<Block>,
|
||||
Client: crate::ClientForGrandpa<Block, BE>,
|
||||
Client: ClientForGrandpa<Block, BE>,
|
||||
{
|
||||
// NOTE: lock must be held through writing to DB to avoid race. this lock
|
||||
// also implicitly synchronizes the check for last finalized number
|
||||
|
||||
@@ -62,9 +62,10 @@ pub struct FinalityProofProvider<BE, Block: BlockT> {
|
||||
shared_authority_set: Option<SharedAuthoritySet<Block::Hash, NumberFor<Block>>>,
|
||||
}
|
||||
|
||||
impl<B, Block: BlockT> FinalityProofProvider<B, Block>
|
||||
impl<B, Block> FinalityProofProvider<B, Block>
|
||||
where
|
||||
B: Backend<Block> + Send + Sync + 'static,
|
||||
Block: BlockT,
|
||||
B: Backend<Block>,
|
||||
{
|
||||
/// Create new finality proof provider using:
|
||||
///
|
||||
@@ -97,7 +98,7 @@ where
|
||||
impl<B, Block> FinalityProofProvider<B, Block>
|
||||
where
|
||||
Block: BlockT,
|
||||
B: Backend<Block> + Send + Sync + 'static,
|
||||
B: Backend<Block>,
|
||||
{
|
||||
/// Prove finality for the given block number by returning a Justification for the last block of
|
||||
/// the authority set.
|
||||
|
||||
@@ -16,36 +16,33 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use std::{sync::Arc, collections::HashMap};
|
||||
use std::{collections::HashMap, marker::PhantomData, sync::Arc};
|
||||
|
||||
use log::debug;
|
||||
use parity_scale_codec::Encode;
|
||||
|
||||
use sp_blockchain::{BlockStatus, well_known_cache_keys};
|
||||
use sc_client_api::{backend::Backend, utils::is_descendent_of};
|
||||
use sc_consensus::shared_data::{SharedDataLocked, SharedDataLockedUpgradable};
|
||||
use sc_telemetry::TelemetryHandle;
|
||||
use sp_utils::mpsc::TracingUnboundedSender;
|
||||
use sp_api::TransactionFor;
|
||||
use sc_consensus::shared_data::{SharedDataLockedUpgradable, SharedDataLocked};
|
||||
|
||||
use sp_blockchain::{well_known_cache_keys, BlockStatus};
|
||||
use sp_consensus::{
|
||||
BlockImport, Error as ConsensusError,
|
||||
BlockCheckParams, BlockImportParams, BlockOrigin, ImportResult, JustificationImport,
|
||||
SelectChain,
|
||||
BlockCheckParams, BlockImport, BlockImportParams, BlockOrigin, Error as ConsensusError,
|
||||
ImportResult, JustificationImport, SelectChain,
|
||||
};
|
||||
use sp_finality_grandpa::{ConsensusLog, ScheduledChange, SetId, GRANDPA_ENGINE_ID};
|
||||
use sp_runtime::Justification;
|
||||
use sp_runtime::generic::{BlockId, OpaqueDigestItemId};
|
||||
use sp_runtime::traits::{
|
||||
Block as BlockT, DigestFor, Header as HeaderT, NumberFor, Zero,
|
||||
};
|
||||
use sp_runtime::traits::{Block as BlockT, DigestFor, Header as HeaderT, NumberFor, Zero};
|
||||
use sp_runtime::Justification;
|
||||
use sp_utils::mpsc::TracingUnboundedSender;
|
||||
|
||||
use crate::{Error, CommandOrError, NewAuthoritySet, VoterCommand};
|
||||
use crate::authorities::{AuthoritySet, SharedAuthoritySet, DelayKind, PendingChange};
|
||||
use crate::environment::finalize_block;
|
||||
use crate::justification::GrandpaJustification;
|
||||
use crate::notification::GrandpaJustificationSender;
|
||||
use std::marker::PhantomData;
|
||||
use crate::{
|
||||
authorities::{AuthoritySet, DelayKind, PendingChange, SharedAuthoritySet},
|
||||
environment::finalize_block,
|
||||
justification::GrandpaJustification,
|
||||
notification::GrandpaJustificationSender,
|
||||
ClientForGrandpa, CommandOrError, Error, NewAuthoritySet, VoterCommand,
|
||||
};
|
||||
|
||||
/// A block-import handler for GRANDPA.
|
||||
///
|
||||
@@ -67,8 +64,8 @@ pub struct GrandpaBlockImport<Backend, Block: BlockT, Client, SC> {
|
||||
_phantom: PhantomData<Backend>,
|
||||
}
|
||||
|
||||
impl<Backend, Block: BlockT, Client, SC: Clone> Clone for
|
||||
GrandpaBlockImport<Backend, Block, Client, SC>
|
||||
impl<Backend, Block: BlockT, Client, SC: Clone> Clone
|
||||
for GrandpaBlockImport<Backend, Block, Client, SC>
|
||||
{
|
||||
fn clone(&self) -> Self {
|
||||
GrandpaBlockImport {
|
||||
@@ -85,11 +82,12 @@ impl<Backend, Block: BlockT, Client, SC: Clone> Clone for
|
||||
}
|
||||
|
||||
impl<BE, Block: BlockT, Client, SC> JustificationImport<Block>
|
||||
for GrandpaBlockImport<BE, Block, Client, SC> where
|
||||
for GrandpaBlockImport<BE, Block, Client, SC>
|
||||
where
|
||||
NumberFor<Block>: finality_grandpa::BlockNumberOps,
|
||||
DigestFor<Block>: Encode,
|
||||
BE: Backend<Block>,
|
||||
Client: crate::ClientForGrandpa<Block, BE>,
|
||||
Client: ClientForGrandpa<Block, BE>,
|
||||
SC: SelectChain<Block>,
|
||||
{
|
||||
type Error = ConsensusError;
|
||||
@@ -219,13 +217,12 @@ pub fn find_forced_change<B: BlockT>(
|
||||
header.digest().convert_first(|l| l.try_to(id).and_then(filter_log))
|
||||
}
|
||||
|
||||
impl<BE, Block: BlockT, Client, SC>
|
||||
GrandpaBlockImport<BE, Block, Client, SC>
|
||||
impl<BE, Block: BlockT, Client, SC> GrandpaBlockImport<BE, Block, Client, SC>
|
||||
where
|
||||
NumberFor<Block>: finality_grandpa::BlockNumberOps,
|
||||
DigestFor<Block>: Encode,
|
||||
BE: Backend<Block>,
|
||||
Client: crate::ClientForGrandpa<Block, BE>,
|
||||
Client: ClientForGrandpa<Block, BE>,
|
||||
{
|
||||
// check for a new authority set change.
|
||||
fn check_new_change(
|
||||
@@ -416,20 +413,24 @@ where
|
||||
|
||||
let just_in_case = just_in_case.map(|(o, i)| (o, i.release_mutex()));
|
||||
|
||||
Ok(PendingSetChanges { just_in_case, applied_changes, do_pause })
|
||||
Ok(PendingSetChanges {
|
||||
just_in_case,
|
||||
applied_changes,
|
||||
do_pause,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl<BE, Block: BlockT, Client, SC> BlockImport<Block>
|
||||
for GrandpaBlockImport<BE, Block, Client, SC> where
|
||||
impl<BE, Block: BlockT, Client, SC> BlockImport<Block> for GrandpaBlockImport<BE, Block, Client, SC>
|
||||
where
|
||||
NumberFor<Block>: finality_grandpa::BlockNumberOps,
|
||||
DigestFor<Block>: Encode,
|
||||
BE: Backend<Block>,
|
||||
Client: crate::ClientForGrandpa<Block, BE>,
|
||||
Client: ClientForGrandpa<Block, BE>,
|
||||
for<'a> &'a Client:
|
||||
BlockImport<Block, Error = ConsensusError, Transaction = TransactionFor<Client, Block>>,
|
||||
TransactionFor<Client, Block>: Send + 'static,
|
||||
TransactionFor<Client, Block>: 'static,
|
||||
SC: Send,
|
||||
{
|
||||
type Error = ConsensusError;
|
||||
@@ -630,7 +631,7 @@ impl<Backend, Block: BlockT, Client, SC> GrandpaBlockImport<Backend, Block, Clie
|
||||
impl<BE, Block: BlockT, Client, SC> GrandpaBlockImport<BE, Block, Client, SC>
|
||||
where
|
||||
BE: Backend<Block>,
|
||||
Client: crate::ClientForGrandpa<Block, BE>,
|
||||
Client: ClientForGrandpa<Block, BE>,
|
||||
NumberFor<Block>: finality_grandpa::BlockNumberOps,
|
||||
{
|
||||
/// Import a block justification and finalize the block.
|
||||
|
||||
@@ -627,13 +627,17 @@ fn global_communication<BE, Block: BlockT, C, N>(
|
||||
metrics: Option<until_imported::Metrics>,
|
||||
) -> (
|
||||
impl Stream<
|
||||
Item = Result<CommunicationInH<Block, Block::Hash>, CommandOrError<Block::Hash, NumberFor<Block>>>,
|
||||
Item = Result<
|
||||
CommunicationInH<Block, Block::Hash>,
|
||||
CommandOrError<Block::Hash, NumberFor<Block>>,
|
||||
>,
|
||||
>,
|
||||
impl Sink<
|
||||
CommunicationOutH<Block, Block::Hash>,
|
||||
Error = CommandOrError<Block::Hash, NumberFor<Block>>,
|
||||
> + Unpin,
|
||||
) where
|
||||
>,
|
||||
)
|
||||
where
|
||||
BE: Backend<Block> + 'static,
|
||||
C: ClientForGrandpa<Block, BE> + 'static,
|
||||
N: NetworkT<Block>,
|
||||
@@ -707,11 +711,11 @@ pub fn grandpa_peers_set_config() -> sc_network::config::NonDefaultSetConfig {
|
||||
/// block import worker that has already been instantiated with `block_import`.
|
||||
pub fn run_grandpa_voter<Block: BlockT, BE: 'static, C, N, SC, VR>(
|
||||
grandpa_params: GrandpaParams<Block, C, N, SC, VR>,
|
||||
) -> sp_blockchain::Result<impl Future<Output = ()> + Unpin + Send + 'static>
|
||||
) -> sp_blockchain::Result<impl Future<Output = ()> + Send>
|
||||
where
|
||||
Block::Hash: Ord,
|
||||
BE: Backend<Block> + 'static,
|
||||
N: NetworkT<Block> + Send + Sync + Clone + 'static,
|
||||
N: NetworkT<Block> + Sync + 'static,
|
||||
SC: SelectChain<Block> + 'static,
|
||||
VR: VotingRule<Block, C> + Clone + 'static,
|
||||
NumberFor<Block>: BlockNumberOps,
|
||||
|
||||
@@ -16,33 +16,33 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use std::marker::{PhantomData, Unpin};
|
||||
use std::pin::Pin;
|
||||
use std::sync::Arc;
|
||||
use std::task::{Context, Poll};
|
||||
|
||||
use finality_grandpa::{voter, voter_set::VoterSet, BlockNumberOps, Error as GrandpaError};
|
||||
use futures::prelude::*;
|
||||
|
||||
use finality_grandpa::{
|
||||
BlockNumberOps, Error as GrandpaError, voter, voter_set::VoterSet
|
||||
};
|
||||
use log::{debug, info, warn};
|
||||
use sp_keystore::SyncCryptoStorePtr;
|
||||
use sp_consensus::SelectChain;
|
||||
|
||||
use sc_client_api::backend::Backend;
|
||||
use sc_telemetry::TelemetryHandle;
|
||||
use sp_utils::mpsc::TracingUnboundedReceiver;
|
||||
use sp_runtime::traits::{NumberFor, Block as BlockT};
|
||||
use sp_blockchain::HeaderMetadata;
|
||||
use sp_consensus::SelectChain;
|
||||
use sp_finality_grandpa::AuthorityId;
|
||||
use sp_keystore::SyncCryptoStorePtr;
|
||||
use sp_runtime::traits::{Block as BlockT, NumberFor};
|
||||
use sp_utils::mpsc::TracingUnboundedReceiver;
|
||||
|
||||
use crate::{
|
||||
global_communication, CommandOrError, CommunicationIn, Config, environment,
|
||||
LinkHalf, Error, aux_schema::PersistentData, VoterCommand, VoterSetState,
|
||||
authorities::SharedAuthoritySet,
|
||||
aux_schema::PersistentData,
|
||||
communication::{Network as NetworkT, NetworkBridge},
|
||||
environment, global_communication,
|
||||
notification::GrandpaJustificationSender,
|
||||
ClientForGrandpa, CommandOrError, CommunicationIn, Config, Error, LinkHalf, VoterCommand,
|
||||
VoterSetState,
|
||||
};
|
||||
use crate::authorities::SharedAuthoritySet;
|
||||
use crate::communication::{Network as NetworkT, NetworkBridge};
|
||||
use crate::notification::GrandpaJustificationSender;
|
||||
use sp_finality_grandpa::AuthorityId;
|
||||
use std::marker::{PhantomData, Unpin};
|
||||
|
||||
struct ObserverChain<'a, Block: BlockT, Client> {
|
||||
client: &'a Arc<Client>,
|
||||
@@ -50,12 +50,17 @@ struct ObserverChain<'a, Block: BlockT, Client> {
|
||||
}
|
||||
|
||||
impl<'a, Block, Client> finality_grandpa::Chain<Block::Hash, NumberFor<Block>>
|
||||
for ObserverChain<'a, Block, Client> where
|
||||
for ObserverChain<'a, Block, Client>
|
||||
where
|
||||
Block: BlockT,
|
||||
Client: HeaderMetadata<Block, Error = sp_blockchain::Error>,
|
||||
NumberFor<Block>: BlockNumberOps,
|
||||
{
|
||||
fn ancestry(&self, base: Block::Hash, block: Block::Hash) -> Result<Vec<Block::Hash>, GrandpaError> {
|
||||
fn ancestry(
|
||||
&self,
|
||||
base: Block::Hash,
|
||||
block: Block::Hash,
|
||||
) -> Result<Vec<Block::Hash>, GrandpaError> {
|
||||
environment::ancestry(&self.client, base, block)
|
||||
}
|
||||
}
|
||||
@@ -75,7 +80,7 @@ where
|
||||
S: Stream<Item = Result<CommunicationIn<Block>, CommandOrError<Block::Hash, NumberFor<Block>>>>,
|
||||
F: Fn(u64),
|
||||
BE: Backend<Block>,
|
||||
Client: crate::ClientForGrandpa<Block, BE>,
|
||||
Client: ClientForGrandpa<Block, BE>,
|
||||
{
|
||||
let authority_set = authority_set.clone();
|
||||
let client = client.clone();
|
||||
@@ -160,13 +165,13 @@ pub fn run_grandpa_observer<BE, Block: BlockT, Client, N, SC>(
|
||||
config: Config,
|
||||
link: LinkHalf<Block, Client, SC>,
|
||||
network: N,
|
||||
) -> sp_blockchain::Result<impl Future<Output = ()> + Unpin + Send + 'static>
|
||||
) -> sp_blockchain::Result<impl Future<Output = ()> + Send>
|
||||
where
|
||||
BE: Backend<Block> + Unpin + 'static,
|
||||
N: NetworkT<Block> + Send + Clone + 'static,
|
||||
SC: SelectChain<Block> + 'static,
|
||||
N: NetworkT<Block>,
|
||||
SC: SelectChain<Block>,
|
||||
NumberFor<Block>: BlockNumberOps,
|
||||
Client: crate::ClientForGrandpa<Block, BE> + 'static,
|
||||
Client: ClientForGrandpa<Block, BE> + 'static,
|
||||
{
|
||||
let LinkHalf {
|
||||
client,
|
||||
@@ -223,7 +228,7 @@ impl<B, BE, Client, Network> ObserverWork<B, BE, Client, Network>
|
||||
where
|
||||
B: BlockT,
|
||||
BE: Backend<B> + 'static,
|
||||
Client: crate::ClientForGrandpa<B, BE> + 'static,
|
||||
Client: ClientForGrandpa<B, BE> + 'static,
|
||||
Network: NetworkT<B>,
|
||||
NumberFor<B>: BlockNumberOps,
|
||||
{
|
||||
@@ -236,7 +241,6 @@ where
|
||||
justification_sender: Option<GrandpaJustificationSender<B>>,
|
||||
telemetry: Option<TelemetryHandle>,
|
||||
) -> Self {
|
||||
|
||||
let mut work = ObserverWork {
|
||||
// `observer` is set to a temporary value and replaced below when
|
||||
// calling `rebuild_observer`.
|
||||
@@ -344,7 +348,7 @@ impl<B, BE, C, N> Future for ObserverWork<B, BE, C, N>
|
||||
where
|
||||
B: BlockT,
|
||||
BE: Backend<B> + Unpin + 'static,
|
||||
C: crate::ClientForGrandpa<B, BE> + 'static,
|
||||
C: ClientForGrandpa<B, BE> + 'static,
|
||||
N: NetworkT<B>,
|
||||
NumberFor<B>: BlockNumberOps,
|
||||
{
|
||||
|
||||
@@ -1013,7 +1013,7 @@ fn voter_persists_its_votes() {
|
||||
fn alice_voter2(
|
||||
peers: &[Ed25519Keyring],
|
||||
net: Arc<Mutex<GrandpaTestNet>>,
|
||||
) -> impl Future<Output = ()> + Unpin + Send + 'static {
|
||||
) -> impl Future<Output = ()> + Send {
|
||||
let (keystore, _) = create_keystore(peers[0]);
|
||||
let mut net = net.lock();
|
||||
|
||||
|
||||
@@ -136,12 +136,14 @@ impl Drop for Metrics {
|
||||
fn drop(&mut self) {
|
||||
// Reduce the global counter by the amount of messages that were still left in the dropped
|
||||
// queue.
|
||||
self.global_waiting_messages.sub(self.local_waiting_messages)
|
||||
self.global_waiting_messages
|
||||
.sub(self.local_waiting_messages)
|
||||
}
|
||||
}
|
||||
|
||||
/// Buffering incoming messages until blocks with given hashes are imported.
|
||||
pub(crate) struct UntilImported<Block, BlockStatus, BlockSyncRequester, I, M> where
|
||||
pub(crate) struct UntilImported<Block, BlockStatus, BlockSyncRequester, I, M>
|
||||
where
|
||||
Block: BlockT,
|
||||
I: Stream<Item = M::Blocked> + Unpin,
|
||||
M: BlockUntilImported<Block>,
|
||||
@@ -152,7 +154,7 @@ pub(crate) struct UntilImported<Block, BlockStatus, BlockSyncRequester, I, M> wh
|
||||
incoming_messages: Fuse<I>,
|
||||
ready: VecDeque<M::Blocked>,
|
||||
/// Interval at which to check status of each awaited block.
|
||||
check_pending: Pin<Box<dyn Stream<Item = Result<(), std::io::Error>> + Send + Sync>>,
|
||||
check_pending: Pin<Box<dyn Stream<Item = Result<(), std::io::Error>> + Send>>,
|
||||
/// Mapping block hashes to their block number, the point in time it was
|
||||
/// first encountered (Instant) and a list of GRANDPA messages referencing
|
||||
/// the block hash.
|
||||
@@ -164,13 +166,18 @@ pub(crate) struct UntilImported<Block, BlockStatus, BlockSyncRequester, I, M> wh
|
||||
metrics: Option<Metrics>,
|
||||
}
|
||||
|
||||
impl<Block, BlockStatus, BlockSyncRequester, I, M> Unpin for UntilImported<Block, BlockStatus, BlockSyncRequester, I, M > where
|
||||
impl<Block, BlockStatus, BlockSyncRequester, I, M> Unpin
|
||||
for UntilImported<Block, BlockStatus, BlockSyncRequester, I, M>
|
||||
where
|
||||
Block: BlockT,
|
||||
I: Stream<Item = M::Blocked> + Unpin,
|
||||
M: BlockUntilImported<Block>,
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
impl<Block, BlockStatus, BlockSyncRequester, I, M> UntilImported<Block, BlockStatus, BlockSyncRequester, I, M> where
|
||||
impl<Block, BlockStatus, BlockSyncRequester, I, M>
|
||||
UntilImported<Block, BlockStatus, BlockSyncRequester, I, M>
|
||||
where
|
||||
Block: BlockT,
|
||||
BlockStatus: BlockStatusT<Block>,
|
||||
BlockSyncRequester: BlockSyncRequesterT<Block>,
|
||||
|
||||
@@ -34,10 +34,11 @@ use sp_runtime::traits::{Block as BlockT, Header, NumberFor, One, Zero};
|
||||
|
||||
/// A future returned by a `VotingRule` to restrict a given vote, if any restriction is necessary.
|
||||
pub type VotingRuleResult<Block> =
|
||||
Pin<Box<dyn Future<Output = Option<(<Block as BlockT>::Hash, NumberFor<Block>)>> + Send + Sync>>;
|
||||
Pin<Box<dyn Future<Output = Option<(<Block as BlockT>::Hash, NumberFor<Block>)>> + Send>>;
|
||||
|
||||
/// A trait for custom voting rules in GRANDPA.
|
||||
pub trait VotingRule<Block, B>: DynClone + Send + Sync where
|
||||
pub trait VotingRule<Block, B>: DynClone + Send + Sync
|
||||
where
|
||||
Block: BlockT,
|
||||
B: HeaderBackend<Block>,
|
||||
{
|
||||
|
||||
@@ -31,7 +31,7 @@ log = { version = "0.4.14", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
frame-benchmarking = { version = "3.1.0", path = "../benchmarking" }
|
||||
grandpa = { package = "finality-grandpa", version = "0.14.0", features = ["derive-codec"] }
|
||||
grandpa = { package = "finality-grandpa", version = "0.14.1", features = ["derive-codec"] }
|
||||
sp-keyring = { version = "3.0.0", path = "../../primitives/keyring" }
|
||||
pallet-balances = { version = "3.0.0", path = "../balances" }
|
||||
pallet-offences = { version = "3.0.0", path = "../offences" }
|
||||
|
||||
@@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ["derive"] }
|
||||
grandpa = { package = "finality-grandpa", version = "0.14.0", default-features = false, features = ["derive-codec"] }
|
||||
grandpa = { package = "finality-grandpa", version = "0.14.1", default-features = false, features = ["derive-codec"] }
|
||||
log = { version = "0.4.8", optional = true }
|
||||
serde = { version = "1.0.101", optional = true, features = ["derive"] }
|
||||
sp-api = { version = "3.0.0", default-features = false, path = "../api" }
|
||||
|
||||
Reference in New Issue
Block a user