Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

CI: run disputes tests #3962

Merged
6 commits merged into from
Sep 29, 2021
Merged
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
39 changes: 28 additions & 11 deletions node/core/dispute-coordinator/src/real/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use polkadot_node_primitives::{
use polkadot_node_subsystem::{
errors::{ChainApiError, RuntimeApiError},
messages::{
BlockDescription, ChainApiMessage, DisputeCoordinatorMessage, DisputeDistributionMessage,
BlockDescription, DisputeCoordinatorMessage, DisputeDistributionMessage,
DisputeParticipationMessage, ImportStatementsResult,
},
overseer, FromOverseer, OverseerSignal, SpawnedSubsystem, SubsystemContext, SubsystemError,
Expand Down Expand Up @@ -522,7 +522,7 @@ async fn handle_incoming(
statements,
pending_confirmation,
} => {
let outcome = handle_import_statements(
handle_import_statements(
ctx,
overlay_db,
state,
Expand All @@ -531,10 +531,10 @@ async fn handle_incoming(
session,
statements,
now,
pending_confirmation,
metrics,
)
.await?;
pending_confirmation.send(outcome).map_err(|_| Error::OneshotSend)?;
},
DisputeCoordinatorMessage::RecentDisputes(rx) => {
let recent_disputes = overlay_db.load_recent_disputes()?.unwrap_or_default();
Expand Down Expand Up @@ -633,10 +633,14 @@ async fn handle_import_statements(
now: Timestamp,
pending_confirmation: oneshot::Sender<ImportStatementsResult>,
metrics: &Metrics,
) -> Result<ImportStatementsResult, Error> {
) -> Result<(), Error> {
if state.highest_session.map_or(true, |h| session + DISPUTE_WINDOW < h) {
// It is not valid to participate in an ancient dispute (spam?).
return Ok(ImportStatementsResult::InvalidImport)
pending_confirmation
.send(ImportStatementsResult::InvalidImport)
.map_err(|_| Error::OneshotSend)?;

return Ok(())
drahnr marked this conversation as resolved.
Show resolved Hide resolved
}

let validators = match state.rolling_session_window.session_info(session) {
Expand All @@ -647,7 +651,11 @@ async fn handle_import_statements(
"Missing info for session which has an active dispute",
);

return Ok(ImportStatementsResult::InvalidImport)
pending_confirmation
.send(ImportStatementsResult::InvalidImport)
.map_err(|_| Error::OneshotSend)?;

return Ok(())
},
Some(info) => info.validators.clone(),
};
Expand Down Expand Up @@ -772,12 +780,15 @@ async fn handle_import_statements(
//
// We expect that if the candidate is truly disputed that the higher-level network
// code will retry.
pending_confirmation
.send(ImportStatementsResult::InvalidImport)
.map_err(|_| Error::OneshotSend)?;

tracing::debug!(
target: LOG_TARGET,
"Recovering availability failed - invalid import."
);
return Ok(ImportStatementsResult::InvalidImport)
return Ok(())
}
metrics.on_open();

Expand All @@ -795,7 +806,11 @@ async fn handle_import_statements(

overlay_db.write_candidate_votes(session, candidate_hash, votes.into());

Ok(ImportStatementsResult::ValidImport)
pending_confirmation
.send(ImportStatementsResult::ValidImport)
.map_err(|_| Error::OneshotSend)?;

Ok(())
}

fn find_controlled_validator_indices(
Expand Down Expand Up @@ -902,7 +917,8 @@ async fn issue_local_statement(

// Do import
if !statements.is_empty() {
match handle_import_statements(
let (pending_confirmation, rx) = oneshot::channel();
handle_import_statements(
ctx,
overlay_db,
state,
Expand All @@ -911,10 +927,11 @@ async fn issue_local_statement(
session,
statements,
now,
pending_confirmation,
metrics,
)
.await?
{
.await?;
match rx.await {
Err(_) => {
tracing::error!(
target: LOG_TARGET,
Expand Down
19 changes: 4 additions & 15 deletions node/core/dispute-coordinator/src/real/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use parity_scale_codec::Encode;
use polkadot_node_subsystem::{
jaeger,
messages::{
AllMessages, BlockDescription, ChainApiMessage, RuntimeApiMessage, RuntimeApiRequest,
AllMessages, BlockDescription, RuntimeApiMessage, RuntimeApiRequest,
},
ActivatedLeaf, ActiveLeavesUpdate, LeafStatus,
};
Expand Down Expand Up @@ -170,33 +170,23 @@ impl TestState {
)))
.await;

self.handle_sync_queries(virtual_overseer, block_hash, block_header, session)
self.handle_sync_queries(virtual_overseer, block_hash, session)
.await;
}

async fn handle_sync_queries(
&self,
virtual_overseer: &mut VirtualOverseer,
block_hash: Hash,
block_header: Header,
session: SessionIndex,
) {
assert_matches!(
virtual_overseer.recv().await,
AllMessages::ChainApi(ChainApiMessage::BlockHeader(h, tx)) => {
assert_eq!(h, block_hash);
let _ = tx.send(Ok(Some(block_header)));
}
);

assert_matches!(
virtual_overseer.recv().await,
AllMessages::RuntimeApi(RuntimeApiMessage::Request(
h,
RuntimeApiRequest::SessionIndexForChild(tx),
)) => {
let parent_hash = session_to_hash(session, b"parent");
assert_eq!(h, parent_hash);
assert_eq!(h, block_hash);
let _ = tx.send(Ok(session));
}
);
Expand Down Expand Up @@ -236,8 +226,7 @@ impl TestState {
)))
.await;

let header = self.headers.get(leaf).unwrap().clone();
self.handle_sync_queries(virtual_overseer, *leaf, header, session).await;
self.handle_sync_queries(virtual_overseer, *leaf, session).await;
}
}

Expand Down
2 changes: 0 additions & 2 deletions parachain/test-parachains/adder/collator/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
# How to run this collator

First start two validators that will run for the relay chain:

```sh
cargo run --release -- -d alice --chain rococo-local --validator --alice --port 50551
cargo run --release -- -d bob --chain rococo-local --validator --bob --port 50552
```

Next start the collator that will collate for the adder parachain:

```sh
cargo run --release -p test-parachain-adder-collator -- --tmp --chain rococo-local --port 50553
```
Expand Down
1 change: 1 addition & 0 deletions scripts/gitlab/test_linux_stable.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ set -e
#shellcheck source=../common/lib.sh
source "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/../common/lib.sh"

time cargo test --release --locked -p polkadot-node-core-dispute-coordinator --features disputes
time cargo test --workspace --release --verbose --locked --features=runtime-benchmarks