pov-recovery: Enable pov-recovery as well on full nodes (#927)

* pov-recovery: Enable pov-recovery as well on full nodes

Pov recovery was before only enabled for collators. The reason behind this was prevention of spam of
the relay chain for block recovery. However, recent events has shown that this wasn't a good idea.
So, this pr enables pov-recover for normal full nodes as well, but with a much higher delay before
trying to recover a block. This means that full nodes will wait in minimum 2.5 minutes and in
maximum 5 minutes before recovering a block. This should give collators in "normal mode" enough time
to recover a block (they wait in maximum 6 seconds after they have seen a new candidate in the relay
chain) before recovering a block. So, we should hopefully not spam the relay chain.

* FMT

* Fixes

* Fix documentation
This commit is contained in:
Bastian Köcher
2022-01-21 20:16:11 +01:00
committed by GitHub
parent ab76ff5313
commit 035f7cee9f
7 changed files with 106 additions and 26 deletions
+37 -7
View File
@@ -54,7 +54,7 @@ pub struct StartCollatorParams<'a, Block: BlockT, BS, Client, RCInterface, Spawn
pub parachain_consensus: Box<dyn ParachainConsensus<Block>>,
pub import_queue: IQ,
pub collator_key: CollatorPair,
pub slot_duration: Duration,
pub relay_chain_slot_duration: Duration,
}
/// Start a collator node for a parachain.
@@ -74,7 +74,7 @@ pub async fn start_collator<'a, Block, BS, Client, Backend, RCInterface, Spawner
parachain_consensus,
import_queue,
collator_key,
slot_duration,
relay_chain_slot_duration,
}: StartCollatorParams<'a, Block, BS, Client, RCInterface, Spawner, IQ>,
) -> sc_service::error::Result<()>
where
@@ -111,7 +111,9 @@ where
relay_chain_interface
.overseer_handle()
.ok_or_else(|| "Polkadot full node did not provide an `OverseerHandle`!")?,
slot_duration,
// We want that collators wait at maximum the relay chain slot duration before starting
// to recover blocks.
cumulus_client_pov_recovery::RecoveryDelay::WithMax { max: relay_chain_slot_duration },
client.clone(),
import_queue,
relay_chain_interface.clone(),
@@ -140,26 +142,30 @@ where
}
/// Parameters given to [`start_full_node`].
pub struct StartFullNodeParams<'a, Block: BlockT, Client, RCInterface> {
pub struct StartFullNodeParams<'a, Block: BlockT, Client, RCInterface, IQ> {
pub para_id: ParaId,
pub client: Arc<Client>,
pub relay_chain_interface: RCInterface,
pub task_manager: &'a mut TaskManager,
pub announce_block: Arc<dyn Fn(Block::Hash, Option<Vec<u8>>) + Send + Sync>,
pub relay_chain_slot_duration: Duration,
pub import_queue: IQ,
}
/// Start a full node for a parachain.
///
/// A full node will only sync the given parachain and will follow the
/// tip of the chain.
pub fn start_full_node<Block, Client, Backend, RCInterface>(
pub fn start_full_node<Block, Client, Backend, RCInterface, IQ>(
StartFullNodeParams {
client,
announce_block,
task_manager,
relay_chain_interface,
para_id,
}: StartFullNodeParams<Block, Client, RCInterface>,
relay_chain_slot_duration,
import_queue,
}: StartFullNodeParams<Block, Client, RCInterface, IQ>,
) -> sc_service::error::Result<()>
where
Block: BlockT,
@@ -173,6 +179,7 @@ where
for<'a> &'a Client: BlockImport<Block>,
Backend: BackendT<Block> + 'static,
RCInterface: RelayChainInterface + Clone + 'static,
IQ: ImportQueue<Block> + 'static,
{
let consensus = cumulus_client_consensus_common::run_parachain_consensus(
para_id,
@@ -185,10 +192,33 @@ where
.spawn_essential_handle()
.spawn("cumulus-consensus", None, consensus);
let pov_recovery = cumulus_client_pov_recovery::PoVRecovery::new(
relay_chain_interface
.overseer_handle()
.ok_or_else(|| "Polkadot full node did not provide an `OverseerHandle`!")?,
// Full nodes should at least wait 2.5 minutes (assuming 6 seconds slot duration) and
// in maximum 5 minutes before starting to recover blocks. Collators should already start
// the recovery way before full nodes try to recover a certain block and then share the
// block with the network using "the normal way". Full nodes are just the "last resort"
// for block recovery.
cumulus_client_pov_recovery::RecoveryDelay::WithMinAndMax {
min: relay_chain_slot_duration * 25,
max: relay_chain_slot_duration * 50,
},
client.clone(),
import_queue,
relay_chain_interface.clone(),
para_id,
);
task_manager
.spawn_essential_handle()
.spawn("cumulus-pov-recovery", None, pov_recovery.run());
Ok(())
}
/// Prepare the parachain's node condifugration
/// Prepare the parachain's node configuration
///
/// This function will disable the default announcement of Substrate for the parachain in favor
/// of the one of Cumulus.