Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DNM] [TEST ONLY] Disable block authoring backoff for all networks #2649

Closed
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion polkadot/node/core/chain-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ async fn run<Client, Context>(
where
Client: HeaderBackend<Block> + AuxStore,
{
let mut fake_finalized = None;

loop {
match ctx.recv().await? {
FromOrchestra::Signal(OverseerSignal::Conclude) => return Ok(()),
Expand Down Expand Up @@ -119,7 +121,12 @@ where
},
ChainApiMessage::FinalizedBlockNumber(response_channel) => {
let _timer = subsystem.metrics.time_finalized_block_number();
let result = subsystem.client.info().finalized_number;
let result = if let Some(fake) = fake_finalized {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is enough, no need to change FinalizedBlockHash as doesn't actually check finality.

fake
} else {
fake_finalized = Some(subsystem.client.info().finalized_number);
fake_finalized.unwrap()
};
// always succeeds
subsystem.metrics.on_request(true);
let _ = response_channel.send(Ok(result));
Expand Down
59 changes: 6 additions & 53 deletions polkadot/node/core/dispute-coordinator/src/initialized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use polkadot_node_primitives::{
};
use polkadot_node_subsystem::{
messages::{
ApprovalVotingMessage, BlockDescription, ChainSelectionMessage, DisputeCoordinatorMessage,
ApprovalVotingMessage, ChainSelectionMessage, DisputeCoordinatorMessage,
DisputeDistributionMessage, ImportStatementsResult,
},
overseer, ActivatedLeaf, ActiveLeavesUpdate, FromOrchestra, OverseerSignal, RuntimeApiError,
Expand All @@ -43,7 +43,7 @@ use polkadot_node_subsystem_util::runtime::{
self, key_ownership_proof, submit_report_dispute_lost, RuntimeInfo,
};
use polkadot_primitives::{
slashing, BlockNumber, CandidateHash, CandidateReceipt, CompactStatement, DisputeStatement,
slashing, CandidateHash, CandidateReceipt, CompactStatement, DisputeStatement,
DisputeStatementSet, Hash, ScrapedOnChainVotes, SessionIndex, ValidDisputeStatementKind,
ValidatorId, ValidatorIndex,
};
Expand Down Expand Up @@ -896,23 +896,16 @@ impl Initialized {
.await?;
},
DisputeCoordinatorMessage::DetermineUndisputedChain {
base: (base_number, base_hash),
block_descriptions,
tx,
base: (_base_number, _base_hash),
block_descriptions: _,
tx: _,
} => {
gum::trace!(
target: LOG_TARGET,
"DisputeCoordinatorMessage::DetermineUndisputedChain"
);

let undisputed_chain = determine_undisputed_chain(
overlay_db,
base_number,
base_hash,
block_descriptions,
)?;

let _ = tx.send(undisputed_chain);
return Err(crate::error::Error::SessionInfo);
},
}

Expand Down Expand Up @@ -1551,43 +1544,3 @@ impl MaybeCandidateReceipt {
}
}
}

/// Determine the best block and its block number.
/// Assumes `block_descriptions` are sorted from the one
/// with the lowest `BlockNumber` to the highest.
fn determine_undisputed_chain(
overlay_db: &mut OverlayedBackend<'_, impl Backend>,
base_number: BlockNumber,
base_hash: Hash,
block_descriptions: Vec<BlockDescription>,
) -> Result<(BlockNumber, Hash)> {
let last = block_descriptions
.last()
.map(|e| (base_number + block_descriptions.len() as BlockNumber, e.block_hash))
.unwrap_or((base_number, base_hash));

// Fast path for no disputes.
let recent_disputes = match overlay_db.load_recent_disputes()? {
None => return Ok(last),
Some(a) if a.is_empty() => return Ok(last),
Some(a) => a,
};

let is_possibly_invalid = |session, candidate_hash| {
recent_disputes
.get(&(session, candidate_hash))
.map_or(false, |status| status.is_possibly_invalid())
};

for (i, BlockDescription { session, candidates, .. }) in block_descriptions.iter().enumerate() {
if candidates.iter().any(|c| is_possibly_invalid(*session, *c)) {
if i == 0 {
return Ok((base_number, base_hash))
} else {
return Ok((base_number + i as BlockNumber, block_descriptions[i - 1].block_hash))
}
}
}

Ok(last)
}
3 changes: 3 additions & 0 deletions polkadot/node/core/dispute-coordinator/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1450,6 +1450,7 @@ fn conflicting_votes_lead_to_dispute_participation() {
}

#[test]
#[ignore]
fn positive_votes_dont_trigger_participation() {
test_harness(|mut test_state, mut virtual_overseer| {
Box::pin(async move {
Expand Down Expand Up @@ -1638,6 +1639,7 @@ fn wrong_validator_index_is_ignored() {
}

#[test]
#[ignore]
fn finality_votes_ignore_disputed_candidates() {
test_harness(|mut test_state, mut virtual_overseer| {
Box::pin(async move {
Expand Down Expand Up @@ -1747,6 +1749,7 @@ fn finality_votes_ignore_disputed_candidates() {
}

#[test]
#[ignore]
fn supermajority_valid_dispute_may_be_finalized() {
test_harness(|mut test_state, mut virtual_overseer| {
Box::pin(async move {
Expand Down
30 changes: 1 addition & 29 deletions polkadot/node/overseer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -821,35 +821,7 @@ where
Ok(())
}

async fn block_finalized(&mut self, block: BlockInfo) -> SubsystemResult<()> {
let mut update = ActiveLeavesUpdate::default();

self.active_leaves.retain(|h, n| {
// prune all orphaned leaves, but don't prune
// the finalized block if it is itself a leaf.
if *n <= block.number && *h != block.hash {
update.deactivated.push(*h);
false
} else {
true
}
});

for deactivated in &update.deactivated {
self.on_head_deactivated(deactivated)
}

self.broadcast_signal(OverseerSignal::BlockFinalized(block.hash, block.number))
s0me0ne-unkn0wn marked this conversation as resolved.
Show resolved Hide resolved
.await?;

// If there are no leaves being deactivated, we don't need to send an update.
//
// Our peers will be informed about our finalized block the next time we
// activating/deactivating some leaf.
if !update.is_empty() {
self.broadcast_signal(OverseerSignal::ActiveLeaves(update)).await?;
}

async fn block_finalized(&mut self, _block: BlockInfo) -> SubsystemResult<()> {
Ok(())
}

Expand Down
18 changes: 3 additions & 15 deletions polkadot/node/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -733,21 +733,9 @@ pub fn new_full<OverseerGenerator: OverseerGen>(
let is_offchain_indexing_enabled = config.offchain_worker.indexing_enabled;
let role = config.role.clone();
let force_authoring = config.force_authoring;
let backoff_authoring_blocks = {
let mut backoff = sc_consensus_slots::BackoffAuthoringOnFinalizedHeadLagging::default();

if config.chain_spec.is_rococo() ||
config.chain_spec.is_wococo() ||
config.chain_spec.is_versi()
{
// it's a testnet that's in flux, finality has stalled sometimes due
// to operational issues and it's annoying to slow down block
// production to 1 block per hour.
backoff.max_interval = 10;
}

Some(backoff)
};
let backoff_authoring_blocks: Option<
sc_consensus_slots::BackoffAuthoringOnFinalizedHeadLagging<u32>,
> = None;

let disable_grandpa = config.disable_grandpa;
let name = config.network.node_name.clone();
Expand Down
Loading