diff --git a/Cargo.lock b/Cargo.lock index 62d0e728ee3..03a9001f01e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8584,6 +8584,7 @@ dependencies = [ "cumulus-relay-chain-interface", "frame-benchmarking", "frame-benchmarking-cli", + "futures", "jsonrpsee", "log", "pallet-transaction-payment-rpc", @@ -8599,6 +8600,7 @@ dependencies = [ "sc-executor", "sc-network", "sc-network-sync", + "sc-offchain", "sc-rpc", "sc-service", "sc-sysinfo", @@ -9838,6 +9840,7 @@ dependencies = [ "polkadot-primitives", "polkadot-statement-table", "sc-network", + "sc-transaction-pool-api", "smallvec", "sp-api", "sp-authority-discovery", @@ -10374,6 +10377,7 @@ dependencies = [ "sc-sysinfo", "sc-telemetry", "sc-transaction-pool", + "sc-transaction-pool-api", "serde", "serde_json", "sp-api", @@ -11934,6 +11938,7 @@ dependencies = [ "sc-consensus-slots", "sc-telemetry", "sc-transaction-pool-api", + "sc-transaction-pool-api", "scale-info", "sp-api", "sp-application-crypto", diff --git a/Cargo.toml b/Cargo.toml index 15aa8614948..149a4d345e0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -75,3 +75,4 @@ opt-level = 3 inherits = "release" lto = true codegen-units = 1 + diff --git a/client/consensus/aura/src/equivocation_import_queue.rs b/client/consensus/aura/src/equivocation_import_queue.rs index ac9c2a52829..b39fa73117f 100644 --- a/client/consensus/aura/src/equivocation_import_queue.rs +++ b/client/consensus/aura/src/equivocation_import_queue.rs @@ -178,12 +178,7 @@ where let inherent_res = self .client .runtime_api() - .check_inherents_with_context( - parent_hash, - block_params.origin.into(), - block, - inherent_data, - ) + .check_inherents(parent_hash, block, inherent_data) .map_err(|e| format!("Unable to check block inherents {:?}", e))?; if !inherent_res.ok() { diff --git a/client/relay-chain-inprocess-interface/src/lib.rs b/client/relay-chain-inprocess-interface/src/lib.rs index 54b0362a475..77a523b3407 100644 --- a/client/relay-chain-inprocess-interface/src/lib.rs +++ b/client/relay-chain-inprocess-interface/src/lib.rs @@ -72,11 +72,7 @@ impl RelayChainInterface for RelayChainInProcessInterface { para_id: ParaId, relay_parent: PHash, ) -> RelayChainResult> { - Ok(self.full_client.runtime_api().dmq_contents_with_context( - relay_parent, - sp_core::ExecutionContext::Importing, - para_id, - )?) + Ok(self.full_client.runtime_api().dmq_contents(relay_parent, para_id)?) } async fn retrieve_all_inbound_hrmp_channel_contents( @@ -84,11 +80,10 @@ impl RelayChainInterface for RelayChainInProcessInterface { para_id: ParaId, relay_parent: PHash, ) -> RelayChainResult>> { - Ok(self.full_client.runtime_api().inbound_hrmp_channels_contents_with_context( - relay_parent, - sp_core::ExecutionContext::Importing, - para_id, - )?) + Ok(self + .full_client + .runtime_api() + .inbound_hrmp_channels_contents(relay_parent, para_id)?) } async fn header(&self, block_id: BlockId) -> RelayChainResult> { @@ -342,8 +337,8 @@ mod tests { use polkadot_primitives::Block as PBlock; use polkadot_test_client::{ construct_transfer_extrinsic, BlockBuilderExt, Client, ClientBlockImportExt, - DefaultTestClientBuilderExt, ExecutionStrategy, InitPolkadotBlockBuilder, - TestClientBuilder, TestClientBuilderExt, + DefaultTestClientBuilderExt, InitPolkadotBlockBuilder, TestClientBuilder, + TestClientBuilderExt, }; use sp_consensus::{BlockOrigin, SyncOracle}; use sp_runtime::traits::Block as BlockT; @@ -364,8 +359,7 @@ mod tests { } fn build_client_backend_and_block() -> (Arc, PBlock, RelayChainInProcessInterface) { - let builder = - TestClientBuilder::new().set_execution_strategy(ExecutionStrategy::NativeWhenPossible); + let builder = TestClientBuilder::new(); let backend = builder.backend(); let client = Arc::new(builder.build()); diff --git a/pallets/parachain-system/src/validate_block/tests.rs b/pallets/parachain-system/src/validate_block/tests.rs index 4801b62e7b5..eab3ed6d213 100644 --- a/pallets/parachain-system/src/validate_block/tests.rs +++ b/pallets/parachain-system/src/validate_block/tests.rs @@ -56,10 +56,7 @@ fn call_validate_block( } fn create_test_client() -> (Client, Header) { - let client = TestClientBuilder::new() - // NOTE: this allows easier debugging - .set_execution_strategy(sc_client_api::ExecutionStrategy::NativeWhenPossible) - .build(); + let client = TestClientBuilder::new().build(); let genesis_header = client .header(client.chain_info().genesis_hash) diff --git a/parachain-template/node/Cargo.toml b/parachain-template/node/Cargo.toml index 10cdfe684b4..96524756334 100644 --- a/parachain-template/node/Cargo.toml +++ b/parachain-template/node/Cargo.toml @@ -15,6 +15,7 @@ log = "0.4.19" codec = { package = "parity-scale-codec", version = "3.0.0" } serde = { version = "1.0.168", features = ["derive"] } jsonrpsee = { version = "0.16.2", features = ["server"] } +futures = "0.3.28" # Local 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 = "polkadot-v1.0.0" } sc-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" } sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" } +sc-offchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" } sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" } sc-executor = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" } sc-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" } diff --git a/parachain-template/node/src/service.rs b/parachain-template/node/src/service.rs index fb311a48b48..9ad3c1ad3cc 100644 --- a/parachain-template/node/src/service.rs +++ b/parachain-template/node/src/service.rs @@ -21,6 +21,7 @@ use cumulus_relay_chain_interface::RelayChainInterface; // Substrate Imports use frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE; +use sc_client_api::Backend; use sc_consensus::ImportQueue; use sc_executor::{ HeapAllocStrategy, NativeElseWasmExecutor, WasmExecutor, DEFAULT_HEAP_ALLOC_STRATEGY, @@ -29,6 +30,7 @@ use sc_network::NetworkBlock; use sc_network_sync::SyncingService; use sc_service::{Configuration, PartialComponents, TFullBackend, TFullClient, TaskManager}; use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle}; +use sc_transaction_pool_api::OffchainTransactionPoolFactory; use sp_keystore::KeystorePtr; use substrate_prometheus_endpoint::Registry; @@ -194,11 +196,25 @@ async fn start_node_impl( .await?; if parachain_config.offchain_worker.enabled { - sc_service::build_offchain_workers( - ¶chain_config, - task_manager.spawn_handle(), - client.clone(), - network.clone(), + use futures::FutureExt; + + task_manager.spawn_handle().spawn( + "offchain-workers-runner", + "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(), ); } diff --git a/test/service/benches/validate_block.rs b/test/service/benches/validate_block.rs index 3f4c39e5aa9..f3b4d0b1214 100644 --- a/test/service/benches/validate_block.rs +++ b/test/service/benches/validate_block.rs @@ -79,8 +79,7 @@ fn benchmark_block_validation(c: &mut Criterion) { // Each account should only be included in one transfer. let (src_accounts, dst_accounts, account_ids) = utils::create_benchmark_accounts(); - let mut test_client_builder = TestClientBuilder::with_default_backend() - .set_execution_strategy(sc_client_api::ExecutionStrategy::AlwaysWasm); + let mut test_client_builder = TestClientBuilder::with_default_backend(); let genesis_init = test_client_builder.genesis_init_mut(); *genesis_init = cumulus_test_client::GenesisParameters { endowed_accounts: account_ids }; let client = test_client_builder.build_with_native_executor(None).0; diff --git a/test/service/benches/validate_block_glutton.rs b/test/service/benches/validate_block_glutton.rs index 5f5fda07168..0e049d8665d 100644 --- a/test/service/benches/validate_block_glutton.rs +++ b/test/service/benches/validate_block_glutton.rs @@ -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 endowed_accounts = vec![AccountId::from(Alice.public())]; - let mut test_client_builder = TestClientBuilder::with_default_backend() - .set_execution_strategy(sc_client_api::ExecutionStrategy::NativeElseWasm); + let mut test_client_builder = TestClientBuilder::with_default_backend(); let genesis_init = test_client_builder.genesis_init_mut(); *genesis_init = cumulus_test_client::GenesisParameters { endowed_accounts }; diff --git a/test/service/src/lib.rs b/test/service/src/lib.rs index e45ba47f6eb..d597997c276 100644 --- a/test/service/src/lib.rs +++ b/test/service/src/lib.rs @@ -55,7 +55,6 @@ use polkadot_node_subsystem::{errors::RecoveryError, messages::AvailabilityRecov use polkadot_overseer::Handle as OverseerHandle; use polkadot_primitives::{CollatorPair, Hash as PHash, PersistedValidationData}; use polkadot_service::ProvideRuntimeApi; -use sc_client_api::execution_extensions::ExecutionStrategies; use sc_consensus::ImportQueue; use sc_network::{ config::{FullNetworkConfiguration, TransportConfig}, @@ -758,13 +757,6 @@ pub fn node_config( wasm_method: WasmExecutionMethod::Compiled { 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_max_connections: Default::default(), rpc_cors: None,