parachain-template: Simplify it (#3801)

Also while doing this, move slot duration fetching into the AURA code.
This commit is contained in:
Bastian Köcher
2024-04-09 11:43:42 +02:00
committed by GitHub
parent 9d6c0f446a
commit 22b95a8a55
6 changed files with 125 additions and 165 deletions
@@ -42,7 +42,7 @@ use sp_api::{CallApiAt, ProvideRuntimeApi};
use sp_application_crypto::AppPublic;
use sp_blockchain::HeaderBackend;
use sp_consensus::SyncOracle;
use sp_consensus_aura::{AuraApi, SlotDuration};
use sp_consensus_aura::AuraApi;
use sp_core::crypto::Pair;
use sp_inherents::CreateInherentDataProviders;
use sp_keystore::KeystorePtr;
@@ -74,8 +74,6 @@ pub struct Params<BI, CIDP, Client, RClient, SO, Proposer, CS> {
pub para_id: ParaId,
/// A handle to the relay-chain client's "Overseer" or task orchestrator.
pub overseer_handle: OverseerHandle,
/// The length of slots in this chain.
pub slot_duration: SlotDuration,
/// The length of slots in the relay chain.
pub relay_chain_slot_duration: Duration,
/// The underlying block proposer this should call into.
@@ -197,11 +195,16 @@ where
Ok(Some(h)) => h,
};
let slot_duration = match params.para_client.runtime_api().slot_duration(parent_hash) {
Ok(d) => d,
Err(e) => reject_with_error!(e),
};
let claim = match collator_util::claim_slot::<_, _, P>(
&*params.para_client,
parent_hash,
&relay_parent_header,
params.slot_duration,
slot_duration,
params.relay_chain_slot_duration,
&params.keystore,
)