Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Update to latest substrate master #491

Merged
merged 2 commits into from
Oct 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
190 changes: 109 additions & 81 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ substrate-network = { git = "https://github.com/paritytech/substrate", branch =
substrate-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
sr-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
futures = "0.1"
futures03 = { package = "futures-preview", version = "0.3.0-alpha.19", features = ["compat"] }
log = "0.4"
exit-future = "0.1.4"
substrate-client = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
Expand Down
11 changes: 6 additions & 5 deletions network/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ pub mod validation;
pub mod gossip;

use codec::{Decode, Encode};
use futures::sync::{oneshot, mpsc};
use futures::sync::oneshot;
use futures::prelude::*;
use futures03::{channel::mpsc, compat::Compat, StreamExt};
use polkadot_primitives::{Block, Hash, Header};
use polkadot_primitives::parachain::{
Id as ParaId, BlockData, CollatorId, CandidateReceipt, Collation, PoVBlock,
Expand Down Expand Up @@ -108,7 +109,7 @@ impl NetworkService for PolkadotNetworkService {
Err(_) => mpsc::unbounded().1, // return empty channel.
};

GossipMessageStream::new(topic_stream)
GossipMessageStream::new(Box::new(Compat::new(topic_stream.map(Ok))))
}

fn gossip_message(&self, topic: Hash, message: GossipMessage) {
Expand Down Expand Up @@ -151,14 +152,14 @@ impl GossipService for consensus_gossip::ConsensusGossip<Block> {

/// A stream of gossip messages and an optional sender for a topic.
pub struct GossipMessageStream {
topic_stream: mpsc::UnboundedReceiver<TopicNotification>,
topic_stream: Box<dyn Stream<Item = TopicNotification, Error = ()> + Send>,
}

impl GossipMessageStream {
/// Create a new instance with the given topic stream.
pub fn new(topic_stream: mpsc::UnboundedReceiver<TopicNotification>) -> Self {
pub fn new(topic_stream: Box<dyn Stream<Item = TopicNotification, Error = ()> + Send>) -> Self {
Self {
topic_stream
topic_stream,
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion network/src/tests/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ impl NetworkService for TestNetwork {
fn gossip_messages_for(&self, topic: Hash) -> GossipMessageStream {
let (tx, rx) = mpsc::unbounded();
let _ = self.gossip.send_listener.unbounded_send((topic, tx));
GossipMessageStream::new(rx)
GossipMessageStream::new(Box::new(rx))
}

fn gossip_message(&self, topic: Hash, message: GossipMessage) {
Expand Down
9 changes: 6 additions & 3 deletions parachain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub mod wasm_api;
use rstd::vec::Vec;

use codec::{Encode, Decode, CompactAs};
use substrate_primitives::TypeId;
use substrate_primitives::{RuntimeDebug, TypeId};

/// Validation parameters for evaluating the parachain validity function.
// TODO: balance downloads (https://github.com/paritytech/polkadot/issues/220)
Expand All @@ -79,8 +79,11 @@ pub struct ValidationResult {
}

/// Unique identifier of a parachain.
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Default, Clone, Copy, Encode, Decode, CompactAs)]
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize, Debug))]
#[derive(
Clone, CompactAs, Copy, Decode, Default, Encode, Eq,
Hash, Ord, PartialEq, PartialOrd, RuntimeDebug
)]
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
pub struct Id(u32);

impl TypeId for Id {
Expand Down
10 changes: 4 additions & 6 deletions primitives/src/parachain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use serde::{Serialize, Deserialize};

#[cfg(feature = "std")]
use primitives::bytes;
use primitives::RuntimeDebug;
use application_crypto::KeyTypeId;

pub use polkadot_parachain::{
Expand Down Expand Up @@ -102,8 +103,7 @@ pub trait ActiveParas {
}

/// Description of how often/when this parachain is scheduled for progression.
#[derive(Encode, Decode, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "std", derive(Debug))]
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug)]
pub enum Scheduling {
/// Scheduled every block.
Always,
Expand All @@ -112,8 +112,7 @@ pub enum Scheduling {
}

/// Information regarding a deployed parachain/thread.
#[derive(Encode, Decode, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "std", derive(Debug))]
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug)]
pub struct Info {
/// Scheduling info.
pub scheduling: Scheduling,
Expand Down Expand Up @@ -429,8 +428,7 @@ pub enum ValidityAttestation {
}

/// An attested candidate.
#[derive(Clone, PartialEq, Decode, Encode)]
#[cfg_attr(feature = "std", derive(Debug))]
#[derive(Clone, PartialEq, Decode, Encode, RuntimeDebug)]
pub struct AttestedCandidate {
/// The candidate data.
pub candidate: CandidateReceipt,
Expand Down
4 changes: 2 additions & 2 deletions runtime/src/attestations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use codec::{Encode, Decode};
use srml_support::{decl_storage, decl_module, ensure, dispatch::Result, traits::Get};

use primitives::{Hash, parachain::{AttestedCandidate, CandidateReceipt, Id as ParaId}};
use sr_primitives::RuntimeDebug;
use sr_staking_primitives::SessionIndex;

use inherents::{ProvideInherent, InherentData, RuntimeString, MakeFatalError, InherentIdentifier};
Expand Down Expand Up @@ -53,8 +54,7 @@ pub struct BlockAttestations<T: Trait> {
}

/// Additional attestations on a parachain block, after it was included.
#[derive(Encode, Decode, Clone, PartialEq)]
#[cfg_attr(feature = "std", derive(Debug))]
#[derive(Encode, Decode, Clone, PartialEq, RuntimeDebug)]
pub struct MoreAttestations;

/// Something which processes rewards for received attestations.
Expand Down
9 changes: 4 additions & 5 deletions runtime/src/claims.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,10 @@ impl PartialEq for EcdsaSignature {
}
}

#[cfg(feature = "std")]
impl std::fmt::Debug for EcdsaSignature {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", &self.0[..])
}
impl rstd::fmt::Debug for EcdsaSignature {
fn fmt(&self, f: &mut rstd::fmt::Formatter<'_>) -> rstd::fmt::Result {
write!(f, "EcdsaSignature({:?})", &self.0[..])
}
}

decl_event!(
Expand Down
6 changes: 3 additions & 3 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ use client::{
runtime_api as client_api, impl_runtime_apis,
};
use sr_primitives::{
ApplyResult, generic, Permill, Perbill, impl_opaque_keys, create_runtime_str, key_types,
create_runtime_str, generic, impl_opaque_keys, key_types,
ApplyResult, Permill, Perbill, RuntimeDebug,
transaction_validity::{TransactionValidity, InvalidTransaction, TransactionValidityError},
weights::{Weight, DispatchInfo}, curve::PiecewiseLinear,
traits::{BlakeTwo256, Block as BlockT, StaticLookup, SignedExtension},
Expand Down Expand Up @@ -118,8 +119,7 @@ pub fn native_version() -> NativeVersion {
///
/// RELEASE: This is only relevant for the initial PoA run-in period and may be removed
/// from the release runtime.
#[derive(Default, Encode, Decode, Clone, Eq, PartialEq)]
#[cfg_attr(feature = "std", derive(Debug))]
#[derive(Default, Encode, Decode, Clone, Eq, PartialEq, RuntimeDebug)]
pub struct OnlyStakingAndClaims;
impl SignedExtension for OnlyStakingAndClaims {
type AccountId = AccountId;
Expand Down
1 change: 0 additions & 1 deletion runtime/src/registrar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,6 @@ impl<T: Trait> ActiveParas for Module<T> {
pub struct LimitParathreadCommits<T: Trait + Send + Sync>(rstd::marker::PhantomData<T>) where
<T as system::Trait>::Call: IsSubType<Module<T>, T>;

#[cfg(feature = "std")]
impl<T: Trait + Send + Sync> rstd::fmt::Debug for LimitParathreadCommits<T> where
<T as system::Trait>::Call: IsSubType<Module<T>, T>
{
Expand Down