lookahead collator: read allowed ancestry len from relay client (#1180)

* Read allowed ancestry len from active config

* extract load_abridged_host_configuration

---------

Co-authored-by: Javier Viola <javier@parity.io>
This commit is contained in:
Chris Sosnin
2023-09-08 19:05:01 +03:00
committed by GitHub
parent bd0678a7e7
commit 60d1a0bdc3
2 changed files with 43 additions and 13 deletions
+17 -2
View File
@@ -20,8 +20,8 @@ use polkadot_primitives::{
};
use cumulus_primitives_core::{
relay_chain::{BlockId as RBlockId, OccupiedCoreAssumption},
ParaId,
relay_chain::{self, BlockId as RBlockId, OccupiedCoreAssumption},
AbridgedHostConfiguration, ParaId,
};
use cumulus_relay_chain_interface::{RelayChainError, RelayChainInterface};
@@ -412,3 +412,18 @@ pub fn relay_slot_and_timestamp(
})
.ok()
}
/// Reads abridged host configuration from the relay chain storage at the given relay parent.
pub async fn load_abridged_host_configuration(
relay_parent: PHash,
relay_client: &impl RelayChainInterface,
) -> Result<Option<AbridgedHostConfiguration>, RelayChainError> {
relay_client
.get_storage_by_key(relay_parent, relay_chain::well_known_keys::ACTIVE_CONFIG)
.await?
.map(|bytes| {
AbridgedHostConfiguration::decode(&mut &bytes[..])
.map_err(RelayChainError::DeserializationError)
})
.transpose()
}