Check in block authoring that we can author with current authoring version (#4201)

* Check in block authoring that we can author with current authoring version

* Update client/consensus/pow/src/lib.rs

Co-Authored-By: André Silva <andre.beat@gmail.com>

* Fix compilation
This commit is contained in:
Bastian Köcher
2019-11-29 11:01:11 +01:00
committed by GitHub
parent 0b52f194f5
commit accc678640
18 changed files with 187 additions and 62 deletions
+23 -5
View File
@@ -63,10 +63,10 @@ impl<B, E> Clone for LocalCallExecutor<B, E> where E: Clone {
}
impl<B, E, Block> CallExecutor<Block, Blake2Hasher> for LocalCallExecutor<B, E>
where
B: backend::Backend<Block, Blake2Hasher>,
E: CodeExecutor + RuntimeInfo,
Block: BlockT<Hash=H256>,
where
B: backend::Backend<Block, Blake2Hasher>,
E: CodeExecutor + RuntimeInfo,
Block: BlockT<Hash=H256>,
{
type Error = E::Error;
@@ -202,7 +202,7 @@ where
let _lock = self.backend.get_import_lock().read();
self.backend.destroy_state(state)?;
}
version.ok_or(sp_blockchain::Error::VersionInvalid.into())
version.map_err(|e| sp_blockchain::Error::VersionInvalid(format!("{:?}", e)).into())
}
fn call_at_state<
@@ -268,3 +268,21 @@ where
Some(self.executor.native_version())
}
}
impl<B, E, Block> runtime_version::GetRuntimeVersion<Block> for LocalCallExecutor<B, E>
where
B: backend::Backend<Block, Blake2Hasher>,
E: CodeExecutor + RuntimeInfo,
Block: BlockT<Hash=H256>,
{
fn native_version(&self) -> &runtime_version::NativeVersion {
self.executor.native_version()
}
fn runtime_version(
&self,
at: &BlockId<Block>,
) -> Result<runtime_version::RuntimeVersion, String> {
CallExecutor::runtime_version(self, at).map_err(|e| format!("{:?}", e))
}
}