Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1,099 changes: 617 additions & 482 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ log = "0.4.6"
tokio = "0.1.7"
futures = "0.1.17"
exit-future = "0.1"
structopt = "0.2"
structopt = "0.3.3"
cli = { package = "substrate-cli", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
service = { package = "polkadot-service", path = "../service" }
2 changes: 1 addition & 1 deletion cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ pub trait Worker: IntoExit {

#[derive(Debug, StructOpt, Clone)]
enum PolkadotSubCommands {
#[structopt(name = "validation-worker", raw(setting = "structopt::clap::AppSettings::Hidden"))]
#[structopt(name = "validation-worker", setting = structopt::clap::AppSettings::Hidden)]
ValidationWorker(ValidationWorkerCommand),
}

Expand Down
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
10 changes: 0 additions & 10 deletions network/src/gossip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,16 +342,6 @@ impl NewLeafActions {
}
}

/// Register a gossip validator for a non-authority node.
pub fn register_non_authority_validator(service: Arc<PolkadotNetworkService>) {
service.with_gossip(|gossip, ctx|
gossip.register_validator(
ctx,
POLKADOT_ENGINE_ID,
Arc::new(substrate_network::consensus_gossip::DiscardAll)),
);
}

/// A registered message validator.
///
/// Create this using `register_validator`.
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
2 changes: 2 additions & 0 deletions parachain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ codec = { package = "parity-scale-codec", version = "1.0.5", default-features =
wasmi = { version = "0.4.3", optional = true }
derive_more = { version = "0.14", optional = true }
serde = { version = "1.0", default-features = false, features = [ "derive" ] }
substrate-primitives = { package = "substrate-primitives", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
rstd = { package = "sr-std", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
lazy_static = { version = "1.3.0", optional = true }
parking_lot = { version = "0.7.1", optional = true }
Expand All @@ -31,6 +32,7 @@ std = [
"wasmi",
"derive_more",
"serde/std",
"substrate-primitives/std",
"rstd/std",
"shared_memory",
"lazy_static",
Expand Down
8 changes: 6 additions & 2 deletions parachain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ pub mod wasm_api;
use rstd::vec::Vec;

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

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

/// Unique identifier of a parachain.
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Default, Clone, Copy, CompactAs, Encode, Decode)]
#[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 From<Id> for u32 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ use super::{
UpwardMessage, IncomingMessage};

#[cfg(not(target_os = "unknown"))]
pub use validation_host::run_worker;
pub use validation_host::EXECUTION_TIMEOUT_SEC;
pub use validation_host::{run_worker, EXECUTION_TIMEOUT_SEC};

mod validation_host;

Expand All @@ -46,7 +45,7 @@ mod ids {
pub const POST_MESSAGE: usize = 1;

/// Post a message to this parachain's relay chain.
pub const POST_UPWARDS_MESSAGE: usize = 2;
pub const POST_UPWARD_MESSAGE: usize = 2;
}

/// WASM code execution mode.
Expand Down Expand Up @@ -125,7 +124,7 @@ impl fmt::Display for ExternalitiesError {
}

impl wasmi::HostError for ExternalitiesError {}
impl ::std::error::Error for ExternalitiesError {}
impl std::error::Error for ExternalitiesError {}

struct Resolver {
max_memory: u32, // in pages.
Expand All @@ -144,7 +143,7 @@ impl ModuleImportResolver for Resolver {
let (params, ret_ty): (&[ValueType], Option<ValueType>) =
(&[ValueType::I32, ValueType::I32, ValueType::I32], None);

if signature.params() != params && signature.return_type() != ret_ty {
if signature.params() != params || signature.return_type() != ret_ty {
Err(WasmError::Instantiation(
format!("Export {} has a bad signature", field_name)
))
Expand All @@ -156,11 +155,11 @@ impl ModuleImportResolver for Resolver {
}
}
"ext_upwards_post_message" => {
let index = ids::POST_UPWARDS_MESSAGE;
let index = ids::POST_UPWARD_MESSAGE;
let (params, ret_ty): (&[ValueType], Option<ValueType>) =
(&[ValueType::I32, ValueType::I32], None);

if signature.params() != params && signature.return_type() != ret_ty {
if signature.params() != params || signature.return_type() != ret_ty {
Err(WasmError::Instantiation(
format!("Export {} has a bad signature", field_name)
))
Expand Down Expand Up @@ -269,7 +268,7 @@ impl<'a, E: 'a + Externalities> Externals for ValidationExternals<'a, E> {
) -> Result<Option<RuntimeValue>, Trap> {
match index {
ids::POST_MESSAGE => self.ext_post_message(args).map(|_| None),
ids::POST_UPWARDS_MESSAGE => self.ext_post_upward_message(args).map(|_| None),
ids::POST_UPWARD_MESSAGE => self.ext_post_upward_message(args).map(|_| None),
_ => panic!("no externality at given index"),
}
}
Expand Down
4 changes: 2 additions & 2 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 @@ -368,8 +369,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
15 changes: 15 additions & 0 deletions rpc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "polkadot-rpc"
version = "0.6.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"

[dependencies]
client = { package = "substrate-client", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
jsonrpc-core = "13.2.0"
polkadot-primitives = { path = "../primitives" }
sr-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
substrate-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
transaction_pool = { package = "substrate-transaction-pool", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
srml-system-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }

45 changes: 45 additions & 0 deletions rpc/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright 2019 Parity Technologies (UK) Ltd.
// This file is part of Polkadot.

// Polkadot is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Polkadot is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.

//! Polkadot-specific RPCs implementation.

#![warn(missing_docs)]

use std::sync::Arc;

use polkadot_primitives::{Block, AccountId, Nonce};
use sr_primitives::traits::ProvideRuntimeApi;
use transaction_pool::txpool::{ChainApi, Pool};

/// A type representing all RPC extensions.
pub type RpcExtension = jsonrpc_core::IoHandler<substrate_rpc::Metadata>;

/// Instantiate all RPC extensions.
pub fn create<C, P>(client: Arc<C>, pool: Arc<Pool<P>>) -> RpcExtension where
C: ProvideRuntimeApi,
C: client::blockchain::HeaderBackend<Block>,
C: Send + Sync + 'static,
C::Api: srml_system_rpc::AccountNonceApi<Block, AccountId, Nonce>,
P: ChainApi + Sync + Send + 'static,
{
use srml_system_rpc::{System, SystemApi};

let mut io = jsonrpc_core::IoHandler::default();
io.extend_with(
SystemApi::to_delegate(System::new(client.clone(), pool))
);
io
}
9 changes: 8 additions & 1 deletion runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ version = { package = "sr-version", git = "https://github.com/paritytech/substra
authorship = { package = "srml-authorship", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
babe = { package = "srml-babe", 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" }
transaction-payment = { package = "srml-transaction-payment", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
collective = { package = "srml-collective", 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" }
elections = { package = "srml-elections", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
Expand All @@ -40,20 +41,22 @@ im-online = { package = "srml-im-online", git = "https://github.com/paritytech/s
indices = { package = "srml-indices", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
membership = { package = "srml-membership", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
offences = { package = "srml-offences", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
randomness-collective-flip = { package = "srml-randomness-collective-flip", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
session = { package = "srml-session", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
srml-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
staking = { package = "srml-staking", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
srml-staking-reward-curve = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
sudo = { package = "srml-sudo", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
system = { package = "srml-system", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
system_rpc_runtime_api = { package = "srml-system-rpc-runtime-api", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
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" }

primitives = { package = "polkadot-primitives", path = "../primitives", default-features = false }

[dev-dependencies]
hex-literal = "0.2.0"
libsecp256k1 = "0.2.1"
libsecp256k1 = "0.3.1"
tiny-keccak = "1.4.2"
keyring = { package = "substrate-keyring", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
substrate-trie = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
Expand Down Expand Up @@ -81,6 +84,7 @@ std = [
"srml-support/std",
"authorship/std",
"balances/std",
"transaction-payment/std",
"collective/std",
"elections/std",
"democracy/std",
Expand All @@ -97,6 +101,7 @@ std = [
"staking/std",
"sudo/std",
"system/std",
"system_rpc_runtime_api/std",
"timestamp/std",
"treasury/std",
"version/std",
Expand All @@ -106,4 +111,6 @@ std = [
"safe-mix/std",
"babe/std",
"babe-primitives/std",
"substrate-session/std",
"randomness-collective-flip/std",
]
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
Loading