Full native build with new structure.

No tests yet.
Wasm build still pulls in std.
This commit is contained in:
Gav
2018-02-07 15:54:18 +01:00
parent 9fe85fc9f4
commit dcff8f1a2f
33 changed files with 56 additions and 74 deletions
+2
View File
@@ -1005,6 +1005,7 @@ dependencies = [
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
"native-runtime 0.1.0",
"parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"polkadot-primitives 0.1.0",
"substrate-codec 0.1.0",
"substrate-executor 0.1.0",
"substrate-primitives 0.1.0",
@@ -1035,6 +1036,7 @@ dependencies = [
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"polkadot-client 0.1.0",
"polkadot-primitives 0.1.0",
"rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)",
"semver 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)",
+1
View File
@@ -7,6 +7,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
error-chain = "0.11"
log = "0.3"
parking_lot = "0.4"
polkadot-primitives = { path = "../polkadot-primitives", version = "0.1" }
substrate-primitives = { path = "../primitives", version = "0.1" }
substrate-state-machine = { path = "../state-machine", version = "0.1" }
substrate-serializer = { path = "../serializer" }
+1 -2
View File
@@ -18,7 +18,7 @@
use state_machine;
use error;
use primitives::relay::block;
use primitives::block;
use blockchain::{self, BlockId};
/// Block insertion transction. Keeps hold if the inseted block state and data.
@@ -50,4 +50,3 @@ pub trait Backend {
/// Returns state backend for specified block.
fn state_at(&self, block: BlockId) -> error::Result<Self::State>;
}
+1 -2
View File
@@ -17,7 +17,7 @@
//! Polkadot blockchain trait
use std::fmt::{Display, Formatter, Error as FmtError};
use primitives::relay::block;
use primitives::block;
use error::Result;
/// Block indentification.
@@ -83,4 +83,3 @@ pub enum BlockStatus {
/// Not in the queue or the blockchain.
Unknown,
}
+2 -2
View File
@@ -17,7 +17,7 @@
//! Tool for creating the genesis block.
use std::collections::HashMap;
use primitives::relay::{Block, Header};
use primitives::{Block, Header};
use triehash::trie_root;
/// Create a genesis block, given the initial storage.
@@ -46,7 +46,7 @@ mod tests {
use state_machine::OverlayedChanges;
use state_machine::backend::InMemory;
use substrate_executor::executor;
use primitives::relay::{AccountId, Hash, BlockNumber, Header, Digest, UncheckedTransaction,
use polkadot_primitives::{AccountId, Hash, BlockNumber, Header, Digest, UncheckedTransaction,
Transaction, Function};
use ed25519::Pair;
+1 -2
View File
@@ -23,7 +23,7 @@ use error;
use backend;
use primitives;
use ser;
use primitives::relay::block::{self, HeaderHash};
use primitives::block::{self, HeaderHash};
use blockchain::{self, BlockId, BlockStatus};
fn header_hash(header: &block::Header) -> block::HeaderHash {
@@ -201,4 +201,3 @@ impl backend::Backend for Backend {
}
}
}
+3 -2
View File
@@ -18,6 +18,7 @@
#![warn(missing_docs)]
extern crate polkadot_primitives;
extern crate substrate_primitives as primitives;
extern crate substrate_state_machine as state_machine;
extern crate substrate_serializer as ser;
@@ -47,8 +48,8 @@ pub use genesis::construct_genesis_block;
pub use blockchain::Info as ChainInfo;
pub use blockchain::BlockId;
use primitives::relay::block;
use primitives::contract::{StorageKey, StorageData};
use primitives::block;
use primitives::storage::{StorageKey, StorageData};
use blockchain::Backend as BlockchainBackend;
use backend::BlockImportOperation;
+1 -1
View File
@@ -16,7 +16,7 @@
//! Trait
use std::iter::Extend;
use rstd::iter::Extend;
use super::slicable::Slicable;
/// Trait to allow itself to be serialised into a value which can be extended
+2 -2
View File
@@ -17,8 +17,8 @@
//! Serialiser and prepender.
use slicable::Slicable;
use std::iter::Extend;
use std::vec::Vec;
use rstd::iter::Extend;
use rstd::vec::Vec;
/// Trait to allow itselg to be serialised and prepended by a given slice.
pub trait KeyedVec {
+2 -9
View File
@@ -20,6 +20,8 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(not(feature = "std"), feature(alloc))]
extern crate substrate_runtime_std as rstd;
mod endiansensitive;
mod slicable;
mod joiner;
@@ -29,12 +31,3 @@ pub use self::endiansensitive::EndianSensitive;
pub use self::slicable::{Slicable, NonTrivialSlicable};
pub use self::joiner::Joiner;
pub use self::keyedvec::KeyedVec;
// TODO: move these into runtime-std and `extern crate runtime_std as std;`
#[cfg(not(feature = "std"))]
mod std {
extern crate alloc;
pub use core::*;
pub use self::alloc::vec;
}
+4 -4
View File
@@ -16,8 +16,8 @@
//! Serialisation.
use std::{mem, slice};
use std::vec::Vec;
use rstd::{mem, slice};
use rstd::vec::Vec;
use super::joiner::Joiner;
use super::endiansensitive::EndianSensitive;
@@ -44,7 +44,7 @@ impl<T: EndianSensitive> Slicable for T {
let size = mem::size_of::<T>();
assert!(size > 0, "EndianSensitive can never be implemented for a zero-sized type.");
if value.len() >= size {
let x: T = unsafe { ::std::ptr::read(value.as_ptr() as *const T) };
let x: T = unsafe { ::rstd::ptr::read(value.as_ptr() as *const T) };
*value = &value[size..];
Some(x.from_le())
} else {
@@ -115,7 +115,7 @@ impl<T: NonTrivialSlicable> Slicable for Vec<T> {
}
fn to_vec(&self) -> Vec<u8> {
use std::iter::Extend;
use rstd::iter::Extend;
let len = self.len();
assert!(len <= u32::max_value() as usize, "Attempted to serialize vec with too many elements.");
+1 -1
View File
@@ -60,7 +60,7 @@ pub trait ParachainContext {
fn produce_candidate<I: IntoIterator<Item=(ParaId, Message)>>(
&self,
ingress: I,
) -> (parachain::BlockData, primitives::relay::Signature);
) -> (parachain::BlockData, ::Signature);
}
/// Relay chain context needed to collate.
+1 -1
View File
@@ -63,7 +63,7 @@ mod tests {
use native_runtime::runtime::staking::balance;
use state_machine::TestExternalities;
use primitives::twox_128;
use primitives::relay::{Hash, Header, BlockNumber, Block, Digest, Transaction,
use polkadot_primitives::{Hash, Header, BlockNumber, Block, Digest, Transaction,
UncheckedTransaction, Function, AccountId};
use ed25519::Pair;
+1 -1
View File
@@ -293,7 +293,7 @@ mod tests {
use native_runtime::runtime::staking::balance;
use state_machine::TestExternalities;
use primitives::twox_128;
use primitives::relay::{Header, Transaction, UncheckedTransaction, Function, AccountId};
use polkadot_primitives::{Header, Transaction, UncheckedTransaction, Function, AccountId};
use runtime_io;
use ed25519::Pair;
+1
View File
@@ -11,6 +11,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
ethcore-network = { git = "https://github.com/paritytech/parity.git" }
ethcore-io = { git = "https://github.com/paritytech/parity.git" }
substrate-primitives = { path = "../primitives" }
polkadot-primitives = { path = "../polkadot-primitives" }
polkadot-client = { path = "../client" }
substrate-state-machine = { path = "../state-machine" }
substrate-serializer = { path = "../serializer" }
+2 -3
View File
@@ -20,7 +20,7 @@ use std::ops::Range;
use std::collections::{HashMap, BTreeMap};
use std::collections::hash_map::Entry;
use network::PeerId;
use primitives::relay::BlockNumber;
use primitives::block::Number as BlockNumber;
use message;
const MAX_PARALLEL_DOWNLOADS: u32 = 1;
@@ -190,7 +190,7 @@ impl BlockCollection {
mod test {
use super::{BlockCollection, BlockData};
use message;
use primitives::relay::{HeaderHash};
use primitives::HeaderHash;
fn is_empty(bc: &BlockCollection) -> bool {
bc.blocks.is_empty() &&
@@ -260,4 +260,3 @@ mod test {
assert_eq!(drained[40..], blocks[121..150].iter().map(|b| BlockData { block: b.clone(), origin: 1 }).collect::<Vec<_>>()[..]);
}
}
+1 -3
View File
@@ -19,7 +19,7 @@
use client::{self, Client as PolkadotClient, ImportResult, ClientInfo, BlockStatus};
use client::error::Error;
use state_machine;
use primitives::relay::block;
use primitives::block;
pub trait Client : Send + Sync {
/// Given a hash return a header
@@ -55,5 +55,3 @@ impl<B, E> Client for PolkadotClient<B, E> where
(self as &Client).block_hash(block_number)
}
}
+5 -3
View File
@@ -28,11 +28,14 @@ extern crate parking_lot;
extern crate smallvec;
extern crate ipnetwork;
extern crate substrate_primitives as primitives;
extern crate polkadot_client as client;
extern crate substrate_state_machine as state_machine;
extern crate substrate_serializer as ser;
extern crate serde;
extern crate serde_json;
// TODO: remove these two; split off dependent logic into polkadot-network and rename this crate
// to substrate-network.
extern crate polkadot_primitives as polkadot_primitives;
extern crate polkadot_client as client;
#[macro_use] extern crate serde_derive;
#[macro_use] extern crate log;
#[macro_use] extern crate bitflags;
@@ -56,7 +59,6 @@ pub use protocol::{ProtocolStatus};
pub use network::{NonReservedPeerMode, ConnectionFilter, ConnectionDirection, NetworkConfiguration};
// TODO: move it elsewhere
fn header_hash(header: &primitives::relay::Header) -> primitives::relay::HeaderHash {
fn header_hash(header: &primitives::Header) -> primitives::block::HeaderHash {
primitives::hashing::blake2_256(&ser::to_vec(header)).into()
}
+4 -3
View File
@@ -17,9 +17,10 @@
//! Network packet message types. These get serialized and put into the lower level protocol payload.
use std::borrow::Borrow;
use primitives::parachain::Id as ParachainId;
use primitives::relay::{AccountId, BlockNumber, HeaderHash, Header, Body};
use primitives::AuthorityId;
use primitives::block::{Number as BlockNumber, HeaderHash, Header, Body};
use service::Role as RoleFlags;
use polkadot_primitives::parachain::Id as ParachainId;
pub type RequestId = u64;
type Bytes = Vec<u8>;
@@ -149,7 +150,7 @@ pub struct Status {
/// Signatue of `best_hash` made with validator address. Required for the validator role.
pub validator_signature: Option<Signature>,
/// Validator address. Required for the validator role.
pub validator_id: Option<AccountId>,
pub validator_id: Option<AuthorityId>,
/// Parachain id. Required for the collator role.
pub parachain_id: Option<ParachainId>,
}
+1 -4
View File
@@ -20,7 +20,7 @@ use std::sync::Arc;
use parking_lot::RwLock;
use serde_json;
use std::time;
use primitives::relay::{HeaderHash, TransactionHash, BlockNumber, Header};
use primitives::block::{HeaderHash, TransactionHash, Number as BlockNumber, Header};
use network::{PeerId, NodeId};
use message::{self, Message};
@@ -342,6 +342,3 @@ impl Protocol {
&*self.chain
}
}
+1 -1
View File
@@ -19,7 +19,7 @@ use std::collections::{BTreeMap};
use std::io;
use network::{NetworkProtocolHandler, NetworkService, NetworkContext, HostInfo, PeerId, ProtocolId,
NetworkConfiguration , NonReservedPeerMode, ErrorKind};
use primitives::relay::{TransactionHash, Header};
use primitives::block::{TransactionHash, Header};
use core_io::{TimerToken};
use io::NetSyncIo;
use protocol::{Protocol, ProtocolStatus, PeerInfo as ProtocolPeerInfo, TransactionStats};
+1 -5
View File
@@ -19,7 +19,7 @@ use io::SyncIo;
use protocol::Protocol;
use network::PeerId;
use client::{ImportResult, BlockStatus, ClientInfo};
use primitives::relay::{HeaderHash, BlockNumber, Header};
use primitives::block::{HeaderHash, Number as BlockNumber, Header};
use blocks::{self, BlockCollection};
use message::{self, Message};
use super::header_hash;
@@ -366,7 +366,3 @@ impl ChainSync {
protocol.send_message(io, peer_id, Message::BlockRequest(request));
}
}
+1 -14
View File
@@ -21,7 +21,6 @@ use primitives::bytes;
use primitives::H256;
use rstd::vec::Vec;
use codec::Slicable;
use parachain;
use transaction::UncheckedTransaction;
/// Used to refer to a block number.
@@ -161,24 +160,12 @@ impl Slicable for Header {
}
}
/// A relay chain block body.
///
/// Included candidates should be sorted by parachain ID, and without duplicate
/// IDs.
#[derive(PartialEq, Eq, Clone)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug))]
#[cfg_attr(feature = "std", serde(rename_all = "camelCase"))]
#[cfg_attr(feature = "std", serde(deny_unknown_fields))]
pub struct Body {
/// Parachain proposal blocks.
pub candidates: Vec<parachain::Candidate>,
}
#[cfg(test)]
mod tests {
use super::*;
use codec::Slicable;
use substrate_serializer as ser;
use parachain;
#[test]
fn test_header_serialization() {
+4 -1
View File
@@ -83,6 +83,9 @@ impl Slicable for Digest {
}
}
/// The body of a block is just a bunch of transactions.
pub type Body = Vec<Transaction>;
/// A Substrate relay chain block.
#[derive(PartialEq, Eq, Clone)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug))]
@@ -90,7 +93,7 @@ pub struct Block {
/// The block header.
pub header: Header,
/// All relay-chain transactions.
pub transactions: Vec<Transaction>,
pub transactions: Body,
}
impl Slicable for Block {
+1 -1
View File
@@ -16,7 +16,7 @@
//! Polkadot blockchain API.
use primitives::relay::block;
use primitives::block;
use client;
use state_machine;
+2 -2
View File
@@ -22,8 +22,8 @@ mod error;
mod tests;
use client::{self, Client};
use primitives::relay::block;
use primitives::contract::{StorageKey, StorageData};
use primitives::block;
use primitives::storage::{StorageKey, StorageData};
use state_machine;
use self::error::Result;
+2
View File
@@ -21,3 +21,5 @@ pub use std::boxed;
pub use std::slice;
pub use std::mem;
pub use std::ops;
pub use std::iter;
pub use std::ptr;
+2
View File
@@ -24,3 +24,5 @@ pub use core::mem;
pub use core::slice;
pub use core::cell;
pub use core::ops;
pub use core::iter;
pub use core::ptr;
@@ -148,7 +148,7 @@ mod tests {
use runtime_io::{with_externalities, twox_128, TestExternalities};
use codec::{KeyedVec, Joiner};
use support::{one, two, with_env};
use primitives::relay::{AccountId, InternalFunction};
use polkadot_primitives::{AccountId, Proposal};
use runtime::{staking, session};
fn new_test_ext() -> TestExternalities {
@@ -140,7 +140,7 @@ mod tests {
use runtime_io::{with_externalities, twox_128, TestExternalities};
use codec::{KeyedVec, Joiner};
use support::{one, two, with_env};
use primitives::relay::AccountId;
use polkadot_primitives::AccountId;
use runtime::{consensus, session};
fn simple_setup() -> TestExternalities {
@@ -216,7 +216,7 @@ mod tests {
use runtime_io::{with_externalities, twox_128, TestExternalities};
use codec::{KeyedVec, Joiner};
use support::{one, two, with_env};
use primitives::relay::AccountId;
use polkadot_primitives::AccountId;
use runtime::{staking, session};
#[test]
@@ -221,7 +221,7 @@ mod tests {
use runtime_io::{with_externalities, twox_128, TestExternalities};
use codec::{Joiner, KeyedVec, Slicable};
use support::{StaticHexInto, HexDisplay, one, two};
use primitives::relay::{Header, Digest, UncheckedTransaction, Transaction, Function};
use polkadot_primitives::{Header, Digest, UncheckedTransaction, Transaction, Function};
use runtime::staking;
#[test]
@@ -338,7 +338,7 @@ mod tests {
#[test]
fn proposals_can_be_stored() {
use primitives::relay::{Proposal, InternalFunction};
use polkadot_primitives::{Proposal, InternalFunction};
let mut t = TestExternalities { storage: HashMap::new(), };
with_externalities(&mut t, || {
let x = Proposal {