Aura improvements (#8881)

* Aura: Expose function to build the verifier

* Use best block to initialize the authorities cache

* Use best block when determining the slot duration

* Remove `AuraBlockImport`

* Some cleanups

* Fix build error
This commit is contained in:
Bastian Köcher
2021-05-22 23:01:11 +02:00
committed by GitHub
parent 00328dca24
commit 4dc8f3a7e5
6 changed files with 99 additions and 152 deletions
+9 -8
View File
@@ -584,7 +584,7 @@ impl<T: Clone + Send + Sync + 'static> SlotDuration<T> {
/// `slot_key` is marked as `'static`, as it should really be a
/// compile-time constant.
pub fn get_or_compute<B: BlockT, C, CB>(client: &C, cb: CB) -> sp_blockchain::Result<Self> where
C: sc_client_api::backend::AuxStore,
C: sc_client_api::backend::AuxStore + sc_client_api::UsageProvider<B>,
C: ProvideRuntimeApi<B>,
CB: FnOnce(ApiRef<C::Api>, &BlockId<B>) -> sp_blockchain::Result<T>,
T: SlotData + Encode + Decode + Debug,
@@ -599,19 +599,20 @@ impl<T: Clone + Send + Sync + 'static> SlotDuration<T> {
})
}),
None => {
use sp_runtime::traits::Zero;
let genesis_slot_duration =
cb(client.runtime_api(), &BlockId::number(Zero::zero()))?;
let best_hash = client.usage_info().chain.best_hash;
let slot_duration =
cb(client.runtime_api(), &BlockId::hash(best_hash))?;
info!(
"⏱ Loaded block-time = {:?} from genesis on first-launch",
genesis_slot_duration.slot_duration()
"⏱ Loaded block-time = {:?} from block {:?}",
slot_duration.slot_duration(),
best_hash,
);
genesis_slot_duration
slot_duration
.using_encoded(|s| client.insert_aux(&[(T::SLOT_KEY, &s[..])], &[]))?;
Ok(SlotDuration(genesis_slot_duration))
Ok(SlotDuration(slot_duration))
}
}?;