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

Companion for removal of execution strategies #2836

Merged
merged 10 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
550 changes: 281 additions & 269 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,4 @@ opt-level = 3
inherits = "release"
lto = true
codegen-units = 1

7 changes: 1 addition & 6 deletions client/consensus/aura/src/equivocation_import_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
22 changes: 8 additions & 14 deletions client/relay-chain-inprocess-interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,23 +72,18 @@ impl RelayChainInterface for RelayChainInProcessInterface {
para_id: ParaId,
relay_parent: PHash,
) -> RelayChainResult<Vec<InboundDownwardMessage>> {
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(
&self,
para_id: ParaId,
relay_parent: PHash,
) -> RelayChainResult<BTreeMap<ParaId, Vec<InboundHrmpMessage>>> {
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<Option<PHeader>> {
Expand Down Expand Up @@ -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;
Expand All @@ -364,8 +359,7 @@ mod tests {
}

fn build_client_backend_and_block() -> (Arc<Client>, 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());

Expand Down
5 changes: 1 addition & 4 deletions pallets/parachain-system/src/validate_block/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions parachain-template/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand All @@ -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-cli = { 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-executor = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-network = { git = "https://github.com/paritytech/substrate", branch = "master" }
Expand Down
26 changes: 21 additions & 5 deletions parachain-template/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;

Expand Down Expand Up @@ -194,11 +196,25 @@ async fn start_node_impl(
.await?;

if parachain_config.offchain_worker.enabled {
sc_service::build_offchain_workers(
&parachain_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(),
);
}

Expand Down
3 changes: 1 addition & 2 deletions test/service/benches/validate_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions test/service/benches/validate_block_glutton.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 };

Expand Down
8 changes: 0 additions & 8 deletions test/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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,
Expand Down