mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-01 13:37:57 +00:00
Update to latest Substrate master + warning fixes (#292)
* Update to latest Substrate master + warning fixes * Update runtime/src/lib.rs Co-Authored-By: thiolliere <gui.thiolliere@gmail.com>
This commit is contained in:
committed by
Robert Habermeier
parent
58ab4f6b9f
commit
a016bac6ad
Generated
+366
-517
File diff suppressed because it is too large
Load Diff
@@ -10,8 +10,8 @@ futures = "0.1.17"
|
||||
client = { package = "substrate-client", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
parity-codec = "3.0"
|
||||
primitives = { package = "substrate-primitives", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
consensus_authorities = { package = "substrate-consensus-authorities", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
consensus_common = { package = "substrate-consensus-common", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
aura = { package = "substrate-consensus-aura", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
polkadot-runtime = { path = "../runtime", version = "0.1" }
|
||||
polkadot-primitives = { path = "../primitives", version = "0.1" }
|
||||
polkadot-cli = { path = "../cli" }
|
||||
|
||||
@@ -63,8 +63,8 @@ use polkadot_cli::{Worker, IntoExit, ProvideRuntimeApi, TaskExecutor};
|
||||
use polkadot_network::validation::{ValidationNetwork, SessionParams};
|
||||
use polkadot_network::NetworkService;
|
||||
use tokio::timer::Timeout;
|
||||
use consensus_authorities::AuthoritiesApi;
|
||||
use consensus_common::SelectChain;
|
||||
use aura::AuraApi;
|
||||
|
||||
pub use polkadot_cli::VersionInfo;
|
||||
pub use polkadot_network::validation::Incoming;
|
||||
@@ -189,7 +189,7 @@ impl<P: 'static, E: 'static> RelayChainContext for ApiContext<P, E> where
|
||||
E: Future<Item=(),Error=()> + Clone + Send + Sync + 'static,
|
||||
{
|
||||
type Error = String;
|
||||
type FutureEgress = Box<Future<Item=ConsolidatedIngress, Error=String> + Send>;
|
||||
type FutureEgress = Box<dyn Future<Item=ConsolidatedIngress, Error=String> + Send>;
|
||||
|
||||
fn unrouted_egress(&self, _id: ParaId) -> Self::FutureEgress {
|
||||
// TODO: https://github.com/paritytech/polkadot/issues/253
|
||||
@@ -227,7 +227,7 @@ impl<P, E> Worker for CollationNode<P, E> where
|
||||
E: Future<Item=(),Error=()> + Clone + Send + Sync + 'static,
|
||||
<P::ProduceCandidate as IntoFuture>::Future: Send + 'static,
|
||||
{
|
||||
type Work = Box<Future<Item=(),Error=()> + Send>;
|
||||
type Work = Box<dyn Future<Item=(),Error=()> + Send>;
|
||||
|
||||
fn configuration(&self) -> CustomConfiguration {
|
||||
let mut config = CustomConfiguration::default();
|
||||
@@ -409,7 +409,7 @@ mod tests {
|
||||
|
||||
impl RelayChainContext for DummyRelayChainContext {
|
||||
type Error = ();
|
||||
type FutureEgress = Box<Future<Item=ConsolidatedIngress,Error=()>>;
|
||||
type FutureEgress = Box<dyn Future<Item=ConsolidatedIngress,Error=()>>;
|
||||
|
||||
fn unrouted_egress(&self, para_id: ParaId) -> Self::FutureEgress {
|
||||
match self.ingress.get(¶_id) {
|
||||
|
||||
@@ -158,14 +158,14 @@ pub fn register_validator<O: KnownOracle + 'static>(
|
||||
/// Create this using `register_validator`.
|
||||
#[derive(Clone)]
|
||||
pub struct RegisteredMessageValidator {
|
||||
inner: Arc<MessageValidator<KnownOracle>>,
|
||||
inner: Arc<MessageValidator<dyn KnownOracle>>,
|
||||
}
|
||||
|
||||
impl RegisteredMessageValidator {
|
||||
#[cfg(test)]
|
||||
pub(crate) fn new_test<O: KnownOracle + 'static>(
|
||||
oracle: O,
|
||||
report_handle: Box<Fn(&PeerId, i32) + Send + Sync>,
|
||||
report_handle: Box<dyn Fn(&PeerId, i32) + Send + Sync>,
|
||||
) -> Self {
|
||||
let validator = Arc::new(MessageValidator::new_test(oracle, report_handle));
|
||||
|
||||
@@ -423,7 +423,7 @@ impl<O: ?Sized + KnownOracle> Inner<O> {
|
||||
|
||||
/// An unregistered message validator. Register this with `register_validator`.
|
||||
pub struct MessageValidator<O: ?Sized> {
|
||||
report_handle: Box<Fn(&PeerId, i32) + Send + Sync>,
|
||||
report_handle: Box<dyn Fn(&PeerId, i32) + Send + Sync>,
|
||||
inner: RwLock<Inner<O>>,
|
||||
}
|
||||
|
||||
@@ -431,7 +431,7 @@ impl<O: KnownOracle + ?Sized> MessageValidator<O> {
|
||||
#[cfg(test)]
|
||||
fn new_test(
|
||||
oracle: O,
|
||||
report_handle: Box<Fn(&PeerId, i32) + Send + Sync>,
|
||||
report_handle: Box<dyn Fn(&PeerId, i32) + Send + Sync>,
|
||||
) -> Self where O: Sized{
|
||||
MessageValidator {
|
||||
report_handle,
|
||||
@@ -449,19 +449,19 @@ impl<O: KnownOracle + ?Sized> MessageValidator<O> {
|
||||
}
|
||||
|
||||
impl<O: KnownOracle + ?Sized> network_gossip::Validator<Block> for MessageValidator<O> {
|
||||
fn new_peer(&self, _context: &mut ValidatorContext<Block>, who: &PeerId, _roles: Roles) {
|
||||
fn new_peer(&self, _context: &mut dyn ValidatorContext<Block>, who: &PeerId, _roles: Roles) {
|
||||
let mut inner = self.inner.write();
|
||||
inner.peers.insert(who.clone(), PeerData {
|
||||
live: HashMap::new(),
|
||||
});
|
||||
}
|
||||
|
||||
fn peer_disconnected(&self, _context: &mut ValidatorContext<Block>, who: &PeerId) {
|
||||
fn peer_disconnected(&self, _context: &mut dyn ValidatorContext<Block>, who: &PeerId) {
|
||||
let mut inner = self.inner.write();
|
||||
inner.peers.remove(who);
|
||||
}
|
||||
|
||||
fn validate(&self, context: &mut ValidatorContext<Block>, sender: &PeerId, mut data: &[u8])
|
||||
fn validate(&self, context: &mut dyn ValidatorContext<Block>, sender: &PeerId, mut data: &[u8])
|
||||
-> GossipValidationResult<Hash>
|
||||
{
|
||||
let (res, cost_benefit) = match GossipMessage::decode(&mut data) {
|
||||
@@ -486,7 +486,7 @@ impl<O: KnownOracle + ?Sized> network_gossip::Validator<Block> for MessageValida
|
||||
res
|
||||
}
|
||||
|
||||
fn message_expired<'a>(&'a self) -> Box<FnMut(Hash, &[u8]) -> bool + 'a> {
|
||||
fn message_expired<'a>(&'a self) -> Box<dyn FnMut(Hash, &[u8]) -> bool + 'a> {
|
||||
let inner = self.inner.read();
|
||||
|
||||
Box::new(move |topic, _data| {
|
||||
@@ -495,7 +495,7 @@ impl<O: KnownOracle + ?Sized> network_gossip::Validator<Block> for MessageValida
|
||||
})
|
||||
}
|
||||
|
||||
fn message_allowed<'a>(&'a self) -> Box<FnMut(&PeerId, MessageIntent, &Hash, &[u8]) -> bool + 'a> {
|
||||
fn message_allowed<'a>(&'a self) -> Box<dyn FnMut(&PeerId, MessageIntent, &Hash, &[u8]) -> bool + 'a> {
|
||||
let mut inner = self.inner.write();
|
||||
Box::new(move |who, intent, topic, data| {
|
||||
let &mut Inner { ref mut peers, ref mut our_view, .. } = &mut *inner;
|
||||
|
||||
+27
-16
@@ -175,7 +175,7 @@ pub enum Message {
|
||||
Collation(Hash, Collation),
|
||||
}
|
||||
|
||||
fn send_polkadot_message(ctx: &mut Context<Block>, to: PeerId, message: Message) {
|
||||
fn send_polkadot_message(ctx: &mut dyn Context<Block>, to: PeerId, message: Message) {
|
||||
trace!(target: "p_net", "Sending polkadot message to {}: {:?}", to, message);
|
||||
let encoded = message.encode();
|
||||
ctx.send_chain_specific(to, encoded)
|
||||
@@ -215,7 +215,7 @@ impl PolkadotProtocol {
|
||||
/// Fetch block data by candidate receipt.
|
||||
fn fetch_pov_block(
|
||||
&mut self,
|
||||
ctx: &mut Context<Block>,
|
||||
ctx: &mut dyn Context<Block>,
|
||||
candidate: &CandidateReceipt,
|
||||
relay_parent: Hash,
|
||||
canon_roots: StructuredUnroutedIngress,
|
||||
@@ -238,7 +238,7 @@ impl PolkadotProtocol {
|
||||
/// Note new validation session.
|
||||
fn new_validation_session(
|
||||
&mut self,
|
||||
ctx: &mut Context<Block>,
|
||||
ctx: &mut dyn Context<Block>,
|
||||
params: validation::SessionParams,
|
||||
) -> validation::ValidationSession {
|
||||
|
||||
@@ -265,7 +265,7 @@ impl PolkadotProtocol {
|
||||
self.live_validation_sessions.remove(parent_hash)
|
||||
}
|
||||
|
||||
fn dispatch_pending_requests(&mut self, ctx: &mut Context<Block>) {
|
||||
fn dispatch_pending_requests(&mut self, ctx: &mut dyn Context<Block>) {
|
||||
let mut new_pending = Vec::new();
|
||||
let validator_keys = &mut self.validators;
|
||||
let next_req_id = &mut self.next_req_id;
|
||||
@@ -316,7 +316,7 @@ impl PolkadotProtocol {
|
||||
self.pending = new_pending;
|
||||
}
|
||||
|
||||
fn on_polkadot_message(&mut self, ctx: &mut Context<Block>, who: PeerId, msg: Message) {
|
||||
fn on_polkadot_message(&mut self, ctx: &mut dyn Context<Block>, who: PeerId, msg: Message) {
|
||||
trace!(target: "p_net", "Polkadot message from {}: {:?}", who, msg);
|
||||
match msg {
|
||||
Message::SessionKey(key) => self.on_session_key(ctx, who, key),
|
||||
@@ -352,7 +352,7 @@ impl PolkadotProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
fn on_session_key(&mut self, ctx: &mut Context<Block>, who: PeerId, key: SessionKey) {
|
||||
fn on_session_key(&mut self, ctx: &mut dyn Context<Block>, who: PeerId, key: SessionKey) {
|
||||
{
|
||||
let info = match self.peers.get_mut(&who) {
|
||||
Some(peer) => peer,
|
||||
@@ -396,7 +396,7 @@ impl PolkadotProtocol {
|
||||
|
||||
fn on_pov_block(
|
||||
&mut self,
|
||||
ctx: &mut Context<Block>,
|
||||
ctx: &mut dyn Context<Block>,
|
||||
who: PeerId,
|
||||
req_id: RequestId,
|
||||
pov_block: Option<PoVBlock>,
|
||||
@@ -429,7 +429,7 @@ impl PolkadotProtocol {
|
||||
}
|
||||
|
||||
// when a validator sends us (a collator) a new role.
|
||||
fn on_new_role(&mut self, ctx: &mut Context<Block>, who: PeerId, role: Role) {
|
||||
fn on_new_role(&mut self, ctx: &mut dyn Context<Block>, who: PeerId, role: Role) {
|
||||
let info = match self.peers.get_mut(&who) {
|
||||
Some(peer) => peer,
|
||||
None => {
|
||||
@@ -467,7 +467,7 @@ impl Specialization<Block> for PolkadotProtocol {
|
||||
Status { collating_for: self.collating_for.clone() }.encode()
|
||||
}
|
||||
|
||||
fn on_connect(&mut self, ctx: &mut Context<Block>, who: PeerId, status: FullStatus) {
|
||||
fn on_connect(&mut self, ctx: &mut dyn Context<Block>, who: PeerId, status: FullStatus) {
|
||||
let local_status = match Status::decode(&mut &status.chain_status[..]) {
|
||||
Some(status) => status,
|
||||
None => {
|
||||
@@ -515,7 +515,7 @@ impl Specialization<Block> for PolkadotProtocol {
|
||||
self.dispatch_pending_requests(ctx);
|
||||
}
|
||||
|
||||
fn on_disconnect(&mut self, ctx: &mut Context<Block>, who: PeerId) {
|
||||
fn on_disconnect(&mut self, ctx: &mut dyn Context<Block>, who: PeerId) {
|
||||
if let Some(info) = self.peers.remove(&who) {
|
||||
if let Some((acc_id, _)) = info.collating_for {
|
||||
let new_primary = self.collators.on_disconnect(acc_id)
|
||||
@@ -559,7 +559,12 @@ impl Specialization<Block> for PolkadotProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
fn on_message(&mut self, ctx: &mut Context<Block>, who: PeerId, message: &mut Option<message::Message<Block>>) {
|
||||
fn on_message(
|
||||
&mut self,
|
||||
ctx: &mut dyn Context<Block>,
|
||||
who: PeerId,
|
||||
message: &mut Option<message::Message<Block>>
|
||||
) {
|
||||
match message.take() {
|
||||
Some(generic_message::Message::ChainSpecific(raw)) => {
|
||||
match Message::decode(&mut raw.as_slice()) {
|
||||
@@ -581,7 +586,7 @@ impl Specialization<Block> for PolkadotProtocol {
|
||||
|
||||
fn on_abort(&mut self) { }
|
||||
|
||||
fn maintain_peers(&mut self, ctx: &mut Context<Block>) {
|
||||
fn maintain_peers(&mut self, ctx: &mut dyn Context<Block>) {
|
||||
self.collators.collect_garbage(None);
|
||||
self.local_collations.collect_garbage(None);
|
||||
self.dispatch_pending_requests(ctx);
|
||||
@@ -600,7 +605,7 @@ impl Specialization<Block> for PolkadotProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
fn on_block_imported(&mut self, _ctx: &mut Context<Block>, hash: Hash, header: &Header) {
|
||||
fn on_block_imported(&mut self, _ctx: &mut dyn Context<Block>, hash: Hash, header: &Header) {
|
||||
self.collators.collect_garbage(Some(&hash));
|
||||
self.local_collations.collect_garbage(Some(&header.parent_hash));
|
||||
}
|
||||
@@ -608,7 +613,13 @@ impl Specialization<Block> for PolkadotProtocol {
|
||||
|
||||
impl PolkadotProtocol {
|
||||
// we received a collation from a peer
|
||||
fn on_collation(&mut self, ctx: &mut Context<Block>, from: PeerId, relay_parent: Hash, collation: Collation) {
|
||||
fn on_collation(
|
||||
&mut self,
|
||||
ctx: &mut dyn Context<Block>,
|
||||
from: PeerId,
|
||||
relay_parent: Hash,
|
||||
collation: Collation
|
||||
) {
|
||||
let collation_para = collation.receipt.parachain_index;
|
||||
let collated_acc = collation.receipt.collator.clone();
|
||||
|
||||
@@ -656,7 +667,7 @@ impl PolkadotProtocol {
|
||||
}
|
||||
|
||||
// disconnect a collator by account-id.
|
||||
fn disconnect_bad_collator(&mut self, ctx: &mut Context<Block>, collator_id: CollatorId) {
|
||||
fn disconnect_bad_collator(&mut self, ctx: &mut dyn Context<Block>, collator_id: CollatorId) {
|
||||
if let Some((who, _)) = self.collator_peer(collator_id) {
|
||||
ctx.report_peer(who, cost::BAD_COLLATION)
|
||||
}
|
||||
@@ -667,7 +678,7 @@ impl PolkadotProtocol {
|
||||
/// Add a local collation and broadcast it to the necessary peers.
|
||||
pub fn add_local_collation(
|
||||
&mut self,
|
||||
ctx: &mut Context<Block>,
|
||||
ctx: &mut dyn Context<Block>,
|
||||
relay_parent: Hash,
|
||||
targets: HashSet<SessionKey>,
|
||||
collation: Collation,
|
||||
|
||||
@@ -154,13 +154,13 @@ impl NetworkService for TestNetwork {
|
||||
}
|
||||
|
||||
fn with_gossip<F: Send + 'static>(&self, with: F)
|
||||
where F: FnOnce(&mut GossipService, &mut NetContext<Block>)
|
||||
where F: FnOnce(&mut dyn GossipService, &mut dyn NetContext<Block>)
|
||||
{
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn with_spec<F: Send + 'static>(&self, with: F)
|
||||
where F: FnOnce(&mut PolkadotProtocol, &mut NetContext<Block>)
|
||||
where F: FnOnce(&mut PolkadotProtocol, &mut dyn NetContext<Block>)
|
||||
{
|
||||
let mut context = TestContext::default();
|
||||
let res = with(&mut *self.proto.lock(), &mut context);
|
||||
|
||||
@@ -78,11 +78,11 @@ impl Executor for TaskExecutor {
|
||||
|
||||
/// A gossip network subservice.
|
||||
pub trait GossipService {
|
||||
fn send_message(&mut self, ctx: &mut NetContext<Block>, who: &PeerId, message: ConsensusMessage);
|
||||
fn send_message(&mut self, ctx: &mut dyn NetContext<Block>, who: &PeerId, message: ConsensusMessage);
|
||||
}
|
||||
|
||||
impl GossipService for consensus_gossip::ConsensusGossip<Block> {
|
||||
fn send_message(&mut self, ctx: &mut NetContext<Block>, who: &PeerId, message: ConsensusMessage) {
|
||||
fn send_message(&mut self, ctx: &mut dyn NetContext<Block>, who: &PeerId, message: ConsensusMessage) {
|
||||
consensus_gossip::ConsensusGossip::send_message(self, ctx, who, message)
|
||||
}
|
||||
}
|
||||
@@ -135,7 +135,7 @@ impl NetworkService for super::NetworkService {
|
||||
}
|
||||
|
||||
fn with_spec<F: Send + 'static>(&self, with: F)
|
||||
where F: FnOnce(&mut PolkadotProtocol, &mut NetContext<Block>)
|
||||
where F: FnOnce(&mut PolkadotProtocol, &mut dyn NetContext<Block>)
|
||||
{
|
||||
super::NetworkService::with_spec(self, with)
|
||||
}
|
||||
@@ -260,7 +260,7 @@ impl<P, E, N, T> ParachainNetwork for ValidationNetwork<P, E, N, T> where
|
||||
{
|
||||
type Error = String;
|
||||
type TableRouter = Router<P, E, N, T>;
|
||||
type BuildTableRouter = Box<Future<Item=Self::TableRouter,Error=String> + Send>;
|
||||
type BuildTableRouter = Box<dyn Future<Item=Self::TableRouter, Error=String> + Send>;
|
||||
|
||||
fn communication_for(
|
||||
&self,
|
||||
|
||||
@@ -77,8 +77,11 @@ pub type SessionKey = ed25519::Public;
|
||||
/// that 32 bits may be multiplied with a balance in 128 bits without worrying about overflow.
|
||||
pub type Balance = u128;
|
||||
|
||||
/// The Ed25519 pub key of an session that belongs to an Aura authority of the chain.
|
||||
pub type AuraId = ed25519::Public;
|
||||
|
||||
/// Header type.
|
||||
pub type Header = generic::Header<BlockNumber, BlakeTwo256, generic::DigestItem<Hash, SessionKey, SessionSignature>>;
|
||||
pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
|
||||
/// Block type.
|
||||
pub type Block = generic::Block<Header, UncheckedExtrinsic>;
|
||||
/// Block ID.
|
||||
|
||||
@@ -24,7 +24,6 @@ consensus_aura = { package = "substrate-consensus-aura-primitives", git = "https
|
||||
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" }
|
||||
balances = { package = "srml-balances", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
consensus = { package = "srml-consensus", 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" }
|
||||
@@ -38,7 +37,6 @@ system = { package = "srml-system", git = "https://github.com/paritytech/substra
|
||||
timestamp = { package = "srml-timestamp", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
treasury = { package = "srml-treasury", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
version = { package = "sr-version", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
consensus_authorities = { package = "substrate-consensus-authorities", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
|
||||
|
||||
[dev-dependencies]
|
||||
hex-literal = "0.2.0"
|
||||
@@ -63,7 +61,6 @@ std = [
|
||||
"sr-io/std",
|
||||
"srml-support/std",
|
||||
"balances/std",
|
||||
"consensus/std",
|
||||
"council/std",
|
||||
"democracy/std",
|
||||
"executive/std",
|
||||
@@ -81,7 +78,6 @@ std = [
|
||||
"serde/std",
|
||||
"log",
|
||||
"safe-mix/std",
|
||||
"consensus_authorities/std",
|
||||
"consensus_aura/std",
|
||||
"aura/std",
|
||||
]
|
||||
|
||||
@@ -193,7 +193,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::{Digest, DigestItem, Header}
|
||||
BuildStorage, traits::{BlakeTwo256, IdentityLookup}, testing::Header
|
||||
};
|
||||
use balances;
|
||||
use srml_support::{impl_outer_origin, assert_ok, assert_err, assert_noop};
|
||||
@@ -213,12 +213,10 @@ mod tests {
|
||||
type BlockNumber = u64;
|
||||
type Hash = H256;
|
||||
type Hashing = BlakeTwo256;
|
||||
type Digest = Digest;
|
||||
type AccountId = u64;
|
||||
type Lookup = IdentityLookup<u64>;
|
||||
type Header = Header;
|
||||
type Event = ();
|
||||
type Log = DigestItem;
|
||||
}
|
||||
impl balances::Trait for Test {
|
||||
type Balance = u64;
|
||||
|
||||
@@ -37,7 +37,7 @@ decl_module! {
|
||||
/// curated GRANDPA set.
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||
/// Changes the GRANDPA voter set.
|
||||
fn set_voters(origin, voters: Vec<(T::SessionKey, u64)>) {
|
||||
fn set_voters(origin, voters: Vec<(grandpa::AuthorityId, u64)>) {
|
||||
system::ensure_root(origin)?;
|
||||
grandpa::Module::<T>::schedule_change(voters, T::BlockNumber::zero(), None)?;
|
||||
}
|
||||
|
||||
+60
-56
@@ -27,10 +27,10 @@ mod slot_range;
|
||||
mod slots;
|
||||
|
||||
use rstd::prelude::*;
|
||||
use substrate_primitives::u32_trait::{_2, _4};
|
||||
use substrate_primitives::u32_trait::{_1, _2, _3, _4};
|
||||
use primitives::{
|
||||
AccountId, AccountIndex, Balance, BlockNumber, Hash, Nonce, SessionKey, Signature,
|
||||
parachain, SessionSignature,
|
||||
parachain, AuraId
|
||||
};
|
||||
use client::{
|
||||
block_builder::api::{self as block_builder_api, InherentData, CheckInherentsResult},
|
||||
@@ -38,13 +38,11 @@ use client::{
|
||||
};
|
||||
use sr_primitives::{
|
||||
ApplyResult, generic, transaction_validity::TransactionValidity, create_runtime_str,
|
||||
traits::{
|
||||
BlakeTwo256, Block as BlockT, DigestFor, StaticLookup, Convert, AuthorityIdFor
|
||||
}
|
||||
traits::{BlakeTwo256, Block as BlockT, DigestFor, StaticLookup, Convert}, impl_opaque_keys
|
||||
};
|
||||
use version::RuntimeVersion;
|
||||
use grandpa::fg_primitives::{self, ScheduledChange};
|
||||
use council::{motions as council_motions, voting as council_voting};
|
||||
use council::motions as council_motions;
|
||||
#[cfg(feature = "std")]
|
||||
use council::seats as council_seats;
|
||||
#[cfg(any(feature = "std", test))]
|
||||
@@ -56,7 +54,6 @@ use srml_support::{parameter_types, construct_runtime};
|
||||
pub use staking::StakerStatus;
|
||||
#[cfg(any(feature = "std", test))]
|
||||
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, INHERENT_IDENTIFIER as PARACHAIN_INHERENT_IDENTIFIER};
|
||||
@@ -89,16 +86,15 @@ impl system::Trait for Runtime {
|
||||
type BlockNumber = BlockNumber;
|
||||
type Hash = Hash;
|
||||
type Hashing = BlakeTwo256;
|
||||
type Digest = generic::Digest<Log>;
|
||||
type AccountId = AccountId;
|
||||
type Lookup = Indices;
|
||||
type Header = generic::Header<BlockNumber, BlakeTwo256, Log>;
|
||||
type Header = generic::Header<BlockNumber, BlakeTwo256>;
|
||||
type Event = Event;
|
||||
type Log = Log;
|
||||
}
|
||||
|
||||
impl aura::Trait for Runtime {
|
||||
type HandleReport = aura::StakingSlasher<Runtime>;
|
||||
type AuthorityId = AuraId;
|
||||
}
|
||||
|
||||
impl indices::Trait for Runtime {
|
||||
@@ -118,24 +114,33 @@ impl balances::Trait for Runtime {
|
||||
type TransferPayment = ();
|
||||
}
|
||||
|
||||
impl consensus::Trait for Runtime {
|
||||
type Log = Log;
|
||||
type SessionKey = SessionKey;
|
||||
|
||||
// the aura module handles offline-reports internally
|
||||
// rather than using an explicit report system.
|
||||
type InherentOfflineReport = ();
|
||||
}
|
||||
|
||||
impl timestamp::Trait for Runtime {
|
||||
type Moment = u64;
|
||||
type OnTimestampSet = Aura;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const Period: BlockNumber = 10 * MINUTES;
|
||||
pub const Offset: BlockNumber = 0;
|
||||
}
|
||||
|
||||
type SessionHandlers = (Grandpa, Aura);
|
||||
impl_opaque_keys! {
|
||||
pub struct SessionKeys(grandpa::AuthorityId, AuraId);
|
||||
}
|
||||
|
||||
// NOTE: `SessionHandler` and `SessionKeys` are co-dependent: One key will be used for each handler.
|
||||
// The number and order of items in `SessionHandler` *MUST* be the same number and order of keys in
|
||||
// `SessionKeys`.
|
||||
// TODO: Introduce some structure to tie these together to make it a bit less of a footgun. This
|
||||
// should be easy, since OneSessionHandler trait provides the `Key` as an associated type. #2858
|
||||
|
||||
impl session::Trait for Runtime {
|
||||
type ConvertAccountIdToSessionKey = ();
|
||||
type OnSessionChange = Staking;
|
||||
type OnSessionEnding = Staking;
|
||||
type SessionHandler = SessionHandlers;
|
||||
type ShouldEndSession = session::PeriodicSessions<Period, Offset>;
|
||||
type Event = Event;
|
||||
type Keys = SessionKeys;
|
||||
}
|
||||
|
||||
/// Converter for currencies to votes.
|
||||
@@ -153,14 +158,20 @@ impl Convert<u128, u128> for CurrencyToVoteHandler {
|
||||
fn convert(x: u128) -> u128 { x * Self::factor() }
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const SessionsPerEra: session::SessionIndex = 6;
|
||||
pub const BondingDuration: staking::EraIndex = 24 * 28;
|
||||
}
|
||||
|
||||
impl staking::Trait for Runtime {
|
||||
type OnRewardMinted = Treasury;
|
||||
type CurrencyToVote = CurrencyToVoteHandler;
|
||||
type Event = Event;
|
||||
type Currency = balances::Module<Self>;
|
||||
type Currency = Balances;
|
||||
type Slash = ();
|
||||
type Reward = ();
|
||||
type SessionsPerEra = SessionsPerEra;
|
||||
type BondingDuration = BondingDuration;
|
||||
}
|
||||
|
||||
const MINUTES: BlockNumber = 6;
|
||||
@@ -169,28 +180,36 @@ 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;
|
||||
pub const EmergencyVotingPeriod: BlockNumber = 3 * 24 * 60 * MINUTES;
|
||||
pub const MinimumDeposit: Balance = 100 * BUCKS;
|
||||
pub const EnactmentPeriod: BlockNumber = 30 * 24 * 60 * MINUTES;
|
||||
pub const CooloffPeriod: BlockNumber = 30 * 24 * 60 * MINUTES;
|
||||
}
|
||||
|
||||
impl democracy::Trait for Runtime {
|
||||
type Currency = balances::Module<Self>;
|
||||
type Proposal = Call;
|
||||
type Event = Event;
|
||||
type Currency = Balances;
|
||||
type EnactmentPeriod = EnactmentPeriod;
|
||||
type LaunchPeriod = LaunchPeriod;
|
||||
type VotingPeriod = VotingPeriod;
|
||||
type EmergencyVotingPeriod = EmergencyVotingPeriod;
|
||||
type MinimumDeposit = MinimumDeposit;
|
||||
type ExternalOrigin = council_motions::EnsureProportionAtLeast<_1, _2, AccountId>;
|
||||
type ExternalMajorityOrigin = council_motions::EnsureProportionAtLeast<_2, _3, AccountId>;
|
||||
type EmergencyOrigin = council_motions::EnsureProportionAtLeast<_1, _1, AccountId>;
|
||||
type CancellationOrigin = council_motions::EnsureProportionAtLeast<_2, _3, AccountId>;
|
||||
type VetoOrigin = council_motions::EnsureMember<AccountId>;
|
||||
type CooloffPeriod = CooloffPeriod;
|
||||
}
|
||||
|
||||
impl council::Trait for Runtime {
|
||||
type Event = Event;
|
||||
type BadPresentation = ();
|
||||
type BadReaper = ();
|
||||
}
|
||||
|
||||
impl council::voting::Trait for Runtime {
|
||||
type Event = Event;
|
||||
type BadVoterIndex = ();
|
||||
type LoserCandidate = ();
|
||||
type OnMembersChanged = CouncilMotions;
|
||||
}
|
||||
|
||||
impl council::motions::Trait for Runtime {
|
||||
@@ -201,16 +220,14 @@ impl council::motions::Trait for Runtime {
|
||||
|
||||
impl treasury::Trait for Runtime {
|
||||
type Currency = balances::Module<Self>;
|
||||
type ApproveOrigin = council_motions::EnsureMembers<_4>;
|
||||
type RejectOrigin = council_motions::EnsureMembers<_2>;
|
||||
type ApproveOrigin = council_motions::EnsureMembers<_4, AccountId>;
|
||||
type RejectOrigin = council_motions::EnsureMembers<_2, AccountId>;
|
||||
type Event = Event;
|
||||
type MintedForSpending = ();
|
||||
type ProposalRejection = ();
|
||||
}
|
||||
|
||||
impl grandpa::Trait for Runtime {
|
||||
type SessionKey = SessionKey;
|
||||
type Log = Log;
|
||||
type Event = Event;
|
||||
}
|
||||
|
||||
@@ -240,26 +257,23 @@ impl sudo::Trait for Runtime {
|
||||
}
|
||||
|
||||
construct_runtime!(
|
||||
pub enum Runtime with Log(InternalLog: DigestItem<Hash, SessionKey, SessionSignature>) where
|
||||
pub enum Runtime where
|
||||
Block = Block,
|
||||
NodeBlock = primitives::Block,
|
||||
UncheckedExtrinsic = UncheckedExtrinsic
|
||||
{
|
||||
System: system::{default, Log(ChangesTrieRoot)},
|
||||
Aura: aura::{Module},
|
||||
System: system,
|
||||
Aura: aura::{Module, Config<T>, Inherent(Timestamp)},
|
||||
Timestamp: timestamp::{Module, Call, Storage, Config<T>, Inherent},
|
||||
// consensus' Inherent is not provided because it assumes instant-finality blocks.
|
||||
Consensus: consensus::{Module, Call, Storage, Config<T>, Log(AuthoritiesChange) },
|
||||
Indices: indices,
|
||||
Balances: balances,
|
||||
Session: session,
|
||||
Session: session::{Module, Call, Storage, Event, Config<T>},
|
||||
Staking: staking,
|
||||
Democracy: democracy,
|
||||
Grandpa: grandpa::{Module, Call, Storage, Config<T>, Log(), Event<T>},
|
||||
Grandpa: grandpa::{Module, Call, Storage, Config<T>, Event},
|
||||
CuratedGrandpa: curated_grandpa::{Module, Call, Config<T>, Storage},
|
||||
Council: council::{Module, Call, Storage, Event<T>},
|
||||
CouncilVoting: council_voting,
|
||||
CouncilMotions: council_motions::{Module, Call, Storage, Event<T>, Origin},
|
||||
CouncilMotions: council_motions::{Module, Call, Storage, Event<T>, Origin<T>},
|
||||
CouncilSeats: council_seats::{Config<T>},
|
||||
Treasury: treasury,
|
||||
Parachains: parachains::{Module, Call, Storage, Config<T>, Inherent, Origin},
|
||||
@@ -271,7 +285,7 @@ construct_runtime!(
|
||||
/// The address format for describing accounts.
|
||||
pub type Address = <Indices as StaticLookup>::Source;
|
||||
/// Block header type as expected by this runtime.
|
||||
pub type Header = generic::Header<BlockNumber, BlakeTwo256, Log>;
|
||||
pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
|
||||
/// Block type as expected by this runtime.
|
||||
pub type Block = generic::Block<Header, UncheckedExtrinsic>;
|
||||
/// A Block signed with a Justification
|
||||
@@ -342,7 +356,7 @@ impl_runtime_apis! {
|
||||
|
||||
impl parachain::ParachainHost<Block> for Runtime {
|
||||
fn validators() -> Vec<parachain::ValidatorId> {
|
||||
Consensus::authorities() // only possible as long as parachain validator crypto === aura crypto
|
||||
Aura::authorities() // only possible as long as parachain validator crypto === aura crypto
|
||||
}
|
||||
fn duty_roster() -> parachain::DutyRoster {
|
||||
Parachains::calculate_duty_roster()
|
||||
@@ -365,15 +379,7 @@ impl_runtime_apis! {
|
||||
fn grandpa_pending_change(digest: &DigestFor<Block>)
|
||||
-> Option<ScheduledChange<BlockNumber>>
|
||||
{
|
||||
for log in digest.logs.iter().filter_map(|l| match l {
|
||||
Log(InternalLog::grandpa(grandpa_signal)) => Some(grandpa_signal),
|
||||
_=> None
|
||||
}) {
|
||||
if let Some(change) = Grandpa::scrape_digest_change(log) {
|
||||
return Some(change);
|
||||
}
|
||||
}
|
||||
None
|
||||
Grandpa::pending_change(digest)
|
||||
}
|
||||
|
||||
fn grandpa_forced_change(_digest: &DigestFor<Block>)
|
||||
@@ -387,15 +393,13 @@ impl_runtime_apis! {
|
||||
}
|
||||
}
|
||||
|
||||
impl consensus_aura::AuraApi<Block> for Runtime {
|
||||
impl consensus_aura::AuraApi<Block, AuraId> for Runtime {
|
||||
fn slot_duration() -> u64 {
|
||||
Aura::slot_duration()
|
||||
}
|
||||
}
|
||||
|
||||
impl consensus_authorities::AuthoritiesApi<Block> for Runtime {
|
||||
fn authorities() -> Vec<AuthorityIdFor<Block>> {
|
||||
Consensus::authorities()
|
||||
fn authorities() -> Vec<AuraId> {
|
||||
Aura::authorities()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -475,7 +475,7 @@ impl<T: Trait> Module<T> {
|
||||
pub fn calculate_duty_roster() -> DutyRoster {
|
||||
let parachains = Self::active_parachains();
|
||||
let parachain_count = parachains.len();
|
||||
let validator_count = <consensus::Module<T>>::authorities().len();
|
||||
let validator_count = crate::Aura::authorities().len();
|
||||
let validators_per_parachain = if parachain_count != 0 { (validator_count - 1) / parachain_count } else { 0 };
|
||||
|
||||
let mut roles_val = (0..validator_count).map(|i| match i {
|
||||
@@ -628,7 +628,7 @@ impl<T: Trait> Module<T> {
|
||||
}
|
||||
}
|
||||
|
||||
let authorities = super::Consensus::authorities();
|
||||
let authorities = super::Aura::authorities();
|
||||
let duty_roster = Self::calculate_duty_roster();
|
||||
|
||||
// convert a duty roster, which is originally a Vec<Chain>, where each
|
||||
@@ -761,14 +761,17 @@ mod tests {
|
||||
use sr_io::{TestExternalities, with_externalities};
|
||||
use substrate_primitives::{H256, Blake2Hasher};
|
||||
use substrate_trie::NodeCodec;
|
||||
use sr_primitives::{generic, BuildStorage};
|
||||
use sr_primitives::traits::{BlakeTwo256, IdentityLookup};
|
||||
use sr_primitives::{
|
||||
BuildStorage, traits::{BlakeTwo256, IdentityLookup}, testing::UintAuthorityId,
|
||||
};
|
||||
use primitives::{
|
||||
parachain::{CandidateReceipt, HeadData, ValidityAttestation, ValidatorIndex}, SessionKey
|
||||
parachain::{CandidateReceipt, HeadData, ValidityAttestation, ValidatorIndex}, SessionKey,
|
||||
BlockNumber, AuraId
|
||||
};
|
||||
use keyring::{AuthorityKeyring, AccountKeyring};
|
||||
use srml_support::{impl_outer_origin, impl_outer_dispatch, assert_ok, assert_err};
|
||||
use {consensus, timestamp};
|
||||
use srml_support::{
|
||||
impl_outer_origin, impl_outer_dispatch, assert_ok, assert_err, parameter_types,
|
||||
};
|
||||
use crate::parachains;
|
||||
|
||||
impl_outer_origin! {
|
||||
@@ -785,33 +788,67 @@ mod tests {
|
||||
|
||||
#[derive(Clone, Eq, PartialEq)]
|
||||
pub struct Test;
|
||||
impl consensus::Trait for Test {
|
||||
type InherentOfflineReport = ();
|
||||
type SessionKey = SessionKey;
|
||||
type Log = crate::Log;
|
||||
}
|
||||
impl system::Trait for Test {
|
||||
type Origin = Origin;
|
||||
type Index = crate::Nonce;
|
||||
type BlockNumber = u64;
|
||||
type Hash = H256;
|
||||
type Hashing = BlakeTwo256;
|
||||
type Digest = generic::Digest<crate::Log>;
|
||||
type AccountId = crate::AccountId;
|
||||
type Lookup = IdentityLookup<crate::AccountId>;
|
||||
type Header = crate::Header;
|
||||
type Event = ();
|
||||
type Log = crate::Log;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const Period: BlockNumber = 1;
|
||||
pub const Offset: BlockNumber = 0;
|
||||
}
|
||||
|
||||
impl session::Trait for Test {
|
||||
type ConvertAccountIdToSessionKey = ();
|
||||
type OnSessionChange = ();
|
||||
type OnSessionEnding = ();
|
||||
type Keys = UintAuthorityId;
|
||||
type ShouldEndSession = session::PeriodicSessions<Period, Offset>;
|
||||
type SessionHandler = ();
|
||||
type Event = ();
|
||||
}
|
||||
|
||||
impl timestamp::Trait for Test {
|
||||
type Moment = u64;
|
||||
type OnTimestampSet = ();
|
||||
}
|
||||
|
||||
impl aura::Trait for Test {
|
||||
type HandleReport = aura::StakingSlasher<Test>;
|
||||
type AuthorityId = AuraId;
|
||||
}
|
||||
|
||||
impl balances::Trait for Test {
|
||||
type Balance = u64;
|
||||
type OnFreeBalanceZero = ();
|
||||
type OnNewAccount = ();
|
||||
type Event = ();
|
||||
type TransactionPayment = ();
|
||||
type DustRemoval = ();
|
||||
type TransferPayment = ();
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const SessionsPerEra: session::SessionIndex = 6;
|
||||
pub const BondingDuration: staking::EraIndex = 24 * 28;
|
||||
}
|
||||
|
||||
impl staking::Trait for Test {
|
||||
type OnRewardMinted = ();
|
||||
type CurrencyToVote = ();
|
||||
type Event = ();
|
||||
type Currency = balances::Module<Test>;
|
||||
type Slash = ();
|
||||
type Reward = ();
|
||||
type SessionsPerEra = SessionsPerEra;
|
||||
type BondingDuration = BondingDuration;
|
||||
}
|
||||
|
||||
impl Trait for Test {
|
||||
type Origin = Origin;
|
||||
type Call = Call;
|
||||
@@ -843,12 +880,7 @@ mod tests {
|
||||
AccountKeyring::Two,
|
||||
];
|
||||
|
||||
t.extend(consensus::GenesisConfig::<Test>{
|
||||
code: vec![],
|
||||
authorities: authority_keys.iter().map(|k| SessionKey::from(*k)).collect(),
|
||||
}.build_storage().unwrap().0);
|
||||
t.extend(session::GenesisConfig::<Test>{
|
||||
session_length: 1000,
|
||||
validators: validator_keys.iter().map(|k| crate::AccountId::from(*k)).collect(),
|
||||
keys: vec![],
|
||||
}.build_storage().unwrap().0);
|
||||
@@ -856,6 +888,9 @@ mod tests {
|
||||
parachains,
|
||||
_phdata: Default::default(),
|
||||
}.build_storage().unwrap().0);
|
||||
t.extend(aura::GenesisConfig::<Test>{
|
||||
authorities: authority_keys.iter().map(|k| SessionKey::from(*k)).collect(),
|
||||
}.build_storage().unwrap().0);
|
||||
t.into()
|
||||
}
|
||||
|
||||
@@ -870,7 +905,7 @@ mod tests {
|
||||
let duty_roster = Parachains::calculate_duty_roster();
|
||||
let candidate_hash = candidate.candidate.hash();
|
||||
|
||||
let authorities = crate::Consensus::authorities();
|
||||
let authorities = crate::Aura::authorities();
|
||||
let extract_key = |public: SessionKey| {
|
||||
AuthorityKeyring::from_raw_public(public.0).unwrap()
|
||||
};
|
||||
|
||||
@@ -112,7 +112,7 @@ type WinningData<T> = [Option<(Bidder<<T as system::Trait>::AccountId, ParaIdOf<
|
||||
// index assigned to them, their winning bid and the range that they won.
|
||||
type WinnersData<T> = Vec<(Option<NewBidder<<T as system::Trait>::AccountId>>, ParaIdOf<T>, BalanceOf<T>, SlotRange)>;
|
||||
|
||||
/// This module's storage items.
|
||||
// This module's storage items.
|
||||
decl_storage! {
|
||||
trait Store for Module<T: Trait> as Slots {
|
||||
|
||||
@@ -781,9 +781,8 @@ mod tests {
|
||||
use substrate_primitives::{Blake2Hasher, H256};
|
||||
use sr_io::with_externalities;
|
||||
use sr_primitives::{
|
||||
BuildStorage,
|
||||
BuildStorage, testing::Header,
|
||||
traits::{BlakeTwo256, Hash, IdentityLookup, OnInitialize, OnFinalize},
|
||||
testing::{Digest, DigestItem, Header}
|
||||
};
|
||||
use srml_support::{impl_outer_origin, parameter_types, assert_ok, assert_noop};
|
||||
use balances;
|
||||
@@ -804,12 +803,10 @@ mod tests {
|
||||
type BlockNumber = u64;
|
||||
type Hash = H256;
|
||||
type Hashing = BlakeTwo256;
|
||||
type Digest = Digest;
|
||||
type AccountId = u64;
|
||||
type Lookup = IdentityLookup<Self::AccountId>;
|
||||
type Header = Header;
|
||||
type Event = ();
|
||||
type Log = DigestItem;
|
||||
}
|
||||
|
||||
impl balances::Trait for Test {
|
||||
|
||||
Generated
+383
-502
File diff suppressed because it is too large
Load Diff
@@ -19,10 +19,9 @@
|
||||
use primitives::{ed25519, sr25519, Pair, crypto::UncheckedInto};
|
||||
use polkadot_primitives::{AccountId, SessionKey};
|
||||
use polkadot_runtime::{
|
||||
GenesisConfig, ConsensusConfig, CouncilSeatsConfig, DemocracyConfig, TreasuryConfig,
|
||||
SessionConfig, StakingConfig, TimestampConfig, BalancesConfig, Perbill,
|
||||
CouncilVotingConfig, GrandpaConfig, SudoConfig, IndicesConfig, Permill,
|
||||
CuratedGrandpaConfig, StakerStatus,
|
||||
GenesisConfig, CouncilSeatsConfig, DemocracyConfig, TreasuryConfig, SystemConfig, AuraConfig,
|
||||
SessionConfig, StakingConfig, TimestampConfig, BalancesConfig, Perbill, SessionKeys,
|
||||
GrandpaConfig, SudoConfig, IndicesConfig, Permill, CuratedGrandpaConfig, StakerStatus,
|
||||
};
|
||||
use telemetry::TelemetryEndpoints;
|
||||
use hex_literal::hex;
|
||||
@@ -76,12 +75,12 @@ fn staging_testnet_config_genesis() -> GenesisConfig {
|
||||
const STASH: u128 = 100 * DOLLARS;
|
||||
|
||||
GenesisConfig {
|
||||
consensus: Some(ConsensusConfig {
|
||||
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(),
|
||||
authorities: initial_authorities.iter().map(|x| x.2.clone()).collect(),
|
||||
_genesis_phantom_data: Default::default(),
|
||||
changes_trie_config: Default::default(),
|
||||
}),
|
||||
system: None,
|
||||
balances: Some(BalancesConfig {
|
||||
transaction_base_fee: 1 * CENTS,
|
||||
transaction_byte_fee: 10 * MILLICENTS,
|
||||
@@ -101,8 +100,10 @@ fn staging_testnet_config_genesis() -> GenesisConfig {
|
||||
}),
|
||||
session: Some(SessionConfig {
|
||||
validators: initial_authorities.iter().map(|x| x.1.clone()).collect(),
|
||||
session_length: 5 * MINUTES,
|
||||
keys: initial_authorities.iter().map(|x| (x.1.clone(), x.2.clone())).collect::<Vec<_>>(),
|
||||
keys: initial_authorities.iter().map(|x| (
|
||||
x.1.clone(),
|
||||
SessionKeys(x.2.clone(), x.2.clone()),
|
||||
)).collect::<Vec<_>>(),
|
||||
}),
|
||||
staking: Some(StakingConfig {
|
||||
current_era: 0,
|
||||
@@ -110,8 +111,6 @@ fn staging_testnet_config_genesis() -> GenesisConfig {
|
||||
session_reward: Perbill::from_parts(2_065),
|
||||
current_session_reward: 0,
|
||||
validator_count: 7,
|
||||
sessions_per_era: 12,
|
||||
bonding_duration: 12,
|
||||
offline_slash_grace: 4,
|
||||
minimum_validator_count: 4,
|
||||
stakers: initial_authorities.iter().map(|x| (x.0.clone(), x.1.clone(), STASH, StakerStatus::Validator)).collect(),
|
||||
@@ -122,19 +121,16 @@ fn staging_testnet_config_genesis() -> GenesisConfig {
|
||||
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.
|
||||
}),
|
||||
council_voting: Some(CouncilVotingConfig {
|
||||
cooloff_period: 4 * DAYS,
|
||||
voting_period: 1 * DAYS,
|
||||
enact_delay_period: 0,
|
||||
}),
|
||||
timestamp: Some(TimestampConfig {
|
||||
minimum_period: SECS_PER_BLOCK / 2, // due to the nature of aura the slots are 2*period
|
||||
}),
|
||||
@@ -149,6 +145,10 @@ fn staging_testnet_config_genesis() -> GenesisConfig {
|
||||
}),
|
||||
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(),
|
||||
}),
|
||||
parachains: Some(Default::default()),
|
||||
curated_grandpa: Some(CuratedGrandpaConfig {
|
||||
@@ -220,12 +220,15 @@ pub fn testnet_genesis(
|
||||
|
||||
const STASH: u128 = 1 << 20;
|
||||
const ENDOWMENT: u128 = 1 << 20;
|
||||
let council_desired_seats = (endowed_accounts.len() / 2 - initial_authorities.len()) as u32;
|
||||
|
||||
GenesisConfig {
|
||||
consensus: Some(ConsensusConfig {
|
||||
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(),
|
||||
authorities: initial_authorities.iter().map(|x| x.2.clone()).collect(),
|
||||
_genesis_phantom_data: Default::default(),
|
||||
changes_trie_config: Default::default(),
|
||||
}),
|
||||
system: None,
|
||||
indices: Some(IndicesConfig {
|
||||
ids: endowed_accounts.clone(),
|
||||
}),
|
||||
@@ -240,15 +243,15 @@ pub fn testnet_genesis(
|
||||
}),
|
||||
session: Some(SessionConfig {
|
||||
validators: initial_authorities.iter().map(|x| x.1.clone()).collect(),
|
||||
session_length: 10,
|
||||
keys: initial_authorities.iter().map(|x| (x.1.clone(), x.2.clone())).collect::<Vec<_>>(),
|
||||
keys: initial_authorities.iter().map(|x| (
|
||||
x.1.clone(),
|
||||
SessionKeys(x.2.clone(), x.2.clone()),
|
||||
)).collect::<Vec<_>>(),
|
||||
}),
|
||||
staking: Some(StakingConfig {
|
||||
current_era: 0,
|
||||
minimum_validator_count: 1,
|
||||
validator_count: 2,
|
||||
sessions_per_era: 5,
|
||||
bonding_duration: 12,
|
||||
offline_slash: Perbill::zero(),
|
||||
session_reward: Perbill::zero(),
|
||||
current_session_reward: 0,
|
||||
@@ -263,19 +266,16 @@ pub fn testnet_genesis(
|
||||
.map(|a| (a.clone(), 1000000)).collect(),
|
||||
candidacy_bond: 10,
|
||||
voter_bond: 2,
|
||||
voting_fee: 5,
|
||||
present_slash_per_voter: 1,
|
||||
carry_count: 4,
|
||||
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,
|
||||
}),
|
||||
council_voting: Some(CouncilVotingConfig {
|
||||
cooloff_period: 75,
|
||||
voting_period: 20,
|
||||
enact_delay_period: 0,
|
||||
}),
|
||||
parachains: Some(Default::default()),
|
||||
timestamp: Some(TimestampConfig {
|
||||
minimum_period: 2, // 2*2=4 second block time.
|
||||
@@ -291,6 +291,10 @@ pub fn testnet_genesis(
|
||||
}),
|
||||
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(),
|
||||
}),
|
||||
curated_grandpa: Some(CuratedGrandpaConfig {
|
||||
shuffle_period: 1024,
|
||||
|
||||
@@ -29,7 +29,7 @@ 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, NothingExtra};
|
||||
use aura::{import_queue, start_aura, AuraImportQueue, SlotDuration};
|
||||
use inherents::InherentDataProviders;
|
||||
use log::info;
|
||||
pub use service::{
|
||||
@@ -304,7 +304,6 @@ service::construct_service_factory! {
|
||||
block_import,
|
||||
Arc::new(proposer_factory),
|
||||
service.network(),
|
||||
service.on_exit(),
|
||||
service.config.custom.inherent_data_providers.clone(),
|
||||
service.config.force_authoring,
|
||||
)?;
|
||||
@@ -328,14 +327,13 @@ service::construct_service_factory! {
|
||||
let justification_import = block_import.clone();
|
||||
|
||||
config.custom.grandpa_import_setup = Some((block_import.clone(), link_half));
|
||||
import_queue::<_, _, _, ed25519::Pair>(
|
||||
import_queue::<_, _, ed25519::Pair>(
|
||||
slot_duration,
|
||||
block_import,
|
||||
Some(justification_import),
|
||||
None,
|
||||
None,
|
||||
client,
|
||||
NothingExtra,
|
||||
config.custom.inherent_data_providers.clone(),
|
||||
).map_err(Into::into)
|
||||
}},
|
||||
@@ -343,6 +341,7 @@ service::construct_service_factory! {
|
||||
Self::Block,
|
||||
>
|
||||
{ |config: &mut FactoryFullConfiguration<Self>, client: Arc<LightClient<Self>>| {
|
||||
#[allow(deprecated)]
|
||||
let fetch_checker = client.backend().blockchain().fetcher()
|
||||
.upgrade()
|
||||
.map(|fetcher| fetcher.checker().clone())
|
||||
@@ -354,23 +353,20 @@ service::construct_service_factory! {
|
||||
let finality_proof_import = block_import.clone();
|
||||
let finality_proof_request_builder = finality_proof_import.create_finality_proof_request_builder();
|
||||
|
||||
import_queue::<_, _, _, ed25519::Pair>(
|
||||
import_queue::<_, _, ed25519::Pair>(
|
||||
SlotDuration::get_or_compute(&*client)?,
|
||||
block_import,
|
||||
None,
|
||||
Some(finality_proof_import),
|
||||
Some(finality_proof_request_builder),
|
||||
client,
|
||||
NothingExtra,
|
||||
config.custom.inherent_data_providers.clone(),
|
||||
).map_err(Into::into)
|
||||
}},
|
||||
SelectChain = LongestChain<FullBackend<Self>, Self::Block>
|
||||
{ |config: &FactoryFullConfiguration<Self>, client: Arc<FullClient<Self>>| {
|
||||
Ok(LongestChain::new(
|
||||
client.backend().clone(),
|
||||
client.import_lock()
|
||||
))
|
||||
#[allow(deprecated)]
|
||||
Ok(LongestChain::new(client.backend().clone()))
|
||||
}
|
||||
},
|
||||
FinalityProofProvider = { |client: Arc<FullClient<Self>>| {
|
||||
|
||||
@@ -90,7 +90,7 @@ impl ParachainContext for AdderContext {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let key = Arc::new(Pair::from_seed([1; 32]));
|
||||
let key = Arc::new(Pair::from_seed(&[1; 32]));
|
||||
let id: ParaId = 100.into();
|
||||
|
||||
println!("Starting adder collator with genesis: ");
|
||||
|
||||
@@ -28,7 +28,6 @@ runtime_aura = { package = "srml-aura", git = "https://github.com/paritytech/sub
|
||||
client = { package = "substrate-client", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
trie = { package = "substrate-trie", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
runtime_primitives = { package = "sr-primitives", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
consensus_authorities = { package = "substrate-consensus-authorities", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
|
||||
[dev-dependencies]
|
||||
substrate-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||
|
||||
@@ -23,25 +23,21 @@
|
||||
/// such as candidate verification while performing event-driven work
|
||||
/// on a local event loop.
|
||||
|
||||
use std::thread;
|
||||
use std::time::{Duration, Instant};
|
||||
use std::sync::Arc;
|
||||
use std::{thread, time::{Duration, Instant}, sync::Arc};
|
||||
|
||||
use client::{error::Result as ClientResult, BlockchainEvents, BlockBody};
|
||||
use client::block_builder::api::BlockBuilder;
|
||||
use client::blockchain::HeaderBackend;
|
||||
use consensus::SelectChain;
|
||||
use consensus_authorities::AuthoritiesApi;
|
||||
use extrinsic_store::Store as ExtrinsicStore;
|
||||
use futures::prelude::*;
|
||||
use primitives::ed25519;
|
||||
use polkadot_primitives::{Block, BlockId};
|
||||
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::runtime::TaskExecutor;
|
||||
use tokio::runtime::current_thread::Runtime as LocalRuntime;
|
||||
use tokio::timer::Interval;
|
||||
use tokio::{timer::Interval, runtime::{TaskExecutor, current_thread::Runtime as LocalRuntime}};
|
||||
use log::{warn, debug};
|
||||
|
||||
use super::{Network, Collators};
|
||||
@@ -118,7 +114,7 @@ pub(crate) fn start<C, N, P, SC>(
|
||||
<C::Collation as IntoFuture>::Future: Send + 'static,
|
||||
P: BlockchainEvents<Block> + BlockBody<Block>,
|
||||
P: ProvideRuntimeApi + HeaderBackend<Block> + Send + Sync + 'static,
|
||||
P::Api: ParachainHost<Block> + BlockBuilder<Block> + AuthoritiesApi<Block>,
|
||||
P::Api: ParachainHost<Block> + BlockBuilder<Block> + AuraApi<Block, AuraId>,
|
||||
N: Network + Send + Sync + 'static,
|
||||
N::TableRouter: Send + 'static,
|
||||
<N::BuildTableRouter as IntoFuture>::Future: Send + 'static,
|
||||
@@ -139,23 +135,18 @@ pub(crate) fn start<C, N, P, SC>(
|
||||
.for_each(move |notification| {
|
||||
let parent_hash = notification.hash;
|
||||
if notification.is_new_best {
|
||||
let res = client
|
||||
.runtime_api()
|
||||
.authorities(&BlockId::hash(parent_hash))
|
||||
.map_err(Into::into)
|
||||
.and_then(|authorities| {
|
||||
validation.get_or_instantiate(
|
||||
parent_hash,
|
||||
notification.header.parent_hash().clone(),
|
||||
&authorities,
|
||||
key.clone(),
|
||||
max_block_data_size,
|
||||
)
|
||||
});
|
||||
let res = validation.get_or_instantiate(
|
||||
parent_hash,
|
||||
notification.header.parent_hash().clone(),
|
||||
key.clone(),
|
||||
max_block_data_size,
|
||||
);
|
||||
|
||||
if let Err(e) = res {
|
||||
warn!("Unable to start parachain validation on top of {:?}: {}",
|
||||
parent_hash, e);
|
||||
warn!(
|
||||
"Unable to start parachain validation on top of {:?}: {}",
|
||||
parent_hash, e
|
||||
);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
||||
@@ -33,7 +33,7 @@ use std::collections::{HashMap, HashSet};
|
||||
use std::sync::Arc;
|
||||
use std::time::{self, Duration, Instant};
|
||||
|
||||
use aura::SlotDuration;
|
||||
use aura::{SlotDuration, AuraApi};
|
||||
use client::{BlockchainEvents, BlockBody};
|
||||
use client::blockchain::HeaderBackend;
|
||||
use client::block_builder::api::BlockBuilder as BlockBuilderApi;
|
||||
@@ -41,18 +41,19 @@ use parity_codec::Encode;
|
||||
use consensus::SelectChain;
|
||||
use extrinsic_store::Store as ExtrinsicStore;
|
||||
use parking_lot::Mutex;
|
||||
use polkadot_primitives::{Hash, Block, BlockId, BlockNumber, Header, SessionKey};
|
||||
use polkadot_primitives::{Hash, Block, BlockId, BlockNumber, Header, SessionKey, AuraId};
|
||||
use polkadot_primitives::parachain::{
|
||||
Id as ParaId, Chain, DutyRoster, Extrinsic as ParachainExtrinsic, CandidateReceipt,
|
||||
ParachainHost, AttestedCandidate, Statement as PrimitiveStatement, Message, OutgoingMessage, CollatorSignature,
|
||||
Collation, PoVBlock,
|
||||
};
|
||||
use primitives::{Pair, ed25519};
|
||||
use runtime_primitives::{traits::{ProvideRuntimeApi, Header as HeaderT, Block as BlockT}, ApplyError};
|
||||
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};
|
||||
use consensus_authorities::AuthoritiesApi;
|
||||
|
||||
use attestation_service::ServiceHandle;
|
||||
use futures::prelude::*;
|
||||
@@ -250,7 +251,7 @@ impl<C, N, P> ParachainValidation<C, N, P> where
|
||||
C: Collators + Send + 'static,
|
||||
N: Network,
|
||||
P: ProvideRuntimeApi + HeaderBackend<Block> + BlockBody<Block> + Send + Sync + 'static,
|
||||
P::Api: ParachainHost<Block> + BlockBuilderApi<Block>,
|
||||
P::Api: ParachainHost<Block> + BlockBuilderApi<Block> + AuraApi<Block, AuraId>,
|
||||
<C::Collation as IntoFuture>::Future: Send + 'static,
|
||||
N::TableRouter: Send + 'static,
|
||||
<N::BuildTableRouter as IntoFuture>::Future: Send + 'static,
|
||||
@@ -266,7 +267,6 @@ impl<C, N, P> ParachainValidation<C, N, P> where
|
||||
&self,
|
||||
parent_hash: Hash,
|
||||
grandparent_hash: Hash,
|
||||
authorities: &[AuthorityId],
|
||||
sign_with: Arc<ed25519::Pair>,
|
||||
max_block_data_size: Option<u64>,
|
||||
)
|
||||
@@ -279,6 +279,8 @@ impl<C, N, P> ParachainValidation<C, N, P> where
|
||||
|
||||
let id = BlockId::hash(parent_hash);
|
||||
|
||||
let authorities = self.client.runtime_api().authorities(&id)?;
|
||||
|
||||
// compute the parent candidates, if we know of them.
|
||||
// this will allow us to circulate outgoing messages to other peers as necessary.
|
||||
let parent_candidates: Vec<_> = crate::attestation_service::fetch_candidates(&*self.client, &id)
|
||||
@@ -309,7 +311,7 @@ impl<C, N, P> ParachainValidation<C, N, P> where
|
||||
|
||||
let (group_info, local_duty) = make_group_info(
|
||||
duty_roster,
|
||||
authorities,
|
||||
&authorities,
|
||||
sign_with.public().into(),
|
||||
)?;
|
||||
|
||||
@@ -321,7 +323,7 @@ impl<C, N, P> ParachainValidation<C, N, P> where
|
||||
debug!(target: "validation", "Active parachains: {:?}", active_parachains);
|
||||
|
||||
let table = Arc::new(SharedTable::new(
|
||||
authorities,
|
||||
&authorities,
|
||||
group_info,
|
||||
sign_with.clone(),
|
||||
parent_hash,
|
||||
@@ -330,7 +332,7 @@ impl<C, N, P> ParachainValidation<C, N, P> where
|
||||
));
|
||||
let router = self.network.communication_for(
|
||||
table.clone(),
|
||||
authorities,
|
||||
&authorities,
|
||||
);
|
||||
|
||||
let drop_signal = match local_duty.validation {
|
||||
@@ -453,7 +455,7 @@ impl<C, N, P, SC, TxApi> ProposerFactory<C, N, P, SC, TxApi> where
|
||||
<C::Collation as IntoFuture>::Future: Send + 'static,
|
||||
P: BlockchainEvents<Block> + BlockBody<Block>,
|
||||
P: ProvideRuntimeApi + HeaderBackend<Block> + Send + Sync + 'static,
|
||||
P::Api: ParachainHost<Block> + BlockBuilderApi<Block> + AuthoritiesApi<Block>,
|
||||
P::Api: ParachainHost<Block> + BlockBuilderApi<Block> + AuraApi<Block, AuraId>,
|
||||
N: Network + Send + Sync + 'static,
|
||||
N::TableRouter: Send + 'static,
|
||||
<N::BuildTableRouter as IntoFuture>::Future: Send + 'static,
|
||||
@@ -509,7 +511,7 @@ impl<C, N, P, SC, TxApi> consensus::Environment<Block> for ProposerFactory<C, N,
|
||||
N: Network,
|
||||
TxApi: PoolChainApi<Block=Block>,
|
||||
P: ProvideRuntimeApi + HeaderBackend<Block> + BlockBody<Block> + Send + Sync + 'static,
|
||||
P::Api: ParachainHost<Block> + BlockBuilderApi<Block>,
|
||||
P::Api: ParachainHost<Block> + BlockBuilderApi<Block> + AuraApi<Block, AuraId>,
|
||||
<C::Collation as IntoFuture>::Future: Send + 'static,
|
||||
N::TableRouter: Send + 'static,
|
||||
<N::BuildTableRouter as IntoFuture>::Future: Send + 'static,
|
||||
@@ -521,7 +523,6 @@ impl<C, N, P, SC, TxApi> consensus::Environment<Block> for ProposerFactory<C, N,
|
||||
fn init(
|
||||
&self,
|
||||
parent_header: &Header,
|
||||
authorities: &[AuthorityId],
|
||||
) -> Result<Self::Proposer, Error> {
|
||||
let parent_hash = parent_header.hash();
|
||||
let parent_id = BlockId::hash(parent_hash);
|
||||
@@ -529,7 +530,6 @@ impl<C, N, P, SC, TxApi> consensus::Environment<Block> for ProposerFactory<C, N,
|
||||
let tracker = self.parachain_validation.get_or_instantiate(
|
||||
parent_hash,
|
||||
parent_header.parent_hash().clone(),
|
||||
authorities,
|
||||
sign_with,
|
||||
self.max_block_data_size,
|
||||
)?;
|
||||
@@ -574,7 +574,7 @@ impl<C, TxApi> consensus::Proposer<Block> for Proposer<C, TxApi> where
|
||||
|
||||
fn propose(&self,
|
||||
inherent_data: InherentData,
|
||||
_digest: <<Block as BlockT>::Header as HeaderT>::Digest,
|
||||
_inherent_digests: DigestFor<Block>,
|
||||
max_duration: Duration,
|
||||
) -> Self::Create {
|
||||
const ATTEMPT_PROPOSE_EVERY: Duration = Duration::from_millis(100);
|
||||
|
||||
Reference in New Issue
Block a user