Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit 59296d3

Browse files
authored
Companion for removal of execution strategies (#2836)
* Companion for removal of execution strategies paritytech/substrate#14387 * Update Cargo.lock * Remove patches * Delete file again * update lockfile for {"polkadot", "substrate"} * Fix * FMT --------- Co-authored-by: parity-processbot <>
1 parent 57558b9 commit 59296d3

File tree

10 files changed

+317
-310
lines changed

10 files changed

+317
-310
lines changed

Cargo.lock

Lines changed: 281 additions & 269 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,4 @@ opt-level = 3
7575
inherits = "release"
7676
lto = true
7777
codegen-units = 1
78+

client/consensus/aura/src/equivocation_import_queue.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,12 +178,7 @@ where
178178
let inherent_res = self
179179
.client
180180
.runtime_api()
181-
.check_inherents_with_context(
182-
parent_hash,
183-
block_params.origin.into(),
184-
block,
185-
inherent_data,
186-
)
181+
.check_inherents(parent_hash, block, inherent_data)
187182
.map_err(|e| format!("Unable to check block inherents {:?}", e))?;
188183

189184
if !inherent_res.ok() {

client/relay-chain-inprocess-interface/src/lib.rs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -72,23 +72,18 @@ impl RelayChainInterface for RelayChainInProcessInterface {
7272
para_id: ParaId,
7373
relay_parent: PHash,
7474
) -> RelayChainResult<Vec<InboundDownwardMessage>> {
75-
Ok(self.full_client.runtime_api().dmq_contents_with_context(
76-
relay_parent,
77-
sp_core::ExecutionContext::Importing,
78-
para_id,
79-
)?)
75+
Ok(self.full_client.runtime_api().dmq_contents(relay_parent, para_id)?)
8076
}
8177

8278
async fn retrieve_all_inbound_hrmp_channel_contents(
8379
&self,
8480
para_id: ParaId,
8581
relay_parent: PHash,
8682
) -> RelayChainResult<BTreeMap<ParaId, Vec<InboundHrmpMessage>>> {
87-
Ok(self.full_client.runtime_api().inbound_hrmp_channels_contents_with_context(
88-
relay_parent,
89-
sp_core::ExecutionContext::Importing,
90-
para_id,
91-
)?)
83+
Ok(self
84+
.full_client
85+
.runtime_api()
86+
.inbound_hrmp_channels_contents(relay_parent, para_id)?)
9287
}
9388

9489
async fn header(&self, block_id: BlockId) -> RelayChainResult<Option<PHeader>> {
@@ -342,8 +337,8 @@ mod tests {
342337
use polkadot_primitives::Block as PBlock;
343338
use polkadot_test_client::{
344339
construct_transfer_extrinsic, BlockBuilderExt, Client, ClientBlockImportExt,
345-
DefaultTestClientBuilderExt, ExecutionStrategy, InitPolkadotBlockBuilder,
346-
TestClientBuilder, TestClientBuilderExt,
340+
DefaultTestClientBuilderExt, InitPolkadotBlockBuilder, TestClientBuilder,
341+
TestClientBuilderExt,
347342
};
348343
use sp_consensus::{BlockOrigin, SyncOracle};
349344
use sp_runtime::traits::Block as BlockT;
@@ -364,8 +359,7 @@ mod tests {
364359
}
365360

366361
fn build_client_backend_and_block() -> (Arc<Client>, PBlock, RelayChainInProcessInterface) {
367-
let builder =
368-
TestClientBuilder::new().set_execution_strategy(ExecutionStrategy::NativeWhenPossible);
362+
let builder = TestClientBuilder::new();
369363
let backend = builder.backend();
370364
let client = Arc::new(builder.build());
371365

pallets/parachain-system/src/validate_block/tests.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,7 @@ fn call_validate_block(
5656
}
5757

5858
fn create_test_client() -> (Client, Header) {
59-
let client = TestClientBuilder::new()
60-
// NOTE: this allows easier debugging
61-
.set_execution_strategy(sc_client_api::ExecutionStrategy::NativeWhenPossible)
62-
.build();
59+
let client = TestClientBuilder::new().build();
6360

6461
let genesis_header = client
6562
.header(client.chain_info().genesis_hash)

parachain-template/node/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ log = "0.4.19"
1515
codec = { package = "parity-scale-codec", version = "3.0.0" }
1616
serde = { version = "1.0.168", features = ["derive"] }
1717
jsonrpsee = { version = "0.16.2", features = ["server"] }
18+
futures = "0.3.28"
1819

1920
# Local
2021
parachain-template-runtime = { path = "../runtime" }
@@ -27,6 +28,7 @@ sc-basic-authorship = { git = "https://github.com/paritytech/substrate", branch
2728
sc-chain-spec = { git = "https://github.com/paritytech/substrate", branch = "master" }
2829
sc-cli = { git = "https://github.com/paritytech/substrate", branch = "master" }
2930
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
31+
sc-offchain = { git = "https://github.com/paritytech/substrate", branch = "master" }
3032
sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
3133
sc-executor = { git = "https://github.com/paritytech/substrate", branch = "master" }
3234
sc-network = { git = "https://github.com/paritytech/substrate", branch = "master" }

parachain-template/node/src/service.rs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use cumulus_relay_chain_interface::RelayChainInterface;
2121

2222
// Substrate Imports
2323
use frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE;
24+
use sc_client_api::Backend;
2425
use sc_consensus::ImportQueue;
2526
use sc_executor::{
2627
HeapAllocStrategy, NativeElseWasmExecutor, WasmExecutor, DEFAULT_HEAP_ALLOC_STRATEGY,
@@ -29,6 +30,7 @@ use sc_network::NetworkBlock;
2930
use sc_network_sync::SyncingService;
3031
use sc_service::{Configuration, PartialComponents, TFullBackend, TFullClient, TaskManager};
3132
use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle};
33+
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
3234
use sp_keystore::KeystorePtr;
3335
use substrate_prometheus_endpoint::Registry;
3436

@@ -194,11 +196,25 @@ async fn start_node_impl(
194196
.await?;
195197

196198
if parachain_config.offchain_worker.enabled {
197-
sc_service::build_offchain_workers(
198-
&parachain_config,
199-
task_manager.spawn_handle(),
200-
client.clone(),
201-
network.clone(),
199+
use futures::FutureExt;
200+
201+
task_manager.spawn_handle().spawn(
202+
"offchain-workers-runner",
203+
"offchain-work",
204+
sc_offchain::OffchainWorkers::new(sc_offchain::OffchainWorkerOptions {
205+
runtime_api_provider: client.clone(),
206+
keystore: Some(params.keystore_container.keystore()),
207+
offchain_db: backend.offchain_storage(),
208+
transaction_pool: Some(OffchainTransactionPoolFactory::new(
209+
transaction_pool.clone(),
210+
)),
211+
network_provider: network.clone(),
212+
is_validator: parachain_config.role.is_authority(),
213+
enable_http_requests: false,
214+
custom_extensions: move |_| vec![],
215+
})
216+
.run(client.clone(), task_manager.spawn_handle())
217+
.boxed(),
202218
);
203219
}
204220

test/service/benches/validate_block.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@ fn benchmark_block_validation(c: &mut Criterion) {
7979
// Each account should only be included in one transfer.
8080
let (src_accounts, dst_accounts, account_ids) = utils::create_benchmark_accounts();
8181

82-
let mut test_client_builder = TestClientBuilder::with_default_backend()
83-
.set_execution_strategy(sc_client_api::ExecutionStrategy::AlwaysWasm);
82+
let mut test_client_builder = TestClientBuilder::with_default_backend();
8483
let genesis_init = test_client_builder.genesis_init_mut();
8584
*genesis_init = cumulus_test_client::GenesisParameters { endowed_accounts: account_ids };
8685
let client = test_client_builder.build_with_native_executor(None).0;

test/service/benches/validate_block_glutton.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ fn benchmark_block_validation(c: &mut Criterion) {
6161
let runtime = tokio::runtime::Runtime::new().expect("creating tokio runtime doesn't fail; qed");
6262

6363
let endowed_accounts = vec![AccountId::from(Alice.public())];
64-
let mut test_client_builder = TestClientBuilder::with_default_backend()
65-
.set_execution_strategy(sc_client_api::ExecutionStrategy::NativeElseWasm);
64+
let mut test_client_builder = TestClientBuilder::with_default_backend();
6665
let genesis_init = test_client_builder.genesis_init_mut();
6766
*genesis_init = cumulus_test_client::GenesisParameters { endowed_accounts };
6867

test/service/src/lib.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ use polkadot_node_subsystem::{errors::RecoveryError, messages::AvailabilityRecov
5555
use polkadot_overseer::Handle as OverseerHandle;
5656
use polkadot_primitives::{CollatorPair, Hash as PHash, PersistedValidationData};
5757
use polkadot_service::ProvideRuntimeApi;
58-
use sc_client_api::execution_extensions::ExecutionStrategies;
5958
use sc_consensus::ImportQueue;
6059
use sc_network::{
6160
config::{FullNetworkConfiguration, TransportConfig},
@@ -758,13 +757,6 @@ pub fn node_config(
758757
wasm_method: WasmExecutionMethod::Compiled {
759758
instantiation_strategy: sc_executor_wasmtime::InstantiationStrategy::PoolingCopyOnWrite,
760759
},
761-
execution_strategies: ExecutionStrategies {
762-
syncing: sc_client_api::ExecutionStrategy::AlwaysWasm,
763-
importing: sc_client_api::ExecutionStrategy::AlwaysWasm,
764-
block_construction: sc_client_api::ExecutionStrategy::AlwaysWasm,
765-
offchain_worker: sc_client_api::ExecutionStrategy::AlwaysWasm,
766-
other: sc_client_api::ExecutionStrategy::AlwaysWasm,
767-
},
768760
rpc_addr: None,
769761
rpc_max_connections: Default::default(),
770762
rpc_cors: None,

0 commit comments

Comments
 (0)