Follow-up on #1068 (#1567)

* BestParaHead small changes

Signed-off-by: Serban Iorga <serban@parity.io>

* Renamings

Signed-off-by: Serban Iorga <serban@parity.io>

* Use ParaInfo in parachains loop

Signed-off-by: Serban Iorga <serban@parity.io>

* Define StorageMapKeyProvider

Signed-off-by: Serban Iorga <serban@parity.io>

* CR fixes

Signed-off-by: Serban Iorga <serban@parity.io>
This commit is contained in:
Serban Iorga
2022-09-05 13:13:31 +03:00
committed by Bastian Köcher
parent 1c94fbeafc
commit ad38cdb873
6 changed files with 190 additions and 113 deletions
@@ -24,9 +24,7 @@ use crate::{
};
use async_trait::async_trait;
use bp_parachains::{
best_parachain_head_hash_storage_key_at_target, BestParaHeadHash, ImportedParaHeadsKeyProvider,
};
use bp_parachains::{BestParaHeadHash, ImportedParaHeadsKeyProvider, ParasInfoKeyProvider};
use bp_polkadot_core::parachains::{ParaHash, ParaHeadsProof, ParaId};
use bp_runtime::HeaderIdProvider;
use codec::Decode;
@@ -122,12 +120,16 @@ where
metrics: Option<&ParachainsLoopMetrics>,
para_id: ParaId,
) -> Result<Option<BestParaHeadHash>, Self::Error> {
let best_para_head_hash_key = best_parachain_head_hash_storage_key_at_target(
P::SourceRelayChain::PARACHAINS_FINALITY_PALLET_NAME,
para_id,
);
let best_para_head_hash: Option<BestParaHeadHash> =
self.client.storage_value(best_para_head_hash_key, Some(at_block.1)).await?;
let best_para_head_hash: Option<BestParaHeadHash> = self
.client
.storage_map_value::<ParasInfoKeyProvider>(
P::SourceRelayChain::PARACHAINS_FINALITY_PALLET_NAME,
&para_id,
Some(at_block.1),
)
.await?
.map(|para_info| para_info.best_head_hash);
if let (Some(metrics), &Some(ref best_para_head_hash)) = (metrics, &best_para_head_hash) {
let imported_para_head = self
.client