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
Show all changes
24 commits
Select commit Hold shift + click to select a range
4cfc108
extract out runtime-codec to a separate crate
rphmeier Jan 30, 2018
cf15e49
more idiomatic std features
rphmeier Jan 30, 2018
d85fec6
clean up workspaces a little
rphmeier Jan 30, 2018
0035e51
fully refactor runtime-std to use conditional compilation
rphmeier Jan 30, 2018
2678266
Merge branch 'master' into author-relay-block
rphmeier Jan 31, 2018
6f6be64
allow polkadot-primitives to compile on nightly
rphmeier Jan 31, 2018
7a1ae23
fix compiler warning
rphmeier Jan 31, 2018
83d5fb4
extract out all primitives
rphmeier Feb 1, 2018
dc81048
refactor codec
rphmeier Feb 1, 2018
8d41279
reintroduce slicable to primitives
rphmeier Feb 5, 2018
ff79e43
integrate new primitives with native-runtime
rphmeier Feb 5, 2018
d6718d9
fix most issues with compiling on WASM
rphmeier Feb 6, 2018
4e9683a
fix compilation for native
rphmeier Feb 6, 2018
014fc55
update native executor tests to use new tx format
rphmeier Feb 6, 2018
6fddf84
get compiling on wasm
rphmeier Feb 6, 2018
d16c9ed
fix tests
rphmeier Feb 6, 2018
e75e8a8
initial merge
rphmeier Feb 6, 2018
6d36db7
fix tests after merge
rphmeier Feb 6, 2018
fe2175b
unclobber function changes
rphmeier Feb 6, 2018
9a76246
fix tests and review grumbles
rphmeier Feb 6, 2018
1676404
move function and proposal types to transaction module
rphmeier Feb 6, 2018
bbbe6ae
remove debug impl in runtime-std
rphmeier Feb 6, 2018
15147c7
merge duty roster changes
rphmeier Feb 6, 2018
4b6006f
combine relay chain primitives into one module
rphmeier Feb 6, 2018
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
902 changes: 508 additions & 394 deletions Cargo.lock

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ members = [
"collator",
"environmental",
"executor",
"native-runtime",
"network",
"primitives",
"rpc-servers",
"rpc",
"rpc_servers",
"native-runtime",
"runtime-codec",
"runtime-std",
"serializer",
"state_machine",
"state-machine",
"validator",
"network",
]
exclude = [
"wasm-runtime"
Expand Down
2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ log = "0.3"
polkadot-client = { path = "../client", version = "0.1" }
polkadot-executor = { path = "../executor", version = "0.1" }
polkadot-primitives = { path = "../primitives", version = "0.1" }
polkadot-rpc-servers = { path = "../rpc_servers", version = "0.1" }
polkadot-rpc-servers = { path = "../rpc-servers", version = "0.1" }
4 changes: 3 additions & 1 deletion client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ error-chain = "0.11"
log = "0.3"
parking_lot = "0.4"
polkadot-primitives = { path = "../primitives", version = "0.1" }
polkadot-state-machine = { path = "../state_machine", version = "0.1" }
polkadot-state-machine = { path = "../state-machine", version = "0.1" }
polkadot-serializer = { path = "../serializer" }
polkadot-executor = { path = "../executor" }
polkadot-runtime-codec = { path = "../runtime-codec", version = "0.1" }
native-runtime = { path = "../native-runtime" }
triehash = "0.1"
hex-literal = "0.1"
ed25519 = { path = "../ed25519", version = "0.1" }
2 changes: 1 addition & 1 deletion client/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

use state_machine;
use error;
use primitives::block;
use primitives::relay::block;
use blockchain::{self, BlockId};

/// Block insertion transction. Keeps hold if the inseted block state and data.
Expand Down
2 changes: 1 addition & 1 deletion client/src/blockchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
//! Polkadot blockchain trait

use std::fmt::{Display, Formatter, Error as FmtError};
use primitives::block;
use primitives::relay::block;
use error::Result;

/// Block indentification.
Expand Down
41 changes: 21 additions & 20 deletions client/src/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@
//! Tool for creating the genesis block.

use std::collections::HashMap;
use native_runtime::primitives::{Block, Header};
use primitives::relay::{Block, Header};
use triehash::trie_root;

/// Create a genesis block, given the initial storage.
pub fn construct_genesis_block(storage: &HashMap<Vec<u8>, Vec<u8>>) -> Block {
let state_root = trie_root(storage.clone().into_iter()).0;
let state_root = trie_root(storage.clone().into_iter()).0.into();
let header = Header {
parent_hash: Default::default(),
number: 0,
state_root,
transaction_root: trie_root(vec![].into_iter()).0,
transaction_root: trie_root(vec![].into_iter()).0.into(),
digest: Default::default(),
};
Block {
Expand All @@ -39,19 +39,19 @@ pub fn construct_genesis_block(storage: &HashMap<Vec<u8>, Vec<u8>>) -> Block {
#[cfg(test)]
mod tests {
use super::*;
use native_runtime::codec::{Slicable, Joiner};
use codec::{Slicable, Joiner};
use native_runtime::support::{one, two, Hashable};
use native_runtime::runtime::genesismap::{GenesisConfig, additional_storage_with_genesis};
use native_runtime::primitives::{AccountID, Hash, BlockNumber, Transaction,
UncheckedTransaction, Digest, Function};
use state_machine::execute;
use state_machine::OverlayedChanges;
use state_machine::backend::InMemory;
use polkadot_executor::executor;
use primitives::{AccountId, Hash};
use primitives::relay::{BlockNumber, Header, Digest, UncheckedTransaction, Transaction, Function};
use primitives::contract::CallData;
use primitives::ed25519::Pair;
use ed25519::Pair;

fn secret_for(who: &AccountID) -> Option<Pair> {
fn secret_for(who: &AccountId) -> Option<Pair> {
match who {
x if *x == one() => Some(Pair::from_seed(b"12345678901234567890123456789012")),
x if *x == two() => Some("9d61b19deffd5a60ba844af492ec2cc44449c5697b326919703bac031cae7f60".into()),
Expand All @@ -64,12 +64,12 @@ mod tests {

let transactions = txs.into_iter().map(|transaction| {
let signature = secret_for(&transaction.signed).unwrap()
.sign(&transaction.to_vec())
.inner();
.sign(&transaction.to_vec());

UncheckedTransaction { transaction, signature }
}).collect::<Vec<_>>();

let transaction_root = ordered_trie_root(transactions.iter().map(Slicable::to_vec)).0;
let transaction_root = ordered_trie_root(transactions.iter().map(Slicable::to_vec)).0.into();

let mut header = Header {
parent_hash,
Expand All @@ -83,37 +83,38 @@ mod tests {
let mut overlay = OverlayedChanges::default();

for tx in transactions.iter() {
header = Header::from_slice(&execute(
let ret_data = execute(
backend,
&mut overlay,
&executor(),
"execute_transaction",
&CallData(vec![].join(&header).join(tx))
).unwrap()).unwrap();
).unwrap();
header = Header::from_slice(&mut &ret_data[..]).unwrap();
}

header = Header::from_slice(&execute(
let ret_data = execute(
backend,
&mut overlay,
&executor(),
"finalise_block",
&CallData(vec![].join(&header))
).unwrap()).unwrap();
).unwrap();
header = Header::from_slice(&mut &ret_data[..]).unwrap();

(vec![].join(&Block { header, transactions }), hash)
(vec![].join(&Block { header, transactions }), hash.into())
}

fn block1(genesis_hash: Hash, backend: &InMemory) -> (Vec<u8>, Hash) {
construct_block(
backend,
1,
genesis_hash,
hex!("25e5b37074063ab75c889326246640729b40d0c86932edc527bc80db0e04fe5c"),
hex!("25e5b37074063ab75c889326246640729b40d0c86932edc527bc80db0e04fe5c").into(),
vec![Transaction {
signed: one(),
nonce: 0,
function: Function::StakingTransfer,
input_data: vec![].join(&two()).join(&69u64),
function: Function::StakingTransfer(two(), 69),
}]
)
}
Expand All @@ -124,7 +125,7 @@ mod tests {
vec![one(), two()], 1000
).genesis_map();
let block = construct_genesis_block(&storage);
let genesis_hash = block.header.blake2_256();
let genesis_hash = block.header.blake2_256().into();
storage.extend(additional_storage_with_genesis(&block).into_iter());

let mut overlay = OverlayedChanges::default();
Expand Down
6 changes: 3 additions & 3 deletions client/src/in_mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ use error;
use backend;
use primitives;
use ser;
use primitives::block::{self, HeaderHash};
use primitives::relay::block::{self, HeaderHash};
use blockchain::{self, BlockId, BlockStatus};

fn header_hash(header: &primitives::block::Header) -> primitives::block::HeaderHash {
primitives::hash(&ser::to_vec(header))
fn header_hash(header: &block::Header) -> block::HeaderHash {
primitives::hashing::blake2_256(&ser::to_vec(header)).into()
}

struct PendingBlock {
Expand Down
13 changes: 9 additions & 4 deletions client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,19 @@
extern crate polkadot_primitives as primitives;
extern crate polkadot_state_machine as state_machine;
extern crate polkadot_serializer as ser;
extern crate polkadot_runtime_codec as codec;
extern crate polkadot_executor;
extern crate native_runtime;
extern crate ed25519;

extern crate triehash;
extern crate parking_lot;
#[macro_use] extern crate error_chain;
#[macro_use] extern crate log;
#[macro_use] extern crate hex_literal;

#[cfg(test)]
#[macro_use]
extern crate hex_literal;

pub mod error;
pub mod blockchain;
Expand All @@ -42,7 +47,7 @@ pub use genesis::construct_genesis_block;
pub use blockchain::Info as ChainInfo;
pub use blockchain::BlockId;

use primitives::{block};
use primitives::relay::block;
use primitives::contract::{CallData, StorageKey, StorageData};

use blockchain::Backend as BlockchainBackend;
Expand Down Expand Up @@ -123,8 +128,8 @@ impl<B, E> Client<B, E> where
parent_hash: Default::default(),
number: 0,
state_root: Default::default(),
parachain_activity: Default::default(),
logs: Default::default(),
transaction_root: Default::default(),
digest: Default::default(),
};

let mut tx = backend.begin_transaction(BlockId::Hash(block::HeaderHash::default()))?;
Expand Down
10 changes: 10 additions & 0 deletions ed25519/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "ed25519"
version = "0.1.0"
authors = ["Parity Technologies <[email protected]>"]

[dependencies]
ring = "0.12"
untrusted = "0.5"
polkadot-primitives = { version = "0.1", path = "../primitives" }
rustc-hex = "1.0"
Loading