Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
157 commits
Select commit Hold shift + click to select a range
1ea0bcf
test/malus: craft the first maliciously disputing actor
drahnr Aug 12, 2021
64b5769
initial draft
drahnr Aug 13, 2021
54bfb57
Add Dockerfile and instructions how to use it to build malus image lo…
radupopa2010 Aug 16, 2021
6493fb6
Forgot one flag for the build cmd
radupopa2010 Aug 16, 2021
84bdc32
we are not docker specific, we are happy to use any containerruntime
drahnr Aug 16, 2021
49f6b83
shuffle things around
drahnr Aug 16, 2021
f03474e
add initial tera based integration test
drahnr Aug 16, 2021
8f7390a
chores
drahnr Aug 16, 2021
765c466
fixins
drahnr Aug 17, 2021
5f4c020
simple setup to start
drahnr Aug 17, 2021
433ac96
other samples (WIP)
drahnr Aug 17, 2021
47a2ecc
add Docker version with cargo-chef
radupopa2010 Aug 17, 2021
5882374
update substarte and small change of orders in commands in the contai…
radupopa2010 Aug 18, 2021
fc4dc08
metrics one
drahnr Aug 17, 2021
3cee6a0
fmt
drahnr Aug 17, 2021
1165add
minor
drahnr Aug 18, 2021
ed9d983
fixin
drahnr Aug 18, 2021
22ba0a3
fix metric names
drahnr Aug 18, 2021
5286ebd
-d
drahnr Aug 18, 2021
3830275
add open gauge
drahnr Aug 18, 2021
dc37848
fmt
drahnr Aug 18, 2021
d3e370c
spellcheck
drahnr Aug 18, 2021
99fb7f9
fix test
drahnr Aug 18, 2021
d889a9a
adjust to changed error messages
drahnr Aug 18, 2021
7a5f424
refactor, more malus impls
drahnr Aug 19, 2021
71a5006
more malus changes
drahnr Aug 19, 2021
e0835bb
foo
drahnr Aug 19, 2021
f1d67eb
minor cleanup
drahnr Aug 19, 2021
de2c4e6
suggest garbage candidate
drahnr Aug 19, 2021
b06b8e9
chore
drahnr Aug 19, 2021
a61fad8
fix suggest garabge malus
drahnr Aug 19, 2021
0ac0a75
malus: back garbage candidate
drahnr Aug 20, 2021
a94cd01
Merge remote-tracking branch 'origin/master' into bernhard-malus-fx
drahnr Aug 20, 2021
246cfa4
cargo lock
drahnr Aug 20, 2021
45b4418
re-introduce metrics
drahnr Aug 20, 2021
5227e3a
chore: cargo fmt
drahnr Aug 20, 2021
bb7f696
undoe 1.54.0 output, CI uses 1.53.0 rustc
drahnr Aug 21, 2021
edb2144
Merge remote-tracking branch 'origin/master' into bernhard-malus-fx
drahnr Aug 21, 2021
7e171f4
update location of js types
radupopa2010 Aug 22, 2021
70338d7
Merge branch 'bernhard-malus-fx' of github.com:paritytech/polkadot in…
radupopa2010 Aug 22, 2021
2b71ebe
Fix trybuild
bkchr Aug 23, 2021
8e21ba2
add tag to image name also; this will be replaced in the prod version
radupopa2010 Aug 24, 2021
de58741
Merge branch 'bernhard-malus-fx' of github.com:paritytech/polkadot in…
radupopa2010 Aug 24, 2021
9b499f2
Tests fixed
grbIzl Aug 24, 2021
5ce4261
Merge branch 'master' into bernhard-malus-fx
ordian Aug 24, 2021
f371b1d
add some fix me
radupopa2010 Aug 24, 2021
43a288c
add dockerfile for ci
radupopa2010 Aug 24, 2021
c826f29
Merge branch 'bernhard-malus-fx' of github.com:paritytech/polkadot in…
radupopa2010 Aug 24, 2021
55d7aae
Add docker file for malus for ci
radupopa2010 Aug 24, 2021
5738e1d
use variables in .toml file
radupopa2010 Aug 25, 2021
a68906d
add chnages for malus test
radupopa2010 Aug 25, 2021
987e4e9
some fixes
ordian Aug 25, 2021
4b98f7e
some more fixes
ordian Aug 25, 2021
26a808f
Update .gitlab-ci.yml
ordian Aug 25, 2021
2926a80
add local build for polkadot and malus
radupopa2010 Aug 26, 2021
77574c8
Merge branch 'bernhard-malus-fx' of github.com:paritytech/polkadot in…
radupopa2010 Aug 26, 2021
497cf40
Merge branch 'master' into bernhard-malus-fx
ordian Aug 27, 2021
4818242
some fixes
ordian Aug 27, 2021
d854fa8
enable disputes feature in CI
ordian Aug 27, 2021
67ddae5
ok, ok
ordian Aug 27, 2021
7449c86
Merge branch 'master' into bernhard-malus-fx
ordian Aug 27, 2021
eb2171a
rename: MsgFilter -> MessageInterceptor
drahnr Aug 30, 2021
08f97bd
remove TODO that would not have worked
drahnr Aug 30, 2021
22b5558
intercept
drahnr Aug 30, 2021
4ff6d8f
refactor
drahnr Aug 30, 2021
8994728
fix README and containers
drahnr Aug 30, 2021
e410fbb
fix
drahnr Aug 30, 2021
d4a3a49
chore: cargo fmt
drahnr Aug 30, 2021
93878de
avoid some more malus-$VARIANT references
drahnr Aug 31, 2021
38ef732
fix argument order
drahnr Aug 31, 2021
a11fe9c
chore: add about
drahnr Aug 31, 2021
970647f
Update sanity check in relay chain selection
Lldenaurois Aug 31, 2021
139ecf9
fix order, add dispute-unavailable-block malus
drahnr Aug 31, 2021
336cbe2
fixup: avoid underflow issue
drahnr Aug 31, 2021
6b3ae25
it's all u32
drahnr Aug 31, 2021
8d4a792
fix conditional use
drahnr Aug 31, 2021
ebdbafa
Revert "it's all u32"
drahnr Aug 31, 2021
4a93c46
Revert "fixup: avoid underflow issue"
drahnr Aug 31, 2021
faa96ff
Revert "Update sanity check in relay chain selection"
drahnr Aug 31, 2021
4bcd239
update the malus bin
radupopa2010 Aug 31, 2021
adbbd66
Update node/malus/integrationtests/0003-dispute-unavailable-block.fea…
drahnr Sep 1, 2021
8f0f646
add some FIXME reminders
radupopa2010 Sep 1, 2021
01b3f47
update path to index.js
radupopa2010 Sep 1, 2021
6d30765
Update .gitlab-ci.yml
ordian Sep 1, 2021
09c4136
Update node/malus/integrationtests/0001-dispute-valid-block.toml
ordian Sep 1, 2021
27665ac
try 1: make malus test run
radupopa2010 Sep 1, 2021
508fe73
merge recent changes
radupopa2010 Sep 1, 2021
ed8d1c2
chore: cargo fmt
drahnr Sep 2, 2021
6e96143
temporary fix
ordian Sep 2, 2021
20bff53
use subcommand syntax from latest gurke
ordian Sep 2, 2021
c3a8205
cargo +nightly fmt
ordian Sep 2, 2021
7edc660
Merge branch 'master' into bernhard-malus-fx
ordian Sep 2, 2021
6f7666c
add collator to a a test
ordian Sep 3, 2021
7a352be
docs: add env vars to README
drahnr Sep 6, 2021
6723967
update ci to run dispute-valid-block test
radupopa2010 Sep 6, 2021
d87f0e7
Merge branch 'bernhard-malus-fx' of github.com:paritytech/polkadot in…
radupopa2010 Sep 6, 2021
f01c3c1
needs the polkadot image
radupopa2010 Sep 6, 2021
ee0d312
Fix path for nodejs container
grbIzl Sep 6, 2021
720c91a
Merge branch 'master' into bernhard-malus-fx
ordian Sep 6, 2021
68ea3a5
post merge fix
ordian Sep 6, 2021
186bff4
download proper dir containg configs for malus test
radupopa2010 Sep 6, 2021
4081d02
Merge branch 'bernhard-malus-fx' of github.com:paritytech/polkadot in…
radupopa2010 Sep 6, 2021
87c48f3
update the malus ci job
radupopa2010 Sep 9, 2021
45cb0e1
merge master, keep my chnages
radupopa2010 Sep 9, 2021
1f6ae66
rm a whitespace
radupopa2010 Sep 9, 2021
1d155fe
temp build for malus
radupopa2010 Sep 14, 2021
72c1426
use correct build command for temp malus
radupopa2010 Sep 14, 2021
5d8292b
remove subcommands for now
ordian Sep 14, 2021
99cb6e0
Merge branch 'master' into bernhard-malus-fx
ordian Sep 14, 2021
76a0837
set max validators per core in the default HostConfig
ordian Sep 14, 2021
0d162b6
tabs
ordian Sep 14, 2021
93c6d06
Merge branch 'master' into bernhard-malus-fx
ordian Sep 17, 2021
f0f9551
Merge branch 'master' into bernhard-malus-fx
ordian Sep 17, 2021
a5f8b8b
update beefy
ordian Sep 17, 2021
f8de68a
fixup
ordian Sep 17, 2021
cd65b53
fixup II
ordian Sep 17, 2021
5827196
Merge branch 'master' into bernhard-malus-fx
ordian Sep 20, 2021
e0f8223
Merge branch 'master' into bernhard-malus-fx
ordian Oct 3, 2021
718301f
make one variant compile
ordian Oct 3, 2021
1b9ad32
make other variants compile
ordian Oct 3, 2021
2823592
revert changes to chain_spec
ordian Oct 3, 2021
f2e6e03
fmt
ordian Oct 3, 2021
e91d5a1
build malus image from polkadot-test-malus again
ordian Oct 3, 2021
e1bfca4
revert unrelated changes
ordian Oct 3, 2021
7bf62a9
try fixing build-malus job
ordian Oct 3, 2021
e04bcc9
Merge branch 'master' into bernhard-malus-fx
ordian Oct 3, 2021
9c3bf47
Revert "remove subcommands for now"
ordian Oct 3, 2021
a1b345c
try fixing build-malus job II
ordian Oct 3, 2021
d5cd103
Merge branch 'master' into bernhard-malus-fx
ordian Oct 3, 2021
bbbaa66
MVP working dispute-ancestor
ordian Oct 4, 2021
d356678
renames
ordian Oct 4, 2021
98389e4
Merge branch 'master' into bernhard-malus-fx
ordian Oct 4, 2021
e4bbd30
Merge branch 'master' into bernhard-malus-fx
ordian Oct 4, 2021
d0a17b2
fix PVF execution on malus
ordian Oct 4, 2021
e86c1ba
fix test
ordian Oct 4, 2021
e4a05e0
fix typo
ordian Oct 4, 2021
6c52998
fmt
ordian Oct 4, 2021
aa6695f
checkmate
ordian Oct 4, 2021
52b8864
try something
ordian Oct 4, 2021
fca9deb
make it actually work
ordian Oct 4, 2021
7e8626e
some tweaks to 01 feature test
ordian Oct 4, 2021
c504eb7
fmt
ordian Oct 4, 2021
8bef2c2
sleep a bit more
ordian Oct 4, 2021
517859b
complete wococoization
ordian Oct 5, 2021
2ff7637
some tweaks to 01 feature test
ordian Oct 5, 2021
42474af
typo fix
ordian Oct 5, 2021
b4e639e
use correct metric names
ordian Oct 5, 2021
8e345e9
fix
ordian Oct 5, 2021
6002ba1
ffs
ordian Oct 5, 2021
7aabc4f
.
ordian Oct 5, 2021
45dbef6
try some rearrangement
ordian Oct 5, 2021
efb7cd3
Attempt to wait till initial node bootstrap in test
grbIzl Oct 5, 2021
3bf9f49
Fix test syntax
grbIzl Oct 5, 2021
6cee882
Run malus tests with v2 script
grbIzl Oct 14, 2021
b3ef403
Merge branch 'master' into bernhard-malus-fx
ordian Oct 14, 2021
c46e26a
Proper symlink created
grbIzl Oct 14, 2021
06ac937
simnet v14
radupopa2010 Oct 15, 2021
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
352 changes: 179 additions & 173 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ panic = "unwind"
[features]
runtime-benchmarks= [ "polkadot-cli/runtime-benchmarks" ]
try-runtime = [ "polkadot-cli/try-runtime" ]
disputes = [ "polkadot-cli/disputes" ]

# Configuration for building a .deb package - for use with `cargo-deb`
[package.metadata.deb]
Expand Down
1 change: 1 addition & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,4 @@ westend-native = [ "service/westend-native" ]
rococo-native = [ "service/rococo-native" ]

malus = [ "full-node", "service/malus" ]
disputes = [ "service/disputes" ]
4 changes: 3 additions & 1 deletion node/core/approval-voting/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,8 @@ impl ApprovalState {
}

struct CurrentlyCheckingSet {
/// Invariant: The contained `Vec` needs to stay sorted as we are using `binary_search_by_key`
/// on it.
candidate_hash_map: HashMap<CandidateHash, Vec<Hash>>,
currently_checking: FuturesUnordered<BoxFuture<'static, ApprovalState>>,
}
Expand Down Expand Up @@ -918,7 +920,7 @@ async fn handle_actions(

match confirmation_rx.await {
Err(oneshot::Canceled) => {
tracing::warn!(target: LOG_TARGET, "Dispute coordinator confirmation lost",)
tracing::debug!(target: LOG_TARGET, "Dispute coordinator confirmation lost",)
},
Ok(ImportStatementsResult::ValidImport) => {},
Ok(ImportStatementsResult::InvalidImport) => tracing::warn!(
Expand Down
2 changes: 1 addition & 1 deletion node/core/backing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@ impl CandidateBackingJob {

match confirmation_rx.await {
Err(oneshot::Canceled) =>
tracing::warn!(target: LOG_TARGET, "Dispute coordinator confirmation lost",),
tracing::debug!(target: LOG_TARGET, "Dispute coordinator confirmation lost",),
Ok(ImportStatementsResult::ValidImport) => {},
Ok(ImportStatementsResult::InvalidImport) =>
tracing::warn!(target: LOG_TARGET, "Failed to import statements of validity",),
Expand Down
24 changes: 18 additions & 6 deletions node/core/candidate-validation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ pub struct Config {
/// The candidate validation subsystem.
pub struct CandidateValidationSubsystem {
metrics: Metrics,
pvf_metrics: polkadot_node_core_pvf::Metrics,
config: Config,
}

Expand All @@ -78,8 +79,12 @@ impl CandidateValidationSubsystem {
/// strategy.
///
/// Check out [`IsolationStrategy`] to get more details.
pub fn with_config(config: Config, metrics: Metrics) -> Self {
CandidateValidationSubsystem { config, metrics }
pub fn with_config(
config: Config,
metrics: Metrics,
pvf_metrics: polkadot_node_core_pvf::Metrics,
) -> Self {
CandidateValidationSubsystem { config, metrics, pvf_metrics }
}
}

Expand All @@ -89,17 +94,23 @@ where
Context: overseer::SubsystemContext<Message = CandidateValidationMessage>,
{
fn start(self, ctx: Context) -> SpawnedSubsystem {
let future =
run(ctx, self.metrics, self.config.artifacts_cache_path, self.config.program_path)
.map_err(|e| SubsystemError::with_origin("candidate-validation", e))
.boxed();
let future = run(
ctx,
self.metrics,
self.pvf_metrics,
self.config.artifacts_cache_path,
self.config.program_path,
)
.map_err(|e| SubsystemError::with_origin("candidate-validation", e))
.boxed();
SpawnedSubsystem { name: "candidate-validation-subsystem", future }
}
}

async fn run<Context>(
mut ctx: Context,
metrics: Metrics,
pvf_metrics: polkadot_node_core_pvf::Metrics,
cache_path: PathBuf,
program_path: PathBuf,
) -> SubsystemResult<()>
Expand All @@ -109,6 +120,7 @@ where
{
let (mut validation_host, task) = polkadot_node_core_pvf::start(
polkadot_node_core_pvf::Config::new(cache_path, program_path),
pvf_metrics,
);
ctx.spawn_blocking("pvf-validation-host", task.boxed())?;

Expand Down
4 changes: 4 additions & 0 deletions node/core/dispute-coordinator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "master" }
assert_matches = "1.4.0"
polkadot-overseer = { path = "../../overseer" }

[features]
# If not enabled, the dispute coordinator will do nothing.
disputes = []
263 changes: 263 additions & 0 deletions node/core/dispute-coordinator/src/dummy.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,263 @@
// Copyright 2020 Parity Technologies (UK) Ltd.
// This file is part of Polkadot.

// Polkadot is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Polkadot is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.

//! Implements the dispute coordinator subsystem (dummy implementation).

use std::sync::Arc;

use polkadot_node_subsystem::{
errors::{ChainApiError, RuntimeApiError},
messages::DisputeCoordinatorMessage,
overseer, FromOverseer, OverseerSignal, SpawnedSubsystem, SubsystemContext, SubsystemError,
};
use polkadot_primitives::v1::BlockNumber;

use futures::{channel::oneshot, prelude::*};
use kvdb::KeyValueDB;
use parity_scale_codec::{Decode, Encode, Error as CodecError};
use polkadot_node_subsystem_util::metrics::{self, prometheus};
use sc_keystore::LocalKeystore;

const LOG_TARGET: &str = "parachain::dispute-coordinator";

/// Candidate validation metrics placeholder.
#[derive(Default, Clone)]
pub struct Metrics;

impl metrics::Metrics for Metrics {
fn try_register(_: &prometheus::Registry) -> Result<Self, prometheus::PrometheusError> {
Ok(Metrics)
}
}

/// Timestamp based on the 1 Jan 1970 UNIX base, which is persistent across node restarts and OS reboots.
type Timestamp = u64;

#[derive(Eq, PartialEq)]
enum Participation {}

struct State {}

/// Configuration for the dispute coordinator subsystem.
#[derive(Debug, Clone, Copy)]
pub struct Config {
/// The data column in the store to use for dispute data.
pub col_data: u32,
}

/// An implementation of the dispute coordinator subsystem.
pub struct DisputeCoordinatorSubsystem {}

impl DisputeCoordinatorSubsystem {
/// Create a new instance of the subsystem.
pub fn new(_: Arc<dyn KeyValueDB>, _: Config, _: Arc<LocalKeystore>, _: Metrics) -> Self {
Self {}
}
}

impl<Context> overseer::Subsystem<Context, SubsystemError> for DisputeCoordinatorSubsystem
where
Context: SubsystemContext<Message = DisputeCoordinatorMessage>,
Context: overseer::SubsystemContext<Message = DisputeCoordinatorMessage>,
{
fn start(self, ctx: Context) -> SpawnedSubsystem {
let future = run(self, ctx).map(|_| Ok(())).boxed();

SpawnedSubsystem { name: "dispute-coordinator-subsystem", future }
}
}

#[derive(Debug, thiserror::Error)]
#[allow(missing_docs)]
pub enum Error {
#[error(transparent)]
RuntimeApi(#[from] RuntimeApiError),

#[error(transparent)]
ChainApi(#[from] ChainApiError),

#[error(transparent)]
Io(#[from] std::io::Error),

#[error(transparent)]
Oneshot(#[from] oneshot::Canceled),

#[error("Oneshot send failed")]
OneshotSend,

#[error(transparent)]
Subsystem(#[from] SubsystemError),

#[error(transparent)]
Codec(#[from] CodecError),
}

impl Error {
fn trace(&self) {
match self {
// don't spam the log with spurious errors
Self::RuntimeApi(_) | Self::Oneshot(_) =>
tracing::debug!(target: LOG_TARGET, err = ?self),
// it's worth reporting otherwise
_ => tracing::warn!(target: LOG_TARGET, err = ?self),
}
}
}

/// The status of dispute. This is a state machine which can be altered by the
/// helper methods.
#[derive(Debug, Clone, Copy, Encode, Decode, PartialEq)]
pub enum DisputeStatus {
/// The dispute is active and unconcluded.
#[codec(index = 0)]
Active,
/// The dispute has been concluded in favor of the candidate
/// since the given timestamp.
#[codec(index = 1)]
ConcludedFor(Timestamp),
/// The dispute has been concluded against the candidate
/// since the given timestamp.
///
/// This takes precedence over `ConcludedFor` in the case that
/// both are true, which is impossible unless a large amount of
/// validators are participating on both sides.
#[codec(index = 2)]
ConcludedAgainst(Timestamp),
}

impl DisputeStatus {
/// Initialize the status to the active state.
pub fn active() -> DisputeStatus {
DisputeStatus::Active
}

/// Transition the status to a new status after observing the dispute has concluded for the candidate.
/// This may be a no-op if the status was already concluded.
pub fn concluded_for(self, now: Timestamp) -> DisputeStatus {
match self {
DisputeStatus::Active => DisputeStatus::ConcludedFor(now),
DisputeStatus::ConcludedFor(at) => DisputeStatus::ConcludedFor(std::cmp::min(at, now)),
against => against,
}
}

/// Transition the status to a new status after observing the dispute has concluded against the candidate.
/// This may be a no-op if the status was already concluded.
pub fn concluded_against(self, now: Timestamp) -> DisputeStatus {
match self {
DisputeStatus::Active => DisputeStatus::ConcludedAgainst(now),
DisputeStatus::ConcludedFor(at) =>
DisputeStatus::ConcludedAgainst(std::cmp::min(at, now)),
DisputeStatus::ConcludedAgainst(at) =>
DisputeStatus::ConcludedAgainst(std::cmp::min(at, now)),
}
}

/// Whether the disputed candidate is possibly invalid.
pub fn is_possibly_invalid(&self) -> bool {
match self {
DisputeStatus::Active | DisputeStatus::ConcludedAgainst(_) => true,
DisputeStatus::ConcludedFor(_) => false,
}
}

/// Yields the timestamp this dispute concluded at, if any.
pub fn concluded_at(&self) -> Option<Timestamp> {
match self {
DisputeStatus::Active => None,
DisputeStatus::ConcludedFor(at) | DisputeStatus::ConcludedAgainst(at) => Some(*at),
}
}
}

async fn run<Context>(subsystem: DisputeCoordinatorSubsystem, mut ctx: Context)
where
Context: overseer::SubsystemContext<Message = DisputeCoordinatorMessage>,
Context: SubsystemContext<Message = DisputeCoordinatorMessage>,
{
loop {
let res = run_until_error(&mut ctx, &subsystem).await;
match res {
Err(e) => {
e.trace();

if let Error::Subsystem(SubsystemError::Context(_)) = e {
break
}
},
Ok(()) => {
tracing::info!(target: LOG_TARGET, "received `Conclude` signal, exiting");
break
},
}
}
}

async fn run_until_error<Context>(
ctx: &mut Context,
_: &DisputeCoordinatorSubsystem,
) -> Result<(), Error>
where
Context: overseer::SubsystemContext<Message = DisputeCoordinatorMessage>,
Context: SubsystemContext<Message = DisputeCoordinatorMessage>,
{
let mut state = State {};

loop {
match ctx.recv().await? {
FromOverseer::Signal(OverseerSignal::Conclude) => return Ok(()),
FromOverseer::Signal(OverseerSignal::ActiveLeaves(_)) => {},
FromOverseer::Signal(OverseerSignal::BlockFinalized(_, _)) => {},
FromOverseer::Communication { msg } => handle_incoming(ctx, &mut state, msg).await?,
}
}
}

async fn handle_incoming(
_: &mut impl SubsystemContext,
_: &mut State,
message: DisputeCoordinatorMessage,
) -> Result<(), Error> {
match message {
DisputeCoordinatorMessage::ImportStatements { .. } => { /* just drop confirmation */ },
DisputeCoordinatorMessage::RecentDisputes(tx) => {
let _ = tx.send(Vec::new());
},
DisputeCoordinatorMessage::ActiveDisputes(tx) => {
let _ = tx.send(Vec::new());
},
DisputeCoordinatorMessage::QueryCandidateVotes(_, tx) => {
let _ = tx.send(Vec::new());
},
DisputeCoordinatorMessage::IssueLocalStatement(_, _, _, _) => {},
DisputeCoordinatorMessage::DetermineUndisputedChain {
base_number,
block_descriptions,
tx,
} => {
let undisputed_chain = block_descriptions
.last()
.map(|e| (base_number + block_descriptions.len() as BlockNumber, e.block_hash));

let _ = tx.send(undisputed_chain);
},
}

Ok(())
}

#[derive(Debug, thiserror::Error)]
enum DisputeMessageCreationError {}
Loading