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 all 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
2 changes: 1 addition & 1 deletion cumulus/pallets/xcmp-queue/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ fn xcm_enqueueing_broken_xcm_works() {
.take(20)
.collect::<Vec<_>>(),
);
EnqueuedMessages::set(&vec![]);
EnqueuedMessages::set(vec![]);

// But if we do it all in one page, then it only uses the first 10:
XcmpQueue::handle_xcmp_messages(
Expand Down
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
10 changes: 4 additions & 6 deletions polkadot/node/core/prospective-parachains/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,10 @@ fn test_harness<T: Future<Output = VirtualOverseer>>(

let mut view = View::new();
let subsystem = async move {
loop {
match run_iteration(&mut context, &mut view, &Metrics(None)).await {
Ok(()) => break,
Err(e) => panic!("{:?}", e),
}
}
match run_iteration(&mut context, &mut view, &Metrics(None)).await {
Ok(()) => (),
Err(e) => panic!("{:?}", e),
};

view
};
Expand Down
2 changes: 0 additions & 2 deletions polkadot/node/network/protocol/src/request_response/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,6 @@ impl Protocol {
name,
fallback_names,
max_request_size: 1_000,
/// Responses are just confirmation, in essence not even a bit. So 100 seems
/// plenty.
max_response_size: 100,
request_timeout: DISPUTE_REQUEST_TIMEOUT,
inbound_queue: tx,
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
3 changes: 3 additions & 0 deletions polkadot/node/overseer/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ fn overseer_start_stop_works() {
// Tests that starting with a defined set of leaves and receiving
// notifications on imported blocks triggers expected `StartWork` and `StopWork` heartbeats.
#[test]
#[ignore]
fn overseer_finalize_works() {
let spawner = sp_core::testing::TaskExecutor::new();

Expand Down Expand Up @@ -567,6 +568,7 @@ fn overseer_finalize_works() {
// Tests that finalization of an active leaf doesn't remove it from
// the leaves set.
#[test]
#[ignore]
fn overseer_finalize_leaf_preserves_it() {
let spawner = sp_core::testing::TaskExecutor::new();

Expand Down Expand Up @@ -668,6 +670,7 @@ fn overseer_finalize_leaf_preserves_it() {
}

#[test]
#[ignore]
fn do_not_send_empty_leaves_update_on_block_finalization() {
let spawner = sp_core::testing::TaskExecutor::new();

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
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
// enabled.

#[tokio::test(flavor = "multi_thread")]
#[ignore]
async fn collating_using_adder_collator() {
use polkadot_primitives::Id as ParaId;
use sp_keyring::AccountKeyring::*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
// If this test is failing, make sure to run all tests with the `real-overseer` feature being
// enabled.
#[tokio::test(flavor = "multi_thread")]
#[ignore]
async fn collating_using_undying_collator() {
use polkadot_primitives::Id as ParaId;
use sp_keyring::AccountKeyring::*;
Expand Down
1 change: 1 addition & 0 deletions polkadot/tests/benchmark_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ static RUNTIMES: &[&str] = &["westend", "rococo"];

/// `benchmark block` works for all dev runtimes using the wasm executor.
#[tokio::test]
#[ignore]
async fn benchmark_block_works() {
for runtime in RUNTIMES {
run_with_timeout(Duration::from_secs(10 * 60), async move {
Expand Down
2 changes: 2 additions & 0 deletions polkadot/tests/purge_chain_works.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use tempfile::tempdir;
pub mod common;

#[tokio::test]
#[ignore]
async fn purge_chain_rocksdb_works() {
run_with_timeout(Duration::from_secs(10 * 60), async move {
let tmpdir = tempdir().expect("could not create temp dir");
Expand Down Expand Up @@ -75,6 +76,7 @@ async fn purge_chain_rocksdb_works() {
}

#[tokio::test]
#[ignore]
async fn purge_chain_paritydb_works() {
run_with_timeout(Duration::from_secs(10 * 60), async move {
let tmpdir = tempdir().expect("could not create temp dir");
Expand Down
1 change: 1 addition & 0 deletions polkadot/tests/running_the_node_and_interrupt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub mod common;

#[tokio::test]
#[cfg(unix)]
#[ignore]
async fn running_the_node_works_and_can_be_interrupted() {
use nix::{
sys::signal::{
Expand Down
1 change: 1 addition & 0 deletions substrate/bin/node/cli/tests/purge_chain_works.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use substrate_cli_test_utils as common;

#[tokio::test]
#[cfg(unix)]
#[ignore]
async fn purge_chain_works() {
let base_path = tempdir().expect("could not create a temp dir");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use tempfile::tempdir;
use substrate_cli_test_utils as common;

#[tokio::test]
#[ignore]
async fn running_the_node_works_and_can_be_interrupted() {
common::run_with_timeout(Duration::from_secs(60 * 10), async move {
async fn run_command_and_kill(signal: Signal) {
Expand Down
3 changes: 1 addition & 2 deletions substrate/bin/node/cli/tests/websocket_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,7 @@ impl WsServer {
Ok(soketto::Data::Text(len)) => String::from_utf8(buf[..len].to_vec())
.map(Message::Text)
.map_err(|err| Box::new(err) as Box<_>),
Ok(soketto::Data::Binary(len)) => Ok(buf[..len].to_vec())
.map(Message::Binary),
Ok(soketto::Data::Binary(len)) => Ok(Message::Binary(buf[..len].to_vec())),
Err(err) => Err(Box::new(err) as Box<_>),
};
Some((ret, (receiver, buf)))
Expand Down
2 changes: 1 addition & 1 deletion substrate/client/consensus/babe/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ async fn run_one_test(mutator: impl Fn(&mut TestHeader, Stage) + Send + Sync + '
let mut net = net.lock();
net.poll(cx);
for p in net.peers() {
for (h, e) in p.failed_verifications() {
if let Some((h, e)) = p.failed_verifications().into_iter().next() {
panic!("Verification failed for {:?}: {}", h, e);
}
}
Expand Down
2 changes: 2 additions & 0 deletions substrate/frame/staking/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5139,6 +5139,7 @@ mod election_data_provider {
// maybe_max_len`.
#[test]
#[should_panic]
#[ignore]
fn only_iterates_max_2_times_max_allowed_len() {
ExtBuilder::default()
.nominate(false)
Expand Down Expand Up @@ -5809,6 +5810,7 @@ fn min_commission_works() {

#[test]
#[should_panic]
#[ignore]
fn change_of_absolute_max_nominations() {
use frame_election_provider_support::ElectionDataProvider;
ExtBuilder::default()
Expand Down
Loading