Companion for removal of execution strategies (#2836)

* Companion for removal of execution strategies

https://github.com/paritytech/substrate/pull/14387

* Update Cargo.lock

* Remove patches

* Delete file again

* update lockfile for {"polkadot", "substrate"}

* Fix

* FMT

---------

Co-authored-by: parity-processbot <>
This commit is contained in:
Bastian Köcher
2023-07-12 00:48:51 +02:00
committed by GitHub
parent 9e68861cad
commit ae0210c1cc
10 changed files with 317 additions and 310 deletions
+281 -269
View File
File diff suppressed because it is too large Load Diff
+1
View File
@@ -75,3 +75,4 @@ opt-level = 3
inherits = "release" inherits = "release"
lto = true lto = true
codegen-units = 1 codegen-units = 1
@@ -178,12 +178,7 @@ where
let inherent_res = self let inherent_res = self
.client .client
.runtime_api() .runtime_api()
.check_inherents_with_context( .check_inherents(parent_hash, block, inherent_data)
parent_hash,
block_params.origin.into(),
block,
inherent_data,
)
.map_err(|e| format!("Unable to check block inherents {:?}", e))?; .map_err(|e| format!("Unable to check block inherents {:?}", e))?;
if !inherent_res.ok() { if !inherent_res.ok() {
@@ -72,11 +72,7 @@ impl RelayChainInterface for RelayChainInProcessInterface {
para_id: ParaId, para_id: ParaId,
relay_parent: PHash, relay_parent: PHash,
) -> RelayChainResult<Vec<InboundDownwardMessage>> { ) -> RelayChainResult<Vec<InboundDownwardMessage>> {
Ok(self.full_client.runtime_api().dmq_contents_with_context( Ok(self.full_client.runtime_api().dmq_contents(relay_parent, para_id)?)
relay_parent,
sp_core::ExecutionContext::Importing,
para_id,
)?)
} }
async fn retrieve_all_inbound_hrmp_channel_contents( async fn retrieve_all_inbound_hrmp_channel_contents(
@@ -84,11 +80,10 @@ impl RelayChainInterface for RelayChainInProcessInterface {
para_id: ParaId, para_id: ParaId,
relay_parent: PHash, relay_parent: PHash,
) -> RelayChainResult<BTreeMap<ParaId, Vec<InboundHrmpMessage>>> { ) -> RelayChainResult<BTreeMap<ParaId, Vec<InboundHrmpMessage>>> {
Ok(self.full_client.runtime_api().inbound_hrmp_channels_contents_with_context( Ok(self
relay_parent, .full_client
sp_core::ExecutionContext::Importing, .runtime_api()
para_id, .inbound_hrmp_channels_contents(relay_parent, para_id)?)
)?)
} }
async fn header(&self, block_id: BlockId) -> RelayChainResult<Option<PHeader>> { async fn header(&self, block_id: BlockId) -> RelayChainResult<Option<PHeader>> {
@@ -342,8 +337,8 @@ mod tests {
use polkadot_primitives::Block as PBlock; use polkadot_primitives::Block as PBlock;
use polkadot_test_client::{ use polkadot_test_client::{
construct_transfer_extrinsic, BlockBuilderExt, Client, ClientBlockImportExt, construct_transfer_extrinsic, BlockBuilderExt, Client, ClientBlockImportExt,
DefaultTestClientBuilderExt, ExecutionStrategy, InitPolkadotBlockBuilder, DefaultTestClientBuilderExt, InitPolkadotBlockBuilder, TestClientBuilder,
TestClientBuilder, TestClientBuilderExt, TestClientBuilderExt,
}; };
use sp_consensus::{BlockOrigin, SyncOracle}; use sp_consensus::{BlockOrigin, SyncOracle};
use sp_runtime::traits::Block as BlockT; use sp_runtime::traits::Block as BlockT;
@@ -364,8 +359,7 @@ mod tests {
} }
fn build_client_backend_and_block() -> (Arc<Client>, PBlock, RelayChainInProcessInterface) { fn build_client_backend_and_block() -> (Arc<Client>, PBlock, RelayChainInProcessInterface) {
let builder = let builder = TestClientBuilder::new();
TestClientBuilder::new().set_execution_strategy(ExecutionStrategy::NativeWhenPossible);
let backend = builder.backend(); let backend = builder.backend();
let client = Arc::new(builder.build()); let client = Arc::new(builder.build());
@@ -56,10 +56,7 @@ fn call_validate_block(
} }
fn create_test_client() -> (Client, Header) { fn create_test_client() -> (Client, Header) {
let client = TestClientBuilder::new() let client = TestClientBuilder::new().build();
// NOTE: this allows easier debugging
.set_execution_strategy(sc_client_api::ExecutionStrategy::NativeWhenPossible)
.build();
let genesis_header = client let genesis_header = client
.header(client.chain_info().genesis_hash) .header(client.chain_info().genesis_hash)
@@ -15,6 +15,7 @@ log = "0.4.19"
codec = { package = "parity-scale-codec", version = "3.0.0" } codec = { package = "parity-scale-codec", version = "3.0.0" }
serde = { version = "1.0.168", features = ["derive"] } serde = { version = "1.0.168", features = ["derive"] }
jsonrpsee = { version = "0.16.2", features = ["server"] } jsonrpsee = { version = "0.16.2", features = ["server"] }
futures = "0.3.28"
# Local # Local
parachain-template-runtime = { path = "../runtime" } parachain-template-runtime = { path = "../runtime" }
@@ -27,6 +28,7 @@ sc-basic-authorship = { git = "https://github.com/paritytech/substrate", branch
sc-chain-spec = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-chain-spec = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-cli = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-cli = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-offchain = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-executor = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-executor = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-network = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-network = { git = "https://github.com/paritytech/substrate", branch = "master" }
+21 -5
View File
@@ -21,6 +21,7 @@ use cumulus_relay_chain_interface::RelayChainInterface;
// Substrate Imports // Substrate Imports
use frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE; use frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE;
use sc_client_api::Backend;
use sc_consensus::ImportQueue; use sc_consensus::ImportQueue;
use sc_executor::{ use sc_executor::{
HeapAllocStrategy, NativeElseWasmExecutor, WasmExecutor, DEFAULT_HEAP_ALLOC_STRATEGY, HeapAllocStrategy, NativeElseWasmExecutor, WasmExecutor, DEFAULT_HEAP_ALLOC_STRATEGY,
@@ -29,6 +30,7 @@ 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};
use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle}; use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle};
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
use sp_keystore::KeystorePtr; use sp_keystore::KeystorePtr;
use substrate_prometheus_endpoint::Registry; use substrate_prometheus_endpoint::Registry;
@@ -194,11 +196,25 @@ async fn start_node_impl(
.await?; .await?;
if parachain_config.offchain_worker.enabled { if parachain_config.offchain_worker.enabled {
sc_service::build_offchain_workers( use futures::FutureExt;
&parachain_config,
task_manager.spawn_handle(), task_manager.spawn_handle().spawn(
client.clone(), "offchain-workers-runner",
network.clone(), "offchain-work",
sc_offchain::OffchainWorkers::new(sc_offchain::OffchainWorkerOptions {
runtime_api_provider: client.clone(),
keystore: Some(params.keystore_container.keystore()),
offchain_db: backend.offchain_storage(),
transaction_pool: Some(OffchainTransactionPoolFactory::new(
transaction_pool.clone(),
)),
network_provider: network.clone(),
is_validator: parachain_config.role.is_authority(),
enable_http_requests: false,
custom_extensions: move |_| vec![],
})
.run(client.clone(), task_manager.spawn_handle())
.boxed(),
); );
} }
@@ -79,8 +79,7 @@ fn benchmark_block_validation(c: &mut Criterion) {
// Each account should only be included in one transfer. // Each account should only be included in one transfer.
let (src_accounts, dst_accounts, account_ids) = utils::create_benchmark_accounts(); let (src_accounts, dst_accounts, account_ids) = utils::create_benchmark_accounts();
let mut test_client_builder = TestClientBuilder::with_default_backend() let mut test_client_builder = TestClientBuilder::with_default_backend();
.set_execution_strategy(sc_client_api::ExecutionStrategy::AlwaysWasm);
let genesis_init = test_client_builder.genesis_init_mut(); let genesis_init = test_client_builder.genesis_init_mut();
*genesis_init = cumulus_test_client::GenesisParameters { endowed_accounts: account_ids }; *genesis_init = cumulus_test_client::GenesisParameters { endowed_accounts: account_ids };
let client = test_client_builder.build_with_native_executor(None).0; let client = test_client_builder.build_with_native_executor(None).0;
@@ -61,8 +61,7 @@ fn benchmark_block_validation(c: &mut Criterion) {
let runtime = tokio::runtime::Runtime::new().expect("creating tokio runtime doesn't fail; qed"); let runtime = tokio::runtime::Runtime::new().expect("creating tokio runtime doesn't fail; qed");
let endowed_accounts = vec![AccountId::from(Alice.public())]; let endowed_accounts = vec![AccountId::from(Alice.public())];
let mut test_client_builder = TestClientBuilder::with_default_backend() let mut test_client_builder = TestClientBuilder::with_default_backend();
.set_execution_strategy(sc_client_api::ExecutionStrategy::NativeElseWasm);
let genesis_init = test_client_builder.genesis_init_mut(); let genesis_init = test_client_builder.genesis_init_mut();
*genesis_init = cumulus_test_client::GenesisParameters { endowed_accounts }; *genesis_init = cumulus_test_client::GenesisParameters { endowed_accounts };
-8
View File
@@ -55,7 +55,6 @@ use polkadot_node_subsystem::{errors::RecoveryError, messages::AvailabilityRecov
use polkadot_overseer::Handle as OverseerHandle; use polkadot_overseer::Handle as OverseerHandle;
use polkadot_primitives::{CollatorPair, Hash as PHash, PersistedValidationData}; use polkadot_primitives::{CollatorPair, Hash as PHash, PersistedValidationData};
use polkadot_service::ProvideRuntimeApi; use polkadot_service::ProvideRuntimeApi;
use sc_client_api::execution_extensions::ExecutionStrategies;
use sc_consensus::ImportQueue; use sc_consensus::ImportQueue;
use sc_network::{ use sc_network::{
config::{FullNetworkConfiguration, TransportConfig}, config::{FullNetworkConfiguration, TransportConfig},
@@ -758,13 +757,6 @@ pub fn node_config(
wasm_method: WasmExecutionMethod::Compiled { wasm_method: WasmExecutionMethod::Compiled {
instantiation_strategy: sc_executor_wasmtime::InstantiationStrategy::PoolingCopyOnWrite, instantiation_strategy: sc_executor_wasmtime::InstantiationStrategy::PoolingCopyOnWrite,
}, },
execution_strategies: ExecutionStrategies {
syncing: sc_client_api::ExecutionStrategy::AlwaysWasm,
importing: sc_client_api::ExecutionStrategy::AlwaysWasm,
block_construction: sc_client_api::ExecutionStrategy::AlwaysWasm,
offchain_worker: sc_client_api::ExecutionStrategy::AlwaysWasm,
other: sc_client_api::ExecutionStrategy::AlwaysWasm,
},
rpc_addr: None, rpc_addr: None,
rpc_max_connections: Default::default(), rpc_max_connections: Default::default(),
rpc_cors: None, rpc_cors: None,