Migrate executor, xinherens, keyring and keystore to 2018 edition (#1585)

This commit is contained in:
Stanislav Tkach
2019-01-29 15:30:07 +02:00
committed by Gav Wood
parent ecffe0c371
commit e6839d2d41
14 changed files with 42 additions and 80 deletions
+7 -6
View File
@@ -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" }
+2
View File
@@ -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 {
+1
View File
@@ -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.
+2 -32
View File
@@ -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.
@@ -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;
+3 -3
View File
@@ -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;
+9 -6
View File
@@ -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() {
+3 -2
View File
@@ -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]
-4
View File
@@ -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
+1 -2
View File
@@ -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};
+1
View File
@@ -2,6 +2,7 @@
name = "substrate-keyring"
version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
[dependencies]
substrate-primitives = { path = "../primitives" }
+2 -4
View File
@@ -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;
+2 -1
View File
@@ -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"
+4 -16
View File
@@ -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;