Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
142f6ac
notify when an authority appears to have missed their block
rphmeier Aug 9, 2018
3f09f5c
Runtime API
gavofyork Aug 9, 2018
6095a6d
offline tracker
rphmeier Aug 9, 2018
21f40e5
Merge branch 'rh-note-offline-validator' of github.com:paritytech/pol…
rphmeier Aug 9, 2018
13a5e89
Move to consensus
gavofyork Aug 9, 2018
8c0fd55
Merge branch 'rh-note-offline-validator' of github.com:paritytech/pol…
gavofyork Aug 9, 2018
de23e91
generating reports of offline indices
rphmeier Aug 9, 2018
5433ef3
stubbed-out evaluation logic
rphmeier Aug 9, 2018
603e5a2
Slashing data pathwat
gavofyork Aug 9, 2018
08f598e
Merge branch 'rh-note-offline-validator' of github.com:paritytech/pol…
rphmeier Aug 9, 2018
4e2ceef
usize -> u32
rphmeier Aug 9, 2018
cff0577
Slash bad validators.
gavofyork Aug 9, 2018
825e1a4
Merge branch 'rh-note-offline-validator' of github.com:paritytech/pol…
gavofyork Aug 9, 2018
14b27cc
update to rhododendron 0.3
rphmeier Aug 9, 2018
00f23eb
Merge branch 'rh-note-offline-validator' of github.com:paritytech/pol…
rphmeier Aug 9, 2018
b827eec
fix compilation of polkadot-consensus
rphmeier Aug 9, 2018
6dd3524
Support offline noting in checked_block
gavofyork Aug 9, 2018
1cb58de
Merge branch 'rh-note-offline-validator' of github.com:paritytech/pol…
gavofyork Aug 9, 2018
241f28f
include offline reports in block authorship voting
rphmeier Aug 10, 2018
614b011
do not vote validators offline after some time
rphmeier Aug 10, 2018
b122ed4
add test for offline-tracker
rphmeier Aug 10, 2018
9724a69
fix test build
rphmeier Aug 10, 2018
60aadd3
bump spec version
rphmeier Aug 10, 2018
2fb0343
Merge remote-tracking branch 'upstream/master' into rh-note-offline-v…
rphmeier Aug 10, 2018
7602e59
update wasm
rphmeier Aug 10, 2018
922035d
Only allow validators that are possible to slash
gavofyork Aug 10, 2018
a6bea42
Fix grumble
tomusdrw Aug 3, 2018
a61396e
More idiomatic
gavofyork Aug 10, 2018
1d787e1
New Wasm.
gavofyork Aug 10, 2018
ab6957f
update rhododendron
rphmeier Aug 10, 2018
7696119
improve logging and reduce round time exponent
rphmeier Aug 10, 2018
2446ded
format offline validators in ss58
rphmeier Aug 10, 2018
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
14 changes: 7 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions demo/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ impl Convert<AccountId, SessionKey> for SessionKeyConversion {
}

impl session::Trait for Concrete {
const NOTE_OFFLINE_POSITION: u32 = 1;
type ConvertAccountIdToSessionKey = SessionKeyConversion;
type OnSessionChange = Staking;
}
Expand Down
27 changes: 19 additions & 8 deletions polkadot/api/src/full.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ use state_machine;

use runtime::Address;
use runtime_primitives::traits::AuxLookup;
use primitives::{AccountId, Block, Header, BlockId, Hash, Index, SessionKey, Timestamp, UncheckedExtrinsic};
use primitives::parachain::{CandidateReceipt, DutyRoster, Id as ParaId};
use primitives::{
AccountId, Block, Header, BlockId, Hash, Index, InherentData,
SessionKey, Timestamp, UncheckedExtrinsic,
};
use primitives::parachain::{DutyRoster, Id as ParaId};

use {BlockBuilder, PolkadotApi, LocalPolkadotApi, ErrorKind, Error, Result};

Expand Down Expand Up @@ -132,20 +135,20 @@ impl<B: LocalBackend<Block>> PolkadotApi for Client<B, LocalCallExecutor<B, Nati
with_runtime!(self, at, || ::runtime::Parachains::parachain_head(parachain))
}

fn build_block(&self, at: &BlockId, timestamp: Timestamp, new_heads: Vec<CandidateReceipt>) -> Result<Self::BlockBuilder> {
fn build_block(&self, at: &BlockId, inherent_data: InherentData) -> Result<Self::BlockBuilder> {
let mut block_builder = self.new_block_at(at)?;
for inherent in self.inherent_extrinsics(at, timestamp, new_heads)? {
for inherent in self.inherent_extrinsics(at, inherent_data)? {
block_builder.push(inherent)?;
}

Ok(block_builder)
}

fn inherent_extrinsics(&self, at: &BlockId, timestamp: Timestamp, new_heads: Vec<CandidateReceipt>) -> Result<Vec<UncheckedExtrinsic>> {
fn inherent_extrinsics(&self, at: &BlockId, inherent_data: InherentData) -> Result<Vec<UncheckedExtrinsic>> {
use codec::{Encode, Decode};

with_runtime!(self, at, || {
let extrinsics = ::runtime::inherent_extrinsics(timestamp, new_heads);
let extrinsics = ::runtime::inherent_extrinsics(inherent_data);
extrinsics.into_iter()
.map(|x| x.encode()) // get encoded representation
.map(|x| Decode::decode(&mut &x[..])) // get byte-vec equivalent to extrinsic
Expand Down Expand Up @@ -216,7 +219,11 @@ mod tests {
let client = client();

let id = BlockId::number(0);
let block_builder = client.build_block(&id, 1_000_000, Vec::new()).unwrap();
let block_builder = client.build_block(&id, InherentData {
timestamp: 1_000_000,
parachain_heads: Vec::new(),
offline_indices: Vec::new(),
}).unwrap();
let block = block_builder.bake().unwrap();

assert_eq!(block.header.number, 1);
Expand All @@ -228,7 +235,11 @@ mod tests {
let client = client();

let id = BlockId::number(0);
let inherent = client.inherent_extrinsics(&id, 1_000_000, Vec::new()).unwrap();
let inherent = client.inherent_extrinsics(&id, InherentData {
timestamp: 1_000_000,
parachain_heads: Vec::new(),
offline_indices: Vec::new(),
}).unwrap();

let mut block_builder = client.new_block_at(&id).unwrap();
for extrinsic in inherent {
Expand Down
12 changes: 7 additions & 5 deletions polkadot/api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ extern crate substrate_keyring as keyring;
pub mod full;
pub mod light;

use primitives::{AccountId, Block, BlockId, Hash, Index, SessionKey, Timestamp,
UncheckedExtrinsic};
use primitives::{
AccountId, Block, BlockId, Hash, Index, SessionKey, Timestamp,
UncheckedExtrinsic, InherentData,
};
use runtime::Address;
use primitives::parachain::{CandidateReceipt, DutyRoster, Id as ParaId};
use primitives::parachain::{DutyRoster, Id as ParaId};

error_chain! {
errors {
Expand Down Expand Up @@ -128,11 +130,11 @@ pub trait PolkadotApi {
fn evaluate_block(&self, at: &BlockId, block: Block) -> Result<bool>;

/// Build a block on top of the given, with inherent extrinsics pre-pushed.
fn build_block(&self, at: &BlockId, timestamp: Timestamp, new_heads: Vec<CandidateReceipt>) -> Result<Self::BlockBuilder>;
fn build_block(&self, at: &BlockId, inherent_data: InherentData) -> Result<Self::BlockBuilder>;

/// Attempt to produce the (encoded) inherent extrinsics for a block being built upon the given.
/// This may vary by runtime and will fail if a runtime doesn't follow the same API.
fn inherent_extrinsics(&self, at: &BlockId, timestamp: Timestamp, new_heads: Vec<CandidateReceipt>) -> Result<Vec<UncheckedExtrinsic>>;
fn inherent_extrinsics(&self, at: &BlockId, inherent_data: InherentData) -> Result<Vec<UncheckedExtrinsic>>;
}

/// Mark for all Polkadot API implementations, that are making use of state data, stored locally.
Expand Down
11 changes: 7 additions & 4 deletions polkadot/api/src/light.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@ use std::sync::Arc;
use client::backend::{Backend, RemoteBackend};
use client::{Client, CallExecutor};
use codec::Decode;
use primitives::{AccountId, Block, BlockId, Hash, Index, SessionKey, Timestamp, UncheckedExtrinsic};
use primitives::{
AccountId, Block, BlockId, Hash, Index, InherentData,
SessionKey, Timestamp, UncheckedExtrinsic,
};
use runtime::Address;
use primitives::parachain::{CandidateReceipt, DutyRoster, Id as ParaId};
use primitives::parachain::{DutyRoster, Id as ParaId};
use {PolkadotApi, BlockBuilder, RemotePolkadotApi, Result, ErrorKind};

/// Light block builder. TODO: make this work (efficiently)
Expand Down Expand Up @@ -92,11 +95,11 @@ impl<B: Backend<Block>, E: CallExecutor<Block>> PolkadotApi for RemotePolkadotAp
Err(ErrorKind::UnknownRuntime.into())
}

fn build_block(&self, _at: &BlockId, _timestamp: Timestamp, _new_heads: Vec<CandidateReceipt>) -> Result<Self::BlockBuilder> {
fn build_block(&self, _at: &BlockId, _inherent: InherentData) -> Result<Self::BlockBuilder> {
Err(ErrorKind::UnknownRuntime.into())
}

fn inherent_extrinsics(&self, _at: &BlockId, _timestamp: Timestamp, _new_heads: Vec<CandidateReceipt>) -> Result<Vec<Vec<u8>>> {
fn inherent_extrinsics(&self, _at: &BlockId, _inherent: InherentData) -> Result<Vec<Vec<u8>>> {
Err(ErrorKind::UnknownRuntime.into())
}
}
Expand Down
2 changes: 1 addition & 1 deletion polkadot/consensus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ed25519 = { path = "../../substrate/ed25519" }
error-chain = "0.12"
log = "0.3"
exit-future = "0.1"
rhododendron = "0.2"
rhododendron = "0.3"
polkadot-api = { path = "../api" }
polkadot-availability-store = { path = "../availability-store" }
polkadot-parachain = { path = "../parachain" }
Expand Down
3 changes: 3 additions & 0 deletions polkadot/consensus/src/dynamic_inclusion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ impl DynamicInclusion {
Some(now + until)
}
}

/// Get the start instant.
pub fn started_at(&self) -> Instant { self.start }
}

#[cfg(test)]
Expand Down
Loading