Move registration of ReadRuntimeVersionExt to ExecutionExtension (#13820)

Instead of registering `ReadRuntimeVersionExt` in `sp-state-machine` it is moved to
`ExecutionExtension` which provides the default extensions.
This commit is contained in:
Bastian Köcher
2023-04-05 14:27:26 +02:00
committed by GitHub
parent d3f5c70dde
commit 495773f96d
14 changed files with 40 additions and 27 deletions
@@ -133,7 +133,7 @@ where
&executor,
"TryRuntime_execute_block",
&payload,
full_extensions(),
full_extensions(executor.clone()),
shared.export_proof,
)?;
@@ -103,7 +103,7 @@ async fn dry_run<T: Decode, Block: BlockT, HostFns: HostFunctions>(
executor,
method,
data,
full_extensions(),
full_extensions(executor.clone()),
)?;
Ok(<T>::decode(&mut &*result)?)
@@ -121,7 +121,7 @@ async fn run<Block: BlockT, HostFns: HostFunctions>(
executor,
method,
data,
full_extensions(),
full_extensions(executor.clone()),
)?;
let storage_changes = changes.drain_storage_changes(
@@ -149,7 +149,7 @@ where
&executor,
"TryRuntime_execute_block",
(block, command.state_root_check, command.try_state.clone()).encode().as_ref(),
full_extensions(),
full_extensions(executor.clone()),
shared
.export_proof
.as_ref()
@@ -97,7 +97,7 @@ where
&executor,
"OffchainWorkerApi_offchain_worker",
&payload,
full_extensions(),
full_extensions(executor.clone()),
)?;
Ok(())
@@ -377,7 +377,7 @@ use sp_core::{
OffchainDbExt, OffchainWorkerExt, TransactionPoolExt,
},
storage::well_known_keys,
traits::{CallContext, ReadRuntimeVersion},
traits::{CallContext, ReadRuntimeVersion, ReadRuntimeVersionExt},
twox_128, H256,
};
use sp_externalities::Extensions;
@@ -810,7 +810,7 @@ where
}
/// Build all extensions that we typically use.
pub(crate) fn full_extensions() -> Extensions {
pub(crate) fn full_extensions<H: HostFunctions>(wasm_executor: WasmExecutor<H>) -> Extensions {
let mut extensions = Extensions::default();
let (offchain, _offchain_state) = TestOffchainExt::new();
let (pool, _pool_state) = TestTransactionPoolExt::new();
@@ -819,6 +819,7 @@ pub(crate) fn full_extensions() -> Extensions {
extensions.register(OffchainWorkerExt::new(offchain));
extensions.register(KeystoreExt::new(keystore));
extensions.register(TransactionPoolExt::new(pool));
extensions.register(ReadRuntimeVersionExt::new(wasm_executor));
extensions
}