mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 19:21:13 +00:00
Adder collator improvements (#1896)
* Fixes bug that collator wasn't sending `Declare` message * Set authority discovery config * Fixes bug that collator wasn't sending `Declare` message * Adds real overseer feature and makes the wasm_validation fail with a proper error * Adds README * Remove debug stuff * Add feature * Make adder collator use the correct parent when building a new block
This commit is contained in:
@@ -6,7 +6,7 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
# Substrate Client
|
||||
authority-discovery = { package = "sc-authority-discovery", git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
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" }
|
||||
@@ -21,7 +21,7 @@ service = { package = "sc-service", git = "https://github.com/paritytech/substra
|
||||
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" }
|
||||
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" }
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
//! Polkadot chain configurations.
|
||||
|
||||
use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
|
||||
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
|
||||
use babe_primitives::AuthorityId as BabeId;
|
||||
use grandpa::AuthorityId as GrandpaId;
|
||||
use hex_literal::hex;
|
||||
|
||||
@@ -40,7 +40,7 @@ pub trait RuntimeApiCollection:
|
||||
+ sp_api::Metadata<Block>
|
||||
+ sp_offchain::OffchainWorkerApi<Block>
|
||||
+ sp_session::SessionKeys<Block>
|
||||
+ authority_discovery_primitives::AuthorityDiscoveryApi<Block>
|
||||
+ sp_authority_discovery::AuthorityDiscoveryApi<Block>
|
||||
where
|
||||
<Self as sp_api::ApiExt<Block>>::StateBackend: sp_api::StateBackend<BlakeTwo256>,
|
||||
{}
|
||||
@@ -58,7 +58,7 @@ where
|
||||
+ sp_api::Metadata<Block>
|
||||
+ sp_offchain::OffchainWorkerApi<Block>
|
||||
+ sp_session::SessionKeys<Block>
|
||||
+ authority_discovery_primitives::AuthorityDiscoveryApi<Block>,
|
||||
+ sp_authority_discovery::AuthorityDiscoveryApi<Block>,
|
||||
<Self as sp_api::ApiExt<Block>>::StateBackend: sp_api::StateBackend<BlakeTwo256>,
|
||||
{}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ use {
|
||||
polkadot_node_core_proposer::ProposerFactory,
|
||||
polkadot_overseer::{AllSubsystems, BlockInfo, Overseer, OverseerHandler},
|
||||
polkadot_primitives::v1::ParachainHost,
|
||||
authority_discovery::Service as AuthorityDiscoveryService,
|
||||
sc_authority_discovery::{Service as AuthorityDiscoveryService, WorkerConfig as AuthorityWorkerConfig},
|
||||
sp_blockchain::HeaderBackend,
|
||||
sp_core::traits::SpawnNamed,
|
||||
sp_keystore::SyncCryptoStorePtr,
|
||||
@@ -475,6 +475,7 @@ pub fn new_full<RuntimeApi, Executor>(
|
||||
mut config: Configuration,
|
||||
is_collator: IsCollator,
|
||||
grandpa_pause: Option<(u32, u32)>,
|
||||
authority_discovery_config: Option<AuthorityWorkerConfig>,
|
||||
) -> Result<NewFull<Arc<FullClient<RuntimeApi, Executor>>>, Error>
|
||||
where
|
||||
RuntimeApi: ConstructRuntimeApi<Block, FullClient<RuntimeApi, Executor>> + Send + Sync + 'static,
|
||||
@@ -570,19 +571,20 @@ pub fn new_full<RuntimeApi, Executor>(
|
||||
use futures::StreamExt;
|
||||
|
||||
let authority_discovery_role = if role.is_authority() {
|
||||
authority_discovery::Role::PublishAndDiscover(
|
||||
sc_authority_discovery::Role::PublishAndDiscover(
|
||||
keystore_container.keystore(),
|
||||
)
|
||||
} else {
|
||||
// don't publish our addresses when we're only a collator
|
||||
authority_discovery::Role::Discover
|
||||
sc_authority_discovery::Role::Discover
|
||||
};
|
||||
let dht_event_stream = network.event_stream("authority-discovery")
|
||||
.filter_map(|e| async move { match e {
|
||||
Event::Dht(e) => Some(e),
|
||||
_ => None,
|
||||
}});
|
||||
let (worker, service) = authority_discovery::new_worker_and_service(
|
||||
let (worker, service) = sc_authority_discovery::new_worker_and_service_with_config(
|
||||
authority_discovery_config.unwrap_or_default(),
|
||||
client.clone(),
|
||||
network.clone(),
|
||||
Box::pin(dht_event_stream),
|
||||
@@ -900,30 +902,35 @@ pub fn build_full(
|
||||
config: Configuration,
|
||||
is_collator: IsCollator,
|
||||
grandpa_pause: Option<(u32, u32)>,
|
||||
authority_discovery_config: Option<AuthorityWorkerConfig>,
|
||||
) -> Result<NewFull<Client>, Error> {
|
||||
if config.chain_spec.is_rococo() {
|
||||
new_full::<rococo_runtime::RuntimeApi, RococoExecutor>(
|
||||
config,
|
||||
is_collator,
|
||||
grandpa_pause,
|
||||
authority_discovery_config,
|
||||
).map(|full| full.with_client(Client::Rococo))
|
||||
} else if config.chain_spec.is_kusama() {
|
||||
new_full::<kusama_runtime::RuntimeApi, KusamaExecutor>(
|
||||
config,
|
||||
is_collator,
|
||||
grandpa_pause,
|
||||
authority_discovery_config,
|
||||
).map(|full| full.with_client(Client::Kusama))
|
||||
} else if config.chain_spec.is_westend() {
|
||||
new_full::<westend_runtime::RuntimeApi, WestendExecutor>(
|
||||
config,
|
||||
is_collator,
|
||||
grandpa_pause,
|
||||
authority_discovery_config,
|
||||
).map(|full| full.with_client(Client::Westend))
|
||||
} else {
|
||||
new_full::<polkadot_runtime::RuntimeApi, PolkadotExecutor>(
|
||||
config,
|
||||
is_collator,
|
||||
grandpa_pause,
|
||||
authority_discovery_config,
|
||||
).map(|full| full.with_client(Client::Polkadot))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ polkadot-test-runtime = { path = "../../../runtime/test-runtime" }
|
||||
polkadot-runtime-parachains = { path = "../../../runtime/parachains" }
|
||||
|
||||
# Substrate dependencies
|
||||
authority-discovery = { package = "sc-authority-discovery", git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sc-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" }
|
||||
consensus_common = { package = "sp-consensus", git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
|
||||
@@ -49,7 +49,7 @@ use sp_blockchain::HeaderBackend;
|
||||
use sp_keyring::Sr25519Keyring;
|
||||
use sp_runtime::{codec::Encode, generic, traits::IdentifyAccount, MultiSigner};
|
||||
use sp_state_machine::BasicExternalities;
|
||||
use std::sync::Arc;
|
||||
use std::{sync::Arc, time::Duration};
|
||||
use substrate_test_client::{BlockchainEventsExt, RpcHandlersExt, RpcTransactionOutput, RpcTransactionError};
|
||||
|
||||
native_executor_instance!(
|
||||
@@ -76,6 +76,11 @@ pub fn polkadot_test_new_full(
|
||||
config,
|
||||
IsCollator::No,
|
||||
None,
|
||||
Some(sc_authority_discovery::WorkerConfig {
|
||||
query_interval: Duration::from_secs(1),
|
||||
query_start_delay: Duration::from_secs(0),
|
||||
..Default::default()
|
||||
}),
|
||||
).map_err(Into::into)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user