polkadot_statement_table/lib.rs
1// Copyright (C) Parity Technologies (UK) Ltd.
2// This file is part of Polkadot.
3
4// Polkadot is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8
9// Polkadot is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License
15// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
16
17//! The statement table.
18//!
19//! This stores messages other authorities issue about candidates.
20//!
21//! These messages are used to create a proposal submitted to a BFT consensus process.
22//!
23//! Proposals are formed of sets of candidates which have the requisite number of
24//! validity and availability votes.
25//!
26//! Each parachain is associated with two sets of authorities: those which can
27//! propose and attest to validity of candidates, and those who can only attest
28//! to availability.
29
30pub mod generic;
31
32pub use generic::{Context, Table};
33
34/// Concrete instantiations suitable for v2 primitives.
35pub mod v2 {
36 use crate::generic;
37 use polkadot_primitives::{
38 vstaging::CommittedCandidateReceiptV2 as CommittedCandidateReceipt, CandidateHash,
39 CompactStatement as PrimitiveStatement, CoreIndex, ValidatorIndex, ValidatorSignature,
40 };
41
42 /// Statements about candidates on the network.
43 pub type Statement = generic::Statement<CommittedCandidateReceipt, CandidateHash>;
44
45 /// Signed statements about candidates.
46 pub type SignedStatement = generic::SignedStatement<
47 CommittedCandidateReceipt,
48 CandidateHash,
49 ValidatorIndex,
50 ValidatorSignature,
51 >;
52
53 /// Kinds of misbehavior, along with proof.
54 pub type Misbehavior = generic::Misbehavior<
55 CommittedCandidateReceipt,
56 CandidateHash,
57 ValidatorIndex,
58 ValidatorSignature,
59 >;
60
61 /// A summary of import of a statement.
62 pub type Summary = generic::Summary<CandidateHash, CoreIndex>;
63
64 impl<'a> From<&'a Statement> for PrimitiveStatement {
65 fn from(s: &'a Statement) -> PrimitiveStatement {
66 match *s {
67 generic::Statement::Valid(s) => PrimitiveStatement::Valid(s),
68 generic::Statement::Seconded(ref s) => PrimitiveStatement::Seconded(s.hash()),
69 }
70 }
71 }
72}