Clean up sr-io (#3609)

* Move trait `Printable` into `sr-primitives`

* Cleanup runtime io trie_root interfaces

* Remove last generic bits from sr-io interface

* Fix srml-sudo after master merge

* Fix benchmarks

* Runtime bump
This commit is contained in:
Bastian Köcher
2019-09-13 16:39:50 +02:00
committed by GitHub
parent 5cb8c0dc1c
commit 45d64a711c
34 changed files with 309 additions and 372 deletions
@@ -10,6 +10,7 @@ rstd = { package = "sr-std", path = "../../sr-std", default-features = false }
runtime_io = { package = "sr-io", path = "../../sr-io", default-features = false }
sandbox = { package = "sr-sandbox", path = "../../sr-sandbox", default-features = false }
primitives = { package = "substrate-primitives", path = "../../primitives", default-features = false }
sr-primitives = { package = "sr-primitives", path = "../../sr-primitives", default-features = false }
[build-dependencies]
wasm-builder-runner = { package = "substrate-wasm-builder-runner", version = "1.0.2", path = "../../utils/wasm-builder-runner" }
@@ -8,9 +8,10 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
use rstd::{vec::Vec, slice, vec};
use runtime_io::{
set_storage, storage, clear_prefix, print, blake2_128, blake2_256,
twox_128, twox_256, ed25519_verify, sr25519_verify, ordered_trie_root
set_storage, storage, clear_prefix, blake2_128, blake2_256,
twox_128, twox_256, ed25519_verify, sr25519_verify,
};
use sr_primitives::{print, traits::{BlakeTwo256, Hash}};
use primitives::{ed25519, sr25519};
macro_rules! impl_stubs {
@@ -94,12 +95,12 @@ impl_stubs!(
[sr25519_verify(&sr25519::Signature(sig), &msg[..], &sr25519::Public(pubkey)) as u8].to_vec()
},
test_ordered_trie_root => |_| {
ordered_trie_root::<primitives::Blake2Hasher, _, _>(
&[
&b"zero"[..],
&b"one"[..],
&b"two"[..],
]
BlakeTwo256::ordered_trie_root(
vec![
b"zero"[..].into(),
b"one"[..].into(),
b"two"[..].into(),
],
).as_ref().to_vec()
},
test_sandbox => |code: &[u8]| {
+4 -6
View File
@@ -31,7 +31,7 @@ use crate::error::{Error, Result};
use codec::{Encode, Decode};
use primitives::{
blake2_128, blake2_256, twox_64, twox_128, twox_256, ed25519, sr25519, Pair, crypto::KeyTypeId,
offchain, hexdisplay::HexDisplay, sandbox as sandbox_primitives, Blake2Hasher,
offchain, sandbox as sandbox_primitives, Blake2Hasher,
traits::Externalities,
};
use trie::{TrieConfiguration, trie_types::Layout};
@@ -418,22 +418,20 @@ impl_wasm_host_interface! {
ext_print_utf8(utf8_data: Pointer<u8>, utf8_len: WordSize) {
if let Ok(utf8) = context.read_memory(utf8_data, utf8_len) {
if let Ok(message) = String::from_utf8(utf8) {
println!("{}", message);
}
runtime_io::print_utf8(&utf8);
}
Ok(())
}
ext_print_hex(data: Pointer<u8>, len: WordSize) {
if let Ok(hex) = context.read_memory(data, len) {
println!("{}", HexDisplay::from(&hex));
runtime_io::print_hex(&hex);
}
Ok(())
}
ext_print_num(number: u64) {
println!("{}", number);
runtime_io::print_num(number);
Ok(())
}