Fix checking for the ParachainHost runtime api (#4594)

The function `has_api` checks that the api + version matches, which
isn't true anymore after bumping the version. The fix is to just compare
the runtime api version being at least `1`.
This commit is contained in:
Bastian Köcher
2021-12-23 20:27:03 +01:00
committed by GitHub
parent 97506a15c9
commit b409837b70
+7 -1
View File
@@ -130,7 +130,13 @@ where
{
fn head_supports_parachains(&self, head: &Hash) -> bool {
let id = BlockId::Hash(*head);
self.runtime_api().has_api::<dyn ParachainHost<Block>>(&id).unwrap_or(false)
// Check that the `ParachainHost` runtime api is at least with version 1 present on chain.
self.runtime_api()
.api_version::<dyn ParachainHost<Block>>(&id)
.ok()
.flatten()
.unwrap_or(0) >=
1
}
}