mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 18:41:03 +00:00
Dual execution (#311)
* Initial logic * Remove accidental file * Config * Remove accidental * Apply CLI config * Additional work. Sadly pointless. * Rearrange everything * Loop into CLI param * Implement dual execution * typo * fix tests. * Better docs * Fix bug * Add some tests * Report block information on consensus failure, tests * Fix test
This commit is contained in:
@@ -30,7 +30,7 @@ use polkadot_api;
|
||||
use polkadot_executor::Executor as LocalDispatch;
|
||||
use polkadot_network::NetworkService;
|
||||
use polkadot_primitives::{Block, BlockId, Hash};
|
||||
use state_machine;
|
||||
use state_machine::{self, ExecutionStrategy};
|
||||
use substrate_executor::NativeExecutor;
|
||||
use transaction_pool::{self, TransactionPool};
|
||||
use tokio::runtime::TaskExecutor;
|
||||
@@ -50,7 +50,7 @@ pub trait Components {
|
||||
type Executor: 'static + client::CallExecutor<Block> + Send + Sync;
|
||||
|
||||
/// Create client.
|
||||
fn build_client(&self, settings: client_db::DatabaseSettings, executor: CodeExecutor, chain_spec: &ChainSpec)
|
||||
fn build_client(&self, settings: client_db::DatabaseSettings, executor: CodeExecutor, chain_spec: &ChainSpec, execution_strategy: ExecutionStrategy)
|
||||
-> Result<(Arc<Client<Self::Backend, Self::Executor, Block>>, Option<Arc<OnDemand<Block, NetworkService>>>), error::Error>;
|
||||
|
||||
/// Create api.
|
||||
@@ -83,9 +83,9 @@ impl Components for FullComponents {
|
||||
type Api = Client<Self::Backend, Self::Executor, Block>;
|
||||
type Executor = client::LocalCallExecutor<client_db::Backend<Block>, NativeExecutor<LocalDispatch>>;
|
||||
|
||||
fn build_client(&self, db_settings: client_db::DatabaseSettings, executor: CodeExecutor, chain_spec: &ChainSpec)
|
||||
fn build_client(&self, db_settings: client_db::DatabaseSettings, executor: CodeExecutor, chain_spec: &ChainSpec, execution_strategy: ExecutionStrategy)
|
||||
-> Result<(Arc<client::Client<Self::Backend, Self::Executor, Block>>, Option<Arc<OnDemand<Block, NetworkService>>>), error::Error> {
|
||||
Ok((Arc::new(client_db::new_client(db_settings, executor, chain_spec)?), None))
|
||||
Ok((Arc::new(client_db::new_client(db_settings, executor, chain_spec, execution_strategy)?), None))
|
||||
}
|
||||
|
||||
fn build_api(&self, client: Arc<client::Client<Self::Backend, Self::Executor, Block>>) -> Arc<Self::Api> {
|
||||
@@ -142,7 +142,7 @@ impl Components for LightComponents {
|
||||
client::light::blockchain::Blockchain<client_db::light::LightStorage<Block>, network::OnDemand<Block, NetworkService>>,
|
||||
network::OnDemand<Block, NetworkService>>;
|
||||
|
||||
fn build_client(&self, db_settings: client_db::DatabaseSettings, executor: CodeExecutor, spec: &ChainSpec)
|
||||
fn build_client(&self, db_settings: client_db::DatabaseSettings, executor: CodeExecutor, spec: &ChainSpec, _execution_strategy: ExecutionStrategy)
|
||||
-> Result<(Arc<client::Client<Self::Backend, Self::Executor, Block>>, Option<Arc<OnDemand<Block, NetworkService>>>), error::Error> {
|
||||
let db_storage = client_db::light::LightStorage::new(db_settings)?;
|
||||
let light_blockchain = client::light::new_light_blockchain(db_storage);
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
use transaction_pool;
|
||||
use chain_spec::ChainSpec;
|
||||
pub use state_machine::ExecutionStrategy;
|
||||
pub use network::Role;
|
||||
pub use network::NetworkConfiguration;
|
||||
pub use client_db::PruningMode;
|
||||
@@ -44,6 +45,8 @@ pub struct Configuration {
|
||||
pub telemetry: Option<String>,
|
||||
/// Node name.
|
||||
pub name: String,
|
||||
/// Execution strategy.
|
||||
pub execution_strategy: ExecutionStrategy,
|
||||
}
|
||||
|
||||
impl Configuration {
|
||||
@@ -60,6 +63,7 @@ impl Configuration {
|
||||
keys: Default::default(),
|
||||
telemetry: Default::default(),
|
||||
pruning: PruningMode::ArchiveAll,
|
||||
execution_strategy: ExecutionStrategy::Both,
|
||||
};
|
||||
configuration.network.boot_nodes = configuration.chain_spec.boot_nodes().to_vec();
|
||||
configuration
|
||||
|
||||
@@ -73,7 +73,7 @@ use tokio::runtime::TaskExecutor;
|
||||
|
||||
pub use self::error::{ErrorKind, Error};
|
||||
pub use self::components::{Components, FullComponents, LightComponents};
|
||||
pub use config::{Configuration, Role, PruningMode};
|
||||
pub use config::{Configuration, Role, PruningMode, ExecutionStrategy};
|
||||
pub use chain_spec::ChainSpec;
|
||||
|
||||
/// Polkadot service.
|
||||
@@ -112,7 +112,7 @@ pub fn new_client(config: Configuration) -> Result<Arc<Client<
|
||||
let executor = polkadot_executor::Executor::new();
|
||||
let is_validator = (config.roles & Role::AUTHORITY) == Role::AUTHORITY;
|
||||
let components = components::FullComponents { is_validator };
|
||||
let (client, _) = components.build_client(db_settings, executor, &config.chain_spec)?;
|
||||
let (client, _) = components.build_client(db_settings, executor, &config.chain_spec, config.execution_strategy)?;
|
||||
Ok(client)
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ impl<Components> Service<Components>
|
||||
let (signal, exit) = ::exit_future::signal();
|
||||
|
||||
// Create client
|
||||
let executor = polkadot_executor::Executor::new();
|
||||
let executor = polkadot_executor::Executor::with_heap_pages(128);
|
||||
|
||||
let mut keystore = Keystore::open(config.keystore_path.into())?;
|
||||
for seed in &config.keys {
|
||||
@@ -144,7 +144,7 @@ impl<Components> Service<Components>
|
||||
pruning: config.pruning,
|
||||
};
|
||||
|
||||
let (client, on_demand) = components.build_client(db_settings, executor, &config.chain_spec)?;
|
||||
let (client, on_demand) = components.build_client(db_settings, executor, &config.chain_spec, config.execution_strategy)?;
|
||||
let api = components.build_api(client.clone());
|
||||
let best_header = client.best_block_header()?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user