mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 22:47:56 +00:00
Rewrite Inherent data (#1488)
* Implement new inherent data * Fixes compilation on wasm * Fixes after rebase * Switch back to generate inherent stuff by macro * Update after rebase * Apply suggestions from code review Co-Authored-By: bkchr <bkchr@users.noreply.github.com> * Fix compilation after rebase * Address grumbles * Remove `InherentDataProviders` from `Client` * Update wasm files after rebase * Address grumbles * Fixes compilation after latest merge * Last fix
This commit is contained in:
@@ -318,6 +318,6 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_connectivity() {
|
||||
service_test::connectivity::<Factory, node_primitives::InherentData>(integration_test_config());
|
||||
service_test::connectivity::<Factory>(integration_test_config());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ extern crate node_primitives;
|
||||
extern crate substrate_service;
|
||||
extern crate node_executor;
|
||||
extern crate substrate_keystore;
|
||||
extern crate substrate_inherents as inherents;
|
||||
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
|
||||
@@ -26,13 +26,14 @@ use consensus::{import_queue, start_aura, AuraImportQueue, SlotDuration, Nothing
|
||||
use grandpa;
|
||||
use node_executor;
|
||||
use primitives::ed25519::Pair;
|
||||
use node_primitives::{Block, InherentData};
|
||||
use node_primitives::Block;
|
||||
use node_runtime::{GenesisConfig, RuntimeApi};
|
||||
use substrate_service::{
|
||||
FactoryFullConfiguration, LightComponents, FullComponents, FullBackend,
|
||||
FullClient, LightClient, LightBackend, FullExecutor, LightExecutor, TaskExecutor
|
||||
FullClient, LightClient, LightBackend, FullExecutor, LightExecutor, TaskExecutor,
|
||||
};
|
||||
use transaction_pool::{self, txpool::{Pool as TransactionPool}};
|
||||
use inherents::InherentDataProviders;
|
||||
|
||||
construct_simple_protocol! {
|
||||
/// Demo protocol attachment for substrate.
|
||||
@@ -45,12 +46,14 @@ pub struct NodeConfig<F: substrate_service::ServiceFactory> {
|
||||
// FIXME: rather than putting this on the config, let's have an actual intermediate setup state
|
||||
// https://github.com/paritytech/substrate/issues/1134
|
||||
pub grandpa_import_setup: Option<(Arc<grandpa::BlockImportForService<F>>, grandpa::LinkHalfForService<F>)>,
|
||||
inherent_data_providers: InherentDataProviders,
|
||||
}
|
||||
|
||||
impl<F> Default for NodeConfig<F> where F: substrate_service::ServiceFactory {
|
||||
fn default() -> NodeConfig<F> {
|
||||
NodeConfig {
|
||||
grandpa_import_setup: None,
|
||||
inherent_data_providers: InherentDataProviders::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -91,7 +94,8 @@ construct_service_factory! {
|
||||
proposer,
|
||||
service.network(),
|
||||
service.on_exit(),
|
||||
));
|
||||
service.config.custom.inherent_data_providers.clone(),
|
||||
)?);
|
||||
|
||||
info!("Running Grandpa session as Authority {}", key.public());
|
||||
}
|
||||
@@ -99,7 +103,8 @@ construct_service_factory! {
|
||||
executor.spawn(grandpa::run_grandpa(
|
||||
grandpa::Config {
|
||||
local_key,
|
||||
gossip_duration: Duration::new(4, 0), // FIXME: make this available through chainspec?
|
||||
// FIXME: make this available through chainspec?
|
||||
gossip_duration: Duration::new(4, 0),
|
||||
justification_period: 4096,
|
||||
name: Some(service.config.name.clone())
|
||||
},
|
||||
@@ -117,35 +122,38 @@ construct_service_factory! {
|
||||
Self::Block,
|
||||
grandpa::BlockImportForService<Self>,
|
||||
NothingExtra,
|
||||
::consensus::InherentProducingFn<InherentData>,
|
||||
>
|
||||
{ |config: &mut FactoryFullConfiguration<Self> , client: Arc<FullClient<Self>>| {
|
||||
let slot_duration = SlotDuration::get_or_compute(&*client)?;
|
||||
let (block_import, link_half) = grandpa::block_import::<_, _, _, RuntimeApi, FullClient<Self>>(client.clone(), client)?;
|
||||
|
||||
let (block_import, link_half) =
|
||||
grandpa::block_import::<_, _, _, RuntimeApi, FullClient<Self>>(
|
||||
client.clone(), client
|
||||
)?;
|
||||
let block_import = Arc::new(block_import);
|
||||
|
||||
config.custom.grandpa_import_setup = Some((block_import.clone(), link_half));
|
||||
|
||||
Ok(import_queue(
|
||||
import_queue(
|
||||
slot_duration,
|
||||
block_import,
|
||||
NothingExtra,
|
||||
::consensus::make_basic_inherent as _,
|
||||
))
|
||||
config.custom.inherent_data_providers.clone(),
|
||||
).map_err(Into::into)
|
||||
}},
|
||||
LightImportQueue = AuraImportQueue<
|
||||
Self::Block,
|
||||
LightClient<Self>,
|
||||
NothingExtra,
|
||||
::consensus::InherentProducingFn<InherentData>,
|
||||
>
|
||||
{ |ref mut config, client: Arc<LightClient<Self>>|
|
||||
Ok(import_queue(
|
||||
SlotDuration::get_or_compute(&*client)?,
|
||||
client,
|
||||
NothingExtra,
|
||||
::consensus::make_basic_inherent as _,
|
||||
))
|
||||
{ |config: &FactoryFullConfiguration<Self>, client: Arc<LightClient<Self>>| {
|
||||
import_queue(
|
||||
SlotDuration::get_or_compute(&*client)?,
|
||||
client,
|
||||
NothingExtra,
|
||||
config.custom.inherent_data_providers.clone(),
|
||||
).map_err(Into::into)
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user