mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 19:11:04 +00:00
update substrate (#259)
* WIP * merging select_chain * WIP * update to point to gui-polkadot-master * Fix collator * update gui-polkadot-master and fix * fix unwraps * better returning an error
This commit is contained in:
committed by
Robert Habermeier
parent
ac2b9168ac
commit
6d778c99d2
@@ -27,16 +27,17 @@ use std::thread;
|
||||
use std::time::{Duration, Instant};
|
||||
use std::sync::Arc;
|
||||
|
||||
use client::{error::Result as ClientResult, BlockchainEvents, ChainHead, BlockBody};
|
||||
use client::{error::Result as ClientResult, BlockchainEvents, BlockBody};
|
||||
use client::block_builder::api::BlockBuilder;
|
||||
use client::blockchain::HeaderBackend;
|
||||
use primitives::ed25519;
|
||||
use consensus::SelectChain;
|
||||
use consensus_authorities::AuthoritiesApi;
|
||||
use extrinsic_store::Store as ExtrinsicStore;
|
||||
use futures::prelude::*;
|
||||
use primitives::ed25519;
|
||||
use polkadot_primitives::{Block, BlockId};
|
||||
use polkadot_primitives::parachain::{CandidateReceipt, ParachainHost};
|
||||
use extrinsic_store::Store as ExtrinsicStore;
|
||||
use runtime_primitives::traits::{ProvideRuntimeApi, Header as HeaderT};
|
||||
use consensus_authorities::AuthoritiesApi;
|
||||
|
||||
use tokio::runtime::TaskExecutor;
|
||||
use tokio::runtime::current_thread::Runtime as LocalRuntime;
|
||||
@@ -102,8 +103,9 @@ pub(crate) struct ServiceHandle {
|
||||
}
|
||||
|
||||
/// Create and start a new instance of the attestation service.
|
||||
pub(crate) fn start<C, N, P>(
|
||||
pub(crate) fn start<C, N, P, SC>(
|
||||
client: Arc<P>,
|
||||
select_chain: SC,
|
||||
parachain_validation: Arc<::ParachainValidation<C, N, P>>,
|
||||
thread_pool: TaskExecutor,
|
||||
key: Arc<ed25519::Pair>,
|
||||
@@ -112,12 +114,13 @@ pub(crate) fn start<C, N, P>(
|
||||
where
|
||||
C: Collators + Send + Sync + 'static,
|
||||
<C::Collation as IntoFuture>::Future: Send + 'static,
|
||||
P: BlockchainEvents<Block> + ChainHead<Block> + BlockBody<Block>,
|
||||
P: BlockchainEvents<Block> + BlockBody<Block>,
|
||||
P: ProvideRuntimeApi + HeaderBackend<Block> + Send + Sync + 'static,
|
||||
P::Api: ParachainHost<Block> + BlockBuilder<Block> + AuthoritiesApi<Block>,
|
||||
N: Network + Send + Sync + 'static,
|
||||
N::TableRouter: Send + 'static,
|
||||
<N::BuildTableRouter as IntoFuture>::Future: Send + 'static,
|
||||
SC: SelectChain<Block> + 'static,
|
||||
{
|
||||
const TIMER_DELAY: Duration = Duration::from_secs(5);
|
||||
const TIMER_INTERVAL: Duration = Duration::from_secs(30);
|
||||
@@ -159,14 +162,14 @@ pub(crate) fn start<C, N, P>(
|
||||
};
|
||||
|
||||
let prune_old_sessions = {
|
||||
let client = client.clone();
|
||||
let select_chain = select_chain.clone();
|
||||
let interval = Interval::new(
|
||||
Instant::now() + TIMER_DELAY,
|
||||
TIMER_INTERVAL,
|
||||
);
|
||||
|
||||
interval
|
||||
.for_each(move |_| match client.leaves() {
|
||||
.for_each(move |_| match select_chain.leaves() {
|
||||
Ok(leaves) => {
|
||||
parachain_validation.retain(|h| leaves.contains(h));
|
||||
Ok(())
|
||||
|
||||
@@ -70,10 +70,11 @@ use std::sync::Arc;
|
||||
use std::time::{self, Duration, Instant};
|
||||
|
||||
use aura::SlotDuration;
|
||||
use client::{BlockchainEvents, ChainHead, BlockBody};
|
||||
use client::{BlockchainEvents, BlockBody};
|
||||
use client::blockchain::HeaderBackend;
|
||||
use client::block_builder::api::BlockBuilder as BlockBuilderApi;
|
||||
use codec::Encode;
|
||||
use consensus::SelectChain;
|
||||
use extrinsic_store::Store as ExtrinsicStore;
|
||||
use parking_lot::Mutex;
|
||||
use polkadot_primitives::{Hash, Block, BlockId, BlockNumber, Header, SessionKey};
|
||||
@@ -456,28 +457,31 @@ struct AttestationTracker {
|
||||
}
|
||||
|
||||
/// Polkadot proposer factory.
|
||||
pub struct ProposerFactory<C, N, P, TxApi: PoolChainApi> {
|
||||
pub struct ProposerFactory<C, N, P, SC, TxApi: PoolChainApi> {
|
||||
parachain_validation: Arc<ParachainValidation<C, N, P>>,
|
||||
transaction_pool: Arc<Pool<TxApi>>,
|
||||
key: Arc<ed25519::Pair>,
|
||||
_service_handle: ServiceHandle,
|
||||
aura_slot_duration: SlotDuration,
|
||||
select_chain: SC,
|
||||
}
|
||||
|
||||
impl<C, N, P, TxApi> ProposerFactory<C, N, P, TxApi> where
|
||||
impl<C, N, P, SC, TxApi> ProposerFactory<C, N, P, SC, TxApi> where
|
||||
C: Collators + Send + Sync + 'static,
|
||||
<C::Collation as IntoFuture>::Future: Send + 'static,
|
||||
P: BlockchainEvents<Block> + ChainHead<Block> + BlockBody<Block>,
|
||||
P: BlockchainEvents<Block> + BlockBody<Block>,
|
||||
P: ProvideRuntimeApi + HeaderBackend<Block> + Send + Sync + 'static,
|
||||
P::Api: ParachainHost<Block> + BlockBuilderApi<Block> + AuthoritiesApi<Block>,
|
||||
N: Network + Send + Sync + 'static,
|
||||
N::TableRouter: Send + 'static,
|
||||
<N::BuildTableRouter as IntoFuture>::Future: Send + 'static,
|
||||
TxApi: PoolChainApi,
|
||||
SC: SelectChain<Block> + 'static,
|
||||
{
|
||||
/// Create a new proposer factory.
|
||||
pub fn new(
|
||||
client: Arc<P>,
|
||||
select_chain: SC,
|
||||
network: N,
|
||||
collators: C,
|
||||
transaction_pool: Arc<Pool<TxApi>>,
|
||||
@@ -497,6 +501,7 @@ impl<C, N, P, TxApi> ProposerFactory<C, N, P, TxApi> where
|
||||
|
||||
let service_handle = ::attestation_service::start(
|
||||
client,
|
||||
select_chain.clone(),
|
||||
parachain_validation.clone(),
|
||||
thread_pool,
|
||||
key.clone(),
|
||||
@@ -509,11 +514,12 @@ impl<C, N, P, TxApi> ProposerFactory<C, N, P, TxApi> where
|
||||
key,
|
||||
_service_handle: service_handle,
|
||||
aura_slot_duration,
|
||||
select_chain
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<C, N, P, TxApi> consensus::Environment<Block> for ProposerFactory<C, N, P, TxApi> where
|
||||
impl<C, N, P, SC, TxApi> consensus::Environment<Block> for ProposerFactory<C, N, P, SC, TxApi> where
|
||||
C: Collators + Send + 'static,
|
||||
N: Network,
|
||||
TxApi: PoolChainApi<Block=Block>,
|
||||
@@ -522,6 +528,7 @@ impl<C, N, P, TxApi> consensus::Environment<Block> for ProposerFactory<C, N, P,
|
||||
<C::Collation as IntoFuture>::Future: Send + 'static,
|
||||
N::TableRouter: Send + 'static,
|
||||
<N::BuildTableRouter as IntoFuture>::Future: Send + 'static,
|
||||
SC: SelectChain<Block>,
|
||||
{
|
||||
type Proposer = Proposer<P, TxApi>;
|
||||
type Error = Error;
|
||||
|
||||
Reference in New Issue
Block a user