mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-21 14:25:41 +00:00
Export unified ParachainHostFunctions (#3854)
This PR exports unified hostfunctions needed for parachains. Basicaly `SubstrateHostFunctions` + `storage_proof_size::HostFunctions`. Also removes the native executor from the parachain template. --------- Co-authored-by: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com>
This commit is contained in:
Generated
+1
@@ -3803,6 +3803,7 @@ dependencies = [
|
|||||||
"sp-blockchain",
|
"sp-blockchain",
|
||||||
"sp-consensus",
|
"sp-consensus",
|
||||||
"sp-core",
|
"sp-core",
|
||||||
|
"sp-io",
|
||||||
"sp-runtime",
|
"sp-runtime",
|
||||||
"sp-transaction-pool",
|
"sp-transaction-pool",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ sp-consensus = { path = "../../../substrate/primitives/consensus/common" }
|
|||||||
sp-core = { path = "../../../substrate/primitives/core" }
|
sp-core = { path = "../../../substrate/primitives/core" }
|
||||||
sp-runtime = { path = "../../../substrate/primitives/runtime" }
|
sp-runtime = { path = "../../../substrate/primitives/runtime" }
|
||||||
sp-transaction-pool = { path = "../../../substrate/primitives/transaction-pool" }
|
sp-transaction-pool = { path = "../../../substrate/primitives/transaction-pool" }
|
||||||
|
sp-io = { path = "../../../substrate/primitives/io" }
|
||||||
|
|
||||||
# Polkadot
|
# Polkadot
|
||||||
polkadot-primitives = { path = "../../../polkadot/primitives" }
|
polkadot-primitives = { path = "../../../polkadot/primitives" }
|
||||||
|
|||||||
@@ -54,6 +54,15 @@ use std::{sync::Arc, time::Duration};
|
|||||||
|
|
||||||
pub use cumulus_primitives_proof_size_hostfunction::storage_proof_size;
|
pub use cumulus_primitives_proof_size_hostfunction::storage_proof_size;
|
||||||
|
|
||||||
|
/// Host functions that should be used in parachain nodes.
|
||||||
|
///
|
||||||
|
/// Contains the standard substrate host functions, as well as a
|
||||||
|
/// host function to enable PoV-reclaim on parachain nodes.
|
||||||
|
pub type ParachainHostFunctions = (
|
||||||
|
cumulus_primitives_proof_size_hostfunction::storage_proof_size::HostFunctions,
|
||||||
|
sp_io::SubstrateHostFunctions,
|
||||||
|
);
|
||||||
|
|
||||||
// Given the sporadic nature of the explicit recovery operation and the
|
// Given the sporadic nature of the explicit recovery operation and the
|
||||||
// possibility to retry infinite times this value is more than enough.
|
// possibility to retry infinite times this value is more than enough.
|
||||||
// In practice here we expect no more than one queued messages.
|
// In practice here we expect no more than one queued messages.
|
||||||
|
|||||||
@@ -69,13 +69,11 @@ use substrate_prometheus_endpoint::Registry;
|
|||||||
use polkadot_primitives::CollatorPair;
|
use polkadot_primitives::CollatorPair;
|
||||||
|
|
||||||
#[cfg(not(feature = "runtime-benchmarks"))]
|
#[cfg(not(feature = "runtime-benchmarks"))]
|
||||||
type HostFunctions =
|
type HostFunctions = cumulus_client_service::ParachainHostFunctions;
|
||||||
(sp_io::SubstrateHostFunctions, cumulus_client_service::storage_proof_size::HostFunctions);
|
|
||||||
|
|
||||||
#[cfg(feature = "runtime-benchmarks")]
|
#[cfg(feature = "runtime-benchmarks")]
|
||||||
type HostFunctions = (
|
type HostFunctions = (
|
||||||
sp_io::SubstrateHostFunctions,
|
cumulus_client_service::ParachainHostFunctions,
|
||||||
cumulus_client_service::storage_proof_size::HostFunctions,
|
|
||||||
frame_benchmarking::benchmarking::HostFunctions,
|
frame_benchmarking::benchmarking::HostFunctions,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0
|
||||||
|
# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json
|
||||||
|
|
||||||
|
title: Export unified `ParachainHostFunctions` from `cumulus-client-service`
|
||||||
|
|
||||||
|
doc:
|
||||||
|
- audience: Node Dev
|
||||||
|
description: |
|
||||||
|
Exports `ParachainHostFunctions` to have a bundled version of `SubstrateHostFunctions` and
|
||||||
|
`cumulus_primitives_proof_size_hostfunction::storage_proof_size::HostFunctions`. This increases discoverability and makes
|
||||||
|
it more obvious that they should be used together in parachain nodes.
|
||||||
|
|
||||||
|
crates:
|
||||||
|
- name: cumulus-client-service
|
||||||
|
bump: minor
|
||||||
@@ -16,7 +16,8 @@ use cumulus_client_consensus_common::ParachainBlockImport as TParachainBlockImpo
|
|||||||
use cumulus_client_consensus_proposer::Proposer;
|
use cumulus_client_consensus_proposer::Proposer;
|
||||||
use cumulus_client_service::{
|
use cumulus_client_service::{
|
||||||
build_network, build_relay_chain_interface, prepare_node_config, start_relay_chain_tasks,
|
build_network, build_relay_chain_interface, prepare_node_config, start_relay_chain_tasks,
|
||||||
BuildNetworkParams, CollatorSybilResistance, DARecoveryProfile, StartRelayChainTasksParams,
|
BuildNetworkParams, CollatorSybilResistance, DARecoveryProfile, ParachainHostFunctions,
|
||||||
|
StartRelayChainTasksParams,
|
||||||
};
|
};
|
||||||
use cumulus_primitives_core::{relay_chain::CollatorPair, ParaId};
|
use cumulus_primitives_core::{relay_chain::CollatorPair, ParaId};
|
||||||
use cumulus_relay_chain_interface::{OverseerHandle, RelayChainInterface};
|
use cumulus_relay_chain_interface::{OverseerHandle, RelayChainInterface};
|
||||||
@@ -25,9 +26,7 @@ use cumulus_relay_chain_interface::{OverseerHandle, RelayChainInterface};
|
|||||||
use frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE;
|
use frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE;
|
||||||
use sc_client_api::Backend;
|
use sc_client_api::Backend;
|
||||||
use sc_consensus::ImportQueue;
|
use sc_consensus::ImportQueue;
|
||||||
use sc_executor::{
|
use sc_executor::{HeapAllocStrategy, WasmExecutor, DEFAULT_HEAP_ALLOC_STRATEGY};
|
||||||
HeapAllocStrategy, NativeElseWasmExecutor, WasmExecutor, DEFAULT_HEAP_ALLOC_STRATEGY,
|
|
||||||
};
|
|
||||||
use sc_network::NetworkBlock;
|
use sc_network::NetworkBlock;
|
||||||
use sc_network_sync::SyncingService;
|
use sc_network_sync::SyncingService;
|
||||||
use sc_service::{Configuration, PartialComponents, TFullBackend, TFullClient, TaskManager};
|
use sc_service::{Configuration, PartialComponents, TFullBackend, TFullClient, TaskManager};
|
||||||
@@ -36,25 +35,7 @@ use sc_transaction_pool_api::OffchainTransactionPoolFactory;
|
|||||||
use sp_keystore::KeystorePtr;
|
use sp_keystore::KeystorePtr;
|
||||||
use substrate_prometheus_endpoint::Registry;
|
use substrate_prometheus_endpoint::Registry;
|
||||||
|
|
||||||
/// Native executor type.
|
type ParachainExecutor = WasmExecutor<ParachainHostFunctions>;
|
||||||
pub struct ParachainNativeExecutor;
|
|
||||||
|
|
||||||
impl sc_executor::NativeExecutionDispatch for ParachainNativeExecutor {
|
|
||||||
type ExtendHostFunctions = (
|
|
||||||
cumulus_client_service::storage_proof_size::HostFunctions,
|
|
||||||
frame_benchmarking::benchmarking::HostFunctions,
|
|
||||||
);
|
|
||||||
|
|
||||||
fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
|
|
||||||
parachain_template_runtime::apis::api::dispatch(method, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn native_version() -> sc_executor::NativeVersion {
|
|
||||||
parachain_template_runtime::native_version()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type ParachainExecutor = NativeElseWasmExecutor<ParachainNativeExecutor>;
|
|
||||||
|
|
||||||
type ParachainClient = TFullClient<Block, RuntimeApi, ParachainExecutor>;
|
type ParachainClient = TFullClient<Block, RuntimeApi, ParachainExecutor>;
|
||||||
|
|
||||||
@@ -92,7 +73,7 @@ pub fn new_partial(config: &Configuration) -> Result<Service, sc_service::Error>
|
|||||||
.default_heap_pages
|
.default_heap_pages
|
||||||
.map_or(DEFAULT_HEAP_ALLOC_STRATEGY, |h| HeapAllocStrategy::Static { extra_pages: h as _ });
|
.map_or(DEFAULT_HEAP_ALLOC_STRATEGY, |h| HeapAllocStrategy::Static { extra_pages: h as _ });
|
||||||
|
|
||||||
let wasm = WasmExecutor::builder()
|
let executor = ParachainExecutor::builder()
|
||||||
.with_execution_method(config.wasm_method)
|
.with_execution_method(config.wasm_method)
|
||||||
.with_onchain_heap_alloc_strategy(heap_pages)
|
.with_onchain_heap_alloc_strategy(heap_pages)
|
||||||
.with_offchain_heap_alloc_strategy(heap_pages)
|
.with_offchain_heap_alloc_strategy(heap_pages)
|
||||||
@@ -100,8 +81,6 @@ pub fn new_partial(config: &Configuration) -> Result<Service, sc_service::Error>
|
|||||||
.with_runtime_cache_size(config.runtime_cache_size)
|
.with_runtime_cache_size(config.runtime_cache_size)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let executor = ParachainExecutor::new_with_wasm_executor(wasm);
|
|
||||||
|
|
||||||
let (client, backend, keystore_container, task_manager) =
|
let (client, backend, keystore_container, task_manager) =
|
||||||
sc_service::new_full_parts_record_import::<Block, RuntimeApi, _>(
|
sc_service::new_full_parts_record_import::<Block, RuntimeApi, _>(
|
||||||
config,
|
config,
|
||||||
|
|||||||
Reference in New Issue
Block a user