mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-06 11:28:02 +00:00
a10e86ba5a
* Add `start_aura2`. * .gitignore patch conflict files and remove one that accidentally got committed * Fix build The tests still don’t work. * Fix compilation errors * Fix compile errors (again) * Try (and fail) to fix tests * Properly deserialize data Previously, `DigestItem::Consensus` had no separate `DigestItemType`, so it did not get properly serialized and deserialized. * Add extra debug logging. Always allow old seals. A `RUST_LOG=substrate_aura_consensus cargo test --all -- --nocapture \ tests::authoring_blocks` revealed that old seals were being and rejected, causing the test to hang. As a temporary debug measure, allow old seals unconditionally, so that CI can test if this fixes the problem. * Forcibly disable rejection of old seals * Use old trait, but newer serialization The old trait for `CompatibleDigestItem` actually worked. By changing its implementation, one can ensure that all *new* seals have the modern form, but *legacy* seals are still decoded correctly. * Bump impl version * Squash spurious deprecation warning `rustc` should not be emitting a deprecation warning in deprecated code, but it does, so silence it. * Rip out unused Cargo feature * Move AURA to aura_primitives * Respond to code review * Wrap overly-long line * Reduce logging verbosity and add target * Add dependency on `sr-primitives` to `aura_primitives` * Fix build It failed with a message about Cargo.lock being out of date. * core: aura: rename aura engine id const * core: aura: remove superfluous logging * core: primitives: add removed semicolons * core: aura: remove unused import * core: network: style fix * runtime: update wasm blobs * runtime: bump impl_version * core: primitives: tag all DigestItemType variants explicitly
116 lines
3.8 KiB
Rust
116 lines
3.8 KiB
Rust
//! Service and ServiceFactory implementation. Specialized wrapper over Substrate service.
|
|
|
|
#![warn(unused_extern_crates)]
|
|
|
|
use std::sync::Arc;
|
|
use log::info;
|
|
use transaction_pool::{self, txpool::{Pool as TransactionPool}};
|
|
use node_template_runtime::{self, GenesisConfig, opaque::Block, RuntimeApi};
|
|
use substrate_service::{
|
|
FactoryFullConfiguration, LightComponents, FullComponents, FullBackend,
|
|
FullClient, LightClient, LightBackend, FullExecutor, LightExecutor,
|
|
TaskExecutor,
|
|
};
|
|
use basic_authorship::ProposerFactory;
|
|
use consensus::{import_queue, start_aura, AuraImportQueue, SlotDuration, NothingExtra};
|
|
use substrate_client as client;
|
|
use primitives::{ed25519::Pair, Pair as PairT};
|
|
use inherents::InherentDataProviders;
|
|
use network::construct_simple_protocol;
|
|
use substrate_executor::native_executor_instance;
|
|
use substrate_service::construct_service_factory;
|
|
|
|
pub use substrate_executor::NativeExecutor;
|
|
// Our native executor instance.
|
|
native_executor_instance!(
|
|
pub Executor,
|
|
node_template_runtime::api::dispatch,
|
|
node_template_runtime::native_version,
|
|
include_bytes!("../runtime/wasm/target/wasm32-unknown-unknown/release/node_template_runtime_wasm.compact.wasm")
|
|
);
|
|
|
|
#[derive(Default)]
|
|
pub struct NodeConfig {
|
|
inherent_data_providers: InherentDataProviders,
|
|
}
|
|
|
|
construct_simple_protocol! {
|
|
/// Demo protocol attachment for substrate.
|
|
pub struct NodeProtocol where Block = Block { }
|
|
}
|
|
|
|
construct_service_factory! {
|
|
struct Factory {
|
|
Block = Block,
|
|
RuntimeApi = RuntimeApi,
|
|
NetworkProtocol = NodeProtocol { |config| Ok(NodeProtocol::new()) },
|
|
RuntimeDispatch = Executor,
|
|
FullTransactionPoolApi = transaction_pool::ChainApi<client::Client<FullBackend<Self>, FullExecutor<Self>, Block, RuntimeApi>, Block>
|
|
{ |config, client| Ok(TransactionPool::new(config, transaction_pool::ChainApi::new(client))) },
|
|
LightTransactionPoolApi = transaction_pool::ChainApi<client::Client<LightBackend<Self>, LightExecutor<Self>, Block, RuntimeApi>, Block>
|
|
{ |config, client| Ok(TransactionPool::new(config, transaction_pool::ChainApi::new(client))) },
|
|
Genesis = GenesisConfig,
|
|
Configuration = NodeConfig,
|
|
FullService = FullComponents<Self>
|
|
{ |config: FactoryFullConfiguration<Self>, executor: TaskExecutor|
|
|
FullComponents::<Factory>::new(config, executor)
|
|
},
|
|
AuthoritySetup = {
|
|
|service: Self::FullService, executor: TaskExecutor, key: Option<Arc<Pair>>| {
|
|
if let Some(key) = key {
|
|
info!("Using authority key {}", key.public());
|
|
let proposer = Arc::new(ProposerFactory {
|
|
client: service.client(),
|
|
transaction_pool: service.transaction_pool(),
|
|
inherents_pool: service.inherents_pool(),
|
|
});
|
|
let client = service.client();
|
|
executor.spawn(start_aura(
|
|
SlotDuration::get_or_compute(&*client)?,
|
|
key.clone(),
|
|
client.clone(),
|
|
client,
|
|
proposer,
|
|
service.network(),
|
|
service.on_exit(),
|
|
service.config.custom.inherent_data_providers.clone(),
|
|
service.config.force_authoring,
|
|
)?);
|
|
}
|
|
|
|
Ok(service)
|
|
}
|
|
},
|
|
LightService = LightComponents<Self>
|
|
{ |config, executor| <LightComponents<Factory>>::new(config, executor) },
|
|
FullImportQueue = AuraImportQueue<
|
|
Self::Block,
|
|
>
|
|
{ |config: &mut FactoryFullConfiguration<Self> , client: Arc<FullClient<Self>>|
|
|
import_queue::<_, _, _, Pair>(
|
|
SlotDuration::get_or_compute(&*client)?,
|
|
client.clone(),
|
|
None,
|
|
client,
|
|
NothingExtra,
|
|
config.custom.inherent_data_providers.clone(),
|
|
true,
|
|
).map_err(Into::into)
|
|
},
|
|
LightImportQueue = AuraImportQueue<
|
|
Self::Block,
|
|
>
|
|
{ |config: &mut FactoryFullConfiguration<Self>, client: Arc<LightClient<Self>>|
|
|
import_queue::<_, _, _, Pair>(
|
|
SlotDuration::get_or_compute(&*client)?,
|
|
client.clone(),
|
|
None,
|
|
client,
|
|
NothingExtra,
|
|
config.custom.inherent_data_providers.clone(),
|
|
true,
|
|
).map_err(Into::into)
|
|
},
|
|
}
|
|
}
|