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

Commit d8e48f4

Browse files
bkchrmichalkucharczykkouteskunert
authored andcommitted
Removal of execution strategies (#14387)
* Start * More work! * Moar * More changes * More fixes * More worrk * More fixes * More fixes to make it compile * Adds `NoOffchainStorage` * Pass the extensions * Small basti making small progress * Fix merge errors and remove `ExecutionContext` * Move registration of `ReadRuntimeVersionExt` to `ExecutionExtension` Instead of registering `ReadRuntimeVersionExt` in `sp-state-machine` it is moved to `ExecutionExtension` which provides the default extensions. * Fix compilation * Register the global extensions inside runtime api instance * Fixes * Fix `generate_initial_session_keys` by passing the keystore extension * Fix the grandpa tests * Fix more tests * Fix more tests * Don't set any heap pages if there isn't an override * Fix small fallout * FMT * Fix tests * More tests * Offchain worker custom extensions * More fixes * Make offchain tx pool creation reusable Introduces an `OffchainTransactionPoolFactory` for creating offchain transactions pools that can be registered in the runtime externalities context. This factory will be required for a later pr to make the creation of offchain transaction pools easier. * Fixes * Fixes * Set offchain transaction pool in BABE before using it in the runtime * Add the `offchain_tx_pool` to Grandpa as well * Fix the nodes * Print some error when using the old warnings * Fix merge issues * Fix compilation * Rename `babe_link` * Rename to `offchain_tx_pool_factory` * Cleanup * FMT * Fix benchmark name * Fix `try-runtime` * Remove `--execution` CLI args * Make clippy happy * Forward bls functions * Fix docs * Update UI tests * Update client/api/src/execution_extensions.rs Co-authored-by: Michal Kucharczyk <[email protected]> * Apply suggestions from code review Co-authored-by: Koute <[email protected]> * Update client/cli/src/params/import_params.rs Co-authored-by: Koute <[email protected]> * Update client/api/src/execution_extensions.rs Co-authored-by: Koute <[email protected]> * Pass the offchain storage to the MMR RPC * Update client/api/src/execution_extensions.rs Co-authored-by: Sebastian Kunert <[email protected]> * Review comments * Fixes --------- Co-authored-by: Michal Kucharczyk <[email protected]> Co-authored-by: Koute <[email protected]> Co-authored-by: Sebastian Kunert <[email protected]>
1 parent 6d28d2e commit d8e48f4

File tree

96 files changed

+1175
-1499
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+1175
-1499
lines changed

Cargo.lock

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

bin/node-template/node/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ sc-service = { version = "0.10.0-dev", path = "../../../client/service" }
2828
sc-telemetry = { version = "4.0.0-dev", path = "../../../client/telemetry" }
2929
sc-transaction-pool = { version = "4.0.0-dev", path = "../../../client/transaction-pool" }
3030
sc-transaction-pool-api = { version = "4.0.0-dev", path = "../../../client/transaction-pool/api" }
31+
sc-offchain = { version = "4.0.0-dev", path = "../../../client/offchain" }
32+
sc-statement-store = { version = "4.0.0-dev", path = "../../../client/statement-store" }
3133
sc-consensus-aura = { version = "0.10.0-dev", path = "../../../client/consensus/aura" }
3234
sp-consensus-aura = { version = "0.10.0-dev", path = "../../../primitives/consensus/aura" }
3335
sc-consensus = { version = "0.10.0-dev", path = "../../../client/consensus/common" }

bin/node-template/node/src/service.rs

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
//! Service and ServiceFactory implementation. Specialized wrapper over substrate service.
22
3+
use futures::FutureExt;
34
use node_template_runtime::{self, opaque::Block, RuntimeApi};
4-
use sc_client_api::BlockBackend;
5+
use sc_client_api::{Backend, BlockBackend};
56
use sc_consensus_aura::{ImportQueueParams, SlotProportion, StartAuraParams};
67
use sc_consensus_grandpa::SharedVoterState;
78
pub use sc_executor::NativeElseWasmExecutor;
89
use sc_service::{error::Error as ServiceError, Configuration, TaskManager, WarpSyncParams};
910
use sc_telemetry::{Telemetry, TelemetryWorker};
11+
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
1012
use sp_consensus_aura::sr25519::AuthorityPair as AuraPair;
1113
use std::{sync::Arc, time::Duration};
1214

@@ -179,11 +181,23 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
179181
})?;
180182

181183
if config.offchain_worker.enabled {
182-
sc_service::build_offchain_workers(
183-
&config,
184-
task_manager.spawn_handle(),
185-
client.clone(),
186-
network.clone(),
184+
task_manager.spawn_handle().spawn(
185+
"offchain-workers-runner",
186+
"offchain-worker",
187+
sc_offchain::OffchainWorkers::new(sc_offchain::OffchainWorkerOptions {
188+
runtime_api_provider: client.clone(),
189+
is_validator: config.role.is_authority(),
190+
keystore: Some(keystore_container.keystore()),
191+
offchain_db: backend.offchain_storage(),
192+
transaction_pool: Some(OffchainTransactionPoolFactory::new(
193+
transaction_pool.clone(),
194+
)),
195+
network_provider: network.clone(),
196+
enable_http_requests: true,
197+
custom_extensions: |_| vec![],
198+
})
199+
.run(client.clone(), task_manager.spawn_handle())
200+
.boxed(),
187201
);
188202
}
189203

@@ -224,7 +238,7 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
224238
let proposer_factory = sc_basic_authorship::ProposerFactory::new(
225239
task_manager.spawn_handle(),
226240
client.clone(),
227-
transaction_pool,
241+
transaction_pool.clone(),
228242
prometheus_registry.as_ref(),
229243
telemetry.as_ref().map(|x| x.handle()),
230244
);
@@ -300,6 +314,7 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
300314
prometheus_registry,
301315
shared_voter_state: SharedVoterState::empty(),
302316
telemetry: telemetry.as_ref().map(|x| x.handle()),
317+
offchain_tx_pool_factory: OffchainTransactionPoolFactory::new(transaction_pool),
303318
};
304319

305320
// the GRANDPA voter task is considered infallible, i.e.

bin/node-template/pallets/template/src/weights.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
// *
2020
// --steps=50
2121
// --repeat=20
22-
// --execution=wasm
2322
// --wasm-execution=compiled
2423
// --output
2524
// pallets/template/src/weights.rs

bin/node/bench/src/construct.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use futures::Future;
2828
use std::{borrow::Cow, collections::HashMap, pin::Pin, sync::Arc};
2929

3030
use node_primitives::Block;
31-
use node_testing::bench::{BenchDb, BlockType, DatabaseType, KeyTypes, Profile};
31+
use node_testing::bench::{BenchDb, BlockType, DatabaseType, KeyTypes};
3232
use sc_transaction_pool_api::{
3333
ImportNotificationStream, PoolFuture, PoolStatus, ReadyTransactions, TransactionFor,
3434
TransactionSource, TransactionStatusStreamFor, TxHash,
@@ -43,15 +43,13 @@ use crate::{
4343
};
4444

4545
pub struct ConstructionBenchmarkDescription {
46-
pub profile: Profile,
4746
pub key_types: KeyTypes,
4847
pub block_type: BlockType,
4948
pub size: SizeType,
5049
pub database_type: DatabaseType,
5150
}
5251

5352
pub struct ConstructionBenchmark {
54-
profile: Profile,
5553
database: BenchDb,
5654
transactions: Transactions,
5755
}
@@ -60,11 +58,6 @@ impl core::BenchmarkDescription for ConstructionBenchmarkDescription {
6058
fn path(&self) -> Path {
6159
let mut path = Path::new(&["node", "proposer"]);
6260

63-
match self.profile {
64-
Profile::Wasm => path.push("wasm"),
65-
Profile::Native => path.push("native"),
66-
}
67-
6861
match self.key_types {
6962
KeyTypes::Sr25519 => path.push("sr25519"),
7063
KeyTypes::Ed25519 => path.push("ed25519"),
@@ -99,24 +92,23 @@ impl core::BenchmarkDescription for ConstructionBenchmarkDescription {
9992
}
10093

10194
Box::new(ConstructionBenchmark {
102-
profile: self.profile,
10395
database: bench_db,
10496
transactions: Transactions(extrinsics),
10597
})
10698
}
10799

108100
fn name(&self) -> Cow<'static, str> {
109101
format!(
110-
"Block construction ({:?}/{}, {:?}, {:?} backend)",
111-
self.block_type, self.size, self.profile, self.database_type,
102+
"Block construction ({:?}/{}, {:?} backend)",
103+
self.block_type, self.size, self.database_type,
112104
)
113105
.into()
114106
}
115107
}
116108

117109
impl core::Benchmark for ConstructionBenchmark {
118110
fn run(&mut self, mode: Mode) -> std::time::Duration {
119-
let context = self.database.create_context(self.profile);
111+
let context = self.database.create_context();
120112

121113
let _ = context
122114
.client

bin/node/bench/src/import.rs

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
use std::borrow::Cow;
3434

3535
use node_primitives::Block;
36-
use node_testing::bench::{BenchDb, BlockType, DatabaseType, KeyTypes, Profile};
36+
use node_testing::bench::{BenchDb, BlockType, DatabaseType, KeyTypes};
3737
use sc_client_api::backend::Backend;
3838
use sp_state_machine::InspectState;
3939

@@ -43,15 +43,13 @@ use crate::{
4343
};
4444

4545
pub struct ImportBenchmarkDescription {
46-
pub profile: Profile,
4746
pub key_types: KeyTypes,
4847
pub block_type: BlockType,
4948
pub size: SizeType,
5049
pub database_type: DatabaseType,
5150
}
5251

5352
pub struct ImportBenchmark {
54-
profile: Profile,
5553
database: BenchDb,
5654
block: Block,
5755
block_type: BlockType,
@@ -61,11 +59,6 @@ impl core::BenchmarkDescription for ImportBenchmarkDescription {
6159
fn path(&self) -> Path {
6260
let mut path = Path::new(&["node", "import"]);
6361

64-
match self.profile {
65-
Profile::Wasm => path.push("wasm"),
66-
Profile::Native => path.push("native"),
67-
}
68-
6962
match self.key_types {
7063
KeyTypes::Sr25519 => path.push("sr25519"),
7164
KeyTypes::Ed25519 => path.push("ed25519"),
@@ -88,29 +81,23 @@ impl core::BenchmarkDescription for ImportBenchmarkDescription {
8881
}
8982

9083
fn setup(self: Box<Self>) -> Box<dyn core::Benchmark> {
91-
let profile = self.profile;
9284
let mut bench_db = BenchDb::with_key_types(self.database_type, 50_000, self.key_types);
9385
let block = bench_db.generate_block(self.block_type.to_content(self.size.transactions()));
94-
Box::new(ImportBenchmark {
95-
database: bench_db,
96-
block_type: self.block_type,
97-
block,
98-
profile,
99-
})
86+
Box::new(ImportBenchmark { database: bench_db, block_type: self.block_type, block })
10087
}
10188

10289
fn name(&self) -> Cow<'static, str> {
10390
format!(
104-
"Block import ({:?}/{}, {:?}, {:?} backend)",
105-
self.block_type, self.size, self.profile, self.database_type,
91+
"Block import ({:?}/{}, {:?} backend)",
92+
self.block_type, self.size, self.database_type,
10693
)
10794
.into()
10895
}
10996
}
11097

11198
impl core::Benchmark for ImportBenchmark {
11299
fn run(&mut self, mode: Mode) -> std::time::Duration {
113-
let mut context = self.database.create_context(self.profile);
100+
let mut context = self.database.create_context();
114101

115102
let _ = context
116103
.client

0 commit comments

Comments
 (0)