mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 07:01:05 +00:00
Don't send ActiveLeaves from leaves in db on startup in Overseer (#6727)
* Don't send `ActiveLeaves` from leaves in db on startup in Overseer. Wait for fresh leaves instead. * Don't pass initial set of leaves to Overseer * Fix compilation error in subsystem-test-helpers
This commit is contained in:
committed by
GitHub
parent
dfb60f32cd
commit
ed6fa5499c
@@ -49,7 +49,6 @@ use {
|
||||
polkadot_node_network_protocol::{
|
||||
peer_set::PeerSetProtocolNames, request_response::ReqProtocolNames,
|
||||
},
|
||||
polkadot_overseer::BlockInfo,
|
||||
sc_client_api::BlockBackend,
|
||||
sp_core::traits::SpawnNamed,
|
||||
sp_trie::PrefixedMemoryDB,
|
||||
@@ -129,10 +128,6 @@ pub use {rococo_runtime, rococo_runtime_constants};
|
||||
#[cfg(feature = "westend-native")]
|
||||
pub use {westend_runtime, westend_runtime_constants};
|
||||
|
||||
/// The maximum number of active leaves we forward to the [`Overseer`] on startup.
|
||||
#[cfg(any(test, feature = "full-node"))]
|
||||
const MAX_ACTIVE_LEAVES: usize = 4;
|
||||
|
||||
/// Provides the header and block number for a hash.
|
||||
///
|
||||
/// Decouples `sc_client_api::Backend` and `sp_blockchain::HeaderBackend`.
|
||||
@@ -668,56 +663,6 @@ impl IsCollator {
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the active leaves the overseer should start with.
|
||||
#[cfg(feature = "full-node")]
|
||||
async fn active_leaves<RuntimeApi, ExecutorDispatch>(
|
||||
select_chain: &impl SelectChain<Block>,
|
||||
client: &FullClient<RuntimeApi, ExecutorDispatch>,
|
||||
) -> Result<Vec<BlockInfo>, Error>
|
||||
where
|
||||
RuntimeApi: ConstructRuntimeApi<Block, FullClient<RuntimeApi, ExecutorDispatch>>
|
||||
+ Send
|
||||
+ Sync
|
||||
+ 'static,
|
||||
RuntimeApi::RuntimeApi:
|
||||
RuntimeApiCollection<StateBackend = sc_client_api::StateBackendFor<FullBackend, Block>>,
|
||||
ExecutorDispatch: NativeExecutionDispatch + 'static,
|
||||
{
|
||||
let best_block = select_chain.best_chain().await?;
|
||||
|
||||
let mut leaves = select_chain
|
||||
.leaves()
|
||||
.await
|
||||
.unwrap_or_default()
|
||||
.into_iter()
|
||||
.filter_map(|hash| {
|
||||
let number = HeaderBackend::number(client, hash).ok()??;
|
||||
|
||||
// Only consider leaves that are in maximum an uncle of the best block.
|
||||
if number < best_block.number().saturating_sub(1) {
|
||||
return None
|
||||
} else if hash == best_block.hash() {
|
||||
return None
|
||||
};
|
||||
|
||||
let parent_hash = client.header(hash).ok()??.parent_hash;
|
||||
|
||||
Some(BlockInfo { hash, parent_hash, number })
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
// Sort by block number and get the maximum number of leaves
|
||||
leaves.sort_by_key(|b| b.number);
|
||||
|
||||
leaves.push(BlockInfo {
|
||||
hash: best_block.hash(),
|
||||
parent_hash: *best_block.parent_hash(),
|
||||
number: *best_block.number(),
|
||||
});
|
||||
|
||||
Ok(leaves.into_iter().rev().take(MAX_ACTIVE_LEAVES).collect())
|
||||
}
|
||||
|
||||
pub const AVAILABILITY_CONFIG: AvailabilityConfig = AvailabilityConfig {
|
||||
col_data: parachains_db::REAL_COLUMNS.col_availability_data,
|
||||
col_meta: parachains_db::REAL_COLUMNS.col_availability_meta,
|
||||
@@ -1009,10 +954,6 @@ where
|
||||
|
||||
let overseer_client = client.clone();
|
||||
let spawner = task_manager.spawn_handle();
|
||||
// Cannot use the `RelayChainSelection`, since that'd require a setup _and running_ overseer
|
||||
// which we are about to setup.
|
||||
let active_leaves =
|
||||
futures::executor::block_on(active_leaves(select_chain.as_longest_chain(), &*client))?;
|
||||
|
||||
let authority_discovery_service = if auth_or_collator || overseer_enable_anyways {
|
||||
use futures::StreamExt;
|
||||
@@ -1068,7 +1009,6 @@ where
|
||||
.generate::<service::SpawnTaskHandle, FullClient<RuntimeApi, ExecutorDispatch>>(
|
||||
overseer_connector,
|
||||
OverseerGenArgs {
|
||||
leaves: active_leaves,
|
||||
keystore,
|
||||
runtime_client: overseer_client.clone(),
|
||||
parachains_db,
|
||||
|
||||
@@ -34,8 +34,8 @@ pub use polkadot_overseer::{
|
||||
HeadSupportsParachains,
|
||||
};
|
||||
use polkadot_overseer::{
|
||||
metrics::Metrics as OverseerMetrics, BlockInfo, InitializedOverseerBuilder, MetricsTrait,
|
||||
Overseer, OverseerConnector, OverseerHandle, SpawnGlue,
|
||||
metrics::Metrics as OverseerMetrics, InitializedOverseerBuilder, MetricsTrait, Overseer,
|
||||
OverseerConnector, OverseerHandle, SpawnGlue,
|
||||
};
|
||||
|
||||
use polkadot_primitives::runtime_api::ParachainHost;
|
||||
@@ -81,8 +81,6 @@ where
|
||||
RuntimeClient::Api: ParachainHost<Block> + BabeApi<Block> + AuthorityDiscoveryApi<Block>,
|
||||
Spawner: 'static + SpawnNamed + Clone + Unpin,
|
||||
{
|
||||
/// Set of initial relay chain leaves to track.
|
||||
pub leaves: Vec<BlockInfo>,
|
||||
/// The keystore to use for i.e. validator keys.
|
||||
pub keystore: Arc<LocalKeystore>,
|
||||
/// Runtime client generic, providing the `ProvieRuntimeApi` trait besides others.
|
||||
@@ -131,7 +129,6 @@ where
|
||||
/// with all default values.
|
||||
pub fn prepared_overseer_builder<Spawner, RuntimeClient>(
|
||||
OverseerGenArgs {
|
||||
leaves,
|
||||
keystore,
|
||||
runtime_client,
|
||||
parachains_db,
|
||||
@@ -309,11 +306,6 @@ where
|
||||
Metrics::register(registry)?,
|
||||
))
|
||||
.chain_selection(ChainSelectionSubsystem::new(chain_selection_config, parachains_db))
|
||||
.leaves(Vec::from_iter(
|
||||
leaves
|
||||
.into_iter()
|
||||
.map(|BlockInfo { hash, parent_hash: _, number }| (hash, number)),
|
||||
))
|
||||
.activation_external_listeners(Default::default())
|
||||
.span_per_active_leaf(Default::default())
|
||||
.active_leaves(Default::default())
|
||||
|
||||
Reference in New Issue
Block a user