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

Commit b8d485f

Browse files
EgorPopelyaevbkchrmichalkucharczykkouteskunert
authored
Ep backport missing cumulus companions (#14594)
* 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]> * `GenesisBuild<T,I>` deprecated. `BuildGenesisConfig` added. (#14306) * frame::support: GenesisConfig types for Runtime enabled * frame::support: macro generating GenesisBuild::build for RuntimeGenesisConfig * frame: ambiguity BuildStorage vs GenesisBuild fixed * fix * RuntimeGenesisBuild added * Revert "frame: ambiguity BuildStorage vs GenesisBuild fixed" This reverts commit 6017dad. * Revert "fix" This reverts commit 477d7ad. * Revert "RuntimeGenesisBuild added" This reverts commit 3c131b6. * Revert "Revert "frame: ambiguity BuildStorage vs GenesisBuild fixed"" This reverts commit 2b1ecd4. * Revert "Revert "fix"" This reverts commit fd7fa62. * Code review suggestions * frame: BuildGenesisConfig added, BuildGenesis deprecated * frame: some pallets updated with BuildGenesisConfig * constuct_runtime: support for BuildGenesisConfig * frame::support: genesis_build macro supports BuildGenesisConfig * frame: BuildGenesisConfig added, BuildGenesis deprecated * Cargo.lock update * test-runtime: fixes * Revert "fix" This reverts commit 477d7ad. * Revert "frame: ambiguity BuildStorage vs GenesisBuild fixed" This reverts commit 6017dad. * self review * doc fixed * ui tests fixed * fmt * tests fixed * genesis_build macrto fixed for non-generic GenesisConfig * BuildGenesisConfig constraints added * warning fixed * some duplication removed * fmt * fix * doc tests fix * doc fix * cleanup: remove BuildModuleGenesisStorage * self review comments * fix * Update frame/treasury/src/tests.rs Co-authored-by: Sebastian Kunert <[email protected]> * Update frame/support/src/traits/hooks.rs Co-authored-by: Sebastian Kunert <[email protected]> * doc fix: GenesisBuild exposed * ".git/.scripts/commands/fmt/fmt.sh" * frame: more serde(skip) + cleanup * Update frame/support/src/traits/hooks.rs Co-authored-by: Davide Galassi <[email protected]> * frame: phantom fields moved to the end of structs * chain-spec: Default::default cleanup * test-runtime: phantom at the end * merge master fixes * fix * fix * fix * fix * fix (facepalm) * Update frame/support/procedural/src/pallet/expand/genesis_build.rs Co-authored-by: Bastian Köcher <[email protected]> * fmt * fix * fix --------- Co-authored-by: parity-processbot <> Co-authored-by: Sebastian Kunert <[email protected]> Co-authored-by: Davide Galassi <[email protected]> Co-authored-by: Bastian Köcher <[email protected]> * Moves `Block` to `frame_system` instead of `construct_runtime` and removes `Header` and `BlockNumber` (#14437) * Initial setup * Adds node block * Uses UncheckedExtrinsic and removes Where section * Updates frame_system to use Block * Adds deprecation warning * Fixes pallet-timestamp * Removes Header and BlockNumber * Addresses review comments * Addresses review comments * Adds comment about compiler bug * Removes where clause * Refactors code * Fixes errors in cargo check * Fixes errors in cargo check * Fixes warnings in cargo check * Formatting * Fixes construct_runtime tests * Uses import instead of full path for BlockNumber * Uses import instead of full path for Header * Formatting * Fixes construct_runtime tests * Fixes imports in benchmarks * Formatting * Fixes construct_runtime tests * Formatting * Minor updates * Fixes construct_runtime ui tests * Fixes construct_runtime ui tests with 1.70 * Fixes docs * Fixes docs * Adds u128 mock block type * Fixes split example * fixes for cumulus * ".git/.scripts/commands/fmt/fmt.sh" * Updates new tests * Fixes fully-qualified path in few places * Formatting * Update frame/examples/default-config/src/lib.rs Co-authored-by: Juan <[email protected]> * Update frame/support/procedural/src/construct_runtime/mod.rs Co-authored-by: Juan <[email protected]> * ".git/.scripts/commands/fmt/fmt.sh" * Addresses some review comments * Fixes build * ".git/.scripts/commands/fmt/fmt.sh" * Update frame/democracy/src/lib.rs Co-authored-by: Oliver Tale-Yazdi <[email protected]> * Update frame/democracy/src/lib.rs Co-authored-by: Oliver Tale-Yazdi <[email protected]> * Update frame/support/procedural/src/construct_runtime/mod.rs Co-authored-by: Oliver Tale-Yazdi <[email protected]> * Update frame/support/procedural/src/construct_runtime/mod.rs Co-authored-by: Oliver Tale-Yazdi <[email protected]> * Addresses review comments * Updates trait bounds * Minor fix * ".git/.scripts/commands/fmt/fmt.sh" * Removes unnecessary bound * ".git/.scripts/commands/fmt/fmt.sh" * Updates test * Fixes build * Adds a bound for header * ".git/.scripts/commands/fmt/fmt.sh" * Removes where block * Minor fix * Minor fix * Fixes tests * ".git/.scripts/commands/update-ui/update-ui.sh" 1.70 * Updates test * Update primitives/runtime/src/traits.rs Co-authored-by: Bastian Köcher <[email protected]> * Update primitives/runtime/src/traits.rs Co-authored-by: Bastian Köcher <[email protected]> * Updates doc * Updates doc --------- Co-authored-by: command-bot <> Co-authored-by: Juan <[email protected]> Co-authored-by: Oliver Tale-Yazdi <[email protected]> Co-authored-by: Bastian Köcher <[email protected]> * Replace system config `Index` for `Nonce` (#14290) * replace Index by Nonce * replace Index by Nonce * replace Index by Nonce * replace Index by Nonce * replace Index by Nonce * wip * remove index in lieu of nonce * wip * remove accountnonce in lieu of nonce * add minor improvement * rebase and merge conflicts --------- Co-authored-by: Bastian Köcher <[email protected]> Co-authored-by: Michal Kucharczyk <[email protected]> Co-authored-by: Koute <[email protected]> Co-authored-by: Sebastian Kunert <[email protected]> Co-authored-by: Davide Galassi <[email protected]> Co-authored-by: gupnik <[email protected]> Co-authored-by: Juan <[email protected]> Co-authored-by: Oliver Tale-Yazdi <[email protected]>
1 parent 6d28d2e commit b8d485f

File tree

422 files changed

+4000
-4713
lines changed

Some content is hidden

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

422 files changed

+4000
-4713
lines changed

Cargo.lock

+16-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bin/node-template/node/Cargo.toml

+2
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/chain_spec.rs

+2
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ fn testnet_genesis(
136136
system: SystemConfig {
137137
// Add Wasm runtime to storage.
138138
code: wasm_binary.to_vec(),
139+
..Default::default()
139140
},
140141
balances: BalancesConfig {
141142
// Configure endowed accounts with initial balance of 1 << 60.
@@ -146,6 +147,7 @@ fn testnet_genesis(
146147
},
147148
grandpa: GrandpaConfig {
148149
authorities: initial_authorities.iter().map(|x| (x.1.clone(), 1)).collect(),
150+
..Default::default()
149151
},
150152
sudo: SudoConfig {
151153
// Assign network admin rights.

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use std::sync::Arc;
99

1010
use jsonrpsee::RpcModule;
11-
use node_template_runtime::{opaque::Block, AccountId, Balance, Index};
11+
use node_template_runtime::{opaque::Block, AccountId, Balance, Nonce};
1212
use sc_transaction_pool_api::TransactionPool;
1313
use sp_api::ProvideRuntimeApi;
1414
use sp_block_builder::BlockBuilder;
@@ -34,7 +34,7 @@ where
3434
C: ProvideRuntimeApi<Block>,
3535
C: HeaderBackend<Block> + HeaderMetadata<Block, Error = BlockChainError> + 'static,
3636
C: Send + Sync + 'static,
37-
C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>,
37+
C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
3838
C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,
3939
C::Api: BlockBuilder<Block>,
4040
P: TransactionPool + 'static,

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

+22-7
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/mock.rs

+5-10
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,15 @@ use crate as pallet_template;
22
use frame_support::traits::{ConstU16, ConstU64};
33
use sp_core::H256;
44
use sp_runtime::{
5-
testing::Header,
65
traits::{BlakeTwo256, IdentityLookup},
6+
BuildStorage,
77
};
88

9-
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
109
type Block = frame_system::mocking::MockBlock<Test>;
1110

1211
// Configure a mock runtime to test the pallet.
1312
frame_support::construct_runtime!(
14-
pub enum Test where
15-
Block = Block,
16-
NodeBlock = Block,
17-
UncheckedExtrinsic = UncheckedExtrinsic,
13+
pub enum Test
1814
{
1915
System: frame_system,
2016
TemplateModule: pallet_template,
@@ -28,13 +24,12 @@ impl frame_system::Config for Test {
2824
type DbWeight = ();
2925
type RuntimeOrigin = RuntimeOrigin;
3026
type RuntimeCall = RuntimeCall;
31-
type Index = u64;
32-
type BlockNumber = u64;
27+
type Nonce = u64;
3328
type Hash = H256;
3429
type Hashing = BlakeTwo256;
3530
type AccountId = u64;
3631
type Lookup = IdentityLookup<Self::AccountId>;
37-
type Header = Header;
32+
type Block = Block;
3833
type RuntimeEvent = RuntimeEvent;
3934
type BlockHashCount = ConstU64<250>;
4035
type Version = ();
@@ -55,5 +50,5 @@ impl pallet_template::Config for Test {
5550

5651
// Build genesis storage according to the mock runtime.
5752
pub fn new_test_ext() -> sp_io::TestExternalities {
58-
frame_system::GenesisConfig::default().build_storage::<Test>().unwrap().into()
53+
frame_system::GenesisConfig::<Test>::default().build_storage().unwrap().into()
5954
}

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

-1
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-template/runtime/src/lib.rs

+8-15
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::Account
6363
pub type Balance = u128;
6464

6565
/// Index of a transaction in the chain.
66-
pub type Index = u32;
66+
pub type Nonce = u32;
6767

6868
/// A hash of some data used by the chain.
6969
pub type Hash = sp_core::H256;
@@ -155,6 +155,8 @@ parameter_types! {
155155
impl frame_system::Config for Runtime {
156156
/// The basic call filter to use in dispatchable.
157157
type BaseCallFilter = frame_support::traits::Everything;
158+
/// The block type for the runtime.
159+
type Block = Block;
158160
/// Block & extrinsics weights: base values and limits.
159161
type BlockWeights = BlockWeights;
160162
/// The maximum length of a block (in bytes).
@@ -165,16 +167,12 @@ impl frame_system::Config for Runtime {
165167
type RuntimeCall = RuntimeCall;
166168
/// The lookup mechanism to get account ID from whatever is passed in dispatchers.
167169
type Lookup = AccountIdLookup<AccountId, ()>;
168-
/// The index type for storing how many extrinsics an account has signed.
169-
type Index = Index;
170-
/// The index type for blocks.
171-
type BlockNumber = BlockNumber;
170+
/// The type for storing how many extrinsics an account has signed.
171+
type Nonce = Nonce;
172172
/// The type for hashing blocks and tries.
173173
type Hash = Hash;
174174
/// The hashing algorithm used.
175175
type Hashing = BlakeTwo256;
176-
/// The header type.
177-
type Header = generic::Header<BlockNumber, BlakeTwo256>;
178176
/// The ubiquitous event type.
179177
type RuntimeEvent = RuntimeEvent;
180178
/// The ubiquitous origin type.
@@ -278,12 +276,7 @@ impl pallet_template::Config for Runtime {
278276

279277
// Create the runtime by composing the FRAME pallets that were previously configured.
280278
construct_runtime!(
281-
pub struct Runtime
282-
where
283-
Block = Block,
284-
NodeBlock = opaque::Block,
285-
UncheckedExtrinsic = UncheckedExtrinsic,
286-
{
279+
pub struct Runtime {
287280
System: frame_system,
288281
Timestamp: pallet_timestamp,
289282
Aura: pallet_aura,
@@ -462,8 +455,8 @@ impl_runtime_apis! {
462455
}
463456
}
464457

465-
impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {
466-
fn account_nonce(account: AccountId) -> Index {
458+
impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime {
459+
fn account_nonce(account: AccountId) -> Nonce {
467460
System::account_nonce(account)
468461
}
469462
}

0 commit comments

Comments
 (0)