Commit 11d79181 authored by Bastian Köcher's avatar Bastian Köcher Committed by Gav Wood
Browse files

Updates substrate to latest master (#107)

* Updates substrate to latest master

* Use slot_duration and not slot

* Update to latest substrate master again to have latest CLI

* Rename iherent indentifier

* Update after master merge
parent e6ebed00
Pipeline #29260 passed with stages
in 14 minutes and 28 seconds
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -11,4 +11,3 @@ futures = "0.1.17"
exit-future = "0.1"
substrate-cli = { git = "https://github.com/paritytech/substrate" }
polkadot-service = { path = "../service" }
structopt = "0.2.13"
......@@ -25,7 +25,6 @@ extern crate tokio;
extern crate substrate_cli as cli;
extern crate polkadot_service as service;
extern crate exit_future;
extern crate structopt;
#[macro_use]
extern crate log;
......@@ -36,8 +35,8 @@ use std::ops::Deref;
use chain_spec::ChainSpec;
use futures::Future;
use tokio::runtime::Runtime;
use structopt::StructOpt;
use service::Service as BareService;
use cli::NoCustom;
pub use service::{
Components as ServiceComponents, PolkadotService, CustomConfiguration, ServiceFactory, Factory,
......@@ -85,42 +84,33 @@ pub fn run<I, T, W>(args: I, worker: W, version: cli::VersionInfo) -> error::Res
T: Into<std::ffi::OsString> + Clone,
W: Worker,
{
let full_version = polkadot_service::full_version_from_strs(
version.version,
version.commit
);
let matches = match cli::CoreParams::clap()
.name(version.executable_name)
.author(version.author)
.about(version.description)
.version(&(full_version + "\n")[..])
.get_matches_from_safe(args) {
Ok(m) => m,
Err(e) => e.exit(),
};
let (spec, mut config) = cli::parse_matches::<service::Factory, _>(load_spec, &version, "parity-polkadot", &matches)?;
match cli::execute_default::<service::Factory, _>(spec, worker, &matches, &config)? {
cli::Action::ExecutedInternally => (),
cli::Action::RunService(worker) => {
info!("Parity ·:· Polkadot");
cli::parse_and_execute::<service::Factory, NoCustom, NoCustom, _, _, _, _, _>(
load_spec, &version, "parity-polkadot", args, worker,
|worker, _custom_args, mut config| {
info!("{}", version.name);
info!(" version {}", config.full_version());
info!(" by Parity Technologies, 2017, 2018");
info!(" by {}, 2017-2019", version.author);
info!("Chain specification: {}", config.chain_spec.name());
info!("Node name: {}", config.name);
info!("Roles: {:?}", config.roles);
config.custom = worker.configuration();
let mut runtime = Runtime::new()?;
let runtime = Runtime::new().map_err(|e| format!("{:?}", e))?;
let executor = runtime.executor();
match config.roles == service::Roles::LIGHT {
true => run_until_exit(runtime, Factory::new_light(config, executor)?, worker)?,
false => run_until_exit(runtime, Factory::new_full(config, executor)?, worker)?,
}
match config.roles {
service::Roles::LIGHT =>
run_until_exit(
runtime,
Factory::new_light(config, executor).map_err(|e| format!("{:?}", e))?,
worker
),
_ => run_until_exit(
runtime,
Factory::new_full(config, executor).map_err(|e| format!("{:?}", e))?,
worker
),
}.map_err(|e| format!("{:?}", e))
}
}
Ok(())
).map_err(Into::into).map(|_| ())
}
fn run_until_exit<T, C, W>(
......
......@@ -16,12 +16,13 @@ polkadot-parachain = { path = "../parachain" }
polkadot-primitives = { path = "../primitives" }
polkadot-runtime = { path = "../runtime" }
polkadot-statement-table = { path = "../statement-table" }
substrate-consensus-aura-primitives = { git = "https://github.com/paritytech/substrate" }
substrate-consensus-aura = { git = "https://github.com/paritytech/substrate" }
substrate-finality-grandpa = { git = "https://github.com/paritytech/substrate" }
substrate-consensus-common = { git = "https://github.com/paritytech/substrate" }
substrate-primitives = { git = "https://github.com/paritytech/substrate" }
substrate-inherents = { git = "https://github.com/paritytech/substrate" }
substrate-transaction-pool = { git = "https://github.com/paritytech/substrate" }
srml-support = { git = "https://github.com/paritytech/substrate" }
srml-aura = { git = "https://github.com/paritytech/substrate" }
substrate-client = { git = "https://github.com/paritytech/substrate" }
substrate-trie = { git = "https://github.com/paritytech/substrate" }
sr-primitives = { git = "https://github.com/paritytech/substrate" }
......
......@@ -33,7 +33,7 @@ use client::blockchain::HeaderBackend;
use client::runtime_api::Core;
use primitives::ed25519;
use futures::prelude::*;
use polkadot_primitives::{Block, BlockId, InherentData};
use polkadot_primitives::{Block, BlockId};
use polkadot_primitives::parachain::ParachainHost;
use extrinsic_store::Store as ExtrinsicStore;
use runtime_primitives::traits::ProvideRuntimeApi;
......@@ -122,7 +122,7 @@ pub(crate) fn start<C, N, P>(
<C::Collation as IntoFuture>::Future: Send + 'static,
P: BlockchainEvents<Block> + ChainHead<Block> + BlockBody<Block>,
P: ProvideRuntimeApi + HeaderBackend<Block> + Send + Sync + 'static,
P::Api: ParachainHost<Block> + Core<Block> + BlockBuilder<Block, InherentData>,
P::Api: ParachainHost<Block> + Core<Block> + BlockBuilder<Block>,
N: Network + Send + Sync + 'static,
N::TableRouter: Send + 'static,
{
......
......@@ -38,7 +38,6 @@ extern crate polkadot_primitives;
extern crate parity_codec as codec;
extern crate substrate_primitives as primitives;
extern crate srml_support as runtime_support;
extern crate sr_primitives as runtime_primitives;
extern crate substrate_client as client;
extern crate substrate_trie as trie;
......@@ -46,9 +45,11 @@ extern crate substrate_trie as trie;
extern crate exit_future;
extern crate tokio;
extern crate substrate_consensus_common as consensus;
extern crate substrate_consensus_aura_primitives as aura_primitives;
extern crate substrate_consensus_aura as aura;
extern crate substrate_finality_grandpa as grandpa;
extern crate substrate_transaction_pool as transaction_pool;
extern crate substrate_inherents as inherents;
extern crate srml_aura as runtime_aura;
#[macro_use]
extern crate error_chain;
......@@ -73,27 +74,35 @@ use client::runtime_api::Core;
use codec::Encode;
use extrinsic_store::Store as ExtrinsicStore;
use parking_lot::Mutex;
use polkadot_primitives::{
Hash, Block, BlockId, BlockNumber, Header, SessionKey, InherentData
use polkadot_primitives::{Hash, Block, BlockId, BlockNumber, Header, SessionKey};
use polkadot_primitives::parachain::{
Id as ParaId, Chain, DutyRoster, BlockData, Extrinsic as ParachainExtrinsic, CandidateReceipt,
CandidateSignature
};
use polkadot_primitives::parachain::{
AttestedCandidate, ParachainHost, Statement as PrimitiveStatement
};
use polkadot_primitives::parachain::{Id as ParaId, Chain, DutyRoster, BlockData, Extrinsic as ParachainExtrinsic, CandidateReceipt, CandidateSignature};
use polkadot_primitives::parachain::{AttestedCandidate, ParachainHost, Statement as PrimitiveStatement};
use primitives::{Ed25519AuthorityId as AuthorityId, ed25519};
use runtime_primitives::traits::ProvideRuntimeApi;
use tokio::runtime::TaskExecutor;
use tokio::timer::{Delay, Interval};
use transaction_pool::txpool::{Pool, ChainApi as PoolChainApi};
use aura_primitives::AuraConsensusData;
use attestation_service::ServiceHandle;
use futures::prelude::*;
use futures::future::{self, Either};
use collation::CollationFetch;
use dynamic_inclusion::DynamicInclusion;
use inherents::InherentData;
use runtime_aura::timestamp::TimestampInherentData;
use aura::SlotDuration;
pub use self::collation::{validate_collation, egress_trie_root, Collators};
pub use self::error::{ErrorKind, Error};
pub use self::shared_table::{SharedTable, ParachainWork, PrimedParachainWork, Validated, Statement, SignedStatement, GenericStatement};
pub use self::shared_table::{
SharedTable, ParachainWork, PrimedParachainWork, Validated, Statement, SignedStatement,
GenericStatement
};
mod attestation_service;
mod dynamic_inclusion;
......@@ -231,7 +240,7 @@ impl<C, N, P> ParachainConsensus<C, N, P> where
C: Collators + Send + 'static,
N: Network,
P: ProvideRuntimeApi + HeaderBackend<Block> + Send + Sync + 'static,
P::Api: ParachainHost<Block> + BlockBuilderApi<Block, InherentData>,
P::Api: ParachainHost<Block> + BlockBuilderApi<Block>,
<C::Collation as IntoFuture>::Future: Send + 'static,
N::TableRouter: Send + 'static,
{
......@@ -325,6 +334,7 @@ pub struct ProposerFactory<C, N, P, TxApi: PoolChainApi> {
transaction_pool: Arc<Pool<TxApi>>,
key: Arc<ed25519::Pair>,
_service_handle: ServiceHandle,
aura_slot_duration: SlotDuration,
}
impl<C, N, P, TxApi> ProposerFactory<C, N, P, TxApi> where
......@@ -332,7 +342,7 @@ impl<C, N, P, TxApi> ProposerFactory<C, N, P, TxApi> where
<C::Collation as IntoFuture>::Future: Send + 'static,
P: BlockchainEvents<Block> + ChainHead<Block> + BlockBody<Block>,
P: ProvideRuntimeApi + HeaderBackend<Block> + Send + Sync + 'static,
P::Api: ParachainHost<Block> + Core<Block> + BlockBuilderApi<Block, InherentData>,
P::Api: ParachainHost<Block> + Core<Block> + BlockBuilderApi<Block>,
N: Network + Send + Sync + 'static,
N::TableRouter: Send + 'static,
TxApi: PoolChainApi,
......@@ -346,6 +356,7 @@ impl<C, N, P, TxApi> ProposerFactory<C, N, P, TxApi> where
thread_pool: TaskExecutor,
key: Arc<ed25519::Pair>,
extrinsic_store: ExtrinsicStore,
aura_slot_duration: SlotDuration,
) -> Self {
let parachain_consensus = Arc::new(ParachainConsensus {
client: client.clone(),
......@@ -369,16 +380,17 @@ impl<C, N, P, TxApi> ProposerFactory<C, N, P, TxApi> where
transaction_pool,
key,
_service_handle: service_handle,
aura_slot_duration,
}
}
}
impl<C, N, P, TxApi> consensus::Environment<Block, AuraConsensusData> for ProposerFactory<C, N, P, TxApi> where
impl<C, N, P, TxApi> consensus::Environment<Block> for ProposerFactory<C, N, P, TxApi> where
C: Collators + Send + 'static,
N: Network,
TxApi: PoolChainApi<Block=Block>,
P: ProvideRuntimeApi + HeaderBackend<Block> + Send + Sync + 'static,
P::Api: ParachainHost<Block> + BlockBuilderApi<Block, InherentData>,
P::Api: ParachainHost<Block> + BlockBuilderApi<Block>,
<C::Collation as IntoFuture>::Future: Send + 'static,
N::TableRouter: Send + 'static,
{
......@@ -406,6 +418,7 @@ impl<C, N, P, TxApi> consensus::Environment<Block, AuraConsensusData> for Propos
parent_id,
parent_number: parent_header.number,
transaction_pool: self.transaction_pool.clone(),
slot_duration: self.aura_slot_duration,
})
}
}
......@@ -483,20 +496,18 @@ pub struct Proposer<C: Send + Sync, TxApi: PoolChainApi> where
parent_number: BlockNumber,
tracker: Arc<AttestationTracker>,
transaction_pool: Arc<Pool<TxApi>>,
slot_duration: SlotDuration,
}
impl<C, TxApi> consensus::Proposer<Block, AuraConsensusData> for Proposer<C, TxApi> where
impl<C, TxApi> consensus::Proposer<Block> for Proposer<C, TxApi> where
TxApi: PoolChainApi<Block=Block>,
C: ProvideRuntimeApi + HeaderBackend<Block> + Send + Sync,
C::Api: ParachainHost<Block> + BlockBuilderApi<Block, InherentData>,
C::Api: ParachainHost<Block> + BlockBuilderApi<Block>,
{
type Error = Error;
type Create = Either<
CreateProposal<C, TxApi>,
future::FutureResult<Block, Error>,
>;
type Create = Either<CreateProposal<C, TxApi>, future::FutureResult<Block, Error>>;
fn propose(&self, consensus_data: AuraConsensusData) -> Self::Create {
fn propose(&self, inherent_data: InherentData) -> Self::Create {
const ATTEMPT_PROPOSE_EVERY: Duration = Duration::from_millis(100);
const SLOT_DURATION_DENOMINATOR: u64 = 3; // wait up to 1/3 of the slot for candidates.
......@@ -506,7 +517,7 @@ impl<C, TxApi> consensus::Proposer<Block, AuraConsensusData> for Proposer<C, TxA
let dynamic_inclusion = DynamicInclusion::new(
self.tracker.table.num_parachains(),
self.tracker.started,
Duration::from_secs(consensus_data.slot_duration / SLOT_DURATION_DENOMINATOR),
Duration::from_secs(self.slot_duration.get() / SLOT_DURATION_DENOMINATOR),
);
let enough_candidates = dynamic_inclusion.acceptable_in(
......@@ -514,7 +525,10 @@ impl<C, TxApi> consensus::Proposer<Block, AuraConsensusData> for Proposer<C, TxA
initial_included,
).unwrap_or_else(|| now + Duration::from_millis(1));
let believed_timestamp = consensus_data.timestamp;
let believed_timestamp = match inherent_data.timestamp_inherent_data() {
Ok(timestamp) => timestamp,
Err(e) => return Either::B(future::err(ErrorKind::InherentError(e).into())),
};
// set up delay until next allowed timestamp.
let current_timestamp = current_timestamp();
......@@ -542,8 +556,8 @@ impl<C, TxApi> consensus::Proposer<Block, AuraConsensusData> for Proposer<C, TxA
transaction_pool: self.transaction_pool.clone(),
table: self.tracker.table.clone(),
believed_minimum_timestamp: believed_timestamp,
consensus_data,
timing,
inherent_data: Some(inherent_data),
})
}
}
......@@ -611,25 +625,22 @@ pub struct CreateProposal<C: Send + Sync, TxApi: PoolChainApi> {
table: Arc<SharedTable>,
timing: ProposalTiming,
believed_minimum_timestamp: u64,
consensus_data: AuraConsensusData,
inherent_data: Option<InherentData>,
}
impl<C, TxApi> CreateProposal<C, TxApi> where
TxApi: PoolChainApi<Block=Block>,
C: ProvideRuntimeApi + HeaderBackend<Block> + Send + Sync,
C::Api: ParachainHost<Block> + BlockBuilderApi<Block, InherentData>,
C::Api: ParachainHost<Block> + BlockBuilderApi<Block>,
{
fn propose_with(&self, candidates: Vec<AttestedCandidate>) -> Result<Block, Error> {
fn propose_with(&mut self, candidates: Vec<AttestedCandidate>) -> Result<Block, Error> {
use client::block_builder::BlockBuilder;
use runtime_primitives::traits::{Hash as HashT, BlakeTwo256};
const MAX_TRANSACTIONS: usize = 40;
let inherent_data = InherentData {
timestamp: self.believed_minimum_timestamp,
parachains: candidates,
aura_expected_slot: self.consensus_data.slot,
};
let mut inherent_data = self.inherent_data.take().expect("CreateProposal is not polled after finishing; qed");
inherent_data.put_data(polkadot_runtime::PARACHAIN_INHERENT_IDENTIFIER, &candidates).map_err(ErrorKind::InherentError)?;
let runtime_api = self.client.runtime_api();
......@@ -694,7 +705,7 @@ impl<C, TxApi> CreateProposal<C, TxApi> where
impl<C, TxApi> Future for CreateProposal<C, TxApi> where
TxApi: PoolChainApi<Block=Block>,
C: ProvideRuntimeApi + HeaderBackend<Block> + Send + Sync,
C::Api: ParachainHost<Block> + BlockBuilderApi<Block, InherentData>,
C::Api: ParachainHost<Block> + BlockBuilderApi<Block>,
{
type Item = Block;
type Error = Error;
......
......@@ -106,14 +106,3 @@ pub type BlockId = generic::BlockId<Block>;
pub struct UncheckedExtrinsic(#[cfg_attr(feature = "std", serde(with="bytes"))] pub Vec<u8>);
impl Extrinsic for UncheckedExtrinsic {}
/// Inherent data to include in a block.
#[derive(Encode, Decode)]
pub struct InherentData {
/// Current timestamp.
pub timestamp: u64,
/// Parachain heads update. This contains fully-attested candidates.
pub parachains: Vec<::parachain::AttestedCandidate>,
/// Expected slot for aura authorship.
pub aura_expected_slot: u64,
}
......@@ -11,32 +11,33 @@ serde = { version = "1.0", default-features = false }
serde_derive = { version = "1.0", optional = true }
safe-mix = { version = "1.0", default-features = false}
polkadot-primitives = { path = "../primitives", default-features = false }
parity-codec = "2.1"
parity-codec-derive = "2.1"
substrate-serializer = { git = "https://github.com/paritytech/substrate" }
sr-std = { git = "https://github.com/paritytech/substrate" }
sr-io = { git = "https://github.com/paritytech/substrate" }
srml-support = { git = "https://github.com/paritytech/substrate" }
substrate-primitives = { git = "https://github.com/paritytech/substrate" }
substrate-client = { git = "https://github.com/paritytech/substrate" }
parity-codec = { version = "2.2", default-features = false }
parity-codec-derive = { version = "2.2", default-features = false }
substrate-serializer = { git = "https://github.com/paritytech/substrate", default-features = false }
sr-std = { git = "https://github.com/paritytech/substrate", default-features = false }
sr-io = { git = "https://github.com/paritytech/substrate", default-features = false }
srml-support = { git = "https://github.com/paritytech/substrate", default-features = false }
substrate-primitives = { git = "https://github.com/paritytech/substrate", default-features = false }
substrate-client = { git = "https://github.com/paritytech/substrate", default-features = false }
substrate-inherents = { git = "https://github.com/paritytech/substrate", default-features = false }
substrate-consensus-aura-primitives = { git = "https://github.com/paritytech/substrate", default-features = false }
srml-aura = { git = "https://github.com/paritytech/substrate" }
srml-balances = { git = "https://github.com/paritytech/substrate" }
srml-consensus = { git = "https://github.com/paritytech/substrate" }
srml-council = { git = "https://github.com/paritytech/substrate" }
srml-democracy = { git = "https://github.com/paritytech/substrate" }
srml-executive = { git = "https://github.com/paritytech/substrate" }
srml-grandpa = { git = "https://github.com/paritytech/substrate" }
srml-indices = { git = "https://github.com/paritytech/substrate" }
sr-primitives = { git = "https://github.com/paritytech/substrate" }
srml-session = { git = "https://github.com/paritytech/substrate" }
srml-staking = { git = "https://github.com/paritytech/substrate" }
srml-sudo = { git = "https://github.com/paritytech/substrate" }
srml-system = { git = "https://github.com/paritytech/substrate" }
srml-timestamp = { git = "https://github.com/paritytech/substrate" }
srml-treasury = { git = "https://github.com/paritytech/substrate" }
srml-upgrade-key = { git = "https://github.com/paritytech/substrate" }
sr-version = { git = "https://github.com/paritytech/substrate" }
srml-aura = { git = "https://github.com/paritytech/substrate", default-features = false }
srml-balances = { git = "https://github.com/paritytech/substrate", default-features = false }
srml-consensus = { git = "https://github.com/paritytech/substrate", default-features = false }
srml-council = { git = "https://github.com/paritytech/substrate", default-features = false }
srml-democracy = { git = "https://github.com/paritytech/substrate", default-features = false }
srml-executive = { git = "https://github.com/paritytech/substrate", default-features = false }
srml-grandpa = { git = "https://github.com/paritytech/substrate", default-features = false }
srml-indices = { git = "https://github.com/paritytech/substrate", default-features = false }
sr-primitives = { git = "https://github.com/paritytech/substrate", default-features = false }
srml-session = { git = "https://github.com/paritytech/substrate", default-features = false }
srml-staking = { git = "https://github.com/paritytech/substrate", default-features = false }
srml-sudo = { git = "https://github.com/paritytech/substrate", default-features = false }
srml-system = { git = "https://github.com/paritytech/substrate", default-features = false }
srml-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false }
srml-treasury = { git = "https://github.com/paritytech/substrate", default-features = false }
srml-upgrade-key = { git = "https://github.com/paritytech/substrate", default-features = false }
sr-version = { git = "https://github.com/paritytech/substrate", default-features = false }
libsecp256k1 = "0.2.1"
tiny-keccak = "1.4.2"
......@@ -52,6 +53,8 @@ std = [
"parity-codec/std",
"parity-codec-derive/std",
"substrate-primitives/std",
"substrate-client/std",
"substrate-inherents/std",
"sr-std/std",
"sr-io/std",
"srml-support/std",
......
......@@ -36,10 +36,10 @@ extern crate parity_codec as codec;
extern crate substrate_consensus_aura_primitives as consensus_aura;
extern crate substrate_primitives;
extern crate substrate_inherents as inherents;
#[macro_use]
extern crate substrate_client as client;
#[macro_use]
extern crate sr_std as rstd;
#[cfg(test)]
extern crate sr_io;
......@@ -80,12 +80,11 @@ use primitives::{
parachain,
};
use client::{
block_builder::api as block_builder_api,
block_builder::api::{self as block_builder_api, InherentData, CheckInherentsResult},
runtime_api as client_api,
};
use consensus_aura::api as aura_api;
use sr_primitives::{
ApplyResult, CheckInherentError, generic, transaction_validity::TransactionValidity,
ApplyResult, generic, transaction_validity::TransactionValidity,
traits::{Convert, BlakeTwo256, Block as BlockT, DigestFor, StaticLookup}
};
use version::RuntimeVersion;
......@@ -102,15 +101,11 @@ pub use sr_primitives::BuildStorage;
pub use consensus::Call as ConsensusCall;
pub use timestamp::Call as TimestampCall;
pub use balances::Call as BalancesCall;
pub use parachains::Call as ParachainsCall;
pub use parachains::{Call as ParachainsCall, INHERENT_IDENTIFIER as PARACHAIN_INHERENT_IDENTIFIER};
pub use sr_primitives::{Permill, Perbill};
pub use timestamp::BlockPeriod;
pub use srml_support::{StorageValue, RuntimeMetadata};
const TIMESTAMP_SET_POSITION: u32 = 0;
const PARACHAINS_SET_POSITION: u32 = 1;
const NOTE_OFFLINE_POSITION: u32 = 2; // this should be reintroduced
/// Runtime version.
pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("polkadot"),
......@@ -164,7 +159,6 @@ impl balances::Trait for Runtime {
}
impl consensus::Trait for Runtime {
const NOTE_OFFLINE_POSITION: u32 = NOTE_OFFLINE_POSITION;
type Log = Log;
type SessionKey = SessionKey;
......@@ -174,7 +168,6 @@ impl consensus::Trait for Runtime {
}
impl timestamp::Trait for Runtime {
const TIMESTAMP_SET_POSITION: u32 = TIMESTAMP_SET_POSITION;
type Moment = u64;
type OnTimestampSet = Aura;
}
......@@ -229,9 +222,7 @@ impl grandpa::Trait for Runtime {
type Event = Event;
}
impl parachains::Trait for Runtime {
const SET_POSITION: u32 = PARACHAINS_SET_POSITION;
}
impl parachains::Trait for Runtime {}
impl upgrade_key::Trait for Runtime {
type Event = Event;
......@@ -250,7 +241,7 @@ construct_runtime!(
pub enum Runtime with Log(InternalLog: DigestItem<Hash, SessionKey>) where
Block = Block,
NodeBlock = primitives::Block,
InherentData = primitives::InherentData
UncheckedExtrinsic = UncheckedExtrinsic
{
System: system::{default, Log(ChangesTrieRoot)},
Aura: aura::{Module},
......@@ -317,7 +308,7 @@ impl_runtime_apis! {
}
}
impl block_builder_api::BlockBuilder<Block, primitives::InherentData> for Runtime {
impl block_builder_api::BlockBuilder<Block> for Runtime {
fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyResult {
Executive::apply_extrinsic(extrinsic)
}
......@@ -326,48 +317,12 @@ impl_runtime_apis! {
Executive::finalise_block()
}
fn inherent_extrinsics(data: primitives::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
use sr_primitives::traits::ProvideInherent;
let mut inherent = Vec::new();
inherent.extend(
Timestamp::create_inherent_extrinsics(data.timestamp)
.into_iter()
.map(|v| (v.0, UncheckedExtrinsic::new_unsigned(Call::Timestamp(v.1))))
);
inherent.extend(
Parachains::create_inherent_extrinsics(data.parachains)
.into_iter()
.map(|v| (v.0, UncheckedExtrinsic::new_unsigned(Call::Parachains(v.1))))
);
inherent.as_mut_slice().sort_unstable_by_key(|v| v.0);
inherent.into_iter().map(|v| v.1).collect()
fn inherent_extrinsics(data: InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
data.create_extrinsics()
}
fn check_inherents(block: Block, data: primitives::InherentData) -> Result<(), CheckInherentError> {
let expected_slot = data.aura_expected_slot;
// draw timestamp out from extrinsics.
let set_timestamp = block.extrinsics()
.get(TIMESTAMP_SET_POSITION as usize)
.and_then(|xt: &UncheckedExtrinsic| match xt.function {
Call::Timestamp(TimestampCall::set(ref t)) => Some(t.clone()),
_ => None,
})
.ok_or_else(|| CheckInherentError::Other("No valid timestamp in block.".into()))?;
// take the "worse" result of normal verification and the timestamp vs. seal
// check.
CheckInherentError::combine_results(
Runtime::check_inherents(block, data),
|| {
Aura::verify_inherent(set_timestamp.into(), expected_slot)
.map_err(|s| CheckInherentError::Other(s.into()))
},
)
fn check_inherents(block: Block, data: InherentData) -> CheckInherentsResult {
data.check_extrinsics(&block)
}
fn random_seed() -> <Block as BlockT>::Hash {
......@@ -419,10 +374,9 @@ impl_runtime_apis! {
}
}
impl aura_api::AuraApi<Block> for Runtime {
impl consensus_aura::AuraApi<Block> for Runtime {
fn slot_duration() -> u64 {
Aura::slot_duration()
}
}
}
......@@ -20,16 +20,15 @@ use rstd::prelude::*;
use codec::Decode;
use bitvec::BigEndian;
use sr_primitives::CheckInherentError;
use sr_primitives::traits::{
Extrinsic, Block as BlockT, Hash as HashT, BlakeTwo256, ProvideInherent,
};
use sr_primitives::traits::{Hash as HashT, BlakeTwo256};
use primitives::parachain::{Id as ParaId, Chain, DutyRoster, AttestedCandidate, Statement};
use {system, session};
use srml_support::{StorageValue, StorageMap};
use srml_support::dispatch::Result;
use inherents::{ProvideInherent, InherentData, RuntimeString, MakeFatalError, InherentIdentifier};
#[cfg(any(feature = "std", test))]
use sr_primitives::{self, ChildrenStorageMap};
......@@ -38,10 +37,7 @@ use rstd::marker::PhantomData;
use system::ensure_inherent;
pub trait Trait: session::Trait {