mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 04:11:07 +00:00
Support authoring for multiple runtime versions (#816)
This commit is contained in:
committed by
Gav Wood
parent
5eb1aefde6
commit
29c9719568
@@ -20,7 +20,7 @@ use runtime_primitives::generic::BlockId;
|
||||
use runtime_primitives::traits::Block as BlockT;
|
||||
use state_machine::{self, OverlayedChanges, Ext,
|
||||
CodeExecutor, ExecutionManager, native_when_possible};
|
||||
use executor::{RuntimeVersion, RuntimeInfo};
|
||||
use executor::{RuntimeVersion, RuntimeInfo, NativeVersion};
|
||||
use hash_db::Hasher;
|
||||
use trie::MemoryDB;
|
||||
use codec::Decode;
|
||||
@@ -89,7 +89,7 @@ where
|
||||
) -> Result<(Vec<u8>, Vec<Vec<u8>>), error::Error>;
|
||||
|
||||
/// Get runtime version if supported.
|
||||
fn native_runtime_version(&self) -> Option<RuntimeVersion>;
|
||||
fn native_runtime_version(&self) -> Option<&NativeVersion>;
|
||||
}
|
||||
|
||||
/// Call executor that executes methods locally, querying all required
|
||||
@@ -194,7 +194,7 @@ where
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
fn native_runtime_version(&self) -> Option<RuntimeVersion> {
|
||||
<E as RuntimeInfo>::NATIVE_VERSION
|
||||
fn native_runtime_version(&self) -> Option<&NativeVersion> {
|
||||
Some(self.executor.native_version())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -905,8 +905,8 @@ impl<B, E, Block> bft::Authorities<Block> for Client<B, E, Block>
|
||||
let native_version: Result<_, bft::Error> = self.executor.native_runtime_version()
|
||||
.ok_or_else(|| bft::ErrorKind::NativeRuntimeMissing.into());
|
||||
let native_version = native_version?;
|
||||
if !on_chain_version.can_author_with(&native_version) {
|
||||
return Err(bft::ErrorKind::IncompatibleAuthoringRuntime(on_chain_version, native_version).into())
|
||||
if !native_version.can_author_with(&on_chain_version) {
|
||||
return Err(bft::ErrorKind::IncompatibleAuthoringRuntime(on_chain_version, native_version.runtime_version.clone()).into())
|
||||
}
|
||||
self.authorities_at(at).map_err(|_| {
|
||||
let descriptor = format!("{:?}", at);
|
||||
|
||||
@@ -52,7 +52,7 @@ mod tests {
|
||||
use test_client::runtime::{Hash, Transfer, Block, BlockNumber, Header, Digest, Extrinsic};
|
||||
use primitives::{Blake2Hasher, ed25519::{Public, Pair}};
|
||||
|
||||
native_executor_instance!(Executor, test_client::runtime::api::dispatch, test_client::runtime::VERSION, include_bytes!("../../test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.compact.wasm"));
|
||||
native_executor_instance!(Executor, test_client::runtime::api::dispatch, test_client::runtime::native_version, include_bytes!("../../test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.compact.wasm"));
|
||||
|
||||
fn executor() -> ::executor::NativeExecutor<Executor> {
|
||||
NativeExecutionDispatch::new()
|
||||
|
||||
@@ -31,7 +31,7 @@ use blockchain::Backend as ChainBackend;
|
||||
use call_executor::{CallExecutor, CallResult};
|
||||
use error::{Error as ClientError, ErrorKind as ClientErrorKind, Result as ClientResult};
|
||||
use light::fetcher::{Fetcher, RemoteCallRequest};
|
||||
use executor::RuntimeVersion;
|
||||
use executor::{RuntimeVersion, NativeVersion};
|
||||
use codec::Decode;
|
||||
use heapsize::HeapSizeOf;
|
||||
use trie::MemoryDB;
|
||||
@@ -118,7 +118,7 @@ where
|
||||
Err(ClientErrorKind::NotAvailableOnLightClient.into())
|
||||
}
|
||||
|
||||
fn native_runtime_version(&self) -> Option<RuntimeVersion> {
|
||||
fn native_runtime_version(&self) -> Option<&NativeVersion> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user