mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 00:01:09 +00:00
Consensus Engines Implementation: Aura (#911)
* Generalize BlockImport - move ImportBlock, BlockOrigin, ImportResult into shared sr-primitives - let Consensus provide and traits again - update consensus traits to latest development - implement traits on client::Client, test_client::TestClient - update RHD to use the new import_block API * Move ImportBlock into consensus-common * Send import notification in aura tests * Integrating aura into service * Make Signatures more generic * Aura Block Production with the given key * run aura on the thread pool * start at exact step start in aura * Add needed wasm blob, in leiu of better solutions. * Make API ids consistent with traits and bring upstream for sharing. * Add decrease_free_balance to Balances module * Encode `Metadata` once instead of two times * Bitops include xor * Upgrade key module. * Default pages to somewhat bigger. * Introduce upgrade key into node * Add `Created` event
This commit is contained in:
committed by
GitHub
parent
c0f7021427
commit
50adea6220
@@ -29,6 +29,7 @@ extern crate parking_lot;
|
||||
extern crate substrate_keystore as keystore;
|
||||
extern crate substrate_primitives as primitives;
|
||||
extern crate sr_primitives as runtime_primitives;
|
||||
extern crate substrate_consensus_common as consensus_common;
|
||||
extern crate substrate_network as network;
|
||||
extern crate substrate_executor;
|
||||
extern crate substrate_client as client;
|
||||
@@ -56,6 +57,7 @@ mod error;
|
||||
mod chain_spec;
|
||||
pub mod config;
|
||||
pub mod chain_ops;
|
||||
pub mod consensus;
|
||||
|
||||
use std::io;
|
||||
use std::net::SocketAddr;
|
||||
@@ -63,7 +65,7 @@ use std::collections::HashMap;
|
||||
#[doc(hidden)]
|
||||
pub use std::{ops::Deref, result::Result, sync::Arc};
|
||||
use futures::prelude::*;
|
||||
use parking_lot::Mutex;
|
||||
use parking_lot::{Mutex, RwLock};
|
||||
use keystore::Store as Keystore;
|
||||
use client::BlockchainEvents;
|
||||
use runtime_primitives::traits::{Header, As};
|
||||
@@ -80,6 +82,8 @@ pub use chain_spec::ChainSpec;
|
||||
pub use transaction_pool::txpool::{self, Pool as TransactionPool, Options as TransactionPoolOptions, ChainApi, IntoPoolError};
|
||||
pub use client::ExecutionStrategy;
|
||||
|
||||
use consensus_common::offline_tracker::OfflineTracker;
|
||||
pub use consensus::ProposerFactory;
|
||||
pub use components::{ServiceFactory, FullBackend, FullExecutor, LightBackend,
|
||||
LightExecutor, Components, PoolApi, ComponentClient,
|
||||
ComponentBlock, FullClient, LightClient, FullComponents, LightComponents,
|
||||
@@ -98,6 +102,7 @@ pub struct Service<Components: components::Components> {
|
||||
keystore: Keystore,
|
||||
exit: ::exit_future::Exit,
|
||||
signal: Option<Signal>,
|
||||
proposer: Arc<ProposerFactory<ComponentClient<Components>, Components::TransactionPoolApi>>,
|
||||
_rpc_http: Option<rpc::HttpServer>,
|
||||
_rpc_ws: Option<Mutex<rpc::WsServer>>, // WsServer is not `Sync`, but the service needs to be.
|
||||
_telemetry: Option<tel::Telemetry>,
|
||||
@@ -118,6 +123,7 @@ pub fn new_client<Factory: components::ServiceFactory>(config: &FactoryFullConfi
|
||||
impl<Components> Service<Components>
|
||||
where
|
||||
Components: components::Components,
|
||||
<Components as components::Components>::Executor: std::clone::Clone,
|
||||
txpool::ExHash<Components::TransactionPoolApi>: serde::de::DeserializeOwned + serde::Serialize,
|
||||
txpool::ExtrinsicFor<Components::TransactionPoolApi>: serde::de::DeserializeOwned + serde::Serialize,
|
||||
{
|
||||
@@ -254,6 +260,13 @@ impl<Components> Service<Components>
|
||||
)
|
||||
};
|
||||
|
||||
let proposer = Arc::new(ProposerFactory {
|
||||
client: client.clone(),
|
||||
transaction_pool: transaction_pool.clone(),
|
||||
offline: Arc::new(RwLock::new(OfflineTracker::new())),
|
||||
force_delay: 0 // FIXME: allow this to be configured
|
||||
});
|
||||
|
||||
// Telemetry
|
||||
let telemetry = match config.telemetry_url {
|
||||
Some(url) => {
|
||||
@@ -287,6 +300,7 @@ impl<Components> Service<Components>
|
||||
transaction_pool: transaction_pool,
|
||||
signal: Some(signal),
|
||||
keystore: keystore,
|
||||
proposer,
|
||||
exit,
|
||||
_rpc_http: rpc_http,
|
||||
_rpc_ws: rpc_ws.map(Mutex::new),
|
||||
@@ -303,6 +317,13 @@ impl<Components> Service<Components> where
|
||||
self.client.clone()
|
||||
}
|
||||
|
||||
/// Get shared proposer instance
|
||||
pub fn proposer(&self)
|
||||
-> Arc<ProposerFactory<ComponentClient<Components>, Components::TransactionPoolApi>>
|
||||
{
|
||||
self.proposer.clone()
|
||||
}
|
||||
|
||||
/// Get shared network instance.
|
||||
pub fn network(&self) -> Arc<components::NetworkService<Components::Factory>> {
|
||||
self.network.as_ref().expect("self.network always Some").clone()
|
||||
@@ -324,6 +345,7 @@ impl<Components> Service<Components> where
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl<Components> Drop for Service<Components> where Components: components::Components {
|
||||
fn drop(&mut self) {
|
||||
debug!(target: "service", "Substrate service shutdown");
|
||||
@@ -450,7 +472,7 @@ macro_rules! construct_simple_service {
|
||||
$name: ident
|
||||
) => {
|
||||
pub struct $name<C: $crate::Components> {
|
||||
inner: $crate::Service<C>,
|
||||
inner: $crate::Arc<$crate::Service<C>>,
|
||||
}
|
||||
|
||||
impl<C: $crate::Components> $name<C> {
|
||||
@@ -460,7 +482,7 @@ macro_rules! construct_simple_service {
|
||||
) -> $crate::Result<Self, $crate::Error> {
|
||||
Ok(
|
||||
Self {
|
||||
inner: $crate::Service::new(config, executor)?
|
||||
inner: $crate::Arc::new($crate::Service::new(config, executor)?)
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -525,8 +547,9 @@ macro_rules! construct_service_factory {
|
||||
Configuration = $config:ty,
|
||||
FullService = $full_service:ty { $( $full_service_init:tt )* },
|
||||
LightService = $light_service:ty { $( $light_service_init:tt )* },
|
||||
ImportQueue = $import_queue:ty
|
||||
{ $( $full_import_queue_init:tt )* }
|
||||
FullImportQueue = $full_import_queue:ty
|
||||
{ $( $full_import_queue_init:tt )* },
|
||||
LightImportQueue = $light_import_queue:ty
|
||||
{ $( $light_import_queue_init:tt )* },
|
||||
}
|
||||
) => {
|
||||
@@ -544,7 +567,8 @@ macro_rules! construct_service_factory {
|
||||
type Configuration = $config;
|
||||
type FullService = $full_service;
|
||||
type LightService = $light_service;
|
||||
type ImportQueue = $import_queue;
|
||||
type FullImportQueue = $full_import_queue;
|
||||
type LightImportQueue = $light_import_queue;
|
||||
|
||||
fn build_full_transaction_pool(
|
||||
config: $crate::TransactionPoolOptions,
|
||||
@@ -571,14 +595,14 @@ macro_rules! construct_service_factory {
|
||||
fn build_full_import_queue(
|
||||
config: &$crate::FactoryFullConfiguration<Self>,
|
||||
client: $crate::Arc<$crate::FullClient<Self>>,
|
||||
) -> $crate::Result<Self::ImportQueue, $crate::Error> {
|
||||
) -> $crate::Result<Self::FullImportQueue, $crate::Error> {
|
||||
( $( $full_import_queue_init )* ) (config, client)
|
||||
}
|
||||
|
||||
fn build_light_import_queue(
|
||||
config: &FactoryFullConfiguration<Self>,
|
||||
client: Arc<$crate::LightClient<Self>>,
|
||||
) -> Result<Self::ImportQueue, $crate::Error> {
|
||||
) -> Result<Self::LightImportQueue, $crate::Error> {
|
||||
( $( $light_import_queue_init )* ) (config, client)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user