diff --git a/substrate/Cargo.lock b/substrate/Cargo.lock index a7047446eb..6d5f20ecdf 100644 --- a/substrate/Cargo.lock +++ b/substrate/Cargo.lock @@ -558,7 +558,7 @@ dependencies = [ name = "native-runtime" version = "0.1.0" dependencies = [ - "runtime-support 0.1.0", + "runtime-std 0.1.0", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -737,7 +737,7 @@ dependencies = [ "polkadot-primitives 0.1.0", "polkadot-serializer 0.1.0", "polkadot-state-machine 0.1.0", - "runtime-support 0.1.0", + "runtime-std 0.1.0", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)", @@ -921,7 +921,7 @@ dependencies = [ ] [[package]] -name = "runtime-support" +name = "runtime-std" version = "0.1.0" dependencies = [ "environmental 0.1.0", diff --git a/substrate/executor/Cargo.toml b/substrate/executor/Cargo.toml index 6164bb1c51..498482c03f 100644 --- a/substrate/executor/Cargo.toml +++ b/substrate/executor/Cargo.toml @@ -14,7 +14,7 @@ parity-wasm = "0.15.0" byteorder = "1.1" rustc-hex = "1.0.0" native-runtime = { path = "../native-runtime", version = "0.1" } -runtime-support = { path = "../native-runtime/support", version = "0.1" } +runtime-std = { path = "../native-runtime/std", version = "0.1" } memcmp = { version = "0.0.6" } [dev-dependencies] diff --git a/substrate/executor/src/lib.rs b/substrate/executor/src/lib.rs index 9bea6958de..cfb0506352 100644 --- a/substrate/executor/src/lib.rs +++ b/substrate/executor/src/lib.rs @@ -35,7 +35,7 @@ extern crate parity_wasm; extern crate byteorder; extern crate rustc_hex; extern crate native_runtime; -extern crate runtime_support; +extern crate runtime_std; extern crate memcmp; #[macro_use] diff --git a/substrate/executor/src/native_executor.rs b/substrate/executor/src/native_executor.rs index 2f050f77b7..0925762f74 100644 --- a/substrate/executor/src/native_executor.rs +++ b/substrate/executor/src/native_executor.rs @@ -4,7 +4,7 @@ use state_machine::{Externalities, CodeExecutor}; use error::{Error, ErrorKind, Result}; use wasm_executor::WasmExecutor; use native_runtime as runtime; -use runtime_support; +use runtime_std; pub struct NativeExecutor; @@ -22,7 +22,7 @@ impl CodeExecutor for NativeExecutor { // get a proper build script, this must be strictly adhered to or things will go wrong. let native_equivalent = include_bytes!("../../wasm-runtime/target/wasm32-unknown-unknown/release/runtime_polkadot.compact.wasm"); if code == &native_equivalent[..] { - runtime_support::with_externalities(ext, || match method { + runtime_std::with_externalities(ext, || match method { "execute_block" => catch_unwind(|| runtime::execute_block(&data.0)).map_err(|_| ErrorKind::Runtime.into()), "execute_transaction" => catch_unwind(|| runtime::execute_transaction(&data.0)).map_err(|_| ErrorKind::Runtime.into()), _ => Err(ErrorKind::MethodNotFound(method.to_owned()).into()), @@ -37,11 +37,10 @@ impl CodeExecutor for NativeExecutor { #[cfg(test)] mod tests { use super::*; - use primitives::twox_128; - use native_runtime::testing::{TestExternalities, one, two}; - use native_runtime::statichex::StaticHexInto; - use native_runtime::keyedvec::KeyedVec; + use native_runtime::codec::KeyedVec; + use native_runtime::support::{TestExternalities, one, two, StaticHexInto}; use native_runtime::runtime::staking::balance; + use primitives::twox_128; fn tx() -> Vec { "679fcf0a846b4224c84ecad7d91a26241c46d00cb53d6480a363274e8965ee34b0b80b4b2e3836d3d8f8f12c0c1aef7350af587d9aee3883561d11726068ac0a2f8c6129d816cf51c374bc7f08c3e63ed156cf78aefb4a6550d97b87997977ee00000000000000000228000000d75a980182b10ab7d54bfed3c964073a0ee172f3daa62325af021a68f707511a4500000000000000".convert() } @@ -82,7 +81,7 @@ mod tests { let r = NativeExecutor.call(&mut t, &native_equivalent_code[..], "execute_transaction", &CallData(tx())); assert!(r.is_ok()); - runtime_support::with_externalities(&mut t, || { + runtime_std::with_externalities(&mut t, || { assert_eq!(balance(&one), 42); assert_eq!(balance(&two), 69); }); @@ -101,7 +100,7 @@ mod tests { let r = NativeExecutor.call(&mut t, &foreign_code[..], "execute_transaction", &CallData(tx())); assert!(r.is_ok()); - runtime_support::with_externalities(&mut t, || { + runtime_std::with_externalities(&mut t, || { assert_eq!(balance(&one), 42); assert_eq!(balance(&two), 69); }); diff --git a/substrate/executor/src/wasm_executor.rs b/substrate/executor/src/wasm_executor.rs index 8a70271c1a..c184abab89 100644 --- a/substrate/executor/src/wasm_executor.rs +++ b/substrate/executor/src/wasm_executor.rs @@ -274,8 +274,11 @@ mod tests { use super::*; use rustc_hex::FromHex; - use native_runtime::testing::TestExternalities; - use primitives::hashing::blake2_256; + use primitives::{blake2_256, twox_128}; + use runtime_std; + use native_runtime::support::{one, two, StaticHexInto, TestExternalities}; + use native_runtime::codec::KeyedVec; + use native_runtime::runtime::staking::balance; #[test] fn returning_should_work() { @@ -373,13 +376,6 @@ mod tests { ); } - use primitives::twox_128; - use native_runtime::testing::{one, two}; - use native_runtime::statichex::StaticHexInto; - use native_runtime::keyedvec::KeyedVec; - use native_runtime::runtime::staking::balance; - use runtime_support; - fn tx() -> Vec { "679fcf0a846b4224c84ecad7d91a26241c46d00cb53d6480a363274e8965ee34b0b80b4b2e3836d3d8f8f12c0c1aef7350af587d9aee3883561d11726068ac0a2f8c6129d816cf51c374bc7f08c3e63ed156cf78aefb4a6550d97b87997977ee00000000000000000228000000d75a980182b10ab7d54bfed3c964073a0ee172f3daa62325af021a68f707511a4500000000000000".convert() } #[test] @@ -407,7 +403,7 @@ mod tests { let r = WasmExecutor.call(&mut t, &foreign_code[..], "execute_transaction", &CallData(tx())); assert!(r.is_ok()); - runtime_support::with_externalities(&mut t, || { + runtime_std::with_externalities(&mut t, || { assert_eq!(balance(&one), 42); assert_eq!(balance(&two), 69); }); diff --git a/substrate/native-runtime/Cargo.toml b/substrate/native-runtime/Cargo.toml index eb5eb82408..25091c2cef 100644 --- a/substrate/native-runtime/Cargo.toml +++ b/substrate/native-runtime/Cargo.toml @@ -9,5 +9,5 @@ with-std = [] without-std = [] [dependencies] -runtime-support = { path = "./support", version = "0.1" } +runtime-std = { path = "./std", version = "0.1" } rustc-hex = "1.0" diff --git a/substrate/native-runtime/support/Cargo.toml b/substrate/native-runtime/std/Cargo.toml similarity index 93% rename from substrate/native-runtime/support/Cargo.toml rename to substrate/native-runtime/std/Cargo.toml index 1c24c014e6..0976e4b378 100644 --- a/substrate/native-runtime/support/Cargo.toml +++ b/substrate/native-runtime/std/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "runtime-support" +name = "runtime-std" version = "0.1.0" authors = ["Parity Technologies "] diff --git a/substrate/native-runtime/support/src/lib.rs b/substrate/native-runtime/std/src/lib.rs similarity index 100% rename from substrate/native-runtime/support/src/lib.rs rename to substrate/native-runtime/std/src/lib.rs diff --git a/substrate/wasm-runtime/Cargo.lock b/substrate/wasm-runtime/Cargo.lock index d134139a3c..15ccc67c64 100644 --- a/substrate/wasm-runtime/Cargo.lock +++ b/substrate/wasm-runtime/Cargo.lock @@ -13,11 +13,11 @@ version = "0.1.0" name = "runtime-polkadot" version = "0.1.0" dependencies = [ - "runtime-support 0.1.0", + "runtime-std 0.1.0", ] [[package]] -name = "runtime-support" +name = "runtime-std" version = "0.1.0" dependencies = [ "pwasm-alloc 0.1.0", @@ -28,6 +28,6 @@ dependencies = [ name = "runtime-test" version = "0.1.0" dependencies = [ - "runtime-support 0.1.0", + "runtime-std 0.1.0", ] diff --git a/substrate/wasm-runtime/build.sh b/substrate/wasm-runtime/build.sh index c3030f99d3..2c78bc67c7 100755 --- a/substrate/wasm-runtime/build.sh +++ b/substrate/wasm-runtime/build.sh @@ -1,7 +1,7 @@ #!/bin/sh cargo +nightly build --target=wasm32-unknown-unknown --release -dirs=`find * -maxdepth 0 -type d | grep -v pwasm- | grep -v support` +dirs=`find * -maxdepth 0 -type d | grep -v pwasm- | grep -v std` for i in $dirs do if [[ -e $i/Cargo.toml ]] diff --git a/substrate/wasm-runtime/polkadot/Cargo.toml b/substrate/wasm-runtime/polkadot/Cargo.toml index ce2d9909a7..669ccac6fa 100644 --- a/substrate/wasm-runtime/polkadot/Cargo.toml +++ b/substrate/wasm-runtime/polkadot/Cargo.toml @@ -7,7 +7,7 @@ authors = ["Parity Technologies "] crate-type = ["cdylib"] [dependencies] -runtime-support = { path = "../support", version = "0.1" } +runtime-std = { path = "../std", version = "0.1" } [features] default = ["without-std"] diff --git a/substrate/wasm-runtime/polkadot/src/codec/joiner.rs b/substrate/wasm-runtime/polkadot/src/codec/joiner.rs index 7fdb1e1645..a7a9f618eb 100644 --- a/substrate/wasm-runtime/polkadot/src/codec/joiner.rs +++ b/substrate/wasm-runtime/polkadot/src/codec/joiner.rs @@ -16,8 +16,8 @@ //! Vec serialiser. -use runtime_support::prelude::*; -use slicable::Slicable; +use runtime_std::prelude::*; +use super::slicable::Slicable; /// Trait to allow itself to be serialised into a `Vec` pub trait Joiner { diff --git a/substrate/wasm-runtime/polkadot/src/codec/keyedvec.rs b/substrate/wasm-runtime/polkadot/src/codec/keyedvec.rs index 210606ab7c..2c55cb5648 100644 --- a/substrate/wasm-runtime/polkadot/src/codec/keyedvec.rs +++ b/substrate/wasm-runtime/polkadot/src/codec/keyedvec.rs @@ -16,8 +16,8 @@ //! Serialiser and prepender. -use runtime_support::prelude::*; -use slicable::Slicable; +use runtime_std::prelude::*; +use super::slicable::Slicable; /// Trait to allow itselg to be serialised and prepended by a given slice. pub trait KeyedVec { diff --git a/substrate/wasm-runtime/polkadot/src/codec/mod.rs b/substrate/wasm-runtime/polkadot/src/codec/mod.rs index 7d9bc90c4f..94afc574c1 100644 --- a/substrate/wasm-runtime/polkadot/src/codec/mod.rs +++ b/substrate/wasm-runtime/polkadot/src/codec/mod.rs @@ -16,8 +16,14 @@ //! Codec utils. -pub mod endiansensitive; -pub mod streamreader; -pub mod joiner; -pub mod slicable; -pub mod keyedvec; +mod endiansensitive; +mod slicable; +mod streamreader; +mod joiner; +mod keyedvec; + +pub use self::endiansensitive::EndianSensitive; +pub use self::slicable::{Slicable, NonTrivialSlicable}; +pub use self::streamreader::StreamReader; +pub use self::joiner::Joiner; +pub use self::keyedvec::KeyedVec; diff --git a/substrate/wasm-runtime/polkadot/src/codec/slicable.rs b/substrate/wasm-runtime/polkadot/src/codec/slicable.rs index c702741ee3..3ac3d880e4 100644 --- a/substrate/wasm-runtime/polkadot/src/codec/slicable.rs +++ b/substrate/wasm-runtime/polkadot/src/codec/slicable.rs @@ -16,10 +16,10 @@ //! Serialisation. -use runtime_support::prelude::*; -use runtime_support::{mem, slice}; -use joiner::Joiner; -use endiansensitive::EndianSensitive; +use runtime_std::prelude::*; +use runtime_std::{mem, slice}; +use super::joiner::Joiner; +use super::endiansensitive::EndianSensitive; /// Trait that allows zero-copy read/write of value-references to/from slices in LE format. pub trait Slicable: Sized { diff --git a/substrate/wasm-runtime/polkadot/src/codec/streamreader.rs b/substrate/wasm-runtime/polkadot/src/codec/streamreader.rs index 33056a5ac3..b745f8afd9 100644 --- a/substrate/wasm-runtime/polkadot/src/codec/streamreader.rs +++ b/substrate/wasm-runtime/polkadot/src/codec/streamreader.rs @@ -16,7 +16,7 @@ //! Deserialiser. -use slicable::Slicable; +use super::slicable::Slicable; /// Simple deserialiser. pub struct StreamReader<'a> { diff --git a/substrate/wasm-runtime/polkadot/src/lib.rs b/substrate/wasm-runtime/polkadot/src/lib.rs index 9389145843..43830a05b0 100644 --- a/substrate/wasm-runtime/polkadot/src/lib.rs +++ b/substrate/wasm-runtime/polkadot/src/lib.rs @@ -20,23 +20,19 @@ #![cfg_attr(feature = "strict", deny(warnings))] #[macro_use] -extern crate runtime_support; +extern crate runtime_std; #[cfg(feature = "with-std")] extern crate rustc_hex; -mod codec; +pub mod codec; #[macro_use] -mod support; +pub mod support; pub mod primitives; pub mod runtime; -pub use codec::{endiansensitive, streamreader, joiner, slicable, keyedvec}; -pub use support::{environment, storable, hashable}; -#[cfg(feature = "with-std")] -pub use support::{testing, statichex}; -use runtime_support::prelude::*; -use slicable::Slicable; +use runtime_std::prelude::*; +use codec::Slicable; use primitives::{Block, UncheckedTransaction}; /// Execute a block, with `input` being the canonical serialisation of the block. Returns the diff --git a/substrate/wasm-runtime/polkadot/src/primitives/block.rs b/substrate/wasm-runtime/polkadot/src/primitives/block.rs index 2975286479..d33b51609c 100644 --- a/substrate/wasm-runtime/polkadot/src/primitives/block.rs +++ b/substrate/wasm-runtime/polkadot/src/primitives/block.rs @@ -16,10 +16,8 @@ //! Block type. -use runtime_support::prelude::*; -use streamreader::StreamReader; -use joiner::Joiner; -use slicable::{Slicable, NonTrivialSlicable}; +use runtime_std::prelude::*; +use codec::{StreamReader, Joiner, Slicable, NonTrivialSlicable}; use primitives::{Header, UncheckedTransaction}; /// A Polkadot relay chain block. diff --git a/substrate/wasm-runtime/polkadot/src/primitives/digest.rs b/substrate/wasm-runtime/polkadot/src/primitives/digest.rs index b51bc8df54..18107460b0 100644 --- a/substrate/wasm-runtime/polkadot/src/primitives/digest.rs +++ b/substrate/wasm-runtime/polkadot/src/primitives/digest.rs @@ -16,7 +16,7 @@ //! Digest type. -use runtime_support::prelude::*; +use runtime_std::prelude::*; #[derive(Clone, Default)] #[cfg_attr(feature = "with-std", derive(PartialEq, Debug))] diff --git a/substrate/wasm-runtime/polkadot/src/primitives/function.rs b/substrate/wasm-runtime/polkadot/src/primitives/function.rs index 875bb98326..112c6e8b80 100644 --- a/substrate/wasm-runtime/polkadot/src/primitives/function.rs +++ b/substrate/wasm-runtime/polkadot/src/primitives/function.rs @@ -17,7 +17,7 @@ //! Function data: This describes a function that can be called from an external transaction. use primitives::AccountID; -use streamreader::StreamReader; +use codec::StreamReader; use runtime::{staking, session, timestamp, governance}; /// Public functions that can be dispatched to. diff --git a/substrate/wasm-runtime/polkadot/src/primitives/header.rs b/substrate/wasm-runtime/polkadot/src/primitives/header.rs index 76f3c012d1..c97d5ebf29 100644 --- a/substrate/wasm-runtime/polkadot/src/primitives/header.rs +++ b/substrate/wasm-runtime/polkadot/src/primitives/header.rs @@ -16,11 +16,9 @@ //! Block header type. -use runtime_support::prelude::*; -use streamreader::StreamReader; -use joiner::Joiner; -use slicable::{Slicable, NonTrivialSlicable}; -use runtime_support::mem; +use runtime_std::prelude::*; +use codec::{StreamReader, Joiner, Slicable, NonTrivialSlicable}; +use runtime_std::mem; use primitives::{BlockNumber, Hash, Digest}; #[derive(Clone)] diff --git a/substrate/wasm-runtime/polkadot/src/primitives/proposal.rs b/substrate/wasm-runtime/polkadot/src/primitives/proposal.rs index 663692a4f7..a4a2a3106b 100644 --- a/substrate/wasm-runtime/polkadot/src/primitives/proposal.rs +++ b/substrate/wasm-runtime/polkadot/src/primitives/proposal.rs @@ -17,11 +17,9 @@ //! Proposal: This describes a combination of a function ID and data that can be used to call into //! an internal function. -use runtime_support::prelude::*; -use runtime_support::mem; -use slicable::Slicable; -use joiner::Joiner; -use streamreader::StreamReader; +use runtime_std::prelude::*; +use runtime_std::mem; +use codec::{Slicable, Joiner, StreamReader}; use runtime::{system, governance, staking, session}; /// Internal functions that can be dispatched to. diff --git a/substrate/wasm-runtime/polkadot/src/primitives/tests.rs b/substrate/wasm-runtime/polkadot/src/primitives/tests.rs index 76412c10b9..fdb600a5bb 100644 --- a/substrate/wasm-runtime/polkadot/src/primitives/tests.rs +++ b/substrate/wasm-runtime/polkadot/src/primitives/tests.rs @@ -17,10 +17,9 @@ //! Tests. use super::*; -use runtime_support::prelude::*; -use joiner::Joiner; -use slicable::{Slicable, NonTrivialSlicable}; -use function::Function; +use runtime_std::prelude::*; +use codec::{Joiner, Slicable}; +use primitives::Function; #[test] fn serialise_transaction_works() { diff --git a/substrate/wasm-runtime/polkadot/src/primitives/transaction.rs b/substrate/wasm-runtime/polkadot/src/primitives/transaction.rs index 96dba4e6fb..9c72e31d34 100644 --- a/substrate/wasm-runtime/polkadot/src/primitives/transaction.rs +++ b/substrate/wasm-runtime/polkadot/src/primitives/transaction.rs @@ -16,12 +16,10 @@ //! Transaction type. -use runtime_support::prelude::*; -use streamreader::StreamReader; -use joiner::Joiner; -use slicable::{Slicable, NonTrivialSlicable}; +use runtime_std::prelude::*; +use codec::{StreamReader, Joiner, Slicable, NonTrivialSlicable}; use primitives::{AccountID, TxOrder, Function}; -use runtime_support::mem; +use runtime_std::mem; /// A vetted and verified transaction from the external world. #[cfg_attr(feature = "with-std", derive(PartialEq, Debug))] diff --git a/substrate/wasm-runtime/polkadot/src/primitives/uncheckedtransaction.rs b/substrate/wasm-runtime/polkadot/src/primitives/uncheckedtransaction.rs index bf3669ec95..ec14befb55 100644 --- a/substrate/wasm-runtime/polkadot/src/primitives/uncheckedtransaction.rs +++ b/substrate/wasm-runtime/polkadot/src/primitives/uncheckedtransaction.rs @@ -16,12 +16,10 @@ //! Unchecked Transaction type. -use slicable::{Slicable, NonTrivialSlicable}; -use streamreader::StreamReader; -use joiner::Joiner; +use runtime_std::{mem, ed25519_verify}; +use runtime_std::prelude::*; +use codec::{Slicable, NonTrivialSlicable, StreamReader, Joiner}; use primitives::Transaction; -use runtime_support::{mem, ed25519_verify}; -use runtime_support::prelude::*; #[cfg(feature = "with-std")] use std::fmt; diff --git a/substrate/wasm-runtime/polkadot/src/runtime/consensus.rs b/substrate/wasm-runtime/polkadot/src/runtime/consensus.rs index 689fdca21e..7d7a0f5ec5 100644 --- a/substrate/wasm-runtime/polkadot/src/runtime/consensus.rs +++ b/substrate/wasm-runtime/polkadot/src/runtime/consensus.rs @@ -16,8 +16,8 @@ //! Conensus module for runtime; manages the authority set ready for the native code. -use runtime_support::prelude::*; -use storable::StorageVec; +use runtime_std::prelude::*; +use support::StorageVec; use primitives::SessionKey; struct AuthorityStorageVec {} diff --git a/substrate/wasm-runtime/polkadot/src/runtime/governance.rs b/substrate/wasm-runtime/polkadot/src/runtime/governance.rs index 307e4bfa00..85a24196bb 100644 --- a/substrate/wasm-runtime/polkadot/src/runtime/governance.rs +++ b/substrate/wasm-runtime/polkadot/src/runtime/governance.rs @@ -25,9 +25,9 @@ //! At the end of the era, all validators approvals are tallied and if there are sufficient to pass //! the proposal then it is enacted. All items in storage concerning the proposal are reset. -use runtime_support::prelude::*; -use keyedvec::KeyedVec; -use storable::{Storable, StorageVec, kill}; +use runtime_std::prelude::*; +use codec::KeyedVec; +use support::{Storable, StorageVec, kill}; use primitives::{AccountID, Hash, BlockNumber, Proposal}; use runtime::{staking, system, session}; @@ -105,7 +105,7 @@ pub fn end_of_an_era() { #[cfg(test)] mod tests { use super::*; - use runtime_support::{with_externalities, twox_128}; + use runtime_std::{with_externalities, twox_128}; use keyedvec::KeyedVec; use joiner::Joiner; use testing::{one, two, TestExternalities}; diff --git a/substrate/wasm-runtime/polkadot/src/runtime/session.rs b/substrate/wasm-runtime/polkadot/src/runtime/session.rs index fdce6e167e..d6dc1e3764 100644 --- a/substrate/wasm-runtime/polkadot/src/runtime/session.rs +++ b/substrate/wasm-runtime/polkadot/src/runtime/session.rs @@ -17,9 +17,9 @@ //! Session manager: is told the validators and allows them to manage their session keys for the //! consensus module. -use runtime_support::prelude::*; -use keyedvec::KeyedVec; -use storable::{kill, Storable, StorageVec}; +use runtime_std::prelude::*; +use codec::KeyedVec; +use support::{kill, Storable, StorageVec}; use primitives::{AccountID, SessionKey, BlockNumber}; use runtime::{system, staking, consensus}; @@ -118,7 +118,7 @@ fn rotate_session() { #[cfg(test)] mod tests { - use runtime_support::{with_externalities, twox_128}; + use runtime_std::{with_externalities, twox_128}; use keyedvec::KeyedVec; use joiner::Joiner; use testing::{one, two, TestExternalities}; diff --git a/substrate/wasm-runtime/polkadot/src/runtime/staking.rs b/substrate/wasm-runtime/polkadot/src/runtime/staking.rs index d9755b55a6..b87d26c360 100644 --- a/substrate/wasm-runtime/polkadot/src/runtime/staking.rs +++ b/substrate/wasm-runtime/polkadot/src/runtime/staking.rs @@ -16,10 +16,10 @@ //! Staking manager: Handles balances and periodically determines the best set of validators. -use runtime_support::prelude::*; -use runtime_support::cell::RefCell; -use keyedvec::KeyedVec; -use storable::{Storable, StorageVec}; +use runtime_std::prelude::*; +use runtime_std::cell::RefCell; +use codec::KeyedVec; +use support::{Storable, StorageVec}; use primitives::{BlockNumber, AccountID}; use runtime::{system, session, governance}; @@ -190,7 +190,7 @@ fn new_era() { #[cfg(test)] mod tests { - use runtime_support::{with_externalities, twox_128}; + use runtime_std::{with_externalities, twox_128}; use keyedvec::KeyedVec; use joiner::Joiner; use testing::{one, two, TestExternalities}; diff --git a/substrate/wasm-runtime/polkadot/src/runtime/system.rs b/substrate/wasm-runtime/polkadot/src/runtime/system.rs index e37cc3cb32..d6236beb78 100644 --- a/substrate/wasm-runtime/polkadot/src/runtime/system.rs +++ b/substrate/wasm-runtime/polkadot/src/runtime/system.rs @@ -17,14 +17,11 @@ //! System manager: Handles all of the top-level stuff; executing block/transaction, setting code //! and depositing logs. +use runtime_std::prelude::*; +use runtime_std::{mem, print}; +use codec::KeyedVec; +use support::{Hashable, Storable, with_env}; use primitives::{Block, BlockNumber, Hash, UncheckedTransaction, TxOrder}; -use runtime_support::mem; -use runtime_support::prelude::*; -use runtime_support::print; -use hashable::Hashable; -use storable::Storable; -use keyedvec::KeyedVec; -use environment::with_env; use runtime::{staking, session}; /// The current block number being processed. Set by `execute_block`. @@ -120,7 +117,7 @@ mod tests { use function::Function; use keyedvec::KeyedVec; use slicable::Slicable; - use runtime_support::{with_externalities, twox_128}; + use runtime_std::{with_externalities, twox_128}; use primitives::{UncheckedTransaction, Transaction}; use statichex::StaticHexInto; use runtime::{system, staking}; diff --git a/substrate/wasm-runtime/polkadot/src/runtime/timestamp.rs b/substrate/wasm-runtime/polkadot/src/runtime/timestamp.rs index 7040473b1a..09fb36a606 100644 --- a/substrate/wasm-runtime/polkadot/src/runtime/timestamp.rs +++ b/substrate/wasm-runtime/polkadot/src/runtime/timestamp.rs @@ -16,7 +16,7 @@ //! Timestamp manager: just handles the current timestamp. -use storable::Storable; +use support::Storable; /// Representation of a time. pub type Timestamp = u64; @@ -35,7 +35,7 @@ pub fn set(now: Timestamp) { mod tests { use joiner::Joiner; use keyedvec::KeyedVec; - use runtime_support::{with_externalities, twox_128}; + use runtime_std::{with_externalities, twox_128}; use runtime::timestamp; use testing::TestExternalities; diff --git a/substrate/wasm-runtime/polkadot/src/support/environment.rs b/substrate/wasm-runtime/polkadot/src/support/environment.rs index 1011b3168b..7670a4801f 100644 --- a/substrate/wasm-runtime/polkadot/src/support/environment.rs +++ b/substrate/wasm-runtime/polkadot/src/support/environment.rs @@ -16,10 +16,10 @@ //! Environment API: Allows certain information to be accessed throughout the runtime. -use runtime_support::boxed::Box; -use runtime_support::mem; -use runtime_support::cell::RefCell; -use runtime_support::rc::Rc; +use runtime_std::boxed::Box; +use runtime_std::mem; +use runtime_std::cell::RefCell; +use runtime_std::rc::Rc; use primitives::{BlockNumber, Digest}; diff --git a/substrate/wasm-runtime/polkadot/src/support/hashable.rs b/substrate/wasm-runtime/polkadot/src/support/hashable.rs index 31c133c3c3..66c3844fda 100644 --- a/substrate/wasm-runtime/polkadot/src/support/hashable.rs +++ b/substrate/wasm-runtime/polkadot/src/support/hashable.rs @@ -16,8 +16,8 @@ //! Hashable trait. -use slicable::Slicable; -use runtime_support::{blake2_256, twox_128, twox_256}; +use codec::Slicable; +use runtime_std::{blake2_256, twox_128, twox_256}; pub trait Hashable: Sized { fn blake2_256(&self) -> [u8; 32]; diff --git a/substrate/wasm-runtime/polkadot/src/support/mod.rs b/substrate/wasm-runtime/polkadot/src/support/mod.rs index c2e034c527..854a8f9f01 100644 --- a/substrate/wasm-runtime/polkadot/src/support/mod.rs +++ b/substrate/wasm-runtime/polkadot/src/support/mod.rs @@ -16,12 +16,19 @@ //! Support code for the runtime. -pub mod environment; -pub mod storable; -pub mod hashable; - +mod environment; +mod storable; +mod hashable; #[cfg(feature = "with-std")] -pub mod statichex; +mod statichex; #[macro_use] #[cfg(feature = "with-std")] -pub mod testing; +mod testing; + +pub use self::environment::{Environment, with_env}; +pub use self::storable::{StorageVec, Storable, kill}; +pub use self::hashable::Hashable; +#[cfg(feature = "with-std")] +pub use self::statichex::{StaticHexConversion, StaticHexInto}; +#[cfg(feature = "with-std")] +pub use self::testing::{AsBytesRef, HexDisplay, TestExternalities, one, two}; diff --git a/substrate/wasm-runtime/polkadot/src/support/storable.rs b/substrate/wasm-runtime/polkadot/src/support/storable.rs index 2af5c83a2d..97f6384c10 100644 --- a/substrate/wasm-runtime/polkadot/src/support/storable.rs +++ b/substrate/wasm-runtime/polkadot/src/support/storable.rs @@ -16,10 +16,9 @@ //! Stuff to do with the runtime's storage. -use slicable::Slicable; -use keyedvec::KeyedVec; -use runtime_support::prelude::*; -use runtime_support::{self, twox_128}; +use runtime_std::prelude::*; +use runtime_std::{self, twox_128}; +use codec::{Slicable, KeyedVec}; /// Trait for a value which may be stored in the storage DB. pub trait Storable { @@ -51,23 +50,23 @@ pub trait Storable { /// Remove `key` from storage. pub fn kill(key: &[u8]) { - runtime_support::set_storage(&twox_128(key)[..], b""); + runtime_std::set_storage(&twox_128(key)[..], b""); } impl Storable for T { fn lookup(key: &[u8]) -> Option { Slicable::set_as_slice(&|out, offset| - runtime_support::read_storage(&twox_128(key)[..], out, offset) >= out.len() + runtime_std::read_storage(&twox_128(key)[..], out, offset) >= out.len() ) } fn store(&self, key: &[u8]) { - self.as_slice_then(|slice| runtime_support::set_storage(&twox_128(key)[..], slice)); + self.as_slice_then(|slice| runtime_std::set_storage(&twox_128(key)[..], slice)); } } impl Storable for [u8] { fn store(&self, key: &[u8]) { - runtime_support::set_storage(&twox_128(key)[..], self) + runtime_std::set_storage(&twox_128(key)[..], self) } } @@ -110,9 +109,9 @@ pub trait StorageVec { mod tests { use super::*; use std::collections::HashMap; - use runtime_support::with_externalities; + use runtime_std::with_externalities; use testing::{TestExternalities, HexDisplay}; - use runtime_support::{storage, twox_128}; + use runtime_std::{storage, twox_128}; #[test] fn integers_can_be_stored() { @@ -153,7 +152,7 @@ mod tests { fn vecs_can_be_retrieved() { let mut t = TestExternalities { storage: HashMap::new(), }; with_externalities(&mut t, || { - runtime_support::set_storage(&twox_128(b":test"), b"\x0b\0\0\0Hello world"); + runtime_std::set_storage(&twox_128(b":test"), b"\x0b\0\0\0Hello world"); let x = b"Hello world".to_vec(); println!("Hex: {}", HexDisplay::from(&storage(&twox_128(b":test")))); let y = >::lookup(b":test").unwrap(); diff --git a/substrate/wasm-runtime/polkadot/src/support/testing.rs b/substrate/wasm-runtime/polkadot/src/support/testing.rs index 63aca0f8ae..e0e1a336c8 100644 --- a/substrate/wasm-runtime/polkadot/src/support/testing.rs +++ b/substrate/wasm-runtime/polkadot/src/support/testing.rs @@ -16,10 +16,10 @@ //! Testing helpers. -use runtime_support::{Externalities, ExternalitiesError}; use std::collections::HashMap; +use runtime_std::{Externalities, ExternalitiesError}; use primitives::AccountID; -use statichex::StaticHexInto; +use super::statichex::StaticHexInto; #[derive(Debug, Default)] /// Simple externaties implementation. diff --git a/substrate/wasm-runtime/support/Cargo.toml b/substrate/wasm-runtime/std/Cargo.toml similarity index 90% rename from substrate/wasm-runtime/support/Cargo.toml rename to substrate/wasm-runtime/std/Cargo.toml index 828fdab534..802d1fabde 100644 --- a/substrate/wasm-runtime/support/Cargo.toml +++ b/substrate/wasm-runtime/std/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "runtime-support" +name = "runtime-std" version = "0.1.0" authors = ["Parity Technologies "] diff --git a/substrate/wasm-runtime/support/src/lib.rs b/substrate/wasm-runtime/std/src/lib.rs similarity index 100% rename from substrate/wasm-runtime/support/src/lib.rs rename to substrate/wasm-runtime/std/src/lib.rs diff --git a/substrate/wasm-runtime/target/wasm32-unknown-unknown/release/runtime_polkadot.compact.wasm b/substrate/wasm-runtime/target/wasm32-unknown-unknown/release/runtime_polkadot.compact.wasm index 63473ae445..1f94e55115 100644 Binary files a/substrate/wasm-runtime/target/wasm32-unknown-unknown/release/runtime_polkadot.compact.wasm and b/substrate/wasm-runtime/target/wasm32-unknown-unknown/release/runtime_polkadot.compact.wasm differ diff --git a/substrate/wasm-runtime/target/wasm32-unknown-unknown/release/runtime_polkadot.wasm b/substrate/wasm-runtime/target/wasm32-unknown-unknown/release/runtime_polkadot.wasm index f2492b00ec..4fa5a8ae0d 100644 Binary files a/substrate/wasm-runtime/target/wasm32-unknown-unknown/release/runtime_polkadot.wasm and b/substrate/wasm-runtime/target/wasm32-unknown-unknown/release/runtime_polkadot.wasm differ diff --git a/substrate/wasm-runtime/test/Cargo.toml b/substrate/wasm-runtime/test/Cargo.toml index 57015d2683..c7191fb805 100644 --- a/substrate/wasm-runtime/test/Cargo.toml +++ b/substrate/wasm-runtime/test/Cargo.toml @@ -7,4 +7,4 @@ authors = ["Parity Technologies "] crate-type = ["cdylib"] [dependencies] -runtime-support = { path = "../support", version = "0.1" } +runtime-std = { path = "../std", version = "0.1" } diff --git a/substrate/wasm-runtime/test/src/lib.rs b/substrate/wasm-runtime/test/src/lib.rs index caa34856f4..c63ca73fca 100644 --- a/substrate/wasm-runtime/test/src/lib.rs +++ b/substrate/wasm-runtime/test/src/lib.rs @@ -7,8 +7,8 @@ extern crate alloc; use alloc::vec::Vec; #[macro_use] -extern crate runtime_support; -use runtime_support::{set_storage, storage, print, blake2_256, twox_128, twox_256, ed25519_verify}; +extern crate runtime_std; +use runtime_std::{set_storage, storage, print, blake2_256, twox_128, twox_256, ed25519_verify}; fn test_blake2_256(input: &[u8]) -> Vec { blake2_256(&input).to_vec()