Punish offline validators, aura-style (#1216)

* make offline-reporting infrastructure more generic

* add a listener-trait for watching when the timestamp has been set

* prevent inclusion of empty offline reports

* add test for exclusion

* generate aura-offline reports

* ability to slash many times for being offline "multiple" times

* Logic for punishing validators for missing aura steps

* stub tests

* pave way for verification of timestamp vs slot

* alter aura import queue to wait for timestamp

* check timestamp matches seal

* do inherent check properly

* service compiles

* all tests compile

* test srml-aura logic

* aura tests pass

* everything builds

* some more final tweaks to block authorship for aura

* switch to manual delays before step

* restore substrate-consensus-aura to always std and address grumbles

* update some state roots in executor tests

* node-executor tests pass

* get most tests passing

* address grumbles
This commit is contained in:
Robert Habermeier
2018-12-10 18:37:08 +01:00
committed by GitHub
parent dcc38fe45a
commit 6299b42a4d
41 changed files with 1344 additions and 379 deletions
+23 -4
View File
@@ -480,16 +480,19 @@ macro_rules! impl_outer_log {
pub struct BasicInherentData {
/// Current timestamp.
pub timestamp: u64,
/// Indices of offline validators.
pub consensus: Vec<u32>,
/// Blank report.
pub consensus: (),
/// Aura expected slot. Can take any value during block construction.
pub aura_expected_slot: u64,
}
impl BasicInherentData {
/// Create a new `BasicInherentData` instance.
pub fn new(timestamp: u64, consensus: Vec<u32>) -> Self {
pub fn new(timestamp: u64, expected_slot: u64) -> Self {
Self {
timestamp,
consensus,
consensus: (),
aura_expected_slot: expected_slot,
}
}
}
@@ -506,6 +509,22 @@ pub enum CheckInherentError {
Other(RuntimeString),
}
impl CheckInherentError {
/// Combine two results, taking the "worse" of the two.
pub fn combine_results<F: FnOnce() -> Result<(), Self>>(this: Result<(), Self>, other: F) -> Result<(), Self> {
match this {
Ok(()) => other(),
Err(CheckInherentError::Other(s)) => Err(CheckInherentError::Other(s)),
Err(CheckInherentError::ValidAtTimestamp(x)) => match other() {
Ok(()) => Err(CheckInherentError::ValidAtTimestamp(x)),
Err(CheckInherentError::ValidAtTimestamp(y))
=> Err(CheckInherentError::ValidAtTimestamp(rstd::cmp::max(x, y))),
Err(CheckInherentError::Other(s)) => Err(CheckInherentError::Other(s)),
}
}
}
}
#[cfg(test)]
mod tests {
use substrate_primitives::hash::H256;