diff --git a/substrate/Cargo.lock b/substrate/Cargo.lock index d6952c3cc1..412d6191d3 100644 --- a/substrate/Cargo.lock +++ b/substrate/Cargo.lock @@ -244,10 +244,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "bincode" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -7708,7 +7707,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "base64 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "bincode 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bincode 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift-codegen 0.50.0 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift-entity 0.50.0 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift-wasm 0.50.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -8049,7 +8048,7 @@ dependencies = [ "checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" "checksum base64 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" "checksum base64 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "489d6c0ed21b11d038c31b6ceccca973e65d73ba3bd8ecb9a2babf5546164643" -"checksum bincode 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b8ab639324e3ee8774d296864fbc0dbbb256cf1a41c490b94cba90c082915f92" +"checksum bincode 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5753e2a71534719bf3f4e57006c3a4f0d2c672a4b676eec84161f763eca87dbf" "checksum bindgen 0.49.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4c07087f3d5731bf3fb375a81841b99597e25dc11bd3bc72d16d43adf6624a6e" "checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" "checksum bitmask 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5da9b3d9f6f585199287a473f4f8dfab6566cf827d15c00c219f53c645687ead" diff --git a/substrate/Cargo.toml b/substrate/Cargo.toml index 6f3c24be2b..fbae35a522 100644 --- a/substrate/Cargo.toml +++ b/substrate/Cargo.toml @@ -119,7 +119,7 @@ members = [ "primitives/sr-api/proc-macro", "primitives/sr-api/test", "primitives/sr-arithmetic", - "primitives/sr-io", + "primitives/io", "primitives/runtime", "primitives/sr-sandbox", "primitives/sr-staking-primitives", diff --git a/substrate/bin/node-template/Cargo.toml b/substrate/bin/node-template/Cargo.toml index a60cbf4ff1..af39bd47f4 100644 --- a/substrate/bin/node-template/Cargo.toml +++ b/substrate/bin/node-template/Cargo.toml @@ -18,7 +18,7 @@ tokio = "0.1.22" parking_lot = "0.9.0" codec = { package = "parity-scale-codec", version = "1.0.0" } trie-root = "0.15.2" -sp-io = { path = "../../primitives/sr-io" } +sp-io = { path = "../../primitives/io" } sc-cli = { path = "../../client/cli" } primitives = { package = "sp-core", path = "../../primitives/core" } sc-executor = { path = "../../client/executor" } diff --git a/substrate/bin/node-template/runtime/Cargo.toml b/substrate/bin/node-template/runtime/Cargo.toml index 3c55cd68fb..438a9f93ed 100644 --- a/substrate/bin/node-template/runtime/Cargo.toml +++ b/substrate/bin/node-template/runtime/Cargo.toml @@ -18,7 +18,7 @@ offchain-primitives = { package = "sp-offchain", path = "../../../primitives/off primitives = { package = "sp-core", path = "../../../primitives/core", default-features = false } randomness-collective-flip = { package = "pallet-randomness-collective-flip", path = "../../../frame/randomness-collective-flip", default-features = false } sp-std = { path = "../../../primitives/std", default-features = false } -runtime-io = { package = "sp-io", path = "../../../primitives/sr-io", default-features = false } +sp-io = { path = "../../../primitives/io", default-features = false } safe-mix = { version = "1.0.0", default-features = false } serde = { version = "1.0.101", optional = true, features = ["derive"] } sp-api = { path = "../../../primitives/sr-api", default-features = false } @@ -51,7 +51,7 @@ std = [ "primitives/std", "randomness-collective-flip/std", "sp-std/std", - "runtime-io/std", + "sp-io/std", "safe-mix/std", "serde", "sp-api/std", diff --git a/substrate/bin/node-template/runtime/src/template.rs b/substrate/bin/node-template/runtime/src/template.rs index 6cdadc72ff..231f9b9a2b 100644 --- a/substrate/bin/node-template/runtime/src/template.rs +++ b/substrate/bin/node-template/runtime/src/template.rs @@ -114,7 +114,7 @@ mod tests { // This function basically just builds a genesis storage key/value store according to // our desired mockup. - fn new_test_ext() -> runtime_io::TestExternalities { + fn new_test_ext() -> sp_io::TestExternalities { system::GenesisConfig::default().build_storage::().unwrap().into() } diff --git a/substrate/bin/node/cli/Cargo.toml b/substrate/bin/node/cli/Cargo.toml index 107fe6bb30..753e22bb42 100644 --- a/substrate/bin/node/cli/Cargo.toml +++ b/substrate/bin/node/cli/Cargo.toml @@ -43,7 +43,7 @@ sp-timestamp = { path = "../../../primitives/timestamp", default-features = fals sp-finality-tracker = { path = "../../../primitives/finality-tracker", default-features = false } inherents = { package = "sp-inherents", path = "../../../primitives/inherents" } keyring = { package = "sp-keyring", path = "../../../primitives/keyring" } -runtime-io = { package = "sp-io", path = "../../../primitives/sr-io" } +sp-io = { path = "../../../primitives/io" } consensus-common = { package = "sp-consensus", path = "../../../primitives/consensus/common" } # client dependencies diff --git a/substrate/bin/node/cli/src/factory_impl.rs b/substrate/bin/node/cli/src/factory_impl.rs index 5f37615b1b..af0633ab64 100644 --- a/substrate/bin/node/cli/src/factory_impl.rs +++ b/substrate/bin/node/cli/src/factory_impl.rs @@ -247,7 +247,7 @@ fn sign( let payload = (xt.function, extra.clone(), additional_signed); let signature = payload.using_encoded(|b| { if b.len() > 256 { - key.sign(&runtime_io::hashing::blake2_256(b)) + key.sign(&sp_io::hashing::blake2_256(b)) } else { key.sign(b) } diff --git a/substrate/bin/node/executor/Cargo.toml b/substrate/bin/node/executor/Cargo.toml index f386a2d929..a86ca7a391 100644 --- a/substrate/bin/node/executor/Cargo.toml +++ b/substrate/bin/node/executor/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" [dependencies] trie-root = "0.15.2" codec = { package = "parity-scale-codec", version = "1.0.0" } -runtime_io = { package = "sp-io", path = "../../../primitives/sr-io" } +sp-io = { path = "../../../primitives/io" } state_machine = { package = "sp-state-machine", path = "../../../primitives/state-machine" } sc-executor = { path = "../../../client/executor" } primitives = { package = "sp-core", path = "../../../primitives/core" } diff --git a/substrate/bin/node/runtime/Cargo.toml b/substrate/bin/node/runtime/Cargo.toml index 5a95961bec..9a43cc08af 100644 --- a/substrate/bin/node/runtime/Cargo.toml +++ b/substrate/bin/node/runtime/Cargo.toml @@ -66,7 +66,7 @@ transaction-payment-rpc-runtime-api = { package = "pallet-transaction-payment-rp wasm-builder-runner = { package = "substrate-wasm-builder-runner", path = "../../../client/utils/wasm-builder-runner", version = "1.0.4" } [dev-dependencies] -runtime_io = { package = "sp-io", path = "../../../primitives/sr-io" } +sp-io = { path = "../../../primitives/io" } [features] default = ["std"] diff --git a/substrate/bin/node/runtime/src/impls.rs b/substrate/bin/node/runtime/src/impls.rs index aa6e0554be..3d034a2fb1 100644 --- a/substrate/bin/node/runtime/src/impls.rs +++ b/substrate/bin/node/runtime/src/impls.rs @@ -150,7 +150,7 @@ mod tests { } fn run_with_system_weight(w: Weight, assertions: F) where F: Fn() -> () { - let mut t: runtime_io::TestExternalities = + let mut t: sp_io::TestExternalities = system::GenesisConfig::default().build_storage::().unwrap().into(); t.execute_with(|| { System::set_block_limits(w, 0); diff --git a/substrate/bin/node/testing/Cargo.toml b/substrate/bin/node/testing/Cargo.toml index b4723cc3f4..799ba86289 100644 --- a/substrate/bin/node/testing/Cargo.toml +++ b/substrate/bin/node/testing/Cargo.toml @@ -17,7 +17,7 @@ node-executor = { path = "../executor" } node-primitives = { path = "../primitives" } node-runtime = { path = "../runtime" } primitives = { package = "sp-core", path = "../../../primitives/core" } -runtime-io = { package = "sp-io", path = "../../../primitives/sr-io" } +sp-io = { path = "../../../primitives/io" } runtime_support = { package = "frame-support", path = "../../../frame/support" } session = { package = "pallet-session", path = "../../../frame/session" } sp-runtime = { path = "../../../primitives/runtime" } diff --git a/substrate/bin/node/testing/src/keyring.rs b/substrate/bin/node/testing/src/keyring.rs index 620c26578a..53dac68096 100644 --- a/substrate/bin/node/testing/src/keyring.rs +++ b/substrate/bin/node/testing/src/keyring.rs @@ -84,7 +84,7 @@ pub fn sign(xt: CheckedExtrinsic, version: u32, genesis_hash: [u8; 32]) -> Unche let key = AccountKeyring::from_account_id(&signed).unwrap(); let signature = payload.using_encoded(|b| { if b.len() > 256 { - key.sign(&runtime_io::hashing::blake2_256(b)) + key.sign(&sp_io::hashing::blake2_256(b)) } else { key.sign(b) } diff --git a/substrate/client/consensus/aura/Cargo.toml b/substrate/client/consensus/aura/Cargo.toml index 16ce2eed27..a2f0eeda38 100644 --- a/substrate/client/consensus/aura/Cargo.toml +++ b/substrate/client/consensus/aura/Cargo.toml @@ -23,7 +23,7 @@ log = "0.4.8" parking_lot = "0.9.0" primitives = { package = "sp-core", path = "../../../primitives/core" } sp-blockchain = { path = "../../../primitives/blockchain" } -runtime_io = { package = "sp-io", path = "../../../primitives/sr-io" } +sp-io = { path = "../../../primitives/io" } runtime_version = { package = "sp-version", path = "../../../primitives/sr-version" } slots = { package = "sc-consensus-slots", path = "../slots" } sp-api = { path = "../../../primitives/sr-api" } diff --git a/substrate/client/consensus/babe/Cargo.toml b/substrate/client/consensus/babe/Cargo.toml index 068fb90dec..7f86960c0c 100644 --- a/substrate/client/consensus/babe/Cargo.toml +++ b/substrate/client/consensus/babe/Cargo.toml @@ -14,7 +14,7 @@ num-bigint = "0.2.3" num-rational = "0.2.2" num-traits = "0.2.8" runtime-version = { package = "sp-version", path = "../../../primitives/sr-version" } -runtime-io = { package = "sp-io", path = "../../../primitives/sr-io" } +sp-io = { path = "../../../primitives/io" } inherents = { package = "sp-inherents", path = "../../../primitives/inherents" } sp-timestamp = { path = "../../../primitives/timestamp" } sc-telemetry = { path = "../../telemetry" } diff --git a/substrate/client/executor/Cargo.toml b/substrate/client/executor/Cargo.toml index dff872dbc4..d40e426e3f 100644 --- a/substrate/client/executor/Cargo.toml +++ b/substrate/client/executor/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] derive_more = "0.99.2" codec = { package = "parity-scale-codec", version = "1.0.0" } -runtime_io = { package = "sp-io", path = "../../primitives/sr-io" } +sp-io = { path = "../../primitives/io" } primitives = { package = "sp-core", path = "../../primitives/core" } trie = { package = "sp-trie", path = "../../primitives/trie" } serializer = { package = "sp-serializer", path = "../../primitives/serializer" } diff --git a/substrate/client/executor/runtime-test/Cargo.toml b/substrate/client/executor/runtime-test/Cargo.toml index 75b9d510bd..9b103aa1ca 100644 --- a/substrate/client/executor/runtime-test/Cargo.toml +++ b/substrate/client/executor/runtime-test/Cargo.toml @@ -7,7 +7,7 @@ build = "build.rs" [dependencies] sp-std = { path = "../../../primitives/std", default-features = false } -runtime_io = { package = "sp-io", path = "../../../primitives/sr-io", default-features = false } +sp-io = { path = "../../../primitives/io", default-features = false } sandbox = { package = "sp-sandbox", path = "../../../primitives/sr-sandbox", default-features = false } primitives = { package = "sp-core", path = "../../../primitives/core", default-features = false } sp-runtime = { package = "sp-runtime", path = "../../../primitives/runtime", default-features = false } @@ -17,4 +17,4 @@ wasm-builder-runner = { package = "substrate-wasm-builder-runner", path = "../.. [features] default = [ "std" ] -std = ["runtime_io/std", "sandbox/std", "sp-std/std"] +std = ["sp-io/std", "sandbox/std", "sp-std/std"] diff --git a/substrate/client/executor/runtime-test/src/lib.rs b/substrate/client/executor/runtime-test/src/lib.rs index 7229d9b1a4..7a97aebc90 100644 --- a/substrate/client/executor/runtime-test/src/lib.rs +++ b/substrate/client/executor/runtime-test/src/lib.rs @@ -9,7 +9,7 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); use sp_std::{vec::Vec, vec}; #[cfg(not(feature = "std"))] -use runtime_io::{ +use sp_io::{ storage, hashing::{blake2_128, blake2_256, sha2_256, twox_128, twox_256}, crypto::{ed25519_verify, sr25519_verify}, }; @@ -146,49 +146,49 @@ primitives::wasm_export_functions! { fn test_offchain_local_storage() -> bool { let kind = primitives::offchain::StorageKind::PERSISTENT; - assert_eq!(runtime_io::offchain::local_storage_get(kind, b"test"), None); - runtime_io::offchain::local_storage_set(kind, b"test", b"asd"); - assert_eq!(runtime_io::offchain::local_storage_get(kind, b"test"), Some(b"asd".to_vec())); + assert_eq!(sp_io::offchain::local_storage_get(kind, b"test"), None); + sp_io::offchain::local_storage_set(kind, b"test", b"asd"); + assert_eq!(sp_io::offchain::local_storage_get(kind, b"test"), Some(b"asd".to_vec())); - let res = runtime_io::offchain::local_storage_compare_and_set( + let res = sp_io::offchain::local_storage_compare_and_set( kind, b"test", Some(b"asd".to_vec()), b"", ); - assert_eq!(runtime_io::offchain::local_storage_get(kind, b"test"), Some(b"".to_vec())); + assert_eq!(sp_io::offchain::local_storage_get(kind, b"test"), Some(b"".to_vec())); res } fn test_offchain_local_storage_with_none() { let kind = primitives::offchain::StorageKind::PERSISTENT; - assert_eq!(runtime_io::offchain::local_storage_get(kind, b"test"), None); + assert_eq!(sp_io::offchain::local_storage_get(kind, b"test"), None); - let res = runtime_io::offchain::local_storage_compare_and_set(kind, b"test", None, b"value"); + let res = sp_io::offchain::local_storage_compare_and_set(kind, b"test", None, b"value"); assert_eq!(res, true); - assert_eq!(runtime_io::offchain::local_storage_get(kind, b"test"), Some(b"value".to_vec())); + assert_eq!(sp_io::offchain::local_storage_get(kind, b"test"), Some(b"value".to_vec())); } fn test_offchain_http() -> bool { use primitives::offchain::HttpRequestStatus; let run = || -> Option<()> { - let id = runtime_io::offchain::http_request_start( + let id = sp_io::offchain::http_request_start( "POST", "http://localhost:12345", &[], ).ok()?; - runtime_io::offchain::http_request_add_header(id, "X-Auth", "test").ok()?; - runtime_io::offchain::http_request_write_body(id, &[1, 2, 3, 4], None).ok()?; - runtime_io::offchain::http_request_write_body(id, &[], None).ok()?; - let status = runtime_io::offchain::http_response_wait(&[id], None); + sp_io::offchain::http_request_add_header(id, "X-Auth", "test").ok()?; + sp_io::offchain::http_request_write_body(id, &[1, 2, 3, 4], None).ok()?; + sp_io::offchain::http_request_write_body(id, &[], None).ok()?; + let status = sp_io::offchain::http_response_wait(&[id], None); assert!(status == vec![HttpRequestStatus::Finished(200)], "Expected Finished(200) status."); - let headers = runtime_io::offchain::http_response_headers(id); + let headers = sp_io::offchain::http_response_headers(id); assert_eq!(headers, vec![(b"X-Auth".to_vec(), b"hello".to_vec())]); let mut buffer = vec![0; 64]; - let read = runtime_io::offchain::http_response_read_body(id, &mut buffer, None).ok()?; + let read = sp_io::offchain::http_response_read_body(id, &mut buffer, None).ok()?; assert_eq!(read, 3); assert_eq!(&buffer[0..read as usize], &[1, 2, 3]); - let read = runtime_io::offchain::http_response_read_body(id, &mut buffer, None).ok()?; + let read = sp_io::offchain::http_response_read_body(id, &mut buffer, None).ok()?; assert_eq!(read, 0); Some(()) diff --git a/substrate/client/executor/src/deprecated_host_interface.rs b/substrate/client/executor/src/deprecated_host_interface.rs index e7f91443c0..7ea3687bb9 100644 --- a/substrate/client/executor/src/deprecated_host_interface.rs +++ b/substrate/client/executor/src/deprecated_host_interface.rs @@ -168,20 +168,20 @@ impl_wasm_host_interface! { ext_print_utf8(utf8_data: Pointer, utf8_len: WordSize) { if let Ok(utf8) = context.read_memory(utf8_data, utf8_len) { - runtime_io::misc::print_utf8(&utf8); + sp_io::misc::print_utf8(&utf8); } Ok(()) } ext_print_hex(data: Pointer, len: WordSize) { if let Ok(hex) = context.read_memory(data, len) { - runtime_io::misc::print_hex(&hex); + sp_io::misc::print_hex(&hex); } Ok(()) } ext_print_num(number: u64) { - runtime_io::misc::print_num(number); + sp_io::misc::print_num(number); Ok(()) } @@ -200,7 +200,7 @@ impl_wasm_host_interface! { let target_str = std::str::from_utf8(&target) .map_err(|_| "Target invalid utf8 in ext_log")?; - runtime_io::logging::log(level.into(), &target_str, &message); + sp_io::logging::log(level.into(), &target_str, &message); Ok(()) } @@ -214,7 +214,7 @@ impl_wasm_host_interface! { .map_err(|_| "Invalid attempt to determine key in ext_set_storage")?; let value = context.read_memory(value_data, value_len) .map_err(|_| "Invalid attempt to determine value in ext_set_storage")?; - Ok(runtime_io::storage::set(&key, &value)) + Ok(sp_io::storage::set(&key, &value)) } ext_set_child_storage( @@ -232,7 +232,7 @@ impl_wasm_host_interface! { let value = context.read_memory(value_data, value_len) .map_err(|_| "Invalid attempt to determine value in ext_set_child_storage")?; - Ok(runtime_io::storage::child_set(&storage_key, &key, &value)) + Ok(sp_io::storage::child_set(&storage_key, &key, &value)) } ext_clear_child_storage( @@ -246,19 +246,19 @@ impl_wasm_host_interface! { let key = context.read_memory(key_data, key_len) .map_err(|_| "Invalid attempt to determine key in ext_clear_child_storage")?; - Ok(runtime_io::storage::child_clear(&storage_key, &key)) + Ok(sp_io::storage::child_clear(&storage_key, &key)) } ext_clear_storage(key_data: Pointer, key_len: WordSize) { let key = context.read_memory(key_data, key_len) .map_err(|_| "Invalid attempt to determine key in ext_clear_storage")?; - Ok(runtime_io::storage::clear(&key)) + Ok(sp_io::storage::clear(&key)) } ext_exists_storage(key_data: Pointer, key_len: WordSize) -> u32 { let key = context.read_memory(key_data, key_len) .map_err(|_| "Invalid attempt to determine key in ext_exists_storage")?; - Ok(if runtime_io::storage::exists(&key) { 1 } else { 0 }) + Ok(if sp_io::storage::exists(&key) { 1 } else { 0 }) } ext_exists_child_storage( @@ -272,13 +272,13 @@ impl_wasm_host_interface! { let key = context.read_memory(key_data, key_len) .map_err(|_| "Invalid attempt to determine key in ext_exists_child_storage")?; - Ok(if runtime_io::storage::child_exists(&storage_key, &key) { 1 } else { 0 }) + Ok(if sp_io::storage::child_exists(&storage_key, &key) { 1 } else { 0 }) } ext_clear_prefix(prefix_data: Pointer, prefix_len: WordSize) { let prefix = context.read_memory(prefix_data, prefix_len) .map_err(|_| "Invalid attempt to determine prefix in ext_clear_prefix")?; - Ok(runtime_io::storage::clear_prefix(&prefix)) + Ok(sp_io::storage::clear_prefix(&prefix)) } ext_clear_child_prefix( @@ -291,13 +291,13 @@ impl_wasm_host_interface! { .map_err(|_| "Invalid attempt to determine storage_key in ext_clear_child_prefix")?; let prefix = context.read_memory(prefix_data, prefix_len) .map_err(|_| "Invalid attempt to determine prefix in ext_clear_child_prefix")?; - Ok(runtime_io::storage::child_clear_prefix(&storage_key, &prefix)) + Ok(sp_io::storage::child_clear_prefix(&storage_key, &prefix)) } ext_kill_child_storage(storage_key_data: Pointer, storage_key_len: WordSize) { let storage_key = context.read_memory(storage_key_data, storage_key_len) .map_err(|_| "Invalid attempt to determine storage_key in ext_kill_child_storage")?; - Ok(runtime_io::storage::child_storage_kill(&storage_key)) + Ok(sp_io::storage::child_storage_kill(&storage_key)) } ext_get_allocated_storage( @@ -308,7 +308,7 @@ impl_wasm_host_interface! { let key = context.read_memory(key_data, key_len) .map_err(|_| "Invalid attempt to determine key in ext_get_allocated_storage")?; - if let Some(value) = runtime_io::storage::get(&key) { + if let Some(value) = sp_io::storage::get(&key) { let offset = context.allocate_memory(value.len() as u32)?; context.write_memory(offset, &value) .map_err(|_| "Invalid attempt to set memory in ext_get_allocated_storage")?; @@ -334,7 +334,7 @@ impl_wasm_host_interface! { let key = context.read_memory(key_data, key_len) .map_err(|_| "Invalid attempt to determine key in ext_get_allocated_child_storage")?; - if let Some(value) = runtime_io::storage::child_get(&storage_key, &key) { + if let Some(value) = sp_io::storage::child_get(&storage_key, &key) { let offset = context.allocate_memory(value.len() as u32)?; context.write_memory(offset, &value) .map_err(|_| "Invalid attempt to set memory in ext_get_allocated_child_storage")?; @@ -358,7 +358,7 @@ impl_wasm_host_interface! { let key = context.read_memory(key_data, key_len) .map_err(|_| "Invalid attempt to get key in ext_get_storage_into")?; - if let Some(value) = runtime_io::storage::get(&key) { + if let Some(value) = sp_io::storage::get(&key) { let data = &value[value.len().min(value_offset as usize)..]; let written = std::cmp::min(value_len as usize, data.len()); context.write_memory(value_data, &data[..written]) @@ -383,7 +383,7 @@ impl_wasm_host_interface! { let key = context.read_memory(key_data, key_len) .map_err(|_| "Invalid attempt to get key in ext_get_child_storage_into")?; - if let Some(value) = runtime_io::storage::child_get(&storage_key, &key) { + if let Some(value) = sp_io::storage::child_get(&storage_key, &key) { let data = &value[value.len().min(value_offset as usize)..]; let written = std::cmp::min(value_len as usize, data.len()); context.write_memory(value_data, &data[..written]) @@ -395,7 +395,7 @@ impl_wasm_host_interface! { } ext_storage_root(result: Pointer) { - context.write_memory(result, runtime_io::storage::root().as_ref()) + context.write_memory(result, sp_io::storage::root().as_ref()) .map_err(|_| "Invalid attempt to set memory in ext_storage_root".into()) } @@ -406,7 +406,7 @@ impl_wasm_host_interface! { ) -> Pointer { let storage_key = context.read_memory(storage_key_data, storage_key_len) .map_err(|_| "Invalid attempt to determine storage_key in ext_child_storage_root")?; - let value = runtime_io::storage::child_root(&storage_key); + let value = sp_io::storage::child_root(&storage_key); let offset = context.allocate_memory(value.len() as u32)?; context.write_memory(offset, &value) @@ -425,7 +425,7 @@ impl_wasm_host_interface! { context.read_memory_into(parent_hash_data, &mut parent_hash[..]) .map_err(|_| "Invalid attempt to get parent_hash in ext_storage_changes_root")?; - if let Some(r) = runtime_io::storage::changes_root(&parent_hash) { + if let Some(r) = sp_io::storage::changes_root(&parent_hash) { context.write_memory(result, &r[..]) .map_err(|_| "Invalid attempt to set memory in ext_storage_changes_root")?; Ok(1) @@ -459,7 +459,7 @@ impl_wasm_host_interface! { } ext_chain_id() -> u64 { - Ok(runtime_io::misc::chain_id()) + Ok(sp_io::misc::chain_id()) } ext_twox_64(data: Pointer, len: WordSize, out: Pointer) { @@ -555,7 +555,7 @@ impl_wasm_host_interface! { .map_err(|_| "Invalid attempt to get id in ext_ed25519_public_keys")?; let key_type = KeyTypeId(id); - let keys = runtime_io::crypto::ed25519_public_keys(key_type).encode(); + let keys = sp_io::crypto::ed25519_public_keys(key_type).encode(); let len = keys.len() as u32; let offset = context.allocate_memory(len)?; @@ -610,7 +610,7 @@ impl_wasm_host_interface! { ) }; - let pubkey = runtime_io::crypto::ed25519_generate(key_type, seed); + let pubkey = sp_io::crypto::ed25519_generate(key_type, seed); context.write_memory(out, pubkey.as_ref()) .map_err(|_| "Invalid attempt to set out in ext_ed25519_generate".into()) @@ -638,7 +638,7 @@ impl_wasm_host_interface! { let pub_key = ed25519::Public::try_from(pubkey.as_ref()) .map_err(|_| "Invalid `ed25519` public key")?; - let signature = runtime_io::crypto::ed25519_sign(key_type, &pub_key, &msg); + let signature = sp_io::crypto::ed25519_sign(key_type, &pub_key, &msg); match signature { Some(signature) => { @@ -656,7 +656,7 @@ impl_wasm_host_interface! { .map_err(|_| "Invalid attempt to get id in ext_sr25519_public_keys")?; let key_type = KeyTypeId(id); - let keys = runtime_io::crypto::sr25519_public_keys(key_type).encode(); + let keys = sp_io::crypto::sr25519_public_keys(key_type).encode(); let len = keys.len() as u32; let offset = context.allocate_memory(len)?; @@ -710,7 +710,7 @@ impl_wasm_host_interface! { ) }; - let pubkey = runtime_io::crypto::sr25519_generate(key_type, seed); + let pubkey = sp_io::crypto::sr25519_generate(key_type, seed); context.write_memory(out, pubkey.as_ref()) .map_err(|_| "Invalid attempt to set out in ext_sr25519_generate".into()) @@ -738,7 +738,7 @@ impl_wasm_host_interface! { let pub_key = sr25519::Public::try_from(pubkey.as_ref()) .map_err(|_| "Invalid `sr25519` public key")?; - let signature = runtime_io::crypto::sr25519_sign(key_type, &pub_key, &msg); + let signature = sp_io::crypto::sr25519_sign(key_type, &pub_key, &msg); match signature { Some(signature) => { @@ -781,20 +781,20 @@ impl_wasm_host_interface! { } ext_is_validator() -> u32 { - if runtime_io::offchain::is_validator() { Ok(1) } else { Ok(0) } + if sp_io::offchain::is_validator() { Ok(1) } else { Ok(0) } } ext_submit_transaction(msg_data: Pointer, len: WordSize) -> u32 { let extrinsic = context.read_memory(msg_data, len) .map_err(|_| "OOB while ext_submit_transaction: wasm")?; - let res = runtime_io::offchain::submit_transaction(extrinsic); + let res = sp_io::offchain::submit_transaction(extrinsic); Ok(if res.is_ok() { 0 } else { 1 }) } ext_network_state(written_out: Pointer) -> Pointer { - let res = runtime_io::offchain::network_state(); + let res = sp_io::offchain::network_state(); let encoded = res.encode(); let len = encoded.len() as u32; @@ -809,17 +809,17 @@ impl_wasm_host_interface! { } ext_timestamp() -> u64 { - Ok(runtime_io::offchain::timestamp().unix_millis()) + Ok(sp_io::offchain::timestamp().unix_millis()) } ext_sleep_until(deadline: u64) { - runtime_io::offchain::sleep_until(offchain::Timestamp::from_unix_millis(deadline)); + sp_io::offchain::sleep_until(offchain::Timestamp::from_unix_millis(deadline)); Ok(()) } ext_random_seed(seed_data: Pointer) { // NOTE the runtime as assumptions about seed size. - let seed = runtime_io::offchain::random_seed(); + let seed = sp_io::offchain::random_seed(); context.write_memory(seed_data, &seed) .map_err(|_| "Invalid attempt to set value in ext_random_seed")?; @@ -840,7 +840,7 @@ impl_wasm_host_interface! { let value = context.read_memory(value, value_len) .map_err(|_| "OOB while ext_local_storage_set: wasm")?; - runtime_io::offchain::local_storage_set(kind, &key, &value); + sp_io::offchain::local_storage_set(kind, &key, &value); Ok(()) } @@ -856,7 +856,7 @@ impl_wasm_host_interface! { let key = context.read_memory(key, key_len) .map_err(|_| "OOB while ext_local_storage_get: wasm")?; - let maybe_value = runtime_io::offchain::local_storage_get(kind, &key); + let maybe_value = sp_io::offchain::local_storage_get(kind, &key); let (offset, len) = if let Some(value) = maybe_value { let offset = context.allocate_memory(value.len() as u32)?; @@ -898,7 +898,7 @@ impl_wasm_host_interface! { ) }; - let res = runtime_io::offchain::local_storage_compare_and_set( + let res = sp_io::offchain::local_storage_compare_and_set( kind, &key, old_value, @@ -928,7 +928,7 @@ impl_wasm_host_interface! { let url_str = str::from_utf8(&url) .map_err(|_| "invalid str while ext_http_request_start: wasm")?; - let id = runtime_io::offchain::http_request_start(method_str, url_str, &meta); + let id = sp_io::offchain::http_request_start(method_str, url_str, &meta); if let Ok(id) = id { Ok(id.into()) @@ -954,7 +954,7 @@ impl_wasm_host_interface! { let value_str = str::from_utf8(&value) .map_err(|_| "Invalid str while ext_http_request_add_header: wasm")?; - let res = runtime_io::offchain::http_request_add_header( + let res = sp_io::offchain::http_request_add_header( offchain::HttpRequestId(request_id as u16), name_str, value_str, @@ -972,7 +972,7 @@ impl_wasm_host_interface! { let chunk = context.read_memory(chunk, chunk_len) .map_err(|_| "OOB while ext_http_request_write_body: wasm")?; - let res = runtime_io::offchain::http_request_write_body( + let res = sp_io::offchain::http_request_write_body( offchain::HttpRequestId(request_id as u16), &chunk, deadline_to_timestamp(deadline), @@ -998,7 +998,7 @@ impl_wasm_host_interface! { ) .collect::, _>>()?; - let res = runtime_io::offchain::http_response_wait(&ids, deadline_to_timestamp(deadline)) + let res = sp_io::offchain::http_response_wait(&ids, deadline_to_timestamp(deadline)) .into_iter() .map(|status| u32::from(status)) .enumerate() @@ -1019,7 +1019,7 @@ impl_wasm_host_interface! { ) -> Pointer { use codec::Encode; - let headers = runtime_io::offchain::http_response_headers( + let headers = sp_io::offchain::http_response_headers( offchain::HttpRequestId(request_id as u16), ); @@ -1044,7 +1044,7 @@ impl_wasm_host_interface! { let mut internal_buffer = Vec::with_capacity(buffer_len as usize); internal_buffer.resize(buffer_len as usize, 0); - let res = runtime_io::offchain::http_response_read_body( + let res = sp_io::offchain::http_response_read_body( offchain::HttpRequestId(request_id as u16), &mut internal_buffer, deadline_to_timestamp(deadline), @@ -1072,4 +1072,3 @@ fn deadline_to_timestamp(deadline: u64) -> Option { Some(offchain::Timestamp::from_unix_millis(deadline)) } } - diff --git a/substrate/client/executor/src/integration_tests/mod.rs b/substrate/client/executor/src/integration_tests/mod.rs index fce39bb400..3cdb9fdafe 100644 --- a/substrate/client/executor/src/integration_tests/mod.rs +++ b/substrate/client/executor/src/integration_tests/mod.rs @@ -40,7 +40,7 @@ fn call_in_wasm( code: &[u8], heap_pages: u64, ) -> crate::error::Result> { - crate::call_in_wasm::( + crate::call_in_wasm::( function, call_data, execution_method, @@ -492,4 +492,3 @@ fn offchain_http_should_work(wasm_method: WasmExecutionMethod) { true.encode(), ); } - diff --git a/substrate/client/executor/src/lib.rs b/substrate/client/executor/src/lib.rs index 5037b490dd..97bdb0e20d 100644 --- a/substrate/client/executor/src/lib.rs +++ b/substrate/client/executor/src/lib.rs @@ -94,13 +94,13 @@ pub trait RuntimeInfo { mod tests { use super::*; use runtime_test::WASM_BINARY; - use runtime_io::TestExternalities; + use sp_io::TestExternalities; #[test] fn call_in_interpreted_wasm_works() { let mut ext = TestExternalities::default(); let mut ext = ext.ext(); - let res = call_in_wasm::<_, runtime_io::SubstrateHostFunctions>( + let res = call_in_wasm::<_, sp_io::SubstrateHostFunctions>( "test_empty_return", &[], WasmExecutionMethod::Interpreted, diff --git a/substrate/client/executor/src/native_executor.rs b/substrate/client/executor/src/native_executor.rs index 5a9bba7b52..635acc8716 100644 --- a/substrate/client/executor/src/native_executor.rs +++ b/substrate/client/executor/src/native_executor.rs @@ -98,7 +98,7 @@ impl NativeExecutor { /// `default_heap_pages` - Number of 64KB pages to allocate for Wasm execution. /// Defaults to `DEFAULT_HEAP_PAGES` if `None` is provided. pub fn new(fallback_method: WasmExecutionMethod, default_heap_pages: Option) -> Self { - let mut host_functions = runtime_io::SubstrateHostFunctions::host_functions(); + let mut host_functions = sp_io::SubstrateHostFunctions::host_functions(); // Add the old and deprecated host functions as well, so that we support old wasm runtimes. host_functions.extend( crate::deprecated_host_interface::SubstrateExternals::host_functions(), diff --git a/substrate/client/executor/src/wasm_runtime.rs b/substrate/client/executor/src/wasm_runtime.rs index 5014c05816..e033285232 100644 --- a/substrate/client/executor/src/wasm_runtime.rs +++ b/substrate/client/executor/src/wasm_runtime.rs @@ -263,7 +263,7 @@ mod tests { #[test] fn host_functions_are_equal() { - let host_functions = runtime_io::SubstrateHostFunctions::host_functions(); + let host_functions = sp_io::SubstrateHostFunctions::host_functions(); let equal = &host_functions[..] == &host_functions[..]; assert!(equal, "Host functions are not equal"); diff --git a/substrate/client/rpc/Cargo.toml b/substrate/client/rpc/Cargo.toml index e167e26a67..534764bfd2 100644 --- a/substrate/client/rpc/Cargo.toml +++ b/substrate/client/rpc/Cargo.toml @@ -33,7 +33,7 @@ assert_matches = "1.3.0" futures01 = { package = "futures", version = "0.1.29" } network = { package = "sc-network", path = "../network" } rustc-hex = "2.0.1" -sp-io = { path = "../../primitives/sr-io" } +sp-io = { path = "../../primitives/io" } test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client" } tokio = "0.1.22" txpool = { package = "sc-transaction-pool", path = "../transaction-pool" } diff --git a/substrate/client/service/Cargo.toml b/substrate/client/service/Cargo.toml index b5b3db284c..8dfb81996f 100644 --- a/substrate/client/service/Cargo.toml +++ b/substrate/client/service/Cargo.toml @@ -29,7 +29,7 @@ serde_json = "1.0.41" sysinfo = "0.9.5" target_info = "0.1.0" keystore = { package = "sc-keystore", path = "../keystore" } -sp-io = { path = "../../primitives/sr-io" } +sp-io = { path = "../../primitives/io" } sp-runtime = { path = "../../primitives/runtime" } sp-blockchain = { path = "../../primitives/blockchain" } primitives = { package = "sp-core", path = "../../primitives/core" } diff --git a/substrate/docs/CODEOWNERS b/substrate/docs/CODEOWNERS index 5b00436bfd..edb10617f4 100644 --- a/substrate/docs/CODEOWNERS +++ b/substrate/docs/CODEOWNERS @@ -20,7 +20,7 @@ # Wasm execution and the wasm side of Substrate Runtime Interface /client/executor/ @pepyakin -/primitives/sr-io/ @pepyakin +/primitives/io/ @pepyakin # Sandboxing capability of Substrate Runtime /primitives/sr-sandbox/ @pepyakin diff --git a/substrate/frame/assets/Cargo.toml b/substrate/frame/assets/Cargo.toml index 85c3623cfe..4618c2a831 100644 --- a/substrate/frame/assets/Cargo.toml +++ b/substrate/frame/assets/Cargo.toml @@ -17,7 +17,7 @@ system = { package = "frame-system", path = "../system", default-features = fals [dev-dependencies] primitives = { package = "sp-core", path = "../../primitives/core" } sp-std = { path = "../../primitives/std" } -runtime-io = { package = "sp-io", path = "../../primitives/sr-io" } +sp-io = { path = "../../primitives/io" } [features] default = ["std"] diff --git a/substrate/frame/assets/src/lib.rs b/substrate/frame/assets/src/lib.rs index 306ac30d09..af2baae62b 100644 --- a/substrate/frame/assets/src/lib.rs +++ b/substrate/frame/assets/src/lib.rs @@ -287,7 +287,7 @@ mod tests { // This function basically just builds a genesis storage key/value store according to // our desired mockup. - fn new_test_ext() -> runtime_io::TestExternalities { + fn new_test_ext() -> sp_io::TestExternalities { system::GenesisConfig::default().build_storage::().unwrap().into() } diff --git a/substrate/frame/aura/Cargo.toml b/substrate/frame/aura/Cargo.toml index 88194574f2..76b54caf12 100644 --- a/substrate/frame/aura/Cargo.toml +++ b/substrate/frame/aura/Cargo.toml @@ -13,7 +13,7 @@ sp-std = { path = "../../primitives/std", default-features = false } serde = { version = "1.0.101", optional = true } session = { package = "pallet-session", path = "../session", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } -runtime-io ={ package = "sp-io", path = "../../primitives/sr-io", default-features = false } +sp-io ={ path = "../../primitives/io", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } sp-consensus-aura = { path = "../../primitives/consensus/aura", default-features = false} system = { package = "frame-system", path = "../system", default-features = false } @@ -31,7 +31,7 @@ std = [ "app-crypto/std", "codec/std", "inherents/std", - "runtime-io/std", + "sp-io/std", "primitives/std", "sp-std/std", "serde", diff --git a/substrate/frame/aura/src/mock.rs b/substrate/frame/aura/src/mock.rs index 49351ad159..241f904617 100644 --- a/substrate/frame/aura/src/mock.rs +++ b/substrate/frame/aura/src/mock.rs @@ -25,7 +25,7 @@ use sp_runtime::{ testing::{Header, UintAuthorityId}, }; use support::{impl_outer_origin, parameter_types, weights::Weight}; -use runtime_io; +use sp_io; use primitives::H256; impl_outer_origin!{ @@ -72,7 +72,7 @@ impl Trait for Test { type AuthorityId = AuthorityId; } -pub fn new_test_ext(authorities: Vec) -> runtime_io::TestExternalities { +pub fn new_test_ext(authorities: Vec) -> sp_io::TestExternalities { let mut t = system::GenesisConfig::default().build_storage::().unwrap(); GenesisConfig::{ authorities: authorities.into_iter().map(|a| UintAuthorityId(a).to_public_key()).collect(), diff --git a/substrate/frame/authority-discovery/Cargo.toml b/substrate/frame/authority-discovery/Cargo.toml index 40fb6122f5..7d52faf3f8 100644 --- a/substrate/frame/authority-discovery/Cargo.toml +++ b/substrate/frame/authority-discovery/Cargo.toml @@ -11,7 +11,7 @@ codec = { package = "parity-scale-codec", version = "1.0.0", default-features = primitives = { package = "sp-core", path = "../../primitives/core", default-features = false } sp-std = { path = "../../primitives/std", default-features = false } serde = { version = "1.0.101", optional = true } -runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } +sp-io = { path = "../../primitives/io", default-features = false } session = { package = "pallet-session", path = "../session", default-features = false, features = ["historical" ] } sp-runtime = { path = "../../primitives/runtime", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } @@ -27,8 +27,8 @@ std = [ "authority-discovery-primitives/std", "codec/std", "primitives/std", + "sp-io/std", "sp-std/std", - "runtime-io/std", "serde", "session/std", "sp-runtime/std", diff --git a/substrate/frame/authority-discovery/src/lib.rs b/substrate/frame/authority-discovery/src/lib.rs index 92dcb2277d..467b494907 100644 --- a/substrate/frame/authority-discovery/src/lib.rs +++ b/substrate/frame/authority-discovery/src/lib.rs @@ -95,7 +95,7 @@ mod tests { use authority_discovery_primitives::{AuthorityPair}; use app_crypto::Pair; use primitives::{crypto::key_types, H256}; - use runtime_io::TestExternalities; + use sp_io::TestExternalities; use sp_runtime::{ testing::{Header, UintAuthorityId}, traits::{ConvertInto, IdentityLookup, OpaqueKeys}, Perbill, KeyTypeId, diff --git a/substrate/frame/authorship/Cargo.toml b/substrate/frame/authorship/Cargo.toml index 65b299dc29..40a045998c 100644 --- a/substrate/frame/authorship/Cargo.toml +++ b/substrate/frame/authorship/Cargo.toml @@ -14,7 +14,7 @@ sp-std = { path = "../../primitives/std", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } system = { package = "frame-system", path = "../system", default-features = false } -runtime-io ={ package = "sp-io", path = "../../primitives/sr-io", default-features = false } +sp-io ={ path = "../../primitives/io", default-features = false } impl-trait-for-tuples = "0.1.3" [features] @@ -27,6 +27,6 @@ std = [ "sp-std/std", "support/std", "system/std", - "runtime-io/std", + "sp-io/std", "sp-authorship/std", ] diff --git a/substrate/frame/authorship/src/lib.rs b/substrate/frame/authorship/src/lib.rs index a5a032165d..4aa188cf71 100644 --- a/substrate/frame/authorship/src/lib.rs +++ b/substrate/frame/authorship/src/lib.rs @@ -492,7 +492,7 @@ mod tests { ) } - fn new_test_ext() -> runtime_io::TestExternalities { + fn new_test_ext() -> sp_io::TestExternalities { let t = system::GenesisConfig::default().build_storage::().unwrap(); t.into() } diff --git a/substrate/frame/babe/Cargo.toml b/substrate/frame/babe/Cargo.toml index 8124ba6a59..c51b7a2ab4 100644 --- a/substrate/frame/babe/Cargo.toml +++ b/substrate/frame/babe/Cargo.toml @@ -18,7 +18,7 @@ timestamp = { package = "pallet-timestamp", path = "../timestamp", default-featu sp-timestamp = { path = "../../primitives/timestamp", default-features = false } session = { package = "pallet-session", path = "../session", default-features = false } babe-primitives = { package = "sp-consensus-babe", path = "../../primitives/consensus/babe", default-features = false } -runtime-io ={ package = "sp-io", path = "../../primitives/sr-io", default-features = false } +sp-io ={ path = "../../primitives/io", default-features = false } [dev-dependencies] lazy_static = "1.4.0" @@ -42,5 +42,5 @@ std = [ "inherents/std", "babe-primitives/std", "session/std", - "runtime-io/std", + "sp-io/std", ] diff --git a/substrate/frame/babe/src/lib.rs b/substrate/frame/babe/src/lib.rs index a5db17e3bd..663f29ee0c 100644 --- a/substrate/frame/babe/src/lib.rs +++ b/substrate/frame/babe/src/lib.rs @@ -523,7 +523,7 @@ fn compute_randomness( s.extend_from_slice(&vrf_output[..]); } - runtime_io::hashing::blake2_256(&s) + sp_io::hashing::blake2_256(&s) } impl ProvideInherent for Module { diff --git a/substrate/frame/babe/src/mock.rs b/substrate/frame/babe/src/mock.rs index 4ca52e27e3..35a423e2ad 100644 --- a/substrate/frame/babe/src/mock.rs +++ b/substrate/frame/babe/src/mock.rs @@ -24,7 +24,7 @@ use sp_runtime::{ }; use sp_version::RuntimeVersion; use support::{impl_outer_origin, parameter_types, weights::Weight}; -use runtime_io; +use sp_io; use primitives::{H256, Blake2Hasher}; impl_outer_origin!{ @@ -97,7 +97,7 @@ impl Trait for Test { type EpochChangeTrigger = crate::ExternalTrigger; } -pub fn new_test_ext(authorities: Vec) -> runtime_io::TestExternalities { +pub fn new_test_ext(authorities: Vec) -> sp_io::TestExternalities { let mut t = system::GenesisConfig::default().build_storage::().unwrap(); GenesisConfig { authorities: authorities.into_iter().map(|a| (UintAuthorityId(a).to_public_key(), 1)).collect(), diff --git a/substrate/frame/balances/Cargo.toml b/substrate/frame/balances/Cargo.toml index f4c6d9f5a1..9c71401b36 100644 --- a/substrate/frame/balances/Cargo.toml +++ b/substrate/frame/balances/Cargo.toml @@ -14,7 +14,7 @@ support = { package = "frame-support", path = "../support", default-features = f system = { package = "frame-system", path = "../system", default-features = false } [dev-dependencies] -runtime-io = { package = "sp-io", path = "../../primitives/sr-io" } +sp-io = { path = "../../primitives/io" } primitives = { package = "sp-core", path = "../../primitives/core" } transaction-payment = { package = "pallet-transaction-payment", path = "../transaction-payment" } diff --git a/substrate/frame/balances/src/mock.rs b/substrate/frame/balances/src/mock.rs index 029beb5cd2..944aab1493 100644 --- a/substrate/frame/balances/src/mock.rs +++ b/substrate/frame/balances/src/mock.rs @@ -18,7 +18,7 @@ use sp_runtime::{Perbill, traits::{ConvertInto, IdentityLookup}, testing::Header}; use primitives::H256; -use runtime_io; +use sp_io; use support::{impl_outer_origin, parameter_types}; use support::traits::Get; use support::weights::{Weight, DispatchInfo}; @@ -148,7 +148,7 @@ impl ExtBuilder { TRANSFER_FEE.with(|v| *v.borrow_mut() = self.transfer_fee); CREATION_FEE.with(|v| *v.borrow_mut() = self.creation_fee); } - pub fn build(self) -> runtime_io::TestExternalities { + pub fn build(self) -> sp_io::TestExternalities { self.set_associated_consts(); let mut t = system::GenesisConfig::default().build_storage::().unwrap(); GenesisConfig:: { diff --git a/substrate/frame/collective/Cargo.toml b/substrate/frame/collective/Cargo.toml index 8472a13186..5e24e72228 100644 --- a/substrate/frame/collective/Cargo.toml +++ b/substrate/frame/collective/Cargo.toml @@ -10,7 +10,7 @@ safe-mix = { version = "1.0.0", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } primitives = { package = "sp-core", path = "../../primitives/core", default-features = false } sp-std = { path = "../../primitives/std", default-features = false } -runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } +sp-io = { path = "../../primitives/io", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } system = { package = "frame-system", path = "../system", default-features = false } @@ -27,7 +27,7 @@ std = [ "primitives/std", "sp-std/std", "serde", - "runtime-io/std", + "sp-io/std", "support/std", "sp-runtime/std", "system/std", diff --git a/substrate/frame/collective/src/lib.rs b/substrate/frame/collective/src/lib.rs index 176967636d..279c720e85 100644 --- a/substrate/frame/collective/src/lib.rs +++ b/substrate/frame/collective/src/lib.rs @@ -437,7 +437,7 @@ mod tests { } ); - fn make_ext() -> runtime_io::TestExternalities { + fn make_ext() -> sp_io::TestExternalities { GenesisConfig { collective_Instance1: Some(collective::GenesisConfig { members: vec![1, 2, 3], diff --git a/substrate/frame/contracts/Cargo.toml b/substrate/frame/contracts/Cargo.toml index f5c9ec5fdb..06bc0925bb 100644 --- a/substrate/frame/contracts/Cargo.toml +++ b/substrate/frame/contracts/Cargo.toml @@ -12,7 +12,7 @@ parity-wasm = { version = "0.41.0", default-features = false } wasmi-validation = { version = "0.3.0", default-features = false } primitives = { package = "sp-core", path = "../../primitives/core", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } -runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } +sp-io = { path = "../../primitives/io", default-features = false } sp-std = { path = "../../primitives/std", default-features = false } sandbox = { package = "sp-sandbox", path = "../../primitives/sr-sandbox", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } @@ -33,7 +33,7 @@ std = [ "codec/std", "primitives/std", "sp-runtime/std", - "runtime-io/std", + "sp-io/std", "sp-std/std", "sandbox/std", "support/std", diff --git a/substrate/frame/contracts/src/account_db.rs b/substrate/frame/contracts/src/account_db.rs index 962dadff2a..2971f46f37 100644 --- a/substrate/frame/contracts/src/account_db.rs +++ b/substrate/frame/contracts/src/account_db.rs @@ -24,7 +24,7 @@ use crate::exec::StorageKey; use sp_std::cell::RefCell; use sp_std::collections::btree_map::{BTreeMap, Entry}; use sp_std::prelude::*; -use runtime_io::hashing::blake2_256; +use sp_io::hashing::blake2_256; use sp_runtime::traits::{Bounded, Zero}; use support::traits::{Currency, Get, Imbalance, SignedImbalance, UpdateBalanceOutcome}; use support::{storage::child, StorageMap}; diff --git a/substrate/frame/contracts/src/lib.rs b/substrate/frame/contracts/src/lib.rs index e288fba2cc..f342a36a7a 100644 --- a/substrate/frame/contracts/src/lib.rs +++ b/substrate/frame/contracts/src/lib.rs @@ -111,7 +111,7 @@ use serde::{Serialize, Deserialize}; use primitives::crypto::UncheckedFrom; use sp_std::{prelude::*, marker::PhantomData, fmt::Debug}; use codec::{Codec, Encode, Decode}; -use runtime_io::hashing::blake2_256; +use sp_io::hashing::blake2_256; use sp_runtime::{ traits::{Hash, StaticLookup, Zero, MaybeSerializeDeserialize, Member, SignedExtension}, transaction_validity::{ @@ -803,7 +803,7 @@ impl Module { let tombstone = >::new( // This operation is cheap enough because last_write (delta not included) // is not this block as it has been checked earlier. - &runtime_io::storage::child_root(&origin_contract.trie_id)[..], + &sp_io::storage::child_root(&origin_contract.trie_id)[..], code_hash, ); diff --git a/substrate/frame/contracts/src/rent.rs b/substrate/frame/contracts/src/rent.rs index 00bf4bf911..cf96ee2c1b 100644 --- a/substrate/frame/contracts/src/rent.rs +++ b/substrate/frame/contracts/src/rent.rs @@ -99,7 +99,7 @@ fn try_evict_or_and_pay_rent( if balance < subsistence_threshold { // The contract cannot afford to leave a tombstone, so remove the contract info altogether. >::remove(account); - runtime_io::storage::child_storage_kill(&contract.trie_id); + sp_io::storage::child_storage_kill(&contract.trie_id); return (RentOutcome::Evicted, None); } @@ -146,7 +146,7 @@ fn try_evict_or_and_pay_rent( // threshold, so it leaves a tombstone. // Note: this operation is heavy. - let child_storage_root = runtime_io::storage::child_root(&contract.trie_id); + let child_storage_root = sp_io::storage::child_root(&contract.trie_id); let tombstone = >::new( &child_storage_root[..], @@ -155,7 +155,7 @@ fn try_evict_or_and_pay_rent( let tombstone_info = ContractInfo::Tombstone(tombstone); >::insert(account, &tombstone_info); - runtime_io::storage::child_storage_kill(&contract.trie_id); + sp_io::storage::child_storage_kill(&contract.trie_id); return (RentOutcome::Evicted, Some(tombstone_info)); } diff --git a/substrate/frame/contracts/src/tests.rs b/substrate/frame/contracts/src/tests.rs index e2e45ef9c0..153a70d54b 100644 --- a/substrate/frame/contracts/src/tests.rs +++ b/substrate/frame/contracts/src/tests.rs @@ -268,7 +268,7 @@ impl ExtBuilder { INSTANTIATION_FEE.with(|v| *v.borrow_mut() = self.instantiation_fee); BLOCK_GAS_LIMIT.with(|v| *v.borrow_mut() = self.block_gas_limit); } - pub fn build(self) -> runtime_io::TestExternalities { + pub fn build(self) -> sp_io::TestExternalities { self.set_associated_consts(); let mut t = system::GenesisConfig::default().build_storage::().unwrap(); balances::GenesisConfig:: { @@ -282,7 +282,7 @@ impl ExtBuilder { }, gas_price: self.gas_price, }.assimilate_storage(&mut t).unwrap(); - runtime_io::TestExternalities::new(t) + sp_io::TestExternalities::new(t) } } diff --git a/substrate/frame/democracy/Cargo.toml b/substrate/frame/democracy/Cargo.toml index 62e4f60f8e..5772f11af1 100644 --- a/substrate/frame/democracy/Cargo.toml +++ b/substrate/frame/democracy/Cargo.toml @@ -9,7 +9,7 @@ serde = { version = "1.0.101", optional = true, features = ["derive"] } safe-mix = { version = "1.0.0", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } sp-std = { path = "../../primitives/std", default-features = false } -runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } +sp-io = { path = "../../primitives/io", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } system = { package = "frame-system", path = "../system", default-features = false } @@ -25,7 +25,7 @@ std = [ "safe-mix/std", "codec/std", "sp-std/std", - "runtime-io/std", + "sp-io/std", "support/std", "sp-runtime/std", "system/std", diff --git a/substrate/frame/democracy/src/lib.rs b/substrate/frame/democracy/src/lib.rs index d5d8850645..82aecc8557 100644 --- a/substrate/frame/democracy/src/lib.rs +++ b/substrate/frame/democracy/src/lib.rs @@ -1200,14 +1200,14 @@ mod tests { type Slash = (); } - fn new_test_ext() -> runtime_io::TestExternalities { + fn new_test_ext() -> sp_io::TestExternalities { let mut t = system::GenesisConfig::default().build_storage::().unwrap(); balances::GenesisConfig::{ balances: vec![(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60)], vesting: vec![], }.assimilate_storage(&mut t).unwrap(); GenesisConfig::default().assimilate_storage(&mut t).unwrap(); - runtime_io::TestExternalities::new(t) + sp_io::TestExternalities::new(t) } type System = system::Module; diff --git a/substrate/frame/elections-phragmen/Cargo.toml b/substrate/frame/elections-phragmen/Cargo.toml index 979ed48ca2..7415107cd2 100644 --- a/substrate/frame/elections-phragmen/Cargo.toml +++ b/substrate/frame/elections-phragmen/Cargo.toml @@ -13,7 +13,7 @@ system = { package = "frame-system", path = "../system", default-features = fals sp-std = { path = "../../primitives/std", default-features = false } [dev-dependencies] -runtime_io = { package = "sp-io", path = "../../primitives/sr-io" } +sp-io = { path = "../../primitives/io" } hex-literal = "0.2.1" balances = { package = "pallet-balances", path = "../balances" } primitives = { package = "sp-core", path = "../../primitives/core" } diff --git a/substrate/frame/elections-phragmen/src/lib.rs b/substrate/frame/elections-phragmen/src/lib.rs index e87a0e7275..9d5ee4e6b6 100644 --- a/substrate/frame/elections-phragmen/src/lib.rs +++ b/substrate/frame/elections-phragmen/src/lib.rs @@ -929,7 +929,7 @@ mod tests { self.term_duration = duration; self } - pub fn build(self) -> runtime_io::TestExternalities { + pub fn build(self) -> sp_io::TestExternalities { VOTING_BOND.with(|v| *v.borrow_mut() = self.voter_bond); TERM_DURATION.with(|v| *v.borrow_mut() = self.term_duration); DESIRED_RUNNERS_UP.with(|v| *v.borrow_mut() = self.desired_runners_up); diff --git a/substrate/frame/elections/Cargo.toml b/substrate/frame/elections/Cargo.toml index 4077d98879..9a1216f38c 100644 --- a/substrate/frame/elections/Cargo.toml +++ b/substrate/frame/elections/Cargo.toml @@ -10,7 +10,7 @@ safe-mix = { version = "1.0.0", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } primitives = { package = "sp-core", path = "../../primitives/core", default-features = false } sp-std = { path = "../../primitives/std", default-features = false } -runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } +sp-io = { path = "../../primitives/io", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } system = { package = "frame-system", path = "../system", default-features = false } @@ -27,7 +27,7 @@ std = [ "primitives/std", "sp-std/std", "serde", - "runtime-io/std", + "sp-io/std", "support/std", "sp-runtime/std", "system/std", diff --git a/substrate/frame/elections/src/mock.rs b/substrate/frame/elections/src/mock.rs index 692d42cc1b..7e3c762427 100644 --- a/substrate/frame/elections/src/mock.rs +++ b/substrate/frame/elections/src/mock.rs @@ -204,7 +204,7 @@ impl ExtBuilder { self.desired_seats = seats; self } - pub fn build(self) -> runtime_io::TestExternalities { + pub fn build(self) -> sp_io::TestExternalities { VOTER_BOND.with(|v| *v.borrow_mut() = self.voter_bond); VOTING_FEE.with(|v| *v.borrow_mut() = self.voting_fee); PRESENT_SLASH_PER_VOTER.with(|v| *v.borrow_mut() = self.bad_presentation_punishment); @@ -274,7 +274,7 @@ pub(crate) fn locks(who: &u64) -> Vec { Balances::locks(who).iter().map(|l| l.amount).collect::>() } -pub(crate) fn new_test_ext_with_candidate_holes() -> runtime_io::TestExternalities { +pub(crate) fn new_test_ext_with_candidate_holes() -> sp_io::TestExternalities { let mut t = ExtBuilder::default().build(); t.execute_with(|| { >::put(vec![0, 0, 1]); diff --git a/substrate/frame/evm/Cargo.toml b/substrate/frame/evm/Cargo.toml index b933c45382..c6a8083a2f 100644 --- a/substrate/frame/evm/Cargo.toml +++ b/substrate/frame/evm/Cargo.toml @@ -14,7 +14,7 @@ balances = { package = "pallet-balances", path = "../balances", default-features primitives = { package = "sp-core", path = "../../primitives/core", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } sp-std = { path = "../../primitives/std", default-features = false } -runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } +sp-io = { path = "../../primitives/io", default-features = false } primitive-types = { version = "0.6", default-features = false, features = ["rlp"] } rlp = { version = "0.4", default-features = false } evm = { version = "0.14", default-features = false } @@ -30,7 +30,7 @@ std = [ "support/std", "system/std", "balances/std", - "runtime-io/std", + "sp-io/std", "sp-std/std", "sha3/std", "rlp/std", diff --git a/substrate/frame/evm/src/backend.rs b/substrate/frame/evm/src/backend.rs index ab0ed43cc9..aec3371f0b 100644 --- a/substrate/frame/evm/src/backend.rs +++ b/substrate/frame/evm/src/backend.rs @@ -96,7 +96,7 @@ impl<'vicinity, T: Trait> BackendT for Backend<'vicinity, T> { } fn chain_id(&self) -> U256 { - U256::from(runtime_io::misc::chain_id()) + U256::from(sp_io::misc::chain_id()) } fn exists(&self, _address: H160) -> bool { diff --git a/substrate/frame/example/Cargo.toml b/substrate/frame/example/Cargo.toml index 9a6be32519..496d4e64a5 100644 --- a/substrate/frame/example/Cargo.toml +++ b/substrate/frame/example/Cargo.toml @@ -12,7 +12,7 @@ system = { package = "frame-system", path = "../system", default-features = fals balances = { package = "pallet-balances", path = "../balances", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } sp-std = { path = "../../primitives/std", default-features = false } -runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } +sp-io = { path = "../../primitives/io", default-features = false } [dev-dependencies] primitives = { package = "sp-core", path = "../../primitives/core" } @@ -26,6 +26,6 @@ std = [ "support/std", "system/std", "balances/std", - "runtime-io/std", + "sp-io/std", "sp-std/std" ] diff --git a/substrate/frame/example/src/lib.rs b/substrate/frame/example/src/lib.rs index f591b3c9d7..10f075ec6d 100644 --- a/substrate/frame/example/src/lib.rs +++ b/substrate/frame/example/src/lib.rs @@ -530,7 +530,7 @@ decl_module! { fn offchain_worker(_n: T::BlockNumber) { // We don't do anything here. // but we could dispatch extrinsic (transaction/unsigned/inherent) using - // runtime_io::submit_extrinsic + // sp_io::submit_extrinsic } } } @@ -709,7 +709,7 @@ mod tests { // This function basically just builds a genesis storage key/value store according to // our desired mockup. - fn new_test_ext() -> runtime_io::TestExternalities { + fn new_test_ext() -> sp_io::TestExternalities { let mut t = system::GenesisConfig::default().build_storage::().unwrap(); // We use default for brevity, but you can configure as desired if needed. balances::GenesisConfig::::default().assimilate_storage(&mut t).unwrap(); diff --git a/substrate/frame/executive/Cargo.toml b/substrate/frame/executive/Cargo.toml index 0e2e748066..3220e2ba49 100644 --- a/substrate/frame/executive/Cargo.toml +++ b/substrate/frame/executive/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" serde = { version = "1.0.101", optional = true } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } sp-std = { path = "../../primitives/std", default-features = false } -runtime-io ={ package = "sp-io", path = "../../primitives/sr-io", default-features = false } +sp-io ={ path = "../../primitives/io", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } system = { package = "frame-system", path = "../system", default-features = false } @@ -28,6 +28,6 @@ std = [ "serde", "codec/std", "sp-runtime/std", - "runtime-io/std", + "sp-io/std", "system/std", ] diff --git a/substrate/frame/executive/src/lib.rs b/substrate/frame/executive/src/lib.rs index 7c94c9c012..efe963a6d3 100644 --- a/substrate/frame/executive/src/lib.rs +++ b/substrate/frame/executive/src/lib.rs @@ -493,7 +493,7 @@ mod tests { }.assimilate_storage(&mut t).unwrap(); let xt = sp_runtime::testing::TestXt(sign_extra(1, 0, 0), Call::Balances(BalancesCall::transfer(2, 69))); let weight = xt.get_dispatch_info().weight as u64; - let mut t = runtime_io::TestExternalities::new(t); + let mut t = sp_io::TestExternalities::new(t); t.execute_with(|| { Executive::initialize_block(&Header::new( 1, @@ -509,7 +509,7 @@ mod tests { }); } - fn new_test_ext(balance_factor: u64) -> runtime_io::TestExternalities { + fn new_test_ext(balance_factor: u64) -> sp_io::TestExternalities { let mut t = system::GenesisConfig::default().build_storage::().unwrap(); balances::GenesisConfig:: { balances: vec![(1, 111 * balance_factor)], diff --git a/substrate/frame/finality-tracker/Cargo.toml b/substrate/frame/finality-tracker/Cargo.toml index 29e304e692..6169ba8c03 100644 --- a/substrate/frame/finality-tracker/Cargo.toml +++ b/substrate/frame/finality-tracker/Cargo.toml @@ -17,7 +17,7 @@ impl-trait-for-tuples = "0.1.3" [dev-dependencies] primitives = { package = "sp-core", path = "../../primitives/core", default-features = false } -runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } +sp-io = { path = "../../primitives/io", default-features = false } [features] default = ["std"] diff --git a/substrate/frame/finality-tracker/src/lib.rs b/substrate/frame/finality-tracker/src/lib.rs index d15953d5ae..14aba50834 100644 --- a/substrate/frame/finality-tracker/src/lib.rs +++ b/substrate/frame/finality-tracker/src/lib.rs @@ -193,7 +193,7 @@ impl ProvideInherent for Module { mod tests { use super::*; - use runtime_io::TestExternalities; + use sp_io::TestExternalities; use primitives::H256; use sp_runtime::{ testing::Header, Perbill, diff --git a/substrate/frame/generic-asset/Cargo.toml b/substrate/frame/generic-asset/Cargo.toml index 1cdbc47394..2b4b5e3ac0 100644 --- a/substrate/frame/generic-asset/Cargo.toml +++ b/substrate/frame/generic-asset/Cargo.toml @@ -13,7 +13,7 @@ support = { package = "frame-support", path = "../support", default-features = f system = { package = "frame-system", path = "../system", default-features = false } [dev-dependencies] -runtime-io ={ package = "sp-io", path = "../../primitives/sr-io" } +sp-io ={ path = "../../primitives/io" } primitives = { package = "sp-core", path = "../../primitives/core" } [features] diff --git a/substrate/frame/generic-asset/src/mock.rs b/substrate/frame/generic-asset/src/mock.rs index 28d6f96de1..461fb0aeca 100644 --- a/substrate/frame/generic-asset/src/mock.rs +++ b/substrate/frame/generic-asset/src/mock.rs @@ -117,7 +117,7 @@ impl ExtBuilder { } // builds genesis config - pub fn build(self) -> runtime_io::TestExternalities { + pub fn build(self) -> sp_io::TestExternalities { let mut t = system::GenesisConfig::default().build_storage::().unwrap(); GenesisConfig:: { @@ -136,7 +136,7 @@ impl ExtBuilder { // This function basically just builds a genesis storage key/value store according to // our desired mockup. -pub fn new_test_ext() -> runtime_io::TestExternalities { +pub fn new_test_ext() -> sp_io::TestExternalities { system::GenesisConfig::default() .build_storage::() .unwrap() diff --git a/substrate/frame/grandpa/Cargo.toml b/substrate/frame/grandpa/Cargo.toml index ebb1143e1f..c7e61844c9 100644 --- a/substrate/frame/grandpa/Cargo.toml +++ b/substrate/frame/grandpa/Cargo.toml @@ -18,7 +18,7 @@ session = { package = "pallet-session", path = "../session", default-features = finality-tracker = { package = "pallet-finality-tracker", path = "../finality-tracker", default-features = false } [dev-dependencies] -runtime-io ={ package = "sp-io", path = "../../primitives/sr-io" } +sp-io ={ path = "../../primitives/io" } [features] default = ["std"] diff --git a/substrate/frame/grandpa/src/mock.rs b/substrate/frame/grandpa/src/mock.rs index fb153d71cf..8826414cfc 100644 --- a/substrate/frame/grandpa/src/mock.rs +++ b/substrate/frame/grandpa/src/mock.rs @@ -19,7 +19,7 @@ #![cfg(test)] use sp_runtime::{Perbill, DigestItem, traits::IdentityLookup, testing::{Header, UintAuthorityId}}; -use runtime_io; +use sp_io; use support::{impl_outer_origin, impl_outer_event, parameter_types, weights::Weight}; use primitives::H256; use codec::{Encode, Decode}; @@ -81,7 +81,7 @@ pub fn to_authorities(vec: Vec<(u64, u64)>) -> AuthorityList { .collect() } -pub fn new_test_ext(authorities: Vec<(u64, u64)>) -> runtime_io::TestExternalities { +pub fn new_test_ext(authorities: Vec<(u64, u64)>) -> sp_io::TestExternalities { let mut t = system::GenesisConfig::default().build_storage::().unwrap(); GenesisConfig { authorities: to_authorities(authorities), diff --git a/substrate/frame/identity/Cargo.toml b/substrate/frame/identity/Cargo.toml index 8fcc01b0c8..c1518bfcfc 100644 --- a/substrate/frame/identity/Cargo.toml +++ b/substrate/frame/identity/Cargo.toml @@ -9,7 +9,7 @@ serde = { version = "1.0.101", optional = true } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } enumflags2 = { version = "0.6.2" } sp-std = { path = "../../primitives/std", default-features = false } -runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } +sp-io = { path = "../../primitives/io", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } system = { package = "frame-system", path = "../system", default-features = false } @@ -24,7 +24,7 @@ std = [ "serde", "codec/std", "sp-std/std", - "runtime-io/std", + "sp-io/std", "sp-runtime/std", "support/std", "system/std", diff --git a/substrate/frame/identity/src/lib.rs b/substrate/frame/identity/src/lib.rs index 8422382057..bea85f6a14 100644 --- a/substrate/frame/identity/src/lib.rs +++ b/substrate/frame/identity/src/lib.rs @@ -853,7 +853,7 @@ mod tests { // This function basically just builds a genesis storage key/value store according to // our desired mockup. - fn new_test_ext() -> runtime_io::TestExternalities { + fn new_test_ext() -> sp_io::TestExternalities { let mut t = system::GenesisConfig::default().build_storage::().unwrap(); // We use default for brevity, but you can configure as desired if needed. balances::GenesisConfig:: { diff --git a/substrate/frame/im-online/Cargo.toml b/substrate/frame/im-online/Cargo.toml index e9b9e049a5..5110f511d1 100644 --- a/substrate/frame/im-online/Cargo.toml +++ b/substrate/frame/im-online/Cargo.toml @@ -12,7 +12,7 @@ primitives = { package="sp-core", path = "../../primitives/core", default-featur sp-std = { path = "../../primitives/std", default-features = false } serde = { version = "1.0.101", optional = true } session = { package = "pallet-session", path = "../session", default-features = false } -runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } +sp-io = { path = "../../primitives/io", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } sp-staking = { path = "../../primitives/sr-staking-primitives", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } @@ -28,7 +28,7 @@ std = [ "sp-std/std", "serde", "session/std", - "runtime-io/std", + "sp-io/std", "sp-runtime/std", "sp-staking/std", "support/std", diff --git a/substrate/frame/im-online/src/lib.rs b/substrate/frame/im-online/src/lib.rs index 70ffc40378..c9991cf690 100644 --- a/substrate/frame/im-online/src/lib.rs +++ b/substrate/frame/im-online/src/lib.rs @@ -285,7 +285,7 @@ decl_module! { debug::RuntimeLogger::init(); // Only send messages if we are a potential validator. - if runtime_io::offchain::is_validator() { + if sp_io::offchain::is_validator() { Self::offchain(now); } } @@ -408,7 +408,7 @@ impl Module { continue; } - let network_state = runtime_io::offchain::network_state() + let network_state = sp_io::offchain::network_state() .map_err(|_| OffchainErr::NetworkState)?; let heartbeat_data = Heartbeat { block_number, @@ -453,7 +453,7 @@ impl Module { done, gossipping_at, }; - runtime_io::offchain::local_storage_compare_and_set( + sp_io::offchain::local_storage_compare_and_set( StorageKind::PERSISTENT, DB_KEY, curr_worker_status, @@ -469,7 +469,7 @@ impl Module { done, gossipping_at, }; - runtime_io::offchain::local_storage_set(StorageKind::PERSISTENT, DB_KEY, &enc.encode()); + sp_io::offchain::local_storage_set(StorageKind::PERSISTENT, DB_KEY, &enc.encode()); } // Checks if a heartbeat gossip already occurred at this block number. @@ -479,7 +479,7 @@ impl Module { now: T::BlockNumber, next_gossip: T::BlockNumber, ) -> Result<(Option>, bool), OffchainErr> { - let last_gossip = runtime_io::offchain::local_storage_get(StorageKind::PERSISTENT, DB_KEY); + let last_gossip = sp_io::offchain::local_storage_get(StorageKind::PERSISTENT, DB_KEY); match last_gossip { Some(last) => { let worker_status: WorkerStatus = Decode::decode(&mut &last[..]) diff --git a/substrate/frame/im-online/src/mock.rs b/substrate/frame/im-online/src/mock.rs index 03cf96cd28..48af849195 100644 --- a/substrate/frame/im-online/src/mock.rs +++ b/substrate/frame/im-online/src/mock.rs @@ -27,7 +27,7 @@ use sp_runtime::testing::{Header, UintAuthorityId, TestXt}; use sp_runtime::traits::{IdentityLookup, BlakeTwo256, ConvertInto}; use primitives::H256; use support::{impl_outer_origin, impl_outer_dispatch, parameter_types, weights::Weight}; -use {runtime_io, system}; +use {sp_io, system}; impl_outer_origin!{ pub enum Origin for Runtime {} @@ -85,7 +85,7 @@ impl ReportOffence for OffenceHandler { } } -pub fn new_test_ext() -> runtime_io::TestExternalities { +pub fn new_test_ext() -> sp_io::TestExternalities { let t = system::GenesisConfig::default().build_storage::().unwrap(); t.into() } diff --git a/substrate/frame/im-online/src/tests.rs b/substrate/frame/im-online/src/tests.rs index 0145b7c4fe..db91a215de 100644 --- a/substrate/frame/im-online/src/tests.rs +++ b/substrate/frame/im-online/src/tests.rs @@ -224,7 +224,7 @@ fn should_generate_heartbeats() { assert_eq!(heartbeat, Heartbeat { block_number: 2, - network_state: runtime_io::offchain::network_state().unwrap(), + network_state: sp_io::offchain::network_state().unwrap(), session_index: 2, authority_index: 2, }); @@ -329,7 +329,7 @@ fn should_not_send_a_report_if_already_online() { assert_eq!(heartbeat, Heartbeat { block_number: 4, - network_state: runtime_io::offchain::network_state().unwrap(), + network_state: sp_io::offchain::network_state().unwrap(), session_index: 2, authority_index: 0, }); diff --git a/substrate/frame/indices/Cargo.toml b/substrate/frame/indices/Cargo.toml index 05e5bfd451..2503d0ea60 100644 --- a/substrate/frame/indices/Cargo.toml +++ b/substrate/frame/indices/Cargo.toml @@ -10,7 +10,7 @@ safe-mix = { version = "1.0.0", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } sp-keyring = { path = "../../primitives/keyring", optional = true } sp-std = { path = "../../primitives/std", default-features = false } -runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } +sp-io = { path = "../../primitives/io", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } primitives = { package = "sp-core", path = "../../primitives/core", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } @@ -28,7 +28,7 @@ std = [ "codec/std", "primitives/std", "sp-std/std", - "runtime-io/std", + "sp-io/std", "support/std", "sp-runtime/std", "system/std", diff --git a/substrate/frame/indices/src/mock.rs b/substrate/frame/indices/src/mock.rs index 880ff5d66e..ea24f46e13 100644 --- a/substrate/frame/indices/src/mock.rs +++ b/substrate/frame/indices/src/mock.rs @@ -24,7 +24,7 @@ use sp_runtime::testing::Header; use sp_runtime::Perbill; use primitives::H256; use support::{impl_outer_origin, parameter_types, weights::Weight}; -use {runtime_io, system}; +use {sp_io, system}; use crate::{GenesisConfig, Module, Trait, IsDeadAccount, OnNewAccount, ResolveHint}; impl_outer_origin!{ @@ -95,7 +95,7 @@ impl Trait for Runtime { type Event = (); } -pub fn new_test_ext() -> runtime_io::TestExternalities { +pub fn new_test_ext() -> sp_io::TestExternalities { { let mut h = ALIVE.borrow_mut(); h.clear(); diff --git a/substrate/frame/membership/Cargo.toml b/substrate/frame/membership/Cargo.toml index 1973dfba19..13c6fba9f9 100644 --- a/substrate/frame/membership/Cargo.toml +++ b/substrate/frame/membership/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" serde = { version = "1.0.101", optional = true } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } sp-std = { path = "../../primitives/std", default-features = false } -runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } +sp-io = { path = "../../primitives/io", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } system = { package = "frame-system", path = "../system", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } @@ -23,7 +23,7 @@ std = [ "codec/std", "sp-runtime/std", "sp-std/std", - "runtime-io/std", + "sp-io/std", "support/std", "system/std", ] diff --git a/substrate/frame/membership/src/lib.rs b/substrate/frame/membership/src/lib.rs index a7bbceaf27..2c441f2d72 100644 --- a/substrate/frame/membership/src/lib.rs +++ b/substrate/frame/membership/src/lib.rs @@ -306,7 +306,7 @@ mod tests { // This function basically just builds a genesis storage key/value store according to // our desired mockup. - fn new_test_ext() -> runtime_io::TestExternalities { + fn new_test_ext() -> sp_io::TestExternalities { let mut t = system::GenesisConfig::default().build_storage::().unwrap(); // We use default for brevity, but you can configure as desired if needed. GenesisConfig::{ diff --git a/substrate/frame/nicks/Cargo.toml b/substrate/frame/nicks/Cargo.toml index d7d94a564d..924d706d51 100644 --- a/substrate/frame/nicks/Cargo.toml +++ b/substrate/frame/nicks/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" serde = { version = "1.0.101", optional = true } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } sp-std = { path = "../../primitives/std", default-features = false } -runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } +sp-io = { path = "../../primitives/io", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } system = { package = "frame-system", path = "../system", default-features = false } @@ -23,7 +23,7 @@ std = [ "serde", "codec/std", "sp-std/std", - "runtime-io/std", + "sp-io/std", "sp-runtime/std", "support/std", "system/std", diff --git a/substrate/frame/nicks/src/lib.rs b/substrate/frame/nicks/src/lib.rs index 60b1d3e5cb..95fd6f5b82 100644 --- a/substrate/frame/nicks/src/lib.rs +++ b/substrate/frame/nicks/src/lib.rs @@ -306,7 +306,7 @@ mod tests { // This function basically just builds a genesis storage key/value store according to // our desired mockup. - fn new_test_ext() -> runtime_io::TestExternalities { + fn new_test_ext() -> sp_io::TestExternalities { let mut t = system::GenesisConfig::default().build_storage::().unwrap(); // We use default for brevity, but you can configure as desired if needed. balances::GenesisConfig:: { diff --git a/substrate/frame/offences/Cargo.toml b/substrate/frame/offences/Cargo.toml index 3f3a6d8b4c..4aac6d0860 100644 --- a/substrate/frame/offences/Cargo.toml +++ b/substrate/frame/offences/Cargo.toml @@ -15,7 +15,7 @@ support = { package = "frame-support", path = "../support", default-features = f system = { package = "frame-system", path = "../system", default-features = false } [dev-dependencies] -runtime-io = { package = "sp-io", path = "../../primitives/sr-io" } +sp-io = { path = "../../primitives/io" } sp-core = { path = "../../primitives/core" } [features] diff --git a/substrate/frame/offences/src/mock.rs b/substrate/frame/offences/src/mock.rs index ad1d0f8b26..abe84fe5f5 100644 --- a/substrate/frame/offences/src/mock.rs +++ b/substrate/frame/offences/src/mock.rs @@ -33,7 +33,7 @@ use support::{ impl_outer_origin, impl_outer_event, parameter_types, StorageMap, StorageDoubleMap, weights::Weight, }; -use {runtime_io, system}; +use {sp_io, system}; impl_outer_origin!{ pub enum Origin for Runtime {} @@ -106,7 +106,7 @@ impl_outer_event! { } } -pub fn new_test_ext() -> runtime_io::TestExternalities { +pub fn new_test_ext() -> sp_io::TestExternalities { let t = system::GenesisConfig::default().build_storage::().unwrap(); t.into() } diff --git a/substrate/frame/randomness-collective-flip/Cargo.toml b/substrate/frame/randomness-collective-flip/Cargo.toml index 1ef171ab54..1840e795f5 100644 --- a/substrate/frame/randomness-collective-flip/Cargo.toml +++ b/substrate/frame/randomness-collective-flip/Cargo.toml @@ -14,7 +14,7 @@ sp-std = { path = "../../primitives/std", default-features = false } [dev-dependencies] primitives = { package = "sp-core", path = "../../primitives/core" } -runtime-io = { package = "sp-io", path = "../../primitives/sr-io" } +sp-io = { path = "../../primitives/io" } [features] default = ["std"] diff --git a/substrate/frame/randomness-collective-flip/src/lib.rs b/substrate/frame/randomness-collective-flip/src/lib.rs index a4c568abd0..17b681d2e0 100644 --- a/substrate/frame/randomness-collective-flip/src/lib.rs +++ b/substrate/frame/randomness-collective-flip/src/lib.rs @@ -193,7 +193,7 @@ mod tests { type System = system::Module; type CollectiveFlip = Module; - fn new_test_ext() -> runtime_io::TestExternalities { + fn new_test_ext() -> sp_io::TestExternalities { let t = system::GenesisConfig::default().build_storage::().unwrap(); t.into() } diff --git a/substrate/frame/scored-pool/Cargo.toml b/substrate/frame/scored-pool/Cargo.toml index a21998fcb7..5ac049d1e2 100644 --- a/substrate/frame/scored-pool/Cargo.toml +++ b/substrate/frame/scored-pool/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } serde = { version = "1.0.101", optional = true } -runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } +sp-io = { path = "../../primitives/io", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } sp-std = { path = "../../primitives/std", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } @@ -22,7 +22,7 @@ default = ["std"] std = [ "codec/std", "serde", - "runtime-io/std", + "sp-io/std", "sp-runtime/std", "sp-std/std", "support/std", diff --git a/substrate/frame/scored-pool/src/mock.rs b/substrate/frame/scored-pool/src/mock.rs index 353e71882e..06e11e62eb 100644 --- a/substrate/frame/scored-pool/src/mock.rs +++ b/substrate/frame/scored-pool/src/mock.rs @@ -125,7 +125,7 @@ impl Trait for Test { // This function basically just builds a genesis storage key/value store according to // our desired mockup. -pub fn new_test_ext() -> runtime_io::TestExternalities { +pub fn new_test_ext() -> sp_io::TestExternalities { let mut t = system::GenesisConfig::default().build_storage::().unwrap(); // We use default for brevity, but you can configure as desired if needed. balances::GenesisConfig:: { diff --git a/substrate/frame/session/Cargo.toml b/substrate/frame/session/Cargo.toml index e55c6b7bb2..3df9b868f9 100644 --- a/substrate/frame/session/Cargo.toml +++ b/substrate/frame/session/Cargo.toml @@ -15,7 +15,7 @@ support = { package = "frame-support", path = "../support", default-features = f system = { package = "frame-system", path = "../system", default-features = false } timestamp = { package = "pallet-timestamp", path = "../timestamp", default-features = false } sp-trie = { path = "../../primitives/trie", default-features = false, optional = true } -runtime-io ={ package = "sp-io", path = "../../primitives/sr-io", default-features = false } +sp-io ={ path = "../../primitives/io", default-features = false } impl-trait-for-tuples = "0.1.3" [dev-dependencies] @@ -36,5 +36,5 @@ std = [ "sp-staking/std", "timestamp/std", "sp-trie/std", - "runtime-io/std", + "sp-io/std", ] diff --git a/substrate/frame/session/src/historical.rs b/substrate/frame/session/src/historical.rs index 32e7203150..e116e6ac34 100644 --- a/substrate/frame/session/src/historical.rs +++ b/substrate/frame/session/src/historical.rs @@ -320,14 +320,14 @@ mod tests { type Historical = Module; - fn new_test_ext() -> runtime_io::TestExternalities { + fn new_test_ext() -> sp_io::TestExternalities { let mut t = system::GenesisConfig::default().build_storage::().unwrap(); crate::GenesisConfig:: { keys: NEXT_VALIDATORS.with(|l| l.borrow().iter().cloned().map(|i| (i, UintAuthorityId(i).into())).collect() ), }.assimilate_storage(&mut t).unwrap(); - runtime_io::TestExternalities::new(t) + sp_io::TestExternalities::new(t) } #[test] diff --git a/substrate/frame/session/src/lib.rs b/substrate/frame/session/src/lib.rs index 6c6be7a573..2fb08540c0 100644 --- a/substrate/frame/session/src/lib.rs +++ b/substrate/frame/session/src/lib.rs @@ -729,14 +729,14 @@ mod tests { reset_before_session_end_called, before_session_end_called, }; - fn new_test_ext() -> runtime_io::TestExternalities { + fn new_test_ext() -> sp_io::TestExternalities { let mut t = system::GenesisConfig::default().build_storage::().unwrap(); GenesisConfig:: { keys: NEXT_VALIDATORS.with(|l| l.borrow().iter().cloned().map(|i| (i, UintAuthorityId(i).into())).collect() ), }.assimilate_storage(&mut t).unwrap(); - runtime_io::TestExternalities::new(t) + sp_io::TestExternalities::new(t) } fn initialize_block(block: u64) { diff --git a/substrate/frame/staking/Cargo.toml b/substrate/frame/staking/Cargo.toml index 501527847e..320a82ac2d 100644 --- a/substrate/frame/staking/Cargo.toml +++ b/substrate/frame/staking/Cargo.toml @@ -11,7 +11,7 @@ codec = { package = "parity-scale-codec", version = "1.0.0", default-features = sp-keyring = { path = "../../primitives/keyring", optional = true } sp-std = { path = "../../primitives/std", default-features = false } phragmen = { package = "sp-phragmen", path = "../../primitives/phragmen", default-features = false } -runtime-io ={ package = "sp-io", path = "../../primitives/sr-io", default-features = false } +sp-io ={ path = "../../primitives/io", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } sp-staking = { path = "../../primitives/sr-staking-primitives", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } @@ -37,7 +37,7 @@ std = [ "codec/std", "sp-std/std", "phragmen/std", - "runtime-io/std", + "sp-io/std", "support/std", "sp-runtime/std", "sp-staking/std", diff --git a/substrate/frame/staking/src/mock.rs b/substrate/frame/staking/src/mock.rs index 9bd60e2923..91c6b3c2a1 100644 --- a/substrate/frame/staking/src/mock.rs +++ b/substrate/frame/staking/src/mock.rs @@ -23,7 +23,7 @@ use sp_runtime::traits::{IdentityLookup, Convert, OpaqueKeys, OnInitialize, Satu use sp_runtime::testing::{Header, UintAuthorityId}; use sp_staking::{SessionIndex, offence::{OffenceDetails, OnOffenceHandler}}; use primitives::{H256, crypto::key_types}; -use runtime_io; +use sp_io; use support::{ assert_ok, impl_outer_origin, parameter_types, StorageLinkedMap, StorageValue, traits::{Currency, Get, FindAuthor}, @@ -289,7 +289,7 @@ impl ExtBuilder { EXISTENTIAL_DEPOSIT.with(|v| *v.borrow_mut() = self.existential_deposit); SLASH_DEFER_DURATION.with(|v| *v.borrow_mut() = self.slash_defer_duration); } - pub fn build(self) -> runtime_io::TestExternalities { + pub fn build(self) -> sp_io::TestExternalities { self.set_associated_consts(); let mut storage = system::GenesisConfig::default().build_storage::().unwrap(); let balance_factor = if self.existential_deposit > 0 { @@ -355,7 +355,7 @@ impl ExtBuilder { keys: validators.iter().map(|x| (*x, UintAuthorityId(*x))).collect(), }.assimilate_storage(&mut storage); - let mut ext = runtime_io::TestExternalities::from(storage); + let mut ext = sp_io::TestExternalities::from(storage); ext.execute_with(|| { let validators = Session::validators(); SESSION.with(|x| diff --git a/substrate/frame/sudo/Cargo.toml b/substrate/frame/sudo/Cargo.toml index f16c0013b8..1487df43b5 100644 --- a/substrate/frame/sudo/Cargo.toml +++ b/substrate/frame/sudo/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" serde = { version = "1.0.101", optional = true } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } sp-std = { path = "../../primitives/std", default-features = false } -runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } +sp-io = { path = "../../primitives/io", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } system = { package = "frame-system", path = "../system", default-features = false } @@ -22,7 +22,7 @@ std = [ "serde", "codec/std", "sp-std/std", - "runtime-io/std", + "sp-io/std", "sp-runtime/std", "support/std", "system/std", diff --git a/substrate/frame/support/Cargo.toml b/substrate/frame/support/Cargo.toml index 0f897bcda8..94b392fb50 100644 --- a/substrate/frame/support/Cargo.toml +++ b/substrate/frame/support/Cargo.toml @@ -10,7 +10,7 @@ serde = { version = "1.0.101", optional = true, features = ["derive"] } codec = { package = "parity-scale-codec", version = "1.0.6", default-features = false, features = ["derive"] } frame-metadata = { path = "../metadata", default-features = false } sp-std = { path = "../../primitives/std", default-features = false } -runtime-io ={ package = "sp-io", path = "../../primitives/sr-io", default-features = false } +sp-io ={ path = "../../primitives/io", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } primitives = { package = "sp-core", path = "../../primitives/core", default-features = false } sp-arithmetic = { path = "../../primitives/sr-arithmetic", default-features = false } @@ -34,7 +34,7 @@ std = [ "once_cell", "bitmask/std", "serde", - "runtime-io/std", + "sp-io/std", "codec/std", "sp-std/std", "sp-runtime/std", diff --git a/substrate/frame/support/src/debug.rs b/substrate/frame/support/src/debug.rs index c872bc79df..0609148092 100644 --- a/substrate/frame/support/src/debug.rs +++ b/substrate/frame/support/src/debug.rs @@ -155,7 +155,7 @@ impl fmt::Write for Writer { impl Writer { /// Print the content of this `Writer` out. pub fn print(&self) { - runtime_io::misc::print_utf8(&self.0) + sp_io::misc::print_utf8(&self.0) } } @@ -204,7 +204,7 @@ impl log::Log for RuntimeLogger { let mut w = Writer::default(); let _ = core::write!(&mut w, "{}", record.args()); - runtime_io::logging::log( + sp_io::logging::log( record.level().into(), record.target(), &w.0, diff --git a/substrate/frame/support/src/hash.rs b/substrate/frame/support/src/hash.rs index 74a061dfc4..d9c1247f7b 100644 --- a/substrate/frame/support/src/hash.rs +++ b/substrate/frame/support/src/hash.rs @@ -18,7 +18,7 @@ use codec::Codec; use sp_std::prelude::Vec; -use runtime_io::hashing::{blake2_128, blake2_256, twox_64, twox_128, twox_256}; +use sp_io::hashing::{blake2_128, blake2_256, twox_64, twox_128, twox_256}; // This trait must be kept coherent with frame-support-procedural HasherKind usage pub trait Hashable: Sized { diff --git a/substrate/frame/support/src/lib.rs b/substrate/frame/support/src/lib.rs index 7c121d7ebf..1ddc6db65c 100644 --- a/substrate/frame/support/src/lib.rs +++ b/substrate/frame/support/src/lib.rs @@ -41,7 +41,7 @@ pub use paste; #[doc(hidden)] pub use state_machine::BasicExternalities; #[doc(hidden)] -pub use runtime_io::storage::root as storage_root; +pub use sp_io::storage::root as storage_root; #[doc(hidden)] pub use sp_runtime::RuntimeDebug; @@ -249,7 +249,7 @@ mod tests { type Origin = u32; } - fn new_test_ext() -> runtime_io::TestExternalities { + fn new_test_ext() -> sp_io::TestExternalities { GenesisConfig::default().build_storage().unwrap().into() } diff --git a/substrate/frame/support/src/storage/child.rs b/substrate/frame/support/src/storage/child.rs index 1930de57bb..6fb8ce87b7 100644 --- a/substrate/frame/support/src/storage/child.rs +++ b/substrate/frame/support/src/storage/child.rs @@ -26,7 +26,7 @@ use codec::{Codec, Encode, Decode}; /// Return the value of the item in storage under `key`, or `None` if there is no explicit entry. pub fn get(storage_key: &[u8], key: &[u8]) -> Option { - runtime_io::storage::child_get(storage_key, key).and_then(|v| { + sp_io::storage::child_get(storage_key, key).and_then(|v| { Decode::decode(&mut &v[..]).map(Some).unwrap_or_else(|_| { // TODO #3700: error should be handleable. runtime_print!("ERROR: Corrupted state in child trie at {:?}/{:?}", storage_key, key); @@ -59,7 +59,7 @@ pub fn get_or_else T>( /// Put `value` in storage under `key`. pub fn put(storage_key: &[u8], key: &[u8], value: &T) { - value.using_encoded(|slice| runtime_io::storage::child_set(storage_key, key, slice)); + value.using_encoded(|slice| sp_io::storage::child_set(storage_key, key, slice)); } /// Remove `key` from storage, returning its value if it had an explicit entry or `None` otherwise. @@ -95,25 +95,25 @@ pub fn take_or_else T>( /// Check to see if `key` has an explicit entry in storage. pub fn exists(storage_key: &[u8], key: &[u8]) -> bool { - runtime_io::storage::child_read(storage_key, key, &mut [0;0][..], 0).is_some() + sp_io::storage::child_read(storage_key, key, &mut [0;0][..], 0).is_some() } /// Remove all `storage_key` key/values pub fn kill_storage(storage_key: &[u8]) { - runtime_io::storage::child_storage_kill(storage_key) + sp_io::storage::child_storage_kill(storage_key) } /// Ensure `key` has no explicit entry in storage. pub fn kill(storage_key: &[u8], key: &[u8]) { - runtime_io::storage::child_clear(storage_key, key); + sp_io::storage::child_clear(storage_key, key); } /// Get a Vec of bytes from storage. pub fn get_raw(storage_key: &[u8], key: &[u8]) -> Option> { - runtime_io::storage::child_get(storage_key, key) + sp_io::storage::child_get(storage_key, key) } /// Put a raw byte slice into storage. pub fn put_raw(storage_key: &[u8], key: &[u8], value: &[u8]) { - runtime_io::storage::child_set(storage_key, key, value) + sp_io::storage::child_set(storage_key, key, value) } diff --git a/substrate/frame/support/src/storage/generator/mod.rs b/substrate/frame/support/src/storage/generator/mod.rs index 2db3e08ccf..27df37a5c5 100644 --- a/substrate/frame/support/src/storage/generator/mod.rs +++ b/substrate/frame/support/src/storage/generator/mod.rs @@ -35,7 +35,7 @@ pub use value::StorageValue; #[cfg(test)] #[allow(dead_code)] mod tests { - use runtime_io::TestExternalities; + use sp_io::TestExternalities; use codec::{Encode, Decode}; use crate::storage::{unhashed, generator::{StorageValue, StorageLinkedMap}}; diff --git a/substrate/frame/support/src/storage/mod.rs b/substrate/frame/support/src/storage/mod.rs index d6de37ca7a..1d575d0794 100644 --- a/substrate/frame/support/src/storage/mod.rs +++ b/substrate/frame/support/src/storage/mod.rs @@ -364,7 +364,7 @@ impl Iterator for PrefixIterator { type Item = Value; fn next(&mut self) -> Option { - match runtime_io::storage::next_key(&self.previous_key) { + match sp_io::storage::next_key(&self.previous_key) { Some(next_key) if next_key.starts_with(&self.prefix[..]) => { let value = unhashed::get(&next_key); @@ -406,7 +406,7 @@ pub trait StoragePrefixedMap { } fn remove_all() { - runtime_io::storage::clear_prefix(&Self::final_prefix()) + sp_io::storage::clear_prefix(&Self::final_prefix()) } fn iter() -> PrefixIterator { @@ -422,7 +422,7 @@ pub trait StoragePrefixedMap { #[cfg(test)] mod test { use primitives::hashing::twox_128; - use runtime_io::TestExternalities; + use sp_io::TestExternalities; use crate::storage::{unhashed, StoragePrefixedMap}; #[test] diff --git a/substrate/frame/support/src/storage/unhashed.rs b/substrate/frame/support/src/storage/unhashed.rs index c13686cf93..55f99f3d81 100644 --- a/substrate/frame/support/src/storage/unhashed.rs +++ b/substrate/frame/support/src/storage/unhashed.rs @@ -21,7 +21,7 @@ use codec::{Encode, Decode}; /// Return the value of the item in storage under `key`, or `None` if there is no explicit entry. pub fn get(key: &[u8]) -> Option { - runtime_io::storage::get(key).and_then(|val| { + sp_io::storage::get(key).and_then(|val| { Decode::decode(&mut &val[..]).map(Some).unwrap_or_else(|_| { // TODO #3700: error should be handleable. runtime_print!("ERROR: Corrupted state at {:?}", key); @@ -50,7 +50,7 @@ pub fn get_or_else T>(key: &[u8], default_valu /// Put `value` in storage under `key`. pub fn put(key: &[u8], value: &T) { - value.using_encoded(|slice| runtime_io::storage::set(key, slice)); + value.using_encoded(|slice| sp_io::storage::set(key, slice)); } /// Remove `key` from storage, returning its value if it had an explicit entry or `None` otherwise. @@ -82,25 +82,25 @@ pub fn take_or_else T>(key: &[u8], default_val /// Check to see if `key` has an explicit entry in storage. pub fn exists(key: &[u8]) -> bool { - runtime_io::storage::read(key, &mut [0;0][..], 0).is_some() + sp_io::storage::read(key, &mut [0;0][..], 0).is_some() } /// Ensure `key` has no explicit entry in storage. pub fn kill(key: &[u8]) { - runtime_io::storage::clear(key); + sp_io::storage::clear(key); } /// Ensure keys with the given `prefix` have no entries in storage. pub fn kill_prefix(prefix: &[u8]) { - runtime_io::storage::clear_prefix(prefix); + sp_io::storage::clear_prefix(prefix); } /// Get a Vec of bytes from storage. pub fn get_raw(key: &[u8]) -> Option> { - runtime_io::storage::get(key) + sp_io::storage::get(key) } /// Put a raw byte slice into storage. pub fn put_raw(key: &[u8], value: &[u8]) { - runtime_io::storage::set(key, value) + sp_io::storage::set(key, value) } diff --git a/substrate/frame/support/test/Cargo.toml b/substrate/frame/support/test/Cargo.toml index 6fa380e86d..abd44f7a95 100644 --- a/substrate/frame/support/test/Cargo.toml +++ b/substrate/frame/support/test/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] serde = { version = "1.0.101", default-features = false, features = ["derive"] } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -runtime-io ={ package = "sp-io", path = "../../../primitives/sr-io", default-features = false } +sp-io ={ path = "../../../primitives/io", default-features = false } state-machine ={ package = "sp-state-machine", path = "../../../primitives/state-machine", optional = true } support = { package = "frame-support", version = "2", path = "../", default-features = false } inherents = { package = "sp-inherents", path = "../../../primitives/inherents", default-features = false } @@ -21,7 +21,7 @@ default = ["std"] std = [ "serde/std", "codec/std", - "runtime-io/std", + "sp-io/std", "support/std", "inherents/std", "primitives/std", diff --git a/substrate/frame/support/test/tests/decl_storage.rs b/substrate/frame/support/test/tests/decl_storage.rs index 231dbdbdac..1c7ff1ce0a 100644 --- a/substrate/frame/support/test/tests/decl_storage.rs +++ b/substrate/frame/support/test/tests/decl_storage.rs @@ -19,7 +19,7 @@ #[allow(dead_code)] mod tests { use support::metadata::*; - use runtime_io::TestExternalities; + use sp_io::TestExternalities; use std::marker::PhantomData; use codec::{Encode, Decode, EncodeLike}; @@ -535,7 +535,7 @@ mod test3 { #[cfg(test)] #[allow(dead_code)] mod test_append_and_len { - use runtime_io::TestExternalities; + use sp_io::TestExternalities; use codec::{Encode, Decode}; pub trait Trait { diff --git a/substrate/frame/support/test/tests/final_keys.rs b/substrate/frame/support/test/tests/final_keys.rs index 3c9e1058a8..21f91e4f78 100644 --- a/substrate/frame/support/test/tests/final_keys.rs +++ b/substrate/frame/support/test/tests/final_keys.rs @@ -17,7 +17,7 @@ use support::storage::unhashed; use codec::Encode; use support::{StorageDoubleMap, StorageLinkedMap, StorageMap, StorageValue, StoragePrefixedMap}; -use runtime_io::{TestExternalities, hashing::{twox_128, blake2_128, blake2_256}}; +use sp_io::{TestExternalities, hashing::{twox_128, blake2_128, blake2_256}}; mod no_instance { use codec::{Encode, Decode, EncodeLike}; diff --git a/substrate/frame/support/test/tests/instance.rs b/substrate/frame/support/test/tests/instance.rs index fb8575f2ea..c2ba694f7d 100644 --- a/substrate/frame/support/test/tests/instance.rs +++ b/substrate/frame/support/test/tests/instance.rs @@ -271,7 +271,7 @@ pub type Header = generic::Header; pub type Block = generic::Block; pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; -fn new_test_ext() -> runtime_io::TestExternalities { +fn new_test_ext() -> sp_io::TestExternalities { GenesisConfig{ module1_Instance1: Some(module1::GenesisConfig { value: 3, diff --git a/substrate/frame/system/Cargo.toml b/substrate/frame/system/Cargo.toml index 81390d2d0e..3fb128e96b 100644 --- a/substrate/frame/system/Cargo.toml +++ b/substrate/frame/system/Cargo.toml @@ -10,7 +10,7 @@ safe-mix = { version = "1.0.0", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } primitives = { package = "sp-core", path = "../../primitives/core", default-features = false } sp-std = { path = "../../primitives/std", default-features = false } -runtime-io ={ package = "sp-io", path = "../../primitives/sr-io", default-features = false } +sp-io ={ path = "../../primitives/io", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } sp-version = { path = "../../primitives/sr-version", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } @@ -27,7 +27,7 @@ std = [ "codec/std", "primitives/std", "sp-std/std", - "runtime-io/std", + "sp-io/std", "support/std", "sp-runtime/std", "sp-version/std", diff --git a/substrate/frame/system/benches/bench.rs b/substrate/frame/system/benches/bench.rs index 461679ea38..731cadb579 100644 --- a/substrate/frame/system/benches/bench.rs +++ b/substrate/frame/system/benches/bench.rs @@ -80,7 +80,7 @@ impl module::Trait for Runtime { type Event = Event; } -fn new_test_ext() -> runtime_io::TestExternalities { +fn new_test_ext() -> sp_io::TestExternalities { system::GenesisConfig::default().build_storage::().unwrap().into() } diff --git a/substrate/frame/system/src/lib.rs b/substrate/frame/system/src/lib.rs index b05326a5cf..d7485db096 100644 --- a/substrate/frame/system/src/lib.rs +++ b/substrate/frame/system/src/lib.rs @@ -119,7 +119,7 @@ use support::{ use codec::{Encode, Decode}; #[cfg(any(feature = "std", test))] -use runtime_io::TestExternalities; +use sp_io::TestExternalities; #[cfg(any(feature = "std", test))] use primitives::ChangesTrieConfiguration; @@ -422,11 +422,11 @@ decl_storage! { build(|config: &GenesisConfig| { use codec::Encode; - runtime_io::storage::set(well_known_keys::CODE, &config.code); - runtime_io::storage::set(well_known_keys::EXTRINSIC_INDEX, &0u32.encode()); + sp_io::storage::set(well_known_keys::CODE, &config.code); + sp_io::storage::set(well_known_keys::EXTRINSIC_INDEX, &0u32.encode()); if let Some(ref changes_trie_config) = config.changes_trie_config { - runtime_io::storage::set( + sp_io::storage::set( well_known_keys::CHANGES_TRIE_CONFIG, &changes_trie_config.encode(), ); @@ -668,9 +668,9 @@ impl Module { } } - let storage_root = T::Hash::decode(&mut &runtime_io::storage::root()[..]) + let storage_root = T::Hash::decode(&mut &sp_io::storage::root()[..]) .expect("Node is configured to use the same hash; qed"); - let storage_changes_root = runtime_io::storage::changes_root(&parent_hash.encode()); + let storage_changes_root = sp_io::storage::changes_root(&parent_hash.encode()); // we can't compute changes trie root earlier && put it to the Digest // because it will include all currently existing temporaries. @@ -1187,7 +1187,7 @@ mod tests { const CALL: &::Call = &(); - fn new_test_ext() -> runtime_io::TestExternalities { + fn new_test_ext() -> sp_io::TestExternalities { GenesisConfig::default().build_storage::().unwrap().into() } diff --git a/substrate/frame/system/src/offchain.rs b/substrate/frame/system/src/offchain.rs index a12c9c3d06..b6f260d9e7 100644 --- a/substrate/frame/system/src/offchain.rs +++ b/substrate/frame/system/src/offchain.rs @@ -111,7 +111,7 @@ pub trait SubmitSignedTransaction { ::create_transaction::(call, public, id, expected) .ok_or(())?; let xt = Self::Extrinsic::new(call, Some(signature_data)).ok_or(())?; - runtime_io::offchain::submit_transaction(xt.encode()) + sp_io::offchain::submit_transaction(xt.encode()) } } @@ -126,7 +126,7 @@ pub trait SubmitUnsignedTransaction { /// and `Err` if transaction was rejected from the pool. fn submit_unsigned(call: impl Into) -> Result<(), ()> { let xt = Self::Extrinsic::new(call.into(), None).ok_or(())?; - runtime_io::offchain::submit_transaction(xt.encode()) + sp_io::offchain::submit_transaction(xt.encode()) } } diff --git a/substrate/frame/timestamp/Cargo.toml b/substrate/frame/timestamp/Cargo.toml index e23bcec013..ab2e40d021 100644 --- a/substrate/frame/timestamp/Cargo.toml +++ b/substrate/frame/timestamp/Cargo.toml @@ -16,7 +16,7 @@ sp-timestamp = { path = "../../primitives/timestamp", default-features = false } impl-trait-for-tuples = "0.1.3" [dev-dependencies] -runtime-io ={ package = "sp-io", path = "../../primitives/sr-io" } +sp-io ={ path = "../../primitives/io" } primitives = { package = "sp-core", path = "../../primitives/core" } [features] diff --git a/substrate/frame/timestamp/src/lib.rs b/substrate/frame/timestamp/src/lib.rs index 065901ea54..90c9f9ef6c 100644 --- a/substrate/frame/timestamp/src/lib.rs +++ b/substrate/frame/timestamp/src/lib.rs @@ -241,7 +241,7 @@ mod tests { use super::*; use support::{impl_outer_origin, assert_ok, parameter_types, weights::Weight}; - use runtime_io::TestExternalities; + use sp_io::TestExternalities; use primitives::H256; use sp_runtime::{Perbill, traits::{BlakeTwo256, IdentityLookup}, testing::Header}; diff --git a/substrate/frame/transaction-payment/Cargo.toml b/substrate/frame/transaction-payment/Cargo.toml index 696b5e4b6b..e8c163fb34 100644 --- a/substrate/frame/transaction-payment/Cargo.toml +++ b/substrate/frame/transaction-payment/Cargo.toml @@ -13,7 +13,7 @@ system = { package = "frame-system", path = "../system", default-features = fals transaction-payment-rpc-runtime-api = { package = "pallet-transaction-payment-rpc-runtime-api", path = "./rpc/runtime-api", default-features = false } [dev-dependencies] -runtime-io = { package = "sp-io", path = "../../primitives/sr-io" } +sp-io = { path = "../../primitives/io" } primitives = { package = "sp-core", path = "../../primitives/core" } balances = { package = "pallet-balances", path = "../balances" } diff --git a/substrate/frame/transaction-payment/src/lib.rs b/substrate/frame/transaction-payment/src/lib.rs index e51468b4f6..6f35f79f14 100644 --- a/substrate/frame/transaction-payment/src/lib.rs +++ b/substrate/frame/transaction-payment/src/lib.rs @@ -380,7 +380,7 @@ mod tests { TRANSACTION_BYTE_FEE.with(|v| *v.borrow_mut() = self.byte_fee); WEIGHT_TO_FEE.with(|v| *v.borrow_mut() = self.weight_to_fee); } - pub fn build(self) -> runtime_io::TestExternalities { + pub fn build(self) -> sp_io::TestExternalities { self.set_constants(); let mut t = system::GenesisConfig::default().build_storage::().unwrap(); balances::GenesisConfig:: { diff --git a/substrate/frame/treasury/Cargo.toml b/substrate/frame/treasury/Cargo.toml index 5b4acd9808..0f588e910e 100644 --- a/substrate/frame/treasury/Cargo.toml +++ b/substrate/frame/treasury/Cargo.toml @@ -14,7 +14,7 @@ system = { package = "frame-system", path = "../system", default-features = fals balances = { package = "pallet-balances", path = "../balances", default-features = false } [dev-dependencies] -runtime-io ={ package = "sp-io", path = "../../primitives/sr-io" } +sp-io ={ path = "../../primitives/io" } primitives = { package = "sp-core", path = "../../primitives/core" } [features] diff --git a/substrate/frame/treasury/src/lib.rs b/substrate/frame/treasury/src/lib.rs index 510dc5348d..92749d5eee 100644 --- a/substrate/frame/treasury/src/lib.rs +++ b/substrate/frame/treasury/src/lib.rs @@ -422,7 +422,7 @@ mod tests { type Balances = balances::Module; type Treasury = Module; - fn new_test_ext() -> runtime_io::TestExternalities { + fn new_test_ext() -> sp_io::TestExternalities { let mut t = system::GenesisConfig::default().build_storage::().unwrap(); balances::GenesisConfig::{ // Total issuance will be 200 with treasury account initialized at ED. @@ -620,7 +620,7 @@ mod tests { vesting: vec![], }.assimilate_storage(&mut t).unwrap(); // Treasury genesis config is not build thus treasury account does not exist - let mut t: runtime_io::TestExternalities = t.into(); + let mut t: sp_io::TestExternalities = t.into(); t.execute_with(|| { assert_eq!(Balances::free_balance(&Treasury::account_id()), 0); // Account does not exist diff --git a/substrate/frame/utility/Cargo.toml b/substrate/frame/utility/Cargo.toml index 5246e86c82..3341fd50ec 100644 --- a/substrate/frame/utility/Cargo.toml +++ b/substrate/frame/utility/Cargo.toml @@ -11,7 +11,7 @@ support = { package = "frame-support", path = "../support", default-features = f system = { package = "frame-system", path = "../system", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } sp-std = { path = "../../primitives/std", default-features = false } -runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } +sp-io = { path = "../../primitives/io", default-features = false } [dev-dependencies] primitives = { package = "sp-core", path = "../../primitives/core" } @@ -25,6 +25,6 @@ std = [ "sp-runtime/std", "support/std", "system/std", - "runtime-io/std", + "sp-io/std", "sp-std/std" ] diff --git a/substrate/frame/utility/src/lib.rs b/substrate/frame/utility/src/lib.rs index 0565997e3d..7639d0c77a 100644 --- a/substrate/frame/utility/src/lib.rs +++ b/substrate/frame/utility/src/lib.rs @@ -132,7 +132,7 @@ mod tests { type Balances = balances::Module; type Utility = Module; - fn new_test_ext() -> runtime_io::TestExternalities { + fn new_test_ext() -> sp_io::TestExternalities { let mut t = system::GenesisConfig::default().build_storage::().unwrap(); balances::GenesisConfig:: { balances: vec![(1, 10), (2, 0)], diff --git a/substrate/primitives/application-crypto/Cargo.toml b/substrate/primitives/application-crypto/Cargo.toml index e13427d256..1c7c647bb6 100644 --- a/substrate/primitives/application-crypto/Cargo.toml +++ b/substrate/primitives/application-crypto/Cargo.toml @@ -10,7 +10,7 @@ primitives = { package = "sp-core", path = "../core", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } serde = { version = "1.0.101", optional = true, features = ["derive"] } sp-std = { path = "../std", default-features = false } -runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } +sp-io = { path = "../../primitives/io", default-features = false } [dev-dependencies] test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client" } @@ -18,7 +18,7 @@ sp-runtime = { path = "../../primitives/runtime" } [features] default = [ "std" ] -std = [ "full_crypto", "primitives/std", "codec/std", "serde", "sp-std/std", "runtime-io/std" ] +std = [ "full_crypto", "primitives/std", "codec/std", "serde", "sp-std/std", "sp-io/std" ] # This feature enables all crypto primitives for `no_std` builds like microcontrollers # or Intel SGX. diff --git a/substrate/primitives/application-crypto/src/ed25519.rs b/substrate/primitives/application-crypto/src/ed25519.rs index 358e5f657e..5097b8e4dc 100644 --- a/substrate/primitives/application-crypto/src/ed25519.rs +++ b/substrate/primitives/application-crypto/src/ed25519.rs @@ -39,19 +39,19 @@ impl RuntimePublic for Public { type Signature = Signature; fn all(key_type: KeyTypeId) -> crate::Vec { - runtime_io::crypto::ed25519_public_keys(key_type) + sp_io::crypto::ed25519_public_keys(key_type) } fn generate_pair(key_type: KeyTypeId, seed: Option>) -> Self { - runtime_io::crypto::ed25519_generate(key_type, seed) + sp_io::crypto::ed25519_generate(key_type, seed) } fn sign>(&self, key_type: KeyTypeId, msg: &M) -> Option { - runtime_io::crypto::ed25519_sign(key_type, self, msg.as_ref()) + sp_io::crypto::ed25519_sign(key_type, self, msg.as_ref()) } fn verify>(&self, msg: &M, signature: &Self::Signature) -> bool { - runtime_io::crypto::ed25519_verify(&signature, msg.as_ref(), self) + sp_io::crypto::ed25519_verify(&signature, msg.as_ref(), self) } } diff --git a/substrate/primitives/application-crypto/src/sr25519.rs b/substrate/primitives/application-crypto/src/sr25519.rs index 749e3db21f..e7b5c7f164 100644 --- a/substrate/primitives/application-crypto/src/sr25519.rs +++ b/substrate/primitives/application-crypto/src/sr25519.rs @@ -39,19 +39,19 @@ impl RuntimePublic for Public { type Signature = Signature; fn all(key_type: KeyTypeId) -> crate::Vec { - runtime_io::crypto::sr25519_public_keys(key_type) + sp_io::crypto::sr25519_public_keys(key_type) } fn generate_pair(key_type: KeyTypeId, seed: Option>) -> Self { - runtime_io::crypto::sr25519_generate(key_type, seed) + sp_io::crypto::sr25519_generate(key_type, seed) } fn sign>(&self, key_type: KeyTypeId, msg: &M) -> Option { - runtime_io::crypto::sr25519_sign(key_type, self, msg.as_ref()) + sp_io::crypto::sr25519_sign(key_type, self, msg.as_ref()) } fn verify>(&self, msg: &M, signature: &Self::Signature) -> bool { - runtime_io::crypto::sr25519_verify(&signature, msg.as_ref(), self) + sp_io::crypto::sr25519_verify(&signature, msg.as_ref(), self) } } diff --git a/substrate/primitives/core/src/lib.rs b/substrate/primitives/core/src/lib.rs index 888f401243..3241f9b4ff 100644 --- a/substrate/primitives/core/src/lib.rs +++ b/substrate/primitives/core/src/lib.rs @@ -235,7 +235,7 @@ pub trait TypeId { /// A log level matching the one from `log` crate. /// -/// Used internally by `runtime_io::log` method. +/// Used internally by `sp_io::log` method. #[derive(Encode, Decode, runtime_interface::pass_by::PassByEnum, Copy, Clone)] pub enum LogLevel { /// `Error` log level. diff --git a/substrate/primitives/sr-io/Cargo.toml b/substrate/primitives/io/Cargo.toml similarity index 100% rename from substrate/primitives/sr-io/Cargo.toml rename to substrate/primitives/io/Cargo.toml diff --git a/substrate/primitives/sr-io/src/lib.rs b/substrate/primitives/io/src/lib.rs similarity index 100% rename from substrate/primitives/sr-io/src/lib.rs rename to substrate/primitives/io/src/lib.rs diff --git a/substrate/primitives/phragmen/Cargo.toml b/substrate/primitives/phragmen/Cargo.toml index 656ce8b9b2..8c546b7349 100644 --- a/substrate/primitives/phragmen/Cargo.toml +++ b/substrate/primitives/phragmen/Cargo.toml @@ -11,7 +11,7 @@ sp-runtime = { path = "../../primitives/runtime", default-features = false } [dev-dependencies] substrate-test-utils = { path = "../../test/utils" } -runtime-io ={ package = "sp-io", path = "../../primitives/sr-io" } +sp-io ={ path = "../../primitives/io" } rand = "0.7.2" [features] diff --git a/substrate/primitives/runtime-interface/Cargo.toml b/substrate/primitives/runtime-interface/Cargo.toml index af0ca7a5f6..cebc5286f6 100644 --- a/substrate/primitives/runtime-interface/Cargo.toml +++ b/substrate/primitives/runtime-interface/Cargo.toml @@ -19,7 +19,7 @@ executor = { package = "sc-executor", path = "../../client/executor" } test-wasm = { package = "sp-runtime-interface-test-wasm", path = "test-wasm" } state_machine = { package = "sp-state-machine", path = "../../primitives/state-machine" } primitives = { package = "sp-core", path = "../core" } -runtime-io = { package = "sp-io", path = "../sr-io" } +sp-io = { path = "../io" } [features] default = [ "std" ] diff --git a/substrate/primitives/runtime-interface/src/lib.rs b/substrate/primitives/runtime-interface/src/lib.rs index bce5dbfec2..3a2a780d2d 100644 --- a/substrate/primitives/runtime-interface/src/lib.rs +++ b/substrate/primitives/runtime-interface/src/lib.rs @@ -134,7 +134,7 @@ mod tests { _, ( HF, - runtime_io::SubstrateHostFunctions, + sp_io::SubstrateHostFunctions, executor::deprecated_host_interface::SubstrateExternals ) >( diff --git a/substrate/primitives/runtime-interface/test-wasm/Cargo.toml b/substrate/primitives/runtime-interface/test-wasm/Cargo.toml index 0d9288de05..553693f248 100644 --- a/substrate/primitives/runtime-interface/test-wasm/Cargo.toml +++ b/substrate/primitives/runtime-interface/test-wasm/Cargo.toml @@ -8,7 +8,7 @@ build = "build.rs" [dependencies] runtime-interface = { package = "sp-runtime-interface", path = "../", default-features = false } sp-std = { path = "../../std", default-features = false } -runtime-io = { package = "sp-io", path = "../../sr-io", default-features = false } +sp-io = { path = "../../io", default-features = false } primitives = { package = "sp-core", path = "../../core", default-features = false } [build-dependencies] @@ -16,4 +16,4 @@ wasm-builder-runner = { package = "substrate-wasm-builder-runner", version = "1. [features] default = [ "std" ] -std = [ "runtime-interface/std", "sp-std/std", "primitives/std", "runtime-io/std" ] +std = [ "runtime-interface/std", "sp-std/std", "primitives/std", "sp-io/std" ] diff --git a/substrate/primitives/runtime-interface/test-wasm/src/lib.rs b/substrate/primitives/runtime-interface/test-wasm/src/lib.rs index 93e9f5b29b..dd75a9cb8a 100644 --- a/substrate/primitives/runtime-interface/test-wasm/src/lib.rs +++ b/substrate/primitives/runtime-interface/test-wasm/src/lib.rs @@ -99,11 +99,11 @@ pub fn force_old_runtime_interface_import() { unsafe { ext_keccak_256(sp_std::ptr::null(), 0, sp_std::ptr::null_mut()); } } -/// This function is not used, but we require it for the compiler to include `runtime-io`. -/// `runtime-io` is required for its panic and oom handler. +/// This function is not used, but we require it for the compiler to include `sp-io`. +/// `sp-io` is required for its panic and oom handler. #[no_mangle] -pub fn import_runtime_io() { - runtime_io::misc::print_utf8(&[]); +pub fn import_sp_io() { + sp_io::misc::print_utf8(&[]); } wasm_export_functions! { diff --git a/substrate/primitives/runtime/Cargo.toml b/substrate/primitives/runtime/Cargo.toml index 8c855d7bb0..94f841d10a 100644 --- a/substrate/primitives/runtime/Cargo.toml +++ b/substrate/primitives/runtime/Cargo.toml @@ -11,7 +11,7 @@ primitives = { package = "sp-core", path = "../core", default-features = false app-crypto = { package = "sc-application-crypto", path = "../application-crypto", default-features = false } arithmetic = { package = "sp-arithmetic", path = "../sr-arithmetic", default-features = false } sp-std = { path = "../std", default-features = false } -runtime_io = { package = "sp-io", path = "../sr-io", default-features = false } +sp-io = { path = "../io", default-features = false } log = { version = "0.4.8", optional = true } paste = "0.1.6" rand = { version = "0.7.2", optional = true } @@ -33,7 +33,7 @@ std = [ "primitives/std", "rand", "sp-std/std", - "runtime_io/std", + "sp-io/std", "serde", "inherents/std", ] diff --git a/substrate/primitives/runtime/src/generic/unchecked_extrinsic.rs b/substrate/primitives/runtime/src/generic/unchecked_extrinsic.rs index a018dedf2a..5b760ba7d1 100644 --- a/substrate/primitives/runtime/src/generic/unchecked_extrinsic.rs +++ b/substrate/primitives/runtime/src/generic/unchecked_extrinsic.rs @@ -17,7 +17,7 @@ //! Generic implementation of an unchecked (pre-verification) extrinsic. use sp_std::{fmt, prelude::*}; -use runtime_io::hashing::blake2_256; +use sp_io::hashing::blake2_256; use codec::{Decode, Encode, EncodeLike, Input, Error}; use crate::{ traits::{self, Member, MaybeDisplay, SignedExtension, Checkable, Extrinsic, IdentifyAccount}, @@ -282,7 +282,7 @@ where #[cfg(test)] mod tests { use super::*; - use runtime_io::hashing::blake2_256; + use sp_io::hashing::blake2_256; use crate::codec::{Encode, Decode}; use crate::traits::{SignedExtension, IdentifyAccount, IdentityLookup}; use serde::{Serialize, Deserialize}; diff --git a/substrate/primitives/runtime/src/lib.rs b/substrate/primitives/runtime/src/lib.rs index c4433b9076..426e29c407 100644 --- a/substrate/primitives/runtime/src/lib.rs +++ b/substrate/primitives/runtime/src/lib.rs @@ -243,7 +243,7 @@ impl traits::IdentifyAccount for MultiSigner { match self { MultiSigner::Ed25519(who) => <[u8; 32]>::from(who).into(), MultiSigner::Sr25519(who) => <[u8; 32]>::from(who).into(), - MultiSigner::Ecdsa(who) => runtime_io::hashing::blake2_256(who.as_ref()).into(), + MultiSigner::Ecdsa(who) => sp_io::hashing::blake2_256(who.as_ref()).into(), } } } @@ -306,10 +306,10 @@ impl Verify for MultiSignature { (MultiSignature::Ed25519(ref sig), who) => sig.verify(msg, &ed25519::Public::from_slice(who.as_ref())), (MultiSignature::Sr25519(ref sig), who) => sig.verify(msg, &sr25519::Public::from_slice(who.as_ref())), (MultiSignature::Ecdsa(ref sig), who) => { - let m = runtime_io::hashing::blake2_256(msg.get()); - match runtime_io::crypto::secp256k1_ecdsa_recover_compressed(sig.as_ref(), &m) { + let m = sp_io::hashing::blake2_256(msg.get()); + match sp_io::crypto::secp256k1_ecdsa_recover_compressed(sig.as_ref(), &m) { Ok(pubkey) => - &runtime_io::hashing::blake2_256(pubkey.as_ref()) + &sp_io::hashing::blake2_256(pubkey.as_ref()) == >::as_ref(who), _ => false, } diff --git a/substrate/primitives/runtime/src/offchain/http.rs b/substrate/primitives/runtime/src/offchain/http.rs index 8fc6ac025c..5110aede13 100644 --- a/substrate/primitives/runtime/src/offchain/http.rs +++ b/substrate/primitives/runtime/src/offchain/http.rs @@ -221,7 +221,7 @@ impl<'a, I: AsRef<[u8]>, T: IntoIterator> Request<'a, T> { let meta = &[]; // start an http request. - let id = runtime_io::offchain::http_request_start( + let id = sp_io::offchain::http_request_start( self.method.as_ref(), self.url, meta, @@ -229,7 +229,7 @@ impl<'a, I: AsRef<[u8]>, T: IntoIterator> Request<'a, T> { // add custom headers for header in &self.headers { - runtime_io::offchain::http_request_add_header( + sp_io::offchain::http_request_add_header( id, header.name(), header.value(), @@ -238,11 +238,11 @@ impl<'a, I: AsRef<[u8]>, T: IntoIterator> Request<'a, T> { // write body for chunk in self.body { - runtime_io::offchain::http_request_write_body(id, chunk.as_ref(), self.deadline)?; + sp_io::offchain::http_request_write_body(id, chunk.as_ref(), self.deadline)?; } // finalise the request - runtime_io::offchain::http_request_write_body(id, &[], self.deadline)?; + sp_io::offchain::http_request_write_body(id, &[], self.deadline)?; Ok(PendingRequest { id, @@ -307,7 +307,7 @@ impl PendingRequest { deadline: impl Into> ) -> Vec> { let ids = requests.iter().map(|r| r.id).collect::>(); - let statuses = runtime_io::offchain::http_response_wait(&ids, deadline.into()); + let statuses = sp_io::offchain::http_response_wait(&ids, deadline.into()); statuses .into_iter() @@ -346,7 +346,7 @@ impl Response { pub fn headers(&mut self) -> &Headers { if self.headers.is_none() { self.headers = Some( - Headers { raw: runtime_io::offchain::http_response_headers(self.id) }, + Headers { raw: sp_io::offchain::http_response_headers(self.id) }, ); } self.headers.as_ref().expect("Headers were just set; qed") @@ -426,7 +426,7 @@ impl Iterator for ResponseBody { } if self.filled_up_to.is_none() { - let result = runtime_io::offchain::http_response_read_body( + let result = sp_io::offchain::http_response_read_body( self.id, &mut self.buffer, self.deadline); @@ -515,7 +515,7 @@ impl<'a> HeadersIterator<'a> { #[cfg(test)] mod tests { use super::*; - use runtime_io::TestExternalities; + use sp_io::TestExternalities; use primitives::offchain::{ OffchainExt, testing, diff --git a/substrate/primitives/runtime/src/traits.rs b/substrate/primitives/runtime/src/traits.rs index a18783782a..de74c949db 100644 --- a/substrate/primitives/runtime/src/traits.rs +++ b/substrate/primitives/runtime/src/traits.rs @@ -18,7 +18,7 @@ use sp_std::prelude::*; use sp_std::{self, result, marker::PhantomData, convert::{TryFrom, TryInto}, fmt::Debug}; -use runtime_io; +use sp_io; #[cfg(feature = "std")] use std::fmt::Display; #[cfg(feature = "std")] @@ -84,23 +84,23 @@ pub trait Verify { impl Verify for primitives::ed25519::Signature { type Signer = primitives::ed25519::Public; fn verify>(&self, mut msg: L, signer: &primitives::ed25519::Public) -> bool { - runtime_io::crypto::ed25519_verify(self, msg.get(), signer) + sp_io::crypto::ed25519_verify(self, msg.get(), signer) } } impl Verify for primitives::sr25519::Signature { type Signer = primitives::sr25519::Public; fn verify>(&self, mut msg: L, signer: &primitives::sr25519::Public) -> bool { - runtime_io::crypto::sr25519_verify(self, msg.get(), signer) + sp_io::crypto::sr25519_verify(self, msg.get(), signer) } } impl Verify for primitives::ecdsa::Signature { type Signer = primitives::ecdsa::Public; fn verify>(&self, mut msg: L, signer: &primitives::ecdsa::Public) -> bool { - match runtime_io::crypto::secp256k1_ecdsa_recover_compressed( + match sp_io::crypto::secp256k1_ecdsa_recover_compressed( self.as_ref(), - &runtime_io::hashing::blake2_256(msg.get()), + &sp_io::hashing::blake2_256(msg.get()), ) { Ok(pubkey) => >::as_ref(signer) == &pubkey[..], _ => false, @@ -399,15 +399,15 @@ impl Hash for BlakeTwo256 { type Output = primitives::H256; type Hasher = Blake2Hasher; fn hash(s: &[u8]) -> Self::Output { - runtime_io::hashing::blake2_256(s).into() + sp_io::hashing::blake2_256(s).into() } fn trie_root(input: Vec<(Vec, Vec)>) -> Self::Output { - runtime_io::trie::blake2_256_root(input) + sp_io::trie::blake2_256_root(input) } fn ordered_trie_root(input: Vec>) -> Self::Output { - runtime_io::trie::blake2_256_ordered_root(input) + sp_io::trie::blake2_256_ordered_root(input) } } @@ -1233,19 +1233,19 @@ impl Printable for usize { impl Printable for u64 { fn print(&self) { - runtime_io::misc::print_num(*self); + sp_io::misc::print_num(*self); } } impl Printable for &[u8] { fn print(&self) { - runtime_io::misc::print_hex(self); + sp_io::misc::print_hex(self); } } impl Printable for &str { fn print(&self) { - runtime_io::misc::print_utf8(self.as_bytes()); + sp_io::misc::print_utf8(self.as_bytes()); } } diff --git a/substrate/primitives/sr-sandbox/Cargo.toml b/substrate/primitives/sr-sandbox/Cargo.toml index 4cd946ef66..6f8d518c49 100755 --- a/substrate/primitives/sr-sandbox/Cargo.toml +++ b/substrate/primitives/sr-sandbox/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" wasmi = { version = "0.6.2", optional = true } primitives = { package = "sp-core", path = "../core", default-features = false } sp-std = { path = "../std", default-features = false } -runtime-io = { package = "sp-io", path = "../sr-io", default-features = false } +sp-io = { path = "../io", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } [dev-dependencies] @@ -22,6 +22,6 @@ std = [ "primitives/std", "sp-std/std", "codec/std", - "runtime-io/std", + "sp-io/std", ] strict = [] diff --git a/substrate/primitives/sr-sandbox/without_std.rs b/substrate/primitives/sr-sandbox/without_std.rs index fb3267a91c..68956db8bf 100755 --- a/substrate/primitives/sr-sandbox/without_std.rs +++ b/substrate/primitives/sr-sandbox/without_std.rs @@ -18,7 +18,7 @@ use sp_std::{prelude::*, slice, marker, mem, vec, rc::Rc}; use codec::{Decode, Encode}; use primitives::sandbox as sandbox_primitives; use super::{Error, TypedValue, ReturnValue, HostFuncType}; -use runtime_io::sandbox; +use sp_io::sandbox; mod ffi { use sp_std::mem; diff --git a/substrate/primitives/state-machine/src/trie_backend_essence.rs b/substrate/primitives/state-machine/src/trie_backend_essence.rs index 6a38f56e0b..f071d19a94 100644 --- a/substrate/primitives/state-machine/src/trie_backend_essence.rs +++ b/substrate/primitives/state-machine/src/trie_backend_essence.rs @@ -113,7 +113,7 @@ impl, H: Hasher> TrieBackendEssence where H::Out: // The key just after the one given in input, basically `key++0`. // Note: We are sure this is the next key if: // * size of key has no limit (i.e. we can always add 0 to the path), - // * and no keys can be inserted between `key` and `key++0` (this is ensured by sr-io). + // * and no keys can be inserted between `key` and `key++0` (this is ensured by sp-io). let mut potential_next_key = Vec::with_capacity(key.len() + 1); potential_next_key.extend_from_slice(key); potential_next_key.push(0); diff --git a/substrate/test/utils/runtime/Cargo.toml b/substrate/test/utils/runtime/Cargo.toml index 40a5f17837..8a2f516fb1 100644 --- a/substrate/test/utils/runtime/Cargo.toml +++ b/substrate/test/utils/runtime/Cargo.toml @@ -21,7 +21,7 @@ offchain-primitives = { package = "sp-offchain", path = "../../../primitives/off primitives = { package = "sp-core", path = "../../../primitives/core", default-features = false } sp-std = { path = "../../../primitives/std", default-features = false } runtime-interface = { package = "sp-runtime-interface", path = "../../../primitives/runtime-interface", default-features = false} -runtime_io = { package = "sp-io", path = "../../../primitives/sr-io", default-features = false } +sp-io = { path = "../../../primitives/io", default-features = false } runtime_support = { package = "frame-support", path = "../../../frame/support", default-features = false } runtime_version = { package = "sp-version", path = "../../../primitives/sr-version", default-features = false } serde = { version = "1.0.101", optional = true, features = ["derive"] } @@ -65,7 +65,7 @@ std = [ "primitives/std", "sp-std/std", "runtime-interface/std", - "runtime_io/std", + "sp-io/std", "runtime_support/std", "runtime_version/std", "serde", diff --git a/substrate/test/utils/runtime/src/genesismap.rs b/substrate/test/utils/runtime/src/genesismap.rs index fc4acfefe2..5b65b54dce 100644 --- a/substrate/test/utils/runtime/src/genesismap.rs +++ b/substrate/test/utils/runtime/src/genesismap.rs @@ -17,7 +17,7 @@ //! Tool for creating the genesis block. use std::collections::{BTreeMap, HashMap}; -use runtime_io::hashing::{blake2_256, twox_128}; +use sp_io::hashing::{blake2_256, twox_128}; use super::{AuthorityId, AccountId, WASM_BINARY, system}; use codec::{Encode, KeyedVec, Joiner}; use primitives::{ChangesTrieConfiguration, map, storage::well_known_keys}; diff --git a/substrate/test/utils/runtime/src/lib.rs b/substrate/test/utils/runtime/src/lib.rs index 4a0a5859c4..dcb76e27ef 100644 --- a/substrate/test/utils/runtime/src/lib.rs +++ b/substrate/test/utils/runtime/src/lib.rs @@ -624,7 +624,7 @@ cfg_if! { impl offchain_primitives::OffchainWorkerApi for Runtime { fn offchain_worker(block: u64) { let ex = Extrinsic::IncludeData(block.encode()); - runtime_io::offchain::submit_transaction(ex.encode()).unwrap(); + sp_io::offchain::submit_transaction(ex.encode()).unwrap(); } } @@ -840,7 +840,7 @@ cfg_if! { impl offchain_primitives::OffchainWorkerApi for Runtime { fn offchain_worker(block: u64) { let ex = Extrinsic::IncludeData(block.encode()); - runtime_io::offchain::submit_transaction(ex.encode()).unwrap() + sp_io::offchain::submit_transaction(ex.encode()).unwrap() } } @@ -891,10 +891,10 @@ fn test_sr25519_crypto() -> (sr25519::AppSignature, sr25519::AppPublic) { fn test_read_storage() { const KEY: &[u8] = b":read_storage"; - runtime_io::storage::set(KEY, b"test"); + sp_io::storage::set(KEY, b"test"); let mut v = [0u8; 4]; - let r = runtime_io::storage::read( + let r = sp_io::storage::read( KEY, &mut v, 0 @@ -903,7 +903,7 @@ fn test_read_storage() { assert_eq!(&v, b"test"); let mut v = [0u8; 4]; - let r = runtime_io::storage::read(KEY, &mut v, 8); + let r = sp_io::storage::read(KEY, &mut v, 8); assert_eq!(r, Some(4)); assert_eq!(&v, &[0, 0, 0, 0]); } @@ -911,10 +911,10 @@ fn test_read_storage() { fn test_read_child_storage() { const CHILD_KEY: &[u8] = b":child_storage:default:read_child_storage"; const KEY: &[u8] = b":read_child_storage"; - runtime_io::storage::child_set(CHILD_KEY, KEY, b"test"); + sp_io::storage::child_set(CHILD_KEY, KEY, b"test"); let mut v = [0u8; 4]; - let r = runtime_io::storage::child_read( + let r = sp_io::storage::child_read( CHILD_KEY, KEY, &mut v, @@ -924,7 +924,7 @@ fn test_read_child_storage() { assert_eq!(&v, b"test"); let mut v = [0u8; 4]; - let r = runtime_io::storage::child_read(CHILD_KEY, KEY, &mut v, 8); + let r = sp_io::storage::child_read(CHILD_KEY, KEY, &mut v, 8); assert_eq!(r, Some(4)); assert_eq!(&v, &[0, 0, 0, 0]); } diff --git a/substrate/test/utils/runtime/src/system.rs b/substrate/test/utils/runtime/src/system.rs index c936ba0444..d305220d5f 100644 --- a/substrate/test/utils/runtime/src/system.rs +++ b/substrate/test/utils/runtime/src/system.rs @@ -18,7 +18,7 @@ //! and depositing logs. use sp_std::prelude::*; -use runtime_io::{ +use sp_io::{ storage::root as storage_root, storage::changes_root as storage_changes_root, hashing::blake2_256, }; @@ -335,12 +335,12 @@ fn info_expect_equal_hash(given: &Hash, expected: &Hash) { mod tests { use super::*; - use runtime_io::TestExternalities; + use sp_io::TestExternalities; use substrate_test_runtime_client::{AccountKeyring, Sr25519Keyring}; use crate::{Header, Transfer, WASM_BINARY}; use primitives::{NeverNativeValue, map, traits::CodeExecutor}; use sc_executor::{NativeExecutor, WasmExecutionMethod, native_executor_instance}; - use runtime_io::hashing::twox_128; + use sp_io::hashing::twox_128; // Declare an instance of the native executor dispatch for the test runtime. native_executor_instance!(