mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 11:41:04 +00:00
This reverts commit 96f2615582.
This commit is contained in:
committed by
GitHub
parent
96f2615582
commit
9a0f08bfe1
@@ -1,76 +1,63 @@
|
||||
[package]
|
||||
name = "polkadot-service"
|
||||
name = "polkadot-service-new"
|
||||
version = "0.8.3"
|
||||
authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
# Substrate Client
|
||||
authority-discovery = { package = "sc-authority-discovery", git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
babe = { package = "sc-consensus-babe", git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
grandpa = { package = "sc-finality-grandpa", git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sc-block-builder = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sc-chain-spec = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sc-client-db = { 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-keystore = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sc-network = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sc-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
service = { package = "sc-service", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
telemetry = { package = "sc-telemetry", git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
|
||||
# Substrate Primitives
|
||||
authority-discovery-primitives = { package = "sp-authority-discovery", git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
babe-primitives = { package = "sp-consensus-babe", git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
consensus_common = { package = "sp-consensus", git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
grandpa_primitives = { package = "sp-finality-grandpa", git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-block-builder = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-io = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-offchain = { package = "sp-offchain", git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-session = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-storage = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-trie = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
|
||||
# Substrate Pallets
|
||||
pallet-babe = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
pallet-im-online = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
pallet-staking = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
|
||||
# Substrate Other
|
||||
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
prometheus-endpoint = { package = "substrate-prometheus-endpoint", git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
|
||||
# External Crates
|
||||
codec = { package = "parity-scale-codec", version = "1.3.4" }
|
||||
futures = "0.3.4"
|
||||
hex-literal = "0.2.1"
|
||||
lazy_static = "1.4.0"
|
||||
log = "0.4.8"
|
||||
parking_lot = "0.9.0"
|
||||
serde = { version = "1.0.102", features = ["derive"] }
|
||||
lazy_static = "1.4.0"
|
||||
log = "0.4.8"
|
||||
futures = "0.3.4"
|
||||
slog = "2.5.2"
|
||||
|
||||
# Polkadot
|
||||
kusama-runtime = { path = "../../runtime/kusama" }
|
||||
polkadot-node-core-proposer = { path = "../core/proposer" }
|
||||
polkadot-overseer = { path = "../overseer" }
|
||||
polkadot-parachain = { path = "../../parachain" }
|
||||
hex-literal = "0.2.1"
|
||||
polkadot-primitives = { path = "../../primitives" }
|
||||
polkadot-rpc = { path = "../../rpc" }
|
||||
polkadot-runtime = { path = "../../runtime/polkadot" }
|
||||
polkadot-overseer = { path = "../overseer" }
|
||||
polkadot-subsystem = { package = "polkadot-node-subsystem", path = "../subsystem" }
|
||||
rococo-runtime = { package = "rococo-v1-runtime", path = "../../runtime/rococo-v1" }
|
||||
kusama-runtime = { path = "../../runtime/kusama" }
|
||||
westend-runtime = { path = "../../runtime/westend" }
|
||||
polkadot-rpc = { path = "../../rpc" }
|
||||
polkadot-node-core-proposer = { path = "../core/proposer" }
|
||||
sp-io = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sc-client-db = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sc-chain-spec = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sc-executor = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sc-network = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-storage = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-trie = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
consensus_common = { package = "sp-consensus", git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
grandpa = { package = "sc-finality-grandpa", git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
grandpa_primitives = { package = "sp-finality-grandpa", git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
service = { package = "sc-service", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
|
||||
telemetry = { package = "sc-telemetry", git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sc-block-builder = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sc-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sc-keystore = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
pallet-babe = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
pallet-staking = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
pallet-im-online = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
authority-discovery = { package = "sc-authority-discovery", git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
authority-discovery-primitives = { package = "sp-authority-discovery", git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
babe = { package = "sc-consensus-babe", git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
babe-primitives = { package = "sp-consensus-babe", git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-block-builder = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.4" }
|
||||
sp-session = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-offchain = { package = "sp-offchain", git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
prometheus-endpoint = { package = "substrate-prometheus-endpoint", git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
|
||||
[dev-dependencies]
|
||||
polkadot-test-runtime-client = { path = "../../runtime/test-runtime/client" }
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
!/*.json
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@@ -24,7 +24,7 @@ use sp_runtime::{
|
||||
};
|
||||
use sc_client_api::{Backend as BackendT, BlockchainEvents, KeyIterator};
|
||||
use sp_storage::{StorageData, StorageKey, ChildInfo, PrefixedStorageKey};
|
||||
use polkadot_primitives::v1::{Block, ParachainHost, AccountId, Nonce, Balance, Header, BlockNumber, Hash};
|
||||
use polkadot_primitives::v1::{Block, ParachainHost, AccountId, Nonce, Balance};
|
||||
use consensus_common::BlockStatus;
|
||||
|
||||
/// A set of APIs that polkadot-like runtimes must implement.
|
||||
@@ -142,7 +142,6 @@ pub enum Client {
|
||||
Polkadot(Arc<crate::FullClient<polkadot_runtime::RuntimeApi, crate::PolkadotExecutor>>),
|
||||
Westend(Arc<crate::FullClient<westend_runtime::RuntimeApi, crate::WestendExecutor>>),
|
||||
Kusama(Arc<crate::FullClient<kusama_runtime::RuntimeApi, crate::KusamaExecutor>>),
|
||||
Rococo(Arc<crate::FullClient<rococo_runtime::RuntimeApi, crate::RococoExecutor>>),
|
||||
}
|
||||
|
||||
impl ClientHandle for Client {
|
||||
@@ -157,9 +156,6 @@ impl ClientHandle for Client {
|
||||
Self::Kusama(client) => {
|
||||
T::execute_with_client::<_, _, crate::FullBackend>(t, client.clone())
|
||||
},
|
||||
Self::Rococo(client) => {
|
||||
T::execute_with_client::<_, _, crate::FullBackend>(t, client.clone())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -170,7 +166,6 @@ impl sc_client_api::UsageProvider<Block> for Client {
|
||||
Self::Polkadot(client) => client.usage_info(),
|
||||
Self::Westend(client) => client.usage_info(),
|
||||
Self::Kusama(client) => client.usage_info(),
|
||||
Self::Rococo(client) => client.usage_info(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -184,7 +179,6 @@ impl sc_client_api::BlockBackend<Block> for Client {
|
||||
Self::Polkadot(client) => client.block_body(id),
|
||||
Self::Westend(client) => client.block_body(id),
|
||||
Self::Kusama(client) => client.block_body(id),
|
||||
Self::Rococo(client) => client.block_body(id),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,7 +187,6 @@ impl sc_client_api::BlockBackend<Block> for Client {
|
||||
Self::Polkadot(client) => client.block(id),
|
||||
Self::Westend(client) => client.block(id),
|
||||
Self::Kusama(client) => client.block(id),
|
||||
Self::Rococo(client) => client.block(id),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,7 +195,6 @@ impl sc_client_api::BlockBackend<Block> for Client {
|
||||
Self::Polkadot(client) => client.block_status(id),
|
||||
Self::Westend(client) => client.block_status(id),
|
||||
Self::Kusama(client) => client.block_status(id),
|
||||
Self::Rococo(client) => client.block_status(id),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,7 +206,6 @@ impl sc_client_api::BlockBackend<Block> for Client {
|
||||
Self::Polkadot(client) => client.justification(id),
|
||||
Self::Westend(client) => client.justification(id),
|
||||
Self::Kusama(client) => client.justification(id),
|
||||
Self::Rococo(client) => client.justification(id),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,7 +217,6 @@ impl sc_client_api::BlockBackend<Block> for Client {
|
||||
Self::Polkadot(client) => client.block_hash(number),
|
||||
Self::Westend(client) => client.block_hash(number),
|
||||
Self::Kusama(client) => client.block_hash(number),
|
||||
Self::Rococo(client) => client.block_hash(number),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -241,7 +231,6 @@ impl sc_client_api::StorageProvider<Block, crate::FullBackend> for Client {
|
||||
Self::Polkadot(client) => client.storage(id, key),
|
||||
Self::Westend(client) => client.storage(id, key),
|
||||
Self::Kusama(client) => client.storage(id, key),
|
||||
Self::Rococo(client) => client.storage(id, key),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,7 +243,6 @@ impl sc_client_api::StorageProvider<Block, crate::FullBackend> for Client {
|
||||
Self::Polkadot(client) => client.storage_keys(id, key_prefix),
|
||||
Self::Westend(client) => client.storage_keys(id, key_prefix),
|
||||
Self::Kusama(client) => client.storage_keys(id, key_prefix),
|
||||
Self::Rococo(client) => client.storage_keys(id, key_prefix),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -267,7 +255,6 @@ impl sc_client_api::StorageProvider<Block, crate::FullBackend> for Client {
|
||||
Self::Polkadot(client) => client.storage_hash(id, key),
|
||||
Self::Westend(client) => client.storage_hash(id, key),
|
||||
Self::Kusama(client) => client.storage_hash(id, key),
|
||||
Self::Rococo(client) => client.storage_hash(id, key),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -280,7 +267,6 @@ impl sc_client_api::StorageProvider<Block, crate::FullBackend> for Client {
|
||||
Self::Polkadot(client) => client.storage_pairs(id, key_prefix),
|
||||
Self::Westend(client) => client.storage_pairs(id, key_prefix),
|
||||
Self::Kusama(client) => client.storage_pairs(id, key_prefix),
|
||||
Self::Rococo(client) => client.storage_pairs(id, key_prefix),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -294,7 +280,6 @@ impl sc_client_api::StorageProvider<Block, crate::FullBackend> for Client {
|
||||
Self::Polkadot(client) => client.storage_keys_iter(id, prefix, start_key),
|
||||
Self::Westend(client) => client.storage_keys_iter(id, prefix, start_key),
|
||||
Self::Kusama(client) => client.storage_keys_iter(id, prefix, start_key),
|
||||
Self::Rococo(client) => client.storage_keys_iter(id, prefix, start_key),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -308,7 +293,6 @@ impl sc_client_api::StorageProvider<Block, crate::FullBackend> for Client {
|
||||
Self::Polkadot(client) => client.child_storage(id, child_info, key),
|
||||
Self::Westend(client) => client.child_storage(id, child_info, key),
|
||||
Self::Kusama(client) => client.child_storage(id, child_info, key),
|
||||
Self::Rococo(client) => client.child_storage(id, child_info, key),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,7 +306,6 @@ impl sc_client_api::StorageProvider<Block, crate::FullBackend> for Client {
|
||||
Self::Polkadot(client) => client.child_storage_keys(id, child_info, key_prefix),
|
||||
Self::Westend(client) => client.child_storage_keys(id, child_info, key_prefix),
|
||||
Self::Kusama(client) => client.child_storage_keys(id, child_info, key_prefix),
|
||||
Self::Rococo(client) => client.child_storage_keys(id, child_info, key_prefix),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -336,7 +319,6 @@ impl sc_client_api::StorageProvider<Block, crate::FullBackend> for Client {
|
||||
Self::Polkadot(client) => client.child_storage_hash(id, child_info, key),
|
||||
Self::Westend(client) => client.child_storage_hash(id, child_info, key),
|
||||
Self::Kusama(client) => client.child_storage_hash(id, child_info, key),
|
||||
Self::Rococo(client) => client.child_storage_hash(id, child_info, key),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -349,7 +331,6 @@ impl sc_client_api::StorageProvider<Block, crate::FullBackend> for Client {
|
||||
Self::Polkadot(client) => client.max_key_changes_range(first, last),
|
||||
Self::Westend(client) => client.max_key_changes_range(first, last),
|
||||
Self::Kusama(client) => client.max_key_changes_range(first, last),
|
||||
Self::Rococo(client) => client.max_key_changes_range(first, last),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -364,54 +345,6 @@ impl sc_client_api::StorageProvider<Block, crate::FullBackend> for Client {
|
||||
Self::Polkadot(client) => client.key_changes(first, last, storage_key, key),
|
||||
Self::Westend(client) => client.key_changes(first, last, storage_key, key),
|
||||
Self::Kusama(client) => client.key_changes(first, last, storage_key, key),
|
||||
Self::Rococo(client) => client.key_changes(first, last, storage_key, key),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl sp_blockchain::HeaderBackend<Block> for Client {
|
||||
fn header(&self, id: BlockId<Block>) -> sp_blockchain::Result<Option<Header>> {
|
||||
match self {
|
||||
Self::Polkadot(client) => client.header(&id),
|
||||
Self::Westend(client) => client.header(&id),
|
||||
Self::Kusama(client) => client.header(&id),
|
||||
Self::Rococo(client) => client.header(&id),
|
||||
}
|
||||
}
|
||||
|
||||
fn info(&self) -> sp_blockchain::Info<Block> {
|
||||
match self {
|
||||
Self::Polkadot(client) => client.info(),
|
||||
Self::Westend(client) => client.info(),
|
||||
Self::Kusama(client) => client.info(),
|
||||
Self::Rococo(client) => client.info(),
|
||||
}
|
||||
}
|
||||
|
||||
fn status(&self, id: BlockId<Block>) -> sp_blockchain::Result<sp_blockchain::BlockStatus> {
|
||||
match self {
|
||||
Self::Polkadot(client) => client.status(id),
|
||||
Self::Westend(client) => client.status(id),
|
||||
Self::Kusama(client) => client.status(id),
|
||||
Self::Rococo(client) => client.status(id),
|
||||
}
|
||||
}
|
||||
|
||||
fn number(&self, hash: Hash) -> sp_blockchain::Result<Option<BlockNumber>> {
|
||||
match self {
|
||||
Self::Polkadot(client) => client.number(hash),
|
||||
Self::Westend(client) => client.number(hash),
|
||||
Self::Kusama(client) => client.number(hash),
|
||||
Self::Rococo(client) => client.number(hash),
|
||||
}
|
||||
}
|
||||
|
||||
fn hash(&self, number: BlockNumber) -> sp_blockchain::Result<Option<Hash>> {
|
||||
match self {
|
||||
Self::Polkadot(client) => client.hash(number),
|
||||
Self::Westend(client) => client.hash(number),
|
||||
Self::Kusama(client) => client.hash(number),
|
||||
Self::Rococo(client) => client.hash(number),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,8 +25,7 @@ use sp_runtime::traits::{Block as BlockT, NumberFor};
|
||||
/// `N` + `M`, the voter will keep voting for block `N`.
|
||||
pub(crate) struct PauseAfterBlockFor<N>(pub(crate) N, pub(crate) N);
|
||||
|
||||
impl<Block, B> grandpa::VotingRule<Block, B> for PauseAfterBlockFor<NumberFor<Block>>
|
||||
where
|
||||
impl<Block, B> grandpa::VotingRule<Block, B> for PauseAfterBlockFor<NumberFor<Block>> where
|
||||
Block: BlockT,
|
||||
B: sp_blockchain::HeaderBackend<Block>,
|
||||
{
|
||||
@@ -41,7 +40,10 @@ where
|
||||
use sp_runtime::traits::Header as _;
|
||||
|
||||
// walk backwards until we find the target block
|
||||
let find_target = |target_number: NumberFor<Block>, current_header: &Block::Header| {
|
||||
let find_target = |
|
||||
target_number: NumberFor<Block>,
|
||||
current_header: &Block::Header
|
||||
| {
|
||||
let mut target_hash = current_header.hash();
|
||||
let mut target_header = current_header.clone();
|
||||
|
||||
@@ -231,10 +233,10 @@ pub(crate) fn kusama_hard_forks() -> Vec<(
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use grandpa::VotingRule;
|
||||
use polkadot_test_runtime_client::prelude::*;
|
||||
use polkadot_test_runtime_client::sp_consensus::BlockOrigin;
|
||||
use sc_block_builder::BlockBuilderProvider;
|
||||
use grandpa::VotingRule;
|
||||
use sp_blockchain::HeaderBackend;
|
||||
use sp_runtime::generic::BlockId;
|
||||
use sp_runtime::traits::Header;
|
||||
@@ -277,12 +279,20 @@ mod tests {
|
||||
|
||||
// add 10 blocks
|
||||
push_blocks(10);
|
||||
assert_eq!(client.info().best_number, 10);
|
||||
assert_eq!(
|
||||
client.info().best_number,
|
||||
10,
|
||||
);
|
||||
|
||||
// we have not reached the pause block
|
||||
// therefore nothing should be restricted
|
||||
assert_eq!(
|
||||
voting_rule.restrict_vote(&*client, &get_header(0), &get_header(10), &get_header(10)),
|
||||
voting_rule.restrict_vote(
|
||||
&*client,
|
||||
&get_header(0),
|
||||
&get_header(10),
|
||||
&get_header(10),
|
||||
),
|
||||
None,
|
||||
);
|
||||
|
||||
@@ -293,7 +303,12 @@ mod tests {
|
||||
// we are targeting the pause block,
|
||||
// the vote should not be restricted
|
||||
assert_eq!(
|
||||
voting_rule.restrict_vote(&*client, &get_header(10), &get_header(20), &get_header(20)),
|
||||
voting_rule.restrict_vote(
|
||||
&*client,
|
||||
&get_header(10),
|
||||
&get_header(20),
|
||||
&get_header(20),
|
||||
),
|
||||
None,
|
||||
);
|
||||
|
||||
@@ -301,7 +316,12 @@ mod tests {
|
||||
// be limited to the pause block.
|
||||
let pause_block = get_header(20);
|
||||
assert_eq!(
|
||||
voting_rule.restrict_vote(&*client, &get_header(10), &get_header(21), &get_header(21)),
|
||||
voting_rule.restrict_vote(
|
||||
&*client,
|
||||
&get_header(10),
|
||||
&get_header(21),
|
||||
&get_header(21),
|
||||
),
|
||||
Some((pause_block.hash(), *pause_block.number())),
|
||||
);
|
||||
|
||||
|
||||
@@ -20,45 +20,41 @@ pub mod chain_spec;
|
||||
mod grandpa_support;
|
||||
mod client;
|
||||
|
||||
|
||||
use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider};
|
||||
use log::info;
|
||||
use polkadot_node_core_proposer::ProposerFactory;
|
||||
use polkadot_overseer::{AllSubsystems, BlockInfo, Overseer, OverseerHandler};
|
||||
use polkadot_subsystem::DummySubsystem;
|
||||
use prometheus_endpoint::Registry;
|
||||
use sc_client_api::ExecutorProvider;
|
||||
use sc_executor::native_executor_instance;
|
||||
use service::{error::Error as ServiceError, RpcHandlers};
|
||||
use sp_blockchain::HeaderBackend;
|
||||
use sp_core::traits::SpawnNamed;
|
||||
use sp_trie::PrefixedMemoryDB;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
||||
pub use self::client::{AbstractClient, Client, ClientHandle, ExecuteWithClient, RuntimeApiCollection};
|
||||
pub use chain_spec::{PolkadotChainSpec, KusamaChainSpec, WestendChainSpec, RococoChainSpec};
|
||||
#[cfg(feature = "full-node")]
|
||||
pub use codec::Codec;
|
||||
pub use consensus_common::{Proposal, SelectChain, BlockImport, RecordProof, block_validation::Chain};
|
||||
pub use polkadot_parachain::wasm_executor::run_worker as run_validation_worker;
|
||||
pub use polkadot_primitives::v1::{Block, BlockId, CollatorId, Id as ParaId};
|
||||
pub use sc_client_api::{Backend, ExecutionStrategy, CallExecutor};
|
||||
pub use sc_consensus::LongestChain;
|
||||
pub use sc_executor::NativeExecutionDispatch;
|
||||
use service::{error::Error as ServiceError, RpcHandlers};
|
||||
use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider};
|
||||
use sc_executor::native_executor_instance;
|
||||
use log::info;
|
||||
use sp_blockchain::HeaderBackend;
|
||||
use polkadot_overseer::{AllSubsystems, BlockInfo, Overseer, OverseerHandler};
|
||||
use polkadot_subsystem::DummySubsystem;
|
||||
use polkadot_node_core_proposer::ProposerFactory;
|
||||
use sp_trie::PrefixedMemoryDB;
|
||||
use sp_core::traits::SpawnNamed;
|
||||
use sc_client_api::ExecutorProvider;
|
||||
pub use service::{
|
||||
Role, PruningMode, TransactionPoolOptions, Error, RuntimeGenesis,
|
||||
TFullClient, TLightClient, TFullBackend, TLightBackend, TFullCallExecutor, TLightCallExecutor,
|
||||
Configuration, ChainSpec, TaskManager,
|
||||
};
|
||||
pub use service::config::{DatabaseConfig, PrometheusConfig};
|
||||
pub use sc_executor::NativeExecutionDispatch;
|
||||
pub use sc_client_api::{Backend, ExecutionStrategy, CallExecutor};
|
||||
pub use sc_consensus::LongestChain;
|
||||
pub use sp_api::{ApiRef, Core as CoreApi, ConstructRuntimeApi, ProvideRuntimeApi, StateBackend};
|
||||
pub use sp_runtime::traits::{DigestFor, HashFor, NumberFor, Block as BlockT, self as runtime_traits, BlakeTwo256};
|
||||
|
||||
pub use kusama_runtime;
|
||||
pub use sp_runtime::traits::{DigestFor, HashFor, NumberFor};
|
||||
pub use consensus_common::{Proposal, SelectChain, BlockImport, RecordProof, block_validation::Chain};
|
||||
pub use polkadot_primitives::v1::{Block, BlockId, CollatorId, Id as ParaId};
|
||||
pub use sp_runtime::traits::{Block as BlockT, self as runtime_traits, BlakeTwo256};
|
||||
pub use chain_spec::{PolkadotChainSpec, KusamaChainSpec, WestendChainSpec};
|
||||
#[cfg(feature = "full-node")]
|
||||
pub use codec::Codec;
|
||||
pub use polkadot_runtime;
|
||||
pub use rococo_runtime;
|
||||
pub use kusama_runtime;
|
||||
pub use westend_runtime;
|
||||
use prometheus_endpoint::Registry;
|
||||
pub use self::client::{AbstractClient, Client, RuntimeApiCollection};
|
||||
|
||||
native_executor_instance!(
|
||||
pub PolkadotExecutor,
|
||||
@@ -81,13 +77,6 @@ native_executor_instance!(
|
||||
frame_benchmarking::benchmarking::HostFunctions,
|
||||
);
|
||||
|
||||
native_executor_instance!(
|
||||
pub RococoExecutor,
|
||||
rococo_runtime::api::dispatch,
|
||||
rococo_runtime::native_version,
|
||||
frame_benchmarking::benchmarking::HostFunctions,
|
||||
);
|
||||
|
||||
/// Can be called for a `Configuration` to check if it is a configuration for the `Kusama` network.
|
||||
pub trait IdentifyVariant {
|
||||
/// Returns if this is a configuration for the `Kusama` network.
|
||||
@@ -95,9 +84,6 @@ pub trait IdentifyVariant {
|
||||
|
||||
/// Returns if this is a configuration for the `Westend` network.
|
||||
fn is_westend(&self) -> bool;
|
||||
|
||||
/// Returns if this is a configuration for the `Rococo` network.
|
||||
fn is_rococo(&self) -> bool;
|
||||
}
|
||||
|
||||
impl IdentifyVariant for Box<dyn ChainSpec> {
|
||||
@@ -107,9 +93,6 @@ impl IdentifyVariant for Box<dyn ChainSpec> {
|
||||
fn is_westend(&self) -> bool {
|
||||
self.id().starts_with("westend") || self.id().starts_with("wnd")
|
||||
}
|
||||
fn is_rococo(&self) -> bool {
|
||||
self.id().starts_with("rococo") || self.id().starts_with("rco")
|
||||
}
|
||||
}
|
||||
|
||||
// If we're using prometheus, use a registry with a prefix of `polkadot`.
|
||||
@@ -121,9 +104,9 @@ fn set_prometheus_registry(config: &mut Configuration) -> Result<(), ServiceErro
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub type FullBackend = service::TFullBackend<Block>;
|
||||
type FullBackend = service::TFullBackend<Block>;
|
||||
type FullSelectChain = sc_consensus::LongestChain<FullBackend, Block>;
|
||||
pub type FullClient<RuntimeApi, Executor> = service::TFullClient<Block, RuntimeApi, Executor>;
|
||||
type FullClient<RuntimeApi, Executor> = service::TFullClient<Block, RuntimeApi, Executor>;
|
||||
type FullGrandpaBlockImport<RuntimeApi, Executor> = grandpa::GrandpaBlockImport<
|
||||
FullBackend, Block, FullClient<RuntimeApi, Executor>, FullSelectChain
|
||||
>;
|
||||
@@ -298,40 +281,18 @@ fn real_overseer<S: SpawnNamed>(
|
||||
}
|
||||
|
||||
#[cfg(feature = "full-node")]
|
||||
pub struct NewFull<C> {
|
||||
pub task_manager: TaskManager,
|
||||
pub client: C,
|
||||
pub node_handles: OverseerHandler,
|
||||
pub network: Arc<sc_network::NetworkService<Block, <Block as BlockT>::Hash>>,
|
||||
pub network_status_sinks: service::NetworkStatusSinks<Block>,
|
||||
pub rpc_handlers: RpcHandlers,
|
||||
}
|
||||
|
||||
#[cfg(feature = "full-node")]
|
||||
impl<C> NewFull<C> {
|
||||
fn with_client(self, func: impl FnOnce(C) -> Client) -> NewFull<Client> {
|
||||
NewFull {
|
||||
client: func(self.client),
|
||||
task_manager: self.task_manager,
|
||||
node_handles: self.node_handles,
|
||||
network: self.network,
|
||||
network_status_sinks: self.network_status_sinks,
|
||||
rpc_handlers: self.rpc_handlers,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Create a new full node of arbitrary runtime and executor.
|
||||
///
|
||||
/// This is an advanced feature and not recommended for general use. Generally, `build_full` is
|
||||
/// a better choice.
|
||||
#[cfg(feature = "full-node")]
|
||||
pub fn new_full<RuntimeApi, Executor>(
|
||||
fn new_full<RuntimeApi, Executor>(
|
||||
mut config: Configuration,
|
||||
collating_for: Option<(CollatorId, ParaId)>,
|
||||
authority_discovery_enabled: bool,
|
||||
grandpa_pause: Option<(u32, u32)>,
|
||||
) -> Result<NewFull<Arc<FullClient<RuntimeApi, Executor>>>, Error>
|
||||
) -> Result<(
|
||||
TaskManager,
|
||||
Arc<FullClient<RuntimeApi, Executor>>,
|
||||
Arc<sc_network::NetworkService<Block, <Block as BlockT>::Hash>>,
|
||||
RpcHandlers,
|
||||
OverseerHandler,
|
||||
), Error>
|
||||
where
|
||||
RuntimeApi: ConstructRuntimeApi<Block, FullClient<RuntimeApi, Executor>> + Send + Sync + 'static,
|
||||
RuntimeApi::RuntimeApi:
|
||||
@@ -396,8 +357,7 @@ pub fn new_full<RuntimeApi, Executor>(
|
||||
on_demand: None,
|
||||
remote_blockchain: None,
|
||||
telemetry_connection_sinks: telemetry_connection_sinks.clone(),
|
||||
network_status_sinks: network_status_sinks.clone(),
|
||||
system_rpc_tx,
|
||||
network_status_sinks, system_rpc_tx,
|
||||
})?;
|
||||
|
||||
let (block_import, link_half, babe_link) = import_setup;
|
||||
@@ -510,8 +470,10 @@ pub fn new_full<RuntimeApi, Executor>(
|
||||
grandpa::VotingRulesBuilder::default()
|
||||
.add(grandpa_support::PauseAfterBlockFor(block, delay))
|
||||
.build()
|
||||
}
|
||||
None => grandpa::VotingRulesBuilder::default().build(),
|
||||
},
|
||||
None =>
|
||||
grandpa::VotingRulesBuilder::default()
|
||||
.build(),
|
||||
};
|
||||
|
||||
let grandpa_config = grandpa::GrandpaParams {
|
||||
@@ -577,14 +539,7 @@ pub fn new_full<RuntimeApi, Executor>(
|
||||
|
||||
network_starter.start_network();
|
||||
|
||||
Ok(NewFull {
|
||||
task_manager,
|
||||
client,
|
||||
node_handles: handler,
|
||||
network,
|
||||
network_status_sinks,
|
||||
rpc_handlers,
|
||||
})
|
||||
Ok((task_manager, client, network, rpc_handlers, handler))
|
||||
}
|
||||
|
||||
/// Builds a new service for a light client.
|
||||
@@ -612,9 +567,7 @@ fn new_light<Runtime, Dispatch>(mut config: Configuration) -> Result<(TaskManage
|
||||
));
|
||||
|
||||
let grandpa_block_import = grandpa::light_block_import(
|
||||
client.clone(),
|
||||
backend.clone(),
|
||||
&(client.clone() as Arc<_>),
|
||||
client.clone(), backend.clone(), &(client.clone() as Arc<_>),
|
||||
Arc::new(on_demand.checker().clone()),
|
||||
)?;
|
||||
|
||||
@@ -662,11 +615,7 @@ fn new_light<Runtime, Dispatch>(mut config: Configuration) -> Result<(TaskManage
|
||||
|
||||
if config.offchain_worker.enabled {
|
||||
service::build_offchain_workers(
|
||||
&config,
|
||||
backend.clone(),
|
||||
task_manager.spawn_handle(),
|
||||
client.clone(),
|
||||
network.clone(),
|
||||
&config, backend.clone(), task_manager.spawn_handle(), client.clone(), network.clone(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -702,41 +651,30 @@ fn new_light<Runtime, Dispatch>(mut config: Configuration) -> Result<(TaskManage
|
||||
|
||||
/// Builds a new object suitable for chain operations.
|
||||
#[cfg(feature = "full-node")]
|
||||
pub fn new_chain_ops(mut config: &mut Configuration) -> Result<
|
||||
pub fn new_chain_ops<Runtime, Dispatch>(mut config: &mut Configuration) -> Result<
|
||||
(
|
||||
Arc<Client>,
|
||||
Arc<FullClient<Runtime, Dispatch>>,
|
||||
Arc<FullBackend>,
|
||||
consensus_common::import_queue::BasicQueue<Block, PrefixedMemoryDB<BlakeTwo256>>,
|
||||
TaskManager,
|
||||
),
|
||||
ServiceError
|
||||
>
|
||||
where
|
||||
Runtime: ConstructRuntimeApi<Block, FullClient<Runtime, Dispatch>> + Send + Sync + 'static,
|
||||
Runtime::RuntimeApi:
|
||||
RuntimeApiCollection<StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>,
|
||||
Dispatch: NativeExecutionDispatch + 'static,
|
||||
{
|
||||
config.keystore = service::config::KeystoreConfig::InMemory;
|
||||
if config.chain_spec.is_rococo() {
|
||||
let service::PartialComponents { client, backend, import_queue, task_manager, .. }
|
||||
= new_partial::<rococo_runtime::RuntimeApi, RococoExecutor>(config)?;
|
||||
Ok((Arc::new(Client::Rococo(client)), backend, import_queue, task_manager))
|
||||
} else if config.chain_spec.is_kusama() {
|
||||
let service::PartialComponents { client, backend, import_queue, task_manager, .. }
|
||||
= new_partial::<kusama_runtime::RuntimeApi, KusamaExecutor>(config)?;
|
||||
Ok((Arc::new(Client::Kusama(client)), backend, import_queue, task_manager))
|
||||
} else if config.chain_spec.is_westend() {
|
||||
let service::PartialComponents { client, backend, import_queue, task_manager, .. }
|
||||
= new_partial::<westend_runtime::RuntimeApi, WestendExecutor>(config)?;
|
||||
Ok((Arc::new(Client::Westend(client)), backend, import_queue, task_manager))
|
||||
} else {
|
||||
let service::PartialComponents { client, backend, import_queue, task_manager, .. }
|
||||
= new_partial::<polkadot_runtime::RuntimeApi, PolkadotExecutor>(config)?;
|
||||
Ok((Arc::new(Client::Polkadot(client)), backend, import_queue, task_manager))
|
||||
}
|
||||
let service::PartialComponents { client, backend, import_queue, task_manager, .. }
|
||||
= new_partial::<Runtime, Dispatch>(config)?;
|
||||
Ok((client, backend, import_queue, task_manager))
|
||||
}
|
||||
|
||||
/// Build a new light node.
|
||||
pub fn build_light(config: Configuration) -> Result<(TaskManager, RpcHandlers), ServiceError> {
|
||||
if config.chain_spec.is_rococo() {
|
||||
new_light::<rococo_runtime::RuntimeApi, RococoExecutor>(config)
|
||||
} else if config.chain_spec.is_kusama() {
|
||||
if config.chain_spec.is_kusama() {
|
||||
new_light::<kusama_runtime::RuntimeApi, KusamaExecutor>(config)
|
||||
} else if config.chain_spec.is_westend() {
|
||||
new_light::<westend_runtime::RuntimeApi, WestendExecutor>(config)
|
||||
@@ -751,34 +689,27 @@ pub fn build_full(
|
||||
collating_for: Option<(CollatorId, ParaId)>,
|
||||
authority_discovery_enabled: bool,
|
||||
grandpa_pause: Option<(u32, u32)>,
|
||||
) -> Result<NewFull<Client>, ServiceError> {
|
||||
if config.chain_spec.is_rococo() {
|
||||
new_full::<rococo_runtime::RuntimeApi, RococoExecutor>(
|
||||
config,
|
||||
collating_for,
|
||||
authority_discovery_enabled,
|
||||
grandpa_pause,
|
||||
).map(|full| full.with_client(Client::Rococo))
|
||||
} else if config.chain_spec.is_kusama() {
|
||||
) -> Result<(TaskManager, Client, OverseerHandler), ServiceError> {
|
||||
if config.chain_spec.is_kusama() {
|
||||
new_full::<kusama_runtime::RuntimeApi, KusamaExecutor>(
|
||||
config,
|
||||
collating_for,
|
||||
authority_discovery_enabled,
|
||||
grandpa_pause,
|
||||
).map(|full| full.with_client(Client::Kusama))
|
||||
).map(|(task_manager, client, _, _, handler)| (task_manager, Client::Kusama(client), handler))
|
||||
} else if config.chain_spec.is_westend() {
|
||||
new_full::<westend_runtime::RuntimeApi, WestendExecutor>(
|
||||
config,
|
||||
collating_for,
|
||||
authority_discovery_enabled,
|
||||
grandpa_pause,
|
||||
).map(|full| full.with_client(Client::Westend))
|
||||
).map(|(task_manager, client, _, _, handler)| (task_manager, Client::Westend(client), handler))
|
||||
} else {
|
||||
new_full::<polkadot_runtime::RuntimeApi, PolkadotExecutor>(
|
||||
config,
|
||||
collating_for,
|
||||
authority_discovery_enabled,
|
||||
grandpa_pause,
|
||||
).map(|full| full.with_client(Client::Polkadot))
|
||||
).map(|(task_manager, client, _, _, handler)| (task_manager, Client::Polkadot(client), handler))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,11 +13,10 @@ rand = "0.7.3"
|
||||
tempfile = "3.1.0"
|
||||
|
||||
# Polkadot dependencies
|
||||
polkadot-overseer = { path = "../overseer" }
|
||||
polkadot-primitives = { path = "../../primitives" }
|
||||
polkadot-rpc = { path = "../../rpc" }
|
||||
polkadot-runtime-common = { path = "../../runtime/common" }
|
||||
polkadot-service = { path = "../service" }
|
||||
polkadot-service = { path = "../../service" }
|
||||
polkadot-test-runtime = { path = "../../runtime/test-runtime" }
|
||||
|
||||
# Substrate dependencies
|
||||
|
||||
@@ -22,13 +22,12 @@ mod chain_spec;
|
||||
|
||||
pub use chain_spec::*;
|
||||
use futures::future::Future;
|
||||
use polkadot_overseer::OverseerHandler;
|
||||
use polkadot_primitives::v0::{
|
||||
Block, CollatorId, Id as ParaId,
|
||||
Block, Hash, CollatorId, Id as ParaId,
|
||||
};
|
||||
use polkadot_runtime_common::BlockHashCount;
|
||||
use polkadot_service::{
|
||||
new_full, NewFull, FullClient, AbstractClient, ClientHandle, ExecuteWithClient,
|
||||
new_full, NewFull, FullNodeHandles, AbstractClient, ClientHandle, ExecuteWithClient,
|
||||
};
|
||||
use polkadot_test_runtime::{Runtime, SignedExtra, SignedPayload, VERSION};
|
||||
use sc_chain_spec::ChainSpec;
|
||||
@@ -37,7 +36,7 @@ use sc_executor::native_executor_instance;
|
||||
use sc_informant::OutputFormat;
|
||||
use sc_network::{
|
||||
config::{NetworkConfiguration, TransportConfig},
|
||||
multiaddr,
|
||||
multiaddr, NetworkService,
|
||||
};
|
||||
use service::{
|
||||
config::{DatabaseConfig, KeystoreConfig, MultiaddrWithPeerId, WasmExecutionMethod},
|
||||
@@ -66,15 +65,25 @@ pub fn polkadot_test_new_full(
|
||||
collating_for: Option<(CollatorId, ParaId)>,
|
||||
authority_discovery_enabled: bool,
|
||||
) -> Result<
|
||||
NewFull<Arc<FullClient<polkadot_test_runtime::RuntimeApi, PolkadotTestExecutor>>>,
|
||||
(
|
||||
TaskManager,
|
||||
Arc<polkadot_service::FullClient<polkadot_test_runtime::RuntimeApi, PolkadotTestExecutor>>,
|
||||
FullNodeHandles,
|
||||
Arc<NetworkService<Block, Hash>>,
|
||||
RpcHandlers,
|
||||
),
|
||||
ServiceError,
|
||||
> {
|
||||
new_full::<polkadot_test_runtime::RuntimeApi, PolkadotTestExecutor>(
|
||||
config,
|
||||
collating_for,
|
||||
authority_discovery_enabled,
|
||||
None,
|
||||
).map_err(Into::into)
|
||||
let NewFull { task_manager, client, node_handles, network, rpc_handlers, .. } =
|
||||
new_full::<polkadot_test_runtime::RuntimeApi, PolkadotTestExecutor>(
|
||||
config,
|
||||
collating_for,
|
||||
authority_discovery_enabled,
|
||||
None,
|
||||
true,
|
||||
)?;
|
||||
|
||||
Ok((task_manager, client, node_handles, network, rpc_handlers))
|
||||
}
|
||||
|
||||
/// A wrapper for the test client that implements `ClientHandle`.
|
||||
@@ -197,7 +206,7 @@ pub fn run_test_node(
|
||||
let config = node_config(storage_update_func, task_executor, key, boot_nodes);
|
||||
let multiaddr = config.network.listen_addresses[0].clone();
|
||||
let authority_discovery_enabled = false;
|
||||
let NewFull {task_manager, client, network, rpc_handlers, node_handles, ..} =
|
||||
let (task_manager, client, handles, network, rpc_handlers) =
|
||||
polkadot_test_new_full(config, None, authority_discovery_enabled)
|
||||
.expect("could not create Polkadot test service");
|
||||
|
||||
@@ -207,7 +216,7 @@ pub fn run_test_node(
|
||||
PolkadotTestNode {
|
||||
task_manager,
|
||||
client,
|
||||
handles: node_handles,
|
||||
handles,
|
||||
addr,
|
||||
rpc_handlers,
|
||||
}
|
||||
@@ -220,7 +229,7 @@ pub struct PolkadotTestNode<S, C> {
|
||||
/// Client's instance.
|
||||
pub client: Arc<C>,
|
||||
/// Node's handles.
|
||||
pub handles: OverseerHandler,
|
||||
pub handles: FullNodeHandles,
|
||||
/// The `MultiaddrWithPeerId` to this node. This is useful if you want to pass it as "boot node" to other nodes.
|
||||
pub addr: MultiaddrWithPeerId,
|
||||
/// RPCHandlers to make RPC queries.
|
||||
|
||||
Reference in New Issue
Block a user