diff --git a/simnode/src/client/parachain.rs b/simnode/src/client/parachain.rs index 75190a9..53ec453 100644 --- a/simnode/src/client/parachain.rs +++ b/simnode/src/client/parachain.rs @@ -39,15 +39,14 @@ use sc_service::{ use sc_transaction_pool::FullPool; use sc_transaction_pool_api::{OffchainTransactionPoolFactory, TransactionPool}; use simnode_runtime_api::CreateTransactionApi; -use sp_api::{ApiExt, ConstructRuntimeApi, Core}; +use sp_api::{ApiExt, ConstructRuntimeApi, Core, ProvideRuntimeApi}; use sp_block_builder::BlockBuilder; use sp_blockchain::HeaderBackend; use sp_consensus::SelectChain; -use sp_core::{crypto::AccountId32, Bytes}; +use sp_consensus_aura::AuraApi; +use sp_core::{crypto::AccountId32, traits::SpawnEssentialNamed, Bytes}; use sp_runtime::traits::{Block as BlockT, Header}; use sp_transaction_pool::runtime_api::TaggedTransactionQueue; - -use sp_core::traits::SpawnEssentialNamed; use std::sync::Arc; /// Parachain handler implementation for Simnode RPC API. @@ -213,8 +212,14 @@ where other: (block_import, mut telemetry, _), } = components; - let parachain_inherent_provider = - Arc::new(Mutex::new(ParachainSproofInherentProvider::::new(client.clone()))); + let slot_duration = client + .runtime_api() + .slot_duration(client.info().best_hash) + .map_err(|err| sc_service::Error::Application(Box::new(err)))?; + + let parachain_inherent_provider = Arc::new(Mutex::new( + ParachainSproofInherentProvider::::new(client.clone(), slot_duration.as_millis()), + )); let net_config = sc_network::config::FullNetworkConfiguration::new(&config.network); let (network, system_rpc_tx, tx_handler_controller, _network_starter, sync_service) = { diff --git a/simnode/src/sproof.rs b/simnode/src/sproof.rs index 1256aab..72ab6a3 100644 --- a/simnode/src/sproof.rs +++ b/simnode/src/sproof.rs @@ -37,6 +37,8 @@ pub struct ParachainSproofInherentProvider { client: Arc>, // sproof builder sproof_builder: Option, + // slot duration for the node + slot_duration: u64, // phantom type _phantom: PhantomData, } @@ -51,8 +53,13 @@ where <::Header as Header>::Number: AsPrimitive, { /// Construct a new sproof-er - pub fn new(client: Arc>) -> Self { - ParachainSproofInherentProvider { client, sproof_builder: None, _phantom: PhantomData } + pub fn new(client: Arc>, slot_duration: u64) -> Self { + ParachainSproofInherentProvider { + client, + slot_duration, + sproof_builder: None, + _phantom: PhantomData, + } } /// updates the sproof to a new state @@ -71,8 +78,13 @@ where sproof.para_id = with_state::(self.client.clone(), None, || { parachain_info::Pallet::::parachain_id() }); - // relay chain is twice as fast the parachain - sproof.current_slot = ((slot * 2) + 1).into(); + sproof.current_slot = if self.slot_duration == 12_000 { + // relay chain is twice as fast the parachain + ((slot * 2) + 1).into() + } else { + // async backing is enabled + slot.into() + }; sproof.host_config.validation_upgrade_delay = 2; sproof.host_config.max_code_size = 15 * 1024 * 1024; sproof.included_para_head =