Limit number of blocks per level (2nd attempt) (#1559)

Prevents the StateDbError::TooManySiblingBlocks error from being triggered by eagerly removing 
stale blocks from the backend on block import and before the error condition is met.

Introduces a just in time block recovery mechanism for blocks that were wrongly removed
via an explicit pov-recovery method

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
Davide Galassi
2022-12-20 12:13:49 +01:00
committed by GitHub
parent f621351332
commit 73837c384e
17 changed files with 1096 additions and 184 deletions
+13 -12
View File
@@ -51,7 +51,7 @@ type ParachainClient = TFullClient<Block, RuntimeApi, ParachainExecutor>;
type ParachainBackend = TFullBackend<Block>;
type ParachainBlockImport = TParachainBlockImport<Arc<ParachainClient>>;
type ParachainBlockImport = TParachainBlockImport<Block, Arc<ParachainClient>, ParachainBackend>;
/// Starts a `ServiceBuilder` for a full service.
///
@@ -111,7 +111,7 @@ pub fn new_partial(
client.clone(),
);
let block_import = ParachainBlockImport::new(client.clone());
let block_import = ParachainBlockImport::new(client.clone(), backend.clone());
let import_queue = build_import_queue(
client.clone(),
@@ -141,7 +141,7 @@ async fn start_node_impl(
parachain_config: Configuration,
polkadot_config: Configuration,
collator_options: CollatorOptions,
id: ParaId,
para_id: ParaId,
hwbench: Option<sc_sysinfo::HwBench>,
) -> sc_service::error::Result<(TaskManager, Arc<ParachainClient>)> {
let parachain_config = prepare_node_config(parachain_config);
@@ -167,7 +167,8 @@ async fn start_node_impl(
s => s.to_string().into(),
})?;
let block_announce_validator = BlockAnnounceValidator::new(relay_chain_interface.clone(), id);
let block_announce_validator =
BlockAnnounceValidator::new(relay_chain_interface.clone(), para_id);
let force_authoring = parachain_config.force_authoring;
let validator = parachain_config.role.is_authority();
@@ -219,7 +220,7 @@ async fn start_node_impl(
task_manager: &mut task_manager,
config: parachain_config,
keystore: params.keystore_container.sync_keystore(),
backend: backend.clone(),
backend,
network: network.clone(),
system_rpc_tx,
tx_handler_controller,
@@ -258,12 +259,12 @@ async fn start_node_impl(
network,
params.keystore_container.sync_keystore(),
force_authoring,
id,
para_id,
)?;
let spawner = task_manager.spawn_handle();
let params = StartCollatorParams {
para_id: id,
para_id,
block_status: client.clone(),
announce_block,
client: client.clone(),
@@ -282,7 +283,7 @@ async fn start_node_impl(
client: client.clone(),
announce_block,
task_manager: &mut task_manager,
para_id: id,
para_id,
relay_chain_interface,
relay_chain_slot_duration,
import_queue: import_queue_service,
@@ -345,7 +346,7 @@ fn build_consensus(
sync_oracle: Arc<NetworkService<Block, Hash>>,
keystore: SyncCryptoStorePtr,
force_authoring: bool,
id: ParaId,
para_id: ParaId,
) -> Result<Box<dyn ParachainConsensus<Block>>, sc_service::Error> {
let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?;
@@ -367,7 +368,7 @@ fn build_consensus(
relay_parent,
&relay_chain_interface,
&validation_data,
id,
para_id,
)
.await;
let timestamp = sp_timestamp::InherentDataProvider::from_system_time();
@@ -408,8 +409,8 @@ pub async fn start_parachain_node(
parachain_config: Configuration,
polkadot_config: Configuration,
collator_options: CollatorOptions,
id: ParaId,
para_id: ParaId,
hwbench: Option<sc_sysinfo::HwBench>,
) -> sc_service::error::Result<(TaskManager, Arc<ParachainClient>)> {
start_node_impl(parachain_config, polkadot_config, collator_options, id, hwbench).await
start_node_impl(parachain_config, polkadot_config, collator_options, para_id, hwbench).await
}