mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 22:47:56 +00:00
Update to Substrate master (#311)
* Best effort to bring up to date. * Fix the executor stuff * Update verisons. * Finish fixing * Final fixes and warnings. * add some docs and bump Wasm versions * Fix tests * Fix final test
This commit is contained in:
Generated
+296
-267
File diff suppressed because it is too large
Load Diff
@@ -9,7 +9,7 @@ edition = "2018"
|
||||
polkadot-primitives = { path = "../primitives" }
|
||||
parking_lot = "0.7.1"
|
||||
log = "0.4.6"
|
||||
parity-codec = "3.0"
|
||||
parity-codec = "4.1"
|
||||
substrate-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
kvdb = { git = "https://github.com/paritytech/parity-common", rev="616b40150ded71f57f650067fcbc5c99d7c343e6" }
|
||||
kvdb-rocksdb = { git = "https://github.com/paritytech/parity-common", rev="616b40150ded71f57f650067fcbc5c99d7c343e6" }
|
||||
|
||||
@@ -26,6 +26,7 @@ use chain_spec::ChainSpec;
|
||||
use futures::Future;
|
||||
use tokio::runtime::Runtime;
|
||||
use service::Service as BareService;
|
||||
use std::sync::Arc;
|
||||
use log::info;
|
||||
|
||||
pub use service::{
|
||||
@@ -35,7 +36,9 @@ pub use service::{
|
||||
|
||||
pub use cli::{VersionInfo, IntoExit, NoCustom};
|
||||
pub use cli::error;
|
||||
pub use tokio::runtime::TaskExecutor;
|
||||
|
||||
/// Abstraction over an executor that lets you spawn tasks in the background.
|
||||
pub type TaskExecutor = Arc<dyn futures::future::Executor<Box<dyn Future<Item = (), Error = ()> + Send>> + Send + Sync>;
|
||||
|
||||
fn load_spec(id: &str) -> Result<Option<service::ChainSpec>, String> {
|
||||
Ok(match ChainSpec::from(id) {
|
||||
@@ -86,17 +89,16 @@ pub fn run<I, T, W>(args: I, worker: W, version: cli::VersionInfo) -> error::Res
|
||||
info!("Roles: {:?}", config.roles);
|
||||
config.custom = worker.configuration();
|
||||
let runtime = Runtime::new().map_err(|e| format!("{:?}", e))?;
|
||||
let executor = runtime.executor();
|
||||
match config.roles {
|
||||
service::Roles::LIGHT =>
|
||||
run_until_exit(
|
||||
runtime,
|
||||
Factory::new_light(config, executor).map_err(|e| format!("{:?}", e))?,
|
||||
Factory::new_light(config).map_err(|e| format!("{:?}", e))?,
|
||||
worker
|
||||
),
|
||||
_ => run_until_exit(
|
||||
runtime,
|
||||
Factory::new_full(config, executor).map_err(|e| format!("{:?}", e))?,
|
||||
Factory::new_full(config).map_err(|e| format!("{:?}", e))?,
|
||||
worker
|
||||
),
|
||||
}.map_err(|e| format!("{:?}", e))
|
||||
@@ -121,7 +123,7 @@ fn run_until_exit<T, C, W>(
|
||||
let informant = cli::informant::build(&service);
|
||||
executor.spawn(exit.until(informant).map(|_| ()));
|
||||
|
||||
let _ = runtime.block_on(worker.work(&*service, executor.clone()));
|
||||
let _ = runtime.block_on(worker.work(&*service, Arc::new(executor)));
|
||||
exit_send.fire();
|
||||
|
||||
// we eagerly drop the service so that the internal exit future is fired,
|
||||
|
||||
@@ -8,7 +8,7 @@ edition = "2018"
|
||||
[dependencies]
|
||||
futures = "0.1.17"
|
||||
client = { package = "substrate-client", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
parity-codec = "3.0"
|
||||
parity-codec = "4.1"
|
||||
primitives = { package = "substrate-primitives", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
substrate-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
consensus_common = { package = "substrate-consensus-common", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
|
||||
@@ -7,6 +7,6 @@ edition = "2018"
|
||||
[dependencies]
|
||||
primitives = { package = "polkadot-primitives", path = "../primitives" }
|
||||
reed_solomon = { package = "reed-solomon-erasure", git = "https://github.com/paritytech/reed-solomon-erasure" }
|
||||
parity-codec = "3.0"
|
||||
parity-codec = "4.1"
|
||||
substrate-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
trie = { package = "substrate-trie", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
|
||||
@@ -11,7 +11,7 @@ parking_lot = "0.7.1"
|
||||
av_store = { package = "polkadot-availability-store", path = "../availability-store" }
|
||||
polkadot-validation = { path = "../validation" }
|
||||
polkadot-primitives = { path = "../primitives" }
|
||||
parity-codec = { version = "3.5.1", features = ["derive"] }
|
||||
parity-codec = { version = "4.1", features = ["derive"] }
|
||||
substrate-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
substrate-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
sr-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
|
||||
@@ -32,10 +32,11 @@ use polkadot_primitives::parachain::{
|
||||
Id as ParaId, BlockData, CollatorId, CandidateReceipt, Collation, PoVBlock,
|
||||
StructuredUnroutedIngress,
|
||||
};
|
||||
use substrate_network::{PeerId, RequestId, Context};
|
||||
use substrate_network::{message, generic_message};
|
||||
use substrate_network::specialization::NetworkSpecialization as Specialization;
|
||||
use substrate_network::StatusMessage as GenericFullStatus;
|
||||
use substrate_network::{
|
||||
PeerId, RequestId, Context, Event, message, generic_message,
|
||||
specialization::NetworkSpecialization as Specialization,
|
||||
StatusMessage as GenericFullStatus
|
||||
};
|
||||
use self::validation::{LiveValidationSessions, RecentValidatorIds, InsertedRecentKey};
|
||||
use self::collator_pool::{CollatorPool, Role, Action};
|
||||
use self::local_collations::LocalCollations;
|
||||
@@ -69,7 +70,7 @@ mod benefit {
|
||||
type FullStatus = GenericFullStatus<Block>;
|
||||
|
||||
/// Specialization of the network service for the polkadot protocol.
|
||||
pub type NetworkService = substrate_network::NetworkService<Block, PolkadotProtocol>;
|
||||
pub type NetworkService = substrate_network::NetworkService<Block, PolkadotProtocol, Hash>;
|
||||
|
||||
/// Status of a Polkadot node.
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Encode, Decode)]
|
||||
@@ -593,6 +594,8 @@ impl Specialization<Block> for PolkadotProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
fn on_event(&mut self, _event: Event) { }
|
||||
|
||||
fn on_abort(&mut self) { }
|
||||
|
||||
fn maintain_peers(&mut self, ctx: &mut dyn Context<Block>) {
|
||||
|
||||
@@ -41,11 +41,13 @@ use sr_primitives::traits::{ApiRef, ProvideRuntimeApi};
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
use futures::{prelude::*, sync::mpsc};
|
||||
use tokio::runtime::{Runtime, TaskExecutor};
|
||||
use tokio::runtime::Runtime;
|
||||
use parity_codec::Encode;
|
||||
|
||||
use super::TestContext;
|
||||
|
||||
type TaskExecutor = Arc<dyn futures::future::Executor<Box<dyn Future<Item = (), Error = ()> + Send>> + Send + Sync>;
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
struct NeverExit;
|
||||
|
||||
|
||||
@@ -44,7 +44,6 @@ use std::io;
|
||||
use std::sync::Arc;
|
||||
|
||||
use arrayvec::ArrayVec;
|
||||
use tokio::runtime::TaskExecutor;
|
||||
use parking_lot::Mutex;
|
||||
use log::{debug, warn};
|
||||
|
||||
@@ -63,6 +62,7 @@ pub trait Executor {
|
||||
}
|
||||
|
||||
/// A wrapped futures::future::Executor.
|
||||
#[derive(Clone)]
|
||||
pub struct WrappedExecutor<T>(pub T);
|
||||
|
||||
impl<T> Executor for WrappedExecutor<T>
|
||||
@@ -75,9 +75,11 @@ impl<T> Executor for WrappedExecutor<T>
|
||||
}
|
||||
}
|
||||
|
||||
impl Executor for TaskExecutor {
|
||||
impl Executor for Arc<
|
||||
dyn futures::future::Executor<Box<dyn Future<Item = (), Error = ()> + Send>> + Send + Sync
|
||||
> {
|
||||
fn spawn<F: Future<Item=(),Error=()> + Send + 'static>(&self, f: F) {
|
||||
TaskExecutor::spawn(self, f)
|
||||
let _ = FutureExecutor::execute(&**self, Box::new(f));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ description = "Types and utilities for creating and working with parachains"
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "parity-codec", version = "3.5", default-features = false, features = [ "derive" ] }
|
||||
codec = { package = "parity-codec", version = "4.1", default-features = false, features = [ "derive" ] }
|
||||
wasmi = { version = "0.4.3", optional = true }
|
||||
derive_more = { version = "0.14", optional = true }
|
||||
serde = { version = "1.0", default-features = false, features = [ "derive" ] }
|
||||
|
||||
@@ -6,8 +6,7 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1.0", optional = true, features = ["derive"] }
|
||||
parity-codec = { version = "3.0", default-features = false }
|
||||
parity-codec-derive = { version = "3.0", default-features = false }
|
||||
parity-codec = { version = "4.1", default-features = false }
|
||||
primitives = { package = "substrate-primitives", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
substrate-client = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
sr-version = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
@@ -23,7 +22,6 @@ pretty_assertions = "0.5.1"
|
||||
default = ["std"]
|
||||
std = [
|
||||
"parity-codec/std",
|
||||
"parity-codec-derive/std",
|
||||
"primitives/std",
|
||||
"substrate-client/std",
|
||||
"rstd/std",
|
||||
|
||||
@@ -12,7 +12,7 @@ serde = { version = "1.0", default-features = false }
|
||||
serde_derive = { version = "1.0", optional = true }
|
||||
safe-mix = { version = "1.0", default-features = false}
|
||||
primitives = { package = "polkadot-primitives", path = "../primitives", default-features = false }
|
||||
parity-codec = { version = "3.0", default-features = false, features = ["derive"] }
|
||||
parity-codec = { version = "4.1", default-features = false, features = ["derive"] }
|
||||
substrate-serializer = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
rstd = { package = "sr-std", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
sr-io = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
@@ -23,10 +23,12 @@ inherents = { package = "substrate-inherents", git = "https://github.com/parityt
|
||||
consensus_aura = { package = "substrate-consensus-aura-primitives", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
offchain_primitives = { package = "substrate-offchain-primitives", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
aura = { package = "srml-aura", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
authorship = { package = "srml-authorship", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
balances = { package = "srml-balances", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
council = { package = "srml-council", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
democracy = { package = "srml-democracy", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
executive = { package = "srml-executive", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
finality-tracker = { package = "srml-finality-tracker", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
grandpa = { package = "srml-grandpa", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
indices = { package = "srml-indices", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
sr-primitives = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
@@ -60,10 +62,13 @@ std = [
|
||||
"rstd/std",
|
||||
"sr-io/std",
|
||||
"srml-support/std",
|
||||
"aura/std",
|
||||
"authorship/std",
|
||||
"balances/std",
|
||||
"council/std",
|
||||
"democracy/std",
|
||||
"executive/std",
|
||||
"finality-tracker/std",
|
||||
"grandpa/std",
|
||||
"indices/std",
|
||||
"sr-primitives/std",
|
||||
@@ -79,5 +84,4 @@ std = [
|
||||
"log",
|
||||
"safe-mix/std",
|
||||
"consensus_aura/std",
|
||||
"aura/std",
|
||||
]
|
||||
|
||||
@@ -197,7 +197,7 @@ mod tests {
|
||||
// The testing primitives are very useful for avoiding having to work with signatures
|
||||
// or public keys. `u64` is used as the `AccountId` and no `Signature`s are required.
|
||||
use sr_primitives::{
|
||||
BuildStorage, traits::{BlakeTwo256, IdentityLookup}, testing::Header
|
||||
traits::{BlakeTwo256, IdentityLookup}, testing::Header
|
||||
};
|
||||
use balances;
|
||||
use srml_support::{impl_outer_origin, assert_ok, assert_err, assert_noop, parameter_types};
|
||||
@@ -222,6 +222,15 @@ mod tests {
|
||||
type Header = Header;
|
||||
type Event = ();
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const ExistentialDeposit: u64 = 0;
|
||||
pub const TransferFee: u64 = 0;
|
||||
pub const CreationFee: u64 = 0;
|
||||
pub const TransactionBaseFee: u64 = 0;
|
||||
pub const TransactionByteFee: u64 = 0;
|
||||
}
|
||||
|
||||
impl balances::Trait for Test {
|
||||
type Balance = u64;
|
||||
type OnFreeBalanceZero = ();
|
||||
@@ -230,6 +239,11 @@ mod tests {
|
||||
type TransactionPayment = ();
|
||||
type DustRemoval = ();
|
||||
type TransferPayment = ();
|
||||
type ExistentialDeposit = ExistentialDeposit;
|
||||
type TransferFee = TransferFee;
|
||||
type CreationFee = CreationFee;
|
||||
type TransactionBaseFee = TransactionBaseFee;
|
||||
type TransactionByteFee = TransactionByteFee;
|
||||
}
|
||||
|
||||
parameter_types!{
|
||||
@@ -274,7 +288,7 @@ mod tests {
|
||||
// This function basically just builds a genesis storage key/value store according to
|
||||
// our desired mockup.
|
||||
fn new_test_ext() -> sr_io::TestExternalities<Blake2Hasher> {
|
||||
let mut t = system::GenesisConfig::<Test>::default().build_storage().unwrap().0;
|
||||
let mut t = system::GenesisConfig::default().build_storage::<Test>().unwrap().0;
|
||||
// We use default for brevity, but you can configure as desired if needed.
|
||||
t.extend(balances::GenesisConfig::<Test>::default().build_storage().unwrap().0);
|
||||
t.extend(GenesisConfig::<Test>{
|
||||
|
||||
+109
-12
@@ -48,7 +48,9 @@ use council::seats as council_seats;
|
||||
#[cfg(any(feature = "std", test))]
|
||||
use version::NativeVersion;
|
||||
use substrate_primitives::OpaqueMetadata;
|
||||
use srml_support::{parameter_types, construct_runtime};
|
||||
use srml_support::{
|
||||
parameter_types, construct_runtime, traits::{SplitTwoWays, Currency, OnUnbalanced}
|
||||
};
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
pub use staking::StakerStatus;
|
||||
@@ -80,6 +82,16 @@ pub fn native_version() -> NativeVersion {
|
||||
}
|
||||
}
|
||||
|
||||
const DOTS: Balance = 1_000_000_000_000;
|
||||
const BUCKS: Balance = DOTS / 100;
|
||||
const CENTS: Balance = BUCKS / 100;
|
||||
const MILLICENTS: Balance = CENTS / 1_000;
|
||||
|
||||
const SECS_PER_BLOCK: BlockNumber = 10;
|
||||
const MINUTES: BlockNumber = 60 / SECS_PER_BLOCK;
|
||||
const HOURS: BlockNumber = MINUTES * 60;
|
||||
const DAYS: BlockNumber = HOURS * 24;
|
||||
|
||||
impl system::Trait for Runtime {
|
||||
type Origin = Origin;
|
||||
type Index = Nonce;
|
||||
@@ -104,14 +116,46 @@ impl indices::Trait for Runtime {
|
||||
type Event = Event;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const ExistentialDeposit: Balance = 1 * BUCKS;
|
||||
pub const TransferFee: Balance = 1 * CENTS;
|
||||
pub const CreationFee: Balance = 1 * CENTS;
|
||||
pub const TransactionBaseFee: Balance = 1 * CENTS;
|
||||
pub const TransactionByteFee: Balance = 10 * MILLICENTS;
|
||||
}
|
||||
|
||||
|
||||
/// Logic for the author to get a portion of fees.
|
||||
pub struct ToAuthor;
|
||||
|
||||
type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;
|
||||
impl OnUnbalanced<NegativeImbalance> for ToAuthor {
|
||||
fn on_unbalanced(amount: NegativeImbalance) {
|
||||
Balances::resolve_creating(&Authorship::author(), amount);
|
||||
}
|
||||
}
|
||||
|
||||
/// Splits fees 80/20 between treasury and block author.
|
||||
pub type DealWithFees = SplitTwoWays<
|
||||
Balance,
|
||||
NegativeImbalance,
|
||||
_4, Treasury, // 4 parts (80%) goes to the treasury.
|
||||
_1, ToAuthor, // 1 part (20%) goes to the block author.
|
||||
>;
|
||||
|
||||
impl balances::Trait for Runtime {
|
||||
type Balance = Balance;
|
||||
type OnFreeBalanceZero = Staking;
|
||||
type OnNewAccount = Indices;
|
||||
type Event = Event;
|
||||
type TransactionPayment = ();
|
||||
type TransactionPayment = DealWithFees;
|
||||
type DustRemoval = ();
|
||||
type TransferPayment = ();
|
||||
type ExistentialDeposit = ExistentialDeposit;
|
||||
type TransferFee = TransferFee;
|
||||
type CreationFee = CreationFee;
|
||||
type TransactionBaseFee = TransactionBaseFee;
|
||||
type TransactionByteFee = TransactionByteFee;
|
||||
}
|
||||
|
||||
impl timestamp::Trait for Runtime {
|
||||
@@ -119,6 +163,18 @@ impl timestamp::Trait for Runtime {
|
||||
type OnTimestampSet = Aura;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const UncleGenerations: u64 = 0;
|
||||
}
|
||||
|
||||
// TODO: substrate#2986 implement this properly
|
||||
impl authorship::Trait for Runtime {
|
||||
type FindAuthor = ();
|
||||
type UncleGenerations = UncleGenerations;
|
||||
type FilterUncle = ();
|
||||
type EventHandler = ();
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const Period: BlockNumber = 10 * MINUTES;
|
||||
pub const Offset: BlockNumber = 0;
|
||||
@@ -174,9 +230,6 @@ impl staking::Trait for Runtime {
|
||||
type BondingDuration = BondingDuration;
|
||||
}
|
||||
|
||||
const MINUTES: BlockNumber = 6;
|
||||
const BUCKS: Balance = 1_000_000_000_000;
|
||||
|
||||
parameter_types! {
|
||||
pub const LaunchPeriod: BlockNumber = 28 * 24 * 60 * MINUTES;
|
||||
pub const VotingPeriod: BlockNumber = 28 * 24 * 60 * MINUTES;
|
||||
@@ -203,6 +256,18 @@ impl democracy::Trait for Runtime {
|
||||
type CooloffPeriod = CooloffPeriod;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const CandidacyBond: Balance = 10 * BUCKS;
|
||||
pub const VotingBond: Balance = 1 * BUCKS;
|
||||
pub const VotingFee: Balance = 2 * BUCKS;
|
||||
pub const PresentSlashPerVoter: Balance = 1 * CENTS;
|
||||
pub const CarryCount: u32 = 6;
|
||||
// one additional vote should go by before an inactive voter can be reaped.
|
||||
pub const InactiveGracePeriod: council::VoteIndex = 1;
|
||||
pub const CouncilVotingPeriod: BlockNumber = 2 * DAYS;
|
||||
pub const DecayRatio: u32 = 0;
|
||||
}
|
||||
|
||||
impl council::Trait for Runtime {
|
||||
type Event = Event;
|
||||
type BadPresentation = ();
|
||||
@@ -210,6 +275,14 @@ impl council::Trait for Runtime {
|
||||
type BadVoterIndex = ();
|
||||
type LoserCandidate = ();
|
||||
type OnMembersChanged = CouncilMotions;
|
||||
type CandidacyBond = CandidacyBond;
|
||||
type VotingBond = VotingBond;
|
||||
type VotingFee = VotingFee;
|
||||
type PresentSlashPerVoter = PresentSlashPerVoter;
|
||||
type CarryCount = CarryCount;
|
||||
type InactiveGracePeriod = InactiveGracePeriod;
|
||||
type CouncilVotingPeriod = CouncilVotingPeriod;
|
||||
type DecayRatio = DecayRatio;
|
||||
}
|
||||
|
||||
impl council::motions::Trait for Runtime {
|
||||
@@ -218,19 +291,41 @@ impl council::motions::Trait for Runtime {
|
||||
type Event = Event;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const ProposalBond: Permill = Permill::from_percent(5);
|
||||
pub const ProposalBondMinimum: Balance = 1 * BUCKS;
|
||||
pub const SpendPeriod: BlockNumber = 1 * DAYS;
|
||||
pub const Burn: Permill = Permill::from_percent(50);
|
||||
}
|
||||
|
||||
impl treasury::Trait for Runtime {
|
||||
type Currency = balances::Module<Self>;
|
||||
type Currency = Balances;
|
||||
type ApproveOrigin = council_motions::EnsureMembers<_4, AccountId>;
|
||||
type RejectOrigin = council_motions::EnsureMembers<_2, AccountId>;
|
||||
type Event = Event;
|
||||
type MintedForSpending = ();
|
||||
type ProposalRejection = ();
|
||||
type ProposalBond = ProposalBond;
|
||||
type ProposalBondMinimum = ProposalBondMinimum;
|
||||
type SpendPeriod = SpendPeriod;
|
||||
type Burn = Burn;
|
||||
}
|
||||
|
||||
impl grandpa::Trait for Runtime {
|
||||
type Event = Event;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const WindowSize: BlockNumber = finality_tracker::DEFAULT_WINDOW_SIZE.into();
|
||||
pub const ReportLatency: BlockNumber = finality_tracker::DEFAULT_REPORT_LATENCY.into();
|
||||
}
|
||||
|
||||
impl finality_tracker::Trait for Runtime {
|
||||
type OnFinalizationStalled = Grandpa;
|
||||
type WindowSize = WindowSize;
|
||||
type ReportLatency = ReportLatency;
|
||||
}
|
||||
|
||||
impl parachains::Trait for Runtime {
|
||||
type Origin = Origin;
|
||||
type Call = Call;
|
||||
@@ -263,20 +358,22 @@ construct_runtime!(
|
||||
NodeBlock = primitives::Block,
|
||||
UncheckedExtrinsic = UncheckedExtrinsic
|
||||
{
|
||||
System: system,
|
||||
System: system::{Module, Call, Storage, Config, Event},
|
||||
Aura: aura::{Module, Config<T>, Inherent(Timestamp)},
|
||||
Timestamp: timestamp::{Module, Call, Storage, Config<T>, Inherent},
|
||||
Authorship: authorship::{Module, Call, Storage},
|
||||
Indices: indices,
|
||||
Balances: balances,
|
||||
Session: session::{Module, Call, Storage, Event, Config<T>},
|
||||
Staking: staking,
|
||||
Democracy: democracy,
|
||||
Grandpa: grandpa::{Module, Call, Storage, Config<T>, Event},
|
||||
CuratedGrandpa: curated_grandpa::{Module, Call, Config<T>, Storage},
|
||||
Staking: staking::{default, OfflineWorker},
|
||||
Democracy: democracy::{Module, Call, Storage, Config, Event<T>},
|
||||
Council: council::{Module, Call, Storage, Event<T>},
|
||||
CouncilMotions: council_motions::{Module, Call, Storage, Event<T>, Origin<T>},
|
||||
CouncilSeats: council_seats::{Config<T>},
|
||||
Treasury: treasury,
|
||||
FinalityTracker: finality_tracker::{Module, Call, Inherent},
|
||||
Grandpa: grandpa::{Module, Call, Storage, Config, Event},
|
||||
CuratedGrandpa: curated_grandpa::{Module, Call, Config<T>, Storage},
|
||||
Treasury: treasury::{Module, Call, Storage, Event<T>},
|
||||
Parachains: parachains::{Module, Call, Storage, Config<T>, Inherent, Origin},
|
||||
Slots: slots::{Module, Call, Storage, Event<T>},
|
||||
Sudo: sudo,
|
||||
|
||||
@@ -93,7 +93,7 @@ pub trait ParachainRegistrar<AccountId> {
|
||||
impl<T: Trait> ParachainRegistrar<T::AccountId> for Module<T> {
|
||||
type ParaId = ParaId;
|
||||
fn new_id() -> ParaId {
|
||||
<NextFreeId<T>>::mutate(|n| { let r = *n; *n = ParaId::from(u32::from(*n) + 1); r })
|
||||
<NextFreeId>::mutate(|n| { let r = *n; *n = ParaId::from(u32::from(*n) + 1); r })
|
||||
}
|
||||
fn register_parachain(id: ParaId, code: Vec<u8>, initial_head_data: Vec<u8>) -> Result {
|
||||
let mut parachains = Self::active_parachains();
|
||||
@@ -102,9 +102,9 @@ impl<T: Trait> ParachainRegistrar<T::AccountId> for Module<T> {
|
||||
Err(idx) => parachains.insert(idx, id),
|
||||
}
|
||||
|
||||
<Code<T>>::insert(id, code);
|
||||
<Parachains<T>>::put(parachains);
|
||||
<Heads<T>>::insert(id, initial_head_data);
|
||||
<Code>::insert(id, code);
|
||||
<Parachains>::put(parachains);
|
||||
<Heads>::insert(id, initial_head_data);
|
||||
|
||||
// Because there are no ordering guarantees that inherents
|
||||
// are applied before regular transactions, a parachain candidate could
|
||||
@@ -121,8 +121,8 @@ impl<T: Trait> ParachainRegistrar<T::AccountId> for Module<T> {
|
||||
Err(_) => return Ok(()),
|
||||
}
|
||||
|
||||
<Code<T>>::remove(id);
|
||||
<Heads<T>>::remove(id);
|
||||
<Code>::remove(id);
|
||||
<Heads>::remove(id);
|
||||
|
||||
let watermark = <Watermarks<T>>::take(id);
|
||||
|
||||
@@ -137,7 +137,7 @@ impl<T: Trait> ParachainRegistrar<T::AccountId> for Module<T> {
|
||||
}
|
||||
}
|
||||
|
||||
<Parachains<T>>::put(parachains);
|
||||
<Parachains>::put(parachains);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -249,12 +249,12 @@ decl_storage! {
|
||||
|
||||
let only_ids: Vec<_> = p.iter().map(|&(ref id, _, _)| id).cloned().collect();
|
||||
|
||||
<Parachains<T> as generator::StorageValue<_>>::put(&only_ids, storage);
|
||||
<Parachains as generator::StorageValue<_>>::put(&only_ids, storage);
|
||||
|
||||
for (id, code, genesis) in p {
|
||||
// no ingress -- a chain cannot be routed to until it is live.
|
||||
<Code<T> as generator::StorageMap<_, _>>::insert(&id, &code, storage);
|
||||
<Heads<T> as generator::StorageMap<_, _>>::insert(&id, &genesis, storage);
|
||||
<Code as generator::StorageMap<_, _>>::insert(&id, &code, storage);
|
||||
<Heads as generator::StorageMap<_, _>>::insert(&id, &genesis, storage);
|
||||
<Watermarks<T> as generator::StorageMap<_, _>>::insert(&id, &Zero::zero(), storage);
|
||||
}
|
||||
});
|
||||
@@ -267,7 +267,7 @@ decl_module! {
|
||||
/// Provide candidate receipts for parachains, in ascending order by id.
|
||||
fn set_heads(origin, heads: Vec<AttestedCandidate>) -> Result {
|
||||
ensure_none(origin)?;
|
||||
ensure!(!<DidUpdate<T>>::exists(), "Parachain heads must be updated only once in the block");
|
||||
ensure!(!<DidUpdate>::exists(), "Parachain heads must be updated only once in the block");
|
||||
|
||||
let active_parachains = Self::active_parachains();
|
||||
let parachain_count = active_parachains.len();
|
||||
@@ -322,7 +322,7 @@ decl_module! {
|
||||
);
|
||||
}
|
||||
|
||||
<DidUpdate<T>>::put(true);
|
||||
<DidUpdate>::put(true);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -385,7 +385,7 @@ impl<T: Trait> Module<T> {
|
||||
) -> Result {
|
||||
// Either there are no more messages to add...
|
||||
if !upward_messages.is_empty() {
|
||||
let (count, size) = <RelayDispatchQueueSize<T>>::get(id);
|
||||
let (count, size) = <RelayDispatchQueueSize>::get(id);
|
||||
ensure!(
|
||||
// ...or we are appending one message onto an empty queue...
|
||||
upward_messages.len() + count as usize == 1
|
||||
@@ -421,7 +421,7 @@ impl<T: Trait> Module<T> {
|
||||
|
||||
for head in heads.iter() {
|
||||
let id = head.parachain_index();
|
||||
<Heads<T>>::insert(id, &head.candidate.head_data.0);
|
||||
<Heads>::insert(id, &head.candidate.head_data.0);
|
||||
|
||||
let last_watermark = <Watermarks<T>>::mutate(id, |mark| {
|
||||
rstd::mem::replace(mark, Some(watermark))
|
||||
@@ -452,14 +452,14 @@ impl<T: Trait> Module<T> {
|
||||
/// Place any new upward messages into our queue for later dispatch.
|
||||
fn queue_upward_messages(id: ParaId, upward_messages: &[UpwardMessage]) {
|
||||
if !upward_messages.is_empty() {
|
||||
<RelayDispatchQueueSize<T>>::mutate(id, |&mut(ref mut count, ref mut len)| {
|
||||
<RelayDispatchQueueSize>::mutate(id, |&mut(ref mut count, ref mut len)| {
|
||||
*count += upward_messages.len() as u32;
|
||||
*len += upward_messages.iter()
|
||||
.fold(0, |a, x| a + x.data.len()) as u32;
|
||||
});
|
||||
// Should never be able to fail assuming our state is uncorrupted, but best not
|
||||
// to panic, even if it does.
|
||||
let _ = <RelayDispatchQueue<T>>::append(id, upward_messages);
|
||||
let _ = <RelayDispatchQueue>::append(id, upward_messages);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -480,7 +480,7 @@ impl<T: Trait> Module<T> {
|
||||
let mut dispatched_count = 0usize;
|
||||
let mut dispatched_size = 0usize;
|
||||
for id in active_parachains.iter().cycle().skip(offset).take(para_count) {
|
||||
let (count, size) = <RelayDispatchQueueSize<T>>::get(id);
|
||||
let (count, size) = <RelayDispatchQueueSize>::get(id);
|
||||
let count = count as usize;
|
||||
let size = size as usize;
|
||||
if dispatched_count == 0 || (
|
||||
@@ -489,8 +489,8 @@ impl<T: Trait> Module<T> {
|
||||
) {
|
||||
if count > 0 {
|
||||
// still dispatching messages...
|
||||
<RelayDispatchQueueSize<T>>::remove(id);
|
||||
let messages = <RelayDispatchQueue<T>>::take(id);
|
||||
<RelayDispatchQueueSize>::remove(id);
|
||||
let messages = <RelayDispatchQueue>::take(id);
|
||||
for UpwardMessage { origin, data } in messages.into_iter() {
|
||||
dispatch_message(*id, origin, &data);
|
||||
}
|
||||
@@ -816,7 +816,7 @@ mod tests {
|
||||
use substrate_primitives::{H256, Blake2Hasher};
|
||||
use substrate_trie::NodeCodec;
|
||||
use sr_primitives::{
|
||||
BuildStorage, traits::{BlakeTwo256, IdentityLookup}, testing::UintAuthorityId,
|
||||
traits::{BlakeTwo256, IdentityLookup}, testing::UintAuthorityId,
|
||||
};
|
||||
use primitives::{
|
||||
parachain::{CandidateReceipt, HeadData, ValidityAttestation, ValidatorIndex}, SessionKey,
|
||||
@@ -877,6 +877,14 @@ mod tests {
|
||||
type AuthorityId = AuraId;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const ExistentialDeposit: Balance = 0;
|
||||
pub const TransferFee: Balance = 0;
|
||||
pub const CreationFee: Balance = 0;
|
||||
pub const TransactionBaseFee: Balance = 0;
|
||||
pub const TransactionByteFee: Balance = 0;
|
||||
}
|
||||
|
||||
impl balances::Trait for Test {
|
||||
type Balance = Balance;
|
||||
type OnFreeBalanceZero = ();
|
||||
@@ -885,6 +893,11 @@ mod tests {
|
||||
type TransactionPayment = ();
|
||||
type DustRemoval = ();
|
||||
type TransferPayment = ();
|
||||
type ExistentialDeposit = ExistentialDeposit;
|
||||
type TransferFee = TransferFee;
|
||||
type CreationFee = CreationFee;
|
||||
type TransactionBaseFee = TransactionBaseFee;
|
||||
type TransactionByteFee = TransactionByteFee;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
@@ -913,7 +926,7 @@ mod tests {
|
||||
type System = system::Module<Test>;
|
||||
|
||||
fn new_test_ext(parachains: Vec<(ParaId, Vec<u8>, Vec<u8>)>) -> TestExternalities<Blake2Hasher> {
|
||||
let mut t = system::GenesisConfig::<Test>::default().build_storage().unwrap().0;
|
||||
let mut t = system::GenesisConfig::default().build_storage::<Test>().unwrap().0;
|
||||
let authority_keys = [
|
||||
AuthorityKeyring::Alice,
|
||||
AuthorityKeyring::Bob,
|
||||
@@ -1049,8 +1062,8 @@ mod tests {
|
||||
assert_eq!(dispatched, vec![
|
||||
(0.into(), ParachainDispatchOrigin::Parachain, vec![0; 4])
|
||||
]);
|
||||
assert!(<RelayDispatchQueue<Test>>::get(ParaId::from(0)).is_empty());
|
||||
assert_eq!(<RelayDispatchQueue<Test>>::get(ParaId::from(1)).len(), 1);
|
||||
assert!(<RelayDispatchQueue>::get(ParaId::from(0)).is_empty());
|
||||
assert_eq!(<RelayDispatchQueue>::get(ParaId::from(1)).len(), 1);
|
||||
});
|
||||
with_externalities(&mut new_test_ext(parachains.clone()), || {
|
||||
let parachains = vec![0.into(), 1.into(), 2.into()];
|
||||
@@ -1070,9 +1083,9 @@ mod tests {
|
||||
(0.into(), ParachainDispatchOrigin::Parachain, vec![0; 2]),
|
||||
(2.into(), ParachainDispatchOrigin::Parachain, vec![2])
|
||||
]);
|
||||
assert!(<RelayDispatchQueue<Test>>::get(ParaId::from(0)).is_empty());
|
||||
assert_eq!(<RelayDispatchQueue<Test>>::get(ParaId::from(1)).len(), 1);
|
||||
assert!(<RelayDispatchQueue<Test>>::get(ParaId::from(2)).is_empty());
|
||||
assert!(<RelayDispatchQueue>::get(ParaId::from(0)).is_empty());
|
||||
assert_eq!(<RelayDispatchQueue>::get(ParaId::from(1)).len(), 1);
|
||||
assert!(<RelayDispatchQueue>::get(ParaId::from(2)).is_empty());
|
||||
});
|
||||
with_externalities(&mut new_test_ext(parachains.clone()), || {
|
||||
let parachains = vec![0.into(), 1.into(), 2.into()];
|
||||
@@ -1092,9 +1105,9 @@ mod tests {
|
||||
(1.into(), ParachainDispatchOrigin::Parachain, vec![1; 2]),
|
||||
(2.into(), ParachainDispatchOrigin::Parachain, vec![2])
|
||||
]);
|
||||
assert_eq!(<RelayDispatchQueue<Test>>::get(ParaId::from(0)).len(), 1);
|
||||
assert!(<RelayDispatchQueue<Test>>::get(ParaId::from(1)).is_empty());
|
||||
assert!(<RelayDispatchQueue<Test>>::get(ParaId::from(2)).is_empty());
|
||||
assert_eq!(<RelayDispatchQueue>::get(ParaId::from(0)).len(), 1);
|
||||
assert!(<RelayDispatchQueue>::get(ParaId::from(1)).is_empty());
|
||||
assert!(<RelayDispatchQueue>::get(ParaId::from(2)).is_empty());
|
||||
});
|
||||
with_externalities(&mut new_test_ext(parachains.clone()), || {
|
||||
let parachains = vec![0.into(), 1.into(), 2.into()];
|
||||
@@ -1114,9 +1127,9 @@ mod tests {
|
||||
(2.into(), ParachainDispatchOrigin::Parachain, vec![2]),
|
||||
(0.into(), ParachainDispatchOrigin::Parachain, vec![0; 2])
|
||||
]);
|
||||
assert!(<RelayDispatchQueue<Test>>::get(ParaId::from(0)).is_empty());
|
||||
assert_eq!(<RelayDispatchQueue<Test>>::get(ParaId::from(1)).len(), 1);
|
||||
assert!(<RelayDispatchQueue<Test>>::get(ParaId::from(2)).is_empty());
|
||||
assert!(<RelayDispatchQueue>::get(ParaId::from(0)).is_empty());
|
||||
assert_eq!(<RelayDispatchQueue>::get(ParaId::from(1)).len(), 1);
|
||||
assert!(<RelayDispatchQueue>::get(ParaId::from(2)).is_empty());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1140,7 +1153,7 @@ mod tests {
|
||||
];
|
||||
assert_ok!(Parachains::check_upward_messages(0.into(), &messages, 2, 3));
|
||||
Parachains::queue_upward_messages(0.into(), &messages);
|
||||
assert_eq!(<RelayDispatchQueue<Test>>::get(ParaId::from(0)), vec![
|
||||
assert_eq!(<RelayDispatchQueue>::get(ParaId::from(0)), vec![
|
||||
UpwardMessage { origin: ParachainDispatchOrigin::Signed, data: vec![0] },
|
||||
UpwardMessage { origin: ParachainDispatchOrigin::Parachain, data: vec![1, 2] },
|
||||
]);
|
||||
@@ -1288,8 +1301,8 @@ mod tests {
|
||||
Origin::NONE,
|
||||
));
|
||||
|
||||
assert!(<RelayDispatchQueue<Test>>::get(ParaId::from(0)).is_empty());
|
||||
assert!(<RelayDispatchQueue<Test>>::get(ParaId::from(1)).is_empty());
|
||||
assert!(<RelayDispatchQueue>::get(ParaId::from(0)).is_empty());
|
||||
assert!(<RelayDispatchQueue>::get(ParaId::from(1)).is_empty());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1436,10 +1449,10 @@ mod tests {
|
||||
Origin::NONE,
|
||||
).is_err());
|
||||
|
||||
assert!(Parachains::dispatch(
|
||||
assert_ok!(Parachains::dispatch(
|
||||
set_heads(vec![candidate_a.clone(), candidate_b.clone()]),
|
||||
Origin::NONE,
|
||||
).is_ok());
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1527,19 +1540,19 @@ mod tests {
|
||||
make_attestations(&mut candidate_a);
|
||||
make_attestations(&mut candidate_b);
|
||||
|
||||
assert!(Parachains::dispatch(
|
||||
assert_ok!(Parachains::dispatch(
|
||||
set_heads(vec![candidate_a, candidate_b]),
|
||||
Origin::NONE,
|
||||
).is_ok());
|
||||
));
|
||||
|
||||
Parachains::on_finalize(i);
|
||||
}
|
||||
|
||||
System::set_block_number(10);
|
||||
assert!(Parachains::dispatch(
|
||||
assert_ok!(Parachains::dispatch(
|
||||
set_heads(vec![]),
|
||||
Origin::NONE,
|
||||
).is_ok());
|
||||
));
|
||||
|
||||
// parachain 1 has had a bunch of parachain candidates included,
|
||||
// which raises the watermark.
|
||||
@@ -1588,10 +1601,10 @@ mod tests {
|
||||
};
|
||||
make_attestations(&mut candidate_c);
|
||||
|
||||
assert!(Parachains::dispatch(
|
||||
assert_ok!(Parachains::dispatch(
|
||||
set_heads(vec![candidate_c]),
|
||||
Origin::NONE,
|
||||
).is_ok());
|
||||
));
|
||||
|
||||
Parachains::on_finalize(11);
|
||||
System::set_block_number(12);
|
||||
|
||||
@@ -250,7 +250,7 @@ decl_module! {
|
||||
ensure!(lease_period_index >= Self::lease_period_index(), "lease period in past");
|
||||
|
||||
// Bump the counter.
|
||||
let n = <AuctionCounter<T>>::mutate(|n| { *n += 1; *n });
|
||||
let n = <AuctionCounter>::mutate(|n| { *n += 1; *n });
|
||||
|
||||
// Set the information.
|
||||
let ending = <system::Module<T>>::block_number() + duration;
|
||||
@@ -639,7 +639,7 @@ impl<T: Trait> Module<T> {
|
||||
amount: BalanceOf<T>
|
||||
) -> Result<(), &'static str> {
|
||||
// Bidding on latest auction.
|
||||
ensure!(auction_index == <AuctionCounter<T>>::get(), "not current auction");
|
||||
ensure!(auction_index == <AuctionCounter>::get(), "not current auction");
|
||||
// Assume it's actually an auction (this should never fail because of above).
|
||||
let (first_lease_period, _) = <AuctionInfo<T>>::get().ok_or("not an auction")?;
|
||||
|
||||
@@ -781,8 +781,7 @@ mod tests {
|
||||
use substrate_primitives::{Blake2Hasher, H256};
|
||||
use sr_io::with_externalities;
|
||||
use sr_primitives::{
|
||||
BuildStorage, testing::Header,
|
||||
traits::{BlakeTwo256, Hash, IdentityLookup, OnInitialize, OnFinalize},
|
||||
testing::Header, traits::{BlakeTwo256, Hash, IdentityLookup, OnInitialize, OnFinalize},
|
||||
};
|
||||
use srml_support::{impl_outer_origin, parameter_types, assert_ok, assert_noop};
|
||||
use balances;
|
||||
@@ -809,14 +808,27 @@ mod tests {
|
||||
type Event = ();
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const ExistentialDeposit: u64 = 0;
|
||||
pub const TransferFee: u64 = 0;
|
||||
pub const CreationFee: u64 = 0;
|
||||
pub const TransactionBaseFee: u64 = 0;
|
||||
pub const TransactionByteFee: u64 = 0;
|
||||
}
|
||||
|
||||
impl balances::Trait for Test {
|
||||
type Balance = u64;
|
||||
type OnFreeBalanceZero = ();
|
||||
type OnNewAccount = ();
|
||||
type TransactionPayment = ();
|
||||
type TransferPayment = ();
|
||||
type DustRemoval = ();
|
||||
type Event = ();
|
||||
type TransactionPayment = ();
|
||||
type DustRemoval = ();
|
||||
type TransferPayment = ();
|
||||
type ExistentialDeposit = ExistentialDeposit;
|
||||
type TransferFee = TransferFee;
|
||||
type CreationFee = CreationFee;
|
||||
type TransactionBaseFee = TransactionBaseFee;
|
||||
type TransactionByteFee = TransactionByteFee;
|
||||
}
|
||||
|
||||
thread_local! {
|
||||
@@ -886,14 +898,9 @@ mod tests {
|
||||
// This function basically just builds a genesis storage key/value store according to
|
||||
// our desired mock up.
|
||||
fn new_test_ext() -> sr_io::TestExternalities<Blake2Hasher> {
|
||||
let mut t = system::GenesisConfig::<Test>::default().build_storage().unwrap().0;
|
||||
let mut t = system::GenesisConfig::default().build_storage::<Test>().unwrap().0;
|
||||
t.extend(balances::GenesisConfig::<Test>{
|
||||
transaction_base_fee: 0,
|
||||
transaction_byte_fee: 0,
|
||||
balances: vec![(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60)],
|
||||
existential_deposit: 0,
|
||||
transfer_fee: 0,
|
||||
creation_fee: 0,
|
||||
vesting: vec![],
|
||||
}.build_storage().unwrap().0);
|
||||
t.into()
|
||||
|
||||
Generated
+238
-195
File diff suppressed because it is too large
Load Diff
@@ -19,9 +19,9 @@
|
||||
use primitives::{ed25519, sr25519, Pair, crypto::UncheckedInto};
|
||||
use polkadot_primitives::{AccountId, SessionKey};
|
||||
use polkadot_runtime::{
|
||||
GenesisConfig, CouncilSeatsConfig, DemocracyConfig, TreasuryConfig, SystemConfig, AuraConfig,
|
||||
GenesisConfig, CouncilSeatsConfig, DemocracyConfig, SystemConfig, AuraConfig,
|
||||
SessionConfig, StakingConfig, TimestampConfig, BalancesConfig, Perbill, SessionKeys,
|
||||
GrandpaConfig, SudoConfig, IndicesConfig, Permill, CuratedGrandpaConfig, StakerStatus,
|
||||
GrandpaConfig, SudoConfig, IndicesConfig, CuratedGrandpaConfig, StakerStatus,
|
||||
};
|
||||
use telemetry::TelemetryEndpoints;
|
||||
use hex_literal::hex;
|
||||
@@ -78,19 +78,13 @@ fn staging_testnet_config_genesis() -> GenesisConfig {
|
||||
system: Some(SystemConfig {
|
||||
// TODO: Change after Substrate 1252 is fixed (https://github.com/paritytech/substrate/issues/1252)
|
||||
code: include_bytes!("../../runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.compact.wasm").to_vec(),
|
||||
_genesis_phantom_data: Default::default(),
|
||||
changes_trie_config: Default::default(),
|
||||
}),
|
||||
balances: Some(BalancesConfig {
|
||||
transaction_base_fee: 1 * CENTS,
|
||||
transaction_byte_fee: 10 * MILLICENTS,
|
||||
balances: endowed_accounts.iter()
|
||||
.map(|k: &AccountId| (k.clone(), ENDOWMENT))
|
||||
.chain(initial_authorities.iter().map(|x| (x.0.clone(), STASH)))
|
||||
.collect(),
|
||||
existential_deposit: 1 * DOLLARS,
|
||||
transfer_fee: 1 * CENTS,
|
||||
creation_fee: 1 * CENTS,
|
||||
vesting: vec![],
|
||||
}),
|
||||
indices: Some(IndicesConfig {
|
||||
@@ -119,33 +113,18 @@ fn staging_testnet_config_genesis() -> GenesisConfig {
|
||||
democracy: Some(Default::default()),
|
||||
council_seats: Some(CouncilSeatsConfig {
|
||||
active_council: vec![],
|
||||
candidacy_bond: 10 * DOLLARS,
|
||||
voter_bond: 1 * DOLLARS,
|
||||
voting_fee: 2 * DOLLARS,
|
||||
present_slash_per_voter: 1 * CENTS,
|
||||
carry_count: 6,
|
||||
presentation_duration: 1 * DAYS,
|
||||
approval_voting_period: 2 * DAYS,
|
||||
term_duration: 28 * DAYS,
|
||||
desired_seats: 0,
|
||||
decay_ratio: 0,
|
||||
inactive_grace_period: 1, // one additional vote should go by before an inactive voter can be reaped.
|
||||
}),
|
||||
timestamp: Some(TimestampConfig {
|
||||
minimum_period: SECS_PER_BLOCK / 2, // due to the nature of aura the slots are 2*period
|
||||
}),
|
||||
treasury: Some(TreasuryConfig {
|
||||
proposal_bond: Permill::from_percent(5),
|
||||
proposal_bond_minimum: 1 * DOLLARS,
|
||||
spend_period: 1 * DAYS,
|
||||
burn: Permill::from_percent(50),
|
||||
}),
|
||||
sudo: Some(SudoConfig {
|
||||
key: endowed_accounts[0].clone(),
|
||||
}),
|
||||
grandpa: Some(GrandpaConfig {
|
||||
authorities: initial_authorities.iter().map(|x| (x.2.clone(), 1)).collect(),
|
||||
_genesis_phantom_data: Default::default(),
|
||||
}),
|
||||
aura: Some(AuraConfig {
|
||||
authorities: initial_authorities.iter().map(|x| x.2.clone()).collect(),
|
||||
@@ -226,18 +205,12 @@ pub fn testnet_genesis(
|
||||
system: Some(SystemConfig {
|
||||
// TODO: Change after Substrate 1252 is fixed (https://github.com/paritytech/substrate/issues/1252)
|
||||
code: include_bytes!("../../runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.compact.wasm").to_vec(),
|
||||
_genesis_phantom_data: Default::default(),
|
||||
changes_trie_config: Default::default(),
|
||||
}),
|
||||
indices: Some(IndicesConfig {
|
||||
ids: endowed_accounts.clone(),
|
||||
}),
|
||||
balances: Some(BalancesConfig {
|
||||
transaction_base_fee: 1,
|
||||
transaction_byte_fee: 0,
|
||||
existential_deposit: 500,
|
||||
transfer_fee: 0,
|
||||
creation_fee: 0,
|
||||
balances: endowed_accounts.iter().map(|k| (k.clone(), ENDOWMENT)).collect(),
|
||||
vesting: vec![],
|
||||
}),
|
||||
@@ -256,42 +229,31 @@ pub fn testnet_genesis(
|
||||
session_reward: Perbill::zero(),
|
||||
current_session_reward: 0,
|
||||
offline_slash_grace: 0,
|
||||
stakers: initial_authorities.iter().map(|x| (x.0.clone(), x.1.clone(), STASH, StakerStatus::Validator)).collect(),
|
||||
stakers: initial_authorities.iter()
|
||||
.map(|x| (x.0.clone(), x.1.clone(), STASH, StakerStatus::Validator))
|
||||
.collect(),
|
||||
invulnerables: initial_authorities.iter().map(|x| x.1.clone()).collect(),
|
||||
}),
|
||||
democracy: Some(DemocracyConfig::default()),
|
||||
council_seats: Some(CouncilSeatsConfig {
|
||||
active_council: endowed_accounts.iter()
|
||||
.filter(|&endowed| initial_authorities.iter().find(|&(_, controller, _)| controller == endowed).is_none())
|
||||
.map(|a| (a.clone(), 1000000)).collect(),
|
||||
candidacy_bond: 10,
|
||||
voter_bond: 2,
|
||||
voting_fee: 5,
|
||||
present_slash_per_voter: 1,
|
||||
carry_count: 4,
|
||||
.filter(|&endowed| initial_authorities.iter()
|
||||
.find(|&(_, controller, _)| controller == endowed)
|
||||
.is_none()
|
||||
).map(|a| (a.clone(), 1000000)).collect(),
|
||||
presentation_duration: 10,
|
||||
approval_voting_period: 20,
|
||||
term_duration: 1000000,
|
||||
desired_seats: (endowed_accounts.len() - initial_authorities.len()) as u32,
|
||||
decay_ratio: council_desired_seats / 3,
|
||||
inactive_grace_period: 1,
|
||||
desired_seats: council_desired_seats,
|
||||
}),
|
||||
parachains: Some(Default::default()),
|
||||
timestamp: Some(TimestampConfig {
|
||||
minimum_period: 2, // 2*2=4 second block time.
|
||||
}),
|
||||
treasury: Some(TreasuryConfig {
|
||||
proposal_bond: Permill::from_percent(5),
|
||||
proposal_bond_minimum: 1_000_000,
|
||||
spend_period: 12 * 60 * 24,
|
||||
burn: Permill::from_percent(50),
|
||||
}),
|
||||
sudo: Some(SudoConfig {
|
||||
key: root_key,
|
||||
}),
|
||||
grandpa: Some(GrandpaConfig {
|
||||
authorities: initial_authorities.iter().map(|x| (x.2.clone(), 1)).collect(),
|
||||
_genesis_phantom_data: Default::default(),
|
||||
}),
|
||||
aura: Some(AuraConfig {
|
||||
authorities: initial_authorities.iter().map(|x| x.2.clone()).collect(),
|
||||
|
||||
@@ -26,7 +26,6 @@ use polkadot_primitives::{parachain, Block, Hash, BlockId};
|
||||
use polkadot_runtime::{GenesisConfig, RuntimeApi};
|
||||
use polkadot_network::gossip::{self as network_gossip, Known};
|
||||
use primitives::{ed25519, Pair};
|
||||
use tokio::runtime::TaskExecutor;
|
||||
use service::{FactoryFullConfiguration, FullBackend, LightBackend, FullExecutor, LightExecutor};
|
||||
use transaction_pool::txpool::{Pool as TransactionPool};
|
||||
use aura::{import_queue, start_aura, AuraImportQueue, SlotDuration};
|
||||
@@ -161,10 +160,10 @@ service::construct_service_factory! {
|
||||
Genesis = GenesisConfig,
|
||||
Configuration = CustomConfiguration,
|
||||
FullService = FullComponents<Self>
|
||||
{ |config: FactoryFullConfiguration<Self>, executor: TaskExecutor| {
|
||||
FullComponents::<Factory>::new(config, executor)
|
||||
{ |config: FactoryFullConfiguration<Self>| {
|
||||
FullComponents::<Factory>::new(config)
|
||||
} },
|
||||
AuthoritySetup = { |mut service: Self::FullService, executor: TaskExecutor, key: Option<Arc<ed25519::Pair>>| {
|
||||
AuthoritySetup = { |mut service: Self::FullService, key: Option<Arc<ed25519::Pair>>| {
|
||||
use polkadot_network::validation::ValidationNetwork;
|
||||
|
||||
let (block_import, link_half) = service.config.custom.grandpa_import_setup.take()
|
||||
@@ -188,7 +187,7 @@ service::construct_service_factory! {
|
||||
|
||||
match config.local_key {
|
||||
None => {
|
||||
executor.spawn(grandpa::run_grandpa_observer(
|
||||
service.spawn_task(grandpa::run_grandpa_observer(
|
||||
config,
|
||||
link_half,
|
||||
service.network(),
|
||||
@@ -199,9 +198,7 @@ service::construct_service_factory! {
|
||||
use service::TelemetryOnConnect;
|
||||
|
||||
let telemetry_on_connect = TelemetryOnConnect {
|
||||
on_exit: Box::new(service.on_exit()),
|
||||
telemetry_connection_sinks: service.telemetry_on_connect_stream(),
|
||||
executor: &executor,
|
||||
};
|
||||
|
||||
let grandpa_config = grandpa::GrandpaParams {
|
||||
@@ -212,7 +209,7 @@ service::construct_service_factory! {
|
||||
on_exit: service.on_exit(),
|
||||
telemetry_on_connect: Some(telemetry_on_connect),
|
||||
};
|
||||
executor.spawn(grandpa::run_grandpa_voter(grandpa_config)?);
|
||||
service.spawn_task(grandpa::run_grandpa_voter(grandpa_config)?);
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -280,7 +277,7 @@ service::construct_service_factory! {
|
||||
service.on_exit(),
|
||||
gossip_validator,
|
||||
service.client(),
|
||||
executor.clone(),
|
||||
polkadot_network::validation::WrappedExecutor(service.spawn_task_handle()),
|
||||
);
|
||||
let proposer_factory = ::consensus::ProposerFactory::new(
|
||||
client.clone(),
|
||||
@@ -288,7 +285,7 @@ service::construct_service_factory! {
|
||||
validation_network.clone(),
|
||||
validation_network,
|
||||
service.transaction_pool(),
|
||||
executor.clone(),
|
||||
Arc::new(service.spawn_task_handle()),
|
||||
key.clone(),
|
||||
extrinsic_store,
|
||||
SlotDuration::get_or_compute(&*client)?,
|
||||
@@ -308,11 +305,11 @@ service::construct_service_factory! {
|
||||
service.config.force_authoring,
|
||||
)?;
|
||||
|
||||
executor.spawn(task);
|
||||
service.spawn_task(task);
|
||||
Ok(service)
|
||||
}},
|
||||
LightService = LightComponents<Self>
|
||||
{ |config, executor| <LightComponents<Factory>>::new(config, executor) },
|
||||
{ |config| <LightComponents<Factory>>::new(config) },
|
||||
FullImportQueue = AuraImportQueue<
|
||||
Self::Block,
|
||||
>
|
||||
|
||||
@@ -5,6 +5,6 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
parity-codec = { version = "3.0", features = ["derive"] }
|
||||
parity-codec = { version = "4.1", features = ["derive"] }
|
||||
substrate-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
primitives = { package = "polkadot-primitives", path = "../primitives" }
|
||||
|
||||
@@ -7,5 +7,5 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
parachain = { package = "polkadot-parachain", path = "../../parachain/", default-features = false }
|
||||
parity-codec = { version = "3.5", default-features = false, features = ["derive"] }
|
||||
parity-codec = { version = "4.1", default-features = false, features = ["derive"] }
|
||||
tiny-keccak = "1.4"
|
||||
|
||||
@@ -11,7 +11,7 @@ tokio = "0.1.7"
|
||||
derive_more = "0.14.0"
|
||||
log = "0.4.6"
|
||||
exit-future = "0.1"
|
||||
parity-codec = "3.1"
|
||||
parity-codec = "4.1"
|
||||
extrinsic_store = { package = "polkadot-availability-store", path = "../availability-store" }
|
||||
parachain = { package = "polkadot-parachain", path = "../parachain" }
|
||||
polkadot-primitives = { path = "../primitives" }
|
||||
|
||||
@@ -31,17 +31,20 @@ use client::blockchain::HeaderBackend;
|
||||
use consensus::SelectChain;
|
||||
use extrinsic_store::Store as ExtrinsicStore;
|
||||
use futures::prelude::*;
|
||||
use log::error;
|
||||
use primitives::ed25519;
|
||||
use polkadot_primitives::{Block, BlockId, AuraId};
|
||||
use polkadot_primitives::parachain::{CandidateReceipt, ParachainHost};
|
||||
use runtime_primitives::traits::{ProvideRuntimeApi, Header as HeaderT};
|
||||
use aura::AuraApi;
|
||||
|
||||
use tokio::{timer::Interval, runtime::{TaskExecutor, current_thread::Runtime as LocalRuntime}};
|
||||
use tokio::{timer::Interval, runtime::current_thread::Runtime as LocalRuntime};
|
||||
use log::{warn, debug};
|
||||
|
||||
use super::{Network, Collators};
|
||||
|
||||
type TaskExecutor = Arc<dyn futures::future::Executor<Box<dyn Future<Item = (), Error = ()> + Send>> + Send + Sync>;
|
||||
|
||||
/// Gets a list of the candidates in a block.
|
||||
pub(crate) fn fetch_candidates<P: BlockBody<Block>>(client: &P, block: &BlockId)
|
||||
-> ClientResult<Option<impl Iterator<Item=CandidateReceipt>>>
|
||||
@@ -179,14 +182,18 @@ pub(crate) fn start<C, N, P, SC>(
|
||||
};
|
||||
|
||||
runtime.spawn(notifications);
|
||||
thread_pool.spawn(prune_old_sessions);
|
||||
if let Err(_) = thread_pool.execute(Box::new(prune_old_sessions)) {
|
||||
error!("Failed to spawn old sessions pruning task");
|
||||
}
|
||||
|
||||
let prune_available = prune_unneeded_availability(client, extrinsic_store)
|
||||
.select(exit.clone())
|
||||
.then(|_| Ok(()));
|
||||
|
||||
// spawn this on the tokio executor since it's fine on a thread pool.
|
||||
thread_pool.spawn(prune_available);
|
||||
if let Err(_) = thread_pool.execute(Box::new(prune_available)) {
|
||||
error!("Failed to spawn available pruning task");
|
||||
}
|
||||
|
||||
if let Err(e) = runtime.block_on(exit) {
|
||||
debug!("BFT event loop error {:?}", e);
|
||||
|
||||
@@ -51,7 +51,6 @@ use primitives::{Pair, ed25519};
|
||||
use runtime_primitives::{
|
||||
traits::{ProvideRuntimeApi, Header as HeaderT, DigestFor}, ApplyError
|
||||
};
|
||||
use tokio::runtime::TaskExecutor;
|
||||
use tokio::timer::{Delay, Interval};
|
||||
use transaction_pool::txpool::{Pool, ChainApi as PoolChainApi};
|
||||
|
||||
@@ -62,10 +61,12 @@ use collation::CollationFetch;
|
||||
use dynamic_inclusion::DynamicInclusion;
|
||||
use inherents::InherentData;
|
||||
use runtime_aura::timestamp::TimestampInherentData;
|
||||
use log::{info, debug, warn, trace};
|
||||
use log::{info, debug, warn, trace, error};
|
||||
|
||||
use ed25519::Public as AuthorityId;
|
||||
|
||||
type TaskExecutor = Arc<dyn futures::future::Executor<Box<dyn Future<Item = (), Error = ()> + Send>> + Send + Sync>;
|
||||
|
||||
pub use self::collation::{
|
||||
validate_collation, validate_incoming, message_queue_root, egress_roots, Collators,
|
||||
};
|
||||
@@ -427,7 +428,9 @@ impl<C, N, P> ParachainValidation<C, N, P> where
|
||||
.then(|_| Ok(()));
|
||||
|
||||
// spawn onto thread pool.
|
||||
self.handle.spawn(cancellable_work);
|
||||
if let Err(_) = self.handle.execute(Box::new(cancellable_work)) {
|
||||
error!("Failed to spawn cancellable work task");
|
||||
}
|
||||
signal
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user