Update for latests substrate & polkadot (#756)

* Update for latests substrate & polkadot

* fmt
This commit is contained in:
Arkadiy Paronyan
2021-11-12 16:45:09 +01:00
committed by GitHub
parent 5f5190625d
commit b2d9102b0d
10 changed files with 244 additions and 297 deletions
+235 -254
View File
File diff suppressed because it is too large Load Diff
@@ -24,12 +24,12 @@ use sc_consensus_slots::InherentDataProviderExt;
use sc_telemetry::TelemetryHandle; use sc_telemetry::TelemetryHandle;
use sp_api::{ApiExt, ProvideRuntimeApi}; use sp_api::{ApiExt, ProvideRuntimeApi};
use sp_block_builder::BlockBuilder as BlockBuilderApi; use sp_block_builder::BlockBuilder as BlockBuilderApi;
use sp_blockchain::{HeaderBackend, ProvideCache}; use sp_blockchain::HeaderBackend;
use sp_consensus::{CanAuthorWith, Error as ConsensusError}; use sp_consensus::{CanAuthorWith, Error as ConsensusError};
use sp_consensus_aura::{digests::CompatibleDigestItem, AuraApi}; use sp_consensus_aura::AuraApi;
use sp_core::crypto::Pair; use sp_core::crypto::Pair;
use sp_inherents::CreateInherentDataProviders; use sp_inherents::CreateInherentDataProviders;
use sp_runtime::traits::{Block as BlockT, DigestItemFor}; use sp_runtime::traits::Block as BlockT;
use std::{fmt::Debug, hash::Hash, sync::Arc}; use std::{fmt::Debug, hash::Hash, sync::Arc};
use substrate_prometheus_endpoint::Registry; use substrate_prometheus_endpoint::Registry;
@@ -69,7 +69,6 @@ where
C: 'static C: 'static
+ ProvideRuntimeApi<Block> + ProvideRuntimeApi<Block>
+ BlockOf + BlockOf
+ ProvideCache<Block>
+ Send + Send
+ Sync + Sync
+ AuxStore + AuxStore
@@ -79,7 +78,6 @@ where
+ Send + Send
+ Sync + Sync
+ 'static, + 'static,
DigestItemFor<Block>: CompatibleDigestItem<P::Signature>,
P: Pair + Send + Sync + 'static, P: Pair + Send + Sync + 'static,
P::Public: Clone + Eq + Send + Sync + Hash + Debug + Codec, P::Public: Clone + Eq + Send + Sync + Hash + Debug + Codec,
P::Signature: Codec, P::Signature: Codec,
+3 -12
View File
@@ -38,7 +38,7 @@ use sc_consensus_slots::{BackoffAuthoringBlocksStrategy, SlotInfo};
use sc_telemetry::TelemetryHandle; use sc_telemetry::TelemetryHandle;
use sp_api::ProvideRuntimeApi; use sp_api::ProvideRuntimeApi;
use sp_application_crypto::AppPublic; use sp_application_crypto::AppPublic;
use sp_blockchain::{HeaderBackend, ProvideCache}; use sp_blockchain::HeaderBackend;
use sp_consensus::{ use sp_consensus::{
EnableProofRecording, Environment, ProofRecording, Proposer, SlotData, SyncOracle, EnableProofRecording, Environment, ProofRecording, Proposer, SlotData, SyncOracle,
}; };
@@ -113,14 +113,8 @@ where
max_block_proposal_slot_portion: Option<SlotProportion>, max_block_proposal_slot_portion: Option<SlotProportion>,
) -> Self ) -> Self
where where
Client: ProvideRuntimeApi<B> Client:
+ BlockOf ProvideRuntimeApi<B> + BlockOf + AuxStore + HeaderBackend<B> + Send + Sync + 'static,
+ ProvideCache<B>
+ AuxStore
+ HeaderBackend<B>
+ Send
+ Sync
+ 'static,
Client::Api: AuraApi<B, P::Public>, Client::Api: AuraApi<B, P::Public>,
BI: BlockImport<B, Transaction = sp_api::TransactionFor<Client, B>> + Send + Sync + 'static, BI: BlockImport<B, Transaction = sp_api::TransactionFor<Client, B>> + Send + Sync + 'static,
SO: SyncOracle + Send + Sync + Clone + 'static, SO: SyncOracle + Send + Sync + Clone + 'static,
@@ -286,7 +280,6 @@ where
CIDP::InherentDataProviders: InherentDataProviderExt + Send, CIDP::InherentDataProviders: InherentDataProviderExt + Send,
Client: ProvideRuntimeApi<Block> Client: ProvideRuntimeApi<Block>
+ BlockOf + BlockOf
+ ProvideCache<Block>
+ AuxStore + AuxStore
+ HeaderBackend<Block> + HeaderBackend<Block>
+ Send + Send
@@ -367,7 +360,6 @@ where
CIDP::InherentDataProviders: InherentDataProviderExt + Send, CIDP::InherentDataProviders: InherentDataProviderExt + Send,
Client: ProvideRuntimeApi<Block> Client: ProvideRuntimeApi<Block>
+ BlockOf + BlockOf
+ ProvideCache<Block>
+ AuxStore + AuxStore
+ HeaderBackend<Block> + HeaderBackend<Block>
+ Send + Send
@@ -447,7 +439,6 @@ where
CIDP::InherentDataProviders: InherentDataProviderExt + Send, CIDP::InherentDataProviders: InherentDataProviderExt + Send,
Client: ProvideRuntimeApi<Block> Client: ProvideRuntimeApi<Block>
+ BlockOf + BlockOf
+ ProvideCache<Block>
+ AuxStore + AuxStore
+ HeaderBackend<Block> + HeaderBackend<Block>
+ Send + Send
@@ -17,7 +17,7 @@
//! The actual implementation of the validate block functionality. //! The actual implementation of the validate block functionality.
use frame_support::traits::{ExecuteBlock, ExtrinsicCall, Get, IsSubType}; use frame_support::traits::{ExecuteBlock, ExtrinsicCall, Get, IsSubType};
use sp_runtime::traits::{Block as BlockT, Extrinsic, HashFor, Header as HeaderT, NumberFor}; use sp_runtime::traits::{Block as BlockT, Extrinsic, HashFor, Header as HeaderT};
use sp_io::KillStorageResult; use sp_io::KillStorageResult;
use sp_std::prelude::*; use sp_std::prelude::*;
@@ -32,7 +32,7 @@ use sp_trie::MemoryDB;
type TrieBackend<B> = sp_state_machine::TrieBackend<MemoryDB<HashFor<B>>, HashFor<B>>; type TrieBackend<B> = sp_state_machine::TrieBackend<MemoryDB<HashFor<B>>, HashFor<B>>;
type Ext<'a, B> = sp_state_machine::Ext<'a, HashFor<B>, NumberFor<B>, TrieBackend<B>>; type Ext<'a, B> = sp_state_machine::Ext<'a, HashFor<B>, TrieBackend<B>>;
fn with_externalities<F: FnOnce(&mut dyn Externalities) -> R, R>(f: F) -> R { fn with_externalities<F: FnOnce(&mut dyn Externalities) -> R, R>(f: F) -> R {
sp_externalities::with_externalities(f).expect("Environmental externalities not set.") sp_externalities::with_externalities(f).expect("Environmental externalities not set.")
@@ -89,7 +89,6 @@ where
sp_io::storage::host_clear.replace_implementation(host_storage_clear), sp_io::storage::host_clear.replace_implementation(host_storage_clear),
sp_io::storage::host_root.replace_implementation(host_storage_root), sp_io::storage::host_root.replace_implementation(host_storage_root),
sp_io::storage::host_clear_prefix.replace_implementation(host_storage_clear_prefix), sp_io::storage::host_clear_prefix.replace_implementation(host_storage_clear_prefix),
sp_io::storage::host_changes_root.replace_implementation(host_storage_changes_root),
sp_io::storage::host_append.replace_implementation(host_storage_append), sp_io::storage::host_append.replace_implementation(host_storage_append),
sp_io::storage::host_next_key.replace_implementation(host_storage_next_key), sp_io::storage::host_next_key.replace_implementation(host_storage_next_key),
sp_io::storage::host_start_transaction sp_io::storage::host_start_transaction
@@ -229,10 +228,6 @@ fn host_storage_clear_prefix(prefix: &[u8], limit: Option<u32>) -> KillStorageRe
}) })
} }
fn host_storage_changes_root(parent_hash: &[u8]) -> Option<Vec<u8>> {
with_externalities(|ext| ext.storage_changes_root(parent_hash).ok().flatten())
}
fn host_storage_append(key: &[u8], value: Vec<u8>) { fn host_storage_append(key: &[u8], value: Vec<u8>) {
with_externalities(|ext| ext.storage_append(key.to_vec(), value)) with_externalities(|ext| ext.storage_append(key.to_vec(), value))
} }
@@ -181,7 +181,6 @@ fn testnet_genesis(
code: parachain_template_runtime::WASM_BINARY code: parachain_template_runtime::WASM_BINARY
.expect("WASM binary was not build, please build it!") .expect("WASM binary was not build, please build it!")
.to_vec(), .to_vec(),
changes_trie_config: Default::default(),
}, },
balances: parachain_template_runtime::BalancesConfig { balances: parachain_template_runtime::BalancesConfig {
balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 60)).collect(), balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 60)).collect(),
@@ -265,7 +265,6 @@ where
transaction_pool: transaction_pool.clone(), transaction_pool: transaction_pool.clone(),
spawn_handle: task_manager.spawn_handle(), spawn_handle: task_manager.spawn_handle(),
import_queue: import_queue.clone(), import_queue: import_queue.clone(),
on_demand: None,
block_announce_validator_builder: Some(Box::new(|_| block_announce_validator)), block_announce_validator_builder: Some(Box::new(|_| block_announce_validator)),
warp_sync: None, warp_sync: None,
})?; })?;
@@ -286,8 +285,6 @@ where
}; };
sc_service::spawn_tasks(sc_service::SpawnTasksParams { sc_service::spawn_tasks(sc_service::SpawnTasksParams {
on_demand: None,
remote_blockchain: None,
rpc_extensions_builder, rpc_extensions_builder,
client: client.clone(), client: client.clone(),
transaction_pool: transaction_pool.clone(), transaction_pool: transaction_pool.clone(),
@@ -47,7 +47,7 @@ mod types {
pub type Hash = sp_core::H256; pub type Hash = sp_core::H256;
/// Digest item type. /// Digest item type.
pub type DigestItem = sp_runtime::generic::DigestItem<Hash>; pub type DigestItem = sp_runtime::generic::DigestItem;
// Aura consensus authority. // Aura consensus authority.
pub type AuraId = sp_consensus_aura::sr25519::AuthorityId; pub type AuraId = sp_consensus_aura::sr25519::AuthorityId;
@@ -153,7 +153,6 @@ fn testnet_genesis(
code: rococo_parachain_runtime::WASM_BINARY code: rococo_parachain_runtime::WASM_BINARY
.expect("WASM binary was not build, please build it!") .expect("WASM binary was not build, please build it!")
.to_vec(), .to_vec(),
changes_trie_config: Default::default(),
}, },
balances: rococo_parachain_runtime::BalancesConfig { balances: rococo_parachain_runtime::BalancesConfig {
balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 60)).collect(), balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 60)).collect(),
@@ -172,7 +171,6 @@ fn shell_testnet_genesis(parachain_id: ParaId) -> shell_runtime::GenesisConfig {
code: shell_runtime::WASM_BINARY code: shell_runtime::WASM_BINARY
.expect("WASM binary was not build, please build it!") .expect("WASM binary was not build, please build it!")
.to_vec(), .to_vec(),
changes_trie_config: Default::default(),
}, },
parachain_info: shell_runtime::ParachainInfoConfig { parachain_id }, parachain_info: shell_runtime::ParachainInfoConfig { parachain_id },
parachain_system: Default::default(), parachain_system: Default::default(),
@@ -322,7 +320,6 @@ fn statemint_genesis(
code: statemint_runtime::WASM_BINARY code: statemint_runtime::WASM_BINARY
.expect("WASM binary was not build, please build it!") .expect("WASM binary was not build, please build it!")
.to_vec(), .to_vec(),
changes_trie_config: Default::default(),
}, },
balances: statemint_runtime::BalancesConfig { balances: statemint_runtime::BalancesConfig {
balances: endowed_accounts.iter().cloned().map(|k| (k, STATEMINT_ED * 4096)).collect(), balances: endowed_accounts.iter().cloned().map(|k| (k, STATEMINT_ED * 4096)).collect(),
@@ -499,7 +496,6 @@ fn statemine_genesis(
code: statemine_runtime::WASM_BINARY code: statemine_runtime::WASM_BINARY
.expect("WASM binary was not build, please build it!") .expect("WASM binary was not build, please build it!")
.to_vec(), .to_vec(),
changes_trie_config: Default::default(),
}, },
balances: statemine_runtime::BalancesConfig { balances: statemine_runtime::BalancesConfig {
balances: endowed_accounts.iter().cloned().map(|k| (k, STATEMINE_ED * 4096)).collect(), balances: endowed_accounts.iter().cloned().map(|k| (k, STATEMINE_ED * 4096)).collect(),
@@ -679,7 +675,6 @@ fn westmint_genesis(
code: westmint_runtime::WASM_BINARY code: westmint_runtime::WASM_BINARY
.expect("WASM binary was not build, please build it!") .expect("WASM binary was not build, please build it!")
.to_vec(), .to_vec(),
changes_trie_config: Default::default(),
}, },
balances: westmint_runtime::BalancesConfig { balances: westmint_runtime::BalancesConfig {
balances: endowed_accounts.iter().cloned().map(|k| (k, WESTMINT_ED * 4096)).collect(), balances: endowed_accounts.iter().cloned().map(|k| (k, WESTMINT_ED * 4096)).collect(),
@@ -345,7 +345,6 @@ where
transaction_pool: transaction_pool.clone(), transaction_pool: transaction_pool.clone(),
spawn_handle: task_manager.spawn_handle(), spawn_handle: task_manager.spawn_handle(),
import_queue: import_queue.clone(), import_queue: import_queue.clone(),
on_demand: None,
block_announce_validator_builder: Some(Box::new(|_| block_announce_validator)), block_announce_validator_builder: Some(Box::new(|_| block_announce_validator)),
warp_sync: None, warp_sync: None,
})?; })?;
@@ -354,8 +353,6 @@ where
let rpc_extensions_builder = Box::new(move |_, _| rpc_ext_builder(rpc_client.clone())); let rpc_extensions_builder = Box::new(move |_, _| rpc_ext_builder(rpc_client.clone()));
sc_service::spawn_tasks(sc_service::SpawnTasksParams { sc_service::spawn_tasks(sc_service::SpawnTasksParams {
on_demand: None,
remote_blockchain: None,
rpc_extensions_builder, rpc_extensions_builder,
client: client.clone(), client: client.clone(),
transaction_pool: transaction_pool.clone(), transaction_pool: transaction_pool.clone(),
@@ -523,7 +520,6 @@ where
transaction_pool: transaction_pool.clone(), transaction_pool: transaction_pool.clone(),
spawn_handle: task_manager.spawn_handle(), spawn_handle: task_manager.spawn_handle(),
import_queue: import_queue.clone(), import_queue: import_queue.clone(),
on_demand: None,
block_announce_validator_builder: Some(Box::new(|_| block_announce_validator)), block_announce_validator_builder: Some(Box::new(|_| block_announce_validator)),
warp_sync: None, warp_sync: None,
})?; })?;
@@ -544,8 +540,6 @@ where
}; };
sc_service::spawn_tasks(sc_service::SpawnTasksParams { sc_service::spawn_tasks(sc_service::SpawnTasksParams {
on_demand: None,
remote_blockchain: None,
rpc_extensions_builder, rpc_extensions_builder,
client: client.clone(), client: client.clone(),
transaction_pool: transaction_pool.clone(), transaction_pool: transaction_pool.clone(),
-3
View File
@@ -231,7 +231,6 @@ where
transaction_pool: transaction_pool.clone(), transaction_pool: transaction_pool.clone(),
spawn_handle: task_manager.spawn_handle(), spawn_handle: task_manager.spawn_handle(),
import_queue: import_queue.clone(), import_queue: import_queue.clone(),
on_demand: None,
block_announce_validator_builder: Some(Box::new(block_announce_validator_builder)), block_announce_validator_builder: Some(Box::new(block_announce_validator_builder)),
warp_sync: None, warp_sync: None,
})?; })?;
@@ -243,8 +242,6 @@ where
}; };
let rpc_handlers = sc_service::spawn_tasks(sc_service::SpawnTasksParams { let rpc_handlers = sc_service::spawn_tasks(sc_service::SpawnTasksParams {
on_demand: None,
remote_blockchain: None,
rpc_extensions_builder, rpc_extensions_builder,
client: client.clone(), client: client.clone(),
transaction_pool: transaction_pool.clone(), transaction_pool: transaction_pool.clone(),