diff --git a/substrate/core/executor/Cargo.toml b/substrate/core/executor/Cargo.toml index 9b88c2f7bb22256021f725ceb68266068c83bab2..d0e120c9faadcb3dc9aa285308be0a840b321b6c 100644 --- a/substrate/core/executor/Cargo.toml +++ b/substrate/core/executor/Cargo.toml @@ -2,16 +2,17 @@ name = "substrate-executor" version = "0.1.0" authors = ["Parity Technologies <admin@parity.io>"] +edition = "2018" [dependencies] error-chain = "0.12" parity-codec = "3.0" -sr-io = { path = "../sr-io" } -substrate-primitives = { path = "../primitives" } -substrate-trie = { path = "../trie" } -substrate-serializer = { path = "../serializer" } -substrate-state-machine = { path = "../state-machine" } -sr-version = { path = "../sr-version" } +runtime_io = { package = "sr-io", path = "../sr-io" } +primitives = { package = "substrate-primitives", path = "../primitives" } +trie = { package = "substrate-trie", path = "../trie" } +serializer = { package = "substrate-serializer", path = "../serializer" } +state_machine = { package = "substrate-state-machine", path = "../state-machine" } +runtime_version = { package = "sr-version", path = "../sr-version" } serde = "1.0" serde_derive = "1.0" wasmi = { version = "0.4.3" } diff --git a/substrate/core/executor/src/error.rs b/substrate/core/executor/src/error.rs index 2a5690d9f65b93b9dd9f48971c6fa92ff9289bcb..c5a6160ac1209dfac67d92bf6fe41d1ea145f7a7 100644 --- a/substrate/core/executor/src/error.rs +++ b/substrate/core/executor/src/error.rs @@ -23,6 +23,8 @@ use state_machine; use serializer; use wasmi; +use error_chain::{error_chain, error_chain_processing, impl_error_chain_processed, + impl_extract_backtrace, impl_error_chain_kind}; error_chain! { foreign_links { diff --git a/substrate/core/executor/src/heap.rs b/substrate/core/executor/src/heap.rs index da7aae22eefffce537dee6731e9a38f8d1e3b157..708c81b3598612bbe1efcea4f1bf027eefc221d1 100644 --- a/substrate/core/executor/src/heap.rs +++ b/substrate/core/executor/src/heap.rs @@ -21,6 +21,7 @@ extern crate fnv; use std::vec; +use log::trace; use self::fnv::FnvHashMap; // The pointers need to be aligned to 8 bytes. diff --git a/substrate/core/executor/src/lib.rs b/substrate/core/executor/src/lib.rs index ddc9828916429b71df7771e1700122f6e3cdbbfb..a42b5a041d3cabdcf8a3ebebe474c513bc001bda 100644 --- a/substrate/core/executor/src/lib.rs +++ b/substrate/core/executor/src/lib.rs @@ -28,37 +28,6 @@ #![warn(missing_docs)] #![recursion_limit="128"] -extern crate tiny_keccak; -extern crate secp256k1; -extern crate parity_codec as codec; -extern crate sr_io as runtime_io; -#[cfg_attr(test, macro_use)] -extern crate substrate_primitives as primitives; -extern crate substrate_serializer as serializer; -extern crate substrate_state_machine as state_machine; -extern crate sr_version as runtime_version; -extern crate substrate_trie as trie; - -extern crate wasmi; -extern crate byteorder; -extern crate parking_lot; - -#[macro_use] -extern crate log; - -#[macro_use] -extern crate error_chain; - -#[cfg(test)] -extern crate assert_matches; - -#[cfg(test)] -extern crate wabt; - -#[cfg(test)] -#[macro_use] -extern crate hex_literal; - #[macro_use] mod wasm_utils; mod wasm_executor; @@ -68,11 +37,12 @@ mod sandbox; mod heap; pub mod error; +pub use wasmi; pub use wasm_executor::WasmExecutor; pub use native_executor::{with_native_environment, NativeExecutor, NativeExecutionDispatch}; pub use state_machine::Externalities; pub use runtime_version::{RuntimeVersion, NativeVersion}; -pub use codec::Codec; +pub use parity_codec::Codec; use primitives::Blake2Hasher; /// Provides runtime information. diff --git a/substrate/core/executor/src/native_executor.rs b/substrate/core/executor/src/native_executor.rs index fcba9c5914772c2112fba501ed8e4a035bdaa228..d6de933c7fd23be022b1d2065f644e71c94e3aa3 100644 --- a/substrate/core/executor/src/native_executor.rs +++ b/substrate/core/executor/src/native_executor.rs @@ -16,16 +16,17 @@ use std::borrow::BorrowMut; use std::cell::{RefMut, RefCell}; -use error::{Error, ErrorKind, Result}; +use crate::error::{Error, ErrorKind, Result}; use state_machine::{CodeExecutor, Externalities}; -use wasm_executor::WasmExecutor; +use crate::wasm_executor::WasmExecutor; use wasmi::{Module as WasmModule, ModuleRef as WasmModuleInstanceRef}; use runtime_version::{NativeVersion, RuntimeVersion}; use std::{collections::HashMap, panic::UnwindSafe}; -use codec::{Decode, Encode}; -use RuntimeInfo; +use parity_codec::{Decode, Encode}; +use crate::RuntimeInfo; use primitives::{Blake2Hasher, NativeOrEncoded}; use primitives::storage::well_known_keys; +use log::trace; /// Default num of pages for the heap const DEFAULT_HEAP_PAGES: u64 = 1024; diff --git a/substrate/core/executor/src/sandbox.rs b/substrate/core/executor/src/sandbox.rs index 87fb4083b38becb404080fb70b6a83f89cafc0ff..b744920b6ed82ee7b3a32b184992e551b234b9e2 100644 --- a/substrate/core/executor/src/sandbox.rs +++ b/substrate/core/executor/src/sandbox.rs @@ -20,9 +20,9 @@ use std::collections::HashMap; use std::rc::Rc; -use codec::{Decode, Encode}; +use parity_codec::{Decode, Encode}; use primitives::sandbox as sandbox_primitives; -use wasm_utils::UserError; +use crate::wasm_utils::UserError; use wasmi; use wasmi::memory_units::Pages; use wasmi::{ @@ -558,7 +558,7 @@ impl Store { #[cfg(test)] mod tests { use primitives::{Blake2Hasher}; - use wasm_executor::WasmExecutor; + use crate::wasm_executor::WasmExecutor; use state_machine::TestExternalities; use wabt; diff --git a/substrate/core/executor/src/wasm_executor.rs b/substrate/core/executor/src/wasm_executor.rs index 7776c83f61db220fe95e9e732f8a3eda02312ed6..a08f828d0502925386df061a2eb822e7cdb4f908 100644 --- a/substrate/core/executor/src/wasm_executor.rs +++ b/substrate/core/executor/src/wasm_executor.rs @@ -26,15 +26,16 @@ use wasmi::{ use wasmi::RuntimeValue::{I32, I64}; use wasmi::memory_units::{Bytes, Pages}; use state_machine::Externalities; -use error::{Error, ErrorKind, Result}; -use wasm_utils::UserError; +use crate::error::{Error, ErrorKind, Result}; +use crate::wasm_utils::UserError; use primitives::{blake2_256, twox_128, twox_256, ed25519}; use primitives::hexdisplay::HexDisplay; use primitives::sandbox as sandbox_primitives; use primitives::{H256, Blake2Hasher}; use trie::ordered_trie_root; -use sandbox; -use heap; +use crate::sandbox; +use crate::heap; +use log::trace; #[cfg(feature="wasm-extern-trace")] macro_rules! debug_trace { @@ -547,7 +548,7 @@ impl_function_executor!(this: FunctionExecutor<'e, E>, Ok(()) }, ext_sandbox_invoke(instance_idx: u32, export_ptr: *const u8, export_len: usize, args_ptr: *const u8, args_len: usize, return_val_ptr: *const u8, return_val_len: usize, state: usize) -> u32 => { - use codec::{Decode, Encode}; + use parity_codec::{Decode, Encode}; trace!(target: "sr-sandbox", "invoke, instance_idx={}", instance_idx); let export = this.memory.get(export_ptr, export_len as usize) @@ -751,8 +752,10 @@ impl WasmExecutor { #[cfg(test)] mod tests { use super::*; - use codec::Encode; + use parity_codec::Encode; use state_machine::TestExternalities; + use hex_literal::{hex, hex_impl}; + use primitives::map; #[test] fn returning_should_work() { diff --git a/substrate/core/executor/wasm/Cargo.toml b/substrate/core/executor/wasm/Cargo.toml index 091945e30644e08cd50288bc14358443f423f1d4..9683cd764eebbc4daaf05e670be8271a9b9d1b4a 100644 --- a/substrate/core/executor/wasm/Cargo.toml +++ b/substrate/core/executor/wasm/Cargo.toml @@ -2,13 +2,14 @@ name = "runtime-test" version = "0.1.0" authors = ["Parity Technologies <admin@parity.io>"] +edition = "2018" [lib] crate-type = ["cdylib"] [dependencies] -sr-io = { path = "../../sr-io", version = "0.1", default-features = false } -sr-sandbox = { path = "../../sr-sandbox", version = "0.1", default-features = false } +runtime_io = { package = "sr-io", path = "../../sr-io", version = "0.1", default-features = false } +sandbox = { package = "sr-sandbox", path = "../../sr-sandbox", version = "0.1", default-features = false } substrate-primitives = { path = "../../primitives", default-features = false } [profile.release] diff --git a/substrate/core/executor/wasm/src/lib.rs b/substrate/core/executor/wasm/src/lib.rs index b85ecafa5a8d13dcd79814927bd7d0d24a94c08f..2ede6f7010df52e58081af7ecdebf7f11972aabe 100644 --- a/substrate/core/executor/wasm/src/lib.rs +++ b/substrate/core/executor/wasm/src/lib.rs @@ -6,10 +6,6 @@ extern crate alloc; use alloc::vec::Vec; use alloc::slice; -extern crate sr_io as runtime_io; -extern crate sr_sandbox as sandbox; -extern crate substrate_primitives; - use runtime_io::{ set_storage, storage, clear_prefix, print, blake2_256, twox_128, twox_256, ed25519_verify, enumerated_trie_root diff --git a/substrate/core/inherents/src/lib.rs b/substrate/core/inherents/src/lib.rs index 14b213b51d5edfe68681453d88cc9dd08355df35..becd99e48167f91b000ddc868f9a01b32a76a74e 100644 --- a/substrate/core/inherents/src/lib.rs +++ b/substrate/core/inherents/src/lib.rs @@ -32,8 +32,7 @@ #![cfg_attr(not(feature = "std"), no_std)] -extern crate parity_codec as codec; - +use parity_codec as codec; use parity_codec_derive::{Encode, Decode}; use rstd::{collections::btree_map::{BTreeMap, IntoIter, Entry}, vec::Vec}; diff --git a/substrate/core/keyring/Cargo.toml b/substrate/core/keyring/Cargo.toml index 04d6c2bd134bfc73900e07a16bfe78b7533d2440..e3203742473e4a3c2cf66d8ccbcd00d88f00d1dc 100644 --- a/substrate/core/keyring/Cargo.toml +++ b/substrate/core/keyring/Cargo.toml @@ -2,6 +2,7 @@ name = "substrate-keyring" version = "0.1.0" authors = ["Parity Technologies <admin@parity.io>"] +edition = "2018" [dependencies] substrate-primitives = { path = "../primitives" } diff --git a/substrate/core/keyring/src/lib.rs b/substrate/core/keyring/src/lib.rs index d2970c54c6b24de9d426e35490418b053b1dcb5e..267da3995cdaf2263328e249681ee11feeb8502c 100644 --- a/substrate/core/keyring/src/lib.rs +++ b/substrate/core/keyring/src/lib.rs @@ -16,12 +16,10 @@ //! Support code for the runtime. A set of test accounts. -#[macro_use] extern crate hex_literal; -#[macro_use] extern crate lazy_static; -extern crate substrate_primitives; - use std::collections::HashMap; use std::ops::Deref; +use lazy_static::lazy_static; +use hex_literal::{hex, hex_impl}; use substrate_primitives::ed25519::{Pair, Public, Signature}; pub use substrate_primitives::ed25519; diff --git a/substrate/core/keystore/Cargo.toml b/substrate/core/keystore/Cargo.toml index 332d22000ba419429bb4196cffc9c5c61285e627..d5dd0cbca9b1d3068b7656abf05d095c8a7b42e8 100644 --- a/substrate/core/keystore/Cargo.toml +++ b/substrate/core/keystore/Cargo.toml @@ -2,10 +2,11 @@ name = "substrate-keystore" version = "0.1.0" authors = ["Parity Technologies <admin@parity.io>"] +edition = "2018" [dependencies] substrate-primitives = { path = "../primitives" } -parity-crypto = { version = "0.2", default-features = false } +crypto = { package = "parity-crypto", version = "0.2", default-features = false } error-chain = "0.12" hex = "0.3" rand = "0.6" diff --git a/substrate/core/keystore/src/lib.rs b/substrate/core/keystore/src/lib.rs index 130835f6bb4540ee72338560fe02f664193e381c..56e1ae62e8eea7e2aee9066e94876f9697ee2005 100644 --- a/substrate/core/keystore/src/lib.rs +++ b/substrate/core/keystore/src/lib.rs @@ -20,27 +20,15 @@ // https://github.com/paritytech/substrate/issues/1547 #![allow(deprecated)] -extern crate substrate_primitives; -extern crate parity_crypto as crypto; -extern crate subtle; -extern crate rand; -extern crate serde_json; -extern crate hex; - -#[macro_use] -extern crate serde_derive; - -#[macro_use] -extern crate error_chain; - -#[cfg(test)] -extern crate tempdir; - use std::collections::HashMap; use std::path::PathBuf; use std::fs::{self, File}; use std::io::{self, Write}; +use serde_derive::{Serialize, Deserialize}; +use error_chain::{error_chain, error_chain_processing, impl_error_chain_processed, + impl_extract_backtrace, impl_error_chain_kind}; + use substrate_primitives::{hashing::blake2_256, ed25519::{Pair, Public, PKCS_LEN}}; pub use crypto::KEY_ITERATIONS;