From c9e964f6e3a34a03c949638825bfe1a79066590f Mon Sep 17 00:00:00 2001 From: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Date: Sat, 23 Nov 2019 18:10:30 +0100 Subject: [PATCH 001/172] elections-phragmen: renounce candidacy [+ remove dead code] (#4123) * new elections phragmen module. * Bump * rename typo * Few nits * Fix runner outgoing bond * remove useused var * Fix refund logic. * Update doc. * Update lock --- Cargo.lock | 400 +++++++++---------- frame/elections-phragmen/src/lib.rs | 580 +++++++++++++++++++--------- 2 files changed, 598 insertions(+), 382 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b36e54aba7..2dc0e193bd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1263,6 +1263,181 @@ dependencies = [ "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "frame-executive" +version = "2.0.0" +dependencies = [ + "frame-support 2.0.0", + "frame-system 2.0.0", + "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "pallet-balances 2.0.0", + "pallet-indices 2.0.0", + "pallet-transaction-payment 2.0.0", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "sr-io 2.0.0", + "sr-primitives 2.0.0", + "sr-std 2.0.0", + "substrate-primitives 2.0.0", +] + +[[package]] +name = "frame-metadata" +version = "2.0.0" +dependencies = [ + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "sr-std 2.0.0", + "substrate-primitives 2.0.0", +] + +[[package]] +name = "frame-support" +version = "2.0.0" +dependencies = [ + "bitmask 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "frame-metadata 2.0.0", + "frame-support-procedural 2.0.0", + "frame-system 2.0.0", + "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "once_cell 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "paste 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "sr-arithmetic 2.0.0", + "sr-io 2.0.0", + "sr-primitives 2.0.0", + "sr-std 2.0.0", + "substrate-inherents 2.0.0", + "substrate-primitives 2.0.0", + "substrate-state-machine 2.0.0", + "tracing 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "frame-support-procedural" +version = "2.0.0" +dependencies = [ + "frame-support-procedural-tools 2.0.0", + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "frame-support-procedural-tools" +version = "2.0.0" +dependencies = [ + "frame-support-procedural-tools-derive 2.0.0", + "proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "frame-support-procedural-tools-derive" +version = "2.0.0" +dependencies = [ + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "frame-support-rpc" +version = "2.0.0" +dependencies = [ + "frame-support 2.0.0", + "frame-system 2.0.0", + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-client-transports 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "substrate-primitives-storage 2.0.0", + "substrate-rpc-api 2.0.0", + "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "frame-support-test" +version = "2.0.0" +dependencies = [ + "frame-support 2.0.0", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "sr-io 2.0.0", + "sr-primitives 2.0.0", + "substrate-inherents 2.0.0", + "substrate-primitives 2.0.0", + "substrate-state-machine 2.0.0", + "trybuild 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "frame-system" +version = "2.0.0" +dependencies = [ + "criterion 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "frame-support 2.0.0", + "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "sr-io 2.0.0", + "sr-primitives 2.0.0", + "sr-std 2.0.0", + "sr-version 2.0.0", + "substrate-primitives 2.0.0", +] + +[[package]] +name = "frame-system-rpc" +version = "2.0.0" +dependencies = [ + "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "frame-system-rpc-runtime-api 2.0.0", + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core-client 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-derive 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "sr-primitives 2.0.0", + "substrate-client 2.0.0", + "substrate-primitives 2.0.0", + "substrate-test-runtime-client 2.0.0", + "substrate-transaction-pool 2.0.0", +] + +[[package]] +name = "frame-system-rpc-runtime-api" +version = "2.0.0" +dependencies = [ + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sr-api 2.0.0", +] + +[[package]] +name = "frame-utility" +version = "2.0.0" +dependencies = [ + "frame-support 2.0.0", + "frame-system 2.0.0", + "pallet-balances 2.0.0", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "sr-io 2.0.0", + "sr-primitives 2.0.0", + "sr-std 2.0.0", + "substrate-primitives 2.0.0", +] + [[package]] name = "fs-swap" version = "0.2.4" @@ -2851,6 +3026,8 @@ dependencies = [ "console_error_panic_hook 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "console_log 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "ctrlc 3.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "frame-support 2.0.0", + "frame-system 2.0.0", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2863,8 +3040,6 @@ dependencies = [ "node-primitives 2.0.0", "node-rpc 2.0.0", "node-runtime 2.0.0", - "frame-support 2.0.0", - "frame-system 2.0.0", "pallet-authority-discovery 0.1.0", "pallet-balances 2.0.0", "pallet-contracts 2.0.0", @@ -2919,11 +3094,11 @@ name = "node-executor" version = "2.0.0" dependencies = [ "criterion 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "frame-support 2.0.0", + "frame-system 2.0.0", "node-primitives 2.0.0", "node-runtime 2.0.0", "node-testing 2.0.0", - "frame-support 2.0.0", - "frame-system 2.0.0", "pallet-balances 2.0.0", "pallet-contracts 2.0.0", "pallet-grandpa 2.0.0", @@ -2958,10 +3133,10 @@ dependencies = [ name = "node-rpc" version = "2.0.0" dependencies = [ + "frame-system-rpc 2.0.0", "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "node-primitives 2.0.0", "node-runtime 2.0.0", - "frame-system-rpc 2.0.0", "pallet-contracts-rpc 2.0.0", "pallet-transaction-payment-rpc 2.0.0", "sr-primitives 2.0.0", @@ -2986,13 +3161,13 @@ dependencies = [ name = "node-runtime" version = "2.0.0" dependencies = [ - "integer-sqrt 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "node-primitives 2.0.0", "frame-executive 2.0.0", "frame-support 2.0.0", "frame-system 2.0.0", "frame-system-rpc-runtime-api 2.0.0", "frame-utility 2.0.0", + "integer-sqrt 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "node-primitives 2.0.0", "pallet-authority-discovery 0.1.0", "pallet-authorship 0.1.0", "pallet-babe 2.0.0", @@ -3110,11 +3285,11 @@ dependencies = [ name = "node-testing" version = "2.0.0" dependencies = [ + "frame-support 2.0.0", + "frame-system 2.0.0", "node-executor 2.0.0", "node-primitives 2.0.0", "node-runtime 2.0.0", - "frame-support 2.0.0", - "frame-system 2.0.0", "pallet-balances 2.0.0", "pallet-contracts 2.0.0", "pallet-grandpa 2.0.0", @@ -3279,181 +3454,6 @@ dependencies = [ "stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "frame-executive" -version = "2.0.0" -dependencies = [ - "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "frame-support 2.0.0", - "frame-system 2.0.0", - "pallet-balances 2.0.0", - "pallet-indices 2.0.0", - "pallet-transaction-payment 2.0.0", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "sr-std 2.0.0", - "substrate-primitives 2.0.0", -] - -[[package]] -name = "frame-metadata" -version = "2.0.0" -dependencies = [ - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-std 2.0.0", - "substrate-primitives 2.0.0", -] - -[[package]] -name = "frame-support" -version = "2.0.0" -dependencies = [ - "bitmask 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "once_cell 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "frame-metadata 2.0.0", - "frame-support-procedural 2.0.0", - "frame-system 2.0.0", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "paste 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-arithmetic 2.0.0", - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "sr-std 2.0.0", - "substrate-inherents 2.0.0", - "substrate-primitives 2.0.0", - "substrate-state-machine 2.0.0", - "tracing 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "frame-support-procedural" -version = "2.0.0" -dependencies = [ - "frame-support-procedural-tools 2.0.0", - "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "frame-support-procedural-tools" -version = "2.0.0" -dependencies = [ - "frame-support-procedural-tools-derive 2.0.0", - "proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "frame-support-procedural-tools-derive" -version = "2.0.0" -dependencies = [ - "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "frame-support-rpc" -version = "2.0.0" -dependencies = [ - "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-client-transports 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "frame-support 2.0.0", - "frame-system 2.0.0", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "substrate-primitives-storage 2.0.0", - "substrate-rpc-api 2.0.0", - "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "frame-support-test" -version = "2.0.0" -dependencies = [ - "frame-support 2.0.0", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "substrate-inherents 2.0.0", - "substrate-primitives 2.0.0", - "substrate-state-machine 2.0.0", - "trybuild 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "frame-system" -version = "2.0.0" -dependencies = [ - "criterion 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "frame-support 2.0.0", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "sr-std 2.0.0", - "sr-version 2.0.0", - "substrate-primitives 2.0.0", -] - -[[package]] -name = "frame-system-rpc" -version = "2.0.0" -dependencies = [ - "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core-client 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-derive 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "frame-system-rpc-runtime-api 2.0.0", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-primitives 2.0.0", - "substrate-client 2.0.0", - "substrate-primitives 2.0.0", - "substrate-test-runtime-client 2.0.0", - "substrate-transaction-pool 2.0.0", -] - -[[package]] -name = "frame-system-rpc-runtime-api" -version = "2.0.0" -dependencies = [ - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-api 2.0.0", -] - -[[package]] -name = "frame-utility" -version = "2.0.0" -dependencies = [ - "frame-support 2.0.0", - "frame-system 2.0.0", - "pallet-balances 2.0.0", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "sr-std 2.0.0", - "substrate-primitives 2.0.0", -] - [[package]] name = "pallet-assets" version = "2.0.0" @@ -3472,9 +3472,9 @@ dependencies = [ name = "pallet-aura" version = "2.0.0" dependencies = [ - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "frame-support 2.0.0", "frame-system 2.0.0", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "pallet-session 2.0.0", "pallet-timestamp 2.0.0", "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3512,9 +3512,9 @@ dependencies = [ name = "pallet-authorship" version = "0.1.0" dependencies = [ - "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "frame-support 2.0.0", "frame-system 2.0.0", + "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "sp-authorship 2.0.0", "sr-io 2.0.0", @@ -3528,10 +3528,10 @@ dependencies = [ name = "pallet-babe" version = "2.0.0" dependencies = [ - "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "frame-support 2.0.0", "frame-system 2.0.0", + "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "pallet-session 2.0.0", "pallet-timestamp 2.0.0", "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3569,9 +3569,9 @@ dependencies = [ name = "pallet-collective" version = "2.0.0" dependencies = [ - "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "frame-support 2.0.0", "frame-system 2.0.0", + "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "pallet-balances 2.0.0", "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3587,10 +3587,10 @@ name = "pallet-contracts" version = "2.0.0" dependencies = [ "assert_matches 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "frame-support 2.0.0", "frame-system 2.0.0", + "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "pallet-balances 2.0.0", "pallet-randomness-collective-flip 2.0.0", "pallet-timestamp 2.0.0", @@ -3654,9 +3654,9 @@ dependencies = [ name = "pallet-elections" version = "2.0.0" dependencies = [ - "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "frame-support 2.0.0", "frame-system 2.0.0", + "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "pallet-balances 2.0.0", "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3671,9 +3671,9 @@ dependencies = [ name = "pallet-elections-phragmen" version = "2.0.0" dependencies = [ - "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "frame-support 2.0.0", "frame-system 2.0.0", + "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "pallet-balances 2.0.0", "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3723,9 +3723,9 @@ dependencies = [ name = "pallet-finality-tracker" version = "2.0.0" dependencies = [ - "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "frame-support 2.0.0", "frame-system 2.0.0", + "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "sp-finality-tracker 2.0.0", @@ -3881,10 +3881,10 @@ dependencies = [ name = "pallet-session" version = "2.0.0" dependencies = [ - "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "frame-support 2.0.0", "frame-system 2.0.0", + "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "pallet-timestamp 2.0.0", "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3950,9 +3950,9 @@ dependencies = [ name = "pallet-timestamp" version = "2.0.0" dependencies = [ - "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "frame-support 2.0.0", "frame-system 2.0.0", + "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "sp-timestamp 2.0.0", @@ -5474,11 +5474,11 @@ name = "subkey" version = "2.0.0" dependencies = [ "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", + "frame-system 2.0.0", "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "node-primitives 2.0.0", "node-runtime 2.0.0", - "frame-system 2.0.0", "pallet-balances 2.0.0", "pallet-transaction-payment 2.0.0", "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -6589,12 +6589,12 @@ name = "substrate-test-runtime" version = "2.0.0" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "memory-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "frame-executive 2.0.0", "frame-support 2.0.0", "frame-system 2.0.0", "frame-system-rpc-runtime-api 2.0.0", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "memory-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "pallet-babe 2.0.0", "pallet-timestamp 2.0.0", "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index 978a2be0d7..c9d515423e 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -52,15 +52,21 @@ //! //! Candidates also reserve a bond as they submit candidacy. A candidate cannot take their candidacy //! back. A candidate can end up in one of the below situations: -//! - **Winner**: A winner is kept as a _member_. They must still have a bond in reserve and they -//! are automatically counted as a candidate for the next election. -//! - **Loser**: Any of the candidate who are not a winner are left as losers. A loser might be an -//! _outgoing member_, meaning that they are an active member who failed to keep their spot. In -//! this case, the outgoing member will get their bond back. Otherwise, the bond is slashed from -//! the loser candidate. +//! - **Winner**: A winner is kept as a _member_. They must still have a bond in reserve and they +//! are automatically counted as a candidate for the next election. //! - **Runner-up**: Runners-up are the best candidates immediately after the winners. The number -//! of runners_up to keep is configurable. Runners-up are used, in order that they are elected, -//! as replacements when a candidate is kicked by `remove_member()`. +//! of runners_up to keep is configurable. Runners-up are used, in order that they are elected, +//! as replacements when a candidate is kicked by `[remove_member]`, or when an active member +//! renounces their candidacy. Runners are automatically counted as a candidate for the next +//! election. +//! - **Loser**: Any of the candidate who are not a winner are left as losers. A loser might be an +//! _outgoing member or runner_, meaning that they are an active member who failed to keep their +//! spot. An outgoing will always lose their bond. +//! +//! ##### Renouncing candidacy. +//! +//! All candidates, elected or not, can renounce their candidacy. A call to [`renounce_candidacy`] +//! will always cause the candidacy bond to be refunded. //! //! Note that with the members being the default candidates for the next round and votes persisting //! in storage, the election system is entirely stable given no further input. This means that if @@ -77,12 +83,10 @@ #![cfg_attr(not(feature = "std"), no_std)] use rstd::prelude::*; -use codec::Decode; use sr_primitives::{print, traits::{Zero, StaticLookup, Bounded, Convert}}; use support::weights::SimpleDispatchInfo; use support::{ decl_storage, decl_event, ensure, decl_module, dispatch, - storage::unhashed, traits::{ Currency, Get, LockableCurrency, LockIdentifier, ReservableCurrency, WithdrawReasons, ChangeMembers, OnUnbalanced, WithdrawReason @@ -161,11 +165,6 @@ decl_storage! { /// The present candidate list. Sorted based on account id. A current member can never enter /// this vector and is always implicitly assumed to be a candidate. pub Candidates get(fn candidates): Vec; - - /// Has the storage format been updated? - /// NOTE: Only use and set to false if you have used an early version of this module. Should - /// be set to true otherwise. - DidMigrate: bool; } } @@ -315,6 +314,7 @@ decl_module! { let index = is_candidate.unwrap_err(); ensure!(!Self::is_member(&who), "member cannot re-submit candidacy"); + ensure!(!Self::is_runner(&who), "runner cannot re-submit candidacy"); T::Currency::reserve(&who, T::CandidacyBond::get()) .map_err(|_| "candidate does not have enough funds")?; @@ -322,7 +322,63 @@ decl_module! { >::mutate(|c| c.insert(index, who)); } - /// Remove a particular member from the set. This is effective immediately. + /// Renounce one's intention to be a candidate for the next election round. 3 potential + /// outcomes exist: + /// - `origin` is a candidate and not elected in any set. In this case, the bond is + /// unreserved, returned and origin is removed as a candidate. + /// - `origin` is a current runner up. In this case, the bond is unreserved, returned and + /// origin is removed as a runner. + /// - `origin` is a current member. In this case, the bond is unreserved and origin is + /// removed as a member, consequently not being a candidate for the next round anymore. + /// Similar to [`remove_voter`], if replacement runners exists, they are immediately used. + #[weight = SimpleDispatchInfo::FixedOperational(2_000_000)] + fn renounce_candidacy(origin) { + let who = ensure_signed(origin)?; + + // NOTE: this function attempts the 3 conditions (being a candidate, member, runner) and + // fails if none are matched. Unlike other Palette functions and modules where checks + // happen first and then execution happens, this function is written the other way + // around. The main intention is that reading all of the candidates, members and runners + // from storage is expensive. Furthermore, we know (soft proof) that they are always + // mutually exclusive. Hence, we try one, and only then decode more storage. + + if let Ok(_replacement) = Self::remove_and_replace_member(&who) { + T::Currency::unreserve(&who, T::CandidacyBond::get()); + Self::deposit_event(RawEvent::MemberRenounced(who.clone())); + + // safety guard to make sure we do only one arm. Better to read runners later. + return Ok(()); + } + + let mut runners_with_stake = Self::runners_up(); + if let Ok(index) = runners_with_stake + .binary_search_by(|(ref r, ref _s)| r.cmp(&who)) + { + runners_with_stake.remove(index); + // unreserve the bond + T::Currency::unreserve(&who, T::CandidacyBond::get()); + // update storage. + >::put(runners_with_stake); + // safety guard to make sure we do only one arm. Better to read runners later. + return Ok(()); + } + + let mut candidates = Self::candidates(); + if let Ok(index) = candidates.binary_search(&who) { + candidates.remove(index); + // unreserve the bond + T::Currency::unreserve(&who, T::CandidacyBond::get()); + // update storage. + >::put(candidates); + // safety guard to make sure we do only one arm. Better to read runners later. + return Ok(()); + } + + return Err("origin is not a candidate, member or a runner."); + } + + /// Remove a particular member from the set. This is effective immediately and the bond of + /// the outgoing member is slashed. /// /// If a runner-up is available, then the best runner-up will be removed and replaces the /// outgoing member. Otherwise, a new phragmen round is started. @@ -339,51 +395,21 @@ decl_module! { ensure_root(origin)?; let who = T::Lookup::lookup(who)?; - let mut members_with_stake = Self::members(); - if let Ok(index) = members_with_stake.binary_search_by(|(ref m, ref _s)| m.cmp(&who)) { - // remove, slash, emit event. - members_with_stake.remove(index); + return Self::remove_and_replace_member(&who).map(|had_replacement| { let (imbalance, _) = T::Currency::slash_reserved(&who, T::CandidacyBond::get()); T::KickedMember::on_unbalanced(imbalance); Self::deposit_event(RawEvent::MemberKicked(who.clone())); - let mut runners_up = Self::runners_up(); - if let Some((replacement, stake)) = runners_up.pop() { - // replace the outgoing with the best runner up. - if let Err(index) = members_with_stake - .binary_search_by(|(ref m, ref _s)| m.cmp(&replacement)) - { - members_with_stake.insert(index, (replacement.clone(), stake)); - ElectionRounds::mutate(|v| *v += 1); - T::ChangeMembers::change_members_sorted( - &[replacement], - &[who], - &members_with_stake - .iter() - .map(|(m, _)| m.clone()) - .collect::>(), - ); - } - // else it would mean that the runner up was already a member. This cannot - // happen. If it does, not much that we can do about it. - - >::put(members_with_stake); - >::put(runners_up); - } else { - // update `Members` storage -- `do_phragmen` adds this to the candidate list. - >::put(members_with_stake); - // trigger a new phragmen. grab a cup of coffee. This might take a while. + if !had_replacement { Self::do_phragmen(); } - } + + () + }) } /// What to do at the end of each block. Checks if an election needs to happen or not. fn on_initialize(n: T::BlockNumber) { - if !DidMigrate::exists() { - DidMigrate::put(true); - Self::do_migrate(); - } if let Err(e) = Self::end_block(n) { print("Guru meditation"); print(e); @@ -405,6 +431,8 @@ decl_event!( /// A member has been removed. This should always be followed by either `NewTerm` ot /// `EmptyTerm`. MemberKicked(AccountId), + /// A member has renounced their candidacy. + MemberRenounced(AccountId), /// A voter (first element) was reported (byt the second element) with the the report being /// successful or not (third element). VoterReported(AccountId, AccountId, bool), @@ -412,6 +440,54 @@ decl_event!( ); impl Module { + /// Attempts to remove a member `who`. If a runner up exists, it is used as the replacement. + /// Otherwise, `Ok(false)` is returned to signal the caller. + /// + /// In both cases, [`Members`], [`ElectionRounds`] and [`RunnersUp`] storage are updated + /// accordingly. Furthermore, the membership change is reported. + /// + /// O(phragmen) in the worse case. + fn remove_and_replace_member(who: &T::AccountId) -> Result { + let mut members_with_stake = Self::members(); + if let Ok(index) = members_with_stake.binary_search_by(|(ref m, ref _s)| m.cmp(who)) { + members_with_stake.remove(index); + + let mut runners_up = Self::runners_up(); + if let Some((replacement, stake)) = runners_up.pop() { + // replace the outgoing with the best runner up. + if let Err(index) = members_with_stake + .binary_search_by(|(ref m, ref _s)| m.cmp(&replacement)) + { + members_with_stake.insert(index, (replacement.clone(), stake)); + ElectionRounds::mutate(|v| *v += 1); + T::ChangeMembers::change_members_sorted( + &[replacement], + &[who.clone()], + &members_with_stake + .iter() + .map(|(m, _)| m.clone()) + .collect::>(), + ); + } + // else it would mean that the runner up was already a member. This cannot + // happen. If it does, not much that we can do about it. + + >::put(members_with_stake); + >::put(runners_up); + + Ok(true) + } else { + // update `Members` storage -- `do_phragmen` adds this to the candidate list. + >::put(members_with_stake); + + // signal caller that no replacement has been found. + Ok(false) + } + } else { + Err("not a member") + } + } + /// Check if `who` is a candidate. It returns the insert index if the element does not exists as /// an error. /// @@ -434,6 +510,13 @@ impl Module { Self::members_ids().binary_search(who).is_ok() } + /// Check if `who` is currently an active runner. + /// + /// Limited number of runners-up. Binary search. Constant time factor. O(1) + fn is_runner(who: &T::AccountId) -> bool { + Self::runners_up_ids().binary_search(who).is_ok() + } + /// Returns number of desired members. fn desired_members() -> u32 { T::DesiredMembers::get() @@ -524,14 +607,12 @@ impl Module { let mut candidates = Self::candidates(); // candidates who explicitly called `submit_candidacy`. Only these folks are at the risk of // losing their bond. - let mut exposed_candidates = candidates.clone(); + let exposed_candidates = candidates.clone(); // current members are always a candidate for the next round as well. // this is guaranteed to not create any duplicates. candidates.append(&mut Self::members_ids()); // previous runners_up are also always candidates for the next round. candidates.append(&mut Self::runners_up_ids()); - // and exposed to being an outgoing in case they are no longer elected. - exposed_candidates.append(&mut Self::runners_up_ids()); let voters_and_votes = >::enumerate() .map(|(v, i)| (v, i)) @@ -544,9 +625,10 @@ impl Module { Self::locked_stake_of, ); - let mut to_release_bond: Vec = Vec::with_capacity(desired_seats); - let old_members = >::take(); if let Some(phragmen_result) = maybe_phragmen_result { + let old_members = >::take(); + let old_runners = >::take(); + // filter out those who had literally no votes at all. // AUDIT/NOTE: the need to do this is because all candidates, even those who have no // vote are still considered by phragmen and when good candidates are scarce, then these @@ -581,22 +663,28 @@ impl Module { // split new set into winners and runner ups. let split_point = desired_seats.min(new_set_with_stake.len()); let mut new_members = (&new_set_with_stake[..split_point]).to_vec(); - let runners_up = &new_set_with_stake[split_point..] + let new_members_ids = new_members + .iter() + .map(|(m, _)| m.clone()) + .collect::>(); + let new_runners_up = &new_set_with_stake[split_point..] .into_iter() .cloned() .rev() .collect::)>>(); + let new_runners_up_ids = new_runners_up + .iter() + .map(|(r, _)| r.clone()) + .collect::>(); + + // save the runners as-is. They are sorted based on desirability. // sort and save the members. new_members.sort(); - >::put(&new_members); - - // save the runners as-is - >::put(runners_up); // report member changes. We compute diff because we need the outgoing list. let (incoming, outgoing) = T::ChangeMembers::compute_members_diff( - &Self::members_ids(), + &new_members_ids, &old_members.into_iter().map(|(m, _)| m).collect::>(), ); T::ChangeMembers::change_members_sorted( @@ -605,62 +693,50 @@ impl Module { &Self::members_ids(), ); - // unlike exposed_candidates, these are members who were in the list and no longer - // exist. They must get their bond back. - to_release_bond = outgoing.to_vec(); + // outgoing candidates lose their bond. + let mut to_burn_bond = outgoing.to_vec(); + + // compute the outgoing of runners up as well and append them to the `to_burn_bond` + { + let (_, outgoing) = T::ChangeMembers::compute_members_diff( + &new_runners_up_ids, + &old_runners.into_iter().map(|(r, _)| r).collect::>(), + ); + to_burn_bond.extend(outgoing); + } // Burn loser bond. members list is sorted. O(NLogM) (N candidates, M members) // runner up list is not sorted. O(K*N) given K runner ups. Overall: O(NLogM + N*K) + // both the member and runner counts are bounded. exposed_candidates.into_iter().for_each(|c| { // any candidate who is not a member and not a runner up. if new_members.binary_search_by_key(&c, |(m, _)| m.clone()).is_err() - && !Self::runners_up_ids().contains(&c) + && !new_runners_up_ids.contains(&c) { let (imbalance, _) = T::Currency::slash_reserved(&c, T::CandidacyBond::get()); T::LoserCandidate::on_unbalanced(imbalance); } }); - Self::deposit_event(RawEvent::NewTerm(new_members.to_vec())); + + // Burn outgoing bonds + to_burn_bond.into_iter().for_each(|x| { + let (imbalance, _) = T::Currency::slash_reserved(&x, T::CandidacyBond::get()); + T::LoserCandidate::on_unbalanced(imbalance); + }); + + >::put(&new_members); + >::put(new_runners_up); + + Self::deposit_event(RawEvent::NewTerm(new_members.clone().to_vec())); } else { Self::deposit_event(RawEvent::EmptyTerm); } - // unreserve the bond of all the outgoings. - to_release_bond.iter().for_each(|m| { - T::Currency::unreserve(&m, T::CandidacyBond::get()); - }); - // clean candidates. >::kill(); ElectionRounds::mutate(|v| *v += 1); } - - /// Perform the storage update needed to migrate the module from the initial version of the - /// storage. - /// - /// If decoding the old storage fails in any way, the consequence is that we start with an empty - /// set. - fn do_migrate() { - // old storage format. - let old_members: Vec = unhashed::get_raw(&>::hashed_key()) - .and_then(|bytes| Decode::decode(&mut &*bytes).ok()).unwrap_or_default(); - let old_runners: Vec = unhashed::get_raw(&>::hashed_key()) - .and_then(|bytes| Decode::decode(&mut &*bytes).ok()).unwrap_or_default(); - - // new storage format. - let new_runners: Vec<(T::AccountId, BalanceOf)> = old_runners - .into_iter() - .map(|r| (r, Zero::zero())) - .collect(); - let new_members: Vec<(T::AccountId, BalanceOf)> = old_members - .into_iter() - .map(|r| (r, Zero::zero())) - .collect(); - - >::put(new_members); - >::put(new_runners); - } } #[cfg(test)] @@ -671,7 +747,7 @@ mod tests { use primitives::H256; use sr_primitives::{ Perbill, testing::Header, BuildStorage, - traits::{OnInitialize, BlakeTwo256, IdentityLookup, Block as BlockT}, + traits::{BlakeTwo256, IdentityLookup, Block as BlockT}, }; use crate as elections; @@ -860,30 +936,6 @@ mod tests { lock.amount } - #[test] - fn temp_migration_works() { - ExtBuilder::default().build().execute_with(|| { - use support::storage::unhashed; - use codec::Encode; - - let old_members = vec![1u64, 2]; - let old_runners = vec![3u64]; - - let members_key = >::hashed_key(); - let runners_key = >::hashed_key(); - - unhashed::put_raw(&members_key, &old_members.encode()[..]); - unhashed::put_raw(&runners_key, &old_runners.encode()[..]); - - assert_eq!(DidMigrate::get(), false); - >::on_initialize(1); - assert_eq!(DidMigrate::get(), true); - - assert_eq!(Elections::members(), vec![(1, 0), (2, 0)]); - assert_eq!(Elections::runners_up(), vec![(3, 0)]); - }); - } - #[test] fn params_should_work() { ExtBuilder::default().build().execute_with(|| { @@ -1017,13 +1069,36 @@ mod tests { }); } + #[test] + fn runner_candidate_submission_should_not_work() { + ExtBuilder::default().desired_runners_up(2).build().execute_with(|| { + assert_ok!(Elections::submit_candidacy(Origin::signed(5))); + assert_ok!(Elections::submit_candidacy(Origin::signed(4))); + assert_ok!(Elections::submit_candidacy(Origin::signed(3))); + + assert_ok!(Elections::vote(Origin::signed(2), vec![5, 4], 20)); + assert_ok!(Elections::vote(Origin::signed(1), vec![3], 10)); + + System::set_block_number(5); + assert_ok!(Elections::end_block(System::block_number())); + + assert_eq!(Elections::members_ids(), vec![4, 5]); + assert_eq!(Elections::runners_up_ids(), vec![3]); + + assert_noop!( + Elections::submit_candidacy(Origin::signed(3)), + "runner cannot re-submit candidacy", + ); + }); + } + #[test] fn poor_candidate_submission_should_not_work() { ExtBuilder::default().build().execute_with(|| { assert_eq!(Elections::candidates(), Vec::::new()); assert_noop!( Elections::submit_candidacy(Origin::signed(7)), - "candidate does not have enough funds" + "candidate does not have enough funds", ); }); } @@ -1089,7 +1164,6 @@ mod tests { #[test] fn can_vote_for_old_members_even_when_no_new_candidates() { - // let allowed_votes = candidates_count as usize + Self::members().len() ExtBuilder::default().build().execute_with(|| { assert_ok!(Elections::submit_candidacy(Origin::signed(5))); assert_ok!(Elections::submit_candidacy(Origin::signed(4))); @@ -1114,7 +1188,7 @@ mod tests { assert_noop!( Elections::vote(Origin::signed(2), vec![10, 20, 30], 20), - "cannot vote more than candidates" + "cannot vote more than candidates", ); }); } @@ -1127,7 +1201,7 @@ mod tests { assert_noop!( Elections::vote(Origin::signed(2), vec![4], 1), - "cannot vote with stake less than minimum balance" + "cannot vote with stake less than minimum balance", ); }) } @@ -1484,7 +1558,6 @@ mod tests { System::set_block_number(5); assert_ok!(Elections::end_block(System::block_number())); assert_eq!(Elections::members_ids(), vec![4, 5]); - assert_eq!(Elections::runners_up_ids(), vec![2]); assert_eq!(balances(&2), (15, 5)); @@ -1493,16 +1566,63 @@ mod tests { System::set_block_number(10); assert_ok!(Elections::end_block(System::block_number())); - assert_eq!(Elections::members_ids(), vec![4, 5]); assert_eq!(Elections::runners_up_ids(), vec![3]); - assert_eq!(balances(&3), (25, 5)); assert_eq!(balances(&2), (15, 2)); }); } #[test] - fn current_members_are_always_implicitly_next_candidate() { + fn members_lose_bond_once_outgoing() { + ExtBuilder::default().build().execute_with(|| { + assert_eq!(balances(&5), (50, 0)); + + assert_ok!(Elections::submit_candidacy(Origin::signed(5))); + assert_eq!(balances(&5), (47, 3)); + + assert_ok!(Elections::vote(Origin::signed(5), vec![5], 50)); + assert_eq!(balances(&5), (45, 5)); + + System::set_block_number(5); + assert_ok!(Elections::end_block(System::block_number())); + assert_eq!(Elections::members_ids(), vec![5]); + + assert_ok!(Elections::remove_voter(Origin::signed(5))); + assert_eq!(balances(&5), (47, 3)); + + System::set_block_number(10); + assert_ok!(Elections::end_block(System::block_number())); + assert_eq!(Elections::members_ids(), vec![]); + + assert_eq!(balances(&5), (47, 0)); + }); + } + + #[test] + fn losers_will_lose_the_bond() { + ExtBuilder::default().build().execute_with(|| { + assert_ok!(Elections::submit_candidacy(Origin::signed(5))); + assert_ok!(Elections::submit_candidacy(Origin::signed(3))); + + assert_ok!(Elections::vote(Origin::signed(4), vec![5], 40)); + + assert_eq!(balances(&5), (47, 3)); + assert_eq!(balances(&3), (27, 3)); + + System::set_block_number(5); + assert_ok!(Elections::end_block(System::block_number())); + + assert_eq!(Elections::members_ids(), vec![5]); + + // winner + assert_eq!(balances(&5), (47, 3)); + // loser + assert_eq!(balances(&3), (27, 0)); + }); + } + + #[test] + fn current_members_are_always_next_candidate() { ExtBuilder::default().build().execute_with(|| { assert_ok!(Elections::submit_candidacy(Origin::signed(5))); assert_ok!(Elections::submit_candidacy(Origin::signed(4))); @@ -1630,55 +1750,6 @@ mod tests { }); } - #[test] - fn outgoing_will_get_the_bond_back() { - ExtBuilder::default().build().execute_with(|| { - assert_eq!(balances(&5), (50, 0)); - - assert_ok!(Elections::submit_candidacy(Origin::signed(5))); - assert_eq!(balances(&5), (47, 3)); - - assert_ok!(Elections::vote(Origin::signed(5), vec![5], 50)); - assert_eq!(balances(&5), (45, 5)); - - System::set_block_number(5); - assert_ok!(Elections::end_block(System::block_number())); - assert_eq!(Elections::members_ids(), vec![5]); - - assert_ok!(Elections::remove_voter(Origin::signed(5))); - assert_eq!(balances(&5), (47, 3)); - - System::set_block_number(10); - assert_ok!(Elections::end_block(System::block_number())); - assert_eq!(Elections::members_ids(), vec![]); - - assert_eq!(balances(&5), (50, 0)); - }); - } - - #[test] - fn losers_will_lose_the_bond() { - ExtBuilder::default().build().execute_with(|| { - assert_ok!(Elections::submit_candidacy(Origin::signed(5))); - assert_ok!(Elections::submit_candidacy(Origin::signed(3))); - - assert_ok!(Elections::vote(Origin::signed(4), vec![5], 40)); - - assert_eq!(balances(&5), (47, 3)); - assert_eq!(balances(&3), (27, 3)); - - System::set_block_number(5); - assert_ok!(Elections::end_block(System::block_number())); - - assert_eq!(Elections::members_ids(), vec![5]); - - // winner - assert_eq!(balances(&5), (47, 3)); - // loser - assert_eq!(balances(&3), (27, 0)); - }); - } - #[test] fn incoming_outgoing_are_reported() { ExtBuilder::default().build().execute_with(|| { @@ -1717,8 +1788,8 @@ mod tests { // 1 is a loser, slashed by 3. assert_eq!(balances(&1), (5, 2)); - // 5 is an outgoing loser, it will get their bond back. - assert_eq!(balances(&5), (48, 2)); + // 5 is an outgoing loser. will also get slashed. + assert_eq!(balances(&5), (45, 2)); assert_eq!( System::events()[0].event, @@ -1766,4 +1837,149 @@ mod tests { assert_eq!(Elections::runners_up(), vec![(3, 20), (2, 30)]); }); } + + #[test] + fn candidates_are_sorted() { + ExtBuilder::default().build().execute_with(|| { + assert_ok!(Elections::submit_candidacy(Origin::signed(5))); + assert_ok!(Elections::submit_candidacy(Origin::signed(3))); + + assert_eq!(Elections::candidates(), vec![3, 5]); + + assert_ok!(Elections::submit_candidacy(Origin::signed(2))); + assert_ok!(Elections::submit_candidacy(Origin::signed(4))); + assert_ok!(Elections::renounce_candidacy(Origin::signed(3))); + + assert_eq!(Elections::candidates(), vec![2, 4, 5]); + }) + } + + #[test] + fn runner_up_replacement_maintains_members_order() { + ExtBuilder::default().desired_runners_up(2).build().execute_with(|| { + assert_ok!(Elections::submit_candidacy(Origin::signed(5))); + assert_ok!(Elections::submit_candidacy(Origin::signed(4))); + assert_ok!(Elections::submit_candidacy(Origin::signed(2))); + + assert_ok!(Elections::vote(Origin::signed(2), vec![5], 20)); + assert_ok!(Elections::vote(Origin::signed(4), vec![4], 40)); + assert_ok!(Elections::vote(Origin::signed(5), vec![2], 50)); + + System::set_block_number(5); + assert_ok!(Elections::end_block(System::block_number())); + + assert_eq!(Elections::members_ids(), vec![2, 4]); + assert_ok!(Elections::remove_member(Origin::ROOT, 2)); + assert_eq!(Elections::members_ids(), vec![4, 5]); + }); + } + + #[test] + fn can_renounce_candidacy_member_with_runners_bond_is_refunded() { + ExtBuilder::default().desired_runners_up(2).build().execute_with(|| { + assert_ok!(Elections::submit_candidacy(Origin::signed(5))); + assert_ok!(Elections::submit_candidacy(Origin::signed(4))); + assert_ok!(Elections::submit_candidacy(Origin::signed(3))); + assert_ok!(Elections::submit_candidacy(Origin::signed(2))); + + assert_ok!(Elections::vote(Origin::signed(5), vec![5], 50)); + assert_ok!(Elections::vote(Origin::signed(4), vec![4], 40)); + assert_ok!(Elections::vote(Origin::signed(3), vec![3], 30)); + assert_ok!(Elections::vote(Origin::signed(2), vec![2], 20)); + + System::set_block_number(5); + assert_ok!(Elections::end_block(System::block_number())); + + assert_eq!(Elections::members_ids(), vec![4, 5]); + assert_eq!(Elections::runners_up_ids(), vec![2, 3]); + + assert_ok!(Elections::renounce_candidacy(Origin::signed(4))); + assert_eq!(balances(&4), (38, 2)); // 2 is voting bond. + + assert_eq!(Elections::members_ids(), vec![3, 5]); + assert_eq!(Elections::runners_up_ids(), vec![2]); + }) + } + + #[test] + fn can_renounce_candidacy_member_without_runners_bond_is_refunded() { + ExtBuilder::default().desired_runners_up(2).build().execute_with(|| { + assert_ok!(Elections::submit_candidacy(Origin::signed(5))); + assert_ok!(Elections::submit_candidacy(Origin::signed(4))); + + assert_ok!(Elections::vote(Origin::signed(5), vec![5], 50)); + assert_ok!(Elections::vote(Origin::signed(4), vec![4], 40)); + + System::set_block_number(5); + assert_ok!(Elections::end_block(System::block_number())); + + assert_ok!(Elections::submit_candidacy(Origin::signed(3))); + assert_ok!(Elections::submit_candidacy(Origin::signed(2))); + assert_ok!(Elections::vote(Origin::signed(3), vec![3], 30)); + assert_ok!(Elections::vote(Origin::signed(2), vec![2], 20)); + + assert_eq!(Elections::members_ids(), vec![4, 5]); + assert_eq!(Elections::runners_up_ids(), vec![]); + assert_eq!(Elections::candidates(), vec![2, 3]); + + assert_ok!(Elections::renounce_candidacy(Origin::signed(4))); + assert_eq!(balances(&4), (38, 2)); // 2 is voting bond. + + // no replacement + assert_eq!(Elections::members_ids(), vec![5]); + assert_eq!(Elections::runners_up_ids(), vec![]); + // still candidate + assert_eq!(Elections::candidates(), vec![2, 3]); + }) + } + + #[test] + fn can_renounce_candidacy_runner() { + ExtBuilder::default().desired_runners_up(2).build().execute_with(|| { + assert_ok!(Elections::submit_candidacy(Origin::signed(5))); + assert_ok!(Elections::submit_candidacy(Origin::signed(4))); + assert_ok!(Elections::submit_candidacy(Origin::signed(3))); + assert_ok!(Elections::submit_candidacy(Origin::signed(2))); + + assert_ok!(Elections::vote(Origin::signed(5), vec![4], 50)); + assert_ok!(Elections::vote(Origin::signed(4), vec![5], 40)); + assert_ok!(Elections::vote(Origin::signed(3), vec![3], 30)); + assert_ok!(Elections::vote(Origin::signed(2), vec![2], 20)); + + System::set_block_number(5); + assert_ok!(Elections::end_block(System::block_number())); + + assert_eq!(Elections::members_ids(), vec![4, 5]); + assert_eq!(Elections::runners_up_ids(), vec![2, 3]); + + assert_ok!(Elections::renounce_candidacy(Origin::signed(3))); + assert_eq!(balances(&3), (28, 2)); // 2 is voting bond. + + assert_eq!(Elections::members_ids(), vec![4, 5]); + assert_eq!(Elections::runners_up_ids(), vec![2]); + }) + } + + #[test] + fn can_renounce_candidacy_candidate() { + ExtBuilder::default().build().execute_with(|| { + assert_ok!(Elections::submit_candidacy(Origin::signed(5))); + assert_eq!(balances(&5), (47, 3)); + assert_eq!(Elections::candidates(), vec![5]); + + assert_ok!(Elections::renounce_candidacy(Origin::signed(5))); + assert_eq!(balances(&5), (50, 0)); + assert_eq!(Elections::candidates(), vec![]); + }) + } + + #[test] + fn wrong_renounce_candidacy_should_fail() { + ExtBuilder::default().build().execute_with(|| { + assert_noop!( + Elections::renounce_candidacy(Origin::signed(5)), + "origin is not a candidate, member or a runner.", + ); + }) + } } -- GitLab From eef00ea7a5bb80853b02fa8319360e8700992fe7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Sat, 23 Nov 2019 23:28:42 +0100 Subject: [PATCH 002/172] Switch to new kvdb-rocksdb (#4186) * Switch to new rocksdb with some hacks to resolve linking errors Rocksdb and `wasmtime-environ` both link `zstd`. In the final link step, this leads to linking errors because of duplicate symbols. The linked Rocksdb fixes this by using `zstd-sys` as well. However, this currently also requires modifications in `zstd-sys`. Someone will need to come up with a better implementation. * Switch to new version of kvdb-rocksdb * Update client/db/src/utils.rs Co-Authored-By: Shawn Tabrizi --- Cargo.lock | 133 ++++++++++++++++---------------------- bin/node/cli/Cargo.toml | 2 +- client/Cargo.toml | 4 +- client/api/Cargo.toml | 4 +- client/db/Cargo.toml | 6 +- client/db/src/lib.rs | 6 +- client/db/src/offchain.rs | 2 +- client/db/src/utils.rs | 20 +++++- 8 files changed, 89 insertions(+), 88 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2dc0e193bd..0a8078053e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -254,22 +254,23 @@ dependencies = [ [[package]] name = "bindgen" -version = "0.47.3" +version = "0.49.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "cexpr 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "clang-sys 0.26.4 (registry+https://github.com/rust-lang/crates.io-index)", + "clang-sys 0.28.1 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "peeking_take_while 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "shlex 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "which 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -502,10 +503,10 @@ dependencies = [ [[package]] name = "clang-sys" -version = "0.26.4" +version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1629,6 +1630,14 @@ dependencies = [ "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "fxhash" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "gcc" version = "0.3.55" @@ -2281,36 +2290,37 @@ dependencies = [ [[package]] name = "kvdb" -version = "0.1.0" -source = "git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d#b0317f649ab2c665b7987b8475878fc4d2e1f81d" +version = "0.1.1" +source = "git+https://github.com/paritytech/parity-common?rev=03a2ba08f47f4af4219280e660a1ea92cb8896bd#03a2ba08f47f4af4219280e660a1ea92cb8896bd" dependencies = [ "elastic-array 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-bytes 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)", + "parity-bytes 0.1.1 (git+https://github.com/paritytech/parity-common?rev=03a2ba08f47f4af4219280e660a1ea92cb8896bd)", ] [[package]] name = "kvdb-memorydb" -version = "0.1.0" -source = "git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d#b0317f649ab2c665b7987b8475878fc4d2e1f81d" +version = "0.1.2" +source = "git+https://github.com/paritytech/parity-common?rev=03a2ba08f47f4af4219280e660a1ea92cb8896bd#03a2ba08f47f4af4219280e660a1ea92cb8896bd" dependencies = [ - "kvdb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)", - "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "kvdb 0.1.1 (git+https://github.com/paritytech/parity-common?rev=03a2ba08f47f4af4219280e660a1ea92cb8896bd)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "kvdb-rocksdb" -version = "0.1.4" -source = "git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d#b0317f649ab2c665b7987b8475878fc4d2e1f81d" +version = "0.1.6" +source = "git+https://github.com/paritytech/parity-common?rev=03a2ba08f47f4af4219280e660a1ea92cb8896bd#03a2ba08f47f4af4219280e660a1ea92cb8896bd" dependencies = [ "elastic-array 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "fs-swap 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "interleaved-ordered 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "kvdb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)", + "kvdb 0.1.1 (git+https://github.com/paritytech/parity-common?rev=03a2ba08f47f4af4219280e660a1ea92cb8896bd)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rocksdb 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rocksdb 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2717,12 +2727,12 @@ dependencies = [ [[package]] name = "librocksdb-sys" -version = "5.18.3" +version = "6.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bindgen 0.47.3 (registry+https://github.com/rust-lang/crates.io-index)", + "bindgen 0.49.2 (registry+https://github.com/rust-lang/crates.io-index)", "cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)", - "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3033,7 +3043,7 @@ dependencies = [ "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "js-sys 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "kvdb-memorydb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)", + "kvdb-memorydb 0.1.2 (git+https://github.com/paritytech/parity-common?rev=03a2ba08f47f4af4219280e660a1ea92cb8896bd)", "libp2p 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "node-executor 2.0.0", @@ -4024,8 +4034,8 @@ dependencies = [ [[package]] name = "parity-bytes" -version = "0.1.0" -source = "git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d#b0317f649ab2c665b7987b8475878fc4d2e1f81d" +version = "0.1.1" +source = "git+https://github.com/paritytech/parity-common?rev=03a2ba08f47f4af4219280e660a1ea92cb8896bd#03a2ba08f47f4af4219280e660a1ea92cb8896bd" [[package]] name = "parity-multiaddr" @@ -4145,15 +4155,6 @@ name = "parity-wasm" version = "0.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "parking_lot" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "parking_lot" version = "0.7.1" @@ -4183,18 +4184,6 @@ dependencies = [ "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "parking_lot_core" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "parking_lot_core" version = "0.4.0" @@ -4535,18 +4524,6 @@ dependencies = [ "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "rand" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "rand" version = "0.6.5" @@ -4835,11 +4812,11 @@ dependencies = [ [[package]] name = "rocksdb" -version = "0.11.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "librocksdb-sys 5.18.3 (registry+https://github.com/rust-lang/crates.io-index)", + "librocksdb-sys 6.2.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -5121,6 +5098,11 @@ dependencies = [ "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "shlex" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "slab" version = "0.4.2" @@ -5667,8 +5649,8 @@ dependencies = [ "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "kvdb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)", - "kvdb-memorydb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)", + "kvdb 0.1.1 (git+https://github.com/paritytech/parity-common?rev=03a2ba08f47f4af4219280e660a1ea92cb8896bd)", + "kvdb-memorydb 0.1.2 (git+https://github.com/paritytech/parity-common?rev=03a2ba08f47f4af4219280e660a1ea92cb8896bd)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5704,8 +5686,8 @@ dependencies = [ "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "kvdb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)", - "kvdb-memorydb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)", + "kvdb 0.1.1 (git+https://github.com/paritytech/parity-common?rev=03a2ba08f47f4af4219280e660a1ea92cb8896bd)", + "kvdb-memorydb 0.1.2 (git+https://github.com/paritytech/parity-common?rev=03a2ba08f47f4af4219280e660a1ea92cb8896bd)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5737,9 +5719,9 @@ version = "2.0.0" dependencies = [ "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", - "kvdb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)", - "kvdb-memorydb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)", - "kvdb-rocksdb 0.1.4 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)", + "kvdb 0.1.1 (git+https://github.com/paritytech/parity-common?rev=03a2ba08f47f4af4219280e660a1ea92cb8896bd)", + "kvdb-memorydb 0.1.2 (git+https://github.com/paritytech/parity-common?rev=03a2ba08f47f4af4219280e660a1ea92cb8896bd)", + "kvdb-rocksdb 0.1.6 (git+https://github.com/paritytech/parity-common?rev=03a2ba08f47f4af4219280e660a1ea92cb8896bd)", "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -8013,7 +7995,7 @@ dependencies = [ "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 bindgen 0.47.3 (registry+https://github.com/rust-lang/crates.io-index)" = "df683a55b54b41d5ea8ebfaebb5aa7e6b84e3f3006a78f010dadc9ca88469260" +"checksum bindgen 0.49.2 (registry+https://github.com/rust-lang/crates.io-index)" = "846a1fba6535362a01487ef6b10f0275faa12e5c5d835c5c1c627aabc46ccbd6" "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" "checksum bitvec 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a993f74b4c99c1908d156b8d2e0fb6277736b0ecbd833982fd1241d39b2766a6" @@ -8042,7 +8024,7 @@ dependencies = [ "checksum cexpr 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "fce5b5fb86b0c57c20c834c1b412fd09c77c8a59b9473f86272709e78874cd1d" "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" "checksum chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e8493056968583b0193c1bb04d6f7684586f3726992d6c573261941a895dbd68" -"checksum clang-sys 0.26.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6ef0c1bcf2e99c649104bd7a7012d8f8802684400e03db0ec0af48583c6fa0e4" +"checksum clang-sys 0.28.1 (registry+https://github.com/rust-lang/crates.io-index)" = "81de550971c976f176130da4b2978d3b524eaa0fd9ac31f3ceb5ae1231fb4853" "checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" "checksum clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "97276801e127ffb46b66ce23f35cc96bd454fa311294bced4bbace7baa8b1d17" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" @@ -8145,6 +8127,7 @@ dependencies = [ "checksum futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c0d66274fb76985d3c62c886d1da7ac4c0903a8c9f754e8fe0f35a6a6cc39e76" "checksum futures-util-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)" = "5ce968633c17e5f97936bd2797b6e38fb56cf16a7422319f7ec2e30d3c470e8d" "checksum futures01 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)" = "7ef8cbbf52909170053540c6c05a62433ddb60662dabee714e2a882caa864f22" +"checksum fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" "checksum generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" "checksum get_if_addrs 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "abddb55a898d32925f3148bd281174a68eeb68bbfd9a5938a57b18f506ee4ef7" @@ -8207,9 +8190,9 @@ dependencies = [ "checksum keccak-hasher 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3468207deea1359a0e921591ae9b4c928733d94eb9d6a2eeda994cfd59f42cf8" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum kv-log-macro 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c54d9f465d530a752e6ebdc217e081a7a614b48cb200f6f0aee21ba6bc9aabb" -"checksum kvdb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)" = "" -"checksum kvdb-memorydb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)" = "" -"checksum kvdb-rocksdb 0.1.4 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)" = "" +"checksum kvdb 0.1.1 (git+https://github.com/paritytech/parity-common?rev=03a2ba08f47f4af4219280e660a1ea92cb8896bd)" = "" +"checksum kvdb-memorydb 0.1.2 (git+https://github.com/paritytech/parity-common?rev=03a2ba08f47f4af4219280e660a1ea92cb8896bd)" = "" +"checksum kvdb-rocksdb 0.1.6 (git+https://github.com/paritytech/parity-common?rev=03a2ba08f47f4af4219280e660a1ea92cb8896bd)" = "" "checksum language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a" "checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" "checksum lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" @@ -8235,7 +8218,7 @@ dependencies = [ "checksum libp2p-wasm-ext 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3f7b8f2bd81fb356e81352d4513856bc21215ecf91502aa1f55b6449642a9acf" "checksum libp2p-websocket 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0d74d4fc229ad7e8d1a973178786bdcd5dadbdd7b9822c4477c8687df6f82f66" "checksum libp2p-yamux 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1913eb7dd6eb5515957b6f1770296f6921968db87bc9b985f0e974b6657e1003" -"checksum librocksdb-sys 5.18.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d19778314deaa7048f2ea7d07b8aa12e1c227acebe975a37eeab6d2f8c74e41b" +"checksum librocksdb-sys 6.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0a0785e816e1e11e7599388a492c61ef80ddc2afc91e313e61662cce537809be" "checksum libsecp256k1 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2bd9a7c16c9487e710536b699c962f022266347c94201174aa0a7eb0546051aa" "checksum libz-sys 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "2eb5e43362e38e2bca2fd5f5134c4d4564a23a5c28e9b95411652021a8675ebe" "checksum linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83" @@ -8286,7 +8269,7 @@ dependencies = [ "checksum openssl-sys 0.9.52 (registry+https://github.com/rust-lang/crates.io-index)" = "c977d08e1312e2f7e4b86f9ebaa0ed3b19d1daff75fae88bbb88108afbd801fc" "checksum output_vt100 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "53cdc5b785b7a58c5aad8216b3dfa114df64b0b06ae6e1501cef91df2fbdf8f9" "checksum owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "49a4b8ea2179e6a2e27411d3bca09ca6dd630821cf6894c6c7c8467a8ee7ef13" -"checksum parity-bytes 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)" = "" +"checksum parity-bytes 0.1.1 (git+https://github.com/paritytech/parity-common?rev=03a2ba08f47f4af4219280e660a1ea92cb8896bd)" = "" "checksum parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "045b3c7af871285146300da35b1932bb6e4639b66c7c98e85d06a32cbc4e8fa7" "checksum parity-multiaddr 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "82afcb7461eae5d122543d8be1c57d306ed89af2d6ff7f8b0f5a3cc8f7e511bc" "checksum parity-multihash 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "df3a17dc27848fd99e4f87eb0f8c9baba6ede0a6d555400c850ca45254ef4ce3" @@ -8298,11 +8281,9 @@ dependencies = [ "checksum parity-wasm 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "16ad52817c4d343339b3bc2e26861bd21478eda0b7509acf83505727000512ac" "checksum parity-wasm 0.40.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1e39faaa292a687ea15120b1ac31899b13586446521df6c149e46f1584671e0f" "checksum parity-wasm 0.41.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc878dac00da22f8f61e7af3157988424567ab01d9920b962ef7dcbd7cd865" -"checksum parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f0802bff09003b291ba756dc7e79313e51cc31667e94afbe847def490424cde5" "checksum parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ab41b4aed082705d1056416ae4468b6ea99d52599ecf3169b00088d43113e337" "checksum parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fa7767817701cce701d5585b9c4db3cdd02086398322c1d7e8bf5094a96a2ce7" "checksum parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" -"checksum parking_lot_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad7f7e6ebdc79edff6fdcb87a55b620174f7a989e3eb31b65231f4af57f00b8c" "checksum parking_lot_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94c8c7923936b28d546dfd14d4472eaf34c99b14e1c973a32b3e6d4eb04298c9" "checksum parking_lot_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cb88cb1cb3790baa6776844f968fea3be44956cf184fa1be5a03341f5491278c" "checksum parking_lot_core 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b" @@ -8342,7 +8323,6 @@ dependencies = [ "checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" "checksum rand 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)" = "64ac302d8f83c0c1974bf758f6b041c6c8ada916fbb44a609158ca8b064cc76c" "checksum rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" -"checksum rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c618c47cd3ebd209790115ab837de41425723956ad3ce2e6a7f09890947cacb9" "checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" "checksum rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3ae1b169243eaf61759b8475a998f0a385e42042370f3a7dbaf35246eacc8412" "checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" @@ -8374,7 +8354,7 @@ dependencies = [ "checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" "checksum ring 0.16.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6747f8da1f2b1fabbee1aaa4eb8a11abf9adef0bf58a41cee45db5d59cecdfac" "checksum rlp 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3a44d5ae8afcb238af8b75640907edc6c931efcfab2c854e81ed35fa080f84cd" -"checksum rocksdb 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f1651697fefd273bfb4fd69466cc2a9d20de557a0213b97233b22b5e95924b5e" +"checksum rocksdb 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "12069b106981c6103d3eab7dd1c86751482d0779a520b7c14954c8b586c1e643" "checksum rpassword 4.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f072d931f11a96546efd97642e1e75e807345aced86b947f9239102f262d0fcd" "checksum rust-argon2 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4ca4eaef519b494d1f2848fc602d18816fed808a981aedf4f1f00ceb7c9d32cf" "checksum rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" @@ -8408,6 +8388,7 @@ dependencies = [ "checksum sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b4d8bfd0e469f417657573d8451fb33d16cfe0989359b93baf3a1ffc639543d" "checksum sha3 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dd26bc0e7a2e3a7c959bc494caf58b72ee0c71d67704e9520f736ca7e4853ecf" "checksum shell32-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9ee04b46101f57121c9da2b151988283b6beb79b34f5bb29a58ee48cb695122c" +"checksum shlex 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2" "checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" "checksum slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1cc9c640a4adbfbcc11ffb95efe5aa7af7309e002adab54b185507dbf2377b99" "checksum slog-async 2.3.0 (git+https://github.com/paritytech/slog-async)" = "" diff --git a/bin/node/cli/Cargo.toml b/bin/node/cli/Cargo.toml index b6bc00c90c..8e4b3b4adc 100644 --- a/bin/node/cli/Cargo.toml +++ b/bin/node/cli/Cargo.toml @@ -92,7 +92,7 @@ console_log = { version = "0.1.2", optional = true } js-sys = { version = "0.3.22", optional = true } wasm-bindgen = { version = "0.2.45", optional = true } wasm-bindgen-futures = { version = "0.3.22", optional = true } -kvdb-memorydb = { git = "https://github.com/paritytech/parity-common", rev="b0317f649ab2c665b7987b8475878fc4d2e1f81d", optional = true } +kvdb-memorydb = { git = "https://github.com/paritytech/parity-common", rev="03a2ba08f47f4af4219280e660a1ea92cb8896bd", optional = true } rand6 = { package = "rand", version = "0.6", features = ["wasm-bindgen"], optional = true } # Imported just for the `wasm-bindgen` feature [dev-dependencies] diff --git a/client/Cargo.toml b/client/Cargo.toml index 6f6799a48c..3f7c4df917 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -19,7 +19,7 @@ header-metadata = { package = "substrate-header-metadata", path = "header-metada hex-literal = { version = "0.2.1" } inherents = { package = "substrate-inherents", path = "../primitives/inherents" } keyring = { package = "substrate-keyring", path = "../primitives/keyring" } -kvdb = { git = "https://github.com/paritytech/parity-common", rev="b0317f649ab2c665b7987b8475878fc4d2e1f81d" } +kvdb = { git = "https://github.com/paritytech/parity-common", rev="03a2ba08f47f4af4219280e660a1ea92cb8896bd" } log = { version = "0.4.8" } parking_lot = { version = "0.9.0" } primitives = { package = "substrate-primitives", path = "../primitives/core" } @@ -36,5 +36,5 @@ env_logger = "0.7.0" tempfile = "3.1.0" client-db = { package = "substrate-client-db", path = "./db", features = ["kvdb-rocksdb"] } test-client = { package = "substrate-test-runtime-client", path = "../test/utils/runtime/client" } -kvdb-memorydb = { git = "https://github.com/paritytech/parity-common", rev="b0317f649ab2c665b7987b8475878fc4d2e1f81d" } +kvdb-memorydb = { git = "https://github.com/paritytech/parity-common", rev="03a2ba08f47f4af4219280e660a1ea92cb8896bd" } panic-handler = { package = "substrate-panic-handler", path = "../primitives/panic-handler" } diff --git a/client/api/Cargo.toml b/client/api/Cargo.toml index af4d03f001..4757d7af81 100644 --- a/client/api/Cargo.toml +++ b/client/api/Cargo.toml @@ -18,7 +18,7 @@ header-metadata = { package = "substrate-header-metadata", path = "../header-met hex-literal = { version = "0.2.1" } inherents = { package = "substrate-inherents", path = "../../primitives/inherents", default-features = false } keyring = { package = "substrate-keyring", path = "../../primitives/keyring" } -kvdb = { git = "https://github.com/paritytech/parity-common", rev="b0317f649ab2c665b7987b8475878fc4d2e1f81d" } +kvdb = { git = "https://github.com/paritytech/parity-common", rev="03a2ba08f47f4af4219280e660a1ea92cb8896bd" } log = { version = "0.4.8" } parking_lot = { version = "0.9.0" } primitives = { package = "substrate-primitives", path = "../../primitives/core", default-features = false } @@ -36,6 +36,6 @@ tempfile = "3.1.0" client-db = { package = "substrate-client-db", path = ".././db", features = ["kvdb-rocksdb"] } test-primitives = { package = "substrate-test-primitives", path = "../../test/utils/primitives" } test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client" } -kvdb-memorydb = { git = "https://github.com/paritytech/parity-common", rev="b0317f649ab2c665b7987b8475878fc4d2e1f81d" } +kvdb-memorydb = { git = "https://github.com/paritytech/parity-common", rev="03a2ba08f47f4af4219280e660a1ea92cb8896bd" } panic-handler = { package = "substrate-panic-handler", path = "../../primitives/panic-handler" } diff --git a/client/db/Cargo.toml b/client/db/Cargo.toml index f03fde576e..bafeee970b 100644 --- a/client/db/Cargo.toml +++ b/client/db/Cargo.toml @@ -7,10 +7,10 @@ edition = "2018" [dependencies] parking_lot = "0.9.0" log = "0.4.8" -kvdb = { git = "https://github.com/paritytech/parity-common", rev="b0317f649ab2c665b7987b8475878fc4d2e1f81d" } +kvdb = { git = "https://github.com/paritytech/parity-common", rev="03a2ba08f47f4af4219280e660a1ea92cb8896bd" } # FIXME replace with release as soon as our rocksdb changes are released upstream https://github.com/paritytech/parity-common/issues/88 -kvdb-rocksdb = { git = "https://github.com/paritytech/parity-common", rev="b0317f649ab2c665b7987b8475878fc4d2e1f81d", optional = true } -kvdb-memorydb = { git = "https://github.com/paritytech/parity-common", rev="b0317f649ab2c665b7987b8475878fc4d2e1f81d" } +kvdb-rocksdb = { git = "https://github.com/paritytech/parity-common", rev="03a2ba08f47f4af4219280e660a1ea92cb8896bd", optional = true } +kvdb-memorydb = { git = "https://github.com/paritytech/parity-common", rev="03a2ba08f47f4af4219280e660a1ea92cb8896bd" } linked-hash-map = "0.5.2" hash-db = "0.15.2" client-api = { package = "substrate-client-api", path = "../api" } diff --git a/client/db/src/lib.rs b/client/db/src/lib.rs index 155d2aaeab..98a3eca375 100644 --- a/client/db/src/lib.rs +++ b/client/db/src/lib.rs @@ -98,7 +98,11 @@ pub struct RefTrackingState { } impl RefTrackingState { - fn new(state: DbState, storage: Arc>, parent_hash: Option) -> RefTrackingState { + fn new( + state: DbState, + storage: Arc>, + parent_hash: Option, + ) -> RefTrackingState { RefTrackingState { state, parent_hash, diff --git a/client/db/src/offchain.rs b/client/db/src/offchain.rs index 0435a1c865..565e113ddd 100644 --- a/client/db/src/offchain.rs +++ b/client/db/src/offchain.rs @@ -43,7 +43,7 @@ impl LocalStorage { /// Create new offchain storage for tests (backed by memorydb) #[cfg(any(test, feature = "test-helpers"))] pub fn new_test() -> Self { - let db = Arc::new(::kvdb_memorydb::create(crate::utils::NUM_COLUMNS)); + let db = Arc::new(kvdb_memorydb::create(crate::utils::NUM_COLUMNS)); Self::new(db as _) } diff --git a/client/db/src/utils.rs b/client/db/src/utils.rs index 0a6112abe7..6b636c0c77 100644 --- a/client/db/src/utils.rs +++ b/client/db/src/utils.rs @@ -213,8 +213,24 @@ pub fn open_database( #[cfg(feature = "kvdb-rocksdb")] DatabaseSettingsSrc::Path { path, cache_size } => { let mut db_config = DatabaseConfig::with_columns(Some(NUM_COLUMNS)); - db_config.memory_budget = *cache_size; - let path = path.to_str().ok_or_else(|| client::error::Error::Backend("Invalid database path".into()))?; + + if let Some(cache_size) = cache_size { + let state_col_budget = (*cache_size as f64 * 0.7) as usize; + let other_col_budget = cache_size - state_col_budget; + + let mut memory_budget = std::collections::HashMap::new(); + for i in 0..NUM_COLUMNS { + if Some(i) == crate::columns::STATE { + memory_budget.insert(Some(i), state_col_budget); + } else { + memory_budget.insert(Some(i), other_col_budget); + } + } + + db_config.memory_budget = memory_budget; + } + let path = path.to_str() + .ok_or_else(|| client::error::Error::Backend("Invalid database path".into()))?; Arc::new(Database::open(&db_config, &path).map_err(db_err)?) }, #[cfg(not(feature = "kvdb-rocksdb"))] -- GitLab From 605852eaa414ddae0bb12bb4974b9cba24ccf7db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Sun, 24 Nov 2019 11:28:29 +0100 Subject: [PATCH 003/172] Log runtime `panic` and `oom` with level error (#4193) --- primitives/sr-io/src/lib.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/primitives/sr-io/src/lib.rs b/primitives/sr-io/src/lib.rs index 2b40670c45..4ceabb4511 100644 --- a/primitives/sr-io/src/lib.rs +++ b/primitives/sr-io/src/lib.rs @@ -743,7 +743,7 @@ mod allocator_impl { pub fn panic(info: &core::panic::PanicInfo) -> ! { unsafe { let message = rstd::alloc::format!("{}", info); - misc::print_utf8(message.as_bytes()); + logging::log(LogLevel::Error, "runtime", message.as_bytes()); core::intrinsics::abort() } } @@ -751,10 +751,8 @@ pub fn panic(info: &core::panic::PanicInfo) -> ! { #[cfg(all(not(feature = "disable_oom"), not(feature = "std")))] #[alloc_error_handler] pub extern fn oom(_: core::alloc::Layout) -> ! { - static OOM_MSG: &str = "Runtime memory exhausted. Aborting"; - unsafe { - misc::print_utf8(OOM_MSG.as_bytes()); + logging::log(LogLevel::Error, "runtime", b"Runtime memory exhausted. Aborting"); core::intrinsics::abort(); } } -- GitLab From 1078691b1a1808fca754304c3bf8c7553624eb62 Mon Sep 17 00:00:00 2001 From: Xiliang Chen Date: Mon, 25 Nov 2019 19:42:51 +1300 Subject: [PATCH 004/172] PaysFee for DispatchInfo (#4165) * Add PaysFee trait * bump version * Apply suggestions from code review Co-Authored-By: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * line width * Apply suggestions from code review Co-Authored-By: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * fix test * fix test * fix test --- bin/node/executor/src/lib.rs | 10 +++--- frame/contracts/src/tests.rs | 2 +- frame/example/src/lib.rs | 8 ++++- frame/support/src/dispatch.rs | 18 +++++++---- frame/support/src/weights.rs | 37 ++++++++++++++-------- frame/system/src/lib.rs | 10 +++--- frame/transaction-payment/src/lib.rs | 46 +++++++++++++++------------- 7 files changed, 79 insertions(+), 52 deletions(-) diff --git a/bin/node/executor/src/lib.rs b/bin/node/executor/src/lib.rs index e6360304d8..b1e5e24ffd 100644 --- a/bin/node/executor/src/lib.rs +++ b/bin/node/executor/src/lib.rs @@ -467,7 +467,7 @@ mod tests { EventRecord { phase: Phase::ApplyExtrinsic(0), event: Event::system(system::Event::ExtrinsicSuccess( - DispatchInfo { weight: 10000, class: DispatchClass::Operational } + DispatchInfo { weight: 10000, class: DispatchClass::Operational, pays_fee: true } )), topics: vec![], }, @@ -489,7 +489,7 @@ mod tests { EventRecord { phase: Phase::ApplyExtrinsic(1), event: Event::system(system::Event::ExtrinsicSuccess( - DispatchInfo { weight: 1000000, class: DispatchClass::Normal } + DispatchInfo { weight: 1000000, class: DispatchClass::Normal, pays_fee: true } )), topics: vec![], }, @@ -520,7 +520,7 @@ mod tests { EventRecord { phase: Phase::ApplyExtrinsic(0), event: Event::system(system::Event::ExtrinsicSuccess( - DispatchInfo { weight: 10000, class: DispatchClass::Operational } + DispatchInfo { weight: 10000, class: DispatchClass::Operational, pays_fee: true } )), topics: vec![], }, @@ -544,7 +544,7 @@ mod tests { EventRecord { phase: Phase::ApplyExtrinsic(1), event: Event::system(system::Event::ExtrinsicSuccess( - DispatchInfo { weight: 1000000, class: DispatchClass::Normal } + DispatchInfo { weight: 1000000, class: DispatchClass::Normal, pays_fee: true } )), topics: vec![], }, @@ -568,7 +568,7 @@ mod tests { EventRecord { phase: Phase::ApplyExtrinsic(2), event: Event::system(system::Event::ExtrinsicSuccess( - DispatchInfo { weight: 1000000, class: DispatchClass::Normal } + DispatchInfo { weight: 1000000, class: DispatchClass::Normal, pays_fee: true } )), topics: vec![], }, diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 5532a0cc9a..d06565ed8e 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -2329,7 +2329,7 @@ fn cannot_self_destruct_in_constructor() { #[test] fn check_block_gas_limit_works() { ExtBuilder::default().block_gas_limit(50).build().execute_with(|| { - let info = DispatchInfo { weight: 100, class: DispatchClass::Normal }; + let info = DispatchInfo { weight: 100, class: DispatchClass::Normal, pays_fee: true }; let check = CheckBlockGasLimit::(Default::default()); let call: Call = crate::Call::put_code(1000, vec![]).into(); diff --git a/frame/example/src/lib.rs b/frame/example/src/lib.rs index 8956de7249..cf22d38f69 100644 --- a/frame/example/src/lib.rs +++ b/frame/example/src/lib.rs @@ -256,7 +256,7 @@ use rstd::marker::PhantomData; use support::{ dispatch::Result, decl_module, decl_storage, decl_event, - weights::{SimpleDispatchInfo, DispatchInfo, DispatchClass, ClassifyDispatch, WeighData, Weight}, + weights::{SimpleDispatchInfo, DispatchInfo, DispatchClass, ClassifyDispatch, WeighData, Weight, PaysFee}, }; use system::{ensure_signed, ensure_root}; use codec::{Encode, Decode}; @@ -301,6 +301,12 @@ impl ClassifyDispatch<(&BalanceOf,)> for WeightForSetDumm } } +impl PaysFee for WeightForSetDummy { + fn pays_fee(&self) -> bool { + true + } +} + /// A type alias for the balance type from this module's point of view. type BalanceOf = ::Balance; diff --git a/frame/support/src/dispatch.rs b/frame/support/src/dispatch.rs index 025ee67dd1..cde1300831 100644 --- a/frame/support/src/dispatch.rs +++ b/frame/support/src/dispatch.rs @@ -25,7 +25,7 @@ pub use frame_metadata::{ }; pub use crate::weights::{ SimpleDispatchInfo, GetDispatchInfo, DispatchInfo, WeighData, ClassifyDispatch, - TransactionPriority, Weight, WeighBlock, + TransactionPriority, Weight, WeighBlock, PaysFee, }; pub use sr_primitives::{ traits::{Dispatchable, DispatchResult, ModuleDispatchError}, @@ -1321,7 +1321,10 @@ macro_rules! decl_module { &$weight, ($( $param_name, )*) ); - return $crate::dispatch::DispatchInfo { weight, class }; + let pays_fee = ::pays_fee( + &$weight + ); + return $crate::dispatch::DispatchInfo { weight, class, pays_fee }; } if let $call_type::__PhantomItem(_, _) = self { unreachable!("__PhantomItem should never be used.") } )* @@ -1337,7 +1340,10 @@ macro_rules! decl_module { &$crate::dispatch::SimpleDispatchInfo::default(), () ); - $crate::dispatch::DispatchInfo { weight, class } + let pays_fee = ::pays_fee( + &$crate::dispatch::SimpleDispatchInfo::default() + ); + $crate::dispatch::DispatchInfo { weight, class, pays_fee } } } @@ -2066,17 +2072,17 @@ mod tests { // operational. assert_eq!( Call::::operational().get_dispatch_info(), - DispatchInfo { weight: 5, class: DispatchClass::Operational }, + DispatchInfo { weight: 5, class: DispatchClass::Operational, pays_fee: true }, ); // default weight. assert_eq!( Call::::aux_0().get_dispatch_info(), - DispatchInfo { weight: 10_000, class: DispatchClass::Normal }, + DispatchInfo { weight: 10_000, class: DispatchClass::Normal, pays_fee: true }, ); // custom basic assert_eq!( Call::::aux_3().get_dispatch_info(), - DispatchInfo { weight: 3, class: DispatchClass::Normal }, + DispatchInfo { weight: 3, class: DispatchClass::Normal, pays_fee: true }, ); } diff --git a/frame/support/src/weights.rs b/frame/support/src/weights.rs index 3a5863ee37..8af418fc74 100644 --- a/frame/support/src/weights.rs +++ b/frame/support/src/weights.rs @@ -76,6 +76,14 @@ pub trait WeighBlock { fn on_finalize(_: BlockNumber) -> Weight { Zero::zero() } } +/// Indicates if dispatch function should pay fees or not. +/// If set to false, the block resource limits are applied, yet no fee is deducted. +pub trait PaysFee { + fn pays_fee(&self) -> bool { + true + } +} + /// Maybe I can do something to remove the duplicate code here. #[impl_for_tuples(30)] impl WeighBlock for SingleModule { @@ -135,17 +143,8 @@ pub struct DispatchInfo { pub weight: Weight, /// Class of this transaction. pub class: DispatchClass, -} - -impl DispatchInfo { - /// Determine if this dispatch should pay the base length-related fee or not. - pub fn pay_length_fee(&self) -> bool { - match self.class { - DispatchClass::Normal => true, - // For now we assume all operational transactions don't pay the length fee. - DispatchClass::Operational => false, - } - } + /// Does this transaction pay fees. + pub pays_fee: bool, } /// A `Dispatchable` function (aka transaction) that can carry some static information along with @@ -209,6 +208,20 @@ impl ClassifyDispatch for SimpleDispatchInfo { } } +impl PaysFee for SimpleDispatchInfo { + fn pays_fee(&self) -> bool { + match self { + SimpleDispatchInfo::FixedNormal(_) => true, + SimpleDispatchInfo::MaxNormal => true, + SimpleDispatchInfo::FreeNormal => true, + + SimpleDispatchInfo::FixedOperational(_) => true, + SimpleDispatchInfo::MaxOperational => true, + SimpleDispatchInfo::FreeOperational => false, + } + } +} + impl Default for SimpleDispatchInfo { fn default() -> Self { // Default weight of all transactions. @@ -253,8 +266,8 @@ impl GetDispatchInfo for sr_primitives::testing::Te // for testing: weight == size. DispatchInfo { weight: self.encode().len() as _, + pays_fee: true, ..Default::default() } } } - diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index 699ff67d2c..611ec2ff16 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -1413,7 +1413,7 @@ mod tests { fn signed_ext_check_weight_works_operational_tx() { new_test_ext().execute_with(|| { let normal = DispatchInfo { weight: 100, ..Default::default() }; - let op = DispatchInfo { weight: 100, class: DispatchClass::Operational }; + let op = DispatchInfo { weight: 100, class: DispatchClass::Operational, pays_fee: true }; let len = 0_usize; let normal_limit = normal_weight_limit(); @@ -1435,8 +1435,8 @@ mod tests { #[test] fn signed_ext_check_weight_priority_works() { new_test_ext().execute_with(|| { - let normal = DispatchInfo { weight: 100, class: DispatchClass::Normal }; - let op = DispatchInfo { weight: 100, class: DispatchClass::Operational }; + let normal = DispatchInfo { weight: 100, class: DispatchClass::Normal, pays_fee: true }; + let op = DispatchInfo { weight: 100, class: DispatchClass::Operational, pays_fee: true }; let len = 0_usize; let priority = CheckWeight::(PhantomData) @@ -1469,7 +1469,7 @@ mod tests { reset_check_weight(normal, normal_limit + 1, true); // Operational ones don't have this limit. - let op = DispatchInfo { weight: 0, class: DispatchClass::Operational }; + let op = DispatchInfo { weight: 0, class: DispatchClass::Operational, pays_fee: true }; reset_check_weight(op, normal_limit, false); reset_check_weight(op, normal_limit + 100, false); reset_check_weight(op, 1024, false); @@ -1496,7 +1496,7 @@ mod tests { #[test] fn signed_ext_check_era_should_change_longevity() { new_test_ext().execute_with(|| { - let normal = DispatchInfo { weight: 100, class: DispatchClass::Normal }; + let normal = DispatchInfo { weight: 100, class: DispatchClass::Normal, pays_fee: true }; let len = 0_usize; let ext = ( CheckWeight::(PhantomData), diff --git a/frame/transaction-payment/src/lib.rs b/frame/transaction-payment/src/lib.rs index c3fa13c0ba..c7310ac587 100644 --- a/frame/transaction-payment/src/lib.rs +++ b/frame/transaction-payment/src/lib.rs @@ -120,7 +120,7 @@ impl Module { let dispatch_info = ::get_dispatch_info(&unchecked_extrinsic); let partial_fee = >::compute_fee(len, dispatch_info, 0u32.into()); - let DispatchInfo { weight, class } = dispatch_info; + let DispatchInfo { weight, class, .. } = dispatch_info; RuntimeDispatchInfo { weight, class, partial_fee } } @@ -154,28 +154,28 @@ impl ChargeTransactionPayment { where BalanceOf: Sync + Send, { - let len_fee = if info.pay_length_fee() { + if info.pays_fee { let len = >::from(len); let base = T::TransactionBaseFee::get(); let per_byte = T::TransactionByteFee::get(); - base.saturating_add(per_byte.saturating_mul(len)) - } else { - Zero::zero() - }; + let len_fee = base.saturating_add(per_byte.saturating_mul(len)); - let weight_fee = { - // cap the weight to the maximum defined in runtime, otherwise it will be the `Bounded` - // maximum of its data type, which is not desired. - let capped_weight = info.weight.min(::MaximumBlockWeight::get()); - T::WeightToFee::convert(capped_weight) - }; + let weight_fee = { + // cap the weight to the maximum defined in runtime, otherwise it will be the `Bounded` + // maximum of its data type, which is not desired. + let capped_weight = info.weight.min(::MaximumBlockWeight::get()); + T::WeightToFee::convert(capped_weight) + }; - // everything except for tip - let basic_fee = len_fee.saturating_add(weight_fee); - let fee_update = NextFeeMultiplier::get(); - let adjusted_fee = fee_update.saturated_multiply_accumulate(basic_fee); + // everything except for tip + let basic_fee = len_fee.saturating_add(weight_fee); + let fee_update = NextFeeMultiplier::get(); + let adjusted_fee = fee_update.saturated_multiply_accumulate(basic_fee); - adjusted_fee.saturating_add(tip) + adjusted_fee.saturating_add(tip) + } else { + tip + } } } @@ -400,7 +400,7 @@ mod tests { /// create a transaction info struct from weight. Handy to avoid building the whole struct. pub fn info_from_weight(w: Weight) -> DispatchInfo { - DispatchInfo { weight: w, ..Default::default() } + DispatchInfo { weight: w, pays_fee: true, ..Default::default() } } #[test] @@ -461,12 +461,14 @@ mod tests { // 1 ain't have a penny. assert_eq!(Balances::free_balance(&1), 0); + let len = 100; + // like a FreeOperational let operational_transaction = DispatchInfo { weight: 0, - class: DispatchClass::Operational + class: DispatchClass::Operational, + pays_fee: false, }; - let len = 100; assert!( ChargeTransactionPayment::::from(0) .validate(&1, CALL, operational_transaction , len) @@ -476,7 +478,8 @@ mod tests { // like a FreeNormal let free_transaction = DispatchInfo { weight: 0, - class: DispatchClass::Normal + class: DispatchClass::Normal, + pays_fee: true, }; assert!( ChargeTransactionPayment::::from(0) @@ -541,4 +544,3 @@ mod tests { } } - -- GitLab From 6a063c24fc7a21216aa4d37ce96c6a846bb23ed8 Mon Sep 17 00:00:00 2001 From: Ashley Date: Mon, 25 Nov 2019 11:43:26 +0100 Subject: [PATCH 005/172] Rewrite `elected_edges.sort_unstable_by` in phragmen (#4195) * Rewrite phragmen elected_edges.sort_unstable_by * map -> and_then --- primitives/phragmen/src/mock.rs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/primitives/phragmen/src/mock.rs b/primitives/phragmen/src/mock.rs index a0ab23db34..fdd218f4f4 100644 --- a/primitives/phragmen/src/mock.rs +++ b/primitives/phragmen/src/mock.rs @@ -274,17 +274,10 @@ pub(crate) fn do_equalize_float( e.1 = 0.0; }); - // todo: rewrite. elected_edges.sort_unstable_by(|x, y| - if let Some(x) = support_map.get(&x.0) { - if let Some(y) = support_map.get(&y.0) { - x.total.partial_cmp(&y.total).unwrap_or(rstd::cmp::Ordering::Equal) - } else { - rstd::cmp::Ordering::Equal - } - } else { - rstd::cmp::Ordering::Equal - } + support_map.get(&x.0) + .and_then(|x| support_map.get(&y.0).and_then(|y| x.total.partial_cmp(&y.total))) + .unwrap_or(rstd::cmp::Ordering::Equal) ); let mut cumulative_stake = 0.0; -- GitLab From 2ac4dd8a7e116c40a80bf443d942da7163cad8ca Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Mon, 25 Nov 2019 11:51:09 +0100 Subject: [PATCH 006/172] Remove `frame/` prefix from `im_online` DB_KEY. (#4191) * Remove `frame/` prefix from `im_online` DB_KEY. Caught in the renaming process. It is not obvious to me why `frame/` or `palette/` or `srml/` was included in the DB key. * Update lib.rs --- frame/im-online/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/im-online/src/lib.rs b/frame/im-online/src/lib.rs index 467596233b..01ebde206e 100644 --- a/frame/im-online/src/lib.rs +++ b/frame/im-online/src/lib.rs @@ -131,7 +131,7 @@ pub mod ed25519 { /// The local storage database key under which the worker progress status /// is tracked. -const DB_KEY: &[u8] = b"frame/im-online-worker-status"; +const DB_KEY: &[u8] = b"parity/im-online-worker-status"; /// It's important to persist the worker state, since e.g. the /// server could be restarted while starting the gossip process, but before -- GitLab From 6681ee19858789f5eb64b23cfd36664d9b863ea0 Mon Sep 17 00:00:00 2001 From: Arkadiy Paronyan Date: Mon, 25 Nov 2019 13:38:37 +0100 Subject: [PATCH 007/172] Fixed shared cache race on import (#4194) * Fixed is_best race on import * Take import lock outside of backend * Actually take the lock --- client/api/src/backend.rs | 4 +-- client/api/src/blockchain.rs | 6 ++-- client/db/src/lib.rs | 8 ++--- client/db/src/storage_cache.rs | 57 +++++++++++++++++----------------- client/src/call_executor.rs | 15 +++++++-- client/src/client.rs | 2 +- client/src/in_mem.rs | 6 ++-- client/src/light/backend.rs | 6 ++-- 8 files changed, 56 insertions(+), 48 deletions(-) diff --git a/client/api/src/backend.rs b/client/api/src/backend.rs index a00c5a3ac8..e44325f088 100644 --- a/client/api/src/backend.rs +++ b/client/api/src/backend.rs @@ -33,7 +33,7 @@ use crate::{ }; use consensus::BlockOrigin; use hash_db::Hasher; -use parking_lot::Mutex; +use parking_lot::RwLock; /// In memory array of storage values. pub type StorageCollection = Vec<(Vec, Option>)>; @@ -310,7 +310,7 @@ pub trait Backend: AuxStore + Send + Sync where /// the using components should acquire and hold the lock whenever they do /// something that the import of a block would interfere with, e.g. importing /// a new block or calculating the best head. - fn get_import_lock(&self) -> &Mutex<()>; + fn get_import_lock(&self) -> &RwLock<()>; } /// Changes trie storage that supports pruning. diff --git a/client/api/src/blockchain.rs b/client/api/src/blockchain.rs index 73b7c138d0..b28a1060b9 100644 --- a/client/api/src/blockchain.rs +++ b/client/api/src/blockchain.rs @@ -22,7 +22,7 @@ use sr_primitives::traits::{Block as BlockT, Header as HeaderT, NumberFor}; use sr_primitives::generic::BlockId; use sr_primitives::Justification; use log::warn; -use parking_lot::Mutex; +use parking_lot::RwLock; use header_metadata::HeaderMetadata; @@ -109,7 +109,7 @@ pub trait Backend: HeaderBackend + HeaderMetadata>, - import_lock: &Mutex<()>, + import_lock: &RwLock<()>, ) -> Result> { let target_header = { match self.header(BlockId::Hash(target_hash))? { @@ -130,7 +130,7 @@ pub trait Backend: HeaderBackend + HeaderMetadata { blockchain: BlockchainDb, canonicalization_delay: u64, shared_cache: SharedCache, - import_lock: Mutex<()>, + import_lock: RwLock<()>, is_archive: bool, } @@ -1251,7 +1251,7 @@ impl> Backend { operation.child_storage_updates, Some(hash), Some(number), - || is_best, + is_best, ); } @@ -1531,13 +1531,13 @@ impl client_api::backend::Backend for Backend fn destroy_state(&self, state: Self::State) -> ClientResult<()> { if let Some(hash) = state.cache.parent_hash.clone() { - let is_best = || self.blockchain.meta.read().best_hash == hash; + let is_best = self.blockchain.meta.read().best_hash == hash; state.release().sync_cache(&[], &[], vec![], vec![], None, None, is_best); } Ok(()) } - fn get_import_lock(&self) -> &Mutex<()> { + fn get_import_lock(&self) -> &RwLock<()> { &self.import_lock } } diff --git a/client/db/src/storage_cache.rs b/client/db/src/storage_cache.rs index 9888dfbe64..3febc6b4d4 100644 --- a/client/db/src/storage_cache.rs +++ b/client/db/src/storage_cache.rs @@ -309,7 +309,7 @@ impl CacheChanges { /// that are invalidated by chain reorganization. `sync_cache` /// should be called after the block has been committed and the /// blockchain route has been calculated. - pub fn sync_cache bool> ( + pub fn sync_cache( &mut self, enacted: &[B::Hash], retracted: &[B::Hash], @@ -317,10 +317,9 @@ impl CacheChanges { child_changes: ChildStorageCollection, commit_hash: Option, commit_number: Option<::Number>, - is_best: F, + is_best: bool, ) { let mut cache = self.shared_cache.lock(); - let is_best = is_best(); trace!("Syncing cache, id = (#{:?}, {:?}), parent={:?}, best={}", commit_number, commit_hash, self.parent_hash, is_best); let cache = &mut *cache; // Filter out commiting block if any. @@ -621,22 +620,22 @@ mod tests { // blocks [ 3a(c) 2a(c) 2b 1b 1a(c) 0 ] // state [ 5 5 4 3 2 2 ] let mut s = CachingState::new(InMemory::::default(), shared.clone(), Some(root_parent)); - s.cache.sync_cache(&[], &[], vec![(key.clone(), Some(vec![2]))], vec![], Some(h0), Some(0), || true); + s.cache.sync_cache(&[], &[], vec![(key.clone(), Some(vec![2]))], vec![], Some(h0), Some(0), true); let mut s = CachingState::new(InMemory::::default(), shared.clone(), Some(h0)); - s.cache.sync_cache(&[], &[], vec![], vec![], Some(h1a), Some(1), || true); + s.cache.sync_cache(&[], &[], vec![], vec![], Some(h1a), Some(1), true); let mut s = CachingState::new(InMemory::::default(), shared.clone(), Some(h0)); - s.cache.sync_cache(&[], &[], vec![(key.clone(), Some(vec![3]))], vec![], Some(h1b), Some(1), || false); + s.cache.sync_cache(&[], &[], vec![(key.clone(), Some(vec![3]))], vec![], Some(h1b), Some(1), false); let mut s = CachingState::new(InMemory::::default(), shared.clone(), Some(h1b.clone())); - s.cache.sync_cache(&[], &[], vec![(key.clone(), Some(vec![4]))], vec![], Some(h2b), Some(2), || false); + s.cache.sync_cache(&[], &[], vec![(key.clone(), Some(vec![4]))], vec![], Some(h2b), Some(2), false); let mut s = CachingState::new(InMemory::::default(), shared.clone(), Some(h1a.clone())); - s.cache.sync_cache(&[], &[], vec![(key.clone(), Some(vec![5]))], vec![], Some(h2a), Some(2), || true); + s.cache.sync_cache(&[], &[], vec![(key.clone(), Some(vec![5]))], vec![], Some(h2a), Some(2), true); let mut s = CachingState::new(InMemory::::default(), shared.clone(), Some(h2a)); - s.cache.sync_cache(&[], &[], vec![], vec![], Some(h3a), Some(3), || true); + s.cache.sync_cache(&[], &[], vec![], vec![], Some(h3a), Some(3), true); let s = CachingState::new(InMemory::::default(), shared.clone(), Some(h3a)); assert_eq!(s.storage(&key).unwrap().unwrap(), vec![5]); @@ -660,7 +659,7 @@ mod tests { vec![], Some(h3b), Some(3), - || true, + true, ); let s = CachingState::new(InMemory::::default(), shared.clone(), Some(h3a)); assert!(s.storage(&key).unwrap().is_none()); @@ -680,16 +679,16 @@ mod tests { let shared = new_shared_cache::(256*1024, (0,1)); let mut s = CachingState::new(InMemory::::default(), shared.clone(), Some(root_parent)); - s.cache.sync_cache(&[], &[], vec![(key.clone(), Some(vec![2]))], vec![], Some(h1), Some(1), || true); + s.cache.sync_cache(&[], &[], vec![(key.clone(), Some(vec![2]))], vec![], Some(h1), Some(1), true); let mut s = CachingState::new(InMemory::::default(), shared.clone(), Some(h1)); - s.cache.sync_cache(&[], &[], vec![], vec![], Some(h2a), Some(2), || true); + s.cache.sync_cache(&[], &[], vec![], vec![], Some(h2a), Some(2), true); let mut s = CachingState::new(InMemory::::default(), shared.clone(), Some(h1)); - s.cache.sync_cache(&[], &[], vec![(key.clone(), Some(vec![3]))], vec![], Some(h2b), Some(2), || false); + s.cache.sync_cache(&[], &[], vec![(key.clone(), Some(vec![3]))], vec![], Some(h2b), Some(2), false); let mut s = CachingState::new(InMemory::::default(), shared.clone(), Some(h2b)); - s.cache.sync_cache(&[], &[], vec![(key.clone(), Some(vec![3]))], vec![], Some(h3b), Some(2), || false); + s.cache.sync_cache(&[], &[], vec![(key.clone(), Some(vec![3]))], vec![], Some(h3b), Some(2), false); let s = CachingState::new(InMemory::::default(), shared.clone(), Some(h2a)); assert_eq!(s.storage(&key).unwrap().unwrap(), vec![2]); @@ -708,19 +707,19 @@ mod tests { let shared = new_shared_cache::(256*1024, (0,1)); let mut s = CachingState::new(InMemory::::default(), shared.clone(), Some(root_parent)); - s.cache.sync_cache(&[], &[], vec![], vec![], Some(h1), Some(1), || true); + s.cache.sync_cache(&[], &[], vec![], vec![], Some(h1), Some(1), true); let mut s = CachingState::new(InMemory::::default(), shared.clone(), Some(h1)); - s.cache.sync_cache(&[], &[], vec![], vec![], Some(h2a), Some(2), || true); + s.cache.sync_cache(&[], &[], vec![], vec![], Some(h2a), Some(2), true); let mut s = CachingState::new(InMemory::::default(), shared.clone(), Some(h2a)); - s.cache.sync_cache(&[], &[], vec![(key.clone(), Some(vec![2]))], vec![], Some(h3a), Some(3), || true); + s.cache.sync_cache(&[], &[], vec![(key.clone(), Some(vec![2]))], vec![], Some(h3a), Some(3), true); let mut s = CachingState::new(InMemory::::default(), shared.clone(), Some(h1)); - s.cache.sync_cache(&[], &[], vec![], vec![], Some(h2b), Some(2), || false); + s.cache.sync_cache(&[], &[], vec![], vec![], Some(h2b), Some(2), false); let mut s = CachingState::new(InMemory::::default(), shared.clone(), Some(h2b)); - s.cache.sync_cache(&[], &[], vec![(key.clone(), Some(vec![3]))], vec![], Some(h3b), Some(3), || false); + s.cache.sync_cache(&[], &[], vec![(key.clone(), Some(vec![3]))], vec![], Some(h3b), Some(3), false); let s = CachingState::new(InMemory::::default(), shared.clone(), Some(h3a)); assert_eq!(s.storage(&key).unwrap().unwrap(), vec![2]); @@ -743,7 +742,7 @@ mod tests { vec![], Some(h0), Some(0), - || true, + true, ); // 32 key, 3 byte size assert_eq!(shared.lock().used_storage_cache_size(), 35 /* bytes */); @@ -756,7 +755,7 @@ mod tests { vec![(s_key.clone(), vec![(key.clone(), Some(vec![1, 2]))])], Some(h0), Some(0), - || true, + true, ); // 35 + (2 * 32) key, 2 byte size assert_eq!(shared.lock().used_storage_cache_size(), 101 /* bytes */); @@ -778,7 +777,7 @@ mod tests { vec![], Some(h0), Some(0), - || true, + true, ); // 32 key, 4 byte size assert_eq!(shared.lock().used_storage_cache_size(), 36 /* bytes */); @@ -791,7 +790,7 @@ mod tests { vec![], Some(h0), Some(0), - || true, + true, ); // 32 key, 2 byte size assert_eq!(shared.lock().used_storage_cache_size(), 34 /* bytes */); @@ -809,10 +808,10 @@ mod tests { let shared = new_shared_cache::(256*1024, (0, 1)); let mut s = CachingState::new(InMemory::::default(), shared.clone(), Some(root_parent)); - s.cache.sync_cache(&[], &[], vec![(key.clone(), Some(vec![2]))], vec![], Some(h0), Some(0), || true); + s.cache.sync_cache(&[], &[], vec![(key.clone(), Some(vec![2]))], vec![], Some(h0), Some(0), true); let mut s = CachingState::new(InMemory::::default(), shared.clone(), Some(h0)); - s.cache.sync_cache(&[], &[], vec![(key.clone(), Some(vec![3]))], vec![], Some(h1), Some(1), || true); + s.cache.sync_cache(&[], &[], vec![(key.clone(), Some(vec![3]))], vec![], Some(h1), Some(1), true); let mut s = CachingState::new(InMemory::::default(), shared.clone(), Some(h1)); assert_eq!(s.storage(&key).unwrap(), Some(vec![3])); @@ -831,7 +830,7 @@ mod tests { s.cache.local_cache.write().storage.insert(key.clone(), Some(vec![42])); // New value is propagated. - s.cache.sync_cache(&[], &[], vec![], vec![], None, None, || true); + s.cache.sync_cache(&[], &[], vec![], vec![], None, None, true); let s = CachingState::new(InMemory::::default(), shared.clone(), Some(h1)); assert_eq!(s.storage(&key).unwrap(), None); @@ -1051,7 +1050,7 @@ mod qc { vec![], Some(hash), Some(total_h as u64), - || false, + false, ); state @@ -1090,7 +1089,7 @@ mod qc { vec![], Some(hash), Some(self.canon.len() as u64 + 1), - || true, + true, ); self.canon.push(next); @@ -1138,7 +1137,7 @@ mod qc { vec![], Some(hash), Some(height), - || true, + true, ); state diff --git a/client/src/call_executor.rs b/client/src/call_executor.rs index e03293f2a7..a41e037636 100644 --- a/client/src/call_executor.rs +++ b/client/src/call_executor.rs @@ -96,7 +96,10 @@ where None, ) .map(|(result, _, _)| result)?; - self.backend.destroy_state(state)?; + { + let _lock = self.backend.get_import_lock().read(); + self.backend.destroy_state(state)?; + } Ok(return_data.into_encoded()) } @@ -179,7 +182,10 @@ where ) .map(|(result, _, _)| result) }?; - self.backend.destroy_state(state)?; + { + let _lock = self.backend.get_import_lock().read(); + self.backend.destroy_state(state)?; + } Ok(result) } @@ -194,7 +200,10 @@ where None, ); let version = self.executor.runtime_version(&mut ext); - self.backend.destroy_state(state)?; + { + let _lock = self.backend.get_import_lock().read(); + self.backend.destroy_state(state)?; + } version.ok_or(error::Error::VersionInvalid.into()) } diff --git a/client/src/client.rs b/client/src/client.rs index 578845a209..b7b704ce78 100644 --- a/client/src/client.rs +++ b/client/src/client.rs @@ -710,7 +710,7 @@ impl Client where Err: From, { let inner = || { - let _import_lock = self.backend.get_import_lock().lock(); + let _import_lock = self.backend.get_import_lock().write(); let mut op = ClientImportOperation { op: self.backend.begin_operation()?, diff --git a/client/src/in_mem.rs b/client/src/in_mem.rs index efab895794..d56c3f2b07 100644 --- a/client/src/in_mem.rs +++ b/client/src/in_mem.rs @@ -18,7 +18,7 @@ use std::collections::{HashMap, HashSet}; use std::sync::Arc; -use parking_lot::{RwLock, Mutex}; +use parking_lot::RwLock; use primitives::{ChangesTrieConfiguration, storage::well_known_keys}; use primitives::offchain::storage::{ InMemOffchainStorage as OffchainStorage @@ -562,7 +562,7 @@ where states: RwLock>>, changes_trie_storage: ChangesTrieStorage, blockchain: Blockchain, - import_lock: Mutex<()>, + import_lock: RwLock<()>, } impl Backend @@ -712,7 +712,7 @@ where Ok(Zero::zero()) } - fn get_import_lock(&self) -> &Mutex<()> { + fn get_import_lock(&self) -> &RwLock<()> { &self.import_lock } } diff --git a/client/src/light/backend.rs b/client/src/light/backend.rs index 5db0c55d5e..8b0d965149 100644 --- a/client/src/light/backend.rs +++ b/client/src/light/backend.rs @@ -19,7 +19,7 @@ use std::collections::HashMap; use std::sync::Arc; -use parking_lot::{RwLock, Mutex}; +use parking_lot::RwLock; use state_machine::{Backend as StateBackend, TrieBackend, backend::InMemory as InMemoryState, ChangesTrieTransaction}; use primitives::offchain::storage::InMemOffchainStorage; @@ -49,7 +49,7 @@ const IN_MEMORY_EXPECT_PROOF: &str = "InMemory state backend has Void error type pub struct Backend { blockchain: Arc>, genesis_state: RwLock>>, - import_lock: Mutex<()>, + import_lock: RwLock<()>, } /// Light block (header and justification) import operation. @@ -216,7 +216,7 @@ impl ClientBackend for Backend where Err(ClientError::NotAvailableOnLightClient) } - fn get_import_lock(&self) -> &Mutex<()> { + fn get_import_lock(&self) -> &RwLock<()> { &self.import_lock } } -- GitLab From 298b632418e7272b298bed7d729fb1b8a3b1dd4d Mon Sep 17 00:00:00 2001 From: Alexey Date: Mon, 25 Nov 2019 19:48:18 +0300 Subject: [PATCH 008/172] Refactor `construct_runtime` to procedural (#3810) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * interim * interim * interim * first working section * cleanup * finished parsing * cleanup * added system module search * added clone and find_entry * generic find_module_entry * interim * working event * added generic event with no instance error * cleanup * added decl origin * cleanup * added all modules * added outer dispatch * added modules expansion * refactored transformations * updated error message * added resolve mechanics * added metadata * finished config * finished inherents * added validate_unsigned * added compares * cleanup * cleanup * cleanup * fix * updated modules for last one wins * cleanup * made nested modules * updated impl version * removed comment * cleanup * added ui tests * added optional comma * removed unnecessary to string cast * removed no compile * cleanup * fmt * returned nocompile * Update srml/support/procedural/src/construct_runtime/parse.rs Co-Authored-By: thiolliere * added where definition * updated ui tests * updated ui test cases * added test case * updated tests * interim * added parse for module part * removed totokens * fixes * fixed multiple iter * changed TokenStream * fmt * updated trybuild * added test for arguments * fmt * fixes + more tests * fixes * fmt * rolled back runtime * minor fixes * empty * fixes * fmt * Update paint/support/procedural/src/lib.rs Co-Authored-By: Bastian Köcher * Update paint/support/procedural/src/lib.rs Co-Authored-By: Bastian Köcher * Update paint/support/procedural/src/construct_runtime/parse.rs Co-Authored-By: Bastian Köcher * interim * refactored seen_keys * refactored hash_set * Update paint/support/procedural/src/construct_runtime/mod.rs Co-Authored-By: Bastian Köcher * refactored find * fix * fixed all_modules * added double declaration check * small fix * fmt * fix * fix default * format --- bin/node-template/runtime/src/lib.rs | 2 +- bin/node/runtime/src/lib.rs | 2 +- .../procedural/src/construct_runtime/mod.rs | 350 +++++++ .../procedural/src/construct_runtime/parse.rs | 401 ++++++++ frame/support/procedural/src/lib.rs | 61 ++ frame/support/procedural/tools/src/syn_ext.rs | 23 +- frame/support/src/lib.rs | 4 +- frame/support/src/runtime.rs | 948 ------------------ .../test/tests/construct_runtime_ui.rs | 10 + .../abundant_where_param.rs | 12 + .../abundant_where_param.stderr | 5 + .../double_module_parts.rs | 14 + .../double_module_parts.stderr | 5 + .../double_module_parts_default.rs | 14 + .../double_module_parts_default.stderr | 5 + .../generics_in_invalid_module.rs | 14 + .../generics_in_invalid_module.stderr | 5 + .../invalid_module_details.rs | 13 + .../invalid_module_details.stderr | 5 + .../invalid_module_details_keyword.rs | 13 + .../invalid_module_details_keyword.stderr | 5 + .../invalid_token_after_module.rs | 13 + .../invalid_token_after_module.stderr | 5 + .../invalid_token_after_name.rs | 13 + .../invalid_token_after_name.stderr | 5 + .../invalid_where_param.rs | 12 + .../invalid_where_param.stderr | 5 + ...g_event_generic_on_module_with_instance.rs | 14 + ...ent_generic_on_module_with_instance.stderr | 5 + .../missing_module_instance.rs | 13 + .../missing_module_instance.stderr | 5 + ..._origin_generic_on_module_with_instance.rs | 14 + ...gin_generic_on_module_with_instance.stderr | 5 + .../missing_system_module.rs | 12 + .../missing_system_module.stderr | 7 + .../missing_where_block.rs | 7 + .../missing_where_block.stderr | 5 + .../missing_where_param.rs | 10 + .../missing_where_param.stderr | 5 + .../no_comma_after_where.rs | 13 + .../no_comma_after_where.stderr | 5 + .../params_in_invalid_module.rs | 14 + .../params_in_invalid_module.stderr | 5 + 43 files changed, 1148 insertions(+), 955 deletions(-) create mode 100644 frame/support/procedural/src/construct_runtime/mod.rs create mode 100644 frame/support/procedural/src/construct_runtime/parse.rs delete mode 100644 frame/support/src/runtime.rs create mode 100644 frame/support/test/tests/construct_runtime_ui.rs create mode 100644 frame/support/test/tests/construct_runtime_ui/abundant_where_param.rs create mode 100644 frame/support/test/tests/construct_runtime_ui/abundant_where_param.stderr create mode 100644 frame/support/test/tests/construct_runtime_ui/double_module_parts.rs create mode 100644 frame/support/test/tests/construct_runtime_ui/double_module_parts.stderr create mode 100644 frame/support/test/tests/construct_runtime_ui/double_module_parts_default.rs create mode 100644 frame/support/test/tests/construct_runtime_ui/double_module_parts_default.stderr create mode 100644 frame/support/test/tests/construct_runtime_ui/generics_in_invalid_module.rs create mode 100644 frame/support/test/tests/construct_runtime_ui/generics_in_invalid_module.stderr create mode 100644 frame/support/test/tests/construct_runtime_ui/invalid_module_details.rs create mode 100644 frame/support/test/tests/construct_runtime_ui/invalid_module_details.stderr create mode 100644 frame/support/test/tests/construct_runtime_ui/invalid_module_details_keyword.rs create mode 100644 frame/support/test/tests/construct_runtime_ui/invalid_module_details_keyword.stderr create mode 100644 frame/support/test/tests/construct_runtime_ui/invalid_token_after_module.rs create mode 100644 frame/support/test/tests/construct_runtime_ui/invalid_token_after_module.stderr create mode 100644 frame/support/test/tests/construct_runtime_ui/invalid_token_after_name.rs create mode 100644 frame/support/test/tests/construct_runtime_ui/invalid_token_after_name.stderr create mode 100644 frame/support/test/tests/construct_runtime_ui/invalid_where_param.rs create mode 100644 frame/support/test/tests/construct_runtime_ui/invalid_where_param.stderr create mode 100644 frame/support/test/tests/construct_runtime_ui/missing_event_generic_on_module_with_instance.rs create mode 100644 frame/support/test/tests/construct_runtime_ui/missing_event_generic_on_module_with_instance.stderr create mode 100644 frame/support/test/tests/construct_runtime_ui/missing_module_instance.rs create mode 100644 frame/support/test/tests/construct_runtime_ui/missing_module_instance.stderr create mode 100644 frame/support/test/tests/construct_runtime_ui/missing_origin_generic_on_module_with_instance.rs create mode 100644 frame/support/test/tests/construct_runtime_ui/missing_origin_generic_on_module_with_instance.stderr create mode 100644 frame/support/test/tests/construct_runtime_ui/missing_system_module.rs create mode 100644 frame/support/test/tests/construct_runtime_ui/missing_system_module.stderr create mode 100644 frame/support/test/tests/construct_runtime_ui/missing_where_block.rs create mode 100644 frame/support/test/tests/construct_runtime_ui/missing_where_block.stderr create mode 100644 frame/support/test/tests/construct_runtime_ui/missing_where_param.rs create mode 100644 frame/support/test/tests/construct_runtime_ui/missing_where_param.stderr create mode 100644 frame/support/test/tests/construct_runtime_ui/no_comma_after_where.rs create mode 100644 frame/support/test/tests/construct_runtime_ui/no_comma_after_where.stderr create mode 100644 frame/support/test/tests/construct_runtime_ui/params_in_invalid_module.rs create mode 100644 frame/support/test/tests/construct_runtime_ui/params_in_invalid_module.stderr diff --git a/bin/node-template/runtime/src/lib.rs b/bin/node-template/runtime/src/lib.rs index 170874bfcb..525452256b 100644 --- a/bin/node-template/runtime/src/lib.rs +++ b/bin/node-template/runtime/src/lib.rs @@ -246,7 +246,7 @@ construct_runtime!( Timestamp: timestamp::{Module, Call, Storage, Inherent}, Aura: aura::{Module, Config, Inherent(Timestamp)}, Grandpa: grandpa::{Module, Call, Storage, Config, Event}, - Indices: indices::{default, Config}, + Indices: indices, Balances: balances::{default, Error}, TransactionPayment: transaction_payment::{Module, Storage}, Sudo: sudo, diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index c4752bae06..8e40573916 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -79,7 +79,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // implementation changes and behavior does not, then leave spec_version as // is and increment impl_version. spec_version: 195, - impl_version: 195, + impl_version: 196, apis: RUNTIME_API_VERSIONS, }; diff --git a/frame/support/procedural/src/construct_runtime/mod.rs b/frame/support/procedural/src/construct_runtime/mod.rs new file mode 100644 index 0000000000..a7401557e1 --- /dev/null +++ b/frame/support/procedural/src/construct_runtime/mod.rs @@ -0,0 +1,350 @@ +// Copyright 2019 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Substrate is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Substrate. If not, see . + +mod parse; + +use frame_support_procedural_tools::syn_ext as ext; +use frame_support_procedural_tools::{generate_crate_access, generate_hidden_includes}; +use parse::{ModuleDeclaration, RuntimeDefinition, WhereSection}; +use proc_macro::TokenStream; +use proc_macro2::{Span, TokenStream as TokenStream2}; +use quote::quote; +use syn::{Ident, Result}; + +pub fn construct_runtime(input: TokenStream) -> TokenStream { + let definition = syn::parse_macro_input!(input as RuntimeDefinition); + construct_runtime_parsed(definition) + .unwrap_or_else(|e| e.to_compile_error()) + .into() +} + +fn construct_runtime_parsed(definition: RuntimeDefinition) -> Result { + let RuntimeDefinition { + name, + where_section: WhereSection { + block, + node_block, + unchecked_extrinsic, + .. + }, + modules: + ext::Braces { + content: ext::Punctuated { inner: modules, .. }, + token: modules_token, + }, + .. + } = definition; + + // Assert we have system module declared + let system_module = match find_system_module(modules.iter()) { + Some(sm) => sm, + None => { + return Err(syn::Error::new( + modules_token.span, + "`System` module declaration is missing. \ + Please add this line: `System: system::{Module, Call, Storage, Config, Event},`", + )) + } + }; + let hidden_crate_name = "construct_runtime"; + let scrate = generate_crate_access(&hidden_crate_name, "frame-support"); + let scrate_decl = generate_hidden_includes(&hidden_crate_name, "frame-support"); + + let all_but_system_modules = modules.iter().filter(|module| module.name != "System"); + + let outer_event = decl_outer_event_or_origin( + &name, + all_but_system_modules.clone(), + &system_module, + &scrate, + DeclOuterKind::Event, + )?; + let outer_origin = decl_outer_event_or_origin( + &name, + all_but_system_modules.clone(), + &system_module, + &scrate, + DeclOuterKind::Origin, + )?; + let all_modules = decl_all_modules(&name, all_but_system_modules); + + let dispatch = decl_outer_dispatch(&name, modules.iter(), &scrate); + let metadata = decl_runtime_metadata(&name, modules.iter(), &scrate); + let outer_config = decl_outer_config(&name, modules.iter(), &scrate); + let inherent = decl_outer_inherent(&block, &unchecked_extrinsic, modules.iter(), &scrate); + let validate_unsigned = decl_validate_unsigned(&name, modules.iter(), &scrate); + + Ok(quote!( + #scrate_decl + + #[derive(Clone, Copy, PartialEq, Eq)] + #[cfg_attr(feature = "std", derive(Debug))] + pub struct #name; + impl #scrate::sr_primitives::traits::GetNodeBlockType for #name { + type NodeBlock = #node_block; + } + impl #scrate::sr_primitives::traits::GetRuntimeBlockType for #name { + type RuntimeBlock = #block; + } + + #outer_event + + #outer_origin + + #all_modules + + #dispatch + + #metadata + + #outer_config + + #inherent + + #validate_unsigned + ) + .into()) +} + +fn decl_validate_unsigned<'a>( + runtime: &'a Ident, + module_declarations: impl Iterator, + scrate: &'a TokenStream2, +) -> TokenStream2 { + let modules_tokens = module_declarations + .filter(|module_declaration| module_declaration.exists_part("ValidateUnsigned")) + .map(|module_declaration| &module_declaration.name); + quote!( + #scrate::impl_outer_validate_unsigned!( + impl ValidateUnsigned for #runtime { + #( #modules_tokens )* + } + ); + ) +} + +fn decl_outer_inherent<'a>( + block: &'a syn::TypePath, + unchecked_extrinsic: &'a syn::TypePath, + module_declarations: impl Iterator, + scrate: &'a TokenStream2, +) -> TokenStream2 { + let modules_tokens = module_declarations.filter_map(|module_declaration| { + let maybe_config_part = module_declaration.find_part("Inherent"); + maybe_config_part.map(|config_part| { + let arg = config_part + .args + .as_ref() + .and_then(|parens| parens.content.inner.iter().next()) + .unwrap_or(&module_declaration.name); + let name = &module_declaration.name; + quote!(#name : #arg,) + }) + }); + quote!( + #scrate::impl_outer_inherent!( + impl Inherents where Block = #block, UncheckedExtrinsic = #unchecked_extrinsic { + #(#modules_tokens)* + } + ); + ) +} + +fn decl_outer_config<'a>( + runtime: &'a Ident, + module_declarations: impl Iterator, + scrate: &'a TokenStream2, +) -> TokenStream2 { + let modules_tokens = module_declarations + .filter_map(|module_declaration| { + module_declaration.find_part("Config").map(|part| { + let transformed_generics: Vec<_> = part + .generics + .params + .iter() + .map(|param| quote!(<#param>)) + .collect(); + (module_declaration, transformed_generics) + }) + }) + .map(|(module_declaration, generics)| { + let module = &module_declaration.module; + let name = Ident::new( + &format!("{}Config", module_declaration.name), + module_declaration.name.span(), + ); + let instance = module_declaration.instance.as_ref().into_iter(); + quote!( + #name => + #module #(#instance)* #(#generics)*, + ) + }); + quote!( + #scrate::sr_primitives::impl_outer_config! { + pub struct GenesisConfig for #runtime { + #(#modules_tokens)* + } + } + ) +} + +fn decl_runtime_metadata<'a>( + runtime: &'a Ident, + module_declarations: impl Iterator, + scrate: &'a TokenStream2, +) -> TokenStream2 { + let modules_tokens = module_declarations + .filter_map(|module_declaration| { + module_declaration.find_part("Module").map(|_| { + let filtered_names: Vec<_> = module_declaration + .module_parts() + .into_iter() + .filter(|part| part.name != "Module") + .map(|part| part.name.clone()) + .collect(); + (module_declaration, filtered_names) + }) + }) + .map(|(module_declaration, filtered_names)| { + let module = &module_declaration.module; + let name = &module_declaration.name; + let instance = module_declaration + .instance + .as_ref() + .map(|name| quote!(<#name>)) + .into_iter(); + quote!(#module::Module #(#instance)* as #name with #(#filtered_names)* ,) + }); + quote!( + #scrate::impl_runtime_metadata!{ + for #runtime with modules + #(#modules_tokens)* + } + ) +} + +fn decl_outer_dispatch<'a>( + runtime: &'a Ident, + module_declarations: impl Iterator, + scrate: &'a TokenStream2, +) -> TokenStream2 { + let modules_tokens = module_declarations + .filter(|module_declaration| module_declaration.exists_part("Call")) + .map(|module_declaration| { + let module = &module_declaration.module; + let name = &module_declaration.name; + quote!(#module::#name) + }); + quote!( + #scrate::impl_outer_dispatch! { + pub enum Call for #runtime where origin: Origin { + #(#modules_tokens,)* + } + } + ) +} + +#[derive(Debug, PartialEq, Eq, Clone, Copy)] +enum DeclOuterKind { + Event, + Origin, +} + +fn decl_outer_event_or_origin<'a>( + runtime_name: &'a Ident, + module_declarations: impl Iterator, + system_name: &'a Ident, + scrate: &'a TokenStream2, + kind: DeclOuterKind, +) -> syn::Result { + let mut modules_tokens = TokenStream2::new(); + let kind_str = format!("{:?}", kind); + for module_declaration in module_declarations { + match module_declaration.find_part(&kind_str) { + Some(module_entry) => { + let module = &module_declaration.module; + let instance = module_declaration.instance.as_ref(); + let generics = &module_entry.generics; + if instance.is_some() && generics.params.len() == 0 { + let msg = format!( + "Instantiable module with no generic `{}` cannot \ + be constructed: module `{}` must have generic `{}`", + kind_str, module_declaration.name, kind_str + ); + return Err(syn::Error::new(module_declaration.name.span(), msg)); + } + let tokens = quote!(#module #instance #generics ,); + modules_tokens.extend(tokens); + } + None => {} + } + } + let macro_call = match kind { + DeclOuterKind::Event => quote!(#scrate::impl_outer_event!), + DeclOuterKind::Origin => quote!(#scrate::impl_outer_origin!), + }; + let enum_name = Ident::new(kind_str.as_str(), Span::call_site()); + Ok(quote!( + #macro_call { + pub enum #enum_name for #runtime_name where system = #system_name { + #modules_tokens + } + } + )) +} + +fn decl_all_modules<'a>( + runtime: &'a Ident, + module_declarations: impl Iterator, +) -> TokenStream2 { + let mut types = TokenStream2::new(); + let mut names = Vec::new(); + for module_declaration in module_declarations { + let type_name = &module_declaration.name; + let module = &module_declaration.module; + let mut generics = vec![quote!(#runtime)]; + generics.extend( + module_declaration + .instance + .iter() + .map(|name| quote!(#module::#name)), + ); + let type_decl = quote!( + pub type #type_name = #module::Module <#(#generics),*>; + ); + types.extend(type_decl); + names.push(&module_declaration.name); + } + // Make nested tuple structure like (((Babe, Consensus), Grandpa), ...) + let all_modules = names.iter().fold( + TokenStream2::default(), + |combined, name| quote!((#name, #combined)), + ); + + quote!( + pub type System = system::Module<#runtime>; + #types + type AllModules = ( #all_modules ); + ) +} + +fn find_system_module<'a>( + mut module_declarations: impl Iterator, +) -> Option<&'a Ident> { + module_declarations + .find(|decl| decl.name == "System") + .map(|decl| &decl.module) +} diff --git a/frame/support/procedural/src/construct_runtime/parse.rs b/frame/support/procedural/src/construct_runtime/parse.rs new file mode 100644 index 0000000000..b3f602824c --- /dev/null +++ b/frame/support/procedural/src/construct_runtime/parse.rs @@ -0,0 +1,401 @@ +// Copyright 2019 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Substrate is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Substrate. If not, see . + +use frame_support_procedural_tools::syn_ext as ext; +use proc_macro2::Span; +use std::collections::HashSet; +use syn::{ + parse::{Parse, ParseStream}, + spanned::Spanned, + token, Error, Ident, Result, Token, +}; + +mod keyword { + syn::custom_keyword!(Block); + syn::custom_keyword!(NodeBlock); + syn::custom_keyword!(UncheckedExtrinsic); +} + +#[derive(Debug)] +pub struct RuntimeDefinition { + pub visibility_token: Token![pub], + pub enum_token: Token![enum], + pub name: Ident, + pub where_section: WhereSection, + pub modules: ext::Braces>, +} + +impl Parse for RuntimeDefinition { + fn parse(input: ParseStream) -> Result { + Ok(Self { + visibility_token: input.parse()?, + enum_token: input.parse()?, + name: input.parse()?, + where_section: input.parse()?, + modules: input.parse()?, + }) + } +} + +#[derive(Debug)] +pub struct WhereSection { + pub block: syn::TypePath, + pub node_block: syn::TypePath, + pub unchecked_extrinsic: syn::TypePath, +} + +impl Parse for WhereSection { + fn parse(input: ParseStream) -> Result { + input.parse::()?; + let mut definitions = Vec::new(); + while !input.peek(token::Brace) { + let definition: WhereDefinition = input.parse()?; + definitions.push(definition); + if !input.peek(Token![,]) { + if !input.peek(token::Brace) { + return Err(input.error("Expected `,` or `{`")); + } + break; + } + input.parse::()?; + } + let block = remove_kind(input, WhereKind::Block, &mut definitions)?.value; + let node_block = remove_kind(input, WhereKind::NodeBlock, &mut definitions)?.value; + let unchecked_extrinsic = + remove_kind(input, WhereKind::UncheckedExtrinsic, &mut definitions)?.value; + if let Some(WhereDefinition { + ref kind_span, + ref kind, + .. + }) = definitions.first() + { + let msg = format!( + "`{:?}` was declared above. Please use exactly one delcataion for `{:?}`.", + kind, kind + ); + return Err(Error::new(*kind_span, msg)); + } + Ok(Self { + block, + node_block, + unchecked_extrinsic, + }) + } +} + +#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)] +pub enum WhereKind { + Block, + NodeBlock, + UncheckedExtrinsic, +} + +#[derive(Debug)] +pub struct WhereDefinition { + pub kind_span: Span, + pub kind: WhereKind, + pub value: syn::TypePath, +} + +impl Parse for WhereDefinition { + fn parse(input: ParseStream) -> Result { + let lookahead = input.lookahead1(); + let (kind_span, kind) = if lookahead.peek(keyword::Block) { + (input.parse::()?.span(), WhereKind::Block) + } else if lookahead.peek(keyword::NodeBlock) { + ( + input.parse::()?.span(), + WhereKind::NodeBlock, + ) + } else if lookahead.peek(keyword::UncheckedExtrinsic) { + ( + input.parse::()?.span(), + WhereKind::UncheckedExtrinsic, + ) + } else { + return Err(lookahead.error()); + }; + + Ok(Self { + kind_span, + kind, + value: { + let _: Token![=] = input.parse()?; + input.parse()? + }, + }) + } +} + +#[derive(Debug)] +pub struct ModuleDeclaration { + pub name: Ident, + pub module: Ident, + pub instance: Option, + pub details: Option>>, +} + +impl Parse for ModuleDeclaration { + fn parse(input: ParseStream) -> Result { + let name = input.parse()?; + let _: Token![:] = input.parse()?; + let module = input.parse()?; + let instance = if input.peek(Token![::]) && input.peek3(Token![<]) { + let _: Token![::] = input.parse()?; + let _: Token![<] = input.parse()?; + let res = Some(input.parse()?); + let _: Token![>] = input.parse()?; + res + } else { + None + }; + let details = if input.peek(Token![::]) { + let _: Token![::] = input.parse()?; + Some(input.parse()?) + } else { + None + }; + let parsed = Self { + name, + module, + instance, + details, + }; + if let Some(ref details) = parsed.details { + let parts = &details.content.inner; + let mut resolved = HashSet::new(); + let has_default = parts.into_iter().any(|m| m.is_default()); + for entry in parts { + match entry { + ModuleEntry::Part(part) if has_default => { + if part.is_included_in_default() { + let msg = format!( + "`{}` is already included in `default`. Either remove `default` or remove `{}`", + part.name, + part.name + ); + return Err(Error::new(part.name.span(), msg)); + } + } + ModuleEntry::Part(part) => { + if !resolved.insert(part.name.clone()) { + let msg = format!( + "`{}` was already declared before. Please remove the duplicate declaration", + part.name + ); + return Err(Error::new(part.name.span(), msg)); + } + } + _ => {} + } + } + } + Ok(parsed) + } +} + +impl ModuleDeclaration { + /// Get resolved module parts, i.e. after expanding `default` keyword + /// or empty declaration + pub fn module_parts(&self) -> Vec { + if let Some(ref details) = self.details { + details + .content + .inner + .iter() + .flat_map(|entry| match entry { + ModuleEntry::Default(ref token) => Self::default_modules(token.span()), + ModuleEntry::Part(ref part) => vec![part.clone()], + }) + .collect() + } else { + Self::default_modules(self.module.span()) + } + } + + pub fn find_part(&self, name: &str) -> Option { + self.module_parts() + .into_iter() + .find(|part| part.name == name) + } + + pub fn exists_part(&self, name: &str) -> bool { + self.find_part(name).is_some() + } + + fn default_modules(span: Span) -> Vec { + let mut res: Vec<_> = ["Module", "Call", "Storage"] + .into_iter() + .map(|name| ModulePart::with_name(name, span)) + .collect(); + res.extend( + ["Event", "Config"] + .into_iter() + .map(|name| ModulePart::with_generics(name, span)), + ); + res + } +} + +#[derive(Debug)] +pub enum ModuleEntry { + Default(Token![default]), + Part(ModulePart), +} + +impl Parse for ModuleEntry { + fn parse(input: ParseStream) -> Result { + let lookahead = input.lookahead1(); + if lookahead.peek(Token![default]) { + Ok(ModuleEntry::Default(input.parse()?)) + } else if lookahead.peek(Ident) { + Ok(ModuleEntry::Part(input.parse()?)) + } else { + Err(lookahead.error()) + } + } +} + +impl ModuleEntry { + pub fn is_default(&self) -> bool { + match self { + ModuleEntry::Default(_) => true, + _ => false, + } + } +} + +#[derive(Debug, Clone)] +pub struct ModulePart { + pub name: Ident, + pub generics: syn::Generics, + pub args: Option>>, +} + +impl Parse for ModulePart { + fn parse(input: ParseStream) -> Result { + let name = input.parse()?; + let generics: syn::Generics = input.parse()?; + if !generics.params.is_empty() && !Self::is_allowed_generic(&name) { + let valid_generics = ModulePart::format_names(ModulePart::allowed_generics()); + let msg = format!( + "`{}` is not allowed to have generics. \ + Only the following modules are allowed to have generics: {}.", + name, valid_generics + ); + return Err(syn::Error::new(name.span(), msg)); + } + let args = if input.peek(token::Paren) { + if !Self::is_allowed_arg(&name) { + let syn::group::Parens { token: parens, .. } = syn::group::parse_parens(input)?; + let valid_names = ModulePart::format_names(ModulePart::allowed_args()); + let msg = format!( + "`{}` is not allowed to have arguments in parens. \ + Only the following modules are allowed to have arguments in parens: {}.", + name, valid_names + ); + return Err(syn::Error::new(parens.span, msg)); + } + Some(input.parse()?) + } else { + None + }; + Ok(Self { + name, + generics, + args, + }) + } +} + +impl ModulePart { + pub fn is_allowed_generic(ident: &Ident) -> bool { + Self::allowed_generics().into_iter().any(|n| ident == n) + } + + pub fn is_allowed_arg(ident: &Ident) -> bool { + Self::allowed_args().into_iter().any(|n| ident == n) + } + + pub fn allowed_generics() -> Vec<&'static str> { + vec!["Event", "Origin", "Config"] + } + + pub fn allowed_args() -> Vec<&'static str> { + vec!["Inherent"] + } + + pub fn format_names(names: Vec<&'static str>) -> String { + let res: Vec<_> = names.into_iter().map(|s| format!("`{}`", s)).collect(); + res.join(", ") + } + + pub fn is_included_in_default(&self) -> bool { + ["Module", "Call", "Storage", "Event", "Config"] + .into_iter() + .any(|name| self.name == name) + } + + /// Plain module name like `Event` or `Call`, etc. + pub fn with_name(name: &str, span: Span) -> Self { + let name = Ident::new(name, span); + Self { + name, + generics: syn::Generics { + lt_token: None, + gt_token: None, + where_clause: None, + ..Default::default() + }, + args: None, + } + } + + /// Module name with generic like `Event` or `Call`, etc. + pub fn with_generics(name: &str, span: Span) -> Self { + let name = Ident::new(name, span); + let typ = Ident::new("T", span); + let generic_param = syn::GenericParam::Type(typ.into()); + let generic_params = vec![generic_param].into_iter().collect(); + let generics = syn::Generics { + lt_token: Some(syn::token::Lt { spans: [span] }), + params: generic_params, + gt_token: Some(syn::token::Gt { spans: [span] }), + where_clause: None, + }; + Self { + name, + generics, + args: None, + } + } +} + +fn remove_kind( + input: ParseStream, + kind: WhereKind, + definitions: &mut Vec, +) -> Result { + if let Some(pos) = definitions.iter().position(|d| d.kind == kind) { + Ok(definitions.remove(pos)) + } else { + let msg = format!( + "Missing associated type for `{:?}`. Add `{:?}` = ... to where section.", + kind, kind + ); + Err(input.error(msg)) + } +} diff --git a/frame/support/procedural/src/lib.rs b/frame/support/procedural/src/lib.rs index 1832e870a3..8f23142bea 100644 --- a/frame/support/procedural/src/lib.rs +++ b/frame/support/procedural/src/lib.rs @@ -23,6 +23,7 @@ extern crate proc_macro; mod storage; +mod construct_runtime; use proc_macro::TokenStream; @@ -219,3 +220,63 @@ use proc_macro::TokenStream; pub fn decl_storage(input: TokenStream) -> TokenStream { storage::decl_storage_impl(input) } + +/// Construct a runtime, with the given name and the given modules. +/// +/// The parameters here are specific types for `Block`, `NodeBlock`, and `UncheckedExtrinsic` +/// and the modules that are used by the runtime. +/// `Block` is the block type that is used in the runtime and `NodeBlock` is the block type +/// that is used in the node. For instance they can differ in the extrinsics type. +/// +/// # Example: +/// +/// ```nocompile +/// construct_runtime!( +/// pub enum Runtime where +/// Block = Block, +/// NodeBlock = runtime::Block, +/// UncheckedExtrinsic = UncheckedExtrinsic +/// { +/// System: system, +/// Test: test::{default}, +/// Test2: test_with_long_module::{Module}, +/// +/// // Module with instances +/// Test3_Instance1: test3::::{Module, Call, Storage, Event, Config, Origin}, +/// Test3_DefaultInstance: test3::{Module, Call, Storage, Event, Config, Origin}, +/// } +/// ) +/// ``` +/// +/// The module `System: system` will expand to `System: system::{Module, Call, Storage, Event, Config}`. +/// The identifier `System` is the name of the module and the lower case identifier `system` is the +/// name of the Rust module/crate for this Substrate module. +/// +/// The module `Test: test::{default}` will expand to +/// `Test: test::{Module, Call, Storage, Event, Config}`. +/// +/// The module `Test2: test_with_long_module::{Module}` will expand to +/// `Test2: test_with_long_module::{Module}`. +/// +/// We provide support for the following types in a module: +/// +/// - `Module` +/// - `Call` +/// - `Storage` +/// - `Event` or `Event` (if the event is generic) +/// - `Origin` or `Origin` (if the origin is generic) +/// - `Config` or `Config` (if the config is generic) +/// - `Inherent ( $(CALL),* )` - If the module provides/can check inherents. The optional parameter +/// is for modules that use a `Call` from a different module as +/// inherent. +/// - `ValidateUnsigned` - If the module validates unsigned extrinsics. +/// +/// # Note +/// +/// The population of the genesis storage depends on the order of modules. So, if one of your +/// modules depends on another module, the module that is depended upon needs to come before +/// the module depending on it. +#[proc_macro] +pub fn construct_runtime(input: TokenStream) -> TokenStream { + construct_runtime::construct_runtime(input) +} diff --git a/frame/support/procedural/tools/src/syn_ext.rs b/frame/support/procedural/tools/src/syn_ext.rs index 18c1cd43ce..afcda4eebf 100644 --- a/frame/support/procedural/tools/src/syn_ext.rs +++ b/frame/support/procedural/tools/src/syn_ext.rs @@ -59,6 +59,11 @@ macro_rules! groups_impl { } } + impl Clone for $name

{ + fn clone(&self) -> Self { + Self { token: self.token.clone(), content: self.content.clone() } + } + } } } @@ -72,11 +77,11 @@ pub struct PunctuatedInner { pub variant: V, } -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct NoTrailing; -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct Trailing; pub type Punctuated = PunctuatedInner; @@ -107,6 +112,12 @@ impl ToTokens for PunctuatedInner { } } +impl Clone for PunctuatedInner { + fn clone(&self) -> Self { + Self { inner: self.inner.clone(), variant: self.variant.clone() } + } +} + /// Note that syn Meta is almost fine for use case (lacks only `ToToken`) #[derive(Debug, Clone)] pub struct Meta { @@ -178,6 +189,14 @@ impl ToTokens for Opt

{ } } +impl Clone for Opt

{ + fn clone(&self) -> Self { + Self { + inner: self.inner.clone() + } + } +} + pub fn extract_type_option(typ: &syn::Type) -> Option { if let syn::Type::Path(ref path) = typ { let v = path.path.segments.last()?; diff --git a/frame/support/src/lib.rs b/frame/support/src/lib.rs index e67120347a..916ffbdfa3 100644 --- a/frame/support/src/lib.rs +++ b/frame/support/src/lib.rs @@ -58,8 +58,6 @@ mod origin; #[macro_use] pub mod metadata; #[macro_use] -mod runtime; -#[macro_use] pub mod inherent; #[macro_use] pub mod unsigned; @@ -116,7 +114,7 @@ macro_rules! parameter_types { } #[doc(inline)] -pub use frame_support_procedural::decl_storage; +pub use frame_support_procedural::{decl_storage, construct_runtime}; /// Return Err of the expression: `return Err($expression);`. /// diff --git a/frame/support/src/runtime.rs b/frame/support/src/runtime.rs deleted file mode 100644 index 52bf48baa5..0000000000 --- a/frame/support/src/runtime.rs +++ /dev/null @@ -1,948 +0,0 @@ -// Copyright 2018-2019 Parity Technologies (UK) Ltd. -// This file is part of Substrate. - -// Substrate is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Substrate is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Substrate. If not, see . - -//! Macros to define a runtime. A runtime is basically all your logic running in Substrate, -//! consisting of selected SRML modules and maybe some of your own modules. -//! A lot of supporting logic is automatically generated for a runtime, -//! mostly to combine data types and metadata of the included modules. - -/// Construct a runtime, with the given name and the given modules. -/// -/// The parameters here are specific types for `Block`, `NodeBlock`, and `InherentData` -/// and the modules that are used by the runtime. -/// `Block` is the block type that is used in the runtime and `NodeBlock` is the block type -/// that is used in the node. For instance they can differ in the extrinsics type. -/// -/// # Example: -/// -/// ```nocompile -/// construct_runtime!( -/// pub enum Runtime where -/// Block = Block, -/// NodeBlock = runtime::Block, -/// UncheckedExtrinsic = UncheckedExtrinsic -/// { -/// System: system, -/// Test: test::{default}, -/// Test2: test_with_long_module::{Module}, -/// -/// // Module with instances -/// Test3_Instance1: test3::::{Module, Call, Storage, Event, Config, Origin}, -/// Test3_DefaultInstance: test3::{Module, Call, Storage, Event, Config, Origin}, -/// } -/// ) -/// ``` -/// -/// The module `System: system` will expand to `System: system::{Module, Call, Storage, Event, Config}`. -/// The identifier `System` is the name of the module and the lower case identifier `system` is the -/// name of the Rust module/crate for this Substrate module. -/// -/// The module `Test: test::{default}` will expand to -/// `Test: test::{Module, Call, Storage, Event, Config}`. -/// -/// The module `Test2: test_with_long_module::{Module}` will expand to -/// `Test2: test_with_long_module::{Module}`. -/// -/// We provide support for the following types in a module: -/// -/// - `Module` -/// - `Call` -/// - `Storage` -/// - `Event` or `Event` (if the event is generic) -/// - `Origin` or `Origin` (if the origin is generic) -/// - `Config` or `Config` (if the config is generic) -/// - `Inherent $( (CALL) )*` - If the module provides/can check inherents. The optional parameter -/// is for modules that use a `Call` from a different module as -/// inherent. -/// - `ValidateUnsigned` - If the module validates unsigned extrinsics. -/// -/// # Note -/// -/// The population of the genesis storage depends on the order of modules. So, if one of your -/// modules depends on another module, the module that is depended upon needs to come before -/// the module depending on it. -#[macro_export] -macro_rules! construct_runtime { - - // Macro transformations (to convert invocations with incomplete parameters to the canonical - // form) - - ( - pub enum $runtime:ident - where - Block = $block:ident, - NodeBlock = $node_block:ty, - UncheckedExtrinsic = $uncheckedextrinsic:ident - { - $( $rest:tt )* - } - ) => { - $crate::construct_runtime!( - { - $runtime; - $block; - $node_block; - $uncheckedextrinsic; - }; - {}; - $( $rest )* - ); - }; - // No modules given, expand to the default module set. - ( - { $( $preset:tt )* }; - { $( $expanded:tt )* }; - $name:ident: $module:ident, - $( $rest:tt )* - ) => { - $crate::construct_runtime!( - { $( $preset )* }; - { $( $expanded )* }; - $name: $module::{default}, - $( $rest )* - ); - }; - // `default` identifier given, expand to default + given extra modules - ( - { $( $preset:tt )* }; - { $( $expanded:tt )* }; - $name:ident: $module:ident::{ - default - $(, - $modules:ident - $( <$modules_generic:ident> )* - $( ( $( $modules_args:ident ),* ) )* - )* - }, - $( $rest:tt )* - ) => { - $crate::construct_runtime!( - { $( $preset )* }; - { - $( $expanded )* - $name: $module::{ - Module, Call, Storage, Event, Config - $(, - $modules $( <$modules_generic> )* - $( ( $( $modules_args ),* ) )* - )* - }, - }; - $( $rest )* - ); - }; - // Take all modules as given by the user. - ( - { $( $preset:tt )* }; - { $( $expanded:tt )* }; - $name:ident: $module:ident :: $( < $module_instance:ident >:: )? { - $( - $modules:ident - $( <$modules_generic:ident> )* - $( ( $( $modules_args:ident ),* ) )* - ),* - }, - $( $rest:tt )* - ) => { - $crate::construct_runtime!( - { $( $preset )* }; - { - $( $expanded )* - $name: $module:: $( < $module_instance >:: )? { - $( - $modules $( <$modules_generic> )* - $( ( $( $modules_args ),* ) )* - ),* - }, - }; - $( $rest )* - ); - }; - // The main macro expansion that actually renders the Runtime code. - ( - { - $runtime:ident; - $block:ident; - $node_block:ty; - $uncheckedextrinsic:ident; - }; - { - $( - $name:ident: $module:ident :: $( < $module_instance:ident >:: )? { - $( - $modules:ident - $( <$modules_generic:ident> )* - $( ( $( $modules_args:ident ),* ) )* - ),* - }, - )* - }; - ) => { - #[derive(Clone, Copy, PartialEq, Eq, $crate::RuntimeDebug)] - pub struct $runtime; - impl $crate::sr_primitives::traits::GetNodeBlockType for $runtime { - type NodeBlock = $node_block; - } - impl $crate::sr_primitives::traits::GetRuntimeBlockType for $runtime { - type RuntimeBlock = $block; - } - $crate::__decl_outer_event!( - $runtime; - $( - $name: $module:: $( < $module_instance >:: )? { - $( $modules $( <$modules_generic> )* ),* - } - ),* - ); - $crate::__decl_outer_origin!( - $runtime; - $( - $name: $module:: $( < $module_instance >:: )? { - $( $modules $( <$modules_generic> )* ),* - } - ),* - ); - $crate::__decl_all_modules!( - $runtime; - ; - {}; - {}; - $( - $name: $module:: $( < $module_instance >:: )? { $( $modules ),* }, - )* - ); - $crate::__decl_outer_dispatch!( - $runtime; - ; - $( - $name: $module::{ $( $modules ),* } - ),*; - ); - $crate::__decl_runtime_metadata!( - $runtime; - {}; - $( - $name: $module:: $( < $module_instance >:: )? { $( $modules )* } - )* - ); - $crate::__decl_outer_config!( - $runtime; - {}; - $( - $name: $module:: $( < $module_instance >:: )? { - $( $modules $( <$modules_generic> )* ),* - }, - )* - ); - $crate::__decl_outer_inherent!( - $runtime; - $block; - $uncheckedextrinsic; - ; - $( - $name: $module::{ $( $modules $( ( $( $modules_args )* ) )* ),* } - ),*; - ); - $crate::__impl_outer_validate_unsigned!( - $runtime; - {}; - $( - $name: $module::{ $( $modules $( ( $( $modules_args )* ) )* )* } - )* - ); - } -} - -/// A macro that generates a "__decl" private macro that transforms parts of the runtime definition -/// to feed them into a public "impl" macro which accepts the format -/// "pub enum $name for $runtime where system = $system". -/// -/// Used to define Event and Origin associated types. -#[macro_export] -#[doc(hidden)] -macro_rules! __create_decl_macro { - ( - // Parameter $d is a hack for the following issue: - // https://github.com/rust-lang/rust/issues/35853 - $macro_name:ident, $macro_outer_name:ident, $macro_enum_name:ident, $d:tt - ) => { - #[macro_export] - #[doc(hidden)] - macro_rules! $macro_name { - ( - $runtime:ident; - $d( $name:ident : $module:ident:: $d( < $module_instance:ident >:: )? { - $d( $modules:ident $d( <$modules_generic:ident> ),* ),* - }),* - ) => { - $d crate::$macro_name!(@inner - $runtime; - ; - {}; - $d( - $name: $module:: $d( < $module_instance >:: )? { - $d( $modules $d( <$modules_generic> )* ),* - }, - )* - ); - }; - // Parse system module - (@inner - $runtime:ident; - ; // there can not be multiple `System`s - { $d( $parsed:tt )* }; - System: $module:ident::{ - $d( $modules:ident $d( <$modules_generic:ident> )* ),* - }, - $d( $rest:tt )* - ) => { - $d crate::$macro_name!(@inner - $runtime; - $module; - { $d( $parsed )* }; - $d( $rest )* - ); - }; - // Parse instantiable module with generic - (@inner - $runtime:ident; - $d( $system:ident )?; - { $d( $parsed:tt )* }; - $name:ident : $module:ident:: < $module_instance:ident >:: { - $macro_enum_name <$event_generic:ident> $d(, $ingore:ident $d( <$ignor:ident> )* )* - }, - $d( $rest:tt )* - ) => { - $d crate::$macro_name!(@inner - $runtime; - $d( $system )?; - { - $d( $parsed )* - $module $module_instance <$event_generic>, - }; - $d( $rest )* - ); - }; - // Parse instantiable module with no generic - (@inner - $runtime:ident; - $d( $system:ident )?; - { $d( $parsed:tt )* }; - $name:ident : $module:ident:: < $module_instance:ident >:: { - $macro_enum_name $d(, $ingore:ident $d( <$ignor:ident> )* )* - }, - $d( $rest:tt )* - ) => { - compile_error!(concat!( - "Instantiable module with not generic ", stringify!($macro_enum_name), - " cannot be constructed: module `", stringify!($name), "` must have generic ", - stringify!($macro_enum_name), "." - )); - }; - // Parse instantiable module with no generic - (@inner - $runtime:ident; - $d( $system:ident )?; - { $d( $parsed:tt )* }; - $name:ident : $module:ident:: { - $macro_enum_name $d( <$event_generic:ident> )* $d(, $ignore:ident $d( <$ignor:ident> )* )* - }, - $d( $rest:tt )* - ) => { - $d crate::$macro_name!(@inner - $runtime; - $d( $system )?; - { - $d( $parsed )* - $module $d( <$event_generic> )*, - }; - $d( $rest )* - ); - }; - // Ignore keyword - (@inner - $runtime:ident; - $d( $system:ident )?; - { $d( $parsed:tt )* }; - $name:ident : $module:ident:: $d( < $module_instance:ident >:: )? { - $ingore:ident $d( <$ignor:ident> )* $d(, $modules:ident $d( <$modules_generic:ident> )* )* - }, - $d( $rest:tt )* - ) => { - $d crate::$macro_name!(@inner - $runtime; - $d( $system )?; - { $d( $parsed )* }; - $name: $module:: $d( < $module_instance >:: )? { $d( $modules $d( <$modules_generic> )* ),* }, - $d( $rest )* - ); - }; - // Ignore module - (@inner - $runtime:ident; - $d( $system:ident )?; - { $d( $parsed:tt )* }; - $name:ident: $module:ident:: $d( < $module_instance:ident >:: )? {}, - $d( $rest:tt )* - ) => { - $d crate::$macro_name!(@inner - $runtime; - $d( $system )?; - { $d( $parsed )* }; - $d( $rest )* - ); - }; - // Expand - (@inner - $runtime:ident; - $system:ident; - { $d( $parsed_modules:ident $d( $instance:ident )? $d( <$parsed_generic:ident> )? ,)* }; - ) => { - $d crate::$macro_outer_name! { - pub enum $macro_enum_name for $runtime where system = $system { - $d( - $parsed_modules $d( $instance )? $d( <$parsed_generic> )?, - )* - } - } - } - } - } -} - -__create_decl_macro!(__decl_outer_event, impl_outer_event, Event, $); -__create_decl_macro!(__decl_outer_origin, impl_outer_origin, Origin, $); - -/// A macro that defines all modules as an associated types of the Runtime type. -#[macro_export] -#[doc(hidden)] -macro_rules! __decl_all_modules { - ( - $runtime:ident; - ; - { $( $parsed:tt )* }; - { $( $parsed_nested:tt )* }; - System: $module:ident::{ Module $(, $modules:ident )* }, - $( $rest:tt )* - ) => { - $crate::__decl_all_modules!( - $runtime; - $module; - { $( $parsed )* }; - { $( $parsed_nested )* }; - $( $rest )* - ); - }; - ( - $runtime:ident; - $( $system:ident )?; - { $( $parsed:tt )* }; - {}; - $name:ident: $module:ident:: $( < $module_instance:ident >:: )? { Module $(, $modules:ident )* }, - $( $rest:tt )* - ) => { - $crate::__decl_all_modules!( - $runtime; - $( $system )?; - { - $( $parsed )* - $module::$name $(<$module_instance>)?, - }; - { $name }; - $( $rest )* - ); - }; - ( - $runtime:ident; - $( $system:ident )?; - { $( $parsed:tt )* }; - { $( $parsed_nested:tt )* }; - $name:ident: $module:ident:: $( < $module_instance:ident >:: )? { Module $(, $modules:ident )* }, - $( $rest:tt )* - ) => { - $crate::__decl_all_modules!( - $runtime; - $( $system )?; - { - $( $parsed )* - $module::$name $(<$module_instance>)?, - }; - { ( $( $parsed_nested )*, $name, ) }; - $( $rest )* - ); - }; - ( - $runtime:ident; - $( $system:ident )?; - { $( $parsed:tt )* }; - { $( $parsed_nested:tt )* }; - $name:ident: $module:ident:: $( < $module_instance:ident >:: )? { $ignore:ident $(, $modules:ident )* }, - $( $rest:tt )* - ) => { - $crate::__decl_all_modules!( - $runtime; - $( $system )?; - { $( $parsed )* }; - { $( $parsed_nested )* }; - $name: $module::{ $( $modules ),* }, - $( $rest )* - ); - }; - ( - $runtime:ident; - $( $system:ident )?; - { $( $parsed:tt )* }; - $name:ident: $module:ident:: $( < $module_instance:ident >:: )? {}, - $( $rest:tt )* - ) => { - $crate::__decl_all_modules!( - $runtime; - $( $system )?; - { $( $parsed )* }; - { $( $parsed_nested )* }; - $( $rest )* - ); - }; - ( - $runtime:ident; - $system:ident; - { $( $parsed_module:ident :: $parsed_name:ident $(<$instance:ident>)? ,)*}; - { $( $parsed_nested:tt )* }; - ) => { - pub type System = system::Module<$runtime>; - $( - pub type $parsed_name = $parsed_module::Module<$runtime $(, $parsed_module::$instance )?>; - )* - type AllModules = ( $( $parsed_nested )* ); - } -} - -/// A macro that defines the Call enum to represent calls to functions in the modules included -/// in the runtime (by wrapping the values of all FooModule::Call enums). -#[macro_export] -#[doc(hidden)] -macro_rules! __decl_outer_dispatch { - ( - $runtime:ident; - $( $parsed_modules:ident :: $parsed_name:ident ),*; - $name:ident: $module:ident::{ - Call $(, $modules:ident $( <$modules_generic:ident> )* )* - } - $(, $rest_name:ident : $rest_module:ident::{ - $( $rest_modules:ident $( <$rest_modules_generic:ident> )* ),* - })*; - ) => { - $crate::__decl_outer_dispatch!( - $runtime; - $( $parsed_modules :: $parsed_name, )* $module::$name; - $( - $rest_name: $rest_module::{ - $( $rest_modules $( <$rest_modules_generic> )* ),* - } - ),*; - ); - }; - ( - $runtime:ident; - $( $parsed_modules:ident :: $parsed_name:ident ),*; - $name:ident: $module:ident::{ - $ignore:ident $( <$ignor:ident> )* $(, $modules:ident $( <$modules_generic:ident> )* )* - } - $(, $rest_name:ident : $rest_module:ident::{ - $( $rest_modules:ident $( <$rest_modules_generic:ident> )* ),* - })*; - ) => { - $crate::__decl_outer_dispatch!( - $runtime; - $( $parsed_modules :: $parsed_name ),*; - $name: $module::{ $( $modules $( <$modules_generic> )* ),* } - $( - , $rest_name: $rest_module::{ - $( $rest_modules $( <$rest_modules_generic> )* ),* - } - )*; - ); - }; - ( - $runtime:ident; - $( $parsed_modules:ident :: $parsed_name:ident ),*; - $name:ident: $module:ident::{} - $(, $rest_name:ident : $rest_module:ident::{ - $( $rest_modules:ident $( <$rest_modules_generic:ident> )* ),* - })*; - ) => { - $crate::__decl_outer_dispatch!( - $runtime; - $( $parsed_modules :: $parsed_name ),*; - $( - $rest_name: $rest_module::{ - $( $rest_modules $( <$rest_modules_generic> )* ),* - } - ),*; - ); - }; - ( - $runtime:ident; - $( $parsed_modules:ident :: $parsed_name:ident ),*; - ; - ) => { - $crate::impl_outer_dispatch!( - pub enum Call for $runtime where origin: Origin { - $( $parsed_modules::$parsed_name, )* - } - ); - }; -} - -/// A private macro that generates metadata() method for the runtime. See impl_runtime_metadata macro. -#[macro_export] -#[doc(hidden)] -macro_rules! __decl_runtime_metadata { - // leading is Module : parse - ( - $runtime:ident; - { $( $parsed:tt )* }; - $( { leading_module: $( $leading_module:ident )* } )? - $name:ident: $module:ident:: $( < $module_instance:ident >:: )? { - Module $( $modules:ident )* - } - $( $rest:tt )* - ) => { - $crate::__decl_runtime_metadata!( - $runtime; - { - $( $parsed )* - $module $( < $module_instance > )? as $name { - $( $( $leading_module )* )? $( $modules )* - } - }; - $( $rest )* - ); - }; - // leading isn't Module : put it in leadings - ( - $runtime:ident; - { $( $parsed:tt )* }; - $( { leading_module: $( $leading_module:ident )* } )? - $name:ident: $module:ident:: $( < $module_instance:ident >:: )? { - $other_module:ident $( $modules:ident )* - } - $( $rest:tt )* - ) => { - $crate::__decl_runtime_metadata!( - $runtime; - { $( $parsed )* }; - { leading_module: $( $( $leading_module )* )? $other_module } - $name: $module:: $( < $module_instance >:: )? { - $( $modules )* - } - $( $rest )* - ); - }; - // does not contain Module : skip - ( - $runtime:ident; - { $( $parsed:tt )* }; - $( { leading_module: $( $leading_module:ident )* } )? - $name:ident: $module:ident:: $( < $module_instance:ident >:: )? {} - $( $rest:tt )* - ) => { - $crate::__decl_runtime_metadata!( - $runtime; - { $( $parsed )* }; - $( $rest )* - ); - }; - // end of decl - ( - $runtime:ident; - { - $( - $parsed_modules:ident $( < $module_instance:ident > )? as $parsed_name:ident { - $( $withs:ident )* - } - )* - }; - ) => { - $crate::impl_runtime_metadata!( - for $runtime with modules - $( $parsed_modules::Module $( < $module_instance > )? as $parsed_name - with $( $withs )* , )* - ); - } -} - -/// A private macro that generates GenesisConfig for the runtime. See `impl_outer_config!` macro. -#[macro_export] -#[doc(hidden)] -macro_rules! __decl_outer_config { - ( - $runtime:ident; - { $( $parsed:tt )* }; - $name:ident: $module:ident:: $( < $module_instance:ident >:: )? { - Config $( <$config_generic:ident> )? - $(, $modules:ident $( <$modules_generic:ident> )* )* - }, - $( $rest:tt )* - ) => { - $crate::__decl_outer_config!( - $runtime; - { - $( $parsed )* - $module::$name $( $module_instance )? $( <$config_generic> )?, - }; - $( $rest )* - ); - }; - ( - $runtime:ident; - { $( $parsed:tt )* }; - $name:ident: $module:ident:: $( < $module_instance:ident >:: )? { - $ingore:ident $( <$ignore_gen:ident> )* - $(, $modules:ident $( <$modules_generic:ident> )* )* - }, - $( $rest:tt )* - ) => { - $crate::__decl_outer_config!( - $runtime; - { $( $parsed )* }; - $name: $module:: $( < $module_instance >:: )? { $( $modules $( <$modules_generic> )* ),* }, - $( $rest )* - ); - }; - ( - $runtime:ident; - { $( $parsed:tt )* }; - $name:ident: $module:ident:: $( < $module_instance:ident >:: )? {}, - $( $rest:tt )* - ) => { - $crate::__decl_outer_config!( - $runtime; - { $( $parsed )* }; - $( $rest )* - ); - }; - ( - $runtime:ident; - { - $( - $parsed_modules:ident :: $parsed_name:ident $( $parsed_instance:ident )? - $( - <$parsed_generic:ident> - )* - ,)* - }; - ) => { - $crate::paste::item! { - $crate::sr_primitives::impl_outer_config!( - pub struct GenesisConfig for $runtime { - $( - [< $parsed_name Config >] => - $parsed_modules $( $parsed_instance )? $( <$parsed_generic> )*, - )* - } - ); - } - }; -} - -/// A private macro that generates check_inherents() implementation for the runtime. -#[macro_export] -#[doc(hidden)] -macro_rules! __decl_outer_inherent { - ( - $runtime:ident; - $block:ident; - $uncheckedextrinsic:ident; - $( $parsed_name:ident :: $parsed_call:ident ),*; - $name:ident: $module:ident::{ - Inherent $(, $modules:ident $( ( $( $modules_call:ident )* ) )* )* - } - $(, $rest_name:ident : $rest_module:ident::{ - $( $rest_modules:ident $( ( $( $rest_call:ident )* ) )* ),* - })*; - ) => { - $crate::__decl_outer_inherent!( - $runtime; - $block; - $uncheckedextrinsic; - $( $parsed_name :: $parsed_call, )* $name::$name; - $( - $rest_name: $rest_module::{ - $( $rest_modules $( ( $( $rest_call )* ) )* ),* - } - ),*; - ); - }; - ( - $runtime:ident; - $block:ident; - $uncheckedextrinsic:ident; - $( $parsed_name:ident :: $parsed_call:ident ),*; - $name:ident: $module:ident::{ - Inherent ( $call:ident ) $(, $modules:ident $( ( $( $modules_call:ident )* ) )* )* - } - $(, $rest_name:ident : $rest_module:ident::{ - $( $rest_modules:ident $( ( $( $rest_call:ident )* ) )* ),* - })*; - ) => { - $crate::__decl_outer_inherent!( - $runtime; - $block; - $uncheckedextrinsic; - $( $parsed_name :: $parsed_call, )* $name::$call; - $( - $rest_name: $rest_module::{ - $( $rest_modules $( ( $( $rest_call )* ) )* ),* - } - ),*; - ); - }; - ( - $runtime:ident; - $block:ident; - $uncheckedextrinsic:ident; - $( $parsed_name:ident :: $parsed_call:ident ),*; - $name:ident: $module:ident::{ - $ignore:ident $( ( $( $ignor:ident )* ) )* - $(, $modules:ident $( ( $( $modules_call:ident )* ) )* )* - } - $(, $rest_name:ident : $rest_module:ident::{ - $( $rest_modules:ident $( ( $( $rest_call:ident )* ) )* ),* - })*; - ) => { - $crate::__decl_outer_inherent!( - $runtime; - $block; - $uncheckedextrinsic; - $( $parsed_name :: $parsed_call ),*; - $name: $module::{ $( $modules $( ( $( $modules_call )* ) )* ),* } - $( - , $rest_name: $rest_module::{ - $( $rest_modules $( ( $( $rest_call )* ) )* ),* - } - )*; - ); - }; - ( - $runtime:ident; - $block:ident; - $uncheckedextrinsic:ident; - $( $parsed_name:ident :: $parsed_call:ident ),*; - $name:ident: $module:ident::{} - $(, $rest_name:ident : $rest_module:ident::{ - $( $rest_modules:ident $( ( $( $rest_call:ident )* ) )* ),* - })*; - ) => { - $crate::__decl_outer_inherent!( - $runtime; - $block; - $uncheckedextrinsic; - $( $parsed_name :: $parsed_call ),*; - $( - $rest_name: $rest_module::{ - $( $rest_modules $( ( $( $rest_call )* ) )* ),* - } - ),*; - ); - }; - ( - $runtime:ident; - $block:ident; - $uncheckedextrinsic:ident; - $( $parsed_name:ident :: $parsed_call:ident ),*; - ; - ) => { - $crate::impl_outer_inherent!( - impl Inherents where Block = $block, UncheckedExtrinsic = $uncheckedextrinsic { - $( $parsed_name : $parsed_call, )* - } - ); - }; -} - -#[macro_export] -#[doc(hidden)] -// Those imports are used by event, config, origin and log macros to get access to its inner type -macro_rules! __decl_instance_import { - ( $( $module:ident <$instance:ident> )* ) => { - $crate::paste::item! { - $(use $module as [< $module _ $instance >];)* - } - }; -} - -/// A private macro that calls impl_outer_validate_unsigned for Call. -#[macro_export] -#[doc(hidden)] -macro_rules! __impl_outer_validate_unsigned { - ( - $runtime:ident; - { $( $parsed:tt )* }; - $name:ident: $module:ident:: $(<$module_instance:ident>::)? { - ValidateUnsigned $( $modules:ident $( ( $( $modules_args:ident )* ) )* )* - } - $( $rest:tt )* - ) => { - $crate::__impl_outer_validate_unsigned!( - $runtime; - { $( $parsed )* $name }; - $( $rest )* - ); - }; - ( - $runtime:ident; - { $( $parsed:tt )* }; - $name:ident: $module:ident:: $(<$module_instance:ident>::)? { - $ignore:ident $( ( $( $args_ignore:ident )* ) )* - $( $modules:ident $( ( $( $modules_args:ident )* ) )* )* - } - $( $rest:tt )* - ) => { - $crate::__impl_outer_validate_unsigned!( - $runtime; - { $( $parsed )* }; - $name: $module:: $(<$module_instance>::)? { - $( $modules $( ( $( $modules_args )* ) )* )* - } - $( $rest )* - ); - }; - ( - $runtime:ident; - { $( $parsed:tt )* }; - $name:ident: $module:ident:: $(<$module_instance:ident>::)? {} - $( $rest:tt )* - ) => { - $crate::__impl_outer_validate_unsigned!( - $runtime; - { $( $parsed )* }; - $( $rest )* - ); - }; - ( - $runtime:ident; - { $( - $parsed_modules:ident - )* }; - ) => { - $crate::impl_outer_validate_unsigned!( - impl ValidateUnsigned for $runtime { - $( $parsed_modules )* - } - ); - }; -} diff --git a/frame/support/test/tests/construct_runtime_ui.rs b/frame/support/test/tests/construct_runtime_ui.rs new file mode 100644 index 0000000000..acddf01f03 --- /dev/null +++ b/frame/support/test/tests/construct_runtime_ui.rs @@ -0,0 +1,10 @@ +use std::env; + +#[test] +fn ui() { + // As trybuild is using `cargo check`, we don't need the real WASM binaries. + env::set_var("BUILD_DUMMY_WASM_BINARY", "1"); + + let t = trybuild::TestCases::new(); + t.compile_fail("tests/construct_runtime_ui/*.rs"); +} diff --git a/frame/support/test/tests/construct_runtime_ui/abundant_where_param.rs b/frame/support/test/tests/construct_runtime_ui/abundant_where_param.rs new file mode 100644 index 0000000000..4d5b40d7c9 --- /dev/null +++ b/frame/support/test/tests/construct_runtime_ui/abundant_where_param.rs @@ -0,0 +1,12 @@ +use support::construct_runtime; + +construct_runtime! { + pub enum Runtime where + Block = Block, + NodeBlock = Block, + Block = Block1, + UncheckedExtrinsic = Uxt, + {} +} + +fn main() {} diff --git a/frame/support/test/tests/construct_runtime_ui/abundant_where_param.stderr b/frame/support/test/tests/construct_runtime_ui/abundant_where_param.stderr new file mode 100644 index 0000000000..4bac57d63c --- /dev/null +++ b/frame/support/test/tests/construct_runtime_ui/abundant_where_param.stderr @@ -0,0 +1,5 @@ +error: `Block` was declared above. Please use exactly one delcataion for `Block`. + --> $DIR/abundant_where_param.rs:7:3 + | +7 | Block = Block1, + | ^^^^^ diff --git a/frame/support/test/tests/construct_runtime_ui/double_module_parts.rs b/frame/support/test/tests/construct_runtime_ui/double_module_parts.rs new file mode 100644 index 0000000000..b741b316e1 --- /dev/null +++ b/frame/support/test/tests/construct_runtime_ui/double_module_parts.rs @@ -0,0 +1,14 @@ +use support::construct_runtime; + +construct_runtime! { + pub enum Runtime where + Block = Block, + NodeBlock = Block, + UncheckedExtrinsic = UncheckedExtrinsic + { + System: system, + Balance: balances::{Config, Call, Config, Origin}, + } +} + +fn main() {} diff --git a/frame/support/test/tests/construct_runtime_ui/double_module_parts.stderr b/frame/support/test/tests/construct_runtime_ui/double_module_parts.stderr new file mode 100644 index 0000000000..9d10474ce8 --- /dev/null +++ b/frame/support/test/tests/construct_runtime_ui/double_module_parts.stderr @@ -0,0 +1,5 @@ +error: `Config` was already declared before. Please remove the duplicate declaration + --> $DIR/double_module_parts.rs:10:37 + | +10 | Balance: balances::{Config, Call, Config, Origin}, + | ^^^^^^ diff --git a/frame/support/test/tests/construct_runtime_ui/double_module_parts_default.rs b/frame/support/test/tests/construct_runtime_ui/double_module_parts_default.rs new file mode 100644 index 0000000000..d259389460 --- /dev/null +++ b/frame/support/test/tests/construct_runtime_ui/double_module_parts_default.rs @@ -0,0 +1,14 @@ +use support::construct_runtime; + +construct_runtime! { + pub enum Runtime where + Block = Block, + NodeBlock = Block, + UncheckedExtrinsic = UncheckedExtrinsic + { + System: system, + Balance: balances::{default, Config}, + } +} + +fn main() {} diff --git a/frame/support/test/tests/construct_runtime_ui/double_module_parts_default.stderr b/frame/support/test/tests/construct_runtime_ui/double_module_parts_default.stderr new file mode 100644 index 0000000000..d8205acc4a --- /dev/null +++ b/frame/support/test/tests/construct_runtime_ui/double_module_parts_default.stderr @@ -0,0 +1,5 @@ +error: `Config` is already included in `default`. Either remove `default` or remove `Config` + --> $DIR/double_module_parts_default.rs:10:32 + | +10 | Balance: balances::{default, Config}, + | ^^^^^^ diff --git a/frame/support/test/tests/construct_runtime_ui/generics_in_invalid_module.rs b/frame/support/test/tests/construct_runtime_ui/generics_in_invalid_module.rs new file mode 100644 index 0000000000..16e3696195 --- /dev/null +++ b/frame/support/test/tests/construct_runtime_ui/generics_in_invalid_module.rs @@ -0,0 +1,14 @@ +use support::construct_runtime; + +construct_runtime! { + pub enum Runtime where + Block = Block, + NodeBlock = Block, + UncheckedExtrinsic = UncheckedExtrinsic + { + System: system, + Balance: balances::::{Call, Origin}, + } +} + +fn main() {} diff --git a/frame/support/test/tests/construct_runtime_ui/generics_in_invalid_module.stderr b/frame/support/test/tests/construct_runtime_ui/generics_in_invalid_module.stderr new file mode 100644 index 0000000000..fe88054921 --- /dev/null +++ b/frame/support/test/tests/construct_runtime_ui/generics_in_invalid_module.stderr @@ -0,0 +1,5 @@ +error: `Call` is not allowed to have generics. Only the following modules are allowed to have generics: `Event`, `Origin`, `Config`. + --> $DIR/generics_in_invalid_module.rs:10:36 + | +10 | Balance: balances::::{Call, Origin}, + | ^^^^ diff --git a/frame/support/test/tests/construct_runtime_ui/invalid_module_details.rs b/frame/support/test/tests/construct_runtime_ui/invalid_module_details.rs new file mode 100644 index 0000000000..bfaeca6a42 --- /dev/null +++ b/frame/support/test/tests/construct_runtime_ui/invalid_module_details.rs @@ -0,0 +1,13 @@ +use support::construct_runtime; + +construct_runtime! { + pub enum Runtime where + Block = Block, + NodeBlock = Block, + UncheckedExtrinsic = UncheckedExtrinsic + { + system: System::(), + } +} + +fn main() {} diff --git a/frame/support/test/tests/construct_runtime_ui/invalid_module_details.stderr b/frame/support/test/tests/construct_runtime_ui/invalid_module_details.stderr new file mode 100644 index 0000000000..559a4637d6 --- /dev/null +++ b/frame/support/test/tests/construct_runtime_ui/invalid_module_details.stderr @@ -0,0 +1,5 @@ +error: expected curly braces + --> $DIR/invalid_module_details.rs:9:19 + | +9 | system: System::(), + | ^^ diff --git a/frame/support/test/tests/construct_runtime_ui/invalid_module_details_keyword.rs b/frame/support/test/tests/construct_runtime_ui/invalid_module_details_keyword.rs new file mode 100644 index 0000000000..87e802f4bc --- /dev/null +++ b/frame/support/test/tests/construct_runtime_ui/invalid_module_details_keyword.rs @@ -0,0 +1,13 @@ +use support::construct_runtime; + +construct_runtime! { + pub enum Runtime where + Block = Block, + NodeBlock = Block, + UncheckedExtrinsic = UncheckedExtrinsic + { + system: System::{enum}, + } +} + +fn main() {} diff --git a/frame/support/test/tests/construct_runtime_ui/invalid_module_details_keyword.stderr b/frame/support/test/tests/construct_runtime_ui/invalid_module_details_keyword.stderr new file mode 100644 index 0000000000..4441f6dc0f --- /dev/null +++ b/frame/support/test/tests/construct_runtime_ui/invalid_module_details_keyword.stderr @@ -0,0 +1,5 @@ +error: expected `default` or identifier + --> $DIR/invalid_module_details_keyword.rs:9:20 + | +9 | system: System::{enum}, + | ^^^^ diff --git a/frame/support/test/tests/construct_runtime_ui/invalid_token_after_module.rs b/frame/support/test/tests/construct_runtime_ui/invalid_token_after_module.rs new file mode 100644 index 0000000000..d7307c2548 --- /dev/null +++ b/frame/support/test/tests/construct_runtime_ui/invalid_token_after_module.rs @@ -0,0 +1,13 @@ +use support::construct_runtime; + +construct_runtime! { + pub enum Runtime where + Block = Block, + NodeBlock = Block, + UncheckedExtrinsic = UncheckedExtrinsic + { + system: System ? + } +} + +fn main() {} diff --git a/frame/support/test/tests/construct_runtime_ui/invalid_token_after_module.stderr b/frame/support/test/tests/construct_runtime_ui/invalid_token_after_module.stderr new file mode 100644 index 0000000000..8a6f15f791 --- /dev/null +++ b/frame/support/test/tests/construct_runtime_ui/invalid_token_after_module.stderr @@ -0,0 +1,5 @@ +error: expected `,` + --> $DIR/invalid_token_after_module.rs:9:18 + | +9 | system: System ? + | ^ diff --git a/frame/support/test/tests/construct_runtime_ui/invalid_token_after_name.rs b/frame/support/test/tests/construct_runtime_ui/invalid_token_after_name.rs new file mode 100644 index 0000000000..f0fb296c73 --- /dev/null +++ b/frame/support/test/tests/construct_runtime_ui/invalid_token_after_name.rs @@ -0,0 +1,13 @@ +use support::construct_runtime; + +construct_runtime! { + pub enum Runtime where + Block = Block, + NodeBlock = Block, + UncheckedExtrinsic = UncheckedExtrinsic + { + system ? + } +} + +fn main() {} diff --git a/frame/support/test/tests/construct_runtime_ui/invalid_token_after_name.stderr b/frame/support/test/tests/construct_runtime_ui/invalid_token_after_name.stderr new file mode 100644 index 0000000000..eaae082c84 --- /dev/null +++ b/frame/support/test/tests/construct_runtime_ui/invalid_token_after_name.stderr @@ -0,0 +1,5 @@ +error: expected `:` + --> $DIR/invalid_token_after_name.rs:9:10 + | +9 | system ? + | ^ diff --git a/frame/support/test/tests/construct_runtime_ui/invalid_where_param.rs b/frame/support/test/tests/construct_runtime_ui/invalid_where_param.rs new file mode 100644 index 0000000000..000af42715 --- /dev/null +++ b/frame/support/test/tests/construct_runtime_ui/invalid_where_param.rs @@ -0,0 +1,12 @@ +use support::construct_runtime; + +construct_runtime! { + pub enum Runtime where + Block = Block, + NodeBlock = Block, + TypeX = Block, + UnchekcedExtrinsic = UnchekcedExtrinsic, + {} +} + +fn main() {} diff --git a/frame/support/test/tests/construct_runtime_ui/invalid_where_param.stderr b/frame/support/test/tests/construct_runtime_ui/invalid_where_param.stderr new file mode 100644 index 0000000000..9e358b6a21 --- /dev/null +++ b/frame/support/test/tests/construct_runtime_ui/invalid_where_param.stderr @@ -0,0 +1,5 @@ +error: expected one of: `Block`, `NodeBlock`, `UncheckedExtrinsic` + --> $DIR/invalid_where_param.rs:7:3 + | +7 | TypeX = Block, + | ^^^^^ diff --git a/frame/support/test/tests/construct_runtime_ui/missing_event_generic_on_module_with_instance.rs b/frame/support/test/tests/construct_runtime_ui/missing_event_generic_on_module_with_instance.rs new file mode 100644 index 0000000000..224ec65ee3 --- /dev/null +++ b/frame/support/test/tests/construct_runtime_ui/missing_event_generic_on_module_with_instance.rs @@ -0,0 +1,14 @@ +use support::construct_runtime; + +construct_runtime! { + pub enum Runtime where + Block = Block, + NodeBlock = Block, + UncheckedExtrinsic = UncheckedExtrinsic + { + System: system, + Balance: balances::::{Event}, + } +} + +fn main() {} diff --git a/frame/support/test/tests/construct_runtime_ui/missing_event_generic_on_module_with_instance.stderr b/frame/support/test/tests/construct_runtime_ui/missing_event_generic_on_module_with_instance.stderr new file mode 100644 index 0000000000..f80b4bd66a --- /dev/null +++ b/frame/support/test/tests/construct_runtime_ui/missing_event_generic_on_module_with_instance.stderr @@ -0,0 +1,5 @@ +error: Instantiable module with no generic `Event` cannot be constructed: module `Balance` must have generic `Event` + --> $DIR/missing_event_generic_on_module_with_instance.rs:10:3 + | +10 | Balance: balances::::{Event}, + | ^^^^^^^ diff --git a/frame/support/test/tests/construct_runtime_ui/missing_module_instance.rs b/frame/support/test/tests/construct_runtime_ui/missing_module_instance.rs new file mode 100644 index 0000000000..9171827d16 --- /dev/null +++ b/frame/support/test/tests/construct_runtime_ui/missing_module_instance.rs @@ -0,0 +1,13 @@ +use support::construct_runtime; + +construct_runtime! { + pub enum Runtime where + Block = Block, + NodeBlock = Block, + UncheckedExtrinsic = UncheckedExtrinsic + { + system: System::<>, + } +} + +fn main() {} diff --git a/frame/support/test/tests/construct_runtime_ui/missing_module_instance.stderr b/frame/support/test/tests/construct_runtime_ui/missing_module_instance.stderr new file mode 100644 index 0000000000..6303c74e42 --- /dev/null +++ b/frame/support/test/tests/construct_runtime_ui/missing_module_instance.stderr @@ -0,0 +1,5 @@ +error: expected identifier + --> $DIR/missing_module_instance.rs:9:20 + | +9 | system: System::<>, + | ^ diff --git a/frame/support/test/tests/construct_runtime_ui/missing_origin_generic_on_module_with_instance.rs b/frame/support/test/tests/construct_runtime_ui/missing_origin_generic_on_module_with_instance.rs new file mode 100644 index 0000000000..6eadbbf3e0 --- /dev/null +++ b/frame/support/test/tests/construct_runtime_ui/missing_origin_generic_on_module_with_instance.rs @@ -0,0 +1,14 @@ +use support::construct_runtime; + +construct_runtime! { + pub enum Runtime where + Block = Block, + NodeBlock = Block, + UncheckedExtrinsic = UncheckedExtrinsic + { + System: system, + Balance: balances::::{Origin}, + } +} + +fn main() {} diff --git a/frame/support/test/tests/construct_runtime_ui/missing_origin_generic_on_module_with_instance.stderr b/frame/support/test/tests/construct_runtime_ui/missing_origin_generic_on_module_with_instance.stderr new file mode 100644 index 0000000000..0f7d36aafb --- /dev/null +++ b/frame/support/test/tests/construct_runtime_ui/missing_origin_generic_on_module_with_instance.stderr @@ -0,0 +1,5 @@ +error: Instantiable module with no generic `Origin` cannot be constructed: module `Balance` must have generic `Origin` + --> $DIR/missing_origin_generic_on_module_with_instance.rs:10:3 + | +10 | Balance: balances::::{Origin}, + | ^^^^^^^ diff --git a/frame/support/test/tests/construct_runtime_ui/missing_system_module.rs b/frame/support/test/tests/construct_runtime_ui/missing_system_module.rs new file mode 100644 index 0000000000..409ee2b8ba --- /dev/null +++ b/frame/support/test/tests/construct_runtime_ui/missing_system_module.rs @@ -0,0 +1,12 @@ +use support::construct_runtime; + +construct_runtime! { + pub enum Runtime where + Block = Block, + NodeBlock = Block, + UncheckedExtrinsic = UncheckedExtrinsic + { + } +} + +fn main() {} diff --git a/frame/support/test/tests/construct_runtime_ui/missing_system_module.stderr b/frame/support/test/tests/construct_runtime_ui/missing_system_module.stderr new file mode 100644 index 0000000000..5964a8aa76 --- /dev/null +++ b/frame/support/test/tests/construct_runtime_ui/missing_system_module.stderr @@ -0,0 +1,7 @@ +error: `System` module declaration is missing. Please add this line: `System: system::{Module, Call, Storage, Config, Event},` + --> $DIR/missing_system_module.rs:8:2 + | +8 | { + | _____^ +9 | | } + | |_____^ diff --git a/frame/support/test/tests/construct_runtime_ui/missing_where_block.rs b/frame/support/test/tests/construct_runtime_ui/missing_where_block.rs new file mode 100644 index 0000000000..8d43c58140 --- /dev/null +++ b/frame/support/test/tests/construct_runtime_ui/missing_where_block.rs @@ -0,0 +1,7 @@ +use support::construct_runtime; + +construct_runtime! { + pub enum Runtime {} +} + +fn main() {} diff --git a/frame/support/test/tests/construct_runtime_ui/missing_where_block.stderr b/frame/support/test/tests/construct_runtime_ui/missing_where_block.stderr new file mode 100644 index 0000000000..4af672a261 --- /dev/null +++ b/frame/support/test/tests/construct_runtime_ui/missing_where_block.stderr @@ -0,0 +1,5 @@ +error: expected `where` + --> $DIR/missing_where_block.rs:4:19 + | +4 | pub enum Runtime {} + | ^^ diff --git a/frame/support/test/tests/construct_runtime_ui/missing_where_param.rs b/frame/support/test/tests/construct_runtime_ui/missing_where_param.rs new file mode 100644 index 0000000000..7ec6409124 --- /dev/null +++ b/frame/support/test/tests/construct_runtime_ui/missing_where_param.rs @@ -0,0 +1,10 @@ +use support::construct_runtime; + +construct_runtime! { + pub enum Runtime where + Block = Block, + NodeBlock = Block, + {} +} + +fn main() {} diff --git a/frame/support/test/tests/construct_runtime_ui/missing_where_param.stderr b/frame/support/test/tests/construct_runtime_ui/missing_where_param.stderr new file mode 100644 index 0000000000..ac7313523c --- /dev/null +++ b/frame/support/test/tests/construct_runtime_ui/missing_where_param.stderr @@ -0,0 +1,5 @@ +error: Missing associated type for `UncheckedExtrinsic`. Add `UncheckedExtrinsic` = ... to where section. + --> $DIR/missing_where_param.rs:7:2 + | +7 | {} + | ^^ diff --git a/frame/support/test/tests/construct_runtime_ui/no_comma_after_where.rs b/frame/support/test/tests/construct_runtime_ui/no_comma_after_where.rs new file mode 100644 index 0000000000..096d5fd376 --- /dev/null +++ b/frame/support/test/tests/construct_runtime_ui/no_comma_after_where.rs @@ -0,0 +1,13 @@ +use support::construct_runtime; + +construct_runtime! { + pub enum Runtime where + UncheckedExtrinsic = UncheckedExtrinsic + Block = Block, + NodeBlock = Block, + { + System: system, + } +} + +fn main() {} diff --git a/frame/support/test/tests/construct_runtime_ui/no_comma_after_where.stderr b/frame/support/test/tests/construct_runtime_ui/no_comma_after_where.stderr new file mode 100644 index 0000000000..caf4a7401b --- /dev/null +++ b/frame/support/test/tests/construct_runtime_ui/no_comma_after_where.stderr @@ -0,0 +1,5 @@ +error: Expected `,` or `{` + --> $DIR/no_comma_after_where.rs:6:3 + | +6 | Block = Block, + | ^^^^^ diff --git a/frame/support/test/tests/construct_runtime_ui/params_in_invalid_module.rs b/frame/support/test/tests/construct_runtime_ui/params_in_invalid_module.rs new file mode 100644 index 0000000000..f493371bb3 --- /dev/null +++ b/frame/support/test/tests/construct_runtime_ui/params_in_invalid_module.rs @@ -0,0 +1,14 @@ +use support::construct_runtime; + +construct_runtime! { + pub enum Runtime where + Block = Block, + NodeBlock = Block, + UncheckedExtrinsic = UncheckedExtrinsic + { + System: system, + Balance: balances::::{Call(toto), Origin}, + } +} + +fn main() {} diff --git a/frame/support/test/tests/construct_runtime_ui/params_in_invalid_module.stderr b/frame/support/test/tests/construct_runtime_ui/params_in_invalid_module.stderr new file mode 100644 index 0000000000..58f35720e3 --- /dev/null +++ b/frame/support/test/tests/construct_runtime_ui/params_in_invalid_module.stderr @@ -0,0 +1,5 @@ +error: `Call` is not allowed to have arguments in parens. Only the following modules are allowed to have arguments in parens: `Inherent`. + --> $DIR/params_in_invalid_module.rs:10:40 + | +10 | Balance: balances::::{Call(toto), Origin}, + | ^^^^^^ -- GitLab From c0f9a21a6d54815de0b1fe7d482a39981b4a238b Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Mon, 25 Nov 2019 17:48:25 +0100 Subject: [PATCH 009/172] Make spawn_essential_task more strict (#4198) --- client/service/src/lib.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/client/service/src/lib.rs b/client/service/src/lib.rs index 2bc56647a6..dd982e5a2e 100644 --- a/client/service/src/lib.rs +++ b/client/service/src/lib.rs @@ -240,10 +240,13 @@ where fn spawn_essential_task(&self, task: impl Future + Send + 'static) { let essential_failed = self.essential_failed.clone(); - let essential_task = task.map_err(move |_| { - error!("Essential task failed. Shutting down service."); - essential_failed.store(true, Ordering::Relaxed); - }); + let essential_task = std::panic::AssertUnwindSafe(task) + .catch_unwind() + .then(move |_| { + error!("Essential task failed. Shutting down service."); + essential_failed.store(true, Ordering::Relaxed); + Ok(()) + }); let task = essential_task.select(self.on_exit()).then(|_| Ok(())); let _ = self.to_spawn_tx.unbounded_send(Box::new(task)); -- GitLab From a9d43cc01f2b30c30f16d0a934aafa10d757acef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Mon, 25 Nov 2019 19:55:21 +0100 Subject: [PATCH 010/172] Remove `keystore` when doing calls and producing a proof (#4196) * Remove keystore parameter. * Fix tests. --- client/src/call_executor.rs | 3 --- client/src/light/call_executor.rs | 4 +--- primitives/sr-api/test/tests/runtime_calls.rs | 1 - primitives/state-machine/src/lib.rs | 24 ++++--------------- 4 files changed, 6 insertions(+), 26 deletions(-) diff --git a/client/src/call_executor.rs b/client/src/call_executor.rs index a41e037636..d37d2b0068 100644 --- a/client/src/call_executor.rs +++ b/client/src/call_executor.rs @@ -262,9 +262,6 @@ where &self.executor, method, call_data, - // Passing `None` here, since we don't really want to prove anything - // about our local keys. - None, ) .map_err(Into::into) } diff --git a/client/src/light/call_executor.rs b/client/src/light/call_executor.rs index a4a8a549de..29b9ca46af 100644 --- a/client/src/light/call_executor.rs +++ b/client/src/light/call_executor.rs @@ -113,7 +113,7 @@ impl CallExecutor for _manager: ExecutionManager, native_call: Option, recorder: &Option>, - extensions: Option, + extensions: Option, ) -> ClientResult> where ExecutionManager: Clone { // there's no actual way/need to specify native/wasm execution strategy on light node // => we can safely ignore passed values @@ -277,7 +277,6 @@ fn check_execution_proof_with_make_header( exec: &Exec, method: &str, call_data: &[u8], - keystore: Option, ) -> Result<(Vec, StorageProof), Box> where B: Backend, @@ -461,7 +460,7 @@ where { let trie_backend = backend.as_trie_backend() .ok_or_else(|| Box::new(ExecutionError::UnableToGenerateProof) as Box)?; - prove_execution_on_trie_backend(trie_backend, overlay, exec, method, call_data, keystore) + prove_execution_on_trie_backend(trie_backend, overlay, exec, method, call_data) } /// Prove execution using the given trie backend, overlayed changes, and call executor. @@ -479,7 +478,6 @@ pub fn prove_execution_on_trie_backend( exec: &Exec, method: &str, call_data: &[u8], - keystore: Option, ) -> Result<(Vec, StorageProof), Box> where S: trie_backend_essence::TrieBackendStorage, @@ -487,12 +485,8 @@ where Exec: CodeExecutor, { let proving_backend = proving_backend::ProvingBackend::new(trie_backend); - let mut extensions = Extensions::new(); - if let Some(keystore) = keystore { - extensions.register(keystore); - } let mut sm = StateMachine::<_, H, _, InMemoryChangesTrieStorage, Exec>::new( - &proving_backend, None, overlay, exec, method, call_data, extensions, + &proving_backend, None, overlay, exec, method, call_data, Extensions::default(), ); let (result, _, _) = sm.execute_using_consensus_failure_handler::<_, NeverNativeValue, fn() -> _>( @@ -512,7 +506,6 @@ pub fn execution_proof_check( exec: &Exec, method: &str, call_data: &[u8], - keystore: Option, ) -> Result, Box> where H: Hasher, @@ -520,7 +513,7 @@ where H::Out: Ord + 'static, { let trie_backend = create_proof_check_backend::(root.into(), proof)?; - execution_proof_check_on_trie_backend(&trie_backend, overlay, exec, method, call_data, keystore) + execution_proof_check_on_trie_backend(&trie_backend, overlay, exec, method, call_data) } /// Check execution proof on proving backend, generated by `prove_execution` call. @@ -530,18 +523,13 @@ pub fn execution_proof_check_on_trie_backend( exec: &Exec, method: &str, call_data: &[u8], - keystore: Option, ) -> Result, Box> where H: Hasher, Exec: CodeExecutor, { - let mut extensions = Extensions::new(); - if let Some(keystore) = keystore { - extensions.register(keystore); - } let mut sm = StateMachine::<_, H, _, InMemoryChangesTrieStorage, Exec>::new( - trie_backend, None, overlay, exec, method, call_data, extensions, + trie_backend, None, overlay, exec, method, call_data, Extensions::default(), ); sm.execute_using_consensus_failure_handler::<_, NeverNativeValue, fn() -> _>( @@ -914,7 +902,6 @@ mod tests { &executor, "test", &[], - None, ).unwrap(); // check proof locally @@ -925,7 +912,6 @@ mod tests { &executor, "test", &[], - None, ).unwrap(); // check that both results are correct -- GitLab From 77e681fb8b9c1e98ef1441bcc648e40ee36dac41 Mon Sep 17 00:00:00 2001 From: cheme Date: Tue, 26 Nov 2019 10:23:11 +0100 Subject: [PATCH 011/172] revert (#4204) --- Cargo.lock | 667 +++++++++++++--------------- primitives/state-machine/Cargo.toml | 2 +- primitives/trie/Cargo.toml | 4 +- primitives/trie/src/lib.rs | 2 +- primitives/trie/src/node_codec.rs | 148 +++--- test/utils/runtime/Cargo.toml | 2 +- 6 files changed, 366 insertions(+), 459 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0a8078053e..a5493f0739 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -47,7 +47,7 @@ dependencies = [ [[package]] name = "ahash" -version = "0.2.18" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "const-random 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -79,7 +79,7 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.22" +version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -95,7 +95,7 @@ dependencies = [ [[package]] name = "arc-swap" -version = "0.4.4" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -286,7 +286,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "bitvec" -version = "0.15.2" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -359,11 +359,6 @@ dependencies = [ "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "bs58" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "bs58" version = "0.3.0" @@ -449,11 +444,8 @@ dependencies = [ [[package]] name = "cast" -version = "0.2.3" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] name = "cc" @@ -496,7 +488,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -555,7 +547,7 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -564,7 +556,7 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "web-sys 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)", + "web-sys 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -626,7 +618,7 @@ dependencies = [ "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "thiserror 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "thiserror 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -682,8 +674,8 @@ dependencies = [ "cranelift-frontend 0.50.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "thiserror 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "wasmparser 0.39.3 (registry+https://github.com/rust-lang/crates.io-index)", + "thiserror 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmparser 0.39.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -700,19 +692,19 @@ version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", - "cast 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", "criterion-plot 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "csv 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand_xoshiro 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rayon 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rayon-core 1.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rayon 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rayon-core 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", @@ -726,17 +718,17 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", - "cast 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", "criterion-plot 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "csv 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_os 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand_xoshiro 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rayon 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rayon 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", @@ -750,7 +742,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cast 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -759,7 +751,7 @@ name = "criterion-plot" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cast 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -809,14 +801,6 @@ dependencies = [ "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "crossbeam-queue" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "crossbeam-utils 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "crossbeam-utils" version = "0.6.6" @@ -1093,7 +1077,7 @@ dependencies = [ "evm-gasometer 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "evm-runtime 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "primitive-types 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rlp 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "rlp 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "sha3 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1139,14 +1123,14 @@ name = "faerie" version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "anyhow 1.0.22 (registry+https://github.com/rust-lang/crates.io-index)", + "anyhow 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "string-interner 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "thiserror 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "thiserror 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1166,7 +1150,7 @@ dependencies = [ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", + "synstructure 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1203,8 +1187,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1261,7 +1245,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "fork-tree" version = "2.0.0" dependencies = [ - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1274,7 +1258,7 @@ dependencies = [ "pallet-balances 2.0.0", "pallet-indices 2.0.0", "pallet-transaction-payment 2.0.0", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", @@ -1286,7 +1270,7 @@ dependencies = [ name = "frame-metadata" version = "2.0.0" dependencies = [ - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 2.0.0", "substrate-primitives 2.0.0", @@ -1303,7 +1287,7 @@ dependencies = [ "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "once_cell 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "paste 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1356,7 +1340,7 @@ dependencies = [ "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-client-transports 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-primitives-storage 2.0.0", "substrate-rpc-api 2.0.0", @@ -1368,7 +1352,7 @@ name = "frame-support-test" version = "2.0.0" dependencies = [ "frame-support 2.0.0", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", @@ -1386,7 +1370,7 @@ dependencies = [ "criterion 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "frame-support 2.0.0", "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", @@ -1407,7 +1391,7 @@ dependencies = [ "jsonrpc-core-client 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-derive 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "substrate-client 2.0.0", @@ -1420,7 +1404,7 @@ dependencies = [ name = "frame-system-rpc-runtime-api" version = "2.0.0" dependencies = [ - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "sr-api 2.0.0", ] @@ -1431,7 +1415,7 @@ dependencies = [ "frame-support 2.0.0", "frame-system 2.0.0", "pallet-balances 2.0.0", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", @@ -1679,7 +1663,7 @@ dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1819,7 +1803,7 @@ name = "hashbrown" version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "ahash 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", + "ahash 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2044,7 +2028,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-normalization 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-normalization 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2054,7 +2038,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-normalization 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-normalization 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2062,7 +2046,7 @@ name = "impl-codec" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2070,7 +2054,7 @@ name = "impl-rlp" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rlp 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "rlp 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2147,10 +2131,10 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.32" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "wasm-bindgen 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2214,7 +2198,7 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "unicase 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "unicase 2.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2240,7 +2224,7 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "unicase 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "unicase 2.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2357,23 +2341,23 @@ dependencies = [ [[package]] name = "libp2p" -version = "0.13.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core-derive 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-deflate 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-dns 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-floodsub 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-identify 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-kad 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-mdns 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-identify 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-kad 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-mdns 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-mplex 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-noise 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-ping 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-ping 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-plaintext 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-secio 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-swarm 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2382,8 +2366,8 @@ dependencies = [ "libp2p-wasm-ext 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-websocket 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-yamux 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multihash 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multihash 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2394,7 +2378,7 @@ dependencies = [ [[package]] name = "libp2p-core" -version = "0.13.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "asn1_der 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2408,8 +2392,8 @@ dependencies = [ "libsecp256k1 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "multistream-select 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multihash 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multihash 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2443,7 +2427,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "flate2 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2453,7 +2437,7 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-dns-unofficial 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2468,7 +2452,7 @@ dependencies = [ "cuckoofilter 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-swarm 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2478,15 +2462,15 @@ dependencies = [ [[package]] name = "libp2p-identify" -version = "0.13.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-swarm 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2497,7 +2481,7 @@ dependencies = [ [[package]] name = "libp2p-kad" -version = "0.13.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2505,11 +2489,11 @@ dependencies = [ "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-swarm 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multihash 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multihash 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2524,17 +2508,17 @@ dependencies = [ [[package]] name = "libp2p-mdns" -version = "0.13.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "dns-parser 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-swarm 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2552,7 +2536,7 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2569,7 +2553,7 @@ dependencies = [ "curve25519-dalek 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2582,15 +2566,15 @@ dependencies = [ [[package]] name = "libp2p-ping" -version = "0.13.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-swarm 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2604,7 +2588,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "rw-stream-sink 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2622,9 +2606,9 @@ dependencies = [ "ctr 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "hmac 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2636,9 +2620,9 @@ dependencies = [ "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "twofish 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "untrusted 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-futures 0.3.27 (registry+https://github.com/rust-lang/crates.io-index)", - "web-sys 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)", + "web-sys 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2647,7 +2631,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2663,7 +2647,7 @@ dependencies = [ "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "get_if_addrs 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "ipnet 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2676,7 +2660,7 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2687,11 +2671,11 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-futures 0.3.27 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2702,7 +2686,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "rw-stream-sink 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "soketto 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2719,7 +2703,7 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "yamux 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2838,7 +2822,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", + "synstructure 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3001,7 +2985,7 @@ dependencies = [ "openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.9.52 (registry+https://github.com/rust-lang/crates.io-index)", "schannel 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", - "security-framework 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "security-framework 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "security-framework-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3041,10 +3025,10 @@ dependencies = [ "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb-memorydb 0.1.2 (git+https://github.com/paritytech/parity-common?rev=03a2ba08f47f4af4219280e660a1ea92cb8896bd)", - "libp2p 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "node-executor 2.0.0", "node-primitives 2.0.0", @@ -3057,7 +3041,7 @@ dependencies = [ "pallet-indices 2.0.0", "pallet-timestamp 2.0.0", "pallet-transaction-payment 2.0.0", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3095,7 +3079,7 @@ dependencies = [ "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", "transaction-factory 0.0.1", "vergen 3.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-futures 0.3.27 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3117,7 +3101,7 @@ dependencies = [ "pallet-timestamp 2.0.0", "pallet-transaction-payment 2.0.0", "pallet-treasury 2.0.0", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "substrate-executor 2.0.0", @@ -3203,7 +3187,7 @@ dependencies = [ "pallet-transaction-payment 2.0.0", "pallet-transaction-payment-rpc-runtime-api 2.0.0", "pallet-treasury 2.0.0", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3235,7 +3219,7 @@ dependencies = [ "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "node-template-runtime 2.0.0", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", @@ -3273,7 +3257,7 @@ dependencies = [ "pallet-sudo 2.0.0", "pallet-timestamp 2.0.0", "pallet-transaction-payment 2.0.0", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "sr-api 2.0.0", @@ -3309,7 +3293,7 @@ dependencies = [ "pallet-timestamp 2.0.0", "pallet-transaction-payment 2.0.0", "pallet-treasury 2.0.0", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "substrate-client 2.0.0", @@ -3346,7 +3330,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3355,7 +3339,7 @@ version = "0.1.41" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3366,12 +3350,12 @@ dependencies = [ "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "num-bigint 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "num-traits" -version = "0.2.9" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3470,7 +3454,7 @@ version = "2.0.0" dependencies = [ "frame-support 2.0.0", "frame-system 2.0.0", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", @@ -3487,7 +3471,7 @@ dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "pallet-session 2.0.0", "pallet-timestamp 2.0.0", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "sp-timestamp 2.0.0", @@ -3507,7 +3491,7 @@ dependencies = [ "frame-support 2.0.0", "frame-system 2.0.0", "pallet-session 2.0.0", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", @@ -3525,7 +3509,7 @@ dependencies = [ "frame-support 2.0.0", "frame-system 2.0.0", "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "sp-authorship 2.0.0", "sr-io 2.0.0", "sr-primitives 2.0.0", @@ -3544,7 +3528,7 @@ dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "pallet-session 2.0.0", "pallet-timestamp 2.0.0", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "sp-timestamp 2.0.0", @@ -3566,7 +3550,7 @@ dependencies = [ "frame-support 2.0.0", "frame-system 2.0.0", "pallet-transaction-payment 2.0.0", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", @@ -3583,7 +3567,7 @@ dependencies = [ "frame-system 2.0.0", "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "pallet-balances 2.0.0", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", @@ -3604,7 +3588,7 @@ dependencies = [ "pallet-balances 2.0.0", "pallet-randomness-collective-flip 2.0.0", "pallet-timestamp 2.0.0", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-wasm 0.40.3 (registry+https://github.com/rust-lang/crates.io-index)", "pwasm-utils 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3625,7 +3609,7 @@ dependencies = [ "jsonrpc-core-client 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-derive 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "pallet-contracts-rpc-runtime-api 2.0.0", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "substrate-client 2.0.0", @@ -3637,7 +3621,7 @@ dependencies = [ name = "pallet-contracts-rpc-runtime-api" version = "2.0.0" dependencies = [ - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "sr-api 2.0.0", "sr-primitives 2.0.0", @@ -3651,7 +3635,7 @@ dependencies = [ "frame-support 2.0.0", "frame-system 2.0.0", "pallet-balances 2.0.0", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", @@ -3668,7 +3652,7 @@ dependencies = [ "frame-system 2.0.0", "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "pallet-balances 2.0.0", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", @@ -3685,7 +3669,7 @@ dependencies = [ "frame-system 2.0.0", "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "pallet-balances 2.0.0", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", @@ -3703,9 +3687,9 @@ dependencies = [ "frame-system 2.0.0", "pallet-balances 2.0.0", "pallet-timestamp 2.0.0", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "primitive-types 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rlp 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "rlp 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "sha3 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", @@ -3721,7 +3705,7 @@ dependencies = [ "frame-support 2.0.0", "frame-system 2.0.0", "pallet-balances 2.0.0", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", @@ -3736,7 +3720,7 @@ dependencies = [ "frame-support 2.0.0", "frame-system 2.0.0", "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "sp-finality-tracker 2.0.0", "sr-io 2.0.0", @@ -3752,7 +3736,7 @@ version = "2.0.0" dependencies = [ "frame-support 2.0.0", "frame-system 2.0.0", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", @@ -3768,7 +3752,7 @@ dependencies = [ "frame-system 2.0.0", "pallet-finality-tracker 2.0.0", "pallet-session 2.0.0", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", @@ -3786,7 +3770,7 @@ dependencies = [ "frame-system 2.0.0", "pallet-authorship 0.1.0", "pallet-session 2.0.0", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", @@ -3802,7 +3786,7 @@ version = "2.0.0" dependencies = [ "frame-support 2.0.0", "frame-system 2.0.0", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "ref_thread_local 0.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3819,7 +3803,7 @@ version = "2.0.0" dependencies = [ "frame-support 2.0.0", "frame-system 2.0.0", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", @@ -3834,7 +3818,7 @@ dependencies = [ "frame-support 2.0.0", "frame-system 2.0.0", "pallet-balances 2.0.0", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", @@ -3849,7 +3833,7 @@ dependencies = [ "frame-support 2.0.0", "frame-system 2.0.0", "pallet-balances 2.0.0", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", @@ -3864,7 +3848,7 @@ version = "2.0.0" dependencies = [ "frame-support 2.0.0", "frame-system 2.0.0", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", @@ -3879,7 +3863,7 @@ dependencies = [ "frame-support 2.0.0", "frame-system 2.0.0", "pallet-balances 2.0.0", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", @@ -3896,7 +3880,7 @@ dependencies = [ "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "pallet-timestamp 2.0.0", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", @@ -3919,7 +3903,7 @@ dependencies = [ "pallet-session 2.0.0", "pallet-staking-reward-curve 2.0.0", "pallet-timestamp 2.0.0", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", @@ -3948,7 +3932,7 @@ version = "2.0.0" dependencies = [ "frame-support 2.0.0", "frame-system 2.0.0", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", @@ -3963,7 +3947,7 @@ dependencies = [ "frame-support 2.0.0", "frame-system 2.0.0", "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "sp-timestamp 2.0.0", "sr-io 2.0.0", @@ -3981,7 +3965,7 @@ dependencies = [ "frame-system 2.0.0", "pallet-balances 2.0.0", "pallet-transaction-payment-rpc-runtime-api 2.0.0", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3996,7 +3980,7 @@ dependencies = [ "jsonrpc-core-client 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-derive 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "pallet-transaction-payment-rpc-runtime-api 2.0.0", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "substrate-client 2.0.0", @@ -4009,7 +3993,7 @@ name = "pallet-transaction-payment-rpc-runtime-api" version = "2.0.0" dependencies = [ "frame-support 2.0.0", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", "sr-api 2.0.0", @@ -4024,7 +4008,7 @@ dependencies = [ "frame-support 2.0.0", "frame-system 2.0.0", "pallet-balances 2.0.0", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", @@ -4039,24 +4023,7 @@ source = "git+https://github.com/paritytech/parity-common?rev=03a2ba08f47f4af421 [[package]] name = "parity-multiaddr" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", - "bs58 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multihash 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "unsigned-varint 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "parity-multiaddr" -version = "0.6.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4064,7 +4031,7 @@ dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multihash 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multihash 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4073,21 +4040,7 @@ dependencies = [ [[package]] name = "parity-multihash" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "blake2 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "sha-1 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sha3 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", - "unsigned-varint 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "parity-multihash" -version = "0.2.0" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "blake2 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4101,25 +4054,25 @@ dependencies = [ [[package]] name = "parity-scale-codec" -version = "1.1.0" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "arrayvec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "bitvec 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", + "arrayvec 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "bitvec 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "byte-slice-cast 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec-derive 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec-derive 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "parity-scale-codec-derive" -version = "1.1.0" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4637,7 +4590,7 @@ dependencies = [ "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4696,22 +4649,22 @@ dependencies = [ [[package]] name = "rayon" -version = "1.2.1" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-deque 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "rayon-core 1.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rayon-core 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rayon-core" -version = "1.6.1" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-deque 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-queue 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4798,13 +4751,13 @@ dependencies = [ "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "spin 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "untrusted 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "web-sys 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)", + "web-sys 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rlp" -version = "0.4.4" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4978,7 +4931,7 @@ dependencies = [ [[package]] name = "security-framework" -version = "0.3.4" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5144,7 +5097,7 @@ name = "slog-scope" version = "4.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "arc-swap 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "arc-swap 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5212,7 +5165,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "sp-authorship" version = "2.0.0" dependencies = [ - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 2.0.0", "substrate-inherents 2.0.0", ] @@ -5221,7 +5174,7 @@ dependencies = [ name = "sp-finality-tracker" version = "2.0.0" dependencies = [ - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 2.0.0", "substrate-inherents 2.0.0", ] @@ -5231,7 +5184,7 @@ name = "sp-timestamp" version = "2.0.0" dependencies = [ "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "sr-api 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -5248,7 +5201,7 @@ name = "sr-api" version = "2.0.0" dependencies = [ "criterion 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "sr-api-proc-macro 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -5277,7 +5230,7 @@ dependencies = [ name = "sr-api-test" version = "2.0.0" dependencies = [ - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustversion 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-api 2.0.0", "sr-primitives 2.0.0", @@ -5294,8 +5247,8 @@ version = "2.0.0" dependencies = [ "criterion 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "integer-sqrt 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "primitive-types 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5310,7 +5263,7 @@ dependencies = [ "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "libsecp256k1 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 2.0.0", "substrate-externalities 2.0.0", "substrate-primitives 2.0.0", @@ -5325,7 +5278,7 @@ version = "2.0.0" dependencies = [ "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "paste 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5343,7 +5296,7 @@ name = "sr-sandbox" version = "2.0.0" dependencies = [ "assert_matches 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-std 2.0.0", "substrate-primitives 2.0.0", @@ -5355,7 +5308,7 @@ dependencies = [ name = "sr-staking-primitives" version = "2.0.0" dependencies = [ - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", ] @@ -5369,7 +5322,7 @@ name = "sr-version" version = "2.0.0" dependencies = [ "impl-serde 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -5463,7 +5416,7 @@ dependencies = [ "node-runtime 2.0.0", "pallet-balances 2.0.0", "pallet-transaction-payment 2.0.0", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", @@ -5476,7 +5429,7 @@ dependencies = [ name = "substrate-application-crypto" version = "2.0.0" dependencies = [ - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", @@ -5493,9 +5446,9 @@ dependencies = [ "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures-timer 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "prost 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "prost-build 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5515,7 +5468,7 @@ dependencies = [ name = "substrate-authority-discovery-primitives" version = "2.0.0" dependencies = [ - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "sr-api 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -5528,7 +5481,7 @@ version = "2.0.0" dependencies = [ "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "substrate-block-builder 2.0.0", "substrate-client 2.0.0", @@ -5556,7 +5509,7 @@ dependencies = [ name = "substrate-block-builder" version = "2.0.0" dependencies = [ - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "sr-api 2.0.0", "sr-primitives 2.0.0", "substrate-block-builder-runtime-api 2.0.0", @@ -5568,7 +5521,7 @@ dependencies = [ name = "substrate-block-builder-runtime-api" version = "2.0.0" dependencies = [ - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "sr-api 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -5652,7 +5605,7 @@ dependencies = [ "kvdb 0.1.1 (git+https://github.com/paritytech/parity-common?rev=03a2ba08f47f4af4219280e660a1ea92cb8896bd)", "kvdb-memorydb 0.1.2 (git+https://github.com/paritytech/parity-common?rev=03a2ba08f47f4af4219280e660a1ea92cb8896bd)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-api 2.0.0", "sr-primitives 2.0.0", @@ -5689,7 +5642,7 @@ dependencies = [ "kvdb 0.1.1 (git+https://github.com/paritytech/parity-common?rev=03a2ba08f47f4af4219280e660a1ea92cb8896bd)", "kvdb-memorydb 0.1.2 (git+https://github.com/paritytech/parity-common?rev=03a2ba08f47f4af4219280e660a1ea92cb8896bd)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-api 2.0.0", "sr-primitives 2.0.0", @@ -5724,7 +5677,7 @@ dependencies = [ "kvdb-rocksdb 0.1.6 (git+https://github.com/paritytech/parity-common?rev=03a2ba08f47f4af4219280e660a1ea92cb8896bd)", "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "quickcheck 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", @@ -5751,7 +5704,7 @@ dependencies = [ "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures-timer 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sp-timestamp 2.0.0", "sr-api 2.0.0", @@ -5782,7 +5735,7 @@ dependencies = [ name = "substrate-consensus-aura-primitives" version = "2.0.0" dependencies = [ - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "sp-timestamp 2.0.0", "sr-api 2.0.0", "sr-primitives 2.0.0", @@ -5805,8 +5758,8 @@ dependencies = [ "merlin 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "num-bigint 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "num-rational 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "pdqselect 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5843,7 +5796,7 @@ dependencies = [ name = "substrate-consensus-babe-primitives" version = "2.0.0" dependencies = [ - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "schnorrkel 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)", "sp-timestamp 2.0.0", "sr-api 2.0.0", @@ -5861,9 +5814,9 @@ dependencies = [ "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures-timer 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -5880,7 +5833,7 @@ dependencies = [ "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "sp-timestamp 2.0.0", "sr-primitives 2.0.0", "substrate-block-builder-runtime-api 2.0.0", @@ -5895,7 +5848,7 @@ dependencies = [ name = "substrate-consensus-pow-primitives" version = "2.0.0" dependencies = [ - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "sr-api 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -5909,7 +5862,7 @@ dependencies = [ "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures-timer 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "substrate-client-api 2.0.0", @@ -5957,7 +5910,7 @@ dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "libsecp256k1 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-wasm 0.40.3 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", @@ -6002,7 +5955,7 @@ dependencies = [ "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", @@ -6033,7 +5986,7 @@ dependencies = [ name = "substrate-finality-grandpa-primitives" version = "2.0.0" dependencies = [ - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "sr-api 2.0.0", "sr-primitives 2.0.0", @@ -6055,7 +6008,7 @@ name = "substrate-inherents" version = "2.0.0" dependencies = [ "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 2.0.0", "substrate-primitives 2.0.0", @@ -6102,12 +6055,12 @@ dependencies = [ "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures-timer 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "linked_hash_set 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "lru 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "quickcheck 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -6153,7 +6106,7 @@ dependencies = [ "hyper-rustls 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "sr-api 2.0.0", @@ -6191,7 +6144,7 @@ name = "substrate-peerset" version = "2.0.0" dependencies = [ "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", @@ -6226,8 +6179,8 @@ dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "libsecp256k1 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "primitive-types 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -6273,7 +6226,7 @@ dependencies = [ "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-pubsub 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", @@ -6307,7 +6260,7 @@ dependencies = [ "jsonrpc-derive 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-pubsub 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", @@ -6344,7 +6297,7 @@ name = "substrate-runtime-interface" version = "2.0.0" dependencies = [ "environmental 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "primitive-types 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-std 2.0.0", @@ -6363,7 +6316,7 @@ name = "substrate-runtime-interface-proc-macro" version = "2.0.0" dependencies = [ "Inflector 0.11.4 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -6419,8 +6372,8 @@ dependencies = [ "node-executor 2.0.0", "node-primitives 2.0.0", "node-runtime 2.0.0", - "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", @@ -6492,7 +6445,7 @@ version = "2.0.0" dependencies = [ "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-primitives 2.0.0", ] @@ -6504,15 +6457,15 @@ dependencies = [ "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-externalities 2.0.0", "substrate-panic-handler 2.0.0", "substrate-primitives 2.0.0", "substrate-trie 2.0.0", - "trie-db 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", + "trie-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "trie-root 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -6524,7 +6477,7 @@ dependencies = [ "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures-timer 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -6543,7 +6496,7 @@ version = "2.0.0" dependencies = [ "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "substrate-client 2.0.0", "substrate-client-api 2.0.0", @@ -6559,7 +6512,7 @@ dependencies = [ name = "substrate-test-primitives" version = "2.0.0" dependencies = [ - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "substrate-application-crypto 2.0.0", @@ -6579,7 +6532,7 @@ dependencies = [ "memory-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "pallet-babe 2.0.0", "pallet-timestamp 2.0.0", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "sr-api 2.0.0", "sr-io 2.0.0", @@ -6603,14 +6556,14 @@ dependencies = [ "substrate-transaction-pool-runtime-api 2.0.0", "substrate-trie 2.0.0", "substrate-wasm-builder-runner 1.0.4", - "trie-db 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", + "trie-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "substrate-test-runtime-client" version = "2.0.0" dependencies = [ - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "substrate-block-builder 2.0.0", "substrate-client 2.0.0", @@ -6641,7 +6594,7 @@ dependencies = [ "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", @@ -6656,7 +6609,7 @@ dependencies = [ "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-api 2.0.0", "sr-primitives 2.0.0", @@ -6684,11 +6637,11 @@ dependencies = [ "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "memory-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 2.0.0", "substrate-primitives 2.0.0", - "trie-bench 0.16.3 (registry+https://github.com/rust-lang/crates.io-index)", - "trie-db 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", + "trie-bench 0.16.2 (registry+https://github.com/rust-lang/crates.io-index)", + "trie-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "trie-root 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "trie-standardmap 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -6751,7 +6704,7 @@ dependencies = [ [[package]] name = "synstructure" -version = "0.12.3" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -6768,7 +6721,7 @@ dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "doc-comment 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "rayon 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rayon 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -6839,15 +6792,15 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.6" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "thiserror-impl 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "thiserror-impl 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "thiserror-impl" -version = "1.0.6" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -7236,7 +7189,7 @@ name = "transaction-factory" version = "0.0.1" dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "sr-api 2.0.0", "sr-primitives 2.0.0", "substrate-block-builder-runtime-api 2.0.0", @@ -7250,22 +7203,22 @@ dependencies = [ [[package]] name = "trie-bench" -version = "0.16.3" +version = "0.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "criterion 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hasher 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "memory-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "trie-db 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "trie-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "trie-root 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "trie-standardmap 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "trie-db" -version = "0.16.0" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "elastic-array 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -7359,10 +7312,10 @@ dependencies = [ [[package]] name = "unicase" -version = "2.6.0" +version = "2.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "version_check 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", + "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -7375,10 +7328,10 @@ dependencies = [ [[package]] name = "unicode-normalization" -version = "0.1.10" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -7527,16 +7480,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "wasm-bindgen" -version = "0.2.55" +version = "0.2.54" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-macro 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-macro 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.55" +version = "0.2.54" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bumpalo 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -7545,7 +7498,7 @@ dependencies = [ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-shared 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-shared 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -7555,49 +7508,49 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", - "web-sys 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "web-sys 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.55" +version = "0.2.54" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-macro-support 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-macro-support 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.55" +version = "0.2.54" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-backend 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-shared 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-backend 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-shared 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.55" +version = "0.2.54" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "wasm-bindgen-webidl" -version = "0.2.55" +version = "0.2.54" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "anyhow 1.0.22 (registry+https://github.com/rust-lang/crates.io-index)", + "anyhow 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)", "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-backend 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-backend 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", "weedle 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -7617,11 +7570,11 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)", "send_wrapper 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", - "web-sys 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "web-sys 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -7633,7 +7586,7 @@ dependencies = [ "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "memory_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "num-rational 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-wasm 0.41.0 (registry+https://github.com/rust-lang/crates.io-index)", "wasmi-validation 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -7656,7 +7609,7 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.39.3" +version = "0.39.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -7664,7 +7617,7 @@ name = "wasmtime-debug" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "anyhow 1.0.22 (registry+https://github.com/rust-lang/crates.io-index)", + "anyhow 1.0.19 (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)", @@ -7672,8 +7625,8 @@ dependencies = [ "gimli 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", "more-asserts 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "thiserror 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "wasmparser 0.39.3 (registry+https://github.com/rust-lang/crates.io-index)", + "thiserror 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmparser 0.39.2 (registry+https://github.com/rust-lang/crates.io-index)", "wasmtime-environ 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -7695,13 +7648,13 @@ dependencies = [ "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "more-asserts 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rayon 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rayon 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "spin 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "thiserror 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "thiserror 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", - "wasmparser 0.39.3 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmparser 0.39.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "zstd 0.5.1+zstd.1.4.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -7711,7 +7664,7 @@ name = "wasmtime-jit" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "anyhow 1.0.22 (registry+https://github.com/rust-lang/crates.io-index)", + "anyhow 1.0.19 (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-frontend 0.50.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -7719,8 +7672,8 @@ dependencies = [ "more-asserts 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "thiserror 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "wasmparser 0.39.3 (registry+https://github.com/rust-lang/crates.io-index)", + "thiserror 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmparser 0.39.2 (registry+https://github.com/rust-lang/crates.io-index)", "wasmtime-debug 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "wasmtime-environ 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "wasmtime-runtime 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -7742,21 +7695,21 @@ dependencies = [ "memoffset 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "more-asserts 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "thiserror 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "thiserror 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "wasmtime-environ 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "web-sys" -version = "0.3.32" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "anyhow 1.0.22 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)", + "anyhow 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)", "sourcefile 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-webidl 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-webidl 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -7970,13 +7923,13 @@ dependencies = [ "checksum aes-ctr 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d2e5b0458ea3beae0d1d8c0f3946564f8e10f90646cf78c06b4351052058d1ee" "checksum aes-soft 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cfd7e7ae3f9a1fb5c03b389fc6bb9a51400d0c13053f0dca698c832bfd893a0d" "checksum aesni 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f70a6b5f971e473091ab7cfb5ffac6cde81666c4556751d8d5620ead8abf100" -"checksum ahash 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "6f33b5018f120946c1dcf279194f238a9f146725593ead1c08fa47ff22b0b5d3" +"checksum ahash 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)" = "2f00e10d4814aa20900e7948174384f79f1317f24f0ba7494e735111653fc330" "checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d" "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" "checksum ansi_term 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" -"checksum anyhow 1.0.22 (registry+https://github.com/rust-lang/crates.io-index)" = "e19f23ab207147bbdbcdfa7f7e4ca5e84963d79bae3937074682177ab9150968" +"checksum anyhow 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)" = "57114fc2a6cc374bce195d3482057c846e706d252ff3604363449695684d7a0d" "checksum app_dirs 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e73a24bad9bd6a94d6395382a6c69fe071708ae4409f763c5475e14ee896313d" -"checksum arc-swap 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d7b8a9123b8027467bce0099fe556c628a53c8d83df0507084c31e9ba2e39aff" +"checksum arc-swap 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f1a1eca3195b729bbd64e292ef2f5fff6b1c28504fed762ce2b1013dde4d8e92" "checksum arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0d382e583f07208808f6b1249e60848879ba3543f57c32277bf52d69c2f0f0ee" "checksum arrayvec 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "cd9fd44efafa8690358b7408d253adf110036b88f55672a933f01d616ad9b1b9" "checksum arrayvec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8" @@ -7998,7 +7951,7 @@ dependencies = [ "checksum bindgen 0.49.2 (registry+https://github.com/rust-lang/crates.io-index)" = "846a1fba6535362a01487ef6b10f0275faa12e5c5d835c5c1c627aabc46ccbd6" "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" -"checksum bitvec 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a993f74b4c99c1908d156b8d2e0fb6277736b0ecbd833982fd1241d39b2766a6" +"checksum bitvec 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9633b74910e1870f50f5af189b08487195cdb83c0e27a71d6f64d5e09dd0538b" "checksum blake2 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "94cb07b0da6a73955f8fb85d24c466778e70cda767a568229b104f0264089330" "checksum blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6d530bdd2d52966a6d03b7a964add7ae1a288d25214066fd4b600f0f796400" "checksum blake2b_simd 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b83b7baab1e671718d78204225800d6b170e648188ac7dc992e9d6bddf87d0c0" @@ -8006,7 +7959,6 @@ dependencies = [ "checksum block-cipher-trait 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1c924d49bd09e7c06003acda26cd9742e796e34282ec6c1189404dee0c1f4774" "checksum block-padding 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" "checksum broadcaster 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "07a1446420a56f1030271649ba0da46d23239b3a68c73591cea5247f15a788a0" -"checksum bs58 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "c95ee6bba9d950218b6cc910cf62bc9e0a171d0f4537e3627b0f54d08549b188" "checksum bs58 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b170cd256a3f9fa6b9edae3e44a7dfdfc77e8124dbc3e2612d75f9c3e2396dae" "checksum bstr 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8d6c2c5b58ab920a4f5aeaaca34b4488074e8cc7596af94e6f8c6ff247c60245" "checksum build-helper 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bdce191bf3fa4995ce948c8c83b4640a1745457a149e73c6db75b4ffe36aad5f" @@ -8019,7 +7971,7 @@ dependencies = [ "checksum c2-chacha 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "214238caa1bf3a496ec3392968969cab8549f96ff30652c9e56885329315f6bb" "checksum c_linked_list 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4964518bd3b4a8190e832886cdc0da9794f12e8e6c1613a9e90ff331c4c8724b" "checksum cargo_metadata 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8d2d1617e838936c0d2323a65cc151e03ae19a7678dd24f72bccf27119b90a5d" -"checksum cast 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4b9434b9a5aa1450faa3f9cb14ea0e8c53bb5d2b3c1bfd1ab4fc03e9f33fbfb0" +"checksum cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "926013f2860c46252efceabb19f4a6b308197505082c609025aa6706c011d427" "checksum cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)" = "aa87058dce70a3ff5621797f1506cb837edd02ac4c0ae642b4542dce802908b8" "checksum cexpr 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "fce5b5fb86b0c57c20c834c1b412fd09c77c8a59b9473f86272709e78874cd1d" "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" @@ -8054,7 +8006,6 @@ dependencies = [ "checksum crossbeam-deque 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c3aa945d63861bfe624b55d153a39684da1e8c0bc8fba932f7ee3a3c16cea3ca" "checksum crossbeam-epoch 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5064ebdbf05ce3cb95e45c8b086f72263f4166b29b97f6baff7ef7fe047b55ac" "checksum crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c979cd6cfe72335896575c6b5688da489e420d36a27a0b9eb0c73db574b4a4b" -"checksum crossbeam-queue 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dfd6515864a82d2f877b42813d4553292c6659498c9a2aa31bab5a15243c2700" "checksum crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6" "checksum crossbeam-utils 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ce446db02cdc3165b94ae73111e570793400d0794e46125cc4056c81cbb039f4" "checksum crunchy 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" @@ -8177,7 +8128,7 @@ dependencies = [ "checksum itertools 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "87fa75c9dea7b07be3138c49abbb83fd4bea199b5cdc76f9804458edc5da0d6e" "checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" "checksum jobserver 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "f2b1d42ef453b30b7387e113da1c83ab1605d90c5b4e0eb8e96d016ed3b8c160" -"checksum js-sys 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)" = "1c840fdb2167497b0bd0db43d6dfe61e91637fa72f9d061f8bd17ddc44ba6414" +"checksum js-sys 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)" = "d8657b7ca06a6044ece477f6900bf7670f8b5fd0cce177a1d7094eef51e0adf4" "checksum jsonrpc-client-transports 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d389a085cb2184604dff060390cadb8cba1f063c7fd0ad710272c163c88b9f20" "checksum jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "34651edf3417637cc45e70ed0182ecfa9ced0b7e8131805fccf7400d989845ca" "checksum jsonrpc-core-client 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9dbaec1d57271ff952f24ca79d37d716cfd749c855b058d9aa5f053a6b8ae4ef" @@ -8198,18 +8149,18 @@ dependencies = [ "checksum lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" "checksum libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)" = "1a31a0627fdf1f6a39ec0dd577e101440b7db22672c0901fe00a9a6fbb5c24e8" "checksum libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753" -"checksum libp2p 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8fab3090cd3af0f0ff5e6c2cc0f6fe6607e9f9282680cf7cd3bdd4cda38ea722" -"checksum libp2p-core 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4a3def059145c191b6975e51784d5edc59e77e1ed5b25402fccac704dd7731f3" +"checksum libp2p 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9aa3d728b96c06763b2e919b4c99a334d698303c49489671b5ffe3a4b0fd4c9c" +"checksum libp2p-core 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "07759706a4cb4a90903c67d92cb9575acd8df90f583dfdc46d57afdeaead4c82" "checksum libp2p-core-derive 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1eeb2704ac14c60f31967e351ed928b848526a5fc6db4104520020665012826f" "checksum libp2p-deflate 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ef2b0bf5d37692ac90e2bffa436bec26c0b0def6c0cab7ea85ff67a353d58aaa" "checksum libp2p-dns 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e3175fb0fc9016c95c8517a297bbdb5fb6bfbd5665bacd2eb23495d1cbdeb033" "checksum libp2p-floodsub 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "92c11b95281e8cb87eb83c204b3ca4988fa665ed9351199b5bcc323056f49816" -"checksum libp2p-identify 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b4e4b0b4bcf410f77361b08335022d5705df34970dc1744ff58d4bb902309547" -"checksum libp2p-kad 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7fd25360fc12b23edb1ed13f73426325a38d32e0927a46fec26ddb6873d7644d" -"checksum libp2p-mdns 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c4c2e225a7dfc571c3ad77a0a5ecccc9537afe42d72289ac9f19768567cd677d" +"checksum libp2p-identify 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4eba6103329e9a1a2aa940671efe5600c758a295e61172139d7a900166da0017" +"checksum libp2p-kad 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "84ceb0faa267b96560ef883dc5bc6dddd9de1662e35a4070208623b391deefca" +"checksum libp2p-mdns 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ab1eec2958fc74883ed8ecb0c38324941a44195a58fea87fcfc2bd17da34d1fa" "checksum libp2p-mplex 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2fe584816d993dc0f893396521a3c93191d78a6f28a892b150baa714a12c3e5" "checksum libp2p-noise 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a30ec2640262a7ad6b1a8b28f6cd8281e620a6802f700adf9ff26e61487c333a" -"checksum libp2p-ping 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5b975ad345eb9bb29ddc64670664a50a8ab3e66e28357abb0f83cfc0a9ca2d78" +"checksum libp2p-ping 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e4e1682cdae649394d2793758ded2bfd4d9d440f807e3b4d9f70981f377aa28a" "checksum libp2p-plaintext 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7f4fe82189f5c20e8f0a11deaa04d492703c501cefd2428ad68f4f64aefab76f" "checksum libp2p-secio 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7ee09e259ceb7633a52fd17f187bedf94e3545b1746487beedbd3a0a07d99817" "checksum libp2p-swarm 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cd55bc9f5f9eac2bb1ff24ca3c8a655810a566ac38c7a6ee1f30aced5a62905b" @@ -8257,7 +8208,7 @@ dependencies = [ "checksum num-bigint 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f9c3f34cdd24f334cb265d9bf8bfa8a241920d026916785747a92f0e55541a1a" "checksum num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "b85e541ef8255f6cf42bbfe4ef361305c6c135d10919ecc26126c4e5ae94bc09" "checksum num-rational 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f2885278d5fe2adc2f75ced642d52d879bffaceb5a2e0b1d4309ffdfb239b454" -"checksum num-traits 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)" = "443c53b3c3531dfcbfa499d8893944db78474ad7a1d87fa2d94d1a2231693ac6" +"checksum num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "6ba9a427cfca2be13aa6f6403b0b7e7368fe982bfa16fccc450ce74c46cd9b32" "checksum num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "76dac5ed2a876980778b8b85f75a71b6cbf0db0b1232ee12f826bccb00d09d72" "checksum ole32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5d2c49021782e5233cd243168edfa8037574afed4eba4bbaf538b3d8d1789d8c" "checksum once_cell 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "532c29a261168a45ce28948f9537ddd7a5dd272cc513b3017b1e82a88f962c37" @@ -8270,12 +8221,10 @@ dependencies = [ "checksum output_vt100 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "53cdc5b785b7a58c5aad8216b3dfa114df64b0b06ae6e1501cef91df2fbdf8f9" "checksum owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "49a4b8ea2179e6a2e27411d3bca09ca6dd630821cf6894c6c7c8467a8ee7ef13" "checksum parity-bytes 0.1.1 (git+https://github.com/paritytech/parity-common?rev=03a2ba08f47f4af4219280e660a1ea92cb8896bd)" = "" -"checksum parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "045b3c7af871285146300da35b1932bb6e4639b66c7c98e85d06a32cbc4e8fa7" -"checksum parity-multiaddr 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "82afcb7461eae5d122543d8be1c57d306ed89af2d6ff7f8b0f5a3cc8f7e511bc" -"checksum parity-multihash 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "df3a17dc27848fd99e4f87eb0f8c9baba6ede0a6d555400c850ca45254ef4ce3" -"checksum parity-multihash 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c70cad855872dd51ce6679e823efb6434061a2c1782a1686438aabf506392cdd" -"checksum parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f9f9d99dae413590a5f37e43cd99b94d4e62a244160562899126913ea7108673" -"checksum parity-scale-codec-derive 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "492ac3aa93d6caa5d20e4e3e0b75d08e2dcd9dd8a50d19529548b6fe11b3f295" +"checksum parity-multiaddr 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7dbc379f41150dedda75cbbdb5b9beb2bf786a07e56c2c99ec89aeaaa894662c" +"checksum parity-multihash 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "340ed03f939e02e4cb71a5a127b5507ba4dab506e41a05f8f467e28d8ce529f4" +"checksum parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "001fbbb956d8593f321c7a784f64d16b2c99b2657823976eea729006ad2c3668" +"checksum parity-scale-codec-derive 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "42af752f59119656fa3cb31e8852ed24e895b968c0bdb41847da7f0cea6d155f" "checksum parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aa9777aa91b8ad9dd5aaa04a9b6bcb02c7f1deb952fca5a66034d5e63afc5c6f" "checksum parity-util-mem 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "570093f39f786beea92dcc09e45d8aae7841516ac19a50431953ac82a0e8f85c" "checksum parity-wasm 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "16ad52817c4d343339b3bc2e26861bd21478eda0b7509acf83505727000512ac" @@ -8341,8 +8290,8 @@ dependencies = [ "checksum rand_xoshiro 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "03b418169fb9c46533f326efd6eed2576699c44ca92d3052a066214a8d828929" "checksum rand_xoshiro 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0e18c91676f670f6f0312764c759405f13afb98d5d73819840cf72a518487bff" "checksum raw-cpuid 7.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4a349ca83373cfa5d6dbb66fd76e58b2cca08da71a5f6400de0a0a6a9bceeaf" -"checksum rayon 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "43739f8831493b276363637423d3622d4bd6394ab6f0a9c4a552e208aeb7fddd" -"checksum rayon-core 1.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f8bf17de6f23b05473c437eb958b9c850bfc8af0961fe17b4cc92d5a627b4791" +"checksum rayon 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "83a27732a533a1be0a0035a111fe76db89ad312f6f0347004c220c57f209a123" +"checksum rayon-core 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "98dcf634205083b17d0861252431eb2acbfb698ab7478a2d20de07954f47ec7b" "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" "checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" "checksum redox_users 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4ecedbca3bf205f8d8f5c2b44d83cd0690e39ee84b951ed649e9f1841132b66d" @@ -8353,7 +8302,7 @@ dependencies = [ "checksum region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "448e868c6e4cfddfa49b6a72c95906c04e8547465e9536575b95c70a4044f856" "checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" "checksum ring 0.16.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6747f8da1f2b1fabbee1aaa4eb8a11abf9adef0bf58a41cee45db5d59cecdfac" -"checksum rlp 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3a44d5ae8afcb238af8b75640907edc6c931efcfab2c854e81ed35fa080f84cd" +"checksum rlp 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8376a3f725ebb53f69263bbebb42196361fdfd551212409c8a721239aab4f09f" "checksum rocksdb 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "12069b106981c6103d3eab7dd1c86751482d0779a520b7c14954c8b586c1e643" "checksum rpassword 4.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f072d931f11a96546efd97642e1e75e807345aced86b947f9239102f262d0fcd" "checksum rust-argon2 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4ca4eaef519b494d1f2848fc602d18816fed808a981aedf4f1f00ceb7c9d32cf" @@ -8374,7 +8323,7 @@ dependencies = [ "checksum scroll 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "abb2332cb595d33f7edd5700f4cbf94892e680c7f0ae56adab58a35190b66cb1" "checksum scroll_derive 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f8584eea9b9ff42825b46faf46a8c24d2cff13ec152fa2a50df788b87c07ee28" "checksum sct 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e3042af939fca8c3453b7af0f1c66e533a15a86169e39de2657310ade8f98d3c" -"checksum security-framework 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8ef2429d7cefe5fd28bd1d2ed41c944547d4ff84776f5935b456da44593a16df" +"checksum security-framework 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "301c862a6d0ee78f124c5e1710205965fc5c553100dcda6d98f13ef87a763f04" "checksum security-framework-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e31493fc37615debb8c5090a7aeb4a9730bc61e77ab10b9af59f1a202284f895" "checksum semver 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a3186ec9e65071a2095434b1f5bb24838d4e8e130f584c790f6033c79943537" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" @@ -8416,7 +8365,7 @@ dependencies = [ "checksum subtle 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ab3af2eb31c42e8f0ccf43548232556c42737e01a96db6e1777b0be108e79799" "checksum syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)" = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" "checksum syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "661641ea2aa15845cddeb97dad000d22070bb5c1fb456b96c1cba883ec691e92" -"checksum synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545" +"checksum synstructure 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "575be94ccb86e8da37efb894a87e2b660be299b41d8ef347f9d6d79fbe61b1ba" "checksum sysinfo 0.9.6 (registry+https://github.com/rust-lang/crates.io-index)" = "6f4b2468c629cffba39c0a4425849ab3cdb03d9dfacba69684609aea04d08ff9" "checksum take_mut 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60" "checksum target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6f4c118a7a38378f305a9e111fcb2f7f838c0be324bfb31a77ea04f7f6e684b4" @@ -8426,8 +8375,8 @@ dependencies = [ "checksum termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "96d6098003bde162e4277c70665bd87c326f5a0c3f3fbfb285787fa482d54e6e" "checksum test-case 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a605baa797821796a751f4a959e1206079b24a4b7e1ed302b7d785d81a9276c9" "checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -"checksum thiserror 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "cc6b305ec0e323c7b6cfff6098a22516e0063d0bb7c3d88660a890217dca099a" -"checksum thiserror-impl 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "45ba8d810d9c48fc456b7ad54574e8bfb7c7918a57ad7a6e6a0985d7959e8597" +"checksum thiserror 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f9fb62ff737e573b1e677459bea6fd023cd5d6e868c3242d3cdf3ef2f0554824" +"checksum thiserror-impl 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "24069c0ba08aab54289d6a25f5036d94afc61e1538bbc42ae5501df141c9027d" "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" "checksum threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e2f0c90a5f3459330ac8bc0d2f879c693bb7a2f59689c1083fc4ef83834da865" "checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" @@ -8463,8 +8412,8 @@ dependencies = [ "checksum tracing-attributes 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a4263b12c3d3c403274493eb805966093b53214124796552d674ca1dd5d27c2b" "checksum tracing-core 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "bc913647c520c959b6d21e35ed8fa6984971deca9f0a2fcb8c51207e0c56af1d" "checksum traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079" -"checksum trie-bench 0.16.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d14da20d0549737c88299aee9e7b46098c30dd2af7cbca0518bdd420f3766191" -"checksum trie-db 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "784a9813d23f18bccab728ab039c39b8a87d0d6956dcdece39e92f5cffe5076e" +"checksum trie-bench 0.16.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3073600c543ed001319d7e092c46dfd8c245af1a218ec5c75eb01582660a2b3e" +"checksum trie-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d0b62d27e8aa1c07414549ac872480ac82380bab39e730242ab08d82d7cc098a" "checksum trie-root 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0b779f7c1c8fe9276365d9d5be5c4b5adeacf545117bb3f64c974305789c5c0b" "checksum trie-standardmap 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c3161ba520ab28cd8e6b68e1126f1009f6e335339d1a73b978139011703264c8" "checksum try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382" @@ -8475,9 +8424,9 @@ dependencies = [ "checksum typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6d2783fe2d6b8c1101136184eb41be8b1ad379e4657050b8aaff0c79ee7575f9" "checksum uint 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e75a4cdd7b87b28840dba13c483b9a88ee6bbf16ba5c951ee1ecfcf723078e0d" "checksum unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7f4765f83163b74f957c797ad9253caf97f103fb064d3999aea9568d09fc8a33" -"checksum unicase 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" +"checksum unicase 2.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2e2e6bd1e59e56598518beb94fd6db628ded570326f0a98c679a304bd9f00150" "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" -"checksum unicode-normalization 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "f0d98d53dfd9509a7c7f36fa8857b8f1fb699edbddd7dc2fb688db2ae5d0b2c1" +"checksum unicode-normalization 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "09c8070a9942f5e7cfccd93f490fdebd230ee3c3c9f107cb25bad5351ef671cf" "checksum unicode-segmentation 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" "checksum unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7007dbd421b92cc6e28410fe7362e2e0a2503394908f417b68ec8d1c364c4e20" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" @@ -8498,24 +8447,24 @@ dependencies = [ "checksum want 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b6395efa4784b027708f7451087e647ec73cc74f5d9bc2e418404248d679a230" "checksum want 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" "checksum wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b89c3ce4ce14bdc6fb6beaf9ec7928ca331de5df7e5ea278375642a2f478570d" -"checksum wasm-bindgen 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)" = "29ae32af33bacd663a9a28241abecf01f2be64e6a185c6139b04f18b6385c5f2" -"checksum wasm-bindgen-backend 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)" = "1845584bd3593442dc0de6e6d9f84454a59a057722f36f005e44665d6ab19d85" +"checksum wasm-bindgen 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)" = "c4568ae1b4e07ca907b1a4de41174eaa3e5be4066c024475586b7842725f69a9" +"checksum wasm-bindgen-backend 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)" = "5a00cfdce37367770062065fd3abb9278cbae86a0d918cacd0978a7acd51b481" "checksum wasm-bindgen-futures 0.3.27 (registry+https://github.com/rust-lang/crates.io-index)" = "83420b37346c311b9ed822af41ec2e82839bfe99867ec6c54e2da43b7538771c" -"checksum wasm-bindgen-macro 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)" = "87fcc747e6b73c93d22c947a6334644d22cfec5abd8b66238484dc2b0aeb9fe4" -"checksum wasm-bindgen-macro-support 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)" = "3dc4b3f2c4078c8c4a5f363b92fcf62604c5913cbd16c6ff5aaf0f74ec03f570" -"checksum wasm-bindgen-shared 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)" = "ca0b78d6d3be8589b95d1d49cdc0794728ca734adf36d7c9f07e6459508bb53d" -"checksum wasm-bindgen-webidl 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)" = "3126356474ceb717c8fb5549ae387c9fbf4872818454f4d87708bee997214bb5" +"checksum wasm-bindgen-macro 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)" = "7c568f4d3cf6d7c1d72b165daf778fb0d6e09a24f96ac14fc8c4f66a96e86b72" +"checksum wasm-bindgen-macro-support 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)" = "430d12539ae324d16097b399e9d07a6d5ce0173b2a61a2d02346ca7c198daffe" +"checksum wasm-bindgen-shared 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)" = "8ae7167f0bbffd7fac2b12da0fa1f834c1d84671a1ae3c93ac8bde2e97179c39" +"checksum wasm-bindgen-webidl 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)" = "3021567c515a746a64ad0b269d120d46e687c0c95702a4750623db935ae6b5e7" "checksum wasm-gc-api 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d0c32691b6c7e6c14e7f8fd55361a9088b507aa49620fcd06c09b3a1082186b9" "checksum wasm-timer 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "aa3e01d234bb71760e685cfafa5e2c96f8ad877c161a721646356651069e26ac" "checksum wasmi 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bf617d864d25af3587aa745529f7aaa541066c876d57e050c0d0c85c61c92aff" "checksum wasmi-validation 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6bc0356e3df56e639fc7f7d8a99741915531e27ed735d911ed83d7e1339c8188" "checksum wasmi-validation 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea78c597064ba73596099281e2f4cfc019075122a65cdda3205af94f0b264d93" -"checksum wasmparser 0.39.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c702914acda5feeeffbc29e4d953e5b9ce79d8b98da4dbf18a77086e116c5470" +"checksum wasmparser 0.39.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e5083b449454f7de0b15f131eee17de54b5a71dcb9adcf11df2b2f78fad0cd82" "checksum wasmtime-debug 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5008729ad53f75020f28fa0d682269335d6f0eac0b3ffafe31f185b2f33aca74" "checksum wasmtime-environ 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a3947662a0b8e05b1418465e64f16de9114f9fec18cc3f56e0ed5aa7737b89d0" "checksum wasmtime-jit 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6ed7922689461a7b5bd0d9c7350cac526c8a520a23b3ffd7f5b446ac51dfc51f" "checksum wasmtime-runtime 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "781d6bb8b346efaa3dc39746386957cd79b8d841e8652ed9b02d77bcf64fb514" -"checksum web-sys 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)" = "98405c0a2e722ed3db341b4c5b70eb9fe0021621f7350bab76df93b09b649bbf" +"checksum web-sys 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)" = "ce8e893e021539beb87de8f06e77bdb390a3ab0db4cfeb569c4e377b55ed20de" "checksum webpki 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d7e664e770ac0110e2384769bcc59ed19e329d81f555916a6e072714957b81b4" "checksum webpki-roots 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a262ae37dd9d60f60dd473d1158f9fbebf110ba7b6a5051c8160460f6043718b" "checksum webpki-roots 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)" = "91cd5736df7f12a964a5067a12c62fa38e1bd8080aff1f80bc29be7c80d19ab4" diff --git a/primitives/state-machine/Cargo.toml b/primitives/state-machine/Cargo.toml index 36557803e1..3f02056647 100644 --- a/primitives/state-machine/Cargo.toml +++ b/primitives/state-machine/Cargo.toml @@ -9,7 +9,7 @@ edition = "2018" log = "0.4.8" parking_lot = "0.9.0" hash-db = "0.15.2" -trie-db = "0.16.0" +trie-db = "0.15.2" trie-root = "0.15.2" trie = { package = "substrate-trie", path = "../trie" } primitives = { package = "substrate-primitives", path = "../core" } diff --git a/primitives/trie/Cargo.toml b/primitives/trie/Cargo.toml index a8e98bee0e..202c9066d0 100644 --- a/primitives/trie/Cargo.toml +++ b/primitives/trie/Cargo.toml @@ -15,13 +15,13 @@ harness = false codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } rstd = { package = "sr-std", path = "../sr-std", default-features = false } hash-db = { version = "0.15.2", default-features = false } -trie-db = { version = "0.16.0", default-features = false } +trie-db = { version = "0.15.2", default-features = false } trie-root = { version = "0.15.2", default-features = false } memory-db = { version = "0.15.2", default-features = false } primitives = { package = "substrate-primitives", path = "../core", default-features = false } [dev-dependencies] -trie-bench = "0.16.3" +trie-bench = "0.16.2" trie-standardmap = "0.15.2" criterion = "0.2.11" hex-literal = "0.2.1" diff --git a/primitives/trie/src/lib.rs b/primitives/trie/src/lib.rs index de056cace1..eab05bab28 100644 --- a/primitives/trie/src/lib.rs +++ b/primitives/trie/src/lib.rs @@ -323,7 +323,7 @@ mod tests { type Layout = super::Layout; fn hashed_null_node() -> TrieHash { - ::hashed_null_node() + >::hashed_null_node() } fn check_equivalent(input: &Vec<(&[u8], &[u8])>) { diff --git a/primitives/trie/src/node_codec.rs b/primitives/trie/src/node_codec.rs index e31ce8cc91..03cbdfce52 100644 --- a/primitives/trie/src/node_codec.rs +++ b/primitives/trie/src/node_codec.rs @@ -17,147 +17,105 @@ //! `NodeCodec` implementation for Substrate's trie format. use rstd::marker::PhantomData; -use rstd::ops::Range; use rstd::vec::Vec; use rstd::borrow::Borrow; -use codec::{Encode, Decode, Input, Compact}; +use codec::{Encode, Decode, Compact}; use hash_db::Hasher; -use trie_db::{self, node::{NibbleSlicePlan, NodePlan, NodeHandlePlan}, ChildReference, +use trie_db::{self, NibbleSlice, node::Node, ChildReference, nibble_ops, Partial, NodeCodec as NodeCodecT}; use crate::error::Error; use crate::trie_constants; use super::{node_header::{NodeHeader, NodeKind}}; -/// Helper struct for trie node decoder. This implements `codec::Input` on a byte slice, while -/// tracking the absolute position. This is similar to `std::io::Cursor` but does not implement -/// `Read` and `io` is not in `rstd`. -struct ByteSliceInput<'a> { - data: &'a [u8], - offset: usize, -} - -impl<'a> ByteSliceInput<'a> { - fn new(data: &'a [u8]) -> Self { - ByteSliceInput { - data, - offset: 0, - } - } - - fn take(&mut self, count: usize) -> Result, codec::Error> { - if self.offset + count > self.data.len() { - return Err("out of data".into()); - } - - let range = self.offset..(self.offset + count); - self.offset += count; - Ok(range) - } -} - -impl<'a> Input for ByteSliceInput<'a> { - fn remaining_len(&mut self) -> Result, codec::Error> { - let remaining = if self.offset <= self.data.len() { - Some(self.data.len() - self.offset) - } else { - None - }; - Ok(remaining) - } - - fn read(&mut self, into: &mut [u8]) -> Result<(), codec::Error> { - let range = self.take(into.len())?; - into.copy_from_slice(&self.data[range]); - Ok(()) - } - - fn read_byte(&mut self) -> Result { - if self.offset + 1 > self.data.len() { - return Err("out of data".into()); - } - - let byte = self.data[self.offset]; - self.offset += 1; - Ok(byte) +fn take<'a>(input: &mut &'a[u8], count: usize) -> Option<&'a[u8]> { + if input.len() < count { + return None } + let r = &(*input)[..count]; + *input = &(*input)[count..]; + Some(r) } /// Concrete implementation of a `NodeCodec` with Parity Codec encoding, generic over the `Hasher` #[derive(Default, Clone)] pub struct NodeCodec(PhantomData); -impl NodeCodecT for NodeCodec { +impl NodeCodecT for NodeCodec { type Error = Error; - type HashOut = H::Out; fn hashed_null_node() -> ::Out { - H::hash(::empty_node()) + H::hash(>::empty_node()) } - fn decode_plan(data: &[u8]) -> rstd::result::Result { - let mut input = ByteSliceInput::new(data); - match NodeHeader::decode(&mut input)? { - NodeHeader::Null => Ok(NodePlan::Empty), + fn decode(data: &[u8]) -> rstd::result::Result { + let input = &mut &*data; + let head = NodeHeader::decode(input)?; + match head { + NodeHeader::Null => Ok(Node::Empty), NodeHeader::Branch(has_value, nibble_count) => { let padding = nibble_count % nibble_ops::NIBBLE_PER_BYTE != 0; // check that the padding is valid (if any) - if padding && nibble_ops::pad_left(data[input.offset]) != 0 { + if padding && nibble_ops::pad_left(input[0]) != 0 { return Err(Error::BadFormat); } - let partial = input.take( + let nibble_data = take( + input, (nibble_count + (nibble_ops::NIBBLE_PER_BYTE - 1)) / nibble_ops::NIBBLE_PER_BYTE, - )?; - let partial_padding = nibble_ops::number_padding(nibble_count); - let bitmap_range = input.take(BITMAP_LENGTH)?; - let bitmap = Bitmap::decode(&data[bitmap_range])?; + ).ok_or(Error::BadFormat)?; + let nibble_slice = NibbleSlice::new_offset( + nibble_data, + nibble_ops::number_padding(nibble_count), + ); + let bitmap_slice = take(input, BITMAP_LENGTH).ok_or(Error::BadFormat)?; + let bitmap = Bitmap::decode(&bitmap_slice[..])?; let value = if has_value { - let count = >::decode(&mut input)?.0 as usize; - Some(input.take(count)?) + let count = >::decode(input)?.0 as usize; + Some(take(input, count).ok_or(Error::BadFormat)?) } else { None }; - let mut children = [ - None, None, None, None, None, None, None, None, - None, None, None, None, None, None, None, None, - ]; + let mut children = [None; 16]; + for i in 0..nibble_ops::NIBBLE_LENGTH { if bitmap.value_at(i) { - let count = >::decode(&mut input)?.0 as usize; - let range = input.take(count)?; - children[i] = Some(if count == H::LENGTH { - NodeHandlePlan::Hash(range) - } else { - NodeHandlePlan::Inline(range) - }); + let count = >::decode(input)?.0 as usize; + children[i] = Some(take(input, count).ok_or(Error::BadFormat)?); } } - Ok(NodePlan::NibbledBranch { - partial: NibbleSlicePlan::new(partial, partial_padding), - value, - children, - }) + Ok(Node::NibbledBranch(nibble_slice, children, value)) } NodeHeader::Leaf(nibble_count) => { let padding = nibble_count % nibble_ops::NIBBLE_PER_BYTE != 0; // check that the padding is valid (if any) - if padding && nibble_ops::pad_left(data[input.offset]) != 0 { + if padding && nibble_ops::pad_left(input[0]) != 0 { return Err(Error::BadFormat); } - let partial = input.take( + let nibble_data = take( + input, (nibble_count + (nibble_ops::NIBBLE_PER_BYTE - 1)) / nibble_ops::NIBBLE_PER_BYTE, - )?; - let partial_padding = nibble_ops::number_padding(nibble_count); - let count = >::decode(&mut input)?.0 as usize; - Ok(NodePlan::Leaf { - partial: NibbleSlicePlan::new(partial, partial_padding), - value: input.take(count)?, - }) + ).ok_or(Error::BadFormat)?; + let nibble_slice = NibbleSlice::new_offset( + nibble_data, + nibble_ops::number_padding(nibble_count), + ); + let count = >::decode(input)?.0 as usize; + Ok(Node::Leaf(nibble_slice, take(input, count).ok_or(Error::BadFormat)?)) } } } + fn try_decode_hash(data: &[u8]) -> Option<::Out> { + if data.len() == H::LENGTH { + let mut r = ::Out::default(); + r.as_mut().copy_from_slice(data); + Some(r) + } else { + None + } + } + fn is_empty_node(data: &[u8]) -> bool { - data == ::empty_node() + data == >::empty_node() } fn empty_node() -> &'static [u8] { diff --git a/test/utils/runtime/Cargo.toml b/test/utils/runtime/Cargo.toml index f89524d284..b32081a863 100644 --- a/test/utils/runtime/Cargo.toml +++ b/test/utils/runtime/Cargo.toml @@ -35,7 +35,7 @@ pallet-timestamp = { path = "../../../frame/timestamp", default-features = false substrate-client = { path = "../../../client", optional = true } substrate-trie = { path = "../../../primitives/trie", default-features = false } transaction-pool-api = { package = "substrate-transaction-pool-runtime-api", path = "../../../primitives/transaction-pool/runtime-api", default-features = false } -trie-db = { version = "0.16.0", default-features = false } +trie-db = { version = "0.15.2", default-features = false } [dev-dependencies] substrate-executor = { path = "../../../client/executor" } -- GitLab From 2b716b5a96e2806a94200434c0f54a10114a126c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Tue, 26 Nov 2019 13:25:43 +0100 Subject: [PATCH 012/172] Give `state_col` 90% of memory budget and fix other col calculation (#4208) * Give `state_col` 90% of memory budget and fix other col calculation * Set default db cache size to 1024 --- client/cli/src/lib.rs | 2 +- client/cli/src/params.rs | 4 ++-- client/db/src/utils.rs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/client/cli/src/lib.rs b/client/cli/src/lib.rs index 5d67f42c63..203ca04951 100644 --- a/client/cli/src/lib.rs +++ b/client/cli/src/lib.rs @@ -733,7 +733,7 @@ where config.database = DatabaseConfig::Path { path: config.in_chain_config_dir(DEFAULT_DB_CONFIG_PATH).expect("We provided a base_path."), - cache_size: cli.database_cache_size, + cache_size: Some(cli.database_cache_size), }; config.state_cache_size = cli.state_cache_size; diff --git a/client/cli/src/params.rs b/client/cli/src/params.rs index 15ec2fa113..1324d3419f 100644 --- a/client/cli/src/params.rs +++ b/client/cli/src/params.rs @@ -385,8 +385,8 @@ pub struct RunCmd { pub light: bool, /// Limit the memory the database cache can use. - #[structopt(long = "db-cache", value_name = "MiB")] - pub database_cache_size: Option, + #[structopt(long = "db-cache", value_name = "MiB", default_value = "1024")] + pub database_cache_size: u32, /// Specify the state cache size. #[structopt(long = "state-cache-size", value_name = "Bytes", default_value = "67108864")] diff --git a/client/db/src/utils.rs b/client/db/src/utils.rs index 6b636c0c77..516f3d11b0 100644 --- a/client/db/src/utils.rs +++ b/client/db/src/utils.rs @@ -215,8 +215,8 @@ pub fn open_database( let mut db_config = DatabaseConfig::with_columns(Some(NUM_COLUMNS)); if let Some(cache_size) = cache_size { - let state_col_budget = (*cache_size as f64 * 0.7) as usize; - let other_col_budget = cache_size - state_col_budget; + let state_col_budget = (*cache_size as f64 * 0.9) as usize; + let other_col_budget = (cache_size - state_col_budget) / (NUM_COLUMNS as usize - 1); let mut memory_budget = std::collections::HashMap::new(); for i in 0..NUM_COLUMNS { -- GitLab From 6e9c6759130d04c72389cf3fba96d8bcf95caef8 Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Tue, 26 Nov 2019 13:27:15 +0100 Subject: [PATCH 013/172] Introduce efficient Hash-based RNG streamer (#4169) * Introduce efficient Hash-based RNG streamer * Loop in the case of being in bias space. * Fix tests * Minor cleanup --- primitives/sr-primitives/src/lib.rs | 3 + .../src/random_number_generator.rs | 103 ++++++++++++++++++ primitives/sr-primitives/src/traits.rs | 9 +- 3 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 primitives/sr-primitives/src/random_number_generator.rs diff --git a/primitives/sr-primitives/src/lib.rs b/primitives/sr-primitives/src/lib.rs index f98a06fbef..1bbf5ad55a 100644 --- a/primitives/sr-primitives/src/lib.rs +++ b/primitives/sr-primitives/src/lib.rs @@ -52,6 +52,7 @@ pub mod offchain; pub mod testing; pub mod traits; pub mod transaction_validity; +pub mod random_number_generator; /// Re-export these since they're only "kind of" generic. pub use generic::{DigestItem, Digest}; @@ -70,6 +71,8 @@ pub use arithmetic::helpers_128bit; /// Re-export big_uint stuff. pub use arithmetic::biguint; +pub use random_number_generator::RandomNumberGenerator; + /// An abstraction over justification for a block's validity under a consensus algorithm. /// /// Essentially a finality proof. The exact formulation will vary between consensus diff --git a/primitives/sr-primitives/src/random_number_generator.rs b/primitives/sr-primitives/src/random_number_generator.rs new file mode 100644 index 0000000000..cb9acfa028 --- /dev/null +++ b/primitives/sr-primitives/src/random_number_generator.rs @@ -0,0 +1,103 @@ +// Copyright 2017-2019 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Substrate is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Substrate. If not, see . + +//! A simple pseudo random number generator that allows a stream of random numbers to be efficiently +//! created from a single initial seed hash. + +use codec::{Encode, Decode}; +use crate::traits::{Hash, TrailingZeroInput}; + +/// Pseudo-random number streamer. This retains the state of the random number stream. It's as +/// secure as the combination of the seed with which it is constructed and the hash function it uses +/// to cycle elements. +/// +/// It can be saved and later reloaded using the Codec traits. +/// +/// Example: +/// ``` +/// use sr_primitives::traits::{Hash, BlakeTwo256}; +/// use sr_primitives::RandomNumberGenerator; +/// let random_seed = BlakeTwo256::hash(b"Sixty-nine"); +/// let mut rng = >::new(random_seed); +/// assert_eq!(rng.pick_u32(100), 59); +/// assert_eq!(rng.pick_item(&[1, 2, 3]), Some(&1)); +/// ``` +/// +/// This can use any cryptographic `Hash` function as the means of entropy-extension, and avoids +/// needless extensions of entropy. +/// +/// If you're persisting it over blocks, be aware that the sequence will start to repeat. This won't +/// be a practical issue unless you're using tiny hash types (e.g. 64-bit) and pulling hundred of +/// megabytes of data from it. +#[derive(Encode, Decode)] +pub struct RandomNumberGenerator { + current: Hashing::Output, + offset: u32, +} + +impl RandomNumberGenerator { + /// A new source of random data. + pub fn new(seed: Hashing::Output) -> Self { + Self { + current: seed, + offset: 0, + } + } + + fn offset(&self) -> usize { self.offset as usize } + + /// Returns a number at least zero, at most `max`. + pub fn pick_u32(&mut self, max: u32) -> u32 { + let needed = (4 - max.leading_zeros() / 8) as usize; + let top = ((1 << (needed as u64 * 8)) / ((max + 1) as u64) * ((max + 1) as u64) - 1) as u32; + loop { + if self.offset() + needed > self.current.as_ref().len() { + // rehash + self.current = Hashing::hash(self.current.as_ref()); + self.offset = 0; + } + let data = &self.current.as_ref()[self.offset()..self.offset() + needed]; + self.offset += needed as u32; + let raw = u32::decode(&mut TrailingZeroInput::new(data)).unwrap_or(0); + if raw <= top { + break if max < u32::max_value() { + raw % (max + 1) + } else { + raw + } + } + } + } + + /// Returns a number at least zero, at most `max`. + /// + /// This returns a `usize`, but internally it only uses `u32` so avoid consensus problems. + pub fn pick_usize(&mut self, max: usize) -> usize { + self.pick_u32(max as u32) as usize + } + + /// Pick a random element from an array of `items`. + /// + /// This is guaranteed to return `Some` except in the case that the given array `items` is + /// empty. + pub fn pick_item<'a, T>(&mut self, items: &'a [T]) -> Option<&'a T> { + if items.is_empty() { + None + } else { + Some(&items[self.pick_usize(items.len() - 1)]) + } + } +} diff --git a/primitives/sr-primitives/src/traits.rs b/primitives/sr-primitives/src/traits.rs index 2b2bed53a4..84ac039a1d 100644 --- a/primitives/sr-primitives/src/traits.rs +++ b/primitives/sr-primitives/src/traits.rs @@ -1026,7 +1026,14 @@ pub trait OpaqueKeys: Clone { } /// Input that adds infinite number of zero after wrapped input. -struct TrailingZeroInput<'a>(&'a [u8]); +pub struct TrailingZeroInput<'a>(&'a [u8]); + +impl<'a> TrailingZeroInput<'a> { + /// Create a new instance from the given byte array. + pub fn new(data: &'a [u8]) -> Self { + Self(data) + } +} impl<'a> codec::Input for TrailingZeroInput<'a> { fn remaining_len(&mut self) -> Result, codec::Error> { -- GitLab From 413c6e95f4f39fb1abdacfbee68727f098e6b656 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Tue, 26 Nov 2019 18:07:31 +0100 Subject: [PATCH 014/172] Allow batch query for block hash. (#4210) --- Cargo.lock | 1 + client/rpc/api/src/chain/mod.rs | 19 +++++++-- client/rpc/src/chain/mod.rs | 19 +++++++-- client/rpc/src/chain/tests.rs | 28 +++++++----- primitives/rpc/Cargo.toml | 3 ++ primitives/rpc/src/lib.rs | 17 ++++++++ primitives/rpc/src/list.rs | 75 +++++++++++++++++++++++++++++++++ primitives/rpc/src/number.rs | 17 +++++++- 8 files changed, 159 insertions(+), 20 deletions(-) create mode 100644 primitives/rpc/src/list.rs diff --git a/Cargo.lock b/Cargo.lock index a5493f0739..7bf2fcba01 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6275,6 +6275,7 @@ name = "substrate-rpc-primitives" version = "2.0.0" dependencies = [ "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-primitives 2.0.0", ] diff --git a/client/rpc/api/src/chain/mod.rs b/client/rpc/api/src/chain/mod.rs index 73f4388236..fd7576f988 100644 --- a/client/rpc/api/src/chain/mod.rs +++ b/client/rpc/api/src/chain/mod.rs @@ -22,7 +22,7 @@ use jsonrpc_core::Result as RpcResult; use jsonrpc_core::futures::Future; use jsonrpc_derive::rpc; use jsonrpc_pubsub::{typed::Subscriber, SubscriptionId}; -use rpc_primitives::number; +use rpc_primitives::{number::NumberOrHex, list::ListOrValue}; use self::error::{FutureResult, Result}; pub use self::gen_client::Client as ChainClient; @@ -45,7 +45,10 @@ pub trait ChainApi { /// /// By default returns latest block hash. #[rpc(name = "chain_getBlockHash", alias("chain_getHead"))] - fn block_hash(&self, hash: Option>) -> Result>; + fn block_hash( + &self, + hash: Option>>, + ) -> Result>>; /// Get hash of the last finalized block in the canon chain. #[rpc(name = "chain_getFinalizedHead", alias("chain_getFinalisedHead"))] @@ -67,7 +70,11 @@ pub trait ChainApi { name = "chain_unsubscribeNewHeads", alias("unsubscribe_newHead", "chain_unsubscribeNewHead") )] - fn unsubscribe_new_heads(&self, metadata: Option, id: SubscriptionId) -> RpcResult; + fn unsubscribe_new_heads( + &self, + metadata: Option, + id: SubscriptionId, + ) -> RpcResult; /// New head subscription #[pubsub( @@ -85,5 +92,9 @@ pub trait ChainApi { name = "chain_unsubscribeFinalizedHeads", alias("chain_unsubscribeFinalisedHeads") )] - fn unsubscribe_finalized_heads(&self, metadata: Option, id: SubscriptionId) -> RpcResult; + fn unsubscribe_finalized_heads( + &self, + metadata: Option, + id: SubscriptionId, + ) -> RpcResult; } diff --git a/client/rpc/src/chain/mod.rs b/client/rpc/src/chain/mod.rs index 20806c6219..c420360576 100644 --- a/client/rpc/src/chain/mod.rs +++ b/client/rpc/src/chain/mod.rs @@ -37,7 +37,7 @@ use client::{ }; use jsonrpc_pubsub::{typed::Subscriber, SubscriptionId}; use primitives::{H256, Blake2Hasher}; -use rpc_primitives::number; +use rpc_primitives::{number::NumberOrHex, list::ListOrValue}; use sr_primitives::{ generic::{BlockId, SignedBlock}, traits::{Block as BlockT, Header, NumberFor}, @@ -79,7 +79,7 @@ trait ChainBackend: Send + Sync + 'static /// By default returns latest block hash. fn block_hash( &self, - number: Option>>, + number: Option>>, ) -> Result> { Ok(match number { None => Some(self.client().info().chain.best_hash), @@ -211,8 +211,19 @@ impl ChainApi, Block::Hash, Block::Header, Sig self.backend.block(hash) } - fn block_hash(&self, number: Option>>) -> Result> { - self.backend.block_hash(number) + fn block_hash( + &self, + number: Option>>> + ) -> Result>> { + match number { + None => self.backend.block_hash(None).map(ListOrValue::Value), + Some(ListOrValue::Value(number)) => self.backend.block_hash(Some(number)).map(ListOrValue::Value), + Some(ListOrValue::List(list)) => Ok(ListOrValue::List(list + .into_iter() + .map(|number| self.backend.block_hash(Some(number))) + .collect::>()? + )) + } } fn finalized_head(&self) -> Result { diff --git a/client/rpc/src/chain/tests.rs b/client/rpc/src/chain/tests.rs index 8b46befee6..4f7c1f65cf 100644 --- a/client/rpc/src/chain/tests.rs +++ b/client/rpc/src/chain/tests.rs @@ -21,6 +21,7 @@ use test_client::{ consensus::BlockOrigin, runtime::{H256, Block, Header}, }; +use rpc_primitives::list::ListOrValue; #[test] fn should_return_header() { @@ -120,34 +121,39 @@ fn should_return_block_hash() { assert_matches!( api.block_hash(None.into()), - Ok(Some(ref x)) if x == &client.genesis_hash() + Ok(ListOrValue::Value(Some(ref x))) if x == &client.genesis_hash() ); assert_matches!( - api.block_hash(Some(0u64.into()).into()), - Ok(Some(ref x)) if x == &client.genesis_hash() + api.block_hash(Some(ListOrValue::Value(0u64.into())).into()), + Ok(ListOrValue::Value(Some(ref x))) if x == &client.genesis_hash() ); assert_matches!( - api.block_hash(Some(1u64.into()).into()), - Ok(None) + api.block_hash(Some(ListOrValue::Value(1u64.into())).into()), + Ok(ListOrValue::Value(None)) ); let block = client.new_block(Default::default()).unwrap().bake().unwrap(); client.import(BlockOrigin::Own, block.clone()).unwrap(); assert_matches!( - api.block_hash(Some(0u64.into()).into()), - Ok(Some(ref x)) if x == &client.genesis_hash() + api.block_hash(Some(ListOrValue::Value(0u64.into())).into()), + Ok(ListOrValue::Value(Some(ref x))) if x == &client.genesis_hash() + ); + assert_matches!( + api.block_hash(Some(ListOrValue::Value(1u64.into())).into()), + Ok(ListOrValue::Value(Some(ref x))) if x == &block.hash() ); assert_matches!( - api.block_hash(Some(1u64.into()).into()), - Ok(Some(ref x)) if x == &block.hash() + api.block_hash(Some(ListOrValue::Value(primitives::U256::from(1u64).into())).into()), + Ok(ListOrValue::Value(Some(ref x))) if x == &block.hash() ); + assert_matches!( - api.block_hash(Some(::primitives::U256::from(1u64).into()).into()), - Ok(Some(ref x)) if x == &block.hash() + api.block_hash(Some(vec![0u64.into(), 1.into(), 2.into()].into())), + Ok(ListOrValue::List(list)) if list == &[client.genesis_hash().into(), block.hash().into(), None] ); } diff --git a/primitives/rpc/Cargo.toml b/primitives/rpc/Cargo.toml index 5216882b1a..eb4cd5a723 100644 --- a/primitives/rpc/Cargo.toml +++ b/primitives/rpc/Cargo.toml @@ -7,3 +7,6 @@ edition = "2018" [dependencies] serde = { version = "1.0.101", features = ["derive"] } primitives = { package = "substrate-primitives", path = "../core" } + +[dev-dependencies] +serde_json = "1.0.41" diff --git a/primitives/rpc/src/lib.rs b/primitives/rpc/src/lib.rs index 667b1b1b4b..74007bea8e 100644 --- a/primitives/rpc/src/lib.rs +++ b/primitives/rpc/src/lib.rs @@ -19,3 +19,20 @@ #![warn(missing_docs)] pub mod number; +pub mod list; + +/// A util function to assert the result of serialization and deserialization is the same. +#[cfg(test)] +pub(crate) fn assert_deser(s: &str, expected: T) where + T: std::fmt::Debug + serde::ser::Serialize + serde::de::DeserializeOwned + PartialEq +{ + assert_eq!( + serde_json::from_str::(s).unwrap(), + expected + ); + assert_eq!( + serde_json::to_string(&expected).unwrap(), + s + ); +} + diff --git a/primitives/rpc/src/list.rs b/primitives/rpc/src/list.rs new file mode 100644 index 0000000000..5cd7b18705 --- /dev/null +++ b/primitives/rpc/src/list.rs @@ -0,0 +1,75 @@ +// Copyright 2019 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Substrate is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Substrate. If not, see . + +//! RPC a lenient list or value type. + +use serde::{Serialize, Deserialize}; + +/// RPC list or value wrapper. +/// +/// For some RPCs it's convenient to call them with either +/// a single value or a whole list of values to get a proper response. +/// In theory you could do a batch query, but it's: +/// 1. Less convient in client libraries +/// 2. If the response value is small, the protocol overhead might be dominant. +/// +/// Also it's nice to be able to maintain backward compatibility for methods that +/// were initially taking a value and now we want to expand them to take a list. +#[derive(Serialize, Deserialize, Debug, PartialEq)] +#[serde(untagged)] +pub enum ListOrValue { + /// A list of values of given type. + List(Vec), + /// A single value of given type. + Value(T), +} + +impl ListOrValue { + /// Map every contained value using function `F`. + /// + /// This allows to easily convert all values in any of the variants. + pub fn map X, X>(self, f: F) -> ListOrValue { + match self { + ListOrValue::List(v) => ListOrValue::List(v.into_iter().map(f).collect()), + ListOrValue::Value(v) => ListOrValue::Value(f(v)), + } + } +} + +impl From for ListOrValue { + fn from(n: T) -> Self { + ListOrValue::Value(n) + } +} + +impl From> for ListOrValue { + fn from(n: Vec) -> Self { + ListOrValue::List(n) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::assert_deser; + + #[test] + fn should_serialize_and_deserialize() { + assert_deser(r#"5"#, ListOrValue::Value(5_u64)); + assert_deser(r#""str""#, ListOrValue::Value("str".to_string())); + assert_deser(r#"[1,2,3]"#, ListOrValue::List(vec![1_u64, 2_u64, 3_u64])); + } +} diff --git a/primitives/rpc/src/number.rs b/primitives/rpc/src/number.rs index 0637e3decf..9c3312e6cc 100644 --- a/primitives/rpc/src/number.rs +++ b/primitives/rpc/src/number.rs @@ -27,7 +27,7 @@ use primitives::U256; /// or we attempt to parse given hex value. /// We do that for consistency with the returned type, default generic header /// serializes block number as hex to avoid overflows in JavaScript. -#[derive(Serialize, Deserialize)] +#[derive(Serialize, Deserialize, Debug, PartialEq)] #[serde(untagged)] pub enum NumberOrHex { /// The original header number type of block. @@ -72,3 +72,18 @@ impl From for NumberOrHex { NumberOrHex::Hex(n) } } + +#[cfg(test)] +mod tests { + use super::*; + use crate::assert_deser; + + #[test] + fn should_serialize_and_deserialize() { + assert_deser(r#""0x1234""#, NumberOrHex::::Hex(0x1234.into())); + assert_deser(r#""0x0""#, NumberOrHex::::Hex(0.into())); + assert_deser(r#"5"#, NumberOrHex::Number(5_u64)); + assert_deser(r#"10000"#, NumberOrHex::Number(10000_u32)); + assert_deser(r#"0"#, NumberOrHex::Number(0_u16)); + } +} -- GitLab From edab4ed2669721e2b927f0892a68435fcb7910fc Mon Sep 17 00:00:00 2001 From: Weiliang Li Date: Wed, 27 Nov 2019 02:14:18 +0900 Subject: [PATCH 015/172] Sort node/cli/Cargo.toml (#4205) --- bin/node/cli/Cargo.toml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/node/cli/Cargo.toml b/bin/node/cli/Cargo.toml index 8e4b3b4adc..01d7b1a48b 100644 --- a/bin/node/cli/Cargo.toml +++ b/bin/node/cli/Cargo.toml @@ -40,18 +40,19 @@ grandpa_primitives = { package = "substrate-finality-grandpa-primitives", path = primitives = { package = "substrate-primitives", path = "../../../primitives/core" } sr-primitives = { path = "../../../primitives/sr-primitives" } sp-timestamp = { path = "../../../primitives/timestamp", default-features = false } - -# core dependencies +sp-finality-tracker = { path = "../../../primitives/finality-tracker", default-features = false } +inherents = { package = "substrate-inherents", path = "../../../primitives/inherents" } +keyring = { package = "substrate-keyring", path = "../../../primitives/keyring" } runtime-io = { package = "sr-io", path = "../../../primitives/sr-io" } + +# client dependencies client-api = { package = "substrate-client-api", path = "../../../client/api" } client = { package = "substrate-client", path = "../../../client/" } -inherents = { package = "substrate-inherents", path = "../../../primitives/inherents" } chain-spec = { package = "substrate-chain-spec", path = "../../../client/chain-spec" } transaction_pool = { package = "substrate-transaction-pool", path = "../../../client/transaction-pool" } network = { package = "substrate-network", path = "../../../client/network" } babe = { package = "substrate-consensus-babe", path = "../../../client/consensus/babe" } grandpa = { package = "substrate-finality-grandpa", path = "../../../client/finality-grandpa" } -keyring = { package = "substrate-keyring", path = "../../../primitives/keyring" } client_db = { package = "substrate-client-db", path = "../../../client/db", default-features = false } offchain = { package = "substrate-offchain", path = "../../../client/offchain" } substrate-rpc = { package = "substrate-rpc", path = "../../../client/rpc" } @@ -63,7 +64,6 @@ authority-discovery = { package = "substrate-authority-discovery", path = "../.. # frame dependencies indices = { package = "pallet-indices", path = "../../../frame/indices" } timestamp = { package = "pallet-timestamp", path = "../../../frame/timestamp", default-features = false } -sp-finality-tracker = { path = "../../../primitives/finality-tracker", default-features = false } contracts = { package = "pallet-contracts", path = "../../../frame/contracts" } system = { package = "frame-system", path = "../../../frame/system" } balances = { package = "pallet-balances", path = "../../../frame/balances" } -- GitLab From 4e240f859e3aae89d7f5b4b0dabd796f16a87db3 Mon Sep 17 00:00:00 2001 From: Arkadiy Paronyan Date: Tue, 26 Nov 2019 18:17:14 +0100 Subject: [PATCH 016/172] Time-based gradual gossip (#4176) --- .../src/communication/gossip.rs | 222 ++++++++++++------ .../network/src/protocol/consensus_gossip.rs | 153 +----------- 2 files changed, 152 insertions(+), 223 deletions(-) diff --git a/client/finality-grandpa/src/communication/gossip.rs b/client/finality-grandpa/src/communication/gossip.rs index 9a07d010e0..3e0f2a7ac4 100644 --- a/client/finality-grandpa/src/communication/gossip.rs +++ b/client/finality-grandpa/src/communication/gossip.rs @@ -92,12 +92,12 @@ use substrate_telemetry::{telemetry, CONSENSUS_DEBUG}; use log::{trace, debug, warn}; use futures::prelude::*; use futures::sync::mpsc; -use rand::Rng; +use rand::seq::SliceRandom; use crate::{environment, CatchUp, CompactCommit, SignedMessage}; use super::{cost, benefit, Round, SetId}; -use std::collections::{HashMap, VecDeque}; +use std::collections::{HashMap, VecDeque, HashSet}; use std::time::{Duration, Instant}; const REBROADCAST_AFTER: Duration = Duration::from_secs(60 * 5); @@ -107,6 +107,13 @@ const CATCH_UP_PROCESS_TIMEOUT: Duration = Duration::from_secs(30); /// catch up request. const CATCH_UP_THRESHOLD: u64 = 2; +const PROPAGATION_ALL: u32 = 4; //in rounds; +const PROPAGATION_ALL_AUTHORITIES: u32 = 2; //in rounds; +const PROPAGATION_SOME_NON_AUTHORITIES: u32 = 3; //in rounds; +const ROUND_DURATION: u32 = 4; // measured in gossip durations + +const MIN_LUCKY: usize = 5; + type Report = (PeerId, i32); /// An outcome of examining a message. @@ -417,21 +424,37 @@ impl PeerInfo { /// The peers we're connected do in gossip. struct Peers { inner: HashMap>, + lucky_peers: HashSet, + lucky_authorities: HashSet, } impl Default for Peers { fn default() -> Self { - Peers { inner: HashMap::new() } + Peers { + inner: HashMap::new(), + lucky_peers: HashSet::new(), + lucky_authorities: HashSet::new(), + } } } impl Peers { fn new_peer(&mut self, who: PeerId, roles: Roles) { + if roles.is_authority() && self.lucky_authorities.len() < MIN_LUCKY { + self.lucky_authorities.insert(who.clone()); + } + if !roles.is_authority() && self.lucky_peers.len() < MIN_LUCKY { + self.lucky_peers.insert(who.clone()); + } self.inner.insert(who, PeerInfo::new(roles)); } fn peer_disconnected(&mut self, who: &PeerId) { self.inner.remove(who); + // This does not happen often enough compared to round duration, + // so we don't reshuffle. + self.lucky_peers.remove(who); + self.lucky_authorities.remove(who); } // returns a reference to the new view, if the peer is known. @@ -492,6 +515,37 @@ impl Peers { fn non_authorities(&self) -> usize { self.inner.iter().filter(|(_, info)| !info.roles.is_authority()).count() } + + fn reshuffle(&mut self) { + let mut lucky_peers : Vec<_> = self.inner + .iter() + .filter_map(|(id, info)| if !info.roles.is_authority() { Some(id.clone()) } else { None }) + .collect(); + let mut lucky_authorities: Vec<_> = self.inner + .iter() + .filter_map(|(id, info)| if info.roles.is_authority() { Some(id.clone()) } else { None }) + .collect(); + + let num_non_authorities = ((lucky_peers.len() as f32).sqrt() as usize) + .max(MIN_LUCKY) + .min(lucky_peers.len()); + + let num_authorities = ((lucky_authorities.len() as f32).sqrt() as usize) + .max(MIN_LUCKY) + .min(lucky_authorities.len()); + + lucky_peers.partial_shuffle(&mut rand::thread_rng(), num_non_authorities); + lucky_peers.truncate(num_non_authorities); + + lucky_authorities.partial_shuffle(&mut rand::thread_rng(), num_authorities); + lucky_authorities.truncate(num_authorities); + + self.lucky_peers.clear(); + self.lucky_peers.extend(lucky_peers.into_iter()); + + self.lucky_authorities.clear(); + self.lucky_authorities.extend(lucky_authorities.into_iter()); + } } #[derive(Debug, PartialEq)] @@ -559,6 +613,7 @@ struct Inner { local_view: Option>>, peers: Peers>, live_topics: KeepTopics, + round_start: Instant, authorities: Vec, config: crate::Config, next_rebroadcast: Instant, @@ -591,6 +646,7 @@ impl Inner { local_view: None, peers: Peers::default(), live_topics: KeepTopics::new(), + round_start: Instant::now(), next_rebroadcast: Instant::now() + REBROADCAST_AFTER, authorities: Vec::new(), pending_catch_up: PendingCatchUp::None, @@ -619,6 +675,8 @@ impl Inner { local_view.round = round; self.live_topics.push(round, set_id); + self.round_start = Instant::now(); + self.peers.reshuffle(); } self.multicast_neighbor_packet() } @@ -1001,10 +1059,14 @@ impl Inner { /// /// Transitions will be triggered on repropagation attempts by the /// underlying gossip layer, which should happen every 30 seconds. - fn round_message_allowed(&self, peer: &PeerInfo, mut previous_attempts: usize) -> bool { - const MIN_AUTHORITIES: usize = 5; + fn round_message_allowed(&self, who: &PeerId, peer: &PeerInfo) -> bool { + let round_duration = self.config.gossip_duration * ROUND_DURATION; + let round_elapsed = self.round_start.elapsed(); - if !self.config.is_authority && previous_attempts == 0 { + + if !self.config.is_authority + && round_elapsed < round_duration * PROPAGATION_ALL + { // non-authority nodes don't gossip any messages right away. we // assume that authorities (and sentries) are strongly connected, so // it should be unnecessary for non-authorities to gossip all @@ -1012,24 +1074,16 @@ impl Inner { return false; } - if !self.config.is_authority { - // since the node is not an authority we skipped the initial attempt - // to gossip the message, therefore we decrement `previous_attempts` - // so that the state machine below works the same way it does for - // authority nodes. - previous_attempts -= 1; - } - if peer.roles.is_authority() { let authorities = self.peers.authorities(); - // the target node is an authority, on the first attempt we start by + // the target node is an authority, on the first round duration we start by // sending the message to only `sqrt(authorities)` (if we're - // connected to at least `MIN_AUTHORITIES`). - if previous_attempts == 0 && authorities > MIN_AUTHORITIES { - let authorities = authorities as f64; - let p = (authorities.sqrt()).max(MIN_AUTHORITIES as f64) / authorities; - rand::thread_rng().gen_bool(p) + // connected to at least `MIN_LUCKY`). + if round_elapsed < round_duration * PROPAGATION_ALL_AUTHORITIES + && authorities > MIN_LUCKY + { + self.peers.lucky_authorities.contains(who) } else { // otherwise we already went through the step above, so // we won't filter the message and send it to all @@ -1038,15 +1092,13 @@ impl Inner { } } else { // the node is not an authority so we apply stricter filters - if previous_attempts >= 3 { - // if we previously tried to send this message 3 (or more) - // times, then it is allowed to be sent to all peers. + if round_elapsed >= round_duration * PROPAGATION_ALL { + // if we waited for 3 (or more) rounds + // then it is allowed to be sent to all peers. true - } else if previous_attempts == 2 { + } else if round_elapsed >= round_duration * PROPAGATION_SOME_NON_AUTHORITIES { // otherwise we only send it to `sqrt(non-authorities)`. - let non_authorities = self.peers.non_authorities() as f64; - let p = non_authorities.sqrt() / non_authorities; - rand::thread_rng().gen_bool(p) + self.peers.lucky_peers.contains(who) } else { false } @@ -1067,19 +1119,20 @@ impl Inner { /// /// Transitions will be triggered on repropagation attempts by the /// underlying gossip layer, which should happen every 30 seconds. - fn global_message_allowed(&self, peer: &PeerInfo, previous_attempts: usize) -> bool { - const MIN_PEERS: usize = 5; + fn global_message_allowed(&self, who: &PeerId, peer: &PeerInfo) -> bool { + let round_duration = self.config.gossip_duration * ROUND_DURATION; + let round_elapsed = self.round_start.elapsed(); if peer.roles.is_authority() { let authorities = self.peers.authorities(); - // the target node is an authority, on the first attempt we start by + // the target node is an authority, on the first round duration we start by // sending the message to only `sqrt(authorities)` (if we're - // connected to at least `MIN_PEERS`). - if previous_attempts == 0 && authorities > MIN_PEERS { - let authorities = authorities as f64; - let p = (authorities.sqrt()).max(MIN_PEERS as f64) / authorities; - rand::thread_rng().gen_bool(p) + // connected to at least `MIN_LUCKY`). + if round_elapsed < round_duration * PROPAGATION_ALL_AUTHORITIES + && authorities > MIN_LUCKY + { + self.peers.lucky_authorities.contains(who) } else { // otherwise we already went through the step above, so // we won't filter the message and send it to all @@ -1090,13 +1143,13 @@ impl Inner { let non_authorities = self.peers.non_authorities(); // the target node is not an authority, on the first and second - // attempt we start by sending the message to only + // round duration we start by sending the message to only // `sqrt(non_authorities)` (if we're connected to at least - // `MIN_PEERS`). - if previous_attempts <= 1 && non_authorities > MIN_PEERS { - let non_authorities = non_authorities as f64; - let p = (non_authorities.sqrt()).max(MIN_PEERS as f64) / non_authorities ; - rand::thread_rng().gen_bool(p) + // `MIN_LUCKY`). + if round_elapsed < round_duration * PROPAGATION_SOME_NON_AUTHORITIES + && non_authorities > MIN_LUCKY + { + self.peers.lucky_peers.contains(who) } else { // otherwise we already went through the step above, so // we won't filter the message and send it to all @@ -1315,14 +1368,14 @@ impl network_gossip::Validator for GossipValidator Some(x) => x, }; - if let MessageIntent::Broadcast { previous_attempts } = intent { + if let MessageIntent::Broadcast = intent { if maybe_round.is_some() { - if !inner.round_message_allowed(peer, previous_attempts) { + if !inner.round_message_allowed(who, peer) { // early return if the vote message isn't allowed at this stage. return false; } } else { - if !inner.global_message_allowed(peer, previous_attempts) { + if !inner.global_message_allowed(who, peer) { // early return if the global message isn't allowed at this stage. return false; } @@ -2132,8 +2185,12 @@ mod tests { #[test] fn progressively_gossips_to_more_peers() { + let mut config = config(); + config.gossip_duration = Duration::from_secs(300); // Set to high value to prevent test race + let round_duration = config.gossip_duration * ROUND_DURATION; + let (val, _) = GossipValidator::::new( - config(), + config, voter_set_state(), ); @@ -2152,7 +2209,9 @@ mod tests { val.inner.write().peers.new_peer(full_nodes[i].clone(), Roles::FULL); } - let test = |previous_attempts, peers| { + let test = |num_round, peers| { + // rewind n round durations + val.inner.write().round_start = Instant::now() - round_duration * num_round; let mut message_allowed = val.message_allowed(); move || { @@ -2160,7 +2219,7 @@ mod tests { for peer in peers { if message_allowed( peer, - MessageIntent::Broadcast { previous_attempts }, + MessageIntent::Broadcast, &crate::communication::round_topic::(1, 0), &[], ) { @@ -2187,22 +2246,22 @@ mod tests { // on the first attempt we will only gossip to `sqrt(authorities)`, // which should average out to 5 peers after a couple of trials - assert_eq!(trial(test(0, &authorities)), 5); + assert_eq!(trial(test(1, &authorities)), 5); // on the second (and subsequent attempts) we should gossip to all // authorities we're connected to. - assert_eq!(trial(test(1, &authorities)), 30); assert_eq!(trial(test(2, &authorities)), 30); + assert_eq!(trial(test(3, &authorities)), 30); // we should only gossip to non-authorities after the third attempt - assert_eq!(trial(test(0, &full_nodes)), 0); assert_eq!(trial(test(1, &full_nodes)), 0); + assert_eq!(trial(test(2, &full_nodes)), 0); // and only to `sqrt(non-authorities)` - assert_eq!(trial(test(2, &full_nodes)), 5); + assert_eq!(trial(test(3, &full_nodes)), 5); // only on the fourth attempt should we gossip to all non-authorities - assert_eq!(trial(test(3, &full_nodes)), 30); + assert_eq!(trial(test(4, &full_nodes)), 30); } #[test] @@ -2231,7 +2290,7 @@ mod tests { assert!( message_allowed( authority, - MessageIntent::Broadcast { previous_attempts: 0 }, + MessageIntent::Broadcast, &crate::communication::round_topic::(1, 0), &[], ) @@ -2240,9 +2299,11 @@ mod tests { } #[test] - fn non_authorities_never_gossip_messages_on_first_attempt() { + fn non_authorities_never_gossip_messages_on_first_round_duration() { let mut config = config(); + config.gossip_duration = Duration::from_secs(300); // Set to high value to prevent test race config.is_authority = false; + let round_duration = config.gossip_duration * ROUND_DURATION; let (val, _) = GossipValidator::::new( config, @@ -2259,32 +2320,37 @@ mod tests { authorities.push(peer_id); } - let mut message_allowed = val.message_allowed(); - - // since our node is not an authority we should **never** gossip any - // messages on the first attempt. - for authority in &authorities { - assert!( - !message_allowed( - authority, - MessageIntent::Broadcast { previous_attempts: 0 }, - &crate::communication::round_topic::(1, 0), - &[], - ) - ); + { + let mut message_allowed = val.message_allowed(); + // since our node is not an authority we should **never** gossip any + // messages on the first attempt. + for authority in &authorities { + assert!( + !message_allowed( + authority, + MessageIntent::Broadcast, + &crate::communication::round_topic::(1, 0), + &[], + ) + ); + } } - // on the third attempt we should allow messages to authorities - // (on the second attempt we would do `sqrt(authorities)`) - for authority in &authorities { - assert!( - message_allowed( - authority, - MessageIntent::Broadcast { previous_attempts: 2 }, - &crate::communication::round_topic::(1, 0), - &[], - ) - ); + { + val.inner.write().round_start = Instant::now() - round_duration * 4; + let mut message_allowed = val.message_allowed(); + // on the fourth round duration we should allow messages to authorities + // (on the second we would do `sqrt(authorities)`) + for authority in &authorities { + assert!( + message_allowed( + authority, + MessageIntent::Broadcast, + &crate::communication::round_topic::(1, 0), + &[], + ) + ); + } } } } diff --git a/client/network/src/protocol/consensus_gossip.rs b/client/network/src/protocol/consensus_gossip.rs index b1f56bc8f5..8cde3c66fe 100644 --- a/client/network/src/protocol/consensus_gossip.rs +++ b/client/network/src/protocol/consensus_gossip.rs @@ -73,7 +73,6 @@ const UNREGISTERED_TOPIC_REPUTATION_CHANGE: i32 = -(1 << 10); struct PeerConsensus { known_messages: HashSet, - filtered_messages: HashMap, roles: Roles, } @@ -108,11 +107,7 @@ pub enum MessageRecipient { #[cfg_attr(test, derive(Debug))] pub enum MessageIntent { /// Requested broadcast. - Broadcast { - /// How many times this message was previously filtered by the gossip - /// validator when trying to propagate to a given peer. - previous_attempts: usize - }, + Broadcast, /// Requested broadcast to all peers. ForcedBroadcast, /// Periodic rebroadcast of all messages to all peers. @@ -131,7 +126,7 @@ pub enum ValidationResult { impl MessageIntent { fn broadcast() -> MessageIntent { - MessageIntent::Broadcast { previous_attempts: 0 } + MessageIntent::Broadcast } } @@ -190,7 +185,8 @@ fn propagate<'a, B: BlockT, I>( peers: &mut HashMap>, validators: &HashMap>>, ) - where I: Clone + IntoIterator, // (msg_hash, topic, message) + // (msg_hash, topic, message) + where I: Clone + IntoIterator, { let mut check_fns = HashMap::new(); let mut message_allowed = move |who: &PeerId, intent: MessageIntent, topic: &B::Hash, message: &ConsensusMessage| { @@ -209,17 +205,12 @@ fn propagate<'a, B: BlockT, I>( for (id, ref mut peer) in peers.iter_mut() { let mut batch = Vec::new(); for (message_hash, topic, message) in messages.clone() { - let previous_attempts = peer.filtered_messages - .get(&message_hash) - .cloned() - .unwrap_or(0); - let intent = match intent { MessageIntent::Broadcast { .. } => if peer.known_messages.contains(&message_hash) { continue; } else { - MessageIntent::Broadcast { previous_attempts } + MessageIntent::Broadcast }, MessageIntent::PeriodicRebroadcast => if peer.known_messages.contains(&message_hash) { @@ -227,22 +218,15 @@ fn propagate<'a, B: BlockT, I>( } else { // peer doesn't know message, so the logic should treat it as an // initial broadcast. - MessageIntent::Broadcast { previous_attempts } + MessageIntent::Broadcast }, other => other, }; if !message_allowed(id, intent, &topic, &message) { - let count = peer.filtered_messages - .entry(message_hash.clone()) - .or_insert(0); - - *count += 1; - continue; } - peer.filtered_messages.remove(message_hash); peer.known_messages.insert(message_hash.clone()); trace!(target: "gossip", "Propagating to {}: {:?}", id, message); @@ -338,7 +322,6 @@ impl ConsensusGossip { trace!(target:"gossip", "Registering {:?} {}", roles, who); self.peers.insert(who.clone(), PeerConsensus { known_messages: HashSet::new(), - filtered_messages: HashMap::new(), roles, }); for (engine_id, v) in self.validators.clone() { @@ -448,7 +431,6 @@ impl ConsensusGossip { for (_, ref mut peer) in self.peers.iter_mut() { peer.known_messages.retain(|h| known_messages.contains(h)); - peer.filtered_messages.retain(|h, _| known_messages.contains(h)); } } @@ -566,12 +548,7 @@ impl ConsensusGossip { let intent = if force { MessageIntent::ForcedBroadcast } else { - let previous_attempts = peer.filtered_messages - .get(&entry.message_hash) - .cloned() - .unwrap_or(0); - - MessageIntent::Broadcast { previous_attempts } + MessageIntent::Broadcast }; if !force && peer.known_messages.contains(&entry.message_hash) { @@ -579,16 +556,9 @@ impl ConsensusGossip { } if !message_allowed(who, intent, &entry.topic, &entry.message.data) { - let count = peer.filtered_messages - .entry(entry.message_hash) - .or_insert(0); - - *count += 1; - continue; } - peer.filtered_messages.remove(&entry.message_hash); peer.known_messages.insert(entry.message_hash.clone()); trace!(target: "gossip", "Sending topic message to {}: {:?}", who, entry.message); @@ -632,7 +602,6 @@ impl ConsensusGossip { trace!(target: "gossip", "Sending direct to {}: {:?}", who, message); - peer.filtered_messages.remove(&message_hash); peer.known_messages.insert(message_hash); protocol.send_consensus(who.clone(), vec![message.clone()]); } @@ -662,8 +631,7 @@ impl Validator for DiscardAll { #[cfg(test)] mod tests { - use std::sync::{Arc, atomic::{AtomicBool, Ordering}}; - use parking_lot::Mutex; + use std::sync::Arc; use sr_primitives::testing::{H256, Block as RawBlock, ExtrinsicWrapper}; use futures03::executor::block_on_stream; @@ -812,109 +780,4 @@ mod tests { let _ = consensus.live_message_sinks.remove(&([0, 0, 0, 0], topic)); assert_eq!(stream.next(), None); } - - #[test] - fn keeps_track_of_broadcast_attempts() { - struct DummyNetworkContext; - impl Context for DummyNetworkContext { - fn report_peer(&mut self, _who: PeerId, _reputation: i32) {} - fn disconnect_peer(&mut self, _who: PeerId) {} - fn send_consensus(&mut self, _who: PeerId, _consensus: Vec) {} - fn send_chain_specific(&mut self, _who: PeerId, _message: Vec) {} - } - - // A mock gossip validator that never expires any message, allows - // setting whether messages should be allowed and keeps track of any - // messages passed to `message_allowed`. - struct MockValidator { - allow: AtomicBool, - messages: Arc, MessageIntent)>>>, - } - - impl MockValidator { - fn new() -> MockValidator { - MockValidator { - allow: AtomicBool::new(false), - messages: Arc::new(Mutex::new(Vec::new())), - } - } - } - - impl Validator for MockValidator { - fn validate( - &self, - _context: &mut dyn ValidatorContext, - _sender: &PeerId, - _data: &[u8], - ) -> ValidationResult { - ValidationResult::ProcessAndKeep(H256::default()) - } - - fn message_expired<'a>(&'a self) -> Box bool + 'a> { - Box::new(move |_topic, _data| false) - } - - fn message_allowed<'a>(&'a self) -> Box bool + 'a> { - let messages = self.messages.clone(); - Box::new(move |_, intent, _, data| { - messages.lock().push((data.to_vec(), intent)); - self.allow.load(Ordering::SeqCst) - }) - } - } - - // we setup an instance of the mock gossip validator, add a new peer to - // it and register a message. - let mut consensus = ConsensusGossip::::new(); - let validator = Arc::new(MockValidator::new()); - consensus.register_validator_internal([0, 0, 0, 0], validator.clone()); - consensus.new_peer( - &mut DummyNetworkContext, - PeerId::random(), - Roles::AUTHORITY, - ); - - let data = vec![1, 2, 3]; - let msg = ConsensusMessage { data: data.clone(), engine_id: [0, 0, 0, 0] }; - consensus.register_message(H256::default(), msg); - - // tick the gossip handler and make sure it triggers a message rebroadcast - let mut tick = || { - consensus.next_broadcast = std::time::Instant::now(); - consensus.tick(&mut DummyNetworkContext); - }; - - // by default we won't allow the message we registered, so everytime we - // tick the gossip handler, the message intent should be kept as - // `Broadcast` but the previous attempts should be incremented. - tick(); - assert_eq!( - validator.messages.lock().pop().unwrap(), - (data.clone(), MessageIntent::Broadcast { previous_attempts: 0 }), - ); - - tick(); - assert_eq!( - validator.messages.lock().pop().unwrap(), - (data.clone(), MessageIntent::Broadcast { previous_attempts: 1 }), - ); - - // we set the validator to allow the message to go through - validator.allow.store(true, Ordering::SeqCst); - - // we still get the same message intent but it should be delivered now - tick(); - assert_eq!( - validator.messages.lock().pop().unwrap(), - (data.clone(), MessageIntent::Broadcast { previous_attempts: 2 }), - ); - - // ticking the gossip handler again the message intent should change to - // `PeriodicRebroadcast` since it was sent. - tick(); - assert_eq!( - validator.messages.lock().pop().unwrap(), - (data.clone(), MessageIntent::PeriodicRebroadcast), - ); - } } -- GitLab From 1dd03824ea838601b1a51d133c56903c46ffe110 Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Tue, 26 Nov 2019 18:17:34 +0100 Subject: [PATCH 017/172] Add receiver for Grafana (#4211) --- Cargo.lock | 1 + client/cli/src/params.rs | 2 ++ client/tracing/Cargo.toml | 1 + client/tracing/src/lib.rs | 12 ++++++++++-- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7bf2fcba01..32995ac322 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6578,6 +6578,7 @@ dependencies = [ name = "substrate-tracing" version = "2.0.0" dependencies = [ + "grafana-data-source 2.0.0", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-telemetry 2.0.0", diff --git a/client/cli/src/params.rs b/client/cli/src/params.rs index 1324d3419f..09a18db207 100644 --- a/client/cli/src/params.rs +++ b/client/cli/src/params.rs @@ -265,6 +265,7 @@ arg_enum! { pub enum TracingReceiver { Log, Telemetry, + Grafana, } } @@ -273,6 +274,7 @@ impl Into for TracingReceiver { match self { TracingReceiver::Log => substrate_tracing::TracingReceiver::Log, TracingReceiver::Telemetry => substrate_tracing::TracingReceiver::Telemetry, + TracingReceiver::Grafana => substrate_tracing::TracingReceiver::Grafana, } } } diff --git a/client/tracing/Cargo.toml b/client/tracing/Cargo.toml index 25a1a7331b..431889cbec 100644 --- a/client/tracing/Cargo.toml +++ b/client/tracing/Cargo.toml @@ -11,6 +11,7 @@ parking_lot = "0.9.0" tracing-core = "0.1.7" substrate-telemetry = { path = "../telemetry" } +grafana-data-source = { path = "../grafana-data-source" } [dev-dependencies] tracing = "0.1.10" diff --git a/client/tracing/src/lib.rs b/client/tracing/src/lib.rs index d6fc4a6418..664d5bf7a9 100644 --- a/client/tracing/src/lib.rs +++ b/client/tracing/src/lib.rs @@ -39,6 +39,7 @@ use parking_lot::Mutex; use tracing_core::{event::Event, Level, metadata::Metadata, span::{Attributes, Id, Record}, subscriber::Subscriber}; use substrate_telemetry::{telemetry, SUBSTRATE_INFO}; +use grafana_data_source::{self, record_metrics}; /// Used to configure how to receive the metrics #[derive(Debug, Clone)] @@ -47,6 +48,8 @@ pub enum TracingReceiver { Log, /// Output to telemetry Telemetry, + /// Output to Grafana, + Grafana, } impl Default for TracingReceiver { @@ -59,7 +62,7 @@ impl Default for TracingReceiver { struct SpanDatum { id: u64, name: &'static str, - target: String, + target: &'static str, level: Level, line: u32, start_time: Instant, @@ -124,7 +127,7 @@ impl Subscriber for ProfilingSubscriber { let span_datum = SpanDatum { id: id, name: attrs.metadata().name(), - target: attrs.metadata().target().to_string(), + target: attrs.metadata().target(), level: attrs.metadata().level().clone(), line: attrs.metadata().line().unwrap_or(0), start_time: Instant::now(), @@ -172,6 +175,7 @@ impl ProfilingSubscriber { match self.receiver { TracingReceiver::Log => print_log(span_datum), TracingReceiver::Telemetry => send_telemetry(span_datum), + TracingReceiver::Grafana => send_grafana(span_datum), } } } @@ -196,3 +200,7 @@ fn send_telemetry(span_datum: SpanDatum) { "time" => span_datum.overall_time.as_nanos(), ); } + +fn send_grafana(span_datum: SpanDatum) { + record_metrics!(span_datum.target => span_datum.overall_time.as_nanos()); +} -- GitLab From 35b3acd7b6edd3259ec2bc7b92116004a0c51d84 Mon Sep 17 00:00:00 2001 From: Robert Habermeier Date: Tue, 26 Nov 2019 18:25:07 +0100 Subject: [PATCH 018/172] update finality-grandpa to v0.10.1 (#4213) --- Cargo.lock | 6 +++--- client/finality-grandpa/Cargo.toml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 32995ac322..14c3ca0c6d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1182,7 +1182,7 @@ dependencies = [ [[package]] name = "finality-grandpa" -version = "0.10.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5950,7 +5950,7 @@ name = "substrate-finality-grandpa" version = "2.0.0" dependencies = [ "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "finality-grandpa 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "finality-grandpa 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "fork-tree 2.0.0", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -8050,7 +8050,7 @@ dependencies = [ "checksum fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" "checksum fdlimit 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b1ee15a7050e5580b3712877157068ea713b245b080ff302ae2ca973cfcd9baa" "checksum file-per-thread-logger 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8505b75b31ef7285168dd237c4a7db3c1f3e0927e7d314e670bc98e854272fe9" -"checksum finality-grandpa 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b36ece7dc398ce17438d815f3202d2cdba8fd930452a68b616965662742b7e10" +"checksum finality-grandpa 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bd555755b04f83d6ed3041f5da26c0123a417ae2b96a826c1171b3f6fb804803" "checksum fixed-hash 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "72fe7539e2c5692c6989f2f9c0457e42f1e5768f96b85c87d273574670ae459f" "checksum fixedbitset 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "86d4de0081402f5e88cdac65c8dcdcc73118c1a7a465e2a05f0da05843a8ea33" "checksum flate2 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6bd6d6f4752952feb71363cffc9ebac9411b75b87c6ab6058c40c8900cf43c0f" diff --git a/client/finality-grandpa/Cargo.toml b/client/finality-grandpa/Cargo.toml index efeac40974..7bc381d3ad 100644 --- a/client/finality-grandpa/Cargo.toml +++ b/client/finality-grandpa/Cargo.toml @@ -27,10 +27,10 @@ inherents = { package = "substrate-inherents", path = "../../primitives/inherent network = { package = "substrate-network", path = "../network" } sp-finality-tracker = { path = "../../primitives/finality-tracker" } fg_primitives = { package = "substrate-finality-grandpa-primitives", path = "../../primitives/finality-grandpa" } -grandpa = { package = "finality-grandpa", version = "0.10.0", features = ["derive-codec"] } +grandpa = { package = "finality-grandpa", version = "0.10.1", features = ["derive-codec"] } [dev-dependencies] -grandpa = { package = "finality-grandpa", version = "0.10.0", features = ["derive-codec", "test-helpers"] } +grandpa = { package = "finality-grandpa", version = "0.10.1", features = ["derive-codec", "test-helpers"] } network = { package = "substrate-network", path = "../network", features = ["test-helpers"] } keyring = { package = "substrate-keyring", path = "../../primitives/keyring" } test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client"} -- GitLab From d9a565c0248ad51fb69d010a5156e154808cce62 Mon Sep 17 00:00:00 2001 From: Robert Habermeier Date: Tue, 26 Nov 2019 18:38:03 +0100 Subject: [PATCH 019/172] skip passed slots and wake up service correctly (#4212) --- client/consensus/slots/src/lib.rs | 13 +++++++++++++ client/service/src/builder.rs | 10 +++++++--- client/service/src/lib.rs | 20 +++++++++++++------- 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/client/consensus/slots/src/lib.rs b/client/consensus/slots/src/lib.rs index 02f6c15b79..9819e1487d 100644 --- a/client/consensus/slots/src/lib.rs +++ b/client/consensus/slots/src/lib.rs @@ -122,6 +122,19 @@ pub trait SimpleSlotWorker { let (timestamp, slot_number, slot_duration) = (slot_info.timestamp, slot_info.number, slot_info.duration); + { + let slot_now = SignedDuration::default().slot_now(slot_duration); + if slot_now > slot_number { + // if this is behind, return. + debug!(target: self.logging_target(), + "Skipping proposal slot {} since our current view is {}", + slot_number, slot_now, + ); + + return Box::pin(future::ready(Ok(()))); + } + } + let epoch_data = match self.epoch_data(&chain_head, slot_number) { Ok(epoch_data) => epoch_data, Err(err) => { diff --git a/client/service/src/builder.rs b/client/service/src/builder.rs index 049dc5d92e..03eea9eb3f 100644 --- a/client/service/src/builder.rs +++ b/client/service/src/builder.rs @@ -49,7 +49,7 @@ use sr_primitives::traits::{ use substrate_executor::{NativeExecutor, NativeExecutionDispatch}; use std::{ io::{Read, Write, Seek}, - marker::PhantomData, sync::Arc, sync::atomic::AtomicBool, time::SystemTime + marker::PhantomData, sync::Arc, time::SystemTime }; use sysinfo::{get_current_pid, ProcessExt, System, SystemExt}; use tel::{telemetry, SUBSTRATE_INFO}; @@ -823,6 +823,9 @@ ServiceBuilder< let (to_spawn_tx, to_spawn_rx) = mpsc::unbounded:: + Send>>(); + // A side-channel for essential tasks to communicate shutdown. + let (essential_failed_tx, essential_failed_rx) = mpsc::unbounded(); + let import_queue = Box::new(import_queue); let chain_info = client.info().chain; @@ -1163,7 +1166,7 @@ ServiceBuilder< let _ = to_spawn_tx.unbounded_send(Box::new(future)); } - + // Instrumentation if let Some(tracing_targets) = config.tracing_targets.as_ref() { let subscriber = substrate_tracing::ProfilingSubscriber::new( @@ -1183,7 +1186,8 @@ ServiceBuilder< transaction_pool, exit, signal: Some(signal), - essential_failed: Arc::new(AtomicBool::new(false)), + essential_failed_tx, + essential_failed_rx, to_spawn_tx, to_spawn_rx, to_poll: Vec::new(), diff --git a/client/service/src/lib.rs b/client/service/src/lib.rs index dd982e5a2e..6ddc6ab797 100644 --- a/client/service/src/lib.rs +++ b/client/service/src/lib.rs @@ -31,7 +31,6 @@ use std::io; use std::marker::PhantomData; use std::net::SocketAddr; use std::collections::HashMap; -use std::sync::atomic::{AtomicBool, Ordering}; use std::time::{Duration, Instant}; use futures::sync::mpsc; use parking_lot::Mutex; @@ -85,9 +84,11 @@ pub struct Service { exit: exit_future::Exit, /// A signal that makes the exit future above resolve, fired on service drop. signal: Option, - /// Set to `true` when a spawned essential task has failed. The next time + /// Send a signal when a spawned essential task has concluded. The next time /// the service future is polled it should complete with an error. - essential_failed: Arc, + essential_failed_tx: mpsc::UnboundedSender<()>, + /// A receiver for spawned essential-tasks concluding. + essential_failed_rx: mpsc::UnboundedReceiver<()>, /// Sender for futures that must be spawned as background tasks. to_spawn_tx: mpsc::UnboundedSender + Send>>, /// Receiver for futures that must be spawned as background tasks. @@ -239,12 +240,12 @@ where } fn spawn_essential_task(&self, task: impl Future + Send + 'static) { - let essential_failed = self.essential_failed.clone(); + let essential_failed = self.essential_failed_tx.clone(); let essential_task = std::panic::AssertUnwindSafe(task) .catch_unwind() .then(move |_| { error!("Essential task failed. Shutting down service."); - essential_failed.store(true, Ordering::Relaxed); + let _ = essential_failed.send(()); Ok(()) }); let task = essential_task.select(self.on_exit()).then(|_| Ok(())); @@ -297,8 +298,13 @@ impl Future for type Error = Error; fn poll(&mut self) -> Poll { - if self.essential_failed.load(Ordering::Relaxed) { - return Err(Error::Other("Essential task failed.".into())); + match self.essential_failed_rx.poll() { + Ok(Async::NotReady) => {}, + Ok(Async::Ready(_)) | Err(_) => { + // Ready(None) should not be possible since we hold a live + // sender. + return Err(Error::Other("Essential task failed.".into())); + } } while let Ok(Async::Ready(Some(task_to_spawn))) = self.to_spawn_rx.poll() { -- GitLab From d5fdf0a33a1fbd296b946ebc05b8dee18964e19a Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 26 Nov 2019 18:39:08 +0100 Subject: [PATCH 020/172] Remove tab (#4212) --- client/consensus/slots/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/consensus/slots/src/lib.rs b/client/consensus/slots/src/lib.rs index 9819e1487d..e3001ce050 100644 --- a/client/consensus/slots/src/lib.rs +++ b/client/consensus/slots/src/lib.rs @@ -126,7 +126,7 @@ pub trait SimpleSlotWorker { let slot_now = SignedDuration::default().slot_now(slot_duration); if slot_now > slot_number { // if this is behind, return. - debug!(target: self.logging_target(), + debug!(target: self.logging_target(), "Skipping proposal slot {} since our current view is {}", slot_number, slot_now, ); -- GitLab From 3f519863a69b621c64fe0994346245bbf1a968d4 Mon Sep 17 00:00:00 2001 From: Qinxuan Chen Date: Wed, 27 Nov 2019 01:39:58 +0800 Subject: [PATCH 021/172] Update some dependencies: (#4207) - derive_more 0.15 -> 0.99 - strum 0.15 -> 0.16 - slog_derive 0.1 -> 0.2 Signed-off-by: koushiro --- Cargo.lock | 80 ++++++++++++------------ bin/node-template/Cargo.toml | 1 - client/Cargo.toml | 2 +- client/api/Cargo.toml | 2 +- client/api/src/error.rs | 7 +++ client/authority-discovery/Cargo.toml | 2 +- client/cli/Cargo.toml | 2 +- client/cli/src/error.rs | 2 + client/consensus/aura/Cargo.toml | 2 +- client/consensus/babe/Cargo.toml | 2 +- client/consensus/pow/Cargo.toml | 2 +- client/executor/Cargo.toml | 2 +- client/executor/src/error.rs | 4 ++ client/grafana-data-source/Cargo.toml | 2 +- client/keystore/Cargo.toml | 2 +- client/network/Cargo.toml | 4 +- client/rpc/api/Cargo.toml | 2 +- client/rpc/api/src/author/error.rs | 2 + client/service/Cargo.toml | 2 +- client/transaction-pool/Cargo.toml | 2 +- client/transaction-pool/graph/Cargo.toml | 2 +- client/transaction-pool/src/error.rs | 2 + primitives/consensus/common/Cargo.toml | 2 +- primitives/consensus/common/src/error.rs | 2 + primitives/inherents/Cargo.toml | 2 +- primitives/inherents/src/lib.rs | 2 +- primitives/keyring/Cargo.toml | 3 +- primitives/keyring/src/ed25519.rs | 2 +- primitives/keyring/src/sr25519.rs | 2 +- 29 files changed, 80 insertions(+), 65 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 14c3ca0c6d..017bbd5904 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -917,15 +917,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "derive_more" -version = "0.15.0" +version = "0.99.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1716,7 +1713,7 @@ version = "2.0.0" dependencies = [ "async-std 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", - "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", "futures-timer 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures-util-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3214,7 +3211,6 @@ name = "node-template" version = "2.0.0" dependencies = [ "ctrlc 3.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5104,12 +5100,12 @@ dependencies = [ [[package]] name = "slog_derive" -version = "0.1.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -5390,18 +5386,21 @@ dependencies = [ [[package]] name = "strum" -version = "0.15.0" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "strum_macros 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "strum_macros" -version = "0.15.0" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -5443,7 +5442,7 @@ name = "substrate-authority-discovery" version = "2.0.0" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures-timer 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5564,7 +5563,7 @@ dependencies = [ "app_dirs 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", - "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "fdlimit 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5596,7 +5595,7 @@ dependencies = [ name = "substrate-client" version = "2.0.0" dependencies = [ - "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5633,7 +5632,7 @@ dependencies = [ name = "substrate-client-api" version = "2.0.0" dependencies = [ - "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5698,7 +5697,7 @@ dependencies = [ name = "substrate-consensus-aura" version = "2.0.0" dependencies = [ - "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5748,7 +5747,7 @@ dependencies = [ name = "substrate-consensus-babe" version = "2.0.0" dependencies = [ - "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "fork-tree 2.0.0", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5811,7 +5810,7 @@ dependencies = [ name = "substrate-consensus-common" version = "2.0.0" dependencies = [ - "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures-timer 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5830,7 +5829,7 @@ dependencies = [ name = "substrate-consensus-pow" version = "2.0.0" dependencies = [ - "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5905,7 +5904,7 @@ dependencies = [ "cranelift-frontend 0.50.0 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift-native 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)", - "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "libsecp256k1 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -6007,7 +6006,7 @@ dependencies = [ name = "substrate-inherents" version = "2.0.0" dependencies = [ - "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 2.0.0", @@ -6020,8 +6019,7 @@ version = "2.0.0" dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", - "strum 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", - "strum_macros 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "strum 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-primitives 2.0.0", ] @@ -6029,7 +6027,7 @@ dependencies = [ name = "substrate-keystore" version = "2.0.0" dependencies = [ - "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -6046,7 +6044,7 @@ version = "2.0.0" dependencies = [ "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "erased-serde 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -6068,7 +6066,7 @@ dependencies = [ "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "slog_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "slog_derive 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "sr-arithmetic 2.0.0", "sr-primitives 2.0.0", @@ -6253,7 +6251,7 @@ dependencies = [ name = "substrate-rpc-api" version = "2.0.0" dependencies = [ - "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-core-client 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -6363,7 +6361,7 @@ dependencies = [ name = "substrate-service" version = "2.0.0" dependencies = [ - "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", "exit-future 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -6592,7 +6590,7 @@ version = "2.0.0" dependencies = [ "assert_matches 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "criterion 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -6608,7 +6606,7 @@ dependencies = [ name = "substrate-transaction-pool" version = "2.0.0" dependencies = [ - "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -8021,7 +8019,7 @@ dependencies = [ "checksum cuckoofilter 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8dd43f7cfaffe0a386636a10baea2ee05cc50df3b77bea4a456c9572a939bf1f" "checksum curve25519-dalek 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8b7dcd30ba50cdf88b55b033456138b7c0ac4afdc436d82e1b79f370f24cc66d" "checksum data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f4f47ca1860a761136924ddd2422ba77b2ea54fe8cc75b9040804a0d9d32ad97" -"checksum derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a141330240c921ec6d074a3e188a7c7ef95668bb95e7d44fa0e5778ec2a7afe" +"checksum derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2159be042979966de68315bce7034bb000c775f22e3e834e1c52ff78f041cae8" "checksum difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" "checksum digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" "checksum directories 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "551a778172a450d7fc12e629ca3b0428d00f6afa9a43da1b630d54604e97371c" @@ -8345,7 +8343,7 @@ dependencies = [ "checksum slog-async 2.3.0 (git+https://github.com/paritytech/slog-async)" = "" "checksum slog-json 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ddc0d2aff1f8f325ef660d9a0eb6e6dcd20b30b3f581a5897f58bf42d061c37a" "checksum slog-scope 4.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7c44c89dd8b0ae4537d1ae318353eaf7840b4869c536e31c41e963d1ea523ee6" -"checksum slog_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9eff3b513cf2e0d1a60e1aba152dc72bedc5b05585722bb3cebd7bcb1e31b98f" +"checksum slog_derive 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a945ec7f7ce853e89ffa36be1e27dce9a43e82ff9093bf3461c30d5da74ed11b" "checksum smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "f7b0758c52e15a8b5e3691eae6cc559f08eee9406e548a4477ba4e67770a82b6" "checksum smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ecf3b85f68e8abaa7555aa5abdb1153079387e60b718283d732f03897fcfc86" "checksum snow 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "91eecae35b461ed26bda7a76bea2cc5bda2bf4b8dd06761879f19e6fdd50c2dd" @@ -8360,8 +8358,8 @@ dependencies = [ "checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" "checksum structopt 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c167b61c7d4c126927f5346a4327ce20abf8a186b8041bbeb1ce49e5db49587b" "checksum structopt-derive 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "519621841414165d2ad0d4c92be8f41844203f2b67e245f9345a5a12d40c69d7" -"checksum strum 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e5d1c33039533f051704951680f1adfd468fd37ac46816ded0d9ee068e60f05f" -"checksum strum_macros 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "47cd23f5c7dee395a00fa20135e2ec0fffcdfa151c56182966d7a3261343432e" +"checksum strum 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6138f8f88a16d90134763314e3fc76fa3ed6a7db4725d6acf9a3ef95a3188d22" +"checksum strum_macros 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0054a7df764039a6cd8592b9de84be4bec368ff081d203a7d5371cbfa8e65c81" "checksum substrate-bip39 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3be511be555a3633e71739a79e4ddff6a6aaa6579fa6114182a51d72c3eb93c5" "checksum subtle 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" "checksum subtle 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ab3af2eb31c42e8f0ccf43548232556c42737e01a96db6e1777b0be108e79799" diff --git a/bin/node-template/Cargo.toml b/bin/node-template/Cargo.toml index ff39373076..11373e8d71 100644 --- a/bin/node-template/Cargo.toml +++ b/bin/node-template/Cargo.toml @@ -10,7 +10,6 @@ name = "node-template" path = "src/main.rs" [dependencies] -derive_more = "0.15.0" futures = "0.3.1" futures01 = { package = "futures", version = "0.1.29" } ctrlc = { version = "3.1.3", features = ["termination"] } diff --git a/client/Cargo.toml b/client/Cargo.toml index 3f7c4df917..d7270dff37 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -9,7 +9,7 @@ block-builder = { package = "substrate-block-builder", path = "block-builder" } client-api = { package = "substrate-client-api", path = "api" } codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } consensus = { package = "substrate-consensus-common", path = "../primitives/consensus/common" } -derive_more = { version = "0.15.0" } +derive_more = { version = "0.99.2" } executor = { package = "substrate-executor", path = "executor" } externalities = { package = "substrate-externalities", path = "../primitives/externalities" } fnv = { version = "1.0.6" } diff --git a/client/api/Cargo.toml b/client/api/Cargo.toml index 4757d7af81..6af1086586 100644 --- a/client/api/Cargo.toml +++ b/client/api/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" block-builder = { package = "substrate-block-builder", path = "../block-builder" } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } consensus = { package = "substrate-consensus-common", path = "../../primitives/consensus/common" } -derive_more = { version = "0.15.0" } +derive_more = { version = "0.99.2" } executor = { package = "substrate-executor", path = "../executor" } externalities = { package = "substrate-externalities", path = "../../primitives/externalities" } fnv = { version = "1.0.6" } diff --git a/client/api/src/error.rs b/client/api/src/error.rs index 9059fe5393..871a1091c6 100644 --- a/client/api/src/error.rs +++ b/client/api/src/error.rs @@ -33,9 +33,11 @@ pub enum Error { Consensus(consensus::Error), /// Backend error. #[display(fmt = "Backend error: {}", _0)] + #[from(ignore)] Backend(String), /// Unknown block. #[display(fmt = "UnknownBlock: {}", _0)] + #[from(ignore)] UnknownBlock(String), /// The `apply_extrinsic` is not valid due to the given `TransactionValidityError`. #[display(fmt = "Extrinsic is not valid: {:?}", _0)] @@ -60,6 +62,7 @@ pub enum Error { JustificationDecode, /// Justification for header is correctly encoded, but invalid. #[display(fmt = "bad justification for header: {}", _0)] + #[from(ignore)] BadJustification(String), /// Not available on light client. #[display(fmt = "This method is not currently available when running in light client mode")] @@ -78,15 +81,18 @@ pub enum Error { CallResultDecode(&'static str, codec::Error), /// Error converting a parameter between runtime and node. #[display(fmt = "Error converting `{}` between runtime and node", _0)] + #[from(ignore)] RuntimeParamConversion(String), /// Changes tries are not supported. #[display(fmt = "Changes tries are not supported by the runtime")] ChangesTriesNotSupported, /// Key changes query has failed. #[display(fmt = "Failed to check changes proof: {}", _0)] + #[from(ignore)] ChangesTrieAccessFailed(String), /// Last finalized block not parent of current. #[display(fmt = "Did not finalize blocks in sequential order.")] + #[from(ignore)] NonSequentialFinalization(String), /// Safety violation: new best block not descendent of last finalized. #[display(fmt = "Potential long-range attack: block not in finalized chain.")] @@ -99,6 +105,7 @@ pub enum Error { InvalidStateRoot, /// A convenience variant for String #[display(fmt = "{}", _0)] + #[from(ignore)] Msg(String), } diff --git a/client/authority-discovery/Cargo.toml b/client/authority-discovery/Cargo.toml index c45eb41684..5447119dc7 100644 --- a/client/authority-discovery/Cargo.toml +++ b/client/authority-discovery/Cargo.toml @@ -13,7 +13,7 @@ authority-discovery-primitives = { package = "substrate-authority-discovery-prim bytes = "0.4.12" client-api = { package = "substrate-client-api", path = "../api" } codec = { package = "parity-scale-codec", default-features = false, version = "1.0.3" } -derive_more = "0.15.0" +derive_more = "0.99.2" futures = "0.3.1" futures-timer = "2.0" keystore = { package = "substrate-keystore", path = "../keystore" } diff --git a/client/cli/Cargo.toml b/client/cli/Cargo.toml index af3be8dc94..a2b5940e74 100644 --- a/client/cli/Cargo.toml +++ b/client/cli/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] clap = "2.33.0" -derive_more = "0.15.0" +derive_more = "0.99.2" env_logger = "0.7.0" log = "0.4.8" atty = "0.2.13" diff --git a/client/cli/src/error.rs b/client/cli/src/error.rs index 6b42773bb8..ab07c0e842 100644 --- a/client/cli/src/error.rs +++ b/client/cli/src/error.rs @@ -33,11 +33,13 @@ pub enum Error { /// Client error Client(client_api::error::Error), /// Input error + #[from(ignore)] Input(String), /// Invalid listen multiaddress #[display(fmt="Invalid listen multiaddress")] InvalidListenMultiaddress, /// Other uncategorized error. + #[from(ignore)] Other(String), } diff --git a/client/consensus/aura/Cargo.toml b/client/consensus/aura/Cargo.toml index 7ef9b514f0..17da93826c 100644 --- a/client/consensus/aura/Cargo.toml +++ b/client/consensus/aura/Cargo.toml @@ -13,7 +13,7 @@ client = { package = "substrate-client", path = "../../" } client-api = { package = "substrate-client-api", path = "../../api" } codec = { package = "parity-scale-codec", version = "1.0.0" } consensus_common = { package = "substrate-consensus-common", path = "../../../primitives/consensus/common" } -derive_more = "0.15.0" +derive_more = "0.99.2" futures = { version = "0.3.1", features = ["compat"] } futures01 = { package = "futures", version = "0.1" } futures-timer = "0.4.0" diff --git a/client/consensus/babe/Cargo.toml b/client/consensus/babe/Cargo.toml index c23bd1b84c..2baf4835d8 100644 --- a/client/consensus/babe/Cargo.toml +++ b/client/consensus/babe/Cargo.toml @@ -38,7 +38,7 @@ schnorrkel = { version = "0.8.5", features = ["preaudit_deprecated"] } rand = "0.7.2" merlin = "1.2.1" pdqselect = "0.1.0" -derive_more = "0.15.0" +derive_more = "0.99.2" [dev-dependencies] keyring = { package = "substrate-keyring", path = "../../../primitives/keyring" } diff --git a/client/consensus/pow/Cargo.toml b/client/consensus/pow/Cargo.toml index 455986e2f6..8ed1af9923 100644 --- a/client/consensus/pow/Cargo.toml +++ b/client/consensus/pow/Cargo.toml @@ -17,4 +17,4 @@ consensus-common = { package = "substrate-consensus-common", path = "../../../pr log = "0.4.8" futures = { version = "0.3.1", features = ["compat"] } sp-timestamp = { path = "../../../primitives/timestamp" } -derive_more = "0.15.0" +derive_more = "0.99.2" diff --git a/client/executor/Cargo.toml b/client/executor/Cargo.toml index 619b974cb6..8c46990395 100644 --- a/client/executor/Cargo.toml +++ b/client/executor/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -derive_more = "0.15.0" +derive_more = "0.99.2" codec = { package = "parity-scale-codec", version = "1.0.0" } runtime_io = { package = "sr-io", path = "../../primitives/sr-io" } primitives = { package = "substrate-primitives", path = "../../primitives/core" } diff --git a/client/executor/src/error.rs b/client/executor/src/error.rs index 58a84e0990..84ae79a789 100644 --- a/client/executor/src/error.rs +++ b/client/executor/src/error.rs @@ -37,12 +37,15 @@ pub enum Error { #[cfg(feature = "wasmtime")] Wasmtime(ActionError), /// Error in the API. Parameter is an error message. + #[from(ignore)] ApiError(String), /// Method is not found #[display(fmt="Method not found: '{}'", _0)] + #[from(ignore)] MethodNotFound(String), /// Code is invalid (expected single byte) #[display(fmt="Invalid Code: {}", _0)] + #[from(ignore)] InvalidCode(String), /// Could not get runtime version. #[display(fmt="On-chain runtime does not specify version")] @@ -70,6 +73,7 @@ pub enum Error { #[display(fmt="The runtime has the `start` function")] RuntimeHasStartFn, /// Some other error occurred + #[from(ignore)] Other(String), /// Some error occurred in the allocator #[display(fmt="Error in allocator: {}", _0)] diff --git a/client/grafana-data-source/Cargo.toml b/client/grafana-data-source/Cargo.toml index 597d036c58..6e9b2685ae 100644 --- a/client/grafana-data-source/Cargo.toml +++ b/client/grafana-data-source/Cargo.toml @@ -18,7 +18,7 @@ chrono = { version = "0.4", features = ["serde"] } lazy_static = "1.4" parking_lot = "0.9" futures-timer = "2.0" -derive_more = "0.15" +derive_more = "0.99" [target.'cfg(not(target_os = "unknown"))'.dependencies] async-std = { version = "1.0.1", features = ["unstable"] } diff --git a/client/keystore/Cargo.toml b/client/keystore/Cargo.toml index 9923a7f357..ef788d864f 100644 --- a/client/keystore/Cargo.toml +++ b/client/keystore/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -derive_more = "0.15.0" +derive_more = "0.99.2" primitives = { package = "substrate-primitives", path = "../../primitives/core" } app-crypto = { package = "substrate-application-crypto", path = "../../primitives/application-crypto" } hex = "0.3.2" diff --git a/client/network/Cargo.toml b/client/network/Cargo.toml index 2feea5fe9d..9691cd5c3c 100644 --- a/client/network/Cargo.toml +++ b/client/network/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" [dependencies] bytes = "0.4.12" -derive_more = "0.15.0" +derive_more = "0.99.2" either = "1.5.3" log = "0.4.8" parking_lot = "0.9.0" @@ -37,7 +37,7 @@ peerset = { package = "substrate-peerset", path = "../../primitives/peerset" } serde = { version = "1.0.101", features = ["derive"] } serde_json = "1.0.41" slog = { version = "2.5.2", features = ["nested-values"] } -slog_derive = "0.1.1" +slog_derive = "0.2.0" smallvec = "0.6.10" tokio-io = "0.1.12" tokio = { version = "0.1.22", optional = true } diff --git a/client/rpc/api/Cargo.toml b/client/rpc/api/Cargo.toml index 906efeaffb..621d487f3a 100644 --- a/client/rpc/api/Cargo.toml +++ b/client/rpc/api/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" [dependencies] codec = { package = "parity-scale-codec", version = "1.0.0" } -derive_more = "0.15.0" +derive_more = "0.99.2" futures = { version = "0.3.1", features = ["compat"] } jsonrpc-core = "14.0.3" jsonrpc-core-client = "14.0.3" diff --git a/client/rpc/api/src/author/error.rs b/client/rpc/api/src/author/error.rs index 8e4f887768..d1c943ef44 100644 --- a/client/rpc/api/src/author/error.rs +++ b/client/rpc/api/src/author/error.rs @@ -30,12 +30,14 @@ pub type FutureResult = Box pub enum Error { /// Client error. #[display(fmt="Client error: {}", _0)] + #[from(ignore)] Client(Box), /// Transaction pool error, #[display(fmt="Transaction pool error: {}", _0)] Pool(txpool::error::Error), /// Verification error #[display(fmt="Extrinsic verification error: {}", _0)] + #[from(ignore)] Verification(Box), /// Incorrect extrinsic format. #[display(fmt="Invalid extrinsic format: {}", _0)] diff --git a/client/service/Cargo.toml b/client/service/Cargo.toml index 81f6aabbe0..f1c3669c47 100644 --- a/client/service/Cargo.toml +++ b/client/service/Cargo.toml @@ -14,7 +14,7 @@ wasmtime = [ ] [dependencies] -derive_more = "0.15.0" +derive_more = "0.99.2" futures = "0.1.29" futures03 = { package = "futures", version = "0.3.1", features = ["compat"] } parking_lot = "0.9.0" diff --git a/client/transaction-pool/Cargo.toml b/client/transaction-pool/Cargo.toml index 60bf0c005c..de19d9d19a 100644 --- a/client/transaction-pool/Cargo.toml +++ b/client/transaction-pool/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" [dependencies] codec = { package = "parity-scale-codec", version = "1.0.0" } -derive_more = "0.15.0" +derive_more = "0.99.2" futures = { version = "0.3.1", features = ["thread-pool"] } log = "0.4.8" parking_lot = "0.9.0" diff --git a/client/transaction-pool/graph/Cargo.toml b/client/transaction-pool/graph/Cargo.toml index c81e59e17f..63b1c54aac 100644 --- a/client/transaction-pool/graph/Cargo.toml +++ b/client/transaction-pool/graph/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -derive_more = "0.15.0" +derive_more = "0.99.2" futures = "0.3.1" log = "0.4.8" parking_lot = "0.9.0" diff --git a/client/transaction-pool/src/error.rs b/client/transaction-pool/src/error.rs index ae0a058e5c..83667d4cbc 100644 --- a/client/transaction-pool/src/error.rs +++ b/client/transaction-pool/src/error.rs @@ -25,8 +25,10 @@ pub enum Error { /// Pool error. Pool(txpool::error::Error), /// Error while converting a `BlockId`. + #[from(ignore)] BlockIdConversion(String), /// Error while calling the runtime api. + #[from(ignore)] RuntimeApi(String), } diff --git a/primitives/consensus/common/Cargo.toml b/primitives/consensus/common/Cargo.toml index 11a266ac9d..02dc7b579f 100644 --- a/primitives/consensus/common/Cargo.toml +++ b/primitives/consensus/common/Cargo.toml @@ -6,7 +6,7 @@ description = "Common utilities for substrate consensus" edition = "2018" [dependencies] -derive_more = "0.15.0" +derive_more = "0.99.2" libp2p = { version = "0.13.0", default-features = false } log = "0.4.8" primitives = { package = "substrate-primitives", path= "../../core" } diff --git a/primitives/consensus/common/src/error.rs b/primitives/consensus/common/src/error.rs index 16781b04ff..0455a553cc 100644 --- a/primitives/consensus/common/src/error.rs +++ b/primitives/consensus/common/src/error.rs @@ -67,9 +67,11 @@ pub enum Error { Other(Box), /// Error from the client while importing #[display(fmt="Import failed: {}", _0)] + #[from(ignore)] ClientImport(String), /// Error from the client while importing #[display(fmt="Chain lookup failed: {}", _0)] + #[from(ignore)] ChainLookup(String), } diff --git a/primitives/inherents/Cargo.toml b/primitives/inherents/Cargo.toml index 108cb15e9c..f01bb9d3a9 100644 --- a/primitives/inherents/Cargo.toml +++ b/primitives/inherents/Cargo.toml @@ -9,7 +9,7 @@ parking_lot = { version = "0.9.0", optional = true } rstd = { package = "sr-std", path = "../sr-std", default-features = false } primitives = { package = "substrate-primitives", path = "../core", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.6", default-features = false, features = ["derive"] } -derive_more = { version = "0.15.0", optional = true } +derive_more = { version = "0.99.2", optional = true } [features] default = [ "std" ] diff --git a/primitives/inherents/src/lib.rs b/primitives/inherents/src/lib.rs index 25512f4fca..b398e43997 100644 --- a/primitives/inherents/src/lib.rs +++ b/primitives/inherents/src/lib.rs @@ -44,8 +44,8 @@ use parking_lot::RwLock; use std::{sync::Arc, format}; /// An error that can occur within the inherent data system. -#[derive(Debug, Encode, Decode, derive_more::Display)] #[cfg(feature = "std")] +#[derive(Debug, Encode, Decode, derive_more::Display)] pub struct Error(String); #[cfg(feature = "std")] diff --git a/primitives/keyring/Cargo.toml b/primitives/keyring/Cargo.toml index cc0e2836ba..5960f7be16 100644 --- a/primitives/keyring/Cargo.toml +++ b/primitives/keyring/Cargo.toml @@ -8,5 +8,4 @@ edition = "2018" primitives = { package = "substrate-primitives", path = "../core" } sr-primitives = { path = "../sr-primitives" } lazy_static = "1.4.0" -strum = "0.15.0" -strum_macros = "0.15.0" +strum = { version = "0.16.0", features = ["derive"] } diff --git a/primitives/keyring/src/ed25519.rs b/primitives/keyring/src/ed25519.rs index c1a357fc0e..4a3e090c76 100644 --- a/primitives/keyring/src/ed25519.rs +++ b/primitives/keyring/src/ed25519.rs @@ -23,7 +23,7 @@ pub use primitives::ed25519; use sr_primitives::AccountId32; /// Set of test accounts. -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, strum_macros::Display, strum_macros::EnumIter)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, strum::Display, strum::EnumIter)] pub enum Keyring { Alice, Bob, diff --git a/primitives/keyring/src/sr25519.rs b/primitives/keyring/src/sr25519.rs index b37b2bdf9b..ff132d8968 100644 --- a/primitives/keyring/src/sr25519.rs +++ b/primitives/keyring/src/sr25519.rs @@ -24,7 +24,7 @@ pub use primitives::sr25519; use sr_primitives::AccountId32; /// Set of test accounts. -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, strum_macros::Display, strum_macros::EnumIter)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, strum::Display, strum::EnumIter)] pub enum Keyring { Alice, Bob, -- GitLab From 8cf5ba3643c8cf6ffb665b25d21167bc59032e9d Mon Sep 17 00:00:00 2001 From: Wei Tang Date: Tue, 26 Nov 2019 20:00:00 +0100 Subject: [PATCH 022/172] Move block proposing execution to dedicated blocking threadpool (#4202) * Move block proposing execution to dedicated blocking threadpool * typo: move comments around * Fix tests --- Cargo.lock | 4 + client/basic-authorship/Cargo.toml | 2 + .../basic-authorship/src/basic_authorship.rs | 94 +++++++++++++------ 3 files changed, 69 insertions(+), 31 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 017bbd5904..42401f8ad0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5481,6 +5481,7 @@ dependencies = [ "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "substrate-block-builder 2.0.0", "substrate-client 2.0.0", @@ -5491,6 +5492,7 @@ dependencies = [ "substrate-telemetry 2.0.0", "substrate-test-runtime-client 2.0.0", "substrate-transaction-pool 2.0.0", + "tokio-executor 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -6963,6 +6965,8 @@ version = "0.2.0-alpha.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures-util-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-sync 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] diff --git a/client/basic-authorship/Cargo.toml b/client/basic-authorship/Cargo.toml index 4d3309fb2d..3732065f8c 100644 --- a/client/basic-authorship/Cargo.toml +++ b/client/basic-authorship/Cargo.toml @@ -17,6 +17,8 @@ inherents = { package = "substrate-inherents", path = "../../primitives/inherent substrate-telemetry = { path = "../telemetry" } transaction_pool = { package = "substrate-transaction-pool", path = "../transaction-pool" } block-builder = { package = "substrate-block-builder", path = "../block-builder" } +tokio-executor = { version = "0.2.0-alpha.6", features = ["blocking"] } [dev-dependencies] test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client" } +parking_lot = "0.9" diff --git a/client/basic-authorship/src/basic_authorship.rs b/client/basic-authorship/src/basic_authorship.rs index 7d8956152c..10b3b2b1a1 100644 --- a/client/basic-authorship/src/basic_authorship.rs +++ b/client/basic-authorship/src/basic_authorship.rs @@ -17,7 +17,6 @@ //! A consensus proposer for "basic" chains which use the primitive inherent-data. // FIXME #1021 move this into substrate-consensus-common -// use std::{time, sync::Arc}; use client_api::{error, CallExecutor}; @@ -45,10 +44,9 @@ pub struct ProposerFactory where A: txpool::ChainApi { pub transaction_pool: Arc>, } -impl consensus_common::Environment for -ProposerFactory, A> +impl ProposerFactory, A> where - A: txpool::ChainApi, + A: txpool::ChainApi + 'static, B: client_api::backend::Backend + Send + Sync + 'static, E: CallExecutor + Send + Sync + Clone + 'static, Block: BlockT, @@ -57,13 +55,11 @@ where as ProvideRuntimeApi>::Api: BlockBuilderApi, { - type Proposer = Proposer, A>; - type Error = error::Error; - - fn init( + pub fn init_with_now( &mut self, parent_header: &::Header, - ) -> Result { + now: Box time::Instant + Send + Sync>, + ) -> Result, A>, error::Error> { let parent_hash = parent_header.hash(); let id = BlockId::hash(parent_hash); @@ -71,32 +67,62 @@ where info!("Starting consensus session on top of parent {:?}", parent_hash); let proposer = Proposer { - client: self.client.clone(), - parent_hash, - parent_id: id, - parent_number: *parent_header.number(), - transaction_pool: self.transaction_pool.clone(), - now: Box::new(time::Instant::now), + inner: Arc::new(ProposerInner { + client: self.client.clone(), + parent_hash, + parent_id: id, + parent_number: *parent_header.number(), + transaction_pool: self.transaction_pool.clone(), + now, + }), }; Ok(proposer) } } +impl consensus_common::Environment for +ProposerFactory, A> +where + A: txpool::ChainApi + 'static, + B: client_api::backend::Backend + Send + Sync + 'static, + E: CallExecutor + Send + Sync + Clone + 'static, + Block: BlockT, + RA: Send + Sync + 'static, + SubstrateClient: ProvideRuntimeApi, + as ProvideRuntimeApi>::Api: + BlockBuilderApi, +{ + type Proposer = Proposer, A>; + type Error = error::Error; + + fn init( + &mut self, + parent_header: &::Header, + ) -> Result { + self.init_with_now(parent_header, Box::new(time::Instant::now)) + } +} + /// The proposer logic. pub struct Proposer { + inner: Arc>, +} + +/// Proposer inner, to wrap parameters under Arc. +struct ProposerInner { client: Arc, parent_hash: ::Hash, parent_id: BlockId, parent_number: <::Header as HeaderT>::Number, transaction_pool: Arc>, - now: Box time::Instant>, + now: Box time::Instant + Send + Sync>, } impl consensus_common::Proposer for Proposer, A> where - A: txpool::ChainApi, + A: txpool::ChainApi + 'static, B: client_api::backend::Backend + Send + Sync + 'static, E: CallExecutor + Send + Sync + Clone + 'static, Block: BlockT, @@ -105,7 +131,7 @@ where as ProvideRuntimeApi>::Api: BlockBuilderApi, { - type Create = futures::future::Ready>; + type Create = tokio_executor::blocking::Blocking>; type Error = error::Error; fn propose( @@ -114,14 +140,17 @@ where inherent_digests: DigestFor, max_duration: time::Duration, ) -> Self::Create { - // leave some time for evaluation and block finalization (33%) - let deadline = (self.now)() + max_duration - max_duration / 3; - futures::future::ready(self.propose_with(inherent_data, inherent_digests, deadline)) + let inner = self.inner.clone(); + tokio_executor::blocking::run(move || { + // leave some time for evaluation and block finalization (33%) + let deadline = (inner.now)() + max_duration - max_duration / 3; + inner.propose_with(inherent_data, inherent_digests, deadline) + }) } } -impl Proposer, A> where - A: txpool::ChainApi, +impl ProposerInner, A> where + A: txpool::ChainApi + 'static, B: client_api::backend::Backend + Send + Sync + 'static, E: CallExecutor + Send + Sync + Clone + 'static, Block: BlockT, @@ -232,8 +261,8 @@ impl Proposer, A> wh mod tests { use super::*; - use std::cell::RefCell; - use consensus_common::{Environment, Proposer}; + use parking_lot::Mutex; + use consensus_common::Proposer; use test_client::{self, runtime::{Extrinsic, Transfer}, AccountKeyring}; fn extrinsic(nonce: u64) -> Extrinsic { @@ -261,16 +290,19 @@ mod tests { transaction_pool: txpool.clone(), }; - let mut proposer = proposer_factory.init( + let cell = Mutex::new(time::Instant::now()); + let mut proposer = proposer_factory.init_with_now( &client.header(&BlockId::number(0)).unwrap().unwrap(), + Box::new(move || { + let mut value = cell.lock(); + let old = *value; + let new = old + time::Duration::from_secs(2); + *value = new; + old + }) ).unwrap(); // when - let cell = RefCell::new(time::Instant::now()); - proposer.now = Box::new(move || { - let new = *cell.borrow() + time::Duration::from_secs(2); - cell.replace(new) - }); let deadline = time::Duration::from_secs(3); let block = futures::executor::block_on(proposer.propose(Default::default(), Default::default(), deadline)) .unwrap(); -- GitLab From ac499c0b9bdf5914b3b03c188edb0e1b9da2ef7d Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Tue, 26 Nov 2019 20:06:32 +0100 Subject: [PATCH 023/172] Add graphs for each function name (#4214) --- client/grafana-data-source/src/lib.rs | 2 +- client/grafana-data-source/test/src/main.rs | 4 ++-- client/service/src/builder.rs | 18 +++++++++--------- client/tracing/src/lib.rs | 3 ++- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/client/grafana-data-source/src/lib.rs b/client/grafana-data-source/src/lib.rs index 7373f62705..09822adb58 100644 --- a/client/grafana-data-source/src/lib.rs +++ b/client/grafana-data-source/src/lib.rs @@ -36,7 +36,7 @@ mod networking; pub use server::run_server; pub use util::now_millis; -type Metrics = HashMap<&'static str, Vec<(f32, i64)>>; +type Metrics = HashMap>; lazy_static! { /// The `RwLock` wrapping the metrics. Not intended to be used directly. diff --git a/client/grafana-data-source/test/src/main.rs b/client/grafana-data-source/test/src/main.rs index bb2b317a6c..a4769e2bbb 100644 --- a/client/grafana-data-source/test/src/main.rs +++ b/client/grafana-data-source/test/src/main.rs @@ -26,8 +26,8 @@ async fn randomness() { let random = rand::thread_rng().gen_range(0.0, 1000.0); record_metrics!( - "random data" => random, - "random^2" => random * random + "random data".to_owned() => random, + "random^2".to_owned() => random * random ); } } diff --git a/client/service/src/builder.rs b/client/service/src/builder.rs index 03eea9eb3f..6d8bc53822 100644 --- a/client/service/src/builder.rs +++ b/client/service/src/builder.rs @@ -1005,15 +1005,15 @@ ServiceBuilder< "used_state_cache_size" => used_state_cache_size, ); record_metrics!( - "peers" => num_peers, - "height" => best_number, - "txcount" => txpool_status.ready, - "cpu" => cpu_usage, - "memory" => memory, - "finalized_height" => finalized_number, - "bandwidth_download" => bandwidth_download, - "bandwidth_upload" => bandwidth_upload, - "used_state_cache_size" => used_state_cache_size + "peers".to_owned() => num_peers, + "height".to_owned() => best_number, + "txcount".to_owned() => txpool_status.ready, + "cpu".to_owned() => cpu_usage, + "memory".to_owned() => memory, + "finalized_height".to_owned() => finalized_number, + "bandwidth_download".to_owned() => bandwidth_download, + "bandwidth_upload".to_owned() => bandwidth_upload, + "used_state_cache_size".to_owned() => used_state_cache_size ); Ok(()) diff --git a/client/tracing/src/lib.rs b/client/tracing/src/lib.rs index 664d5bf7a9..d1fe48cea3 100644 --- a/client/tracing/src/lib.rs +++ b/client/tracing/src/lib.rs @@ -202,5 +202,6 @@ fn send_telemetry(span_datum: SpanDatum) { } fn send_grafana(span_datum: SpanDatum) { - record_metrics!(span_datum.target => span_datum.overall_time.as_nanos()); + let name = format!("{}::{}", span_datum.target, span_datum.name); + record_metrics!(name => span_datum.overall_time.as_nanos()); } -- GitLab From b3a7c8e463ff7a63ce20e1eb14d8ccc63de4a412 Mon Sep 17 00:00:00 2001 From: Benjamin Kampmann Date: Tue, 26 Nov 2019 21:38:28 +0100 Subject: [PATCH 024/172] Remove all (non-dev) `client` references from `frame`, activate dependency enforcer (#4184) * Move transaction pool to primitives * move backend, errors into primitives * remove unused client depencies * Move rpc-api into primitives * Move peerset back to client * Move rpc/api back to client, move palette/support/rpc into utils * move support-rpc into subfolder * move system-rpc into utils * move transaction-pool and -graph back into client * fix broken imports * Clean up test primitives * Make support test utils independent of frame * remove unnecessary node dependencies from service * Reactivate dependency script: - only enforce the now achieved status quo will remain - allow for primitives to depend on /client for now without failing - more discriptive error message so people understand, what it wants - minor fix to differentiative between ../client and /client (which may be a subfolder) - don't allow this to fail anylonger. * fix doc comment * 'Should not' rather than 'must not'. * Revert unwanted dependency changes * fix faulty import * fixup derive_more version * fix wrong import path --- .gitlab-ci.yml | 1 - .maintain/ensure-deps.sh | 49 +++- Cargo.lock | 258 ++++++++++-------- Cargo.toml | 8 +- bin/node-template/Cargo.toml | 2 +- bin/node/cli/Cargo.toml | 2 +- bin/node/rpc/Cargo.toml | 4 +- bin/node/rpc/src/lib.rs | 4 +- client/Cargo.toml | 2 +- client/api/Cargo.toml | 2 +- client/api/src/backend.rs | 46 ++-- client/api/src/call_executor.rs | 16 +- client/api/src/client.rs | 8 +- client/api/src/lib.rs | 17 +- client/api/src/light.rs | 15 +- client/authority-discovery/Cargo.toml | 3 +- client/authority-discovery/src/error.rs | 2 +- client/authority-discovery/src/lib.rs | 24 +- client/basic-authorship/Cargo.toml | 3 +- .../basic-authorship/src/basic_authorship.rs | 26 +- client/block-builder/Cargo.toml | 1 + client/block-builder/src/lib.rs | 39 +-- client/cli/Cargo.toml | 2 +- client/cli/src/error.rs | 4 +- client/cli/src/informant.rs | 2 +- client/consensus/aura/Cargo.toml | 1 + client/consensus/aura/src/lib.rs | 21 +- client/consensus/babe/Cargo.toml | 2 +- client/consensus/babe/src/aux_schema.rs | 6 +- client/consensus/babe/src/epoch_changes.rs | 8 +- client/consensus/babe/src/lib.rs | 31 ++- client/consensus/babe/src/tests.rs | 2 +- client/consensus/pow/Cargo.toml | 1 + client/consensus/pow/src/lib.rs | 16 +- client/consensus/slots/Cargo.toml | 1 + client/consensus/slots/src/aux_schema.rs | 2 +- client/consensus/slots/src/lib.rs | 6 +- client/db/Cargo.toml | 2 +- client/db/src/cache/list_cache.rs | 2 +- client/db/src/cache/list_entry.rs | 2 +- client/db/src/cache/list_storage.rs | 2 +- client/db/src/cache/mod.rs | 4 +- client/db/src/children.rs | 8 +- client/db/src/lib.rs | 51 ++-- client/db/src/light.rs | 18 +- client/db/src/utils.rs | 49 ++-- client/finality-grandpa/Cargo.toml | 2 +- client/finality-grandpa/src/aux_schema.rs | 2 +- .../finality-grandpa/src/consensus_changes.rs | 4 +- client/finality-grandpa/src/environment.rs | 6 +- client/finality-grandpa/src/finality_proof.rs | 7 +- client/finality-grandpa/src/import.rs | 11 +- client/finality-grandpa/src/justification.rs | 3 +- client/finality-grandpa/src/lib.rs | 10 +- client/finality-grandpa/src/light_import.rs | 9 +- client/finality-grandpa/src/observer.rs | 2 +- client/finality-grandpa/src/tests.rs | 4 +- client/header-metadata/Cargo.toml | 10 - client/network/Cargo.toml | 4 +- client/network/src/chain.rs | 4 +- client/network/src/error.rs | 4 +- client/network/src/on_demand_layer.rs | 2 +- client/network/src/protocol/light_dispatch.rs | 4 +- client/network/src/protocol/sync.rs | 3 +- .../src/protocol/sync/extra_requests.rs | 4 +- client/network/src/test/mod.rs | 5 +- client/offchain/Cargo.toml | 2 +- {primitives => client}/peerset/Cargo.toml | 0 {primitives => client}/peerset/src/lib.rs | 0 .../peerset/src/peersstate.rs | 0 {primitives => client}/peerset/tests/fuzz.rs | 0 client/rpc/Cargo.toml | 5 +- client/rpc/api/Cargo.toml | 4 +- client/rpc/src/author/mod.rs | 2 +- client/rpc/src/chain/mod.rs | 2 +- client/rpc/src/state/mod.rs | 4 +- client/rpc/src/state/state_full.rs | 5 +- client/rpc/src/state/state_light.rs | 4 +- client/service/Cargo.toml | 6 +- client/service/src/builder.rs | 3 +- client/service/src/error.rs | 4 +- client/src/call_executor.rs | 18 +- client/src/cht.rs | 2 +- client/src/client.rs | 193 +++++++------ client/src/in_mem.rs | 101 ++++--- client/src/leaves.rs | 8 +- client/src/lib.rs | 1 - client/src/light/backend.rs | 4 +- client/src/light/blockchain.rs | 8 +- client/src/light/call_executor.rs | 5 +- client/src/light/fetcher.rs | 10 +- client/src/light/mod.rs | 2 +- client/transaction-pool/Cargo.toml | 4 +- client/transaction-pool/graph/Cargo.toml | 2 +- .../transaction-pool/graph/benches/basics.rs | 2 +- frame/contracts/rpc/Cargo.toml | 2 +- frame/contracts/rpc/src/lib.rs | 2 +- frame/elections-phragmen/Cargo.toml | 1 + frame/elections-phragmen/src/lib.rs | 3 +- frame/staking/Cargo.toml | 1 + frame/staking/src/tests.rs | 3 +- frame/support/src/lib.rs | 41 --- frame/system/rpc/Cargo.toml | 23 -- frame/transaction-payment/rpc/Cargo.toml | 2 +- frame/transaction-payment/rpc/src/lib.rs | 2 +- primitives/blockchain/Cargo.toml | 17 ++ .../blockchain/src/backend.rs | 4 +- .../blockchain}/src/error.rs | 50 +++- .../blockchain/src/header_metadata.rs | 0 primitives/blockchain/src/lib.rs | 25 ++ primitives/phragmen/Cargo.toml | 2 +- primitives/phragmen/src/lib.rs | 2 + primitives/phragmen/src/tests.rs | 2 +- primitives/sr-api/test/Cargo.toml | 1 + primitives/sr-api/test/tests/decl_and_impl.rs | 3 +- test/utils/Cargo.toml | 5 + test/utils/client/Cargo.toml | 1 + test/utils/client/src/client_ext.rs | 4 +- test/utils/primitives/Cargo.toml | 50 ---- test/utils/runtime/client/Cargo.toml | 1 + .../runtime/client/src/block_builder_ext.rs | 11 +- test/utils/src/lib.rs | 54 ++++ test/utils/transaction-factory/Cargo.toml | 1 + .../transaction-factory/src/complex_mode.rs | 2 +- test/utils/transaction-factory/src/lib.rs | 4 +- .../transaction-factory/src/simple_modes.rs | 2 +- .../frame/rpc/support}/Cargo.toml | 10 +- .../frame/rpc/support}/src/lib.rs | 8 +- utils/frame/rpc/system/Cargo.toml | 24 ++ .../rpc => utils/frame/rpc/system}/src/lib.rs | 13 +- 130 files changed, 836 insertions(+), 816 deletions(-) delete mode 100644 client/header-metadata/Cargo.toml rename {primitives => client}/peerset/Cargo.toml (100%) rename {primitives => client}/peerset/src/lib.rs (100%) rename {primitives => client}/peerset/src/peersstate.rs (100%) rename {primitives => client}/peerset/tests/fuzz.rs (100%) delete mode 100644 frame/system/rpc/Cargo.toml create mode 100644 primitives/blockchain/Cargo.toml rename client/api/src/blockchain.rs => primitives/blockchain/src/backend.rs (98%) rename {client/api => primitives/blockchain}/src/error.rs (77%) rename client/header-metadata/src/lib.rs => primitives/blockchain/src/header_metadata.rs (100%) create mode 100644 primitives/blockchain/src/lib.rs create mode 100644 test/utils/Cargo.toml create mode 100644 test/utils/src/lib.rs rename {frame/support/rpc => utils/frame/rpc/support}/Cargo.toml (54%) rename {frame/support/rpc => utils/frame/rpc/support}/src/lib.rs (95%) create mode 100644 utils/frame/rpc/system/Cargo.toml rename {frame/system/rpc => utils/frame/rpc/system}/src/lib.rs (93%) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e4226ee8ad..439fda5fab 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -148,7 +148,6 @@ test-linux-stable: &test-linux test-dependency-rules: &test-linux stage: test <<: *docker-env - allow_failure: true except: variables: - $DEPLOY_TAG diff --git a/.maintain/ensure-deps.sh b/.maintain/ensure-deps.sh index d8383cd313..7087200cef 100755 --- a/.maintain/ensure-deps.sh +++ b/.maintain/ensure-deps.sh @@ -3,36 +3,41 @@ # The script is meant to check if the rules regarding packages # dependencies are satisfied. # The general format is: -# [top-lvl-dir]<[crate-name-prefix] +# [top-lvl-dir] MESSAGE/[other-top-dir] # For instance no crate within `./client` directory # is allowed to import any crate with a directory path containing `frame`. -# Such rule is just: `client /dev/null +} + +for rule in "${MUST_NOT[@]}" +do + check_rule "$rule"; +done + +# Only the MUST NOT will be counted towards failure +HARD_VIOLATIONS=${#VIOLATIONS[@]} + + +for rule in "${PLEASE_DONT[@]}" +do + check_rule "$rule"; done # Display violations and fail @@ -58,4 +77,4 @@ EOF I=$I+1 done -exit ${#VIOLATIONS[@]} +exit $HARD_VIOLATIONS diff --git a/Cargo.lock b/Cargo.lock index 42401f8ad0..317215e5b6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1328,22 +1328,6 @@ dependencies = [ "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "frame-support-rpc" -version = "2.0.0" -dependencies = [ - "frame-support 2.0.0", - "frame-system 2.0.0", - "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-client-transports 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "substrate-primitives-storage 2.0.0", - "substrate-rpc-api 2.0.0", - "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "frame-support-test" version = "2.0.0" @@ -1377,26 +1361,6 @@ dependencies = [ "substrate-primitives 2.0.0", ] -[[package]] -name = "frame-system-rpc" -version = "2.0.0" -dependencies = [ - "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "frame-system-rpc-runtime-api 2.0.0", - "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core-client 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-derive 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-primitives 2.0.0", - "substrate-client 2.0.0", - "substrate-primitives 2.0.0", - "substrate-test-runtime-client 2.0.0", - "substrate-transaction-pool 2.0.0", -] - [[package]] name = "frame-system-rpc-runtime-api" version = "2.0.0" @@ -3041,6 +3005,7 @@ dependencies = [ "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-transaction-pool 2.0.0", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "sp-finality-tracker 2.0.0", "sp-timestamp 2.0.0", @@ -3071,7 +3036,6 @@ dependencies = [ "substrate-service 2.0.0", "substrate-service-test 2.0.0", "substrate-telemetry 2.0.0", - "substrate-transaction-pool 2.0.0", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", "transaction-factory 0.0.1", @@ -3124,15 +3088,15 @@ dependencies = [ name = "node-rpc" version = "2.0.0" dependencies = [ - "frame-system-rpc 2.0.0", "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "node-primitives 2.0.0", "node-runtime 2.0.0", "pallet-contracts-rpc 2.0.0", "pallet-transaction-payment-rpc 2.0.0", + "sc-transaction-pool 2.0.0", "sr-primitives 2.0.0", "substrate-client 2.0.0", - "substrate-transaction-pool 2.0.0", + "substrate-frame-rpc-system 2.0.0", ] [[package]] @@ -3217,6 +3181,7 @@ dependencies = [ "node-template-runtime 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-transaction-pool 2.0.0", "sr-io 2.0.0", "sr-primitives 2.0.0", "substrate-basic-authorship 2.0.0", @@ -3232,7 +3197,6 @@ dependencies = [ "substrate-network 2.0.0", "substrate-primitives 2.0.0", "substrate-service 2.0.0", - "substrate-transaction-pool 2.0.0", "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", "trie-root 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "vergen 3.0.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3607,8 +3571,8 @@ dependencies = [ "pallet-contracts-rpc-runtime-api 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-blockchain 2.0.0", "sr-primitives 2.0.0", - "substrate-client 2.0.0", "substrate-primitives 2.0.0", "substrate-rpc-primitives 2.0.0", ] @@ -3672,6 +3636,7 @@ dependencies = [ "sr-std 2.0.0", "substrate-phragmen 2.0.0", "substrate-primitives 2.0.0", + "substrate-test-utils 2.0.0", ] [[package]] @@ -3909,6 +3874,7 @@ dependencies = [ "substrate-keyring 2.0.0", "substrate-phragmen 2.0.0", "substrate-primitives 2.0.0", + "substrate-test-utils 2.0.0", ] [[package]] @@ -3978,8 +3944,8 @@ dependencies = [ "pallet-transaction-payment-rpc-runtime-api 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-blockchain 2.0.0", "sr-primitives 2.0.0", - "substrate-client 2.0.0", "substrate-primitives 2.0.0", "substrate-rpc-primitives 2.0.0", ] @@ -4863,6 +4829,63 @@ dependencies = [ "winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "sc-rpc-api" +version = "2.0.0" +dependencies = [ + "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core-client 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-derive 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-pubsub 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-transaction-graph 2.0.0", + "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "sr-version 2.0.0", + "substrate-primitives 2.0.0", + "substrate-rpc-primitives 2.0.0", +] + +[[package]] +name = "sc-transaction-graph" +version = "2.0.0" +dependencies = [ + "assert_matches 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "criterion 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "sr-primitives 2.0.0", + "substrate-primitives 2.0.0", + "substrate-test-runtime 2.0.0", +] + +[[package]] +name = "sc-transaction-pool" +version = "2.0.0" +dependencies = [ + "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-transaction-graph 2.0.0", + "sr-api 2.0.0", + "sr-primitives 2.0.0", + "substrate-keyring 2.0.0", + "substrate-primitives 2.0.0", + "substrate-test-runtime-client 2.0.0", + "substrate-transaction-pool-runtime-api 2.0.0", +] + [[package]] name = "schannel" version = "0.1.16" @@ -5166,6 +5189,21 @@ dependencies = [ "substrate-inherents 2.0.0", ] +[[package]] +name = "sp-blockchain" +version = "2.0.0" +dependencies = [ + "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "lru 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sr-primitives 2.0.0", + "substrate-block-builder-runtime-api 2.0.0", + "substrate-consensus-common 2.0.0", + "substrate-state-machine 2.0.0", +] + [[package]] name = "sp-finality-tracker" version = "2.0.0" @@ -5228,6 +5266,7 @@ version = "2.0.0" dependencies = [ "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustversion 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-blockchain 2.0.0", "sr-api 2.0.0", "sr-primitives 2.0.0", "sr-version 2.0.0", @@ -5452,6 +5491,7 @@ dependencies = [ "prost 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "prost-build 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-blockchain 2.0.0", "sr-api 2.0.0", "sr-primitives 2.0.0", "substrate-authority-discovery-primitives 2.0.0", @@ -5482,6 +5522,8 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-transaction-pool 2.0.0", + "sp-blockchain 2.0.0", "sr-primitives 2.0.0", "substrate-block-builder 2.0.0", "substrate-client 2.0.0", @@ -5491,7 +5533,6 @@ dependencies = [ "substrate-primitives 2.0.0", "substrate-telemetry 2.0.0", "substrate-test-runtime-client 2.0.0", - "substrate-transaction-pool 2.0.0", "tokio-executor 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5511,6 +5552,7 @@ name = "substrate-block-builder" version = "2.0.0" dependencies = [ "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-blockchain 2.0.0", "sr-api 2.0.0", "sr-primitives 2.0.0", "substrate-block-builder-runtime-api 2.0.0", @@ -5576,10 +5618,10 @@ dependencies = [ "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "rpassword 4.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-blockchain 2.0.0", "sr-primitives 2.0.0", "structopt 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-client-api 2.0.0", - "substrate-header-metadata 2.0.0", "substrate-keyring 2.0.0", "substrate-network 2.0.0", "substrate-panic-handler 2.0.0", @@ -5608,6 +5650,7 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-blockchain 2.0.0", "sr-api 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -5618,7 +5661,6 @@ dependencies = [ "substrate-consensus-common 2.0.0", "substrate-executor 2.0.0", "substrate-externalities 2.0.0", - "substrate-header-metadata 2.0.0", "substrate-inherents 2.0.0", "substrate-keyring 2.0.0", "substrate-panic-handler 2.0.0", @@ -5645,6 +5687,7 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-blockchain 2.0.0", "sr-api 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -5654,7 +5697,6 @@ dependencies = [ "substrate-consensus-common 2.0.0", "substrate-executor 2.0.0", "substrate-externalities 2.0.0", - "substrate-header-metadata 2.0.0", "substrate-inherents 2.0.0", "substrate-keyring 2.0.0", "substrate-panic-handler 2.0.0", @@ -5681,12 +5723,12 @@ dependencies = [ "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "quickcheck 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-blockchain 2.0.0", "sr-primitives 2.0.0", "substrate-client 2.0.0", "substrate-client-api 2.0.0", "substrate-consensus-common 2.0.0", "substrate-executor 2.0.0", - "substrate-header-metadata 2.0.0", "substrate-keyring 2.0.0", "substrate-primitives 2.0.0", "substrate-state-db 2.0.0", @@ -5707,6 +5749,7 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-blockchain 2.0.0", "sp-timestamp 2.0.0", "sr-api 2.0.0", "sr-io 2.0.0", @@ -5765,6 +5808,7 @@ dependencies = [ "pdqselect 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "schnorrkel 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-blockchain 2.0.0", "sp-timestamp 2.0.0", "sr-api 2.0.0", "sr-io 2.0.0", @@ -5780,7 +5824,6 @@ dependencies = [ "substrate-consensus-slots 2.0.0", "substrate-consensus-uncles 2.0.0", "substrate-executor 2.0.0", - "substrate-header-metadata 2.0.0", "substrate-inherents 2.0.0", "substrate-keyring 2.0.0", "substrate-keystore 2.0.0", @@ -5835,6 +5878,7 @@ dependencies = [ "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-blockchain 2.0.0", "sp-timestamp 2.0.0", "sr-primitives 2.0.0", "substrate-block-builder-runtime-api 2.0.0", @@ -5865,6 +5909,7 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-blockchain 2.0.0", "sr-primitives 2.0.0", "substrate-client-api 2.0.0", "substrate-consensus-common 2.0.0", @@ -5960,6 +6005,7 @@ dependencies = [ "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-blockchain 2.0.0", "sp-finality-tracker 2.0.0", "sr-api 2.0.0", "sr-primitives 2.0.0", @@ -5968,7 +6014,6 @@ dependencies = [ "substrate-consensus-babe-primitives 2.0.0", "substrate-consensus-common 2.0.0", "substrate-finality-grandpa-primitives 2.0.0", - "substrate-header-metadata 2.0.0", "substrate-inherents 2.0.0", "substrate-keyring 2.0.0", "substrate-keystore 2.0.0", @@ -5996,12 +6041,40 @@ dependencies = [ ] [[package]] -name = "substrate-header-metadata" +name = "substrate-frame-rpc-support" version = "2.0.0" dependencies = [ - "lru 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "frame-support 2.0.0", + "frame-system 2.0.0", + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-client-transports 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-rpc-api 2.0.0", + "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "substrate-primitives-storage 2.0.0", + "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "substrate-frame-rpc-system" +version = "2.0.0" +dependencies = [ + "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "frame-system-rpc-runtime-api 2.0.0", + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core-client 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-derive 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-transaction-graph 2.0.0", + "sc-transaction-pool 2.0.0", + "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-blockchain 2.0.0", "sr-primitives 2.0.0", + "substrate-primitives 2.0.0", + "substrate-test-runtime-client 2.0.0", ] [[package]] @@ -6070,6 +6143,7 @@ dependencies = [ "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "slog_derive 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-blockchain 2.0.0", "sr-arithmetic 2.0.0", "sr-primitives 2.0.0", "substrate-block-builder 2.0.0", @@ -6077,7 +6151,6 @@ dependencies = [ "substrate-client-api 2.0.0", "substrate-consensus-babe-primitives 2.0.0", "substrate-consensus-common 2.0.0", - "substrate-header-metadata 2.0.0", "substrate-keyring 2.0.0", "substrate-peerset 2.0.0", "substrate-primitives 2.0.0", @@ -6109,6 +6182,7 @@ dependencies = [ "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-transaction-pool 2.0.0", "sr-api 2.0.0", "sr-primitives 2.0.0", "substrate-client-api 2.0.0", @@ -6118,7 +6192,6 @@ dependencies = [ "substrate-offchain-primitives 2.0.0", "substrate-primitives 2.0.0", "substrate-test-runtime-client 2.0.0", - "substrate-transaction-pool 2.0.0", "threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -6154,12 +6227,12 @@ dependencies = [ name = "substrate-phragmen" version = "2.0.0" dependencies = [ - "frame-support 2.0.0", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", + "substrate-test-utils 2.0.0", ] [[package]] @@ -6229,7 +6302,10 @@ dependencies = [ "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-rpc-api 2.0.0", + "sc-transaction-pool 2.0.0", "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-blockchain 2.0.0", "sr-api 2.0.0", "sr-io 2.0.0", "sr-primitives 2.0.0", @@ -6240,36 +6316,13 @@ dependencies = [ "substrate-keystore 2.0.0", "substrate-network 2.0.0", "substrate-primitives 2.0.0", - "substrate-rpc-api 2.0.0", "substrate-rpc-primitives 2.0.0", "substrate-session 2.0.0", "substrate-state-machine 2.0.0", "substrate-test-runtime-client 2.0.0", - "substrate-transaction-pool 2.0.0", "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "substrate-rpc-api" -version = "2.0.0" -dependencies = [ - "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core-client 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-derive 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-pubsub 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-version 2.0.0", - "substrate-primitives 2.0.0", - "substrate-rpc-primitives 2.0.0", - "substrate-transaction-graph 2.0.0", -] - [[package]] name = "substrate-rpc-primitives" version = "2.0.0" @@ -6370,15 +6423,14 @@ dependencies = [ "grafana-data-source 2.0.0", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "node-executor 2.0.0", - "node-primitives 2.0.0", - "node-runtime 2.0.0", "parity-multiaddr 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-transaction-pool 2.0.0", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-blockchain 2.0.0", "sr-api 2.0.0", "sr-io 2.0.0", "sr-primitives 2.0.0", @@ -6402,7 +6454,6 @@ dependencies = [ "substrate-telemetry 2.0.0", "substrate-test-runtime-client 2.0.0", "substrate-tracing 2.0.0", - "substrate-transaction-pool 2.0.0", "substrate-transaction-pool-runtime-api 2.0.0", "sysinfo 0.9.6 (registry+https://github.com/rust-lang/crates.io-index)", "target_info 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -6498,6 +6549,7 @@ dependencies = [ "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-blockchain 2.0.0", "sr-primitives 2.0.0", "substrate-client 2.0.0", "substrate-client-api 2.0.0", @@ -6565,6 +6617,7 @@ name = "substrate-test-runtime-client" version = "2.0.0" dependencies = [ "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-blockchain 2.0.0", "sr-primitives 2.0.0", "substrate-block-builder 2.0.0", "substrate-client 2.0.0", @@ -6574,6 +6627,10 @@ dependencies = [ "substrate-test-runtime 2.0.0", ] +[[package]] +name = "substrate-test-utils" +version = "2.0.0" + [[package]] name = "substrate-tracing" version = "2.0.0" @@ -6586,42 +6643,6 @@ dependencies = [ "tracing-core 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "substrate-transaction-graph" -version = "2.0.0" -dependencies = [ - "assert_matches 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "criterion 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", - "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-primitives 2.0.0", - "substrate-primitives 2.0.0", - "substrate-test-runtime 2.0.0", -] - -[[package]] -name = "substrate-transaction-pool" -version = "2.0.0" -dependencies = [ - "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-api 2.0.0", - "sr-primitives 2.0.0", - "substrate-keyring 2.0.0", - "substrate-primitives 2.0.0", - "substrate-test-runtime-client 2.0.0", - "substrate-transaction-graph 2.0.0", - "substrate-transaction-pool-runtime-api 2.0.0", -] - [[package]] name = "substrate-transaction-pool-runtime-api" version = "2.0.0" @@ -7194,6 +7215,7 @@ version = "0.0.1" dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-blockchain 2.0.0", "sr-api 2.0.0", "sr-primitives 2.0.0", "substrate-block-builder-runtime-api 2.0.0", diff --git a/Cargo.toml b/Cargo.toml index d398fd78b2..84fbb2430b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,11 +27,11 @@ members = [ "client/executor", "client/executor/runtime-test", "client/finality-grandpa", - "client/header-metadata", "client/tracing", "client/keystore", "client/network", "client/offchain", + "client/peerset", "client/rpc-servers", "client/rpc", "client/rpc/api", @@ -79,10 +79,8 @@ members = [ "frame/support/procedural", "frame/support/procedural/tools", "frame/support/procedural/tools/derive", - "frame/support/rpc", "frame/support/test", "frame/system", - "frame/system/rpc", "frame/system/rpc/runtime-api", "frame/timestamp", "frame/transaction-payment", @@ -94,6 +92,7 @@ members = [ "primitives/authority-discovery", "primitives/authorship", "primitives/block-builder/runtime-api", + "primitives/blockchain", "primitives/consensus/aura", "primitives/consensus/babe", "primitives/consensus/common", @@ -108,7 +107,6 @@ members = [ "primitives/keyring", "primitives/offchain", "primitives/panic-handler", - "primitives/peerset", "primitives/phragmen", "primitives/rpc", "primitives/runtime-interface", @@ -139,6 +137,8 @@ members = [ "test/utils/transaction-factory", "utils/build-script-utils", "utils/fork-tree", + "utils/frame/rpc/support", + "utils/frame/rpc/system", "utils/wasm-builder", ] diff --git a/bin/node-template/Cargo.toml b/bin/node-template/Cargo.toml index 11373e8d71..5e0ee24547 100644 --- a/bin/node-template/Cargo.toml +++ b/bin/node-template/Cargo.toml @@ -24,7 +24,7 @@ primitives = { package = "substrate-primitives", path = "../../primitives/core" substrate-executor = { path = "../../client/executor" } substrate-service = { path = "../../client/service" } inherents = { package = "substrate-inherents", path = "../../primitives/inherents" } -transaction-pool = { package = "substrate-transaction-pool", path = "../../client/transaction-pool" } +transaction-pool = { package = "sc-transaction-pool", path = "../../client/transaction-pool" } network = { package = "substrate-network", path = "../../client/network" } aura = { package = "substrate-consensus-aura", path = "../../client/consensus/aura" } aura-primitives = { package = "substrate-consensus-aura-primitives", path = "../../primitives/consensus/aura" } diff --git a/bin/node/cli/Cargo.toml b/bin/node/cli/Cargo.toml index 01d7b1a48b..e9705f52dc 100644 --- a/bin/node/cli/Cargo.toml +++ b/bin/node/cli/Cargo.toml @@ -49,7 +49,7 @@ runtime-io = { package = "sr-io", path = "../../../primitives/sr-io" } client-api = { package = "substrate-client-api", path = "../../../client/api" } client = { package = "substrate-client", path = "../../../client/" } chain-spec = { package = "substrate-chain-spec", path = "../../../client/chain-spec" } -transaction_pool = { package = "substrate-transaction-pool", path = "../../../client/transaction-pool" } +transaction_pool = { package = "sc-transaction-pool", path = "../../../client/transaction-pool" } network = { package = "substrate-network", path = "../../../client/network" } babe = { package = "substrate-consensus-babe", path = "../../../client/consensus/babe" } grandpa = { package = "substrate-finality-grandpa", path = "../../../client/finality-grandpa" } diff --git a/bin/node/rpc/Cargo.toml b/bin/node/rpc/Cargo.toml index e9889854ee..d267118c12 100644 --- a/bin/node/rpc/Cargo.toml +++ b/bin/node/rpc/Cargo.toml @@ -12,5 +12,5 @@ node-runtime = { path = "../runtime" } sr-primitives = { path = "../../../primitives/sr-primitives" } pallet-contracts-rpc = { path = "../../../frame/contracts/rpc/" } pallet-transaction-payment-rpc = { path = "../../../frame/transaction-payment/rpc/" } -frame-system-rpc = { path = "../../../frame/system/rpc/" } -transaction_pool = { package = "substrate-transaction-pool", path = "../../../client/transaction-pool" } +substrate-frame-rpc-system = { path = "../../../utils/frame/rpc/system" } +transaction_pool = { package = "sc-transaction-pool", path = "../../../client/transaction-pool" } diff --git a/bin/node/rpc/src/lib.rs b/bin/node/rpc/src/lib.rs index 7f19af45e4..cb7aee283b 100644 --- a/bin/node/rpc/src/lib.rs +++ b/bin/node/rpc/src/lib.rs @@ -41,13 +41,13 @@ pub fn create(client: Arc, pool: Arc>) -> jsonrpc_core::IoHa C: ProvideRuntimeApi, C: client::blockchain::HeaderBackend, C: Send + Sync + 'static, - C::Api: frame_system_rpc::AccountNonceApi, + C::Api: substrate_frame_rpc_system::AccountNonceApi, C::Api: pallet_contracts_rpc::ContractsRuntimeApi, C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi, P: ChainApi + Sync + Send + 'static, M: jsonrpc_core::Metadata + Default, { - use frame_system_rpc::{System, SystemApi}; + use substrate_frame_rpc_system::{System, SystemApi}; use pallet_contracts_rpc::{Contracts, ContractsApi}; use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi}; diff --git a/client/Cargo.toml b/client/Cargo.toml index d7270dff37..b78812d882 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -15,7 +15,6 @@ externalities = { package = "substrate-externalities", path = "../primitives/ext fnv = { version = "1.0.6" } futures = { version = "0.3.1", features = ["compat"] } hash-db = { version = "0.15.2" } -header-metadata = { package = "substrate-header-metadata", path = "header-metadata" } hex-literal = { version = "0.2.1" } inherents = { package = "substrate-inherents", path = "../primitives/inherents" } keyring = { package = "substrate-keyring", path = "../primitives/keyring" } @@ -27,6 +26,7 @@ rstd = { package = "sr-std", path = "../primitives/sr-std" } runtime-version = { package = "sr-version", path = "../primitives/sr-version" } sr-api = { path = "../primitives/sr-api" } sr-primitives = { path = "../primitives/sr-primitives" } +sp-blockchain = { path = "../primitives/blockchain" } state-machine = { package = "substrate-state-machine", path = "../primitives/state-machine" } substrate-telemetry = { path = "telemetry" } trie = { package = "substrate-trie", path = "../primitives/trie" } diff --git a/client/api/Cargo.toml b/client/api/Cargo.toml index 6af1086586..ff83aa412b 100644 --- a/client/api/Cargo.toml +++ b/client/api/Cargo.toml @@ -14,7 +14,7 @@ externalities = { package = "substrate-externalities", path = "../../primitives/ fnv = { version = "1.0.6" } futures = { version = "0.3.1" } hash-db = { version = "0.15.2", default-features = false } -header-metadata = { package = "substrate-header-metadata", path = "../header-metadata" } +sp-blockchain = { path = "../../primitives/blockchain" } hex-literal = { version = "0.2.1" } inherents = { package = "substrate-inherents", path = "../../primitives/inherents", default-features = false } keyring = { package = "substrate-keyring", path = "../../primitives/keyring" } diff --git a/client/api/src/backend.rs b/client/api/src/backend.rs index e44325f088..220aede2f5 100644 --- a/client/api/src/backend.rs +++ b/client/api/src/backend.rs @@ -28,9 +28,9 @@ use crate::{ blockchain::{ Backend as BlockchainBackend, well_known_cache_keys }, - error, light::RemoteBlockchain, }; +use sp_blockchain; use consensus::BlockOrigin; use hash_db::Hasher; use parking_lot::RwLock; @@ -116,7 +116,7 @@ pub trait BlockImportOperation where /// Returns pending state. /// /// Returns None for backends with locally-unavailable state data. - fn state(&self) -> error::Result>; + fn state(&self) -> sp_blockchain::Result>; /// Append block data to the transaction. fn set_block_data( @@ -125,37 +125,37 @@ pub trait BlockImportOperation where body: Option>, justification: Option, state: NewBlockState, - ) -> error::Result<()>; + ) -> sp_blockchain::Result<()>; /// Update cached data. fn update_cache(&mut self, cache: HashMap>); /// Inject storage data into the database. - fn update_db_storage(&mut self, update: >::Transaction) -> error::Result<()>; + fn update_db_storage(&mut self, update: >::Transaction) -> sp_blockchain::Result<()>; /// Inject storage data into the database replacing any existing data. - fn reset_storage(&mut self, top: StorageOverlay, children: ChildrenStorageOverlay) -> error::Result; + fn reset_storage(&mut self, top: StorageOverlay, children: ChildrenStorageOverlay) -> sp_blockchain::Result; /// Set storage changes. fn update_storage( &mut self, update: StorageCollection, child_update: ChildStorageCollection, - ) -> error::Result<()>; + ) -> sp_blockchain::Result<()>; /// Inject changes trie data into the database. - fn update_changes_trie(&mut self, update: ChangesTrieTransaction>) -> error::Result<()>; + fn update_changes_trie(&mut self, update: ChangesTrieTransaction>) -> sp_blockchain::Result<()>; /// Insert auxiliary keys. /// /// Values are `None` if should be deleted. - fn insert_aux(&mut self, ops: I) -> error::Result<()> + fn insert_aux(&mut self, ops: I) -> sp_blockchain::Result<()> where I: IntoIterator, Option>)>; /// Mark a block as finalized. - fn mark_finalized(&mut self, id: BlockId, justification: Option) -> error::Result<()>; + fn mark_finalized(&mut self, id: BlockId, justification: Option) -> sp_blockchain::Result<()>; /// Mark a block as new head. If both block import and set head are specified, set head overrides block import's best block rule. - fn mark_head(&mut self, id: BlockId) -> error::Result<()>; + fn mark_head(&mut self, id: BlockId) -> sp_blockchain::Result<()>; } /// Finalize Facilities @@ -175,7 +175,7 @@ pub trait Finalizer, B: Backend, justification: Option, notify: bool, - ) -> error::Result<()>; + ) -> sp_blockchain::Result<()>; /// Finalize a block. @@ -196,7 +196,7 @@ pub trait Finalizer, B: Backend, justification: Option, notify: bool, - ) -> error::Result<()>; + ) -> sp_blockchain::Result<()>; } @@ -211,10 +211,10 @@ pub trait AuxStore { 'c: 'a, I: IntoIterator, D: IntoIterator, - >(&self, insert: I, delete: D) -> error::Result<()>; + >(&self, insert: I, delete: D) -> sp_blockchain::Result<()>; /// Query auxiliary data from key-value store. - fn get_aux(&self, key: &[u8]) -> error::Result>>; + fn get_aux(&self, key: &[u8]) -> sp_blockchain::Result>>; } /// Client backend. @@ -245,18 +245,18 @@ pub trait Backend: AuxStore + Send + Sync where /// Begin a new block insertion transaction with given parent block id. /// /// When constructing the genesis, this is called with all-zero hash. - fn begin_operation(&self) -> error::Result; + fn begin_operation(&self) -> sp_blockchain::Result; /// Note an operation to contain state transition. - fn begin_state_operation(&self, operation: &mut Self::BlockImportOperation, block: BlockId) -> error::Result<()>; + fn begin_state_operation(&self, operation: &mut Self::BlockImportOperation, block: BlockId) -> sp_blockchain::Result<()>; /// Commit block insertion. - fn commit_operation(&self, transaction: Self::BlockImportOperation) -> error::Result<()>; + fn commit_operation(&self, transaction: Self::BlockImportOperation) -> sp_blockchain::Result<()>; /// Finalize block with given Id. /// /// This should only be called if the parent of the given block has been finalized. - fn finalize_block(&self, block: BlockId, justification: Option) -> error::Result<()>; + fn finalize_block(&self, block: BlockId, justification: Option) -> sp_blockchain::Result<()>; /// Returns reference to blockchain backend. fn blockchain(&self) -> &Self::Blockchain; @@ -276,17 +276,17 @@ pub trait Backend: AuxStore + Send + Sync where } /// Returns state backend with post-state of given block. - fn state_at(&self, block: BlockId) -> error::Result; + fn state_at(&self, block: BlockId) -> sp_blockchain::Result; /// Destroy state and save any useful data, such as cache. - fn destroy_state(&self, _state: Self::State) -> error::Result<()> { + fn destroy_state(&self, _state: Self::State) -> sp_blockchain::Result<()> { Ok(()) } /// Attempts to revert the chain by `n` blocks. /// /// Returns the number of blocks that were successfully reverted. - fn revert(&self, n: NumberFor) -> error::Result>; + fn revert(&self, n: NumberFor) -> sp_blockchain::Result>; /// Insert auxiliary data into key-value store. fn insert_aux< @@ -295,12 +295,12 @@ pub trait Backend: AuxStore + Send + Sync where 'c: 'a, I: IntoIterator, D: IntoIterator, - >(&self, insert: I, delete: D) -> error::Result<()> + >(&self, insert: I, delete: D) -> sp_blockchain::Result<()> { AuxStore::insert_aux(self, insert, delete) } /// Query auxiliary data from key-value store. - fn get_aux(&self, key: &[u8]) -> error::Result>> { + fn get_aux(&self, key: &[u8]) -> sp_blockchain::Result>> { AuxStore::get_aux(self, key) } diff --git a/client/api/src/call_executor.rs b/client/api/src/call_executor.rs index 7327333633..11a18d2e01 100644 --- a/client/api/src/call_executor.rs +++ b/client/api/src/call_executor.rs @@ -31,7 +31,7 @@ use hash_db::Hasher; use primitives::{Blake2Hasher, NativeOrEncoded}; use sr_api::{ProofRecorder, InitializeBlock}; -use crate::error; +use sp_blockchain; /// Method call executor. pub trait CallExecutor @@ -53,7 +53,7 @@ where call_data: &[u8], strategy: ExecutionStrategy, extensions: Option, - ) -> Result, error::Error>; + ) -> Result, sp_blockchain::Error>; /// Execute a contextual call on top of state in a block of a given hash. /// @@ -62,7 +62,7 @@ where /// of the execution context. fn contextual_call< 'a, - IB: Fn() -> error::Result<()>, + IB: Fn() -> sp_blockchain::Result<()>, EM: Fn( Result, Self::Error>, Result, Self::Error> @@ -81,12 +81,12 @@ where native_call: Option, proof_recorder: &Option>, extensions: Option, - ) -> error::Result> where ExecutionManager: Clone; + ) -> sp_blockchain::Result> where ExecutionManager: Clone; /// Extract RuntimeVersion of given block /// /// No changes are made. - fn runtime_version(&self, id: &BlockId) -> Result; + fn runtime_version(&self, id: &BlockId) -> Result; /// Execute a call to a contract on top of given state. /// @@ -113,7 +113,7 @@ where (S::Transaction, H::Out), Option>> ), - error::Error, + sp_blockchain::Error, >; /// Execute a call to a contract on top of given state, gathering execution proof. @@ -125,7 +125,7 @@ where overlay: &mut OverlayedChanges, method: &str, call_data: &[u8] - ) -> Result<(Vec, StorageProof), error::Error> { + ) -> Result<(Vec, StorageProof), sp_blockchain::Error> { let trie_state = state.as_trie_backend() .ok_or_else(|| Box::new(state_machine::ExecutionError::UnableToGenerateProof) @@ -143,7 +143,7 @@ where overlay: &mut OverlayedChanges, method: &str, call_data: &[u8] - ) -> Result<(Vec, StorageProof), error::Error>; + ) -> Result<(Vec, StorageProof), sp_blockchain::Error>; /// Get runtime version if supported. fn native_runtime_version(&self) -> Option<&NativeVersion>; diff --git a/client/api/src/client.rs b/client/api/src/client.rs index 8b4343c327..73ce4f1080 100644 --- a/client/api/src/client.rs +++ b/client/api/src/client.rs @@ -27,7 +27,7 @@ use consensus::BlockOrigin; use crate::blockchain::Info; use crate::notifications::StorageEventStream; -use crate::error; +use sp_blockchain; /// Type that implements `futures::Stream` of block import events. pub type ImportNotifications = mpsc::UnboundedReceiver>; @@ -63,7 +63,7 @@ pub trait BlockchainEvents { &self, filter_keys: Option<&[StorageKey]>, child_filter_keys: Option<&[(StorageKey, Option>)]>, - ) -> error::Result>; + ) -> sp_blockchain::Result>; } /// Fetch block body by ID. @@ -71,14 +71,14 @@ pub trait BlockBody { /// Get block body by ID. Returns `None` if the body is not stored. fn block_body(&self, id: &BlockId - ) -> error::Result::Extrinsic>>>; + ) -> sp_blockchain::Result::Extrinsic>>>; } /// Provide a list of potential uncle headers for a given block. pub trait ProvideUncles { /// Gets the uncles of the block with `target_hash` going back `max_generation` ancestors. fn uncles(&self, target_hash: Block::Hash, max_generation: NumberFor) - -> error::Result>; + -> sp_blockchain::Result>; } /// Client info diff --git a/client/api/src/lib.rs b/client/api/src/lib.rs index 04abc86308..97d7fb2a02 100644 --- a/client/api/src/lib.rs +++ b/client/api/src/lib.rs @@ -18,20 +18,17 @@ #![warn(missing_docs)] pub mod backend; -pub mod blockchain; pub mod call_executor; pub mod client; -pub mod error; pub mod execution_extensions; pub mod light; pub mod notifications; -// TODO: avoid re-exports +pub use sp_blockchain as blockchain; pub use backend::*; -pub use blockchain::*; +pub use notifications::*; pub use call_executor::*; pub use client::*; -pub use error::*; pub use light::*; pub use notifications::*; @@ -40,9 +37,7 @@ pub use state_machine::{StorageProof, ExecutionStrategy}; /// Utility methods for the client. pub mod utils { - use super::HeaderBackend; - use header_metadata::HeaderMetadata; - use crate::error; + use sp_blockchain::{HeaderBackend, HeaderMetadata, Error}; use primitives::H256; use sr_primitives::traits::{Block as BlockT}; use std::borrow::Borrow; @@ -56,8 +51,8 @@ pub mod utils { pub fn is_descendent_of<'a, Block: BlockT, T, H: Borrow + 'a>( client: &'a T, current: Option<(H, H)>, - ) -> impl Fn(&H256, &H256) -> Result + 'a - where T: HeaderBackend + HeaderMetadata, + ) -> impl Fn(&H256, &H256) -> Result + 'a + where T: HeaderBackend + HeaderMetadata, { move |base, hash| { if base == hash { return Ok(false); } @@ -76,7 +71,7 @@ pub mod utils { } } - let ancestor = header_metadata::lowest_common_ancestor(client, *hash, *base)?; + let ancestor = sp_blockchain::lowest_common_ancestor(client, *hash, *base)?; Ok(ancestor.hash == *base) } diff --git a/client/api/src/light.rs b/client/api/src/light.rs index 433d1dbec1..d0206dbc40 100644 --- a/client/api/src/light.rs +++ b/client/api/src/light.rs @@ -28,16 +28,11 @@ use sr_primitives::{ }; use primitives::{ChangesTrieConfiguration}; use state_machine::StorageProof; -use header_metadata::HeaderMetadata; -use crate::{ - backend::{ - AuxStore, NewBlockState, - }, - blockchain::{ - well_known_cache_keys, HeaderBackend, Cache as BlockchainCache, - }, - error::{ Error as ClientError, Result as ClientResult }, +use sp_blockchain::{ + HeaderMetadata, well_known_cache_keys, HeaderBackend, Cache as BlockchainCache, + Error as ClientError, Result as ClientResult, }; +use crate::backend::{ AuxStore, NewBlockState }; /// Remote call request. #[derive(Clone, Debug, PartialEq, Eq, Hash)] pub struct RemoteCallRequest { @@ -288,7 +283,7 @@ pub trait RemoteBlockchain: Send + Sync { pub mod tests { use futures::future::Ready; use parking_lot::Mutex; - use crate::error::Error as ClientError; + use sp_blockchain::Error as ClientError; use test_primitives::{Block, Header, Extrinsic}; use super::*; diff --git a/client/authority-discovery/Cargo.toml b/client/authority-discovery/Cargo.toml index 5447119dc7..81cf48a720 100644 --- a/client/authority-discovery/Cargo.toml +++ b/client/authority-discovery/Cargo.toml @@ -21,12 +21,13 @@ libp2p = { version = "0.13.0", default-features = false, features = ["secp256k1" log = "0.4.8" network = { package = "substrate-network", path = "../network" } primitives = { package = "substrate-primitives", path = "../../primitives/core" } +sp-blockchain = { path = "../../primitives/blockchain" } prost = "0.5.0" serde_json = "1.0.41" sr-primitives = { path = "../../primitives/sr-primitives" } [dev-dependencies] parking_lot = "0.9.0" -peerset = { package = "substrate-peerset", path = "../../primitives/peerset" } +peerset = { package = "substrate-peerset", path = "../peerset" } test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client" } sr-api = { path = "../../primitives/sr-api" } diff --git a/client/authority-discovery/src/error.rs b/client/authority-discovery/src/error.rs index a05bc3b680..fdbd5b31fe 100644 --- a/client/authority-discovery/src/error.rs +++ b/client/authority-discovery/src/error.rs @@ -27,7 +27,7 @@ pub enum Error { /// Failed to hash the authority id to be used as a dht key. HashingAuthorityId(libp2p::core::multiaddr::multihash::EncodeError), /// Failed calling into the Substrate runtime. - CallingRuntime(client_api::error::Error), + CallingRuntime(sp_blockchain::Error), /// From the Dht we only get the hashed authority id. In order to retrieve the actual authority id and to ensure it /// is actually an authority, we match the hash against the hash of the authority id of all other authorities. This /// error is the result of the above failing. diff --git a/client/authority-discovery/src/lib.rs b/client/authority-discovery/src/lib.rs index 0c9d8e59ac..f404ad3c43 100644 --- a/client/authority-discovery/src/lib.rs +++ b/client/authority-discovery/src/lib.rs @@ -117,7 +117,7 @@ where Block: BlockT + Unpin + 'static, Network: NetworkProvider, Client: ProvideRuntimeApi + Send + Sync + 'static + HeaderBackend, - ::Api: AuthorityDiscoveryApi, + ::Api: AuthorityDiscoveryApi, Self: Future, { /// Return a new authority discovery. @@ -358,7 +358,7 @@ where Block: BlockT + Unpin + 'static, Network: NetworkProvider, Client: ProvideRuntimeApi + Send + Sync + 'static + HeaderBackend, - ::Api: AuthorityDiscoveryApi, + ::Api: AuthorityDiscoveryApi, { type Output = (); @@ -500,7 +500,7 @@ mod tests { fn header( &self, _id: BlockId, - ) -> std::result::Result, client_api::error::Error> { + ) -> std::result::Result, sp_blockchain::Error> { Ok(None) } @@ -517,21 +517,21 @@ mod tests { fn status( &self, _id: BlockId, - ) -> std::result::Result { + ) -> std::result::Result { Ok(client_api::blockchain::BlockStatus::Unknown) } fn number( &self, _hash: Block::Hash, - ) -> std::result::Result>, client_api::error::Error> { + ) -> std::result::Result>, sp_blockchain::Error> { Ok(None) } fn hash( &self, _number: NumberFor, - ) -> std::result::Result, client_api::error::Error> { + ) -> std::result::Result, sp_blockchain::Error> { Ok(None) } } @@ -547,7 +547,7 @@ mod tests { _: ExecutionContext, _: Option<()>, _: Vec, - ) -> std::result::Result, client_api::error::Error> { + ) -> std::result::Result, sp_blockchain::Error> { unimplemented!("Not required for testing!") } @@ -557,7 +557,7 @@ mod tests { _: ExecutionContext, _: Option<(Block)>, _: Vec, - ) -> std::result::Result, client_api::error::Error> { + ) -> std::result::Result, sp_blockchain::Error> { unimplemented!("Not required for testing!") } @@ -567,13 +567,13 @@ mod tests { _: ExecutionContext, _: Option<&::Header>, _: Vec, - ) -> std::result::Result, client_api::error::Error> { + ) -> std::result::Result, sp_blockchain::Error> { unimplemented!("Not required for testing!") } } impl ApiExt for RuntimeApi { - type Error = client_api::error::Error; + type Error = sp_blockchain::Error; fn map_api_result std::result::Result, R, E>( &self, @@ -585,7 +585,7 @@ mod tests { fn runtime_version_at( &self, _: &BlockId, - ) -> std::result::Result { + ) -> std::result::Result { unimplemented!("Not required for testing!") } @@ -605,7 +605,7 @@ mod tests { _: ExecutionContext, _: Option<()>, _: Vec, - ) -> std::result::Result>, client_api::error::Error> { + ) -> std::result::Result>, sp_blockchain::Error> { return Ok(NativeOrEncoded::Native(self.authorities.clone())); } } diff --git a/client/basic-authorship/Cargo.toml b/client/basic-authorship/Cargo.toml index 3732065f8c..852a9bbe78 100644 --- a/client/basic-authorship/Cargo.toml +++ b/client/basic-authorship/Cargo.toml @@ -10,12 +10,13 @@ futures = "0.3.1" codec = { package = "parity-scale-codec", version = "1.0.0" } sr-primitives = { path = "../../primitives/sr-primitives" } primitives = { package = "substrate-primitives", path = "../../primitives/core" } +sp-blockchain = { path = "../../primitives/blockchain" } client = { package = "substrate-client", path = "../" } client-api = { package = "substrate-client-api", path = "../api" } consensus_common = { package = "substrate-consensus-common", path = "../../primitives/consensus/common" } inherents = { package = "substrate-inherents", path = "../../primitives/inherents" } substrate-telemetry = { path = "../telemetry" } -transaction_pool = { package = "substrate-transaction-pool", path = "../transaction-pool" } +transaction_pool = { package = "sc-transaction-pool", path = "../../client/transaction-pool" } block-builder = { package = "substrate-block-builder", path = "../block-builder" } tokio-executor = { version = "0.2.0-alpha.6", features = ["blocking"] } diff --git a/client/basic-authorship/src/basic_authorship.rs b/client/basic-authorship/src/basic_authorship.rs index 10b3b2b1a1..46494ef4bb 100644 --- a/client/basic-authorship/src/basic_authorship.rs +++ b/client/basic-authorship/src/basic_authorship.rs @@ -19,7 +19,8 @@ // FIXME #1021 move this into substrate-consensus-common use std::{time, sync::Arc}; -use client_api::{error, CallExecutor}; +use client_api::CallExecutor; +use sp_blockchain; use client::Client as SubstrateClient; use codec::Decode; use consensus_common::{evaluation}; @@ -53,13 +54,13 @@ where RA: Send + Sync + 'static, SubstrateClient: ProvideRuntimeApi, as ProvideRuntimeApi>::Api: - BlockBuilderApi, + BlockBuilderApi, { pub fn init_with_now( &mut self, parent_header: &::Header, now: Box time::Instant + Send + Sync>, - ) -> Result, A>, error::Error> { + ) -> Result, A>, sp_blockchain::Error> { let parent_hash = parent_header.hash(); let id = BlockId::hash(parent_hash); @@ -91,15 +92,15 @@ where RA: Send + Sync + 'static, SubstrateClient: ProvideRuntimeApi, as ProvideRuntimeApi>::Api: - BlockBuilderApi, + BlockBuilderApi, { type Proposer = Proposer, A>; - type Error = error::Error; + type Error = sp_blockchain::Error; fn init( &mut self, parent_header: &::Header, - ) -> Result { + ) -> Result { self.init_with_now(parent_header, Box::new(time::Instant::now)) } } @@ -129,10 +130,10 @@ where RA: Send + Sync + 'static, SubstrateClient: ProvideRuntimeApi, as ProvideRuntimeApi>::Api: - BlockBuilderApi, + BlockBuilderApi, { - type Create = tokio_executor::blocking::Blocking>; - type Error = error::Error; + type Create = tokio_executor::blocking::Blocking>; + type Error = sp_blockchain::Error; fn propose( &mut self, @@ -157,14 +158,14 @@ impl ProposerInner, RA: Send + Sync + 'static, SubstrateClient: ProvideRuntimeApi, as ProvideRuntimeApi>::Api: - BlockBuilderApi, + BlockBuilderApi, { fn propose_with( &self, inherent_data: InherentData, inherent_digests: DigestFor, deadline: time::Instant, - ) -> Result { + ) -> Result { /// If the block is full we will attempt to push at most /// this number of transactions before quitting for real. /// It allows us to increase block utilization. @@ -202,7 +203,8 @@ impl ProposerInner, Ok(()) => { debug!("[{:?}] Pushed to the block.", pending.hash); } - Err(error::Error::ApplyExtrinsicFailed(e)) if e.exhausted_resources() => { + Err(sp_blockchain::Error::ApplyExtrinsicFailed(sp_blockchain::ApplyExtrinsicFailed::Validity(e))) + if e.exhausted_resources() => { if is_first { debug!("[{:?}] Invalid transaction: FullBlock on empty block", pending.hash); unqueue_invalid.push(pending.hash.clone()); diff --git a/client/block-builder/Cargo.toml b/client/block-builder/Cargo.toml index 34bfac17bf..7b39643aa5 100644 --- a/client/block-builder/Cargo.toml +++ b/client/block-builder/Cargo.toml @@ -7,6 +7,7 @@ edition = "2018" [dependencies] state-machine = { package = "substrate-state-machine", path = "../../primitives/state-machine" } sr-primitives = { path = "../../primitives/sr-primitives" } +sp-blockchain = { path = "../../primitives/blockchain" } primitives = { package = "substrate-primitives", path = "../../primitives/core" } codec = { package = "parity-scale-codec", version = "1.0.6", features = ["derive"] } runtime_api = { package = "substrate-block-builder-runtime-api", path = "../../primitives/block-builder/runtime-api" } diff --git a/client/block-builder/src/lib.rs b/client/block-builder/src/lib.rs index f6e793dce7..6978473645 100644 --- a/client/block-builder/src/lib.rs +++ b/client/block-builder/src/lib.rs @@ -17,7 +17,7 @@ //! Substrate block builder //! //! This crate provides the [`BlockBuilder`] utility and the corresponding runtime api -//! [`BlockBuilder`](api::BlockBuilder). +//! [`BlockBuilder`](api::BlockBuilder).Error //! //! The block builder utility is used in the node as an abstraction over the runtime api to //! initialize a block, to push extrinsics and to finalize a block. @@ -31,42 +31,15 @@ use sr_primitives::{ traits::{ Header as HeaderT, Hash, Block as BlockT, HashFor, ProvideRuntimeApi, ApiRef, DigestFor, NumberFor, One, - }, - transaction_validity::TransactionValidityError, + } }; - +use sp_blockchain::{ApplyExtrinsicFailed, Error}; use primitives::ExecutionContext; use state_machine::StorageProof; use sr_api::{Core, ApiExt, ApiErrorFor}; -#[allow(deprecated)] -use runtime_api::compatability_v3; - pub use runtime_api::BlockBuilder as BlockBuilderApi; -/// Error when the runtime failed to apply an extrinsic. -pub enum ApplyExtrinsicFailed { - /// The transaction cannot be included into the current block. - /// - /// This doesn't necessary mean that the transaction itself is invalid, but it might be just - /// unappliable onto the current block. - Validity(TransactionValidityError), - /// This is used for miscelanious errors that can be represented by string and not handleable. - /// - /// This will become obsolete with complete migration to v4 APIs. - Msg(String), -} - -#[allow(deprecated)] -impl From for ApplyExtrinsicFailed { - fn from(e: compatability_v3::ApplyError) -> Self { - use self::compatability_v3::ApplyError::*; - match e { - Validity(tx_validity) => Self::Validity(tx_validity), - e => Self::Msg(format!("Apply extrinsic failed: {:?}", e)), - } - } -} /// Utility for building new (valid) blocks from a stream of extrinsics. pub struct BlockBuilder<'a, Block: BlockT, A: ProvideRuntimeApi> { @@ -81,7 +54,7 @@ where Block: BlockT, A: ProvideRuntimeApi + 'a, A::Api: BlockBuilderApi, - ApiErrorFor: From, + ApiErrorFor: From, { /// Create a new instance of builder based on the given `parent_hash` and `parent_number`. /// @@ -149,7 +122,7 @@ where extrinsics.push(xt); Ok(()) } - Err(e) => Err(ApplyExtrinsicFailed::from(e))?, + Err(e) => Err(ApplyExtrinsicFailed::from(e).into())?, } }) } else { @@ -163,7 +136,7 @@ where extrinsics.push(xt); Ok(()) } - Err(tx_validity) => Err(ApplyExtrinsicFailed::Validity(tx_validity))?, + Err(tx_validity) => Err(ApplyExtrinsicFailed::Validity(tx_validity).into())?, } }) } diff --git a/client/cli/Cargo.toml b/client/cli/Cargo.toml index a2b5940e74..ef6134822e 100644 --- a/client/cli/Cargo.toml +++ b/client/cli/Cargo.toml @@ -23,7 +23,7 @@ fdlimit = "0.1.1" serde_json = "1.0.41" panic-handler = { package = "substrate-panic-handler", path = "../../primitives/panic-handler" } client-api = { package = "substrate-client-api", path = "../api" } -header-metadata = { package = "substrate-header-metadata", path = "../header-metadata" } +sp-blockchain = { path = "../../primitives/blockchain" } network = { package = "substrate-network", path = "../network" } sr-primitives = { path = "../../primitives/sr-primitives" } primitives = { package = "substrate-primitives", path = "../../primitives/core" } diff --git a/client/cli/src/error.rs b/client/cli/src/error.rs index ab07c0e842..bec3aa1ec7 100644 --- a/client/cli/src/error.rs +++ b/client/cli/src/error.rs @@ -16,8 +16,6 @@ //! Initialization errors. -use client_api; - /// Result type alias for the CLI. pub type Result = std::result::Result; @@ -31,7 +29,7 @@ pub enum Error { /// Service error Service(service::Error), /// Client error - Client(client_api::error::Error), + Client(sp_blockchain::Error), /// Input error #[from(ignore)] Input(String), diff --git a/client/cli/src/informant.rs b/client/cli/src/informant.rs index 2f32f95b67..46dca3e54c 100644 --- a/client/cli/src/informant.rs +++ b/client/cli/src/informant.rs @@ -50,7 +50,7 @@ pub fn build(service: &impl AbstractService) -> impl futures::Future, + C::Api: AuraApi, { slots::SlotDuration::get_or_compute(client, |a, b| a.slot_duration(b)).map(Self) } @@ -340,7 +343,7 @@ enum Error { BadSignature(B::Hash), #[display(fmt = "Rejecting block too far in future")] TooFarInFuture, - Client(client::error::Error), + Client(sp_blockchain::Error), DataProvider(String), Runtime(String), } @@ -448,7 +451,7 @@ impl AuraVerifier inherent_data: InherentData, timestamp_now: u64, ) -> Result<(), Error> - where C: ProvideRuntimeApi, C::Api: BlockBuilderApi + where C: ProvideRuntimeApi, C::Api: BlockBuilderApi { const MAX_TIMESTAMP_DRIFT_SECS: u64 = 60; @@ -495,7 +498,7 @@ impl AuraVerifier #[forbid(deprecated)] impl Verifier for AuraVerifier where C: ProvideRuntimeApi + Send + Sync + client_api::backend::AuxStore + ProvideCache + BlockOf, - C::Api: BlockBuilderApi + AuraApi> + ApiExt, + C::Api: BlockBuilderApi + AuraApi> + ApiExt, DigestItemFor: CompatibleDigestItem

, P: Pair + Send + Sync + 'static, P::Public: Send + Sync + Hash + Eq + Clone + Decode + Encode + Debug + 'static, @@ -682,7 +685,7 @@ pub fn import_queue( ) -> Result, consensus_common::Error> where B: BlockT, C: 'static + ProvideRuntimeApi + BlockOf + ProvideCache + Send + Sync + AuxStore, - C::Api: BlockBuilderApi + AuraApi> + ApiExt, + C::Api: BlockBuilderApi + AuraApi> + ApiExt, DigestItemFor: CompatibleDigestItem

, P: Pair + Send + Sync + 'static, P::Public: Clone + Eq + Send + Sync + Hash + Debug + Encode + Decode, @@ -721,7 +724,7 @@ mod tests { use test_client; use aura_primitives::sr25519::AuthorityPair; - type Error = client::error::Error; + type Error = sp_blockchain::Error; type TestClient = client::Client< test_client::Backend, diff --git a/client/consensus/babe/Cargo.toml b/client/consensus/babe/Cargo.toml index 2baf4835d8..a9dd0c5890 100644 --- a/client/consensus/babe/Cargo.toml +++ b/client/consensus/babe/Cargo.toml @@ -23,7 +23,7 @@ client-api = { package = "substrate-client-api", path = "../../api" } client = { package = "substrate-client", path = "../../" } sr-api = { path = "../../../primitives/sr-api" } block-builder-api = { package = "substrate-block-builder-runtime-api", path = "../../../primitives/block-builder/runtime-api" } -header-metadata = { package = "substrate-header-metadata", path = "../../header-metadata" } +sp-blockchain = { path = "../../../primitives/blockchain" } consensus-common = { package = "substrate-consensus-common", path = "../../../primitives/consensus/common" } uncles = { package = "substrate-consensus-uncles", path = "../uncles" } slots = { package = "substrate-consensus-slots", path = "../slots" } diff --git a/client/consensus/babe/src/aux_schema.rs b/client/consensus/babe/src/aux_schema.rs index 04e9f81e5c..288f20db97 100644 --- a/client/consensus/babe/src/aux_schema.rs +++ b/client/consensus/babe/src/aux_schema.rs @@ -19,10 +19,8 @@ use log::info; use codec::{Decode, Encode}; -use client_api::{ - backend::AuxStore, - error::{Result as ClientResult, Error as ClientError}, -}; +use client_api::backend::AuxStore; +use sp_blockchain::{Result as ClientResult, Error as ClientError}; use sr_primitives::traits::Block as BlockT; use babe_primitives::BabeBlockWeight; diff --git a/client/consensus/babe/src/epoch_changes.rs b/client/consensus/babe/src/epoch_changes.rs index a5621efcd1..a07235c4ff 100644 --- a/client/consensus/babe/src/epoch_changes.rs +++ b/client/consensus/babe/src/epoch_changes.rs @@ -25,12 +25,8 @@ use fork_tree::ForkTree; use parking_lot::{Mutex, MutexGuard}; use sr_primitives::traits::{Block as BlockT, NumberFor, One, Zero}; use codec::{Encode, Decode}; -use client_api::{ - error::Error as ClientError, - utils::is_descendent_of, - blockchain::HeaderBackend -}; -use header_metadata::HeaderMetadata; +use client_api::utils::is_descendent_of; +use sp_blockchain::{HeaderMetadata, HeaderBackend, Error as ClientError}; use primitives::H256; use std::ops::Add; diff --git a/client/consensus/babe/src/lib.rs b/client/consensus/babe/src/lib.rs index 5d327bcedf..3fd1e526d4 100644 --- a/client/consensus/babe/src/lib.rs +++ b/client/consensus/babe/src/lib.rs @@ -90,8 +90,6 @@ use consensus_common::import_queue::{Verifier, BasicQueue, CacheKeyId}; use client_api::{ backend::{AuxStore, Backend}, call_executor::CallExecutor, - error::{Result as ClientResult, Error as ClientError}, - blockchain::{self, HeaderBackend, ProvideCache}, BlockchainEvents, ProvideUncles, }; use client::Client; @@ -103,7 +101,10 @@ use futures::prelude::*; use log::{warn, debug, info, trace}; use slots::{SlotWorker, SlotData, SlotInfo, SlotCompatible}; use epoch_changes::descendent_query; -use header_metadata::HeaderMetadata; +use sp_blockchain::{ + Result as ClientResult, Error as ClientError, + HeaderBackend, ProvideCache, HeaderMetadata +}; use schnorrkel::SignatureError; use sr_api::ApiExt; @@ -157,11 +158,11 @@ enum Error { #[display(fmt = "VRF verification failed: {:?}", _0)] VRFVerificationFailed(SignatureError), #[display(fmt = "Could not fetch parent header: {:?}", _0)] - FetchParentHeader(client_api::error::Error), + FetchParentHeader(sp_blockchain::Error), #[display(fmt = "Expected epoch change to happen at {:?}, s{}", _0, _1)] ExpectedEpochChange(B::Hash, u64), #[display(fmt = "Could not look up epoch: {:?}", _0)] - CouldNotLookUpEpoch(Box>), + CouldNotLookUpEpoch(Box>), #[display(fmt = "Block {} is not valid under any epoch.", _0)] BlockNotValid(B::Hash), #[display(fmt = "Unexpected epoch change")] @@ -170,9 +171,9 @@ enum Error { ParentBlockNoAssociatedWeight(B::Hash), #[display(fmt = "Checking inherents failed: {}", _0)] CheckInherents(String), - Client(client_api::error::Error), + Client(sp_blockchain::Error), Runtime(inherents::Error), - ForkTree(Box>), + ForkTree(Box>), } impl std::convert::From> for String { @@ -206,7 +207,7 @@ impl Config { /// Either fetch the slot duration from disk or compute it from the genesis /// state. pub fn get_or_compute(client: &C) -> ClientResult where - C: AuxStore + ProvideRuntimeApi, C::Api: BabeApi, + C: AuxStore + ProvideRuntimeApi, C::Api: BabeApi, { trace!(target: "babe", "Getting slot duration"); match slots::SlotDuration::get_or_compute(client, |a, b| a.configuration(b)).map(Self) { @@ -558,7 +559,7 @@ impl BabeVerifier { block_id: BlockId, inherent_data: InherentData, ) -> Result<(), Error> - where PRA: ProvideRuntimeApi, PRA::Api: BlockBuilderApi + where PRA: ProvideRuntimeApi, PRA::Api: BlockBuilderApi { let inherent_res = self.api.runtime_api().check_inherents( &block_id, @@ -627,8 +628,8 @@ impl Verifier for BabeVerifier + 'static + Clone + Send + Sync, RA: Send + Sync, PRA: ProvideRuntimeApi + Send + Sync + AuxStore + ProvideCache, - PRA::Api: BlockBuilderApi - + BabeApi, + PRA::Api: BlockBuilderApi + + BabeApi, { fn verify( &mut self, @@ -851,8 +852,8 @@ impl BlockImport for BabeBlockImport return Ok(ImportResult::AlreadyInChain), - Ok(blockchain::BlockStatus::Unknown) => {}, + Ok(sp_blockchain::BlockStatus::InChain) => return Ok(ImportResult::AlreadyInChain), + Ok(sp_blockchain::BlockStatus::Unknown) => {}, Err(e) => return Err(ConsensusError::ClientImport(e.to_string())), } @@ -907,7 +908,7 @@ impl BlockImport for BabeBlockImport| ConsensusError::ChainLookup( + .map_err(|e: fork_tree::Error| ConsensusError::ChainLookup( babe_err(Error::::CouldNotLookUpEpoch(Box::new(e))).into() ))? .ok_or_else(|| ConsensusError::ClientImport( @@ -1146,7 +1147,7 @@ pub fn import_queue, I, RA, PRA>( E: CallExecutor + Clone + Send + Sync + 'static, RA: Send + Sync + 'static, PRA: ProvideRuntimeApi + ProvideCache + Send + Sync + AuxStore + 'static, - PRA::Api: BlockBuilderApi + BabeApi + ApiExt, + PRA::Api: BlockBuilderApi + BabeApi + ApiExt, { register_babe_inherent_data_provider(&inherent_data_providers, babe_link.config.slot_duration)?; diff --git a/client/consensus/babe/src/tests.rs b/client/consensus/babe/src/tests.rs index 19c5844511..4695eb721f 100644 --- a/client/consensus/babe/src/tests.rs +++ b/client/consensus/babe/src/tests.rs @@ -41,7 +41,7 @@ use std::{time::Duration, cell::RefCell}; type Item = DigestItem; -type Error = client::error::Error; +type Error = sp_blockchain::Error; type TestClient = client::Client< test_client::Backend, diff --git a/client/consensus/pow/Cargo.toml b/client/consensus/pow/Cargo.toml index 8ed1af9923..acdfb9e843 100644 --- a/client/consensus/pow/Cargo.toml +++ b/client/consensus/pow/Cargo.toml @@ -8,6 +8,7 @@ edition = "2018" [dependencies] codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } primitives = { package = "substrate-primitives", path = "../../../primitives/core" } +sp-blockchain = { path = "../../../primitives/blockchain" } sr-primitives = { path = "../../../primitives/sr-primitives" } client-api = { package = "substrate-client-api", path = "../../api" } block-builder-api = { package = "substrate-block-builder-runtime-api", path = "../../../primitives/block-builder/runtime-api" } diff --git a/client/consensus/pow/src/lib.rs b/client/consensus/pow/src/lib.rs index cb3f23fbf5..1daa9c4eae 100644 --- a/client/consensus/pow/src/lib.rs +++ b/client/consensus/pow/src/lib.rs @@ -32,10 +32,8 @@ use std::sync::Arc; use std::thread; use std::collections::HashMap; -use client_api::{ - BlockOf, blockchain::{HeaderBackend, ProvideCache}, backend::AuxStore, - well_known_cache_keys::Id as CacheKeyId, -}; +use client_api::{BlockOf, backend::AuxStore}; +use sp_blockchain::{HeaderBackend, ProvideCache, well_known_cache_keys::Id as CacheKeyId}; use block_builder_api::BlockBuilder as BlockBuilderApi; use sr_primitives::{Justification, RuntimeString}; use sr_primitives::generic::{BlockId, Digest, DigestItem}; @@ -66,7 +64,7 @@ pub enum Error { #[display(fmt = "Fetching best header failed using select chain: {:?}", _0)] BestHeaderSelectChain(ConsensusError), #[display(fmt = "Fetching best header failed: {:?}", _0)] - BestHeader(client_api::error::Error), + BestHeader(sp_blockchain::Error), #[display(fmt = "Best header does not exist")] NoBestHeader, #[display(fmt = "Block proposing error: {:?}", _0)] @@ -79,7 +77,7 @@ pub enum Error { CreateInherents(inherents::Error), #[display(fmt = "Checking inherents failed: {}", _0)] CheckInherents(String), - Client(client_api::error::Error), + Client(sp_blockchain::Error), Codec(codec::Error), Environment(String), Runtime(RuntimeString) @@ -211,7 +209,7 @@ impl, C, S, Algorithm> PowVerifier { inherent_data: InherentData, timestamp_now: u64, ) -> Result<(), Error> where - C: ProvideRuntimeApi, C::Api: BlockBuilderApi + C: ProvideRuntimeApi, C::Api: BlockBuilderApi { const MAX_TIMESTAMP_DRIFT_SECS: u64 = 60; @@ -249,7 +247,7 @@ impl, C, S, Algorithm> PowVerifier { impl, C, S, Algorithm> Verifier for PowVerifier where C: ProvideRuntimeApi + Send + Sync + HeaderBackend + AuxStore + ProvideCache + BlockOf, - C::Api: BlockBuilderApi, + C::Api: BlockBuilderApi, S: SelectChain, Algorithm: PowAlgorithm + Send + Sync, { @@ -341,7 +339,7 @@ pub fn import_queue( B: BlockT, C: ProvideRuntimeApi + HeaderBackend + BlockOf + ProvideCache + AuxStore, C: Send + Sync + AuxStore + 'static, - C::Api: BlockBuilderApi, + C::Api: BlockBuilderApi, Algorithm: PowAlgorithm + Send + Sync + 'static, S: SelectChain + 'static, { diff --git a/client/consensus/slots/Cargo.toml b/client/consensus/slots/Cargo.toml index 6218d965c7..083ecdae11 100644 --- a/client/consensus/slots/Cargo.toml +++ b/client/consensus/slots/Cargo.toml @@ -10,6 +10,7 @@ build = "build.rs" codec = { package = "parity-scale-codec", version = "1.0.0" } client-api = { package = "substrate-client-api", path = "../../api" } primitives = { package = "substrate-primitives", path = "../../../primitives/core" } +sp-blockchain = { path = "../../../primitives/blockchain" } sr-primitives = { path = "../../../primitives/sr-primitives" } substrate-telemetry = { path = "../../telemetry" } consensus_common = { package = "substrate-consensus-common", path = "../../../primitives/consensus/common" } diff --git a/client/consensus/slots/src/aux_schema.rs b/client/consensus/slots/src/aux_schema.rs index 1e777f35a1..21e4d1256f 100644 --- a/client/consensus/slots/src/aux_schema.rs +++ b/client/consensus/slots/src/aux_schema.rs @@ -18,7 +18,7 @@ use codec::{Encode, Decode}; use client_api::backend::AuxStore; -use client_api::error::{Result as ClientResult, Error as ClientError}; +use sp_blockchain::{Result as ClientResult, Error as ClientError}; use sr_primitives::traits::Header; const SLOT_HEADER_MAP_KEY: &[u8] = b"slot_header_map"; diff --git a/client/consensus/slots/src/lib.rs b/client/consensus/slots/src/lib.rs index e3001ce050..a26f8ec6b9 100644 --- a/client/consensus/slots/src/lib.rs +++ b/client/consensus/slots/src/lib.rs @@ -401,17 +401,17 @@ impl SlotDuration { /// /// `slot_key` is marked as `'static`, as it should really be a /// compile-time constant. - pub fn get_or_compute(client: &C, cb: CB) -> client_api::error::Result where + pub fn get_or_compute(client: &C, cb: CB) -> sp_blockchain::Result where C: client_api::backend::AuxStore, C: ProvideRuntimeApi, - CB: FnOnce(ApiRef, &BlockId) -> client_api::error::Result, + CB: FnOnce(ApiRef, &BlockId) -> sp_blockchain::Result, T: SlotData + Encode + Decode + Debug, { match client.get_aux(T::SLOT_KEY)? { Some(v) => ::decode(&mut &v[..]) .map(SlotDuration) .map_err(|_| { - client_api::error::Error::Backend({ + sp_blockchain::Error::Backend({ error!(target: "slots", "slot duration kept in invalid format"); "slot duration kept in invalid format".to_string() }) diff --git a/client/db/Cargo.toml b/client/db/Cargo.toml index bafeee970b..67372757a6 100644 --- a/client/db/Cargo.toml +++ b/client/db/Cargo.toml @@ -23,7 +23,7 @@ executor = { package = "substrate-executor", path = "../executor" } state_db = { package = "substrate-state-db", path = "../state-db" } trie = { package = "substrate-trie", path = "../../primitives/trie" } consensus_common = { package = "substrate-consensus-common", path = "../../primitives/consensus/common" } -header_metadata = { package = "substrate-header-metadata", path = "../header-metadata" } +sp-blockchain = { path = "../../primitives/blockchain" } [dev-dependencies] substrate-keyring = { path = "../../primitives/keyring" } diff --git a/client/db/src/cache/list_cache.rs b/client/db/src/cache/list_cache.rs index a51e6045c0..a36321df16 100644 --- a/client/db/src/cache/list_cache.rs +++ b/client/db/src/cache/list_cache.rs @@ -43,7 +43,7 @@ use std::collections::{BTreeSet, BTreeMap}; use log::warn; -use client_api::error::{Error as ClientError, Result as ClientResult}; +use sp_blockchain::{Error as ClientError, Result as ClientResult}; use sr_primitives::traits::{ Block as BlockT, NumberFor, Zero, Bounded, CheckedSub }; diff --git a/client/db/src/cache/list_entry.rs b/client/db/src/cache/list_entry.rs index afb2899362..b596863061 100644 --- a/client/db/src/cache/list_entry.rs +++ b/client/db/src/cache/list_entry.rs @@ -16,7 +16,7 @@ //! List-cache storage entries. -use client_api::error::Result as ClientResult; +use sp_blockchain::Result as ClientResult; use sr_primitives::traits::{Block as BlockT, NumberFor}; use codec::{Encode, Decode}; diff --git a/client/db/src/cache/list_storage.rs b/client/db/src/cache/list_storage.rs index d689619053..0615ae6aee 100644 --- a/client/db/src/cache/list_storage.rs +++ b/client/db/src/cache/list_storage.rs @@ -20,7 +20,7 @@ use std::sync::Arc; use kvdb::{KeyValueDB, DBTransaction}; -use client_api::error::{Error as ClientError, Result as ClientResult}; +use sp_blockchain::{Error as ClientError, Result as ClientResult}; use codec::{Encode, Decode}; use sr_primitives::generic::BlockId; use sr_primitives::traits::{Block as BlockT, Header as HeaderT, NumberFor}; diff --git a/client/db/src/cache/mod.rs b/client/db/src/cache/mod.rs index b3ff1a4ea6..068acb37ec 100644 --- a/client/db/src/cache/mod.rs +++ b/client/db/src/cache/mod.rs @@ -22,7 +22,7 @@ use parking_lot::RwLock; use kvdb::{KeyValueDB, DBTransaction}; use client_api::blockchain::{well_known_cache_keys::{self, Id as CacheKeyId}, Cache as BlockchainCache}; -use client_api::error::Result as ClientResult; +use sp_blockchain::Result as ClientResult; use codec::{Encode, Decode}; use sr_primitives::generic::BlockId; use sr_primitives::traits::{Block as BlockT, Header as HeaderT, NumberFor, Zero}; @@ -211,7 +211,7 @@ impl<'a, Block: BlockT> DbCacheTransaction<'a, Block> { .cloned() .collect::>(); - let mut insert_op = |name: CacheKeyId, value: Option>| -> Result<(), client_api::error::Error> { + let mut insert_op = |name: CacheKeyId, value: Option>| -> Result<(), sp_blockchain::Error> { let cache = self.cache.get_cache(name); let op = cache.on_block_insert( &mut self::list_storage::DbStorageTransaction::new( diff --git a/client/db/src/children.rs b/client/db/src/children.rs index f6dd7299e4..db0469098b 100644 --- a/client/db/src/children.rs +++ b/client/db/src/children.rs @@ -18,7 +18,7 @@ use kvdb::{KeyValueDB, DBTransaction}; use codec::{Encode, Decode}; -use client_api::error; +use sp_blockchain; use std::hash::Hash; @@ -26,13 +26,13 @@ use std::hash::Hash; pub fn read_children< K: Eq + Hash + Clone + Encode + Decode, V: Eq + Hash + Clone + Encode + Decode, ->(db: &dyn KeyValueDB, column: Option, prefix: &[u8], parent_hash: K) -> error::Result> { +>(db: &dyn KeyValueDB, column: Option, prefix: &[u8], parent_hash: K) -> sp_blockchain::Result> { let mut buf = prefix.to_vec(); parent_hash.using_encoded(|s| buf.extend(s)); let raw_val_opt = match db.get(column, &buf[..]) { Ok(raw_val_opt) => raw_val_opt, - Err(_) => return Err(error::Error::Backend("Error reading value from database".into())), + Err(_) => return Err(sp_blockchain::Error::Backend("Error reading value from database".into())), }; let raw_val = match raw_val_opt { @@ -42,7 +42,7 @@ pub fn read_children< let children: Vec = match Decode::decode(&mut &raw_val[..]) { Ok(children) => children, - Err(_) => return Err(error::Error::Backend("Error decoding children".into())), + Err(_) => return Err(sp_blockchain::Error::Backend("Error decoding children".into())), }; Ok(children) diff --git a/client/db/src/lib.rs b/client/db/src/lib.rs index 1de3eea9b9..dceffc852a 100644 --- a/client/db/src/lib.rs +++ b/client/db/src/lib.rs @@ -39,12 +39,13 @@ use std::path::PathBuf; use std::io; use std::collections::{HashMap, HashSet}; -use client_api::ForkBlocks; +use client_api::{execution_extensions::ExecutionExtensions, ForkBlocks}; use client_api::backend::NewBlockState; use client_api::backend::{StorageCollection, ChildStorageCollection}; -use client_api::blockchain::{well_known_cache_keys, HeaderBackend}; -use client_api::error::{Result as ClientResult, Error as ClientError}; -use client_api::execution_extensions::ExecutionExtensions; +use sp_blockchain::{ + Result as ClientResult, Error as ClientError, + well_known_cache_keys, HeaderBackend, +}; use codec::{Decode, Encode}; use hash_db::{Hasher, Prefix}; use kvdb::{KeyValueDB, DBTransaction}; @@ -67,7 +68,7 @@ use state_machine::{ use crate::utils::{Meta, db_err, meta_keys, read_db, read_meta}; use client::leaves::{LeafSet, FinalizationDisplaced}; use state_db::StateDb; -use header_metadata::{CachedHeaderMetadata, HeaderMetadata, HeaderMetadataCache}; +use sp_blockchain::{CachedHeaderMetadata, HeaderMetadata, HeaderMetadataCache}; use crate::storage_cache::{CachingState, SharedCache, new_shared_cache}; use log::{trace, debug, warn}; pub use state_db::PruningMode; @@ -239,7 +240,7 @@ pub fn new_client( >, Arc>, ), - client::error::Error, + sp_blockchain::Error, > where Block: BlockT, @@ -381,7 +382,7 @@ impl client::blockchain::Backend for BlockchainDb { match read_db(&*self.db, columns::KEY_LOOKUP, columns::BODY, id)? { Some(body) => match Decode::decode(&mut &body[..]) { Ok(body) => Ok(Some(body)), - Err(err) => return Err(client::error::Error::Backend( + Err(err) => return Err(sp_blockchain::Error::Backend( format!("Error decoding body: {}", err) )), } @@ -393,7 +394,7 @@ impl client::blockchain::Backend for BlockchainDb { match read_db(&*self.db, columns::KEY_LOOKUP, columns::JUSTIFICATION, id)? { Some(justification) => match Decode::decode(&mut &justification[..]) { Ok(justification) => Ok(Some(justification)), - Err(err) => return Err(client::error::Error::Backend( + Err(err) => return Err(sp_blockchain::Error::Backend( format!("Error decoding justification: {}", err) )), } @@ -425,7 +426,7 @@ impl client::blockchain::ProvideCache for BlockchainDb HeaderMetadata for BlockchainDb { - type Error = client::error::Error; + type Error = sp_blockchain::Error; fn header_metadata(&self, hash: Block::Hash) -> Result, Self::Error> { self.header_metadata_cache.header_metadata(hash).or_else(|_| { @@ -517,12 +518,12 @@ impl client_api::backend::BlockImportOperation ) -> ClientResult { if top.iter().any(|(k, _)| well_known_keys::is_child_storage_key(k)) { - return Err(client::error::Error::GenesisInvalid.into()); + return Err(sp_blockchain::Error::GenesisInvalid.into()); } for child_key in children.keys() { if !well_known_keys::is_child_storage_key(&child_key) { - return Err(client::error::Error::GenesisInvalid.into()); + return Err(sp_blockchain::Error::GenesisInvalid.into()); } } @@ -823,7 +824,7 @@ impl> Backend { let is_archive_pruning = config.pruning.is_archive(); let blockchain = BlockchainDb::new(db.clone())?; let meta = blockchain.meta.clone(); - let map_e = |e: state_db::Error| ::client::error::Error::from(format!("State database error: {:?}", e)); + let map_e = |e: state_db::Error| ::sp_blockchain::Error::from(format!("State database error: {:?}", e)); let state_db: StateDb<_, _> = StateDb::new(config.pruning.clone(), &StateMetaDb(&*db)).map_err(map_e)?; let storage_db = StorageDb { db: db.clone(), @@ -948,7 +949,7 @@ impl> Backend { // cannot find tree route with empty DB. if meta.best_hash != Default::default() { - let tree_route = header_metadata::tree_route( + let tree_route = sp_blockchain::tree_route( &self.blockchain, meta.best_hash, route_to, @@ -963,7 +964,7 @@ impl> Backend { (&r.number, &r.hash) ); - return Err(::client::error::Error::NotInFinalizedChain.into()); + return Err(::sp_blockchain::Error::NotInFinalizedChain.into()); } retracted.push(r.hash.clone()); @@ -1005,7 +1006,7 @@ impl> Backend { ) -> ClientResult<()> { let last_finalized = last_finalized.unwrap_or_else(|| self.blockchain.meta.read().finalized_hash); if *header.parent_hash() != last_finalized { - return Err(::client::error::Error::NonSequentialFinalization( + return Err(::sp_blockchain::Error::NonSequentialFinalization( format!("Last finalized {:?} not parent of {:?}", last_finalized, header.hash()), ).into()); } @@ -1068,7 +1069,7 @@ impl> Backend { trace!(target: "db", "Canonicalize block #{} ({:?})", new_canonical, hash); let commit = self.storage.state_db.canonicalize_block(&hash) - .map_err(|e: state_db::Error| client::error::Error::from(format!("State database error: {:?}", e)))?; + .map_err(|e: state_db::Error| sp_blockchain::Error::from(format!("State database error: {:?}", e)))?; apply_state_commit(transaction, commit); }; @@ -1152,7 +1153,7 @@ impl> Backend { } let number_u64 = number.saturated_into::(); let commit = self.storage.state_db.insert_block(&hash, number_u64, &pending_block.header.parent_hash(), changeset) - .map_err(|e: state_db::Error| client::error::Error::from(format!("State database error: {:?}", e)))?; + .map_err(|e: state_db::Error| sp_blockchain::Error::from(format!("State database error: {:?}", e)))?; apply_state_commit(&mut transaction, commit); // Check if need to finalize. Genesis is always finalized instantly. @@ -1217,7 +1218,7 @@ impl> Backend { meta_updates.push((hash, *number, true, false)); Some((enacted, retracted)) } else { - return Err(client::error::Error::UnknownBlock(format!("Cannot set head {:?}", set_head))) + return Err(sp_blockchain::Error::UnknownBlock(format!("Cannot set head {:?}", set_head))) } } else { None @@ -1288,7 +1289,7 @@ impl> Backend { transaction.put(columns::META, meta_keys::FINALIZED_BLOCK, &lookup_key); let commit = self.storage.state_db.canonicalize_block(&f_hash) - .map_err(|e: state_db::Error| client::error::Error::from(format!("State database error: {:?}", e)))?; + .map_err(|e: state_db::Error| sp_blockchain::Error::from(format!("State database error: {:?}", e)))?; apply_state_commit(transaction, commit); let changes_trie_config = self.changes_trie_config(parent_hash)?; @@ -1451,12 +1452,12 @@ impl client_api::backend::Backend for Backend Some(commit) => { apply_state_commit(&mut transaction, commit); let removed = self.blockchain.header(BlockId::Number(best))?.ok_or_else( - || client::error::Error::UnknownBlock( + || sp_blockchain::Error::UnknownBlock( format!("Error reverting to {}. Block hash not found.", best)))?; best -= One::one(); // prev block let hash = self.blockchain.hash(best)?.ok_or_else( - || client::error::Error::UnknownBlock( + || sp_blockchain::Error::UnknownBlock( format!("Error reverting to {}. Block hash not found.", best)))?; let key = utils::number_and_hash_to_lookup_key(best.clone(), &hash)?; transaction.put(columns::META, meta_keys::BEST_BLOCK, &key); @@ -1500,7 +1501,7 @@ impl client_api::backend::Backend for Backend Ok(Some(ref hdr)) => { let hash = hdr.hash(); if !self.have_state_at(&hash, *hdr.number()) { - return Err(client::error::Error::UnknownBlock(format!("State already discarded for {:?}", block))) + return Err(sp_blockchain::Error::UnknownBlock(format!("State already discarded for {:?}", block))) } if let Ok(()) = self.storage.state_db.pin(&hash) { let root = H256::from_slice(hdr.state_root().as_ref()); @@ -1508,10 +1509,10 @@ impl client_api::backend::Backend for Backend let state = RefTrackingState::new(db_state, self.storage.clone(), Some(hash.clone())); Ok(CachingState::new(state, self.shared_cache.clone(), Some(hash))) } else { - Err(client::error::Error::UnknownBlock(format!("State already discarded for {:?}", block))) + Err(sp_blockchain::Error::UnknownBlock(format!("State already discarded for {:?}", block))) } }, - Ok(None) => Err(client::error::Error::UnknownBlock(format!("Unknown state for block {:?}", block))), + Ok(None) => Err(sp_blockchain::Error::UnknownBlock(format!("Unknown state for block {:?}", block))), Err(e) => Err(e), } } @@ -1561,7 +1562,7 @@ mod tests { use sr_primitives::testing::{Header, Block as RawBlock, ExtrinsicWrapper}; use sr_primitives::traits::{Hash, BlakeTwo256}; use state_machine::{TrieMut, TrieDBMut, ChangesTrieRootsStorage, ChangesTrieStorage}; - use header_metadata::{lowest_common_ancestor, tree_route}; + use sp_blockchain::{lowest_common_ancestor, tree_route}; use test_client; diff --git a/client/db/src/light.rs b/client/db/src/light.rs index bdce0e6384..72f0d96986 100644 --- a/client/db/src/light.rs +++ b/client/db/src/light.rs @@ -24,18 +24,20 @@ use kvdb::{KeyValueDB, DBTransaction}; use client_api::backend::{AuxStore, NewBlockState}; use client::blockchain::{ - BlockStatus, Cache as BlockchainCache, - HeaderBackend as BlockchainHeaderBackend, Info as BlockchainInfo, - well_known_cache_keys, + BlockStatus, Cache as BlockchainCache,Info as BlockchainInfo, }; use client::cht; -use client::error::{Error as ClientError, Result as ClientResult}; +use sp_blockchain::{ + CachedHeaderMetadata, HeaderMetadata, HeaderMetadataCache, + Error as ClientError, Result as ClientResult, + HeaderBackend as BlockchainHeaderBackend, + well_known_cache_keys, +}; use client::light::blockchain::Storage as LightBlockchainStorage; use codec::{Decode, Encode}; use primitives::Blake2Hasher; use sr_primitives::generic::{DigestItem, BlockId}; use sr_primitives::traits::{Block as BlockT, Header as HeaderT, Zero, One, NumberFor}; -use header_metadata::{CachedHeaderMetadata, HeaderMetadata, HeaderMetadataCache}; use crate::cache::{DbCacheSync, DbCache, ComplexBlockId, EntryType as CacheEntryType}; use crate::utils::{self, meta_keys, Meta, db_err, read_db, block_id_to_lookup_key, read_meta}; use crate::DatabaseSettings; @@ -235,7 +237,7 @@ impl LightStorage { // handle reorg. let meta = self.meta.read(); if meta.best_hash != Default::default() { - let tree_route = header_metadata::tree_route(self, meta.best_hash, route_to)?; + let tree_route = sp_blockchain::tree_route(self, meta.best_hash, route_to)?; // update block number to hash lookup entries. for retracted in tree_route.retracted() { @@ -282,7 +284,7 @@ impl LightStorage { ) -> ClientResult<()> { let meta = self.meta.read(); if &meta.finalized_hash != header.parent_hash() { - return Err(::client::error::Error::NonSequentialFinalization( + return Err(::sp_blockchain::Error::NonSequentialFinalization( format!("Last finalized {:?} not parent of {:?}", meta.finalized_hash, hash), ).into()) @@ -560,7 +562,7 @@ pub(crate) mod tests { use client::cht; use sr_primitives::generic::DigestItem; use sr_primitives::testing::{H256 as Hash, Header, Block as RawBlock, ExtrinsicWrapper}; - use header_metadata::{lowest_common_ancestor, tree_route}; + use sp_blockchain::{lowest_common_ancestor, tree_route}; use super::*; type Block = RawBlock>; diff --git a/client/db/src/utils.rs b/client/db/src/utils.rs index 516f3d11b0..b16a7ecdaa 100644 --- a/client/db/src/utils.rs +++ b/client/db/src/utils.rs @@ -25,7 +25,6 @@ use kvdb::{KeyValueDB, DBTransaction}; use kvdb_rocksdb::{Database, DatabaseConfig}; use log::debug; -use client; use codec::Decode; use trie::DBValue; use sr_primitives::generic::BlockId; @@ -82,9 +81,9 @@ pub type NumberIndexKey = [u8; 4]; /// /// In the current database schema, this kind of key is only used for /// lookups into an index, NOT for storing header data or others. -pub fn number_index_key>(n: N) -> client::error::Result { +pub fn number_index_key>(n: N) -> sp_blockchain::Result { let n = n.try_into().map_err(|_| - client::error::Error::Backend("Block number cannot be converted to u32".into()) + sp_blockchain::Error::Backend("Block number cannot be converted to u32".into()) )?; Ok([ @@ -100,7 +99,7 @@ pub fn number_index_key>(n: N) -> client::error::Result( number: N, hash: H, -) -> client::error::Result> where +) -> sp_blockchain::Result> where N: TryInto, H: AsRef<[u8]>, { @@ -111,11 +110,11 @@ pub fn number_and_hash_to_lookup_key( /// Convert block lookup key into block number. /// all block lookup keys start with the block number. -pub fn lookup_key_to_number(key: &[u8]) -> client::error::Result where +pub fn lookup_key_to_number(key: &[u8]) -> sp_blockchain::Result where N: From { if key.len() < 4 { - return Err(client::error::Error::Backend("Invalid block key".into())); + return Err(sp_blockchain::Error::Backend("Invalid block key".into())); } Ok((key[0] as u32) << 24 | (key[1] as u32) << 16 @@ -128,7 +127,7 @@ pub fn remove_number_to_key_mapping>( transaction: &mut DBTransaction, key_lookup_col: Option, number: N, -) -> client::error::Result<()> { +) -> sp_blockchain::Result<()> { transaction.delete(key_lookup_col, number_index_key(number)?.as_ref()); Ok(()) } @@ -139,7 +138,7 @@ pub fn remove_key_mappings, H: AsRef<[u8]>>( key_lookup_col: Option, number: N, hash: H, -) -> client::error::Result<()> { +) -> sp_blockchain::Result<()> { remove_number_to_key_mapping(transaction, key_lookup_col, number)?; transaction.delete(key_lookup_col, hash.as_ref()); Ok(()) @@ -152,7 +151,7 @@ pub fn insert_number_to_key_mapping + Clone, H: AsRef<[u8]>>( key_lookup_col: Option, number: N, hash: H, -) -> client::error::Result<()> { +) -> sp_blockchain::Result<()> { transaction.put_vec( key_lookup_col, number_index_key(number.clone())?.as_ref(), @@ -167,7 +166,7 @@ pub fn insert_hash_to_key_mapping, H: AsRef<[u8]> + Clone>( key_lookup_col: Option, number: N, hash: H, -) -> client::error::Result<()> { +) -> sp_blockchain::Result<()> { transaction.put_vec( key_lookup_col, hash.clone().as_ref(), @@ -183,7 +182,7 @@ pub fn block_id_to_lookup_key( db: &dyn KeyValueDB, key_lookup_col: Option, id: BlockId -) -> Result>, client::error::Error> where +) -> Result>, sp_blockchain::Error> where Block: BlockT, ::sr_primitives::traits::NumberFor: UniqueSaturatedFrom + UniqueSaturatedInto, { @@ -199,8 +198,8 @@ pub fn block_id_to_lookup_key( } /// Maps database error to client error -pub fn db_err(err: io::Error) -> client::error::Error { - client::error::Error::Backend(format!("{}", err)) +pub fn db_err(err: io::Error) -> sp_blockchain::Error { + sp_blockchain::Error::Backend(format!("{}", err)) } /// Open RocksDB database. @@ -208,7 +207,7 @@ pub fn open_database( config: &DatabaseSettings, col_meta: Option, db_type: &str -) -> client::error::Result> { +) -> sp_blockchain::Result> { let db: Arc = match &config.source { #[cfg(feature = "kvdb-rocksdb")] DatabaseSettingsSrc::Path { path, cache_size } => { @@ -230,13 +229,13 @@ pub fn open_database( db_config.memory_budget = memory_budget; } let path = path.to_str() - .ok_or_else(|| client::error::Error::Backend("Invalid database path".into()))?; + .ok_or_else(|| sp_blockchain::Error::Backend("Invalid database path".into()))?; Arc::new(Database::open(&db_config, &path).map_err(db_err)?) }, #[cfg(not(feature = "kvdb-rocksdb"))] DatabaseSettingsSrc::Path { .. } => { let msg = "Try to open RocksDB database with RocksDB disabled".into(); - return Err(client::error::Error::Backend(msg)); + return Err(sp_blockchain::Error::Backend(msg)); }, DatabaseSettingsSrc::Custom(db) => db.clone(), }; @@ -245,7 +244,7 @@ pub fn open_database( match db.get(col_meta, meta_keys::TYPE).map_err(db_err)? { Some(stored_type) => { if db_type.as_bytes() != &*stored_type { - return Err(client::error::Error::Backend( + return Err(sp_blockchain::Error::Backend( format!("Unexpected database type. Expected: {}", db_type)).into()); } }, @@ -265,7 +264,7 @@ pub fn read_db( col_index: Option, col: Option, id: BlockId -) -> client::error::Result> +) -> sp_blockchain::Result> where Block: BlockT, { @@ -281,12 +280,12 @@ pub fn read_header( col_index: Option, col: Option, id: BlockId, -) -> client::error::Result> { +) -> sp_blockchain::Result> { match read_db(db, col_index, col, id)? { Some(header) => match Block::Header::decode(&mut &header[..]) { Ok(header) => Ok(Some(header)), Err(_) => return Err( - client::error::Error::Backend("Error decoding header".into()) + sp_blockchain::Error::Backend("Error decoding header".into()) ), } None => Ok(None), @@ -299,15 +298,15 @@ pub fn require_header( col_index: Option, col: Option, id: BlockId, -) -> client::error::Result { +) -> sp_blockchain::Result { read_header(db, col_index, col, id) - .and_then(|header| header.ok_or_else(|| client::error::Error::UnknownBlock(format!("{}", id)))) + .and_then(|header| header.ok_or_else(|| sp_blockchain::Error::UnknownBlock(format!("{}", id)))) } /// Read meta from the database. pub fn read_meta(db: &dyn KeyValueDB, col_meta: Option, col_header: Option) -> Result< Meta<<::Header as HeaderT>::Number, Block::Hash>, - client::error::Error, + sp_blockchain::Error, > where Block: BlockT, @@ -315,7 +314,7 @@ pub fn read_meta(db: &dyn KeyValueDB, col_meta: Option, col_header: let genesis_hash: Block::Hash = match db.get(col_meta, meta_keys::GENESIS_HASH).map_err(db_err)? { Some(h) => match Decode::decode(&mut &h[..]) { Ok(h) => h, - Err(err) => return Err(client::error::Error::Backend( + Err(err) => return Err(sp_blockchain::Error::Backend( format!("Error decoding genesis hash: {}", err) )), }, @@ -328,7 +327,7 @@ pub fn read_meta(db: &dyn KeyValueDB, col_meta: Option, col_header: }), }; - let load_meta_block = |desc, key| -> Result<_, client::error::Error> { + let load_meta_block = |desc, key| -> Result<_, sp_blockchain::Error> { if let Some(Some(header)) = db.get(col_meta, key).and_then(|id| match id { Some(id) => db.get(col_header, &id).map(|h| h.map(|b| Block::Header::decode(&mut &b[..]).ok())), diff --git a/client/finality-grandpa/Cargo.toml b/client/finality-grandpa/Cargo.toml index 7bc381d3ad..71460966ad 100644 --- a/client/finality-grandpa/Cargo.toml +++ b/client/finality-grandpa/Cargo.toml @@ -22,8 +22,8 @@ keystore = { package = "substrate-keystore", path = "../keystore" } serde_json = "1.0.41" client-api = { package = "substrate-client-api", path = "../api" } client = { package = "substrate-client", path = "../" } -header-metadata = { package = "substrate-header-metadata", path = "../header-metadata" } inherents = { package = "substrate-inherents", path = "../../primitives/inherents" } +sp-blockchain = { path = "../../primitives/blockchain" } network = { package = "substrate-network", path = "../network" } sp-finality-tracker = { path = "../../primitives/finality-tracker" } fg_primitives = { package = "substrate-finality-grandpa-primitives", path = "../../primitives/finality-grandpa" } diff --git a/client/finality-grandpa/src/aux_schema.rs b/client/finality-grandpa/src/aux_schema.rs index 9857367dc9..cac8e566d2 100644 --- a/client/finality-grandpa/src/aux_schema.rs +++ b/client/finality-grandpa/src/aux_schema.rs @@ -20,7 +20,7 @@ use std::fmt::Debug; use std::sync::Arc; use codec::{Encode, Decode}; use client_api::backend::AuxStore; -use client_api::error::{Result as ClientResult, Error as ClientError}; +use sp_blockchain::{Result as ClientResult, Error as ClientError}; use fork_tree::ForkTree; use grandpa::round::State as RoundState; use sr_primitives::traits::{Block as BlockT, NumberFor}; diff --git a/client/finality-grandpa/src/consensus_changes.rs b/client/finality-grandpa/src/consensus_changes.rs index e276b287dd..5f7828f02b 100644 --- a/client/finality-grandpa/src/consensus_changes.rs +++ b/client/finality-grandpa/src/consensus_changes.rs @@ -47,11 +47,11 @@ impl ConsensusChanges { /// Finalize all pending consensus changes that are finalized by given block. /// Returns true if there any changes were finalized. - pub(crate) fn finalize ::client_api::error::Result>>( + pub(crate) fn finalize ::sp_blockchain::Result>>( &mut self, block: (N, H), canonical_at_height: F, - ) -> ::client_api::error::Result<(bool, bool)> { + ) -> ::sp_blockchain::Result<(bool, bool)> { let (split_idx, has_finalized_changes) = self.pending_changes.iter() .enumerate() .take_while(|(_, &(at_height, _))| at_height <= block.0) diff --git a/client/finality-grandpa/src/environment.rs b/client/finality-grandpa/src/environment.rs index 214e8bc798..af6e03743a 100644 --- a/client/finality-grandpa/src/environment.rs +++ b/client/finality-grandpa/src/environment.rs @@ -24,13 +24,13 @@ use codec::{Decode, Encode}; use futures::prelude::*; use tokio_timer::Delay; use parking_lot::RwLock; +use sp_blockchain::{HeaderBackend, Error as ClientError}; use client_api::{ - HeaderBackend, BlockchainEvents, + BlockchainEvents, backend::{Backend}, Finalizer, call_executor::CallExecutor, - error::Error as ClientError, utils::is_descendent_of, }; use client::{ @@ -534,7 +534,7 @@ pub(crate) fn ancestry, E, RA>( { if base == block { return Err(GrandpaError::NotDescendent) } - let tree_route_res = header_metadata::tree_route(client, block, base); + let tree_route_res = sp_blockchain::tree_route(client, block, base); let tree_route = match tree_route_res { Ok(tree_route) => tree_route, diff --git a/client/finality-grandpa/src/finality_proof.rs b/client/finality-grandpa/src/finality_proof.rs index c675a4d1f3..209eb974b0 100644 --- a/client/finality-grandpa/src/finality_proof.rs +++ b/client/finality-grandpa/src/finality_proof.rs @@ -38,11 +38,10 @@ use std::iter; use std::sync::Arc; use log::{trace, warn}; +use sp_blockchain::{Backend as BlockchainBackend, Error as ClientError, Result as ClientResult}; use client_api::{ - backend::Backend, blockchain::Backend as BlockchainBackend, CallExecutor, - error::{Error as ClientError, Result as ClientResult}, + backend::Backend, CallExecutor, StorageProof, light::{FetchChecker, RemoteReadRequest}, - StorageProof, }; use client::Client; use codec::{Encode, Decode}; @@ -259,7 +258,7 @@ pub(crate) fn prove_finality, B: BlockchainBackend ::client_api::error::Result>> +) -> ::sp_blockchain::Result>> where J: ProvableJustification, { diff --git a/client/finality-grandpa/src/import.rs b/client/finality-grandpa/src/import.rs index d6a3ea6e94..2c18600ae9 100644 --- a/client/finality-grandpa/src/import.rs +++ b/client/finality-grandpa/src/import.rs @@ -21,11 +21,8 @@ use codec::Encode; use futures::sync::mpsc; use parking_lot::RwLockWriteGuard; -use client_api::{ - backend::Backend, blockchain, - CallExecutor, blockchain::HeaderBackend, well_known_cache_keys, - utils::is_descendent_of, -}; +use sp_blockchain::{HeaderBackend, BlockStatus, well_known_cache_keys}; +use client_api::{backend::Backend, CallExecutor, utils::is_descendent_of}; use client::Client; use consensus_common::{ BlockImport, Error as ConsensusError, @@ -403,8 +400,8 @@ impl, RA, SC> BlockImport // early exit if block already in chain, otherwise the check for // authority changes will error when trying to re-import a change block match self.inner.status(BlockId::Hash(hash)) { - Ok(blockchain::BlockStatus::InChain) => return Ok(ImportResult::AlreadyInChain), - Ok(blockchain::BlockStatus::Unknown) => {}, + Ok(BlockStatus::InChain) => return Ok(ImportResult::AlreadyInChain), + Ok(BlockStatus::Unknown) => {}, Err(e) => return Err(ConsensusError::ClientImport(e.to_string()).into()), } diff --git a/client/finality-grandpa/src/justification.rs b/client/finality-grandpa/src/justification.rs index eff06776bd..807a785ca8 100644 --- a/client/finality-grandpa/src/justification.rs +++ b/client/finality-grandpa/src/justification.rs @@ -17,7 +17,8 @@ use std::collections::{HashMap, HashSet}; use client::Client; -use client_api::{CallExecutor, backend::Backend, error::Error as ClientError}; +use client_api::{CallExecutor, backend::Backend}; +use sp_blockchain::Error as ClientError; use codec::{Encode, Decode}; use grandpa::voter_set::VoterSet; use grandpa::{Error as GrandpaError}; diff --git a/client/finality-grandpa/src/lib.rs b/client/finality-grandpa/src/lib.rs index 8355f7c93e..2b83488d59 100644 --- a/client/finality-grandpa/src/lib.rs +++ b/client/finality-grandpa/src/lib.rs @@ -55,10 +55,8 @@ use futures::prelude::*; use log::{debug, error, info}; use futures::sync::mpsc; -use client_api::{ - BlockchainEvents, CallExecutor, backend::Backend, error::Error as ClientError, - ExecutionStrategy, HeaderBackend -}; +use client_api::{BlockchainEvents, CallExecutor, backend::Backend, ExecutionStrategy}; +use sp_blockchain::{HeaderBackend, Error as ClientError}; use client::Client; use codec::{Decode, Encode}; use sr_primitives::generic::BlockId; @@ -546,7 +544,7 @@ pub struct GrandpaParams, N, RA, SC, VR, X> { /// block import worker that has already been instantiated with `block_import`. pub fn run_grandpa_voter, N, RA, SC, VR, X>( grandpa_params: GrandpaParams, -) -> client_api::error::Result + Send + 'static> where +) -> sp_blockchain::Result + Send + 'static> where Block::Hash: Ord, B: Backend + 'static, E: CallExecutor + Send + Sync + 'static, @@ -880,7 +878,7 @@ where #[deprecated(since = "1.1.0", note = "Please switch to run_grandpa_voter.")] pub fn run_grandpa, N, RA, SC, VR, X>( grandpa_params: GrandpaParams, -) -> ::client_api::error::Result + Send + 'static> where +) -> ::sp_blockchain::Result + Send + 'static> where Block::Hash: Ord, B: Backend + 'static, E: CallExecutor + Send + Sync + 'static, diff --git a/client/finality-grandpa/src/light_import.rs b/client/finality-grandpa/src/light_import.rs index 6212f853e8..6b5fbb3489 100644 --- a/client/finality-grandpa/src/light_import.rs +++ b/client/finality-grandpa/src/light_import.rs @@ -19,13 +19,8 @@ use std::sync::Arc; use log::{info, trace, warn}; use parking_lot::RwLock; use client::Client; -use client_api::{ - CallExecutor, - backend::{AuxStore, Backend, Finalizer}, - blockchain::HeaderBackend, - error::Error as ClientError, - well_known_cache_keys, -}; +use client_api::{CallExecutor, backend::{AuxStore, Backend, Finalizer}}; +use sp_blockchain::{HeaderBackend, Error as ClientError, well_known_cache_keys}; use codec::{Encode, Decode}; use consensus_common::{ import_queue::Verifier, diff --git a/client/finality-grandpa/src/observer.rs b/client/finality-grandpa/src/observer.rs index b182eaaaa5..83c2fac275 100644 --- a/client/finality-grandpa/src/observer.rs +++ b/client/finality-grandpa/src/observer.rs @@ -156,7 +156,7 @@ pub fn run_grandpa_observer, N, RA, SC>( link: LinkHalf, network: N, on_exit: impl Future + Clone + Send + 'static, -) -> ::client_api::error::Result + Send + 'static> where +) -> ::sp_blockchain::Result + Send + 'static> where B: Backend + 'static, E: CallExecutor + Send + Sync + 'static, N: Network + Send + Sync + 'static, diff --git a/client/finality-grandpa/src/tests.rs b/client/finality-grandpa/src/tests.rs index abcd44635c..fde730e298 100644 --- a/client/finality-grandpa/src/tests.rs +++ b/client/finality-grandpa/src/tests.rs @@ -26,7 +26,7 @@ use futures03::{StreamExt as _, TryStreamExt as _}; use tokio::runtime::current_thread; use keyring::Ed25519Keyring; use client::LongestChain; -use client_api::error::Result; +use sp_blockchain::Result; use sr_api::{Core, RuntimeVersion, ApiExt, StorageProof}; use test_client::{self, runtime::BlockNumber}; use consensus_common::{BlockOrigin, ForkChoiceStrategy, ImportedAux, BlockImportParams, ImportResult}; @@ -242,7 +242,7 @@ impl Core for RuntimeApi { } impl ApiExt for RuntimeApi { - type Error = client_api::error::Error; + type Error = sp_blockchain::Error; fn map_api_result result::Result, R, E>( &self, diff --git a/client/header-metadata/Cargo.toml b/client/header-metadata/Cargo.toml deleted file mode 100644 index b321685c6c..0000000000 --- a/client/header-metadata/Cargo.toml +++ /dev/null @@ -1,10 +0,0 @@ -[package] -name = "substrate-header-metadata" -version = "2.0.0" -authors = ["Parity Technologies "] -edition = "2018" - -[dependencies] -lru = { version = "0.4.0" } -parking_lot = { version = "0.9.0" } -sr-primitives = { path = "../../primitives/sr-primitives" } diff --git a/client/network/Cargo.toml b/client/network/Cargo.toml index 9691cd5c3c..a536623d39 100644 --- a/client/network/Cargo.toml +++ b/client/network/Cargo.toml @@ -27,13 +27,13 @@ fork-tree = { path = "../../utils/fork-tree" } consensus = { package = "substrate-consensus-common", path = "../../primitives/consensus/common" } client = { package = "substrate-client", path = "../" } client-api = { package = "substrate-client-api", path = "../api" } -header_metadata = { package = "substrate-header-metadata", path = "../header-metadata" } +sp-blockchain = { path = "../../primitives/blockchain" } sr-primitives = { path = "../../primitives/sr-primitives" } sr-arithmetic = { path = "../../primitives/sr-arithmetic" } primitives = { package = "substrate-primitives", path = "../../primitives/core" } block-builder = { package = "substrate-block-builder", path = "../block-builder" } codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } -peerset = { package = "substrate-peerset", path = "../../primitives/peerset" } +peerset = { package = "substrate-peerset", path = "../peerset" } serde = { version = "1.0.101", features = ["derive"] } serde_json = "1.0.41" slog = { version = "2.5.2", features = ["nested-values"] } diff --git a/client/network/src/chain.rs b/client/network/src/chain.rs index 5207a24bf9..ac883987cd 100644 --- a/client/network/src/chain.rs +++ b/client/network/src/chain.rs @@ -17,7 +17,7 @@ //! Blockchain access trait use client::Client as SubstrateClient; -use client_api::error::Error; +use sp_blockchain::Error; use client_api::{ChangesProof, StorageProof, ClientInfo, CallExecutor}; use consensus::{BlockImport, BlockStatus, Error as ConsensusError}; use sr_primitives::traits::{Block as BlockT, Header as HeaderT}; @@ -162,7 +162,7 @@ impl Client for SubstrateClient where return Ok(false); } - let ancestor = header_metadata::lowest_common_ancestor(self, *block, *base)?; + let ancestor = sp_blockchain::lowest_common_ancestor(self, *block, *base)?; Ok(ancestor.hash == *base) } diff --git a/client/network/src/error.rs b/client/network/src/error.rs index a33f0280ab..8f15e318ce 100644 --- a/client/network/src/error.rs +++ b/client/network/src/error.rs @@ -16,8 +16,6 @@ //! Substrate network possible errors. -use client_api; - use libp2p::{PeerId, Multiaddr}; use std::fmt; @@ -31,7 +29,7 @@ pub enum Error { /// Io error Io(std::io::Error), /// Client error - Client(client_api::error::Error), + Client(sp_blockchain::Error), /// The same bootnode (based on address) is registered with two different peer ids. #[display( fmt = "The same bootnode (`{}`) is registered with two different peer ids: `{}` and `{}`", diff --git a/client/network/src/on_demand_layer.rs b/client/network/src/on_demand_layer.rs index 4a5ec4adcf..82c5ed6940 100644 --- a/client/network/src/on_demand_layer.rs +++ b/client/network/src/on_demand_layer.rs @@ -22,7 +22,7 @@ use std::sync::Arc; use futures::{prelude::*, sync::mpsc, sync::oneshot}; use futures03::compat::{Compat01As03, Future01CompatExt as _}; use parking_lot::Mutex; -use client_api::error::Error as ClientError; +use sp_blockchain::Error as ClientError; use client_api::{Fetcher, FetchChecker, RemoteHeaderRequest, RemoteCallRequest, RemoteReadRequest, RemoteChangesRequest, RemoteReadChildRequest, RemoteBodyRequest}; diff --git a/client/network/src/protocol/light_dispatch.rs b/client/network/src/protocol/light_dispatch.rs index 280495c0c4..afc7ac563b 100644 --- a/client/network/src/protocol/light_dispatch.rs +++ b/client/network/src/protocol/light_dispatch.rs @@ -25,7 +25,7 @@ use std::time::{Instant, Duration}; use log::{trace, info}; use futures::sync::oneshot::{Sender as OneShotSender}; use linked_hash_map::{Entry, LinkedHashMap}; -use client_api::error::Error as ClientError; +use sp_blockchain::Error as ClientError; use client_api::{FetchChecker, RemoteHeaderRequest, RemoteCallRequest, RemoteReadRequest, RemoteChangesRequest, ChangesProof, RemoteReadChildRequest, RemoteBodyRequest, StorageProof}; @@ -677,7 +677,7 @@ pub mod tests { use std::time::Instant; use futures::{Future, sync::oneshot}; use sr_primitives::traits::{Block as BlockT, NumberFor, Header as HeaderT}; - use client_api::{error::{Error as ClientError, Result as ClientResult}}; + use sp_blockchain::{Error as ClientError, Result as ClientResult}; use client_api::{FetchChecker, RemoteHeaderRequest, ChangesProof, RemoteCallRequest, RemoteReadRequest, RemoteReadChildRequest, RemoteChangesRequest, RemoteBodyRequest}; diff --git a/client/network/src/protocol/sync.rs b/client/network/src/protocol/sync.rs index 6f1255cd8a..3ee26deab3 100644 --- a/client/network/src/protocol/sync.rs +++ b/client/network/src/protocol/sync.rs @@ -28,7 +28,8 @@ //! use blocks::BlockCollection; -use client_api::{ClientInfo, error::Error as ClientError}; +use client_api::ClientInfo; +use sp_blockchain::Error as ClientError; use consensus::{BlockOrigin, BlockStatus, block_validation::{BlockAnnounceValidator, Validation}, import_queue::{IncomingBlock, BlockImportResult, BlockImportError} diff --git a/client/network/src/protocol/sync/extra_requests.rs b/client/network/src/protocol/sync/extra_requests.rs index 5bfeeba2a5..a96f855776 100644 --- a/client/network/src/protocol/sync/extra_requests.rs +++ b/client/network/src/protocol/sync/extra_requests.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Substrate. If not, see . -use client_api::error::Error as ClientError; +use sp_blockchain::Error as ClientError; use crate::protocol::sync::{PeerSync, PeerSyncState}; use fork_tree::ForkTree; use libp2p::PeerId; @@ -283,7 +283,7 @@ impl<'a, B: BlockT> Matcher<'a, B> { #[cfg(test)] mod tests { use crate::protocol::sync::PeerSync; - use client_api::error::Error as ClientError; + use sp_blockchain::Error as ClientError; use quickcheck::{Arbitrary, Gen, QuickCheck, StdThreadGen}; use rand::Rng; use std::collections::{HashMap, HashSet}; diff --git a/client/network/src/test/mod.rs b/client/network/src/test/mod.rs index 964f27051a..e7cc1b103b 100644 --- a/client/network/src/test/mod.rs +++ b/client/network/src/test/mod.rs @@ -27,12 +27,13 @@ use std::sync::Arc; use crate::config::build_multiaddr; use log::trace; use crate::chain::FinalityProofProvider; +use sp_blockchain::{ + Result as ClientResult, well_known_cache_keys::{self, Id as CacheKeyId}, +}; use client_api::{ ClientInfo, BlockchainEvents, BlockImportNotification, FinalityNotifications, ImportNotifications, FinalityNotification, - error::Result as ClientResult, - well_known_cache_keys::{self, Id as CacheKeyId}, backend::{AuxStore, Backend, Finalizer} }; use block_builder::BlockBuilder; diff --git a/client/offchain/Cargo.toml b/client/offchain/Cargo.toml index 0f78b6804b..afec2af4fd 100644 --- a/client/offchain/Cargo.toml +++ b/client/offchain/Cargo.toml @@ -35,7 +35,7 @@ client-db = { package = "substrate-client-db", path = "../db/", default-features env_logger = "0.7.0" test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client" } tokio = "0.1.22" -transaction_pool = { package = "substrate-transaction-pool", path = "../transaction-pool" } +transaction_pool = { package = "sc-transaction-pool", path = "../../client/transaction-pool" } [features] default = [] diff --git a/primitives/peerset/Cargo.toml b/client/peerset/Cargo.toml similarity index 100% rename from primitives/peerset/Cargo.toml rename to client/peerset/Cargo.toml diff --git a/primitives/peerset/src/lib.rs b/client/peerset/src/lib.rs similarity index 100% rename from primitives/peerset/src/lib.rs rename to client/peerset/src/lib.rs diff --git a/primitives/peerset/src/peersstate.rs b/client/peerset/src/peersstate.rs similarity index 100% rename from primitives/peerset/src/peersstate.rs rename to client/peerset/src/peersstate.rs diff --git a/primitives/peerset/tests/fuzz.rs b/client/peerset/tests/fuzz.rs similarity index 100% rename from primitives/peerset/tests/fuzz.rs rename to client/peerset/tests/fuzz.rs diff --git a/client/rpc/Cargo.toml b/client/rpc/Cargo.toml index f8eaac0af0..a42ada7205 100644 --- a/client/rpc/Cargo.toml +++ b/client/rpc/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -api = { package = "substrate-rpc-api", path = "./api" } +api = { package = "sc-rpc-api", path = "./api" } client-api = { package = "substrate-client-api", path = "../api" } client = { package = "substrate-client", path = "../" } sr-api = { path = "../../primitives/sr-api" } @@ -23,7 +23,8 @@ rpc-primitives = { package = "substrate-rpc-primitives", path = "../../primitive state_machine = { package = "substrate-state-machine", path = "../../primitives/state-machine" } substrate-executor = { path = "../executor" } substrate-keystore = { path = "../keystore" } -transaction_pool = { package = "substrate-transaction-pool", path = "../transaction-pool" } +transaction_pool = { package = "sc-transaction-pool", path = "../../client/transaction-pool" } +sp-blockchain = { path = "../../primitives/blockchain" } hash-db = { version = "0.15.2", default-features = false } parking_lot = { version = "0.9.0" } diff --git a/client/rpc/api/Cargo.toml b/client/rpc/api/Cargo.toml index 621d487f3a..9d88aae9a0 100644 --- a/client/rpc/api/Cargo.toml +++ b/client/rpc/api/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "substrate-rpc-api" +name = "sc-rpc-api" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" @@ -18,5 +18,5 @@ primitives = { package = "substrate-primitives", path = "../../../primitives/cor runtime_version = { package = "sr-version", path = "../../../primitives/sr-version" } serde = { version = "1.0.101", features = ["derive"] } serde_json = "1.0.41" -txpool = { package = "substrate-transaction-graph", path = "../../transaction-pool/graph" } +txpool = { package = "sc-transaction-graph", path = "../../../client/transaction-pool/graph" } rpc-primitives = { package = "substrate-rpc-primitives", path = "../../../primitives/rpc" } diff --git a/client/rpc/src/author/mod.rs b/client/rpc/src/author/mod.rs index 29be7b8d88..920331d9ae 100644 --- a/client/rpc/src/author/mod.rs +++ b/client/rpc/src/author/mod.rs @@ -24,7 +24,7 @@ use futures::future::{FutureExt, TryFutureExt}; use log::warn; use client::Client; -use client_api::error::Error as ClientError; +use sp_blockchain::Error as ClientError; use rpc::futures::{ Sink, Future, diff --git a/client/rpc/src/chain/mod.rs b/client/rpc/src/chain/mod.rs index c420360576..8c35df0bf7 100644 --- a/client/rpc/src/chain/mod.rs +++ b/client/rpc/src/chain/mod.rs @@ -288,6 +288,6 @@ fn subscribe_headers( }); } -fn client_err(err: client::error::Error) -> Error { +fn client_err(err: sp_blockchain::Error) -> Error { Error::Client(Box::new(err)) } diff --git a/client/rpc/src/state/mod.rs b/client/rpc/src/state/mod.rs index 8e15c48807..491ea33969 100644 --- a/client/rpc/src/state/mod.rs +++ b/client/rpc/src/state/mod.rs @@ -184,7 +184,7 @@ pub fn new_full( RA: Send + Sync + 'static, Client: ProvideRuntimeApi, as ProvideRuntimeApi>::Api: - Metadata, + Metadata, { State { backend: Box::new(self::state_full::FullState::new(client, subscriptions)), @@ -332,6 +332,6 @@ impl StateApi for State } } -fn client_err(err: client::error::Error) -> Error { +fn client_err(err: sp_blockchain::Error) -> Error { Error::Client(Box::new(err)) } diff --git a/client/rpc/src/state/state_full.rs b/client/rpc/src/state/state_full.rs index dcb876c846..55b6e65d48 100644 --- a/client/rpc/src/state/state_full.rs +++ b/client/rpc/src/state/state_full.rs @@ -28,7 +28,8 @@ use rpc::{ }; use api::Subscriptions; -use client_api::{backend::Backend, error::Result as ClientResult}; +use client_api::backend::Backend; +use sp_blockchain::Result as ClientResult; use client::{ Client, CallExecutor, BlockchainEvents, }; @@ -232,7 +233,7 @@ impl StateBackend for FullState: ProvideRuntimeApi, as ProvideRuntimeApi>::Api: - Metadata, + Metadata, { fn call( &self, diff --git a/client/rpc/src/state/state_light.rs b/client/rpc/src/state/state_light.rs index c3155ef4a9..c761d3bfe4 100644 --- a/client/rpc/src/state/state_light.rs +++ b/client/rpc/src/state/state_light.rs @@ -40,9 +40,9 @@ use rpc::{ use api::Subscriptions; use client_api::backend::Backend; +use sp_blockchain::Error as ClientError; use client::{ - BlockchainEvents, Client, CallExecutor, - error::Error as ClientError, + BlockchainEvents, Client, CallExecutor, light::{ blockchain::{future_header, RemoteBlockchain}, fetcher::{Fetcher, RemoteCallRequest, RemoteReadRequest, RemoteReadChildRequest}, diff --git a/client/service/Cargo.toml b/client/service/Cargo.toml index f1c3669c47..2c19c57a31 100644 --- a/client/service/Cargo.toml +++ b/client/service/Cargo.toml @@ -31,6 +31,7 @@ target_info = "0.1.0" keystore = { package = "substrate-keystore", path = "../keystore" } sr-io = { path = "../../primitives/sr-io" } sr-primitives = { path = "../../primitives/sr-primitives" } +sp-blockchain = { path = "../../primitives/blockchain" } primitives = { package = "substrate-primitives", path = "../../primitives/core" } session = { package = "substrate-session", path = "../../primitives/session" } app-crypto = { package = "substrate-application-crypto", path = "../../primitives/application-crypto" } @@ -44,7 +45,7 @@ tx-pool-api = { package = "substrate-transaction-pool-runtime-api", path = "../. client_db = { package = "substrate-client-db", path = "../db" } codec = { package = "parity-scale-codec", version = "1.0.0" } substrate-executor = { path = "../executor" } -transaction_pool = { package = "substrate-transaction-pool", path = "../transaction-pool" } +transaction_pool = { package = "sc-transaction-pool", path = "../../client/transaction-pool" } rpc-servers = { package = "substrate-rpc-servers", path = "../rpc-servers" } rpc = { package = "substrate-rpc", path = "../rpc" } tel = { package = "substrate-telemetry", path = "../telemetry" } @@ -56,9 +57,6 @@ tracing = "0.1.10" [dev-dependencies] substrate-test-runtime-client = { path = "../../test/utils/runtime/client" } -node-executor = { path = "../../bin/node/executor" } -node-primitives = { path = "../../bin/node/primitives" } -node-runtime = { path = "../../bin/node/runtime" } babe-primitives = { package = "substrate-consensus-babe-primitives", path = "../../primitives/consensus/babe" } grandpa = { package = "substrate-finality-grandpa", path = "../finality-grandpa" } grandpa-primitives = { package = "substrate-finality-grandpa-primitives", path = "../../primitives/finality-grandpa" } diff --git a/client/service/src/builder.rs b/client/service/src/builder.rs index 6d8bc53822..ef3403e6d8 100644 --- a/client/service/src/builder.rs +++ b/client/service/src/builder.rs @@ -54,6 +54,7 @@ use std::{ use sysinfo::{get_current_pid, ProcessExt, System, SystemExt}; use tel::{telemetry, SUBSTRATE_INFO}; use transaction_pool::txpool::{self, ChainApi, Pool as TransactionPool}; +use sp_blockchain; use grafana_data_source::{self, record_metrics}; /// Aggregator for the components required to build a service. @@ -765,7 +766,7 @@ ServiceBuilder< offchain::OffchainWorkerApi + tx_pool_api::TaggedTransactionQueue + session::SessionKeys + - sr_api::ApiExt, + sr_api::ApiExt, TBl: BlockT::Out>, TRtApi: 'static + Send + Sync, TCfg: Default, diff --git a/client/service/src/error.rs b/client/service/src/error.rs index 85a6892b26..cd2fce6bde 100644 --- a/client/service/src/error.rs +++ b/client/service/src/error.rs @@ -16,10 +16,10 @@ //! Errors that can occur during the service operation. -use client; use network; use keystore; use consensus_common; +use sp_blockchain; /// Service Result typedef. pub type Result = std::result::Result; @@ -28,7 +28,7 @@ pub type Result = std::result::Result; #[derive(Debug, derive_more::Display, derive_more::From)] pub enum Error { /// Client error. - Client(client::error::Error), + Client(sp_blockchain::Error), /// IO error. Io(std::io::Error), /// Consensus error. diff --git a/client/src/call_executor.rs b/client/src/call_executor.rs index d37d2b0068..787e00a84d 100644 --- a/client/src/call_executor.rs +++ b/client/src/call_executor.rs @@ -31,9 +31,7 @@ use primitives::{ traits::CodeExecutor, }; use sr_api::{ProofRecorder, InitializeBlock}; -use client_api::{ - error, backend, call_executor::CallExecutor, -}; +use client_api::{backend, call_executor::CallExecutor}; /// Call executor that executes methods locally, querying all required /// data from local backend. @@ -79,7 +77,7 @@ where call_data: &[u8], strategy: ExecutionStrategy, extensions: Option, - ) -> error::Result> { + ) -> sp_blockchain::Result> { let mut changes = OverlayedChanges::default(); let state = self.backend.state_at(*id)?; let return_data = StateMachine::new( @@ -105,7 +103,7 @@ where fn contextual_call< 'a, - IB: Fn() -> error::Result<()>, + IB: Fn() -> sp_blockchain::Result<()>, EM: Fn( Result, Self::Error>, Result, Self::Error> @@ -124,7 +122,7 @@ where native_call: Option, recorder: &Option>, extensions: Option, - ) -> Result, error::Error> where ExecutionManager: Clone { + ) -> Result, sp_blockchain::Error> where ExecutionManager: Clone { match initialize_block { InitializeBlock::Do(ref init_block) if init_block.borrow().as_ref().map(|id| id != at).unwrap_or(true) => { @@ -189,7 +187,7 @@ where Ok(result) } - fn runtime_version(&self, id: &BlockId) -> error::Result { + fn runtime_version(&self, id: &BlockId) -> sp_blockchain::Result { let mut overlay = OverlayedChanges::default(); let state = self.backend.state_at(*id)?; @@ -204,7 +202,7 @@ where let _lock = self.backend.get_import_lock().read(); self.backend.destroy_state(state)?; } - version.ok_or(error::Error::VersionInvalid.into()) + version.ok_or(sp_blockchain::Error::VersionInvalid.into()) } fn call_at_state< @@ -223,7 +221,7 @@ where manager: ExecutionManager, native_call: Option, extensions: Option, - ) -> error::Result<( + ) -> sp_blockchain::Result<( NativeOrEncoded, (S::Transaction, ::Out), Option>>, @@ -255,7 +253,7 @@ where overlay: &mut OverlayedChanges, method: &str, call_data: &[u8] - ) -> Result<(Vec, StorageProof), error::Error> { + ) -> Result<(Vec, StorageProof), sp_blockchain::Error> { state_machine::prove_execution_on_trie_backend( trie_state, overlay, diff --git a/client/src/cht.rs b/client/src/cht.rs index 874ea02c2a..dc49069f0a 100644 --- a/client/src/cht.rs +++ b/client/src/cht.rs @@ -33,7 +33,7 @@ use state_machine::backend::InMemory as InMemoryState; use state_machine::{MemoryDB, TrieBackend, Backend as StateBackend, StorageProof, prove_read_on_trie_backend, read_proof_check, read_proof_check_on_proving_backend}; -use client_api::error::{Error as ClientError, Result as ClientResult}; +use sp_blockchain::{Error as ClientError, Result as ClientResult}; /// The size of each CHT. This value is passed to every CHT-related function from /// production code. Other values are passed from tests. diff --git a/client/src/client.rs b/client/src/client.rs index b7b704ce78..ea30948458 100644 --- a/client/src/client.rs +++ b/client/src/client.rs @@ -52,7 +52,12 @@ use consensus::{ ImportResult, BlockOrigin, ForkChoiceStrategy, SelectChain, self, }; -use header_metadata::{HeaderMetadata, CachedHeaderMetadata}; +use sp_blockchain::{self as blockchain, + Backend as ChainBackend, + HeaderBackend as ChainHeaderBackend, ProvideCache, Cache, + well_known_cache_keys::Id as CacheKeyId, + HeaderMetadata, CachedHeaderMetadata, +}; use sr_api::{CallRuntimeAt, ConstructRuntimeApi, Core as CoreApi, ProofRecorder, InitializeBlock}; use block_builder::BlockBuilderApi; @@ -62,11 +67,6 @@ pub use client_api::{ self, BlockImportOperation, PrunableStateChangesTrieStorage, ClientImportOperation, Finalizer, ImportSummary, NewBlockState, }, - blockchain::{ - self, Backend as ChainBackend, - HeaderBackend as ChainHeaderBackend, ProvideCache, Cache, - well_known_cache_keys::Id as CacheKeyId, - }, client::{ ImportNotifications, FinalityNotification, FinalityNotifications, BlockImportNotification, ClientInfo, BlockchainEvents, BlockBody, ProvideUncles, ForkBlocks, @@ -74,10 +74,9 @@ pub use client_api::{ }, execution_extensions::{ExecutionExtensions, ExecutionStrategies}, notifications::{StorageNotifications, StorageEventStream}, - error::Error, - error, CallExecutor, }; +use sp_blockchain::Error; use crate::{ call_executor::LocalCallExecutor, @@ -146,7 +145,7 @@ pub fn new_in_mem( executor: E, genesis_storage: S, keystore: Option, -) -> error::Result sp_blockchain::Result, LocalCallExecutor, E>, Block, @@ -166,7 +165,7 @@ pub fn new_with_backend( executor: E, build_genesis_storage: S, keystore: Option, -) -> error::Result, Block, RA>> +) -> sp_blockchain::Result, Block, RA>> where E: CodeExecutor + RuntimeInfo, S: BuildStorage, @@ -198,7 +197,7 @@ impl Client where build_genesis_storage: S, fork_blocks: ForkBlocks, execution_extensions: ExecutionExtensions, - ) -> error::Result { + ) -> sp_blockchain::Result { if backend.blockchain().header(BlockId::Number(Zero::zero()))?.is_none() { let (genesis_storage, children_genesis_storage) = build_genesis_storage.build_storage()?; let mut op = backend.begin_operation()?; @@ -237,29 +236,29 @@ impl Client where } /// Get a reference to the state at a given block. - pub fn state_at(&self, block: &BlockId) -> error::Result { + pub fn state_at(&self, block: &BlockId) -> sp_blockchain::Result { self.backend.state_at(*block) } /// Given a `BlockId` and a key prefix, return the matching child storage keys in that block. - pub fn storage_keys(&self, id: &BlockId, key_prefix: &StorageKey) -> error::Result> { + pub fn storage_keys(&self, id: &BlockId, key_prefix: &StorageKey) -> sp_blockchain::Result> { let keys = self.state_at(id)?.keys(&key_prefix.0).into_iter().map(StorageKey).collect(); Ok(keys) } /// Given a `BlockId` and a key, return the value under the key in that block. - pub fn storage(&self, id: &BlockId, key: &StorageKey) -> error::Result> { + pub fn storage(&self, id: &BlockId, key: &StorageKey) -> sp_blockchain::Result> { Ok(self.state_at(id)? - .storage(&key.0).map_err(|e| error::Error::from_state(Box::new(e)))? + .storage(&key.0).map_err(|e| sp_blockchain::Error::from_state(Box::new(e)))? .map(StorageData) ) } /// Given a `BlockId` and a key, return the value under the hash in that block. pub fn storage_hash(&self, id: &BlockId, key: &StorageKey) - -> error::Result> { + -> sp_blockchain::Result> { Ok(self.state_at(id)? - .storage_hash(&key.0).map_err(|e| error::Error::from_state(Box::new(e)))? + .storage_hash(&key.0).map_err(|e| sp_blockchain::Error::from_state(Box::new(e)))? ) } @@ -269,7 +268,7 @@ impl Client where id: &BlockId, child_storage_key: &StorageKey, key_prefix: &StorageKey - ) -> error::Result> { + ) -> sp_blockchain::Result> { let keys = self.state_at(id)? .child_keys(&child_storage_key.0, &key_prefix.0) .into_iter() @@ -284,9 +283,9 @@ impl Client where id: &BlockId, child_storage_key: &StorageKey, key: &StorageKey - ) -> error::Result> { + ) -> sp_blockchain::Result> { Ok(self.state_at(id)? - .child_storage(&child_storage_key.0, &key.0).map_err(|e| error::Error::from_state(Box::new(e)))? + .child_storage(&child_storage_key.0, &key.0).map_err(|e| sp_blockchain::Error::from_state(Box::new(e)))? .map(StorageData)) } @@ -296,21 +295,21 @@ impl Client where id: &BlockId, child_storage_key: &StorageKey, key: &StorageKey - ) -> error::Result> { + ) -> sp_blockchain::Result> { Ok(self.state_at(id)? - .child_storage_hash(&child_storage_key.0, &key.0).map_err(|e| error::Error::from_state(Box::new(e)))? + .child_storage_hash(&child_storage_key.0, &key.0).map_err(|e| sp_blockchain::Error::from_state(Box::new(e)))? ) } /// Get the code at a given block. - pub fn code_at(&self, id: &BlockId) -> error::Result> { + pub fn code_at(&self, id: &BlockId) -> sp_blockchain::Result> { Ok(self.storage(id, &StorageKey(well_known_keys::CODE.to_vec()))? .expect("None is returned if there's no value stored for the given key;\ ':code' key is always defined; qed").0) } /// Get the RuntimeVersion at a given block. - pub fn runtime_version_at(&self, id: &BlockId) -> error::Result { + pub fn runtime_version_at(&self, id: &BlockId) -> sp_blockchain::Result { self.executor.runtime_version(id) } @@ -320,7 +319,7 @@ impl Client where } /// Reads storage value at a given block + key, returning read proof. - pub fn read_proof(&self, id: &BlockId, keys: I) -> error::Result where + pub fn read_proof(&self, id: &BlockId, keys: I) -> sp_blockchain::Result where I: IntoIterator, I::Item: AsRef<[u8]>, { @@ -336,7 +335,7 @@ impl Client where id: &BlockId, storage_key: &[u8], keys: I, - ) -> error::Result where + ) -> sp_blockchain::Result where I: IntoIterator, I::Item: AsRef<[u8]>, { @@ -353,21 +352,21 @@ impl Client where id: &BlockId, method: &str, call_data: &[u8] - ) -> error::Result<(Vec, StorageProof)> { + ) -> sp_blockchain::Result<(Vec, StorageProof)> { let state = self.state_at(id)?; let header = self.prepare_environment_block(id)?; prove_execution(state, header, &self.executor, method, call_data) } /// Reads given header and generates CHT-based header proof. - pub fn header_proof(&self, id: &BlockId) -> error::Result<(Block::Header, StorageProof)> { + pub fn header_proof(&self, id: &BlockId) -> sp_blockchain::Result<(Block::Header, StorageProof)> { self.header_proof_with_cht_size(id, cht::size()) } /// Get block hash by number. pub fn block_hash(&self, block_number: <::Header as HeaderT>::Number - ) -> error::Result> { + ) -> sp_blockchain::Result> { self.backend.blockchain().hash(block_number) } @@ -376,8 +375,8 @@ impl Client where &self, id: &BlockId, cht_size: NumberFor, - ) -> error::Result<(Block::Header, StorageProof)> { - let proof_error = || error::Error::Backend(format!("Failed to generate header proof for {:?}", id)); + ) -> sp_blockchain::Result<(Block::Header, StorageProof)> { + let proof_error = || sp_blockchain::Error::Backend(format!("Failed to generate header proof for {:?}", id)); let header = self.backend.blockchain().expect_header(*id)?; let block_num = *header.number(); let cht_num = cht::block_to_cht_number(cht_size, block_num).ok_or_else(proof_error)?; @@ -401,14 +400,14 @@ impl Client where &self, first: NumberFor, last: BlockId, - ) -> error::Result, BlockId)>> { + ) -> sp_blockchain::Result, BlockId)>> { let (config, storage) = match self.require_changes_trie().ok() { Some((config, storage)) => (config, storage), None => return Ok(None), }; let last_num = self.backend.blockchain().expect_block_number_from_id(&last)?; if first > last_num { - return Err(error::Error::ChangesTrieAccessFailed("Invalid changes trie range".into())); + return Err(sp_blockchain::Error::ChangesTrieAccessFailed("Invalid changes trie range".into())); } let finalized_number = self.backend.blockchain().info().finalized_number; let oldest = storage.oldest_changes_trie_block(&config, finalized_number); @@ -426,7 +425,7 @@ impl Client where last: BlockId, storage_key: Option<&StorageKey>, key: &StorageKey - ) -> error::Result, u32)>> { + ) -> sp_blockchain::Result, u32)>> { let (config, storage) = self.require_changes_trie()?; let last_number = self.backend.blockchain().expect_block_number_from_id(&last)?; let last_hash = self.backend.blockchain().expect_block_hash_from_id(&last)?; @@ -450,7 +449,7 @@ impl Client where storage_key.as_ref().map(|sk| sk.0.as_slice()), &key.0) .and_then(|r| r.map(|r| r.map(|(block, tx)| (block, tx))).collect::>()) - .map_err(|err| error::Error::ChangesTrieAccessFailed(err)) + .map_err(|err| sp_blockchain::Error::ChangesTrieAccessFailed(err)) } /// Get proof for computation of (block, extrinsic) pairs where key has been changed at given blocks range. @@ -467,7 +466,7 @@ impl Client where max: Block::Hash, storage_key: Option<&StorageKey>, key: &StorageKey, - ) -> error::Result> { + ) -> sp_blockchain::Result> { self.key_changes_proof_with_cht_size( first, last, @@ -489,7 +488,7 @@ impl Client where storage_key: Option<&StorageKey>, key: &StorageKey, cht_size: NumberFor, - ) -> error::Result> { + ) -> sp_blockchain::Result> { struct AccessedRootsRecorder<'a, Block: BlockT> { storage: &'a dyn ChangesTrieStorage>, min: NumberFor, @@ -575,7 +574,7 @@ impl Client where storage_key.as_ref().map(|sk| sk.0.as_slice()), &key.0, ) - .map_err(|err| error::Error::from(error::Error::ChangesTrieAccessFailed(err)))?; + .map_err(|err| sp_blockchain::Error::from(sp_blockchain::Error::ChangesTrieAccessFailed(err)))?; // now gather proofs for all changes tries roots that were touched during key_changes_proof // execution AND are unknown (i.e. replaced with CHT) to the requester @@ -595,7 +594,7 @@ impl Client where &self, cht_size: NumberFor, blocks: I - ) -> error::Result { + ) -> sp_blockchain::Result { // most probably we have touched several changes tries that are parts of the single CHT // => GroupBy changes tries by CHT number and then gather proof for the whole group at once let mut proofs = Vec::new(); @@ -615,7 +614,7 @@ impl Client where cht_size: NumberFor, cht_num: NumberFor, blocks: Vec> - ) -> error::Result { + ) -> sp_blockchain::Result { let cht_start = cht::start_number(cht_size, cht_num); let mut current_num = cht_start; let cht_range = ::std::iter::from_fn(|| { @@ -631,12 +630,12 @@ impl Client where } /// Returns changes trie configuration and storage or an error if it is not supported. - fn require_changes_trie(&self) -> error::Result<(ChangesTrieConfiguration, &B::ChangesTrieStorage)> { + fn require_changes_trie(&self) -> sp_blockchain::Result<(ChangesTrieConfiguration, &B::ChangesTrieStorage)> { let config = self.changes_trie_config()?; let storage = self.backend.changes_trie_storage(); match (config, storage) { (Some(config), Some(storage)) => Ok((config, storage)), - _ => Err(error::Error::ChangesTriesNotSupported.into()), + _ => Err(sp_blockchain::Error::ChangesTriesNotSupported.into()), } } @@ -644,7 +643,7 @@ impl Client where pub fn new_block( &self, inherent_digests: DigestFor, - ) -> error::Result> where + ) -> sp_blockchain::Result> where E: Clone + Send + Sync, RA: Send + Sync, Self: ProvideRuntimeApi, @@ -665,7 +664,7 @@ impl Client where &self, parent: &BlockId, inherent_digests: DigestFor, - ) -> error::Result> where + ) -> sp_blockchain::Result> where E: Clone + Send + Sync, RA: Send + Sync, Self: ProvideRuntimeApi, @@ -689,7 +688,7 @@ impl Client where &self, parent: &BlockId, inherent_digests: DigestFor, - ) -> error::Result> where + ) -> sp_blockchain::Result> where E: Clone + Send + Sync, RA: Send + Sync, Self: ProvideRuntimeApi, @@ -707,7 +706,7 @@ impl Client where /// Lock the import lock, and run operations inside. pub fn lock_import_and_run(&self, f: F) -> Result where F: FnOnce(&mut ClientImportOperation) -> Result, - Err: From, + Err: From, { let inner = || { let _import_lock = self.backend.get_import_lock().write(); @@ -744,7 +743,7 @@ impl Client where operation: &mut ClientImportOperation, import_block: BlockImportParams, new_cache: HashMap>, - ) -> error::Result where + ) -> sp_blockchain::Result where E: CallExecutor + Send + Sync + Clone, { let BlockImportParams { @@ -829,7 +828,7 @@ impl Client where aux: Vec<(Vec, Option>)>, fork_choice: ForkChoiceStrategy, enact_state: bool, - ) -> error::Result where + ) -> sp_blockchain::Result where E: CallExecutor + Send + Sync + Clone, { let parent_hash = import_headers.post().parent_hash().clone(); @@ -843,7 +842,7 @@ impl Client where // the block is lower than our last finalized block so it must revert // finality, refusing import. if *import_headers.post().number() <= info.finalized_number { - return Err(error::Error::NotInFinalizedChain); + return Err(sp_blockchain::Error::NotInFinalizedChain); } // this is a fairly arbitrary choice of where to draw the line on making notifications, @@ -902,7 +901,7 @@ impl Client where }; let retracted = if is_new_best { - let route_from_best = header_metadata::tree_route( + let route_from_best = sp_blockchain::tree_route( self.backend.blockchain(), info.best_hash, parent_hash, @@ -948,7 +947,7 @@ impl Client where origin: BlockOrigin, hash: Block::Hash, body: &[Block::Extrinsic], - ) -> error::Result<( + ) -> sp_blockchain::Result<( Option>, Option>>, Option<( @@ -1009,7 +1008,7 @@ impl Client where let (top, children) = overlay.into_committed(); let children = children.map(|(sk, it)| (sk, it.collect())).collect(); if import_headers.post().state_root() != &storage_update.1 { - return Err(error::Error::InvalidStateRoot); + return Err(sp_blockchain::Error::InvalidStateRoot); } Ok((Some(storage_update.0), Some(changes_update), Some((top.collect(), children)))) @@ -1025,7 +1024,7 @@ impl Client where justification: Option, best_block: Block::Hash, notify: bool, - ) -> error::Result<()> { + ) -> sp_blockchain::Result<()> { // find tree route from last finalized to given block. let last_finalized = self.backend.blockchain().last_finalized()?; @@ -1034,16 +1033,16 @@ impl Client where return Ok(()); } - let route_from_finalized = header_metadata::tree_route(self.backend.blockchain(), last_finalized, block)?; + let route_from_finalized = sp_blockchain::tree_route(self.backend.blockchain(), last_finalized, block)?; if let Some(retracted) = route_from_finalized.retracted().get(0) { warn!("Safety violation: attempted to revert finalized block {:?} which is not in the \ same chain as last finalized {:?}", retracted, last_finalized); - return Err(error::Error::NotInFinalizedChain); + return Err(sp_blockchain::Error::NotInFinalizedChain); } - let route_from_best = header_metadata::tree_route(self.backend.blockchain(), best_block, block)?; + let route_from_best = sp_blockchain::tree_route(self.backend.blockchain(), best_block, block)?; // if the block is not a direct ancestor of the current best chain, // then some other block is the common ancestor. @@ -1083,7 +1082,7 @@ impl Client where fn notify_finalized( &self, notify_finalized: Vec, - ) -> error::Result<()> { + ) -> sp_blockchain::Result<()> { let mut sinks = self.finality_notification_sinks.lock(); for finalized_hash in notify_finalized { @@ -1106,7 +1105,7 @@ impl Client where Ok(()) } - fn notify_imported(&self, notify_import: ImportSummary) -> error::Result<()> { + fn notify_imported(&self, notify_import: ImportSummary) -> sp_blockchain::Result<()> { if let Some(storage_changes) = notify_import.storage_changes { // TODO [ToDr] How to handle re-orgs? Should we re-emit all storage changes? self.storage_notifications.lock() @@ -1133,7 +1132,7 @@ impl Client where /// Attempts to revert the chain by `n` blocks. Returns the number of blocks that were /// successfully reverted. - pub fn revert(&self, n: NumberFor) -> error::Result> { + pub fn revert(&self, n: NumberFor) -> sp_blockchain::Result> { Ok(self.backend.revert(n)?) } @@ -1147,7 +1146,7 @@ impl Client where } /// Get block status. - pub fn block_status(&self, id: &BlockId) -> error::Result { + pub fn block_status(&self, id: &BlockId) -> sp_blockchain::Result { // this can probably be implemented more efficiently if let BlockId::Hash(ref h) = id { if self.importing_block.read().as_ref().map_or(false, |importing| h == importing) { @@ -1171,23 +1170,23 @@ impl Client where } /// Get block header by id. - pub fn header(&self, id: &BlockId) -> error::Result::Header>> { + pub fn header(&self, id: &BlockId) -> sp_blockchain::Result::Header>> { self.backend.blockchain().header(*id) } /// Get block body by id. - pub fn body(&self, id: &BlockId) -> error::Result::Extrinsic>>> { + pub fn body(&self, id: &BlockId) -> sp_blockchain::Result::Extrinsic>>> { self.backend.blockchain().body(*id) } /// Get block justification set by id. - pub fn justification(&self, id: &BlockId) -> error::Result> { + pub fn justification(&self, id: &BlockId) -> sp_blockchain::Result> { self.backend.blockchain().justification(*id) } /// Get full block by id. pub fn block(&self, id: &BlockId) - -> error::Result>> + -> sp_blockchain::Result>> { Ok(match (self.header(id)?, self.body(id)?, self.justification(id)?) { (Some(header), Some(extrinsics), justification) => @@ -1197,8 +1196,8 @@ impl Client where } /// Gets the uncles of the block with `target_hash` going back `max_generation` ancestors. - pub fn uncles(&self, target_hash: Block::Hash, max_generation: NumberFor) -> error::Result> { - let load_header = |id: Block::Hash| -> error::Result { + pub fn uncles(&self, target_hash: Block::Hash, max_generation: NumberFor) -> sp_blockchain::Result> { + let load_header = |id: Block::Hash| -> sp_blockchain::Result { match self.backend.blockchain().header(BlockId::Hash(id))? { Some(hdr) => Ok(hdr), None => Err(Error::UnknownBlock(format!("{:?}", id))), @@ -1230,12 +1229,12 @@ impl Client where fn changes_trie_config(&self) -> Result, Error> { Ok(self.backend.state_at(BlockId::Number(self.backend.blockchain().info().best_number))? .storage(well_known_keys::CHANGES_TRIE_CONFIG) - .map_err(|e| error::Error::from_state(Box::new(e)))? + .map_err(|e| sp_blockchain::Error::from_state(Box::new(e)))? .and_then(|c| Decode::decode(&mut &*c).ok())) } /// Prepare in-memory header that is used in execution environment. - fn prepare_environment_block(&self, parent: &BlockId) -> error::Result { + fn prepare_environment_block(&self, parent: &BlockId) -> sp_blockchain::Result { let parent_header = self.backend.blockchain().expect_header(*parent)?; Ok(<::Header as HeaderT>::new( self.backend.blockchain().expect_block_number_from_id(parent)? + One::one(), @@ -1252,7 +1251,7 @@ impl HeaderMetadata for Client where E: CallExecutor, Block: BlockT, { - type Error = error::Error; + type Error = sp_blockchain::Error; fn header_metadata(&self, hash: Block::Hash) -> Result, Self::Error> { self.backend.blockchain().header_metadata(hash) @@ -1272,7 +1271,7 @@ impl ProvideUncles for Client where E: CallExecutor, Block: BlockT, { - fn uncles(&self, target_hash: Block::Hash, max_generation: NumberFor) -> error::Result> { + fn uncles(&self, target_hash: Block::Hash, max_generation: NumberFor) -> sp_blockchain::Result> { Ok(Client::uncles(self, target_hash, max_generation)? .into_iter() .filter_map(|hash| Client::header(self, &BlockId::Hash(hash)).unwrap_or(None)) @@ -1287,7 +1286,7 @@ impl ChainHeaderBackend for Client wher Block: BlockT, RA: Send + Sync, { - fn header(&self, id: BlockId) -> error::Result> { + fn header(&self, id: BlockId) -> sp_blockchain::Result> { self.backend.blockchain().header(id) } @@ -1295,15 +1294,15 @@ impl ChainHeaderBackend for Client wher self.backend.blockchain().info() } - fn status(&self, id: BlockId) -> error::Result { + fn status(&self, id: BlockId) -> sp_blockchain::Result { self.backend.blockchain().status(id) } - fn number(&self, hash: Block::Hash) -> error::Result::Header as HeaderT>::Number>> { + fn number(&self, hash: Block::Hash) -> sp_blockchain::Result::Header as HeaderT>::Number>> { self.backend.blockchain().number(hash) } - fn hash(&self, number: NumberFor) -> error::Result> { + fn hash(&self, number: NumberFor) -> sp_blockchain::Result> { self.backend.blockchain().hash(number) } } @@ -1316,11 +1315,11 @@ impl sr_primitives::traits::BlockIdTo for Client) -> error::Result> { + fn to_hash(&self, block_id: &BlockId) -> sp_blockchain::Result> { self.block_hash_from_id(block_id) } - fn to_number(&self, block_id: &BlockId) -> error::Result>> { + fn to_number(&self, block_id: &BlockId) -> sp_blockchain::Result>> { self.block_number_from_id(block_id) } } @@ -1331,7 +1330,7 @@ impl ChainHeaderBackend for &Client whe Block: BlockT, RA: Send + Sync, { - fn header(&self, id: BlockId) -> error::Result> { + fn header(&self, id: BlockId) -> sp_blockchain::Result> { (**self).backend.blockchain().header(id) } @@ -1339,15 +1338,15 @@ impl ChainHeaderBackend for &Client whe (**self).backend.blockchain().info() } - fn status(&self, id: BlockId) -> error::Result { + fn status(&self, id: BlockId) -> sp_blockchain::Result { (**self).status(id) } - fn number(&self, hash: Block::Hash) -> error::Result::Header as HeaderT>::Number>> { + fn number(&self, hash: Block::Hash) -> sp_blockchain::Result::Header as HeaderT>::Number>> { (**self).number(hash) } - fn hash(&self, number: NumberFor) -> error::Result> { + fn hash(&self, number: NumberFor) -> sp_blockchain::Result> { (**self).hash(number) } } @@ -1397,7 +1396,7 @@ impl CallRuntimeAt for Client where native_call: Option, context: ExecutionContext, recorder: &Option>, - ) -> error::Result> { + ) -> sp_blockchain::Result> { let (manager, extensions) = self.execution_extensions.manager_and_extensions(at, context); self.executor.contextual_call::<_, fn(_,_) -> _,_,_>( || core_api.initialize_block(at, &self.prepare_environment_block(at)?), @@ -1413,7 +1412,7 @@ impl CallRuntimeAt for Client where ) } - fn runtime_version_at(&self, at: &BlockId) -> error::Result { + fn runtime_version_at(&self, at: &BlockId) -> sp_blockchain::Result { self.runtime_version_at(at) } } @@ -1529,13 +1528,13 @@ impl Finalizer for Client, justification: Option, notify: bool, - ) -> error::Result<()> { + ) -> sp_blockchain::Result<()> { let last_best = self.backend.blockchain().info().best_hash; let to_finalize_hash = self.backend.blockchain().expect_block_hash_from_id(&id)?; self.apply_finality_with_block_hash(operation, to_finalize_hash, justification, last_best, notify) } - fn finalize_block(&self, id: BlockId, justification: Option, notify: bool) -> error::Result<()> { + fn finalize_block(&self, id: BlockId, justification: Option, notify: bool) -> sp_blockchain::Result<()> { self.lock_import_and_run(|operation| { self.apply_finality(operation, id, justification, notify) }) @@ -1553,11 +1552,11 @@ impl Finalizer for &Client, justification: Option, notify: bool, - ) -> error::Result<()> { + ) -> sp_blockchain::Result<()> { (**self).apply_finality(operation, id, justification, notify) } - fn finalize_block(&self, id: BlockId, justification: Option, notify: bool) -> error::Result<()> { + fn finalize_block(&self, id: BlockId, justification: Option, notify: bool) -> sp_blockchain::Result<()> { (**self).finalize_block(id, justification, notify) } } @@ -1585,7 +1584,7 @@ where &self, filter_keys: Option<&[StorageKey]>, child_filter_keys: Option<&[(StorageKey, Option>)]>, - ) -> error::Result> { + ) -> sp_blockchain::Result> { Ok(self.storage_notifications.lock().listen(filter_keys, child_filter_keys)) } } @@ -1620,7 +1619,7 @@ where } } - fn best_block_header(&self) -> error::Result<::Header> { + fn best_block_header(&self) -> sp_blockchain::Result<::Header> { let info = self.backend.blockchain().info(); let import_lock = self.backend.get_import_lock(); let best_hash = self.backend.blockchain().best_containing(info.best_hash, None, import_lock)? @@ -1630,7 +1629,7 @@ where .expect("given block hash was fetched from block in db; qed")) } - fn leaves(&self) -> Result::Hash>, error::Error> { + fn leaves(&self) -> Result::Hash>, sp_blockchain::Error> { self.backend.blockchain().leaves() } } @@ -1670,7 +1669,7 @@ impl BlockBody for Client E: CallExecutor, Block: BlockT, { - fn block_body(&self, id: &BlockId) -> error::Result::Extrinsic>>> { + fn block_body(&self, id: &BlockId) -> sp_blockchain::Result::Extrinsic>>> { self.body(id) } } @@ -1688,7 +1687,7 @@ impl backend::AuxStore for Client 'c: 'a, I: IntoIterator, D: IntoIterator, - >(&self, insert: I, delete: D) -> error::Result<()> { + >(&self, insert: I, delete: D) -> sp_blockchain::Result<()> { // Import is locked here because we may have other block import // operations that tries to set aux data. Note that for consensus // layer, one can always use atomic operations to make sure @@ -1698,7 +1697,7 @@ impl backend::AuxStore for Client }) } /// Query auxiliary data from key-value store. - fn get_aux(&self, key: &[u8]) -> error::Result>> { + fn get_aux(&self, key: &[u8]) -> sp_blockchain::Result>> { backend::AuxStore::get_aux(&*self.backend, key) } } @@ -1717,11 +1716,11 @@ impl backend::AuxStore for &Client 'c: 'a, I: IntoIterator, D: IntoIterator, - >(&self, insert: I, delete: D) -> error::Result<()> { + >(&self, insert: I, delete: D) -> sp_blockchain::Result<()> { (**self).insert_aux(insert, delete) } - fn get_aux(&self, key: &[u8]) -> error::Result>> { + fn get_aux(&self, key: &[u8]) -> sp_blockchain::Result>> { (**self).get_aux(key) } } @@ -1731,7 +1730,7 @@ pub fn apply_aux<'a, 'b: 'a, 'c: 'a, B, Block, H, D, I>( operation: &mut ClientImportOperation, insert: I, delete: D -) -> error::Result<()> +) -> sp_blockchain::Result<()> where Block: BlockT, H: Hasher, @@ -2702,7 +2701,7 @@ pub(crate) mod tests { let import_err = client.import(BlockOrigin::Own, b3).err().unwrap(); let expected_err = ConsensusError::ClientImport( - error::Error::NotInFinalizedChain.to_string() + sp_blockchain::Error::NotInFinalizedChain.to_string() ); assert_eq!( @@ -2725,7 +2724,7 @@ pub(crate) mod tests { let import_err = client.import(BlockOrigin::Own, c1).err().unwrap(); let expected_err = ConsensusError::ClientImport( - error::Error::NotInFinalizedChain.to_string() + sp_blockchain::Error::NotInFinalizedChain.to_string() ); assert_eq!( diff --git a/client/src/in_mem.rs b/client/src/in_mem.rs index d56c3f2b07..e6140e6d74 100644 --- a/client/src/in_mem.rs +++ b/client/src/in_mem.rs @@ -30,10 +30,9 @@ use state_machine::backend::{Backend as StateBackend, InMemory}; use state_machine::{self, InMemoryChangesTrieStorage, ChangesTrieAnchorBlockId, ChangesTrieTransaction}; use hash_db::{Hasher, Prefix}; use trie::MemoryDB; -use header_metadata::{CachedHeaderMetadata, HeaderMetadata}; +use sp_blockchain::{CachedHeaderMetadata, HeaderMetadata}; use client_api::{ - error, backend::{self, NewBlockState, StorageCollection, ChildStorageCollection}, blockchain::{ self, BlockStatus, HeaderBackend, well_known_cache_keys::Id as CacheKeyId @@ -158,7 +157,7 @@ impl Blockchain { justification: Option, body: Option::Extrinsic>>, new_state: NewBlockState, - ) -> client_api::error::Result<()> { + ) -> sp_blockchain::Result<()> { let number = header.number().clone(); if new_state.is_best() { self.apply_head(&header)?; @@ -208,16 +207,16 @@ impl Blockchain { } /// Set an existing block as head. - pub fn set_head(&self, id: BlockId) -> error::Result<()> { + pub fn set_head(&self, id: BlockId) -> sp_blockchain::Result<()> { let header = match self.header(id)? { Some(h) => h, - None => return Err(error::Error::UnknownBlock(format!("{}", id))), + None => return Err(sp_blockchain::Error::UnknownBlock(format!("{}", id))), }; self.apply_head(&header) } - fn apply_head(&self, header: &::Header) -> error::Result<()> { + fn apply_head(&self, header: &::Header) -> sp_blockchain::Result<()> { let hash = header.hash(); let number = header.number(); @@ -228,7 +227,7 @@ impl Blockchain { if &best_hash == header.parent_hash() { None } else { - let route = header_metadata::tree_route(self, best_hash, *header.parent_hash())?; + let route = sp_blockchain::tree_route(self, best_hash, *header.parent_hash())?; Some(route) } }; @@ -255,10 +254,10 @@ impl Blockchain { Ok(()) } - fn finalize_header(&self, id: BlockId, justification: Option) -> error::Result<()> { + fn finalize_header(&self, id: BlockId, justification: Option) -> sp_blockchain::Result<()> { let hash = match self.header(id)? { Some(h) => h.hash(), - None => return Err(error::Error::UnknownBlock(format!("{}", id))), + None => return Err(sp_blockchain::Error::UnknownBlock(format!("{}", id))), }; let mut storage = self.storage.write(); @@ -290,7 +289,7 @@ impl Blockchain { } impl HeaderBackend for Blockchain { - fn header(&self, id: BlockId) -> error::Result::Header>> { + fn header(&self, id: BlockId) -> sp_blockchain::Result::Header>> { Ok(self.id(id).and_then(|hash| { self.storage.read().blocks.get(&hash).map(|b| b.header().clone()) })) @@ -307,28 +306,28 @@ impl HeaderBackend for Blockchain { } } - fn status(&self, id: BlockId) -> error::Result { + fn status(&self, id: BlockId) -> sp_blockchain::Result { match self.id(id).map_or(false, |hash| self.storage.read().blocks.contains_key(&hash)) { true => Ok(BlockStatus::InChain), false => Ok(BlockStatus::Unknown), } } - fn number(&self, hash: Block::Hash) -> error::Result>> { + fn number(&self, hash: Block::Hash) -> sp_blockchain::Result>> { Ok(self.storage.read().blocks.get(&hash).map(|b| *b.header().number())) } - fn hash(&self, number: <::Header as HeaderT>::Number) -> error::Result> { + fn hash(&self, number: <::Header as HeaderT>::Number) -> sp_blockchain::Result> { Ok(self.id(BlockId::Number(number))) } } impl HeaderMetadata for Blockchain { - type Error = error::Error; + type Error = sp_blockchain::Error; fn header_metadata(&self, hash: Block::Hash) -> Result, Self::Error> { self.header(BlockId::hash(hash))?.map(|header| CachedHeaderMetadata::from(&header)) - .ok_or(error::Error::UnknownBlock(format!("header not found: {}", hash))) + .ok_or(sp_blockchain::Error::UnknownBlock(format!("header not found: {}", hash))) } fn insert_header_metadata(&self, _hash: Block::Hash, _metadata: CachedHeaderMetadata) { @@ -340,20 +339,20 @@ impl HeaderMetadata for Blockchain { } impl blockchain::Backend for Blockchain { - fn body(&self, id: BlockId) -> error::Result::Extrinsic>>> { + fn body(&self, id: BlockId) -> sp_blockchain::Result::Extrinsic>>> { Ok(self.id(id).and_then(|hash| { self.storage.read().blocks.get(&hash) .and_then(|b| b.extrinsics().map(|x| x.to_vec())) })) } - fn justification(&self, id: BlockId) -> error::Result> { + fn justification(&self, id: BlockId) -> sp_blockchain::Result> { Ok(self.id(id).and_then(|hash| self.storage.read().blocks.get(&hash).and_then(|b| b.justification().map(|x| x.clone())) )) } - fn last_finalized(&self) -> error::Result { + fn last_finalized(&self) -> sp_blockchain::Result { Ok(self.storage.read().finalized_hash.clone()) } @@ -361,11 +360,11 @@ impl blockchain::Backend for Blockchain { None } - fn leaves(&self) -> error::Result> { + fn leaves(&self) -> sp_blockchain::Result> { Ok(self.storage.read().leaves.hashes()) } - fn children(&self, _parent_hash: Block::Hash) -> error::Result> { + fn children(&self, _parent_hash: Block::Hash) -> sp_blockchain::Result> { unimplemented!() } } @@ -383,7 +382,7 @@ impl backend::AuxStore for Blockchain { 'c: 'a, I: IntoIterator, D: IntoIterator, - >(&self, insert: I, delete: D) -> error::Result<()> { + >(&self, insert: I, delete: D) -> sp_blockchain::Result<()> { let mut storage = self.storage.write(); for (k, v) in insert { storage.aux.insert(k.to_vec(), v.to_vec()); @@ -394,7 +393,7 @@ impl backend::AuxStore for Blockchain { Ok(()) } - fn get_aux(&self, key: &[u8]) -> error::Result>> { + fn get_aux(&self, key: &[u8]) -> sp_blockchain::Result>> { Ok(self.storage.read().aux.get(key).cloned()) } } @@ -409,7 +408,7 @@ impl client_api::light::Storage for Blockchain _cache: HashMap>, state: NewBlockState, aux_ops: Vec<(Vec, Option>)>, - ) -> error::Result<()> { + ) -> sp_blockchain::Result<()> { let hash = header.hash(); self.insert(hash, header, None, None, state)?; @@ -417,15 +416,15 @@ impl client_api::light::Storage for Blockchain Ok(()) } - fn set_head(&self, id: BlockId) -> error::Result<()> { + fn set_head(&self, id: BlockId) -> sp_blockchain::Result<()> { Blockchain::set_head(self, id) } - fn last_finalized(&self) -> error::Result { + fn last_finalized(&self) -> sp_blockchain::Result { Ok(self.storage.read().finalized_hash.clone()) } - fn finalize_header(&self, id: BlockId) -> error::Result<()> { + fn finalize_header(&self, id: BlockId) -> sp_blockchain::Result<()> { Blockchain::finalize_header(self, id, None) } @@ -433,18 +432,18 @@ impl client_api::light::Storage for Blockchain &self, _cht_size: NumberFor, block: NumberFor, - ) -> error::Result { + ) -> sp_blockchain::Result { self.storage.read().header_cht_roots.get(&block).cloned() - .ok_or_else(|| error::Error::Backend(format!("Header CHT for block {} not exists", block))) + .ok_or_else(|| sp_blockchain::Error::Backend(format!("Header CHT for block {} not exists", block))) } fn changes_trie_cht_root( &self, _cht_size: NumberFor, block: NumberFor, - ) -> error::Result { + ) -> sp_blockchain::Result { self.storage.read().changes_trie_cht_roots.get(&block).cloned() - .ok_or_else(|| error::Error::Backend(format!("Changes trie CHT for block {} not exists", block))) + .ok_or_else(|| sp_blockchain::Error::Backend(format!("Changes trie CHT for block {} not exists", block))) } fn cache(&self) -> Option>> { @@ -473,7 +472,7 @@ where { type State = InMemory; - fn state(&self) -> error::Result> { + fn state(&self) -> sp_blockchain::Result> { Ok(Some(&self.old_state)) } @@ -483,7 +482,7 @@ where body: Option::Extrinsic>>, justification: Option, state: NewBlockState, - ) -> error::Result<()> { + ) -> sp_blockchain::Result<()> { assert!(self.pending_block.is_none(), "Only one block per operation is allowed"); self.pending_block = Some(PendingBlock { block: StoredBlock::new(header, body, justification), @@ -496,17 +495,17 @@ where self.pending_cache = cache; } - fn update_db_storage(&mut self, update: as StateBackend>::Transaction) -> error::Result<()> { + fn update_db_storage(&mut self, update: as StateBackend>::Transaction) -> sp_blockchain::Result<()> { self.new_state = Some(self.old_state.update(update)); Ok(()) } - fn update_changes_trie(&mut self, update: ChangesTrieTransaction>) -> error::Result<()> { + fn update_changes_trie(&mut self, update: ChangesTrieTransaction>) -> sp_blockchain::Result<()> { self.changes_trie_update = Some(update.0); Ok(()) } - fn reset_storage(&mut self, top: StorageOverlay, children: ChildrenStorageOverlay) -> error::Result { + fn reset_storage(&mut self, top: StorageOverlay, children: ChildrenStorageOverlay) -> sp_blockchain::Result { check_genesis_storage(&top, &children)?; let child_delta = children.into_iter() @@ -522,7 +521,7 @@ where Ok(root) } - fn insert_aux(&mut self, ops: I) -> error::Result<()> + fn insert_aux(&mut self, ops: I) -> sp_blockchain::Result<()> where I: IntoIterator, Option>)> { self.aux.append(&mut ops.into_iter().collect()); @@ -533,16 +532,16 @@ where &mut self, _update: StorageCollection, _child_update: ChildStorageCollection, - ) -> error::Result<()> { + ) -> sp_blockchain::Result<()> { Ok(()) } - fn mark_finalized(&mut self, block: BlockId, justification: Option) -> error::Result<()> { + fn mark_finalized(&mut self, block: BlockId, justification: Option) -> sp_blockchain::Result<()> { self.finalized_blocks.push((block, justification)); Ok(()) } - fn mark_head(&mut self, block: BlockId) -> error::Result<()> { + fn mark_head(&mut self, block: BlockId) -> sp_blockchain::Result<()> { assert!(self.pending_block.is_none(), "Only one set block per operation is allowed"); self.set_head = Some(block); Ok(()) @@ -594,11 +593,11 @@ where 'c: 'a, I: IntoIterator, D: IntoIterator, - >(&self, insert: I, delete: D) -> error::Result<()> { + >(&self, insert: I, delete: D) -> sp_blockchain::Result<()> { self.blockchain.insert_aux(insert, delete) } - fn get_aux(&self, key: &[u8]) -> error::Result>> { + fn get_aux(&self, key: &[u8]) -> sp_blockchain::Result>> { self.blockchain.get_aux(key) } } @@ -615,7 +614,7 @@ where type ChangesTrieStorage = ChangesTrieStorage; type OffchainStorage = OffchainStorage; - fn begin_operation(&self) -> error::Result { + fn begin_operation(&self) -> sp_blockchain::Result { let old_state = self.state_at(BlockId::Hash(Default::default()))?; Ok(BlockImportOperation { pending_block: None, @@ -629,12 +628,12 @@ where }) } - fn begin_state_operation(&self, operation: &mut Self::BlockImportOperation, block: BlockId) -> error::Result<()> { + fn begin_state_operation(&self, operation: &mut Self::BlockImportOperation, block: BlockId) -> sp_blockchain::Result<()> { operation.old_state = self.state_at(block)?; Ok(()) } - fn commit_operation(&self, operation: Self::BlockImportOperation) -> error::Result<()> { + fn commit_operation(&self, operation: Self::BlockImportOperation) -> sp_blockchain::Result<()> { if !operation.finalized_blocks.is_empty() { for (block, justification) in operation.finalized_blocks { self.blockchain.finalize_header(block, justification)?; @@ -674,7 +673,7 @@ where Ok(()) } - fn finalize_block(&self, block: BlockId, justification: Option) -> error::Result<()> { + fn finalize_block(&self, block: BlockId, justification: Option) -> sp_blockchain::Result<()> { self.blockchain.finalize_header(block, justification) } @@ -694,7 +693,7 @@ where None } - fn state_at(&self, block: BlockId) -> error::Result { + fn state_at(&self, block: BlockId) -> sp_blockchain::Result { match block { BlockId::Hash(h) if h == Default::default() => { return Ok(Self::State::default()); @@ -704,11 +703,11 @@ where match self.blockchain.id(block).and_then(|id| self.states.read().get(&id).cloned()) { Some(state) => Ok(state), - None => Err(error::Error::UnknownBlock(format!("{}", block))), + None => Err(sp_blockchain::Error::UnknownBlock(format!("{}", block))), } } - fn revert(&self, _n: NumberFor) -> error::Result> { + fn revert(&self, _n: NumberFor) -> sp_blockchain::Result> { Ok(Zero::zero()) } @@ -797,13 +796,13 @@ impl state_machine::ChangesTrieStorage> for Change } /// Check that genesis storage is valid. -pub fn check_genesis_storage(top: &StorageOverlay, children: &ChildrenStorageOverlay) -> error::Result<()> { +pub fn check_genesis_storage(top: &StorageOverlay, children: &ChildrenStorageOverlay) -> sp_blockchain::Result<()> { if top.iter().any(|(k, _)| well_known_keys::is_child_storage_key(k)) { - return Err(error::Error::GenesisInvalid.into()); + return Err(sp_blockchain::Error::GenesisInvalid.into()); } if children.keys().any(|child_key| !well_known_keys::is_child_storage_key(&child_key)) { - return Err(error::Error::GenesisInvalid.into()); + return Err(sp_blockchain::Error::GenesisInvalid.into()); } Ok(()) diff --git a/client/src/leaves.rs b/client/src/leaves.rs index bc42e83a66..83cfa59896 100644 --- a/client/src/leaves.rs +++ b/client/src/leaves.rs @@ -21,7 +21,7 @@ use std::cmp::Reverse; use kvdb::{KeyValueDB, DBTransaction}; use sr_primitives::traits::SimpleArithmetic; use codec::{Encode, Decode}; -use client_api::error; +use sp_blockchain::{Error, Result}; #[derive(Debug, Clone, PartialEq, Eq)] struct LeafSetItem { @@ -77,7 +77,7 @@ impl LeafSet where } /// Read the leaf list from the DB, using given prefix for keys. - pub fn read_from_db(db: &dyn KeyValueDB, column: Option, prefix: &[u8]) -> error::Result { + pub fn read_from_db(db: &dyn KeyValueDB, column: Option, prefix: &[u8]) -> Result { let mut storage = BTreeMap::new(); for (key, value) in db.iter_from_prefix(column, prefix) { @@ -85,11 +85,11 @@ impl LeafSet where let raw_hash = &mut &key[prefix.len()..]; let hash = match Decode::decode(raw_hash) { Ok(hash) => hash, - Err(_) => return Err(error::Error::Backend("Error decoding hash".into())), + Err(_) => return Err(Error::Backend("Error decoding hash".into())), }; let number = match Decode::decode(&mut &value[..]) { Ok(number) => number, - Err(_) => return Err(error::Error::Backend("Error decoding number".into())), + Err(_) => return Err(Error::Backend("Error decoding number".into())), }; storage.entry(Reverse(number)).or_insert_with(Vec::new).push(hash); } diff --git a/client/src/lib.rs b/client/src/lib.rs index 71127d3cb0..1bbfbe0270 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -84,7 +84,6 @@ mod call_executor; mod client; pub use client_api::{ - error, blockchain, blockchain::well_known_cache_keys, blockchain::Info as ChainInfo, diff --git a/client/src/light/backend.rs b/client/src/light/backend.rs index 8b0d965149..da21ebf9e8 100644 --- a/client/src/light/backend.rs +++ b/client/src/light/backend.rs @@ -26,6 +26,7 @@ use primitives::offchain::storage::InMemOffchainStorage; use sr_primitives::{generic::BlockId, Justification, StorageOverlay, ChildrenStorageOverlay}; use sr_primitives::traits::{Block as BlockT, NumberFor, Zero, Header}; use crate::in_mem::{self, check_genesis_storage}; +use sp_blockchain::{ Error as ClientError, Result as ClientResult }; use client_api::{ backend::{ AuxStore, Backend as ClientBackend, BlockImportOperation, RemoteBackend, NewBlockState, @@ -34,9 +35,6 @@ use client_api::{ blockchain::{ HeaderBackend as BlockchainHeaderBackend, well_known_cache_keys, }, - error::{ - Error as ClientError, Result as ClientResult - }, light::Storage as BlockchainStorage, }; use crate::light::blockchain::Blockchain; diff --git a/client/src/light/blockchain.rs b/client/src/light/blockchain.rs index b9003c6a29..11982e4529 100644 --- a/client/src/light/blockchain.rs +++ b/client/src/light/blockchain.rs @@ -23,7 +23,10 @@ use std::sync::Arc; use sr_primitives::{Justification, generic::BlockId}; use sr_primitives::traits::{Block as BlockT, Header as HeaderT, NumberFor, Zero}; -use header_metadata::{HeaderMetadata, CachedHeaderMetadata}; +use sp_blockchain::{ + HeaderMetadata, CachedHeaderMetadata, + Error as ClientError, Result as ClientResult, +}; pub use client_api::{ backend::{ AuxStore, NewBlockState @@ -33,9 +36,6 @@ pub use client_api::{ HeaderBackend as BlockchainHeaderBackend, Info as BlockchainInfo, ProvideCache, well_known_cache_keys, }, - error::{ - Error as ClientError, Result as ClientResult - }, light::{ RemoteBlockchain, LocalOrRemote, Storage } diff --git a/client/src/light/call_executor.rs b/client/src/light/call_executor.rs index 29b9ca46af..c998ac0e45 100644 --- a/client/src/light/call_executor.rs +++ b/client/src/light/call_executor.rs @@ -38,9 +38,10 @@ use hash_db::Hasher; use sr_api::{ProofRecorder, InitializeBlock}; +use sp_blockchain::{Error as ClientError, Result as ClientResult}; + use client_api::{ backend::RemoteBackend, - error::{Error as ClientError, Result as ClientResult}, light::RemoteCallRequest, call_executor::CallExecutor }; @@ -450,7 +451,7 @@ mod tests { ), ); match execution_result { - Err(client_api::error::Error::Execution(_)) => (), + Err(sp_blockchain::Error::Execution(_)) => (), _ => panic!("Unexpected execution result: {:?}", execution_result), } } diff --git a/client/src/light/fetcher.rs b/client/src/light/fetcher.rs index e8b88e93b9..d3f9436262 100644 --- a/client/src/light/fetcher.rs +++ b/client/src/light/fetcher.rs @@ -33,12 +33,10 @@ use state_machine::{ read_child_proof_check, }; pub use state_machine::StorageProof; +use sp_blockchain::{Error as ClientError, Result as ClientResult}; use crate::cht; pub use client_api::{ - error::{ - Error as ClientError, Result as ClientResult - }, light::{ RemoteCallRequest, RemoteHeaderRequest, RemoteReadRequest, RemoteReadChildRequest, RemoteChangesRequest, ChangesProof, RemoteBodyRequest, Fetcher, FetchChecker, @@ -329,10 +327,8 @@ pub mod tests { use codec::Decode; use crate::client::tests::prepare_client_with_key_changes; use executor::{NativeExecutor, WasmExecutionMethod}; - use client_api::{ - backend::NewBlockState, - error::Error as ClientError, - }; + use sp_blockchain::Error as ClientError; + use client_api::backend::NewBlockState; use test_client::{ self, ClientExt, blockchain::HeaderBackend, AccountKeyring, runtime::{self, Hash, Block, Header, Extrinsic} diff --git a/client/src/light/mod.rs b/client/src/light/mod.rs index 787e48e449..e9dec286f6 100644 --- a/client/src/light/mod.rs +++ b/client/src/light/mod.rs @@ -27,11 +27,11 @@ use executor::RuntimeInfo; use primitives::{H256, Blake2Hasher, traits::CodeExecutor}; use sr_primitives::BuildStorage; use sr_primitives::traits::Block as BlockT; +use sp_blockchain::Result as ClientResult; use crate::call_executor::LocalCallExecutor; use crate::client::Client; use client_api::{ - error::Result as ClientResult, light::Storage as BlockchainStorage, }; use crate::light::backend::Backend; diff --git a/client/transaction-pool/Cargo.toml b/client/transaction-pool/Cargo.toml index de19d9d19a..241c7beb23 100644 --- a/client/transaction-pool/Cargo.toml +++ b/client/transaction-pool/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "substrate-transaction-pool" +name = "sc-transaction-pool" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" @@ -14,7 +14,7 @@ primitives = { package = "substrate-primitives", path = "../../primitives/core" sr-api = { path = "../../primitives/sr-api" } sr-primitives = { path = "../../primitives/sr-primitives" } tx-runtime-api = { package = "substrate-transaction-pool-runtime-api", path = "../../primitives/transaction-pool/runtime-api" } -txpool = { package = "substrate-transaction-graph", path = "./graph" } +txpool = { package = "sc-transaction-graph", path = "./graph" } [dev-dependencies] keyring = { package = "substrate-keyring", path = "../../primitives/keyring" } diff --git a/client/transaction-pool/graph/Cargo.toml b/client/transaction-pool/graph/Cargo.toml index 63b1c54aac..685a2f6ff9 100644 --- a/client/transaction-pool/graph/Cargo.toml +++ b/client/transaction-pool/graph/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "substrate-transaction-graph" +name = "sc-transaction-graph" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" diff --git a/client/transaction-pool/graph/benches/basics.rs b/client/transaction-pool/graph/benches/basics.rs index dcd725ce46..1ddd27df96 100644 --- a/client/transaction-pool/graph/benches/basics.rs +++ b/client/transaction-pool/graph/benches/basics.rs @@ -17,7 +17,7 @@ use criterion::{criterion_group, criterion_main, Criterion}; use futures::executor::block_on; -use substrate_transaction_graph::*; +use sc_transaction_graph::*; use sr_primitives::transaction_validity::{ValidTransaction, InvalidTransaction}; use codec::Encode; use test_runtime::{Block, Extrinsic, Transfer, H256, AccountId}; diff --git a/frame/contracts/rpc/Cargo.toml b/frame/contracts/rpc/Cargo.toml index 06c8776ece..a06353831c 100644 --- a/frame/contracts/rpc/Cargo.toml +++ b/frame/contracts/rpc/Cargo.toml @@ -5,11 +5,11 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -client = { package = "substrate-client", path = "../../../client/" } codec = { package = "parity-scale-codec", version = "1.0.0" } jsonrpc-core = "14.0.3" jsonrpc-core-client = "14.0.3" jsonrpc-derive = "14.0.3" +sp-blockchain = { path = "../../../primitives/blockchain" } primitives = { package = "substrate-primitives", path = "../../../primitives/core" } rpc-primitives = { package = "substrate-rpc-primitives", path = "../../../primitives/rpc" } serde = { version = "1.0.101", features = ["derive"] } diff --git a/frame/contracts/rpc/src/lib.rs b/frame/contracts/rpc/src/lib.rs index 9cc1aef938..e330e9efcc 100644 --- a/frame/contracts/rpc/src/lib.rs +++ b/frame/contracts/rpc/src/lib.rs @@ -18,7 +18,7 @@ use std::sync::Arc; -use client::blockchain::HeaderBackend; +use sp_blockchain::HeaderBackend; use codec::Codec; use jsonrpc_core::{Error, ErrorCode, Result}; use jsonrpc_derive::rpc; diff --git a/frame/elections-phragmen/Cargo.toml b/frame/elections-phragmen/Cargo.toml index bf17df628d..fbbc49380e 100644 --- a/frame/elections-phragmen/Cargo.toml +++ b/frame/elections-phragmen/Cargo.toml @@ -17,6 +17,7 @@ runtime_io = { package = "sr-io", path = "../../primitives/sr-io" } hex-literal = "0.2.1" balances = { package = "pallet-balances", path = "../balances" } primitives = { package = "substrate-primitives", path = "../../primitives/core" } +substrate-test-utils = { path = "../../test/utils" } serde = { version = "1.0.101" } [features] diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index c9d515423e..4ae237e378 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -743,7 +743,8 @@ impl Module { mod tests { use super::*; use std::cell::RefCell; - use support::{assert_ok, assert_noop, parameter_types, assert_eq_uvec}; + use support::{assert_ok, assert_noop, parameter_types}; + use substrate_test_utils::assert_eq_uvec; use primitives::H256; use sr_primitives::{ Perbill, testing::Header, BuildStorage, diff --git a/frame/staking/Cargo.toml b/frame/staking/Cargo.toml index 3ad4b68c83..005b45da76 100644 --- a/frame/staking/Cargo.toml +++ b/frame/staking/Cargo.toml @@ -24,6 +24,7 @@ primitives = { package = "substrate-primitives", path = "../../primitives/core" balances = { package = "pallet-balances", path = "../balances" } timestamp = { package = "pallet-timestamp", path = "../timestamp" } pallet-staking-reward-curve = { path = "../staking/reward-curve"} +substrate-test-utils = { path = "../../test/utils" } [features] equalize = [] diff --git a/frame/staking/src/tests.rs b/frame/staking/src/tests.rs index aef5a26a04..7c16091d06 100644 --- a/frame/staking/src/tests.rs +++ b/frame/staking/src/tests.rs @@ -20,7 +20,8 @@ use super::*; use mock::*; use sr_primitives::{assert_eq_error_rate, traits::OnInitialize}; use sr_staking_primitives::offence::{OffenceDetails, OnOffenceHandler}; -use support::{assert_ok, assert_noop, assert_eq_uvec, traits::{Currency, ReservableCurrency}}; +use support::{assert_ok, assert_noop, traits::{Currency, ReservableCurrency}}; +use substrate_test_utils::assert_eq_uvec; #[test] fn force_unstake_works() { diff --git a/frame/support/src/lib.rs b/frame/support/src/lib.rs index 916ffbdfa3..ad599fac83 100644 --- a/frame/support/src/lib.rs +++ b/frame/support/src/lib.rs @@ -185,47 +185,6 @@ macro_rules! assert_ok { } } -/// Panic when the vectors are different, without taking the order into account. -/// -/// # Examples -/// -/// ```rust -/// #[macro_use] -/// # extern crate frame_support; -/// # use frame_support::{assert_eq_uvec}; -/// # fn main() { -/// assert_eq_uvec!(vec![1,2], vec![2,1]); -/// # } -/// ``` -/// -/// ```rust,should_panic -/// #[macro_use] -/// # extern crate frame_support; -/// # use frame_support::{assert_eq_uvec}; -/// # fn main() { -/// assert_eq_uvec!(vec![1,2,3], vec![2,1]); -/// # } -/// ``` -#[macro_export] -#[cfg(feature = "std")] -macro_rules! assert_eq_uvec { - ( $x:expr, $y:expr ) => { - $crate::__assert_eq_uvec!($x, $y); - $crate::__assert_eq_uvec!($y, $x); - } -} - -#[macro_export] -#[doc(hidden)] -#[cfg(feature = "std")] -macro_rules! __assert_eq_uvec { - ( $x:expr, $y:expr ) => { - $x.iter().for_each(|e| { - if !$y.contains(e) { panic!(format!("vectors not equal: {:?} != {:?}", $x, $y)); } - }); - } -} - /// The void type - it cannot exist. // Oh rust, you crack me up... #[derive(Clone, Eq, PartialEq, RuntimeDebug)] diff --git a/frame/system/rpc/Cargo.toml b/frame/system/rpc/Cargo.toml deleted file mode 100644 index c916287e91..0000000000 --- a/frame/system/rpc/Cargo.toml +++ /dev/null @@ -1,23 +0,0 @@ -[package] -name = "frame-system-rpc" -version = "2.0.0" -authors = ["Parity Technologies "] -edition = "2018" - -[dependencies] -client = { package = "substrate-client", path = "../../../client/" } -codec = { package = "parity-scale-codec", version = "1.0.0" } -jsonrpc-core = "14.0.3" -jsonrpc-core-client = "14.0.3" -jsonrpc-derive = "14.0.3" -log = "0.4.8" -serde = { version = "1.0.101", features = ["derive"] } -sr-primitives = { path = "../../../primitives/sr-primitives" } -frame-system-rpc-runtime-api = { path = "./runtime-api" } -substrate-primitives = { path = "../../../primitives/core" } -transaction_pool = { package = "substrate-transaction-pool", path = "../../../client/transaction-pool" } - -[dev-dependencies] -test-client = { package = "substrate-test-runtime-client", path = "../../../test/utils/runtime/client" } -env_logger = "0.7.0" -futures = "0.3.1" diff --git a/frame/transaction-payment/rpc/Cargo.toml b/frame/transaction-payment/rpc/Cargo.toml index 92bbda3220..5ae6eafc19 100644 --- a/frame/transaction-payment/rpc/Cargo.toml +++ b/frame/transaction-payment/rpc/Cargo.toml @@ -5,7 +5,6 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -client = { package = "substrate-client", path = "../../../client/" } codec = { package = "parity-scale-codec", version = "1.0.0" } jsonrpc-core = "14.0.3" jsonrpc-core-client = "14.0.3" @@ -14,4 +13,5 @@ primitives = { package = "substrate-primitives", path = "../../../primitives/co rpc-primitives = { package = "substrate-rpc-primitives", path = "../../../primitives/rpc" } serde = { version = "1.0.101", features = ["derive"] } sr-primitives = { path = "../../../primitives/sr-primitives" } +sp-blockchain = { path = "../../../primitives/blockchain" } pallet-transaction-payment-rpc-runtime-api = { path = "./runtime-api" } diff --git a/frame/transaction-payment/rpc/src/lib.rs b/frame/transaction-payment/rpc/src/lib.rs index 54ec16f032..527bfc424a 100644 --- a/frame/transaction-payment/rpc/src/lib.rs +++ b/frame/transaction-payment/rpc/src/lib.rs @@ -18,7 +18,7 @@ use std::sync::Arc; use codec::{Codec, Decode}; -use client::blockchain::HeaderBackend; +use sp_blockchain::HeaderBackend; use jsonrpc_core::{Error as RpcError, ErrorCode, Result}; use jsonrpc_derive::rpc; use sr_primitives::{ diff --git a/primitives/blockchain/Cargo.toml b/primitives/blockchain/Cargo.toml new file mode 100644 index 0000000000..812c1dd668 --- /dev/null +++ b/primitives/blockchain/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "sp-blockchain" +version = "2.0.0" +authors = ["Parity Technologies "] +edition = "2018" + +[dependencies] +log = "0.4.8" +lru = "0.4.0" +parking_lot = "0.9.0" +derive_more = "0.99.2" +parity-scale-codec = { version = "1.0.0", default-features = false, features = ["derive"] } +sp_consensus = { package = "substrate-consensus-common", path = "../consensus/common" } +sr-primitives = { path = "../sr-primitives" } +sp-block-builder-runtime-api = { package = "substrate-block-builder-runtime-api", path = "../block-builder/runtime-api" } +sp-state-machine = { package = "substrate-state-machine", path = "../state-machine" } + diff --git a/client/api/src/blockchain.rs b/primitives/blockchain/src/backend.rs similarity index 98% rename from client/api/src/blockchain.rs rename to primitives/blockchain/src/backend.rs index b28a1060b9..c28a75f620 100644 --- a/client/api/src/blockchain.rs +++ b/primitives/blockchain/src/backend.rs @@ -24,7 +24,7 @@ use sr_primitives::Justification; use log::warn; use parking_lot::RwLock; -use header_metadata::HeaderMetadata; +use crate::header_metadata::HeaderMetadata; use crate::error::{Error, Result}; @@ -262,7 +262,7 @@ pub enum BlockStatus { /// A list of all well known keys in the blockchain cache. pub mod well_known_cache_keys { /// The type representing cache keys. - pub type Id = consensus::import_queue::CacheKeyId; + pub type Id = sp_consensus::import_queue::CacheKeyId; /// A list of authorities. pub const AUTHORITIES: Id = *b"auth"; diff --git a/client/api/src/error.rs b/primitives/blockchain/src/error.rs similarity index 77% rename from client/api/src/error.rs rename to primitives/blockchain/src/error.rs index 871a1091c6..73b2422498 100644 --- a/client/api/src/error.rs +++ b/primitives/blockchain/src/error.rs @@ -17,20 +17,40 @@ //! Substrate client possible errors. use std::{self, error, result}; -use state_machine; +use sp_state_machine; use sr_primitives::transaction_validity::TransactionValidityError; -use consensus; +#[allow(deprecated)] +use sp_block_builder_runtime_api::compatability_v3; +use sp_consensus; use derive_more::{Display, From}; +use parity_scale_codec::Error as CodecError; /// Client Result type alias pub type Result = result::Result; + +/// Error when the runtime failed to apply an extrinsic. +#[derive(Debug, Display)] +pub enum ApplyExtrinsicFailed { + /// The transaction cannot be included into the current block. + /// + /// This doesn't necessary mean that the transaction itself is invalid, but it might be just + /// unappliable onto the current block. + #[display(fmt = "Extrinsic is not valid: {:?}", _0)] + Validity(TransactionValidityError), + /// This is used for miscelanious errors that can be represented by string and not handleable. + /// + /// This will become obsolete with complete migration to v4 APIs. + #[display(fmt = "Extrinsic failed: {:?}", _0)] + Msg(String), +} + /// Substrate Client error #[derive(Debug, Display, From)] pub enum Error { /// Consensus Error #[display(fmt = "Consensus: {}", _0)] - Consensus(consensus::Error), + Consensus(sp_consensus::Error), /// Backend error. #[display(fmt = "Backend error: {}", _0)] #[from(ignore)] @@ -40,11 +60,11 @@ pub enum Error { #[from(ignore)] UnknownBlock(String), /// The `apply_extrinsic` is not valid due to the given `TransactionValidityError`. - #[display(fmt = "Extrinsic is not valid: {:?}", _0)] - ApplyExtrinsicFailed(TransactionValidityError), + #[display(fmt = "{:?}", _0)] + ApplyExtrinsicFailed(ApplyExtrinsicFailed), /// Execution error. #[display(fmt = "Execution: {}", _0)] - Execution(Box), + Execution(Box), /// Blockchain error. #[display(fmt = "Blockchain: {}", _0)] Blockchain(Box), @@ -78,7 +98,7 @@ pub enum Error { RemoteFetchFailed, /// Error decoding call result. #[display(fmt = "Error decoding call result of {}: {}", _0, _1)] - CallResultDecode(&'static str, codec::Error), + CallResultDecode(&'static str, CodecError), /// Error converting a parameter between runtime and node. #[display(fmt = "Error converting `{}` between runtime and node", _0)] #[from(ignore)] @@ -131,14 +151,14 @@ impl<'a> From<&'a str> for Error { } } -impl From for Error { - fn from(err: block_builder::ApplyExtrinsicFailed) -> Self { - use block_builder::ApplyExtrinsicFailed; - match err { - ApplyExtrinsicFailed::Validity(tx_validity) => Self::ApplyExtrinsicFailed(tx_validity), - ApplyExtrinsicFailed::Msg(msg) => Self::Msg(msg), +#[allow(deprecated)] +impl From for ApplyExtrinsicFailed { + fn from(e: compatability_v3::ApplyError) -> Self { + use self::compatability_v3::ApplyError::*; + match e { + Validity(tx_validity) => Self::Validity(tx_validity), + e => Self::Msg(format!("Apply extrinsic failed: {:?}", e)), } - } } @@ -149,7 +169,7 @@ impl Error { } /// Chain a state error. - pub fn from_state(e: Box) -> Self { + pub fn from_state(e: Box) -> Self { Error::Execution(e) } } diff --git a/client/header-metadata/src/lib.rs b/primitives/blockchain/src/header_metadata.rs similarity index 100% rename from client/header-metadata/src/lib.rs rename to primitives/blockchain/src/header_metadata.rs diff --git a/primitives/blockchain/src/lib.rs b/primitives/blockchain/src/lib.rs new file mode 100644 index 0000000000..2a8a7c96fe --- /dev/null +++ b/primitives/blockchain/src/lib.rs @@ -0,0 +1,25 @@ +// Copyright 2019 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Substrate is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Substrate. If not, see . + +//! Substrate blockchain traits and primtives + +mod backend; +mod header_metadata; +mod error; + +pub use error::*; +pub use backend::*; +pub use header_metadata::*; diff --git a/primitives/phragmen/Cargo.toml b/primitives/phragmen/Cargo.toml index c1465628e5..18dc3c29fb 100644 --- a/primitives/phragmen/Cargo.toml +++ b/primitives/phragmen/Cargo.toml @@ -10,8 +10,8 @@ rstd = { package = "sr-std", path = "../sr-std", default-features = false } sr-primitives = { path = "../../primitives/sr-primitives", default-features = false } [dev-dependencies] +substrate-test-utils = { path = "../../test/utils" } runtime-io ={ package = "sr-io", path = "../../primitives/sr-io" } -support = { package = "frame-support", path = "../../frame/support" } rand = "0.7.2" [features] diff --git a/primitives/phragmen/src/lib.rs b/primitives/phragmen/src/lib.rs index 67ea6077ad..d027bcfa8d 100644 --- a/primitives/phragmen/src/lib.rs +++ b/primitives/phragmen/src/lib.rs @@ -38,7 +38,9 @@ use sr_primitives::RuntimeDebug; use sr_primitives::{helpers_128bit::multiply_by_rational, Perbill, Rational128}; use sr_primitives::traits::{Zero, Convert, Member, SimpleArithmetic, Saturating, Bounded}; +#[cfg(test)] mod mock; +#[cfg(test)] mod tests; /// A type in which performing operations on balances and stakes of candidates and voters are safe. diff --git a/primitives/phragmen/src/tests.rs b/primitives/phragmen/src/tests.rs index aaeac27c14..8aaa45dce0 100644 --- a/primitives/phragmen/src/tests.rs +++ b/primitives/phragmen/src/tests.rs @@ -20,7 +20,7 @@ use crate::mock::*; use crate::{elect, PhragmenResult}; -use support::assert_eq_uvec; +use substrate_test_utils::assert_eq_uvec; use sr_primitives::Perbill; #[test] diff --git a/primitives/sr-api/test/Cargo.toml b/primitives/sr-api/test/Cargo.toml index 7915266cca..5cdbdc861e 100644 --- a/primitives/sr-api/test/Cargo.toml +++ b/primitives/sr-api/test/Cargo.toml @@ -9,6 +9,7 @@ sr-api = { path = "../" } test-client = { package = "substrate-test-runtime-client", path = "../../../test/utils/runtime/client" } sr-version = { path = "../../sr-version" } sr-primitives = { path = "../../sr-primitives" } +sp-blockchain = { path = "../../blockchain" } consensus_common = { package = "substrate-consensus-common", path = "../../../primitives/consensus/common" } codec = { package = "parity-scale-codec", version = "1.0.0" } state-machine = { package = "substrate-state-machine", path = "../../../primitives/state-machine" } diff --git a/primitives/sr-api/test/tests/decl_and_impl.rs b/primitives/sr-api/test/tests/decl_and_impl.rs index 91863e1865..6bc5ea908c 100644 --- a/primitives/sr-api/test/tests/decl_and_impl.rs +++ b/primitives/sr-api/test/tests/decl_and_impl.rs @@ -18,7 +18,8 @@ use sr_api::{RuntimeApiInfo, decl_runtime_apis, impl_runtime_apis}; use sr_primitives::{traits::{GetNodeBlockType, Block as BlockT}, generic::BlockId}; -use test_client::{client::error::Result, runtime::Block}; +use test_client::runtime::Block; +use sp_blockchain::Result; /// The declaration of the `Runtime` type and the implementation of the `GetNodeBlockType` /// trait are done by the `construct_runtime!` macro in a real runtime. diff --git a/test/utils/Cargo.toml b/test/utils/Cargo.toml new file mode 100644 index 0000000000..ac4c995419 --- /dev/null +++ b/test/utils/Cargo.toml @@ -0,0 +1,5 @@ +[package] +name = "substrate-test-utils" +version = "2.0.0" +authors = ["Parity Technologies "] +edition = "2018" diff --git a/test/utils/client/Cargo.toml b/test/utils/client/Cargo.toml index d0ba0eca7c..e153604603 100644 --- a/test/utils/client/Cargo.toml +++ b/test/utils/client/Cargo.toml @@ -16,4 +16,5 @@ keyring = { package = "substrate-keyring", path = "../../../primitives/keyring" codec = { package = "parity-scale-codec", version = "1.0.0" } primitives = { package = "substrate-primitives", path = "../../../primitives/core" } sr-primitives = { path = "../../../primitives/sr-primitives" } +sp-blockchain = { path = "../../../primitives/blockchain" } state_machine = { package = "substrate-state-machine", path = "../../../primitives/state-machine" } diff --git a/test/utils/client/src/client_ext.rs b/test/utils/client/src/client_ext.rs index d7ae5097a3..78ed619a0d 100644 --- a/test/utils/client/src/client_ext.rs +++ b/test/utils/client/src/client_ext.rs @@ -56,7 +56,7 @@ pub trait ClientExt: Sized { &self, id: BlockId, justification: Option, - ) -> client::error::Result<()>; + ) -> sp_blockchain::Result<()>; /// Returns hash of the genesis block. fn genesis_hash(&self) -> ::Hash; @@ -152,7 +152,7 @@ impl ClientExt for Client &self, id: BlockId, justification: Option, - ) -> client::error::Result<()> { + ) -> sp_blockchain::Result<()> { Finalizer::finalize_block(self, id, justification, true) } diff --git a/test/utils/primitives/Cargo.toml b/test/utils/primitives/Cargo.toml index d82226d347..92917fdd26 100644 --- a/test/utils/primitives/Cargo.toml +++ b/test/utils/primitives/Cargo.toml @@ -7,31 +7,9 @@ edition = "2018" [dependencies] app-crypto = { package = "substrate-application-crypto", path = "../../../primitives/application-crypto", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -# aura-primitives = { package = "substrate-consensus-aura-primitives", path = "../../../primitives/consensus/aura", default-features = false } -# babe-primitives = { package = "substrate-consensus-babe-primitives", path = "../../../primitives/consensus/babe", default-features = false } -# block-builder-api = { package = "substrate-block-builder-runtime-api", path = "../../../primitives/block-builder/runtime-api", default-features = false } -# inherents = { package = "substrate-inherents", path = "../../../primitives/inherents", default-features = false } -# log = { version = "0.4.8", optional = true } -# memory-db = { version = "0.15.2", default-features = false } -# offchain-primitives = { package = "substrate-offchain-primitives", path = "../../../primitives/offchain", default-features = false} primitives = { package = "substrate-primitives", path = "../../../primitives/core", default-features = false } -# rstd = { package = "sr-std", path = "../../../primitives/sr-std", default-features = false } -# runtime-interface = { package = "substrate-runtime-interface", path = "../../../primitives/runtime-interface", default-features = false} -# runtime_io = { package = "sr-io", path = "../../../primitives/sr-io", default-features = false } -# runtime_support = { package = "frame-support", path = "../../../frame/support", default-features = false } -# runtime_version = { package = "sr-version", path = "../../../primitives/sr-version", default-features = false } serde = { version = "1.0.101", optional = true, features = ["derive"] } -# session = { package = "substrate-session", path = "../../../primitives/session", default-features = false } -# sr-api = { path = "../../../primitives/sr-api", default-features = false } sr-primitives = { path = "../../../primitives/sr-primitives", default-features = false } -# pallet-babe = { path = "../../../frame/babe", default-features = false } -# frame-system = { path = "../../../frame/system", default-features = false } -# frame-system-rpc-runtime-api = { path = "../../../frame/system/rpc/runtime-api", default-features = false } -# pallet-timestamp = { path = "../../../frame/timestamp", default-features = false } -# substrate-client = { path = "../../../client", optional = true } -# substrate-trie = { path = "../../../primitives/trie", default-features = false } -# transaction-pool-api = { package = "substrate-transaction-pool-runtime-api", path = "../../../primitives/transaction-pool/runtime-api", default-features = false } -# trie-db = { version = "0.15.2", default-features = false } [features] default = [ @@ -39,33 +17,5 @@ default = [ ] std = [ "app-crypto/std", - # "aura-primitives/std", - # "babe-primitives/std", - # "block-builder-api/std", - # "codec/std", - # "executive/std", - # "inherents/std", - # "keyring", - # "log", - # "memory-db/std", - # "offchain-primitives/std", - # "primitives/std", - # "primitives/std", - # "rstd/std", - # "runtime-interface/std", - # "runtime_io/std", - # "runtime_support/std", - # "runtime_version/std", "serde", - # "session/std", - # "sr-api/std", - # "sr-primitives/std", - # "pallet-babe/std", - # "frame-system-rpc-runtime-api/std", - # "frame-system/std", - # "pallet-timestamp/std", - # "substrate-client", - # "substrate-trie/std", - # "transaction-pool-api/std", - # "trie-db/std", ] diff --git a/test/utils/runtime/client/Cargo.toml b/test/utils/runtime/client/Cargo.toml index 68f5820062..83e5edb246 100644 --- a/test/utils/runtime/client/Cargo.toml +++ b/test/utils/runtime/client/Cargo.toml @@ -10,6 +10,7 @@ generic-test-client = { package = "substrate-test-client", path = "../../client" primitives = { package = "substrate-primitives", path = "../../../../primitives/core" } runtime = { package = "substrate-test-runtime", path = "../../runtime" } sr-primitives = { path = "../../../../primitives/sr-primitives" } +sp-blockchain = { path = "../../../../primitives/blockchain" } codec = { package = "parity-scale-codec", version = "1.0.0" } client-api = { package = "substrate-client-api", path = "../../../../client/api" } client = { package = "substrate-client", path = "../../../../client/" } diff --git a/test/utils/runtime/client/src/block_builder_ext.rs b/test/utils/runtime/client/src/block_builder_ext.rs index 6bd3ed18eb..e6e8ac3249 100644 --- a/test/utils/runtime/client/src/block_builder_ext.rs +++ b/test/utils/runtime/client/src/block_builder_ext.rs @@ -18,27 +18,26 @@ use runtime; use sr_primitives::traits::ProvideRuntimeApi; -use generic_test_client::client; use block_builder::BlockBuilderApi; /// Extension trait for test block builder. pub trait BlockBuilderExt { /// Add transfer extrinsic to the block. - fn push_transfer(&mut self, transfer: runtime::Transfer) -> Result<(), client::error::Error>; + fn push_transfer(&mut self, transfer: runtime::Transfer) -> Result<(), sp_blockchain::Error>; /// Add storage change extrinsic to the block. fn push_storage_change( &mut self, key: Vec, value: Option>, - ) -> Result<(), client::error::Error>; + ) -> Result<(), sp_blockchain::Error>; } impl<'a, A> BlockBuilderExt for block_builder::BlockBuilder<'a, runtime::Block, A> where A: ProvideRuntimeApi + 'a, - A::Api: BlockBuilderApi, + A::Api: BlockBuilderApi, { - fn push_transfer(&mut self, transfer: runtime::Transfer) -> Result<(), client::error::Error> { + fn push_transfer(&mut self, transfer: runtime::Transfer) -> Result<(), sp_blockchain::Error> { self.push(transfer.into_signed_tx()) } @@ -46,7 +45,7 @@ impl<'a, A> BlockBuilderExt for block_builder::BlockBuilder<'a, runtime::Block, &mut self, key: Vec, value: Option>, - ) -> Result<(), client::error::Error> { + ) -> Result<(), sp_blockchain::Error> { self.push(runtime::Extrinsic::StorageChange(key, value)) } } diff --git a/test/utils/src/lib.rs b/test/utils/src/lib.rs new file mode 100644 index 0000000000..f79a5da5c6 --- /dev/null +++ b/test/utils/src/lib.rs @@ -0,0 +1,54 @@ +// Copyright 2017-2019 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Substrate is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Substrate. If not, see . + +//! Test utils + +/// Panic when the vectors are different, without taking the order into account. +/// +/// # Examples +/// +/// ```rust +/// #[macro_use] +/// # use substrate_test_utils::{assert_eq_uvec}; +/// # fn main() { +/// assert_eq_uvec!(vec![1,2], vec![2,1]); +/// # } +/// ``` +/// +/// ```rust,should_panic +/// #[macro_use] +/// # use substrate_test_utils::{assert_eq_uvec}; +/// # fn main() { +/// assert_eq_uvec!(vec![1,2,3], vec![2,1]); +/// # } +/// ``` +#[macro_export] +macro_rules! assert_eq_uvec { + ( $x:expr, $y:expr ) => { + $crate::__assert_eq_uvec!($x, $y); + $crate::__assert_eq_uvec!($y, $x); + } +} + +#[macro_export] +#[doc(hidden)] +macro_rules! __assert_eq_uvec { + ( $x:expr, $y:expr ) => { + $x.iter().for_each(|e| { + if !$y.contains(e) { panic!(format!("vectors not equal: {:?} != {:?}", $x, $y)); } + }); + } +} diff --git a/test/utils/transaction-factory/Cargo.toml b/test/utils/transaction-factory/Cargo.toml index fdd948a6f2..5c15a887c6 100644 --- a/test/utils/transaction-factory/Cargo.toml +++ b/test/utils/transaction-factory/Cargo.toml @@ -16,4 +16,5 @@ primitives = { package = "substrate-primitives", path = "../../../primitives/cor sr-api = { path = "../../../primitives/sr-api" } sr-primitives = { path = "../../../primitives/sr-primitives" } substrate-service = { path = "../../../client/service" } +sp-blockchain = { path = "../../../primitives/blockchain" } diff --git a/test/utils/transaction-factory/src/complex_mode.rs b/test/utils/transaction-factory/src/complex_mode.rs index 086698ffc3..bbc01c19ba 100644 --- a/test/utils/transaction-factory/src/complex_mode.rs +++ b/test/utils/transaction-factory/src/complex_mode.rs @@ -64,7 +64,7 @@ where Backend: client_api::backend::Backend + Send, Client: ProvideRuntimeApi, as ProvideRuntimeApi>::Api: - BlockBuilder, + BlockBuilder, RtApi: ConstructRuntimeApi> + Send + Sync, RA: RuntimeAdapter, { diff --git a/test/utils/transaction-factory/src/lib.rs b/test/utils/transaction-factory/src/lib.rs index 357e8067f3..f6f895fd22 100644 --- a/test/utils/transaction-factory/src/lib.rs +++ b/test/utils/transaction-factory/src/lib.rs @@ -105,7 +105,7 @@ where Backend: client_api::backend::Backend + Send, Client: ProvideRuntimeApi, as ProvideRuntimeApi>::Api: - BlockBuilder, + BlockBuilder, RtApi: ConstructRuntimeApi> + Send + Sync, Sc: SelectChain, RA: RuntimeAdapter, @@ -165,7 +165,7 @@ where Client: ProvideRuntimeApi, RtApi: ConstructRuntimeApi> + Send + Sync, as ProvideRuntimeApi>::Api: - BlockBuilder, + BlockBuilder, RA: RuntimeAdapter, { let mut block = client.new_block(Default::default()).expect("Failed to create new block"); diff --git a/test/utils/transaction-factory/src/simple_modes.rs b/test/utils/transaction-factory/src/simple_modes.rs index f869201b46..973de45c7e 100644 --- a/test/utils/transaction-factory/src/simple_modes.rs +++ b/test/utils/transaction-factory/src/simple_modes.rs @@ -59,7 +59,7 @@ where Backend: client_api::backend::Backend + Send, Client: ProvideRuntimeApi, as ProvideRuntimeApi>::Api: - BlockBuilder, + BlockBuilder, RtApi: ConstructRuntimeApi> + Send + Sync, RA: RuntimeAdapter, { diff --git a/frame/support/rpc/Cargo.toml b/utils/frame/rpc/support/Cargo.toml similarity index 54% rename from frame/support/rpc/Cargo.toml rename to utils/frame/rpc/support/Cargo.toml index 15e9fee7f0..937acb8295 100644 --- a/frame/support/rpc/Cargo.toml +++ b/utils/frame/rpc/support/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "frame-support-rpc" +name = "substrate-frame-rpc-support" version = "2.0.0" authors = ["Parity Technologies ", "Andrew Dirksen "] edition = "2018" @@ -10,10 +10,10 @@ jsonrpc-client-transports = "14" jsonrpc-core = "14" parity-scale-codec = "1" serde = "1" -frame-support = { path = "../" } -substrate-primitives-storage = { path = "../../../primitives/core/storage" } -substrate-rpc-api = { path = "../../../client/rpc/api" } +frame-support = { path = "../../../../frame/support" } +substrate-primitives-storage = { path = "../../../../primitives/core/storage" } +sc-rpc-api = { path = "../../../../client/rpc/api" } [dev-dependencies] -frame-system = { path = "../../system" } +frame-system = { path = "../../../../frame/system" } tokio = "0.1" diff --git a/frame/support/rpc/src/lib.rs b/utils/frame/rpc/support/src/lib.rs similarity index 95% rename from frame/support/rpc/src/lib.rs rename to utils/frame/rpc/support/src/lib.rs index e248e0c9fe..ef594b687e 100644 --- a/frame/support/rpc/src/lib.rs +++ b/utils/frame/rpc/support/src/lib.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Substrate. If not, see . -//! Combines [substrate_rpc_api::state::StateClient] with [frame_support::storage::generator] traits +//! Combines [sc_rpc_api::state::StateClient] with [frame_support::storage::generator] traits //! to provide strongly typed chain state queries over rpc. #![warn(missing_docs)] @@ -28,7 +28,7 @@ use frame_support::storage::generator::{ StorageDoubleMap, StorageLinkedMap, StorageMap, StorageValue }; use substrate_primitives_storage::{StorageData, StorageKey}; -use substrate_rpc_api::state::StateClient; +use sc_rpc_api::state::StateClient; /// A typed query on chain state usable from an RPC client. /// @@ -40,9 +40,9 @@ use substrate_rpc_api::state::StateClient; /// # use jsonrpc_client_transports::transports::http; /// # use parity_scale_codec::Encode; /// # use frame_support::{decl_storage, decl_module}; -/// # use frame_support_rpc::StorageQuery; +/// # use substrate_frame_rpc_support::StorageQuery; /// # use frame_system::Trait; -/// # use substrate_rpc_api::state::StateClient; +/// # use sc_rpc_api::state::StateClient; /// # /// # // Hash would normally be ::Hash, but we don't have /// # // frame_system::Trait implemented for TestRuntime. Here we just pretend. diff --git a/utils/frame/rpc/system/Cargo.toml b/utils/frame/rpc/system/Cargo.toml new file mode 100644 index 0000000000..a4b6d21693 --- /dev/null +++ b/utils/frame/rpc/system/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "substrate-frame-rpc-system" +version = "2.0.0" +authors = ["Parity Technologies "] +edition = "2018" + +[dependencies] +codec = { package = "parity-scale-codec", version = "1.0.0" } +jsonrpc-core = "14.0.3" +jsonrpc-core-client = "14.0.3" +jsonrpc-derive = "14.0.3" +log = "0.4.8" +serde = { version = "1.0.101", features = ["derive"] } +sr-primitives = { path = "../../../../primitives/sr-primitives" } +frame-system-rpc-runtime-api = { path = "../../../../frame/system/rpc/runtime-api" } +substrate-primitives = { path = "../../../../primitives/core" } +sp-blockchain = { path = "../../../../primitives/blockchain" } +sc-transaction-graph = { path = "../../../../client/transaction-pool/graph" } + +[dev-dependencies] +test-client = { package = "substrate-test-runtime-client", path = "../../../../test/utils/runtime/client" } +sc-transaction-pool = { path = "../../../../client/transaction-pool" } +env_logger = "0.7.0" +futures = "0.3.1" diff --git a/frame/system/rpc/src/lib.rs b/utils/frame/rpc/system/src/lib.rs similarity index 93% rename from frame/system/rpc/src/lib.rs rename to utils/frame/rpc/system/src/lib.rs index 10c416c798..63b91c3cd2 100644 --- a/frame/system/rpc/src/lib.rs +++ b/utils/frame/rpc/system/src/lib.rs @@ -19,7 +19,7 @@ use std::sync::Arc; use codec::{self, Codec, Encode}; -use client::blockchain::HeaderBackend; +use sp_blockchain::HeaderBackend; use jsonrpc_core::{Result, Error, ErrorCode}; use jsonrpc_derive::rpc; use sr_primitives::{ @@ -27,7 +27,7 @@ use sr_primitives::{ traits, }; use substrate_primitives::hexdisplay::HexDisplay; -use transaction_pool::txpool::{self, Pool}; +use sc_transaction_graph::{self, ChainApi, Pool}; pub use frame_system_rpc_runtime_api::AccountNonceApi; pub use self::gen_client::Client as SystemClient; @@ -47,13 +47,13 @@ pub trait SystemApi { const RUNTIME_ERROR: i64 = 1; /// An implementation of System-specific RPC methods. -pub struct System { +pub struct System { client: Arc, pool: Arc>, _marker: std::marker::PhantomData, } -impl System { +impl System { /// Create new `System` given client and transaction pool. pub fn new(client: Arc, pool: Arc>) -> Self { System { @@ -70,7 +70,7 @@ where C: HeaderBackend, C: Send + Sync + 'static, C::Api: AccountNonceApi, - P: txpool::ChainApi + Sync + Send + 'static, + P: ChainApi + Sync + Send + 'static, Block: traits::Block, AccountId: Clone + std::fmt::Display + Codec, Index: Clone + std::fmt::Display + Codec + traits::SimpleArithmetic, @@ -118,6 +118,7 @@ where #[cfg(test)] mod tests { use super::*; + use sc_transaction_pool; use futures::executor::block_on; use test_client::{ @@ -130,7 +131,7 @@ mod tests { // given let _ = env_logger::try_init(); let client = Arc::new(test_client::new()); - let pool = Arc::new(Pool::new(Default::default(), transaction_pool::FullChainApi::new(client.clone()))); + let pool = Arc::new(Pool::new(Default::default(), sc_transaction_pool::FullChainApi::new(client.clone()))); let new_transaction = |nonce: u64| { let t = Transfer { -- GitLab From 47b158b7a04bf0f5cd542a468076a7fda29648a4 Mon Sep 17 00:00:00 2001 From: Weiliang Li Date: Wed, 27 Nov 2019 22:13:00 +0900 Subject: [PATCH 025/172] fix ligature glitch in frame/staking/src/lib.rs (#4217) --- frame/staking/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/staking/src/lib.rs b/frame/staking/src/lib.rs index 29aeb7901c..ae9e53c851 100644 --- a/frame/staking/src/lib.rs +++ b/frame/staking/src/lib.rs @@ -445,7 +445,7 @@ type PositiveImbalanceOf = <::Currency as Currency<::AccountId>>::PositiveImbalance; type NegativeImbalanceOf = <::Currency as Currency<::AccountId>>::NegativeImbalance; -type MomentOf= <::Time as Time>::Moment; +type MomentOf = <::Time as Time>::Moment; /// Means for interacting with a specialized version of the `session` trait. /// -- GitLab From ed61aa6430825c40ee4917aaa0b4fd2fd0df649d Mon Sep 17 00:00:00 2001 From: Wei Tang Date: Wed, 27 Nov 2019 17:44:34 +0100 Subject: [PATCH 026/172] Make block proposing remaining duration configurable (#4215) * Make proposing remaining duration configurable * Pass chain_head to proposing_remaining_duration and change default --- client/consensus/slots/src/lib.rs | 77 ++++++++++++++++++----------- client/consensus/slots/src/slots.rs | 16 ++---- 2 files changed, 51 insertions(+), 42 deletions(-) diff --git a/client/consensus/slots/src/lib.rs b/client/consensus/slots/src/lib.rs index a26f8ec6b9..1e770b5dd8 100644 --- a/client/consensus/slots/src/lib.rs +++ b/client/consensus/slots/src/lib.rs @@ -38,7 +38,7 @@ use inherents::{InherentData, InherentDataProviders}; use log::{debug, error, info, warn}; use sr_primitives::generic::BlockId; use sr_primitives::traits::{ApiRef, Block as BlockT, Header, ProvideRuntimeApi}; -use std::{fmt::Debug, ops::Deref, pin::Pin, sync::Arc}; +use std::{fmt::Debug, ops::Deref, pin::Pin, sync::Arc, time::{Instant, Duration}}; use substrate_telemetry::{telemetry, CONSENSUS_DEBUG, CONSENSUS_WARN, CONSENSUS_INFO}; use parking_lot::Mutex; use client_api; @@ -113,6 +113,25 @@ pub trait SimpleSlotWorker { /// Returns a `Proposer` to author on top of the given block. fn proposer(&mut self, block: &B::Header) -> Result; + /// Remaining duration of the slot. + fn slot_remaining_duration(&self, slot_info: &SlotInfo) -> Duration { + let now = Instant::now(); + if now < slot_info.ends_at { + slot_info.ends_at.duration_since(now) + } else { + Duration::from_millis(0) + } + } + + /// Remaining duration for proposing. None means unlimited. + fn proposing_remaining_duration( + &self, + _head: &B::Header, + slot_info: &SlotInfo + ) -> Option { + Some(self.slot_remaining_duration(slot_info)) + } + /// Implements the `on_slot` functionality from `SlotWorker`. fn on_slot(&mut self, chain_head: B::Header, slot_info: SlotInfo) -> Pin> + Send>> where @@ -192,45 +211,43 @@ pub trait SimpleSlotWorker { }, }; - let remaining_duration = slot_info.remaining_duration(); + let slot_remaining_duration = self.slot_remaining_duration(&slot_info); + let proposing_remaining_duration = self.proposing_remaining_duration(&chain_head, &slot_info); let logs = self.pre_digest_data(slot_number, &claim); // deadline our production to approx. the end of the slot - let proposal_work = futures::future::select( - proposer.propose( - slot_info.inherent_data, - sr_primitives::generic::Digest { - logs, + let proposing = proposer.propose( + slot_info.inherent_data, + sr_primitives::generic::Digest { + logs, + }, + slot_remaining_duration, + ).map_err(|e| consensus_common::Error::ClientImport(format!("{:?}", e))); + let delay: Box + Unpin + Send> = match proposing_remaining_duration { + Some(r) => Box::new(Delay::new(r)), + None => Box::new(future::pending()), + }; + + let proposal_work = + Box::new(futures::future::select(proposing, delay).map(move |v| match v { + futures::future::Either::Left((b, _)) => b.map(|b| (b, claim)), + futures::future::Either::Right(_) => { + info!("Discarding proposal for slot {}; block production took too long", slot_number); + // If the node was compiled with debug, tell the user to use release optimizations. + #[cfg(build_type="debug")] + info!("Recompile your node in `--release` mode to mitigate this problem."); + telemetry!(CONSENSUS_INFO; "slots.discarding_proposal_took_too_long"; + "slot" => slot_number, + ); + Err(consensus_common::Error::ClientImport("Timeout in the Slots proposer".into())) }, - remaining_duration, - ).map_err(|e| consensus_common::Error::ClientImport(format!("{:?}", e))), - Delay::new(remaining_duration) - ).map(|v| match v { - futures::future::Either::Left((b, _)) => b.map(|b| (b, claim)), - futures::future::Either::Right(_) => - Err(consensus_common::Error::ClientImport("Timeout in the Slots proposer".into())), - }); + })); let block_import_params_maker = self.block_import_params(); let block_import = self.block_import(); let logging_target = self.logging_target(); Box::pin(proposal_work.map_ok(move |(block, claim)| { - // minor hack since we don't have access to the timestamp - // that is actually set by the proposer. - let slot_after_building = SignedDuration::default().slot_now(slot_duration); - if slot_after_building != slot_number { - info!("Discarding proposal for slot {}; block production took too long", slot_number); - // If the node was compiled with debug, tell the user to use release optimizations. - #[cfg(build_type="debug")] - info!("Recompile your node in `--release` mode to mitigate this problem."); - telemetry!(CONSENSUS_INFO; "slots.discarding_proposal_took_too_long"; - "slot" => slot_number, - ); - - return; - } - let (header, body) = block.deconstruct(); let header_num = *header.number(); let header_hash = header.hash(); diff --git a/client/consensus/slots/src/slots.rs b/client/consensus/slots/src/slots.rs index 0166d09bb7..640b24ec1c 100644 --- a/client/consensus/slots/src/slots.rs +++ b/client/consensus/slots/src/slots.rs @@ -71,6 +71,8 @@ pub fn time_until_next(now: Duration, slot_duration: u64) -> Duration { pub struct SlotInfo { /// The slot number. pub number: u64, + /// The last slot number produced. + pub last_number: u64, /// Current timestamp. pub timestamp: u64, /// The instant at which the slot ends. @@ -81,18 +83,6 @@ pub struct SlotInfo { pub duration: u64, } -impl SlotInfo { - /// Yields the remaining duration in the slot. - pub fn remaining_duration(&self) -> Duration { - let now = Instant::now(); - if now < self.ends_at { - self.ends_at.duration_since(now) - } else { - Duration::from_millis(0) - } - } -} - /// A stream that returns every time there is a new slot. pub(crate) struct Slots { last_slot: u64, @@ -160,11 +150,13 @@ impl Stream for Slots { // never yield the same slot twice. if slot_num > self.last_slot { + let last_slot = self.last_slot; self.last_slot = slot_num; break Poll::Ready(Some(Ok(SlotInfo { number: slot_num, duration: self.slot_duration, + last_number: last_slot, timestamp, ends_at, inherent_data, -- GitLab From cc14055ad2a32d9efb0c4bb187da563bb5d2958f Mon Sep 17 00:00:00 2001 From: Weiliang Li Date: Thu, 28 Nov 2019 02:32:35 +0900 Subject: [PATCH 027/172] Add sha2-256 hash function (#4218) * Add sha2-256 hash function Widely used hash function, supported by bitcoin and ethereum * Add runtime io support * add test * add test * Update hashing.rs * Update hashing.rs --- client/executor/runtime-test/src/lib.rs | 6 +++- client/executor/src/integration_tests/mod.rs | 36 ++++++++++++++++++++ primitives/core/src/hashing.rs | 12 ++++++- primitives/sr-io/src/lib.rs | 5 +++ 4 files changed, 57 insertions(+), 2 deletions(-) diff --git a/client/executor/runtime-test/src/lib.rs b/client/executor/runtime-test/src/lib.rs index 16c6c353d9..63f89fca57 100644 --- a/client/executor/runtime-test/src/lib.rs +++ b/client/executor/runtime-test/src/lib.rs @@ -10,7 +10,7 @@ use rstd::{vec::Vec, vec}; #[cfg(not(feature = "std"))] use runtime_io::{ - storage, hashing::{blake2_128, blake2_256, twox_128, twox_256}, + storage, hashing::{blake2_128, blake2_256, sha2_256, twox_128, twox_256}, crypto::{ed25519_verify, sr25519_verify}, }; #[cfg(not(feature = "std"))] @@ -60,6 +60,10 @@ primitives::wasm_export_functions! { blake2_128(&input).to_vec() } + fn test_sha2_256(input: Vec) -> Vec { + sha2_256(&input).to_vec() + } + fn test_twox_256(input: Vec) -> Vec { twox_256(&input).to_vec() } diff --git a/client/executor/src/integration_tests/mod.rs b/client/executor/src/integration_tests/mod.rs index 32424c6065..fce39bb400 100644 --- a/client/executor/src/integration_tests/mod.rs +++ b/client/executor/src/integration_tests/mod.rs @@ -230,6 +230,42 @@ fn blake2_128_should_work(wasm_method: WasmExecutionMethod) { ); } +#[test_case(WasmExecutionMethod::Interpreted)] +#[cfg_attr(feature = "wasmtime", test_case(WasmExecutionMethod::Compiled))] +fn sha2_256_should_work(wasm_method: WasmExecutionMethod) { + let mut ext = TestExternalities::default(); + let mut ext = ext.ext(); + let test_code = WASM_BINARY; + assert_eq!( + call_in_wasm( + "test_sha2_256", + &[0], + wasm_method, + &mut ext, + &test_code[..], + 8, + ) + .unwrap(), + hex!("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855") + .to_vec() + .encode(), + ); + assert_eq!( + call_in_wasm( + "test_sha2_256", + &b"Hello world!".to_vec().encode(), + wasm_method, + &mut ext, + &test_code[..], + 8, + ) + .unwrap(), + hex!("c0535e4be2b79ffd93291305436bf889314e4a3faec05ecffcbb7df31ad9e51a") + .to_vec() + .encode(), + ); +} + #[test_case(WasmExecutionMethod::Interpreted)] #[cfg_attr(feature = "wasmtime", test_case(WasmExecutionMethod::Compiled))] fn twox_256_should_work(wasm_method: WasmExecutionMethod) { diff --git a/primitives/core/src/hashing.rs b/primitives/core/src/hashing.rs index c3f7ddf9f5..8fce710230 100644 --- a/primitives/core/src/hashing.rs +++ b/primitives/core/src/hashing.rs @@ -17,6 +17,7 @@ //! Hashing functions. use blake2_rfc; +use sha2::{Digest, Sha256}; use tiny_keccak::{Hasher, Keccak}; use twox_hash; @@ -123,7 +124,7 @@ pub fn twox_256(data: &[u8]) -> [u8; 32] { r } -/// Do a keccak 256 hash and return result. +/// Do a keccak 256-bit hash and return result. pub fn keccak_256(data: &[u8]) -> [u8; 32] { let mut keccak = Keccak::v256(); keccak.update(data); @@ -131,3 +132,12 @@ pub fn keccak_256(data: &[u8]) -> [u8; 32] { keccak.finalize(&mut output); output } + +/// Do a sha2 256-bit hash and return result. +pub fn sha2_256(data: &[u8]) -> [u8; 32] { + let mut hasher = Sha256::new(); + hasher.input(data); + let mut output = [0u8; 32]; + output.copy_from_slice(&hasher.result()); + output +} diff --git a/primitives/sr-io/src/lib.rs b/primitives/sr-io/src/lib.rs index 4ceabb4511..589b6a1dd1 100644 --- a/primitives/sr-io/src/lib.rs +++ b/primitives/sr-io/src/lib.rs @@ -384,6 +384,11 @@ pub trait Hashing { primitives::hashing::keccak_256(data) } + /// Conduct a 256-bit Sha2 hash. + fn sha2_256(data: &[u8]) -> [u8; 32] { + primitives::hashing::sha2_256(data) + } + /// Conduct a 128-bit Blake2 hash. fn blake2_128(data: &[u8]) -> [u8; 16] { primitives::hashing::blake2_128(data) -- GitLab From a512dcdd3931aa571c92c8550a0e079d5b27239a Mon Sep 17 00:00:00 2001 From: thiolliere Date: Wed, 27 Nov 2019 19:23:20 +0100 Subject: [PATCH 028/172] Implement all storage after prefix (#4227) * Implement all storage after prefix * fix test, bump version and fix doc * bump metadata version * Update frame/support/procedural/src/storage/storage_struct.rs --- bin/node/runtime/src/lib.rs | 2 +- frame/executive/src/lib.rs | 2 +- frame/metadata/src/lib.rs | 12 +- frame/support/procedural/src/lib.rs | 46 +++++- .../procedural/src/storage/instance_trait.rs | 73 +-------- .../procedural/src/storage/storage_struct.rs | 73 +++++---- .../src/storage/generator/double_map.rs | 31 +++- .../src/storage/generator/linked_map.rs | 154 +++++++++--------- frame/support/src/storage/generator/map.rs | 35 ++-- frame/support/src/storage/generator/mod.rs | 10 +- frame/support/src/storage/generator/value.rs | 20 ++- frame/support/src/storage/mod.rs | 2 +- frame/support/test/tests/final_keys.rs | 146 ++++++++--------- frame/support/test/tests/instance.rs | 11 -- utils/frame/rpc/support/src/lib.rs | 4 +- 15 files changed, 303 insertions(+), 318 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 8e40573916..fbb690a622 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -78,7 +78,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // and set impl_version to equal spec_version. If only runtime // implementation changes and behavior does not, then leave spec_version as // is and increment impl_version. - spec_version: 195, + spec_version: 196, impl_version: 196, apis: RUNTIME_API_VERSIONS, }; diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index f6b50143a7..d160bd7bdd 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -525,7 +525,7 @@ mod tests { header: Header { parent_hash: [69u8; 32].into(), number: 1, - state_root: hex!("f0d1d66255c2e5b40580eb8b93ddbe732491478487f85e358e1d167d369e398e").into(), + state_root: hex!("c6b01b27df520ba23adb96e7fc032acb7c586ba1b477c6282de43184111f2091").into(), extrinsics_root: hex!("03170a2e7597b7b7e3d84c05391d139a62b157e78786d8c082f29dcf4c111314").into(), digest: Digest { logs: vec![], }, }, diff --git a/frame/metadata/src/lib.rs b/frame/metadata/src/lib.rs index d85a6837fc..113273be02 100644 --- a/frame/metadata/src/lib.rs +++ b/frame/metadata/src/lib.rs @@ -342,8 +342,10 @@ pub enum RuntimeMetadata { V6(RuntimeMetadataDeprecated), /// Version 7 for runtime metadata. No longer used. V7(RuntimeMetadataDeprecated), - /// Version 8 for runtime metadata. - V8(RuntimeMetadataV8), + /// Version 8 for runtime metadata. No longer used. + V8(RuntimeMetadataDeprecated), + /// Version 9 for runtime metadata. + V9(RuntimeMetadataV9), } /// Enum that should fail. @@ -367,12 +369,12 @@ impl Decode for RuntimeMetadataDeprecated { /// The metadata of a runtime. #[derive(Eq, Encode, PartialEq, RuntimeDebug)] #[cfg_attr(feature = "std", derive(Decode, Serialize))] -pub struct RuntimeMetadataV8 { +pub struct RuntimeMetadataV9 { pub modules: DecodeDifferentArray, } /// The latest version of the metadata. -pub type RuntimeMetadataLastVersion = RuntimeMetadataV8; +pub type RuntimeMetadataLastVersion = RuntimeMetadataV9; /// All metadata about an runtime module. #[derive(Clone, PartialEq, Eq, Encode, RuntimeDebug)] @@ -397,6 +399,6 @@ impl Into for RuntimeMetadataPrefixed { impl Into for RuntimeMetadataLastVersion { fn into(self) -> RuntimeMetadataPrefixed { - RuntimeMetadataPrefixed(META_RESERVED, RuntimeMetadata::V8(self)) + RuntimeMetadataPrefixed(META_RESERVED, RuntimeMetadata::V9(self)) } } diff --git a/frame/support/procedural/src/lib.rs b/frame/support/procedural/src/lib.rs index 8f23142bea..506e55fa17 100644 --- a/frame/support/procedural/src/lib.rs +++ b/frame/support/procedural/src/lib.rs @@ -56,7 +56,15 @@ use proc_macro::TokenStream; /// * Value: `Foo: type`: Implements the /// [`StorageValue`](../frame_support/storage/trait.StorageValue.html) trait using the /// [`StorageValue generator`](../frame_support/storage/generator/trait.StorageValue.html). -/// The generator `unhashed_key` is `$module_prefix ++ " " ++ $storage_name` +/// +/// The generator is implemented with: +/// * `module_prefix`: module_prefix +/// * `storage_prefix`: storage_name +/// +/// Thus the storage value is finally stored at: +/// ```nocompile +/// Twox128(module_prefix) ++ Twox128(storage_prefix) +/// ``` /// /// * Map: `Foo: map hasher($hash) type => type`: Implements the /// [`StorageMap`](../frame_support/storage/trait.StorageMap.html) trait using the @@ -69,9 +77,15 @@ use proc_macro::TokenStream; /// with care, see generator documentation. /// /// The generator is implemented with: -/// * `prefix`: `$module_prefix ++ " " ++ $storage_name` +/// * `module_prefix`: $module_prefix +/// * `storage_prefix`: storage_name /// * `Hasher`: $hash /// +/// Thus the keys are stored at: +/// ```nocompile +/// twox128(module_prefix) ++ twox128(storage_prefix) ++ hasher(encode(key)) +/// ``` +/// /// * Linked map: `Foo: linked_map hasher($hash) type => type`: Implements the /// [`StorageLinkedMap`](../frame_support/storage/trait.StorageLinkedMap.html) trait using the /// [`StorageLinkedMap generator`](../frame_support/storage/generator/trait.StorageLinkedMap.html). @@ -82,15 +96,25 @@ use proc_macro::TokenStream; /// `hasher($hash)` is optional and its default is `blake2_256`. One should use another hasher /// with care, see generator documentation. /// -/// The generator is implemented with: -/// * `prefix`: `$module_prefix ++ " " ++ $storage_name` -/// * `head_key`: `"head of " ++ $module_prefix ++ " " ++ $storage_name` -/// * `Hasher`: $hash -/// /// All key formatting logic can be accessed in a type-agnostic format via the /// [`KeyFormat`](../srml_support/storage/generator/trait.KeyFormat.html) trait, which /// is implemented for the storage linked map type as well. /// +/// The generator key format is implemented with: +/// * `module_prefix`: $module_prefix +/// * `storage_prefix`: storage_name +/// * `head_prefix`: `"HeadOf" ++ storage_name` +/// * `Hasher`: $hash +/// +/// Thus the keys are stored at: +/// ```nocompile +/// Twox128(module_prefix) ++ Twox128(storage_prefix) ++ Hasher(encode(key)) +/// ``` +/// and head is stored at: +/// ```nocompile +/// Twox128(module_prefix) ++ Twox128(head_prefix) +/// ``` +/// /// * Double map: `Foo: double_map hasher($hash1) u32, $hash2(u32) => u32`: Implements the /// [`StorageDoubleMap`](../frame_support/storage/trait.StorageDoubleMap.html) trait using the /// [`StorageDoubleMap generator`](../frame_support/storage/generator/trait.StorageDoubleMap.html). @@ -111,10 +135,16 @@ use proc_macro::TokenStream; /// Otherwise, other items in storage with the same first key can be compromised. /// /// The generator is implemented with: -/// * `key1_prefix`: `$module_prefix ++ " " ++ $storage_name` +/// * `module_prefix`: $module_prefix +/// * `storage_prefix`: storage_name /// * `Hasher1`: $hash1 /// * `Hasher2`: $hash2 /// +/// Thus keys are stored at: +/// ```nocompile +/// Twox128(module_prefix) ++ Twox128(storage_prefix) ++ Hasher1(encode(key1)) ++ Hasher2(encode(key2)) +/// ``` +/// /// Supported hashers (ordered from least to best security): /// /// * `twox_64_concat` - TwoX with 64bit + key concatenated. diff --git a/frame/support/procedural/src/storage/instance_trait.rs b/frame/support/procedural/src/storage/instance_trait.rs index 1a7add89a4..abc56092e3 100644 --- a/frame/support/procedural/src/storage/instance_trait.rs +++ b/frame/support/procedural/src/storage/instance_trait.rs @@ -19,24 +19,12 @@ use proc_macro2::{TokenStream, Span}; use quote::quote; -use super::{DeclStorageDefExt, StorageLineTypeDef}; +use super::DeclStorageDefExt; const NUMBER_OF_INSTANCE: usize = 16; -const INHERENT_INSTANCE_NAME: &str = "__InherentHiddenInstance"; +pub(crate) const INHERENT_INSTANCE_NAME: &str = "__InherentHiddenInstance"; pub(crate) const DEFAULT_INSTANTIABLE_TRAIT_NAME: &str = "__GeneratedInstantiable"; -// prefix for consts in trait Instance -pub(crate) const PREFIX_FOR: &str = "PREFIX_FOR_"; -pub(crate) const HEAD_KEY_FOR: &str = "HEAD_KEY_FOR_"; - -// Used to generate the const: -// `const $name: &'static str = $value_prefix ++ instance_prefix ++ $value_suffix` -struct InstanceConstDef { - name: syn::Ident, - value_prefix: String, - value_suffix: String, -} - // Used to generate an instance implementation. struct InstanceDef { prefix: String, @@ -47,33 +35,7 @@ struct InstanceDef { pub fn decl_and_impl(scrate: &TokenStream, def: &DeclStorageDefExt) -> TokenStream { let mut impls = TokenStream::new(); - let mut const_defs = vec![]; - - for line in def.storage_lines.iter() { - let storage_prefix = format!("{} {}", def.crate_name, line.name); - - let const_name = syn::Ident::new( - &format!("{}{}", PREFIX_FOR, line.name.to_string()), proc_macro2::Span::call_site() - ); - const_defs.push(InstanceConstDef { - name: const_name, - value_prefix: String::new(), - value_suffix: storage_prefix.clone(), - }); - - if let StorageLineTypeDef::LinkedMap(_) = line.storage_type { - let const_name = syn::Ident::new( - &format!("{}{}", HEAD_KEY_FOR, line.name.to_string()), proc_macro2::Span::call_site() - ); - const_defs.push(InstanceConstDef { - name: const_name, - value_prefix: "head of ".into(), - value_suffix: storage_prefix, - }); - } - } - - impls.extend(create_instance_trait(&const_defs, def)); + impls.extend(create_instance_trait(def)); // Implementation of instances. if let Some(module_instance) = &def.module_instance { @@ -95,7 +57,7 @@ pub fn decl_and_impl(scrate: &TokenStream, def: &DeclStorageDefExt) -> TokenStre ); for instance_def in instance_defs { - impls.extend(create_and_impl_instance_struct(scrate, &instance_def, &const_defs, def)); + impls.extend(create_and_impl_instance_struct(scrate, &instance_def, def)); } } @@ -116,27 +78,18 @@ pub fn decl_and_impl(scrate: &TokenStream, def: &DeclStorageDefExt) -> TokenStre instance_struct: inherent_instance, doc: quote!(#[doc(hidden)]), }; - impls.extend(create_and_impl_instance_struct(scrate, &instance_def, &const_defs, def)); + impls.extend(create_and_impl_instance_struct(scrate, &instance_def, def)); } impls } fn create_instance_trait( - const_defs: &[InstanceConstDef], def: &DeclStorageDefExt, ) -> TokenStream { let instance_trait = def.module_instance.as_ref().map(|i| i.instance_trait.clone()) .unwrap_or_else(|| syn::Ident::new(DEFAULT_INSTANTIABLE_TRAIT_NAME, Span::call_site())); - let mut const_impls = TokenStream::new(); - for const_def in const_defs { - let const_name = &const_def.name; - const_impls.extend(quote! { - const #const_name: &'static str; - }); - } - let optional_hide = if def.module_instance.is_some() { quote!() } else { @@ -151,7 +104,6 @@ fn create_instance_trait( pub trait #instance_trait: 'static { /// The prefix used by any storage entry of an instance. const PREFIX: &'static str; - #const_impls } } } @@ -159,22 +111,8 @@ fn create_instance_trait( fn create_and_impl_instance_struct( scrate: &TokenStream, instance_def: &InstanceDef, - const_defs: &[InstanceConstDef], def: &DeclStorageDefExt, ) -> TokenStream { - let mut const_impls = TokenStream::new(); - - for const_def in const_defs { - let const_value = format!( - "{}{}{}", const_def.value_prefix, instance_def.prefix, const_def.value_suffix - ); - let const_name = &const_def.name; - - const_impls.extend(quote! { - const #const_name: &'static str = #const_value; - }); - } - let instance_trait = def.module_instance.as_ref().map(|i| i.instance_trait.clone()) .unwrap_or_else(|| syn::Ident::new(DEFAULT_INSTANTIABLE_TRAIT_NAME, Span::call_site())); @@ -194,7 +132,6 @@ fn create_and_impl_instance_struct( pub struct #instance_struct; impl #instance_trait for #instance_struct { const PREFIX: &'static str = #prefix; - #const_impls } } } diff --git a/frame/support/procedural/src/storage/storage_struct.rs b/frame/support/procedural/src/storage/storage_struct.rs index 5267876a44..017e6cf2ff 100644 --- a/frame/support/procedural/src/storage/storage_struct.rs +++ b/frame/support/procedural/src/storage/storage_struct.rs @@ -16,11 +16,11 @@ //! Implementation of storage structures and implementation of storage traits on them. -use proc_macro2::TokenStream; +use proc_macro2::{TokenStream, Ident, Span}; use quote::quote; use super::{ DeclStorageDefExt, StorageLineTypeDef, - instance_trait::{PREFIX_FOR, HEAD_KEY_FOR}, + instance_trait::INHERENT_INSTANCE_NAME, }; fn from_optional_value_to_query(is_option: bool, default: &Option) -> TokenStream { @@ -78,17 +78,14 @@ pub fn decl_and_impl(scrate: &TokenStream, def: &DeclStorageDefExt) -> TokenStre let from_optional_value_to_query = from_optional_value_to_query(line.is_option, &line.default_value); - let final_prefix = if let Some(instance) = def.module_instance.as_ref() { - let instance = &instance.instance_generic; - let const_name = syn::Ident::new( - &format!("{}{}", PREFIX_FOR, line.name.to_string()), proc_macro2::Span::call_site() - ); - quote!( #instance::#const_name.as_bytes() ) + // Contains accessor to instance, used to get prefixes + let instance_or_inherent = if let Some(instance) = def.module_instance.as_ref() { + instance.instance_generic.clone() } else { - let prefix = format!("{} {}", def.crate_name, line.name); - quote!( #prefix.as_bytes() ) + Ident::new(INHERENT_INSTANCE_NAME, Span::call_site()) }; + let storage_name_str = syn::LitStr::new(&line.name.to_string(), line.name.span()); let storage_generator_trait = &line.storage_generator_trait; let storage_struct = &line.storage_struct; @@ -104,8 +101,12 @@ pub fn decl_and_impl(scrate: &TokenStream, def: &DeclStorageDefExt) -> TokenStre { type Query = #query_type; - fn unhashed_key() -> &'static [u8] { - #final_prefix + fn module_prefix() -> &'static [u8] { + #instance_or_inherent::PREFIX.as_bytes() + } + + fn storage_prefix() -> &'static [u8] { + #storage_name_str.as_bytes() } fn from_optional_value_to_query(v: Option<#value_type>) -> Self::Query { @@ -127,8 +128,12 @@ pub fn decl_and_impl(scrate: &TokenStream, def: &DeclStorageDefExt) -> TokenStre type Query = #query_type; type Hasher = #scrate::#hasher; - fn prefix() -> &'static [u8] { - #final_prefix + fn module_prefix() -> &'static [u8] { + #instance_or_inherent::PREFIX.as_bytes() + } + + fn storage_prefix() -> &'static [u8] { + #storage_name_str.as_bytes() } fn from_optional_value_to_query(v: Option<#value_type>) -> Self::Query { @@ -144,30 +149,18 @@ pub fn decl_and_impl(scrate: &TokenStream, def: &DeclStorageDefExt) -> TokenStre StorageLineTypeDef::LinkedMap(map) => { let hasher = map.hasher.to_storage_hasher_struct(); - // make sure to use different prefix for head and elements. - let head_key = if let Some(instance) = def.module_instance.as_ref() { - let instance = &instance.instance_generic; - let const_name = syn::Ident::new( - &format!("{}{}", HEAD_KEY_FOR, line.name.to_string()), proc_macro2::Span::call_site() - ); - quote!( #instance::#const_name.as_bytes() ) - } else { - let prefix = format!("head of {} {}", def.crate_name, line.name); - quote!( #prefix.as_bytes() ) - }; + let head_prefix_str = syn::LitStr::new( + &format!("HeadOf{}", line.name.to_string()), + line.name.span(), + ); quote!( impl<#impl_trait> #scrate::#storage_generator_trait for #storage_struct #optional_storage_where_clause { type Query = #query_type; - type Hasher = #scrate::#hasher; type KeyFormat = Self; - fn prefix() -> &'static [u8] { - #final_prefix - } - fn from_optional_value_to_query(v: Option<#value_type>) -> Self::Query { #from_optional_value_to_query } @@ -180,8 +173,16 @@ pub fn decl_and_impl(scrate: &TokenStream, def: &DeclStorageDefExt) -> TokenStre impl<#impl_trait> #scrate::storage::generator::LinkedMapKeyFormat for #storage_struct { type Hasher = #scrate::#hasher; - fn head_key() -> &'static [u8] { - #head_key + fn module_prefix() -> &'static [u8] { + #instance_or_inherent::PREFIX.as_bytes() + } + + fn storage_prefix() -> &'static [u8] { + #storage_name_str.as_bytes() + } + + fn head_prefix() -> &'static [u8] { + #head_prefix_str.as_bytes() } } ) @@ -199,8 +200,12 @@ pub fn decl_and_impl(scrate: &TokenStream, def: &DeclStorageDefExt) -> TokenStre type Hasher2 = #scrate::#hasher2; - fn key1_prefix() -> &'static [u8] { - #final_prefix + fn module_prefix() -> &'static [u8] { + #instance_or_inherent::PREFIX.as_bytes() + } + + fn storage_prefix() -> &'static [u8] { + #storage_name_str.as_bytes() } fn from_optional_value_to_query(v: Option<#value_type>) -> Self::Query { diff --git a/frame/support/src/storage/generator/double_map.rs b/frame/support/src/storage/generator/double_map.rs index 072b530e4c..28378034b2 100644 --- a/frame/support/src/storage/generator/double_map.rs +++ b/frame/support/src/storage/generator/double_map.rs @@ -17,7 +17,7 @@ use rstd::prelude::*; use rstd::borrow::Borrow; use codec::{Ref, FullCodec, FullEncode, Encode, EncodeLike, EncodeAppend}; -use crate::{storage::{self, unhashed}, hash::StorageHasher}; +use crate::{storage::{self, unhashed}, hash::{StorageHasher, Twox128}}; /// Generator for `StorageDoubleMap` used by `decl_storage`. /// @@ -29,7 +29,7 @@ use crate::{storage::{self, unhashed}, hash::StorageHasher}; /// /// Thus value for (key1, key2) is stored at: /// ```nocompile -/// Hasher1(key1_prefix ++ key1) ++ Hasher2(key2) +/// Twox128(module_prefix) ++ Twox128(storage_prefix) ++ Hasher1(encode(key1)) ++ Hasher2(encode(key2)) /// ``` /// /// # Warning @@ -49,8 +49,11 @@ pub trait StorageDoubleMap { /// Hasher for the second key. type Hasher2: StorageHasher; - /// Get the prefix for first key. - fn key1_prefix() -> &'static [u8]; + /// Module prefix. Used for generating final key. + fn module_prefix() -> &'static [u8]; + + /// Storage prefix. Used for generating final key. + fn storage_prefix() -> &'static [u8]; /// Convert an optional value retrieved from storage to the type queried. fn from_optional_value_to_query(v: Option) -> Self::Query; @@ -59,13 +62,23 @@ pub trait StorageDoubleMap { fn from_query_to_optional_value(v: Self::Query) -> Option; /// Generate the first part of the key used in top storage. - fn storage_double_map_final_key1(k1: KArg1) -> ::Output + fn storage_double_map_final_key1(k1: KArg1) -> Vec where KArg1: EncodeLike, { - let mut final_key1 = Self::key1_prefix().to_vec(); - k1.encode_to(&mut final_key1); - Self::Hasher1::hash(&final_key1) + let module_prefix_hashed = Twox128::hash(Self::module_prefix()); + let storage_prefix_hashed = Twox128::hash(Self::storage_prefix()); + let key_hashed = k1.borrow().using_encoded(Self::Hasher1::hash); + + let mut final_key = Vec::with_capacity( + module_prefix_hashed.len() + storage_prefix_hashed.len() + key_hashed.as_ref().len() + ); + + final_key.extend_from_slice(&module_prefix_hashed[..]); + final_key.extend_from_slice(&storage_prefix_hashed[..]); + final_key.extend_from_slice(key_hashed.as_ref()); + + final_key } /// Generate the full key used in top storage. @@ -74,7 +87,7 @@ pub trait StorageDoubleMap { KArg1: EncodeLike, KArg2: EncodeLike, { - let mut final_key = Self::storage_double_map_final_key1(k1).as_ref().to_vec(); + let mut final_key = Self::storage_double_map_final_key1(k1); final_key.extend_from_slice(k2.using_encoded(Self::Hasher2::hash).as_ref()); final_key } diff --git a/frame/support/src/storage/generator/linked_map.rs b/frame/support/src/storage/generator/linked_map.rs index cf40349699..fb0603fce7 100644 --- a/frame/support/src/storage/generator/linked_map.rs +++ b/frame/support/src/storage/generator/linked_map.rs @@ -15,48 +15,18 @@ // along with Substrate. If not, see . use codec::{FullCodec, Encode, Decode, EncodeLike, Ref}; -use crate::{storage::{self, unhashed}, hash::StorageHasher, traits::Len}; -use rstd::marker::PhantomData; +use crate::{storage::{self, unhashed}, hash::{StorageHasher, Twox128}, traits::Len}; +use rstd::{prelude::*, marker::PhantomData}; /// Generator for `StorageLinkedMap` used by `decl_storage`. /// -/// # Mapping of keys to a storage path -/// -/// The key for the head of the map is stored at one fixed path: -/// ```nocompile -/// Hasher(head_key) -/// ``` -/// -/// For each key, the value stored under that key is appended with a -/// [`Linkage`](struct.Linkage.html) (which hold previous and next key) at the path: -/// ```nocompile -/// Hasher(prefix ++ key) -/// ``` -/// -/// Enumeration is done by getting the head of the linked map and then iterating getting the -/// value and linkage stored at the key until the found linkage has no next key. -/// -/// # Warning -/// -/// If the keys are not trusted (e.g. can be set by a user), a cryptographic `hasher` such as -/// `blake2_256` must be used. Otherwise, other values in storage can be compromised. +/// By default final key generation rely on `KeyFormat`. pub trait StorageLinkedMap { /// The type that get/take returns. type Query; - /// Hasher used to insert into storage. - type Hasher: StorageHasher; - /// The family of key formats used for this map. - type KeyFormat: KeyFormat; - - /// Prefix used to prepend each key. - fn prefix() -> &'static [u8]; - - /// The head key of the linked-map. - fn head_key() -> &'static [u8] { - ::head_key() - } + type KeyFormat: KeyFormat; /// Convert an optional value retrieved from storage to the type queried. fn from_optional_value_to_query(v: Option) -> Self::Query; @@ -65,41 +35,80 @@ pub trait StorageLinkedMap { fn from_query_to_optional_value(v: Self::Query) -> Option; /// Generate the full key used in top storage. - fn storage_linked_map_final_key(key: KeyArg) -> ::Output + fn storage_linked_map_final_key(key: KeyArg) -> Vec where KeyArg: EncodeLike, { - ::storage_linked_map_final_key::(Self::prefix(), &key) + ::storage_linked_map_final_key::(&key) } /// Generate the hashed key for head - fn storage_linked_map_final_head_key() -> ::Output { + fn storage_linked_map_final_head_key() -> Vec { ::storage_linked_map_final_head_key() } } /// A type-abstracted key format used for a family of linked-map types. +/// +/// # Default mapping of keys to a storage path +/// +/// The key for the head of the map is stored at one fixed path: +/// ```nocompile +/// Twox128(module_prefix) ++ Twox128(head_prefix) +/// ``` +/// +/// For each key, the value stored under that key is appended with a +/// [`Linkage`](struct.Linkage.html) (which hold previous and next key) at the path: +/// ```nocompile +/// Twox128(module_prefix) ++ Twox128(storage_prefix) ++ Hasher(encode(key)) +/// ``` +/// +/// Enumeration is done by getting the head of the linked map and then iterating getting the +/// value and linkage stored at the key until the found linkage has no next key. +/// +/// # Warning +/// +/// If the keys are not trusted (e.g. can be set by a user), a cryptographic `hasher` such as +/// `blake2_256` must be used. Otherwise, other values in storage can be compromised. pub trait KeyFormat { + /// Hasher. Used for generating final key and final head key. type Hasher: StorageHasher; - /// Key used to store linked map head. - fn head_key() -> &'static [u8]; + /// Module prefix. Used for generating final key. + fn module_prefix() -> &'static [u8]; + + /// Storage prefix. Used for generating final key. + fn storage_prefix() -> &'static [u8]; + + /// Storage prefix. Used for generating final head key. + fn head_prefix() -> &'static [u8]; /// Generate the full key used in top storage. - fn storage_linked_map_final_key(prefix: &[u8], key: &K) - -> ::Output + fn storage_linked_map_final_key(key: &K) -> Vec where K: Encode, { - let mut final_key = prefix.to_vec(); - key.encode_to(&mut final_key); - ::hash(&final_key) + let module_prefix_hashed = Twox128::hash(Self::module_prefix()); + let storage_prefix_hashed = Twox128::hash(Self::storage_prefix()); + let key_hashed = key.using_encoded(Self::Hasher::hash); + + let mut final_key = Vec::with_capacity( + module_prefix_hashed.len() + storage_prefix_hashed.len() + key_hashed.as_ref().len() + ); + + final_key.extend_from_slice(&module_prefix_hashed[..]); + final_key.extend_from_slice(&storage_prefix_hashed[..]); + final_key.extend_from_slice(key_hashed.as_ref()); + + final_key } - fn storage_linked_map_final_head_key() - -> ::Output - { - ::hash(Self::head_key()) + /// Generate the full key used in top storage to store the head of the linked map. + fn storage_linked_map_final_head_key() -> Vec { + [ + Twox128::hash(Self::module_prefix()), + Twox128::hash(Self::head_prefix()), + ].concat() } } @@ -135,17 +144,15 @@ struct EncodeLikeLinkage, NKey: EncodeLike, Key: Enco /// A key-value pair iterator for enumerable map. pub struct Enumerator { next: Option, - prefix: &'static [u8], _phantom: PhantomData<(V, F)>, } impl Enumerator { /// Create an explicit enumerator for testing. #[cfg(test)] - pub fn from_head(head: K, prefix: &'static [u8]) -> Self { + pub fn from_head(head: K) -> Self { Enumerator { next: Some(head), - prefix, _phantom: Default::default(), } } @@ -163,15 +170,15 @@ where let next = self.next.take()?; let (val, linkage): (V, Linkage) = { - let next_full_key = F::storage_linked_map_final_key(self.prefix, &next); + let next_full_key = F::storage_linked_map_final_key(&next); match read_with_linkage::(next_full_key.as_ref()) { Some(value) => value, None => { // TODO #3700: error should be handleable. runtime_print!( - "ERROR: Corrupted state: linked map head_key={:?}: \ + "ERROR: Corrupted state: linked map {:?}{:?}: \ next value doesn't exist at {:?}", - F::head_key(), next_full_key.as_ref(), + F::module_prefix(), F::storage_prefix(), next_full_key, ); return None } @@ -187,18 +194,14 @@ where /// /// Takes care of updating previous and next elements points /// as well as updates head if the element is first or last. -fn remove_linkage(linkage: Linkage, prefix: &[u8]) +fn remove_linkage(linkage: Linkage) where K: FullCodec, V: FullCodec, F: KeyFormat, { - let next_key = linkage.next.as_ref() - .map(|k| F::storage_linked_map_final_key(prefix, k)) - .map(|x| x.as_ref().to_vec()); - let prev_key = linkage.previous.as_ref() - .map(|k| F::storage_linked_map_final_key(prefix, k)) - .map(|x| x.as_ref().to_vec()); + let next_key = linkage.next.as_ref().map(|k| F::storage_linked_map_final_key(k)); + let prev_key = linkage.previous.as_ref().map(|k| F::storage_linked_map_final_key(k)); if let Some(prev_key) = prev_key { // Retrieve previous element and update `next` @@ -208,9 +211,9 @@ where } else { // TODO #3700: error should be handleable. runtime_print!( - "ERROR: Corrupted state: linked map head_key={:?}: \ + "ERROR: Corrupted state: linked map {:?}{:?}: \ previous value doesn't exist at {:?}", - F::head_key(), prev_key, + F::module_prefix(), F::storage_prefix(), prev_key, ); } } else { @@ -225,9 +228,9 @@ where } else { // TODO #3700: error should be handleable. runtime_print!( - "ERROR: Corrupted state: linked map head_key={:?}: \ + "ERROR: Corrupted state: linked map {:?}{:?}: \ next value doesn't exist at {:?}", - F::head_key(), next_key, + F::module_prefix(), F::storage_prefix(), next_key, ); } } @@ -245,7 +248,7 @@ where /// Generate linkage for newly inserted element. /// /// Takes care of updating head and previous head's pointer. -pub(super) fn new_head_linkage(key: KeyArg, prefix: &[u8]) -> Linkage +pub(super) fn new_head_linkage(key: KeyArg) -> Linkage where KeyArg: EncodeLike, K: FullCodec, @@ -255,7 +258,7 @@ where if let Some(head) = read_head::() { // update previous head predecessor { - let head_key = F::storage_linked_map_final_key(prefix, &head); + let head_key = F::storage_linked_map_final_key(&head); if let Some((data, linkage)) = read_with_linkage::(head_key.as_ref()) { let new_linkage = EncodeLikeLinkage::<_, _, K> { previous: Some(Ref::from(&key)), @@ -266,9 +269,9 @@ where } else { // TODO #3700: error should be handleable. runtime_print!( - "ERROR: Corrupted state: linked map head_key={:?}: \ + "ERROR: Corrupted state: linked map {:?}{:?}: \ head value doesn't exist at {:?}", - F::head_key(), head_key.as_ref(), + F::module_prefix(), F::storage_prefix(), head_key, ); // Thus we consider we are first - update the head and produce empty linkage @@ -333,7 +336,6 @@ where } fn swap, KeyArg2: EncodeLike>(key1: KeyArg1, key2: KeyArg2) { - let prefix = Self::prefix(); let final_key1 = Self::storage_linked_map_final_key(Ref::from(&key1)); let final_key2 = Self::storage_linked_map_final_key(Ref::from(&key2)); let full_value_1 = read_with_linkage::(final_key1.as_ref()); @@ -348,13 +350,13 @@ where // Remove key and insert the new one. (Some((value, _linkage)), None) => { Self::remove(key1); - let linkage = new_head_linkage::<_, _, V, G::KeyFormat>(key2, prefix); + let linkage = new_head_linkage::<_, _, V, G::KeyFormat>(key2); unhashed::put(final_key2.as_ref(), &(value, linkage)); } // Remove key and insert the new one. (None, Some((value, _linkage))) => { Self::remove(key2); - let linkage = new_head_linkage::<_, _, V, G::KeyFormat>(key1, prefix); + let linkage = new_head_linkage::<_, _, V, G::KeyFormat>(key1); unhashed::put(final_key1.as_ref(), &(value, linkage)); } // No-op. @@ -368,7 +370,7 @@ where // overwrite but reuse existing linkage Some((_data, linkage)) => linkage, // create new linkage - None => new_head_linkage::<_, _, V, G::KeyFormat>(key, Self::prefix()), + None => new_head_linkage::<_, _, V, G::KeyFormat>(key), }; unhashed::put(final_key.as_ref(), &(val, linkage)) } @@ -398,7 +400,7 @@ where let full_value: Option<(V, Linkage)> = unhashed::take(final_key.as_ref()); let value = full_value.map(|(data, linkage)| { - remove_linkage::(linkage, Self::prefix()); + remove_linkage::(linkage); data }); @@ -408,7 +410,6 @@ where fn enumerate() -> Self::Enumerator { Enumerator::<_, _, G::KeyFormat> { next: read_head::<_, G::KeyFormat>(), - prefix: Self::prefix(), _phantom: Default::default(), } } @@ -436,7 +437,6 @@ where where K2: FullCodec + Clone, V2: Decode, TK: Fn(K2) -> K, TV: Fn(V2) -> V { let head_key = read_head::().ok_or(None)?; - let prefix = G::prefix(); let mut last_key = None; let mut current_key = head_key.clone(); @@ -451,7 +451,7 @@ where }; loop { - let old_raw_key = G::KeyFormat::storage_linked_map_final_key(prefix, ¤t_key); + let old_raw_key = G::KeyFormat::storage_linked_map_final_key(¤t_key); let x = unhashed::take(old_raw_key.as_ref()); let (val, linkage): (V2, Linkage) = match x { Some(v) => v, diff --git a/frame/support/src/storage/generator/map.rs b/frame/support/src/storage/generator/map.rs index 3c3edac28a..926fe8748d 100644 --- a/frame/support/src/storage/generator/map.rs +++ b/frame/support/src/storage/generator/map.rs @@ -18,13 +18,13 @@ use rstd::prelude::*; use rstd::borrow::Borrow; use codec::{FullCodec, FullEncode, Encode, EncodeLike, Ref, EncodeAppend}; -use crate::{storage::{self, unhashed}, hash::StorageHasher, traits::Len}; +use crate::{storage::{self, unhashed}, hash::{StorageHasher, Twox128}, traits::Len}; /// Generator for `StorageMap` used by `decl_storage`. /// -/// For each key value is stored at: +/// By default each key value is stored at: /// ```nocompile -/// Hasher(prefix ++ key) +/// Twox128(module_prefix) ++ Twox128(storage_prefix) ++ Hasher(encode(key)) /// ``` /// /// # Warning @@ -35,11 +35,14 @@ pub trait StorageMap { /// The type that get/take returns. type Query; - /// Hasher used to insert into storage. + /// Hasher. Used for generating final key. type Hasher: StorageHasher; - /// Prefix used to prepend each key. - fn prefix() -> &'static [u8]; + /// Module prefix. Used for generating final key. + fn module_prefix() -> &'static [u8]; + + /// Storage prefix. Used for generating final key. + fn storage_prefix() -> &'static [u8]; /// Convert an optional value retrieved from storage to the type queried. fn from_optional_value_to_query(v: Option) -> Self::Query; @@ -48,13 +51,23 @@ pub trait StorageMap { fn from_query_to_optional_value(v: Self::Query) -> Option; /// Generate the full key used in top storage. - fn storage_map_final_key(key: KeyArg) -> ::Output + fn storage_map_final_key(key: KeyArg) -> Vec where KeyArg: EncodeLike, { - let mut final_key = Self::prefix().to_vec(); - key.borrow().encode_to(&mut final_key); - Self::Hasher::hash(&final_key) + let module_prefix_hashed = Twox128::hash(Self::module_prefix()); + let storage_prefix_hashed = Twox128::hash(Self::storage_prefix()); + let key_hashed = key.borrow().using_encoded(Self::Hasher::hash); + + let mut final_key = Vec::with_capacity( + module_prefix_hashed.len() + storage_prefix_hashed.len() + key_hashed.as_ref().len() + ); + + final_key.extend_from_slice(&module_prefix_hashed[..]); + final_key.extend_from_slice(&storage_prefix_hashed[..]); + final_key.extend_from_slice(key_hashed.as_ref()); + + final_key } } @@ -62,7 +75,7 @@ impl> storage::StorageMap type Query = G::Query; fn hashed_key_for>(key: KeyArg) -> Vec { - Self::storage_map_final_key(key).as_ref().to_vec() + Self::storage_map_final_key(key) } fn swap, KeyArg2: EncodeLike>(key1: KeyArg1, key2: KeyArg2) { diff --git a/frame/support/src/storage/generator/mod.rs b/frame/support/src/storage/generator/mod.rs index f546546dc7..2db3e08ccf 100644 --- a/frame/support/src/storage/generator/mod.rs +++ b/frame/support/src/storage/generator/mod.rs @@ -94,22 +94,18 @@ mod tests { let t = GenesisConfig::default().build_storage().unwrap(); TestExternalities::new(t).execute_with(|| { - let prefix = NumberMap::prefix(); - // start with a map of u32 -> u32. for i in 0u32..100u32 { - let final_key = ::storage_linked_map_final_key( - prefix, &i, - ); + let final_key = ::storage_linked_map_final_key(&i); - let linkage = linked_map::new_head_linkage::<_, u32, u32, Format>(&i, prefix); + let linkage = linked_map::new_head_linkage::<_, u32, u32, Format>(&i); unhashed::put(final_key.as_ref(), &(&i, linkage)); } let head = linked_map::read_head::().unwrap(); assert_eq!( - Enumerator::::from_head(head, prefix).collect::>(), + Enumerator::::from_head(head).collect::>(), (0..100).rev().map(|x| (x, x)).collect::>(), ); diff --git a/frame/support/src/storage/generator/value.rs b/frame/support/src/storage/generator/value.rs index 5ebc25a70a..0cf143bac1 100644 --- a/frame/support/src/storage/generator/value.rs +++ b/frame/support/src/storage/generator/value.rs @@ -21,16 +21,19 @@ use crate::{storage::{self, unhashed}, hash::{Twox128, StorageHasher}, traits::L /// Generator for `StorageValue` used by `decl_storage`. /// -/// Value is stored at: +/// By default value is stored at: /// ```nocompile -/// Twox128(unhashed_key) +/// Twox128(module_prefix) ++ Twox128(storage_prefix) /// ``` pub trait StorageValue { /// The type that get/take returns. type Query; - /// Unhashed key used in storage - fn unhashed_key() -> &'static [u8]; + /// Module prefix. Used for generating final key. + fn module_prefix() -> &'static [u8]; + + /// Storage prefix. Used for generating final key. + fn storage_prefix() -> &'static [u8]; /// Convert an optional value retrieved from storage to the type queried. fn from_optional_value_to_query(v: Option) -> Self::Query; @@ -39,15 +42,18 @@ pub trait StorageValue { fn from_query_to_optional_value(v: Self::Query) -> Option; /// Generate the full key used in top storage. - fn storage_value_final_key() -> [u8; 16] { - Twox128::hash(Self::unhashed_key()) + fn storage_value_final_key() -> [u8; 32] { + let mut final_key = [0u8; 32]; + final_key[0..16].copy_from_slice(&Twox128::hash(Self::module_prefix())); + final_key[16..32].copy_from_slice(&Twox128::hash(Self::storage_prefix())); + final_key } } impl> storage::StorageValue for G { type Query = G::Query; - fn hashed_key() -> [u8; 16] { + fn hashed_key() -> [u8; 32] { Self::storage_value_final_key() } diff --git a/frame/support/src/storage/mod.rs b/frame/support/src/storage/mod.rs index 91e1776788..88818b84e2 100644 --- a/frame/support/src/storage/mod.rs +++ b/frame/support/src/storage/mod.rs @@ -34,7 +34,7 @@ pub trait StorageValue { type Query; /// Get the storage key. - fn hashed_key() -> [u8; 16]; + fn hashed_key() -> [u8; 32]; /// Does the value (explicitly) exist in storage? fn exists() -> bool; diff --git a/frame/support/test/tests/final_keys.rs b/frame/support/test/tests/final_keys.rs index c1cf5c651a..365aa5779d 100644 --- a/frame/support/test/tests/final_keys.rs +++ b/frame/support/test/tests/final_keys.rs @@ -17,7 +17,7 @@ use support::storage::unhashed; use codec::Encode; use support::{StorageDoubleMap, StorageLinkedMap, StorageMap, StorageValue}; -use runtime_io::{TestExternalities, hashing}; +use runtime_io::{TestExternalities, hashing::{twox_128, blake2_128, blake2_256}}; mod no_instance { use codec::{Encode, Decode, EncodeLike}; @@ -89,44 +89,43 @@ mod instance { fn final_keys_no_instance() { TestExternalities::default().execute_with(|| { no_instance::Value::put(1); - assert_eq!(unhashed::get::(&hashing::twox_128(b"FinalKeysNone Value")), Some(1u32)); + let k = [twox_128(b"FinalKeysNone"), twox_128(b"Value")].concat(); + assert_eq!(unhashed::get::(&k), Some(1u32)); no_instance::Map::insert(1, 2); - let mut k = b"FinalKeysNone Map".to_vec(); - k.extend(1u32.encode()); - assert_eq!(unhashed::get::(&hashing::blake2_256(&k)), Some(2u32)); + let mut k = [twox_128(b"FinalKeysNone"), twox_128(b"Map")].concat(); + k.extend(1u32.using_encoded(blake2_256).to_vec()); + assert_eq!(unhashed::get::(&k), Some(2u32)); no_instance::Map2::insert(1, 2); - let mut k = b"FinalKeysNone Map2".to_vec(); - k.extend(1u32.encode()); - assert_eq!(unhashed::get::(&hashing::twox_128(&k)), Some(2u32)); + let mut k = [twox_128(b"FinalKeysNone"), twox_128(b"Map2")].concat(); + k.extend(1u32.using_encoded(twox_128).to_vec()); + assert_eq!(unhashed::get::(&k), Some(2u32)); - let head = b"head of FinalKeysNone LinkedMap".to_vec(); - assert_eq!(unhashed::get::(&hashing::blake2_256(&head)), None); + let head = [twox_128(b"FinalKeysNone"), twox_128(b"HeadOfLinkedMap")].concat(); + assert_eq!(unhashed::get::(&head), None); no_instance::LinkedMap::insert(1, 2); - let mut k = b"FinalKeysNone LinkedMap".to_vec(); - k.extend(1u32.encode()); - assert_eq!(unhashed::get::(&hashing::blake2_256(&k)), Some(2u32)); - assert_eq!(unhashed::get::(&hashing::blake2_256(&head)), Some(1u32)); + let mut k = [twox_128(b"FinalKeysNone"), twox_128(b"LinkedMap")].concat(); + k.extend(1u32.using_encoded(blake2_256).to_vec()); + assert_eq!(unhashed::get::(&k), Some(2u32)); + assert_eq!(unhashed::get::(&head), Some(1u32)); no_instance::LinkedMap2::insert(1, 2); - let mut k = b"FinalKeysNone LinkedMap2".to_vec(); - k.extend(1u32.encode()); - assert_eq!(unhashed::get::(&hashing::twox_128(&k)), Some(2u32)); + let mut k = [twox_128(b"FinalKeysNone"), twox_128(b"LinkedMap2")].concat(); + k.extend(1u32.using_encoded(twox_128).to_vec()); + assert_eq!(unhashed::get::(&k), Some(2u32)); no_instance::DoubleMap::insert(&1, &2, &3); - let mut k = b"FinalKeysNone DoubleMap".to_vec(); - k.extend(1u32.encode()); - let mut k = hashing::blake2_256(&k).to_vec(); - k.extend(&hashing::blake2_256(&2u32.encode())); + let mut k = [twox_128(b"FinalKeysNone"), twox_128(b"DoubleMap")].concat(); + k.extend(1u32.using_encoded(blake2_256).to_vec()); + k.extend(2u32.using_encoded(blake2_256).to_vec()); assert_eq!(unhashed::get::(&k), Some(3u32)); no_instance::DoubleMap2::insert(&1, &2, &3); - let mut k = b"FinalKeysNone DoubleMap2".to_vec(); - k.extend(1u32.encode()); - let mut k = hashing::twox_128(&k).to_vec(); - k.extend(&hashing::blake2_128(&2u32.encode())); + let mut k = [twox_128(b"FinalKeysNone"), twox_128(b"DoubleMap2")].concat(); + k.extend(1u32.using_encoded(twox_128).to_vec()); + k.extend(2u32.using_encoded(blake2_128).to_vec()); assert_eq!(unhashed::get::(&k), Some(3u32)); }); } @@ -135,44 +134,43 @@ fn final_keys_no_instance() { fn final_keys_default_instance() { TestExternalities::default().execute_with(|| { >::put(1); - assert_eq!(unhashed::get::(&hashing::twox_128(b"FinalKeysSome Value")), Some(1u32)); + let k = [twox_128(b"FinalKeysSome"), twox_128(b"Value")].concat(); + assert_eq!(unhashed::get::(&k), Some(1u32)); >::insert(1, 2); - let mut k = b"FinalKeysSome Map".to_vec(); - k.extend(1u32.encode()); - assert_eq!(unhashed::get::(&hashing::blake2_256(&k)), Some(2u32)); + let mut k = [twox_128(b"FinalKeysSome"), twox_128(b"Map")].concat(); + k.extend(1u32.using_encoded(blake2_256).to_vec()); + assert_eq!(unhashed::get::(&k), Some(2u32)); >::insert(1, 2); - let mut k = b"FinalKeysSome Map2".to_vec(); - k.extend(1u32.encode()); - assert_eq!(unhashed::get::(&hashing::twox_128(&k)), Some(2u32)); + let mut k = [twox_128(b"FinalKeysSome"), twox_128(b"Map2")].concat(); + k.extend(1u32.using_encoded(twox_128).to_vec()); + assert_eq!(unhashed::get::(&k), Some(2u32)); - let head = b"head of FinalKeysSome LinkedMap".to_vec(); - assert_eq!(unhashed::get::(&hashing::blake2_256(&head)), None); + let head = [twox_128(b"FinalKeysSome"), twox_128(b"HeadOfLinkedMap")].concat(); + assert_eq!(unhashed::get::(&head), None); >::insert(1, 2); - let mut k = b"FinalKeysSome LinkedMap".to_vec(); - k.extend(1u32.encode()); - assert_eq!(unhashed::get::(&hashing::blake2_256(&k)), Some(2u32)); - assert_eq!(unhashed::get::(&hashing::blake2_256(&head)), Some(1u32)); + let mut k = [twox_128(b"FinalKeysSome"), twox_128(b"LinkedMap")].concat(); + k.extend(1u32.using_encoded(blake2_256).to_vec()); + assert_eq!(unhashed::get::(&k), Some(2u32)); + assert_eq!(unhashed::get::(&head), Some(1u32)); >::insert(1, 2); - let mut k = b"FinalKeysSome LinkedMap2".to_vec(); - k.extend(1u32.encode()); - assert_eq!(unhashed::get::(&hashing::twox_128(&k)), Some(2u32)); + let mut k = [twox_128(b"FinalKeysSome"), twox_128(b"LinkedMap2")].concat(); + k.extend(1u32.using_encoded(twox_128).to_vec()); + assert_eq!(unhashed::get::(&k), Some(2u32)); >::insert(&1, &2, &3); - let mut k = b"FinalKeysSome DoubleMap".to_vec(); - k.extend(1u32.encode()); - let mut k = hashing::blake2_256(&k).to_vec(); - k.extend(&hashing::blake2_256(&2u32.encode())); + let mut k = [twox_128(b"FinalKeysSome"), twox_128(b"DoubleMap")].concat(); + k.extend(1u32.using_encoded(blake2_256).to_vec()); + k.extend(2u32.using_encoded(blake2_256).to_vec()); assert_eq!(unhashed::get::(&k), Some(3u32)); >::insert(&1, &2, &3); - let mut k = b"FinalKeysSome DoubleMap2".to_vec(); - k.extend(1u32.encode()); - let mut k = hashing::twox_128(&k).to_vec(); - k.extend(&hashing::blake2_128(&2u32.encode())); + let mut k = [twox_128(b"FinalKeysSome"), twox_128(b"DoubleMap2")].concat(); + k.extend(1u32.using_encoded(twox_128).to_vec()); + k.extend(2u32.using_encoded(blake2_128).to_vec()); assert_eq!(unhashed::get::(&k), Some(3u32)); }); } @@ -181,47 +179,43 @@ fn final_keys_default_instance() { fn final_keys_instance_2() { TestExternalities::default().execute_with(|| { >::put(1); - assert_eq!( - unhashed::get::(&hashing::twox_128(b"Instance2FinalKeysSome Value")), - Some(1u32) - ); + let k = [twox_128(b"Instance2FinalKeysSome"), twox_128(b"Value")].concat(); + assert_eq!(unhashed::get::(&k), Some(1u32)); >::insert(1, 2); - let mut k = b"Instance2FinalKeysSome Map".to_vec(); - k.extend(1u32.encode()); - assert_eq!(unhashed::get::(&hashing::blake2_256(&k)), Some(2u32)); + let mut k = [twox_128(b"Instance2FinalKeysSome"), twox_128(b"Map")].concat(); + k.extend(1u32.using_encoded(blake2_256).to_vec()); + assert_eq!(unhashed::get::(&k), Some(2u32)); >::insert(1, 2); - let mut k = b"Instance2FinalKeysSome Map2".to_vec(); - k.extend(1u32.encode()); - assert_eq!(unhashed::get::(&hashing::twox_128(&k)), Some(2u32)); + let mut k = [twox_128(b"Instance2FinalKeysSome"), twox_128(b"Map2")].concat(); + k.extend(1u32.using_encoded(twox_128).to_vec()); + assert_eq!(unhashed::get::(&k), Some(2u32)); - let head = b"head of Instance2FinalKeysSome LinkedMap".to_vec(); - assert_eq!(unhashed::get::(&hashing::blake2_256(&head)), None); + let head = [twox_128(b"Instance2FinalKeysSome"), twox_128(b"HeadOfLinkedMap")].concat(); + assert_eq!(unhashed::get::(&head), None); >::insert(1, 2); - let mut k = b"Instance2FinalKeysSome LinkedMap".to_vec(); - k.extend(1u32.encode()); - assert_eq!(unhashed::get::(&hashing::blake2_256(&k)), Some(2u32)); - assert_eq!(unhashed::get::(&hashing::blake2_256(&head)), Some(1u32)); + let mut k = [twox_128(b"Instance2FinalKeysSome"), twox_128(b"LinkedMap")].concat(); + k.extend(1u32.using_encoded(blake2_256).to_vec()); + assert_eq!(unhashed::get::(&k), Some(2u32)); + assert_eq!(unhashed::get::(&head), Some(1u32)); >::insert(1, 2); - let mut k = b"Instance2FinalKeysSome LinkedMap2".to_vec(); - k.extend(1u32.encode()); - assert_eq!(unhashed::get::(&hashing::twox_128(&k)), Some(2u32)); + let mut k = [twox_128(b"Instance2FinalKeysSome"), twox_128(b"LinkedMap2")].concat(); + k.extend(1u32.using_encoded(twox_128).to_vec()); + assert_eq!(unhashed::get::(&k), Some(2u32)); >::insert(&1, &2, &3); - let mut k = b"Instance2FinalKeysSome DoubleMap".to_vec(); - k.extend(1u32.encode()); - let mut k = hashing::blake2_256(&k).to_vec(); - k.extend(&hashing::blake2_256(&2u32.encode())); + let mut k = [twox_128(b"Instance2FinalKeysSome"), twox_128(b"DoubleMap")].concat(); + k.extend(1u32.using_encoded(blake2_256).to_vec()); + k.extend(2u32.using_encoded(blake2_256).to_vec()); assert_eq!(unhashed::get::(&k), Some(3u32)); >::insert(&1, &2, &3); - let mut k = b"Instance2FinalKeysSome DoubleMap2".to_vec(); - k.extend(1u32.encode()); - let mut k = hashing::twox_128(&k).to_vec(); - k.extend(&hashing::blake2_128(&2u32.encode())); + let mut k = [twox_128(b"Instance2FinalKeysSome"), twox_128(b"DoubleMap2")].concat(); + k.extend(1u32.using_encoded(twox_128).to_vec()); + k.extend(2u32.using_encoded(blake2_128).to_vec()); assert_eq!(unhashed::get::(&k), Some(3u32)); }); } diff --git a/frame/support/test/tests/instance.rs b/frame/support/test/tests/instance.rs index dc4fded17e..eff73ad6ea 100644 --- a/frame/support/test/tests/instance.rs +++ b/frame/support/test/tests/instance.rs @@ -472,14 +472,3 @@ fn test_instance_storage_metadata() { let metadata = Module2_2::storage_metadata(); pretty_assertions::assert_eq!(EXPECTED_METADATA, metadata); } - -#[test] -fn instance_prefix_is_prefix_of_entries() { - use module2::Instance; - - let prefix = module2::Instance2::PREFIX; - assert!(module2::Instance2::PREFIX_FOR_Value.starts_with(prefix)); - assert!(module2::Instance2::PREFIX_FOR_Map.starts_with(prefix)); - assert!(module2::Instance2::PREFIX_FOR_LinkedMap.starts_with(prefix)); - assert!(module2::Instance2::PREFIX_FOR_DoubleMap.starts_with(prefix)); -} diff --git a/utils/frame/rpc/support/src/lib.rs b/utils/frame/rpc/support/src/lib.rs index ef594b687e..c9163bdc30 100644 --- a/utils/frame/rpc/support/src/lib.rs +++ b/utils/frame/rpc/support/src/lib.rs @@ -108,7 +108,7 @@ impl StorageQuery { /// Create a storage query for a value in a StorageMap. pub fn map, K: FullEncode>(key: K) -> Self { Self { - key: StorageKey(St::storage_map_final_key(key).as_ref().to_vec()), + key: StorageKey(St::storage_map_final_key(key)), _spook: PhantomData, } } @@ -116,7 +116,7 @@ impl StorageQuery { /// Create a storage query for a value in a StorageLinkedMap. pub fn linked_map, K: FullCodec>(key: K) -> Self { Self { - key: StorageKey(St::storage_linked_map_final_key(key).as_ref().to_vec()), + key: StorageKey(St::storage_linked_map_final_key(key)), _spook: PhantomData, } } -- GitLab From c22a53bfd188b2b51e920aaabceba08a4fa8d160 Mon Sep 17 00:00:00 2001 From: cheme Date: Wed, 27 Nov 2019 19:23:37 +0100 Subject: [PATCH 029/172] This reverts commit 77e681fb8b9c1e98ef1441bcc648e40ee36dac41. (#4230) It brings back trie-db 0.16. --- Cargo.lock | 18 ++-- primitives/state-machine/Cargo.toml | 2 +- primitives/trie/Cargo.toml | 4 +- primitives/trie/src/lib.rs | 2 +- primitives/trie/src/node_codec.rs | 148 ++++++++++++++++++---------- test/utils/runtime/Cargo.toml | 2 +- 6 files changed, 109 insertions(+), 67 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 317215e5b6..226cce363e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6517,7 +6517,7 @@ dependencies = [ "substrate-panic-handler 2.0.0", "substrate-primitives 2.0.0", "substrate-trie 2.0.0", - "trie-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", + "trie-db 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", "trie-root 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -6609,7 +6609,7 @@ dependencies = [ "substrate-transaction-pool-runtime-api 2.0.0", "substrate-trie 2.0.0", "substrate-wasm-builder-runner 1.0.4", - "trie-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", + "trie-db 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -6663,8 +6663,8 @@ dependencies = [ "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 2.0.0", "substrate-primitives 2.0.0", - "trie-bench 0.16.2 (registry+https://github.com/rust-lang/crates.io-index)", - "trie-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", + "trie-bench 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)", + "trie-db 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", "trie-root 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "trie-standardmap 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -7229,7 +7229,7 @@ dependencies = [ [[package]] name = "trie-bench" -version = "0.16.2" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "criterion 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", @@ -7237,14 +7237,14 @@ dependencies = [ "keccak-hasher 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "memory-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "trie-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", + "trie-db 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", "trie-root 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "trie-standardmap 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "trie-db" -version = "0.15.2" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "elastic-array 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -8438,8 +8438,8 @@ dependencies = [ "checksum tracing-attributes 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a4263b12c3d3c403274493eb805966093b53214124796552d674ca1dd5d27c2b" "checksum tracing-core 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "bc913647c520c959b6d21e35ed8fa6984971deca9f0a2fcb8c51207e0c56af1d" "checksum traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079" -"checksum trie-bench 0.16.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3073600c543ed001319d7e092c46dfd8c245af1a218ec5c75eb01582660a2b3e" -"checksum trie-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d0b62d27e8aa1c07414549ac872480ac82380bab39e730242ab08d82d7cc098a" +"checksum trie-bench 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)" = "403d8ec7dbc4b46781ef18cd96b371bb9ce6ec394fe83ece75eb3bc755dfa69f" +"checksum trie-db 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "784a9813d23f18bccab728ab039c39b8a87d0d6956dcdece39e92f5cffe5076e" "checksum trie-root 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0b779f7c1c8fe9276365d9d5be5c4b5adeacf545117bb3f64c974305789c5c0b" "checksum trie-standardmap 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c3161ba520ab28cd8e6b68e1126f1009f6e335339d1a73b978139011703264c8" "checksum try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382" diff --git a/primitives/state-machine/Cargo.toml b/primitives/state-machine/Cargo.toml index 3f02056647..36557803e1 100644 --- a/primitives/state-machine/Cargo.toml +++ b/primitives/state-machine/Cargo.toml @@ -9,7 +9,7 @@ edition = "2018" log = "0.4.8" parking_lot = "0.9.0" hash-db = "0.15.2" -trie-db = "0.15.2" +trie-db = "0.16.0" trie-root = "0.15.2" trie = { package = "substrate-trie", path = "../trie" } primitives = { package = "substrate-primitives", path = "../core" } diff --git a/primitives/trie/Cargo.toml b/primitives/trie/Cargo.toml index 202c9066d0..cc9d1b2dde 100644 --- a/primitives/trie/Cargo.toml +++ b/primitives/trie/Cargo.toml @@ -15,13 +15,13 @@ harness = false codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } rstd = { package = "sr-std", path = "../sr-std", default-features = false } hash-db = { version = "0.15.2", default-features = false } -trie-db = { version = "0.15.2", default-features = false } +trie-db = { version = "0.16.0", default-features = false } trie-root = { version = "0.15.2", default-features = false } memory-db = { version = "0.15.2", default-features = false } primitives = { package = "substrate-primitives", path = "../core", default-features = false } [dev-dependencies] -trie-bench = "0.16.2" +trie-bench = "0.17.0" trie-standardmap = "0.15.2" criterion = "0.2.11" hex-literal = "0.2.1" diff --git a/primitives/trie/src/lib.rs b/primitives/trie/src/lib.rs index eab05bab28..de056cace1 100644 --- a/primitives/trie/src/lib.rs +++ b/primitives/trie/src/lib.rs @@ -323,7 +323,7 @@ mod tests { type Layout = super::Layout; fn hashed_null_node() -> TrieHash { - >::hashed_null_node() + ::hashed_null_node() } fn check_equivalent(input: &Vec<(&[u8], &[u8])>) { diff --git a/primitives/trie/src/node_codec.rs b/primitives/trie/src/node_codec.rs index 03cbdfce52..e31ce8cc91 100644 --- a/primitives/trie/src/node_codec.rs +++ b/primitives/trie/src/node_codec.rs @@ -17,105 +17,147 @@ //! `NodeCodec` implementation for Substrate's trie format. use rstd::marker::PhantomData; +use rstd::ops::Range; use rstd::vec::Vec; use rstd::borrow::Borrow; -use codec::{Encode, Decode, Compact}; +use codec::{Encode, Decode, Input, Compact}; use hash_db::Hasher; -use trie_db::{self, NibbleSlice, node::Node, ChildReference, +use trie_db::{self, node::{NibbleSlicePlan, NodePlan, NodeHandlePlan}, ChildReference, nibble_ops, Partial, NodeCodec as NodeCodecT}; use crate::error::Error; use crate::trie_constants; use super::{node_header::{NodeHeader, NodeKind}}; -fn take<'a>(input: &mut &'a[u8], count: usize) -> Option<&'a[u8]> { - if input.len() < count { - return None +/// Helper struct for trie node decoder. This implements `codec::Input` on a byte slice, while +/// tracking the absolute position. This is similar to `std::io::Cursor` but does not implement +/// `Read` and `io` is not in `rstd`. +struct ByteSliceInput<'a> { + data: &'a [u8], + offset: usize, +} + +impl<'a> ByteSliceInput<'a> { + fn new(data: &'a [u8]) -> Self { + ByteSliceInput { + data, + offset: 0, + } + } + + fn take(&mut self, count: usize) -> Result, codec::Error> { + if self.offset + count > self.data.len() { + return Err("out of data".into()); + } + + let range = self.offset..(self.offset + count); + self.offset += count; + Ok(range) + } +} + +impl<'a> Input for ByteSliceInput<'a> { + fn remaining_len(&mut self) -> Result, codec::Error> { + let remaining = if self.offset <= self.data.len() { + Some(self.data.len() - self.offset) + } else { + None + }; + Ok(remaining) + } + + fn read(&mut self, into: &mut [u8]) -> Result<(), codec::Error> { + let range = self.take(into.len())?; + into.copy_from_slice(&self.data[range]); + Ok(()) + } + + fn read_byte(&mut self) -> Result { + if self.offset + 1 > self.data.len() { + return Err("out of data".into()); + } + + let byte = self.data[self.offset]; + self.offset += 1; + Ok(byte) } - let r = &(*input)[..count]; - *input = &(*input)[count..]; - Some(r) } /// Concrete implementation of a `NodeCodec` with Parity Codec encoding, generic over the `Hasher` #[derive(Default, Clone)] pub struct NodeCodec(PhantomData); -impl NodeCodecT for NodeCodec { +impl NodeCodecT for NodeCodec { type Error = Error; + type HashOut = H::Out; fn hashed_null_node() -> ::Out { - H::hash(>::empty_node()) + H::hash(::empty_node()) } - fn decode(data: &[u8]) -> rstd::result::Result { - let input = &mut &*data; - let head = NodeHeader::decode(input)?; - match head { - NodeHeader::Null => Ok(Node::Empty), + fn decode_plan(data: &[u8]) -> rstd::result::Result { + let mut input = ByteSliceInput::new(data); + match NodeHeader::decode(&mut input)? { + NodeHeader::Null => Ok(NodePlan::Empty), NodeHeader::Branch(has_value, nibble_count) => { let padding = nibble_count % nibble_ops::NIBBLE_PER_BYTE != 0; // check that the padding is valid (if any) - if padding && nibble_ops::pad_left(input[0]) != 0 { + if padding && nibble_ops::pad_left(data[input.offset]) != 0 { return Err(Error::BadFormat); } - let nibble_data = take( - input, + let partial = input.take( (nibble_count + (nibble_ops::NIBBLE_PER_BYTE - 1)) / nibble_ops::NIBBLE_PER_BYTE, - ).ok_or(Error::BadFormat)?; - let nibble_slice = NibbleSlice::new_offset( - nibble_data, - nibble_ops::number_padding(nibble_count), - ); - let bitmap_slice = take(input, BITMAP_LENGTH).ok_or(Error::BadFormat)?; - let bitmap = Bitmap::decode(&bitmap_slice[..])?; + )?; + let partial_padding = nibble_ops::number_padding(nibble_count); + let bitmap_range = input.take(BITMAP_LENGTH)?; + let bitmap = Bitmap::decode(&data[bitmap_range])?; let value = if has_value { - let count = >::decode(input)?.0 as usize; - Some(take(input, count).ok_or(Error::BadFormat)?) + let count = >::decode(&mut input)?.0 as usize; + Some(input.take(count)?) } else { None }; - let mut children = [None; 16]; - + let mut children = [ + None, None, None, None, None, None, None, None, + None, None, None, None, None, None, None, None, + ]; for i in 0..nibble_ops::NIBBLE_LENGTH { if bitmap.value_at(i) { - let count = >::decode(input)?.0 as usize; - children[i] = Some(take(input, count).ok_or(Error::BadFormat)?); + let count = >::decode(&mut input)?.0 as usize; + let range = input.take(count)?; + children[i] = Some(if count == H::LENGTH { + NodeHandlePlan::Hash(range) + } else { + NodeHandlePlan::Inline(range) + }); } } - Ok(Node::NibbledBranch(nibble_slice, children, value)) + Ok(NodePlan::NibbledBranch { + partial: NibbleSlicePlan::new(partial, partial_padding), + value, + children, + }) } NodeHeader::Leaf(nibble_count) => { let padding = nibble_count % nibble_ops::NIBBLE_PER_BYTE != 0; // check that the padding is valid (if any) - if padding && nibble_ops::pad_left(input[0]) != 0 { + if padding && nibble_ops::pad_left(data[input.offset]) != 0 { return Err(Error::BadFormat); } - let nibble_data = take( - input, + let partial = input.take( (nibble_count + (nibble_ops::NIBBLE_PER_BYTE - 1)) / nibble_ops::NIBBLE_PER_BYTE, - ).ok_or(Error::BadFormat)?; - let nibble_slice = NibbleSlice::new_offset( - nibble_data, - nibble_ops::number_padding(nibble_count), - ); - let count = >::decode(input)?.0 as usize; - Ok(Node::Leaf(nibble_slice, take(input, count).ok_or(Error::BadFormat)?)) + )?; + let partial_padding = nibble_ops::number_padding(nibble_count); + let count = >::decode(&mut input)?.0 as usize; + Ok(NodePlan::Leaf { + partial: NibbleSlicePlan::new(partial, partial_padding), + value: input.take(count)?, + }) } } } - fn try_decode_hash(data: &[u8]) -> Option<::Out> { - if data.len() == H::LENGTH { - let mut r = ::Out::default(); - r.as_mut().copy_from_slice(data); - Some(r) - } else { - None - } - } - fn is_empty_node(data: &[u8]) -> bool { - data == >::empty_node() + data == ::empty_node() } fn empty_node() -> &'static [u8] { diff --git a/test/utils/runtime/Cargo.toml b/test/utils/runtime/Cargo.toml index b32081a863..f89524d284 100644 --- a/test/utils/runtime/Cargo.toml +++ b/test/utils/runtime/Cargo.toml @@ -35,7 +35,7 @@ pallet-timestamp = { path = "../../../frame/timestamp", default-features = false substrate-client = { path = "../../../client", optional = true } substrate-trie = { path = "../../../primitives/trie", default-features = false } transaction-pool-api = { package = "substrate-transaction-pool-runtime-api", path = "../../../primitives/transaction-pool/runtime-api", default-features = false } -trie-db = { version = "0.15.2", default-features = false } +trie-db = { version = "0.16.0", default-features = false } [dev-dependencies] substrate-executor = { path = "../../../client/executor" } -- GitLab From a3fb0fda66cbc19e05d067d22f6b6cceabdd4207 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Wed, 27 Nov 2019 19:23:55 +0100 Subject: [PATCH 030/172] Hard-cap the execution time of custom contract calls. (#4226) * Reject call requests that allocate too high gas limit. * Lower to 5x --- frame/contracts/rpc/src/lib.rs | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/frame/contracts/rpc/src/lib.rs b/frame/contracts/rpc/src/lib.rs index e330e9efcc..6f357f53b8 100644 --- a/frame/contracts/rpc/src/lib.rs +++ b/frame/contracts/rpc/src/lib.rs @@ -39,7 +39,16 @@ const RUNTIME_ERROR: i64 = 1; const CONTRACT_DOESNT_EXIST: i64 = 2; const CONTRACT_IS_A_TOMBSTONE: i64 = 3; -// A private newtype for converting `GetStorageError` into an RPC error. +/// A rough estimate of how much gas a decent hardware consumes per second, +/// using native execution. +/// This value is used to set the upper bound for maximal contract calls to +/// prevent blocking the RPC for too long. +/// +/// Based on W3F research spreadsheet: +/// https://docs.google.com/spreadsheets/d/1h0RqncdqiWI4KgxO0z9JIpZEJESXjX_ZCK6LFX6veDo/view +const GAS_PER_SECOND: u64 = 1_000_000_000; + +/// A private newtype for converting `GetStorageError` into an RPC error. struct GetStorageError(runtime_api::GetStorageError); impl From for Error { fn from(e: GetStorageError) -> Error { @@ -148,6 +157,19 @@ where data: None, })?; + let max_gas_limit = 5 * GAS_PER_SECOND; + if gas_limit > max_gas_limit { + return Err(Error { + code: ErrorCode::InvalidParams, + message: format!( + "Requested gas limit is greater than maximum allowed: {} > {}", + gas_limit, + max_gas_limit + ), + data: None, + }); + } + let exec_result = api .call(&at, origin, dest, value, gas_limit, input_data.to_vec()) .map_err(|e| Error { -- GitLab From 994a173a751baa9c5a9df533767d182618b553b5 Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Wed, 27 Nov 2019 18:57:03 +0000 Subject: [PATCH 031/172] Validators don't get slashed for offlineness until 10% at once (#4232) * Validators don't get slashed for offlineness until 10% at once * Update frame/im-online/src/tests.rs Co-Authored-By: Marcio Diaz * Update frame/im-online/src/tests.rs Co-Authored-By: Marcio Diaz * Apply suggestions from code review Co-Authored-By: joe petrowski <25483142+joepetrowski@users.noreply.github.com> --- frame/im-online/src/lib.rs | 12 +++++++++--- frame/im-online/src/tests.rs | 11 ++++++++--- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/frame/im-online/src/lib.rs b/frame/im-online/src/lib.rs index 01ebde206e..8f3361186f 100644 --- a/frame/im-online/src/lib.rs +++ b/frame/im-online/src/lib.rs @@ -653,8 +653,14 @@ impl Offence for UnresponsivenessOffence { } fn slash_fraction(offenders: u32, validator_set_count: u32) -> Perbill { - // the formula is min((3 * (k - 1)) / n, 1) * 0.05 - let x = Perbill::from_rational_approximation(3 * (offenders - 1), validator_set_count); - x.saturating_mul(Perbill::from_percent(5)) + // the formula is min((3 * (k - (n / 10 + 1))) / n, 1) * 0.07 + // basically, 10% can be offline with no slash, but after that, it linearly climbs up to 7% + // when 13/30 are offline (around 5% when 1/3 are offline). + if let Some(threshold) = offenders.checked_sub(validator_set_count / 10 + 1) { + let x = Perbill::from_rational_approximation(3 * threshold, validator_set_count); + x.saturating_mul(Perbill::from_percent(7)) + } else { + Perbill::default() + } } } diff --git a/frame/im-online/src/tests.rs b/frame/im-online/src/tests.rs index edfdc34bc0..788956ba6e 100644 --- a/frame/im-online/src/tests.rs +++ b/frame/im-online/src/tests.rs @@ -38,14 +38,19 @@ fn test_unresponsiveness_slash_fraction() { ); assert_eq!( - UnresponsivenessOffence::<()>::slash_fraction(3, 50), - Perbill::from_parts(6000000), // 0.6% + UnresponsivenessOffence::<()>::slash_fraction(5, 50), + Perbill::zero(), // 0% + ); + + assert_eq!( + UnresponsivenessOffence::<()>::slash_fraction(7, 50), + Perbill::from_parts(4200000), // 0.42% ); // One third offline should be punished around 5%. assert_eq!( UnresponsivenessOffence::<()>::slash_fraction(17, 50), - Perbill::from_parts(48000000), // 4.8% + Perbill::from_parts(46200000), // 4.62% ); } -- GitLab From b853a4f9d31e571d04c4c8c73c4a27ff82e10451 Mon Sep 17 00:00:00 2001 From: Robert Habermeier Date: Wed, 27 Nov 2019 20:06:32 +0100 Subject: [PATCH 032/172] safe multi-era slashing for NPoS (#3846) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * define slashing spans * tests and pruning for slashing-spans record * validators get slashed before nominators * apply slash to nominators as well * chill and end slashing spans * actually perform slashes * integration (tests failing) * prune metadata * fix compilation * some tests for slashing and metadata garbage collection * correctly pass session index to slash handler * test span-max property for nominators and validators * test that slashes are summed correctly * reward value computation * implement rewarding * add comment about rewards * do not adjust slash fraction in offences module * fix offences tests * remove unused new_offenders field * update runtime version * fix up some docs * fix some CI failures * remove no-std incompatible vec! invocation * try to fix span-max rounding error * Update srml/staking/src/slashing.rs Fix type: winow -> window Co-Authored-By: Tomasz Drwięga * slashes from prior spans don't kick validator again * more information for nominators, suppression * ensure ledger is consistent with itself post-slash * implement slash out of unlocking funds also * slashing: create records to be applied after-the-fact * queue slashes for a few eras later * method for canceling deferred slashes * attempt to fix test in CI * storage migration for `Nominators` * update node-runtime to use SlashDeferDuration * adjust migration entry-points somewhat * fix migration compilation * add manual Vec import to migration * enable migrations feature in node-runtime * bump runtime version * update to latest master crate renames * update to use ensure-origin * Apply suggestions from code review use `ensure!` Co-Authored-By: Gavin Wood * fix multi-slash removal * initialize storage version to current in genesis * add test for version initialization --- bin/node/runtime/Cargo.toml | 2 +- bin/node/runtime/src/lib.rs | 4 + frame/balances/src/lib.rs | 1 + frame/offences/src/lib.rs | 68 +- frame/offences/src/mock.rs | 5 +- frame/offences/src/tests.rs | 33 +- frame/staking/Cargo.toml | 1 + frame/staking/src/lib.rs | 444 +++++++--- frame/staking/src/migration.rs | 88 ++ frame/staking/src/mock.rs | 59 +- frame/staking/src/slashing.rs | 824 ++++++++++++++++++ frame/staking/src/tests.rs | 639 +++++++++++++- .../sr-staking-primitives/src/offence.rs | 4 + 13 files changed, 1922 insertions(+), 250 deletions(-) create mode 100644 frame/staking/src/migration.rs create mode 100644 frame/staking/src/slashing.rs diff --git a/bin/node/runtime/Cargo.toml b/bin/node/runtime/Cargo.toml index 3844fa336f..f5c4d5855b 100644 --- a/bin/node/runtime/Cargo.toml +++ b/bin/node/runtime/Cargo.toml @@ -50,7 +50,7 @@ nicks = { package = "pallet-nicks", path = "../../../frame/nicks", default-featu offences = { package = "pallet-offences", path = "../../../frame/offences", default-features = false } randomness-collective-flip = { package = "pallet-randomness-collective-flip", path = "../../../frame/randomness-collective-flip", default-features = false } session = { package = "pallet-session", path = "../../../frame/session", default-features = false, features = ["historical"] } -staking = { package = "pallet-staking", path = "../../../frame/staking", default-features = false } +staking = { package = "pallet-staking", path = "../../../frame/staking", default-features = false, features = ["migrate"] } pallet-staking-reward-curve = { path = "../../../frame/staking/reward-curve"} sudo = { package = "pallet-sudo", path = "../../../frame/sudo", default-features = false } support = { package = "frame-support", path = "../../../frame/support", default-features = false } diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index fbb690a622..d55f37da12 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -250,6 +250,7 @@ pallet_staking_reward_curve::build! { parameter_types! { pub const SessionsPerEra: sr_staking_primitives::SessionIndex = 6; pub const BondingDuration: staking::EraIndex = 24 * 28; + pub const SlashDeferDuration: staking::EraIndex = 24 * 7; // 1/4 the bonding duration. pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE; } @@ -263,6 +264,9 @@ impl staking::Trait for Runtime { type Reward = (); // rewards are minted from the void type SessionsPerEra = SessionsPerEra; type BondingDuration = BondingDuration; + type SlashDeferDuration = SlashDeferDuration; + /// A super-majority of the council can cancel the slash. + type SlashCancelOrigin = collective::EnsureProportionAtLeast<_3, _4, AccountId, CouncilCollective>; type SessionInterface = Self; type RewardCurve = RewardCurve; } diff --git a/frame/balances/src/lib.rs b/frame/balances/src/lib.rs index fd6ec99c07..cee4f9dbe9 100644 --- a/frame/balances/src/lib.rs +++ b/frame/balances/src/lib.rs @@ -986,6 +986,7 @@ where ) -> (Self::NegativeImbalance, Self::Balance) { let free_balance = Self::free_balance(who); let free_slash = cmp::min(free_balance, value); + Self::set_free_balance(who, free_balance - free_slash); let remaining_slash = value - free_slash; // NOTE: `slash()` prefers free balance, but assumes that reserve balance can be drawn diff --git a/frame/offences/src/lib.rs b/frame/offences/src/lib.rs index a6cf4d7956..ce9a1a0a41 100644 --- a/frame/offences/src/lib.rs +++ b/frame/offences/src/lib.rs @@ -24,17 +24,11 @@ mod mock; mod tests; -use rstd::{ - vec::Vec, - collections::btree_set::BTreeSet, -}; +use rstd::vec::Vec; use support::{ decl_module, decl_event, decl_storage, Parameter, }; -use sr_primitives::{ - Perbill, - traits::{Hash, Saturating}, -}; +use sr_primitives::traits::Hash; use sr_staking_primitives::{ offence::{Offence, ReportOffence, Kind, OnOffenceHandler, OffenceDetails}, }; @@ -100,10 +94,11 @@ where // Go through all offenders in the offence report and find all offenders that was spotted // in unique reports. - let TriageOutcome { - new_offenders, - concurrent_offenders, - } = match Self::triage_offence_report::(reporters, &time_slot, offenders) { + let TriageOutcome { concurrent_offenders } = match Self::triage_offence_report::( + reporters, + &time_slot, + offenders, + ) { Some(triage) => triage, // The report contained only duplicates, so there is no need to slash again. None => return, @@ -113,44 +108,18 @@ where Self::deposit_event(Event::Offence(O::ID, time_slot.encode())); let offenders_count = concurrent_offenders.len() as u32; - let previous_offenders_count = offenders_count - new_offenders.len() as u32; // The amount new offenders are slashed let new_fraction = O::slash_fraction(offenders_count, validator_set_count); - // The amount previous offenders are slashed additionally. - // - // Since they were slashed in the past, we slash by: - // x = (new - prev) / (1 - prev) - // because: - // Y = X * (1 - prev) - // Z = Y * (1 - x) - // Z = X * (1 - new) - let old_fraction = if previous_offenders_count > 0 { - let previous_fraction = O::slash_fraction( - offenders_count.saturating_sub(previous_offenders_count), - validator_set_count, - ); - let numerator = new_fraction.saturating_sub(previous_fraction); - let denominator = Perbill::one().saturating_sub(previous_fraction); - denominator.saturating_mul(numerator) - } else { - new_fraction.clone() - }; + let slash_perbill: Vec<_> = (0..concurrent_offenders.len()) + .map(|_| new_fraction.clone()).collect(); - // calculate how much to slash - let slash_perbill = concurrent_offenders - .iter() - .map(|details| { - if previous_offenders_count > 0 && new_offenders.contains(&details.offender) { - new_fraction.clone() - } else { - old_fraction.clone() - } - }) - .collect::>(); - - T::OnOffenceHandler::on_offence(&concurrent_offenders, &slash_perbill); + T::OnOffenceHandler::on_offence( + &concurrent_offenders, + &slash_perbill, + offence.session_index(), + ); } } @@ -173,13 +142,13 @@ impl Module { offenders: Vec, ) -> Option> { let mut storage = ReportIndexStorage::::load(time_slot); - let mut new_offenders = BTreeSet::new(); + let mut any_new = false; for offender in offenders { let report_id = Self::report_id::(time_slot, &offender); if !>::exists(&report_id) { - new_offenders.insert(offender.clone()); + any_new = true; >::insert( &report_id, OffenceDetails { @@ -192,7 +161,7 @@ impl Module { } } - if !new_offenders.is_empty() { + if any_new { // Load report details for the all reports happened at the same time. let concurrent_offenders = storage.concurrent_reports .iter() @@ -202,7 +171,6 @@ impl Module { storage.save(); Some(TriageOutcome { - new_offenders, concurrent_offenders, }) } else { @@ -212,8 +180,6 @@ impl Module { } struct TriageOutcome { - /// Offenders that was spotted in the unique reports. - new_offenders: BTreeSet, /// Other reports for the same report kinds. concurrent_offenders: Vec>, } diff --git a/frame/offences/src/mock.rs b/frame/offences/src/mock.rs index e8e4c864d1..491c9681b1 100644 --- a/frame/offences/src/mock.rs +++ b/frame/offences/src/mock.rs @@ -46,6 +46,7 @@ impl offence::OnOffenceHandler for OnOff fn on_offence( _offenders: &[OffenceDetails], slash_fraction: &[Perbill], + _offence_session: SessionIndex, ) { ON_OFFENCE_PERBILL.with(|f| { *f.borrow_mut() = slash_fraction.to_vec(); @@ -148,9 +149,7 @@ impl offence::Offence for Offence { } fn session_index(&self) -> SessionIndex { - // session index is not used by the pallet-offences directly, but rather it exists only for - // filtering historical reports. - unimplemented!() + 1 } fn slash_fraction( diff --git a/frame/offences/src/tests.rs b/frame/offences/src/tests.rs index 28e655d16b..aa71d1d620 100644 --- a/frame/offences/src/tests.rs +++ b/frame/offences/src/tests.rs @@ -23,6 +23,7 @@ use crate::mock::{ Offences, System, Offence, TestEvent, KIND, new_test_ext, with_on_offence_fractions, offence_reports, }; +use sr_primitives::Perbill; use system::{EventRecord, Phase}; #[test] @@ -48,38 +49,6 @@ fn should_report_an_authority_and_trigger_on_offence() { }); } -#[test] -fn should_calculate_the_fraction_correctly() { - new_test_ext().execute_with(|| { - // given - let time_slot = 42; - assert_eq!(offence_reports(KIND, time_slot), vec![]); - let offence1 = Offence { - validator_set_count: 5, - time_slot, - offenders: vec![5], - }; - let offence2 = Offence { - validator_set_count: 5, - time_slot, - offenders: vec![4], - }; - - // when - Offences::report_offence(vec![], offence1); - with_on_offence_fractions(|f| { - assert_eq!(f.clone(), vec![Perbill::from_percent(25)]); - }); - - Offences::report_offence(vec![], offence2); - - // then - with_on_offence_fractions(|f| { - assert_eq!(f.clone(), vec![Perbill::from_percent(15), Perbill::from_percent(45)]); - }); - }); -} - #[test] fn should_not_report_the_same_authority_twice_in_the_same_slot() { new_test_ext().execute_with(|| { diff --git a/frame/staking/Cargo.toml b/frame/staking/Cargo.toml index 005b45da76..110c3d868c 100644 --- a/frame/staking/Cargo.toml +++ b/frame/staking/Cargo.toml @@ -28,6 +28,7 @@ substrate-test-utils = { path = "../../test/utils" } [features] equalize = [] +migrate = [] default = ["std", "equalize"] std = [ "serde", diff --git a/frame/staking/src/lib.rs b/frame/staking/src/lib.rs index ae9e53c851..aeeda48593 100644 --- a/frame/staking/src/lib.rs +++ b/frame/staking/src/lib.rs @@ -108,6 +108,8 @@ //! determined, a value is deducted from the balance of the validator and all the nominators who //! voted for this validator (values are deducted from the _stash_ account of the slashed entity). //! +//! Slashing logic is further described in the documentation of the `slashing` module. +//! //! Similar to slashing, rewards are also shared among a validator and its associated nominators. //! Yet, the reward funds are not always transferred to the stash account and can be configured. //! See [Reward Calculation](#reward-calculation) for more details. @@ -248,6 +250,8 @@ mod mock; #[cfg(test)] mod tests; +mod migration; +mod slashing; pub mod inflation; @@ -268,6 +272,7 @@ use sr_primitives::{ curve::PiecewiseLinear, traits::{ Convert, Zero, One, StaticLookup, CheckedSub, Saturating, Bounded, SaturatedConversion, + SimpleArithmetic, EnsureOrigin, } }; use sr_staking_primitives::{ @@ -278,7 +283,7 @@ use sr_staking_primitives::{ use sr_primitives::{Serialize, Deserialize}; use system::{ensure_signed, ensure_root}; -use phragmen::{elect, equalize, build_support_map, ExtendedBalance, PhragmenStakedAssignment}; +use phragmen::{ExtendedBalance, PhragmenStakedAssignment}; const DEFAULT_MINIMUM_VALIDATOR_COUNT: u32 = 4; const MAX_NOMINATIONS: usize = 16; @@ -406,6 +411,74 @@ impl< .collect(); Self { total, active: self.active, stash: self.stash, unlocking } } + +} + +impl StakingLedger where + Balance: SimpleArithmetic + Saturating + Copy, +{ + /// Slash the validator for a given amount of balance. This can grow the value + /// of the slash in the case that the validator has less than `minimum_balance` + /// active funds. Returns the amount of funds actually slashed. + /// + /// Slashes from `active` funds first, and then `unlocking`, starting with the + /// chunks that are closest to unlocking. + fn slash( + &mut self, + mut value: Balance, + minimum_balance: Balance, + ) -> Balance { + let pre_total = self.total; + let total = &mut self.total; + let active = &mut self.active; + + let slash_out_of = | + total_remaining: &mut Balance, + target: &mut Balance, + value: &mut Balance, + | { + let mut slash_from_target = (*value).min(*target); + + if !slash_from_target.is_zero() { + *target -= slash_from_target; + + // don't leave a dust balance in the staking system. + if *target <= minimum_balance { + slash_from_target += *target; + *value += rstd::mem::replace(target, Zero::zero()); + } + + *total_remaining = total_remaining.saturating_sub(slash_from_target); + *value -= slash_from_target; + } + }; + + slash_out_of(total, active, &mut value); + + let i = self.unlocking.iter_mut() + .map(|chunk| { + slash_out_of(total, &mut chunk.value, &mut value); + chunk.value + }) + .take_while(|value| value.is_zero()) // take all fully-consumed chunks out. + .count(); + + // kill all drained chunks. + let _ = self.unlocking.drain(..i); + + pre_total.saturating_sub(*total) + } +} + +/// A record of the nominations made by a specific account. +#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug)] +pub struct Nominations { + /// The targets of nomination. + pub targets: Vec, + /// The era the nominations were submitted. + pub submitted_in: EraIndex, + /// Whether the nominations have been suppressed. + pub suppressed: bool, } /// The amount of exposure (to slashing) than an individual nominator has. @@ -431,12 +504,20 @@ pub struct Exposure { pub others: Vec>, } -/// A slashing event occurred, slashing a validator for a given amount of balance. -#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Encode, Decode, Default, RuntimeDebug)] -pub struct SlashJournalEntry { - who: AccountId, - amount: Balance, - own_slash: Balance, // the amount of `who`'s own exposure that was slashed +/// A pending slash record. The value of the slash has been computed but not applied yet, +/// rather deferred for several eras. +#[derive(Encode, Decode, Default, RuntimeDebug)] +pub struct UnappliedSlash { + /// The stash ID of the offending validator. + validator: AccountId, + /// The validator's own slash. + own: Balance, + /// All other slashed stakers and amounts. + others: Vec<(AccountId, Balance)>, + /// Reporters of the offence; bounty payout recipients. + reporters: Vec, + /// The amount of payout. + payout: Balance, } pub type BalanceOf = @@ -519,6 +600,14 @@ pub trait Trait: system::Trait { /// Number of eras that staked funds must remain bonded for. type BondingDuration: Get; + /// Number of eras that slashes are deferred by, after computation. This + /// should be less than the bonding duration. Set to 0 if slashes should be + /// applied immediately, without opportunity for intervention. + type SlashDeferDuration: Get; + + /// The origin which can cancel a deferred slash. Root can always do this. + type SlashCancelOrigin: EnsureOrigin; + /// Interface for interacting with a session module. type SessionInterface: self::SessionInterface; @@ -571,7 +660,10 @@ decl_storage! { pub Validators get(fn validators): linked_map T::AccountId => ValidatorPrefs>; /// The map from nominator stash key to the set of stash keys of all validators to nominate. - pub Nominators get(fn nominators): linked_map T::AccountId => Vec; + /// + /// NOTE: is private so that we can ensure upgraded before all typical accesses. + /// Direct storage APIs can still bypass this protection. + Nominators get(fn nominators): linked_map T::AccountId => Option>; /// Nominators for a particular account that is in action right now. You can't iterate /// through validators here, but you can find them in the Session module. @@ -609,12 +701,38 @@ decl_storage! { /// The rest of the slashed value is handled by the `Slash`. pub SlashRewardFraction get(fn slash_reward_fraction) config(): Perbill; + /// The amount of currency given to reporters of a slash event which was + /// canceled by extraordinary circumstances (e.g. governance). + pub CanceledSlashPayout get(fn canceled_payout) config(): BalanceOf; + + /// All unapplied slashes that are queued for later. + pub UnappliedSlashes: map EraIndex => Vec>>; + /// A mapping from still-bonded eras to the first session index of that era. BondedEras: Vec<(EraIndex, SessionIndex)>; - /// All slashes that have occurred in a given era. - EraSlashJournal get(fn era_slash_journal): - map EraIndex => Vec>>; + /// All slashing events on validators, mapped by era to the highest slash proportion + /// and slash value of the era. + ValidatorSlashInEra: + double_map EraIndex, twox_128(T::AccountId) => Option<(Perbill, BalanceOf)>; + + /// All slashing events on nominators, mapped by era to the highest slash value of the era. + NominatorSlashInEra: + double_map EraIndex, twox_128(T::AccountId) => Option>; + + /// Slashing spans for stash accounts. + SlashingSpans: map T::AccountId => Option; + + /// Records information about the maximum slash of a stash within a slashing span, + /// as well as how much reward has been paid out. + SpanSlash: + map (T::AccountId, slashing::SpanIndex) => slashing::SpanRecord>; + + /// The earliest era for which we have a pending, unapplied slash. + EarliestUnappliedSlash: Option; + + /// The version of storage for upgrade. + StorageVersion: u32; } add_extra_genesis { config(stakers): @@ -646,6 +764,8 @@ decl_storage! { }, _ => Ok(()) }; } + + StorageVersion::put(migration::CURRENT_VERSION); }); } } @@ -673,6 +793,10 @@ decl_module! { fn deposit_event() = default; + fn on_initialize() { + Self::ensure_storage_upgraded(); + } + fn on_finalize() { // Set the start of the first era. if !>::exists() { @@ -859,6 +983,8 @@ decl_module! { /// # #[weight = SimpleDispatchInfo::FixedNormal(750_000)] fn validate(origin, prefs: ValidatorPrefs>) { + Self::ensure_storage_upgraded(); + let controller = ensure_signed(origin)?; let ledger = Self::ledger(&controller).ok_or("not a controller")?; let stash = &ledger.stash; @@ -879,6 +1005,8 @@ decl_module! { /// # #[weight = SimpleDispatchInfo::FixedNormal(750_000)] fn nominate(origin, targets: Vec<::Source>) { + Self::ensure_storage_upgraded(); + let controller = ensure_signed(origin)?; let ledger = Self::ledger(&controller).ok_or("not a controller")?; let stash = &ledger.stash; @@ -888,8 +1016,14 @@ decl_module! { .map(|t| T::Lookup::lookup(t)) .collect::, _>>()?; + let nominations = Nominations { + targets, + submitted_in: Self::current_era(), + suppressed: false, + }; + >::remove(stash); - >::insert(stash, targets); + >::insert(stash, &nominations); } /// Declare no desire to either validate or nominate. @@ -907,9 +1041,7 @@ decl_module! { fn chill(origin) { let controller = ensure_signed(origin)?; let ledger = Self::ledger(&controller).ok_or("not a controller")?; - let stash = &ledger.stash; - >::remove(stash); - >::remove(stash); + Self::chill_stash(&ledger.stash); } /// (Re-)set the payment target for a controller. @@ -1018,14 +1150,48 @@ decl_module! { ensure_root(origin)?; ForceEra::put(Forcing::ForceAlways); } + + /// Cancel enactment of a deferred slash. Can be called by either the root origin or + /// the `T::SlashCancelOrigin`. + /// passing the era and indices of the slashes for that era to kill. + /// + /// # + /// - One storage write. + /// # + #[weight = SimpleDispatchInfo::FreeOperational] + fn cancel_deferred_slash(origin, era: EraIndex, slash_indices: Vec) { + T::SlashCancelOrigin::try_origin(origin) + .map(|_| ()) + .or_else(ensure_root) + .map_err(|_| "bad origin")?; + + let mut slash_indices = slash_indices; + slash_indices.sort_unstable(); + let mut unapplied = ::UnappliedSlashes::get(&era); + + for (removed, index) in slash_indices.into_iter().enumerate() { + let index = index as usize; + + // if `index` is not duplicate, `removed` must be <= index. + ensure!(removed <= index, "duplicate index"); + + // all prior removals were from before this index, since the + // list is sorted. + let index = index - removed; + ensure!(index < unapplied.len(), "slash record index out of bounds"); + + unapplied.remove(index); + } + + ::UnappliedSlashes::insert(&era, &unapplied); + } } } impl Module { // PUBLIC IMMUTABLES - /// The total balance that can be slashed from a validator controller account as of - /// right now. + /// The total balance that can be slashed from a stash account as of right now. pub fn slashable_balance_of(stash: &T::AccountId) -> BalanceOf { Self::bonded(stash).and_then(Self::ledger).map(|l| l.active).unwrap_or_default() } @@ -1048,67 +1214,15 @@ impl Module { >::insert(controller, ledger); } - /// Slash a given validator by a specific amount with given (historical) exposure. - /// - /// Removes the slash from the validator's balance by preference, - /// and reduces the nominators' balance if needed. - /// - /// Returns the resulting `NegativeImbalance` to allow distributing the slashed amount and - /// pushes an entry onto the slash journal. - fn slash_validator( - stash: &T::AccountId, - slash: BalanceOf, - exposure: &Exposure>, - journal: &mut Vec>>, - ) -> NegativeImbalanceOf { - // The amount we are actually going to slash (can't be bigger than the validator's total - // exposure) - let slash = slash.min(exposure.total); - - // limit what we'll slash of the stash's own to only what's in - // the exposure. - // - // note: this is fine only because we limit reports of the current era. - // otherwise, these funds may have already been slashed due to something - // reported from a prior era. - let already_slashed_own = journal.iter() - .filter(|entry| &entry.who == stash) - .map(|entry| entry.own_slash) - .fold(>::zero(), |a, c| a.saturating_add(c)); - - let own_remaining = exposure.own.saturating_sub(already_slashed_own); - - // The amount we'll slash from the validator's stash directly. - let own_slash = own_remaining.min(slash); - let (mut imbalance, missing) = T::Currency::slash(stash, own_slash); - let own_slash = own_slash - missing; - // The amount remaining that we can't slash from the validator, - // that must be taken from the nominators. - let rest_slash = slash - own_slash; - if !rest_slash.is_zero() { - // The total to be slashed from the nominators. - let total = exposure.total - exposure.own; - if !total.is_zero() { - for i in exposure.others.iter() { - let per_u64 = Perbill::from_rational_approximation(i.value, total); - // best effort - not much that can be done on fail. - imbalance.subsume(T::Currency::slash(&i.who, per_u64 * rest_slash).0) - } - } - } - - journal.push(SlashJournalEntry { - who: stash.clone(), - own_slash: own_slash.clone(), - amount: slash, - }); - - // trigger the event - Self::deposit_event( - RawEvent::Slash(stash.clone(), slash) - ); + /// Chill a stash account. + fn chill_stash(stash: &T::AccountId) { + >::remove(stash); + >::remove(stash); + } - imbalance + /// Ensures storage is upgraded to most recent necessary state. + fn ensure_storage_upgraded() { + migration::perform_migrations::(); } /// Actually make a payment to a staker. This uses the currency's reward function @@ -1229,41 +1343,61 @@ impl Module { // Increment current era. let current_era = CurrentEra::mutate(|s| { *s += 1; *s }); - // prune journal for last era. - >::remove(current_era - 1); - CurrentEraStartSessionIndex::mutate(|v| { *v = start_session_index; }); let bonding_duration = T::BondingDuration::get(); - if current_era > bonding_duration { - let first_kept = current_era - bonding_duration; - BondedEras::mutate(|bonded| { - bonded.push((current_era, start_session_index)); + BondedEras::mutate(|bonded| { + bonded.push((current_era, start_session_index)); + + if current_era > bonding_duration { + let first_kept = current_era - bonding_duration; // prune out everything that's from before the first-kept index. let n_to_prune = bonded.iter() .take_while(|&&(era_idx, _)| era_idx < first_kept) .count(); - bonded.drain(..n_to_prune); + // kill slashing metadata. + for (pruned_era, _) in bonded.drain(..n_to_prune) { + slashing::clear_era_metadata::(pruned_era); + } if let Some(&(_, first_session)) = bonded.first() { T::SessionInterface::prune_historical_up_to(first_session); } - }) - } + } + }); // Reassign all Stakers. let (_slot_stake, maybe_new_validators) = Self::select_validators(); + Self::apply_unapplied_slashes(current_era); maybe_new_validators } + /// Apply previously-unapplied slashes on the beginning of a new era, after a delay. + fn apply_unapplied_slashes(current_era: EraIndex) { + let slash_defer_duration = T::SlashDeferDuration::get(); + ::EarliestUnappliedSlash::mutate(|earliest| if let Some(ref mut earliest) = earliest { + let keep_from = current_era.saturating_sub(slash_defer_duration); + for era in (*earliest)..keep_from { + let era_slashes = ::UnappliedSlashes::take(&era); + for slash in era_slashes { + slashing::apply_slash::(slash); + } + } + + *earliest = (*earliest).max(keep_from) + }) + } + /// Select a new validator set from the assembled stakers and their role preferences. /// /// Returns the new `SlotStake` value and a set of newly selected _stash_ IDs. + /// + /// Assumes storage is coherent with the declaration. fn select_validators() -> (BalanceOf, Option>) { let mut all_nominators: Vec<(T::AccountId, Vec)> = Vec::new(); let all_validator_candidates_iter = >::enumerate(); @@ -1272,9 +1406,24 @@ impl Module { all_nominators.push(self_vote); who }).collect::>(); - all_nominators.extend(>::enumerate()); - let maybe_phragmen_result = elect::<_, _, _, T::CurrencyToVote>( + let nominator_votes = >::enumerate().map(|(nominator, nominations)| { + let Nominations { submitted_in, mut targets, suppressed: _ } = nominations; + + // Filter out nomination targets which were nominated before the most recent + // slashing span. + targets.retain(|stash| { + ::SlashingSpans::get(&stash).map_or( + true, + |spans| submitted_in >= spans.last_start(), + ) + }); + + (nominator, targets) + }); + all_nominators.extend(nominator_votes); + + let maybe_phragmen_result = phragmen::elect::<_, _, _, T::CurrencyToVote>( Self::validator_count() as usize, Self::minimum_validator_count().max(1) as usize, all_validators, @@ -1293,7 +1442,7 @@ impl Module { let to_balance = |e: ExtendedBalance| >>::convert(e); - let mut supports = build_support_map::<_, _, _, T::CurrencyToVote>( + let mut supports = phragmen::build_support_map::<_, _, _, T::CurrencyToVote>( &elected_stashes, &assignments, Self::slashable_balance_of, @@ -1324,7 +1473,7 @@ impl Module { let tolerance = 0_u128; let iterations = 2_usize; - equalize::<_, _, T::CurrencyToVote, _>( + phragmen::equalize::<_, _, T::CurrencyToVote, _>( staked_assignments, &mut supports, tolerance, @@ -1384,6 +1533,8 @@ impl Module { /// Remove all associated data of a stash account from the staking system. /// + /// Assumes storage is upgraded before calling. + /// /// This is called : /// - Immediately when an account's balance falls below existential deposit. /// - after a `withdraw_unbond()` call that frees all of a stash's bonded balance. @@ -1394,6 +1545,8 @@ impl Module { >::remove(stash); >::remove(stash); >::remove(stash); + + slashing::clear_stash_metadata::(stash); } /// Add reward points to validators using their stash account ID. @@ -1449,6 +1602,7 @@ impl Module { impl session::OnSessionEnding for Module { fn on_session_ending(_ending: SessionIndex, start_session: SessionIndex) -> Option> { + Self::ensure_storage_upgraded(); Self::new_session(start_session - 1).map(|(new, _old)| new) } } @@ -1457,12 +1611,14 @@ impl OnSessionEnding fn on_session_ending(_ending: SessionIndex, start_session: SessionIndex) -> Option<(Vec, Vec<(T::AccountId, Exposure>)>)> { + Self::ensure_storage_upgraded(); Self::new_session(start_session - 1) } } impl OnFreeBalanceZero for Module { fn on_free_balance_zero(stash: &T::AccountId) { + Self::ensure_storage_upgraded(); Self::kill_stash(stash); } } @@ -1526,12 +1682,37 @@ impl OnOffenceHandler>], slash_fraction: &[Perbill], + slash_session: SessionIndex, ) { - let mut remaining_imbalance = >::zero(); - let slash_reward_fraction = SlashRewardFraction::get(); + >::ensure_storage_upgraded(); + + let reward_proportion = SlashRewardFraction::get(); let era_now = Self::current_era(); - let mut journal = Self::era_slash_journal(era_now); + let window_start = era_now.saturating_sub(T::BondingDuration::get()); + let current_era_start_session = CurrentEraStartSessionIndex::get(); + + // fast path for current-era report - most likely. + let slash_era = if slash_session >= current_era_start_session { + era_now + } else { + let eras = BondedEras::get(); + + // reverse because it's more likely to find reports from recent eras. + match eras.iter().rev().filter(|&&(_, ref sesh)| sesh <= &slash_session).next() { + None => return, // before bonding period. defensive - should be filtered out. + Some(&(ref slash_era, _)) => *slash_era, + } + }; + + ::EarliestUnappliedSlash::mutate(|earliest| { + if earliest.is_none() { + *earliest = Some(era_now) + } + }); + + let slash_defer_duration = T::SlashDeferDuration::get(); + for (details, slash_fraction) in offenders.iter().zip(slash_fraction) { let stash = &details.offender.0; let exposure = &details.offender.1; @@ -1541,57 +1722,34 @@ impl OnOffenceHandler>::exists(stash) { - >::remove(stash); - Self::ensure_new_era(); - } - - // calculate the amount to slash - let slash_exposure = exposure.total; - let amount = *slash_fraction * slash_exposure; - // in some cases `slash_fraction` can be just `0`, - // which means we are not slashing this time. - if amount.is_zero() { - continue; - } - - // make sure to disable validator till the end of this session - if T::SessionInterface::disable_validator(stash).unwrap_or(false) { - // force a new era, to select a new validator set - Self::ensure_new_era(); - } - // actually slash the validator - let slashed_amount = Self::slash_validator(stash, amount, exposure, &mut journal); - - // distribute the rewards according to the slash - let slash_reward = slash_reward_fraction * slashed_amount.peek(); - if !slash_reward.is_zero() && !details.reporters.is_empty() { - let (mut reward, rest) = slashed_amount.split(slash_reward); - // split the reward between reporters equally. Division cannot fail because - // we guarded against it in the enclosing if. - let per_reporter = reward.peek() / (details.reporters.len() as u32).into(); - for reporter in &details.reporters { - let (reporter_reward, rest) = reward.split(per_reporter); - reward = rest; - T::Currency::resolve_creating(reporter, reporter_reward); + let unapplied = slashing::compute_slash::(slashing::SlashParams { + stash, + slash: *slash_fraction, + exposure, + slash_era, + window_start, + now: era_now, + reward_proportion, + }); + + if let Some(mut unapplied) = unapplied { + unapplied.reporters = details.reporters.clone(); + if slash_defer_duration == 0 { + // apply right away. + slashing::apply_slash::(unapplied); + } else { + // defer to end of some `slash_defer_duration` from now. + ::UnappliedSlashes::mutate( + era_now, + move |for_later| for_later.push(unapplied), + ); } - // The rest goes to the treasury. - remaining_imbalance.subsume(reward); - remaining_imbalance.subsume(rest); - } else { - remaining_imbalance.subsume(slashed_amount); } } - >::insert(era_now, journal); - - // Handle the rest of imbalances - T::Slash::on_unbalanced(remaining_imbalance); } } -/// Filter historical offences out and only allow those from the current era. +/// Filter historical offences out and only allow those from the bonding period. pub struct FilterHistoricalOffences { _inner: rstd::marker::PhantomData<(T, R)>, } @@ -1603,9 +1761,13 @@ impl ReportOffence O: Offence, { fn report_offence(reporters: Vec, offence: O) { - // disallow any slashing from before the current era. + >::ensure_storage_upgraded(); + + // disallow any slashing from before the current bonding period. let offence_session = offence.session_index(); - if offence_session >= >::current_era_start_session_index() { + let bonded_eras = BondedEras::get(); + + if bonded_eras.first().filter(|(_, start)| offence_session >= *start).is_some() { R::report_offence(reporters, offence) } else { >::deposit_event( diff --git a/frame/staking/src/migration.rs b/frame/staking/src/migration.rs new file mode 100644 index 0000000000..e89c6af1b9 --- /dev/null +++ b/frame/staking/src/migration.rs @@ -0,0 +1,88 @@ +// Copyright 2019 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Substrate is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Substrate. If not, see . + +//! Storage migrations for srml-staking. + +/// Indicator of a version of a storage layout. +pub type VersionNumber = u32; + +// the current expected version of the storage +pub const CURRENT_VERSION: VersionNumber = 1; + +#[cfg(any(test, feature = "migrate"))] +mod inner { + use crate::{Store, Module, Trait}; + use support::{StorageLinkedMap, StorageValue}; + use rstd::vec::Vec; + use super::{CURRENT_VERSION, VersionNumber}; + + // the minimum supported version of the migration logic. + const MIN_SUPPORTED_VERSION: VersionNumber = 0; + + // migrate storage from v0 to v1. + // + // this upgrades the `Nominators` linked_map value type from `Vec` to + // `Option>` + pub fn to_v1(version: &mut VersionNumber) { + if *version != 0 { return } + *version += 1; + + let now = >::current_era(); + let res = as Store>::Nominators::translate::, _, _>( + |key| key, + |targets| crate::Nominations { + targets, + submitted_in: now, + suppressed: false, + }, + ); + + if let Err(e) = res { + support::print("Encountered error in migration of Staking::Nominators map."); + if e.is_none() { + support::print("Staking::Nominators map reinitialized"); + } + } + + support::print("Finished migrating Staking storage to v1."); + } + + pub(super) fn perform_migrations() { + as Store>::StorageVersion::mutate(|version| { + if *version < MIN_SUPPORTED_VERSION { + support::print("Cannot migrate staking storage because version is less than\ + minimum."); + support::print(*version); + return + } + + if *version == CURRENT_VERSION { return } + + to_v1::(version); + }); + } +} + +#[cfg(not(any(test, feature = "migrate")))] +mod inner { + pub(super) fn perform_migrations() { } +} + +/// Perform all necessary storage migrations to get storage into the expected stsate for current +/// logic. No-op if fully upgraded. +pub(crate) fn perform_migrations() { + inner::perform_migrations::(); +} diff --git a/frame/staking/src/mock.rs b/frame/staking/src/mock.rs index c2a0745983..f6068a4773 100644 --- a/frame/staking/src/mock.rs +++ b/frame/staking/src/mock.rs @@ -21,10 +21,10 @@ use sr_primitives::{Perbill, KeyTypeId}; use sr_primitives::curve::PiecewiseLinear; use sr_primitives::traits::{IdentityLookup, Convert, OpaqueKeys, OnInitialize, SaturatedConversion}; use sr_primitives::testing::{Header, UintAuthorityId}; -use sr_staking_primitives::SessionIndex; +use sr_staking_primitives::{SessionIndex, offence::{OffenceDetails, OnOffenceHandler}}; use primitives::{H256, crypto::key_types}; use runtime_io; -use support::{assert_ok, impl_outer_origin, parameter_types, StorageLinkedMap}; +use support::{assert_ok, impl_outer_origin, parameter_types, StorageLinkedMap, StorageValue}; use support::traits::{Currency, Get, FindAuthor}; use crate::{ EraIndex, GenesisConfig, Module, Trait, StakerStatus, ValidatorPrefs, RewardDestination, @@ -48,6 +48,7 @@ impl Convert for CurrencyToVoteHandler { thread_local! { static SESSION: RefCell<(Vec, HashSet)> = RefCell::new(Default::default()); static EXISTENTIAL_DEPOSIT: RefCell = RefCell::new(0); + static SLASH_DEFER_DURATION: RefCell = RefCell::new(0); } pub struct TestSessionHandler; @@ -87,6 +88,13 @@ impl Get for ExistentialDeposit { } } +pub struct SlashDeferDuration; +impl Get for SlashDeferDuration { + fn get() -> EraIndex { + SLASH_DEFER_DURATION.with(|v| *v.borrow()) + } +} + impl_outer_origin!{ pub enum Origin for Test {} } @@ -202,6 +210,8 @@ impl Trait for Test { type Slash = (); type Reward = (); type SessionsPerEra = SessionsPerEra; + type SlashDeferDuration = SlashDeferDuration; + type SlashCancelOrigin = system::EnsureRoot; type BondingDuration = BondingDuration; type SessionInterface = Self; type RewardCurve = RewardCurve; @@ -213,6 +223,7 @@ pub struct ExtBuilder { nominate: bool, validator_count: u32, minimum_validator_count: u32, + slash_defer_duration: EraIndex, fair: bool, num_validators: Option, invulnerables: Vec, @@ -226,6 +237,7 @@ impl Default for ExtBuilder { nominate: true, validator_count: 2, minimum_validator_count: 0, + slash_defer_duration: 0, fair: true, num_validators: None, invulnerables: vec![], @@ -254,6 +266,10 @@ impl ExtBuilder { self.minimum_validator_count = count; self } + pub fn slash_defer_duration(mut self, eras: EraIndex) -> Self { + self.slash_defer_duration = eras; + self + } pub fn fair(mut self, is_fair: bool) -> Self { self.fair = is_fair; self @@ -268,6 +284,7 @@ impl ExtBuilder { } pub fn set_associated_consts(&self) { 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 { self.set_associated_consts(); @@ -393,6 +410,14 @@ pub fn assert_is_stash(acc: u64) { assert!(Staking::bonded(&acc).is_some(), "Not a stash."); } +pub fn assert_ledger_consistent(stash: u64) { + assert_is_stash(stash); + let ledger = Staking::ledger(stash - 1).unwrap(); + + let real_total: Balance = ledger.unlocking.iter().fold(ledger.active, |a, c| a + c.value); + assert_eq!(real_total, ledger.total); +} + pub fn bond_validator(acc: u64, val: u64) { // a = controller // a + 1 = stash @@ -451,3 +476,33 @@ pub fn reward_all_elected() { pub fn validator_controllers() -> Vec { Session::validators().into_iter().map(|s| Staking::bonded(&s).expect("no controller for validator")).collect() } + +pub fn on_offence_in_era( + offenders: &[OffenceDetails>], + slash_fraction: &[Perbill], + era: EraIndex, +) { + let bonded_eras = crate::BondedEras::get(); + for &(bonded_era, start_session) in bonded_eras.iter() { + if bonded_era == era { + Staking::on_offence(offenders, slash_fraction, start_session); + return + } else if bonded_era > era { + break + } + } + + if Staking::current_era() == era { + Staking::on_offence(offenders, slash_fraction, Staking::current_era_start_session_index()); + } else { + panic!("cannot slash in era {}", era); + } +} + +pub fn on_offence_now( + offenders: &[OffenceDetails>], + slash_fraction: &[Perbill], +) { + let now = Staking::current_era(); + on_offence_in_era(offenders, slash_fraction, now) +} diff --git a/frame/staking/src/slashing.rs b/frame/staking/src/slashing.rs new file mode 100644 index 0000000000..23315a670a --- /dev/null +++ b/frame/staking/src/slashing.rs @@ -0,0 +1,824 @@ +// Copyright 2019 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Substrate is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Substrate. If not, see . + +//! A slashing implementation for NPoS systems. +//! +//! For the purposes of the economic model, it is easiest to think of each validator +//! of a nominator which nominates only its own identity. +//! +//! The act of nomination signals intent to unify economic identity with the validator - to take part in the +//! rewards of a job well done, and to take part in the punishment of a job done badly. +//! +//! There are 3 main difficulties to account for with slashing in NPoS: +//! - A nominator can nominate multiple validators and be slashed via any of them. +//! - Until slashed, stake is reused from era to era. Nominating with N coins for E eras in a row +//! does not mean you have N*E coins to be slashed - you've only ever had N. +//! - Slashable offences can be found after the fact and out of order. +//! +//! The algorithm implemented in this module tries to balance these 3 difficulties. +//! +//! First, we only slash participants for the _maximum_ slash they receive in some time period, +//! rather than the sum. This ensures a protection from overslashing. +//! +//! Second, we do not want the time period (or "span") that the maximum is computed +//! over to last indefinitely. That would allow participants to begin acting with +//! impunity after some point, fearing no further repercussions. For that reason, we +//! automatically "chill" validators and withdraw a nominator's nomination after a slashing event, +//! requiring them to re-enlist voluntarily (acknowledging the slash) and begin a new +//! slashing span. +//! +//! Typically, you will have a single slashing event per slashing span. Only in the case +//! where a validator releases many misbehaviors at once, or goes "back in time" to misbehave in +//! eras that have already passed, would you encounter situations where a slashing span +//! has multiple misbehaviors. However, accounting for such cases is necessary +//! to deter a class of "rage-quit" attacks. +//! +//! Based on research at https://research.web3.foundation/en/latest/polkadot/slashing/npos/ + +use super::{ + EraIndex, Trait, Module, Store, BalanceOf, Exposure, Perbill, SessionInterface, + NegativeImbalanceOf, UnappliedSlash, +}; +use sr_primitives::traits::{Zero, Saturating}; +use support::{ + StorageMap, StorageDoubleMap, + traits::{Currency, OnUnbalanced, Imbalance}, +}; +use rstd::vec::Vec; +use codec::{Encode, Decode}; + +/// The proportion of the slashing reward to be paid out on the first slashing detection. +/// This is f_1 in the paper. +const REWARD_F1: Perbill = Perbill::from_percent(50); + +/// The index of a slashing span - unique to each stash. +pub(crate) type SpanIndex = u32; + +// A range of start..end eras for a slashing span. +#[derive(Encode, Decode)] +#[cfg_attr(test, derive(Debug, PartialEq))] +pub(crate) struct SlashingSpan { + pub(crate) index: SpanIndex, + pub(crate) start: EraIndex, + pub(crate) length: Option, // the ongoing slashing span has indeterminate length. +} + +impl SlashingSpan { + fn contains_era(&self, era: EraIndex) -> bool { + self.start <= era && self.length.map_or(true, |l| self.start + l > era) + } +} + +/// An encoding of all of a nominator's slashing spans. +#[derive(Encode, Decode)] +pub struct SlashingSpans { + // the index of the current slashing span of the nominator. different for + // every stash, resets when the account hits free balance 0. + span_index: SpanIndex, + // the start era of the most recent (ongoing) slashing span. + last_start: EraIndex, + // all prior slashing spans start indices, in reverse order (most recent first) + // encoded as offsets relative to the slashing span after it. + prior: Vec, +} + +impl SlashingSpans { + // creates a new record of slashing spans for a stash, starting at the beginning + // of the bonding period, relative to now. + fn new(window_start: EraIndex) -> Self { + SlashingSpans { + span_index: 0, + last_start: window_start, + prior: Vec::new(), + } + } + + // update the slashing spans to reflect the start of a new span at the era after `now` + // returns `true` if a new span was started, `false` otherwise. `false` indicates + // that internal state is unchanged. + fn end_span(&mut self, now: EraIndex) -> bool { + let next_start = now + 1; + if next_start <= self.last_start { return false } + + let last_length = next_start - self.last_start; + self.prior.insert(0, last_length); + self.last_start = next_start; + self.span_index += 1; + true + } + + // an iterator over all slashing spans in _reverse_ order - most recent first. + pub(crate) fn iter(&'_ self) -> impl Iterator + '_ { + let mut last_start = self.last_start; + let mut index = self.span_index; + let last = SlashingSpan { index, start: last_start, length: None }; + let prior = self.prior.iter().cloned().map(move |length| { + let start = last_start - length; + last_start = start; + index -= 1; + + SlashingSpan { index, start, length: Some(length) } + }); + + rstd::iter::once(last).chain(prior) + } + + /// Yields the era index where the last (current) slashing span started. + pub(crate) fn last_start(&self) -> EraIndex { + self.last_start + } + + // prune the slashing spans against a window, whose start era index is given. + // + // If this returns `Some`, then it includes a range start..end of all the span + // indices which were pruned. + fn prune(&mut self, window_start: EraIndex) -> Option<(SpanIndex, SpanIndex)> { + let old_idx = self.iter() + .skip(1) // skip ongoing span. + .position(|span| span.length.map_or(false, |len| span.start + len <= window_start)); + + let earliest_span_index = self.span_index - self.prior.len() as SpanIndex; + let pruned = match old_idx { + Some(o) => { + self.prior.truncate(o); + let new_earliest = self.span_index - self.prior.len() as SpanIndex; + Some((earliest_span_index, new_earliest)) + } + None => None, + }; + + // readjust the ongoing span, if it started before the beginning of the window. + self.last_start = rstd::cmp::max(self.last_start, window_start); + pruned + } +} + +/// A slashing-span record for a particular stash. +#[derive(Encode, Decode, Default)] +pub(crate) struct SpanRecord { + slashed: Balance, + paid_out: Balance, +} + +impl SpanRecord { + /// The value of stash balance slashed in this span. + #[cfg(test)] + pub(crate) fn amount_slashed(&self) -> &Balance { + &self.slashed + } +} + +/// Parameters for performing a slash. +#[derive(Clone)] +pub(crate) struct SlashParams<'a, T: 'a + Trait> { + /// The stash account being slashed. + pub(crate) stash: &'a T::AccountId, + /// The proportion of the slash. + pub(crate) slash: Perbill, + /// The exposure of the stash and all nominators. + pub(crate) exposure: &'a Exposure>, + /// The era where the offence occurred. + pub(crate) slash_era: EraIndex, + /// The first era in the current bonding period. + pub(crate) window_start: EraIndex, + /// The current era. + pub(crate) now: EraIndex, + /// The maximum percentage of a slash that ever gets paid out. + /// This is f_inf in the paper. + pub(crate) reward_proportion: Perbill, +} + +/// Computes a slash of a validator and nominators. It returns an unapplied +/// record to be applied at some later point. Slashing metadata is updated in storage, +/// since unapplied records are only rarely intended to be dropped. +/// +/// The pending slash record returned does not have initialized reporters. Those have +/// to be set at a higher level, if any. +pub(crate) fn compute_slash(params: SlashParams) + -> Option>> +{ + let SlashParams { + stash, + slash, + exposure, + slash_era, + window_start, + now, + reward_proportion, + } = params.clone(); + + let mut reward_payout = Zero::zero(); + let mut val_slashed = Zero::zero(); + + // is the slash amount here a maximum for the era? + let own_slash = slash * exposure.own; + if slash * exposure.total == Zero::zero() { + // kick out the validator even if they won't be slashed, + // as long as the misbehavior is from their most recent slashing span. + kick_out_if_recent::(params); + return None; + } + + let (prior_slash_p, _era_slash) = as Store>::ValidatorSlashInEra::get( + &slash_era, + stash, + ).unwrap_or((Perbill::zero(), Zero::zero())); + + // compare slash proportions rather than slash values to avoid issues due to rounding + // error. + if slash.deconstruct() > prior_slash_p.deconstruct() { + as Store>::ValidatorSlashInEra::insert( + &slash_era, + stash, + &(slash, own_slash), + ); + } else { + // we slash based on the max in era - this new event is not the max, + // so neither the validator or any nominators will need an update. + // + // this does lead to a divergence of our system from the paper, which + // pays out some reward even if the latest report is not max-in-era. + // we opt to avoid the nominator lookups and edits and leave more rewards + // for more drastic misbehavior. + return None; + } + + // apply slash to validator. + { + let mut spans = fetch_spans::( + stash, + window_start, + &mut reward_payout, + &mut val_slashed, + reward_proportion, + ); + + let target_span = spans.compare_and_update_span_slash( + slash_era, + own_slash, + ); + + if target_span == Some(spans.span_index()) { + // misbehavior occurred within the current slashing span - take appropriate + // actions. + + // chill the validator - it misbehaved in the current span and should + // not continue in the next election. also end the slashing span. + spans.end_span(now); + >::chill_stash(stash); + + // make sure to disable validator till the end of this session + if T::SessionInterface::disable_validator(stash).unwrap_or(false) { + // force a new era, to select a new validator set + >::ensure_new_era() + } + } + } + + let mut nominators_slashed = Vec::new(); + reward_payout += slash_nominators::(params, prior_slash_p, &mut nominators_slashed); + + Some(UnappliedSlash { + validator: stash.clone(), + own: val_slashed, + others: nominators_slashed, + reporters: Vec::new(), + payout: reward_payout, + }) +} + +// doesn't apply any slash, but kicks out the validator if the misbehavior is from +// the most recent slashing span. +fn kick_out_if_recent( + params: SlashParams, +) { + // these are not updated by era-span or end-span. + let mut reward_payout = Zero::zero(); + let mut val_slashed = Zero::zero(); + let mut spans = fetch_spans::( + params.stash, + params.window_start, + &mut reward_payout, + &mut val_slashed, + params.reward_proportion, + ); + + if spans.era_span(params.slash_era).map(|s| s.index) == Some(spans.span_index()) { + spans.end_span(params.now); + >::chill_stash(params.stash); + + // make sure to disable validator till the end of this session + if T::SessionInterface::disable_validator(params.stash).unwrap_or(false) { + // force a new era, to select a new validator set + >::ensure_new_era() + } + } +} + +/// Slash nominators. Accepts general parameters and the prior slash percentage of the validator. +/// +/// Returns the amount of reward to pay out. +fn slash_nominators( + params: SlashParams, + prior_slash_p: Perbill, + nominators_slashed: &mut Vec<(T::AccountId, BalanceOf)>, +) -> BalanceOf { + let SlashParams { + stash: _, + slash, + exposure, + slash_era, + window_start, + now, + reward_proportion, + } = params; + + let mut reward_payout = Zero::zero(); + + nominators_slashed.reserve(exposure.others.len()); + for nominator in &exposure.others { + let stash = &nominator.who; + let mut nom_slashed = Zero::zero(); + + // the era slash of a nominator always grows, if the validator + // had a new max slash for the era. + let era_slash = { + let own_slash_prior = prior_slash_p * nominator.value; + let own_slash_by_validator = slash * nominator.value; + let own_slash_difference = own_slash_by_validator.saturating_sub(own_slash_prior); + + let mut era_slash = as Store>::NominatorSlashInEra::get( + &slash_era, + stash, + ).unwrap_or(Zero::zero()); + + era_slash += own_slash_difference; + + as Store>::NominatorSlashInEra::insert( + &slash_era, + stash, + &era_slash, + ); + + era_slash + }; + + // compare the era slash against other eras in the same span. + { + let mut spans = fetch_spans::( + stash, + window_start, + &mut reward_payout, + &mut nom_slashed, + reward_proportion, + ); + + let target_span = spans.compare_and_update_span_slash( + slash_era, + era_slash, + ); + + if target_span == Some(spans.span_index()) { + // Chill the nominator outright, ending the slashing span. + spans.end_span(now); + >::chill_stash(stash); + } + } + + nominators_slashed.push((stash.clone(), nom_slashed)); + } + + reward_payout +} + +// helper struct for managing a set of spans we are currently inspecting. +// writes alterations to disk on drop, but only if a slash has been carried out. +// +// NOTE: alterations to slashing metadata should not be done after this is dropped. +// dropping this struct applies any necessary slashes, which can lead to free balance +// being 0, and the account being garbage-collected -- a dead account should get no new +// metadata. +struct InspectingSpans<'a, T: Trait + 'a> { + dirty: bool, + window_start: EraIndex, + stash: &'a T::AccountId, + spans: SlashingSpans, + paid_out: &'a mut BalanceOf, + slash_of: &'a mut BalanceOf, + reward_proportion: Perbill, + _marker: rstd::marker::PhantomData, +} + +// fetches the slashing spans record for a stash account, initializing it if necessary. +fn fetch_spans<'a, T: Trait + 'a>( + stash: &'a T::AccountId, + window_start: EraIndex, + paid_out: &'a mut BalanceOf, + slash_of: &'a mut BalanceOf, + reward_proportion: Perbill, +) -> InspectingSpans<'a, T> { + let spans = as Store>::SlashingSpans::get(stash).unwrap_or_else(|| { + let spans = SlashingSpans::new(window_start); + as Store>::SlashingSpans::insert(stash, &spans); + spans + }); + + InspectingSpans { + dirty: false, + window_start, + stash, + spans, + slash_of, + paid_out, + reward_proportion, + _marker: rstd::marker::PhantomData, + } +} + +impl<'a, T: 'a + Trait> InspectingSpans<'a, T> { + fn span_index(&self) -> SpanIndex { + self.spans.span_index + } + + fn end_span(&mut self, now: EraIndex) { + self.dirty = self.spans.end_span(now) || self.dirty; + } + + fn add_slash(&mut self, amount: BalanceOf) { + *self.slash_of += amount; + } + + // find the span index of the given era, if covered. + fn era_span(&self, era: EraIndex) -> Option { + self.spans.iter().find(|span| span.contains_era(era)) + } + + // compares the slash in an era to the overall current span slash. + // if it's higher, applies the difference of the slashes and then updates the span on disk. + // + // returns the span index of the era where the slash occurred, if any. + fn compare_and_update_span_slash( + &mut self, + slash_era: EraIndex, + slash: BalanceOf, + ) -> Option { + let target_span = self.era_span(slash_era)?; + let span_slash_key = (self.stash.clone(), target_span.index); + let mut span_record = as Store>::SpanSlash::get(&span_slash_key); + let mut changed = false; + + let reward = if span_record.slashed < slash { + // new maximum span slash. apply the difference. + let difference = slash - span_record.slashed; + span_record.slashed = slash; + + // compute reward. + let reward = REWARD_F1 + * (self.reward_proportion * slash).saturating_sub(span_record.paid_out); + + self.add_slash(difference); + changed = true; + + reward + } else if span_record.slashed == slash { + // compute reward. no slash difference to apply. + REWARD_F1 * (self.reward_proportion * slash).saturating_sub(span_record.paid_out) + } else { + Zero::zero() + }; + + if !reward.is_zero() { + changed = true; + span_record.paid_out += reward; + *self.paid_out += reward; + } + + if changed { + self.dirty = true; + as Store>::SpanSlash::insert(&span_slash_key, &span_record); + } + + Some(target_span.index) + } +} + +impl<'a, T: 'a + Trait> Drop for InspectingSpans<'a, T> { + fn drop(&mut self) { + // only update on disk if we slashed this account. + if !self.dirty { return } + + if let Some((start, end)) = self.spans.prune(self.window_start) { + for span_index in start..end { + as Store>::SpanSlash::remove(&(self.stash.clone(), span_index)); + } + } + + as Store>::SlashingSpans::insert(self.stash, &self.spans); + } +} + +/// Clear slashing metadata for an obsolete era. +pub(crate) fn clear_era_metadata(obsolete_era: EraIndex) { + as Store>::ValidatorSlashInEra::remove_prefix(&obsolete_era); + as Store>::NominatorSlashInEra::remove_prefix(&obsolete_era); +} + +/// Clear slashing metadata for a dead account. +pub(crate) fn clear_stash_metadata(stash: &T::AccountId) { + let spans = match as Store>::SlashingSpans::take(stash) { + None => return, + Some(s) => s, + }; + + // kill slashing-span metadata for account. + // + // this can only happen while the account is staked _if_ they are completely slashed. + // in that case, they may re-bond, but it would count again as span 0. Further ancient + // slashes would slash into this new bond, since metadata has now been cleared. + for span in spans.iter() { + as Store>::SpanSlash::remove(&(stash.clone(), span.index)); + } +} + +// apply the slash to a stash account, deducting any missing funds from the reward +// payout, saturating at 0. this is mildly unfair but also an edge-case that +// can only occur when overlapping locked funds have been slashed. +fn do_slash( + stash: &T::AccountId, + value: BalanceOf, + reward_payout: &mut BalanceOf, + slashed_imbalance: &mut NegativeImbalanceOf, +) { + let controller = match >::bonded(stash) { + None => return, // defensive: should always exist. + Some(c) => c, + }; + + let mut ledger = match >::ledger(&controller) { + Some(ledger) => ledger, + None => return, // nothing to do. + }; + + let value = ledger.slash(value, T::Currency::minimum_balance()); + + if !value.is_zero() { + let (imbalance, missing) = T::Currency::slash(stash, value); + slashed_imbalance.subsume(imbalance); + + if !missing.is_zero() { + // deduct overslash from the reward payout + *reward_payout = reward_payout.saturating_sub(missing); + } + + >::update_ledger(&controller, &ledger); + + // trigger the event + >::deposit_event( + super::RawEvent::Slash(stash.clone(), value) + ); + } +} + +/// Apply a previously-unapplied slash. +pub(crate) fn apply_slash(unapplied_slash: UnappliedSlash>) { + let mut slashed_imbalance = NegativeImbalanceOf::::zero(); + let mut reward_payout = unapplied_slash.payout; + + do_slash::( + &unapplied_slash.validator, + unapplied_slash.own, + &mut reward_payout, + &mut slashed_imbalance, + ); + + for &(ref nominator, nominator_slash) in &unapplied_slash.others { + do_slash::( + &nominator, + nominator_slash, + &mut reward_payout, + &mut slashed_imbalance, + ); + } + + pay_reporters::(reward_payout, slashed_imbalance, &unapplied_slash.reporters); +} + + +/// Apply a reward payout to some reporters, paying the rewards out of the slashed imbalance. +fn pay_reporters( + reward_payout: BalanceOf, + slashed_imbalance: NegativeImbalanceOf, + reporters: &[T::AccountId], +) { + if reward_payout.is_zero() || reporters.is_empty() { + // nobody to pay out to or nothing to pay; + // just treat the whole value as slashed. + T::Slash::on_unbalanced(slashed_imbalance); + return + } + + // take rewards out of the slashed imbalance. + let reward_payout = reward_payout.min(slashed_imbalance.peek()); + let (mut reward_payout, mut value_slashed) = slashed_imbalance.split(reward_payout); + + let per_reporter = reward_payout.peek() / (reporters.len() as u32).into(); + for reporter in reporters { + let (reporter_reward, rest) = reward_payout.split(per_reporter); + reward_payout = rest; + + // this cancels out the reporter reward imbalance internally, leading + // to no change in total issuance. + T::Currency::resolve_creating(reporter, reporter_reward); + } + + // the rest goes to the on-slash imbalance handler (e.g. treasury) + value_slashed.subsume(reward_payout); // remainder of reward division remains. + T::Slash::on_unbalanced(value_slashed); +} + +// TODO: function for undoing a slash. +// + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn span_contains_era() { + // unbounded end + let span = SlashingSpan { index: 0, start: 1000, length: None }; + assert!(!span.contains_era(0)); + assert!(!span.contains_era(999)); + + assert!(span.contains_era(1000)); + assert!(span.contains_era(1001)); + assert!(span.contains_era(10000)); + + // bounded end - non-inclusive range. + let span = SlashingSpan { index: 0, start: 1000, length: Some(10) }; + assert!(!span.contains_era(0)); + assert!(!span.contains_era(999)); + + assert!(span.contains_era(1000)); + assert!(span.contains_era(1001)); + assert!(span.contains_era(1009)); + assert!(!span.contains_era(1010)); + assert!(!span.contains_era(1011)); + } + + #[test] + fn single_slashing_span() { + let spans = SlashingSpans { + span_index: 0, + last_start: 1000, + prior: Vec::new(), + }; + + assert_eq!( + spans.iter().collect::>(), + vec![SlashingSpan { index: 0, start: 1000, length: None }], + ); + } + + #[test] + fn many_prior_spans() { + let spans = SlashingSpans { + span_index: 10, + last_start: 1000, + prior: vec![10, 9, 8, 10], + }; + + assert_eq!( + spans.iter().collect::>(), + vec![ + SlashingSpan { index: 10, start: 1000, length: None }, + SlashingSpan { index: 9, start: 990, length: Some(10) }, + SlashingSpan { index: 8, start: 981, length: Some(9) }, + SlashingSpan { index: 7, start: 973, length: Some(8) }, + SlashingSpan { index: 6, start: 963, length: Some(10) }, + ], + ) + } + + #[test] + fn pruning_spans() { + let mut spans = SlashingSpans { + span_index: 10, + last_start: 1000, + prior: vec![10, 9, 8, 10], + }; + + assert_eq!(spans.prune(981), Some((6, 8))); + assert_eq!( + spans.iter().collect::>(), + vec![ + SlashingSpan { index: 10, start: 1000, length: None }, + SlashingSpan { index: 9, start: 990, length: Some(10) }, + SlashingSpan { index: 8, start: 981, length: Some(9) }, + ], + ); + + assert_eq!(spans.prune(982), None); + assert_eq!( + spans.iter().collect::>(), + vec![ + SlashingSpan { index: 10, start: 1000, length: None }, + SlashingSpan { index: 9, start: 990, length: Some(10) }, + SlashingSpan { index: 8, start: 981, length: Some(9) }, + ], + ); + + assert_eq!(spans.prune(989), None); + assert_eq!( + spans.iter().collect::>(), + vec![ + SlashingSpan { index: 10, start: 1000, length: None }, + SlashingSpan { index: 9, start: 990, length: Some(10) }, + SlashingSpan { index: 8, start: 981, length: Some(9) }, + ], + ); + + assert_eq!(spans.prune(1000), Some((8, 10))); + assert_eq!( + spans.iter().collect::>(), + vec![ + SlashingSpan { index: 10, start: 1000, length: None }, + ], + ); + + assert_eq!(spans.prune(2000), None); + assert_eq!( + spans.iter().collect::>(), + vec![ + SlashingSpan { index: 10, start: 2000, length: None }, + ], + ); + + // now all in one shot. + let mut spans = SlashingSpans { + span_index: 10, + last_start: 1000, + prior: vec![10, 9, 8, 10], + }; + assert_eq!(spans.prune(2000), Some((6, 10))); + assert_eq!( + spans.iter().collect::>(), + vec![ + SlashingSpan { index: 10, start: 2000, length: None }, + ], + ); + } + + #[test] + fn ending_span() { + let mut spans = SlashingSpans { + span_index: 1, + last_start: 10, + prior: Vec::new(), + }; + + assert!(spans.end_span(10)); + + assert_eq!( + spans.iter().collect::>(), + vec![ + SlashingSpan { index: 2, start: 11, length: None }, + SlashingSpan { index: 1, start: 10, length: Some(1) }, + ], + ); + + assert!(spans.end_span(15)); + assert_eq!( + spans.iter().collect::>(), + vec![ + SlashingSpan { index: 3, start: 16, length: None }, + SlashingSpan { index: 2, start: 11, length: Some(5) }, + SlashingSpan { index: 1, start: 10, length: Some(1) }, + ], + ); + + // does nothing if not a valid end. + assert!(!spans.end_span(15)); + assert_eq!( + spans.iter().collect::>(), + vec![ + SlashingSpan { index: 3, start: 16, length: None }, + SlashingSpan { index: 2, start: 11, length: Some(5) }, + SlashingSpan { index: 1, start: 10, length: Some(1) }, + ], + ); + } +} diff --git a/frame/staking/src/tests.rs b/frame/staking/src/tests.rs index 7c16091d06..7e1939e437 100644 --- a/frame/staking/src/tests.rs +++ b/frame/staking/src/tests.rs @@ -19,7 +19,7 @@ use super::*; use mock::*; use sr_primitives::{assert_eq_error_rate, traits::OnInitialize}; -use sr_staking_primitives::offence::{OffenceDetails, OnOffenceHandler}; +use sr_staking_primitives::offence::OffenceDetails; use support::{assert_ok, assert_noop, traits::{Currency, ReservableCurrency}}; use substrate_test_utils::assert_eq_uvec; @@ -80,7 +80,7 @@ fn basic_setup_works() { Staking::ledger(100), Some(StakingLedger { stash: 101, total: 500, active: 500, unlocking: vec![] }) ); - assert_eq!(Staking::nominators(101), vec![11, 21]); + assert_eq!(Staking::nominators(101).unwrap().targets, vec![11, 21]); if cfg!(feature = "equalize") { assert_eq!( @@ -638,7 +638,7 @@ fn nominators_also_get_slashed() { assert_eq!(Balances::total_balance(&2), initial_balance); // 10 goes offline - Staking::on_offence( + on_offence_now( &[OffenceDetails { offender: ( 11, @@ -1661,12 +1661,26 @@ fn reward_validator_slashing_validator_doesnt_overflow() { // Set staker let _ = Balances::make_free_balance_be(&11, stake); let _ = Balances::make_free_balance_be(&2, stake); + + // only slashes out of bonded stake are applied. without this line, + // it is 0. + Staking::bond(Origin::signed(2), 20000, stake - 1, RewardDestination::default()).unwrap(); >::insert(&11, Exposure { total: stake, own: 1, others: vec![ IndividualExposure { who: 2, value: stake - 1 } ]}); + // Check slashing - let _ = Staking::slash_validator(&11, reward_slash, &Staking::stakers(&11), &mut Vec::new()); + on_offence_now( + &[ + OffenceDetails { + offender: (11, Staking::stakers(&11)), + reporters: vec![], + }, + ], + &[Perbill::from_percent(100)], + ); + assert_eq!(Balances::total_balance(&11), stake - 1); assert_eq!(Balances::total_balance(&2), 1); }) @@ -1761,7 +1775,7 @@ fn era_is_always_same_length() { #[test] fn offence_forces_new_era() { ExtBuilder::default().build().execute_with(|| { - Staking::on_offence( + on_offence_now( &[OffenceDetails { offender: ( 11, @@ -1781,7 +1795,7 @@ fn offence_ensures_new_era_without_clobbering() { ExtBuilder::default().build().execute_with(|| { assert_ok!(Staking::force_new_era_always(Origin::ROOT)); - Staking::on_offence( + on_offence_now( &[OffenceDetails { offender: ( 11, @@ -1800,7 +1814,7 @@ fn offence_ensures_new_era_without_clobbering() { fn offence_deselects_validator_when_slash_is_zero() { ExtBuilder::default().build().execute_with(|| { assert!(>::exists(11)); - Staking::on_offence( + on_offence_now( &[OffenceDetails { offender: ( 11, @@ -1823,7 +1837,7 @@ fn slashing_performed_according_exposure() { assert_eq!(Staking::stakers(&11).own, 1000); // Handle an offence with a historical exposure. - Staking::on_offence( + on_offence_now( &[OffenceDetails { offender: ( 11, @@ -1843,6 +1857,71 @@ fn slashing_performed_according_exposure() { }); } +#[test] +fn slash_in_old_span_does_not_deselect() { + ExtBuilder::default().build().execute_with(|| { + start_era(1); + + assert!(>::exists(11)); + on_offence_now( + &[OffenceDetails { + offender: ( + 11, + Staking::stakers(&11), + ), + reporters: vec![], + }], + &[Perbill::from_percent(0)], + ); + assert_eq!(Staking::force_era(), Forcing::ForceNew); + assert!(!>::exists(11)); + + start_era(2); + + Staking::validate(Origin::signed(10), Default::default()).unwrap(); + assert_eq!(Staking::force_era(), Forcing::NotForcing); + assert!(>::exists(11)); + + start_era(3); + + // this staker is in a new slashing span now, having re-registered after + // their prior slash. + + on_offence_in_era( + &[OffenceDetails { + offender: ( + 11, + Staking::stakers(&11), + ), + reporters: vec![], + }], + &[Perbill::from_percent(0)], + 1, + ); + + // not for zero-slash. + assert_eq!(Staking::force_era(), Forcing::NotForcing); + assert!(>::exists(11)); + + on_offence_in_era( + &[OffenceDetails { + offender: ( + 11, + Staking::stakers(&11), + ), + reporters: vec![], + }], + &[Perbill::from_percent(100)], + 1, + ); + + // or non-zero. + assert_eq!(Staking::force_era(), Forcing::NotForcing); + assert!(>::exists(11)); + assert_ledger_consistent(11); + }); +} + #[test] fn reporters_receive_their_slice() { // This test verifies that the reporters of the offence receive their slice from the slashed @@ -1856,7 +1935,7 @@ fn reporters_receive_their_slice() { assert_eq!(Staking::stakers(&11).total, initial_balance); - Staking::on_offence( + on_offence_now( &[OffenceDetails { offender: ( 11, @@ -1867,27 +1946,80 @@ fn reporters_receive_their_slice() { &[Perbill::from_percent(50)], ); - // initial_balance x 50% (slash fraction) x 10% (rewards slice) - let reward = initial_balance / 20 / 2; - assert_eq!(Balances::free_balance(&1), 10 + reward); - assert_eq!(Balances::free_balance(&2), 20 + reward); + // F1 * (reward_proportion * slash - 0) + // 50% * (10% * initial_balance / 2) + let reward = (initial_balance / 20) / 2; + let reward_each = reward / 2; // split into two pieces. + assert_eq!(Balances::free_balance(&1), 10 + reward_each); + assert_eq!(Balances::free_balance(&2), 20 + reward_each); + assert_ledger_consistent(11); }); } #[test] -fn invulnerables_are_not_slashed() { - // For invulnerable validators no slashing is performed. - ExtBuilder::default().invulnerables(vec![11]).build().execute_with(|| { +fn subsequent_reports_in_same_span_pay_out_less() { + // This test verifies that the reporters of the offence receive their slice from the slashed + // amount. + ExtBuilder::default().build().execute_with(|| { + // The reporters' reward is calculated from the total exposure. #[cfg(feature = "equalize")] let initial_balance = 1250; #[cfg(not(feature = "equalize"))] - let initial_balance = 1375; + let initial_balance = 1125; + + assert_eq!(Staking::stakers(&11).total, initial_balance); + on_offence_now( + &[OffenceDetails { + offender: ( + 11, + Staking::stakers(&11), + ), + reporters: vec![1], + }], + &[Perbill::from_percent(20)], + ); + + // F1 * (reward_proportion * slash - 0) + // 50% * (10% * initial_balance * 20%) + let reward = (initial_balance / 5) / 20; + assert_eq!(Balances::free_balance(&1), 10 + reward); + + on_offence_now( + &[OffenceDetails { + offender: ( + 11, + Staking::stakers(&11), + ), + reporters: vec![1], + }], + &[Perbill::from_percent(50)], + ); + + let prior_payout = reward; + + // F1 * (reward_proportion * slash - prior_payout) + // 50% * (10% * (initial_balance / 2) - prior_payout) + let reward = ((initial_balance / 20) - prior_payout) / 2; + assert_eq!(Balances::free_balance(&1), 10 + prior_payout + reward); + assert_ledger_consistent(11); + }); +} + +#[test] +fn invulnerables_are_not_slashed() { + // For invulnerable validators no slashing is performed. + ExtBuilder::default().invulnerables(vec![11]).build().execute_with(|| { assert_eq!(Balances::free_balance(&11), 1000); assert_eq!(Balances::free_balance(&21), 2000); - assert_eq!(Staking::stakers(&21).total, initial_balance); - Staking::on_offence( + let exposure = Staking::stakers(&21); + let initial_balance = Staking::slashable_balance_of(&21); + + let nominator_balances: Vec<_> = exposure.others + .iter().map(|o| Balances::free_balance(&o.who)).collect(); + + on_offence_now( &[ OffenceDetails { offender: (11, Staking::stakers(&11)), @@ -1905,6 +2037,16 @@ fn invulnerables_are_not_slashed() { assert_eq!(Balances::free_balance(&11), 1000); // 2000 - (0.2 * initial_balance) assert_eq!(Balances::free_balance(&21), 2000 - (2 * initial_balance / 10)); + + // ensure that nominators were slashed as well. + for (initial_balance, other) in nominator_balances.into_iter().zip(exposure.others) { + assert_eq!( + Balances::free_balance(&other.who), + initial_balance - (2 * other.value / 10), + ); + } + assert_ledger_consistent(11); + assert_ledger_consistent(21); }); } @@ -1914,7 +2056,7 @@ fn dont_slash_if_fraction_is_zero() { ExtBuilder::default().build().execute_with(|| { assert_eq!(Balances::free_balance(&11), 1000); - Staking::on_offence( + on_offence_now( &[OffenceDetails { offender: ( 11, @@ -1927,5 +2069,462 @@ fn dont_slash_if_fraction_is_zero() { // The validator hasn't been slashed. The new era is not forced. assert_eq!(Balances::free_balance(&11), 1000); + assert_ledger_consistent(11); + }); +} + +#[test] +fn only_slash_for_max_in_era() { + ExtBuilder::default().build().execute_with(|| { + assert_eq!(Balances::free_balance(&11), 1000); + + on_offence_now( + &[ + OffenceDetails { + offender: (11, Staking::stakers(&11)), + reporters: vec![], + }, + ], + &[Perbill::from_percent(50)], + ); + + // The validator has been slashed and has been force-chilled. + assert_eq!(Balances::free_balance(&11), 500); + assert_eq!(Staking::force_era(), Forcing::ForceNew); + + on_offence_now( + &[ + OffenceDetails { + offender: (11, Staking::stakers(&11)), + reporters: vec![], + }, + ], + &[Perbill::from_percent(25)], + ); + + // The validator has not been slashed additionally. + assert_eq!(Balances::free_balance(&11), 500); + + on_offence_now( + &[ + OffenceDetails { + offender: (11, Staking::stakers(&11)), + reporters: vec![], + }, + ], + &[Perbill::from_percent(60)], + ); + + // The validator got slashed 10% more. + assert_eq!(Balances::free_balance(&11), 400); + assert_ledger_consistent(11); + }) +} + +#[test] +fn garbage_collection_after_slashing() { + ExtBuilder::default().existential_deposit(1).build().execute_with(|| { + assert_eq!(Balances::free_balance(&11), 256_000); + + on_offence_now( + &[ + OffenceDetails { + offender: (11, Staking::stakers(&11)), + reporters: vec![], + }, + ], + &[Perbill::from_percent(10)], + ); + + assert_eq!(Balances::free_balance(&11), 256_000 - 25_600); + assert!(::SlashingSpans::get(&11).is_some()); + assert_eq!(::SpanSlash::get(&(11, 0)).amount_slashed(), &25_600); + + on_offence_now( + &[ + OffenceDetails { + offender: (11, Staking::stakers(&11)), + reporters: vec![], + }, + ], + &[Perbill::from_percent(100)], + ); + + // validator and nominator slash in era are garbage-collected by era change, + // so we don't test those here. + + assert_eq!(Balances::free_balance(&11), 0); + assert!(::SlashingSpans::get(&11).is_none()); + assert_eq!(::SpanSlash::get(&(11, 0)).amount_slashed(), &0); + }) +} + +#[test] +fn garbage_collection_on_window_pruning() { + ExtBuilder::default().build().execute_with(|| { + start_era(1); + + assert_eq!(Balances::free_balance(&11), 1000); + + let exposure = Staking::stakers(&11); + assert_eq!(Balances::free_balance(&101), 2000); + let nominated_value = exposure.others.iter().find(|o| o.who == 101).unwrap().value; + + on_offence_now( + &[ + OffenceDetails { + offender: (11, Staking::stakers(&11)), + reporters: vec![], + }, + ], + &[Perbill::from_percent(10)], + ); + + let now = Staking::current_era(); + + assert_eq!(Balances::free_balance(&11), 900); + assert_eq!(Balances::free_balance(&101), 2000 - (nominated_value / 10)); + + assert!(::ValidatorSlashInEra::get(&now, &11).is_some()); + assert!(::NominatorSlashInEra::get(&now, &101).is_some()); + + // + 1 because we have to exit the bonding window. + for era in (0..(BondingDuration::get() + 1)).map(|offset| offset + now + 1) { + assert!(::ValidatorSlashInEra::get(&now, &11).is_some()); + assert!(::NominatorSlashInEra::get(&now, &101).is_some()); + + start_era(era); + } + + assert!(::ValidatorSlashInEra::get(&now, &11).is_none()); + assert!(::NominatorSlashInEra::get(&now, &101).is_none()); + }) +} + +#[test] +fn slashing_nominators_by_span_max() { + ExtBuilder::default().build().execute_with(|| { + start_era(1); + start_era(2); + start_era(3); + + assert_eq!(Balances::free_balance(&11), 1000); + assert_eq!(Balances::free_balance(&21), 2000); + assert_eq!(Balances::free_balance(&101), 2000); + assert_eq!(Staking::slashable_balance_of(&21), 1000); + + + let exposure_11 = Staking::stakers(&11); + let exposure_21 = Staking::stakers(&21); + assert_eq!(Balances::free_balance(&101), 2000); + let nominated_value_11 = exposure_11.others.iter().find(|o| o.who == 101).unwrap().value; + let nominated_value_21 = exposure_21.others.iter().find(|o| o.who == 101).unwrap().value; + + on_offence_in_era( + &[ + OffenceDetails { + offender: (11, Staking::stakers(&11)), + reporters: vec![], + }, + ], + &[Perbill::from_percent(10)], + 2, + ); + + assert_eq!(Balances::free_balance(&11), 900); + + let slash_1_amount = Perbill::from_percent(10) * nominated_value_11; + assert_eq!(Balances::free_balance(&101), 2000 - slash_1_amount); + + let expected_spans = vec![ + slashing::SlashingSpan { index: 1, start: 4, length: None }, + slashing::SlashingSpan { index: 0, start: 0, length: Some(4) }, + ]; + + let get_span = |account| ::SlashingSpans::get(&account).unwrap(); + + assert_eq!( + get_span(11).iter().collect::>(), + expected_spans, + ); + + assert_eq!( + get_span(101).iter().collect::>(), + expected_spans, + ); + + // second slash: higher era, higher value, same span. + on_offence_in_era( + &[ + OffenceDetails { + offender: (21, Staking::stakers(&21)), + reporters: vec![], + }, + ], + &[Perbill::from_percent(30)], + 3, + ); + + // 11 was not further slashed, but 21 and 101 were. + assert_eq!(Balances::free_balance(&11), 900); + assert_eq!(Balances::free_balance(&21), 1700); + + let slash_2_amount = Perbill::from_percent(30) * nominated_value_21; + assert!(slash_2_amount > slash_1_amount); + + // only the maximum slash in a single span is taken. + assert_eq!(Balances::free_balance(&101), 2000 - slash_2_amount); + + // third slash: in same era and on same validator as first, higher + // in-era value, but lower slash value than slash 2. + on_offence_in_era( + &[ + OffenceDetails { + offender: (11, Staking::stakers(&11)), + reporters: vec![], + }, + ], + &[Perbill::from_percent(20)], + 2, + ); + + // 11 was further slashed, but 21 and 101 were not. + assert_eq!(Balances::free_balance(&11), 800); + assert_eq!(Balances::free_balance(&21), 1700); + + let slash_3_amount = Perbill::from_percent(20) * nominated_value_21; + assert!(slash_3_amount < slash_2_amount); + assert!(slash_3_amount > slash_1_amount); + + // only the maximum slash in a single span is taken. + assert_eq!(Balances::free_balance(&101), 2000 - slash_2_amount); + }); +} + +#[test] +fn slashes_are_summed_across_spans() { + ExtBuilder::default().build().execute_with(|| { + start_era(1); + start_era(2); + start_era(3); + + assert_eq!(Balances::free_balance(&21), 2000); + assert_eq!(Staking::slashable_balance_of(&21), 1000); + + let get_span = |account| ::SlashingSpans::get(&account).unwrap(); + + on_offence_now( + &[ + OffenceDetails { + offender: (21, Staking::stakers(&21)), + reporters: vec![], + }, + ], + &[Perbill::from_percent(10)], + ); + + let expected_spans = vec![ + slashing::SlashingSpan { index: 1, start: 4, length: None }, + slashing::SlashingSpan { index: 0, start: 0, length: Some(4) }, + ]; + + assert_eq!(get_span(21).iter().collect::>(), expected_spans); + assert_eq!(Balances::free_balance(&21), 1900); + + // 21 has been force-chilled. re-signal intent to validate. + Staking::validate(Origin::signed(20), Default::default()).unwrap(); + + start_era(4); + + assert_eq!(Staking::slashable_balance_of(&21), 900); + + on_offence_now( + &[ + OffenceDetails { + offender: (21, Staking::stakers(&21)), + reporters: vec![], + }, + ], + &[Perbill::from_percent(10)], + ); + + let expected_spans = vec![ + slashing::SlashingSpan { index: 2, start: 5, length: None }, + slashing::SlashingSpan { index: 1, start: 4, length: Some(1) }, + slashing::SlashingSpan { index: 0, start: 0, length: Some(4) }, + ]; + + assert_eq!(get_span(21).iter().collect::>(), expected_spans); + assert_eq!(Balances::free_balance(&21), 1810); + }); +} + +#[test] +fn deferred_slashes_are_deferred() { + ExtBuilder::default().slash_defer_duration(2).build().execute_with(|| { + start_era(1); + + assert_eq!(Balances::free_balance(&11), 1000); + + let exposure = Staking::stakers(&11); + assert_eq!(Balances::free_balance(&101), 2000); + let nominated_value = exposure.others.iter().find(|o| o.who == 101).unwrap().value; + + on_offence_now( + &[ + OffenceDetails { + offender: (11, Staking::stakers(&11)), + reporters: vec![], + }, + ], + &[Perbill::from_percent(10)], + ); + + assert_eq!(Balances::free_balance(&11), 1000); + assert_eq!(Balances::free_balance(&101), 2000); + + start_era(2); + + assert_eq!(Balances::free_balance(&11), 1000); + assert_eq!(Balances::free_balance(&101), 2000); + + start_era(3); + + assert_eq!(Balances::free_balance(&11), 1000); + assert_eq!(Balances::free_balance(&101), 2000); + + // at the start of era 4, slashes from era 1 are processed, + // after being deferred for at least 2 full eras. + start_era(4); + + assert_eq!(Balances::free_balance(&11), 900); + assert_eq!(Balances::free_balance(&101), 2000 - (nominated_value / 10)); + }) +} + +#[test] +fn remove_deferred() { + ExtBuilder::default().slash_defer_duration(2).build().execute_with(|| { + start_era(1); + + assert_eq!(Balances::free_balance(&11), 1000); + + let exposure = Staking::stakers(&11); + assert_eq!(Balances::free_balance(&101), 2000); + let nominated_value = exposure.others.iter().find(|o| o.who == 101).unwrap().value; + + on_offence_now( + &[ + OffenceDetails { + offender: (11, exposure.clone()), + reporters: vec![], + }, + ], + &[Perbill::from_percent(10)], + ); + + assert_eq!(Balances::free_balance(&11), 1000); + assert_eq!(Balances::free_balance(&101), 2000); + + start_era(2); + + on_offence_in_era( + &[ + OffenceDetails { + offender: (11, exposure.clone()), + reporters: vec![], + }, + ], + &[Perbill::from_percent(15)], + 1, + ); + + Staking::cancel_deferred_slash(Origin::ROOT, 1, vec![0]).unwrap(); + + assert_eq!(Balances::free_balance(&11), 1000); + assert_eq!(Balances::free_balance(&101), 2000); + + start_era(3); + + assert_eq!(Balances::free_balance(&11), 1000); + assert_eq!(Balances::free_balance(&101), 2000); + + // at the start of era 4, slashes from era 1 are processed, + // after being deferred for at least 2 full eras. + start_era(4); + + // the first slash for 10% was cancelled, so no effect. + assert_eq!(Balances::free_balance(&11), 1000); + assert_eq!(Balances::free_balance(&101), 2000); + + start_era(5); + + let slash_10 = Perbill::from_percent(10); + let slash_15 = Perbill::from_percent(15); + let initial_slash = slash_10 * nominated_value; + + let total_slash = slash_15 * nominated_value; + let actual_slash = total_slash - initial_slash; + + // 5% slash (15 - 10) processed now. + assert_eq!(Balances::free_balance(&11), 950); + assert_eq!(Balances::free_balance(&101), 2000 - actual_slash); + }) +} + +#[test] +fn remove_multi_deferred() { + ExtBuilder::default().slash_defer_duration(2).build().execute_with(|| { + start_era(1); + + assert_eq!(Balances::free_balance(&11), 1000); + + let exposure = Staking::stakers(&11); + assert_eq!(Balances::free_balance(&101), 2000); + + on_offence_now( + &[ + OffenceDetails { + offender: (11, exposure.clone()), + reporters: vec![], + }, + ], + &[Perbill::from_percent(10)], + ); + + on_offence_now( + &[ + OffenceDetails { + offender: (21, Staking::stakers(&21)), + reporters: vec![], + } + ], + &[Perbill::from_percent(10)], + ); + + + on_offence_now( + &[ + OffenceDetails { + offender: (11, exposure.clone()), + reporters: vec![], + }, + ], + &[Perbill::from_percent(25)], + ); + + assert_eq!(::UnappliedSlashes::get(&1).len(), 3); + Staking::cancel_deferred_slash(Origin::ROOT, 1, vec![0, 2]).unwrap(); + + let slashes = ::UnappliedSlashes::get(&1); + assert_eq!(slashes.len(), 1); + assert_eq!(slashes[0].validator, 21); + }) +} + +#[test] +fn version_initialized() { + ExtBuilder::default().build().execute_with(|| { + assert_eq!(::StorageVersion::get(), crate::migration::CURRENT_VERSION); }); } diff --git a/primitives/sr-staking-primitives/src/offence.rs b/primitives/sr-staking-primitives/src/offence.rs index db51f75df1..04d887fbe0 100644 --- a/primitives/sr-staking-primitives/src/offence.rs +++ b/primitives/sr-staking-primitives/src/offence.rs @@ -117,9 +117,12 @@ pub trait OnOffenceHandler { /// the authorities should be slashed and is computed /// according to the `OffenceCount` already. This is of the same length as `offenders.` /// Zero is a valid value for a fraction. + /// + /// The `session` parameter is the session index of the offence. fn on_offence( offenders: &[OffenceDetails], slash_fraction: &[Perbill], + session: SessionIndex, ); } @@ -127,6 +130,7 @@ impl OnOffenceHandler for () { fn on_offence( _offenders: &[OffenceDetails], _slash_fraction: &[Perbill], + _session: SessionIndex, ) {} } -- GitLab From 47231564bc17d2ec7fcf3afa0e88b931c157c06b Mon Sep 17 00:00:00 2001 From: Robert Habermeier Date: Wed, 27 Nov 2019 22:53:34 +0100 Subject: [PATCH 033/172] back-off block proposal (#4235) --- client/consensus/babe/src/lib.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/client/consensus/babe/src/lib.rs b/client/consensus/babe/src/lib.rs index 3fd1e526d4..2c81367039 100644 --- a/client/consensus/babe/src/lib.rs +++ b/client/consensus/babe/src/lib.rs @@ -453,6 +453,32 @@ impl slots::SimpleSlotWorker for BabeWorker Option { + // never give more than 20 times more lenience. + const BACKOFF_CAP: u64 = 20; + + let slot_remaining = self.slot_remaining_duration(slot_info); + let parent_slot = match find_pre_digest::(head) { + Err(_) => return Some(slot_remaining), + Ok(d) => d.slot_number(), + }; + + // we allow a lenience of the number of slots since the head of the + // chain was produced, minus 1 (since there is always a difference of at least 1) + // + // linear back-off. + // in normal cases we only attempt to issue blocks up to the end of the slot. + // when the chain has been stalled for a few slots, we give more lenience. + let slot_lenience = slot_info.number.saturating_sub(parent_slot + 1); + let slot_lenience = std::cmp::min(slot_lenience, BACKOFF_CAP); + let slot_lenience = Duration::from_secs(slot_lenience * slot_info.duration); + Some(slot_lenience + slot_remaining) + } } impl SlotWorker for BabeWorker where -- GitLab From 657736e0027174b29a6c14141a11c794bf3fa9bc Mon Sep 17 00:00:00 2001 From: Bryant Eisenbach <3859395+fubuloubu@users.noreply.github.com> Date: Wed, 27 Nov 2019 18:59:37 -0500 Subject: [PATCH 034/172] Use raw public key instead of compressed (#4234) * refactor: Use raw public key instead of compressed * Fix whitespace --- primitives/core/src/ecdsa.rs | 53 ++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/primitives/core/src/ecdsa.rs b/primitives/core/src/ecdsa.rs index 7ba750f49b..50ad9ddfa0 100644 --- a/primitives/core/src/ecdsa.rs +++ b/primitives/core/src/ecdsa.rs @@ -46,9 +46,9 @@ use secp256k1::{PublicKey, SecretKey}; #[cfg(feature = "full_crypto")] type Seed = [u8; 32]; -/// The ECDSA 33-byte compressed public key. +/// The ECDSA 64-byte raw public key. #[derive(Clone, Encode, Decode)] -pub struct Public(pub [u8; 33]); +pub struct Public(pub [u8; 64]); impl PartialOrd for Public { fn partial_cmp(&self, other: &Self) -> Option { @@ -72,7 +72,7 @@ impl Eq for Public {} impl Default for Public { fn default() -> Self { - Public([0u8; 33]) + Public([0u8; 64]) } } @@ -84,8 +84,8 @@ pub struct Pair { secret: SecretKey, } -impl AsRef<[u8; 33]> for Public { - fn as_ref(&self) -> &[u8; 33] { +impl AsRef<[u8; 64]> for Public { + fn as_ref(&self) -> &[u8; 64] { &self.0 } } @@ -106,8 +106,8 @@ impl rstd::convert::TryFrom<&[u8]> for Public { type Error = (); fn try_from(data: &[u8]) -> Result { - if data.len() == 33 { - let mut inner = [0u8; 33]; + if data.len() == 64 { + let mut inner = [0u8; 64]; inner.copy_from_slice(data); Ok(Public(inner)) } else { @@ -116,7 +116,7 @@ impl rstd::convert::TryFrom<&[u8]> for Public { } } -impl From for [u8; 33] { +impl From for [u8; 64] { fn from(x: Public) -> Self { x.0 } @@ -129,8 +129,8 @@ impl From for Public { } } -impl UncheckedFrom<[u8; 33]> for Public { - fn unchecked_from(x: [u8; 33]) -> Self { +impl UncheckedFrom<[u8; 64]> for Public { + fn unchecked_from(x: [u8; 64]) -> Self { Public(x) } } @@ -292,7 +292,7 @@ impl Signature { let message = secp256k1::Message::parse(&blake2_256(message.as_ref())); let sig: (_, _) = self.try_into().ok()?; secp256k1::recover(&message, &sig.0, &sig.1).ok() - .map(|recovered| Public(recovered.serialize_compressed())) + .map(|recovered| Public::from_full(recovered.serialize())) } } @@ -332,16 +332,27 @@ pub enum PublicError { } impl Public { - /// A new instance from the given 33-byte `data`. + /// A new instance from the given 64-byte `data`. /// /// NOTE: No checking goes on to ensure this is a real public key. Only use it if /// you are certain that the array actually is a pubkey. GIGO! - pub fn from_raw(data: [u8; 33]) -> Self { + pub fn from_raw(data: [u8; 64]) -> Self { Public(data) } + /// A new instance from the given 65-byte `data`. + /// + /// NOTE: No checking goes on to ensure this is a real public key. Only use it if + /// you are certain that the array actually is a pubkey. GIGO! + pub fn from_full(data: [u8; 65]) -> Self { + let raw_key = &data[1..]; + let mut key = [0u8; 64]; + key.copy_from_slice(raw_key); + Public(key) + } + /// Return a slice filled with raw data. - pub fn as_array_ref(&self) -> &[u8; 33] { + pub fn as_array_ref(&self) -> &[u8; 64] { self.as_ref() } } @@ -352,7 +363,7 @@ impl TraitPublic for Public { /// NOTE: No checking goes on to ensure this is a real public key. Only use it if /// you are certain that the array actually is a pubkey. GIGO! fn from_slice(data: &[u8]) -> Self { - let mut r = [0u8; 33]; + let mut r = [0u8; 64]; r.copy_from_slice(data); Public(r) } @@ -448,7 +459,7 @@ impl TraitPair for Pair { /// Get the public key. fn public(&self) -> Public { - Public(self.public.serialize_compressed()) + Public::from_full(self.public.serialize()) } /// Sign a message. @@ -462,7 +473,7 @@ impl TraitPair for Pair { let message = secp256k1::Message::parse(&blake2_256(message.as_ref())); let sig: (_, _) = match sig.try_into() { Ok(x) => x, _ => return false }; match secp256k1::recover(&message, &sig.0, &sig.1) { - Ok(actual) => &pubkey.0[..] == &actual.serialize_compressed()[..], + Ok(actual) => &pubkey.0[..] == &actual.serialize()[1..], _ => false, } } @@ -477,7 +488,7 @@ impl TraitPair for Pair { let ri = match secp256k1::RecoveryId::parse(sig[64]) { Ok(x) => x, _ => return false }; let sig = match secp256k1::Signature::parse_slice(&sig[0..64]) { Ok(x) => x, _ => return false }; match secp256k1::recover(&message, &sig, &ri) { - Ok(actual) => pubkey.as_ref() == &actual.serialize_compressed()[..], + Ok(actual) => pubkey.as_ref() == &actual.serialize()[1..], _ => false, } } @@ -558,7 +569,7 @@ mod test { ); let public = pair.public(); assert_eq!(public, Public::from_raw( - hex!("028db55b05db86c0b1786ca49f095d76344c9e6056b2f02701a7e7f3c20aabfd91") + hex!("8db55b05db86c0b1786ca49f095d76344c9e6056b2f02701a7e7f3c20aabfd913ebbe148dd17c56551a52952371071a6c604b3f3abe8f2c8fa742158ea6dd7d4") )); let message = b""; let signature = hex!("3dde91174bd9359027be59a428b8146513df80a2a3c7eda2194f64de04a69ab97b753169e94db6ffd50921a2668a48b94ca11e3d32c1ff19cfe88890aa7e8f3c00"); @@ -575,7 +586,7 @@ mod test { ).unwrap(); let public = pair.public(); assert_eq!(public, Public::from_raw( - hex!("028db55b05db86c0b1786ca49f095d76344c9e6056b2f02701a7e7f3c20aabfd91") + hex!("8db55b05db86c0b1786ca49f095d76344c9e6056b2f02701a7e7f3c20aabfd913ebbe148dd17c56551a52952371071a6c604b3f3abe8f2c8fa742158ea6dd7d4") )); let message = b""; let signature = hex!("3dde91174bd9359027be59a428b8146513df80a2a3c7eda2194f64de04a69ab97b753169e94db6ffd50921a2668a48b94ca11e3d32c1ff19cfe88890aa7e8f3c00"); @@ -599,7 +610,7 @@ mod test { let pair = Pair::from_seed(b"12345678901234567890123456789012"); let public = pair.public(); assert_eq!(public, Public::from_raw( - hex!("035676109c54b9a16d271abeb4954316a40a32bcce023ac14c8e26e958aa68fba9") + hex!("5676109c54b9a16d271abeb4954316a40a32bcce023ac14c8e26e958aa68fba995840f3de562156558efbfdac3f16af0065e5f66795f4dd8262a228ef8c6d813") )); let message = hex!("2f8c6129d816cf51c374bc7f08c3e63ed156cf78aefb4a6550d97b87997977ee00000000000000000200d75a980182b10ab7d54bfed3c964073a0ee172f3daa62325af021a68f707511a4500000000000000"); let signature = pair.sign(&message[..]); -- GitLab From b9e7f09a675b5625cc8b156848d976592e07a409 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Thu, 28 Nov 2019 01:00:29 +0100 Subject: [PATCH 035/172] The storage runtime interface should not enforce a hash type (#4231) * The storage runtime interface should not enforce a hash type Currently the runtime interface enforces `H256` as hash type, but in the future people could use whatever they want as hash type. The hash type always needs to match between the runtime and the node, but that is already required. * Update primitives/externalities/src/lib.rs Co-Authored-By: thiolliere --- Cargo.lock | 1 - bin/node/executor/src/lib.rs | 4 +- client/db/src/lib.rs | 6 +- client/db/src/storage_cache.rs | 2 +- .../executor/src/deprecated_host_interface.rs | 2 +- client/executor/src/wasm_runtime.rs | 12 ++-- client/src/cht.rs | 6 +- client/src/light/backend.rs | 10 +-- client/src/light/fetcher.rs | 4 +- frame/system/src/lib.rs | 10 ++- primitives/externalities/Cargo.toml | 1 - primitives/externalities/src/lib.rs | 44 +++++++++--- primitives/sr-io/src/lib.rs | 30 ++++++-- primitives/sr-primitives/src/traits.rs | 18 +---- primitives/state-machine/src/backend.rs | 15 ++-- primitives/state-machine/src/basic.rs | 31 ++++---- .../state-machine/src/changes_trie/build.rs | 5 +- .../src/changes_trie/changes_iterator.rs | 14 ++-- .../state-machine/src/changes_trie/mod.rs | 2 +- .../state-machine/src/changes_trie/prune.rs | 14 ++-- primitives/state-machine/src/ext.rs | 70 ++++++++++++------- primitives/state-machine/src/lib.rs | 16 ++--- .../state-machine/src/overlayed_changes.rs | 4 +- .../state-machine/src/proving_backend.rs | 15 ++-- primitives/state-machine/src/testing.rs | 2 +- primitives/state-machine/src/trie_backend.rs | 16 +++-- .../state-machine/src/trie_backend_essence.rs | 16 +++-- primitives/trie/src/lib.rs | 26 ++++--- test/utils/runtime/src/system.rs | 22 ++++-- 29 files changed, 253 insertions(+), 165 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 226cce363e..6ae7d4deab 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5986,7 +5986,6 @@ name = "substrate-externalities" version = "2.0.0" dependencies = [ "environmental 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "primitive-types 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 2.0.0", "substrate-primitives-storage 2.0.0", ] diff --git a/bin/node/executor/src/lib.rs b/bin/node/executor/src/lib.rs index b1e5e24ffd..d85ec452c7 100644 --- a/bin/node/executor/src/lib.rs +++ b/bin/node/executor/src/lib.rs @@ -913,7 +913,7 @@ mod tests { None, ).0.unwrap(); - assert!(t.ext().storage_changes_root(GENESIS_HASH.into()).unwrap().is_some()); + assert!(t.ext().storage_changes_root(&GENESIS_HASH.encode()).unwrap().is_some()); } #[test] @@ -929,7 +929,7 @@ mod tests { None, ).0.unwrap(); - assert!(t.ext().storage_changes_root(GENESIS_HASH.into()).unwrap().is_some()); + assert!(t.ext().storage_changes_root(&GENESIS_HASH.encode()).unwrap().is_some()); } #[test] diff --git a/client/db/src/lib.rs b/client/db/src/lib.rs index dceffc852a..253b48e6fa 100644 --- a/client/db/src/lib.rs +++ b/client/db/src/lib.rs @@ -174,7 +174,7 @@ impl StateBackend for RefTrackingState { self.state.storage_root(delta) } - fn child_storage_root(&self, storage_key: &[u8], delta: I) -> (Vec, bool, Self::Transaction) + fn child_storage_root(&self, storage_key: &[u8], delta: I) -> (H256, bool, Self::Transaction) where I: IntoIterator, Option>)>, { @@ -193,7 +193,9 @@ impl StateBackend for RefTrackingState { self.state.child_keys(child_key, prefix) } - fn as_trie_backend(&mut self) -> Option<&state_machine::TrieBackend> { + fn as_trie_backend( + &mut self, + ) -> Option<&state_machine::TrieBackend> { self.state.as_trie_backend() } } diff --git a/client/db/src/storage_cache.rs b/client/db/src/storage_cache.rs index 3febc6b4d4..3884857786 100644 --- a/client/db/src/storage_cache.rs +++ b/client/db/src/storage_cache.rs @@ -568,7 +568,7 @@ impl, B: BlockT> StateBackend for CachingState< self.state.storage_root(delta) } - fn child_storage_root(&self, storage_key: &[u8], delta: I) -> (Vec, bool, Self::Transaction) + fn child_storage_root(&self, storage_key: &[u8], delta: I) -> (H::Out, bool, Self::Transaction) where I: IntoIterator, Option>)>, H::Out: Ord diff --git a/client/executor/src/deprecated_host_interface.rs b/client/executor/src/deprecated_host_interface.rs index 223b13367a..f74a9597e5 100644 --- a/client/executor/src/deprecated_host_interface.rs +++ b/client/executor/src/deprecated_host_interface.rs @@ -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) = runtime_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) diff --git a/client/executor/src/wasm_runtime.rs b/client/executor/src/wasm_runtime.rs index c58f63a1e0..5014c05816 100644 --- a/client/executor/src/wasm_runtime.rs +++ b/client/executor/src/wasm_runtime.rs @@ -26,7 +26,7 @@ use log::{trace, warn}; use codec::Decode; -use primitives::{storage::well_known_keys, traits::Externalities, H256}; +use primitives::{storage::well_known_keys, traits::Externalities}; use runtime_version::RuntimeVersion; use std::{collections::hash_map::{Entry, HashMap}, panic::AssertUnwindSafe}; @@ -82,7 +82,7 @@ pub struct RuntimesCache { /// A cache of runtime instances along with metadata, ready to be reused. /// /// Instances are keyed by the Wasm execution method and the hash of their code. - instances: HashMap<(WasmExecutionMethod, [u8; 32]), Result>, + instances: HashMap<(WasmExecutionMethod, Vec), Result>, } impl RuntimesCache { @@ -128,7 +128,7 @@ impl RuntimesCache { wasm_method: WasmExecutionMethod, default_heap_pages: u64, host_functions: &[&'static dyn Function], - ) -> Result<(&mut (dyn WasmRuntime + 'static), &RuntimeVersion, H256), Error> { + ) -> Result<(&mut (dyn WasmRuntime + 'static), &RuntimeVersion, Vec), Error> { let code_hash = ext .original_storage_hash(well_known_keys::CODE) .ok_or(Error::InvalidCode("`CODE` not found in storage.".into()))?; @@ -138,7 +138,7 @@ impl RuntimesCache { .and_then(|pages| u64::decode(&mut &pages[..]).ok()) .unwrap_or(default_heap_pages); - let result = match self.instances.entry((wasm_method, code_hash.into())) { + let result = match self.instances.entry((wasm_method, code_hash.clone())) { Entry::Occupied(o) => { let result = o.into_mut(); if let Ok(ref mut cached_runtime) = result { @@ -198,10 +198,10 @@ impl RuntimesCache { pub fn invalidate_runtime( &mut self, wasm_method: WasmExecutionMethod, - code_hash: H256, + code_hash: Vec, ) { // Just remove the instance, it will be re-created the next time it is requested. - self.instances.remove(&(wasm_method, code_hash.into())); + self.instances.remove(&(wasm_method, code_hash)); } } diff --git a/client/src/cht.rs b/client/src/cht.rs index dc49069f0a..7e0552f2f2 100644 --- a/client/src/cht.rs +++ b/client/src/cht.rs @@ -92,7 +92,7 @@ pub fn build_proof( where Header: HeaderT, Hasher: hash_db::Hasher, - Hasher::Out: Ord, + Hasher::Out: Ord + codec::Codec, BlocksI: IntoIterator, HashesI: IntoIterator>>, { @@ -119,7 +119,7 @@ pub fn check_proof( where Header: HeaderT, Hasher: hash_db::Hasher, - Hasher::Out: Ord, + Hasher::Out: Ord + codec::Codec, { do_check_proof::( local_root, @@ -148,7 +148,7 @@ pub fn check_proof_on_proving_backend( where Header: HeaderT, Hasher: hash_db::Hasher, - Hasher::Out: Ord, + Hasher::Out: Ord + codec::Codec, { do_check_proof::( local_root, diff --git a/client/src/light/backend.rs b/client/src/light/backend.rs index da21ebf9e8..2077713ba5 100644 --- a/client/src/light/backend.rs +++ b/client/src/light/backend.rs @@ -21,7 +21,9 @@ use std::collections::HashMap; use std::sync::Arc; use parking_lot::RwLock; -use state_machine::{Backend as StateBackend, TrieBackend, backend::InMemory as InMemoryState, ChangesTrieTransaction}; +use state_machine::{ + Backend as StateBackend, TrieBackend, backend::InMemory as InMemoryState, ChangesTrieTransaction +}; use primitives::offchain::storage::InMemOffchainStorage; use sr_primitives::{generic::BlockId, Justification, StorageOverlay, ChildrenStorageOverlay}; use sr_primitives::traits::{Block as BlockT, NumberFor, Zero, Header}; @@ -341,7 +343,7 @@ impl std::fmt::Debug for GenesisOrUnavailableState { impl StateBackend for GenesisOrUnavailableState where - H::Out: Ord, + H::Out: Ord + codec::Codec, { type Error = ClientError; type Transaction = (); @@ -409,7 +411,7 @@ impl StateBackend for GenesisOrUnavailableState } } - fn child_storage_root(&self, key: &[u8], delta: I) -> (Vec, bool, Self::Transaction) + fn child_storage_root(&self, key: &[u8], delta: I) -> (H::Out, bool, Self::Transaction) where I: IntoIterator, Option>)> { @@ -418,7 +420,7 @@ impl StateBackend for GenesisOrUnavailableState let (root, is_equal, _) = state.child_storage_root(key, delta); (root, is_equal, ()) }, - GenesisOrUnavailableState::Unavailable => (H::Out::default().as_ref().to_vec(), true, ()), + GenesisOrUnavailableState::Unavailable => (H::Out::default(), true, ()), } } diff --git a/client/src/light/fetcher.rs b/client/src/light/fetcher.rs index d3f9436262..9db6dda172 100644 --- a/client/src/light/fetcher.rs +++ b/client/src/light/fetcher.rs @@ -70,7 +70,7 @@ impl> LightDataChecker { ) -> ClientResult, u32)>> where H: Hasher, - H::Out: Ord, + H::Out: Ord + codec::Codec, { // since we need roots of all changes tries for the range begin..max // => remote node can't use max block greater that one that we have passed @@ -148,7 +148,7 @@ impl> LightDataChecker { ) -> ClientResult<()> where H: Hasher, - H::Out: Ord, + H::Out: Ord + codec::Codec, { // all the checks are sharing the same storage let storage = create_proof_check_backend_storage(remote_roots_proof); diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index 611ec2ff16..17fb3fbf0e 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -668,13 +668,17 @@ impl Module { } } - let storage_root = T::Hashing::storage_root(); - let storage_changes_root = T::Hashing::storage_changes_root(parent_hash); + let storage_root = T::Hash::decode(&mut &runtime_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()); // we can't compute changes trie root earlier && put it to the Digest // because it will include all currently existing temporaries. if let Some(storage_changes_root) = storage_changes_root { - let item = generic::DigestItem::ChangesTrieRoot(storage_changes_root); + let item = generic::DigestItem::ChangesTrieRoot( + T::Hash::decode(&mut &storage_changes_root[..]) + .expect("Node is configured to use the same hash; qed") + ); digest.push(item); } diff --git a/primitives/externalities/Cargo.toml b/primitives/externalities/Cargo.toml index 0b806ecee0..ec4fa9a9a5 100644 --- a/primitives/externalities/Cargo.toml +++ b/primitives/externalities/Cargo.toml @@ -6,7 +6,6 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -primitive-types = { version = "0.6", features = ["codec"] } primitives-storage = { package = "substrate-primitives-storage", path = "../core/storage" } rstd = { package = "sr-std", path = "../sr-std" } environmental = { version = "1.0.2" } diff --git a/primitives/externalities/src/lib.rs b/primitives/externalities/src/lib.rs index 4efbc54a4e..da3fe16d77 100644 --- a/primitives/externalities/src/lib.rs +++ b/primitives/externalities/src/lib.rs @@ -22,8 +22,6 @@ //! //! This crate exposes the main [`Externalities`] trait. -use primitive_types::H256; - use std::any::{Any, TypeId}; use primitives_storage::ChildStorageKey; @@ -42,26 +40,40 @@ pub trait Externalities: ExtensionStore { fn storage(&self, key: &[u8]) -> Option>; /// Get storage value hash. This may be optimized for large values. - fn storage_hash(&self, key: &[u8]) -> Option; + fn storage_hash(&self, key: &[u8]) -> Option>; /// Get child storage value hash. This may be optimized for large values. - fn child_storage_hash(&self, storage_key: ChildStorageKey, key: &[u8]) -> Option; + /// + /// Returns an `Option` that holds the SCALE encoded hash. + fn child_storage_hash(&self, storage_key: ChildStorageKey, key: &[u8]) -> Option>; /// Read original runtime storage, ignoring any overlayed changes. fn original_storage(&self, key: &[u8]) -> Option>; /// Read original runtime child storage, ignoring any overlayed changes. + /// + /// Returns an `Option` that holds the SCALE encoded hash. fn original_child_storage(&self, storage_key: ChildStorageKey, key: &[u8]) -> Option>; /// Get original storage value hash, ignoring any overlayed changes. /// This may be optimized for large values. - fn original_storage_hash(&self, key: &[u8]) -> Option; + /// + /// Returns an `Option` that holds the SCALE encoded hash. + fn original_storage_hash(&self, key: &[u8]) -> Option>; /// Get original child storage value hash, ignoring any overlayed changes. /// This may be optimized for large values. - fn original_child_storage_hash(&self, storage_key: ChildStorageKey, key: &[u8]) -> Option; + /// + /// Returns an `Option` that holds the SCALE encoded hash. + fn original_child_storage_hash( + &self, + storage_key: ChildStorageKey, + key: &[u8], + ) -> Option>; /// Read child runtime storage. + /// + /// Returns an `Option` that holds the SCALE encoded hash. fn child_storage(&self, storage_key: ChildStorageKey, key: &[u8]) -> Option>; /// Set storage entry `key` of current contract being called (effective immediately). @@ -107,14 +119,23 @@ pub trait Externalities: ExtensionStore { fn place_storage(&mut self, key: Vec, value: Option>); /// Set or clear a child storage entry. Return whether the operation succeeds. - fn place_child_storage(&mut self, storage_key: ChildStorageKey, key: Vec, value: Option>); + fn place_child_storage( + &mut self, + storage_key: ChildStorageKey, + key: Vec, + value: Option>, + ); /// Get the identity of the chain. fn chain_id(&self) -> u64; /// Get the trie root of the current storage map. This will also update all child storage keys /// in the top-level storage map. - fn storage_root(&mut self) -> H256; + /// + /// The hash is defined by the `Block`. + /// + /// Returns the SCALE encoded hash. + fn storage_root(&mut self) -> Vec; /// Get the trie root of a child storage map. This will also update the value of the child /// storage keys in the top-level storage map. @@ -123,7 +144,12 @@ pub trait Externalities: ExtensionStore { fn child_storage_root(&mut self, storage_key: ChildStorageKey) -> Vec; /// Get the change trie root of the current storage overlay at a block with given parent. - fn storage_changes_root(&mut self, parent: H256) -> Result, ()>; + /// `parent` is expects a SCALE endcoded hash. + /// + /// The hash is defined by the `Block`. + /// + /// Returns the SCALE encoded hash. + fn storage_changes_root(&mut self, parent: &[u8]) -> Result>, ()>; } /// Extension for the [`Externalities`] trait. diff --git a/primitives/sr-io/src/lib.rs b/primitives/sr-io/src/lib.rs index 589b6a1dd1..40d52db98b 100644 --- a/primitives/sr-io/src/lib.rs +++ b/primitives/sr-io/src/lib.rs @@ -50,7 +50,7 @@ use primitives::{ }; #[cfg(feature = "std")] -use trie::{TrieConfiguration, trie_types::Layout}; +use ::trie::{TrieConfiguration, trie_types::Layout}; use runtime_interface::{runtime_interface, Pointer}; @@ -186,28 +186,45 @@ pub trait Storage { } /// "Commit" all existing operations and compute the resulting storage root. - fn root(&mut self) -> H256 { + /// + /// The hashing algorithm is defined by the `Block`. + /// + /// Returns the SCALE encoded hash. + fn root(&mut self) -> Vec { self.storage_root() } /// "Commit" all existing operations and compute the resulting child storage root. + /// + /// The hashing algorithm is defined by the `Block`. + /// + /// Returns the SCALE encoded hash. fn child_root(&mut self, child_storage_key: &[u8]) -> Vec { let storage_key = child_storage_key_or_panic(child_storage_key); self.child_storage_root(storage_key) } /// "Commit" all existing operations and get the resulting storage change root. - fn changes_root(&mut self, parent_hash: [u8; 32]) -> Option { - self.storage_changes_root(parent_hash.into()).ok().and_then(|h| h) + /// `parent_hash` is a SCALE encoded hash. + /// + /// The hashing algorithm is defined by the `Block`. + /// + /// Returns an `Option` that holds the SCALE encoded hash. + fn changes_root(&mut self, parent_hash: &[u8]) -> Option> { + self.storage_changes_root(parent_hash).ok().and_then(|h| h) } +} +/// Interface that provides trie related functionality. +#[runtime_interface] +pub trait Trie { /// A trie root formed from the iterated items. - fn blake2_256_trie_root(input: Vec<(Vec, Vec)>) -> H256 { + fn blake2_256_root(input: Vec<(Vec, Vec)>) -> H256 { Layout::::trie_root(input) } /// A trie root formed from the enumerated items. - fn blake2_256_ordered_trie_root(input: Vec>) -> H256 { + fn blake2_256_ordered_root(input: Vec>) -> H256 { Layout::::ordered_trie_root(input) } } @@ -779,6 +796,7 @@ pub type SubstrateHostFunctions = ( allocator::HostFunctions, logging::HostFunctions, sandbox::HostFunctions, + crate::trie::HostFunctions, ); #[cfg(test)] diff --git a/primitives/sr-primitives/src/traits.rs b/primitives/sr-primitives/src/traits.rs index 84ac039a1d..7c6a88acc2 100644 --- a/primitives/sr-primitives/src/traits.rs +++ b/primitives/sr-primitives/src/traits.rs @@ -384,12 +384,6 @@ pub trait Hash: 'static + MaybeSerializeDeserialize + Debug + Clone + Eq + Parti /// The Patricia tree root of the given mapping. fn trie_root(input: Vec<(Vec, Vec)>) -> Self::Output; - - /// Acquire the global storage root. - fn storage_root() -> Self::Output; - - /// Acquire the global storage changes root. - fn storage_changes_root(parent_hash: Self::Output) -> Option; } /// Blake2-256 Hash implementation. @@ -405,19 +399,11 @@ impl Hash for BlakeTwo256 { } fn trie_root(input: Vec<(Vec, Vec)>) -> Self::Output { - runtime_io::storage::blake2_256_trie_root(input) + runtime_io::trie::blake2_256_root(input) } fn ordered_trie_root(input: Vec>) -> Self::Output { - runtime_io::storage::blake2_256_ordered_trie_root(input) - } - - fn storage_root() -> Self::Output { - runtime_io::storage::root().into() - } - - fn storage_changes_root(parent_hash: Self::Output) -> Option { - runtime_io::storage::changes_root(parent_hash.into()).map(Into::into) + runtime_io::trie::blake2_256_ordered_root(input) } } diff --git a/primitives/state-machine/src/backend.rs b/primitives/state-machine/src/backend.rs index 5fbda1aa32..366634ae1a 100644 --- a/primitives/state-machine/src/backend.rs +++ b/primitives/state-machine/src/backend.rs @@ -25,6 +25,7 @@ use trie::{ TrieMut, MemoryDB, child_trie_root, default_child_trie_root, TrieConfiguration, trie_types::{TrieDBMut, Layout}, }; +use codec::{Encode, Codec}; /// A state backend is used to read state data and can have changes committed /// to it. @@ -95,7 +96,7 @@ pub trait Backend: std::fmt::Debug { /// Calculate the child storage root, with given delta over what is already stored in /// the backend, and produce a "transaction" that can be used to commit. The second argument /// is true if child storage root equals default storage root. - fn child_storage_root(&self, storage_key: &[u8], delta: I) -> (Vec, bool, Self::Transaction) + fn child_storage_root(&self, storage_key: &[u8], delta: I) -> (H::Out, bool, Self::Transaction) where I: IntoIterator, Option>)>, H::Out: Ord; @@ -134,7 +135,7 @@ pub trait Backend: std::fmt::Debug { I1: IntoIterator, Option>)>, I2i: IntoIterator, Option>)>, I2: IntoIterator, I2i)>, - ::Out: Ord, + H::Out: Ord + Encode, { let mut txs: Self::Transaction = Default::default(); let mut child_roots: Vec<_> = Default::default(); @@ -146,7 +147,7 @@ pub trait Backend: std::fmt::Debug { if empty { child_roots.push((storage_key, None)); } else { - child_roots.push((storage_key, Some(child_root))); + child_roots.push((storage_key, Some(child_root.encode()))); } } let (root, parent_txs) = self.storage_root( @@ -190,7 +191,7 @@ impl<'a, T: Backend, H: Hasher> Backend for &'a T { (*self).storage_root(delta) } - fn child_storage_root(&self, storage_key: &[u8], delta: I) -> (Vec, bool, Self::Transaction) + fn child_storage_root(&self, storage_key: &[u8], delta: I) -> (H::Out, bool, Self::Transaction) where I: IntoIterator, Option>)>, H::Out: Ord, @@ -287,7 +288,7 @@ impl PartialEq for InMemory { } } -impl InMemory { +impl InMemory where H::Out: Codec { /// Copy the state, with applied updates pub fn update(&self, changes: >::Transaction) -> Self { let mut inner: HashMap<_, _> = self.inner.clone(); @@ -362,7 +363,7 @@ impl InMemory { } } -impl Backend for InMemory { +impl Backend for InMemory where H::Out: Codec { type Error = Void; type Transaction = Vec<(Option>, Vec, Option>)>; type TrieBackendStorage = MemoryDB; @@ -418,7 +419,7 @@ impl Backend for InMemory { (root, full_transaction) } - fn child_storage_root(&self, storage_key: &[u8], delta: I) -> (Vec, bool, Self::Transaction) + fn child_storage_root(&self, storage_key: &[u8], delta: I) -> (H::Out, bool, Self::Transaction) where I: IntoIterator, Option>)>, H::Out: Ord diff --git a/primitives/state-machine/src/basic.rs b/primitives/state-machine/src/basic.rs index e758b3dd3b..82a0c21f20 100644 --- a/primitives/state-machine/src/basic.rs +++ b/primitives/state-machine/src/basic.rs @@ -26,9 +26,10 @@ use primitives::{ well_known_keys::is_child_storage_key, ChildStorageKey, StorageOverlay, ChildrenStorageOverlay }, - traits::Externalities, Blake2Hasher, hash::H256, + traits::Externalities, Blake2Hasher, }; use log::warn; +use codec::Encode; /// Simple HashMap-based Externalities impl. #[derive(Debug)] @@ -118,15 +119,15 @@ impl Externalities for BasicExternalities { self.top.get(key).cloned() } - fn storage_hash(&self, key: &[u8]) -> Option { - self.storage(key).map(|v| Blake2Hasher::hash(&v)) + fn storage_hash(&self, key: &[u8]) -> Option> { + self.storage(key).map(|v| Blake2Hasher::hash(&v).encode()) } fn original_storage(&self, key: &[u8]) -> Option> { self.storage(key) } - fn original_storage_hash(&self, key: &[u8]) -> Option { + fn original_storage_hash(&self, key: &[u8]) -> Option> { self.storage_hash(key) } @@ -134,11 +135,15 @@ impl Externalities for BasicExternalities { self.children.get(storage_key.as_ref()).and_then(|child| child.get(key)).cloned() } - fn child_storage_hash(&self, storage_key: ChildStorageKey, key: &[u8]) -> Option { - self.child_storage(storage_key, key).map(|v| Blake2Hasher::hash(&v)) + fn child_storage_hash(&self, storage_key: ChildStorageKey, key: &[u8]) -> Option> { + self.child_storage(storage_key, key).map(|v| Blake2Hasher::hash(&v).encode()) } - fn original_child_storage_hash(&self, storage_key: ChildStorageKey, key: &[u8]) -> Option { + fn original_child_storage_hash( + &self, + storage_key: ChildStorageKey, + key: &[u8], + ) -> Option> { self.child_storage_hash(storage_key, key) } @@ -196,7 +201,7 @@ impl Externalities for BasicExternalities { fn chain_id(&self) -> u64 { 42 } - fn storage_root(&mut self) -> H256 { + fn storage_root(&mut self) -> Vec { let mut top = self.top.clone(); let keys: Vec<_> = self.children.keys().map(|k| k.to_vec()).collect(); // Single child trie implementation currently allows using the same child @@ -215,7 +220,7 @@ impl Externalities for BasicExternalities { } } - Layout::::trie_root(self.top.clone()) + Layout::::trie_root(self.top.clone()).as_ref().into() } fn child_storage_root(&mut self, storage_key: ChildStorageKey) -> Vec { @@ -225,10 +230,10 @@ impl Externalities for BasicExternalities { InMemory::::default().child_storage_root(storage_key.as_ref(), delta).0 } else { default_child_trie_root::>(storage_key.as_ref()) - } + }.encode() } - fn storage_changes_root(&mut self, _parent: H256) -> Result, ()> { + fn storage_changes_root(&mut self, _parent: &[u8]) -> Result>, ()> { Ok(None) } } @@ -243,7 +248,7 @@ impl externalities::ExtensionStore for BasicExternalities { #[cfg(test)] mod tests { use super::*; - use primitives::{H256, map}; + use primitives::map; use primitives::storage::well_known_keys::CODE; use hex_literal::hex; @@ -255,7 +260,7 @@ mod tests { ext.set_storage(b"dogglesworth".to_vec(), b"cat".to_vec()); const ROOT: [u8; 32] = hex!("39245109cef3758c2eed2ccba8d9b370a917850af3824bc8348d505df2c298fa"); - assert_eq!(ext.storage_root(), H256::from(ROOT)); + assert_eq!(&ext.storage_root()[..], &ROOT); } #[test] diff --git a/primitives/state-machine/src/changes_trie/build.rs b/primitives/state-machine/src/changes_trie/build.rs index 10c38a41e2..6c50c028ca 100644 --- a/primitives/state-machine/src/changes_trie/build.rs +++ b/primitives/state-machine/src/changes_trie/build.rs @@ -18,7 +18,7 @@ use std::collections::{BTreeMap, BTreeSet}; use std::collections::btree_map::Entry; -use codec::Decode; +use codec::{Decode, Encode}; use hash_db::Hasher; use num_traits::One; use crate::backend::Backend; @@ -47,6 +47,7 @@ pub(crate) fn prepare_input<'a, B, H, Number>( where B: Backend, H: Hasher + 'a, + H::Out: Encode, Number: BlockNumber, { let number = parent.number.clone() + One::one(); @@ -200,7 +201,7 @@ fn prepare_digest_input<'a, H, Number>( ), String> where H: Hasher, - H::Out: 'a, + H::Out: 'a + Encode, Number: BlockNumber, { let build_skewed_digest = config.end.as_ref() == Some(&block); diff --git a/primitives/state-machine/src/changes_trie/changes_iterator.rs b/primitives/state-machine/src/changes_trie/changes_iterator.rs index 2f61b87fe2..017eb33d52 100644 --- a/primitives/state-machine/src/changes_trie/changes_iterator.rs +++ b/primitives/state-machine/src/changes_trie/changes_iterator.rs @@ -19,7 +19,7 @@ use std::cell::RefCell; use std::collections::VecDeque; -use codec::{Decode, Encode}; +use codec::{Decode, Encode, Codec}; use hash_db::Hasher; use num_traits::Zero; use trie::Recorder; @@ -81,7 +81,7 @@ pub fn key_changes_proof<'a, H: Hasher, Number: BlockNumber>( max: Number, storage_key: Option<&[u8]>, key: &[u8], -) -> Result>, String> { +) -> Result>, String> where H::Out: Codec { // we can't query any roots before root let max = ::std::cmp::min(max.clone(), end.number.clone()); @@ -129,7 +129,7 @@ pub fn key_changes_proof_check<'a, H: Hasher, Number: BlockNumber>( max: Number, storage_key: Option<&[u8]>, key: &[u8] -) -> Result, String> { +) -> Result, String> where H::Out: Encode { key_changes_proof_check_with_db( config, roots_storage, @@ -152,7 +152,7 @@ pub fn key_changes_proof_check_with_db<'a, H: Hasher, Number: BlockNumber>( max: Number, storage_key: Option<&[u8]>, key: &[u8] -) -> Result, String> { +) -> Result, String> where H::Out: Encode { // we can't query any roots before root let max = ::std::cmp::min(max.clone(), end.number.clone()); @@ -316,8 +316,8 @@ pub struct DrilldownIterator<'a, H, Number> essence: DrilldownIteratorEssence<'a, H, Number>, } -impl<'a, H: Hasher, Number: BlockNumber> Iterator - for DrilldownIterator<'a, H, Number> +impl<'a, H: Hasher, Number: BlockNumber> Iterator for DrilldownIterator<'a, H, Number> + where H::Out: Encode { type Item = Result<(Number, u32), String>; @@ -358,7 +358,7 @@ impl<'a, H, Number> Iterator for ProvingDrilldownIterator<'a, H, Number> where Number: BlockNumber, H: Hasher, - H::Out: 'a, + H::Out: 'a + Codec, { type Item = Result<(Number, u32), String>; diff --git a/primitives/state-machine/src/changes_trie/mod.rs b/primitives/state-machine/src/changes_trie/mod.rs index f771fddf61..0542ec6268 100644 --- a/primitives/state-machine/src/changes_trie/mod.rs +++ b/primitives/state-machine/src/changes_trie/mod.rs @@ -181,7 +181,7 @@ pub fn build_changes_trie<'a, B: Backend, S: Storage, H: Hasher, N parent_hash: H::Out, ) -> Result, H::Out, CacheAction)>, ()> where - H::Out: Ord + 'static, + H::Out: Ord + 'static + Encode, { let (storage, config) = match (storage, changes.changes_trie_config.as_ref()) { (Some(storage), Some(config)) => (storage, config), diff --git a/primitives/state-machine/src/changes_trie/prune.rs b/primitives/state-machine/src/changes_trie/prune.rs index fccd177e60..2f39f9162c 100644 --- a/primitives/state-machine/src/changes_trie/prune.rs +++ b/primitives/state-machine/src/changes_trie/prune.rs @@ -25,7 +25,7 @@ use crate::trie_backend_essence::TrieBackendEssence; use crate::changes_trie::{AnchorBlockId, Configuration, Storage, BlockNumber}; use crate::changes_trie::storage::TrieBackendAdapter; use crate::changes_trie::input::{ChildIndex, InputKey}; -use codec::Decode; +use codec::{Decode, Codec}; /// Get number of oldest block for which changes trie is not pruned /// given changes trie configuration, pruning parameter and number of @@ -55,7 +55,7 @@ pub fn prune, H: Hasher, Number: BlockNumber, F: FnMut(H:: min_blocks_to_keep: Number, current_block: &AnchorBlockId, mut remove_trie_node: F, -) { +) where H::Out: Codec { // select range for pruning let (first, last) = match pruning_range(config, min_blocks_to_keep, current_block.number.clone()) { @@ -116,7 +116,7 @@ fn prune_trie, H: Hasher, Number: BlockNumber, F: FnMut(H: storage: &S, root: H::Out, remove_trie_node: &mut F, -) { +) where H::Out: Codec { // enumerate all changes trie' keys, recording all nodes that have been 'touched' // (effectively - all changes trie nodes) @@ -221,13 +221,15 @@ mod tests { storage: &S, min_blocks_to_keep: u64, current_block: u64, - ) -> HashSet { + ) -> HashSet where H::Out: Codec { let mut pruned_trie_nodes = HashSet::new(); - prune(config, + prune( + config, storage, min_blocks_to_keep, &AnchorBlockId { hash: Default::default(), number: current_block }, - |node| { pruned_trie_nodes.insert(node); }); + |node| { pruned_trie_nodes.insert(node); }, + ); pruned_trie_nodes } diff --git a/primitives/state-machine/src/ext.rs b/primitives/state-machine/src/ext.rs index 0e93302a95..57197a4ae3 100644 --- a/primitives/state-machine/src/ext.rs +++ b/primitives/state-machine/src/ext.rs @@ -30,6 +30,7 @@ use primitives::{ }; use trie::{trie_types::Layout, MemoryDB, default_child_trie_root}; use externalities::Extensions; +use codec::{Decode, Encode}; use std::{error, fmt, any::{Any, TypeId}}; use log::{warn, trace}; @@ -189,25 +190,25 @@ where result } - fn storage_hash(&self, key: &[u8]) -> Option { + fn storage_hash(&self, key: &[u8]) -> Option> { let _guard = panic_handler::AbortGuard::force_abort(); let result = self.overlay .storage(key) .map(|x| x.map(|x| H::hash(x))) - .unwrap_or_else(|| - self.backend.storage_hash(key).expect(EXT_NOT_ALLOWED_TO_FAIL) - ); + .unwrap_or_else(|| self.backend.storage_hash(key).expect(EXT_NOT_ALLOWED_TO_FAIL)); + trace!(target: "state-trace", "{:04x}: Hash {}={:?}", self.id, HexDisplay::from(&key), result, ); - result + result.map(|r| r.encode()) } fn original_storage(&self, key: &[u8]) -> Option> { let _guard = panic_handler::AbortGuard::force_abort(); let result = self.backend.storage(key).expect(EXT_NOT_ALLOWED_TO_FAIL); + trace!(target: "state-trace", "{:04x}: GetOriginal {}={:?}", self.id, HexDisplay::from(&key), @@ -216,15 +217,16 @@ where result } - fn original_storage_hash(&self, key: &[u8]) -> Option { + fn original_storage_hash(&self, key: &[u8]) -> Option> { let _guard = panic_handler::AbortGuard::force_abort(); let result = self.backend.storage_hash(key).expect(EXT_NOT_ALLOWED_TO_FAIL); + trace!(target: "state-trace", "{:04x}: GetOriginalHash {}={:?}", self.id, HexDisplay::from(&key), result, ); - result + result.map(|r| r.encode()) } fn child_storage(&self, storage_key: ChildStorageKey, key: &[u8]) -> Option> { @@ -246,7 +248,7 @@ where result } - fn child_storage_hash(&self, storage_key: ChildStorageKey, key: &[u8]) -> Option { + fn child_storage_hash(&self, storage_key: ChildStorageKey, key: &[u8]) -> Option> { let _guard = panic_handler::AbortGuard::force_abort(); let result = self.overlay .child_storage(storage_key.as_ref(), key) @@ -262,7 +264,7 @@ where result, ); - result + result.map(|r| r.encode()) } fn original_child_storage(&self, storage_key: ChildStorageKey, key: &[u8]) -> Option> { @@ -280,7 +282,11 @@ where result } - fn original_child_storage_hash(&self, storage_key: ChildStorageKey, key: &[u8]) -> Option { + fn original_child_storage_hash( + &self, + storage_key: ChildStorageKey, + key: &[u8], + ) -> Option> { let _guard = panic_handler::AbortGuard::force_abort(); let result = self.backend .child_storage_hash(storage_key.as_ref(), key) @@ -292,7 +298,7 @@ where HexDisplay::from(&key), result, ); - result + result.map(|r| r.encode()) } fn exists_storage(&self, key: &[u8]) -> bool { @@ -415,14 +421,14 @@ where 42 } - fn storage_root(&mut self) -> H256 { + fn storage_root(&mut self) -> Vec { let _guard = panic_handler::AbortGuard::force_abort(); if let Some((_, ref root)) = self.storage_transaction { trace!(target: "state-trace", "{:04x}: Root (cached) {}", self.id, HexDisplay::from(&root.as_ref()), ); - return root.clone(); + return root.encode(); } let child_storage_keys = @@ -447,7 +453,7 @@ where self.id, HexDisplay::from(&root.as_ref()), ); - root + root.encode() } fn child_storage_root(&mut self, storage_key: ChildStorageKey) -> Vec { @@ -455,6 +461,7 @@ where if self.storage_transaction.is_some() { let root = self .storage(storage_key.as_ref()) + .and_then(|k| Decode::decode(&mut &k[..]).ok()) .unwrap_or( default_child_trie_root::>(storage_key.as_ref()) ); @@ -463,7 +470,7 @@ where HexDisplay::from(&storage_key.as_ref()), HexDisplay::from(&root.as_ref()), ); - root + root.encode() } else { let storage_key = storage_key.as_ref(); @@ -481,7 +488,7 @@ where if is_empty { self.overlay.set_storage(storage_key.into(), None); } else { - self.overlay.set_storage(storage_key.into(), Some(root.clone())); + self.overlay.set_storage(storage_key.into(), Some(root.encode())); } trace!(target: "state-trace", "{:04x}: ChildRoot({}) {}", @@ -489,20 +496,29 @@ where HexDisplay::from(&storage_key.as_ref()), HexDisplay::from(&root.as_ref()), ); - root - + root.encode() } } - fn storage_changes_root(&mut self, parent_hash: H256) -> Result, ()> { + fn storage_changes_root(&mut self, parent_hash: &[u8]) -> Result>, ()> { let _guard = panic_handler::AbortGuard::force_abort(); + self.changes_trie_transaction = build_changes_trie::<_, T, H, N>( self.backend, self.changes_trie_storage.clone(), self.overlay, - parent_hash, + H256::decode(&mut &parent_hash[..]).map_err(|e| + trace!( + target: "state-trace", + "Failed to decode changes root parent hash: {}", + e, + ) + )?, )?; - let result = Ok(self.changes_trie_transaction.as_ref().map(|(_, root, _)| root.clone())); + let result = Ok( + self.changes_trie_transaction.as_ref().map(|(_, root, _)| root.encode()) + ); + trace!(target: "state-trace", "{:04x}: ChangesRoot({}) {:?}", self.id, HexDisplay::from(&parent_hash.as_ref()), @@ -566,7 +582,7 @@ mod tests { let mut overlay = prepare_overlay_with_changes(); let backend = TestBackend::default(); let mut ext = TestExt::new(&mut overlay, &backend, None, None); - assert_eq!(ext.storage_changes_root(Default::default()).unwrap(), None); + assert_eq!(ext.storage_changes_root(&H256::default().encode()).unwrap(), None); } #[test] @@ -576,7 +592,7 @@ mod tests { let storage = TestChangesTrieStorage::with_blocks(vec![(100, Default::default())]); let backend = TestBackend::default(); let mut ext = TestExt::new(&mut overlay, &backend, Some(&storage), None); - assert_eq!(ext.storage_changes_root(Default::default()).unwrap(), None); + assert_eq!(ext.storage_changes_root(&H256::default().encode()).unwrap(), None); } #[test] @@ -586,8 +602,8 @@ mod tests { let backend = TestBackend::default(); let mut ext = TestExt::new(&mut overlay, &backend, Some(&storage), None); assert_eq!( - ext.storage_changes_root(Default::default()).unwrap(), - Some(hex!("bb0c2ef6e1d36d5490f9766cfcc7dfe2a6ca804504c3bb206053890d6dd02376").into()), + ext.storage_changes_root(&H256::default().encode()).unwrap(), + Some(hex!("bb0c2ef6e1d36d5490f9766cfcc7dfe2a6ca804504c3bb206053890d6dd02376").to_vec()), ); } @@ -599,8 +615,8 @@ mod tests { let backend = TestBackend::default(); let mut ext = TestExt::new(&mut overlay, &backend, Some(&storage), None); assert_eq!( - ext.storage_changes_root(Default::default()).unwrap(), - Some(hex!("96f5aae4690e7302737b6f9b7f8567d5bbb9eac1c315f80101235a92d9ec27f4").into()), + ext.storage_changes_root(&H256::default().encode()).unwrap(), + Some(hex!("96f5aae4690e7302737b6f9b7f8567d5bbb9eac1c315f80101235a92d9ec27f4").to_vec()), ); } } diff --git a/primitives/state-machine/src/lib.rs b/primitives/state-machine/src/lib.rs index 151b1a776f..d4798ad4fb 100644 --- a/primitives/state-machine/src/lib.rs +++ b/primitives/state-machine/src/lib.rs @@ -21,7 +21,7 @@ use std::{fmt, result, collections::HashMap, panic::UnwindSafe, marker::PhantomData}; use log::{warn, trace}; use hash_db::Hasher; -use codec::{Decode, Encode}; +use codec::{Decode, Encode, Codec}; use primitives::{ storage::well_known_keys, NativeOrEncoded, NeverNativeValue, traits::CodeExecutor, hexdisplay::HexDisplay, hash::H256, @@ -567,7 +567,7 @@ pub fn prove_child_read( where B: Backend, H: Hasher, - H::Out: Ord, + H::Out: Ord + Codec, I: IntoIterator, I::Item: AsRef<[u8]>, { @@ -584,7 +584,7 @@ pub fn prove_read_on_trie_backend( where S: trie_backend_essence::TrieBackendStorage, H: Hasher, - H::Out: Ord, + H::Out: Ord + Codec, I: IntoIterator, I::Item: AsRef<[u8]>, { @@ -606,7 +606,7 @@ pub fn prove_child_read_on_trie_backend( where S: trie_backend_essence::TrieBackendStorage, H: Hasher, - H::Out: Ord, + H::Out: Ord + Codec, I: IntoIterator, I::Item: AsRef<[u8]>, { @@ -627,7 +627,7 @@ pub fn read_proof_check( ) -> Result, Option>>, Box> where H: Hasher, - H::Out: Ord, + H::Out: Ord + Codec, I: IntoIterator, I::Item: AsRef<[u8]>, { @@ -649,7 +649,7 @@ pub fn read_child_proof_check( ) -> Result, Option>>, Box> where H: Hasher, - H::Out: Ord, + H::Out: Ord + Codec, I: IntoIterator, I::Item: AsRef<[u8]>, { @@ -673,7 +673,7 @@ pub fn read_proof_check_on_proving_backend( ) -> Result>, Box> where H: Hasher, - H::Out: Ord, + H::Out: Ord + Codec, { proving_backend.storage(key).map_err(|e| Box::new(e) as Box) } @@ -686,7 +686,7 @@ pub fn read_child_proof_check_on_proving_backend( ) -> Result>, Box> where H: Hasher, - H::Out: Ord, + H::Out: Ord + Codec, { proving_backend.child_storage(storage_key, key).map_err(|e| Box::new(e) as Box) } diff --git a/primitives/state-machine/src/overlayed_changes.rs b/primitives/state-machine/src/overlayed_changes.rs index 73cb8b604a..9bbfd68f67 100644 --- a/primitives/state-machine/src/overlayed_changes.rs +++ b/primitives/state-machine/src/overlayed_changes.rs @@ -352,7 +352,7 @@ impl From>> for OverlayedValue { mod tests { use hex_literal::hex; use primitives::{ - Blake2Hasher, H256, traits::Externalities, storage::well_known_keys::EXTRINSIC_INDEX, + Blake2Hasher, traits::Externalities, storage::well_known_keys::EXTRINSIC_INDEX, }; use crate::backend::InMemory; use crate::changes_trie::InMemoryStorage as InMemoryChangesTrieStorage; @@ -426,7 +426,7 @@ mod tests { ); const ROOT: [u8; 32] = hex!("39245109cef3758c2eed2ccba8d9b370a917850af3824bc8348d505df2c298fa"); - assert_eq!(ext.storage_root(), H256::from(ROOT)); + assert_eq!(&ext.storage_root()[..], &ROOT); } #[test] diff --git a/primitives/state-machine/src/proving_backend.rs b/primitives/state-machine/src/proving_backend.rs index 2ebd82f0c4..446dc635e1 100644 --- a/primitives/state-machine/src/proving_backend.rs +++ b/primitives/state-machine/src/proving_backend.rs @@ -18,7 +18,7 @@ use std::sync::Arc; use parking_lot::RwLock; -use codec::{Decode, Encode}; +use codec::{Decode, Encode, Codec}; use log::debug; use hash_db::{Hasher, HashDB, EMPTY_PREFIX, Prefix}; use trie::{ @@ -119,6 +119,7 @@ impl<'a, S, H> ProvingBackendRecorder<'a, S, H> where S: TrieBackendStorage, H: Hasher, + H::Out: Codec, { /// Produce proof for a key query. pub fn storage(&mut self, key: &[u8]) -> Result>, String> { @@ -145,6 +146,7 @@ impl<'a, S, H> ProvingBackendRecorder<'a, S, H> key: &[u8] ) -> Result>, String> { let root = self.storage(storage_key)? + .and_then(|r| Decode::decode(&mut &r[..]).ok()) .unwrap_or(default_child_trie_root::>(storage_key)); let mut read_overlay = S::Overlay::default(); @@ -158,7 +160,7 @@ impl<'a, S, H> ProvingBackendRecorder<'a, S, H> read_child_trie_value_with::, _, _>( storage_key, &eph, - &root, + &root.as_ref(), key, &mut *self.proof_recorder ).map_err(map_e) @@ -199,7 +201,9 @@ pub struct ProofRecorderBackend<'a, S: 'a + TrieBackendStorage, H: 'a + Hashe proof_recorder: ProofRecorder, } -impl<'a, S: 'a + TrieBackendStorage, H: 'a + Hasher> ProvingBackend<'a, S, H> { +impl<'a, S: 'a + TrieBackendStorage, H: 'a + Hasher> ProvingBackend<'a, S, H> + where H::Out: Codec +{ /// Create new proving backend. pub fn new(backend: &'a TrieBackend) -> Self { let proof_recorder = Default::default(); @@ -254,7 +258,7 @@ impl<'a, S, H> Backend for ProvingBackend<'a, S, H> where S: 'a + TrieBackendStorage, H: 'a + Hasher, - H::Out: Ord, + H::Out: Ord + Codec, { type Error = String; type Transaction = S::Overlay; @@ -302,7 +306,7 @@ impl<'a, S, H> Backend for ProvingBackend<'a, S, H> self.0.storage_root(delta) } - fn child_storage_root(&self, storage_key: &[u8], delta: I) -> (Vec, bool, Self::Transaction) + fn child_storage_root(&self, storage_key: &[u8], delta: I) -> (H::Out, bool, Self::Transaction) where I: IntoIterator, Option>)>, H::Out: Ord @@ -318,6 +322,7 @@ pub fn create_proof_check_backend( ) -> Result, H>, Box> where H: Hasher, + H::Out: Codec, { let db = create_proof_check_backend_storage(proof); diff --git a/primitives/state-machine/src/testing.rs b/primitives/state-machine/src/testing.rs index 61b338bc81..dd4f7c557e 100644 --- a/primitives/state-machine/src/testing.rs +++ b/primitives/state-machine/src/testing.rs @@ -178,7 +178,7 @@ mod tests { ext.set_storage(b"dog".to_vec(), b"puppy".to_vec()); ext.set_storage(b"dogglesworth".to_vec(), b"cat".to_vec()); const ROOT: [u8; 32] = hex!("2a340d3dfd52f5992c6b117e9e45f479e6da5afffafeb26ab619cf137a95aeb8"); - assert_eq!(ext.storage_root(), H256::from(ROOT)); + assert_eq!(&ext.storage_root()[..], &ROOT); } #[test] diff --git a/primitives/state-machine/src/trie_backend.rs b/primitives/state-machine/src/trie_backend.rs index 432ccf3e75..a2ca5c5d4a 100644 --- a/primitives/state-machine/src/trie_backend.rs +++ b/primitives/state-machine/src/trie_backend.rs @@ -22,13 +22,14 @@ use trie::{Trie, delta_trie_root, default_child_trie_root, child_delta_trie_root use trie::trie_types::{TrieDB, TrieError, Layout}; use crate::trie_backend_essence::{TrieBackendEssence, TrieBackendStorage, Ephemeral}; use crate::Backend; +use codec::{Codec, Decode}; /// Patricia trie-based backend. Transaction type is an overlay of changes to commit. pub struct TrieBackend, H: Hasher> { essence: TrieBackendEssence, } -impl, H: Hasher> TrieBackend { +impl, H: Hasher> TrieBackend where H::Out: Codec { /// Create new trie-based backend. pub fn new(storage: S, root: H::Out) -> Self { TrieBackend { @@ -64,7 +65,7 @@ impl, H: Hasher> std::fmt::Debug for TrieBackend } impl, H: Hasher> Backend for TrieBackend where - H::Out: Ord, + H::Out: Ord + Codec, { type Error = String; type Transaction = S::Overlay; @@ -159,16 +160,17 @@ impl, H: Hasher> Backend for TrieBackend where (root, write_overlay) } - fn child_storage_root(&self, storage_key: &[u8], delta: I) -> (Vec, bool, Self::Transaction) + fn child_storage_root(&self, storage_key: &[u8], delta: I) -> (H::Out, bool, Self::Transaction) where I: IntoIterator, Option>)>, - H::Out: Ord + H::Out: Ord, { let default_root = default_child_trie_root::>(storage_key); let mut write_overlay = S::Overlay::default(); let mut root = match self.storage(storage_key) { - Ok(value) => value.unwrap_or(default_root.clone()), + Ok(value) => + value.and_then(|r| Decode::decode(&mut &r[..]).ok()).unwrap_or(default_root.clone()), Err(e) => { warn!(target: "trie", "Failed to read child storage root: {}", e); default_root.clone() @@ -181,10 +183,10 @@ impl, H: Hasher> Backend for TrieBackend where &mut write_overlay, ); - match child_delta_trie_root::, _, _, _, _>( + match child_delta_trie_root::, _, _, _, _, _>( storage_key, &mut eph, - root.clone(), + root, delta ) { Ok(ret) => root = ret, diff --git a/primitives/state-machine/src/trie_backend_essence.rs b/primitives/state-machine/src/trie_backend_essence.rs index 5a54319634..a8572aff60 100644 --- a/primitives/state-machine/src/trie_backend_essence.rs +++ b/primitives/state-machine/src/trie_backend_essence.rs @@ -26,6 +26,7 @@ use trie::{Trie, MemoryDB, PrefixedMemoryDB, DBValue, for_keys_in_child_trie}; use trie::trie_types::{TrieDB, TrieError, Layout}; use crate::backend::Consolidate; +use codec::Encode; /// Patricia trie-based storage trait. pub trait Storage: Send + Sync { @@ -39,7 +40,7 @@ pub struct TrieBackendEssence, H: Hasher> { root: H::Out, } -impl, H: Hasher> TrieBackendEssence { +impl, H: Hasher> TrieBackendEssence where H::Out: Encode { /// Create new trie-based backend. pub fn new(storage: S, root: H::Out) -> Self { TrieBackendEssence { @@ -79,7 +80,7 @@ impl, H: Hasher> TrieBackendEssence { /// Get the value of child storage at given key. pub fn child_storage(&self, storage_key: &[u8], key: &[u8]) -> Result>, String> { let root = self.storage(storage_key)? - .unwrap_or(default_child_trie_root::>(storage_key)); + .unwrap_or(default_child_trie_root::>(storage_key).encode()); let mut read_overlay = S::Overlay::default(); let eph = Ephemeral { @@ -95,7 +96,7 @@ impl, H: Hasher> TrieBackendEssence { /// Retrieve all entries keys of child storage and call `f` for each of those keys. pub fn for_keys_in_child_storage(&self, storage_key: &[u8], f: F) { let root = match self.storage(storage_key) { - Ok(v) => v.unwrap_or(default_child_trie_root::>(storage_key)), + Ok(v) => v.unwrap_or(default_child_trie_root::>(storage_key).encode()), Err(e) => { debug!(target: "trie", "Error while iterating child storage: {}", e); return; @@ -119,9 +120,14 @@ impl, H: Hasher> TrieBackendEssence { } /// Execute given closure for all keys starting with prefix. - pub fn for_child_keys_with_prefix(&self, storage_key: &[u8], prefix: &[u8], mut f: F) { + pub fn for_child_keys_with_prefix( + &self, + storage_key: &[u8], + prefix: &[u8], + mut f: F, + ) { let root_vec = match self.storage(storage_key) { - Ok(v) => v.unwrap_or(default_child_trie_root::>(storage_key)), + Ok(v) => v.unwrap_or(default_child_trie_root::>(storage_key).encode()), Err(e) => { debug!(target: "trie", "Error while iterating child storage: {}", e); return; diff --git a/primitives/trie/src/lib.rs b/primitives/trie/src/lib.rs index de056cace1..e1315f011f 100644 --- a/primitives/trie/src/lib.rs +++ b/primitives/trie/src/lib.rs @@ -167,39 +167,45 @@ pub fn read_trie_value_with< } /// Determine the default child trie root. -pub fn default_child_trie_root(_storage_key: &[u8]) -> Vec { - L::trie_root::<_, Vec, Vec>(core::iter::empty()).as_ref().iter().cloned().collect() +pub fn default_child_trie_root( + _storage_key: &[u8], +) -> ::Out { + L::trie_root::<_, Vec, Vec>(core::iter::empty()) } /// Determine a child trie root given its ordered contents, closed form. H is the default hasher, /// but a generic implementation may ignore this type parameter and use other hashers. -pub fn child_trie_root(_storage_key: &[u8], input: I) -> Vec +pub fn child_trie_root( + _storage_key: &[u8], + input: I, +) -> ::Out where I: IntoIterator, A: AsRef<[u8]> + Ord, B: AsRef<[u8]>, { - L::trie_root(input).as_ref().iter().cloned().collect() + L::trie_root(input) } /// Determine a child trie root given a hash DB and delta values. H is the default hasher, /// but a generic implementation may ignore this type parameter and use other hashers. -pub fn child_delta_trie_root( +pub fn child_delta_trie_root( _storage_key: &[u8], db: &mut DB, - root_vec: Vec, - delta: I -) -> Result, Box>> + root_data: RD, + delta: I, +) -> Result<::Out, Box>> where I: IntoIterator)>, A: AsRef<[u8]> + Ord, B: AsRef<[u8]>, + RD: AsRef<[u8]>, DB: hash_db::HashDB + hash_db::PlainDB, trie_db::DBValue>, { let mut root = TrieHash::::default(); // root is fetched from DB, not writable by runtime, so it's always valid. - root.as_mut().copy_from_slice(&root_vec); + root.as_mut().copy_from_slice(root_data.as_ref()); { let mut trie = TrieDBMut::::from_existing(&mut *db, &mut root)?; @@ -212,7 +218,7 @@ pub fn child_delta_trie_root( } } - Ok(root.as_ref().to_vec()) + Ok(root) } /// Call `f` for all keys in a child trie. diff --git a/test/utils/runtime/src/system.rs b/test/utils/runtime/src/system.rs index 1ac318c417..1a04da1764 100644 --- a/test/utils/runtime/src/system.rs +++ b/test/utils/runtime/src/system.rs @@ -30,7 +30,7 @@ use sr_primitives::{ TransactionValidity, ValidTransaction, InvalidTransaction, TransactionValidityError, }, }; -use codec::{KeyedVec, Encode}; +use codec::{KeyedVec, Encode, Decode}; use frame_system::Trait; use crate::{ AccountId, BlockNumber, Extrinsic, Transfer, H256 as Hash, Block, Header, Digest, AuthorityId @@ -139,20 +139,26 @@ fn execute_block_with_state_root_handler( }); let o_new_authorities = ::take(); + let storage_root = Hash::decode(&mut &storage_root()[..]) + .expect("`storage_root` is a valid hash"); if let Mode::Overwrite = mode { - header.state_root = storage_root().into(); + header.state_root = storage_root; } else { // check storage root. - let storage_root = storage_root().into(); info_expect_equal_hash(&storage_root, &header.state_root); assert!(storage_root == header.state_root, "Storage root must match that calculated."); } // check digest let digest = &mut header.digest; - if let Some(storage_changes_root) = storage_changes_root(header.parent_hash.into()) { - digest.push(generic::DigestItem::ChangesTrieRoot(storage_changes_root.into())); + if let Some(storage_changes_root) = storage_changes_root(&header.parent_hash.encode()) { + digest.push( + generic::DigestItem::ChangesTrieRoot( + Hash::decode(&mut &storage_changes_root[..]) + .expect("`storage_changes_root` is a valid hash") + ) + ); } if let Some(new_authorities) = o_new_authorities { digest.push(generic::DigestItem::Consensus(*b"aura", new_authorities.encode())); @@ -226,8 +232,10 @@ pub fn finalize_block() -> Header { let o_new_authorities = ::take(); // This MUST come after all changes to storage are done. Otherwise we will fail the // “Storage root does not match that calculated” assertion. - let storage_root = BlakeTwo256::storage_root(); - let storage_changes_root = BlakeTwo256::storage_changes_root(parent_hash); + let storage_root = Hash::decode(&mut &storage_root()[..]) + .expect("`storage_root` is a valid hash"); + let storage_changes_root = storage_changes_root(&parent_hash.encode()) + .map(|r| Hash::decode(&mut &r[..]).expect("`storage_changes_root` is a valid hash")); if let Some(storage_changes_root) = storage_changes_root { digest.push(generic::DigestItem::ChangesTrieRoot(storage_changes_root)); -- GitLab From 2ffaf0541773956b68130d0a8c2cf3d435c83288 Mon Sep 17 00:00:00 2001 From: Svyatoslav Nikolsky Date: Thu, 28 Nov 2019 03:00:54 +0300 Subject: [PATCH 036/172] Recover transaction pool on light client (#3833) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * recover tx pool on light client * revert local tests fix * removed import renamings * futures03::Future -> std::future::Future * Update core/transaction-pool/graph/src/error.rs Co-Authored-By: Tomasz Drwięga * replace remove_from_ready with remove_invalid * avoid excess hashing * debug -> warn * TransactionPool + BasicTransactionPool * pause future tx reject when resubmitting * bump impl_version to make CI happy * and revert back local test fixes * alter doc to restart CI * Transaction::clone() -> Transaction::duplicate() * transactions -> updated_tranasctions * remove explicit consensus-common ref * ::std:: -> std:: * manual set/unset flag -> calling clusore with given flag value * removed comments * removed force argument * BestIterator -> Box * separate crate for TxPool + Maintainer trait * long line fix * pos-merge fix * fix benches compilation * Rename txpoolapi to txpool_api * Clean up. * Finalize merge. * post-merge fix * Move transaction pool api to primitives directly. * Consistent naming for txpool-runtime-api * Warn about missing docs. * Move abstraction for offchain calls to tx-pool-api. * Merge RPC instantiation. * Update cargo.lock * Post merge fixes. * Avoid depending on client. * Fix build --- .gitignore | 5 +- .maintain/common.sh | 21 - .maintain/update.sh | 29 - Cargo.lock | 75 ++- Cargo.toml | 1 + bin/node-template/Cargo.toml | 3 +- bin/node-template/runtime/Cargo.toml | 4 +- bin/node-template/runtime/src/lib.rs | 2 +- bin/node-template/src/service.rs | 23 +- bin/node/cli/Cargo.toml | 3 +- bin/node/cli/src/service.rs | 50 +- bin/node/rpc/Cargo.toml | 2 +- bin/node/rpc/src/lib.rs | 62 +- bin/node/runtime/Cargo.toml | 4 +- bin/node/runtime/src/lib.rs | 2 +- client/api/Cargo.toml | 1 + client/api/src/execution_extensions.rs | 7 +- client/api/src/light.rs | 25 +- client/basic-authorship/Cargo.toml | 3 +- .../basic-authorship/src/basic_authorship.rs | 44 +- client/basic-authorship/src/lib.rs | 5 +- client/offchain/Cargo.toml | 3 +- client/offchain/src/lib.rs | 29 +- client/rpc/Cargo.toml | 3 +- client/rpc/api/Cargo.toml | 2 +- client/rpc/api/src/author/error.rs | 4 +- client/rpc/api/src/author/mod.rs | 8 +- client/rpc/src/author/mod.rs | 67 +- client/rpc/src/author/tests.rs | 20 +- client/service/Cargo.toml | 5 +- client/service/src/builder.rs | 224 ++----- client/service/src/config.rs | 4 +- client/service/src/lib.rs | 57 +- client/service/test/Cargo.toml | 1 + client/service/test/src/lib.rs | 1 + client/transaction-pool/Cargo.toml | 7 +- client/transaction-pool/graph/Cargo.toml | 1 + .../transaction-pool/graph/benches/basics.rs | 4 +- .../transaction-pool/graph/src/base_pool.rs | 202 +++++- client/transaction-pool/graph/src/future.rs | 6 + client/transaction-pool/graph/src/lib.rs | 4 +- client/transaction-pool/graph/src/listener.rs | 2 +- client/transaction-pool/graph/src/pool.rs | 216 +++++-- client/transaction-pool/graph/src/ready.rs | 3 +- .../graph/src/validated_pool.rs | 177 +++++- client/transaction-pool/graph/src/watcher.rs | 45 +- client/transaction-pool/src/api.rs | 103 ++- client/transaction-pool/src/error.rs | 9 +- client/transaction-pool/src/lib.rs | 108 +++- client/transaction-pool/src/maintainer.rs | 587 ++++++++++++++++++ docs/CODEOWNERS | 1 + docs/README.adoc | 2 +- primitives/sr-primitives/src/offchain/mod.rs | 23 - primitives/transaction-pool/Cargo.toml | 14 + .../transaction-pool/runtime-api/Cargo.toml | 2 +- primitives/transaction-pool/src/error.rs | 82 +++ primitives/transaction-pool/src/lib.rs | 328 ++++++++++ test/utils/primitives/src/lib.rs | 2 +- test/utils/runtime/Cargo.toml | 4 +- test/utils/runtime/client/Cargo.toml | 1 + test/utils/runtime/client/src/lib.rs | 90 ++- test/utils/runtime/src/lib.rs | 4 +- utils/frame/rpc/system/Cargo.toml | 7 +- utils/frame/rpc/system/src/lib.rs | 206 ++++-- 64 files changed, 2371 insertions(+), 668 deletions(-) delete mode 100644 .maintain/common.sh delete mode 100755 .maintain/update.sh create mode 100644 client/transaction-pool/src/maintainer.rs create mode 100644 primitives/transaction-pool/Cargo.toml create mode 100644 primitives/transaction-pool/src/error.rs create mode 100644 primitives/transaction-pool/src/lib.rs diff --git a/.gitignore b/.gitignore index 6c79bfaf62..aadaa13912 100644 --- a/.gitignore +++ b/.gitignore @@ -2,14 +2,11 @@ **/*.rs.bk *.swp .wasm-binaries -polkadot/runtime/wasm/target/ -core/executor/wasm/target/ -core/test-runtime/wasm/target/ pwasm-alloc/target/ pwasm-libc/target/ pwasm-alloc/Cargo.lock pwasm-libc/Cargo.lock -node/runtime/wasm/target/ +bin/node/runtime/wasm/target/ **/._* **/.criterion/ .vscode diff --git a/.maintain/common.sh b/.maintain/common.sh deleted file mode 100644 index 8aff9acc57..0000000000 --- a/.maintain/common.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env bash - -ROOT=`dirname "$0"` - -# A list of directories which contain wasm projects. -SRCS=( - "core/executor/wasm" - "node/runtime/wasm" - "node-template/runtime/wasm" - "core/test-runtime/wasm" -) - -# Make pushd/popd silent. - -pushd () { - command pushd "$@" > /dev/null -} - -popd () { - command popd "$@" > /dev/null -} diff --git a/.maintain/update.sh b/.maintain/update.sh deleted file mode 100755 index a264fab43d..0000000000 --- a/.maintain/update.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env bash - -# This script assumes that all pre-requisites are installed. - -set -e - -PROJECT_ROOT=`git rev-parse --show-toplevel` -source `dirname "$0"`/common.sh - -export CARGO_INCREMENTAL=0 - -# Save current directory. -pushd . - -cd $ROOT - -for SRC in "${SRCS[@]}" -do - echo "*** Updating and building wasm binaries in $SRC" - cd "$PROJECT_ROOT/$SRC" - - cargo update - ./build.sh "$@" - - cd - >> /dev/null -done - -# Restore initial directory. -popd diff --git a/Cargo.lock b/Cargo.lock index 6ae7d4deab..506c4e966b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -915,6 +915,19 @@ name = "data-encoding" version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "derive_more" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "derive_more" version = "0.99.2" @@ -3009,6 +3022,7 @@ dependencies = [ "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "sp-finality-tracker 2.0.0", "sp-timestamp 2.0.0", + "sp-transaction-pool-api 2.0.0", "sr-io 2.0.0", "sr-primitives 2.0.0", "structopt 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3093,7 +3107,7 @@ dependencies = [ "node-runtime 2.0.0", "pallet-contracts-rpc 2.0.0", "pallet-transaction-payment-rpc 2.0.0", - "sc-transaction-pool 2.0.0", + "sp-transaction-pool-api 2.0.0", "sr-primitives 2.0.0", "substrate-client 2.0.0", "substrate-frame-rpc-system 2.0.0", @@ -3152,6 +3166,7 @@ dependencies = [ "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-transaction-pool-runtime-api 2.0.0", "sr-api 2.0.0", "sr-io 2.0.0", "sr-primitives 2.0.0", @@ -3166,7 +3181,6 @@ dependencies = [ "substrate-offchain-primitives 2.0.0", "substrate-primitives 2.0.0", "substrate-session 2.0.0", - "substrate-transaction-pool-runtime-api 2.0.0", "substrate-wasm-builder-runner 1.0.4", ] @@ -3182,6 +3196,7 @@ dependencies = [ "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sc-transaction-pool 2.0.0", + "sp-transaction-pool-api 2.0.0", "sr-io 2.0.0", "sr-primitives 2.0.0", "substrate-basic-authorship 2.0.0", @@ -3220,6 +3235,7 @@ dependencies = [ "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-transaction-pool-runtime-api 2.0.0", "sr-api 2.0.0", "sr-io 2.0.0", "sr-primitives 2.0.0", @@ -3231,7 +3247,6 @@ dependencies = [ "substrate-offchain-primitives 2.0.0", "substrate-primitives 2.0.0", "substrate-session 2.0.0", - "substrate-transaction-pool-runtime-api 2.0.0", "substrate-wasm-builder-runner 1.0.4", ] @@ -4842,9 +4857,9 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sc-transaction-graph 2.0.0", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-transaction-pool-api 2.0.0", "sr-version 2.0.0", "substrate-primitives 2.0.0", "substrate-rpc-primitives 2.0.0", @@ -4863,6 +4878,7 @@ dependencies = [ "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-transaction-pool-api 2.0.0", "sr-primitives 2.0.0", "substrate-primitives 2.0.0", "substrate-test-runtime 2.0.0", @@ -4878,12 +4894,15 @@ dependencies = [ "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sc-transaction-graph 2.0.0", + "sp-blockchain 2.0.0", + "sp-transaction-pool-api 2.0.0", + "sp-transaction-pool-runtime-api 2.0.0", "sr-api 2.0.0", "sr-primitives 2.0.0", + "substrate-client-api 2.0.0", "substrate-keyring 2.0.0", "substrate-primitives 2.0.0", "substrate-test-runtime-client 2.0.0", - "substrate-transaction-pool-runtime-api 2.0.0", ] [[package]] @@ -5225,6 +5244,28 @@ dependencies = [ "substrate-inherents 2.0.0", ] +[[package]] +name = "sp-transaction-pool-api" +version = "2.0.0" +dependencies = [ + "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "sr-primitives 2.0.0", + "substrate-primitives 2.0.0", +] + +[[package]] +name = "sp-transaction-pool-runtime-api" +version = "2.0.0" +dependencies = [ + "sr-api 2.0.0", + "sr-primitives 2.0.0", + "substrate-primitives 2.0.0", +] + [[package]] name = "spin" version = "0.5.2" @@ -5524,6 +5565,7 @@ dependencies = [ "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sc-transaction-pool 2.0.0", "sp-blockchain 2.0.0", + "sp-transaction-pool-api 2.0.0", "sr-primitives 2.0.0", "substrate-block-builder 2.0.0", "substrate-client 2.0.0", @@ -5688,6 +5730,7 @@ dependencies = [ "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sp-blockchain 2.0.0", + "sp-transaction-pool-api 2.0.0", "sr-api 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -6067,11 +6110,12 @@ dependencies = [ "jsonrpc-derive 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "sc-transaction-graph 2.0.0", "sc-transaction-pool 2.0.0", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "sp-blockchain 2.0.0", + "sp-transaction-pool-api 2.0.0", "sr-primitives 2.0.0", + "substrate-client 2.0.0", "substrate-primitives 2.0.0", "substrate-test-runtime-client 2.0.0", ] @@ -6182,6 +6226,7 @@ dependencies = [ "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "sc-transaction-pool 2.0.0", + "sp-transaction-pool-api 2.0.0", "sr-api 2.0.0", "sr-primitives 2.0.0", "substrate-client-api 2.0.0", @@ -6305,6 +6350,7 @@ dependencies = [ "sc-transaction-pool 2.0.0", "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", "sp-blockchain 2.0.0", + "sp-transaction-pool-api 2.0.0", "sr-api 2.0.0", "sr-io 2.0.0", "sr-primitives 2.0.0", @@ -6430,6 +6476,8 @@ dependencies = [ "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "sp-blockchain 2.0.0", + "sp-transaction-pool-api 2.0.0", + "sp-transaction-pool-runtime-api 2.0.0", "sr-api 2.0.0", "sr-io 2.0.0", "sr-primitives 2.0.0", @@ -6453,7 +6501,6 @@ dependencies = [ "substrate-telemetry 2.0.0", "substrate-test-runtime-client 2.0.0", "substrate-tracing 2.0.0", - "substrate-transaction-pool-runtime-api 2.0.0", "sysinfo 0.9.6 (registry+https://github.com/rust-lang/crates.io-index)", "target_info 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", @@ -6471,6 +6518,7 @@ dependencies = [ "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-transaction-pool-api 2.0.0", "sr-primitives 2.0.0", "substrate-client 2.0.0", "substrate-consensus-common 2.0.0", @@ -6586,6 +6634,7 @@ dependencies = [ "pallet-timestamp 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-transaction-pool-runtime-api 2.0.0", "sr-api 2.0.0", "sr-io 2.0.0", "sr-primitives 2.0.0", @@ -6605,7 +6654,6 @@ dependencies = [ "substrate-session 2.0.0", "substrate-state-machine 2.0.0", "substrate-test-runtime-client 2.0.0", - "substrate-transaction-pool-runtime-api 2.0.0", "substrate-trie 2.0.0", "substrate-wasm-builder-runner 1.0.4", "trie-db 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -6615,6 +6663,7 @@ dependencies = [ name = "substrate-test-runtime-client" version = "2.0.0" dependencies = [ + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "sp-blockchain 2.0.0", "sr-primitives 2.0.0", @@ -6642,15 +6691,6 @@ dependencies = [ "tracing-core 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "substrate-transaction-pool-runtime-api" -version = "2.0.0" -dependencies = [ - "sr-api 2.0.0", - "sr-primitives 2.0.0", - "substrate-primitives 2.0.0", -] - [[package]] name = "substrate-trie" version = "2.0.0" @@ -8044,6 +8084,7 @@ dependencies = [ "checksum cuckoofilter 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8dd43f7cfaffe0a386636a10baea2ee05cc50df3b77bea4a456c9572a939bf1f" "checksum curve25519-dalek 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8b7dcd30ba50cdf88b55b033456138b7c0ac4afdc436d82e1b79f370f24cc66d" "checksum data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f4f47ca1860a761136924ddd2422ba77b2ea54fe8cc75b9040804a0d9d32ad97" +"checksum derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a141330240c921ec6d074a3e188a7c7ef95668bb95e7d44fa0e5778ec2a7afe" "checksum derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2159be042979966de68315bce7034bb000c775f22e3e834e1c52ff78f041cae8" "checksum difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" "checksum digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" diff --git a/Cargo.toml b/Cargo.toml index 84fbb2430b..9b7ad19f83 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -126,6 +126,7 @@ members = [ "primitives/sr-version", "primitives/state-machine", "primitives/timestamp", + "primitives/transaction-pool", "primitives/transaction-pool/runtime-api", "primitives/trie", "primitives/wasm-interface", diff --git a/bin/node-template/Cargo.toml b/bin/node-template/Cargo.toml index 5e0ee24547..9fc248fe80 100644 --- a/bin/node-template/Cargo.toml +++ b/bin/node-template/Cargo.toml @@ -24,7 +24,8 @@ primitives = { package = "substrate-primitives", path = "../../primitives/core" substrate-executor = { path = "../../client/executor" } substrate-service = { path = "../../client/service" } inherents = { package = "substrate-inherents", path = "../../primitives/inherents" } -transaction-pool = { package = "sc-transaction-pool", path = "../../client/transaction-pool" } +txpool = { package = "sc-transaction-pool", path = "../../client/transaction-pool" } +txpool-api = { package = "sp-transaction-pool-api", path = "../../primitives/transaction-pool" } network = { package = "substrate-network", path = "../../client/network" } aura = { package = "substrate-consensus-aura", path = "../../client/consensus/aura" } aura-primitives = { package = "substrate-consensus-aura-primitives", path = "../../primitives/consensus/aura" } diff --git a/bin/node-template/runtime/Cargo.toml b/bin/node-template/runtime/Cargo.toml index f71c238d4c..46767e7098 100644 --- a/bin/node-template/runtime/Cargo.toml +++ b/bin/node-template/runtime/Cargo.toml @@ -29,7 +29,7 @@ support = { package = "frame-support", path = "../../../frame/support", default- system = { package = "frame-system", path = "../../../frame/system", default-features = false } timestamp = { package = "pallet-timestamp", path = "../../../frame/timestamp", default-features = false } transaction-payment = { package = "pallet-transaction-payment", path = "../../../frame/transaction-payment", default-features = false } -tx-pool-api = { package = "substrate-transaction-pool-runtime-api", path = "../../../primitives/transaction-pool/runtime-api", default-features = false } +txpool-runtime-api = { package = "sp-transaction-pool-runtime-api", path = "../../../primitives/transaction-pool/runtime-api", default-features = false } version = { package = "sr-version", path = "../../../primitives/sr-version", default-features = false } [build-dependencies] @@ -62,6 +62,6 @@ std = [ "system/std", "timestamp/std", "transaction-payment/std", - "tx-pool-api/std", + "txpool-runtime-api/std", "version/std", ] diff --git a/bin/node-template/runtime/src/lib.rs b/bin/node-template/runtime/src/lib.rs index 525452256b..36edeecc6e 100644 --- a/bin/node-template/runtime/src/lib.rs +++ b/bin/node-template/runtime/src/lib.rs @@ -328,7 +328,7 @@ impl_runtime_apis! { } } - impl tx_pool_api::TaggedTransactionQueue for Runtime { + impl txpool_runtime_api::TaggedTransactionQueue for Runtime { fn validate_transaction(tx: ::Extrinsic) -> TransactionValidity { Executive::validate_transaction(tx) } diff --git a/bin/node-template/src/service.rs b/bin/node-template/src/service.rs index ad517d956b..5a04459ef3 100644 --- a/bin/node-template/src/service.rs +++ b/bin/node-template/src/service.rs @@ -5,7 +5,6 @@ use std::time::Duration; use substrate_client::LongestChain; use runtime::{self, GenesisConfig, opaque::Block, RuntimeApi}; use substrate_service::{error::{Error as ServiceError}, AbstractService, Configuration, ServiceBuilder}; -use transaction_pool::{self, txpool::{Pool as TransactionPool}}; use inherents::InherentDataProviders; use network::{construct_simple_protocol}; use substrate_executor::native_executor_instance; @@ -41,9 +40,13 @@ macro_rules! new_full_start { .with_select_chain(|_config, backend| { Ok(substrate_client::LongestChain::new(backend.clone())) })? - .with_transaction_pool(|config, client| - Ok(transaction_pool::txpool::Pool::new(config, transaction_pool::FullChainApi::new(client))) - )? + .with_transaction_pool(|config, client, _fetcher| { + let pool_api = txpool::FullChainApi::new(client.clone()); + let pool = txpool::BasicPool::new(config, pool_api); + let maintainer = txpool::FullBasicPoolMaintainer::new(pool.pool().clone(), client); + let maintainable_pool = txpool_api::MaintainableTransactionPool::new(pool, maintainer); + Ok(maintainable_pool) + })? .with_import_queue(|_config, client, mut select_chain, transaction_pool| { let select_chain = select_chain.take() .ok_or_else(|| substrate_service::Error::SelectChainRequired)?; @@ -191,9 +194,15 @@ pub fn new_light(config: Configuration RpcExtension { - node_rpc::create(client, pool) + .with_rpc_extensions(|client, pool, _backend, fetcher, _remote_blockchain| -> Result { + Ok(node_rpc::create(client, pool, node_rpc::LightDeps::none(fetcher))) })?; (builder, import_setup, inherent_data_providers) @@ -267,6 +270,17 @@ type ConcreteClient = >; #[allow(dead_code)] type ConcreteBackend = Backend; +#[allow(dead_code)] +type ConcreteTransactionPool = txpool_api::MaintainableTransactionPool< + txpool::BasicPool< + txpool::FullChainApi, + ConcreteBlock + >, + txpool::FullBasicPoolMaintainer< + ConcreteClient, + txpool::FullChainApi + > +>; /// A specialized configuration object for setting up the node.. pub type NodeConfiguration = Configuration; @@ -280,7 +294,7 @@ pub fn new_full(config: NodeConfiguration) LongestChain, NetworkStatus, NetworkService::Hash>, - TransactionPool>, + ConcreteTransactionPool, OffchainWorkers< ConcreteClient, >::OffchainStorage, @@ -303,9 +317,15 @@ pub fn new_light(config: NodeConfiguration) .with_select_chain(|_config, backend| { Ok(LongestChain::new(backend.clone())) })? - .with_transaction_pool(|config, client| - Ok(TransactionPool::new(config, transaction_pool::FullChainApi::new(client))) - )? + .with_transaction_pool(|config, client, fetcher| { + let fetcher = fetcher + .ok_or_else(|| "Trying to start light transaction pool without active fetcher")?; + let pool_api = txpool::LightChainApi::new(client.clone(), fetcher.clone()); + let pool = txpool::BasicPool::new(config, pool_api); + let maintainer = txpool::LightBasicPoolMaintainer::with_defaults(pool.pool().clone(), client, fetcher); + let maintainable_pool = txpool_api::MaintainableTransactionPool::new(pool, maintainer); + Ok(maintainable_pool) + })? .with_import_queue_and_fprb(|_config, client, backend, fetcher, _select_chain, _tx_pool| { let fetch_checker = fetcher .map(|fetcher| fetcher.checker().clone()) @@ -344,8 +364,14 @@ pub fn new_light(config: NodeConfiguration) .with_finality_proof_provider(|client, backend| Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, client)) as _) )? - .with_rpc_extensions(|client, pool, _backend| -> RpcExtension { - node_rpc::create(client, pool) + .with_rpc_extensions(|client, pool, _backend, fetcher, remote_blockchain| -> Result { + let fetcher = fetcher + .ok_or_else(|| "Trying to start node RPC without active fetcher")?; + let remote_blockchain = remote_blockchain + .ok_or_else(|| "Trying to start node RPC without active remote blockchain")?; + + let light_deps = node_rpc::LightDeps { remote_blockchain, fetcher }; + Ok(node_rpc::create(client, pool, Some(light_deps))) })? .build()?; diff --git a/bin/node/rpc/Cargo.toml b/bin/node/rpc/Cargo.toml index d267118c12..fb571e2706 100644 --- a/bin/node/rpc/Cargo.toml +++ b/bin/node/rpc/Cargo.toml @@ -13,4 +13,4 @@ sr-primitives = { path = "../../../primitives/sr-primitives" } pallet-contracts-rpc = { path = "../../../frame/contracts/rpc/" } pallet-transaction-payment-rpc = { path = "../../../frame/transaction-payment/rpc/" } substrate-frame-rpc-system = { path = "../../../utils/frame/rpc/system" } -transaction_pool = { package = "sc-transaction-pool", path = "../../../client/transaction-pool" } +txpool-api = { package = "sp-transaction-pool-api", path = "../../../primitives/transaction-pool" } diff --git a/bin/node/rpc/src/lib.rs b/bin/node/rpc/src/lib.rs index cb7aee283b..06b0e33606 100644 --- a/bin/node/rpc/src/lib.rs +++ b/bin/node/rpc/src/lib.rs @@ -34,32 +34,68 @@ use std::sync::Arc; use node_primitives::{Block, AccountId, Index, Balance}; use node_runtime::UncheckedExtrinsic; use sr_primitives::traits::ProvideRuntimeApi; -use transaction_pool::txpool::{ChainApi, Pool}; +use txpool_api::TransactionPool; + +/// Light client extra dependencies. +pub struct LightDeps { + /// Remote access to the blockchain (async). + pub remote_blockchain: Arc>, + /// Fetcher instance. + pub fetcher: Arc, +} + +impl LightDeps { + /// Create empty `LightDeps` with given `F` type. + /// + /// This is a convenience method to be used in the service builder, + /// to make sure the type of the `LightDeps` is matching. + pub fn none(_: Option>) -> Option { + None + } +} /// Instantiate all RPC extensions. -pub fn create(client: Arc, pool: Arc>) -> jsonrpc_core::IoHandler where +/// +/// If you provide `LightDeps`, the system is configured for light client. +pub fn create( + client: Arc, + pool: Arc

, + light_deps: Option>, +) -> jsonrpc_core::IoHandler where C: ProvideRuntimeApi, C: client::blockchain::HeaderBackend, C: Send + Sync + 'static, C::Api: substrate_frame_rpc_system::AccountNonceApi, C::Api: pallet_contracts_rpc::ContractsRuntimeApi, C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi, - P: ChainApi + Sync + Send + 'static, + F: client::light::fetcher::Fetcher + 'static, + P: TransactionPool + 'static, M: jsonrpc_core::Metadata + Default, { - use substrate_frame_rpc_system::{System, SystemApi}; + use substrate_frame_rpc_system::{FullSystem, LightSystem, SystemApi}; use pallet_contracts_rpc::{Contracts, ContractsApi}; use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi}; let mut io = jsonrpc_core::IoHandler::default(); - io.extend_with( - SystemApi::to_delegate(System::new(client.clone(), pool)) - ); - io.extend_with( - ContractsApi::to_delegate(Contracts::new(client.clone())) - ); - io.extend_with( - TransactionPaymentApi::to_delegate(TransactionPayment::new(client)) - ); + + if let Some(LightDeps { remote_blockchain, fetcher }) = light_deps { + io.extend_with( + SystemApi::::to_delegate(LightSystem::new(client, remote_blockchain, fetcher, pool)) + ); + } else { + io.extend_with( + SystemApi::to_delegate(FullSystem::new(client.clone(), pool)) + ); + + // Making synchronous calls in light client freezes the browser currently, + // more context: https://github.com/paritytech/substrate/pull/3480 + // These RPCs should use an asynchronous caller instead. + io.extend_with( + ContractsApi::to_delegate(Contracts::new(client.clone())) + ); + io.extend_with( + TransactionPaymentApi::to_delegate(TransactionPayment::new(client)) + ); + } io } diff --git a/bin/node/runtime/Cargo.toml b/bin/node/runtime/Cargo.toml index f5c4d5855b..c24e4eb4d0 100644 --- a/bin/node/runtime/Cargo.toml +++ b/bin/node/runtime/Cargo.toml @@ -27,7 +27,7 @@ sr-primitives = { path = "../../../primitives/sr-primitives", default-features = sr-staking-primitives = { path = "../../../primitives/sr-staking-primitives", default-features = false } substrate-keyring = { path = "../../../primitives/keyring", optional = true } substrate-session = { path = "../../../primitives/session", default-features = false } -tx-pool-api = { package = "substrate-transaction-pool-runtime-api", path = "../../../primitives/transaction-pool/runtime-api", default-features = false } +txpool-runtime-api = { package = "sp-transaction-pool-runtime-api", path = "../../../primitives/transaction-pool/runtime-api", default-features = false } version = { package = "sr-version", path = "../../../primitives/sr-version", default-features = false } # frame dependencies @@ -116,7 +116,7 @@ std = [ "transaction-payment-rpc-runtime-api/std", "transaction-payment/std", "treasury/std", - "tx-pool-api/std", + "txpool-runtime-api/std", "utility/std", "version/std", ] diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index d55f37da12..c1ae051020 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -609,7 +609,7 @@ impl_runtime_apis! { } } - impl tx_pool_api::TaggedTransactionQueue for Runtime { + impl txpool_runtime_api::TaggedTransactionQueue for Runtime { fn validate_transaction(tx: ::Extrinsic) -> TransactionValidity { Executive::validate_transaction(tx) } diff --git a/client/api/Cargo.toml b/client/api/Cargo.toml index ff83aa412b..b48990d763 100644 --- a/client/api/Cargo.toml +++ b/client/api/Cargo.toml @@ -29,6 +29,7 @@ sr-primitives = { path = "../../primitives/sr-primitives", default-features = fa state-machine = { package = "substrate-state-machine", path = "../../primitives/state-machine" } substrate-telemetry = { path = "../telemetry" } trie = { package = "substrate-trie", path = "../../primitives/trie" } +txpool-api = { package = "sp-transaction-pool-api", path = "../../primitives/transaction-pool" } [dev-dependencies] env_logger = "0.7.0" diff --git a/client/api/src/execution_extensions.rs b/client/api/src/execution_extensions.rs index 83d70998e1..94ce6c573e 100644 --- a/client/api/src/execution_extensions.rs +++ b/client/api/src/execution_extensions.rs @@ -30,7 +30,6 @@ use primitives::{ use sr_primitives::{ generic::BlockId, traits, - offchain::{TransactionPool}, }; use state_machine::{ExecutionStrategy, ExecutionManager, DefaultHandler}; use externalities::Extensions; @@ -71,7 +70,7 @@ impl Default for ExecutionStrategies { pub struct ExecutionExtensions { strategies: ExecutionStrategies, keystore: Option, - transaction_pool: RwLock>>>, + transaction_pool: RwLock>>>, } impl Default for ExecutionExtensions { @@ -105,7 +104,7 @@ impl ExecutionExtensions { /// extension to be a `Weak` reference. /// That's also the reason why it's being registered lazily instead of /// during initialisation. - pub fn register_transaction_pool(&self, pool: Weak>) { + pub fn register_transaction_pool(&self, pool: Weak>) { *self.transaction_pool.write() = Some(pool); } @@ -166,7 +165,7 @@ impl ExecutionExtensions { /// A wrapper type to pass `BlockId` to the actual transaction pool. struct TransactionPoolAdapter { at: BlockId, - pool: Arc>, + pool: Arc>, } impl offchain::TransactionPool for TransactionPoolAdapter { diff --git a/client/api/src/light.rs b/client/api/src/light.rs index d0206dbc40..56a18dcc1f 100644 --- a/client/api/src/light.rs +++ b/client/api/src/light.rs @@ -139,15 +139,30 @@ pub struct RemoteBodyRequest { /// is correct (see FetchedDataChecker) and return already checked data. pub trait Fetcher: Send + Sync { /// Remote header future. - type RemoteHeaderResult: Future> + Send + 'static; + type RemoteHeaderResult: Future> + Unpin + Send + 'static; /// Remote storage read future. - type RemoteReadResult: Future, Option>>, ClientError>> + Send + 'static; + type RemoteReadResult: Future, Option>>, + ClientError, + >> + Unpin + Send + 'static; /// Remote call result future. - type RemoteCallResult: Future, ClientError>> + Send + 'static; + type RemoteCallResult: Future, + ClientError, + >> + Unpin + Send + 'static; /// Remote changes result future. - type RemoteChangesResult: Future, u32)>, ClientError>> + Send + 'static; + type RemoteChangesResult: Future, u32)>, + ClientError, + >> + Unpin + Send + 'static; /// Remote block body result future. - type RemoteBodyResult: Future, ClientError>> + Send + 'static; + type RemoteBodyResult: Future, + ClientError, + >> + Unpin + Send + 'static; /// Fetch remote header. fn remote_header(&self, request: RemoteHeaderRequest) -> Self::RemoteHeaderResult; diff --git a/client/basic-authorship/Cargo.toml b/client/basic-authorship/Cargo.toml index 852a9bbe78..c284f4b2ee 100644 --- a/client/basic-authorship/Cargo.toml +++ b/client/basic-authorship/Cargo.toml @@ -16,10 +16,11 @@ client-api = { package = "substrate-client-api", path = "../api" } consensus_common = { package = "substrate-consensus-common", path = "../../primitives/consensus/common" } inherents = { package = "substrate-inherents", path = "../../primitives/inherents" } substrate-telemetry = { path = "../telemetry" } -transaction_pool = { package = "sc-transaction-pool", path = "../../client/transaction-pool" } +txpool-api = { package = "sp-transaction-pool-api", path = "../../primitives/transaction-pool" } block-builder = { package = "substrate-block-builder", path = "../block-builder" } tokio-executor = { version = "0.2.0-alpha.6", features = ["blocking"] } [dev-dependencies] +txpool = { package = "sc-transaction-pool", path = "../../client/transaction-pool" } test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client" } parking_lot = "0.9" diff --git a/client/basic-authorship/src/basic_authorship.rs b/client/basic-authorship/src/basic_authorship.rs index 46494ef4bb..abffe8ee40 100644 --- a/client/basic-authorship/src/basic_authorship.rs +++ b/client/basic-authorship/src/basic_authorship.rs @@ -33,21 +33,21 @@ use sr_primitives::{ }, generic::BlockId, }; -use transaction_pool::txpool::{self, Pool as TransactionPool}; +use txpool_api::{TransactionPool, InPoolTransaction}; use substrate_telemetry::{telemetry, CONSENSUS_INFO}; use block_builder::BlockBuilderApi; /// Proposer factory. -pub struct ProposerFactory where A: txpool::ChainApi { +pub struct ProposerFactory where A: TransactionPool { /// The client instance. pub client: Arc, /// The transaction pool. - pub transaction_pool: Arc>, + pub transaction_pool: Arc, } impl ProposerFactory, A> where - A: txpool::ChainApi + 'static, + A: TransactionPool + 'static, B: client_api::backend::Backend + Send + Sync + 'static, E: CallExecutor + Send + Sync + Clone + 'static, Block: BlockT, @@ -85,7 +85,7 @@ where impl consensus_common::Environment for ProposerFactory, A> where - A: txpool::ChainApi + 'static, + A: TransactionPool + 'static, B: client_api::backend::Backend + Send + Sync + 'static, E: CallExecutor + Send + Sync + Clone + 'static, Block: BlockT, @@ -106,24 +106,24 @@ where } /// The proposer logic. -pub struct Proposer { +pub struct Proposer { inner: Arc>, } /// Proposer inner, to wrap parameters under Arc. -struct ProposerInner { +struct ProposerInner { client: Arc, parent_hash: ::Hash, parent_id: BlockId, parent_number: <::Header as HeaderT>::Number, - transaction_pool: Arc>, + transaction_pool: Arc, now: Box time::Instant + Send + Sync>, } impl consensus_common::Proposer for Proposer, A> where - A: txpool::ChainApi + 'static, + A: TransactionPool + 'static, B: client_api::backend::Backend + Send + Sync + 'static, E: CallExecutor + Send + Sync + Clone + 'static, Block: BlockT, @@ -151,7 +151,7 @@ where } impl ProposerInner, A> where - A: txpool::ChainApi + 'static, + A: TransactionPool + 'static, B: client_api::backend::Backend + Send + Sync + 'static, E: CallExecutor + Send + Sync + Clone + 'static, Block: BlockT, @@ -192,22 +192,24 @@ impl ProposerInner, let pending_iterator = self.transaction_pool.ready(); debug!("Attempting to push transactions from the pool."); - for pending in pending_iterator { + for pending_tx in pending_iterator { if (self.now)() > deadline { debug!("Consensus deadline reached when pushing block transactions, proceeding with proposing."); break; } - trace!("[{:?}] Pushing to the block.", pending.hash); - match block_builder::BlockBuilder::push(&mut block_builder, pending.data.clone()) { + let pending_tx_data = pending_tx.data().clone(); + let pending_tx_hash = pending_tx.hash().clone(); + trace!("[{:?}] Pushing to the block.", pending_tx_hash); + match block_builder::BlockBuilder::push(&mut block_builder, pending_tx_data) { Ok(()) => { - debug!("[{:?}] Pushed to the block.", pending.hash); + debug!("[{:?}] Pushed to the block.", pending_tx_hash); } Err(sp_blockchain::Error::ApplyExtrinsicFailed(sp_blockchain::ApplyExtrinsicFailed::Validity(e))) if e.exhausted_resources() => { if is_first { - debug!("[{:?}] Invalid transaction: FullBlock on empty block", pending.hash); - unqueue_invalid.push(pending.hash.clone()); + debug!("[{:?}] Invalid transaction: FullBlock on empty block", pending_tx_hash); + unqueue_invalid.push(pending_tx_hash); } else if skipped < MAX_SKIPPED_TRANSACTIONS { skipped += 1; debug!( @@ -220,8 +222,8 @@ impl ProposerInner, } } Err(e) => { - debug!("[{:?}] Invalid transaction: {}", pending.hash, e); - unqueue_invalid.push(pending.hash.clone()); + debug!("[{:?}] Invalid transaction: {}", pending_tx_hash, e); + unqueue_invalid.push(pending_tx_hash); } } @@ -266,6 +268,7 @@ mod tests { use parking_lot::Mutex; use consensus_common::Proposer; use test_client::{self, runtime::{Extrinsic, Transfer}, AccountKeyring}; + use txpool::{BasicPool, FullChainApi}; fn extrinsic(nonce: u64) -> Extrinsic { Transfer { @@ -280,11 +283,10 @@ mod tests { fn should_cease_building_block_when_deadline_is_reached() { // given let client = Arc::new(test_client::new()); - let chain_api = transaction_pool::FullChainApi::new(client.clone()); - let txpool = Arc::new(TransactionPool::new(Default::default(), chain_api)); + let txpool = Arc::new(BasicPool::new(Default::default(), FullChainApi::new(client.clone()))); futures::executor::block_on( - txpool.submit_at(&BlockId::number(0), vec![extrinsic(0), extrinsic(1)], false) + txpool.submit_at(&BlockId::number(0), vec![extrinsic(0), extrinsic(1)]) ).unwrap(); let mut proposer_factory = ProposerFactory { diff --git a/client/basic-authorship/src/lib.rs b/client/basic-authorship/src/lib.rs index 7961e4fe9e..de4a8af93b 100644 --- a/client/basic-authorship/src/lib.rs +++ b/client/basic-authorship/src/lib.rs @@ -24,10 +24,9 @@ //! # use sr_primitives::generic::BlockId; //! # use std::{sync::Arc, time::Duration}; //! # use test_client::{self, runtime::{Extrinsic, Transfer}, AccountKeyring}; -//! # use transaction_pool::txpool::{self, Pool as TransactionPool}; +//! # use txpool::{BasicPool, FullChainApi}; //! # let client = Arc::new(test_client::new()); -//! # let chain_api = transaction_pool::FullChainApi::new(client.clone()); -//! # let txpool = Arc::new(TransactionPool::new(Default::default(), chain_api)); +//! # let txpool = Arc::new(BasicPool::new(Default::default(), FullChainApi::new(client.clone()))); //! // The first step is to create a `ProposerFactory`. //! let mut proposer_factory = ProposerFactory { //! client: client.clone(), diff --git a/client/offchain/Cargo.toml b/client/offchain/Cargo.toml index afec2af4fd..d7e0ba1e98 100644 --- a/client/offchain/Cargo.toml +++ b/client/offchain/Cargo.toml @@ -35,7 +35,8 @@ client-db = { package = "substrate-client-db", path = "../db/", default-features env_logger = "0.7.0" test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client" } tokio = "0.1.22" -transaction_pool = { package = "sc-transaction-pool", path = "../../client/transaction-pool" } +txpool = { package = "sc-transaction-pool", path = "../../client/transaction-pool" } +txpool-api = { package = "sp-transaction-pool-api", path = "../../primitives/transaction-pool" } [features] default = [] diff --git a/client/offchain/src/lib.rs b/client/offchain/src/lib.rs index a1db2456bd..bf7965d308 100644 --- a/client/offchain/src/lib.rs +++ b/client/offchain/src/lib.rs @@ -145,9 +145,11 @@ impl OffchainWorkers< #[cfg(test)] mod tests { use super::*; - use network::{Multiaddr, PeerId}; use std::sync::Arc; - use transaction_pool::txpool::Pool; + use network::{Multiaddr, PeerId}; + use test_client::runtime::Block; + use txpool::{BasicPool, FullChainApi}; + use txpool_api::{TransactionPool, InPoolTransaction}; struct MockNetworkStateInfo(); @@ -161,15 +163,26 @@ mod tests { } } + struct TestPool(BasicPool, Block>); + + impl txpool_api::OffchainSubmitTransaction for TestPool { + fn submit_at( + &self, + at: &BlockId, + extrinsic: ::Extrinsic, + ) -> Result<(), ()> { + futures::executor::block_on(self.0.submit_one(&at, extrinsic)) + .map(|_| ()) + .map_err(|_| ()) + } + } + #[test] fn should_call_into_runtime_and_produce_extrinsic() { // given let _ = env_logger::try_init(); let client = Arc::new(test_client::new()); - let pool = Arc::new(Pool::new( - Default::default(), - transaction_pool::FullChainApi::new(client.clone()) - )); + let pool = Arc::new(TestPool(BasicPool::new(Default::default(), FullChainApi::new(client.clone())))); client.execution_extensions() .register_transaction_pool(Arc::downgrade(&pool.clone()) as _); let db = client_db::offchain::LocalStorage::new_test(); @@ -180,7 +193,7 @@ mod tests { futures::executor::block_on(offchain.on_block_imported(&0u64, network_state, false)); // then - assert_eq!(pool.status().ready, 1); - assert_eq!(pool.ready().next().unwrap().is_propagateable(), false); + assert_eq!(pool.0.status().ready, 1); + assert_eq!(pool.0.ready().next().unwrap().is_propagateable(), false); } } diff --git a/client/rpc/Cargo.toml b/client/rpc/Cargo.toml index a42ada7205..afc79ed026 100644 --- a/client/rpc/Cargo.toml +++ b/client/rpc/Cargo.toml @@ -23,7 +23,7 @@ rpc-primitives = { package = "substrate-rpc-primitives", path = "../../primitive state_machine = { package = "substrate-state-machine", path = "../../primitives/state-machine" } substrate-executor = { path = "../executor" } substrate-keystore = { path = "../keystore" } -transaction_pool = { package = "sc-transaction-pool", path = "../../client/transaction-pool" } +txpool-api = { package = "sp-transaction-pool-api", path = "../../primitives/transaction-pool" } sp-blockchain = { path = "../../primitives/blockchain" } hash-db = { version = "0.15.2", default-features = false } parking_lot = { version = "0.9.0" } @@ -36,3 +36,4 @@ rustc-hex = "2.0.1" sr-io = { path = "../../primitives/sr-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/client/rpc/api/Cargo.toml b/client/rpc/api/Cargo.toml index 9d88aae9a0..acc4aa1c00 100644 --- a/client/rpc/api/Cargo.toml +++ b/client/rpc/api/Cargo.toml @@ -18,5 +18,5 @@ primitives = { package = "substrate-primitives", path = "../../../primitives/cor runtime_version = { package = "sr-version", path = "../../../primitives/sr-version" } serde = { version = "1.0.101", features = ["derive"] } serde_json = "1.0.41" -txpool = { package = "sc-transaction-graph", path = "../../../client/transaction-pool/graph" } +txpool-api = { package = "sp-transaction-pool-api", path = "../../../primitives/transaction-pool" } rpc-primitives = { package = "substrate-rpc-primitives", path = "../../../primitives/rpc" } diff --git a/client/rpc/api/src/author/error.rs b/client/rpc/api/src/author/error.rs index d1c943ef44..eb98fbda51 100644 --- a/client/rpc/api/src/author/error.rs +++ b/client/rpc/api/src/author/error.rs @@ -34,7 +34,7 @@ pub enum Error { Client(Box), /// Transaction pool error, #[display(fmt="Transaction pool error: {}", _0)] - Pool(txpool::error::Error), + Pool(txpool_api::error::Error), /// Verification error #[display(fmt="Extrinsic verification error: {}", _0)] #[from(ignore)] @@ -93,7 +93,7 @@ const UNSUPPORTED_KEY_TYPE: i64 = POOL_INVALID_TX + 7; impl From for rpc::Error { fn from(e: Error) -> Self { - use txpool::error::{Error as PoolError}; + use txpool_api::error::{Error as PoolError}; match e { Error::BadFormat(e) => rpc::Error { diff --git a/client/rpc/api/src/author/mod.rs b/client/rpc/api/src/author/mod.rs index 4ea96cb3c6..927bb530ea 100644 --- a/client/rpc/api/src/author/mod.rs +++ b/client/rpc/api/src/author/mod.rs @@ -21,11 +21,9 @@ pub mod hash; use jsonrpc_derive::rpc; use jsonrpc_pubsub::{typed::Subscriber, SubscriptionId}; -use primitives::{ - Bytes -}; +use primitives::Bytes; +use txpool_api::TransactionStatus; use self::error::{FutureResult, Result}; -use txpool::watcher::Status; pub use self::gen_client::Client as AuthorClient; @@ -69,7 +67,7 @@ pub trait AuthorApi { )] fn watch_extrinsic(&self, metadata: Self::Metadata, - subscriber: Subscriber>, + subscriber: Subscriber>, bytes: Bytes ); diff --git a/client/rpc/src/author/mod.rs b/client/rpc/src/author/mod.rs index 920331d9ae..9380bc46f5 100644 --- a/client/rpc/src/author/mod.rs +++ b/client/rpc/src/author/mod.rs @@ -20,7 +20,6 @@ mod tests; use std::{sync::Arc, convert::TryInto}; -use futures::future::{FutureExt, TryFutureExt}; use log::warn; use client::Client; @@ -30,21 +29,17 @@ use rpc::futures::{ Sink, Future, future::result, }; -use futures::{StreamExt as _, compat::Compat, future::ready}; +use futures::{StreamExt as _, compat::Compat}; +use futures::future::{ready, FutureExt, TryFutureExt}; use api::Subscriptions; use jsonrpc_pubsub::{typed::Subscriber, SubscriptionId}; use codec::{Encode, Decode}; use primitives::{Bytes, Blake2Hasher, H256, traits::BareCryptoStorePtr}; +use sr_api::ConstructRuntimeApi; use sr_primitives::{generic, traits::{self, ProvideRuntimeApi}}; -use transaction_pool::{ - txpool::{ - ChainApi as PoolChainApi, - BlockHash, - ExHash, - IntoPoolError, - Pool, - watcher::Status, - }, +use txpool_api::{ + TransactionPool, InPoolTransaction, TransactionStatus, + BlockHash, TxHash, TransactionFor, IntoPoolError, }; use session::SessionKeys; @@ -53,22 +48,22 @@ pub use api::author::*; use self::error::{Error, FutureResult, Result}; /// Authoring API -pub struct Author where P: PoolChainApi + Sync + Send + 'static { +pub struct Author { /// Substrate client - client: Arc::Block, RA>>, + client: Arc>, /// Transactions pool - pool: Arc>, + pool: Arc

, /// Subscriptions manager subscriptions: Subscriptions, /// The key store. keystore: BareCryptoStorePtr, } -impl Author where P: PoolChainApi + Sync + Send + 'static { +impl Author { /// Create new instance of Authoring API. pub fn new( - client: Arc::Block, RA>>, - pool: Arc>, + client: Arc>, + pool: Arc

, subscriptions: Subscriptions, keystore: BareCryptoStorePtr, ) -> Self { @@ -81,16 +76,15 @@ impl Author where P: PoolChainApi + Sync + Send + 'sta } } -impl AuthorApi, BlockHash

> for Author where - B: client_api::backend::Backend<

::Block, Blake2Hasher> + Send + Sync + 'static, - E: client_api::CallExecutor<

::Block, Blake2Hasher> + Send + Sync + 'static, - P: PoolChainApi + Sync + Send + 'static, - P::Block: traits::Block, - P::Error: 'static, - RA: Send + Sync + 'static, - Client: ProvideRuntimeApi, - as ProvideRuntimeApi>::Api: - SessionKeys, +impl AuthorApi for Author where + Block: traits::Block, + B: client_api::backend::Backend + Send + Sync + 'static, + E: client_api::CallExecutor + Clone + Send + Sync + 'static, + P: TransactionPool + Sync + Send + 'static, + RA: ConstructRuntimeApi> + Send + Sync + 'static, + Client: ProvideRuntimeApi, + as ProvideRuntimeApi>::Api: + SessionKeys, { type Metadata = crate::metadata::Metadata; @@ -115,7 +109,7 @@ impl AuthorApi, BlockHash

> for Author whe ).map(Into::into).map_err(|e| Error::Client(Box::new(e))) } - fn submit_extrinsic(&self, ext: Bytes) -> FutureResult> { + fn submit_extrinsic(&self, ext: Bytes) -> FutureResult> { let xt = match Decode::decode(&mut &ext[..]) { Ok(xt) => xt, Err(err) => return Box::new(result(Err(err.into()))), @@ -131,13 +125,13 @@ impl AuthorApi, BlockHash

> for Author whe } fn pending_extrinsics(&self) -> Result> { - Ok(self.pool.ready().map(|tx| tx.data.encode().into()).collect()) + Ok(self.pool.ready().map(|tx| tx.data().encode().into()).collect()) } fn remove_extrinsic( &self, - bytes_or_hash: Vec>>, - ) -> Result>> { + bytes_or_hash: Vec>>, + ) -> Result>> { let hashes = bytes_or_hash.into_iter() .map(|x| match x { hash::ExtrinsicOrHash::Hash(h) => Ok(h), @@ -149,21 +143,22 @@ impl AuthorApi, BlockHash

> for Author whe .collect::>>()?; Ok( - self.pool.remove_invalid(&hashes) + self.pool + .remove_invalid(&hashes) .into_iter() - .map(|tx| tx.hash.clone()) + .map(|tx| tx.hash().clone()) .collect() ) } fn watch_extrinsic(&self, _metadata: Self::Metadata, - subscriber: Subscriber, BlockHash

>>, + subscriber: Subscriber, BlockHash

>>, xt: Bytes, ) { let submit = || -> Result<_> { let best_block_hash = self.client.info().chain.best_hash; - let dxt = <

::Block as traits::Block>::Extrinsic::decode(&mut &xt[..]) + let dxt = TransactionFor::

::decode(&mut &xt[..]) .map_err(error::Error::from)?; Ok( self.pool @@ -179,7 +174,7 @@ impl AuthorApi, BlockHash

> for Author whe let future = ready(submit()) .and_then(|res| res) // convert the watcher into a `Stream` - .map(|res| res.map(|watcher| watcher.into_stream().map(|v| Ok::<_, ()>(Ok(v))))) + .map(|res| res.map(|stream| stream.map(|v| Ok::<_, ()>(Ok(v))))) // now handle the import result, // start a new subscrition .map(move |result| match result { diff --git a/client/rpc/src/author/tests.rs b/client/rpc/src/author/tests.rs index 5ae044ff49..14aa03a643 100644 --- a/client/rpc/src/author/tests.rs +++ b/client/rpc/src/author/tests.rs @@ -25,13 +25,10 @@ use primitives::{ }; use rpc::futures::Stream as _; use test_client::{ - self, AccountKeyring, runtime::{Extrinsic, Transfer, SessionKeys, RuntimeApi, Block}, DefaultTestClientBuilderExt, - TestClientBuilderExt, Backend, Client, Executor -}; -use transaction_pool::{ - txpool::Pool, - FullChainApi, + self, AccountKeyring, runtime::{Extrinsic, Transfer, SessionKeys, RuntimeApi, Block}, + DefaultTestClientBuilderExt, TestClientBuilderExt, Backend, Client, Executor, }; +use txpool::{BasicPool, FullChainApi}; use tokio::runtime; fn uxt(sender: AccountKeyring, nonce: u64) -> Extrinsic { @@ -44,18 +41,23 @@ fn uxt(sender: AccountKeyring, nonce: u64) -> Extrinsic { tx.into_signed_tx() } +type FullTransactionPool = BasicPool< + FullChainApi, Block>, + Block, +>; + struct TestSetup { pub runtime: runtime::Runtime, pub client: Arc>, pub keystore: BareCryptoStorePtr, - pub pool: Arc, Block>>>, + pub pool: Arc, } impl Default for TestSetup { fn default() -> Self { let keystore = KeyStore::new(); let client = Arc::new(test_client::TestClientBuilder::new().set_keystore(keystore.clone()).build()); - let pool = Arc::new(Pool::new(Default::default(), FullChainApi::new(client.clone()))); + let pool = Arc::new(BasicPool::new(Default::default(), FullChainApi::new(client.clone()))); TestSetup { runtime: runtime::Runtime::new().expect("Failed to create runtime in test setup"), client, @@ -66,7 +68,7 @@ impl Default for TestSetup { } impl TestSetup { - fn author(&self) -> Author, Block>, RuntimeApi> { + fn author(&self) -> Author { Author { client: self.client.clone(), pool: self.pool.clone(), diff --git a/client/service/Cargo.toml b/client/service/Cargo.toml index 2c19c57a31..bf9491add3 100644 --- a/client/service/Cargo.toml +++ b/client/service/Cargo.toml @@ -41,11 +41,12 @@ chain-spec = { package = "substrate-chain-spec", path = "../chain-spec" } client-api = { package = "substrate-client-api", path = "../api" } client = { package = "substrate-client", path = "../" } sr-api = { path = "../../primitives/sr-api" } -tx-pool-api = { package = "substrate-transaction-pool-runtime-api", path = "../../primitives/transaction-pool/runtime-api" } +txpool-runtime-api = { package = "sp-transaction-pool-runtime-api", path = "../../primitives/transaction-pool/runtime-api" } client_db = { package = "substrate-client-db", path = "../db" } codec = { package = "parity-scale-codec", version = "1.0.0" } substrate-executor = { path = "../executor" } -transaction_pool = { package = "sc-transaction-pool", path = "../../client/transaction-pool" } +txpool = { package = "sc-transaction-pool", path = "../transaction-pool" } +txpool-api = { package = "sp-transaction-pool-api", path = "../../primitives/transaction-pool" } rpc-servers = { package = "substrate-rpc-servers", path = "../rpc-servers" } rpc = { package = "substrate-rpc", path = "../rpc" } tel = { package = "substrate-telemetry", path = "../telemetry" } diff --git a/client/service/src/builder.rs b/client/service/src/builder.rs index ef3403e6d8..1666257ab9 100644 --- a/client/service/src/builder.rs +++ b/client/service/src/builder.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Substrate. If not, see . -use crate::{Service, NetworkStatus, NetworkState, error::{self, Error}, DEFAULT_PROTOCOL_ID}; +use crate::{Service, NetworkStatus, NetworkState, error::Error, DEFAULT_PROTOCOL_ID}; use crate::{SpawnTaskHandle, start_rpc_servers, build_network_future, TransactionPoolAdapter}; use crate::status_sinks; use crate::config::{Configuration, DatabaseConfig}; @@ -30,7 +30,6 @@ use consensus_common::import_queue::ImportQueue; use futures::{prelude::*, sync::mpsc}; use futures03::{ compat::{Compat, Future01CompatExt}, - future::ready, FutureExt as _, TryFutureExt as _, StreamExt as _, TryStreamExt as _, future::{select, Either} @@ -42,9 +41,11 @@ use network::{config::BoxFinalityProofRequestBuilder, specialization::NetworkSpe use parking_lot::{Mutex, RwLock}; use primitives::{Blake2Hasher, H256, Hasher}; use rpc; +use sr_api::ConstructRuntimeApi; use sr_primitives::generic::BlockId; use sr_primitives::traits::{ - Block as BlockT, Extrinsic, ProvideRuntimeApi, NumberFor, One, Zero, Header, SaturatedConversion + Block as BlockT, ProvideRuntimeApi, NumberFor, One, + Zero, Header, SaturatedConversion, }; use substrate_executor::{NativeExecutor, NativeExecutionDispatch}; use std::{ @@ -53,7 +54,7 @@ use std::{ }; use sysinfo::{get_current_pid, ProcessExt, System, SystemExt}; use tel::{telemetry, SUBSTRATE_INFO}; -use transaction_pool::txpool::{self, ChainApi, Pool as TransactionPool}; +use txpool_api::{TransactionPool, TransactionPoolMaintainer}; use sp_blockchain; use grafana_data_source::{self, record_metrics}; @@ -295,7 +296,7 @@ where TGen: RuntimeGenesis, TCSExt: Extension { client, backend, keystore, - fetcher: Some(fetcher), + fetcher: Some(fetcher.clone()), select_chain: None, import_queue: (), finality_proof_request_builder: None, @@ -559,10 +560,19 @@ impl( self, - transaction_pool_builder: impl FnOnce(transaction_pool::txpool::Options, Arc) -> Result + transaction_pool_builder: impl FnOnce( + txpool::txpool::Options, + Arc, + Option, + ) -> Result ) -> Result, Error> { - let transaction_pool = transaction_pool_builder(self.config.transaction_pool.clone(), self.client.clone())?; + TNetP, UExPool, TRpc, Backend>, Error> + where TSc: Clone, TFchr: Clone { + let transaction_pool = transaction_pool_builder( + self.config.transaction_pool.clone(), + self.client.clone(), + self.fetcher.clone(), + )?; Ok(ServiceBuilder { config: self.config, @@ -586,10 +596,23 @@ impl( self, - rpc_ext_builder: impl FnOnce(Arc, Arc, Arc) -> URpc + rpc_ext_builder: impl FnOnce( + Arc, + Arc, + Arc, + Option, + Option>>, + ) -> Result, ) -> Result, Error> { - let rpc_extensions = rpc_ext_builder(self.client.clone(), self.transaction_pool.clone(), self.backend.clone()); + TNetP, TExPool, URpc, Backend>, Error> + where TSc: Clone, TFchr: Clone { + let rpc_extensions = rpc_ext_builder( + self.client.clone(), + self.transaction_pool.clone(), + self.backend.clone(), + self.fetcher.clone(), + self.remote_backend.clone(), + )?; Ok(ServiceBuilder { config: self.config, @@ -742,7 +765,7 @@ where } } -impl +impl ServiceBuilder< TBl, TRtApi, @@ -756,7 +779,7 @@ ServiceBuilder< BoxFinalityProofRequestBuilder, Arc>, TNetP, - TransactionPool, + TExPool, TRpc, TBackend, > where @@ -764,11 +787,11 @@ ServiceBuilder< as ProvideRuntimeApi>::Api: sr_api::Metadata + offchain::OffchainWorkerApi + - tx_pool_api::TaggedTransactionQueue + + txpool_runtime_api::TaggedTransactionQueue + session::SessionKeys + sr_api::ApiExt, TBl: BlockT::Out>, - TRtApi: 'static + Send + Sync, + TRtApi: ConstructRuntimeApi> + 'static + Send + Sync, TCfg: Default, TGen: RuntimeGenesis, TCSExt: Extension, @@ -777,7 +800,9 @@ ServiceBuilder< TSc: Clone, TImpQu: 'static + ImportQueue, TNetP: NetworkSpecialization, - TExPoolApi: 'static + ChainApi::Hash>, + TExPool: 'static + + TransactionPool::Hash> + + TransactionPoolMaintainer::Hash>, TRpc: rpc::RpcExtension + Clone, { /// Builds the service. @@ -787,7 +812,7 @@ ServiceBuilder< TSc, NetworkStatus, NetworkService::Hash>, - TransactionPool, + TExPool, offchain::OffchainWorkers< Client, TBackend::OffchainStorage, @@ -900,7 +925,6 @@ ServiceBuilder< { // block notifications let txpool = Arc::downgrade(&transaction_pool); - let wclient = Arc::downgrade(&client); let offchain = offchain_workers.as_ref().map(Arc::downgrade); let to_spawn_tx_ = to_spawn_tx.clone(); let network_state_info: Arc = network.clone(); @@ -912,14 +936,12 @@ ServiceBuilder< let number = *notification.header.number(); let txpool = txpool.upgrade(); - if let (Some(txpool), Some(client)) = (txpool.as_ref(), wclient.upgrade()) { - let future = maintain_transaction_pool( + if let Some(txpool) = txpool.as_ref() { + let future = txpool.maintain( &BlockId::hash(notification.hash), - &client, - &*txpool, ¬ification.retracted, - ).map_err(|e| warn!("Pool error processing new block: {:?}", e))?; - let _ = to_spawn_tx_.unbounded_send(future); + ).map(|_| Ok(())).compat(); + let _ = to_spawn_tx_.unbounded_send(Box::new(future)); } let offchain = offchain.as_ref().and_then(|o| o.upgrade()); @@ -1202,157 +1224,3 @@ ServiceBuilder< }) } } - -pub(crate) fn maintain_transaction_pool( - id: &BlockId, - client: &Arc>, - transaction_pool: &TransactionPool, - retracted: &[Block::Hash], -) -> error::Result + Send>> where - Block: BlockT::Out>, - Backend: 'static + client_api::backend::Backend, - Client: ProvideRuntimeApi, - as ProvideRuntimeApi>::Api: - tx_pool_api::TaggedTransactionQueue, - Executor: 'static + client::CallExecutor, - PoolApi: 'static + txpool::ChainApi, - Api: 'static, -{ - // Put transactions from retracted blocks back into the pool. - let client_copy = client.clone(); - let retracted_transactions = retracted.to_vec().into_iter() - .filter_map(move |hash| client_copy.block(&BlockId::hash(hash)).ok().unwrap_or(None)) - .flat_map(|block| block.block.deconstruct().1.into_iter()) - .filter(|tx| tx.is_signed().unwrap_or(false)); - let resubmit_future = transaction_pool - .submit_at(id, retracted_transactions, true) - .then(|resubmit_result| ready(match resubmit_result { - Ok(_) => Ok(()), - Err(e) => { - warn!("Error re-submitting transactions: {:?}", e); - Ok(()) - } - })) - .compat(); - - // Avoid calling into runtime if there is nothing to prune from the pool anyway. - if transaction_pool.status().is_empty() { - return Ok(Box::new(resubmit_future)) - } - - let block = client.block(id)?; - Ok(match block { - Some(block) => { - let parent_id = BlockId::hash(*block.block.header().parent_hash()); - let prune_future = transaction_pool - .prune(id, &parent_id, block.block.extrinsics()) - .boxed() - .compat() - .map_err(|e| { format!("{:?}", e); }); - - Box::new(resubmit_future.and_then(|_| prune_future)) - }, - None => Box::new(resubmit_future), - }) -} - -#[cfg(test)] -mod tests { - use super::*; - use futures03::executor::block_on; - use consensus_common::{BlockOrigin, SelectChain}; - use substrate_test_runtime_client::{prelude::*, runtime::Transfer}; - - #[test] - fn should_remove_transactions_from_the_pool() { - let (client, longest_chain) = TestClientBuilder::new().build_with_longest_chain(); - let client = Arc::new(client); - let pool = TransactionPool::new(Default::default(), ::transaction_pool::FullChainApi::new(client.clone())); - let transaction = Transfer { - amount: 5, - nonce: 0, - from: AccountKeyring::Alice.into(), - to: Default::default(), - }.into_signed_tx(); - let best = longest_chain.best_chain().unwrap(); - - // store the transaction in the pool - block_on(pool.submit_one(&BlockId::hash(best.hash()), transaction.clone())).unwrap(); - - // import the block - let mut builder = client.new_block(Default::default()).unwrap(); - builder.push(transaction.clone()).unwrap(); - let block = builder.bake().unwrap(); - let id = BlockId::hash(block.header().hash()); - client.import(BlockOrigin::Own, block).unwrap(); - - // fire notification - this should clean up the queue - assert_eq!(pool.status().ready, 1); - maintain_transaction_pool( - &id, - &client, - &pool, - &[] - ).unwrap().wait().unwrap(); - - // then - assert_eq!(pool.status().ready, 0); - assert_eq!(pool.status().future, 0); - } - - #[test] - fn should_add_reverted_transactions_to_the_pool() { - let (client, longest_chain) = TestClientBuilder::new().build_with_longest_chain(); - let client = Arc::new(client); - let pool = TransactionPool::new(Default::default(), ::transaction_pool::FullChainApi::new(client.clone())); - let transaction = Transfer { - amount: 5, - nonce: 0, - from: AccountKeyring::Alice.into(), - to: Default::default(), - }.into_signed_tx(); - let best = longest_chain.best_chain().unwrap(); - - // store the transaction in the pool - block_on(pool.submit_one(&BlockId::hash(best.hash()), transaction.clone())).unwrap(); - - // import the block - let mut builder = client.new_block(Default::default()).unwrap(); - builder.push(transaction.clone()).unwrap(); - let block = builder.bake().unwrap(); - let block1_hash = block.header().hash(); - let id = BlockId::hash(block1_hash.clone()); - client.import(BlockOrigin::Own, block).unwrap(); - - // fire notification - this should clean up the queue - assert_eq!(pool.status().ready, 1); - maintain_transaction_pool( - &id, - &client, - &pool, - &[] - ).unwrap().wait().unwrap(); - - // then - assert_eq!(pool.status().ready, 0); - assert_eq!(pool.status().future, 0); - - // import second block - let builder = client.new_block_at(&BlockId::hash(best.hash()), Default::default()).unwrap(); - let block = builder.bake().unwrap(); - let id = BlockId::hash(block.header().hash()); - client.import(BlockOrigin::Own, block).unwrap(); - - // fire notification - this should add the transaction back to the pool. - maintain_transaction_pool( - &id, - &client, - &pool, - &[block1_hash] - ).unwrap().wait().unwrap(); - - // then - assert_eq!(pool.status().ready, 1); - assert_eq!(pool.status().future, 0); - } -} diff --git a/client/service/src/config.rs b/client/service/src/config.rs index a17c0ee877..6ef2aa46ac 100644 --- a/client/service/src/config.rs +++ b/client/service/src/config.rs @@ -22,7 +22,7 @@ pub use network::config::{ExtTransport, NetworkConfiguration, Roles}; pub use substrate_executor::WasmExecutionMethod; use std::{path::PathBuf, net::SocketAddr, sync::Arc}; -use transaction_pool; +pub use txpool::txpool::Options as TransactionPoolOptions; use chain_spec::{ChainSpec, RuntimeGenesis, Extension, NoExtension}; use primitives::crypto::Protected; use target_info::Target; @@ -40,7 +40,7 @@ pub struct Configuration { /// Node roles. pub roles: Roles, /// Extrinsic pool configuration. - pub transaction_pool: transaction_pool::txpool::Options, + pub transaction_pool: TransactionPoolOptions, /// Network configuration. pub network: NetworkConfiguration, /// Path to the base configuration directory. diff --git a/client/service/src/lib.rs b/client/service/src/lib.rs index 6ddc6ab797..702f72f832 100644 --- a/client/service/src/lib.rs +++ b/client/service/src/lib.rs @@ -53,12 +53,13 @@ use sr_primitives::generic::BlockId; use sr_primitives::traits::{NumberFor, Block as BlockT}; pub use self::error::Error; -pub use self::builder::{ServiceBuilder, ServiceBuilderExport, ServiceBuilderImport, ServiceBuilderRevert}; +pub use self::builder::{ + ServiceBuilder, ServiceBuilderExport, ServiceBuilderImport, ServiceBuilderRevert, +}; pub use config::{Configuration, Roles, PruningMode}; pub use chain_spec::{ChainSpec, Properties, RuntimeGenesis, Extension as ChainSpecExtension}; -pub use transaction_pool::txpool::{ - self, Pool as TransactionPool, Options as TransactionPoolOptions, ChainApi, IntoPoolError -}; +pub use txpool_api::{TransactionPool, TransactionPoolMaintainer, InPoolTransaction, IntoPoolError}; +pub use txpool::txpool::Options as TransactionPoolOptions; pub use client::FinalityNotifications; pub use rpc::Metadata as RpcMetadata; #[doc(hidden)] @@ -144,8 +145,9 @@ pub trait AbstractService: 'static + Future + type RuntimeApi: Send + Sync; /// Chain selection algorithm. type SelectChain: consensus_common::SelectChain; - /// API of the transaction pool. - type TransactionPoolApi: ChainApi; + /// Transaction pool. + type TransactionPool: TransactionPool + + TransactionPoolMaintainer; /// Network specialization. type NetworkSpecialization: NetworkSpecialization; @@ -193,22 +195,23 @@ pub trait AbstractService: 'static + Future + fn network_status(&self, interval: Duration) -> mpsc::UnboundedReceiver<(NetworkStatus, NetworkState)>; /// Get shared transaction pool instance. - fn transaction_pool(&self) -> Arc>; + fn transaction_pool(&self) -> Arc; /// Get a handle to a future that will resolve on exit. fn on_exit(&self) -> ::exit_future::Exit; } -impl AbstractService for +impl AbstractService for Service, TSc, NetworkStatus, - NetworkService, TransactionPool, TOc> + NetworkService, TExPool, TOc> where TBl: BlockT, TBackend: 'static + client_api::backend::Backend, TExec: 'static + client::CallExecutor + Send + Sync + Clone, TRtApi: 'static + Send + Sync, TSc: consensus_common::SelectChain + 'static + Clone + Send, - TExPoolApi: 'static + ChainApi, + TExPool: 'static + TransactionPool + + TransactionPoolMaintainer, TOc: 'static + Send + Sync, TNetSpec: NetworkSpecialization, { @@ -217,7 +220,7 @@ where type CallExecutor = TExec; type RuntimeApi = TRtApi; type SelectChain = TSc; - type TransactionPoolApi = TExPoolApi; + type TransactionPool = TExPool; type NetworkSpecialization = TNetSpec; fn telemetry_on_connect_stream(&self) -> mpsc::UnboundedReceiver<()> { @@ -282,7 +285,7 @@ where stream } - fn transaction_pool(&self) -> Arc> { + fn transaction_pool(&self) -> Arc { self.transaction_pool.clone() } @@ -589,35 +592,35 @@ pub struct TransactionPoolAdapter { /// Get transactions for propagation. /// /// Function extracted to simplify the test and prevent creating `ServiceFactory`. -fn transactions_to_propagate(pool: &TransactionPool) +fn transactions_to_propagate(pool: &Pool) -> Vec<(H, B::Extrinsic)> where - PoolApi: ChainApi, + Pool: TransactionPool, B: BlockT, H: std::hash::Hash + Eq + sr_primitives::traits::Member + sr_primitives::traits::MaybeSerialize, - E: txpool::error::IntoPoolError + From, + E: IntoPoolError + From, { pool.ready() .filter(|t| t.is_propagateable()) .map(|t| { - let hash = t.hash.clone(); - let ex: B::Extrinsic = t.data.clone(); + let hash = t.hash().clone(); + let ex: B::Extrinsic = t.data().clone(); (hash, ex) }) .collect() } -impl network::TransactionPool for - TransactionPoolAdapter> +impl network::TransactionPool for + TransactionPoolAdapter where C: network::ClientHandle + Send + Sync, - PoolApi: 'static + ChainApi, + Pool: 'static + TransactionPool, B: BlockT, H: std::hash::Hash + Eq + sr_primitives::traits::Member + sr_primitives::traits::MaybeSerialize, - E: txpool::error::IntoPoolError + From, + E: 'static + IntoPoolError + From, { fn transactions(&self) -> Vec<(H, ::Extrinsic)> { - transactions_to_propagate(&self.pool) + transactions_to_propagate(&*self.pool) } fn hash_of(&self, transaction: &B::Extrinsic) -> H { @@ -647,7 +650,7 @@ where match import_result { Ok(_) => report_handle.report_peer(who, reputation_change_good), Err(e) => match e.into_pool_error() { - Ok(txpool::error::Error::AlreadyImported(_)) => (), + Ok(txpool_api::error::Error::AlreadyImported(_)) => (), Ok(e) => { report_handle.report_peer(who, reputation_change_bad); debug!("Error adding transaction to the pool: {:?}", e) @@ -679,16 +682,14 @@ mod tests { use consensus_common::SelectChain; use sr_primitives::traits::BlindCheckable; use substrate_test_runtime_client::{prelude::*, runtime::{Extrinsic, Transfer}}; + use txpool::{BasicPool, FullChainApi}; #[test] fn should_not_propagate_transactions_that_are_marked_as_such() { // given let (client, longest_chain) = TestClientBuilder::new().build_with_longest_chain(); let client = Arc::new(client); - let pool = Arc::new(TransactionPool::new( - Default::default(), - transaction_pool::FullChainApi::new(client.clone()) - )); + let pool = Arc::new(BasicPool::new(Default::default(), FullChainApi::new(client.clone()))); let best = longest_chain.best_chain().unwrap(); let transaction = Transfer { amount: 5, @@ -701,7 +702,7 @@ mod tests { assert_eq!(pool.status().ready, 2); // when - let transactions = transactions_to_propagate(&pool); + let transactions = transactions_to_propagate(&*pool); // then assert_eq!(transactions.len(), 1); diff --git a/client/service/test/Cargo.toml b/client/service/test/Cargo.toml index 365fd87bfe..7a85966a39 100644 --- a/client/service/test/Cargo.toml +++ b/client/service/test/Cargo.toml @@ -18,3 +18,4 @@ consensus = { package = "substrate-consensus-common", path = "../../../primitive client = { package = "substrate-client", path = "../../" } sr-primitives = { path = "../../../primitives/sr-primitives" } primitives = { package = "substrate-primitives", path = "../../../primitives/core" } +txpool-api = { package = "sp-transaction-pool-api", path = "../../../primitives/transaction-pool" } diff --git a/client/service/test/src/lib.rs b/client/service/test/src/lib.rs index 594e5bf7ed..3b1e3593dc 100644 --- a/client/service/test/src/lib.rs +++ b/client/service/test/src/lib.rs @@ -36,6 +36,7 @@ use service::{ use network::{multiaddr, Multiaddr}; use network::config::{NetworkConfiguration, TransportConfig, NodeKeyConfig, Secret, NonReservedPeerMode}; use sr_primitives::{generic::BlockId, traits::Block as BlockT}; +use txpool_api::TransactionPool; /// Maximum duration of single wait call. const MAX_WAIT_TIME: Duration = Duration::from_secs(60 * 3); diff --git a/client/transaction-pool/Cargo.toml b/client/transaction-pool/Cargo.toml index 241c7beb23..3f1c80c2de 100644 --- a/client/transaction-pool/Cargo.toml +++ b/client/transaction-pool/Cargo.toml @@ -7,14 +7,17 @@ edition = "2018" [dependencies] codec = { package = "parity-scale-codec", version = "1.0.0" } derive_more = "0.99.2" -futures = { version = "0.3.1", features = ["thread-pool"] } +futures = { version = "0.3.1", features = ["compat", "compat"] } log = "0.4.8" parking_lot = "0.9.0" primitives = { package = "substrate-primitives", path = "../../primitives/core" } sr-api = { path = "../../primitives/sr-api" } sr-primitives = { path = "../../primitives/sr-primitives" } -tx-runtime-api = { package = "substrate-transaction-pool-runtime-api", path = "../../primitives/transaction-pool/runtime-api" } txpool = { package = "sc-transaction-graph", path = "./graph" } +txpool-api = { package = "sp-transaction-pool-api", path = "../../primitives/transaction-pool" } +txpool-runtime-api = { package = "sp-transaction-pool-runtime-api", path = "../../primitives/transaction-pool/runtime-api" } +client-api = { package = "substrate-client-api", path = "../api" } +sp-blockchain = { path = "../../primitives/blockchain" } [dev-dependencies] keyring = { package = "substrate-keyring", path = "../../primitives/keyring" } diff --git a/client/transaction-pool/graph/Cargo.toml b/client/transaction-pool/graph/Cargo.toml index 685a2f6ff9..c9dd98d8ba 100644 --- a/client/transaction-pool/graph/Cargo.toml +++ b/client/transaction-pool/graph/Cargo.toml @@ -12,6 +12,7 @@ parking_lot = "0.9.0" serde = { version = "1.0.101", features = ["derive"] } primitives = { package = "substrate-primitives", path = "../../../primitives/core" } sr-primitives = { path = "../../../primitives/sr-primitives" } +txpool-api = { package = "sp-transaction-pool-api", path = "../../../primitives/transaction-pool" } [dev-dependencies] assert_matches = "1.3.0" diff --git a/client/transaction-pool/graph/benches/basics.rs b/client/transaction-pool/graph/benches/basics.rs index 1ddd27df96..920facaa2c 100644 --- a/client/transaction-pool/graph/benches/basics.rs +++ b/client/transaction-pool/graph/benches/basics.rs @@ -48,8 +48,8 @@ fn to_tag(nonce: u64, from: AccountId) -> Tag { impl ChainApi for TestApi { type Block = Block; type Hash = H256; - type Error = error::Error; - type ValidationFuture = futures::future::Ready>; + type Error = txpool_api::error::Error; + type ValidationFuture = futures::future::Ready>; fn validate_transaction( &self, diff --git a/client/transaction-pool/graph/src/base_pool.rs b/client/transaction-pool/graph/src/base_pool.rs index cb37aee07f..a683741aa4 100644 --- a/client/transaction-pool/graph/src/base_pool.rs +++ b/client/transaction-pool/graph/src/base_pool.rs @@ -34,8 +34,8 @@ use sr_primitives::transaction_validity::{ TransactionLongevity as Longevity, TransactionPriority as Priority, }; +use txpool_api::{error, PoolStatus, InPoolTransaction}; -use crate::error; use crate::future::{FutureTransactions, WaitingTransaction}; use crate::ready::ReadyTransactions; @@ -104,13 +104,65 @@ pub struct Transaction { pub propagate: bool, } -impl Transaction { - /// Returns `true` if the transaction should be propagated to other peers. - pub fn is_propagateable(&self) -> bool { +impl AsRef for Transaction { + fn as_ref(&self) -> &Extrinsic { + &self.data + } +} + +impl InPoolTransaction for Transaction { + type Transaction = Extrinsic; + type Hash = Hash; + + fn data(&self) -> &Extrinsic { + &self.data + } + + fn hash(&self) -> &Hash { + &self.hash + } + + fn priority(&self) -> &Priority { + &self.priority + } + + fn longevity(&self) ->&Longevity { + &self.valid_till + } + + fn requires(&self) -> &[Tag] { + &self.requires + } + + fn provides(&self) -> &[Tag] { + &self.provides + } + + fn is_propagateable(&self) -> bool { self.propagate } } +impl Transaction { + /// Explicit transaction clone. + /// + /// Transaction should be cloned only if absolutely necessary && we want + /// every reason to be commented. That's why we `Transaction` is not `Clone`, + /// but there's explicit `duplicate` method. + pub fn duplicate(&self) -> Self { + Transaction { + data: self.data.clone(), + bytes: self.bytes.clone(), + hash: self.hash.clone(), + priority: self.priority.clone(), + valid_till: self.valid_till.clone(), + requires: self.requires.clone(), + provides: self.provides.clone(), + propagate: self.propagate, + } + } +} + impl fmt::Debug for Transaction where Hash: fmt::Debug, Extrinsic: fmt::Debug, @@ -159,6 +211,7 @@ const RECENTLY_PRUNED_TAGS: usize = 2; /// required tags. #[derive(Debug)] pub struct BasePool { + reject_future_transactions: bool, future: FutureTransactions, ready: ReadyTransactions, /// Store recently pruned tags (for last two invocations). @@ -169,18 +222,37 @@ pub struct BasePool { recently_pruned_index: usize, } -impl Default for BasePool { +impl Default for BasePool { fn default() -> Self { + Self::new(false) + } +} + +impl BasePool { + /// Create new pool given reject_future_transactions flag. + pub fn new(reject_future_transactions: bool) -> Self { BasePool { + reject_future_transactions, future: Default::default(), ready: Default::default(), recently_pruned: Default::default(), recently_pruned_index: 0, } } -} -impl BasePool { + /// Temporary enables future transactions, runs closure and then restores + /// `reject_future_transactions` flag back to previous value. + /// + /// The closure accepts the mutable reference to the pool and original value + /// of the `reject_future_transactions` flag. + pub(crate) fn with_futures_enabled(&mut self, closure: impl FnOnce(&mut Self, bool) -> T) -> T { + let previous = self.reject_future_transactions; + self.reject_future_transactions = false; + let return_value = closure(self, previous); + self.reject_future_transactions = previous; + return_value + } + /// Imports transaction to the pool. /// /// The pool consists of two parts: Future and Ready. @@ -206,6 +278,10 @@ impl BasePool BasePool Vec>> { + self.future.clear() + } + /// Prunes transactions that provide given list of tags. /// /// This will cause all transactions that provide these tags to be removed from the pool, @@ -385,7 +466,7 @@ impl BasePool BasePool Status { - Status { + pub fn status(&self) -> PoolStatus { + PoolStatus { ready: self.ready.len(), ready_bytes: self.ready.bytes(), future: self.future.len(), @@ -423,26 +504,6 @@ impl BasePool bool { - self.ready == 0 && self.future == 0 - } -} - /// Queue limits #[derive(Debug, Clone)] pub struct Limit { @@ -972,4 +1033,85 @@ requires: [03,02], provides: [04], data: [4]}".to_owned() propagate: false, }.is_propagateable(), false); } + + #[test] + fn should_reject_future_transactions() { + // given + let mut pool = pool(); + + // when + pool.reject_future_transactions = true; + + // then + let err = pool.import(Transaction { + data: vec![5u8], + bytes: 1, + hash: 5, + priority: 5u64, + valid_till: 64u64, + requires: vec![vec![0]], + provides: vec![], + propagate: true, + }); + + if let Err(error::Error::RejectedFutureTransaction) = err { + } else { + assert!(false, "Invalid error kind: {:?}", err); + } + } + + #[test] + fn should_clear_future_queue() { + // given + let mut pool = pool(); + + // when + pool.import(Transaction { + data: vec![5u8], + bytes: 1, + hash: 5, + priority: 5u64, + valid_till: 64u64, + requires: vec![vec![0]], + provides: vec![], + propagate: true, + }).unwrap(); + + // then + assert_eq!(pool.future.len(), 1); + + // and then when + assert_eq!(pool.clear_future().len(), 1); + + // then + assert_eq!(pool.future.len(), 0); + } + + #[test] + fn should_accept_future_transactions_when_explcitly_asked_to() { + // given + let mut pool = pool(); + pool.reject_future_transactions = true; + + // when + let flag_value = pool.with_futures_enabled(|pool, flag| { + pool.import(Transaction { + data: vec![5u8], + bytes: 1, + hash: 5, + priority: 5u64, + valid_till: 64u64, + requires: vec![vec![0]], + provides: vec![], + propagate: true, + }).unwrap(); + + flag + }); + + // then + assert_eq!(flag_value, true); + assert_eq!(pool.reject_future_transactions, true); + assert_eq!(pool.future.len(), 1); + } } diff --git a/client/transaction-pool/graph/src/future.rs b/client/transaction-pool/graph/src/future.rs index c7b13c912d..8b01e9d654 100644 --- a/client/transaction-pool/graph/src/future.rs +++ b/client/transaction-pool/graph/src/future.rs @@ -227,6 +227,12 @@ impl FutureTransactions { self.waiting.values().map(|waiting| &*waiting.transaction) } + /// Removes and returns all future transactions. + pub fn clear(&mut self) -> Vec>> { + self.wanted_tags.clear(); + self.waiting.drain().map(|(_, tx)| tx.transaction).collect() + } + /// Returns number of transactions in the Future queue. pub fn len(&self) -> usize { self.waiting.len() diff --git a/client/transaction-pool/graph/src/lib.rs b/client/transaction-pool/graph/src/lib.rs index 715e60874b..db92bef272 100644 --- a/client/transaction-pool/graph/src/lib.rs +++ b/client/transaction-pool/graph/src/lib.rs @@ -32,11 +32,9 @@ mod rotator; mod validated_pool; pub mod base_pool; -pub mod error; pub mod watcher; -pub use self::error::IntoPoolError; -pub use self::base_pool::{Transaction, Status}; +pub use self::base_pool::Transaction; pub use self::pool::{ Pool, Options, ChainApi, EventStream, ExtrinsicFor, diff --git a/client/transaction-pool/graph/src/listener.rs b/client/transaction-pool/graph/src/listener.rs index a96c31544f..f9b71555e2 100644 --- a/client/transaction-pool/graph/src/listener.rs +++ b/client/transaction-pool/graph/src/listener.rs @@ -92,7 +92,7 @@ impl Listene /// Transaction was removed as invalid. pub fn invalid(&mut self, tx: &H) { - warn!(target: "transaction-pool", "Extrinsic invalid: {:?}", tx); + warn!(target: "txpool", "Extrinsic invalid: {:?}", tx); self.fire(tx, |watcher| watcher.invalid()); } diff --git a/client/transaction-pool/graph/src/pool.rs b/client/transaction-pool/graph/src/pool.rs index d6ef61d17e..d40942c5e9 100644 --- a/client/transaction-pool/graph/src/pool.rs +++ b/client/transaction-pool/graph/src/pool.rs @@ -21,7 +21,6 @@ use std::{ }; use crate::base_pool as base; -use crate::error; use crate::watcher::Watcher; use serde::Serialize; @@ -35,6 +34,8 @@ use sr_primitives::{ traits::{self, SaturatedConversion}, transaction_validity::{TransactionValidity, TransactionTag as Tag, TransactionValidityError}, }; +use txpool_api::{error, PoolStatus}; + use crate::validated_pool::{ValidatedPool, ValidatedTransaction}; /// Modification notification event stream type; @@ -92,6 +93,8 @@ pub struct Options { pub ready: base::Limit, /// Future queue limits. pub future: base::Limit, + /// Reject future transactions. + pub reject_future_transactions: bool, } impl Default for Options { @@ -105,6 +108,7 @@ impl Default for Options { count: 128, total_bytes: 1 * 1024 * 1024, }, + reject_future_transactions: false, } } } @@ -131,7 +135,9 @@ impl Pool { let validated_pool = self.validated_pool.clone(); self.verify(at, xts, force) .map(move |validated_transactions| validated_transactions - .map(|validated_transactions| validated_pool.submit(validated_transactions))) + .map(|validated_transactions| validated_pool.submit(validated_transactions + .into_iter() + .map(|(_, tx)| tx)))) } /// Imports one unverified extrinsic to the pool @@ -161,10 +167,40 @@ impl Pool { let validated_pool = self.validated_pool.clone(); Either::Right( self.verify_one(at, block_number, xt, false) - .map(move |validated_transactions| validated_pool.submit_and_watch(validated_transactions)) + .map(move |validated_transactions| validated_pool.submit_and_watch(validated_transactions.1)) ) } + /// Revalidate all ready transactions. + /// + /// Returns future that performs validation of all ready transactions and + /// then resubmits all transactions back to the pool. + pub fn revalidate_ready(&self, at: &BlockId) -> impl Future> { + let validated_pool = self.validated_pool.clone(); + let ready = self.validated_pool.ready().map(|tx| tx.data.clone()); + self.verify(at, ready, false) + .map(move |revalidated_transactions| revalidated_transactions.map( + move |revalidated_transactions| validated_pool.resubmit(revalidated_transactions) + )) + } + + /// Prunes known ready transactions. + /// + /// Used to clear the pool from transactions that were part of recently imported block. + /// The main difference from the `prune` is that we do not revalidate any transactions + /// and ignore unknown passed hashes. + pub fn prune_known(&self, at: &BlockId, hashes: &[ExHash]) -> Result<(), B::Error> { + // Get details of all extrinsics that are already in the pool + let in_pool_tags = self.validated_pool.extrinsics_tags(hashes) + .into_iter().filter_map(|x| x).flat_map(|x| x); + + // Prune all transactions that provide given tags + let prune_status = self.validated_pool.prune_tags(in_pool_tags)?; + let pruned_transactions = hashes.into_iter().cloned() + .chain(prune_status.pruned.iter().map(|tx| tx.hash.clone())); + self.validated_pool.fire_pruned(at, pruned_transactions) + } + /// Prunes ready transactions. /// /// Used to clear the pool from transactions that were part of recently imported block. @@ -184,7 +220,8 @@ impl Pool { extrinsics.len() ); // Get details of all extrinsics that are already in the pool - let (in_pool_hashes, in_pool_tags) = self.validated_pool.extrinsics_tags(extrinsics); + let in_pool_hashes = extrinsics.iter().map(|extrinsic| self.hash_of(extrinsic)).collect::>(); + let in_pool_tags = self.validated_pool.extrinsics_tags(&in_pool_hashes); // Zip the ones from the pool with the full list (we get pairs `(Extrinsic, Option>)`) let all = extrinsics.iter().zip(in_pool_tags.into_iter()); @@ -274,7 +311,7 @@ impl Pool { &at, known_imported_hashes, pruned_hashes, - reverified_transactions, + reverified_transactions.into_iter().map(|(_, xt)| xt).collect(), )) ))) } @@ -303,7 +340,7 @@ impl Pool { } /// Returns pool status. - pub fn status(&self) -> base::Status { + pub fn status(&self) -> PoolStatus { self.validated_pool.status() } @@ -325,7 +362,7 @@ impl Pool { at: &BlockId, xts: impl IntoIterator>, force: bool, - ) -> impl Future>, B::Error>> { + ) -> impl Future, ValidatedTransactionFor>, B::Error>> { // we need a block number to compute tx validity let block_number = match self.resolve_block_number(at) { Ok(block_number) => block_number, @@ -338,7 +375,7 @@ impl Pool { ); // make single validation future that waits all until all extrinsics are validated - Either::Right(join_all(validation_futures).then(|x| ready(Ok(x)))) + Either::Right(join_all(validation_futures).then(|x| ready(Ok(x.into_iter().collect())))) } /// Returns future that validates single transaction at given block. @@ -348,14 +385,17 @@ impl Pool { block_number: NumberFor, xt: ExtrinsicFor, force: bool, - ) -> impl Future> { + ) -> impl Future, ValidatedTransactionFor)> { let (hash, bytes) = self.validated_pool.api().hash_and_length(&xt); if !force && self.validated_pool.is_banned(&hash) { - return Either::Left(ready(ValidatedTransaction::Invalid(hash, error::Error::TemporarilyBanned.into()))) + return Either::Left(ready(( + hash.clone(), + ValidatedTransaction::Invalid(hash, error::Error::TemporarilyBanned.into()), + ))) } Either::Right(self.validated_pool.api().validate_transaction(block_id, xt.clone()) - .then(move |validation_result| ready(match validation_result { + .then(move |validation_result| ready((hash.clone(), match validation_result { Ok(validity) => match validity { Ok(validity) => if validity.provides.is_empty() { ValidatedTransaction::Invalid(hash, error::Error::NoTagsProvided.into()) @@ -379,7 +419,7 @@ impl Pool { ValidatedTransaction::Unknown(hash, error::Error::UnknownTransaction(e).into()), }, Err(e) => ValidatedTransaction::Invalid(hash, e), - }))) + })))) } } @@ -391,50 +431,30 @@ impl Clone for Pool { } } -impl sr_primitives::offchain::TransactionPool for Pool { - fn submit_at( - &self, - at: &BlockId, - extrinsic: ::Extrinsic, - ) -> Result<(), ()> { - log::debug!( - target: "txpool", - "(offchain call) Submitting a transaction to the pool: {:?}", - extrinsic - ); - - let result = futures::executor::block_on(self.submit_one(&at, extrinsic)); - - result.map(|_| ()) - .map_err(|e| log::warn!( - target: "txpool", - "(offchain call) Error submitting a transaction to the pool: {:?}", - e - )) - } -} - #[cfg(test)] mod tests { use std::{ - collections::HashMap, + collections::{HashMap, HashSet}, time::Instant, }; use parking_lot::Mutex; use futures::executor::block_on; use super::*; + use txpool_api::TransactionStatus; use sr_primitives::transaction_validity::{ValidTransaction, InvalidTransaction}; use codec::Encode; use test_runtime::{Block, Extrinsic, Transfer, H256, AccountId}; use assert_matches::assert_matches; use crate::base_pool::Limit; - use crate::watcher; const INVALID_NONCE: u64 = 254; #[derive(Clone, Debug, Default)] struct TestApi { delay: Arc>>>, + invalidate: Arc>>, + clear_requirements: Arc>>, + add_requirements: Arc>>, } impl ChainApi for TestApi { @@ -449,6 +469,7 @@ mod tests { at: &BlockId, uxt: ExtrinsicFor, ) -> Self::ValidationFuture { + let hash = self.hash_and_length(&uxt).0; let block_number = self.block_id_to_number(at).unwrap().unwrap(); let nonce = uxt.transfer().nonce; @@ -462,16 +483,30 @@ mod tests { } } + if self.invalidate.lock().contains(&hash) { + return futures::future::ready(Ok(InvalidTransaction::Custom(0).into())); + } + futures::future::ready(if nonce < block_number { Ok(InvalidTransaction::Stale.into()) } else { - Ok(Ok(ValidTransaction { + let mut transaction = ValidTransaction { priority: 4, requires: if nonce > block_number { vec![vec![nonce as u8 - 1]] } else { vec![] }, provides: if nonce == INVALID_NONCE { vec![] } else { vec![vec![nonce as u8]] }, longevity: 3, propagate: true, - })) + }; + + if self.clear_requirements.lock().contains(&hash) { + transaction.requires.clear(); + } + + if self.add_requirements.lock().contains(&hash) { + transaction.requires.push(vec![128]); + } + + Ok(Ok(transaction)) }) } @@ -651,6 +686,7 @@ mod tests { let pool = Pool::new(Options { ready: limit.clone(), future: limit.clone(), + ..Default::default() }, TestApi::default()); let hash1 = block_on(pool.submit_one(&BlockId::Number(0), uxt(Transfer { @@ -685,6 +721,7 @@ mod tests { let pool = Pool::new(Options { ready: limit.clone(), future: limit.clone(), + ..Default::default() }, TestApi::default()); // when @@ -742,8 +779,8 @@ mod tests { // then let mut stream = futures::executor::block_on_stream(watcher.into_stream()); - assert_eq!(stream.next(), Some(watcher::Status::Ready)); - assert_eq!(stream.next(), Some(watcher::Status::Finalized(H256::from_low_u64_be(2).into()))); + assert_eq!(stream.next(), Some(TransactionStatus::Ready)); + assert_eq!(stream.next(), Some(TransactionStatus::Finalized(H256::from_low_u64_be(2).into()))); assert_eq!(stream.next(), None); } @@ -767,8 +804,8 @@ mod tests { // then let mut stream = futures::executor::block_on_stream(watcher.into_stream()); - assert_eq!(stream.next(), Some(watcher::Status::Ready)); - assert_eq!(stream.next(), Some(watcher::Status::Finalized(H256::from_low_u64_be(2).into()))); + assert_eq!(stream.next(), Some(TransactionStatus::Ready)); + assert_eq!(stream.next(), Some(TransactionStatus::Finalized(H256::from_low_u64_be(2).into()))); assert_eq!(stream.next(), None); } @@ -796,8 +833,8 @@ mod tests { // then let mut stream = futures::executor::block_on_stream(watcher.into_stream()); - assert_eq!(stream.next(), Some(watcher::Status::Future)); - assert_eq!(stream.next(), Some(watcher::Status::Ready)); + assert_eq!(stream.next(), Some(TransactionStatus::Future)); + assert_eq!(stream.next(), Some(TransactionStatus::Ready)); } #[test] @@ -819,8 +856,8 @@ mod tests { // then let mut stream = futures::executor::block_on_stream(watcher.into_stream()); - assert_eq!(stream.next(), Some(watcher::Status::Ready)); - assert_eq!(stream.next(), Some(watcher::Status::Invalid)); + assert_eq!(stream.next(), Some(TransactionStatus::Ready)); + assert_eq!(stream.next(), Some(TransactionStatus::Invalid)); assert_eq!(stream.next(), None); } @@ -846,8 +883,8 @@ mod tests { // then let mut stream = futures::executor::block_on_stream(watcher.into_stream()); - assert_eq!(stream.next(), Some(watcher::Status::Ready)); - assert_eq!(stream.next(), Some(watcher::Status::Broadcast(peers))); + assert_eq!(stream.next(), Some(TransactionStatus::Ready)); + assert_eq!(stream.next(), Some(TransactionStatus::Broadcast(peers))); } #[test] @@ -860,6 +897,7 @@ mod tests { let pool = Pool::new(Options { ready: limit.clone(), future: limit.clone(), + ..Default::default() }, TestApi::default()); let xt = uxt(Transfer { @@ -883,8 +921,8 @@ mod tests { // then let mut stream = futures::executor::block_on_stream(watcher.into_stream()); - assert_eq!(stream.next(), Some(watcher::Status::Ready)); - assert_eq!(stream.next(), Some(watcher::Status::Dropped)); + assert_eq!(stream.next(), Some(TransactionStatus::Ready)); + assert_eq!(stream.next(), Some(TransactionStatus::Dropped)); } #[test] @@ -941,5 +979,81 @@ mod tests { assert_eq!(pool.status().future, 0); } } + + #[test] + fn should_revalidate_ready_transactions() { + fn transfer(nonce: u64) -> Extrinsic { + uxt(Transfer { + from: AccountId::from_h256(H256::from_low_u64_be(1)), + to: AccountId::from_h256(H256::from_low_u64_be(2)), + amount: 5, + nonce, + }) + } + + // given + let pool = pool(); + let tx0 = transfer(0); + let hash0 = pool.validated_pool.api().hash_and_length(&tx0).0; + let watcher0 = block_on(pool.submit_and_watch(&BlockId::Number(0), tx0)).unwrap(); + let tx1 = transfer(1); + let hash1 = pool.validated_pool.api().hash_and_length(&tx1).0; + let watcher1 = block_on(pool.submit_and_watch(&BlockId::Number(0), tx1)).unwrap(); + let tx2 = transfer(2); + let hash2 = pool.validated_pool.api().hash_and_length(&tx2).0; + let watcher2 = block_on(pool.submit_and_watch(&BlockId::Number(0), tx2)).unwrap(); + let tx3 = transfer(3); + let hash3 = pool.validated_pool.api().hash_and_length(&tx3).0; + let watcher3 = block_on(pool.submit_and_watch(&BlockId::Number(0), tx3)).unwrap(); + let tx4 = transfer(4); + let hash4 = pool.validated_pool.api().hash_and_length(&tx4).0; + let watcher4 = block_on(pool.submit_and_watch(&BlockId::Number(0), tx4)).unwrap(); + assert_eq!(pool.status().ready, 5); + + // when + pool.validated_pool.api().invalidate.lock().insert(hash3); + pool.validated_pool.api().clear_requirements.lock().insert(hash1); + pool.validated_pool.api().add_requirements.lock().insert(hash0); + block_on(pool.revalidate_ready(&BlockId::Number(0))).unwrap(); + + // then + // hash0 now has unsatisfied requirements => it is moved to the future queue + // hash1 is now independent of hash0 => it is in ready queue + // hash2 still depends on hash1 => it is in ready queue + // hash3 is now invalid => it is removed from the pool + // hash4 now depends on invalidated hash3 => it is moved to the future queue + // + // events for hash3 are: Ready, Invalid + // events for hash4 are: Ready, Invalid + assert_eq!(pool.status().ready, 2); + assert_eq!( + futures::executor::block_on_stream(watcher3.into_stream()).collect::>(), + vec![TransactionStatus::Ready, TransactionStatus::Invalid], + ); + + // when + pool.validated_pool.remove_invalid(&[hash0, hash1, hash2, hash4]); + + // then + // events for hash0 are: Ready, Future, Invalid + // events for hash1 are: Ready, Invalid + // events for hash2 are: Ready, Invalid + assert_eq!( + futures::executor::block_on_stream(watcher0.into_stream()).collect::>(), + vec![TransactionStatus::Ready, TransactionStatus::Future, TransactionStatus::Invalid], + ); + assert_eq!( + futures::executor::block_on_stream(watcher1.into_stream()).collect::>(), + vec![TransactionStatus::Ready, TransactionStatus::Invalid], + ); + assert_eq!( + futures::executor::block_on_stream(watcher2.into_stream()).collect::>(), + vec![TransactionStatus::Ready, TransactionStatus::Invalid], + ); + assert_eq!( + futures::executor::block_on_stream(watcher4.into_stream()).collect::>(), + vec![TransactionStatus::Ready, TransactionStatus::Future, TransactionStatus::Invalid], + ); + } } diff --git a/client/transaction-pool/graph/src/ready.rs b/client/transaction-pool/graph/src/ready.rs index 3698bf447e..3684572bd0 100644 --- a/client/transaction-pool/graph/src/ready.rs +++ b/client/transaction-pool/graph/src/ready.rs @@ -28,8 +28,8 @@ use sr_primitives::traits::Member; use sr_primitives::transaction_validity::{ TransactionTag as Tag, }; +use txpool_api::error; -use crate::error; use crate::future::WaitingTransaction; use crate::base_pool::Transaction; @@ -433,6 +433,7 @@ impl ReadyTransactions { } } +/// Iterator of ready transactions ordered by priority. pub struct BestIterator { all: Arc>>>, awaiting: HashMap)>, diff --git a/client/transaction-pool/graph/src/validated_pool.rs b/client/transaction-pool/graph/src/validated_pool.rs index 7317d41f42..2aca2adb72 100644 --- a/client/transaction-pool/graph/src/validated_pool.rs +++ b/client/transaction-pool/graph/src/validated_pool.rs @@ -18,16 +18,16 @@ use std::{ collections::{HashSet, HashMap}, fmt, hash, + sync::Arc, time, }; use crate::base_pool as base; -use crate::error; use crate::listener::Listener; use crate::rotator::PoolRotator; use crate::watcher::Watcher; use serde::Serialize; -use log::debug; +use log::{debug, warn}; use futures::channel::mpsc; use parking_lot::{Mutex, RwLock}; @@ -36,6 +36,7 @@ use sr_primitives::{ traits::{self, SaturatedConversion}, transaction_validity::TransactionTag as Tag, }; +use txpool_api::{error, PoolStatus}; use crate::base_pool::PruneStatus; use crate::pool::{EventStream, Options, ChainApi, BlockHash, ExHash, ExtrinsicFor, TransactionFor}; @@ -76,11 +77,12 @@ pub(crate) struct ValidatedPool { impl ValidatedPool { /// Create a new transaction pool. pub fn new(options: Options, api: B) -> Self { + let base_pool = base::BasePool::new(options.reject_future_transactions); ValidatedPool { api, options, listener: Default::default(), - pool: Default::default(), + pool: RwLock::new(base_pool), import_notification_sinks: Default::default(), rotator: Default::default(), } @@ -189,18 +191,134 @@ impl ValidatedPool { } } + /// Resubmits revalidated transactions back to the pool. + /// + /// Removes and then submits passed transactions and all dependent transactions. + /// Transactions that are missing from the pool are not submitted. + pub fn resubmit(&self, mut updated_transactions: HashMap, ValidatedTransactionFor>) { + #[derive(Debug, Clone, Copy, PartialEq)] + enum Status { Future, Ready, Failed, Dropped }; + + let (mut initial_statuses, final_statuses) = { + let mut pool = self.pool.write(); + + // remove all passed transactions from the ready/future queues + // (this may remove additional transactions as well) + // + // for every transaction that has an entry in the `updated_transactions`, + // we store updated validation result in txs_to_resubmit + // for every transaction that has no entry in the `updated_transactions`, + // we store last validation result (i.e. the pool entry) in txs_to_resubmit + let mut initial_statuses = HashMap::new(); + let mut txs_to_resubmit = Vec::with_capacity(updated_transactions.len()); + while !updated_transactions.is_empty() { + let hash = updated_transactions.keys().next().cloned().expect("transactions is not empty; qed"); + + // note we are not considering tx with hash invalid here - we just want + // to remove it along with dependent transactions and `remove_invalid()` + // does exactly what we need + let removed = pool.remove_invalid(&[hash.clone()]); + for removed_tx in removed { + let removed_hash = removed_tx.hash.clone(); + let updated_transaction = updated_transactions.remove(&removed_hash); + let tx_to_resubmit = if let Some(updated_tx) = updated_transaction { + updated_tx + } else { + // in most cases we'll end up in successful `try_unwrap`, but if not + // we still need to reinsert transaction back to the pool => duplicate call + let transaction = match Arc::try_unwrap(removed_tx) { + Ok(transaction) => transaction, + Err(transaction) => transaction.duplicate(), + }; + ValidatedTransaction::Valid(transaction) + }; + + initial_statuses.insert(removed_hash.clone(), Status::Ready); + txs_to_resubmit.push((removed_hash, tx_to_resubmit)); + } + } + + // if we're rejecting future transactions, then insertion order matters here: + // if tx1 depends on tx2, then if tx1 is inserted before tx2, then it goes + // to the future queue and gets rejected immediately + // => let's temporary stop rejection and clear future queue before return + pool.with_futures_enabled(|pool, reject_future_transactions| { + // now resubmit all removed transactions back to the pool + let mut final_statuses = HashMap::new(); + for (hash, tx_to_resubmit) in txs_to_resubmit { + match tx_to_resubmit { + ValidatedTransaction::Valid(tx) => match pool.import(tx) { + Ok(imported) => match imported { + base::Imported::Ready { promoted, failed, removed, .. } => { + final_statuses.insert(hash, Status::Ready); + for hash in promoted { + final_statuses.insert(hash, Status::Ready); + } + for hash in failed { + final_statuses.insert(hash, Status::Failed); + } + for tx in removed { + final_statuses.insert(tx.hash.clone(), Status::Dropped); + } + }, + base::Imported::Future { .. } => { + final_statuses.insert(hash, Status::Future); + }, + }, + Err(err) => { + // we do not want to fail if single transaction import has failed + // nor we do want to propagate this error, because it could tx unknown to caller + // => let's just notify listeners (and issue debug message) + warn!( + target: "txpool", + "[{:?}] Removing invalid transaction from update: {}", + hash, + err, + ); + final_statuses.insert(hash, Status::Failed); + }, + }, + ValidatedTransaction::Invalid(_, _) | ValidatedTransaction::Unknown(_, _) => { + final_statuses.insert(hash, Status::Failed); + }, + } + } + + // if the pool is configured to reject future transactions, let's clear the future + // queue, updating final statuses as required + if reject_future_transactions { + for future_tx in pool.clear_future() { + final_statuses.insert(future_tx.hash.clone(), Status::Dropped); + } + } + + (initial_statuses, final_statuses) + }) + }; + + // and now let's notify listeners about status changes + let mut listener = self.listener.write(); + for (hash, final_status) in final_statuses { + let initial_status = initial_statuses.remove(&hash); + if initial_status.is_none() || Some(final_status) != initial_status { + match final_status { + Status::Future => listener.future(&hash), + Status::Ready => listener.ready(&hash, None), + Status::Failed => listener.invalid(&hash), + Status::Dropped => listener.dropped(&hash, None), + } + } + } + } + /// For each extrinsic, returns tags that it provides (if known), or None (if it is unknown). - pub fn extrinsics_tags(&self, extrinsics: &[ExtrinsicFor]) -> (Vec>, Vec>>) { - let hashes = extrinsics.iter().map(|extrinsic| self.api.hash_and_length(extrinsic).0).collect::>(); - let in_pool = self.pool.read().by_hash(&hashes); - ( - hashes, - in_pool.into_iter() - .map(|existing_in_pool| existing_in_pool - .map(|transaction| transaction.provides.iter().cloned() - .collect())) - .collect(), - ) + pub fn extrinsics_tags(&self, hashes: &[ExHash]) -> Vec>> { + self.pool.read().by_hash(&hashes) + .into_iter() + .map(|existing_in_pool| existing_in_pool + .map(|transaction| transaction.provides.iter().cloned() + .collect())) + .collect() } /// Prunes ready transactions that provide given list of tags. @@ -249,20 +367,29 @@ impl ValidatedPool { // Fire `pruned` notifications for collected hashes and make sure to include // `known_imported_hashes` since they were just imported as part of the block. let hashes = hashes.chain(known_imported_hashes.into_iter()); - { - let header_hash = self.api.block_id_to_hash(at)? - .ok_or_else(|| error::Error::InvalidBlockId(format!("{:?}", at)).into())?; - let mut listener = self.listener.write(); - for h in hashes { - listener.pruned(header_hash, &h); - } - } + self.fire_pruned(at, hashes)?; + // perform regular cleanup of old transactions in the pool // and update temporary bans. self.clear_stale(at)?; Ok(()) } + /// Fire notifications for pruned transactions. + pub fn fire_pruned( + &self, + at: &BlockId, + hashes: impl Iterator>, + ) -> Result<(), B::Error> { + let header_hash = self.api.block_id_to_hash(at)? + .ok_or_else(|| error::Error::InvalidBlockId(format!("{:?}", at)).into())?; + let mut listener = self.listener.write(); + for h in hashes { + listener.pruned(header_hash, &h); + } + Ok(()) + } + /// Removes stale transactions from the pool. /// /// Stale transactions are transaction beyond their longevity period. @@ -270,8 +397,8 @@ impl ValidatedPool { /// See `prune_tags` if you want this. pub fn clear_stale(&self, at: &BlockId) -> Result<(), B::Error> { let block_number = self.api.block_id_to_number(at)? - .ok_or_else(|| error::Error::InvalidBlockId(format!("{:?}", at)).into())? - .saturated_into::(); + .ok_or_else(|| error::Error::InvalidBlockId(format!("{:?}", at)).into())? + .saturated_into::(); let now = time::Instant::now(); let to_remove = { self.ready() @@ -346,7 +473,7 @@ impl ValidatedPool { } /// Returns pool status. - pub fn status(&self) -> base::Status { + pub fn status(&self) -> PoolStatus { self.pool.read().status() } } diff --git a/client/transaction-pool/graph/src/watcher.rs b/client/transaction-pool/graph/src/watcher.rs index 11d6b9f407..fa93386c8c 100644 --- a/client/transaction-pool/graph/src/watcher.rs +++ b/client/transaction-pool/graph/src/watcher.rs @@ -20,34 +20,14 @@ use futures::{ Stream, channel::mpsc, }; -use serde::{Serialize, Deserialize}; - -/// Possible extrinsic status events -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] -pub enum Status { - /// Extrinsic is part of the future queue. - Future, - /// Extrinsic is part of the ready queue. - Ready, - /// Extrinsic has been finalized in block with given hash. - Finalized(H2), - /// Some state change (perhaps another extrinsic was included) rendered this extrinsic invalid. - Usurped(H), - /// The extrinsic has been broadcast to the given peers. - Broadcast(Vec), - /// Extrinsic has been dropped from the pool because of the limit. - Dropped, - /// Extrinsic was detected as invalid. - Invalid, -} +use txpool_api::TransactionStatus; /// Extrinsic watcher. /// /// Represents a stream of status updates for particular extrinsic. #[derive(Debug)] pub struct Watcher { - receiver: mpsc::UnboundedReceiver>, + receiver: mpsc::UnboundedReceiver>, hash: H, } @@ -60,7 +40,7 @@ impl Watcher { /// Pipe the notifications to given sink. /// /// Make sure to drive the future to completion. - pub fn into_stream(self) -> impl Stream> { + pub fn into_stream(self) -> impl Stream> { self.receiver } } @@ -68,7 +48,7 @@ impl Watcher { /// Sender part of the watcher. Exposed only for testing purposes. #[derive(Debug)] pub struct Sender { - receivers: Vec>>, + receivers: Vec>>, finalized: bool, } @@ -94,49 +74,48 @@ impl Sender { /// Transaction became ready. pub fn ready(&mut self) { - self.send(Status::Ready) + self.send(TransactionStatus::Ready) } /// Transaction was moved to future. pub fn future(&mut self) { - self.send(Status::Future) + self.send(TransactionStatus::Future) } /// Some state change (perhaps another extrinsic was included) rendered this extrinsic invalid. pub fn usurped(&mut self, hash: H) { - self.send(Status::Usurped(hash)) + self.send(TransactionStatus::Usurped(hash)) } /// Extrinsic has been finalized in block with given hash. pub fn finalized(&mut self, hash: H2) { - self.send(Status::Finalized(hash)); + self.send(TransactionStatus::Finalized(hash)); self.finalized = true; } /// Extrinsic has been marked as invalid by the block builder. pub fn invalid(&mut self) { - self.send(Status::Invalid); + self.send(TransactionStatus::Invalid); // we mark as finalized as there are no more notifications self.finalized = true; } /// Transaction has been dropped from the pool because of the limit. pub fn dropped(&mut self) { - self.send(Status::Dropped); + self.send(TransactionStatus::Dropped); } /// The extrinsic has been broadcast to the given peers. pub fn broadcast(&mut self, peers: Vec) { - self.send(Status::Broadcast(peers)) + self.send(TransactionStatus::Broadcast(peers)) } - /// Returns true if the are no more listeners for this extrinsic or it was finalized. pub fn is_done(&self) -> bool { self.finalized || self.receivers.is_empty() } - fn send(&mut self, status: Status) { + fn send(&mut self, status: TransactionStatus) { self.receivers.retain(|sender| sender.unbounded_send(status.clone()).is_ok()) } } diff --git a/client/transaction-pool/src/api.rs b/client/transaction-pool/src/api.rs index 28681fb11b..87b494201d 100644 --- a/client/transaction-pool/src/api.rs +++ b/client/transaction-pool/src/api.rs @@ -17,20 +17,20 @@ //! Chain api required for the transaction pool. use std::{marker::PhantomData, pin::Pin, sync::Arc}; +use codec::{Decode, Encode}; +use futures::{channel::oneshot, executor::{ThreadPool, ThreadPoolBuilder}, future::{Future, FutureExt, ready}}; -use codec::Encode; - -use futures::{channel::oneshot, executor::{ThreadPool, ThreadPoolBuilder}, future::Future}; - +use client_api::{ + blockchain::HeaderBackend, + light::{Fetcher, RemoteCallRequest} +}; use primitives::{H256, Blake2Hasher, Hasher}; - -use sr_primitives::{generic::BlockId, traits, transaction_validity::TransactionValidity}; - -use tx_runtime_api::TaggedTransactionQueue; +use sr_primitives::{generic::BlockId, traits::{self, Block as BlockT}, transaction_validity::TransactionValidity}; +use txpool_runtime_api::TaggedTransactionQueue; use crate::error::{self, Error}; -/// The transaction pool logic +/// The transaction pool logic for full client. pub struct FullChainApi { client: Arc, pool: ThreadPool, @@ -38,7 +38,7 @@ pub struct FullChainApi { } impl FullChainApi where - Block: traits::Block, + Block: BlockT, T: traits::ProvideRuntimeApi + traits::BlockIdTo { /// Create new transaction pool logic. pub fn new(client: Arc) -> Self { @@ -55,7 +55,7 @@ impl FullChainApi where } impl txpool::ChainApi for FullChainApi where - Block: traits::Block, + Block: BlockT, T: traits::ProvideRuntimeApi + traits::BlockIdTo + 'static + Send + Sync, T::Api: TaggedTransactionQueue, sr_api::ApiErrorFor: Send, @@ -110,3 +110,84 @@ impl txpool::ChainApi for FullChainApi where }) } } + +/// The transaction pool logic for light client. +pub struct LightChainApi { + client: Arc, + fetcher: Arc, + _phantom: PhantomData, +} + +impl LightChainApi where + Block: BlockT, + T: HeaderBackend, + F: Fetcher, +{ + /// Create new transaction pool logic. + pub fn new(client: Arc, fetcher: Arc) -> Self { + LightChainApi { + client, + fetcher, + _phantom: Default::default(), + } + } +} + +impl txpool::ChainApi for LightChainApi where + Block: BlockT, + T: HeaderBackend + 'static, + F: Fetcher + 'static, +{ + type Block = Block; + type Hash = H256; + type Error = error::Error; + type ValidationFuture = Box> + Send + Unpin>; + + fn validate_transaction( + &self, + at: &BlockId, + uxt: txpool::ExtrinsicFor, + ) -> Self::ValidationFuture { + let header_hash = self.client.expect_block_hash_from_id(at); + let header_and_hash = header_hash + .and_then(|header_hash| self.client.expect_header(BlockId::Hash(header_hash)) + .map(|header| (header_hash, header))); + let (block, header) = match header_and_hash { + Ok((header_hash, header)) => (header_hash, header), + Err(err) => return Box::new(ready(Err(err.into()))), + }; + let remote_validation_request = self.fetcher.remote_call(RemoteCallRequest { + block, + header, + method: "TaggedTransactionQueue_validate_transaction".into(), + call_data: uxt.encode(), + retry_count: None, + }); + let remote_validation_request = remote_validation_request.then(move |result| { + let result: error::Result = result + .map_err(Into::into) + .and_then(|result| Decode::decode(&mut &result[..]) + .map_err(|e| Error::RuntimeApi( + format!("Error decoding tx validation result: {:?}", e) + )) + ); + ready(result) + }); + + Box::new(remote_validation_request) + } + + fn block_id_to_number(&self, at: &BlockId) -> error::Result>> { + Ok(self.client.block_number_from_id(at)?) + } + + fn block_id_to_hash(&self, at: &BlockId) -> error::Result>> { + Ok(self.client.block_hash_from_id(at)?) + } + + fn hash_and_length(&self, ex: &txpool::ExtrinsicFor) -> (Self::Hash, usize) { + ex.using_encoded(|x| { + (Blake2Hasher::hash(x), x.len()) + }) + } +} diff --git a/client/transaction-pool/src/error.rs b/client/transaction-pool/src/error.rs index 83667d4cbc..d769944ad6 100644 --- a/client/transaction-pool/src/error.rs +++ b/client/transaction-pool/src/error.rs @@ -23,7 +23,9 @@ pub type Result = std::result::Result; #[derive(Debug, derive_more::Display, derive_more::From)] pub enum Error { /// Pool error. - Pool(txpool::error::Error), + Pool(txpool_api::error::Error), + /// Blockchain error. + Blockchain(sp_blockchain::Error), /// Error while converting a `BlockId`. #[from(ignore)] BlockIdConversion(String), @@ -36,14 +38,15 @@ impl std::error::Error for Error { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { match self { Error::Pool(ref err) => Some(err), + Error::Blockchain(ref err) => Some(err), Error::BlockIdConversion(_) => None, Error::RuntimeApi(_) => None, } } } -impl txpool::IntoPoolError for Error { - fn into_pool_error(self) -> std::result::Result { +impl txpool_api::IntoPoolError for Error { + fn into_pool_error(self) -> std::result::Result { match self { Error::Pool(e) => Ok(e), e => Err(e), diff --git a/client/transaction-pool/src/lib.rs b/client/transaction-pool/src/lib.rs index d7703de652..1499ab26d4 100644 --- a/client/transaction-pool/src/lib.rs +++ b/client/transaction-pool/src/lib.rs @@ -14,15 +14,119 @@ // You should have received a copy of the GNU General Public License // along with Substrate. If not, see . -//! Substrate transaction pool. +//! Substrate transaction pool implementation. #![warn(missing_docs)] #![warn(unused_extern_crates)] mod api; +mod maintainer; + pub mod error; #[cfg(test)] mod tests; -pub use api::FullChainApi; pub use txpool; +pub use crate::api::{FullChainApi, LightChainApi}; +pub use crate::maintainer::{FullBasicPoolMaintainer, LightBasicPoolMaintainer}; + +use std::{collections::HashMap, sync::Arc}; +use futures::{Future, FutureExt}; + +use sr_primitives::{ + generic::BlockId, + traits::Block as BlockT, +}; +use txpool_api::{ + TransactionPool, PoolStatus, ImportNotificationStream, + TxHash, TransactionFor, TransactionStatusStreamFor, +}; + +/// Basic implementation of transaction pool that can be customized by providing PoolApi. +pub struct BasicPool + where + Block: BlockT, + PoolApi: txpool::ChainApi, +{ + pool: Arc>, +} + +impl BasicPool + where + Block: BlockT, + PoolApi: txpool::ChainApi, +{ + /// Create new basic transaction pool with provided api. + pub fn new(options: txpool::Options, pool_api: PoolApi) -> Self { + BasicPool { + pool: Arc::new(txpool::Pool::new(options, pool_api)), + } + } + + /// Gets shared reference to the underlying pool. + pub fn pool(&self) -> &Arc> { + &self.pool + } +} + +impl TransactionPool for BasicPool + where + Block: BlockT, + PoolApi: 'static + txpool::ChainApi, +{ + type Block = PoolApi::Block; + type Hash = txpool::ExHash; + type InPoolTransaction = txpool::base_pool::Transaction, TransactionFor>; + type Error = error::Error; + + fn submit_at( + &self, + at: &BlockId, + xts: impl IntoIterator> + 'static, + ) -> Box, Self::Error>>, Self::Error>> + Send + Unpin> { + Box::new(self.pool.submit_at(at, xts, false)) + } + + fn submit_one( + &self, + at: &BlockId, + xt: TransactionFor, + ) -> Box, Self::Error>> + Send + Unpin> { + Box::new(self.pool.submit_one(at, xt)) + } + + fn submit_and_watch( + &self, + at: &BlockId, + xt: TransactionFor, + ) -> Box>, Self::Error>> + Send + Unpin> { + Box::new( + self.pool.submit_and_watch(at, xt) + .map(|result| result.map(|watcher| Box::new(watcher.into_stream()) as _)) + ) + } + + fn remove_invalid(&self, hashes: &[TxHash]) -> Vec> { + self.pool.remove_invalid(hashes) + } + + fn status(&self) -> PoolStatus { + self.pool.status() + } + + fn ready(&self) -> Box>> { + Box::new(self.pool.ready()) + } + + fn import_notification_stream(&self) -> ImportNotificationStream { + self.pool.import_notification_stream() + } + + fn hash_of(&self, xt: &TransactionFor) -> TxHash { + self.pool.hash_of(xt) + } + + fn on_broadcasted(&self, propagations: HashMap, Vec>) { + self.pool.on_broadcasted(propagations) + } +} diff --git a/client/transaction-pool/src/maintainer.rs b/client/transaction-pool/src/maintainer.rs new file mode 100644 index 0000000000..a390dde88b --- /dev/null +++ b/client/transaction-pool/src/maintainer.rs @@ -0,0 +1,587 @@ +// Copyright 2019 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Substrate is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Substrate. If not, see . + +use std::{ + marker::{PhantomData, Unpin}, + sync::Arc, + time::Instant, +}; +use futures::{ + Future, FutureExt, + future::{Either, join, ready}, +}; +use log::warn; +use parking_lot::Mutex; + +use client_api::{ + client::BlockBody, + light::{Fetcher, RemoteBodyRequest}, +}; +use primitives::{Blake2Hasher, H256}; +use sr_primitives::{ + generic::BlockId, + traits::{Block as BlockT, Extrinsic, Header, NumberFor, ProvideRuntimeApi, SimpleArithmetic}, +}; +use sp_blockchain::HeaderBackend; +use txpool_api::TransactionPoolMaintainer; +use txpool_runtime_api::TaggedTransactionQueue; + +use txpool::{self, ChainApi}; + +/// Basic transaction pool maintainer for full clients. +pub struct FullBasicPoolMaintainer { + pool: Arc>, + client: Arc, +} + +impl FullBasicPoolMaintainer { + /// Create new basic full pool maintainer. + pub fn new( + pool: Arc>, + client: Arc, + ) -> Self { + FullBasicPoolMaintainer { pool, client } + } +} + +impl TransactionPoolMaintainer +for + FullBasicPoolMaintainer +where + Block: BlockT::Out>, + Client: ProvideRuntimeApi + HeaderBackend + BlockBody + 'static, + Client::Api: TaggedTransactionQueue, + PoolApi: ChainApi + 'static, +{ + type Block = Block; + type Hash = Block::Hash; + + fn maintain( + &self, + id: &BlockId, + retracted: &[Block::Hash], + ) -> Box + Send + Unpin> { + // Put transactions from retracted blocks back into the pool. + let client_copy = self.client.clone(); + let retracted_transactions = retracted.to_vec().into_iter() + .filter_map(move |hash| client_copy.block_body(&BlockId::hash(hash)).ok().unwrap_or(None)) + .flat_map(|block| block.into_iter()) + .filter(|tx| tx.is_signed().unwrap_or(false)); + let resubmit_future = self.pool + .submit_at(id, retracted_transactions, true) + .then(|resubmit_result| ready(match resubmit_result { + Ok(_) => (), + Err(e) => { + warn!("Error re-submitting transactions: {:?}", e); + () + } + })); + + // Avoid calling into runtime if there is nothing to prune from the pool anyway. + if self.pool.status().is_empty() { + return Box::new(resubmit_future) + } + + let block = (self.client.header(*id), self.client.block_body(id)); + match block { + (Ok(Some(header)), Ok(Some(extrinsics))) => { + let parent_id = BlockId::hash(*header.parent_hash()); + let prune_future = self.pool + .prune(id, &parent_id, &extrinsics) + .then(|prune_result| ready(match prune_result { + Ok(_) => (), + Err(e) => { + warn!("Error pruning transactions: {:?}", e); + () + } + })); + + Box::new(resubmit_future.then(|_| prune_future)) + }, + (Ok(_), Ok(_)) => Box::new(resubmit_future), + err => { + warn!("Error reading block: {:?}", err); + Box::new(resubmit_future) + }, + } + } +} + +/// Basic transaction pool maintainer for light clients. +pub struct LightBasicPoolMaintainer { + pool: Arc>, + client: Arc, + fetcher: Arc, + revalidate_time_period: Option, + revalidate_block_period: Option>, + revalidation_status: Arc>>>, + _phantom: PhantomData, +} + +impl LightBasicPoolMaintainer + where + Block: BlockT::Out>, + Client: ProvideRuntimeApi + HeaderBackend + BlockBody + 'static, + Client::Api: TaggedTransactionQueue, + PoolApi: ChainApi + 'static, + F: Fetcher + 'static, +{ + /// Create light pool maintainer with default constants. + /// + /// Default constants are: revalidate every 60 seconds or every 20 blocks + /// (whatever happens first). + pub fn with_defaults( + pool: Arc>, + client: Arc, + fetcher: Arc, + ) -> Self { + Self::new( + pool, + client, + fetcher, + Some(std::time::Duration::from_secs(60)), + Some(20.into()), + ) + } + + /// Create light pool maintainer with passed constants. + pub fn new( + pool: Arc>, + client: Arc, + fetcher: Arc, + revalidate_time_period: Option, + revalidate_block_period: Option>, + ) -> Self { + Self { + pool, + client, + fetcher, + revalidate_time_period, + revalidate_block_period, + revalidation_status: Arc::new(Mutex::new(TxPoolRevalidationStatus::NotScheduled)), + _phantom: Default::default(), + } + } + + /// Returns future that prunes block transactions from the pool. + fn prune( + &self, + id: &BlockId, + header: &Block::Header, + ) -> impl std::future::Future { + // fetch transactions (possible future optimization: proofs of inclusion) that + // have been included into new block and prune these from the pool + let id = id.clone(); + let pool = self.pool.clone(); + self.fetcher.remote_body(RemoteBodyRequest { + header: header.clone(), + retry_count: None, + }) + .then(move |transactions| ready( + transactions + .map_err(|e| format!("{}", e)) + .and_then(|transactions| { + let hashes = transactions + .into_iter() + .map(|tx| pool.hash_of(&tx)) + .collect::>(); + pool.prune_known(&id, &hashes) + .map_err(|e| format!("{}", e)) + }) + )) + .then(|r| { + if let Err(e) = r { + warn!("Error pruning known transactions: {}", e) + } + ready(()) + }) + } + + /// Returns future that performs in-pool transations revalidation, if required. + fn revalidate( + &self, + id: &BlockId, + header: &Block::Header, + ) -> impl std::future::Future { + // to determine whether ready transaction is still valid, we perform periodic revalidaton + // of ready transactions + let is_revalidation_required = self.revalidation_status.lock().is_required( + *header.number(), + self.revalidate_time_period, + self.revalidate_block_period, + ); + match is_revalidation_required { + true => { + let revalidation_status = self.revalidation_status.clone(); + Either::Left(self.pool + .revalidate_ready(id) + .map(|r| r.map_err(|e| warn!("Error revalidating known transactions: {}", e))) + .map(move |_| revalidation_status.lock().clear())) + }, + false => Either::Right(ready(())), + } + } +} + +impl TransactionPoolMaintainer +for + LightBasicPoolMaintainer +where + Block: BlockT::Out>, + Client: ProvideRuntimeApi + HeaderBackend + BlockBody + 'static, + Client::Api: TaggedTransactionQueue, + PoolApi: ChainApi + 'static, + F: Fetcher + 'static, +{ + type Block = Block; + type Hash = Block::Hash; + + fn maintain( + &self, + id: &BlockId, + _retracted: &[Block::Hash], + ) -> Box + Send + Unpin> { + // Do nothing if transaction pool is empty. + if self.pool.status().is_empty() { + self.revalidation_status.lock().clear(); + return Box::new(ready(())); + } + let header = self.client.header(*id) + .and_then(|h| h.ok_or(sp_blockchain::Error::UnknownBlock(format!("{}", id)))); + let header = match header { + Ok(header) => header, + Err(err) => { + println!("Failed to maintain light tx pool: {:?}", err); + return Box::new(ready(())); + } + }; + + // else prune block transactions from the pool + let prune_future = self.prune(id, &header); + + // and then (optionally) revalidate in-pool transactions + let revalidate_future = self.revalidate(id, &header); + + let maintain_future = join( + prune_future, + revalidate_future, + ).map(|_| ()); + + Box::new(maintain_future) + } +} + +/// The status of transactions revalidation at light tx pool. +#[cfg_attr(test, derive(Debug))] +enum TxPoolRevalidationStatus { + /// The revalidation has never been completed. + NotScheduled, + /// The revalidation is scheduled. + Scheduled(Option, Option), + /// The revalidation is in progress. + InProgress, +} + +impl TxPoolRevalidationStatus { + /// Called when revalidation is completed. + pub fn clear(&mut self) { + *self = TxPoolRevalidationStatus::NotScheduled; + } + + /// Returns true if revalidation is required. + pub fn is_required( + &mut self, + block: N, + revalidate_time_period: Option, + revalidate_block_period: Option, + ) -> bool { + match *self { + TxPoolRevalidationStatus::NotScheduled => { + *self = TxPoolRevalidationStatus::Scheduled( + revalidate_time_period.map(|period| Instant::now() + period), + revalidate_block_period.map(|period| block + period), + ); + false + }, + TxPoolRevalidationStatus::Scheduled(revalidate_at_time, revalidate_at_block) => { + let is_required = revalidate_at_time.map(|at| Instant::now() >= at).unwrap_or(false) + || revalidate_at_block.map(|at| block >= at).unwrap_or(false); + if is_required { + *self = TxPoolRevalidationStatus::InProgress; + } + is_required + }, + TxPoolRevalidationStatus::InProgress => false, + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + use futures::executor::block_on; + use codec::Encode; + use test_client::{prelude::*, runtime::{Block, Transfer}, consensus::{BlockOrigin, SelectChain}}; + use txpool_api::PoolStatus; + use crate::api::{FullChainApi, LightChainApi}; + + #[test] + fn should_remove_transactions_from_the_full_pool() { + let (client, longest_chain) = TestClientBuilder::new().build_with_longest_chain(); + let client = Arc::new(client); + let pool = txpool::Pool::new(Default::default(), FullChainApi::new(client.clone())); + let pool = Arc::new(pool); + let transaction = Transfer { + amount: 5, + nonce: 0, + from: AccountKeyring::Alice.into(), + to: Default::default(), + }.into_signed_tx(); + let best = longest_chain.best_chain().unwrap(); + + // store the transaction in the pool + block_on(pool.submit_one(&BlockId::hash(best.hash()), transaction.clone())).unwrap(); + + // import the block + let mut builder = client.new_block(Default::default()).unwrap(); + builder.push(transaction.clone()).unwrap(); + let block = builder.bake().unwrap(); + let id = BlockId::hash(block.header().hash()); + client.import(BlockOrigin::Own, block).unwrap(); + + // fire notification - this should clean up the queue + assert_eq!(pool.status().ready, 1); + block_on(FullBasicPoolMaintainer::new(pool.clone(), client).maintain(&id, &[])); + + // then + assert_eq!(pool.status().ready, 0); + assert_eq!(pool.status().future, 0); + } + + #[test] + fn should_remove_transactions_from_the_light_pool() { + let transaction = Transfer { + amount: 5, + nonce: 0, + from: AccountKeyring::Alice.into(), + to: Default::default(), + }.into_signed_tx(); + let fetcher_transaction = transaction.clone(); + let fetcher = Arc::new(test_client::new_light_fetcher() + .with_remote_body(Some(Box::new(move |_| Ok(vec![fetcher_transaction.clone()])))) + .with_remote_call(Some(Box::new(move |_| { + let validity: sr_primitives::transaction_validity::TransactionValidity = + Ok(sr_primitives::transaction_validity::ValidTransaction { + priority: 0, + requires: Vec::new(), + provides: vec![vec![42]], + longevity: 0, + propagate: true, + }); + Ok(validity.encode()) + })))); + + let (client, longest_chain) = TestClientBuilder::new().build_with_longest_chain(); + let client = Arc::new(client); + let pool = txpool::Pool::new(Default::default(), LightChainApi::new( + client.clone(), + fetcher.clone(), + )); + let pool = Arc::new(pool); + let best = longest_chain.best_chain().unwrap(); + + // store the transaction in the pool + block_on(pool.submit_one(&BlockId::hash(best.hash()), transaction.clone())).unwrap(); + + // fire notification - this should clean up the queue + assert_eq!(pool.status().ready, 1); + block_on(LightBasicPoolMaintainer::with_defaults(pool.clone(), client.clone(), fetcher).maintain( + &BlockId::Number(0), + &[], + )); + + // then + assert_eq!(pool.status().ready, 0); + assert_eq!(pool.status().future, 0); + } + + #[test] + fn should_schedule_transactions_revalidation_at_light_pool() { + // when revalidation is not scheduled, it became scheduled + let mut status = TxPoolRevalidationStatus::NotScheduled; + assert!(!status.is_required(10u32, None, None)); + match status { + TxPoolRevalidationStatus::Scheduled(_, _) => (), + _ => panic!("Unexpected status: {:?}", status), + } + + // revalidation required at time + let mut status = TxPoolRevalidationStatus::Scheduled(Some(Instant::now()), None); + assert!(status.is_required(10u32, None, None)); + match status { + TxPoolRevalidationStatus::InProgress => (), + _ => panic!("Unexpected status: {:?}", status), + } + + // revalidation required at block + let mut status = TxPoolRevalidationStatus::Scheduled(None, Some(10)); + assert!(status.is_required(10u32, None, None)); + match status { + TxPoolRevalidationStatus::InProgress => (), + _ => panic!("Unexpected status: {:?}", status), + } + } + + #[test] + fn should_revalidate_transactions_at_light_pool() { + use std::sync::atomic; + use sr_primitives::transaction_validity::*; + + let build_fetcher = || { + let validated = Arc::new(atomic::AtomicBool::new(false)); + Arc::new(test_client::new_light_fetcher() + .with_remote_body(Some(Box::new(move |_| Ok(vec![])))) + .with_remote_call(Some(Box::new(move |_| { + let is_inserted = validated.swap(true, atomic::Ordering::SeqCst); + let validity: TransactionValidity = if is_inserted { + Err(TransactionValidityError::Invalid( + InvalidTransaction::Custom(0) + )) + } else { + Ok(ValidTransaction { + priority: 0, + requires: Vec::new(), + provides: vec![vec![42]], + longevity: 0, + propagate: true, + }) + }; + Ok(validity.encode()) + })))) + }; + + fn with_fetcher_maintain + 'static>( + fetcher: Arc, + revalidate_time_period: Option, + revalidate_block_period: Option, + prepare_maintainer: impl Fn(&Mutex>), + ) -> PoolStatus { + let (client, longest_chain) = TestClientBuilder::new().build_with_longest_chain(); + let client = Arc::new(client); + + // now let's prepare pool + let pool = txpool::Pool::new(Default::default(), LightChainApi::new( + client.clone(), + fetcher.clone(), + )); + let pool = Arc::new(pool); + let best = longest_chain.best_chain().unwrap(); + + // let's prepare maintainer + let maintainer = LightBasicPoolMaintainer::new( + pool.clone(), + client, + fetcher, + revalidate_time_period, + revalidate_block_period, + ); + prepare_maintainer(&*maintainer.revalidation_status); + + // store the transaction in the pool + block_on(pool.submit_one( + &BlockId::hash(best.hash()), + Transfer { + amount: 5, + nonce: 0, + from: AccountKeyring::Alice.into(), + to: Default::default(), + }.into_signed_tx(), + )).unwrap(); + + // and run maintain procedures + block_on(maintainer.maintain(&BlockId::Number(0), &[])); + + pool.status() + } + + // when revalidation is never required - nothing happens + let fetcher = build_fetcher(); + //let maintainer = DefaultLightTransactionPoolMaintainer::new(client.clone(), fetcher.clone(), None, None); + let status = with_fetcher_maintain(fetcher, None, None, |_revalidation_status| {}); + assert_eq!(status.ready, 1); + + // when revalidation is scheduled by time - it is performed + let fetcher = build_fetcher(); + let status = with_fetcher_maintain(fetcher, None, None, |revalidation_status| + *revalidation_status.lock() = TxPoolRevalidationStatus::Scheduled(Some(Instant::now()), None) + ); + assert_eq!(status.ready, 0); + + // when revalidation is scheduled by block number - it is performed + let fetcher = build_fetcher(); + let status = with_fetcher_maintain(fetcher, None, None, |revalidation_status| + *revalidation_status.lock() = TxPoolRevalidationStatus::Scheduled(None, Some(0)) + ); + assert_eq!(status.ready, 0); + } + + #[test] + fn should_add_reverted_transactions_to_the_pool() { + let (client, longest_chain) = TestClientBuilder::new().build_with_longest_chain(); + let client = Arc::new(client); + let pool = txpool::Pool::new(Default::default(), FullChainApi::new(client.clone())); + let pool = Arc::new(pool); + let transaction = Transfer { + amount: 5, + nonce: 0, + from: AccountKeyring::Alice.into(), + to: Default::default(), + }.into_signed_tx(); + let best = longest_chain.best_chain().unwrap(); + + // store the transaction in the pool + block_on(pool.submit_one(&BlockId::hash(best.hash()), transaction.clone())).unwrap(); + + // import the block + let mut builder = client.new_block(Default::default()).unwrap(); + builder.push(transaction.clone()).unwrap(); + let block = builder.bake().unwrap(); + let block1_hash = block.header().hash(); + let id = BlockId::hash(block1_hash.clone()); + client.import(BlockOrigin::Own, block).unwrap(); + + // fire notification - this should clean up the queue + assert_eq!(pool.status().ready, 1); + block_on(FullBasicPoolMaintainer::new(pool.clone(), client.clone()).maintain(&id, &[])); + + // then + assert_eq!(pool.status().ready, 0); + assert_eq!(pool.status().future, 0); + + // import second block + let builder = client.new_block_at(&BlockId::hash(best.hash()), Default::default()).unwrap(); + let block = builder.bake().unwrap(); + let id = BlockId::hash(block.header().hash()); + client.import(BlockOrigin::Own, block).unwrap(); + + // fire notification - this should add the transaction back to the pool. + block_on(FullBasicPoolMaintainer::new(pool.clone(), client).maintain(&id, &[block1_hash])); + + // then + assert_eq!(pool.status().ready, 1); + assert_eq!(pool.status().future, 0); + } +} diff --git a/docs/CODEOWNERS b/docs/CODEOWNERS index 5ad126c3f6..29f510a556 100644 --- a/docs/CODEOWNERS +++ b/docs/CODEOWNERS @@ -28,6 +28,7 @@ # Transaction pool /client/transaction-pool/ @tomusdrw +/primitives/transaction-pool/ @tomusdrw # Offchain /client/offchain/ @tomusdrw diff --git a/docs/README.adoc b/docs/README.adoc index 76e640db9b..d8c582296c 100644 --- a/docs/README.adoc +++ b/docs/README.adoc @@ -439,7 +439,7 @@ substrate-executor, substrate-finality-grandpa, substrate-keyring, substrate-key substrate-network-libp2p, substrate-primitives, substrate-rpc, substrate-rpc-servers, substrate-serializer, substrate-service, substrate-service-test, substrate-state-db, substrate-state-machine, substrate-telemetry, substrate-test-client, -substrate-test-runtime, substrate-transaction-graph, substrate-transaction-pool, +substrate-test-runtime, substrate-transaction-graph, sp-transaction-pool, substrate-trie * Substrate Runtime [source, shell] diff --git a/primitives/sr-primitives/src/offchain/mod.rs b/primitives/sr-primitives/src/offchain/mod.rs index 51dc19bc12..07c25570ee 100644 --- a/primitives/sr-primitives/src/offchain/mod.rs +++ b/primitives/sr-primitives/src/offchain/mod.rs @@ -16,27 +16,4 @@ //! A collection of higher lever helpers for offchain calls. -use crate::{ - traits, - generic::BlockId, -}; - pub mod http; - -/// An abstraction for transaction pool. -/// -/// This trait is used by offchain calls to be able to submit transactions. -/// The main use case is for offchain workers, to feed back the results of computations, -/// but since the transaction pool access is a separate `ExternalitiesExtension` it can -/// be also used in context of other offchain calls. For one may generate and submit -/// a transaction for some misbehavior reports (say equivocation). -pub trait TransactionPool: Send + Sync { - /// Submit transaction. - /// - /// The transaction will end up in the pool and be propagated to others. - fn submit_at( - &self, - at: &BlockId, - extrinsic: Block::Extrinsic, - ) -> Result<(), ()>; -} diff --git a/primitives/transaction-pool/Cargo.toml b/primitives/transaction-pool/Cargo.toml new file mode 100644 index 0000000000..b2ea581249 --- /dev/null +++ b/primitives/transaction-pool/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "sp-transaction-pool-api" +version = "2.0.0" +authors = ["Parity Technologies "] +edition = "2018" + +[dependencies] +derive_more = "0.15.0" +futures = "0.3.1" +log = "0.4.8" +serde = { version = "1.0.101", features = ["derive"] } +codec = { package = "parity-scale-codec", version = "1.0.0" } +primitives = { package = "substrate-primitives", path = "../core" } +sr-primitives = { path = "../sr-primitives" } diff --git a/primitives/transaction-pool/runtime-api/Cargo.toml b/primitives/transaction-pool/runtime-api/Cargo.toml index e002208502..2a1014989d 100644 --- a/primitives/transaction-pool/runtime-api/Cargo.toml +++ b/primitives/transaction-pool/runtime-api/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "substrate-transaction-pool-runtime-api" +name = "sp-transaction-pool-runtime-api" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" diff --git a/primitives/transaction-pool/src/error.rs b/primitives/transaction-pool/src/error.rs new file mode 100644 index 0000000000..19270f349a --- /dev/null +++ b/primitives/transaction-pool/src/error.rs @@ -0,0 +1,82 @@ +// Copyright 2018-2019 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Substrate is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Substrate. If not, see . + +//! Transaction pool errors. + +use sr_primitives::transaction_validity::{ + TransactionPriority as Priority, InvalidTransaction, UnknownTransaction, +}; + +/// Transaction pool result. +pub type Result = std::result::Result; + +/// Transaction pool error type. +#[derive(Debug, derive_more::Display, derive_more::From)] +pub enum Error { + /// Transaction is not verifiable yet, but might be in the future. + #[display(fmt="Unknown transaction validity: {:?}", _0)] + UnknownTransaction(UnknownTransaction), + /// Transaction is invalid. + #[display(fmt="Invalid transaction validity: {:?}", _0)] + InvalidTransaction(InvalidTransaction), + /// The transaction validity returned no "provides" tag. + /// + /// Such transactions are not accepted to the pool, since we use those tags + /// to define identity of transactions (occupance of the same "slot"). + #[display(fmt="The transaction does not provide any tags, so the pool can't identify it.")] + NoTagsProvided, + /// The transaction is temporarily banned. + #[display(fmt="Temporarily Banned")] + TemporarilyBanned, + /// The transaction is already in the pool. + #[display(fmt="[{:?}] Already imported", _0)] + AlreadyImported(Box), + /// The transaction cannot be imported cause it's a replacement and has too low priority. + #[display(fmt="Too low priority ({} > {})", old, new)] + TooLowPriority { + /// Transaction already in the pool. + old: Priority, + /// Transaction entering the pool. + new: Priority + }, + /// Deps cycle etected and we couldn't import transaction. + #[display(fmt="Cycle Detected")] + CycleDetected, + /// Transaction was dropped immediately after it got inserted. + #[display(fmt="Transaction couldn't enter the pool because of the limit.")] + ImmediatelyDropped, + /// Invalid block id. + InvalidBlockId(String), + /// The pool is not accepting future transactions. + #[display(fmt="The pool is not accepting future transactions")] + RejectedFutureTransaction, +} + +impl std::error::Error for Error {} + +/// Transaction pool error conversion. +pub trait IntoPoolError: ::std::error::Error + Send + Sized { + /// Try to extract original `Error` + /// + /// This implementation is optional and used only to + /// provide more descriptive error messages for end users + /// of RPC API. + fn into_pool_error(self) -> ::std::result::Result { Err(self) } +} + +impl IntoPoolError for Error { + fn into_pool_error(self) -> ::std::result::Result { Ok(self) } +} diff --git a/primitives/transaction-pool/src/lib.rs b/primitives/transaction-pool/src/lib.rs new file mode 100644 index 0000000000..30671d4b1a --- /dev/null +++ b/primitives/transaction-pool/src/lib.rs @@ -0,0 +1,328 @@ +// Copyright 2019 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Substrate is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Substrate. If not, see . + +//! Transaction pool types. + +#![warn(missing_docs)] + +pub mod error; + +pub use error::IntoPoolError; +pub use sr_primitives::transaction_validity::{ + TransactionLongevity, TransactionPriority, TransactionTag, +}; + +use std::{ + collections::HashMap, + hash::Hash, + sync::Arc, +}; +use futures::{ + Future, Stream, + channel::mpsc, +}; +use serde::{Deserialize, Serialize}; +use sr_primitives::{ + generic::BlockId, + traits::{Block as BlockT, Member}, +}; + +/// Transaction pool status. +#[derive(Debug)] +pub struct PoolStatus { + /// Number of transactions in the ready queue. + pub ready: usize, + /// Sum of bytes of ready transaction encodings. + pub ready_bytes: usize, + /// Number of transactions in the future queue. + pub future: usize, + /// Sum of bytes of ready transaction encodings. + pub future_bytes: usize, +} + +impl PoolStatus { + /// Returns true if the are no transactions in the pool. + pub fn is_empty(&self) -> bool { + self.ready == 0 && self.future == 0 + } +} + +/// Possible transaction status events. +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub enum TransactionStatus { + /// Transaction is part of the future queue. + Future, + /// Transaction is part of the ready queue. + Ready, + /// Transaction has been finalized in block with given hash. + Finalized(BlockHash), + /// Some state change (perhaps another transaction was included) rendered this transaction invalid. + Usurped(Hash), + /// The transaction has been broadcast to the given peers. + Broadcast(Vec), + /// Transaction has been dropped from the pool because of the limit. + Dropped, + /// Transaction was detected as invalid. + Invalid, +} + +/// The stream of transaction events. +pub type TransactionStatusStream = dyn Stream> + Send + Unpin; + +/// The import notification event stream. +pub type ImportNotificationStream = mpsc::UnboundedReceiver<()>; + +/// Transaction hash type for a pool. +pub type TxHash

=

::Hash; +/// Block hash type for a pool. +pub type BlockHash

= <

::Block as BlockT>::Hash; +/// Transaction type for a pool. +pub type TransactionFor

= <

::Block as BlockT>::Extrinsic; +/// Type of transactions event stream for a pool. +pub type TransactionStatusStreamFor

= TransactionStatusStream, BlockHash

>; + +/// In-pool transaction interface. +/// +/// The pool is container of transactions that are implementing this trait. +/// See `sr_primitives::ValidTransaction` for details about every field. +pub trait InPoolTransaction { + /// Transaction type. + type Transaction; + /// Transaction hash type. + type Hash; + + /// Get the reference to the transaction data. + fn data(&self) -> &Self::Transaction; + /// Get hash of the transaction. + fn hash(&self) -> &Self::Hash; + /// Get priority of the transaction. + fn priority(&self) -> &TransactionPriority; + /// Get longevity of the transaction. + fn longevity(&self) ->&TransactionLongevity; + /// Get transaction dependencies. + fn requires(&self) -> &[TransactionTag]; + /// Get tags that transaction provides. + fn provides(&self) -> &[TransactionTag]; + /// Return a flag indicating if the transaction should be propagated to other peers. + fn is_propagateable(&self) -> bool; +} + +/// Transaction pool interface. +pub trait TransactionPool: Send + Sync { + /// Block type. + type Block: BlockT; + /// Transaction hash type. + type Hash: Hash + Eq + Member + Serialize; + /// In-pool transaction type. + type InPoolTransaction: InPoolTransaction< + Transaction = TransactionFor, + Hash = TxHash + >; + /// Error type. + type Error: From + IntoPoolError; + + /// Returns a future that imports a bunch of unverified transactions to the pool. + fn submit_at( + &self, + at: &BlockId, + xts: impl IntoIterator> + 'static, + ) -> Box, Self::Error>>, + Self::Error + >> + Send + Unpin>; + + /// Returns a future that imports one unverified transaction to the pool. + fn submit_one( + &self, + at: &BlockId, + xt: TransactionFor, + ) -> Box, + Self::Error + >> + Send + Unpin>; + + /// Returns a future that import a single transaction and starts to watch their progress in the pool. + fn submit_and_watch( + &self, + at: &BlockId, + xt: TransactionFor, + ) -> Box>, Self::Error>> + Send + Unpin>; + + /// Remove transactions identified by given hashes (and dependent transactions) from the pool. + fn remove_invalid(&self, hashes: &[TxHash]) -> Vec>; + + /// Returns pool status. + fn status(&self) -> PoolStatus; + + /// Get an iterator for ready transactions ordered by priority + fn ready(&self) -> Box>>; + + /// Return an event stream of transactions imported to the pool. + fn import_notification_stream(&self) -> ImportNotificationStream; + + /// Returns transaction hash + fn hash_of(&self, xt: &TransactionFor) -> TxHash; + + /// Notify the pool about transactions broadcast. + fn on_broadcasted(&self, propagations: HashMap, Vec>); +} + +/// An abstraction for transaction pool. +/// +/// This trait is used by offchain calls to be able to submit transactions. +/// The main use case is for offchain workers, to feed back the results of computations, +/// but since the transaction pool access is a separate `ExternalitiesExtension` it can +/// be also used in context of other offchain calls. For one may generate and submit +/// a transaction for some misbehavior reports (say equivocation). +pub trait OffchainSubmitTransaction: Send + Sync { + /// Submit transaction. + /// + /// The transaction will end up in the pool and be propagated to others. + fn submit_at( + &self, + at: &BlockId, + extrinsic: Block::Extrinsic, + ) -> Result<(), ()>; +} + +impl OffchainSubmitTransaction for TPool { + fn submit_at( + &self, + at: &BlockId, + extrinsic: ::Extrinsic, + ) -> Result<(), ()> { + log::debug!( + target: "txpool", + "(offchain call) Submitting a transaction to the pool: {:?}", + extrinsic + ); + + let result = futures::executor::block_on(self.submit_one(&at, extrinsic)); + + result.map(|_| ()) + .map_err(|e| log::warn!( + target: "txpool", + "(offchain call) Error submitting a transaction to the pool: {:?}", + e + )) + } +} + +/// Transaction pool maintainer interface. +pub trait TransactionPoolMaintainer: Send + Sync { + /// Block type. + type Block: BlockT; + /// Transaction Hash type. + type Hash: Hash + Eq + Member + Serialize; + + /// Returns a future that performs maintenance procedures on the pool when + /// with given hash is imported. + fn maintain( + &self, + id: &BlockId, + retracted: &[Self::Hash], + ) -> Box + Send + Unpin>; +} + +/// Maintainable pool implementation. +pub struct MaintainableTransactionPool { + pool: Pool, + maintainer: Maintainer, +} + +impl MaintainableTransactionPool { + /// Create new maintainable pool using underlying pool and maintainer. + pub fn new(pool: Pool, maintainer: Maintainer) -> Self { + MaintainableTransactionPool { pool, maintainer } + } +} + +impl TransactionPool for MaintainableTransactionPool + where + Pool: TransactionPool, + Maintainer: Send + Sync, +{ + type Block = Pool::Block; + type Hash = Pool::Hash; + type InPoolTransaction = Pool::InPoolTransaction; + type Error = Pool::Error; + + fn submit_at( + &self, + at: &BlockId, + xts: impl IntoIterator> + 'static, + ) -> Box, Self::Error>>, Self::Error>> + Send + Unpin> { + self.pool.submit_at(at, xts) + } + + fn submit_one( + &self, + at: &BlockId, + xt: TransactionFor, + ) -> Box, Self::Error>> + Send + Unpin> { + self.pool.submit_one(at, xt) + } + + fn submit_and_watch( + &self, + at: &BlockId, + xt: TransactionFor, + ) -> Box>, Self::Error>> + Send + Unpin> { + self.pool.submit_and_watch(at, xt) + } + + fn remove_invalid(&self, hashes: &[TxHash]) -> Vec> { + self.pool.remove_invalid(hashes) + } + + fn status(&self) -> PoolStatus { + self.pool.status() + } + + fn ready(&self) -> Box>> { + self.pool.ready() + } + + fn import_notification_stream(&self) -> ImportNotificationStream { + self.pool.import_notification_stream() + } + + fn hash_of(&self, xt: &TransactionFor) -> TxHash { + self.pool.hash_of(xt) + } + + fn on_broadcasted(&self, propagations: HashMap, Vec>) { + self.pool.on_broadcasted(propagations) + } +} + +impl TransactionPoolMaintainer for MaintainableTransactionPool + where + Pool: Send + Sync, + Maintainer: TransactionPoolMaintainer +{ + type Block = Maintainer::Block; + type Hash = Maintainer::Hash; + + fn maintain( + &self, + id: &BlockId, + retracted: &[Self::Hash], + ) -> Box + Send + Unpin> { + self.maintainer.maintain(id, retracted) + } +} diff --git a/test/utils/primitives/src/lib.rs b/test/utils/primitives/src/lib.rs index d30b9eabf6..eebdbb165f 100644 --- a/test/utils/primitives/src/lib.rs +++ b/test/utils/primitives/src/lib.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Substrate. If not, see . -//! The Substrate test primitives to share +//! The Substrate test primitives to share #![cfg_attr(not(feature = "std"), no_std)] diff --git a/test/utils/runtime/Cargo.toml b/test/utils/runtime/Cargo.toml index f89524d284..f51bceb095 100644 --- a/test/utils/runtime/Cargo.toml +++ b/test/utils/runtime/Cargo.toml @@ -34,7 +34,7 @@ frame-system-rpc-runtime-api = { path = "../../../frame/system/rpc/runtime-api", pallet-timestamp = { path = "../../../frame/timestamp", default-features = false } substrate-client = { path = "../../../client", optional = true } substrate-trie = { path = "../../../primitives/trie", default-features = false } -transaction-pool-api = { package = "substrate-transaction-pool-runtime-api", path = "../../../primitives/transaction-pool/runtime-api", default-features = false } +txpool-runtime-api = { package = "sp-transaction-pool-runtime-api", path = "../../../primitives/transaction-pool/runtime-api", default-features = false } trie-db = { version = "0.16.0", default-features = false } [dev-dependencies] @@ -78,6 +78,6 @@ std = [ "pallet-timestamp/std", "substrate-client", "substrate-trie/std", - "transaction-pool-api/std", + "txpool-runtime-api/std", "trie-db/std", ] diff --git a/test/utils/runtime/client/Cargo.toml b/test/utils/runtime/client/Cargo.toml index 83e5edb246..22758584c7 100644 --- a/test/utils/runtime/client/Cargo.toml +++ b/test/utils/runtime/client/Cargo.toml @@ -14,3 +14,4 @@ sp-blockchain = { path = "../../../../primitives/blockchain" } codec = { package = "parity-scale-codec", version = "1.0.0" } client-api = { package = "substrate-client-api", path = "../../../../client/api" } client = { package = "substrate-client", path = "../../../../client/" } +futures = "0.3.1" diff --git a/test/utils/runtime/client/src/lib.rs b/test/utils/runtime/client/src/lib.rs index d56bcfa770..57be949bca 100644 --- a/test/utils/runtime/client/src/lib.rs +++ b/test/utils/runtime/client/src/lib.rs @@ -30,7 +30,15 @@ pub use runtime; use primitives::sr25519; use runtime::genesismap::{GenesisConfig, additional_storage_with_genesis}; -use sr_primitives::traits::{Block as BlockT, Header as HeaderT, Hash as HashT}; +use sr_primitives::traits::{Block as BlockT, Header as HeaderT, Hash as HashT, NumberFor}; +use client::{ + light::fetcher::{ + Fetcher, + RemoteHeaderRequest, RemoteReadRequest, RemoteReadChildRequest, + RemoteCallRequest, RemoteChangesRequest, RemoteBodyRequest, + }, +}; + /// A prelude to import in tests. pub mod prelude { @@ -247,6 +255,81 @@ impl TestClientBuilderExt for TestClientBuilder< } } +/// Type of optional fetch callback. +type MaybeFetcherCallback = Option Result + Send + Sync>>; + +/// Type of fetcher future result. +type FetcherFutureResult = futures::future::Ready>; + +/// Implementation of light client fetcher used in tests. +#[derive(Default)] +pub struct LightFetcher { + call: MaybeFetcherCallback, Vec>, + body: MaybeFetcherCallback, Vec>, +} + +impl LightFetcher { + /// Sets remote call callback. + pub fn with_remote_call( + self, + call: MaybeFetcherCallback, Vec>, + ) -> Self { + LightFetcher { + call, + body: self.body, + } + } + + /// Sets remote body callback. + pub fn with_remote_body( + self, + body: MaybeFetcherCallback, Vec>, + ) -> Self { + LightFetcher { + call: self.call, + body, + } + } +} + +impl Fetcher for LightFetcher { + type RemoteHeaderResult = FetcherFutureResult; + type RemoteReadResult = FetcherFutureResult, Option>>>; + type RemoteCallResult = FetcherFutureResult>; + type RemoteChangesResult = FetcherFutureResult, u32)>>; + type RemoteBodyResult = FetcherFutureResult>; + + fn remote_header(&self, _: RemoteHeaderRequest) -> Self::RemoteHeaderResult { + unimplemented!() + } + + fn remote_read(&self, _: RemoteReadRequest) -> Self::RemoteReadResult { + unimplemented!() + } + + fn remote_read_child(&self, _: RemoteReadChildRequest) -> Self::RemoteReadResult { + unimplemented!() + } + + fn remote_call(&self, req: RemoteCallRequest) -> Self::RemoteCallResult { + match self.call { + Some(ref call) => futures::future::ready(call(req)), + None => unimplemented!(), + } + } + + fn remote_changes(&self, _: RemoteChangesRequest) -> Self::RemoteChangesResult { + unimplemented!() + } + + fn remote_body(&self, req: RemoteBodyRequest) -> Self::RemoteBodyResult { + match self.body { + Some(ref body) => futures::future::ready(body(req)), + None => unimplemented!(), + } + } +} + /// Creates new client instance used for tests. pub fn new() -> Client { TestClientBuilder::new().build() @@ -275,3 +358,8 @@ pub fn new_light() -> ( backend, ) } + +/// Creates new light client fetcher used for tests. +pub fn new_light_fetcher() -> LightFetcher { + LightFetcher::default() +} diff --git a/test/utils/runtime/src/lib.rs b/test/utils/runtime/src/lib.rs index 58caae2098..7dd98c56c0 100644 --- a/test/utils/runtime/src/lib.rs +++ b/test/utils/runtime/src/lib.rs @@ -477,7 +477,7 @@ cfg_if! { } } - impl transaction_pool_api::TaggedTransactionQueue for Runtime { + impl txpool_runtime_api::TaggedTransactionQueue for Runtime { fn validate_transaction(utx: ::Extrinsic) -> TransactionValidity { if let Extrinsic::IncludeData(data) = utx { return Ok(ValidTransaction { @@ -662,7 +662,7 @@ cfg_if! { } } - impl transaction_pool_api::TaggedTransactionQueue for Runtime { + impl txpool_runtime_api::TaggedTransactionQueue for Runtime { fn validate_transaction(utx: ::Extrinsic) -> TransactionValidity { if let Extrinsic::IncludeData(data) = utx { return Ok(ValidTransaction{ diff --git a/utils/frame/rpc/system/Cargo.toml b/utils/frame/rpc/system/Cargo.toml index a4b6d21693..9b5b32919c 100644 --- a/utils/frame/rpc/system/Cargo.toml +++ b/utils/frame/rpc/system/Cargo.toml @@ -5,7 +5,9 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] +client = { package = "substrate-client", path = "../../../../client/" } codec = { package = "parity-scale-codec", version = "1.0.0" } +futures = "0.3.1" jsonrpc-core = "14.0.3" jsonrpc-core-client = "14.0.3" jsonrpc-derive = "14.0.3" @@ -15,10 +17,9 @@ sr-primitives = { path = "../../../../primitives/sr-primitives" } frame-system-rpc-runtime-api = { path = "../../../../frame/system/rpc/runtime-api" } substrate-primitives = { path = "../../../../primitives/core" } sp-blockchain = { path = "../../../../primitives/blockchain" } -sc-transaction-graph = { path = "../../../../client/transaction-pool/graph" } +txpool-api = { package = "sp-transaction-pool-api", path = "../../../../primitives/transaction-pool" } [dev-dependencies] test-client = { package = "substrate-test-runtime-client", path = "../../../../test/utils/runtime/client" } -sc-transaction-pool = { path = "../../../../client/transaction-pool" } env_logger = "0.7.0" -futures = "0.3.1" +txpool = { package = "sc-transaction-pool", path = "../../../../client/transaction-pool" } diff --git a/utils/frame/rpc/system/src/lib.rs b/utils/frame/rpc/system/src/lib.rs index 63b91c3cd2..ebda962031 100644 --- a/utils/frame/rpc/system/src/lib.rs +++ b/utils/frame/rpc/system/src/lib.rs @@ -18,20 +18,34 @@ use std::sync::Arc; -use codec::{self, Codec, Encode}; -use sp_blockchain::HeaderBackend; -use jsonrpc_core::{Result, Error, ErrorCode}; +use codec::{self, Codec, Decode, Encode}; +use client::{ + light::blockchain::{future_header, RemoteBlockchain}, + light::fetcher::{Fetcher, RemoteCallRequest}, +}; +use jsonrpc_core::{ + Error, ErrorCode, + futures::future::{result, Future}, +}; use jsonrpc_derive::rpc; +use futures::future::{ready, TryFutureExt}; +use sp_blockchain::{ + HeaderBackend, + Error as ClientError +}; use sr_primitives::{ generic::BlockId, traits, }; use substrate_primitives::hexdisplay::HexDisplay; -use sc_transaction_graph::{self, ChainApi, Pool}; +use txpool_api::{TransactionPool, InPoolTransaction}; pub use frame_system_rpc_runtime_api::AccountNonceApi; pub use self::gen_client::Client as SystemClient; +/// Future that resolves to account nonce. +pub type FutureResult = Box + Send>; + /// System RPC methods. #[rpc] pub trait SystemApi { @@ -41,22 +55,22 @@ pub trait SystemApi { /// currently in the pool and if no transactions are found in the pool /// it fallbacks to query the index from the runtime (aka. state nonce). #[rpc(name = "system_accountNextIndex", alias("account_nextIndex"))] - fn nonce(&self, account: AccountId) -> Result; + fn nonce(&self, account: AccountId) -> FutureResult; } const RUNTIME_ERROR: i64 = 1; -/// An implementation of System-specific RPC methods. -pub struct System { +/// An implementation of System-specific RPC methods on full client. +pub struct FullSystem { client: Arc, - pool: Arc>, + pool: Arc

, _marker: std::marker::PhantomData, } -impl System { - /// Create new `System` given client and transaction pool. - pub fn new(client: Arc, pool: Arc>) -> Self { - System { +impl FullSystem { + /// Create new `FullSystem` given client and transaction pool. + pub fn new(client: Arc, pool: Arc

) -> Self { + FullSystem { client, pool, _marker: Default::default(), @@ -64,74 +78,164 @@ impl System { } } -impl SystemApi for System +impl SystemApi for FullSystem where C: traits::ProvideRuntimeApi, C: HeaderBackend, C: Send + Sync + 'static, C::Api: AccountNonceApi, - P: ChainApi + Sync + Send + 'static, + P: TransactionPool + 'static, Block: traits::Block, AccountId: Clone + std::fmt::Display + Codec, - Index: Clone + std::fmt::Display + Codec + traits::SimpleArithmetic, + Index: Clone + std::fmt::Display + Codec + Send + traits::SimpleArithmetic + 'static, { - fn nonce(&self, account: AccountId) -> Result { - let api = self.client.runtime_api(); - let best = self.client.info().best_hash; - let at = BlockId::hash(best); + fn nonce(&self, account: AccountId) -> FutureResult { + let get_nonce = || { + let api = self.client.runtime_api(); + let best = self.client.info().best_hash; + let at = BlockId::hash(best); + + let nonce = api.account_nonce(&at, account.clone()).map_err(|e| Error { + code: ErrorCode::ServerError(RUNTIME_ERROR), + message: "Unable to query nonce.".into(), + data: Some(format!("{:?}", e).into()), + })?; + + Ok(adjust_nonce(&*self.pool, account, nonce)) + }; + + Box::new(result(get_nonce())) + } +} + +/// An implementation of System-specific RPC methods on light client. +pub struct LightSystem { + client: Arc, + remote_blockchain: Arc>, + fetcher: Arc, + pool: Arc

, +} + +impl LightSystem { + /// Create new `LightSystem`. + pub fn new( + client: Arc, + remote_blockchain: Arc>, + fetcher: Arc, + pool: Arc

, + ) -> Self { + LightSystem { + client, + remote_blockchain, + fetcher, + pool, + } + } +} - let nonce = api.account_nonce(&at, account.clone()).map_err(|e| Error { +impl SystemApi for LightSystem +where + P: TransactionPool + 'static, + C: HeaderBackend, + C: Send + Sync + 'static, + F: Fetcher + 'static, + Block: traits::Block, + AccountId: Clone + std::fmt::Display + Codec + Send + 'static, + Index: Clone + std::fmt::Display + Codec + Send + traits::SimpleArithmetic + 'static, +{ + fn nonce(&self, account: AccountId) -> FutureResult { + let best_hash = self.client.info().best_hash; + let best_id = BlockId::hash(best_hash); + let future_best_header = future_header(&*self.remote_blockchain, &*self.fetcher, best_id); + let fetcher = self.fetcher.clone(); + let call_data = account.encode(); + let future_best_header = future_best_header + .and_then(move |maybe_best_header| ready( + match maybe_best_header { + Some(best_header) => Ok(best_header), + None => Err(ClientError::UnknownBlock(format!("{}", best_hash))), + } + )); + let future_nonce = future_best_header.and_then(move |best_header| + fetcher.remote_call(RemoteCallRequest { + block: best_hash, + header: best_header, + method: "AccountNonceApi_account_nonce".into(), + call_data, + retry_count: None, + }) + ).compat(); + let future_nonce = future_nonce.and_then(|nonce| Decode::decode(&mut &nonce[..]) + .map_err(|e| ClientError::CallResultDecode("Cannot decode account nonce", e))); + let future_nonce = future_nonce.map_err(|e| Error { code: ErrorCode::ServerError(RUNTIME_ERROR), message: "Unable to query nonce.".into(), data: Some(format!("{:?}", e).into()), - })?; - - log::debug!(target: "rpc", "State nonce for {}: {}", account, nonce); - // Now we need to query the transaction pool - // and find transactions originating from the same sender. - // - // Since extrinsics are opaque to us, we look for them using - // `provides` tag. And increment the nonce if we find a transaction - // that matches the current one. - let mut current_nonce = nonce.clone(); - let mut current_tag = (account.clone(), nonce.clone()).encode(); - for tx in self.pool.ready() { - log::debug!( - target: "rpc", - "Current nonce to {}, checking {} vs {:?}", - current_nonce, - HexDisplay::from(¤t_tag), - tx.provides.iter().map(|x| format!("{}", HexDisplay::from(x))).collect::>(), - ); - // since transactions in `ready()` need to be ordered by nonce - // it's fine to continue with current iterator. - if tx.provides.get(0) == Some(¤t_tag) { - current_nonce += traits::One::one(); - current_tag = (account.clone(), current_nonce.clone()).encode(); - } - } + }); + + let pool = self.pool.clone(); + let future_nonce = future_nonce.map(move |nonce| adjust_nonce(&*pool, account, nonce)); + + Box::new(future_nonce) + } +} - Ok(current_nonce) +/// Adjust account nonce from state, so that tx with the nonce will be +/// placed after all ready txpool transactions. +fn adjust_nonce( + pool: &P, + account: AccountId, + nonce: Index, +) -> Index where + P: TransactionPool, + AccountId: Clone + std::fmt::Display + Encode, + Index: Clone + std::fmt::Display + Encode + traits::SimpleArithmetic + 'static, +{ + log::debug!(target: "rpc", "State nonce for {}: {}", account, nonce); + // Now we need to query the transaction pool + // and find transactions originating from the same sender. + // + // Since extrinsics are opaque to us, we look for them using + // `provides` tag. And increment the nonce if we find a transaction + // that matches the current one. + let mut current_nonce = nonce.clone(); + let mut current_tag = (account.clone(), nonce.clone()).encode(); + for tx in pool.ready() { + log::debug!( + target: "rpc", + "Current nonce to {}, checking {} vs {:?}", + current_nonce, + HexDisplay::from(¤t_tag), + tx.provides().iter().map(|x| format!("{}", HexDisplay::from(x))).collect::>(), + ); + // since transactions in `ready()` need to be ordered by nonce + // it's fine to continue with current iterator. + if tx.provides().get(0) == Some(¤t_tag) { + current_nonce += traits::One::one(); + current_tag = (account.clone(), current_nonce.clone()).encode(); + } } + + current_nonce } #[cfg(test)] mod tests { use super::*; - use sc_transaction_pool; use futures::executor::block_on; use test_client::{ runtime::Transfer, AccountKeyring, }; + use txpool::{BasicPool, FullChainApi}; #[test] fn should_return_next_nonce_for_some_account() { // given let _ = env_logger::try_init(); let client = Arc::new(test_client::new()); - let pool = Arc::new(Pool::new(Default::default(), sc_transaction_pool::FullChainApi::new(client.clone()))); + let pool = Arc::new(BasicPool::new(Default::default(), FullChainApi::new(client.clone()))); let new_transaction = |nonce: u64| { let t = Transfer { @@ -148,12 +252,12 @@ mod tests { let ext1 = new_transaction(1); block_on(pool.submit_one(&BlockId::number(0), ext1)).unwrap(); - let accounts = System::new(client, pool); + let accounts = FullSystem::new(client, pool); // when let nonce = accounts.nonce(AccountKeyring::Alice.into()); // then - assert_eq!(nonce.unwrap(), 2); + assert_eq!(nonce.wait().unwrap(), 2); } } -- GitLab From 1d746bfadc1b5bb3d03b208f465f13be37755c59 Mon Sep 17 00:00:00 2001 From: Qinxuan Chen Date: Thu, 28 Nov 2019 16:55:30 +0800 Subject: [PATCH 037/172] Prune some duplicate dependencies (#4219) * Prune some duplicate dependencies * Remove ed25519-dalek 0.9.1 * Remove hex 0.3.2 * Remove parity-wasm 0.40.3 * Remove pwasm-utils 0.11.0 * Remove wasmi-validation 0.2.0 * Remove quickcheck 0.8.5 * Remove tempdir (Replace tempdir with tempfile) Signed-off-by: koushiro * Remove useless tempdir_with_prefix Signed-off-by: koushiro * Remove derive_more 0.15 Signed-off-by: koushiro --- Cargo.lock | 102 ++++------------------ bin/subkey/Cargo.toml | 2 +- client/cli/Cargo.toml | 2 +- client/cli/src/lib.rs | 3 +- client/db/Cargo.toml | 2 +- client/executor/Cargo.toml | 2 +- client/keystore/Cargo.toml | 4 +- client/keystore/src/lib.rs | 12 +-- client/network/Cargo.toml | 2 +- client/network/src/config.rs | 8 +- client/service/test/Cargo.toml | 2 +- client/service/test/src/lib.rs | 14 +-- frame/contracts/Cargo.toml | 7 +- frame/support/procedural/tools/Cargo.toml | 2 +- primitives/core/Cargo.toml | 2 +- primitives/core/src/ed25519.rs | 6 +- primitives/transaction-pool/Cargo.toml | 2 +- 17 files changed, 55 insertions(+), 119 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 506c4e966b..68e86cb216 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -915,19 +915,6 @@ name = "data-encoding" version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "derive_more" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "derive_more" version = "0.99.2" @@ -985,17 +972,6 @@ name = "doc-comment" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "ed25519-dalek" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "curve25519-dalek 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "ed25519-dalek" version = "1.0.0-pre.2" @@ -1805,11 +1781,6 @@ dependencies = [ "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "hex" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "hex" version = "0.4.0" @@ -3558,14 +3529,13 @@ dependencies = [ "assert_matches 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "frame-support 2.0.0", "frame-system 2.0.0", - "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "pallet-balances 2.0.0", "pallet-randomness-collective-flip 2.0.0", "pallet-timestamp 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-wasm 0.40.3 (registry+https://github.com/rust-lang/crates.io-index)", - "pwasm-utils 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-wasm 0.41.0 (registry+https://github.com/rust-lang/crates.io-index)", + "pwasm-utils 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", @@ -3573,7 +3543,7 @@ dependencies = [ "sr-std 2.0.0", "substrate-primitives 2.0.0", "wabt 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", - "wasmi-validation 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmi-validation 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4075,11 +4045,6 @@ dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "parity-wasm" -version = "0.40.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "parity-wasm" version = "0.41.0" @@ -4382,12 +4347,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "pwasm-utils" -version = "0.11.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-wasm 0.40.3 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-wasm 0.41.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4395,17 +4360,6 @@ name = "quick-error" version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "quickcheck" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "quickcheck" version = "0.9.0" @@ -5248,7 +5202,7 @@ dependencies = [ name = "sp-transaction-pool-api" version = "2.0.0" dependencies = [ - "derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5489,7 +5443,7 @@ version = "2.0.0" dependencies = [ "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", "frame-system 2.0.0", - "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "hex 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "node-primitives 2.0.0", "node-runtime 2.0.0", @@ -5672,7 +5626,7 @@ dependencies = [ "substrate-state-machine 2.0.0", "substrate-telemetry 2.0.0", "substrate-tracing 2.0.0", - "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5765,7 +5719,7 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "quickcheck 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)", + "quickcheck 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sp-blockchain 2.0.0", "sr-primitives 2.0.0", "substrate-client 2.0.0", @@ -6000,7 +5954,7 @@ dependencies = [ "libsecp256k1 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-wasm 0.40.3 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-wasm 0.41.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-version 2.0.0", @@ -6146,14 +6100,14 @@ name = "substrate-keystore" version = "2.0.0" dependencies = [ "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", - "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "hex 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-application-crypto 2.0.0", "substrate-primitives 2.0.0", "subtle 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -6200,7 +6154,7 @@ dependencies = [ "substrate-test-client 2.0.0", "substrate-test-runtime 2.0.0", "substrate-test-runtime-client 2.0.0", - "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -6287,7 +6241,7 @@ dependencies = [ "blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "criterion 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "ed25519-dalek 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", + "ed25519-dalek 1.0.0-pre.2 (registry+https://github.com/rust-lang/crates.io-index)", "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "hash256-std-hasher 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "hex 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -6525,7 +6479,7 @@ dependencies = [ "substrate-network 2.0.0", "substrate-primitives 2.0.0", "substrate-service 2.0.0", - "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -6802,15 +6756,6 @@ name = "target_info" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "tempdir" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "tempfile" version = "3.1.0" @@ -7656,14 +7601,6 @@ dependencies = [ "wasmi-validation 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "wasmi-validation" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "parity-wasm 0.40.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "wasmi-validation" version = "0.3.0" @@ -8084,7 +8021,6 @@ dependencies = [ "checksum cuckoofilter 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8dd43f7cfaffe0a386636a10baea2ee05cc50df3b77bea4a456c9572a939bf1f" "checksum curve25519-dalek 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8b7dcd30ba50cdf88b55b033456138b7c0ac4afdc436d82e1b79f370f24cc66d" "checksum data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f4f47ca1860a761136924ddd2422ba77b2ea54fe8cc75b9040804a0d9d32ad97" -"checksum derive_more 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a141330240c921ec6d074a3e188a7c7ef95668bb95e7d44fa0e5778ec2a7afe" "checksum derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2159be042979966de68315bce7034bb000c775f22e3e834e1c52ff78f041cae8" "checksum difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" "checksum digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" @@ -8092,7 +8028,6 @@ dependencies = [ "checksum dirs-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "afa0b23de8fd801745c471deffa6e12d248f962c9fd4b4c33787b055599bde7b" "checksum dns-parser 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c4d33be9473d06f75f58220f71f7a9317aca647dc061dbd3c361b0bef505fbea" "checksum doc-comment 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "923dea538cea0aa3025e8685b20d6ee21ef99c4f77e954a30febbaac5ec73a97" -"checksum ed25519-dalek 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d07e8b8a8386c3b89a7a4b329fdfa4cb545de2545e9e2ebbc3dd3929253e426" "checksum ed25519-dalek 1.0.0-pre.2 (registry+https://github.com/rust-lang/crates.io-index)" = "845aaacc16f01178f33349e7c992ecd0cee095aa5e577f0f4dee35971bd36455" "checksum either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" "checksum elastic-array 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "073be79b6538296faf81c631872676600616073817dd9a440c477ad09b408983" @@ -8164,7 +8099,6 @@ dependencies = [ "checksum heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1679e6ea370dee694f91f1dc469bf94cf8f52051d147aec3e1f9497c6fc22461" "checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" "checksum hermit-abi 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "307c3c9f937f38e3534b1d6447ecf090cafcc9744e4a6360e8b037b2cf5af120" -"checksum hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" "checksum hex 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "023b39be39e3a2da62a94feb433e91e8bcd37676fbc8bea371daf52b7a769a3e" "checksum hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "961de220ec9a91af2e1e5bd80d02109155695e516771762381ef8581317066e0" "checksum hex-literal-impl 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9d4c5c844e2fee0bf673d54c2c177f1713b3d2af2ff6e666b49cb7572e6cf42d" @@ -8294,7 +8228,6 @@ dependencies = [ "checksum parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aa9777aa91b8ad9dd5aaa04a9b6bcb02c7f1deb952fca5a66034d5e63afc5c6f" "checksum parity-util-mem 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "570093f39f786beea92dcc09e45d8aae7841516ac19a50431953ac82a0e8f85c" "checksum parity-wasm 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "16ad52817c4d343339b3bc2e26861bd21478eda0b7509acf83505727000512ac" -"checksum parity-wasm 0.40.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1e39faaa292a687ea15120b1ac31899b13586446521df6c149e46f1584671e0f" "checksum parity-wasm 0.41.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc878dac00da22f8f61e7af3157988424567ab01d9920b962ef7dcbd7cd865" "checksum parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ab41b4aed082705d1056416ae4468b6ea99d52599ecf3169b00088d43113e337" "checksum parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fa7767817701cce701d5585b9c4db3cdd02086398322c1d7e8bf5094a96a2ce7" @@ -8330,9 +8263,8 @@ dependencies = [ "checksum prost-derive 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5e7dc378b94ac374644181a2247cebf59a6ec1c88b49ac77f3a94b86b79d0e11" "checksum prost-types 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1de482a366941c8d56d19b650fac09ca08508f2a696119ee7513ad590c8bac6f" "checksum protobuf 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "40361836defdd5871ff7e84096c6f6444af7fc157f8ef1789f54f147687caa20" -"checksum pwasm-utils 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d473123ba135028544926f7aa6f34058d8bc6f120c4fcd3777f84af724280b3" +"checksum pwasm-utils 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4f7a12f176deee919f4ba55326ee17491c8b707d0987aed822682c821b660192" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" -"checksum quickcheck 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)" = "9c35d9c36a562f37eca96e79f66d5fd56eefbc22560dacc4a864cabd2d277456" "checksum quickcheck 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d5ca504a2fdaa08d3517f442fbbba91ac24d1ec4c51ea68688a038765e3b2662" "checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" "checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" @@ -8436,7 +8368,6 @@ dependencies = [ "checksum take_mut 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60" "checksum target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6f4c118a7a38378f305a9e111fcb2f7f838c0be324bfb31a77ea04f7f6e684b4" "checksum target_info 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c63f48baada5c52e65a29eef93ab4f8982681b67f9e8d29c7b05abcfec2b9ffe" -"checksum tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8" "checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" "checksum termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "96d6098003bde162e4277c70665bd87c326f5a0c3f3fbfb285787fa482d54e6e" "checksum test-case 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a605baa797821796a751f4a959e1206079b24a4b7e1ed302b7d785d81a9276c9" @@ -8523,7 +8454,6 @@ dependencies = [ "checksum wasm-gc-api 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d0c32691b6c7e6c14e7f8fd55361a9088b507aa49620fcd06c09b3a1082186b9" "checksum wasm-timer 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "aa3e01d234bb71760e685cfafa5e2c96f8ad877c161a721646356651069e26ac" "checksum wasmi 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bf617d864d25af3587aa745529f7aaa541066c876d57e050c0d0c85c61c92aff" -"checksum wasmi-validation 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6bc0356e3df56e639fc7f7d8a99741915531e27ed735d911ed83d7e1339c8188" "checksum wasmi-validation 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea78c597064ba73596099281e2f4cfc019075122a65cdda3205af94f0b264d93" "checksum wasmparser 0.39.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e5083b449454f7de0b15f131eee17de54b5a71dcb9adcf11df2b2f78fad0cd82" "checksum wasmtime-debug 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5008729ad53f75020f28fa0d682269335d6f0eac0b3ffafe31f185b2f33aca74" diff --git a/bin/subkey/Cargo.toml b/bin/subkey/Cargo.toml index 978ecc709f..c7edb4f397 100644 --- a/bin/subkey/Cargo.toml +++ b/bin/subkey/Cargo.toml @@ -14,7 +14,7 @@ clap = "2.33.0" tiny-bip39 = "0.6.2" rustc-hex = "2.0.1" substrate-bip39 = "0.3.1" -hex = "0.3.2" +hex = "0.4.0" hex-literal = "0.2.1" codec = { package = "parity-scale-codec", version = "1.0.0" } system = { package = "frame-system", path = "../../frame/system" } diff --git a/client/cli/Cargo.toml b/client/cli/Cargo.toml index ef6134822e..976242d24d 100644 --- a/client/cli/Cargo.toml +++ b/client/cli/Cargo.toml @@ -37,7 +37,7 @@ rpassword = "4.0.1" substrate-tracing = { package = "substrate-tracing", path = "../tracing" } [dev-dependencies] -tempdir = "0.3.7" +tempfile = "3.1.0" [features] wasmtime = [ diff --git a/client/cli/src/lib.rs b/client/cli/src/lib.rs index 203ca04951..3be5a50d3d 100644 --- a/client/cli/src/lib.rs +++ b/client/cli/src/lib.rs @@ -969,7 +969,6 @@ fn kill_color(s: &str) -> String { #[cfg(test)] mod tests { use super::*; - use tempdir::TempDir; use network::config::identity::ed25519; #[test] @@ -1018,7 +1017,7 @@ mod tests { fn secret_file(net_config_dir: Option) -> error::Result<()> { NodeKeyType::variants().into_iter().try_for_each(|t| { let node_key_type = NodeKeyType::from_str(t).unwrap(); - let tmp = TempDir::new("alice")?; + let tmp = tempfile::Builder::new().prefix("alice").tempdir()?; let file = tmp.path().join(format!("{}_mysecret", t)).to_path_buf(); let params = NodeKeyParams { node_key_type, diff --git a/client/db/Cargo.toml b/client/db/Cargo.toml index 67372757a6..d713212b07 100644 --- a/client/db/Cargo.toml +++ b/client/db/Cargo.toml @@ -29,7 +29,7 @@ sp-blockchain = { path = "../../primitives/blockchain" } substrate-keyring = { path = "../../primitives/keyring" } test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client" } env_logger = "0.7.0" -quickcheck = "0.8" +quickcheck = "0.9" [features] default = [] diff --git a/client/executor/Cargo.toml b/client/executor/Cargo.toml index 8c46990395..9aa201ce96 100644 --- a/client/executor/Cargo.toml +++ b/client/executor/Cargo.toml @@ -14,7 +14,7 @@ serializer = { package = "substrate-serializer", path = "../../primitives/serial runtime_version = { package = "sr-version", path = "../../primitives/sr-version" } panic-handler = { package = "substrate-panic-handler", path = "../../primitives/panic-handler" } wasmi = "0.6.2" -parity-wasm = "0.40.3" +parity-wasm = "0.41.0" lazy_static = "1.4.0" wasm-interface = { package = "substrate-wasm-interface", path = "../../primitives/wasm-interface" } runtime-interface = { package = "substrate-runtime-interface", path = "../../primitives/runtime-interface" } diff --git a/client/keystore/Cargo.toml b/client/keystore/Cargo.toml index ef788d864f..2d006b1314 100644 --- a/client/keystore/Cargo.toml +++ b/client/keystore/Cargo.toml @@ -8,11 +8,11 @@ edition = "2018" derive_more = "0.99.2" primitives = { package = "substrate-primitives", path = "../../primitives/core" } app-crypto = { package = "substrate-application-crypto", path = "../../primitives/application-crypto" } -hex = "0.3.2" +hex = "0.4.0" rand = "0.7.2" serde_json = "1.0.41" subtle = "2.1.1" parking_lot = "0.9.0" [dev-dependencies] -tempdir = "0.3.7" +tempfile = "3.1.0" diff --git a/client/keystore/src/lib.rs b/client/keystore/src/lib.rs index c86e9f8b88..3c1dffbb81 100644 --- a/client/keystore/src/lib.rs +++ b/client/keystore/src/lib.rs @@ -317,12 +317,12 @@ impl BareCryptoStore for Store { #[cfg(test)] mod tests { use super::*; - use tempdir::TempDir; + use tempfile::TempDir; use primitives::{testing::{SR25519}, crypto::{Ss58Codec}}; #[test] fn basic_store() { - let temp_dir = TempDir::new("keystore").unwrap(); + let temp_dir = TempDir::new().unwrap(); let store = Store::open(temp_dir.path(), None).unwrap(); assert!(store.read().public_keys::().unwrap().is_empty()); @@ -337,7 +337,7 @@ mod tests { #[test] fn test_insert_ephemeral_from_seed() { - let temp_dir = TempDir::new("keystore").unwrap(); + let temp_dir = TempDir::new().unwrap(); let store = Store::open(temp_dir.path(), None).unwrap(); let pair: ed25519::AppPair = store @@ -358,7 +358,7 @@ mod tests { #[test] fn password_being_used() { let password = String::from("password"); - let temp_dir = TempDir::new("keystore").unwrap(); + let temp_dir = TempDir::new().unwrap(); let store = Store::open(temp_dir.path(), Some(password.clone().into())).unwrap(); let pair: ed25519::AppPair = store.write().generate().unwrap(); @@ -380,7 +380,7 @@ mod tests { #[test] fn public_keys_are_returned() { - let temp_dir = TempDir::new("keystore").unwrap(); + let temp_dir = TempDir::new().unwrap(); let store = Store::open(temp_dir.path(), None).unwrap(); let mut public_keys = Vec::new(); @@ -403,7 +403,7 @@ mod tests { #[test] fn store_unknown_and_extract_it() { - let temp_dir = TempDir::new("keystore").unwrap(); + let temp_dir = TempDir::new().unwrap(); let store = Store::open(temp_dir.path(), None).unwrap(); let secret_uri = "//Alice"; diff --git a/client/network/Cargo.toml b/client/network/Cargo.toml index a536623d39..1362747f71 100644 --- a/client/network/Cargo.toml +++ b/client/network/Cargo.toml @@ -57,7 +57,7 @@ quickcheck = "0.9.0" rand = "0.7.2" test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client" } test_runtime = { package = "substrate-test-runtime", path = "../../test/utils/runtime" } -tempdir = "0.3.7" +tempfile = "3.1.0" tokio = "0.1.22" [features] diff --git a/client/network/src/config.rs b/client/network/src/config.rs index d10345c2f3..85e3e36cf6 100644 --- a/client/network/src/config.rs +++ b/client/network/src/config.rs @@ -502,7 +502,11 @@ where #[cfg(test)] mod tests { use super::*; - use tempdir::TempDir; + use tempfile::TempDir; + + fn tempdir_with_prefix(prefix: &str) -> TempDir { + tempfile::Builder::new().prefix(prefix).tempdir().unwrap() + } fn secret_bytes(kp: &Keypair) -> Vec { match kp { @@ -514,7 +518,7 @@ mod tests { #[test] fn test_secret_file() { - let tmp = TempDir::new("x").unwrap(); + let tmp = tempdir_with_prefix("x"); std::fs::remove_dir(tmp.path()).unwrap(); // should be recreated let file = tmp.path().join("x").to_path_buf(); let kp1 = NodeKeyConfig::Ed25519(Secret::File(file.clone())).into_keypair().unwrap(); diff --git a/client/service/test/Cargo.toml b/client/service/test/Cargo.toml index 7a85966a39..fa7f834efa 100644 --- a/client/service/test/Cargo.toml +++ b/client/service/test/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -tempdir = "0.3.7" +tempfile = "3.1.0" tokio = "0.1.22" futures = "0.1.29" log = "0.4.8" diff --git a/client/service/test/src/lib.rs b/client/service/test/src/lib.rs index 3b1e3593dc..73dc551800 100644 --- a/client/service/test/src/lib.rs +++ b/client/service/test/src/lib.rs @@ -22,7 +22,7 @@ use std::net::Ipv4Addr; use std::time::Duration; use log::info; use futures::{Future, Stream, Poll}; -use tempdir::TempDir; +use tempfile::TempDir; use tokio::{runtime::Runtime, prelude::FutureExt}; use tokio::timer::Interval; use service::{ @@ -290,6 +290,10 @@ impl TestNet where } } +fn tempdir_with_prefix(prefix: &str) -> TempDir { + tempfile::Builder::new().prefix(prefix).tempdir().expect("Error creating test dir") +} + pub fn connectivity( spec: ChainSpec, full_builder: Fb, @@ -314,7 +318,7 @@ pub fn connectivity( }; { - let temp = TempDir::new("substrate-connectivity-test").expect("Error creating test dir"); + let temp = tempdir_with_prefix("substrate-connectivity-test"); let runtime = { let mut network = TestNet::new( &temp, @@ -352,7 +356,7 @@ pub fn connectivity( temp.close().expect("Error removing temp dir"); } { - let temp = TempDir::new("substrate-connectivity-test").expect("Error creating test dir"); + let temp = tempdir_with_prefix("substrate-connectivity-test"); { let mut network = TestNet::new( &temp, @@ -414,7 +418,7 @@ pub fn sync( // FIXME: BABE light client support is currently not working. const NUM_LIGHT_NODES: usize = 10; const NUM_BLOCKS: usize = 512; - let temp = TempDir::new("substrate-sync-test").expect("Error creating test dir"); + let temp = tempdir_with_prefix("substrate-sync-test"); let mut network = TestNet::new( &temp, spec.clone(), @@ -479,7 +483,7 @@ pub fn consensus( const NUM_FULL_NODES: usize = 10; const NUM_LIGHT_NODES: usize = 10; const NUM_BLOCKS: usize = 10; // 10 * 2 sec block production time = ~20 seconds - let temp = TempDir::new("substrate-conensus-test").expect("Error creating test dir"); + let temp = tempdir_with_prefix("substrate-conensus-test"); let mut network = TestNet::new( &temp, spec.clone(), diff --git a/frame/contracts/Cargo.toml b/frame/contracts/Cargo.toml index 2b4536dd8a..4a870b18e4 100644 --- a/frame/contracts/Cargo.toml +++ b/frame/contracts/Cargo.toml @@ -6,10 +6,10 @@ edition = "2018" [dependencies] serde = { version = "1.0.101", optional = true, features = ["derive"] } -pwasm-utils = { version = "0.11.0", default-features = false } +pwasm-utils = { version = "0.12.0", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -parity-wasm = { version = "0.40.3", default-features = false } -wasmi-validation = { version = "0.2.0", default-features = false } +parity-wasm = { version = "0.41.0", default-features = false } +wasmi-validation = { version = "0.3.0", default-features = false } primitives = { package = "substrate-primitives", path = "../../primitives/core", default-features = false } sr-primitives = { path = "../../primitives/sr-primitives", default-features = false } runtime-io = { package = "sr-io", path = "../../primitives/sr-io", default-features = false } @@ -23,7 +23,6 @@ wabt = "0.9.2" assert_matches = "1.3.0" hex-literal = "0.2.1" balances = { package = "pallet-balances", path = "../balances" } -hex = "0.3.2" timestamp = { package = "pallet-timestamp", path = "../timestamp" } randomness-collective-flip = { package = "pallet-randomness-collective-flip", path = "../randomness-collective-flip" } diff --git a/frame/support/procedural/tools/Cargo.toml b/frame/support/procedural/tools/Cargo.toml index 740a6985fe..8a9f87116b 100644 --- a/frame/support/procedural/tools/Cargo.toml +++ b/frame/support/procedural/tools/Cargo.toml @@ -8,5 +8,5 @@ edition = "2018" frame-support-procedural-tools-derive = { package = "frame-support-procedural-tools-derive", path = "./derive" } proc-macro2 = "1.0.6" quote = "1.0.2" -syn = { version = "1.0.7", features = ["full"] } +syn = { version = "1.0.7", features = ["full", "visit"] } proc-macro-crate = "0.1.4" diff --git a/primitives/core/Cargo.toml b/primitives/core/Cargo.toml index 240da745f4..e15c5ac49f 100644 --- a/primitives/core/Cargo.toml +++ b/primitives/core/Cargo.toml @@ -17,7 +17,7 @@ impl-serde = { version = "0.2.3", optional = true } wasmi = { version = "0.6.2", optional = true } hash-db = { version = "0.15.2", default-features = false } hash256-std-hasher = { version = "0.15.2", default-features = false } -ed25519-dalek = { version = "0.9.1", default-features = false, features = ["u64_backend"], optional = true } +ed25519-dalek = { version = "1.0.0-pre.2", default-features = false, features = ["u64_backend"], optional = true } base58 = { version = "0.1.0", optional = true } blake2-rfc = { version = "0.2.18", default-features = false, optional = true } schnorrkel = { version = "0.8.5", features = ["preaudit_deprecated"], default-features = false, optional = true } diff --git a/primitives/core/src/ed25519.rs b/primitives/core/src/ed25519.rs index 37933ee678..34ec0d6c8d 100644 --- a/primitives/core/src/ed25519.rs +++ b/primitives/core/src/ed25519.rs @@ -445,7 +445,7 @@ impl TraitPair for Pair { fn from_seed_slice(seed_slice: &[u8]) -> Result { let secret = ed25519_dalek::SecretKey::from_bytes(seed_slice) .map_err(|_| SecretStringError::InvalidSeedLength)?; - let public = ed25519_dalek::PublicKey::from(secret.expand::()); + let public = ed25519_dalek::PublicKey::from(&secret); Ok(Pair(ed25519_dalek::Keypair { secret, public })) } @@ -474,7 +474,7 @@ impl TraitPair for Pair { /// Sign a message. fn sign(&self, message: &[u8]) -> Signature { - let r = self.0.sign::(message).to_bytes(); + let r = self.0.sign(message).to_bytes(); Signature::from_raw(r) } @@ -498,7 +498,7 @@ impl TraitPair for Pair { Err(_) => return false }; - match public_key.verify::(message.as_ref(), &sig) { + match public_key.verify(message.as_ref(), &sig) { Ok(_) => true, _ => false, } diff --git a/primitives/transaction-pool/Cargo.toml b/primitives/transaction-pool/Cargo.toml index b2ea581249..ce20c8acec 100644 --- a/primitives/transaction-pool/Cargo.toml +++ b/primitives/transaction-pool/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -derive_more = "0.15.0" +derive_more = "0.99.2" futures = "0.3.1" log = "0.4.8" serde = { version = "1.0.101", features = ["derive"] } -- GitLab From 25b99d47832b7485082bf98232b66e0779b82713 Mon Sep 17 00:00:00 2001 From: Weiliang Li Date: Thu, 28 Nov 2019 17:56:01 +0900 Subject: [PATCH 038/172] Parameter trait for Time::Moment (#4237) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Debug for Time::Moment Without this we cannot have a Moment parameter in dispatchable functions * Update frame/support/src/traits.rs Co-Authored-By: Bastian Köcher * Update traits.rs --- frame/support/src/traits.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frame/support/src/traits.rs b/frame/support/src/traits.rs index 167afd1b72..3de5c4770b 100644 --- a/frame/support/src/traits.rs +++ b/frame/support/src/traits.rs @@ -26,6 +26,8 @@ use sr_primitives::{ traits::{MaybeSerializeDeserialize, SimpleArithmetic, Saturating}, }; +use crate::dispatch::Parameter; + /// Anything that can have a `::len()` method. pub trait Len { /// Return the length of data type. @@ -622,7 +624,7 @@ bitmask! { } pub trait Time { - type Moment: SimpleArithmetic + FullCodec + Clone + Default + Copy; + type Moment: SimpleArithmetic + Parameter + Default + Copy; fn now() -> Self::Moment; } -- GitLab From 99dff40edeff7bcb4ec3272b2323fd2577f94c19 Mon Sep 17 00:00:00 2001 From: thiolliere Date: Thu, 28 Nov 2019 11:06:06 +0100 Subject: [PATCH 039/172] improve doc (#4239) --- frame/support/src/dispatch.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/frame/support/src/dispatch.rs b/frame/support/src/dispatch.rs index cde1300831..3c41326b15 100644 --- a/frame/support/src/dispatch.rs +++ b/frame/support/src/dispatch.rs @@ -48,6 +48,9 @@ pub trait Callable { // https://github.com/rust-lang/rust/issues/51331 pub type CallableCallFor = >::Call; +/// A type that can be used as a parameter in a dispatchable function. +/// +/// When using `decl_module` all arguments for call functions must implement this trait. pub trait Parameter: Codec + EncodeLike + Clone + Eq + fmt::Debug {} impl Parameter for T where T: Codec + EncodeLike + Clone + Eq + fmt::Debug {} -- GitLab From 7492d0bd921441ef2710437206e0a314d23e391c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Thu, 28 Nov 2019 12:16:54 +0100 Subject: [PATCH 040/172] Handle Grafana server bind errors gracefuly. (#4241) * Fix error handling for grafana sever start. * Update client/grafana-data-source/src/server.rs Co-Authored-By: Pierre Krieger --- Cargo.lock | 1 + client/grafana-data-source/Cargo.toml | 1 + client/grafana-data-source/src/server.rs | 53 ++++++++++++++++++++---- client/service/src/lib.rs | 2 +- 4 files changed, 49 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 68e86cb216..95f5217e33 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1672,6 +1672,7 @@ dependencies = [ "futures-util-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.13.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/client/grafana-data-source/Cargo.toml b/client/grafana-data-source/Cargo.toml index 6e9b2685ae..b6503dec6c 100644 --- a/client/grafana-data-source/Cargo.toml +++ b/client/grafana-data-source/Cargo.toml @@ -7,6 +7,7 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] +log = "0.4.8" hyper = { version = "0.13.0-alpha.4", default-features = false, features = ["unstable-stream"] } tokio-io = "0.2.0-alpha.6" tokio-executor = "0.2.0-alpha.6" diff --git a/client/grafana-data-source/src/server.rs b/client/grafana-data-source/src/server.rs index 0213e9ff25..cb1efd67bd 100644 --- a/client/grafana-data-source/src/server.rs +++ b/client/grafana-data-source/src/server.rs @@ -110,12 +110,50 @@ impl tokio_executor::TypedExecutor for Executor } } +/// An error that may occur during server runtime. +#[derive(Debug, derive_more::Display, derive_more::From)] +pub enum RunError { + /// Propagated hyper server error. + Hyper(hyper::Error), + /// Initial bind IO error. + Io(std::io::Error), +} + +impl std::error::Error for RunError { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + match *self { + Self::Hyper(ref e) => Some(e), + Self::Io(ref e) => Some(e), + } + } +} + /// Start the data source server. #[cfg(not(target_os = "unknown"))] -pub async fn run_server(address: std::net::SocketAddr) -> Result<(), hyper::Error> { +pub async fn run_server(mut address: std::net::SocketAddr) -> Result<(), RunError> { + use async_std::{net, io}; use crate::networking::Incoming; - let listener = async_std::net::TcpListener::bind(&address).await.unwrap(); + let listener = loop { + let listener = net::TcpListener::bind(&address).await; + match listener { + Ok(listener) => { + log::info!("Grafana data source server started at {}", address); + break listener + }, + Err(err) => match err.kind() { + io::ErrorKind::AddrInUse | io::ErrorKind::PermissionDenied if address.port() != 0 => { + log::warn!( + "Unable to bind grafana data source server to {}. Trying random port.", + address + ); + address.set_port(0); + continue; + }, + _ => Err(err)?, + } + } + }; let service = make_service_fn(|_| { async { @@ -128,11 +166,12 @@ pub async fn run_server(address: std::net::SocketAddr) -> Result<(), hyper::Erro .serve(service) .boxed(); - let clean = clean_up(Duration::days(1), Duration::weeks(1)) + let every = std::time::Duration::from_secs(24 * 3600); + let clean = clean_up(every, Duration::weeks(1)) .boxed(); let result = match select(server, clean).await { - Either::Left((result, _)) => result, + Either::Left((result, _)) => result.map_err(Into::into), Either::Right(_) => Ok(()) }; @@ -140,14 +179,14 @@ pub async fn run_server(address: std::net::SocketAddr) -> Result<(), hyper::Erro } #[cfg(target_os = "unknown")] -pub async fn run_server(_: std::net::SocketAddr) -> Result<(), hyper::Error> { +pub async fn run_server(_: std::net::SocketAddr) -> Result<(), RunError> { Ok(()) } /// Periodically remove old metrics. -async fn clean_up(every: Duration, before: Duration) { +async fn clean_up(every: std::time::Duration, before: Duration) { loop { - Delay::new(every.to_std().unwrap()).await; + Delay::new(every).await; let oldest_allowed = (Utc::now() - before).timestamp_millis(); diff --git a/client/service/src/lib.rs b/client/service/src/lib.rs index 702f72f832..0291dd1d51 100644 --- a/client/service/src/lib.rs +++ b/client/service/src/lib.rs @@ -524,7 +524,7 @@ fn start_rpc_servers rpc_servers::RpcHandler { - warn!("Unable to bind server to {}. Trying random port.", address); + warn!("Unable to bind RPC server to {}. Trying random port.", address); address.set_port(0); start(&address) }, -- GitLab From 4031142b52e1ee857cb00992cb1e12388b9e87de Mon Sep 17 00:00:00 2001 From: Arkadiy Paronyan Date: Thu, 28 Nov 2019 12:24:28 +0100 Subject: [PATCH 041/172] Check block CLI command (#4240) * Check block operation * Update client/cli/src/lib.rs * Update client/cli/src/params.rs --- bin/node-template/src/cli.rs | 2 + bin/node/cli/src/cli.rs | 2 + bin/node/cli/src/service.rs | 1 + client/cli/src/lib.rs | 193 +++++--- client/cli/src/params.rs | 126 ++--- client/consensus/aura/src/lib.rs | 2 + client/consensus/babe/src/lib.rs | 2 + client/consensus/babe/src/tests.rs | 1 + client/consensus/pow/src/lib.rs | 2 + client/finality-grandpa/src/light_import.rs | 1 + client/finality-grandpa/src/tests.rs | 3 + client/network/src/protocol/sync.rs | 2 + client/network/src/test/block_import.rs | 1 + client/network/src/test/mod.rs | 1 + client/service/src/builder.rs | 99 +--- client/service/src/chain_ops.rs | 462 ++++++++++-------- client/service/src/lib.rs | 4 +- client/src/client.rs | 29 +- .../consensus/common/src/block_import.rs | 4 + .../consensus/common/src/import_queue.rs | 3 + test/utils/client/src/client_ext.rs | 4 + test/utils/transaction-factory/src/lib.rs | 1 + 22 files changed, 516 insertions(+), 429 deletions(-) diff --git a/bin/node-template/src/cli.rs b/bin/node-template/src/cli.rs index 1171a90654..edbe40feb8 100644 --- a/bin/node-template/src/cli.rs +++ b/bin/node-template/src/cli.rs @@ -44,6 +44,8 @@ pub fn run(args: I, exit: E, version: VersionInfo) -> error::Result<()> Ok(new_full_start!(config).0), load_spec, exit), ParseAndPrepare::ImportBlocks(cmd) => cmd.run_with_builder(|config: Config<_>| Ok(new_full_start!(config).0), load_spec, exit), + ParseAndPrepare::CheckBlock(cmd) => cmd.run_with_builder(|config: Config<_>| + Ok(new_full_start!(config).0), load_spec, exit), ParseAndPrepare::PurgeChain(cmd) => cmd.run(load_spec), ParseAndPrepare::RevertChain(cmd) => cmd.run_with_builder(|config: Config<_>| Ok(new_full_start!(config).0), load_spec), diff --git a/bin/node/cli/src/cli.rs b/bin/node/cli/src/cli.rs index f648038d82..aaa02dcc2b 100644 --- a/bin/node/cli/src/cli.rs +++ b/bin/node/cli/src/cli.rs @@ -136,6 +136,8 @@ pub fn run(args: I, exit: E, version: substrate_cli::VersionInfo) -> er Ok(new_full_start!(config).0), load_spec, exit), ParseAndPrepare::ImportBlocks(cmd) => cmd.run_with_builder(|config: Config<_, _>| Ok(new_full_start!(config).0), load_spec, exit), + ParseAndPrepare::CheckBlock(cmd) => cmd.run_with_builder(|config: Config<_, _>| + Ok(new_full_start!(config).0), load_spec, exit), ParseAndPrepare::PurgeChain(cmd) => cmd.run(load_spec), ParseAndPrepare::RevertChain(cmd) => cmd.run_with_builder(|config: Config<_, _>| Ok(new_full_start!(config).0), load_spec), diff --git a/bin/node/cli/src/service.rs b/bin/node/cli/src/service.rs index 405e0c89df..5c7b97c0b8 100644 --- a/bin/node/cli/src/service.rs +++ b/bin/node/cli/src/service.rs @@ -568,6 +568,7 @@ mod tests { auxiliary: Vec::new(), fork_choice: ForkChoiceStrategy::LongestChain, allow_missing_state: false, + import_existing: false, }; block_import.import_block(params, Default::default()) diff --git a/client/cli/src/lib.rs b/client/cli/src/lib.rs index 3be5a50d3d..08012ec627 100644 --- a/client/cli/src/lib.rs +++ b/client/cli/src/lib.rs @@ -29,7 +29,7 @@ pub mod informant; use client_api::execution_extensions::ExecutionStrategies; use service::{ config::{Configuration, DatabaseConfig}, - ServiceBuilderExport, ServiceBuilderImport, ServiceBuilderRevert, + ServiceBuilderCommand, RuntimeGenesis, ChainSpecExtension, PruningMode, ChainSpec, }; use network::{ @@ -54,7 +54,7 @@ pub use structopt::clap::App; use params::{ RunCmd, PurgeChainCmd, RevertCmd, ImportBlocksCmd, ExportBlocksCmd, BuildSpecCmd, NetworkConfigurationParams, MergeParameters, TransactionPoolParams, - NodeKeyParams, NodeKeyType, Cors, + NodeKeyParams, NodeKeyType, Cors, CheckBlockCmd, }; pub use params::{NoCustom, CoreParams, SharedParams, ExecutionStrategy as ExecutionStrategyParam}; pub use traits::{GetLogFilter, AugmentClap}; @@ -64,6 +64,8 @@ use lazy_static::lazy_static; use futures::{Future, FutureExt, TryFutureExt}; use futures01::{Async, Future as _}; use substrate_telemetry::TelemetryEndpoints; +use sr_primitives::generic::BlockId; +use sr_primitives::traits::Block as BlockT; /// default sub directory to store network config const DEFAULT_NETWORK_CONFIG_PATH : &'static str = "network"; @@ -231,6 +233,9 @@ where params::CoreParams::ImportBlocks(params) => ParseAndPrepare::ImportBlocks( ParseAndPrepareImport { params, version } ), + params::CoreParams::CheckBlock(params) => ParseAndPrepare::CheckBlock( + CheckBlock { params, version } + ), params::CoreParams::PurgeChain(params) => ParseAndPrepare::PurgeChain( ParseAndPreparePurge { params, version } ), @@ -263,6 +268,8 @@ pub enum ParseAndPrepare<'a, CC, RP> { ExportBlocks(ParseAndPrepareExport<'a>), /// Command ready to import the chain. ImportBlocks(ParseAndPrepareImport<'a>), + /// Command to check a block. + CheckBlock(CheckBlock<'a>), /// Command ready to purge the chain. PurgeChain(ParseAndPreparePurge<'a>), /// Command ready to revert the chain. @@ -366,7 +373,7 @@ impl<'a> ParseAndPrepareExport<'a> { ) -> error::Result<()> where S: FnOnce(&str) -> Result>, String>, F: FnOnce(Configuration) -> Result, - B: ServiceBuilderExport, + B: ServiceBuilderCommand, C: Default, G: RuntimeGenesis, E: ChainSpecExtension, @@ -427,19 +434,13 @@ impl<'a> ParseAndPrepareImport<'a> { ) -> error::Result<()> where S: FnOnce(&str) -> Result>, String>, F: FnOnce(Configuration) -> Result, - B: ServiceBuilderImport, + B: ServiceBuilderCommand, C: Default, G: RuntimeGenesis, E: ChainSpecExtension, Exit: IntoExit { - let mut config = create_config_with_db_path(spec_factory, &self.params.shared_params, self.version)?; - config.wasm_method = self.params.wasm_method.into(); - config.execution_strategies = ExecutionStrategies { - importing: self.params.execution.into(), - other: self.params.execution.into(), - ..Default::default() - }; + let config = create_config_with_db_path(spec_factory, &self.params.shared_params, self.version)?; let file: Box = match self.params.input { Some(filename) => Box::new(File::open(filename)?), @@ -461,7 +462,7 @@ impl<'a> ParseAndPrepareImport<'a> { let _ = exit_send.send(()); }); - let mut import_fut = builder(config)?.import_blocks(file); + let mut import_fut = builder(config)?.import_blocks(file, false); let fut = futures01::future::poll_fn(|| { if exit_recv.try_recv().is_ok() { return Ok(Async::Ready(())); @@ -475,6 +476,49 @@ impl<'a> ParseAndPrepareImport<'a> { } } +/// Command to check a block. +pub struct CheckBlock<'a> { + params: CheckBlockCmd, + version: &'a VersionInfo, +} + +impl<'a> CheckBlock<'a> { + /// Runs the command and imports to the chain. + pub fn run_with_builder( + self, + builder: F, + spec_factory: S, + _exit: Exit, + ) -> error::Result<()> + where S: FnOnce(&str) -> Result>, String>, + F: FnOnce(Configuration) -> Result, + B: ServiceBuilderCommand, + <::Block as BlockT>::Hash: FromStr, + C: Default, + G: RuntimeGenesis, + E: ChainSpecExtension, + Exit: IntoExit + { + let config = create_config_with_db_path(spec_factory, &self.params.shared_params, self.version)?; + + let input = if self.params.input.starts_with("0x") { &self.params.input[2..] } else { &self.params.input[..] }; + let block_id = match FromStr::from_str(input) { + Ok(hash) => BlockId::hash(hash), + Err(_) => match self.params.input.parse::() { + Ok(n) => BlockId::number((n as u32).into()), + Err(_) => return Err(error::Error::Input("Invalid hash or number specified".into())), + } + }; + + let start = std::time::Instant::now(); + let check = builder(config)?.check_block(block_id); + let mut runtime = tokio::runtime::current_thread::Runtime::new().unwrap(); + runtime.block_on(check)?; + println!("Completed in {} ms.", start.elapsed().as_millis()); + Ok(()) + } +} + /// Command ready to purge the chain. pub struct ParseAndPreparePurge<'a> { params: PurgeChainCmd, @@ -548,7 +592,7 @@ impl<'a> ParseAndPrepareRevert<'a> { ) -> error::Result<()> where S: FnOnce(&str) -> Result>, String>, F: FnOnce(Configuration) -> Result, - B: ServiceBuilderRevert, + B: ServiceBuilderCommand, C: Default, G: RuntimeGenesis, E: ChainSpecExtension, @@ -694,69 +738,24 @@ fn fill_config_keystore_password( Ok(()) } -fn create_run_node_config( - cli: RunCmd, spec_factory: S, impl_name: &'static str, version: &VersionInfo, -) -> error::Result> +fn fill_shared_config(config: &mut Configuration, cli: &SharedParams, role: service::Roles) + -> error::Result<()> where C: Default, G: RuntimeGenesis, E: ChainSpecExtension, - S: FnOnce(&str) -> Result>, String>, { - let spec = load_spec(&cli.shared_params, spec_factory)?; - let base_path = base_path(&cli.shared_params, &version); - let mut config = service::Configuration::default_with_spec_and_base_path(spec.clone(), Some(base_path)); - - fill_config_keystore_password(&mut config, &cli)?; - - config.impl_name = impl_name; - config.impl_commit = version.commit; - config.impl_version = version.version; - - config.name = match cli.name.or(cli.keyring.account.map(|a| a.to_string())) { - None => generate_node_name(), - Some(name) => name, - }; - match is_node_name_valid(&config.name) { - Ok(_) => (), - Err(msg) => Err( - error::Error::Input( - format!("Invalid node name '{}'. Reason: {}. If unsure, use none.", - config.name, - msg - ) - ) - )? - } - - config.keystore_path = cli.keystore_path.or_else(|| config.in_chain_config_dir(DEFAULT_KEYSTORE_CONFIG_PATH)); - config.database = DatabaseConfig::Path { path: config.in_chain_config_dir(DEFAULT_DB_CONFIG_PATH).expect("We provided a base_path."), cache_size: Some(cli.database_cache_size), }; config.state_cache_size = cli.state_cache_size; - let is_dev = cli.shared_params.dev; - let is_authority = cli.validator || cli.sentry || is_dev || cli.keyring.account.is_some(); - - let role = - if cli.light { - service::Roles::LIGHT - } else if is_authority { - service::Roles::AUTHORITY - } else { - service::Roles::FULL - }; - - // set sentry mode (i.e. act as an authority but **never** actively participate) - config.sentry_mode = cli.sentry; - // by default we disable pruning if the node is an authority (i.e. // `ArchiveAll`), otherwise we keep state for the last 256 blocks. if the // node is an authority and pruning is enabled explicitly, then we error // unless `unsafe_pruning` is set. - config.pruning = match cli.pruning { + config.pruning = match &cli.pruning { Some(ref s) if s == "archive" => PruningMode::ArchiveAll, None if role == service::Roles::AUTHORITY => PruningMode::ArchiveAll, None => PruningMode::default(), @@ -776,7 +775,7 @@ where config.wasm_method = cli.wasm_method.into(); - let exec = cli.execution_strategies; + let exec = &cli.execution_strategies; let exec_all_or = |strat: params::ExecutionStrategy| exec.execution.unwrap_or(strat).into(); config.execution_strategies = ExecutionStrategies { syncing: exec_all_or(exec.execution_syncing), @@ -785,6 +784,61 @@ where offchain_worker: exec_all_or(exec.execution_offchain_worker), other: exec_all_or(exec.execution_other), }; + Ok(()) +} + +fn create_run_node_config( + cli: RunCmd, spec_factory: S, impl_name: &'static str, version: &VersionInfo, +) -> error::Result> +where + C: Default, + G: RuntimeGenesis, + E: ChainSpecExtension, + S: FnOnce(&str) -> Result>, String>, +{ + let spec = load_spec(&cli.shared_params, spec_factory)?; + let base_path = base_path(&cli.shared_params, &version); + let mut config = service::Configuration::default_with_spec_and_base_path(spec.clone(), Some(base_path)); + + fill_config_keystore_password(&mut config, &cli)?; + + let is_dev = cli.shared_params.dev; + let is_authority = cli.validator || cli.sentry || is_dev || cli.keyring.account.is_some(); + let role = + if cli.light { + service::Roles::LIGHT + } else if is_authority { + service::Roles::AUTHORITY + } else { + service::Roles::FULL + }; + + fill_shared_config(&mut config, &cli.shared_params, role)?; + + config.impl_name = impl_name; + config.impl_commit = version.commit; + config.impl_version = version.version; + + config.name = match cli.name.or(cli.keyring.account.map(|a| a.to_string())) { + None => generate_node_name(), + Some(name) => name, + }; + match is_node_name_valid(&config.name) { + Ok(_) => (), + Err(msg) => Err( + error::Error::Input( + format!("Invalid node name '{}'. Reason: {}. If unsure, use none.", + config.name, + msg + ) + ) + )? + } + + config.keystore_path = cli.keystore_path.or_else(|| config.in_chain_config_dir(DEFAULT_KEYSTORE_CONFIG_PATH)); + + // set sentry mode (i.e. act as an authority but **never** actively participate) + config.sentry_mode = cli.sentry; config.offchain_worker = match (cli.offchain_worker, role) { (params::OffchainWorkerEnabled::WhenValidating, service::Roles::AUTHORITY) => true, @@ -871,11 +925,7 @@ where let base_path = base_path(cli, version); let mut config = service::Configuration::default_with_spec_and_base_path(spec.clone(), Some(base_path)); - config.database = DatabaseConfig::Path { - path: config.in_chain_config_dir(DEFAULT_DB_CONFIG_PATH).expect("We provided a base_path."), - cache_size: None, - }; - + fill_shared_config(&mut config, &cli, service::Roles::FULL)?; Ok(config) } @@ -943,14 +993,15 @@ fn init_logger(pattern: &str) { ) }; - if !enable_color { - output = kill_color(output.as_ref()); - } - if !isatty && record.level() <= log::Level::Info && atty::is(atty::Stream::Stdout) { // duplicate INFO/WARN output to console println!("{}", output); } + + if !enable_color { + output = kill_color(output.as_ref()); + } + writeln!(buf, "{}", output) }); diff --git a/client/cli/src/params.rs b/client/cli/src/params.rs index 09a18db207..6657556551 100644 --- a/client/cli/src/params.rs +++ b/client/cli/src/params.rs @@ -46,7 +46,7 @@ impl Into for ExecutionStrategy { arg_enum! { /// How to execute Wasm runtime code #[allow(missing_docs)] - #[derive(Debug, Clone)] + #[derive(Debug, Clone, Copy)] pub enum WasmExecutionMethod { // Uses an interpreter. Interpreted, @@ -109,6 +109,44 @@ pub struct SharedParams { /// Sets a custom logging filter. #[structopt(short = "l", long = "log", value_name = "LOG_PATTERN")] pub log: Option, + + /// Specify the state pruning mode, a number of blocks to keep or 'archive'. + /// + /// Default is to keep all block states if the node is running as a + /// validator (i.e. 'archive'), otherwise state is only kept for the last + /// 256 blocks. + #[structopt(long = "pruning", value_name = "PRUNING_MODE")] + pub pruning: Option, + + /// Force start with unsafe pruning settings. + /// + /// When running as a validator it is highly recommended to disable state + /// pruning (i.e. 'archive') which is the default. The node will refuse to + /// start as a validator if pruning is enabled unless this option is set. + #[structopt(long = "unsafe-pruning")] + pub unsafe_pruning: bool, + + /// Method for executing Wasm runtime code. + #[structopt( + long = "wasm-execution", + value_name = "METHOD", + possible_values = &WasmExecutionMethod::enabled_variants(), + case_insensitive = true, + default_value = "Interpreted" + )] + pub wasm_method: WasmExecutionMethod, + + #[allow(missing_docs)] + #[structopt(flatten)] + pub execution_strategies: ExecutionStrategies, + + /// Limit the memory the database cache can use. + #[structopt(long = "db-cache", value_name = "MiB", default_value = "1024")] + pub database_cache_size: u32, + + /// Specify the state cache size. + #[structopt(long = "state-cache-size", value_name = "Bytes", default_value = "67108864")] + pub state_cache_size: usize, } impl GetLogFilter for SharedParams { @@ -386,14 +424,6 @@ pub struct RunCmd { #[structopt(long = "light")] pub light: bool, - /// Limit the memory the database cache can use. - #[structopt(long = "db-cache", value_name = "MiB", default_value = "1024")] - pub database_cache_size: u32, - - /// Specify the state cache size. - #[structopt(long = "state-cache-size", value_name = "Bytes", default_value = "67108864")] - pub state_cache_size: usize, - /// Listen to all RPC interfaces. /// /// Default is local. @@ -438,22 +468,6 @@ pub struct RunCmd { #[structopt(long = "grafana-port", value_name = "PORT")] pub grafana_port: Option, - /// Specify the state pruning mode, a number of blocks to keep or 'archive'. - /// - /// Default is to keep all block states if the node is running as a - /// validator (i.e. 'archive'), otherwise state is only kept for the last - /// 256 blocks. - #[structopt(long = "pruning", value_name = "PRUNING_MODE")] - pub pruning: Option, - - /// Force start with unsafe pruning settings. - /// - /// When running as a validator it is highly recommended to disable state - /// pruning (i.e. 'archive') which is the default. The node will refuse to - /// start as a validator if pruning is enabled unless this option is set. - #[structopt(long = "unsafe-pruning")] - pub unsafe_pruning: bool, - /// The human-readable name for this node. /// /// The node name will be reported to the telemetry server, if enabled. @@ -487,20 +501,6 @@ pub struct RunCmd { )] pub offchain_worker: OffchainWorkerEnabled, - /// Method for executing Wasm runtime code. - #[structopt( - long = "wasm-execution", - value_name = "METHOD", - possible_values = &WasmExecutionMethod::enabled_variants(), - case_insensitive = true, - default_value = "Interpreted" - )] - pub wasm_method: WasmExecutionMethod, - - #[allow(missing_docs)] - #[structopt(flatten)] - pub execution_strategies: ExecutionStrategies, - #[allow(missing_docs)] #[structopt(flatten)] pub shared_params: SharedParams, @@ -764,29 +764,29 @@ pub struct ImportBlocksCmd { #[allow(missing_docs)] #[structopt(flatten)] pub shared_params: SharedParams, +} - /// Method for executing Wasm runtime code. - #[structopt( - long = "wasm-execution", - value_name = "METHOD", - possible_values = &WasmExecutionMethod::variants(), - case_insensitive = true, - default_value = "Interpreted" - )] - pub wasm_method: WasmExecutionMethod, +impl_get_log_filter!(ImportBlocksCmd); - /// The means of execution used when calling into the runtime while importing blocks. - #[structopt( - long = "execution", - value_name = "STRATEGY", - possible_values = &ExecutionStrategy::variants(), - case_insensitive = true, - default_value = "NativeElseWasm" - )] - pub execution: ExecutionStrategy, +/// The `check-block` command used to validate blocks. +#[derive(Debug, StructOpt, Clone)] +pub struct CheckBlockCmd { + /// Block hash or number + #[structopt(value_name = "HASH or NUMBER")] + pub input: String, + + /// The default number of 64KB pages to ever allocate for Wasm execution. + /// + /// Don't alter this unless you know what you're doing. + #[structopt(long = "default-heap-pages", value_name = "COUNT")] + pub default_heap_pages: Option, + + #[allow(missing_docs)] + #[structopt(flatten)] + pub shared_params: SharedParams, } -impl_get_log_filter!(ImportBlocksCmd); +impl_get_log_filter!(CheckBlockCmd); /// The `revert` command used revert the chain to a previous state. #[derive(Debug, StructOpt, Clone)] @@ -835,6 +835,9 @@ pub enum CoreParams { /// Import blocks from file. ImportBlocks(ImportBlocksCmd), + /// Validte a single block. + CheckBlock(CheckBlockCmd), + /// Revert chain to the previous state. Revert(RevertCmd), @@ -868,6 +871,10 @@ impl StructOpt for CoreParams where ImportBlocksCmd::augment_clap(SubCommand::with_name("import-blocks")) .about("Import blocks from file.") ) + .subcommand( + CheckBlockCmd::augment_clap(SubCommand::with_name("check-block")) + .about("Re-validate a known block.") + ) .subcommand( RevertCmd::augment_clap(SubCommand::with_name("revert")) .about("Revert chain to the previous state.") @@ -886,6 +893,8 @@ impl StructOpt for CoreParams where CoreParams::ExportBlocks(ExportBlocksCmd::from_clap(matches)), ("import-blocks", Some(matches)) => CoreParams::ImportBlocks(ImportBlocksCmd::from_clap(matches)), + ("check-block", Some(matches)) => + CoreParams::CheckBlock(CheckBlockCmd::from_clap(matches)), ("revert", Some(matches)) => CoreParams::Revert(RevertCmd::from_clap(matches)), ("purge-chain", Some(matches)) => CoreParams::PurgeChain(PurgeChainCmd::from_clap(matches)), @@ -902,6 +911,7 @@ impl GetLogFilter for CoreParams where CC: GetLogFilter { CoreParams::BuildSpec(c) => c.get_log_filter(), CoreParams::ExportBlocks(c) => c.get_log_filter(), CoreParams::ImportBlocks(c) => c.get_log_filter(), + CoreParams::CheckBlock(c) => c.get_log_filter(), CoreParams::PurgeChain(c) => c.get_log_filter(), CoreParams::Revert(c) => c.get_log_filter(), CoreParams::Custom(c) => c.get_log_filter(), diff --git a/client/consensus/aura/src/lib.rs b/client/consensus/aura/src/lib.rs index 131cc8a1ab..a97fa9bde3 100644 --- a/client/consensus/aura/src/lib.rs +++ b/client/consensus/aura/src/lib.rs @@ -281,6 +281,7 @@ impl slots::SimpleSlotWorker for AuraWorker Verifier for AuraVerifier where auxiliary: Vec::new(), fork_choice: ForkChoiceStrategy::LongestChain, allow_missing_state: false, + import_existing: false, }; Ok((block_import_params, maybe_keys)) diff --git a/client/consensus/babe/src/lib.rs b/client/consensus/babe/src/lib.rs index 2c81367039..b4c2aff549 100644 --- a/client/consensus/babe/src/lib.rs +++ b/client/consensus/babe/src/lib.rs @@ -436,6 +436,7 @@ impl slots::SimpleSlotWorker for BabeWorker Verifier for BabeVerifier, C, S, Algorithm> Verifier for PowVerifier best_aux.total_difficulty), allow_missing_state: false, + import_existing: false, }; Ok((import_block, None)) @@ -532,6 +533,7 @@ fn mine_loop, C, Algorithm, E, SO, S>( auxiliary: vec![(key, Some(aux.encode()))], fork_choice: ForkChoiceStrategy::Custom(true), allow_missing_state: false, + import_existing: false, }; block_import.import_block(import_block, HashMap::default()) diff --git a/client/finality-grandpa/src/light_import.rs b/client/finality-grandpa/src/light_import.rs index 6b5fbb3489..579043751b 100644 --- a/client/finality-grandpa/src/light_import.rs +++ b/client/finality-grandpa/src/light_import.rs @@ -659,6 +659,7 @@ pub mod tests { auxiliary: Vec::new(), fork_choice: ForkChoiceStrategy::LongestChain, allow_missing_state: true, + import_existing: false, }; do_import_block::<_, _, _, TestJustification>( &client, diff --git a/client/finality-grandpa/src/tests.rs b/client/finality-grandpa/src/tests.rs index fde730e298..2ea15d9022 100644 --- a/client/finality-grandpa/src/tests.rs +++ b/client/finality-grandpa/src/tests.rs @@ -975,6 +975,7 @@ fn allows_reimporting_change_blocks() { auxiliary: Vec::new(), fork_choice: ForkChoiceStrategy::LongestChain, allow_missing_state: false, + import_existing: false, } }; @@ -1028,6 +1029,7 @@ fn test_bad_justification() { auxiliary: Vec::new(), fork_choice: ForkChoiceStrategy::LongestChain, allow_missing_state: false, + import_existing: false, } }; @@ -1738,6 +1740,7 @@ fn imports_justification_for_regular_blocks_on_import() { auxiliary: Vec::new(), fork_choice: ForkChoiceStrategy::LongestChain, allow_missing_state: false, + import_existing: false, }; assert_eq!( diff --git a/client/network/src/protocol/sync.rs b/client/network/src/protocol/sync.rs index 3ee26deab3..affa8cae1e 100644 --- a/client/network/src/protocol/sync.rs +++ b/client/network/src/protocol/sync.rs @@ -662,6 +662,7 @@ impl ChainSync { justification: block_data.block.justification, origin: block_data.origin, allow_missing_state: false, + import_existing: false, } }).collect() } @@ -675,6 +676,7 @@ impl ChainSync { justification: b.justification, origin: Some(who.clone()), allow_missing_state: true, + import_existing: false, } }).collect() } diff --git a/client/network/src/test/block_import.rs b/client/network/src/test/block_import.rs index 6d077dcc6b..16114667ed 100644 --- a/client/network/src/test/block_import.rs +++ b/client/network/src/test/block_import.rs @@ -41,6 +41,7 @@ fn prepare_good_block() -> (TestClient, Hash, u64, PeerId, IncomingBlock) justification, origin: Some(peer_id.clone()), allow_missing_state: false, + import_existing: false, }) } diff --git a/client/network/src/test/mod.rs b/client/network/src/test/mod.rs index e7cc1b103b..31b45d4efe 100644 --- a/client/network/src/test/mod.rs +++ b/client/network/src/test/mod.rs @@ -99,6 +99,7 @@ impl Verifier for PassThroughVerifier { auxiliary: Vec::new(), fork_choice: ForkChoiceStrategy::LongestChain, allow_missing_state: false, + import_existing: false, }, maybe_keys)) } } diff --git a/client/service/src/builder.rs b/client/service/src/builder.rs index 1666257ab9..2f67748337 100644 --- a/client/service/src/builder.rs +++ b/client/service/src/builder.rs @@ -25,7 +25,6 @@ use client_api::{ }; use client::Client; use chain_spec::{RuntimeGenesis, Extension}; -use codec::{Decode, Encode, IoReader}; use consensus_common::import_queue::ImportQueue; use futures::{prelude::*, sync::mpsc}; use futures03::{ @@ -44,8 +43,7 @@ use rpc; use sr_api::ConstructRuntimeApi; use sr_primitives::generic::BlockId; use sr_primitives::traits::{ - Block as BlockT, ProvideRuntimeApi, NumberFor, One, - Zero, Header, SaturatedConversion, + Block as BlockT, ProvideRuntimeApi, NumberFor, Header, SaturatedConversion, }; use substrate_executor::{NativeExecutor, NativeExecutionDispatch}; use std::{ @@ -80,12 +78,12 @@ pub struct ServiceBuilder { config: Configuration, - client: Arc, + pub (crate) client: Arc, backend: Arc, keystore: Arc>, fetcher: Option, select_chain: Option, - import_queue: TImpQu, + pub (crate) import_queue: TImpQu, finality_proof_request_builder: Option, finality_proof_provider: Option, network_protocol: TNetP, @@ -660,21 +658,17 @@ impl Box + Send>; -} - -/// Implemented on `ServiceBuilder`. Allows exporting blocks once you have given all the required -/// components to the builder. -pub trait ServiceBuilderExport { - /// Type of block of the builder. - type Block: BlockT; /// Performs the blocks export. fn export_blocks( @@ -684,85 +678,18 @@ pub trait ServiceBuilderExport { to: Option>, json: bool ) -> Box>; -} - -/// Implemented on `ServiceBuilder`. Allows reverting the chain once you have given all the -/// required components to the builder. -pub trait ServiceBuilderRevert { - /// Type of block of the builder. - type Block: BlockT; - /// Performs a revert of `blocks` bocks. + /// Performs a revert of `blocks` blocks. fn revert_chain( &self, blocks: NumberFor ) -> Result<(), Error>; -} -impl< - TBl, TRtApi, TCfg, TGen, TCSExt, TBackend, - TExec, TFchr, TSc, TImpQu, TFprb, TFpp, TNetP, - TExPool, TRpc, Backend -> ServiceBuilderImport for ServiceBuilder< - TBl, TRtApi, TCfg, TGen, TCSExt, Client, - TFchr, TSc, TImpQu, TFprb, TFpp, TNetP, TExPool, TRpc, Backend -> where - TBl: BlockT::Out>, - TBackend: 'static + client_api::backend::Backend + Send, - TExec: 'static + client::CallExecutor + Send + Sync + Clone, - TImpQu: 'static + ImportQueue, - TRtApi: 'static + Send + Sync, -{ - fn import_blocks( + /// Re-validate known block. + fn check_block( self, - input: impl Read + Seek + Send + 'static, - ) -> Box + Send> { - let client = self.client; - let mut queue = self.import_queue; - Box::new(import_blocks!(TBl, client, queue, input).compat()) - } -} - -impl - ServiceBuilderExport for ServiceBuilder, - TFchr, TSc, TImpQu, TFprb, TFpp, TNetP, TExPool, TRpc, TBackend> -where - TBl: BlockT::Out>, - TBackend: 'static + client_api::backend::Backend + Send, - TExec: 'static + client::CallExecutor + Send + Sync + Clone, - TRtApi: 'static + Send + Sync, -{ - type Block = TBl; - - fn export_blocks( - self, - mut output: impl Write + 'static, - from: NumberFor, - to: Option>, - json: bool - ) -> Box> { - let client = self.client; - Box::new(export_blocks!(client, output, from, to, json).compat()) - } -} - -impl - ServiceBuilderRevert for ServiceBuilder, - TFchr, TSc, TImpQu, TFprb, TFpp, TNetP, TExPool, TRpc, TBackend> -where - TBl: BlockT::Out>, - TBackend: 'static + client_api::backend::Backend + Send, - TExec: 'static + client::CallExecutor + Send + Sync + Clone -{ - type Block = TBl; - - fn revert_chain( - &self, - blocks: NumberFor - ) -> Result<(), Error> { - let client = &self.client; - revert_chain!(client, blocks) - } + block: BlockId + ) -> Box + Send>; } impl diff --git a/client/service/src/chain_ops.rs b/client/service/src/chain_ops.rs index 2ccd120006..239d8df71d 100644 --- a/client/service/src/chain_ops.rs +++ b/client/service/src/chain_ops.rs @@ -17,239 +17,297 @@ //! Chain utilities. use crate::error; +use crate::builder::{ServiceBuilderCommand, ServiceBuilder}; +use crate::error::Error; use chain_spec::{ChainSpec, RuntimeGenesis, Extension}; +use log::{warn, info}; +use futures::{future, prelude::*}; +use futures03::{ + TryFutureExt as _, +}; +use primitives::{Blake2Hasher, Hasher}; +use sr_primitives::traits::{ + Block as BlockT, NumberFor, One, Zero, Header, SaturatedConversion +}; +use sr_primitives::generic::{BlockId, SignedBlock}; +use codec::{Decode, Encode, IoReader}; +use client::Client; +use consensus_common::import_queue::{IncomingBlock, Link, BlockImportError, BlockImportResult, ImportQueue}; +use consensus_common::BlockOrigin; -/// Defines the logic for an operation exporting blocks within a range. -#[macro_export] -/// Export blocks -macro_rules! export_blocks { -($client:ident, $output:ident, $from:ident, $to:ident, $json:ident) => {{ - let mut block = $from; - - let last = match $to { - Some(v) if v.is_zero() => One::one(), - Some(v) => v, - None => $client.info().chain.best_number, - }; - - let mut wrote_header = false; - - // Exporting blocks is implemented as a future, because we want the operation to be - // interruptible. - // - // Every time we write a block to the output, the `Future` re-schedules itself and returns - // `Poll::Pending`. - // This makes it possible either to interleave other operations in-between the block exports, - // or to stop the operation completely. - futures03::future::poll_fn(move |cx| { - if last < block { - return std::task::Poll::Ready(Err("Invalid block range specified".into())); +use std::{ + io::{Read, Write, Seek}, +}; + +use network::message; + +/// Build a chain spec json +pub fn build_spec(spec: ChainSpec, raw: bool) -> error::Result where + G: RuntimeGenesis, + E: Extension, +{ + Ok(spec.to_json(raw)?) +} + +impl< + TBl, TRtApi, TCfg, TGen, TCSExt, TBackend, + TExec, TFchr, TSc, TImpQu, TFprb, TFpp, TNetP, + TExPool, TRpc, Backend +> ServiceBuilderCommand for ServiceBuilder< + TBl, TRtApi, TCfg, TGen, TCSExt, Client, + TFchr, TSc, TImpQu, TFprb, TFpp, TNetP, TExPool, TRpc, Backend +> where + TBl: BlockT::Out>, + TBackend: 'static + client_api::backend::Backend + Send, + TExec: 'static + client::CallExecutor + Send + Sync + Clone, + TImpQu: 'static + ImportQueue, + TRtApi: 'static + Send + Sync, +{ + type Block = TBl; + + fn import_blocks( + self, + input: impl Read + Seek + Send + 'static, + force: bool, + ) -> Box + Send> { + struct WaitLink { + imported_blocks: u64, + has_error: bool, } - if !wrote_header { - info!("Exporting blocks from #{} to #{}", block, last); - if !$json { - let last_: u64 = last.saturated_into::(); - let block_: u64 = block.saturated_into::(); - let len: u64 = last_ - block_ + 1; - $output.write_all(&len.encode())?; + impl WaitLink { + fn new() -> WaitLink { + WaitLink { + imported_blocks: 0, + has_error: false, + } } - wrote_header = true; } - match $client.block(&BlockId::number(block))? { - Some(block) => { - if $json { - serde_json::to_writer(&mut $output, &block) - .map_err(|e| format!("Error writing JSON: {}", e))?; - } else { - $output.write_all(&block.encode())?; + impl Link for WaitLink { + fn blocks_processed( + &mut self, + imported: usize, + _count: usize, + results: Vec<(Result>, BlockImportError>, B::Hash)> + ) { + self.imported_blocks += imported as u64; + + for result in results { + if let (Err(err), hash) = result { + warn!("There was an error importing block with hash {:?}: {:?}", hash, err); + self.has_error = true; + break; + } } - }, - // Reached end of the chain. - None => return std::task::Poll::Ready(Ok(())), - } - if (block % 10000.into()).is_zero() { - info!("#{}", block); - } - if block == last { - return std::task::Poll::Ready(Ok(())); + } } - block += One::one(); - // Re-schedule the task in order to continue the operation. - cx.waker().wake_by_ref(); - std::task::Poll::Pending - }) -}} -} + let client = self.client; + let mut queue = self.import_queue; -/// Defines the logic for an operation importing blocks from some known import. -#[macro_export] -/// Import blocks -macro_rules! import_blocks { -($block:ty, $client:ident, $queue:ident, $input:ident) => {{ - use consensus_common::import_queue::{IncomingBlock, Link, BlockImportError, BlockImportResult}; - use consensus_common::BlockOrigin; - use network::message; - use sr_primitives::generic::SignedBlock; - use sr_primitives::traits::Block; - - struct WaitLink { - imported_blocks: u64, - has_error: bool, - } + let mut io_reader_input = IoReader(input); + let mut count = None::; + let mut read_block_count = 0; + let mut link = WaitLink::new(); - impl WaitLink { - fn new() -> WaitLink { - WaitLink { - imported_blocks: 0, - has_error: false, - } - } - } + // Importing blocks is implemented as a future, because we want the operation to be + // interruptible. + // + // Every time we read a block from the input or import a bunch of blocks from the import + // queue, the `Future` re-schedules itself and returns `Poll::Pending`. + // This makes it possible either to interleave other operations in-between the block imports, + // or to stop the operation completely. + let import = futures03::future::poll_fn(move |cx| { + // Start by reading the number of blocks if not done so already. + let count = match count { + Some(c) => c, + None => { + let c: u64 = match Decode::decode(&mut io_reader_input) { + Ok(c) => c, + Err(err) => { + let err = format!("Error reading file: {}", err); + return std::task::Poll::Ready(Err(From::from(err))); + }, + }; + info!("Importing {} blocks", c); + count = Some(c); + c + } + }; - impl Link for WaitLink { - fn blocks_processed( - &mut self, - imported: usize, - _count: usize, - results: Vec<(Result>, BlockImportError>, B::Hash)> - ) { - self.imported_blocks += imported as u64; - - for result in results { - if let (Err(err), hash) = result { - warn!("There was an error importing block with hash {:?}: {:?}", hash, err); - self.has_error = true; - break; + // Read blocks from the input. + if read_block_count < count { + match SignedBlock::::decode(&mut io_reader_input) { + Ok(signed) => { + let (header, extrinsics) = signed.block.deconstruct(); + let hash = header.hash(); + let block = message::BlockData:: { + hash, + justification: signed.justification, + header: Some(header), + body: Some(extrinsics), + receipt: None, + message_queue: None + }; + // import queue handles verification and importing it into the client + queue.import_blocks(BlockOrigin::File, vec![ + IncomingBlock:: { + hash: block.hash, + header: block.header, + body: block.body, + justification: block.justification, + origin: None, + allow_missing_state: false, + import_existing: force, + } + ]); + } + Err(e) => { + warn!("Error reading block data at {}: {}", read_block_count, e); + return std::task::Poll::Ready(Ok(())); + } } + + read_block_count += 1; + if read_block_count % 1000 == 0 { + info!("#{} blocks were added to the queue", read_block_count); + } + + cx.waker().wake_by_ref(); + return std::task::Poll::Pending; } - } - } - let mut io_reader_input = IoReader($input); - let mut count = None::; - let mut read_block_count = 0; - let mut link = WaitLink::new(); - - // Importing blocks is implemented as a future, because we want the operation to be - // interruptible. - // - // Every time we read a block from the input or import a bunch of blocks from the import - // queue, the `Future` re-schedules itself and returns `Poll::Pending`. - // This makes it possible either to interleave other operations in-between the block imports, - // or to stop the operation completely. - futures03::future::poll_fn(move |cx| { - // Start by reading the number of blocks if not done so already. - let count = match count { - Some(c) => c, - None => { - let c: u64 = match Decode::decode(&mut io_reader_input) { - Ok(c) => c, - Err(err) => { - let err = format!("Error reading file: {}", err); - return std::task::Poll::Ready(Err(From::from(err))); - }, - }; - info!("Importing {} blocks", c); - count = Some(c); - c + let blocks_before = link.imported_blocks; + queue.poll_actions(cx, &mut link); + + if link.has_error { + info!( + "Stopping after #{} blocks because of an error", + link.imported_blocks, + ); + return std::task::Poll::Ready(Ok(())); + } + + if link.imported_blocks / 1000 != blocks_before / 1000 { + info!( + "#{} blocks were imported (#{} left)", + link.imported_blocks, + count - link.imported_blocks + ); + } + + if link.imported_blocks >= count { + info!("Imported {} blocks. Best: #{}", read_block_count, client.info().chain.best_number); + return std::task::Poll::Ready(Ok(())); + + } else { + // Polling the import queue will re-schedule the task when ready. + return std::task::Poll::Pending; } + }); + Box::new(import.compat()) + } + + fn export_blocks( + self, + mut output: impl Write + 'static, + from: NumberFor, + to: Option>, + json: bool + ) -> Box> { + let client = self.client; + let mut block = from; + + let last = match to { + Some(v) if v.is_zero() => One::one(), + Some(v) => v, + None => client.info().chain.best_number, }; - // Read blocks from the input. - if read_block_count < count { - match SignedBlock::<$block>::decode(&mut io_reader_input) { - Ok(signed) => { - let (header, extrinsics) = signed.block.deconstruct(); - let hash = header.hash(); - let block = message::BlockData::<$block> { - hash, - justification: signed.justification, - header: Some(header), - body: Some(extrinsics), - receipt: None, - message_queue: None - }; - // import queue handles verification and importing it into the client - $queue.import_blocks(BlockOrigin::File, vec![ - IncomingBlock::<$block> { - hash: block.hash, - header: block.header, - body: block.body, - justification: block.justification, - origin: None, - allow_missing_state: false, - } - ]); - } - Err(e) => { - warn!("Error reading block data at {}: {}", read_block_count, e); - return std::task::Poll::Ready(Ok(())); + let mut wrote_header = false; + + // Exporting blocks is implemented as a future, because we want the operation to be + // interruptible. + // + // Every time we write a block to the output, the `Future` re-schedules itself and returns + // `Poll::Pending`. + // This makes it possible either to interleave other operations in-between the block exports, + // or to stop the operation completely. + let export = futures03::future::poll_fn(move |cx| { + if last < block { + return std::task::Poll::Ready(Err("Invalid block range specified".into())); + } + + if !wrote_header { + info!("Exporting blocks from #{} to #{}", block, last); + if !json { + let last_: u64 = last.saturated_into::(); + let block_: u64 = block.saturated_into::(); + let len: u64 = last_ - block_ + 1; + output.write_all(&len.encode())?; } + wrote_header = true; } - read_block_count += 1; - if read_block_count % 1000 == 0 { - info!("#{} blocks were added to the queue", read_block_count); + match client.block(&BlockId::number(block))? { + Some(block) => { + if json { + serde_json::to_writer(&mut output, &block) + .map_err(|e| format!("Error writing JSON: {}", e))?; + } else { + output.write_all(&block.encode())?; + } + }, + // Reached end of the chain. + None => return std::task::Poll::Ready(Ok(())), } + if (block % 10000.into()).is_zero() { + info!("#{}", block); + } + if block == last { + return std::task::Poll::Ready(Ok(())); + } + block += One::one(); + // Re-schedule the task in order to continue the operation. cx.waker().wake_by_ref(); - return std::task::Poll::Pending; - } - - let blocks_before = link.imported_blocks; - $queue.poll_actions(cx, &mut link); + std::task::Poll::Pending + }); - if link.has_error { - info!( - "Stopping after #{} blocks because of an error", - link.imported_blocks, - ); - return std::task::Poll::Ready(Ok(())); - } - - if link.imported_blocks / 1000 != blocks_before / 1000 { - info!( - "#{} blocks were imported (#{} left)", - link.imported_blocks, - count - link.imported_blocks - ); - } + Box::new(export.compat()) + } - if link.imported_blocks >= count { - info!("Imported {} blocks. Best: #{}", read_block_count, $client.info().chain.best_number); - return std::task::Poll::Ready(Ok(())); + fn revert_chain( + &self, + blocks: NumberFor + ) -> Result<(), Error> { + let reverted = self.client.revert(blocks)?; + let info = self.client.info().chain; + if reverted.is_zero() { + info!("There aren't any non-finalized blocks to revert."); } else { - // Polling the import queue will re-schedule the task when ready. - return std::task::Poll::Pending; + info!("Reverted {} blocks. Best: #{} ({})", reverted, info.best_number, info.best_hash); } - }) -}} -} + Ok(()) + } -/// Revert the chain some number of blocks. -#[macro_export] -macro_rules! revert_chain { -($client:ident, $blocks:ident) => {{ - let reverted = $client.revert($blocks)?; - let info = $client.info().chain; - - if reverted.is_zero() { - info!("There aren't any non-finalized blocks to revert."); - } else { - info!("Reverted {} blocks. Best: #{} ({})", reverted, info.best_number, info.best_hash); + fn check_block( + self, + block_id: BlockId + ) -> Box + Send> { + match self.client.block(&block_id) { + Ok(Some(block)) => { + let mut buf = Vec::new(); + 1u64.encode_to(&mut buf); + block.encode_to(&mut buf); + let reader = std::io::Cursor::new(buf); + self.import_blocks(reader, true) + } + Ok(None) => Box::new(future::err("Unknown block".into())), + Err(e) => Box::new(future::err(format!("Error reading block: {:?}", e).into())), + } } - Ok(()) -}} } -/// Build a chain spec json -pub fn build_spec(spec: ChainSpec, raw: bool) -> error::Result where - G: RuntimeGenesis, - E: Extension, -{ - Ok(spec.to_json(raw)?) -} diff --git a/client/service/src/lib.rs b/client/service/src/lib.rs index 0291dd1d51..2115fd50a7 100644 --- a/client/service/src/lib.rs +++ b/client/service/src/lib.rs @@ -53,9 +53,7 @@ use sr_primitives::generic::BlockId; use sr_primitives::traits::{NumberFor, Block as BlockT}; pub use self::error::Error; -pub use self::builder::{ - ServiceBuilder, ServiceBuilderExport, ServiceBuilderImport, ServiceBuilderRevert, -}; +pub use self::builder::{ServiceBuilder, ServiceBuilderCommand}; pub use config::{Configuration, Roles, PruningMode}; pub use chain_spec::{ChainSpec, Properties, RuntimeGenesis, Extension as ChainSpecExtension}; pub use txpool_api::{TransactionPool, TransactionPoolMaintainer, InPoolTransaction, IntoPoolError}; diff --git a/client/src/client.rs b/client/src/client.rs index ea30948458..171a27223a 100644 --- a/client/src/client.rs +++ b/client/src/client.rs @@ -756,6 +756,7 @@ impl Client where auxiliary, fork_choice, allow_missing_state, + import_existing, } = import_block; assert!(justification.is_some() && finalized || justification.is_none()); @@ -800,6 +801,7 @@ impl Client where auxiliary, fork_choice, enact_state, + import_existing, ); if let Ok(ImportResult::Imported(ref aux)) = result { @@ -828,13 +830,17 @@ impl Client where aux: Vec<(Vec, Option>)>, fork_choice: ForkChoiceStrategy, enact_state: bool, + import_existing: bool, ) -> sp_blockchain::Result where E: CallExecutor + Send + Sync + Clone, { let parent_hash = import_headers.post().parent_hash().clone(); - match self.backend.blockchain().status(BlockId::Hash(hash))? { - blockchain::BlockStatus::InChain => return Ok(ImportResult::AlreadyInChain), - blockchain::BlockStatus::Unknown => {}, + let status = self.backend.blockchain().status(BlockId::Hash(hash))?; + match (import_existing, status) { + (false, blockchain::BlockStatus::InChain) => return Ok(ImportResult::AlreadyInChain), + (false, blockchain::BlockStatus::Unknown) => {}, + (true, blockchain::BlockStatus::InChain) => {}, + (true, blockchain::BlockStatus::Unknown) => return Err(Error::UnknownBlock(format!("{:?}", hash))), } let info = self.backend.blockchain().info(); @@ -1454,7 +1460,7 @@ impl<'a, B, E, Block, RA> consensus::BlockImport for &'a Client, ) -> Result { - let BlockCheckParams { hash, number, parent_hash, allow_missing_state } = block; + let BlockCheckParams { hash, number, parent_hash, allow_missing_state, import_existing } = block; if let Some(h) = self.fork_blocks.as_ref().and_then(|x| x.get(&number)) { if &hash != h { @@ -1473,7 +1479,8 @@ impl<'a, B, E, Block, RA> consensus::BlockImport for &'a Client return Ok(ImportResult::AlreadyInChain), + BlockStatus::InChainWithState | BlockStatus::Queued if !import_existing => return Ok(ImportResult::AlreadyInChain), + BlockStatus::InChainWithState | BlockStatus::Queued => {}, BlockStatus::InChainPruned => return Ok(ImportResult::AlreadyInChain), BlockStatus::Unknown => {}, BlockStatus::KnownBad => return Ok(ImportResult::KnownBad), @@ -2773,7 +2780,8 @@ pub(crate) mod tests { hash: a1.hash().clone(), number: 0, parent_hash: a1.header().parent_hash().clone(), - allow_missing_state: false + allow_missing_state: false, + import_existing: false, }; assert_eq!(client.check_block(check_block_a1.clone()).unwrap(), ImportResult::imported(false)); @@ -2792,7 +2800,8 @@ pub(crate) mod tests { hash: a2.hash().clone(), number: 1, parent_hash: a1.header().parent_hash().clone(), - allow_missing_state: false + allow_missing_state: false, + import_existing: false, }; assert_eq!(client.check_block(check_block_a1.clone()).unwrap(), ImportResult::AlreadyInChain); @@ -2808,7 +2817,8 @@ pub(crate) mod tests { hash: a3.hash().clone(), number: 2, parent_hash: a2.header().parent_hash().clone(), - allow_missing_state: false + allow_missing_state: false, + import_existing: false, }; // a1 and a2 are both pruned at this point @@ -2823,7 +2833,8 @@ pub(crate) mod tests { hash: b1.hash().clone(), number: 0, parent_hash: b1.header().parent_hash().clone(), - allow_missing_state: false + allow_missing_state: false, + import_existing: false, }; assert_eq!(client.check_block(check_block_b1.clone()).unwrap(), ImportResult::MissingState); check_block_b1.allow_missing_state = true; diff --git a/primitives/consensus/common/src/block_import.rs b/primitives/consensus/common/src/block_import.rs index 79d9be7b84..344a79167b 100644 --- a/primitives/consensus/common/src/block_import.rs +++ b/primitives/consensus/common/src/block_import.rs @@ -105,6 +105,8 @@ pub struct BlockCheckParams { pub parent_hash: Block::Hash, /// Allow importing the block skipping state verification if parent state is missing. pub allow_missing_state: bool, + /// Re-validate existing block. + pub import_existing: bool, } /// Data required to import a Block. @@ -142,6 +144,8 @@ pub struct BlockImportParams { pub fork_choice: ForkChoiceStrategy, /// Allow importing the block skipping state verification if parent state is missing. pub allow_missing_state: bool, + /// Re-validate existing block. + pub import_existing: bool, } impl BlockImportParams { diff --git a/primitives/consensus/common/src/import_queue.rs b/primitives/consensus/common/src/import_queue.rs index 4bc986e1a3..614609cc53 100644 --- a/primitives/consensus/common/src/import_queue.rs +++ b/primitives/consensus/common/src/import_queue.rs @@ -65,6 +65,8 @@ pub struct IncomingBlock { pub origin: Option, /// Allow importing the block skipping state verification if parent state is missing. pub allow_missing_state: bool, + /// Re-validate existing block. + pub import_existing: bool, } /// Type of keys in the blockchain cache that consensus module could use for its needs. @@ -230,6 +232,7 @@ pub fn import_single_block>( number, parent_hash, allow_missing_state: block.allow_missing_state, + import_existing: block.import_existing, }))? { BlockImportResult::ImportedUnknown { .. } => (), r => return Ok(r), // Any other successful result means that the block is already imported. diff --git a/test/utils/client/src/client_ext.rs b/test/utils/client/src/client_ext.rs index 78ed619a0d..39010070e1 100644 --- a/test/utils/client/src/client_ext.rs +++ b/test/utils/client/src/client_ext.rs @@ -83,6 +83,7 @@ impl ClientExt for Client auxiliary: Vec::new(), fork_choice: ForkChoiceStrategy::LongestChain, allow_missing_state: false, + import_existing: false, }; BlockImport::import_block(&mut (&*self), import, HashMap::new()).map(|_| ()) @@ -102,6 +103,7 @@ impl ClientExt for Client auxiliary: Vec::new(), fork_choice: ForkChoiceStrategy::Custom(true), allow_missing_state: false, + import_existing: false, }; BlockImport::import_block(&mut (&*self), import, HashMap::new()).map(|_| ()) @@ -121,6 +123,7 @@ impl ClientExt for Client auxiliary: Vec::new(), fork_choice: ForkChoiceStrategy::Custom(true), allow_missing_state: false, + import_existing: false, }; BlockImport::import_block(&mut (&*self), import, HashMap::new()).map(|_| ()) @@ -143,6 +146,7 @@ impl ClientExt for Client auxiliary: Vec::new(), fork_choice: ForkChoiceStrategy::LongestChain, allow_missing_state: false, + import_existing: false, }; BlockImport::import_block(&mut (&*self), import, HashMap::new()).map(|_| ()) diff --git a/test/utils/transaction-factory/src/lib.rs b/test/utils/transaction-factory/src/lib.rs index f6f895fd22..cab30b9a40 100644 --- a/test/utils/transaction-factory/src/lib.rs +++ b/test/utils/transaction-factory/src/lib.rs @@ -199,6 +199,7 @@ fn import_block( auxiliary: Vec::new(), fork_choice: ForkChoiceStrategy::LongestChain, allow_missing_state: false, + import_existing: false, }; (&**client).import_block(import, HashMap::new()).expect("Failed to import block"); } -- GitLab From d9fca7e325dce0d77c121b9d54a5b96268509782 Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Thu, 28 Nov 2019 14:45:09 +0000 Subject: [PATCH 042/172] Commission is stated as percent of rewards (#4243) --- frame/staking/src/lib.rs | 20 ++++++++++---------- frame/staking/src/tests.rs | 7 +++---- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/frame/staking/src/lib.rs b/frame/staking/src/lib.rs index aeeda48593..b2fb0c6e31 100644 --- a/frame/staking/src/lib.rs +++ b/frame/staking/src/lib.rs @@ -187,7 +187,7 @@ //! The validator and its nominator split their reward as following: //! //! The validator can declare an amount, named -//! [`validator_payment`](./struct.ValidatorPrefs.html#structfield.validator_payment), that does not +//! [`commission`](./struct.ValidatorPrefs.html#structfield.commission), that does not //! get shared with the nominators at each reward payout through its //! [`ValidatorPrefs`](./struct.ValidatorPrefs.html). This value gets deducted from the total reward //! that is paid to the validator and its nominators. The remaining portion is split among the @@ -347,19 +347,19 @@ impl Default for RewardDestination { } } -/// Preference of what happens on a slash event. +/// Preference of what happens regarding validation. #[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug)] -pub struct ValidatorPrefs { +pub struct ValidatorPrefs { /// Reward that validator takes up-front; only the rest is split between themselves and /// nominators. #[codec(compact)] - pub validator_payment: Balance, + pub commission: Perbill, } -impl Default for ValidatorPrefs { +impl Default for ValidatorPrefs { fn default() -> Self { ValidatorPrefs { - validator_payment: Default::default(), + commission: Default::default(), } } } @@ -657,7 +657,7 @@ decl_storage! { pub Payee get(fn payee): map T::AccountId => RewardDestination; /// The map from (wannabe) validator stash key to the preferences of that validator. - pub Validators get(fn validators): linked_map T::AccountId => ValidatorPrefs>; + pub Validators get(fn validators): linked_map T::AccountId => ValidatorPrefs; /// The map from nominator stash key to the set of stash keys of all validators to nominate. /// @@ -982,7 +982,7 @@ decl_module! { /// - Writes are limited to the `origin` account key. /// # #[weight = SimpleDispatchInfo::FixedNormal(750_000)] - fn validate(origin, prefs: ValidatorPrefs>) { + fn validate(origin, prefs: ValidatorPrefs) { Self::ensure_storage_upgraded(); let controller = ensure_signed(origin)?; @@ -1252,8 +1252,8 @@ impl Module { /// nominators' balance, pro-rata based on their exposure, after having removed the validator's /// pre-payout cut. fn reward_validator(stash: &T::AccountId, reward: BalanceOf) -> PositiveImbalanceOf { - let off_the_table = reward.min(Self::validators(stash).validator_payment); - let reward = reward - off_the_table; + let off_the_table = Self::validators(stash).commission * reward; + let reward = reward.saturating_sub(off_the_table); let mut imbalance = >::zero(); let validator_cut = if reward.is_zero() { Zero::zero() diff --git a/frame/staking/src/tests.rs b/frame/staking/src/tests.rs index 7e1939e437..65fcd38507 100644 --- a/frame/staking/src/tests.rs +++ b/frame/staking/src/tests.rs @@ -965,7 +965,6 @@ fn validator_payment_prefs_work() { // This test will focus on validator payment. ExtBuilder::default().build().execute_with(|| { // Initial config - let validator_cut = 5; let stash_initial_balance = Balances::total_balance(&11); // check the balance of a validator accounts. @@ -983,7 +982,7 @@ fn validator_payment_prefs_work() { }); >::insert(&2, RewardDestination::Stash); >::insert(&11, ValidatorPrefs { - validator_payment: validator_cut + commission: Perbill::from_percent(50), }); // Compute total payout now for whole duration as other parameter won't change @@ -994,9 +993,9 @@ fn validator_payment_prefs_work() { start_era(1); // whats left to be shared is the sum of 3 rounds minus the validator's cut. - let shared_cut = total_payout_0 - validator_cut; + let shared_cut = total_payout_0 / 2; // Validator's payee is Staked account, 11, reward will be paid here. - assert_eq!(Balances::total_balance(&11), stash_initial_balance + shared_cut / 2 + validator_cut); + assert_eq!(Balances::total_balance(&11), stash_initial_balance + shared_cut / 2 + shared_cut); // Controller account will not get any reward. assert_eq!(Balances::total_balance(&10), 1); // Rest of the reward will be shared and paid to the nominator in stake. -- GitLab From ac56b134ceff7aea2c109ebfce1e4b338ae04705 Mon Sep 17 00:00:00 2001 From: Arkadiy Paronyan Date: Fri, 29 Nov 2019 09:09:12 +0100 Subject: [PATCH 043/172] Fixed node binary (#4244) * Fixed node binary * Remove extra params --- bin/node/cli/src/cli.rs | 25 +++++++------------------ client/cli/src/lib.rs | 18 ++++++++++-------- client/cli/src/params.rs | 16 ++++++++++++++++ 3 files changed, 33 insertions(+), 26 deletions(-) diff --git a/bin/node/cli/src/cli.rs b/bin/node/cli/src/cli.rs index aaa02dcc2b..3a83c3eb76 100644 --- a/bin/node/cli/src/cli.rs +++ b/bin/node/cli/src/cli.rs @@ -14,10 +14,10 @@ // You should have received a copy of the GNU General Public License // along with Substrate. If not, see . -pub use substrate_cli::error; +pub use substrate_cli::VersionInfo; use tokio::prelude::Future; use tokio::runtime::{Builder as RuntimeBuilder, Runtime}; -pub use substrate_cli::{VersionInfo, IntoExit, NoCustom, SharedParams, ExecutionStrategyParam}; +use substrate_cli::{IntoExit, NoCustom, SharedParams, ImportParams, error}; use substrate_service::{AbstractService, Roles as ServiceRoles, Configuration}; use log::info; use structopt::{StructOpt, clap::App}; @@ -25,7 +25,6 @@ use substrate_cli::{display_role, parse_and_prepare, AugmentClap, GetLogFilter, use crate::{service, ChainSpec, load_spec}; use crate::factory_impl::FactoryState; use transaction_factory::RuntimeAdapter; -use client::ExecutionStrategies; /// Custom subcommands. #[derive(Clone, Debug, StructOpt)] @@ -82,15 +81,9 @@ pub struct FactoryCmd { #[structopt(flatten)] pub shared_params: SharedParams, - /// The means of execution used when calling into the runtime while importing blocks. - #[structopt( - long = "execution", - value_name = "STRATEGY", - possible_values = &ExecutionStrategyParam::variants(), - case_insensitive = true, - default_value = "NativeElseWasm" - )] - pub execution: ExecutionStrategyParam, + #[allow(missing_docs)] + #[structopt(flatten)] + pub import_params: ImportParams, } impl AugmentClap for FactoryCmd { @@ -147,12 +140,8 @@ pub fn run(args: I, exit: E, version: substrate_cli::VersionInfo) -> er &cli_args.shared_params, &version, )?; - config.execution_strategies = ExecutionStrategies { - importing: cli_args.execution.into(), - block_construction: cli_args.execution.into(), - other: cli_args.execution.into(), - ..Default::default() - }; + + substrate_cli::fill_import_params(&mut config, &cli_args.import_params, ServiceRoles::FULL)?; match ChainSpec::from(config.chain_spec.id()) { Some(ref c) if c == &ChainSpec::Development || c == &ChainSpec::LocalTestnet => {}, diff --git a/client/cli/src/lib.rs b/client/cli/src/lib.rs index 08012ec627..4d8b9830c8 100644 --- a/client/cli/src/lib.rs +++ b/client/cli/src/lib.rs @@ -56,7 +56,7 @@ use params::{ NetworkConfigurationParams, MergeParameters, TransactionPoolParams, NodeKeyParams, NodeKeyType, Cors, CheckBlockCmd, }; -pub use params::{NoCustom, CoreParams, SharedParams, ExecutionStrategy as ExecutionStrategyParam}; +pub use params::{NoCustom, CoreParams, SharedParams, ImportParams, ExecutionStrategy}; pub use traits::{GetLogFilter, AugmentClap}; use app_dirs::{AppInfo, AppDataType}; use log::info; @@ -440,7 +440,8 @@ impl<'a> ParseAndPrepareImport<'a> { E: ChainSpecExtension, Exit: IntoExit { - let config = create_config_with_db_path(spec_factory, &self.params.shared_params, self.version)?; + let mut config = create_config_with_db_path(spec_factory, &self.params.shared_params, self.version)?; + fill_import_params(&mut config, &self.params.import_params, service::Roles::FULL)?; let file: Box = match self.params.input { Some(filename) => Box::new(File::open(filename)?), @@ -499,7 +500,8 @@ impl<'a> CheckBlock<'a> { E: ChainSpecExtension, Exit: IntoExit { - let config = create_config_with_db_path(spec_factory, &self.params.shared_params, self.version)?; + let mut config = create_config_with_db_path(spec_factory, &self.params.shared_params, self.version)?; + fill_import_params(&mut config, &self.params.import_params, service::Roles::FULL)?; let input = if self.params.input.starts_with("0x") { &self.params.input[2..] } else { &self.params.input[..] }; let block_id = match FromStr::from_str(input) { @@ -738,7 +740,8 @@ fn fill_config_keystore_password( Ok(()) } -fn fill_shared_config(config: &mut Configuration, cli: &SharedParams, role: service::Roles) +/// Put block import CLI params into `config` object. +pub fn fill_import_params(config: &mut Configuration, cli: &ImportParams, role: service::Roles) -> error::Result<()> where C: Default, @@ -776,7 +779,7 @@ where config.wasm_method = cli.wasm_method.into(); let exec = &cli.execution_strategies; - let exec_all_or = |strat: params::ExecutionStrategy| exec.execution.unwrap_or(strat).into(); + let exec_all_or = |strat: ExecutionStrategy| exec.execution.unwrap_or(strat).into(); config.execution_strategies = ExecutionStrategies { syncing: exec_all_or(exec.execution_syncing), importing: exec_all_or(exec.execution_import_block), @@ -813,7 +816,7 @@ where service::Roles::FULL }; - fill_shared_config(&mut config, &cli.shared_params, role)?; + fill_import_params(&mut config, &cli.import_params, role)?; config.impl_name = impl_name; config.impl_commit = version.commit; @@ -924,8 +927,7 @@ where let spec = load_spec(cli, spec_factory)?; let base_path = base_path(cli, version); - let mut config = service::Configuration::default_with_spec_and_base_path(spec.clone(), Some(base_path)); - fill_shared_config(&mut config, &cli, service::Roles::FULL)?; + let config = service::Configuration::default_with_spec_and_base_path(spec.clone(), Some(base_path)); Ok(config) } diff --git a/client/cli/src/params.rs b/client/cli/src/params.rs index 6657556551..2ad6a9ea55 100644 --- a/client/cli/src/params.rs +++ b/client/cli/src/params.rs @@ -109,7 +109,11 @@ pub struct SharedParams { /// Sets a custom logging filter. #[structopt(short = "l", long = "log", value_name = "LOG_PATTERN")] pub log: Option, +} +/// Parameters for block import. +#[derive(Debug, StructOpt, Clone)] +pub struct ImportParams { /// Specify the state pruning mode, a number of blocks to keep or 'archive'. /// /// Default is to keep all block states if the node is running as a @@ -505,6 +509,10 @@ pub struct RunCmd { #[structopt(flatten)] pub shared_params: SharedParams, + #[allow(missing_docs)] + #[structopt(flatten)] + pub import_params: ImportParams, + #[allow(missing_docs)] #[structopt(flatten)] pub network_config: NetworkConfigurationParams, @@ -764,6 +772,10 @@ pub struct ImportBlocksCmd { #[allow(missing_docs)] #[structopt(flatten)] pub shared_params: SharedParams, + + #[allow(missing_docs)] + #[structopt(flatten)] + pub import_params: ImportParams, } impl_get_log_filter!(ImportBlocksCmd); @@ -784,6 +796,10 @@ pub struct CheckBlockCmd { #[allow(missing_docs)] #[structopt(flatten)] pub shared_params: SharedParams, + + #[allow(missing_docs)] + #[structopt(flatten)] + pub import_params: ImportParams, } impl_get_log_filter!(CheckBlockCmd); -- GitLab From 93aabb7fd9d3ff62ea09a2c684322ac7caf93356 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Fri, 29 Nov 2019 11:01:11 +0100 Subject: [PATCH 044/172] Check in block authoring that we can author with current authoring version (#4201) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Check in block authoring that we can author with current authoring version * Update client/consensus/pow/src/lib.rs Co-Authored-By: André Silva * Fix compilation --- Cargo.lock | 1 + bin/node-template/Cargo.toml | 1 + bin/node-template/src/service.rs | 6 ++- bin/node/cli/Cargo.toml | 2 +- bin/node/cli/src/service.rs | 4 ++ client/consensus/aura/src/lib.rs | 16 +++++--- client/consensus/babe/src/lib.rs | 14 +++++-- client/consensus/babe/src/tests.rs | 1 + client/consensus/pow/src/lib.rs | 24 ++++++++++-- client/consensus/slots/src/lib.rs | 32 ++++++++++----- client/executor/src/lib.rs | 5 +-- client/executor/src/native_executor.rs | 12 ++---- client/rpc/src/state/state_light.rs | 5 ++- client/src/call_executor.rs | 28 ++++++++++--- client/src/client.rs | 7 ++-- primitives/blockchain/src/error.rs | 13 ++----- primitives/consensus/common/src/lib.rs | 54 ++++++++++++++++++++++++-- primitives/sr-version/src/lib.rs | 24 ++++++++++++ 18 files changed, 187 insertions(+), 62 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 95f5217e33..29ba292790 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3177,6 +3177,7 @@ dependencies = [ "substrate-client 2.0.0", "substrate-consensus-aura 2.0.0", "substrate-consensus-aura-primitives 2.0.0", + "substrate-consensus-common 2.0.0", "substrate-executor 2.0.0", "substrate-finality-grandpa 2.0.0", "substrate-finality-grandpa-primitives 2.0.0", diff --git a/bin/node-template/Cargo.toml b/bin/node-template/Cargo.toml index 9fc248fe80..09b438a0ac 100644 --- a/bin/node-template/Cargo.toml +++ b/bin/node-template/Cargo.toml @@ -29,6 +29,7 @@ txpool-api = { package = "sp-transaction-pool-api", path = "../../primitives/tra network = { package = "substrate-network", path = "../../client/network" } aura = { package = "substrate-consensus-aura", path = "../../client/consensus/aura" } aura-primitives = { package = "substrate-consensus-aura-primitives", path = "../../primitives/consensus/aura" } +consensus-common = { package = "substrate-consensus-common", path = "../../primitives/consensus/common" } grandpa = { package = "substrate-finality-grandpa", path = "../../client/finality-grandpa" } grandpa-primitives = { package = "substrate-finality-grandpa-primitives", path = "../../primitives/finality-grandpa" } substrate-client = { path = "../../client/" } diff --git a/bin/node-template/src/service.rs b/bin/node-template/src/service.rs index 5a04459ef3..6fd4daed69 100644 --- a/bin/node-template/src/service.rs +++ b/bin/node-template/src/service.rs @@ -111,7 +111,10 @@ pub fn new_full(config: Configuration( + let can_author_with = + consensus_common::CanAuthorWithNativeVersion::new(client.executor().clone()); + + let aura = aura::start_aura::<_, _, _, _, _, AuraPair, _, _, _, _>( aura::SlotDuration::get_or_compute(&*client)?, client, select_chain, @@ -121,6 +124,7 @@ pub fn new_full(config: Configuration( +pub fn start_aura( slot_duration: SlotDuration, client: Arc, select_chain: SC, @@ -153,6 +153,7 @@ pub fn start_aura( inherent_data_providers: InherentDataProviders, force_authoring: bool, keystore: KeyStorePtr, + can_author_with: CAW, ) -> Result, consensus_common::Error> where B: BlockT, C: ProvideRuntimeApi + BlockOf + ProvideCache + AuxStore + Send + Sync, @@ -168,6 +169,7 @@ pub fn start_aura( I: BlockImport + Send + Sync + 'static, Error: ::std::error::Error + Send + From<::consensus_common::Error> + From + 'static, SO: SyncOracle + Send + Sync + Clone, + CAW: CanAuthorWith + Send, { let worker = AuraWorker { client: client.clone(), @@ -182,13 +184,14 @@ pub fn start_aura( &inherent_data_providers, slot_duration.0.slot_duration() )?; - Ok(slots::start_slot_worker::<_, _, _, _, _, AuraSlotCompatible>( + Ok(slots::start_slot_worker::<_, _, _, _, _, AuraSlotCompatible, _>( slot_duration.0, select_chain, worker, sync_oracle, inherent_data_providers, AuraSlotCompatible, + can_author_with, ).map(|()| Ok::<(), ()>(())).compat()) } @@ -864,7 +867,7 @@ mod tests { &inherent_data_providers, slot_duration.get() ).expect("Registers aura inherent data provider"); - let aura = start_aura::<_, _, _, _, _, AuthorityPair, _, _, _>( + let aura = start_aura::<_, _, _, _, _, AuthorityPair, _, _, _, _>( slot_duration, client.clone(), select_chain, @@ -874,6 +877,7 @@ mod tests { inherent_data_providers, false, keystore, + consensus_common::AlwaysCanAuthor, ).expect("Starts aura"); runtime.spawn(aura); diff --git a/client/consensus/babe/src/lib.rs b/client/consensus/babe/src/lib.rs index b4c2aff549..026a49a160 100644 --- a/client/consensus/babe/src/lib.rs +++ b/client/consensus/babe/src/lib.rs @@ -65,7 +65,7 @@ pub use babe_primitives::{ pub use consensus_common::SyncOracle; use std::{collections::HashMap, sync::Arc, u64, pin::Pin, time::{Instant, Duration}}; use babe_primitives; -use consensus_common::ImportResult; +use consensus_common::{ImportResult, CanAuthorWith}; use consensus_common::import_queue::{ BoxJustificationImport, BoxFinalityProofImport, }; @@ -241,7 +241,7 @@ impl std::ops::Deref for Config { } /// Parameters for BABE. -pub struct BabeParams { +pub struct BabeParams { /// The keystore that manages the keys of the node. pub keystore: KeyStorePtr, @@ -270,10 +270,13 @@ pub struct BabeParams { /// The source of timestamps for relative slots pub babe_link: BabeLink, + + /// Checks if the current native implementation can author with a runtime at a given block. + pub can_author_with: CAW, } /// Start the babe worker. The returned future should be run in a tokio runtime. -pub fn start_babe(BabeParams { +pub fn start_babe(BabeParams { keystore, client, select_chain, @@ -283,7 +286,8 @@ pub fn start_babe(BabeParams { inherent_data_providers, force_authoring, babe_link, -}: BabeParams) -> Result< + can_author_with, +}: BabeParams) -> Result< impl futures01::Future, consensus_common::Error, > where @@ -298,6 +302,7 @@ pub fn start_babe(BabeParams { I: BlockImport + Send + Sync + 'static, Error: std::error::Error + Send + From<::consensus_common::Error> + From + 'static, SO: SyncOracle + Send + Sync + Clone, + CAW: CanAuthorWith + Send, { let config = babe_link.config; let worker = BabeWorker { @@ -326,6 +331,7 @@ pub fn start_babe(BabeParams { sync_oracle, inherent_data_providers, babe_link.time_source, + can_author_with, ); Ok(slot_worker.map(|_| Ok::<(), ()>(())).compat()) diff --git a/client/consensus/babe/src/tests.rs b/client/consensus/babe/src/tests.rs index 7be6679bef..405443bc13 100644 --- a/client/consensus/babe/src/tests.rs +++ b/client/consensus/babe/src/tests.rs @@ -404,6 +404,7 @@ fn run_one_test( force_authoring: false, babe_link: data.link.clone(), keystore, + can_author_with: consensus_common::AlwaysCanAuthor, }).expect("Starts babe")); } diff --git a/client/consensus/pow/src/lib.rs b/client/consensus/pow/src/lib.rs index 067861d7c9..914d484da7 100644 --- a/client/consensus/pow/src/lib.rs +++ b/client/consensus/pow/src/lib.rs @@ -44,7 +44,7 @@ use primitives::H256; use inherents::{InherentDataProviders, InherentData}; use consensus_common::{ BlockImportParams, BlockOrigin, ForkChoiceStrategy, SyncOracle, Environment, Proposer, - SelectChain, Error as ConsensusError + SelectChain, Error as ConsensusError, CanAuthorWith, }; use consensus_common::import_queue::{BoxBlockImport, BasicQueue, Verifier}; use codec::{Encode, Decode}; @@ -372,7 +372,7 @@ pub fn import_queue( /// information, or just be a graffiti. `round` is for number of rounds the /// CPU miner runs each time. This parameter should be tweaked so that each /// mining round is within sub-second time. -pub fn start_mine, C, Algorithm, E, SO, S>( +pub fn start_mine, C, Algorithm, E, SO, S, CAW>( mut block_import: BoxBlockImport, client: Arc, algorithm: Algorithm, @@ -383,6 +383,7 @@ pub fn start_mine, C, Algorithm, E, SO, S>( build_time: std::time::Duration, select_chain: Option, inherent_data_providers: inherents::InherentDataProviders, + can_author_with: CAW, ) where C: HeaderBackend + AuxStore + 'static, Algorithm: PowAlgorithm + Send + Sync + 'static, @@ -390,6 +391,7 @@ pub fn start_mine, C, Algorithm, E, SO, S>( E::Error: std::fmt::Debug, SO: SyncOracle + Send + Sync + 'static, S: SelectChain + 'static, + CAW: CanAuthorWith + Send + 'static, { if let Err(_) = register_pow_inherent_data_provider(&inherent_data_providers) { warn!("Registering inherent data provider for timestamp failed"); @@ -407,7 +409,8 @@ pub fn start_mine, C, Algorithm, E, SO, S>( &mut sync_oracle, build_time.clone(), select_chain.as_ref(), - &inherent_data_providers + &inherent_data_providers, + &can_author_with, ) { Ok(()) => (), Err(e) => error!( @@ -420,7 +423,7 @@ pub fn start_mine, C, Algorithm, E, SO, S>( }); } -fn mine_loop, C, Algorithm, E, SO, S>( +fn mine_loop, C, Algorithm, E, SO, S, CAW>( block_import: &mut BoxBlockImport, client: &C, algorithm: &Algorithm, @@ -431,6 +434,7 @@ fn mine_loop, C, Algorithm, E, SO, S>( build_time: std::time::Duration, select_chain: Option<&S>, inherent_data_providers: &inherents::InherentDataProviders, + can_author_with: &CAW, ) -> Result<(), Error> where C: HeaderBackend + AuxStore, Algorithm: PowAlgorithm, @@ -438,6 +442,7 @@ fn mine_loop, C, Algorithm, E, SO, S>( E::Error: std::fmt::Debug, SO: SyncOracle, S: SelectChain, + CAW: CanAuthorWith, { 'outer: loop { if sync_oracle.is_major_syncing() { @@ -461,6 +466,17 @@ fn mine_loop, C, Algorithm, E, SO, S>( (hash, header) }, }; + + if can_author_with.can_author_with(&BlockId::Hash(best_hash)) { + debug!( + target: "pow", + "Skipping proposal `can_author_with` returned `false`. \ + Probably a node update is required!" + ); + std::thread::sleep(std::time::Duration::from_secs(1)); + continue 'outer + } + let mut aux = PowAux::read(client, &best_hash)?; let mut proposer = env.init(&best_header) .map_err(|e| Error::Environment(format!("{:?}", e)))?; diff --git a/client/consensus/slots/src/lib.rs b/client/consensus/slots/src/lib.rs index 1e770b5dd8..56d44d13b4 100644 --- a/client/consensus/slots/src/lib.rs +++ b/client/consensus/slots/src/lib.rs @@ -31,7 +31,7 @@ use slots::Slots; pub use aux_schema::{check_equivocation, MAX_SLOT_CAPACITY, PRUNING_BOUND}; use codec::{Decode, Encode}; -use consensus_common::{BlockImport, Proposer, SyncOracle, SelectChain}; +use consensus_common::{BlockImport, Proposer, SyncOracle, SelectChain, CanAuthorWith}; use futures::{prelude::*, future::{self, Either}}; use futures_timer::Delay; use inherents::{InherentData, InherentDataProviders}; @@ -304,22 +304,24 @@ pub trait SlotCompatible { /// /// Every time a new slot is triggered, `worker.on_slot` is called and the future it returns is /// polled until completion, unless we are major syncing. -pub fn start_slot_worker( +pub fn start_slot_worker( slot_duration: SlotDuration, client: C, mut worker: W, mut sync_oracle: SO, inherent_data_providers: InherentDataProviders, timestamp_extractor: SC, + can_author_with: CAW, ) -> impl Future where B: BlockT, - C: SelectChain + Clone, + C: SelectChain, W: SlotWorker, W::OnSlot: Unpin, - SO: SyncOracle + Send + Clone, + SO: SyncOracle + Send, SC: SlotCompatible + Unpin, T: SlotData + Clone, + CAW: CanAuthorWith + Send, { let SlotDuration(slot_duration) = slot_duration; @@ -346,11 +348,23 @@ where } }; - Either::Left(worker.on_slot(chain_head, slot_info).map_err( - |e| { - warn!(target: "slots", "Encountered consensus error: {:?}", e); - }).or_else(|_| future::ready(Ok(()))) - ) + if can_author_with.can_author_with(&BlockId::Hash(chain_head.hash())) { + Either::Left( + worker.on_slot(chain_head, slot_info) + .map_err(|e| { + warn!(target: "slots", "Encountered consensus error: {:?}", e); + }) + .or_else(|_| future::ready(Ok(()))) + ) + } else { + warn!( + target: "slots", + "Unable to author block in slot {}. `can_author_with` returned `false`. \ + Probably a node update is required!", + slot_num, + ); + Either::Right(future::ready(Ok(()))) + } }).then(|res| { if let Err(err) = res { warn!(target: "slots", "Slots stream terminated with an error: {:?}", err); diff --git a/client/executor/src/lib.rs b/client/executor/src/lib.rs index 0638a71d1c..5037b490dd 100644 --- a/client/executor/src/lib.rs +++ b/client/executor/src/lib.rs @@ -87,10 +87,7 @@ pub trait RuntimeInfo { fn native_version(&self) -> &NativeVersion; /// Extract RuntimeVersion of given :code block - fn runtime_version ( - &self, - ext: &mut E, - ) -> Option; + fn runtime_version (&self, ext: &mut E) -> error::Result; } #[cfg(test)] diff --git a/client/executor/src/native_executor.rs b/client/executor/src/native_executor.rs index 23ea17a0c4..f5d02f274a 100644 --- a/client/executor/src/native_executor.rs +++ b/client/executor/src/native_executor.rs @@ -25,7 +25,7 @@ use codec::{Decode, Encode}; use primitives::{NativeOrEncoded, traits::{CodeExecutor, Externalities}}; -use log::{trace, warn}; +use log::trace; use std::{result, cell::RefCell, panic::{UnwindSafe, AssertUnwindSafe}}; @@ -181,14 +181,8 @@ impl RuntimeInfo for NativeExecutor { fn runtime_version( &self, ext: &mut E, - ) -> Option { - match self.with_runtime(ext, |_runtime, version, _ext| Ok(Ok(version.clone()))) { - Ok(version) => Some(version), - Err(e) => { - warn!(target: "executor", "Failed to fetch runtime: {:?}", e); - None - } - } + ) -> Result { + self.with_runtime(ext, |_runtime, version, _ext| Ok(Ok(version.clone()))) } } diff --git a/client/rpc/src/state/state_light.rs b/client/rpc/src/state/state_light.rs index c761d3bfe4..c246312749 100644 --- a/client/rpc/src/state/state_light.rs +++ b/client/rpc/src/state/state_light.rs @@ -547,7 +547,8 @@ fn runtime_version>( Bytes(Vec::new()), ) .then(|version| ready(version.and_then(|version| - Decode::decode(&mut &version.0[..]).map_err(|_| client_err(ClientError::VersionInvalid)) + Decode::decode(&mut &version.0[..]) + .map_err(|e| client_err(ClientError::VersionInvalid(e.what().into()))) ))) } @@ -696,7 +697,7 @@ fn ignore_error(future: F) -> impl std::future::Future Ok(Some(result)), Err(()) => Ok(None), - })) + })) } #[cfg(test)] diff --git a/client/src/call_executor.rs b/client/src/call_executor.rs index 787e00a84d..2a2fc3ad55 100644 --- a/client/src/call_executor.rs +++ b/client/src/call_executor.rs @@ -63,10 +63,10 @@ impl Clone for LocalCallExecutor where E: Clone { } impl CallExecutor for LocalCallExecutor -where - B: backend::Backend, - E: CodeExecutor + RuntimeInfo, - Block: BlockT, + where + B: backend::Backend, + E: CodeExecutor + RuntimeInfo, + Block: BlockT, { type Error = E::Error; @@ -202,7 +202,7 @@ where let _lock = self.backend.get_import_lock().read(); self.backend.destroy_state(state)?; } - version.ok_or(sp_blockchain::Error::VersionInvalid.into()) + version.map_err(|e| sp_blockchain::Error::VersionInvalid(format!("{:?}", e)).into()) } fn call_at_state< @@ -268,3 +268,21 @@ where Some(self.executor.native_version()) } } + +impl runtime_version::GetRuntimeVersion for LocalCallExecutor + where + B: backend::Backend, + E: CodeExecutor + RuntimeInfo, + Block: BlockT, +{ + fn native_version(&self) -> &runtime_version::NativeVersion { + self.executor.native_version() + } + + fn runtime_version( + &self, + at: &BlockId, + ) -> Result { + CallExecutor::runtime_version(self, at).map_err(|e| format!("{:?}", e)) + } +} diff --git a/client/src/client.rs b/client/src/client.rs index 171a27223a..6d6a690d84 100644 --- a/client/src/client.rs +++ b/client/src/client.rs @@ -1753,9 +1753,10 @@ where } impl consensus::block_validation::Chain for Client - where BE: backend::Backend, - E: CallExecutor, - B: BlockT + where + BE: backend::Backend, + E: CallExecutor, + B: BlockT { fn block_status(&self, id: &BlockId) -> Result> { Client::block_status(self, id).map_err(|e| Box::new(e) as Box<_>) diff --git a/primitives/blockchain/src/error.rs b/primitives/blockchain/src/error.rs index 73b2422498..6302edb3d2 100644 --- a/primitives/blockchain/src/error.rs +++ b/primitives/blockchain/src/error.rs @@ -28,7 +28,6 @@ use parity_scale_codec::Error as CodecError; /// Client Result type alias pub type Result = result::Result; - /// Error when the runtime failed to apply an extrinsic. #[derive(Debug, Display)] pub enum ApplyExtrinsicFailed { @@ -72,8 +71,9 @@ pub enum Error { #[display(fmt = "Current state of blockchain has invalid authorities set")] InvalidAuthoritiesSet, /// Could not get runtime version. - #[display(fmt = "On-chain runtime does not specify version")] - VersionInvalid, + #[display(fmt = "Failed to get runtime version: {}", _0)] + #[from(ignore)] + VersionInvalid(String), /// Genesis config is invalid. #[display(fmt = "Genesis config provided is invalid")] GenesisInvalid, @@ -125,7 +125,6 @@ pub enum Error { InvalidStateRoot, /// A convenience variant for String #[display(fmt = "{}", _0)] - #[from(ignore)] Msg(String), } @@ -139,12 +138,6 @@ impl error::Error for Error { } } -impl From for Error { - fn from(s: String) -> Self { - Error::Msg(s) - } -} - impl<'a> From<&'a str> for Error { fn from(s: &'a str) -> Self { Error::Msg(s.into()) diff --git a/primitives/consensus/common/src/lib.rs b/primitives/consensus/common/src/lib.rs index 154ea7bb52..3dc1cc7a39 100644 --- a/primitives/consensus/common/src/lib.rs +++ b/primitives/consensus/common/src/lib.rs @@ -31,7 +31,7 @@ use std::sync::Arc; use std::time::Duration; -use sr_primitives::traits::{Block as BlockT, DigestFor}; +use sr_primitives::{traits::{Block as BlockT, DigestFor}, generic::BlockId}; use futures::prelude::*; pub use inherents::InherentData; @@ -123,13 +123,59 @@ impl SyncOracle for NoNetwork { fn is_offline(&mut self) -> bool { false } } -impl SyncOracle for Arc -where T: ?Sized, for<'r> &'r T: SyncOracle -{ +impl SyncOracle for Arc where T: ?Sized, for<'r> &'r T: SyncOracle { fn is_major_syncing(&mut self) -> bool { <&T>::is_major_syncing(&mut &**self) } + fn is_offline(&mut self) -> bool { <&T>::is_offline(&mut &**self) } } + +/// Checks if the current active native block authoring implementation can author with the runtime +/// at the given block. +pub trait CanAuthorWith { + /// See trait docs for more information. + fn can_author_with(&self, at: &BlockId) -> bool; +} + +/// Checks if the node can author blocks by using +/// [`NativeVersion::can_author_with`](runtime_version::NativeVersion::can_author_with). +pub struct CanAuthorWithNativeVersion(T); + +impl CanAuthorWithNativeVersion { + /// Creates a new instance of `Self`. + pub fn new(inner: T) -> Self { + Self(inner) + } +} + +impl, Block: BlockT> CanAuthorWith + for CanAuthorWithNativeVersion +{ + fn can_author_with(&self, at: &BlockId) -> bool { + match self.0.runtime_version(at) { + Ok(version) => self.0.native_version().can_author_with(&version), + Err(e) => { + error!( + target: "CanAuthorWithNativeVersion", + "Failed to get runtime version at `{}` and will disable authoring. Error: {}", + at, + e, + ); + + false + } + } + } +} + +/// Returns always `true` for `can_author_with`. This is useful for tests. +pub struct AlwaysCanAuthor; + +impl CanAuthorWith for AlwaysCanAuthor { + fn can_author_with(&self, _: &BlockId) -> bool { + true + } +} diff --git a/primitives/sr-version/src/lib.rs b/primitives/sr-version/src/lib.rs index f342c25217..d7d829bd4b 100644 --- a/primitives/sr-version/src/lib.rs +++ b/primitives/sr-version/src/lib.rs @@ -33,6 +33,9 @@ use codec::Decode; use sr_primitives::RuntimeString; pub use sr_primitives::create_runtime_str; +#[cfg(feature = "std")] +use sr_primitives::{traits::Block as BlockT, generic::BlockId}; + /// The identity of a particular API interface that the runtime might provide. pub type ApiId = [u8; 8]; @@ -165,6 +168,27 @@ impl NativeVersion { } } +/// Something that can provide the runtime version at a given block and the native runtime version. +#[cfg(feature = "std")] +pub trait GetRuntimeVersion { + /// Returns the version of the native runtime. + fn native_version(&self) -> &NativeVersion; + + /// Returns the version of runtime at the given block. + fn runtime_version(&self, at: &BlockId) -> Result; +} + +#[cfg(feature = "std")] +impl, Block: BlockT> GetRuntimeVersion for std::sync::Arc { + fn native_version(&self) -> &NativeVersion { + (&**self).native_version() + } + + fn runtime_version(&self, at: &BlockId) -> Result { + (&**self).runtime_version(at) + } +} + #[cfg(feature = "std")] mod apis_serialize { use super::*; -- GitLab From 229f71565da196566c4c52ea7be49f42b8f3352f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Fri, 29 Nov 2019 11:32:44 +0100 Subject: [PATCH 045/172] Update kvdb-rocksdb again (#4236) * Update kvdb-rocksdb again * Switch to released crates * Remove last git references --- Cargo.lock | 40 ++++++++++++++++++++-------------------- bin/node/cli/Cargo.toml | 2 +- client/Cargo.toml | 4 ++-- client/api/Cargo.toml | 4 ++-- client/db/Cargo.toml | 7 +++---- 5 files changed, 28 insertions(+), 29 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 29ba292790..ff709c1a3f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2221,30 +2221,30 @@ dependencies = [ [[package]] name = "kvdb" version = "0.1.1" -source = "git+https://github.com/paritytech/parity-common?rev=03a2ba08f47f4af4219280e660a1ea92cb8896bd#03a2ba08f47f4af4219280e660a1ea92cb8896bd" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "elastic-array 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-bytes 0.1.1 (git+https://github.com/paritytech/parity-common?rev=03a2ba08f47f4af4219280e660a1ea92cb8896bd)", + "parity-bytes 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "kvdb-memorydb" version = "0.1.2" -source = "git+https://github.com/paritytech/parity-common?rev=03a2ba08f47f4af4219280e660a1ea92cb8896bd#03a2ba08f47f4af4219280e660a1ea92cb8896bd" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "kvdb 0.1.1 (git+https://github.com/paritytech/parity-common?rev=03a2ba08f47f4af4219280e660a1ea92cb8896bd)", + "kvdb 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "kvdb-rocksdb" -version = "0.1.6" -source = "git+https://github.com/paritytech/parity-common?rev=03a2ba08f47f4af4219280e660a1ea92cb8896bd#03a2ba08f47f4af4219280e660a1ea92cb8896bd" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "elastic-array 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "fs-swap 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "interleaved-ordered 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "kvdb 0.1.1 (git+https://github.com/paritytech/parity-common?rev=03a2ba08f47f4af4219280e660a1ea92cb8896bd)", + "kvdb 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)", "owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2973,7 +2973,7 @@ dependencies = [ "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "js-sys 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "kvdb-memorydb 0.1.2 (git+https://github.com/paritytech/parity-common?rev=03a2ba08f47f4af4219280e660a1ea92cb8896bd)", + "kvdb-memorydb 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "node-executor 2.0.0", @@ -3968,7 +3968,7 @@ dependencies = [ [[package]] name = "parity-bytes" version = "0.1.1" -source = "git+https://github.com/paritytech/parity-common?rev=03a2ba08f47f4af4219280e660a1ea92cb8896bd#03a2ba08f47f4af4219280e660a1ea92cb8896bd" +source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "parity-multiaddr" @@ -5643,8 +5643,8 @@ dependencies = [ "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "kvdb 0.1.1 (git+https://github.com/paritytech/parity-common?rev=03a2ba08f47f4af4219280e660a1ea92cb8896bd)", - "kvdb-memorydb 0.1.2 (git+https://github.com/paritytech/parity-common?rev=03a2ba08f47f4af4219280e660a1ea92cb8896bd)", + "kvdb 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "kvdb-memorydb 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5680,8 +5680,8 @@ dependencies = [ "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "kvdb 0.1.1 (git+https://github.com/paritytech/parity-common?rev=03a2ba08f47f4af4219280e660a1ea92cb8896bd)", - "kvdb-memorydb 0.1.2 (git+https://github.com/paritytech/parity-common?rev=03a2ba08f47f4af4219280e660a1ea92cb8896bd)", + "kvdb 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "kvdb-memorydb 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5714,9 +5714,9 @@ version = "2.0.0" dependencies = [ "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", - "kvdb 0.1.1 (git+https://github.com/paritytech/parity-common?rev=03a2ba08f47f4af4219280e660a1ea92cb8896bd)", - "kvdb-memorydb 0.1.2 (git+https://github.com/paritytech/parity-common?rev=03a2ba08f47f4af4219280e660a1ea92cb8896bd)", - "kvdb-rocksdb 0.1.6 (git+https://github.com/paritytech/parity-common?rev=03a2ba08f47f4af4219280e660a1ea92cb8896bd)", + "kvdb 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "kvdb-memorydb 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "kvdb-rocksdb 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -8143,9 +8143,9 @@ dependencies = [ "checksum keccak-hasher 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3468207deea1359a0e921591ae9b4c928733d94eb9d6a2eeda994cfd59f42cf8" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum kv-log-macro 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c54d9f465d530a752e6ebdc217e081a7a614b48cb200f6f0aee21ba6bc9aabb" -"checksum kvdb 0.1.1 (git+https://github.com/paritytech/parity-common?rev=03a2ba08f47f4af4219280e660a1ea92cb8896bd)" = "" -"checksum kvdb-memorydb 0.1.2 (git+https://github.com/paritytech/parity-common?rev=03a2ba08f47f4af4219280e660a1ea92cb8896bd)" = "" -"checksum kvdb-rocksdb 0.1.6 (git+https://github.com/paritytech/parity-common?rev=03a2ba08f47f4af4219280e660a1ea92cb8896bd)" = "" +"checksum kvdb 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c1b2f251f01a7224426abdb2563707d856f7de995d821744fd8fa8e2874f69e3" +"checksum kvdb-memorydb 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "296c12309ed36cb74d59206406adbf1971c3baa56d5410efdb508d8f1c60a351" +"checksum kvdb-rocksdb 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d3f82177237c1ae67d6ab208a6f790cab569a1d81c1ba02348e0736a99510be3" "checksum language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a" "checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" "checksum lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" @@ -8222,7 +8222,7 @@ dependencies = [ "checksum openssl-sys 0.9.52 (registry+https://github.com/rust-lang/crates.io-index)" = "c977d08e1312e2f7e4b86f9ebaa0ed3b19d1daff75fae88bbb88108afbd801fc" "checksum output_vt100 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "53cdc5b785b7a58c5aad8216b3dfa114df64b0b06ae6e1501cef91df2fbdf8f9" "checksum owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "49a4b8ea2179e6a2e27411d3bca09ca6dd630821cf6894c6c7c8467a8ee7ef13" -"checksum parity-bytes 0.1.1 (git+https://github.com/paritytech/parity-common?rev=03a2ba08f47f4af4219280e660a1ea92cb8896bd)" = "" +"checksum parity-bytes 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0c276d76c5333b8c2579e02d49a06733a55b8282d2d9b13e8d53b6406bd7e30a" "checksum parity-multiaddr 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7dbc379f41150dedda75cbbdb5b9beb2bf786a07e56c2c99ec89aeaaa894662c" "checksum parity-multihash 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "340ed03f939e02e4cb71a5a127b5507ba4dab506e41a05f8f467e28d8ce529f4" "checksum parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "001fbbb956d8593f321c7a784f64d16b2c99b2657823976eea729006ad2c3668" diff --git a/bin/node/cli/Cargo.toml b/bin/node/cli/Cargo.toml index 3e98d5a2bb..d04a0382b4 100644 --- a/bin/node/cli/Cargo.toml +++ b/bin/node/cli/Cargo.toml @@ -94,7 +94,7 @@ console_log = { version = "0.1.2", optional = true } js-sys = { version = "0.3.22", optional = true } wasm-bindgen = { version = "0.2.45", optional = true } wasm-bindgen-futures = { version = "0.3.22", optional = true } -kvdb-memorydb = { git = "https://github.com/paritytech/parity-common", rev="03a2ba08f47f4af4219280e660a1ea92cb8896bd", optional = true } +kvdb-memorydb = { version = "0.1.1", optional = true } rand6 = { package = "rand", version = "0.6", features = ["wasm-bindgen"], optional = true } # Imported just for the `wasm-bindgen` feature [dev-dependencies] diff --git a/client/Cargo.toml b/client/Cargo.toml index b78812d882..9800e6c14f 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -18,7 +18,7 @@ hash-db = { version = "0.15.2" } hex-literal = { version = "0.2.1" } inherents = { package = "substrate-inherents", path = "../primitives/inherents" } keyring = { package = "substrate-keyring", path = "../primitives/keyring" } -kvdb = { git = "https://github.com/paritytech/parity-common", rev="03a2ba08f47f4af4219280e660a1ea92cb8896bd" } +kvdb = "0.1.1" log = { version = "0.4.8" } parking_lot = { version = "0.9.0" } primitives = { package = "substrate-primitives", path = "../primitives/core" } @@ -36,5 +36,5 @@ env_logger = "0.7.0" tempfile = "3.1.0" client-db = { package = "substrate-client-db", path = "./db", features = ["kvdb-rocksdb"] } test-client = { package = "substrate-test-runtime-client", path = "../test/utils/runtime/client" } -kvdb-memorydb = { git = "https://github.com/paritytech/parity-common", rev="03a2ba08f47f4af4219280e660a1ea92cb8896bd" } +kvdb-memorydb = "0.1.2" panic-handler = { package = "substrate-panic-handler", path = "../primitives/panic-handler" } diff --git a/client/api/Cargo.toml b/client/api/Cargo.toml index b48990d763..90fab81ba9 100644 --- a/client/api/Cargo.toml +++ b/client/api/Cargo.toml @@ -18,7 +18,7 @@ sp-blockchain = { path = "../../primitives/blockchain" } hex-literal = { version = "0.2.1" } inherents = { package = "substrate-inherents", path = "../../primitives/inherents", default-features = false } keyring = { package = "substrate-keyring", path = "../../primitives/keyring" } -kvdb = { git = "https://github.com/paritytech/parity-common", rev="03a2ba08f47f4af4219280e660a1ea92cb8896bd" } +kvdb = "0.1.1" log = { version = "0.4.8" } parking_lot = { version = "0.9.0" } primitives = { package = "substrate-primitives", path = "../../primitives/core", default-features = false } @@ -37,6 +37,6 @@ tempfile = "3.1.0" client-db = { package = "substrate-client-db", path = ".././db", features = ["kvdb-rocksdb"] } test-primitives = { package = "substrate-test-primitives", path = "../../test/utils/primitives" } test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client" } -kvdb-memorydb = { git = "https://github.com/paritytech/parity-common", rev="03a2ba08f47f4af4219280e660a1ea92cb8896bd" } +kvdb-memorydb = "0.1.2" panic-handler = { package = "substrate-panic-handler", path = "../../primitives/panic-handler" } diff --git a/client/db/Cargo.toml b/client/db/Cargo.toml index d713212b07..d406298e0b 100644 --- a/client/db/Cargo.toml +++ b/client/db/Cargo.toml @@ -7,10 +7,9 @@ edition = "2018" [dependencies] parking_lot = "0.9.0" log = "0.4.8" -kvdb = { git = "https://github.com/paritytech/parity-common", rev="03a2ba08f47f4af4219280e660a1ea92cb8896bd" } -# FIXME replace with release as soon as our rocksdb changes are released upstream https://github.com/paritytech/parity-common/issues/88 -kvdb-rocksdb = { git = "https://github.com/paritytech/parity-common", rev="03a2ba08f47f4af4219280e660a1ea92cb8896bd", optional = true } -kvdb-memorydb = { git = "https://github.com/paritytech/parity-common", rev="03a2ba08f47f4af4219280e660a1ea92cb8896bd" } +kvdb = "0.1.1" +kvdb-rocksdb = { version = "0.2", optional = true } +kvdb-memorydb = "0.1.2" linked-hash-map = "0.5.2" hash-db = "0.15.2" client-api = { package = "substrate-client-api", path = "../api" } -- GitLab From e3245d49dc55c9e3a88ab3e45ff4a0c4d37750c4 Mon Sep 17 00:00:00 2001 From: mattrutherford <44339188+mattrutherford@users.noreply.github.com> Date: Fri, 29 Nov 2019 15:44:42 +0000 Subject: [PATCH 046/172] Tracing - Implement feature to record values with span creation (#4242) * implement feature to record arbitrary values with span creation * align dependency versions * Fix formatting, refactor * Change `Level` in decl_module from `INFO` to `DEBUG`, because we may want to use `INFO` in spans added manually in individual pallets, in future. --- Cargo.lock | 257 +++++++++++++++++----------------- client/Cargo.toml | 1 + client/tracing/Cargo.toml | 4 + client/tracing/src/lib.rs | 128 ++++++++++++++--- frame/support/src/dispatch.rs | 12 +- 5 files changed, 251 insertions(+), 151 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ff709c1a3f..2a5b8cde28 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -249,7 +249,7 @@ 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.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -372,7 +372,7 @@ dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "regex-automata 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -437,9 +437,9 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -489,7 +489,7 @@ dependencies = [ "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -615,7 +615,7 @@ dependencies = [ "cranelift-codegen-shared 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)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "thiserror 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -640,7 +640,7 @@ name = "cranelift-entity" version = "0.50.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -673,7 +673,7 @@ dependencies = [ "cranelift-entity 0.50.0 (registry+https://github.com/rust-lang/crates.io-index)", "cranelift-frontend 0.50.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "thiserror 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "wasmparser 0.39.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -705,9 +705,9 @@ dependencies = [ "rand_xoshiro 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "rayon-core 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", "tinytemplate 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "walkdir 2.2.9 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -729,9 +729,9 @@ dependencies = [ "rand_os 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand_xoshiro 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", "tinytemplate 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "walkdir 2.2.9 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -843,7 +843,7 @@ dependencies = [ "csv-core 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1032,7 +1032,7 @@ name = "erased-serde" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1245,7 +1245,7 @@ dependencies = [ "pallet-indices 2.0.0", "pallet-transaction-payment 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -1257,7 +1257,7 @@ name = "frame-metadata" version = "2.0.0" dependencies = [ "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 2.0.0", "substrate-primitives 2.0.0", ] @@ -1276,7 +1276,7 @@ dependencies = [ "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "paste 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sr-arithmetic 2.0.0", "sr-io 2.0.0", "sr-primitives 2.0.0", @@ -1324,7 +1324,7 @@ dependencies = [ "frame-support 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "substrate-inherents 2.0.0", @@ -1342,7 +1342,7 @@ dependencies = [ "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -1366,7 +1366,7 @@ dependencies = [ "frame-system 2.0.0", "pallet-balances 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -1674,8 +1674,8 @@ dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2008,7 +2008,7 @@ name = "impl-serde" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2095,8 +2095,8 @@ dependencies = [ "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-pubsub 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "websocket 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2109,9 +2109,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2155,7 +2155,7 @@ dependencies = [ "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2991,7 +2991,7 @@ dependencies = [ "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "sc-transaction-pool 2.0.0", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-finality-tracker 2.0.0", "sp-timestamp 2.0.0", "sp-transaction-pool-api 2.0.0", @@ -3137,7 +3137,7 @@ dependencies = [ "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-transaction-pool-runtime-api 2.0.0", "sr-api 2.0.0", "sr-io 2.0.0", @@ -3207,7 +3207,7 @@ dependencies = [ "pallet-transaction-payment 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-transaction-pool-runtime-api 2.0.0", "sr-api 2.0.0", "sr-io 2.0.0", @@ -3403,7 +3403,7 @@ dependencies = [ "frame-support 2.0.0", "frame-system 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3421,7 +3421,7 @@ dependencies = [ "pallet-timestamp 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-timestamp 2.0.0", "sr-io 2.0.0", "sr-primitives 2.0.0", @@ -3440,7 +3440,7 @@ dependencies = [ "frame-system 2.0.0", "pallet-session 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-staking-primitives 2.0.0", @@ -3478,7 +3478,7 @@ dependencies = [ "pallet-timestamp 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-timestamp 2.0.0", "sr-io 2.0.0", "sr-primitives 2.0.0", @@ -3500,7 +3500,7 @@ dependencies = [ "pallet-transaction-payment 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3517,7 +3517,7 @@ dependencies = [ "pallet-balances 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3538,7 +3538,7 @@ dependencies = [ "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-wasm 0.41.0 (registry+https://github.com/rust-lang/crates.io-index)", "pwasm-utils 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-sandbox 2.0.0", @@ -3557,7 +3557,7 @@ dependencies = [ "jsonrpc-derive 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "pallet-contracts-rpc-runtime-api 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-blockchain 2.0.0", "sr-primitives 2.0.0", "substrate-primitives 2.0.0", @@ -3569,7 +3569,7 @@ name = "pallet-contracts-rpc-runtime-api" version = "2.0.0" dependencies = [ "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sr-api 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3584,7 +3584,7 @@ dependencies = [ "pallet-balances 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3601,7 +3601,7 @@ dependencies = [ "pallet-balances 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3617,7 +3617,7 @@ dependencies = [ "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "pallet-balances 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3638,7 +3638,7 @@ dependencies = [ "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "primitive-types 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sha3 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", @@ -3654,7 +3654,7 @@ dependencies = [ "frame-system 2.0.0", "pallet-balances 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3669,7 +3669,7 @@ dependencies = [ "frame-system 2.0.0", "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-finality-tracker 2.0.0", "sr-io 2.0.0", "sr-primitives 2.0.0", @@ -3685,7 +3685,7 @@ dependencies = [ "frame-support 2.0.0", "frame-system 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3701,7 +3701,7 @@ dependencies = [ "pallet-finality-tracker 2.0.0", "pallet-session 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-staking-primitives 2.0.0", @@ -3719,7 +3719,7 @@ dependencies = [ "pallet-authorship 0.1.0", "pallet-session 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-staking-primitives 2.0.0", @@ -3737,7 +3737,7 @@ dependencies = [ "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "ref_thread_local 0.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3752,7 +3752,7 @@ dependencies = [ "frame-support 2.0.0", "frame-system 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3767,7 +3767,7 @@ dependencies = [ "frame-system 2.0.0", "pallet-balances 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3782,7 +3782,7 @@ dependencies = [ "frame-system 2.0.0", "pallet-balances 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-staking-primitives 2.0.0", @@ -3812,7 +3812,7 @@ dependencies = [ "frame-system 2.0.0", "pallet-balances 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3830,7 +3830,7 @@ dependencies = [ "pallet-timestamp 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-staking-primitives 2.0.0", @@ -3853,7 +3853,7 @@ dependencies = [ "pallet-timestamp 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-staking-primitives 2.0.0", @@ -3882,7 +3882,7 @@ dependencies = [ "frame-support 2.0.0", "frame-system 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3897,7 +3897,7 @@ dependencies = [ "frame-system 2.0.0", "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-timestamp 2.0.0", "sr-io 2.0.0", "sr-primitives 2.0.0", @@ -3930,7 +3930,7 @@ dependencies = [ "jsonrpc-derive 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "pallet-transaction-payment-rpc-runtime-api 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-blockchain 2.0.0", "sr-primitives 2.0.0", "substrate-primitives 2.0.0", @@ -3943,8 +3943,8 @@ version = "2.0.0" dependencies = [ "frame-support 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", "sr-api 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3958,7 +3958,7 @@ dependencies = [ "frame-system 2.0.0", "pallet-balances 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -3982,7 +3982,7 @@ dependencies = [ "data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4010,7 +4010,7 @@ dependencies = [ "bitvec 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "byte-slice-cast 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec-derive 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4813,8 +4813,8 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", "sp-transaction-pool-api 2.0.0", "sr-version 2.0.0", "substrate-primitives 2.0.0", @@ -4833,7 +4833,7 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-transaction-pool-api 2.0.0", "sr-primitives 2.0.0", "substrate-primitives 2.0.0", @@ -4956,7 +4956,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4971,15 +4971,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.102" +version = "1.0.103" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde_derive 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_derive" -version = "1.0.102" +version = "1.0.103" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4989,12 +4989,12 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.41" +version = "1.0.42" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -5081,8 +5081,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", "erased-serde 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5208,7 +5208,7 @@ dependencies = [ "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "substrate-primitives 2.0.0", ] @@ -5283,7 +5283,7 @@ dependencies = [ "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "primitive-types 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 2.0.0", "substrate-debug-derive 2.0.0", ] @@ -5313,8 +5313,8 @@ dependencies = [ "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "paste 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", "sr-arithmetic 2.0.0", "sr-io 2.0.0", "sr-std 2.0.0", @@ -5355,7 +5355,7 @@ version = "2.0.0" dependencies = [ "impl-serde 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", ] @@ -5391,7 +5391,7 @@ name = "string-interner" version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -5465,7 +5465,7 @@ name = "substrate-application-crypto" version = "2.0.0" dependencies = [ "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -5487,7 +5487,7 @@ dependencies = [ "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "prost 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "prost-build 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", "sp-blockchain 2.0.0", "sr-api 2.0.0", "sr-primitives 2.0.0", @@ -5578,8 +5578,8 @@ name = "substrate-chain-spec" version = "2.0.0" dependencies = [ "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "substrate-chain-spec-derive 2.0.0", "substrate-network 2.0.0", @@ -5615,7 +5615,7 @@ dependencies = [ "names 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "rpassword 4.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", "sp-blockchain 2.0.0", "sr-primitives 2.0.0", "structopt 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5668,6 +5668,7 @@ dependencies = [ "substrate-test-runtime-client 2.0.0", "substrate-trie 2.0.0", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tracing 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -6002,7 +6003,7 @@ dependencies = [ "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", "sp-blockchain 2.0.0", "sp-finality-tracker 2.0.0", "sr-api 2.0.0", @@ -6031,7 +6032,7 @@ name = "substrate-finality-grandpa-primitives" version = "2.0.0" dependencies = [ "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sr-api 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -6049,7 +6050,7 @@ dependencies = [ "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "sc-rpc-api 2.0.0", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-primitives-storage 2.0.0", "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -6067,7 +6068,7 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "sc-transaction-pool 2.0.0", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-blockchain 2.0.0", "sp-transaction-pool-api 2.0.0", "sr-primitives 2.0.0", @@ -6105,7 +6106,7 @@ dependencies = [ "hex 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-application-crypto 2.0.0", "substrate-primitives 2.0.0", "subtle 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -6137,8 +6138,8 @@ dependencies = [ "quickcheck 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "slog_derive 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", @@ -6220,7 +6221,7 @@ dependencies = [ "libp2p 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -6228,7 +6229,7 @@ name = "substrate-phragmen" version = "2.0.0" dependencies = [ "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-std 2.0.0", @@ -6261,8 +6262,8 @@ dependencies = [ "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "schnorrkel 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 2.0.0", "substrate-bip39 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -6283,7 +6284,7 @@ name = "substrate-primitives-storage" version = "2.0.0" dependencies = [ "impl-serde 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 2.0.0", "substrate-debug-derive 2.0.0", ] @@ -6304,7 +6305,7 @@ dependencies = [ "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "sc-rpc-api 2.0.0", "sc-transaction-pool 2.0.0", - "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", "sp-blockchain 2.0.0", "sp-transaction-pool-api 2.0.0", "sr-api 2.0.0", @@ -6328,8 +6329,8 @@ dependencies = [ name = "substrate-rpc-primitives" version = "2.0.0" dependencies = [ - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-primitives 2.0.0", ] @@ -6342,8 +6343,8 @@ dependencies = [ "jsonrpc-pubsub 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-ws-server 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", ] @@ -6409,8 +6410,8 @@ dependencies = [ name = "substrate-serializer" version = "2.0.0" dependencies = [ - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -6428,8 +6429,8 @@ dependencies = [ "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sc-transaction-pool 2.0.0", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "sp-blockchain 2.0.0", "sp-transaction-pool-api 2.0.0", @@ -6536,7 +6537,7 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "slog-async 2.3.0 (git+https://github.com/paritytech/slog-async)", "slog-json 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -6569,7 +6570,7 @@ name = "substrate-test-primitives" version = "2.0.0" dependencies = [ "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "substrate-application-crypto 2.0.0", "substrate-primitives 2.0.0", @@ -6589,7 +6590,7 @@ dependencies = [ "pallet-babe 2.0.0", "pallet-timestamp 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-transaction-pool-runtime-api 2.0.0", "sr-api 2.0.0", "sr-io 2.0.0", @@ -6639,9 +6640,13 @@ version = "2.0.0" name = "substrate-tracing" version = "2.0.0" dependencies = [ + "erased-serde 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "grafana-data-source 2.0.0", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", + "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-telemetry 2.0.0", "tracing 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "tracing-core 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -6878,8 +6883,8 @@ name = "tinytemplate" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -7144,7 +7149,7 @@ name = "toml" version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -7269,8 +7274,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -7440,9 +7445,9 @@ name = "wabt" version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", "wabt-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -7653,7 +7658,7 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "more-asserts 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "spin 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "thiserror 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -8329,9 +8334,9 @@ dependencies = [ "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum send_wrapper 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a0eddf2e8f50ced781f288c19f18621fa72a3779e3cb58dbf23b07469b0abeb4" -"checksum serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)" = "0c4b39bd9b0b087684013a792c59e3e07a46a01d2322518d8a1104641a0b1be0" -"checksum serde_derive 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)" = "ca13fc1a832f793322228923fbb3aba9f3f44444898f835d31ad1b74fa0a2bf8" -"checksum serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)" = "2f72eb2a68a7dc3f9a691bfda9305a1c017a6215e5a4545c258500d2099a37c2" +"checksum serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)" = "1217f97ab8e8904b57dd22eb61cde455fa7446a9c1cf43966066da047c1f3702" +"checksum serde_derive 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)" = "a8c6faef9a2e64b0064f48570289b4bf8823b7581f1d6157c1b52152306651d0" +"checksum serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)" = "1a3351dcbc1f067e2c92ab7c3c1f288ad1a4cffc470b5aaddb4c2e0a3ae80043" "checksum sha-1 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "23962131a91661d643c98940b20fcaffe62d776a823247be80a48fcb8b6fce68" "checksum sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" "checksum sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b4d8bfd0e469f417657573d8451fb33d16cfe0989359b93baf3a1ffc639543d" diff --git a/client/Cargo.toml b/client/Cargo.toml index 9800e6c14f..7dadb1f847 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -30,6 +30,7 @@ sp-blockchain = { path = "../primitives/blockchain" } state-machine = { package = "substrate-state-machine", path = "../primitives/state-machine" } substrate-telemetry = { path = "telemetry" } trie = { package = "substrate-trie", path = "../primitives/trie" } +tracing = "0.1.10" [dev-dependencies] env_logger = "0.7.0" diff --git a/client/tracing/Cargo.toml b/client/tracing/Cargo.toml index 431889cbec..013135486a 100644 --- a/client/tracing/Cargo.toml +++ b/client/tracing/Cargo.toml @@ -6,8 +6,12 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] +erased-serde = "0.3.9" log = { version = "0.4.8" } parking_lot = "0.9.0" +serde = "1.0.101" +serde_json = "1.0.41" +slog = { version = "2.5.2", features = ["nested-values"] } tracing-core = "0.1.7" substrate-telemetry = { path = "../telemetry" } diff --git a/client/tracing/src/lib.rs b/client/tracing/src/lib.rs index d1fe48cea3..1ab2931147 100644 --- a/client/tracing/src/lib.rs +++ b/client/tracing/src/lib.rs @@ -24,22 +24,37 @@ //! A span is set in the following way: //! ``` //! let span = tracing::span!(tracing::Level::INFO, "my_span_name"); -//! let _enter = span.enter(); +//! let _guard = span.enter(); //! ``` //! To begin timing, a span must be entered. When the span is dropped, the execution time //! is recorded and details sent to the `Receiver` which defines how to process it. //! -//! Currently we provide `Log` (default) and `Telemetry` variants for `Receiver` +//! It's possible to record values with each span in the following way: +//! ``` +//! let span = tracing::span!(tracing::Level::INFO, "my_span_name", my_number = 10, a_key = "a value"); +//! let _guard = span.enter(); +//! ``` +//! Currently we provide `Log` (default), `Telemetry` and `Grafana` variants for `Receiver` use std::collections::HashMap; +use std::fmt; use std::sync::atomic::{AtomicU64, Ordering}; use std::time::{Duration, Instant}; use parking_lot::Mutex; -use tracing_core::{event::Event, Level, metadata::Metadata, span::{Attributes, Id, Record}, subscriber::Subscriber}; +use serde::ser::{Serialize, Serializer, SerializeMap}; +use slog::{SerdeValue, Value}; +use tracing_core::{ + event::Event, + field::{Visit, Field}, + Level, + metadata::Metadata, + span::{Attributes, Id, Record}, + subscriber::Subscriber +}; -use substrate_telemetry::{telemetry, SUBSTRATE_INFO}; use grafana_data_source::{self, record_metrics}; +use substrate_telemetry::{telemetry, SUBSTRATE_INFO}; /// Used to configure how to receive the metrics #[derive(Debug, Clone)] @@ -48,7 +63,7 @@ pub enum TracingReceiver { Log, /// Output to telemetry Telemetry, - /// Output to Grafana, + /// Output to Grafana Grafana, } @@ -67,6 +82,68 @@ struct SpanDatum { line: u32, start_time: Instant, overall_time: Duration, + values: Visitor, +} + +#[derive(Clone, Debug)] +struct Visitor(Vec<(String, String)>); + +impl Visit for Visitor { + fn record_i64(&mut self, field: &Field, value: i64) { + self.record_debug(field, &value) + } + + fn record_u64(&mut self, field: &Field, value: u64) { + self.record_debug(field, &value) + } + + fn record_bool(&mut self, field: &Field, value: bool) { + self.record_debug(field, &value) + } + + fn record_debug(&mut self, field: &Field, value: &dyn std::fmt::Debug) { + self.0.push((field.name().to_string(), format!("{:?}",value))); + } +} + +impl Serialize for Visitor { + fn serialize(&self, serializer: S) -> Result + where S: Serializer, + { + let mut map = serializer.serialize_map(Some(self.0.len()))?; + for (k, v) in &self.0 { + map.serialize_entry(k, v)?; + } + map.end() + } +} + +impl fmt::Display for Visitor { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let values = self.0.iter().map(|(k,v)| format!("{}={}",k,v)).collect::>().join(", "); + write!(f, "{}", values) + } +} + +impl SerdeValue for Visitor { + fn as_serde(&self) -> &dyn erased_serde::Serialize { + self + } + + fn to_sendable(&self) -> Box { + Box::new(self.clone()) + } +} + +impl Value for Visitor { + fn serialize( + &self, + _record: &slog::Record, + key: slog::Key, + ser: &mut dyn slog::Serializer, + ) -> slog::Result { + ser.emit_serde(key, self) + } } /// Responsible for assigning ids to new spans, which are not re-used. @@ -79,9 +156,9 @@ pub struct ProfilingSubscriber { impl ProfilingSubscriber { /// Takes a `Receiver` and a comma separated list of targets, - /// either with a level "paint=trace" - /// or without "paint". - pub fn new(receiver: TracingReceiver, targets: &String) -> Self { + /// either with a level: "pallet=trace" + /// or without: "pallet". + pub fn new(receiver: TracingReceiver, targets: &str) -> Self { let targets: Vec<_> = targets.split(',').map(|s| parse_target(s)).collect(); ProfilingSubscriber { next_id: AtomicU64::new(1), @@ -95,7 +172,7 @@ impl ProfilingSubscriber { // Default to TRACE if no level given or unable to parse Level // We do not support a global `Level` currently fn parse_target(s: &str) -> (String, Level) { - match s.find("=") { + match s.find('=') { Some(i) => { let target = s[0..i].to_string(); if s.len() > i { @@ -124,14 +201,17 @@ impl Subscriber for ProfilingSubscriber { fn new_span(&self, attrs: &Attributes<'_>) -> Id { let id = self.next_id.fetch_add(1, Ordering::Relaxed); + let mut values = Visitor(Vec::new()); + attrs.record(&mut values); let span_datum = SpanDatum { - id: id, + id, name: attrs.metadata().name(), target: attrs.metadata().target(), level: attrs.metadata().level().clone(), line: attrs.metadata().line().unwrap_or(0), start_time: Instant::now(), overall_time: Duration::from_nanos(0), + values, }; self.span_data.lock().insert(id, span_datum); Id::from_u64(id) @@ -181,15 +261,24 @@ impl ProfilingSubscriber { } fn print_log(span_datum: SpanDatum) { - let message = format!( - "Tracing: {} {}: {}, line: {}, time: {} ns", - span_datum.level, - span_datum.target, - span_datum.name, - span_datum.line, - span_datum.overall_time.as_nanos() - ); - log::info!(target: "substrate_tracing", "{}", message); + if span_datum.values.0.is_empty() { + log::info!("TRACING: {} {}: {}, line: {}, time: {}", + span_datum.level, + span_datum.target, + span_datum.name, + span_datum.line, + span_datum.overall_time.as_nanos(), + ); + } else { + log::info!("TRACING: {} {}: {}, line: {}, time: {}, {}", + span_datum.level, + span_datum.target, + span_datum.name, + span_datum.line, + span_datum.overall_time.as_nanos(), + span_datum.values + ); + } } fn send_telemetry(span_datum: SpanDatum) { @@ -198,6 +287,7 @@ fn send_telemetry(span_datum: SpanDatum) { "target" => span_datum.target, "line" => span_datum.line, "time" => span_datum.overall_time.as_nanos(), + "values" => span_datum.values ); } diff --git a/frame/support/src/dispatch.rs b/frame/support/src/dispatch.rs index 3c41326b15..2421a62da9 100644 --- a/frame/support/src/dispatch.rs +++ b/frame/support/src/dispatch.rs @@ -868,7 +868,7 @@ macro_rules! decl_module { use $crate::rstd::if_std; if_std! { use $crate::tracing; - let span = tracing::span!(tracing::Level::INFO, "on_initialize"); + let span = tracing::span!(tracing::Level::DEBUG, "on_initialize"); let _enter = span.enter(); } { $( $impl )* } @@ -890,7 +890,7 @@ macro_rules! decl_module { use $crate::rstd::if_std; if_std! { use $crate::tracing; - let span = tracing::span!(tracing::Level::INFO, "on_initialize"); + let span = tracing::span!(tracing::Level::DEBUG, "on_initialize"); let _enter = span.enter(); } { $( $impl )* } @@ -922,7 +922,7 @@ macro_rules! decl_module { use $crate::rstd::if_std; if_std! { use $crate::tracing; - let span = tracing::span!(tracing::Level::INFO, "on_finalize"); + let span = tracing::span!(tracing::Level::DEBUG, "on_finalize"); let _enter = span.enter(); } { $( $impl )* } @@ -944,7 +944,7 @@ macro_rules! decl_module { use $crate::rstd::if_std; if_std! { use $crate::tracing; - let span = tracing::span!(tracing::Level::INFO, "on_finalize"); + let span = tracing::span!(tracing::Level::DEBUG, "on_finalize"); let _enter = span.enter(); } { $( $impl )* } @@ -1047,7 +1047,7 @@ macro_rules! decl_module { use $crate::rstd::if_std; if_std! { use $crate::tracing; - let span = tracing::span!(tracing::Level::INFO, stringify!($name)); + let span = tracing::span!(tracing::Level::DEBUG, stringify!($name)); let _enter = span.enter(); } { @@ -1073,7 +1073,7 @@ macro_rules! decl_module { use $crate::rstd::if_std; if_std! { use $crate::tracing; - let span = tracing::span!(tracing::Level::INFO, stringify!($name)); + let span = tracing::span!(tracing::Level::DEBUG, stringify!($name)); let _enter = span.enter(); } { $( $impl )* } -- GitLab From bf15ecfdd71555afe9a3f86db03e90e8d66d28f7 Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Fri, 29 Nov 2019 18:54:07 +0100 Subject: [PATCH 047/172] Grandpa: save all completed prior rounds (#4203) * Save concluded rounds. * Doc nit * Fix cargo --- client/finality-grandpa/src/aux_schema.rs | 38 ++++++++++++++++++++++ client/finality-grandpa/src/environment.rs | 1 + 2 files changed, 39 insertions(+) diff --git a/client/finality-grandpa/src/aux_schema.rs b/client/finality-grandpa/src/aux_schema.rs index cac8e566d2..beb2103ec4 100644 --- a/client/finality-grandpa/src/aux_schema.rs +++ b/client/finality-grandpa/src/aux_schema.rs @@ -36,6 +36,7 @@ use crate::NewAuthoritySet; const VERSION_KEY: &[u8] = b"grandpa_schema_version"; const SET_STATE_KEY: &[u8] = b"grandpa_completed_round"; +const CONCLUDED_ROUNDS: &[u8] = b"grandpa_concluded_rounds"; const AUTHORITY_SET_KEY: &[u8] = b"grandpa_voters"; const CONSENSUS_CHANGES_KEY: &[u8] = b"grandpa_consensus_changes"; @@ -405,6 +406,18 @@ pub(crate) fn write_voter_set_state( ) } +/// Write concluded round. +pub(crate) fn write_concluded_round( + backend: &B, + round_data: &CompletedRound, +) -> ClientResult<()> { + let mut key = CONCLUDED_ROUNDS.to_vec(); + let round_number = round_data.number; + round_number.using_encoded(|n| key.extend(n)); + + backend.insert_aux(&[(&key[..], round_data.encode().as_slice())], &[]) +} + /// Update the consensus changes. pub(crate) fn update_consensus_changes( set: &ConsensusChanges, @@ -608,4 +621,29 @@ mod test { }, ); } + + #[test] + fn write_read_concluded_rounds() { + let client = test_client::new(); + let hash = H256::random(); + let round_state = RoundState::genesis((hash, 0)); + + let completed_round = CompletedRound:: { + number: 42, + state: round_state.clone(), + base: round_state.prevote_ghost.unwrap(), + votes: vec![], + }; + + assert!(write_concluded_round(&client, &completed_round).is_ok()); + + let round_number = completed_round.number; + let mut key = CONCLUDED_ROUNDS.to_vec(); + round_number.using_encoded(|n| key.extend(n)); + + assert_eq!( + load_decode::<_, CompletedRound::>(&client, &key).unwrap(), + Some(completed_round), + ); + } } diff --git a/client/finality-grandpa/src/environment.rs b/client/finality-grandpa/src/environment.rs index af6e03743a..bc04ecef04 100644 --- a/client/finality-grandpa/src/environment.rs +++ b/client/finality-grandpa/src/environment.rs @@ -865,6 +865,7 @@ where historical_votes.seen().iter().skip(n_existing_votes).cloned() ); already_completed.state = state; + crate::aux_schema::write_concluded_round(&*self.client, &already_completed); } let set_state = VoterSetState::::Live { -- GitLab From d5e189e2ae27db2bdb28a57bcdfb0da54a916a59 Mon Sep 17 00:00:00 2001 From: Stanislav Tkach Date: Fri, 29 Nov 2019 21:20:20 +0200 Subject: [PATCH 048/172] Make weights compatible with u64 (#4192) * Use Weight instead of u32 everywhere * Revert Weight declaration * Fix benches --- bin/node/runtime/src/impls.rs | 2 +- frame/assets/src/lib.rs | 4 ++-- frame/aura/src/mock.rs | 4 ++-- frame/authority-discovery/src/lib.rs | 4 ++-- frame/authorship/src/lib.rs | 4 ++-- frame/babe/src/mock.rs | 4 ++-- frame/balances/src/mock.rs | 2 +- frame/collective/src/lib.rs | 4 ++-- frame/contracts/src/tests.rs | 4 ++-- frame/democracy/src/lib.rs | 5 +++-- frame/elections-phragmen/src/lib.rs | 4 ++-- frame/elections/src/mock.rs | 5 +++-- frame/example/src/lib.rs | 4 ++-- frame/executive/src/lib.rs | 4 ++-- frame/finality-tracker/src/lib.rs | 4 ++-- frame/generic-asset/src/mock.rs | 4 ++-- frame/grandpa/src/mock.rs | 4 ++-- frame/im-online/src/mock.rs | 4 ++-- frame/indices/src/mock.rs | 4 ++-- frame/membership/src/lib.rs | 4 ++-- frame/nicks/src/lib.rs | 4 ++-- frame/offences/src/mock.rs | 7 +++++-- frame/randomness-collective-flip/src/lib.rs | 4 ++-- frame/scored-pool/src/mock.rs | 4 ++-- frame/session/src/mock.rs | 4 ++-- frame/staking/src/mock.rs | 9 ++++++--- frame/system/benches/bench.rs | 4 ++-- frame/timestamp/src/lib.rs | 4 ++-- frame/transaction-payment/src/lib.rs | 2 +- frame/treasury/src/lib.rs | 4 ++-- frame/utility/src/lib.rs | 7 +++++-- test/utils/runtime/src/lib.rs | 4 ++-- 32 files changed, 73 insertions(+), 62 deletions(-) diff --git a/bin/node/runtime/src/impls.rs b/bin/node/runtime/src/impls.rs index de2efdae4a..1b9006e75e 100644 --- a/bin/node/runtime/src/impls.rs +++ b/bin/node/runtime/src/impls.rs @@ -340,7 +340,7 @@ mod tests { mb, 10 * mb, Weight::max_value() / 2, - Weight::max_value() + Weight::max_value(), ].into_iter().for_each(|i| { run_with_system_weight(i, || { let next = TargetedFeeAdjustment::::convert(Fixed64::default()); diff --git a/frame/assets/src/lib.rs b/frame/assets/src/lib.rs index 6f4647ac2e..314a8d4569 100644 --- a/frame/assets/src/lib.rs +++ b/frame/assets/src/lib.rs @@ -240,7 +240,7 @@ impl Module { mod tests { use super::*; - use support::{impl_outer_origin, assert_ok, assert_noop, parameter_types}; + use support::{impl_outer_origin, assert_ok, assert_noop, parameter_types, weights::Weight}; use primitives::H256; // The testing primitives are very useful for avoiding having to work with signatures // or public keys. `u64` is used as the `AccountId` and no `Signature`s are required. @@ -257,7 +257,7 @@ mod tests { pub struct Test; parameter_types! { pub const BlockHashCount: u64 = 250; - pub const MaximumBlockWeight: u32 = 1024; + pub const MaximumBlockWeight: Weight = 1024; pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); } diff --git a/frame/aura/src/mock.rs b/frame/aura/src/mock.rs index f476fd1826..c95a36e131 100644 --- a/frame/aura/src/mock.rs +++ b/frame/aura/src/mock.rs @@ -24,7 +24,7 @@ use sr_primitives::{ traits::IdentityLookup, Perbill, testing::{Header, UintAuthorityId}, }; -use support::{impl_outer_origin, parameter_types}; +use support::{impl_outer_origin, parameter_types, weights::Weight}; use runtime_io; use primitives::H256; @@ -38,7 +38,7 @@ pub struct Test; parameter_types! { pub const BlockHashCount: u64 = 250; - pub const MaximumBlockWeight: u32 = 1024; + pub const MaximumBlockWeight: Weight = 1024; pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); pub const MinimumPeriod: u64 = 1; diff --git a/frame/authority-discovery/src/lib.rs b/frame/authority-discovery/src/lib.rs index b3a5ebded5..6c9e316252 100644 --- a/frame/authority-discovery/src/lib.rs +++ b/frame/authority-discovery/src/lib.rs @@ -100,7 +100,7 @@ mod tests { testing::{Header, UintAuthorityId}, traits::{ConvertInto, IdentityLookup, OpaqueKeys}, Perbill, KeyTypeId, }; - use support::{impl_outer_origin, parameter_types}; + use support::{impl_outer_origin, parameter_types, weights::Weight}; type AuthorityDiscovery = Module; type SessionIndex = u32; @@ -144,7 +144,7 @@ mod tests { pub const Offset: BlockNumber = 0; pub const UncleGenerations: u64 = 0; pub const BlockHashCount: u64 = 250; - pub const MaximumBlockWeight: u32 = 1024; + pub const MaximumBlockWeight: Weight = 1024; pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); } diff --git a/frame/authorship/src/lib.rs b/frame/authorship/src/lib.rs index b4118b93a0..de7a07520e 100644 --- a/frame/authorship/src/lib.rs +++ b/frame/authorship/src/lib.rs @@ -365,7 +365,7 @@ mod tests { use sr_primitives::{ traits::{BlakeTwo256, IdentityLookup}, testing::Header, generic::DigestItem, Perbill, }; - use support::{parameter_types, impl_outer_origin, ConsensusEngineId}; + use support::{parameter_types, impl_outer_origin, ConsensusEngineId, weights::Weight}; impl_outer_origin!{ pub enum Origin for Test {} @@ -376,7 +376,7 @@ mod tests { parameter_types! { pub const BlockHashCount: u64 = 250; - pub const MaximumBlockWeight: u32 = 1024; + pub const MaximumBlockWeight: Weight = 1024; pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); } diff --git a/frame/babe/src/mock.rs b/frame/babe/src/mock.rs index d7aed7b42a..847b2a75e1 100644 --- a/frame/babe/src/mock.rs +++ b/frame/babe/src/mock.rs @@ -23,7 +23,7 @@ use sr_primitives::{ traits::IdentityLookup, Perbill, testing::{Header, UintAuthorityId}, impl_opaque_keys, }; use sr_version::RuntimeVersion; -use support::{impl_outer_origin, parameter_types}; +use support::{impl_outer_origin, parameter_types, weights::Weight}; use runtime_io; use primitives::{H256, Blake2Hasher}; @@ -39,7 +39,7 @@ pub struct Test; parameter_types! { pub const BlockHashCount: u64 = 250; - pub const MaximumBlockWeight: u32 = 1024; + pub const MaximumBlockWeight: Weight = 1024; pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); pub const MinimumPeriod: u64 = 1; diff --git a/frame/balances/src/mock.rs b/frame/balances/src/mock.rs index 62eabd1cf0..1756c77ce2 100644 --- a/frame/balances/src/mock.rs +++ b/frame/balances/src/mock.rs @@ -55,7 +55,7 @@ impl Get for CreationFee { pub struct Runtime; parameter_types! { pub const BlockHashCount: u64 = 250; - pub const MaximumBlockWeight: u32 = 1024; + pub const MaximumBlockWeight: Weight = 1024; pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); } diff --git a/frame/collective/src/lib.rs b/frame/collective/src/lib.rs index eff8366f07..dec87da246 100644 --- a/frame/collective/src/lib.rs +++ b/frame/collective/src/lib.rs @@ -378,7 +378,7 @@ impl< #[cfg(test)] mod tests { use super::*; - use support::{Hashable, assert_ok, assert_noop, parameter_types}; + use support::{Hashable, assert_ok, assert_noop, parameter_types, weights::Weight}; use system::{EventRecord, Phase}; use hex_literal::hex; use primitives::H256; @@ -390,7 +390,7 @@ mod tests { parameter_types! { pub const BlockHashCount: u64 = 250; - pub const MaximumBlockWeight: u32 = 1024; + pub const MaximumBlockWeight: Weight = 1024; pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); } diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index d06565ed8e..6129784d41 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -35,7 +35,7 @@ use sr_primitives::{ use support::{ assert_ok, assert_err, impl_outer_dispatch, impl_outer_event, impl_outer_origin, parameter_types, storage::child, StorageMap, StorageValue, traits::{Currency, Get}, - weights::{DispatchInfo, DispatchClass}, + weights::{DispatchInfo, DispatchClass, Weight}, }; use std::{cell::RefCell, sync::atomic::{AtomicUsize, Ordering}}; use primitives::storage::well_known_keys; @@ -94,7 +94,7 @@ impl Get for BlockGasLimit { pub struct Test; parameter_types! { pub const BlockHashCount: u64 = 250; - pub const MaximumBlockWeight: u32 = 1024; + pub const MaximumBlockWeight: Weight = 1024; pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); } diff --git a/frame/democracy/src/lib.rs b/frame/democracy/src/lib.rs index 3ff6c1e2ec..9842044461 100644 --- a/frame/democracy/src/lib.rs +++ b/frame/democracy/src/lib.rs @@ -972,7 +972,8 @@ mod tests { use super::*; use support::{ impl_outer_origin, impl_outer_dispatch, assert_noop, assert_ok, parameter_types, - traits::Contains + traits::Contains, + weights::Weight, }; use primitives::H256; use sr_primitives::{traits::{BlakeTwo256, IdentityLookup, Bounded}, testing::Header, Perbill}; @@ -1000,7 +1001,7 @@ mod tests { pub struct Test; parameter_types! { pub const BlockHashCount: u64 = 250; - pub const MaximumBlockWeight: u32 = 1024; + pub const MaximumBlockWeight: Weight = 1024; pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); } diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index 4ae237e378..338ceeba52 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -743,7 +743,7 @@ impl Module { mod tests { use super::*; use std::cell::RefCell; - use support::{assert_ok, assert_noop, parameter_types}; + use support::{assert_ok, assert_noop, parameter_types, weights::Weight}; use substrate_test_utils::assert_eq_uvec; use primitives::H256; use sr_primitives::{ @@ -754,7 +754,7 @@ mod tests { parameter_types! { pub const BlockHashCount: u64 = 250; - pub const MaximumBlockWeight: u32 = 1024; + pub const MaximumBlockWeight: Weight = 1024; pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); } diff --git a/frame/elections/src/mock.rs b/frame/elections/src/mock.rs index 77b13d74a1..173a45a248 100644 --- a/frame/elections/src/mock.rs +++ b/frame/elections/src/mock.rs @@ -21,7 +21,8 @@ use std::cell::RefCell; use support::{ StorageValue, StorageMap, parameter_types, assert_ok, - traits::{Get, ChangeMembers, Currency} + traits::{Get, ChangeMembers, Currency}, + weights::Weight, }; use primitives::H256; use sr_primitives::{ @@ -32,7 +33,7 @@ use crate as elections; parameter_types! { pub const BlockHashCount: u64 = 250; - pub const MaximumBlockWeight: u32 = 1024; + pub const MaximumBlockWeight: Weight = 1024; pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); } diff --git a/frame/example/src/lib.rs b/frame/example/src/lib.rs index cf22d38f69..a73e0d2868 100644 --- a/frame/example/src/lib.rs +++ b/frame/example/src/lib.rs @@ -287,7 +287,7 @@ impl WeighData<(&BalanceOf,)> for WeightForSetDummy { fn weigh_data(&self, target: (&BalanceOf,)) -> Weight { let multiplier = self.0; - (*target.0 * multiplier).saturated_into::() + (*target.0 * multiplier).saturated_into::() } } @@ -665,7 +665,7 @@ mod tests { pub struct Test; parameter_types! { pub const BlockHashCount: u64 = 250; - pub const MaximumBlockWeight: u32 = 1024; + pub const MaximumBlockWeight: Weight = 1024; pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); } diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index d160bd7bdd..d5dc5fa135 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -393,7 +393,7 @@ mod tests { pub struct Runtime; parameter_types! { pub const BlockHashCount: u64 = 250; - pub const MaximumBlockWeight: u32 = 1024; + pub const MaximumBlockWeight: Weight = 1024; pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); } @@ -641,7 +641,7 @@ mod tests { assert!(Executive::apply_extrinsic(x2.clone()).unwrap().is_ok()); // default weight for `TestXt` == encoded length. - assert_eq!(>::all_extrinsics_weight(), (3 * len) as u32); + assert_eq!(>::all_extrinsics_weight(), (3 * len) as Weight); assert_eq!(>::all_extrinsics_len(), 3 * len); let _ = >::finalize(); diff --git a/frame/finality-tracker/src/lib.rs b/frame/finality-tracker/src/lib.rs index 7d03f1bc7d..2be496ab45 100644 --- a/frame/finality-tracker/src/lib.rs +++ b/frame/finality-tracker/src/lib.rs @@ -199,7 +199,7 @@ mod tests { testing::Header, Perbill, traits::{BlakeTwo256, IdentityLookup, OnFinalize, Header as HeaderT}, }; - use support::{assert_ok, impl_outer_origin, parameter_types}; + use support::{assert_ok, impl_outer_origin, parameter_types, weights::Weight}; use frame_system as system; use std::cell::RefCell; @@ -230,7 +230,7 @@ mod tests { parameter_types! { pub const BlockHashCount: u64 = 250; - pub const MaximumBlockWeight: u32 = 1024; + pub const MaximumBlockWeight: Weight = 1024; pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); } diff --git a/frame/generic-asset/src/mock.rs b/frame/generic-asset/src/mock.rs index 57b13760fa..36dea84d66 100644 --- a/frame/generic-asset/src/mock.rs +++ b/frame/generic-asset/src/mock.rs @@ -26,7 +26,7 @@ use sr_primitives::{ traits::{BlakeTwo256, IdentityLookup}, }; use primitives::H256; -use support::{parameter_types, impl_outer_event, impl_outer_origin}; +use support::{parameter_types, impl_outer_event, impl_outer_origin, weights::Weight}; use super::*; @@ -41,7 +41,7 @@ impl_outer_origin! { pub struct Test; parameter_types! { pub const BlockHashCount: u64 = 250; - pub const MaximumBlockWeight: u32 = 1024; + pub const MaximumBlockWeight: Weight = 1024; pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); } diff --git a/frame/grandpa/src/mock.rs b/frame/grandpa/src/mock.rs index c6ea207557..3fdf807f24 100644 --- a/frame/grandpa/src/mock.rs +++ b/frame/grandpa/src/mock.rs @@ -20,7 +20,7 @@ use sr_primitives::{Perbill, DigestItem, traits::IdentityLookup, testing::{Header, UintAuthorityId}}; use runtime_io; -use support::{impl_outer_origin, impl_outer_event, parameter_types}; +use support::{impl_outer_origin, impl_outer_event, parameter_types, weights::Weight}; use primitives::H256; use codec::{Encode, Decode}; use crate::{AuthorityId, AuthorityList, GenesisConfig, Trait, Module, ConsensusLog}; @@ -43,7 +43,7 @@ impl Trait for Test { } parameter_types! { pub const BlockHashCount: u64 = 250; - pub const MaximumBlockWeight: u32 = 1024; + pub const MaximumBlockWeight: Weight = 1024; pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); } diff --git a/frame/im-online/src/mock.rs b/frame/im-online/src/mock.rs index 4be33c44ed..650353e6f9 100644 --- a/frame/im-online/src/mock.rs +++ b/frame/im-online/src/mock.rs @@ -26,7 +26,7 @@ use sr_staking_primitives::{SessionIndex, offence::ReportOffence}; use sr_primitives::testing::{Header, UintAuthorityId, TestXt}; use sr_primitives::traits::{IdentityLookup, BlakeTwo256, ConvertInto}; use primitives::H256; -use support::{impl_outer_origin, impl_outer_dispatch, parameter_types}; +use support::{impl_outer_origin, impl_outer_dispatch, parameter_types, weights::Weight}; use {runtime_io, system}; impl_outer_origin!{ @@ -96,7 +96,7 @@ pub struct Runtime; parameter_types! { pub const BlockHashCount: u64 = 250; - pub const MaximumBlockWeight: u32 = 1024; + pub const MaximumBlockWeight: Weight = 1024; pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); } diff --git a/frame/indices/src/mock.rs b/frame/indices/src/mock.rs index 427fd87c47..43b009a544 100644 --- a/frame/indices/src/mock.rs +++ b/frame/indices/src/mock.rs @@ -23,7 +23,7 @@ use ref_thread_local::{ref_thread_local, RefThreadLocal}; use sr_primitives::testing::Header; use sr_primitives::Perbill; use primitives::H256; -use support::{impl_outer_origin, parameter_types}; +use support::{impl_outer_origin, parameter_types, weights::Weight}; use {runtime_io, system}; use crate::{GenesisConfig, Module, Trait, IsDeadAccount, OnNewAccount, ResolveHint}; @@ -67,7 +67,7 @@ impl ResolveHint for TestResolveHint { pub struct Runtime; parameter_types! { pub const BlockHashCount: u64 = 250; - pub const MaximumBlockWeight: u32 = 1024; + pub const MaximumBlockWeight: Weight = 1024; pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); } diff --git a/frame/membership/src/lib.rs b/frame/membership/src/lib.rs index 472220cffd..0adddc1816 100644 --- a/frame/membership/src/lib.rs +++ b/frame/membership/src/lib.rs @@ -194,7 +194,7 @@ mod tests { use super::*; use std::cell::RefCell; - use support::{assert_ok, assert_noop, impl_outer_origin, parameter_types}; + use support::{assert_ok, assert_noop, impl_outer_origin, parameter_types, weights::Weight}; use primitives::H256; // The testing primitives are very useful for avoiding having to work with signatures // or public keys. `u64` is used as the `AccountId` and no `Signature`s are requried. @@ -212,7 +212,7 @@ mod tests { pub struct Test; parameter_types! { pub const BlockHashCount: u64 = 250; - pub const MaximumBlockWeight: u32 = 1024; + pub const MaximumBlockWeight: Weight = 1024; pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); } diff --git a/frame/nicks/src/lib.rs b/frame/nicks/src/lib.rs index 94b7043c17..a82b3d15a9 100644 --- a/frame/nicks/src/lib.rs +++ b/frame/nicks/src/lib.rs @@ -229,7 +229,7 @@ decl_module! { mod tests { use super::*; - use support::{assert_ok, assert_noop, impl_outer_origin, parameter_types}; + use support::{assert_ok, assert_noop, impl_outer_origin, parameter_types, weights::Weight}; use primitives::H256; use system::EnsureSignedBy; // The testing primitives are very useful for avoiding having to work with signatures @@ -249,7 +249,7 @@ mod tests { pub struct Test; parameter_types! { pub const BlockHashCount: u64 = 250; - pub const MaximumBlockWeight: u32 = 1024; + pub const MaximumBlockWeight: Weight = 1024; pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); } diff --git a/frame/offences/src/mock.rs b/frame/offences/src/mock.rs index 491c9681b1..dc331b3147 100644 --- a/frame/offences/src/mock.rs +++ b/frame/offences/src/mock.rs @@ -29,7 +29,10 @@ use sr_staking_primitives::{ use sr_primitives::testing::Header; use sr_primitives::traits::{IdentityLookup, BlakeTwo256}; use substrate_primitives::H256; -use support::{impl_outer_origin, impl_outer_event, parameter_types, StorageMap, StorageDoubleMap}; +use support::{ + impl_outer_origin, impl_outer_event, parameter_types, StorageMap, StorageDoubleMap, + weights::Weight, +}; use {runtime_io, system}; impl_outer_origin!{ @@ -65,7 +68,7 @@ pub fn with_on_offence_fractions) -> R>(f: F) -> pub struct Runtime; parameter_types! { pub const BlockHashCount: u64 = 250; - pub const MaximumBlockWeight: u32 = 1024; + pub const MaximumBlockWeight: Weight = 1024; pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); } diff --git a/frame/randomness-collective-flip/src/lib.rs b/frame/randomness-collective-flip/src/lib.rs index 595249b986..ba5f0f79f4 100644 --- a/frame/randomness-collective-flip/src/lib.rs +++ b/frame/randomness-collective-flip/src/lib.rs @@ -156,7 +156,7 @@ mod tests { use sr_primitives::{ Perbill, traits::{BlakeTwo256, OnInitialize, Header as _, IdentityLookup}, testing::Header, }; - use support::{impl_outer_origin, parameter_types, traits::Randomness}; + use support::{impl_outer_origin, parameter_types, weights::Weight, traits::Randomness}; #[derive(Clone, PartialEq, Eq)] pub struct Test; @@ -167,7 +167,7 @@ mod tests { parameter_types! { pub const BlockHashCount: u64 = 250; - pub const MaximumBlockWeight: u32 = 1024; + pub const MaximumBlockWeight: Weight = 1024; pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); } diff --git a/frame/scored-pool/src/mock.rs b/frame/scored-pool/src/mock.rs index 394f486a8b..b2e1b29cbf 100644 --- a/frame/scored-pool/src/mock.rs +++ b/frame/scored-pool/src/mock.rs @@ -19,7 +19,7 @@ use super::*; use std::cell::RefCell; -use support::{impl_outer_origin, parameter_types}; +use support::{impl_outer_origin, parameter_types, weights::Weight}; use primitives::H256; // The testing primitives are very useful for avoiding having to work with signatures // or public keys. `u64` is used as the `AccountId` and no `Signature`s are requried. @@ -45,7 +45,7 @@ parameter_types! { pub const ScoreOrigin: u64 = 3; pub const BlockHashCount: u64 = 250; - pub const MaximumBlockWeight: u32 = 1024; + pub const MaximumBlockWeight: Weight = 1024; pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); diff --git a/frame/session/src/mock.rs b/frame/session/src/mock.rs index cb95a35570..4a2c1d45c3 100644 --- a/frame/session/src/mock.rs +++ b/frame/session/src/mock.rs @@ -18,7 +18,7 @@ use super::*; use std::cell::RefCell; -use support::{impl_outer_origin, parameter_types}; +use support::{impl_outer_origin, parameter_types, weights::Weight}; use primitives::{crypto::key_types::DUMMY, H256}; use sr_primitives::{ Perbill, impl_opaque_keys, traits::{BlakeTwo256, IdentityLookup, ConvertInto}, @@ -152,7 +152,7 @@ pub struct Test; parameter_types! { pub const BlockHashCount: u64 = 250; - pub const MaximumBlockWeight: u32 = 1024; + pub const MaximumBlockWeight: Weight = 1024; pub const MaximumBlockLength: u32 = 2 * 1024; pub const MinimumPeriod: u64 = 5; pub const AvailableBlockRatio: Perbill = Perbill::one(); diff --git a/frame/staking/src/mock.rs b/frame/staking/src/mock.rs index f6068a4773..91cffb8b74 100644 --- a/frame/staking/src/mock.rs +++ b/frame/staking/src/mock.rs @@ -24,8 +24,11 @@ use sr_primitives::testing::{Header, UintAuthorityId}; use sr_staking_primitives::{SessionIndex, offence::{OffenceDetails, OnOffenceHandler}}; use primitives::{H256, crypto::key_types}; use runtime_io; -use support::{assert_ok, impl_outer_origin, parameter_types, StorageLinkedMap, StorageValue}; -use support::traits::{Currency, Get, FindAuthor}; +use support::{ + assert_ok, impl_outer_origin, parameter_types, StorageLinkedMap, StorageValue, + traits::{Currency, Get, FindAuthor}, + weights::Weight, +}; use crate::{ EraIndex, GenesisConfig, Module, Trait, StakerStatus, ValidatorPrefs, RewardDestination, Nominators, inflation @@ -114,7 +117,7 @@ impl FindAuthor for Author11 { pub struct Test; parameter_types! { pub const BlockHashCount: u64 = 250; - pub const MaximumBlockWeight: u32 = 1024; + pub const MaximumBlockWeight: Weight = 1024; pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); } diff --git a/frame/system/benches/bench.rs b/frame/system/benches/bench.rs index f42d5f6bd3..bdf3b83a38 100644 --- a/frame/system/benches/bench.rs +++ b/frame/system/benches/bench.rs @@ -16,7 +16,7 @@ use criterion::{Criterion, criterion_group, criterion_main, black_box}; use frame_system as system; -use support::{decl_module, decl_event, impl_outer_origin, impl_outer_event}; +use support::{decl_module, decl_event, impl_outer_origin, impl_outer_event, weights::Weight}; use primitives::H256; use sr_primitives::{Perbill, traits::{BlakeTwo256, IdentityLookup}, testing::Header}; @@ -52,7 +52,7 @@ impl_outer_event! { support::parameter_types! { pub const BlockHashCount: u64 = 250; - pub const MaximumBlockWeight: u32 = 4 * 1024 * 1024; + pub const MaximumBlockWeight: Weight = 4 * 1024 * 1024; pub const MaximumBlockLength: u32 = 4 * 1024 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75); } diff --git a/frame/timestamp/src/lib.rs b/frame/timestamp/src/lib.rs index 9585f350eb..73f9cd71b6 100644 --- a/frame/timestamp/src/lib.rs +++ b/frame/timestamp/src/lib.rs @@ -240,7 +240,7 @@ impl Time for Module { mod tests { use super::*; - use support::{impl_outer_origin, assert_ok, parameter_types}; + use support::{impl_outer_origin, assert_ok, parameter_types, weights::Weight}; use runtime_io::TestExternalities; use primitives::H256; use sr_primitives::{Perbill, traits::{BlakeTwo256, IdentityLookup}, testing::Header}; @@ -253,7 +253,7 @@ mod tests { pub struct Test; parameter_types! { pub const BlockHashCount: u64 = 250; - pub const MaximumBlockWeight: u32 = 1024; + pub const MaximumBlockWeight: Weight = 1024; pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); } diff --git a/frame/transaction-payment/src/lib.rs b/frame/transaction-payment/src/lib.rs index c7310ac587..abb7518e35 100644 --- a/frame/transaction-payment/src/lib.rs +++ b/frame/transaction-payment/src/lib.rs @@ -269,7 +269,7 @@ mod tests { parameter_types! { pub const BlockHashCount: u64 = 250; - pub const MaximumBlockWeight: u32 = 1024; + pub const MaximumBlockWeight: Weight = 1024; pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); } diff --git a/frame/treasury/src/lib.rs b/frame/treasury/src/lib.rs index d71f8731c4..30ebc6f5a3 100644 --- a/frame/treasury/src/lib.rs +++ b/frame/treasury/src/lib.rs @@ -351,7 +351,7 @@ impl OnUnbalanced> for Module { mod tests { use super::*; - use support::{assert_noop, assert_ok, impl_outer_origin, parameter_types}; + use support::{assert_noop, assert_ok, impl_outer_origin, parameter_types, weights::Weight}; use primitives::H256; use sr_primitives::{ traits::{BlakeTwo256, OnFinalize, IdentityLookup}, testing::Header, Perbill @@ -365,7 +365,7 @@ mod tests { pub struct Test; parameter_types! { pub const BlockHashCount: u64 = 250; - pub const MaximumBlockWeight: u32 = 1024; + pub const MaximumBlockWeight: Weight = 1024; pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); } diff --git a/frame/utility/src/lib.rs b/frame/utility/src/lib.rs index ae5a4bd6cb..2fc5194f7d 100644 --- a/frame/utility/src/lib.rs +++ b/frame/utility/src/lib.rs @@ -63,7 +63,10 @@ decl_module! { mod tests { use super::*; - use support::{assert_ok, assert_noop, impl_outer_origin, parameter_types, impl_outer_dispatch}; + use support::{ + assert_ok, assert_noop, impl_outer_origin, parameter_types, impl_outer_dispatch, + weights::Weight + }; use primitives::H256; use sr_primitives::{Perbill, traits::{BlakeTwo256, IdentityLookup}, testing::Header}; @@ -85,7 +88,7 @@ mod tests { pub struct Test; parameter_types! { pub const BlockHashCount: u64 = 250; - pub const MaximumBlockWeight: u32 = 1024; + pub const MaximumBlockWeight: Weight = 1024; pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); } diff --git a/test/utils/runtime/src/lib.rs b/test/utils/runtime/src/lib.rs index 7dd98c56c0..7761cfb944 100644 --- a/test/utils/runtime/src/lib.rs +++ b/test/utils/runtime/src/lib.rs @@ -47,7 +47,7 @@ use runtime_version::RuntimeVersion; pub use primitives::{hash::H256}; #[cfg(any(feature = "std", test))] use runtime_version::NativeVersion; -use runtime_support::{impl_outer_origin, parameter_types}; +use runtime_support::{impl_outer_origin, parameter_types, weights::Weight}; use inherents::{CheckInherentsResult, InherentData}; use cfg_if::cfg_if; @@ -353,7 +353,7 @@ impl From for Event { parameter_types! { pub const BlockHashCount: BlockNumber = 250; pub const MinimumPeriod: u64 = 5; - pub const MaximumBlockWeight: u32 = 4 * 1024 * 1024; + pub const MaximumBlockWeight: Weight = 4 * 1024 * 1024; pub const MaximumBlockLength: u32 = 4 * 1024 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75); } -- GitLab From b41085293e28b699702519879a73349a1ddcc439 Mon Sep 17 00:00:00 2001 From: thiolliere Date: Fri, 29 Nov 2019 20:25:30 +0100 Subject: [PATCH 049/172] remove unused file (#4251) --- client/executor/src/host_interface.rs | 1075 ------------------------- 1 file changed, 1075 deletions(-) delete mode 100644 client/executor/src/host_interface.rs diff --git a/client/executor/src/host_interface.rs b/client/executor/src/host_interface.rs deleted file mode 100644 index 0499cad566..0000000000 --- a/client/executor/src/host_interface.rs +++ /dev/null @@ -1,1075 +0,0 @@ -// Copyright 2017-2019 Parity Technologies (UK) Ltd. -// This file is part of Substrate. - -// Substrate is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Substrate is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Substrate. If not, see . - -//! Definition and implementation of the old and deprecated Substrate runtime interface for the host. - -use codec::Encode; -use std::{convert::TryFrom, str}; -use primitives::{ - blake2_128, blake2_256, twox_64, twox_128, twox_256, ed25519, sr25519, Blake2Hasher, Pair, - crypto::KeyTypeId, offchain, -}; -use trie::{TrieConfiguration, trie_types::Layout}; -use wasm_interface::{ - Pointer, WordSize, WritePrimitive, ReadPrimitive, FunctionContext, Result as WResult, -}; - -#[cfg(feature="wasm-extern-trace")] -macro_rules! debug_trace { - ( $( $x:tt )* ) => ( trace!( $( $x )* ) ) -} - -#[cfg(not(feature="wasm-extern-trace"))] -macro_rules! debug_trace { - ( $( $x:tt )* ) => () -} - -/// The old and deprecated Substrate externals. These are still required for backwards compatibility -/// reasons. -pub struct SubstrateExternals; - -enum RecoverResult { - Invalid(u32), - Valid(secp256k1::PublicKey), -} - -fn secp256k1_recover( - context: &mut dyn FunctionContext, - msg_data: Pointer, - sig_data: Pointer, -) -> WResult { - let mut sig = [0u8; 65]; - context.read_memory_into(sig_data, &mut sig[..]) - .map_err(|_| "Invalid attempt to get signature in ext_secp256k1_ecdsa_recover")?; - let rs = match secp256k1::Signature::parse_slice(&sig[0..64]) { - Ok(rs) => rs, - _ => return Ok(RecoverResult::Invalid(1)), - }; - - let recovery_id = if sig[64] > 26 { sig[64] - 27 } else { sig[64] } as u8; - let v = match secp256k1::RecoveryId::parse(recovery_id) { - Ok(v) => v, - _ => return Ok(RecoverResult::Invalid(2)), - }; - - let mut msg = [0u8; 32]; - context.read_memory_into(msg_data, &mut msg[..]) - .map_err(|_| "Invalid attempt to get message in ext_secp256k1_ecdsa_recover")?; - - Ok(match secp256k1::recover(&secp256k1::Message::parse(&msg), &rs, &v) { - Ok(pubkey) => RecoverResult::Valid(pubkey), - Err(_) => RecoverResult::Invalid(3), - }) -} - -impl_wasm_host_interface! { - impl SubstrateExternals where context { - ext_malloc(size: WordSize) -> Pointer { - let r = context.allocate_memory(size)?; - debug_trace!(target: "sr-io", "malloc {} bytes at {:?}", size, r); - Ok(r) - } - - ext_free(addr: Pointer) { - context.deallocate_memory(addr)?; - debug_trace!(target: "sr-io", "free {:?}", addr); - Ok(()) - } - - ext_sandbox_instantiate( - dispatch_thunk_idx: u32, - wasm_ptr: Pointer, - wasm_len: WordSize, - imports_ptr: Pointer, - imports_len: WordSize, - state: u32, - ) -> u32 { - let wasm = context.read_memory(wasm_ptr, wasm_len) - .map_err(|_| "OOB while ext_sandbox_instantiate: wasm")?; - let raw_env_def = context.read_memory(imports_ptr, imports_len) - .map_err(|_| "OOB while ext_sandbox_instantiate: imports")?; - - context.sandbox().instance_new(dispatch_thunk_idx, &wasm, &raw_env_def, state) - } - - ext_sandbox_instance_teardown(instance_idx: u32) { - context.sandbox().instance_teardown(instance_idx) - } - - ext_sandbox_invoke( - instance_idx: u32, - export_ptr: Pointer, - export_len: WordSize, - args_ptr: Pointer, - args_len: WordSize, - return_val_ptr: Pointer, - return_val_len: WordSize, - state: u32, - ) -> u32 { - let export = context.read_memory(export_ptr, export_len) - .map_err(|_| "OOB while ext_sandbox_invoke: export") - .and_then(|b| - String::from_utf8(b) - .map_err(|_| "Export name should be a valid utf-8 sequence") - )?; - - // Deserialize arguments and convert them into wasmi types. - let serialized_args = context.read_memory(args_ptr, args_len) - .map_err(|_| "OOB while ext_sandbox_invoke: args")?; - - context.sandbox().invoke( - instance_idx, - &export, - &serialized_args, - return_val_ptr, - return_val_len, - state, - ) - } - - ext_sandbox_memory_new(initial: WordSize, maximum: WordSize) -> u32 { - context.sandbox().memory_new(initial, maximum) - } - - ext_sandbox_memory_get( - memory_idx: u32, - offset: WordSize, - buf_ptr: Pointer, - buf_len: WordSize, - ) -> u32 { - context.sandbox().memory_get(memory_idx, offset, buf_ptr, buf_len) - } - - ext_sandbox_memory_set( - memory_idx: u32, - offset: WordSize, - val_ptr: Pointer, - val_len: WordSize, - ) -> u32 { - context.sandbox().memory_set(memory_idx, offset, val_ptr, val_len) - } - - ext_sandbox_memory_teardown(memory_idx: u32) { - context.sandbox().memory_teardown(memory_idx) - } - - 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); - } - Ok(()) - } - - ext_print_hex(data: Pointer, len: WordSize) { - if let Ok(hex) = context.read_memory(data, len) { - runtime_io::misc::print_hex(&hex); - } - Ok(()) - } - - ext_print_num(number: u64) { - runtime_io::misc::print_num(number); - Ok(()) - } - - ext_log( - level: u32, - target_data: Pointer, - target_len: WordSize, - message_data: Pointer, - message_len: WordSize, - ) { - let target = context.read_memory(target_data, target_len) - .map_err(|_| "Invalid attempt to determine target in ext_log")?; - let message = context.read_memory(message_data, message_len) - .map_err(|_| "Invalid attempt to determine message in ext_log")?; - - 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); - Ok(()) - } - - ext_set_storage( - key_data: Pointer, - key_len: WordSize, - value_data: Pointer, - value_len: WordSize, - ) { - let key = context.read_memory(key_data, key_len) - .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)) - } - - ext_set_child_storage( - storage_key_data: Pointer, - storage_key_len: WordSize, - key_data: Pointer, - key_len: WordSize, - value_data: Pointer, - value_len: WordSize, - ) { - let storage_key = context.read_memory(storage_key_data, storage_key_len) - .map_err(|_| "Invalid attempt to determine storage_key in ext_set_child_storage")?; - let key = context.read_memory(key_data, key_len) - .map_err(|_| "Invalid attempt to determine key in ext_set_child_storage")?; - 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)) - } - - ext_clear_child_storage( - storage_key_data: Pointer, - storage_key_len: WordSize, - key_data: Pointer, - 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_clear_child_storage")?; - 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)) - } - - 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)) - } - - 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 }) - } - - ext_exists_child_storage( - storage_key_data: Pointer, - storage_key_len: WordSize, - key_data: Pointer, - key_len: WordSize, - ) -> u32 { - let storage_key = context.read_memory(storage_key_data, storage_key_len) - .map_err(|_| "Invalid attempt to determine storage_key in ext_exists_child_storage")?; - 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 }) - } - - 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)) - } - - ext_clear_child_prefix( - storage_key_data: Pointer, - storage_key_len: WordSize, - prefix_data: Pointer, - prefix_len: WordSize, - ) { - let storage_key = context.read_memory(storage_key_data, storage_key_len) - .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)) - } - - 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)) - } - - ext_get_allocated_storage( - key_data: Pointer, - key_len: WordSize, - written_out: Pointer, - ) -> Pointer { - 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) { - 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")?; - context.write_primitive(written_out, value.len() as u32) - .map_err(|_| "Invalid attempt to write written_out in ext_get_allocated_storage")?; - Ok(offset) - } else { - context.write_primitive(written_out, u32::max_value()) - .map_err(|_| "Invalid attempt to write failed written_out in ext_get_allocated_storage")?; - Ok(Pointer::null()) - } - } - - ext_get_allocated_child_storage( - storage_key_data: Pointer, - storage_key_len: WordSize, - key_data: Pointer, - key_len: WordSize, - written_out: Pointer, - ) -> Pointer { - let storage_key = context.read_memory(storage_key_data, storage_key_len) - .map_err(|_| "Invalid attempt to determine storage_key in ext_get_allocated_child_storage")?; - 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) { - 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")?; - context.write_primitive(written_out, value.len() as u32) - .map_err(|_| "Invalid attempt to write written_out in ext_get_allocated_child_storage")?; - Ok(offset) - } else { - context.write_primitive(written_out, u32::max_value()) - .map_err(|_| "Invalid attempt to write failed written_out in ext_get_allocated_child_storage")?; - Ok(Pointer::null()) - } - } - - ext_get_storage_into( - key_data: Pointer, - key_len: WordSize, - value_data: Pointer, - value_len: WordSize, - value_offset: WordSize, - ) -> WordSize { - 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) { - 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]) - .map_err(|_| "Invalid attempt to set value in ext_get_storage_into")?; - Ok(value.len() as u32) - } else { - Ok(u32::max_value()) - } - } - - ext_get_child_storage_into( - storage_key_data: Pointer, - storage_key_len: WordSize, - key_data: Pointer, - key_len: WordSize, - value_data: Pointer, - value_len: WordSize, - value_offset: WordSize, - ) -> WordSize { - let storage_key = context.read_memory(storage_key_data, storage_key_len) - .map_err(|_| "Invalid attempt to determine storage_key in ext_get_child_storage_into")?; - 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) { - 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]) - .map_err(|_| "Invalid attempt to get value in ext_get_child_storage_into")?; - Ok(value.len() as u32) - } else { - Ok(u32::max_value()) - } - } - - ext_storage_root(result: Pointer) { - context.write_memory(result, runtime_io::storage::root().as_ref()) - .map_err(|_| "Invalid attempt to set memory in ext_storage_root".into()) - } - - ext_child_storage_root( - storage_key_data: Pointer, - storage_key_len: WordSize, - written_out: Pointer, - ) -> 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 offset = context.allocate_memory(value.len() as u32)?; - context.write_memory(offset, &value) - .map_err(|_| "Invalid attempt to set memory in ext_child_storage_root")?; - context.write_primitive(written_out, value.len() as u32) - .map_err(|_| "Invalid attempt to write written_out in ext_child_storage_root")?; - Ok(offset) - } - - ext_storage_changes_root( - parent_hash_data: Pointer, - _len: WordSize, - result: Pointer, - ) -> u32 { - let mut parent_hash = [0u8; 32]; - 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) { - context.write_memory(result, &r[..]) - .map_err(|_| "Invalid attempt to set memory in ext_storage_changes_root")?; - Ok(1) - } else { - Ok(0) - } - } - - ext_blake2_256_enumerated_trie_root( - values_data: Pointer, - lens_data: Pointer, - lens_len: WordSize, - result: Pointer, - ) { - let values = (0..lens_len) - .map(|i| context.read_primitive(lens_data.offset(i).ok_or("Pointer overflow")?)) - .collect::, _>>()? - .into_iter() - .scan(0u32, |acc, v| { let o = *acc; *acc += v; Some((o, v)) }) - .map(|(offset, len)| - context.read_memory(values_data.offset(offset).ok_or("Pointer overflow")?, len) - .map_err(|_| - "Invalid attempt to get memory in ext_blake2_256_enumerated_trie_root" - ) - ) - .collect::, _>>()?; - let r = Layout::::ordered_trie_root(values.into_iter()); - context.write_memory(result, &r[..]) - .map_err(|_| "Invalid attempt to set memory in ext_blake2_256_enumerated_trie_root")?; - Ok(()) - } - - ext_chain_id() -> u64 { - Ok(runtime_io::misc::chain_id()) - } - - ext_twox_64(data: Pointer, len: WordSize, out: Pointer) { - let result: [u8; 8] = if len == 0 { - let hashed = twox_64(&[0u8; 0]); - hashed - } else { - let key = context.read_memory(data, len) - .map_err(|_| "Invalid attempt to get key in ext_twox_64")?; - let hashed_key = twox_64(&key); - hashed_key - }; - - context.write_memory(out, &result) - .map_err(|_| "Invalid attempt to set result in ext_twox_64")?; - Ok(()) - } - - ext_twox_128(data: Pointer, len: WordSize, out: Pointer) { - let result: [u8; 16] = if len == 0 { - let hashed = twox_128(&[0u8; 0]); - hashed - } else { - let key = context.read_memory(data, len) - .map_err(|_| "Invalid attempt to get key in ext_twox_128")?; - let hashed_key = twox_128(&key); - hashed_key - }; - - context.write_memory(out, &result) - .map_err(|_| "Invalid attempt to set result in ext_twox_128")?; - Ok(()) - } - - ext_twox_256(data: Pointer, len: WordSize, out: Pointer) { - let result: [u8; 32] = if len == 0 { - twox_256(&[0u8; 0]) - } else { - let mem = context.read_memory(data, len) - .map_err(|_| "Invalid attempt to get data in ext_twox_256")?; - twox_256(&mem) - }; - context.write_memory(out, &result) - .map_err(|_| "Invalid attempt to set result in ext_twox_256")?; - Ok(()) - } - - ext_blake2_128(data: Pointer, len: WordSize, out: Pointer) { - let result: [u8; 16] = if len == 0 { - let hashed = blake2_128(&[0u8; 0]); - hashed - } else { - let key = context.read_memory(data, len) - .map_err(|_| "Invalid attempt to get key in ext_blake2_128")?; - let hashed_key = blake2_128(&key); - hashed_key - }; - - context.write_memory(out, &result) - .map_err(|_| "Invalid attempt to set result in ext_blake2_128")?; - Ok(()) - } - - ext_blake2_256(data: Pointer, len: WordSize, out: Pointer) { - let result: [u8; 32] = if len == 0 { - blake2_256(&[0u8; 0]) - } else { - let mem = context.read_memory(data, len) - .map_err(|_| "Invalid attempt to get data in ext_blake2_256")?; - blake2_256(&mem) - }; - context.write_memory(out, &result) - .map_err(|_| "Invalid attempt to set result in ext_blake2_256")?; - Ok(()) - } - - ext_keccak_256(data: Pointer, len: WordSize, out: Pointer) { - let result: [u8; 32] = if len == 0 { - tiny_keccak::keccak256(&[0u8; 0]) - } else { - let mem = context.read_memory(data, len) - .map_err(|_| "Invalid attempt to get data in ext_keccak_256")?; - tiny_keccak::keccak256(&mem) - }; - context.write_memory(out, &result) - .map_err(|_| "Invalid attempt to set result in ext_keccak_256")?; - Ok(()) - } - - ext_ed25519_public_keys(id_data: Pointer, result_len: Pointer) -> Pointer { - let mut id = [0u8; 4]; - context.read_memory_into(id_data, &mut id[..]) - .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 len = keys.len() as u32; - let offset = context.allocate_memory(len)?; - - context.write_memory(offset, keys.as_ref()) - .map_err(|_| "Invalid attempt to set memory in ext_ed25519_public_keys")?; - context.write_primitive(result_len, len) - .map_err(|_| "Invalid attempt to write result_len in ext_ed25519_public_keys")?; - - Ok(offset) - } - - ext_ed25519_verify( - msg_data: Pointer, - msg_len: WordSize, - sig_data: Pointer, - pubkey_data: Pointer, - ) -> u32 { - let mut sig = [0u8; 64]; - context.read_memory_into(sig_data, &mut sig[..]) - .map_err(|_| "Invalid attempt to get signature in ext_ed25519_verify")?; - let mut pubkey = [0u8; 32]; - context.read_memory_into(pubkey_data, &mut pubkey[..]) - .map_err(|_| "Invalid attempt to get pubkey in ext_ed25519_verify")?; - let msg = context.read_memory(msg_data, msg_len) - .map_err(|_| "Invalid attempt to get message in ext_ed25519_verify")?; - - Ok(if ed25519::Pair::verify_weak(&sig, &msg, &pubkey) { - 0 - } else { - 1 - }) - } - - ext_ed25519_generate( - id_data: Pointer, - seed: Pointer, - seed_len: WordSize, - out: Pointer, - ) { - let mut id = [0u8; 4]; - context.read_memory_into(id_data, &mut id[..]) - .map_err(|_| "Invalid attempt to get id in ext_ed25519_generate")?; - let key_type = KeyTypeId(id); - - let seed = if seed_len == 0 { - None - } else { - Some( - context.read_memory(seed, seed_len) - .map_err(|_| "Invalid attempt to get seed in ext_ed25519_generate")? - ) - }; - - let pubkey = runtime_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()) - } - - ext_ed25519_sign( - id_data: Pointer, - pubkey_data: Pointer, - msg_data: Pointer, - msg_len: WordSize, - out: Pointer, - ) -> u32 { - let mut id = [0u8; 4]; - context.read_memory_into(id_data, &mut id[..]) - .map_err(|_| "Invalid attempt to get id in ext_ed25519_sign")?; - let key_type = KeyTypeId(id); - - let mut pubkey = [0u8; 32]; - context.read_memory_into(pubkey_data, &mut pubkey[..]) - .map_err(|_| "Invalid attempt to get pubkey in ext_ed25519_sign")?; - - let msg = context.read_memory(msg_data, msg_len) - .map_err(|_| "Invalid attempt to get message in ext_ed25519_sign")?; - - 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); - - match signature { - Some(signature) => { - context.write_memory(out, signature.as_ref()) - .map_err(|_| "Invalid attempt to set out in ext_ed25519_sign")?; - Ok(0) - }, - None => Ok(1), - } - } - - ext_sr25519_public_keys(id_data: Pointer, result_len: Pointer) -> Pointer { - let mut id = [0u8; 4]; - context.read_memory_into(id_data, &mut id[..]) - .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 len = keys.len() as u32; - let offset = context.allocate_memory(len)?; - - context.write_memory(offset, keys.as_ref()) - .map_err(|_| "Invalid attempt to set memory in ext_sr25519_public_keys")?; - context.write_primitive(result_len, len) - .map_err(|_| "Invalid attempt to write result_len in ext_sr25519_public_keys")?; - - Ok(offset) - } - - ext_sr25519_verify( - msg_data: Pointer, - msg_len: WordSize, - sig_data: Pointer, - pubkey_data: Pointer, - ) -> u32 { - let mut sig = [0u8; 64]; - context.read_memory_into(sig_data, &mut sig[..]) - .map_err(|_| "Invalid attempt to get signature in ext_sr25519_verify")?; - let mut pubkey = [0u8; 32]; - context.read_memory_into(pubkey_data, &mut pubkey[..]) - .map_err(|_| "Invalid attempt to get pubkey in ext_sr25519_verify")?; - let msg = context.read_memory(msg_data, msg_len) - .map_err(|_| "Invalid attempt to get message in ext_sr25519_verify")?; - - Ok(if sr25519::Pair::verify_weak(&sig, &msg, &pubkey) { - 0 - } else { - 1 - }) - } - - ext_sr25519_generate( - id_data: Pointer, - seed: Pointer, - seed_len: WordSize, - out: Pointer, - ) { - let mut id = [0u8; 4]; - context.read_memory_into(id_data, &mut id[..]) - .map_err(|_| "Invalid attempt to get id in ext_sr25519_generate")?; - let key_type = KeyTypeId(id); - let seed = if seed_len == 0 { - None - } else { - Some( - context.read_memory(seed, seed_len) - .map_err(|_| "Invalid attempt to get seed in ext_sr25519_generate")? - ) - }; - - let pubkey = runtime_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()) - } - - ext_sr25519_sign( - id_data: Pointer, - pubkey_data: Pointer, - msg_data: Pointer, - msg_len: WordSize, - out: Pointer, - ) -> u32 { - let mut id = [0u8; 4]; - context.read_memory_into(id_data, &mut id[..]) - .map_err(|_| "Invalid attempt to get id in ext_sr25519_sign")?; - let key_type = KeyTypeId(id); - - let mut pubkey = [0u8; 32]; - context.read_memory_into(pubkey_data, &mut pubkey[..]) - .map_err(|_| "Invalid attempt to get pubkey in ext_sr25519_sign")?; - - let msg = context.read_memory(msg_data, msg_len) - .map_err(|_| "Invalid attempt to get message in ext_sr25519_sign")?; - - 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); - - match signature { - Some(signature) => { - context.write_memory(out, signature.as_ref()) - .map_err(|_| "Invalid attempt to set out in ext_sr25519_sign")?; - Ok(0) - }, - None => Ok(1), - } - } - - ext_secp256k1_ecdsa_recover( - msg_data: Pointer, - sig_data: Pointer, - pubkey_data: Pointer, - ) -> u32 { - match secp256k1_recover(context, msg_data, sig_data)? { - RecoverResult::Invalid(c) => Ok(c), - RecoverResult::Valid(pubkey) => { - context.write_memory(pubkey_data, &pubkey.serialize()[1..65]) - .map_err(|_| "Invalid attempt to set pubkey in ext_secp256k1_ecdsa_recover")?; - Ok(0) - } - } - } - - ext_secp256k1_ecdsa_recover_compressed( - msg_data: Pointer, - sig_data: Pointer, - pubkey_data: Pointer, - ) -> u32 { - match secp256k1_recover(context, msg_data, sig_data)? { - RecoverResult::Invalid(c) => Ok(c), - RecoverResult::Valid(pubkey) => { - context.write_memory(pubkey_data, &pubkey.serialize_compressed()[..]) - .map_err(|_| "Invalid attempt to set pubkey in ext_secp256k1_ecdsa_recover")?; - Ok(0) - } - } - } - - ext_is_validator() -> u32 { - if runtime_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); - - Ok(if res.is_ok() { 0 } else { 1 }) - } - - ext_network_state(written_out: Pointer) -> Pointer { - let res = runtime_io::offchain::network_state(); - - let encoded = res.encode(); - let len = encoded.len() as u32; - let offset = context.allocate_memory(len)?; - context.write_memory(offset, &encoded) - .map_err(|_| "Invalid attempt to set memory in ext_network_state")?; - - context.write_primitive(written_out, len) - .map_err(|_| "Invalid attempt to write written_out in ext_network_state")?; - - Ok(offset) - } - - ext_timestamp() -> u64 { - Ok(runtime_io::offchain::timestamp().unix_millis()) - } - - ext_sleep_until(deadline: u64) { - runtime_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(); - - context.write_memory(seed_data, &seed) - .map_err(|_| "Invalid attempt to set value in ext_random_seed")?; - Ok(()) - } - - ext_local_storage_set( - kind: u32, - key: Pointer, - key_len: WordSize, - value: Pointer, - value_len: WordSize, - ) { - let kind = offchain::StorageKind::try_from(kind) - .map_err(|_| "storage kind OOB while ext_local_storage_set: wasm")?; - let key = context.read_memory(key, key_len) - .map_err(|_| "OOB while ext_local_storage_set: wasm")?; - 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); - - Ok(()) - } - - ext_local_storage_get( - kind: u32, - key: Pointer, - key_len: WordSize, - value_len: Pointer, - ) -> Pointer { - let kind = offchain::StorageKind::try_from(kind) - .map_err(|_| "storage kind OOB while ext_local_storage_get: wasm")?; - 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 (offset, len) = if let Some(value) = maybe_value { - let offset = context.allocate_memory(value.len() as u32)?; - context.write_memory(offset, &value) - .map_err(|_| "Invalid attempt to set memory in ext_local_storage_get")?; - (offset, value.len() as u32) - } else { - (Pointer::null(), u32::max_value()) - }; - - context.write_primitive(value_len, len) - .map_err(|_| "Invalid attempt to write value_len in ext_local_storage_get")?; - - Ok(offset) - } - - ext_local_storage_compare_and_set( - kind: u32, - key: Pointer, - key_len: WordSize, - old_value: Pointer, - old_value_len: WordSize, - new_value: Pointer, - new_value_len: WordSize, - ) -> u32 { - let kind = offchain::StorageKind::try_from(kind) - .map_err(|_| "storage kind OOB while ext_local_storage_compare_and_set: wasm")?; - let key = context.read_memory(key, key_len) - .map_err(|_| "OOB while ext_local_storage_compare_and_set: wasm")?; - let new_value = context.read_memory(new_value, new_value_len) - .map_err(|_| "OOB while ext_local_storage_compare_and_set: wasm")?; - - let old_value = if old_value_len == u32::max_value() { - None - } else { - Some( - context.read_memory(old_value, old_value_len) - .map_err(|_| "OOB while ext_local_storage_compare_and_set: wasm")? - ) - }; - - let res = runtime_io::offchain::local_storage_compare_and_set( - kind, - &key, - old_value, - &new_value, - ); - - Ok(if res { 0 } else { 1 }) - } - - ext_http_request_start( - method: Pointer, - method_len: WordSize, - url: Pointer, - url_len: WordSize, - meta: Pointer, - meta_len: WordSize, - ) -> u32 { - let method = context.read_memory(method, method_len) - .map_err(|_| "OOB while ext_http_request_start: wasm")?; - let url = context.read_memory(url, url_len) - .map_err(|_| "OOB while ext_http_request_start: wasm")?; - let meta = context.read_memory(meta, meta_len) - .map_err(|_| "OOB while ext_http_request_start: wasm")?; - - let method_str = str::from_utf8(&method) - .map_err(|_| "invalid str while ext_http_request_start: wasm")?; - 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); - - if let Ok(id) = id { - Ok(id.into()) - } else { - Ok(u32::max_value()) - } - } - - ext_http_request_add_header( - request_id: u32, - name: Pointer, - name_len: WordSize, - value: Pointer, - value_len: WordSize, - ) -> u32 { - let name = context.read_memory(name, name_len) - .map_err(|_| "OOB while ext_http_request_add_header: wasm")?; - let value = context.read_memory(value, value_len) - .map_err(|_| "OOB while ext_http_request_add_header: wasm")?; - - let name_str = str::from_utf8(&name) - .map_err(|_| "Invalid str while ext_http_request_add_header: wasm")?; - 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( - offchain::HttpRequestId(request_id as u16), - name_str, - value_str, - ); - - Ok(if res.is_ok() { 0 } else { 1 }) - } - - ext_http_request_write_body( - request_id: u32, - chunk: Pointer, - chunk_len: WordSize, - deadline: u64, - ) -> u32 { - 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( - offchain::HttpRequestId(request_id as u16), - &chunk, - deadline_to_timestamp(deadline), - ); - - Ok(match res { - Ok(()) => 0, - Err(e) => e.into(), - }) - } - - ext_http_response_wait( - ids: Pointer, - ids_len: WordSize, - statuses: Pointer, - deadline: u64, - ) { - let ids = (0..ids_len) - .map(|i| - context.read_primitive(ids.offset(i).ok_or("Point overflow")?) - .map(|id: u32| offchain::HttpRequestId(id as u16)) - .map_err(|_| "OOB while ext_http_response_wait: wasm") - ) - .collect::, _>>()?; - - let res = runtime_io::offchain::http_response_wait(&ids, deadline_to_timestamp(deadline)) - .into_iter() - .map(|status| u32::from(status)) - .enumerate() - // make sure to take up to `ids_len` to avoid exceeding the mem. - .take(ids_len as usize); - - for (i, status) in res { - context.write_primitive(statuses.offset(i as u32).ok_or("Point overflow")?, status) - .map_err(|_| "Invalid attempt to set memory in ext_http_response_wait")?; - } - - Ok(()) - } - - ext_http_response_headers( - request_id: u32, - written_out: Pointer, - ) -> Pointer { - use codec::Encode; - - let headers = runtime_io::offchain::http_response_headers( - offchain::HttpRequestId(request_id as u16), - ); - - let encoded = headers.encode(); - let len = encoded.len() as u32; - let offset = context.allocate_memory(len)?; - - context.write_memory(offset, &encoded) - .map_err(|_| "Invalid attempt to set memory in ext_http_response_headers")?; - context.write_primitive(written_out, len) - .map_err(|_| "Invalid attempt to write written_out in ext_http_response_headers")?; - - Ok(offset) - } - - ext_http_response_read_body( - request_id: u32, - buffer: Pointer, - buffer_len: WordSize, - deadline: u64, - ) -> WordSize { - 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( - offchain::HttpRequestId(request_id as u16), - &mut internal_buffer, - deadline_to_timestamp(deadline), - ); - - Ok(match res { - Ok(read) => { - context.write_memory(buffer, &internal_buffer[..read as usize]) - .map_err(|_| "Invalid attempt to set memory in ext_http_response_read_body")?; - - read as u32 - }, - Err(err) => { - u32::max_value() - u32::from(err) + 1 - } - }) - } - } -} - -fn deadline_to_timestamp(deadline: u64) -> Option { - if deadline == 0 { - None - } else { - Some(offchain::Timestamp::from_unix_millis(deadline)) - } -} - -- GitLab From ccd72addd95c5af12d385254b11824e37242c70c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Sat, 30 Nov 2019 12:25:37 +0100 Subject: [PATCH 050/172] Fix filling the db path in the CLI (#4253) --- client/cli/src/lib.rs | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/client/cli/src/lib.rs b/client/cli/src/lib.rs index 4d8b9830c8..b430070c35 100644 --- a/client/cli/src/lib.rs +++ b/client/cli/src/lib.rs @@ -741,17 +741,22 @@ fn fill_config_keystore_password( } /// Put block import CLI params into `config` object. -pub fn fill_import_params(config: &mut Configuration, cli: &ImportParams, role: service::Roles) - -> error::Result<()> -where - C: Default, - G: RuntimeGenesis, - E: ChainSpecExtension, +pub fn fill_import_params( + config: &mut Configuration, + cli: &ImportParams, + role: service::Roles, +) -> error::Result<()> + where + C: Default, + G: RuntimeGenesis, + E: ChainSpecExtension, { - config.database = DatabaseConfig::Path { - path: config.in_chain_config_dir(DEFAULT_DB_CONFIG_PATH).expect("We provided a base_path."), - cache_size: Some(cli.database_cache_size), - }; + match config.database { + DatabaseConfig::Path { ref mut cache_size, .. } => + *cache_size = Some(cli.database_cache_size), + DatabaseConfig::Custom(_) => {}, + } + config.state_cache_size = cli.state_cache_size; // by default we disable pruning if the node is an authority (i.e. @@ -927,7 +932,16 @@ where let spec = load_spec(cli, spec_factory)?; let base_path = base_path(cli, version); - let config = service::Configuration::default_with_spec_and_base_path(spec.clone(), Some(base_path)); + let mut config = service::Configuration::default_with_spec_and_base_path( + spec.clone(), + Some(base_path), + ); + + config.database = DatabaseConfig::Path { + path: config.in_chain_config_dir(DEFAULT_DB_CONFIG_PATH).expect("We provided a base_path."), + cache_size: None, + }; + Ok(config) } -- GitLab From 47312a04c4264a33a08ad77c20cf7057f6f93515 Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Sat, 30 Nov 2019 19:37:03 +0100 Subject: [PATCH 051/172] Fix db path on normal run. (#4254) --- client/cli/src/lib.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/client/cli/src/lib.rs b/client/cli/src/lib.rs index b430070c35..c7b256c15f 100644 --- a/client/cli/src/lib.rs +++ b/client/cli/src/lib.rs @@ -804,9 +804,7 @@ where E: ChainSpecExtension, S: FnOnce(&str) -> Result>, String>, { - let spec = load_spec(&cli.shared_params, spec_factory)?; - let base_path = base_path(&cli.shared_params, &version); - let mut config = service::Configuration::default_with_spec_and_base_path(spec.clone(), Some(base_path)); + let mut config = create_config_with_db_path(spec_factory, &cli.shared_params, &version)?; fill_config_keystore_password(&mut config, &cli)?; -- GitLab From 82fbf9a78fe74cc828f475558448fb544f974ca7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Sat, 30 Nov 2019 23:20:23 +0100 Subject: [PATCH 052/172] Check filename length is valid in keystore (#4255) --- client/keystore/src/lib.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/client/keystore/src/lib.rs b/client/keystore/src/lib.rs index 3c1dffbb81..36cbcb5786 100644 --- a/client/keystore/src/lib.rs +++ b/client/keystore/src/lib.rs @@ -226,7 +226,7 @@ impl Store { // skip directories and non-unicode file names (hex is unicode) if let Some(name) = path.file_name().and_then(|n| n.to_str()) { match hex::decode(name) { - Ok(ref hex) => { + Ok(ref hex) if hex.len() > 4 => { if &hex[0..4] != &key_type.0 { continue } let public = TPublic::from_slice(&hex[4..]); public_keys.push(public); @@ -422,4 +422,17 @@ mod tests { assert_eq!(key_pair.public(), store_key_pair.public()); } + + #[test] + fn store_ignores_files_with_invalid_name() { + let temp_dir = TempDir::new().unwrap(); + let store = Store::open(temp_dir.path(), None).unwrap(); + + let file_name = temp_dir.path().join(hex::encode(&SR25519.0[..2])); + fs::write(file_name, "test").expect("Invalid file is written"); + + assert!( + store.read().public_keys_by_type::(SR25519).unwrap().is_empty(), + ); + } } -- GitLab From 64177dad3c3575d330f6da8b371dc373d01e14fe Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Sun, 1 Dec 2019 10:13:09 +0100 Subject: [PATCH 053/172] Economic fixes for democracy module (#4256) * Fix up `end_block` mess; add free preimage noting for imminents. * Fixes * Bump runtime * Update frame/democracy/src/lib.rs Co-Authored-By: Shawn Tabrizi * Handle grumble * Update frame/democracy/src/lib.rs Co-Authored-By: Shawn Tabrizi --- bin/node/runtime/src/lib.rs | 8 +- .../src/communication/gossip.rs | 4 +- frame/democracy/src/lib.rs | 586 ++++++++++++------ 3 files changed, 415 insertions(+), 183 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index c1ae051020..366f884735 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -78,8 +78,8 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // and set impl_version to equal spec_version. If only runtime // implementation changes and behavior does not, then leave spec_version as // is and increment impl_version. - spec_version: 196, - impl_version: 196, + spec_version: 197, + impl_version: 197, apis: RUNTIME_API_VERSIONS, }; @@ -278,6 +278,8 @@ parameter_types! { pub const MinimumDeposit: Balance = 100 * DOLLARS; pub const EnactmentPeriod: BlockNumber = 30 * 24 * 60 * MINUTES; pub const CooloffPeriod: BlockNumber = 28 * 24 * 60 * MINUTES; + // One cent: $10,000 / MB + pub const PreimageByteDeposit: Balance = 1 * CENTS; } impl democracy::Trait for Runtime { @@ -305,6 +307,8 @@ impl democracy::Trait for Runtime { // only do it once and it lasts only for the cooloff period. type VetoOrigin = collective::EnsureMember; type CooloffPeriod = CooloffPeriod; + type PreimageByteDeposit = PreimageByteDeposit; + type Slash = Treasury; } type CouncilCollective = collective::Instance1; diff --git a/client/finality-grandpa/src/communication/gossip.rs b/client/finality-grandpa/src/communication/gossip.rs index 3e0f2a7ac4..bd1b6197ea 100644 --- a/client/finality-grandpa/src/communication/gossip.rs +++ b/client/finality-grandpa/src/communication/gossip.rs @@ -517,7 +517,7 @@ impl Peers { } fn reshuffle(&mut self) { - let mut lucky_peers : Vec<_> = self.inner + let mut lucky_peers: Vec<_> = self.inner .iter() .filter_map(|(id, info)| if !info.roles.is_authority() { Some(id.clone()) } else { None }) .collect(); @@ -670,7 +670,7 @@ impl Inner { let set_id = local_view.set_id; debug!(target: "afg", "Voter {} noting beginning of round {:?} to network.", - self.config.name(), (round,set_id)); + self.config.name(), (round, set_id)); local_view.round = round; diff --git a/frame/democracy/src/lib.rs b/frame/democracy/src/lib.rs index 9842044461..988f82734c 100644 --- a/frame/democracy/src/lib.rs +++ b/frame/democracy/src/lib.rs @@ -22,7 +22,7 @@ use rstd::prelude::*; use rstd::{result, convert::TryFrom}; use sr_primitives::{ RuntimeDebug, - traits::{Zero, Bounded, CheckedMul, CheckedDiv, EnsureOrigin, Hash, Dispatchable}, + traits::{Zero, Bounded, CheckedMul, CheckedDiv, EnsureOrigin, Hash, Dispatchable, Saturating}, }; use codec::{Ref, Encode, Decode, Input, Output, Error}; use support::{ @@ -31,7 +31,7 @@ use support::{ weights::SimpleDispatchInfo, traits::{ Currency, ReservableCurrency, LockableCurrency, WithdrawReason, LockIdentifier, Get, - OnFreeBalanceZero + OnFreeBalanceZero, OnUnbalanced } }; use support::dispatch::Result; @@ -174,6 +174,8 @@ impl Decode for Vote { } type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; +type NegativeImbalanceOf = +<::Currency as Currency<::AccountId>>::NegativeImbalance; pub trait Trait: system::Trait + Sized { type Proposal: Parameter + Dispatchable; @@ -227,30 +229,36 @@ pub trait Trait: system::Trait + Sized { /// Period in blocks where an external proposal may not be re-submitted after being vetoed. type CooloffPeriod: Get; + + /// The amount of balance that must be deposited per byte of preimage stored. + type PreimageByteDeposit: Get>; + + /// Handler for the unbalanced reduction when slashing a preimage deposit. + type Slash: OnUnbalanced>; } /// Info regarding an ongoing referendum. #[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug)] -pub struct ReferendumInfo { +pub struct ReferendumInfo { /// When voting on this referendum will end. end: BlockNumber, - /// The proposal being voted on. - proposal: Proposal, + /// The hash of the proposal being voted on. + proposal_hash: Hash, /// The thresholding mechanism to determine whether it passed. threshold: VoteThreshold, /// The delay (in blocks) to wait after a successful referendum before deploying. delay: BlockNumber, } -impl ReferendumInfo { +impl ReferendumInfo { /// Create a new instance. pub fn new( end: BlockNumber, - proposal: Proposal, + proposal_hash: Hash, threshold: VoteThreshold, delay: BlockNumber ) -> Self { - ReferendumInfo { end, proposal, threshold, delay } + ReferendumInfo { end, proposal_hash, threshold, delay } } } @@ -258,8 +266,11 @@ decl_storage! { trait Store for Module as Democracy { /// The number of (public) proposals that have been made so far. pub PublicPropCount get(fn public_prop_count) build(|_| 0 as PropIndex) : PropIndex; - /// The public proposals. Unsorted. - pub PublicProps get(fn public_props): Vec<(PropIndex, T::Proposal, T::AccountId)>; + /// The public proposals. Unsorted. The second item is the proposal's hash. + pub PublicProps get(fn public_props): Vec<(PropIndex, T::Hash, T::AccountId)>; + /// Map of hashes to the proposal preimage, along with who registered it and their deposit. + /// The block number is the block at which it was deposited. + pub Preimages: map T::Hash => Option<(Vec, T::AccountId, BalanceOf, T::BlockNumber)>; /// Those who have locked a deposit. pub DepositOf get(fn deposit_of): map PropIndex => Option<(BalanceOf, Vec)>; @@ -269,10 +280,10 @@ decl_storage! { pub NextTally get(fn next_tally) build(|_| 0 as ReferendumIndex): ReferendumIndex; /// Information concerning any given referendum. pub ReferendumInfoOf get(fn referendum_info): - map ReferendumIndex => Option<(ReferendumInfo)>; + map ReferendumIndex => Option<(ReferendumInfo)>; /// Queue of successful referenda to be dispatched. pub DispatchQueue get(fn dispatch_queue): - map T::BlockNumber => Vec>; + map T::BlockNumber => Vec>; /// Get the voters for the current proposal. pub VotersFor get(fn voters_for): map ReferendumIndex => Vec; @@ -298,7 +309,7 @@ decl_storage! { /// This happens when a referendum needs to be tabled and one of two conditions are met: /// - `LastTabledWasExternal` is `false`; or /// - `PublicProps` is empty. - pub NextExternal: Option<(T::Proposal, VoteThreshold)>; + pub NextExternal: Option<(T::Hash, VoteThreshold)>; /// A record of who vetoed what. Maps proposal hash to a possible existent block number /// (until when it may not be resubmitted) and who vetoed it. @@ -316,17 +327,38 @@ decl_event!( ::Hash, ::BlockNumber, { + /// A motion has been proposed by a public account. Proposed(PropIndex, Balance), + /// A public proposal has been tabled for referendum vote. Tabled(PropIndex, Balance, Vec), + /// An external proposal has been tabled. ExternalTabled, + /// A referendum has begun. Started(ReferendumIndex, VoteThreshold), + /// A proposal has been approved by referendum. Passed(ReferendumIndex), + /// A proposal has been rejected by referendum. NotPassed(ReferendumIndex), + /// A referendum has been cancelled. Cancelled(ReferendumIndex), + /// A proposal has been enacted. Executed(ReferendumIndex, bool), + /// An account has delegated their vote to another account. Delegated(AccountId, AccountId), + /// An account has cancelled a previous delegation operation. Undelegated(AccountId), + /// An external proposal has been vetoed. Vetoed(AccountId, Hash, BlockNumber), + /// A proposal's preimage was noted, and the deposit taken. + PreimageNoted(Hash, AccountId, Balance), + /// A proposal preimage was removed and used (the deposit was returned). + PreimageUsed(Hash, AccountId, Balance), + /// A proposal could not be executed because its preimage was invalid. + PreimageInvalid(Hash, ReferendumIndex), + /// A proposal could not be executed because its preimage was missing. + PreimageMissing(Hash, ReferendumIndex), + /// A registered preimage was removed and the deposit collected by the reaper (last item). + PreimageReaped(Hash, AccountId, Balance, AccountId), } ); @@ -354,6 +386,9 @@ decl_module! { /// Period in blocks where an external proposal may not be re-submitted after being vetoed. const CooloffPeriod: T::BlockNumber = T::CooloffPeriod::get(); + /// The amount of balance that must be deposited per byte of preimage stored. + const PreimageByteDeposit: BalanceOf = T::PreimageByteDeposit::get(); + fn deposit_event() = default; /// Propose a sensitive action to be taken. @@ -364,11 +399,10 @@ decl_module! { /// # #[weight = SimpleDispatchInfo::FixedNormal(5_000_000)] fn propose(origin, - proposal: Box, + proposal_hash: T::Hash, #[compact] value: BalanceOf ) { let who = ensure_signed(origin)?; - ensure!(value >= T::MinimumDeposit::get(), "value too low"); T::Currency::reserve(&who, value) .map_err(|_| "proposer's balance too low")?; @@ -377,7 +411,7 @@ decl_module! { PublicPropCount::put(index + 1); >::insert(index, (value, &[&who][..])); - let new_prop = (index, proposal, who); + let new_prop = (index, proposal_hash, who); >::append_or_put(&[Ref::from(&new_prop)][..]); Self::deposit_event(RawEvent::Proposed(index, value)); @@ -439,7 +473,7 @@ decl_module! { T::CancellationOrigin::ensure_origin(origin)?; let info = Self::referendum_info(ref_index).ok_or("unknown index")?; - let h = T::Hashing::hash_of(&info.proposal); + let h = info.proposal_hash; ensure!(!>::exists(h), "cannot cancel the same proposal twice"); >::insert(h, true); @@ -449,14 +483,13 @@ decl_module! { /// Schedule a referendum to be tabled once it is legal to schedule an external /// referendum. #[weight = SimpleDispatchInfo::FixedNormal(5_000_000)] - fn external_propose(origin, proposal: Box) { + fn external_propose(origin, proposal_hash: T::Hash) { T::ExternalOrigin::ensure_origin(origin)?; ensure!(!>::exists(), "proposal already made"); - let proposal_hash = T::Hashing::hash_of(&proposal); if let Some((until, _)) = >::get(proposal_hash) { ensure!(>::block_number() >= until, "proposal still blacklisted"); } - >::put((*proposal, VoteThreshold::SuperMajorityApprove)); + >::put((proposal_hash, VoteThreshold::SuperMajorityApprove)); } /// Schedule a majority-carries referendum to be tabled next once it is legal to schedule @@ -465,9 +498,9 @@ decl_module! { /// Unlike `external_propose`, blacklisting has no effect on this and it may replace a /// pre-scheduled `external_propose` call. #[weight = SimpleDispatchInfo::FixedNormal(5_000_000)] - fn external_propose_majority(origin, proposal: Box) { + fn external_propose_majority(origin, proposal_hash: T::Hash) { T::ExternalMajorityOrigin::ensure_origin(origin)?; - >::put((*proposal, VoteThreshold::SimpleMajority)); + >::put((proposal_hash, VoteThreshold::SimpleMajority)); } /// Schedule a negative-turnout-bias referendum to be tabled next once it is legal to @@ -476,9 +509,9 @@ decl_module! { /// Unlike `external_propose`, blacklisting has no effect on this and it may replace a /// pre-scheduled `external_propose` call. #[weight = SimpleDispatchInfo::FixedNormal(5_000_000)] - fn external_propose_default(origin, proposal: Box) { + fn external_propose_default(origin, proposal_hash: T::Hash) { T::ExternalDefaultOrigin::ensure_origin(origin)?; - >::put((*proposal, VoteThreshold::SuperMajorityAgainst)); + >::put((proposal_hash, VoteThreshold::SuperMajorityAgainst)); } /// Schedule the currently externally-proposed majority-carries referendum to be tabled @@ -497,15 +530,18 @@ decl_module! { delay: T::BlockNumber ) { T::FastTrackOrigin::ensure_origin(origin)?; - let (proposal, threshold) = >::get().ok_or("no proposal made")?; - ensure!(threshold != VoteThreshold::SuperMajorityApprove, "next external proposal not simple majority"); - ensure!(proposal_hash == T::Hashing::hash_of(&proposal), "invalid hash"); + let (e_proposal_hash, threshold) = >::get().ok_or("no proposal made")?; + ensure!( + threshold != VoteThreshold::SuperMajorityApprove, + "next external proposal not simple majority" + ); + ensure!(proposal_hash == e_proposal_hash, "invalid hash"); >::kill(); let now = >::block_number(); // We don't consider it an error if `vote_period` is too low, like `emergency_propose`. let period = voting_period.max(T::EmergencyVotingPeriod::get()); - Self::inject_referendum(now + period, proposal, threshold, delay).map(|_| ())?; + Self::inject_referendum(now + period, proposal_hash, threshold, delay).map(|_| ())?; } /// Veto and blacklist the external proposal hash. @@ -513,8 +549,8 @@ decl_module! { fn veto_external(origin, proposal_hash: T::Hash) { let who = T::VetoOrigin::ensure_origin(origin)?; - if let Some((proposal, _)) = >::get() { - ensure!(proposal_hash == T::Hashing::hash_of(&proposal), "unknown proposal"); + if let Some((e_proposal_hash, _)) = >::get() { + ensure!(proposal_hash == e_proposal_hash, "unknown proposal"); } else { Err("no external proposal")?; } @@ -560,7 +596,7 @@ decl_module! { } fn on_initialize(n: T::BlockNumber) { - if let Err(e) = Self::end_block(n) { + if let Err(e) = Self::begin_block(n) { sr_primitives::print(e); } } @@ -642,6 +678,70 @@ decl_module! { ); Self::deposit_event(RawEvent::Undelegated(who)); } + + /// Veto and blacklist the proposal hash. Must be from Root origin. + #[weight = SimpleDispatchInfo::FixedNormal(10_000)] + fn clear_public_proposals(origin) { + ensure_root(origin)?; + + >::kill(); + } + + /// Register the preimage for an upcoming proposal. This doesn't require the proposal to be + /// in the dispatch queue but does require a deposit, returned once enacted. + #[weight = SimpleDispatchInfo::FixedNormal(100_000)] + fn note_preimage(origin, encoded_proposal: Vec) { + let who = ensure_signed(origin)?; + let proposal_hash = T::Hashing::hash(&encoded_proposal[..]); + ensure!(!>::exists(&proposal_hash), "preimage already noted"); + + let deposit = >::from(encoded_proposal.len() as u32) + .saturating_mul(T::PreimageByteDeposit::get()); + T::Currency::reserve(&who, deposit)?; + + let now = >::block_number(); + >::insert(proposal_hash, (encoded_proposal, who.clone(), deposit, now)); + + Self::deposit_event(RawEvent::PreimageNoted(proposal_hash, who, deposit)); + } + + /// Register the preimage for an upcoming proposal. This requires the proposal to be + /// in the dispatch queue. No deposit is needed. + #[weight = SimpleDispatchInfo::FixedNormal(100_000)] + fn note_imminent_preimage(origin, + encoded_proposal: Vec, + when: T::BlockNumber, + which: u32 + ) { + let who = ensure_signed(origin)?; + let proposal_hash = T::Hashing::hash(&encoded_proposal[..]); + ensure!(!>::exists(&proposal_hash), "preimage already noted"); + let queue = >::get(when); + let item = queue.get(which as usize).and_then(|x| x.as_ref()) + .ok_or("dispatch queue entry not found")?; + ensure!(item.0 == proposal_hash, "dispatch queue entry invalid"); + + let now = >::block_number(); + >::insert(proposal_hash, (encoded_proposal, who.clone(), >::zero(), now)); + + Self::deposit_event(RawEvent::PreimageNoted(proposal_hash, who, Zero::zero())); + } + + /// Remove an expired proposal preimage and collect the deposit. + #[weight = SimpleDispatchInfo::FixedNormal(10_000)] + fn reap_preimage(origin, proposal_hash: T::Hash) { + let who = ensure_signed(origin)?; + + if let Some((_, old, deposit, then)) = >::get(&proposal_hash) { + let now = >::block_number(); + if now >= then + T::EnactmentPeriod::get() + T::VotingPeriod::get() { + // allowed to claim the deposit. + let _ = T::Currency::repatriate_reserved(&old, &who, deposit); + >::remove(&proposal_hash); + Self::deposit_event(RawEvent::PreimageReaped(proposal_hash, old, deposit, who)); + } + } + } } } @@ -661,7 +761,7 @@ impl Module { /// Get all referenda currently active. pub fn active_referenda() - -> Vec<(ReferendumIndex, ReferendumInfo)> + -> Vec<(ReferendumIndex, ReferendumInfo)> { let next = Self::next_tally(); let last = Self::referendum_count(); @@ -673,7 +773,7 @@ impl Module { /// Get all referenda ready for tally at block `n`. pub fn maturing_referenda_at( n: T::BlockNumber - ) -> Vec<(ReferendumIndex, ReferendumInfo)> { + ) -> Vec<(ReferendumIndex, ReferendumInfo)> { let next = Self::next_tally(); let last = Self::referendum_count(); (next..last).into_iter() @@ -764,13 +864,13 @@ impl Module { /// Start a referendum. pub fn internal_start_referendum( - proposal: T::Proposal, + proposal_hash: T::Hash, threshold: VoteThreshold, delay: T::BlockNumber ) -> result::Result { >::inject_referendum( >::block_number() + T::VotingPeriod::get(), - proposal, + proposal_hash, threshold, delay ) @@ -797,7 +897,7 @@ impl Module { /// Start a referendum fn inject_referendum( end: T::BlockNumber, - proposal: T::Proposal, + proposal_hash: T::Hash, threshold: VoteThreshold, delay: T::BlockNumber, ) -> result::Result { @@ -811,7 +911,7 @@ impl Module { } ReferendumCount::put(ref_index + 1); - let item = ReferendumInfo { end, proposal, threshold, delay }; + let item = ReferendumInfo { end, proposal_hash, threshold, delay }; >::insert(ref_index, item); Self::deposit_event(RawEvent::Started(ref_index, threshold)); Ok(ref_index) @@ -827,9 +927,25 @@ impl Module { } /// Enact a proposal from a referendum. - fn enact_proposal(proposal: T::Proposal, index: ReferendumIndex) { - let ok = proposal.dispatch(system::RawOrigin::Root.into()).is_ok(); - Self::deposit_event(RawEvent::Executed(index, ok)); + fn enact_proposal(proposal_hash: T::Hash, index: ReferendumIndex) -> Result { + if let Some((encoded_proposal, who, amount, _)) = >::take(&proposal_hash) { + if let Ok(proposal) = T::Proposal::decode(&mut &encoded_proposal[..]) { + let _ = T::Currency::unreserve(&who, amount); + Self::deposit_event(RawEvent::PreimageUsed(proposal_hash, who, amount)); + + let ok = proposal.dispatch(system::RawOrigin::Root.into()).is_ok(); + Self::deposit_event(RawEvent::Executed(index, ok)); + + Ok(()) + } else { + T::Slash::on_unbalanced(T::Currency::slash_reserved(&who, amount).0); + Self::deposit_event(RawEvent::PreimageInvalid(proposal_hash, index)); + Err("invalid preimage") + } + } else { + Self::deposit_event(RawEvent::PreimageMissing(proposal_hash, index)); + Err("missing preimage") + } } /// Table the next waiting proposal for a vote. @@ -892,7 +1008,7 @@ impl Module { fn bake_referendum( now: T::BlockNumber, index: ReferendumIndex, - info: ReferendumInfo + info: ReferendumInfo ) -> Result { let (approve, against, capital) = Self::tally(index); let total_issuance = T::Currency::total_issuance(); @@ -924,11 +1040,11 @@ impl Module { if approved { Self::deposit_event(RawEvent::Passed(index)); if info.delay.is_zero() { - Self::enact_proposal(info.proposal, index); + let _ = Self::enact_proposal(info.proposal_hash, index); } else { >::append_or_insert( now + info.delay, - &[Some((info.proposal, index))][..] + &[Some((info.proposal_hash, index))][..] ); } } else { @@ -940,8 +1056,7 @@ impl Module { } /// Current era is ending; we should finish up any proposals. - // TODO: move to initialize_block #2779 - fn end_block(now: T::BlockNumber) -> Result { + fn begin_block(now: T::BlockNumber) -> Result { // pick out another public referendum if it's time. if (now % T::LaunchPeriod::get()).is_zero() { // Errors come from the queue being empty. we don't really care about that, and even if @@ -954,8 +1069,8 @@ impl Module { Self::bake_referendum(now, index, info)?; } - for (proposal, index) in >::take(now).into_iter().filter_map(|x| x) { - Self::enact_proposal(proposal, index); + for (proposal_hash, index) in >::take(now).into_iter().filter_map(|x| x) { + let _ = Self::enact_proposal(proposal_hash, index); } Ok(()) } @@ -970,6 +1085,7 @@ impl OnFreeBalanceZero for Module { #[cfg(test)] mod tests { use super::*; + use std::cell::RefCell; use support::{ impl_outer_origin, impl_outer_dispatch, assert_noop, assert_ok, parameter_types, traits::Contains, @@ -1057,6 +1173,13 @@ mod tests { *n >= 1 && *n <= 5 } } + thread_local! { + static PREIMAGE_BYTE_DEPOSIT: RefCell = RefCell::new(0); + } + pub struct PreimageByteDeposit; + impl Get for PreimageByteDeposit { + fn get() -> u64 { PREIMAGE_BYTE_DEPOSIT.with(|v| *v.borrow()) } + } impl super::Trait for Test { type Proposal = Call; type Event = (); @@ -1073,6 +1196,8 @@ mod tests { type CancellationOrigin = EnsureSignedBy; type VetoOrigin = EnsureSignedBy; type CooloffPeriod = CooloffPeriod; + type PreimageByteDeposit = PreimageByteDeposit; + type Slash = (); } fn new_test_ext() -> runtime_io::TestExternalities { @@ -1098,21 +1223,43 @@ mod tests { }); } - fn set_balance_proposal(value: u64) -> Call { - Call::Balances(balances::Call::set_balance(42, value, 0)) + fn set_balance_proposal(value: u64) -> Vec { + Call::Balances(balances::Call::set_balance(42, value, 0)).encode() + } + + fn set_balance_proposal_hash(value: u64) -> H256 { + BlakeTwo256::hash(&set_balance_proposal(value)[..]) + } + + fn set_balance_proposal_hash_and_note(value: u64) -> H256 { + let p = set_balance_proposal(value); + let h = BlakeTwo256::hash(&p[..]); + match Democracy::note_preimage(Origin::signed(6), p) { + Ok(_) | Err("preimage already noted") => (), + Err(x) => panic!(x), + } + h } fn propose_set_balance(who: u64, value: u64, delay: u64) -> super::Result { Democracy::propose( Origin::signed(who), - Box::new(set_balance_proposal(value)), + set_balance_proposal_hash(value), + delay + ) + } + + fn propose_set_balance_and_note(who: u64, value: u64, delay: u64) -> super::Result { + Democracy::propose( + Origin::signed(who), + set_balance_proposal_hash_and_note(value), delay ) } fn next_block() { - assert_eq!(Democracy::end_block(System::block_number()), Ok(())); System::set_block_number(System::block_number() + 1); + assert_eq!(Democracy::begin_block(System::block_number()), Ok(())); } fn fast_forward_to(n: u64) { @@ -1121,24 +1268,104 @@ mod tests { } } + #[test] + fn missing_preimage_should_fail() { + new_test_ext().execute_with(|| { + System::set_block_number(1); + let r = Democracy::inject_referendum( + 2, + set_balance_proposal_hash(2), + VoteThreshold::SuperMajorityApprove, + 0 + ).unwrap(); + assert_ok!(Democracy::vote(Origin::signed(1), r, AYE)); + + next_block(); + next_block(); + + assert_eq!(Balances::free_balance(&42), 0); + }); + } + + #[test] + fn preimage_deposit_should_be_required_and_returned() { + new_test_ext().execute_with(|| { + System::set_block_number(1); + // fee of 100 is too much. + PREIMAGE_BYTE_DEPOSIT.with(|v| *v.borrow_mut() = 100); + assert_noop!( + Democracy::note_preimage(Origin::signed(6), vec![0; 500]), + "not enough free funds" + ); + // fee of 1 is reasonable. + PREIMAGE_BYTE_DEPOSIT.with(|v| *v.borrow_mut() = 1); + let r = Democracy::inject_referendum( + 2, + set_balance_proposal_hash_and_note(2), + VoteThreshold::SuperMajorityApprove, + 0 + ).unwrap(); + assert_ok!(Democracy::vote(Origin::signed(1), r, AYE)); + + assert_eq!(Balances::reserved_balance(6), 12); + + next_block(); + next_block(); + + assert_eq!(Balances::reserved_balance(6), 0); + assert_eq!(Balances::free_balance(6), 60); + assert_eq!(Balances::free_balance(42), 2); + }); + } + + #[test] + fn noting_imminent_preimage_for_free_should_work() { + new_test_ext().execute_with(|| { + System::set_block_number(1); + PREIMAGE_BYTE_DEPOSIT.with(|v| *v.borrow_mut() = 1); + + let r = Democracy::inject_referendum( + 2, + set_balance_proposal_hash(2), + VoteThreshold::SuperMajorityApprove, + 1 + ).unwrap(); + assert_ok!(Democracy::vote(Origin::signed(1), r, AYE)); + + assert_noop!( + Democracy::note_imminent_preimage(Origin::signed(7), set_balance_proposal(2), 3, 0), + "dispatch queue entry not found" + ); + + next_block(); + + // Now we're in the dispatch queue it's all good. + assert_ok!(Democracy::note_imminent_preimage(Origin::signed(7), set_balance_proposal(2), 3, 0)); + + next_block(); + + assert_eq!(Balances::free_balance(42), 2); + }); + } + #[test] fn external_and_public_interleaving_works() { new_test_ext().execute_with(|| { System::set_block_number(0); assert_ok!(Democracy::external_propose( Origin::signed(2), - Box::new(set_balance_proposal(1)), + set_balance_proposal_hash_and_note(1), )); - assert_ok!(propose_set_balance(6, 2, 2)); + assert_ok!(propose_set_balance_and_note(6, 2, 2)); - fast_forward_to(1); + fast_forward_to(2); // both waiting: external goes first. assert_eq!( Democracy::referendum_info(0), Some(ReferendumInfo { - end: 2, - proposal: set_balance_proposal(1), + end: 4, + proposal_hash: set_balance_proposal_hash_and_note(1), threshold: VoteThreshold::SuperMajorityApprove, delay: 2 }) @@ -1146,31 +1373,31 @@ mod tests { // replenish external assert_ok!(Democracy::external_propose( Origin::signed(2), - Box::new(set_balance_proposal(3)), + set_balance_proposal_hash_and_note(3), )); - fast_forward_to(3); + fast_forward_to(4); // both waiting: public goes next. assert_eq!( Democracy::referendum_info(1), Some(ReferendumInfo { - end: 4, - proposal: set_balance_proposal(2), + end: 6, + proposal_hash: set_balance_proposal_hash_and_note(2), threshold: VoteThreshold::SuperMajorityApprove, delay: 2 }) ); // don't replenish public - fast_forward_to(5); + fast_forward_to(6); // it's external "turn" again, though since public is empty that doesn't really matter assert_eq!( Democracy::referendum_info(2), Some(ReferendumInfo { - end: 6, - proposal: set_balance_proposal(3), + end: 8, + proposal_hash: set_balance_proposal_hash_and_note(3), threshold: VoteThreshold::SuperMajorityApprove, delay: 2 }) @@ -1178,17 +1405,17 @@ mod tests { // replenish external assert_ok!(Democracy::external_propose( Origin::signed(2), - Box::new(set_balance_proposal(5)), + set_balance_proposal_hash_and_note(5), )); - fast_forward_to(7); + fast_forward_to(8); // external goes again because there's no public waiting. assert_eq!( Democracy::referendum_info(3), Some(ReferendumInfo { - end: 8, - proposal: set_balance_proposal(5), + end: 10, + proposal_hash: set_balance_proposal_hash_and_note(5), threshold: VoteThreshold::SuperMajorityApprove, delay: 2 }) @@ -1196,36 +1423,36 @@ mod tests { // replenish both assert_ok!(Democracy::external_propose( Origin::signed(2), - Box::new(set_balance_proposal(7)), + set_balance_proposal_hash_and_note(7), )); - assert_ok!(propose_set_balance(6, 4, 2)); + assert_ok!(propose_set_balance_and_note(6, 4, 2)); - fast_forward_to(9); + fast_forward_to(10); // public goes now since external went last time. assert_eq!( Democracy::referendum_info(4), Some(ReferendumInfo { - end: 10, - proposal: set_balance_proposal(4), + end: 12, + proposal_hash: set_balance_proposal_hash_and_note(4), threshold: VoteThreshold::SuperMajorityApprove, delay: 2 }) ); // replenish public again - assert_ok!(propose_set_balance(6, 6, 2)); + assert_ok!(propose_set_balance_and_note(6, 6, 2)); // cancel external - let h = BlakeTwo256::hash_of(&set_balance_proposal(7)); + let h = set_balance_proposal_hash_and_note(7); assert_ok!(Democracy::veto_external(Origin::signed(3), h)); - fast_forward_to(11); + fast_forward_to(12); // public goes again now since there's no external waiting. assert_eq!( Democracy::referendum_info(5), Some(ReferendumInfo { - end: 12, - proposal: set_balance_proposal(6), + end: 14, + proposal_hash: set_balance_proposal_hash_and_note(6), threshold: VoteThreshold::SuperMajorityApprove, delay: 2 }) @@ -1240,7 +1467,7 @@ mod tests { System::set_block_number(0); let r = Democracy::inject_referendum( 2, - set_balance_proposal(2), + set_balance_proposal_hash_and_note(2), VoteThreshold::SuperMajorityApprove, 2 ).unwrap(); @@ -1254,7 +1481,7 @@ mod tests { let r = Democracy::inject_referendum( 2, - set_balance_proposal(2), + set_balance_proposal_hash_and_note(2), VoteThreshold::SuperMajorityApprove, 2 ).unwrap(); @@ -1269,32 +1496,32 @@ mod tests { System::set_block_number(0); assert_ok!(Democracy::external_propose( Origin::signed(2), - Box::new(set_balance_proposal(2)), + set_balance_proposal_hash_and_note(2), )); assert!(>::exists()); - let h = BlakeTwo256::hash_of(&set_balance_proposal(2)); + let h = set_balance_proposal_hash_and_note(2); assert_ok!(Democracy::veto_external(Origin::signed(3), h.clone())); // cancelled. assert!(!>::exists()); // fails - same proposal can't be resubmitted. assert_noop!(Democracy::external_propose( Origin::signed(2), - Box::new(set_balance_proposal(2)), + set_balance_proposal_hash(2), ), "proposal still blacklisted"); fast_forward_to(1); // fails as we're still in cooloff period. assert_noop!(Democracy::external_propose( Origin::signed(2), - Box::new(set_balance_proposal(2)), + set_balance_proposal_hash(2), ), "proposal still blacklisted"); fast_forward_to(2); // works; as we're out of the cooloff period. assert_ok!(Democracy::external_propose( Origin::signed(2), - Box::new(set_balance_proposal(2)), + set_balance_proposal_hash_and_note(2), )); assert!(>::exists()); @@ -1313,12 +1540,12 @@ mod tests { // same proposal fails as we're still in cooloff assert_noop!(Democracy::external_propose( Origin::signed(2), - Box::new(set_balance_proposal(2)), + set_balance_proposal_hash(2), ), "proposal still blacklisted"); // different proposal works fine. assert_ok!(Democracy::external_propose( Origin::signed(2), - Box::new(set_balance_proposal(3)), + set_balance_proposal_hash_and_note(3), )); }); } @@ -1329,22 +1556,22 @@ mod tests { System::set_block_number(0); assert_noop!(Democracy::external_propose( Origin::signed(1), - Box::new(set_balance_proposal(2)), + set_balance_proposal_hash(2), ), "Invalid origin"); assert_ok!(Democracy::external_propose( Origin::signed(2), - Box::new(set_balance_proposal(2)), + set_balance_proposal_hash_and_note(2), )); assert_noop!(Democracy::external_propose( Origin::signed(2), - Box::new(set_balance_proposal(1)), + set_balance_proposal_hash(1), ), "proposal already made"); - fast_forward_to(1); + fast_forward_to(2); assert_eq!( Democracy::referendum_info(0), Some(ReferendumInfo { - end: 2, - proposal: set_balance_proposal(2), + end: 4, + proposal_hash: set_balance_proposal_hash(2), threshold: VoteThreshold::SuperMajorityApprove, delay: 2 }) @@ -1358,18 +1585,18 @@ mod tests { System::set_block_number(0); assert_noop!(Democracy::external_propose_majority( Origin::signed(1), - Box::new(set_balance_proposal(2)) + set_balance_proposal_hash(2) ), "Invalid origin"); assert_ok!(Democracy::external_propose_majority( Origin::signed(3), - Box::new(set_balance_proposal(2)) + set_balance_proposal_hash_and_note(2) )); - fast_forward_to(1); + fast_forward_to(2); assert_eq!( Democracy::referendum_info(0), Some(ReferendumInfo { - end: 2, - proposal: set_balance_proposal(2), + end: 4, + proposal_hash: set_balance_proposal_hash(2), threshold: VoteThreshold::SimpleMajority, delay: 2, }) @@ -1383,18 +1610,18 @@ mod tests { System::set_block_number(0); assert_noop!(Democracy::external_propose_default( Origin::signed(3), - Box::new(set_balance_proposal(2)) + set_balance_proposal_hash(2) ), "Invalid origin"); assert_ok!(Democracy::external_propose_default( Origin::signed(1), - Box::new(set_balance_proposal(2)) + set_balance_proposal_hash_and_note(2) )); - fast_forward_to(1); + fast_forward_to(2); assert_eq!( Democracy::referendum_info(0), Some(ReferendumInfo { - end: 2, - proposal: set_balance_proposal(2), + end: 4, + proposal_hash: set_balance_proposal_hash(2), threshold: VoteThreshold::SuperMajorityAgainst, delay: 2, }) @@ -1406,11 +1633,11 @@ mod tests { fn fast_track_referendum_works() { new_test_ext().execute_with(|| { System::set_block_number(0); - let h = BlakeTwo256::hash_of(&set_balance_proposal(2)); + let h = set_balance_proposal_hash_and_note(2); assert_noop!(Democracy::fast_track(Origin::signed(5), h, 3, 2), "no proposal made"); assert_ok!(Democracy::external_propose_majority( Origin::signed(3), - Box::new(set_balance_proposal(2)) + set_balance_proposal_hash_and_note(2) )); assert_noop!(Democracy::fast_track(Origin::signed(1), h, 3, 2), "Invalid origin"); assert_ok!(Democracy::fast_track(Origin::signed(5), h, 0, 0)); @@ -1418,7 +1645,7 @@ mod tests { Democracy::referendum_info(0), Some(ReferendumInfo { end: 1, - proposal: set_balance_proposal(2), + proposal_hash: set_balance_proposal_hash_and_note(2), threshold: VoteThreshold::SimpleMajority, delay: 0, }) @@ -1430,10 +1657,10 @@ mod tests { fn fast_track_referendum_fails_when_no_simple_majority() { new_test_ext().execute_with(|| { System::set_block_number(0); - let h = BlakeTwo256::hash_of(&set_balance_proposal(2)); + let h = set_balance_proposal_hash_and_note(2); assert_ok!(Democracy::external_propose( Origin::signed(2), - Box::new(set_balance_proposal(2)) + set_balance_proposal_hash_and_note(2) )); assert_noop!( Democracy::fast_track(Origin::signed(5), h, 3, 2), @@ -1446,9 +1673,9 @@ mod tests { fn locked_for_should_work() { new_test_ext().execute_with(|| { System::set_block_number(1); - assert_ok!(propose_set_balance(1, 2, 2)); - assert_ok!(propose_set_balance(1, 4, 4)); - assert_ok!(propose_set_balance(1, 3, 3)); + assert_ok!(propose_set_balance_and_note(1, 2, 2)); + assert_ok!(propose_set_balance_and_note(1, 4, 4)); + assert_ok!(propose_set_balance_and_note(1, 3, 3)); assert_eq!(Democracy::locked_for(0), Some(2)); assert_eq!(Democracy::locked_for(1), Some(4)); assert_eq!(Democracy::locked_for(2), Some(3)); @@ -1459,11 +1686,11 @@ mod tests { fn single_proposal_should_work() { new_test_ext().execute_with(|| { System::set_block_number(0); - assert_ok!(propose_set_balance(1, 2, 1)); + assert_ok!(propose_set_balance_and_note(1, 2, 1)); assert!(Democracy::referendum_info(0).is_none()); - // end of 0 => next referendum scheduled. - fast_forward_to(1); + // start of 2 => next referendum scheduled. + fast_forward_to(2); let r = 0; assert_ok!(Democracy::vote(Origin::signed(1), r, AYE)); @@ -1472,8 +1699,8 @@ mod tests { assert_eq!( Democracy::referendum_info(0), Some(ReferendumInfo { - end: 2, - proposal: set_balance_proposal(2), + end: 4, + proposal_hash: set_balance_proposal_hash_and_note(2), threshold: VoteThreshold::SuperMajorityApprove, delay: 2 }) @@ -1482,21 +1709,21 @@ mod tests { assert_eq!(Democracy::vote_of((r, 1)), AYE); assert_eq!(Democracy::tally(r), (1, 0, 1)); - fast_forward_to(2); + fast_forward_to(3); // referendum still running assert!(Democracy::referendum_info(0).is_some()); - // referendum runs during 1 and 2, ends @ end of 2. - fast_forward_to(3); + // referendum runs during 2 and 3, ends @ start of 4. + fast_forward_to(4); assert!(Democracy::referendum_info(0).is_none()); - assert_eq!(Democracy::dispatch_queue(4), vec![ - Some((set_balance_proposal(2), 0)) + assert_eq!(Democracy::dispatch_queue(6), vec![ + Some((set_balance_proposal_hash_and_note(2), 0)) ]); // referendum passes and wait another two blocks for enactment. - fast_forward_to(5); + fast_forward_to(6); assert_eq!(Balances::free_balance(&42), 2); }); @@ -1506,23 +1733,23 @@ mod tests { fn cancel_queued_should_work() { new_test_ext().execute_with(|| { System::set_block_number(0); - assert_ok!(propose_set_balance(1, 2, 1)); + assert_ok!(propose_set_balance_and_note(1, 2, 1)); - // end of 0 => next referendum scheduled. - fast_forward_to(1); + // start of 2 => next referendum scheduled. + fast_forward_to(2); assert_ok!(Democracy::vote(Origin::signed(1), 0, AYE)); - fast_forward_to(3); + fast_forward_to(4); - assert_eq!(Democracy::dispatch_queue(4), vec![ - Some((set_balance_proposal(2), 0)) + assert_eq!(Democracy::dispatch_queue(6), vec![ + Some((set_balance_proposal_hash_and_note(2), 0)) ]); - assert_noop!(Democracy::cancel_queued(Origin::ROOT, 3, 0, 0), "proposal not found"); - assert_noop!(Democracy::cancel_queued(Origin::ROOT, 4, 1, 0), "proposal not found"); - assert_ok!(Democracy::cancel_queued(Origin::ROOT, 4, 0, 0)); - assert_eq!(Democracy::dispatch_queue(4), vec![None]); + assert_noop!(Democracy::cancel_queued(Origin::ROOT, 5, 0, 0), "proposal not found"); + assert_noop!(Democracy::cancel_queued(Origin::ROOT, 6, 1, 0), "proposal not found"); + assert_ok!(Democracy::cancel_queued(Origin::ROOT, 6, 0, 0)); + assert_eq!(Democracy::dispatch_queue(6), vec![None]); }); } @@ -1560,9 +1787,9 @@ mod tests { fn single_proposal_should_work_with_proxy() { new_test_ext().execute_with(|| { System::set_block_number(0); - assert_ok!(propose_set_balance(1, 2, 1)); + assert_ok!(propose_set_balance_and_note(1, 2, 1)); - fast_forward_to(1); + fast_forward_to(2); let r = 0; assert_ok!(Democracy::set_proxy(Origin::signed(1), 10)); assert_ok!(Democracy::proxy_vote(Origin::signed(10), r, AYE)); @@ -1571,7 +1798,7 @@ mod tests { assert_eq!(Democracy::vote_of((r, 1)), AYE); assert_eq!(Democracy::tally(r), (1, 0, 1)); - fast_forward_to(5); + fast_forward_to(6); assert_eq!(Balances::free_balance(&42), 2); }); } @@ -1581,9 +1808,9 @@ mod tests { new_test_ext().execute_with(|| { System::set_block_number(0); - assert_ok!(propose_set_balance(1, 2, 1)); + assert_ok!(propose_set_balance_and_note(1, 2, 1)); - fast_forward_to(1); + fast_forward_to(2); // Delegate vote. assert_ok!(Democracy::delegate(Origin::signed(2), 1, Conviction::max_value())); @@ -1595,7 +1822,7 @@ mod tests { // Delegated vote is counted. assert_eq!(Democracy::tally(r), (3, 0, 3)); - fast_forward_to(5); + fast_forward_to(6); assert_eq!(Balances::free_balance(&42), 2); }); @@ -1606,9 +1833,9 @@ mod tests { new_test_ext().execute_with(|| { System::set_block_number(0); - assert_ok!(propose_set_balance(1, 2, 1)); + assert_ok!(propose_set_balance_and_note(1, 2, 1)); - fast_forward_to(1); + fast_forward_to(2); // Check behavior with cycle. assert_ok!(Democracy::delegate(Origin::signed(2), 1, Conviction::max_value())); @@ -1621,7 +1848,7 @@ mod tests { // Delegated vote is counted. assert_eq!(Democracy::tally(r), (6, 0, 6)); - fast_forward_to(5); + fast_forward_to(6); assert_eq!(Balances::free_balance(&42), 2); }); @@ -1633,9 +1860,9 @@ mod tests { new_test_ext().execute_with(|| { System::set_block_number(0); - assert_ok!(propose_set_balance(1, 2, 1)); + assert_ok!(propose_set_balance_and_note(1, 2, 1)); - fast_forward_to(1); + fast_forward_to(2); let r = 0; assert_ok!(Democracy::vote(Origin::signed(1), r, AYE)); @@ -1648,7 +1875,7 @@ mod tests { // Delegated vote is not counted. assert_eq!(Democracy::tally(r), (3, 0, 3)); - fast_forward_to(5); + fast_forward_to(6); assert_eq!(Balances::free_balance(&42), 2); }); @@ -1659,13 +1886,13 @@ mod tests { new_test_ext().execute_with(|| { System::set_block_number(0); - assert_ok!(propose_set_balance(1, 2, 1)); + assert_ok!(propose_set_balance_and_note(1, 2, 1)); // Delegate and undelegate vote. assert_ok!(Democracy::delegate(Origin::signed(2), 1, Conviction::max_value())); assert_ok!(Democracy::undelegate(Origin::signed(2))); - fast_forward_to(1); + fast_forward_to(2); let r = 0; assert_ok!(Democracy::vote(Origin::signed(1), r, AYE)); @@ -1676,7 +1903,7 @@ mod tests { // Delegated vote is not counted. assert_eq!(Democracy::tally(r), (1, 0, 1)); - fast_forward_to(5); + fast_forward_to(6); assert_eq!(Balances::free_balance(&42), 2); }); @@ -1688,9 +1915,9 @@ mod tests { new_test_ext().execute_with(|| { System::set_block_number(0); - assert_ok!(propose_set_balance(1, 2, 1)); + assert_ok!(propose_set_balance_and_note(1, 2, 1)); - fast_forward_to(1); + fast_forward_to(2); let r = 0; assert_ok!(Democracy::vote(Origin::signed(1), r, AYE)); @@ -1708,7 +1935,7 @@ mod tests { // Delegated vote is not counted. assert_eq!(Democracy::tally(r), (3, 0, 3)); - fast_forward_to(5); + fast_forward_to(6); assert_eq!(Balances::free_balance(&42), 2); }); @@ -1718,7 +1945,7 @@ mod tests { fn deposit_for_proposals_should_be_taken() { new_test_ext().execute_with(|| { System::set_block_number(1); - assert_ok!(propose_set_balance(1, 2, 5)); + assert_ok!(propose_set_balance_and_note(1, 2, 5)); assert_ok!(Democracy::second(Origin::signed(2), 0)); assert_ok!(Democracy::second(Origin::signed(5), 0)); assert_ok!(Democracy::second(Origin::signed(5), 0)); @@ -1733,7 +1960,7 @@ mod tests { fn deposit_for_proposals_should_be_returned() { new_test_ext().execute_with(|| { System::set_block_number(1); - assert_ok!(propose_set_balance(1, 2, 5)); + assert_ok!(propose_set_balance_and_note(1, 2, 5)); assert_ok!(Democracy::second(Origin::signed(2), 0)); assert_ok!(Democracy::second(Origin::signed(5), 0)); assert_ok!(Democracy::second(Origin::signed(5), 0)); @@ -1765,7 +1992,7 @@ mod tests { fn poor_seconder_should_not_work() { new_test_ext().execute_with(|| { System::set_block_number(1); - assert_ok!(propose_set_balance(2, 2, 11)); + assert_ok!(propose_set_balance_and_note(2, 2, 11)); assert_noop!(Democracy::second(Origin::signed(1), 0), "seconder\'s balance too low"); }); } @@ -1774,14 +2001,14 @@ mod tests { fn runners_up_should_come_after() { new_test_ext().execute_with(|| { System::set_block_number(0); - assert_ok!(propose_set_balance(1, 2, 2)); - assert_ok!(propose_set_balance(1, 4, 4)); - assert_ok!(propose_set_balance(1, 3, 3)); - fast_forward_to(1); + assert_ok!(propose_set_balance_and_note(1, 2, 2)); + assert_ok!(propose_set_balance_and_note(1, 4, 4)); + assert_ok!(propose_set_balance_and_note(1, 3, 3)); + fast_forward_to(2); assert_ok!(Democracy::vote(Origin::signed(1), 0, AYE)); - fast_forward_to(3); + fast_forward_to(4); assert_ok!(Democracy::vote(Origin::signed(1), 1, AYE)); - fast_forward_to(5); + fast_forward_to(6); assert_ok!(Democracy::vote(Origin::signed(1), 2, AYE)); }); } @@ -1791,8 +2018,8 @@ mod tests { new_test_ext().execute_with(|| { System::set_block_number(1); let r = Democracy::inject_referendum( - 1, - set_balance_proposal(2), + 2, + set_balance_proposal_hash_and_note(2), VoteThreshold::SuperMajorityApprove, 0 ).unwrap(); @@ -1814,8 +2041,8 @@ mod tests { new_test_ext().execute_with(|| { System::set_block_number(1); let r = Democracy::inject_referendum( - 1, - set_balance_proposal(2), + 2, + set_balance_proposal_hash_and_note(2), VoteThreshold::SuperMajorityApprove, 0 ).unwrap(); @@ -1834,8 +2061,8 @@ mod tests { new_test_ext().execute_with(|| { System::set_block_number(1); let r = Democracy::inject_referendum( - 1, - set_balance_proposal(2), + 2, + set_balance_proposal_hash_and_note(2), VoteThreshold::SuperMajorityApprove, 0 ).unwrap(); @@ -1857,11 +2084,12 @@ mod tests { new_test_ext().execute_with(|| { System::set_block_number(1); let r = Democracy::inject_referendum( - 1, - set_balance_proposal(2), + 2, + set_balance_proposal_hash_and_note(2), VoteThreshold::SuperMajorityApprove, 0 ).unwrap(); + assert_ok!(Democracy::vote(Origin::signed(1), r, BIG_AYE)); assert_ok!(Democracy::vote(Origin::signed(2), r, BIG_NAY)); assert_ok!(Democracy::vote(Origin::signed(3), r, BIG_NAY)); @@ -1883,8 +2111,8 @@ mod tests { new_test_ext().execute_with(|| { System::set_block_number(1); let r = Democracy::inject_referendum( - 1, - set_balance_proposal(2), + 2, + set_balance_proposal_hash_and_note(2), VoteThreshold::SuperMajorityApprove, 1 ).unwrap(); @@ -1911,8 +2139,8 @@ mod tests { new_test_ext().execute_with(|| { System::set_block_number(1); let r = Democracy::inject_referendum( - 1, - set_balance_proposal(2), + 2, + set_balance_proposal_hash_and_note(2), VoteThreshold::SuperMajorityApprove, 0 ).unwrap(); @@ -1936,8 +2164,8 @@ mod tests { System::set_block_number(1); let r = Democracy::inject_referendum( - 1, - set_balance_proposal(2), + 2, + set_balance_proposal_hash_and_note(2), VoteThreshold::SuperMajorityApprove, 0 ).unwrap(); @@ -1959,8 +2187,8 @@ mod tests { new_test_ext().execute_with(|| { System::set_block_number(0); let r = Democracy::inject_referendum( - 1, - set_balance_proposal(2), + 2, + set_balance_proposal_hash_and_note(2), VoteThreshold::SuperMajorityApprove, 0 ).unwrap(); @@ -1993,19 +2221,19 @@ mod tests { assert_eq!(Balances::locks(2), vec![BalanceLock { id: DEMOCRACY_ID, amount: u64::max_value(), - until: 17, + until: 18, reasons: WithdrawReason::Transfer.into() }]); assert_eq!(Balances::locks(3), vec![BalanceLock { id: DEMOCRACY_ID, amount: u64::max_value(), - until: 9, + until: 10, reasons: WithdrawReason::Transfer.into() }]); assert_eq!(Balances::locks(4), vec![BalanceLock { id: DEMOCRACY_ID, amount: u64::max_value(), - until: 5, + until: 6, reasons: WithdrawReason::Transfer.into() }]); assert_eq!(Balances::locks(5), vec![]); @@ -2019,8 +2247,8 @@ mod tests { new_test_ext().execute_with(|| { System::set_block_number(1); let r = Democracy::inject_referendum( - 1, - set_balance_proposal(2), + 2, + set_balance_proposal_hash_and_note(2), VoteThreshold::SuperMajorityApprove, 0 ).unwrap(); -- GitLab From 77324be7e54233cc5dbd2e2e03c32c34f82998ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Sun, 1 Dec 2019 10:14:01 +0100 Subject: [PATCH 054/172] Add some logs, fix reorg import. (#4250) --- client/transaction-pool/graph/src/base_pool.rs | 14 +++++++------- client/transaction-pool/graph/src/pool.rs | 6 +++--- client/transaction-pool/graph/src/ready.rs | 4 ++-- .../graph/src/validated_pool.rs | 18 ++++++++++++++---- client/transaction-pool/src/maintainer.rs | 7 ++++--- 5 files changed, 30 insertions(+), 19 deletions(-) diff --git a/client/transaction-pool/graph/src/base_pool.rs b/client/transaction-pool/graph/src/base_pool.rs index a683741aa4..ed2a5e2f6c 100644 --- a/client/transaction-pool/graph/src/base_pool.rs +++ b/client/transaction-pool/graph/src/base_pool.rs @@ -341,7 +341,7 @@ impl BasePool BasePool BasePool BasePool Vec>> { - let mut removed = self.ready.remove_invalid(hashes); + pub fn remove_subtree(&mut self, hashes: &[Hash]) -> Vec>> { + let mut removed = self.ready.remove_subtree(hashes); removed.extend(self.future.remove(hashes)); removed } @@ -454,7 +454,7 @@ impl BasePool) -> PruneStatus { @@ -905,7 +905,7 @@ mod tests { assert_eq!(pool.future.len(), 1); // when - pool.remove_invalid(&[6, 1]); + pool.remove_subtree(&[6, 1]); // then assert_eq!(pool.ready().count(), 1); diff --git a/client/transaction-pool/graph/src/pool.rs b/client/transaction-pool/graph/src/pool.rs index d40942c5e9..7d91ebaf4a 100644 --- a/client/transaction-pool/graph/src/pool.rs +++ b/client/transaction-pool/graph/src/pool.rs @@ -283,7 +283,7 @@ impl Pool { tags: impl IntoIterator, known_imported_hashes: impl IntoIterator> + Clone, ) -> impl Future> { - log::trace!(target: "txpool", "Pruning at {:?}", at); + log::debug!(target: "txpool", "Pruning at {:?}", at); // Prune all transactions that provide given tags let prune_status = match self.validated_pool.prune_tags(tags) { Ok(prune_status) => prune_status, @@ -317,7 +317,7 @@ impl Pool { } /// Return an event stream of notifications for when transactions are imported to the pool. - /// + /// /// Consumers of this stream should use the `ready` method to actually get the /// pending transactions in the right order. pub fn import_notification_stream(&self) -> EventStream { @@ -329,7 +329,7 @@ impl Pool { self.validated_pool.on_broadcasted(propagated) } - /// Remove from the pool. + /// Remove invalid transactions from the pool. pub fn remove_invalid(&self, hashes: &[ExHash]) -> Vec> { self.validated_pool.remove_invalid(hashes) } diff --git a/client/transaction-pool/graph/src/ready.rs b/client/transaction-pool/graph/src/ready.rs index 3684572bd0..81c370625c 100644 --- a/client/transaction-pool/graph/src/ready.rs +++ b/client/transaction-pool/graph/src/ready.rs @@ -230,12 +230,12 @@ impl ReadyTransactions { }).collect() } - /// Removes invalid transactions from the ready pool. + /// Removes a subtree of transactions from the ready pool. /// /// NOTE removing a transaction will also cause a removal of all transactions that depend on that one /// (i.e. the entire subgraph that this transaction is a start of will be removed). /// All removed transactions are returned. - pub fn remove_invalid(&mut self, hashes: &[Hash]) -> Vec>> { + pub fn remove_subtree(&mut self, hashes: &[Hash]) -> Vec>> { let mut removed = vec![]; let mut to_remove = hashes.iter().cloned().collect::>(); diff --git a/client/transaction-pool/graph/src/validated_pool.rs b/client/transaction-pool/graph/src/validated_pool.rs index 2aca2adb72..f46c2b0cf6 100644 --- a/client/transaction-pool/graph/src/validated_pool.rs +++ b/client/transaction-pool/graph/src/validated_pool.rs @@ -215,9 +215,9 @@ impl ValidatedPool { let hash = updated_transactions.keys().next().cloned().expect("transactions is not empty; qed"); // note we are not considering tx with hash invalid here - we just want - // to remove it along with dependent transactions and `remove_invalid()` + // to remove it along with dependent transactions and `remove_subtree()` // does exactly what we need - let removed = pool.remove_invalid(&[hash.clone()]); + let removed = pool.remove_subtree(&[hash.clone()]); for removed_tx in removed { let removed_hash = removed_tx.hash.clone(); let updated_transaction = updated_transactions.remove(&removed_hash); @@ -451,13 +451,23 @@ impl ValidatedPool { } } - /// Remove from the pool. + /// Remove a subtree of transactions from the pool and mark them invalid. + /// + /// The transactions passed as an argument will be additionally banned + /// to prevent them from entering the pool right away. + /// Note this is not the case for the dependent transactions - those may + /// still be valid so we want to be able to re-import them. pub fn remove_invalid(&self, hashes: &[ExHash]) -> Vec> { + // early exit in case there is no invalid transactions. + if hashes.is_empty() { + return vec![] + } + // temporarily ban invalid transactions debug!(target: "txpool", "Banning invalid transactions: {:?}", hashes); self.rotator.ban(&time::Instant::now(), hashes.iter().cloned()); - let invalid = self.pool.write().remove_invalid(hashes); + let invalid = self.pool.write().remove_subtree(hashes); let mut listener = self.listener.write(); for tx in &invalid { diff --git a/client/transaction-pool/src/maintainer.rs b/client/transaction-pool/src/maintainer.rs index a390dde88b..f5eeb90b85 100644 --- a/client/transaction-pool/src/maintainer.rs +++ b/client/transaction-pool/src/maintainer.rs @@ -23,7 +23,7 @@ use futures::{ Future, FutureExt, future::{Either, join, ready}, }; -use log::warn; +use log::{warn, debug}; use parking_lot::Mutex; use client_api::{ @@ -79,13 +79,14 @@ where let retracted_transactions = retracted.to_vec().into_iter() .filter_map(move |hash| client_copy.block_body(&BlockId::hash(hash)).ok().unwrap_or(None)) .flat_map(|block| block.into_iter()) - .filter(|tx| tx.is_signed().unwrap_or(false)); + // if signed information is not present, attempt to resubmit anyway. + .filter(|tx| tx.is_signed().unwrap_or(true)); let resubmit_future = self.pool .submit_at(id, retracted_transactions, true) .then(|resubmit_result| ready(match resubmit_result { Ok(_) => (), Err(e) => { - warn!("Error re-submitting transactions: {:?}", e); + debug!(target: "txpool", "Error re-submitting transactions: {:?}", e); () } })); -- GitLab From 33476f08b3400a07fd7c69cd5bf4ad8f47f11373 Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Sun, 1 Dec 2019 12:08:24 +0100 Subject: [PATCH 055/172] Fix functions doc. (#4260) --- client/peerset/src/peersstate.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/peerset/src/peersstate.rs b/client/peerset/src/peersstate.rs index 57dfc50d34..a1a50750f3 100644 --- a/client/peerset/src/peersstate.rs +++ b/client/peerset/src/peersstate.rs @@ -249,8 +249,8 @@ impl PeersState { /// Tries to accept the peer as an incoming connection. /// - /// If there are enough slots available, switches the node to "connected" and returns `Ok`. If - /// the slots are full, the node stays "not connected" and we return `Err`. + /// If there are enough slots available, switches the node to "connected" and returns `true`. If + /// the slots are full, the node stays "not connected" and we return `false`. /// /// Note that reserved nodes don't count towards the number of slots. fn try_accept_incoming(&mut self, peer_id: &PeerId) -> bool { -- GitLab From ea8dd676bac763c9619d5626070ffff0305b8ebe Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Sun, 1 Dec 2019 14:59:56 +0100 Subject: [PATCH 056/172] Use result. (#4259) --- client/finality-grandpa/src/environment.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/finality-grandpa/src/environment.rs b/client/finality-grandpa/src/environment.rs index bc04ecef04..0f70ac531d 100644 --- a/client/finality-grandpa/src/environment.rs +++ b/client/finality-grandpa/src/environment.rs @@ -865,7 +865,7 @@ where historical_votes.seen().iter().skip(n_existing_votes).cloned() ); already_completed.state = state; - crate::aux_schema::write_concluded_round(&*self.client, &already_completed); + crate::aux_schema::write_concluded_round(&*self.client, &already_completed)?; } let set_state = VoterSetState::::Live { -- GitLab From 1903f36f7bafea45eababfda9011a239b3aaab6c Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Sun, 1 Dec 2019 20:52:00 +0100 Subject: [PATCH 057/172] Introduce `VestingCurrency` trait (#4257) * Introduce `VestingCurrency` trait * Return error if account already has vesting schedule --- frame/balances/src/lib.rs | 59 ++++++++++++++++++++++++++++--------- frame/support/src/traits.rs | 23 +++++++++++++++ 2 files changed, 68 insertions(+), 14 deletions(-) diff --git a/frame/balances/src/lib.rs b/frame/balances/src/lib.rs index cee4f9dbe9..553592364b 100644 --- a/frame/balances/src/lib.rs +++ b/frame/balances/src/lib.rs @@ -167,7 +167,7 @@ use support::{ traits::{ UpdateBalanceOutcome, Currency, OnFreeBalanceZero, OnUnbalanced, TryDrop, WithdrawReason, WithdrawReasons, LockIdentifier, LockableCurrency, ExistenceRequirement, - Imbalance, SignedImbalance, ReservableCurrency, Get, + Imbalance, SignedImbalance, ReservableCurrency, Get, VestingCurrency, }, weights::SimpleDispatchInfo, dispatch::Result, @@ -510,19 +510,6 @@ decl_module! { } impl, I: Instance> Module { - - // PUBLIC IMMUTABLES - - /// Get the amount that is currently being vested and cannot be transferred out of this account. - pub fn vesting_balance(who: &T::AccountId) -> T::Balance { - if let Some(v) = Self::vesting(who) { - Self::free_balance(who) - .min(v.locked_at(>::block_number())) - } else { - Zero::zero() - } - } - // PRIVATE MUTABLES /// Set the reserved balance of an account to some new value. Will enforce `ExistentialDeposit` @@ -1209,6 +1196,50 @@ where } } +impl, I: Instance> VestingCurrency for Module +where + T::Balance: MaybeSerializeDeserialize + Debug +{ + type Moment = T::BlockNumber; + + /// Get the amount that is currently being vested and cannot be transferred out of this account. + fn vesting_balance(who: &T::AccountId) -> T::Balance { + if let Some(v) = Self::vesting(who) { + Self::free_balance(who) + .min(v.locked_at(>::block_number())) + } else { + Zero::zero() + } + } + + /// Adds a vesting schedule to a given account. + /// + /// If there already exists a vesting schedule for the given account, an `Err` is returned + /// and nothing is updated. + fn add_vesting_schedule( + who: &T::AccountId, + locked: T::Balance, + per_block: T::Balance, + starting_block: T::BlockNumber + ) -> Result { + if >::exists(who) { + return Err("A vesting schedule already exists for this account."); + } + let vesting_schedule = VestingSchedule { + locked, + per_block, + starting_block + }; + >::insert(who, vesting_schedule); + Ok(()) + } + + /// Remove a vesting schedule for a given account. + fn remove_vesting_schedule(who: &T::AccountId) { + >::remove(who); + } +} + impl, I: Instance> IsDeadAccount for Module where T::Balance: MaybeSerializeDeserialize + Debug diff --git a/frame/support/src/traits.rs b/frame/support/src/traits.rs index 3de5c4770b..d06d728454 100644 --- a/frame/support/src/traits.rs +++ b/frame/support/src/traits.rs @@ -602,6 +602,29 @@ pub trait LockableCurrency: Currency { ); } +/// A currency whose accounts can have balances which vest over time. +pub trait VestingCurrency: Currency { + /// The quantity used to denote time; usually just a `BlockNumber`. + type Moment; + + /// Get the amount that is currently being vested and cannot be transferred out of this account. + fn vesting_balance(who: &AccountId) -> Self::Balance; + + /// Adds a vesting schedule to a given account. + /// + /// If there already exists a vesting schedule for the given account, an `Err` is returned + /// and nothing is updated. + fn add_vesting_schedule( + who: &AccountId, + locked: Self::Balance, + per_block: Self::Balance, + starting_block: Self::Moment, + ) -> result::Result<(), &'static str>; + + /// Remove a vesting schedule for a given account. + fn remove_vesting_schedule(who: &AccountId); +} + bitmask! { /// Reasons for moving funds out of an account. #[derive(Encode, Decode)] -- GitLab From 28c329e010dbedecd2d6df58ea4d4c7fab140c83 Mon Sep 17 00:00:00 2001 From: Benjamin Kampmann Date: Mon, 2 Dec 2019 11:23:53 +0100 Subject: [PATCH 058/172] The crate rename (#4223) * Adding script for rename, could be applicable for nodes on top of it, too * add stderr and gitlab ci features * apply script * fix now minor details in expected stderr * Update the Cargo.lock * fix name: sc-transaction -> sc-tracing * fix rename in script, too --- .gitlab-ci.yml | 18 +- .maintain/rename-crates-for-2.0.sh | 112 + Cargo.lock | 3086 ++++++++--------- bin/node-template/Cargo.toml | 32 +- bin/node-template/runtime/Cargo.toml | 28 +- bin/node-template/runtime/src/lib.rs | 18 +- bin/node-template/runtime/src/template.rs | 2 +- bin/node-template/src/chain_spec.rs | 6 +- bin/node-template/src/cli.rs | 6 +- bin/node-template/src/main.rs | 2 +- bin/node-template/src/service.rs | 14 +- bin/node/cli/Cargo.toml | 64 +- bin/node/cli/bin/main.rs | 6 +- bin/node/cli/build.rs | 2 +- bin/node/cli/src/browser.rs | 2 +- bin/node/cli/src/chain_spec.rs | 10 +- bin/node/cli/src/cli.rs | 16 +- bin/node/cli/src/factory_impl.rs | 4 +- bin/node/cli/src/service.rs | 26 +- bin/node/executor/Cargo.toml | 16 +- bin/node/executor/benches/bench.rs | 2 +- bin/node/executor/src/lib.rs | 10 +- bin/node/primitives/Cargo.toml | 8 +- bin/node/primitives/src/lib.rs | 2 +- bin/node/rpc-client/Cargo.toml | 2 +- bin/node/rpc-client/src/main.rs | 2 +- bin/node/rpc/Cargo.toml | 4 +- bin/node/rpc/src/lib.rs | 4 +- bin/node/runtime/Cargo.toml | 38 +- bin/node/runtime/src/impls.rs | 6 +- bin/node/runtime/src/lib.rs | 20 +- bin/node/testing/Cargo.toml | 12 +- bin/node/testing/src/client.rs | 4 +- bin/node/testing/src/genesis.rs | 2 +- bin/node/testing/src/keyring.rs | 2 +- bin/subkey/Cargo.toml | 4 +- bin/subkey/src/main.rs | 2 +- client/Cargo.toml | 36 +- client/api/Cargo.toml | 34 +- client/api/src/backend.rs | 4 +- client/api/src/call_executor.rs | 4 +- client/api/src/client.rs | 2 +- client/api/src/execution_extensions.rs | 2 +- client/api/src/lib.rs | 2 +- client/api/src/light.rs | 2 +- client/api/src/notifications.rs | 4 +- client/authority-discovery/Cargo.toml | 18 +- client/authority-discovery/src/lib.rs | 10 +- client/basic-authorship/Cargo.toml | 20 +- .../basic-authorship/src/basic_authorship.rs | 6 +- client/basic-authorship/src/lib.rs | 4 +- client/block-builder/Cargo.toml | 12 +- client/block-builder/src/lib.rs | 4 +- client/chain-spec/Cargo.toml | 12 +- client/chain-spec/derive/Cargo.toml | 2 +- client/chain-spec/derive/src/impls.rs | 2 +- client/chain-spec/src/chain_spec.rs | 2 +- client/chain-spec/src/extension.rs | 4 +- client/chain-spec/src/lib.rs | 10 +- client/cli/Cargo.toml | 22 +- client/cli/src/informant.rs | 2 +- client/cli/src/informant/display.rs | 2 +- client/cli/src/lib.rs | 10 +- client/cli/src/params.rs | 10 +- client/consensus/aura/Cargo.toml | 40 +- client/consensus/aura/src/digest.rs | 2 +- client/consensus/aura/src/lib.rs | 12 +- client/consensus/babe/Cargo.toml | 44 +- client/consensus/babe/src/aux_schema.rs | 2 +- client/consensus/babe/src/epoch_changes.rs | 2 +- client/consensus/babe/src/lib.rs | 10 +- client/consensus/babe/src/tests.rs | 4 +- client/consensus/babe/src/verification.rs | 2 +- client/consensus/pow/Cargo.toml | 16 +- client/consensus/pow/src/lib.rs | 6 +- client/consensus/slots/Cargo.toml | 14 +- client/consensus/slots/src/aux_schema.rs | 4 +- client/consensus/slots/src/lib.rs | 12 +- client/consensus/uncles/Cargo.toml | 12 +- client/consensus/uncles/src/lib.rs | 2 +- client/db/Cargo.toml | 22 +- client/db/src/cache/list_cache.rs | 8 +- client/db/src/cache/list_entry.rs | 2 +- client/db/src/cache/list_storage.rs | 4 +- client/db/src/cache/mod.rs | 4 +- client/db/src/lib.rs | 10 +- client/db/src/light.rs | 8 +- client/db/src/storage_cache.rs | 6 +- client/db/src/utils.rs | 8 +- client/executor/Cargo.toml | 30 +- client/executor/runtime-test/Cargo.toml | 12 +- client/executor/runtime-test/src/lib.rs | 2 +- .../executor/src/deprecated_host_interface.rs | 4 +- client/executor/src/native_executor.rs | 4 +- client/executor/src/wasmi_execution.rs | 2 +- .../src/wasmtime/function_executor.rs | 2 +- client/finality-grandpa/Cargo.toml | 32 +- client/finality-grandpa/src/authorities.rs | 2 +- client/finality-grandpa/src/aux_schema.rs | 2 +- .../src/communication/gossip.rs | 4 +- .../finality-grandpa/src/communication/mod.rs | 4 +- .../src/communication/periodic.rs | 2 +- .../src/communication/tests.rs | 2 +- client/finality-grandpa/src/environment.rs | 6 +- client/finality-grandpa/src/finality_proof.rs | 4 +- client/finality-grandpa/src/import.rs | 6 +- client/finality-grandpa/src/justification.rs | 4 +- client/finality-grandpa/src/lib.rs | 6 +- client/finality-grandpa/src/light_import.rs | 6 +- client/finality-grandpa/src/observer.rs | 2 +- client/finality-grandpa/src/tests.rs | 6 +- client/finality-grandpa/src/until_imported.rs | 2 +- client/finality-grandpa/src/voting_rule.rs | 4 +- client/keystore/Cargo.toml | 6 +- client/network/Cargo.toml | 24 +- client/network/src/behaviour.rs | 2 +- client/network/src/chain.rs | 6 +- client/network/src/config.rs | 4 +- client/network/src/lib.rs | 6 +- client/network/src/on_demand_layer.rs | 2 +- client/network/src/protocol.rs | 6 +- .../network/src/protocol/consensus_gossip.rs | 6 +- client/network/src/protocol/light_dispatch.rs | 4 +- client/network/src/protocol/message.rs | 4 +- client/network/src/protocol/specialization.rs | 2 +- client/network/src/protocol/sync.rs | 2 +- client/network/src/protocol/sync/blocks.rs | 4 +- .../src/protocol/sync/extra_requests.rs | 2 +- client/network/src/service.rs | 6 +- client/network/src/test/block_import.rs | 2 +- client/network/src/test/mod.rs | 6 +- client/offchain/Cargo.toml | 20 +- client/offchain/src/lib.rs | 6 +- client/peerset/Cargo.toml | 2 +- client/peerset/tests/fuzz.rs | 2 +- client/rpc-servers/Cargo.toml | 4 +- client/rpc/Cargo.toml | 30 +- client/rpc/api/Cargo.toml | 6 +- client/rpc/src/author/mod.rs | 4 +- client/rpc/src/chain/chain_full.rs | 2 +- client/rpc/src/chain/chain_light.rs | 2 +- client/rpc/src/chain/mod.rs | 2 +- client/rpc/src/state/mod.rs | 4 +- client/rpc/src/state/state_full.rs | 4 +- client/rpc/src/state/state_light.rs | 2 +- client/rpc/src/state/tests.rs | 2 +- client/rpc/src/system/mod.rs | 2 +- client/service/Cargo.toml | 50 +- client/service/src/builder.rs | 14 +- client/service/src/chain_ops.rs | 4 +- client/service/src/config.rs | 4 +- client/service/src/lib.rs | 10 +- client/service/test/Cargo.toml | 14 +- client/service/test/src/lib.rs | 2 +- client/src/call_executor.rs | 4 +- client/src/cht.rs | 2 +- client/src/client.rs | 10 +- client/src/genesis.rs | 2 +- client/src/in_mem.rs | 6 +- client/src/leaves.rs | 2 +- client/src/lib.rs | 6 +- client/src/light/backend.rs | 4 +- client/src/light/blockchain.rs | 4 +- client/src/light/call_executor.rs | 6 +- client/src/light/fetcher.rs | 4 +- client/src/light/mod.rs | 4 +- client/state-db/Cargo.toml | 4 +- client/telemetry/Cargo.toml | 2 +- client/telemetry/src/lib.rs | 8 +- client/tracing/Cargo.toml | 4 +- client/tracing/src/lib.rs | 2 +- client/transaction-pool/Cargo.toml | 14 +- client/transaction-pool/graph/Cargo.toml | 6 +- .../transaction-pool/graph/benches/basics.rs | 6 +- .../transaction-pool/graph/src/base_pool.rs | 4 +- client/transaction-pool/graph/src/error.rs | 2 +- client/transaction-pool/graph/src/future.rs | 2 +- client/transaction-pool/graph/src/listener.rs | 2 +- client/transaction-pool/graph/src/pool.rs | 4 +- client/transaction-pool/graph/src/ready.rs | 4 +- .../graph/src/validated_pool.rs | 2 +- client/transaction-pool/src/api.rs | 4 +- client/transaction-pool/src/lib.rs | 2 +- client/transaction-pool/src/maintainer.rs | 8 +- client/transaction-pool/src/tests.rs | 2 +- frame/assets/Cargo.toml | 10 +- frame/assets/src/lib.rs | 6 +- frame/aura/Cargo.toml | 18 +- frame/aura/src/lib.rs | 10 +- frame/aura/src/mock.rs | 6 +- frame/authority-discovery/Cargo.toml | 16 +- frame/authority-discovery/src/lib.rs | 6 +- frame/authorship/Cargo.toml | 12 +- frame/authorship/src/lib.rs | 6 +- frame/babe/Cargo.toml | 20 +- frame/babe/src/lib.rs | 10 +- frame/babe/src/mock.rs | 6 +- frame/babe/src/tests.rs | 2 +- frame/balances/Cargo.toml | 10 +- frame/balances/src/lib.rs | 6 +- frame/balances/src/mock.rs | 4 +- frame/balances/src/tests.rs | 2 +- frame/collective/Cargo.toml | 10 +- frame/collective/src/lib.rs | 10 +- frame/contracts/Cargo.toml | 12 +- frame/contracts/rpc/Cargo.toml | 6 +- frame/contracts/rpc/runtime-api/Cargo.toml | 10 +- frame/contracts/rpc/runtime-api/src/lib.rs | 4 +- frame/contracts/rpc/src/lib.rs | 2 +- frame/contracts/src/account_db.rs | 2 +- frame/contracts/src/exec.rs | 6 +- frame/contracts/src/gas.rs | 2 +- frame/contracts/src/lib.rs | 2 +- frame/contracts/src/rent.rs | 2 +- frame/contracts/src/tests.rs | 2 +- frame/contracts/src/wasm/code_cache.rs | 2 +- frame/contracts/src/wasm/env_def/macros.rs | 2 +- frame/contracts/src/wasm/prepare.rs | 2 +- frame/contracts/src/wasm/runtime.rs | 4 +- frame/democracy/Cargo.toml | 10 +- frame/democracy/src/lib.rs | 6 +- frame/democracy/src/vote_threshold.rs | 4 +- frame/elections-phragmen/Cargo.toml | 12 +- frame/elections-phragmen/src/lib.rs | 8 +- frame/elections/Cargo.toml | 10 +- frame/elections/src/lib.rs | 2 +- frame/elections/src/mock.rs | 6 +- frame/evm/Cargo.toml | 10 +- frame/evm/src/backend.rs | 2 +- frame/evm/src/lib.rs | 4 +- frame/example/Cargo.toml | 10 +- frame/example/src/lib.rs | 8 +- frame/executive/Cargo.toml | 10 +- frame/executive/src/lib.rs | 34 +- frame/finality-tracker/Cargo.toml | 12 +- frame/finality-tracker/src/lib.rs | 4 +- frame/generic-asset/Cargo.toml | 10 +- frame/generic-asset/src/lib.rs | 4 +- frame/generic-asset/src/mock.rs | 2 +- frame/grandpa/Cargo.toml | 18 +- frame/grandpa/src/lib.rs | 8 +- frame/grandpa/src/mock.rs | 6 +- frame/grandpa/src/tests.rs | 4 +- frame/im-online/Cargo.toml | 16 +- frame/im-online/src/lib.rs | 6 +- frame/im-online/src/mock.rs | 8 +- frame/im-online/src/tests.rs | 2 +- frame/indices/Cargo.toml | 14 +- frame/indices/src/address.rs | 2 +- frame/indices/src/lib.rs | 2 +- frame/indices/src/mock.rs | 6 +- frame/membership/Cargo.toml | 10 +- frame/membership/src/lib.rs | 4 +- frame/metadata/Cargo.toml | 4 +- frame/nicks/Cargo.toml | 10 +- frame/nicks/src/lib.rs | 4 +- frame/offences/Cargo.toml | 14 +- frame/offences/src/lib.rs | 4 +- frame/offences/src/mock.rs | 10 +- frame/offences/src/tests.rs | 2 +- frame/randomness-collective-flip/Cargo.toml | 10 +- frame/randomness-collective-flip/src/lib.rs | 4 +- frame/scored-pool/Cargo.toml | 10 +- frame/scored-pool/src/lib.rs | 2 +- frame/scored-pool/src/mock.rs | 2 +- frame/scored-pool/src/tests.rs | 2 +- frame/session/Cargo.toml | 22 +- frame/session/src/historical.rs | 12 +- frame/session/src/lib.rs | 10 +- frame/session/src/mock.rs | 8 +- frame/staking/Cargo.toml | 20 +- frame/staking/reward-curve/Cargo.toml | 2 +- frame/staking/reward-curve/src/lib.rs | 18 +- frame/staking/reward-curve/tests/test.rs | 4 +- frame/staking/src/inflation.rs | 4 +- frame/staking/src/lib.rs | 6 +- frame/staking/src/mock.rs | 12 +- frame/staking/src/slashing.rs | 2 +- frame/staking/src/tests.rs | 4 +- frame/sudo/Cargo.toml | 10 +- frame/sudo/src/lib.rs | 6 +- frame/support/Cargo.toml | 18 +- .../procedural/src/construct_runtime/mod.rs | 6 +- .../src/storage/genesis_config/mod.rs | 14 +- frame/support/procedural/tools/src/lib.rs | 4 +- frame/support/src/dispatch.rs | 28 +- frame/support/src/error.rs | 2 +- frame/support/src/inherent.rs | 2 +- frame/support/src/lib.rs | 4 +- frame/support/src/traits.rs | 2 +- frame/support/src/unsigned.rs | 4 +- frame/support/src/weights.rs | 8 +- frame/support/test/Cargo.toml | 12 +- frame/support/test/tests/instance.rs | 6 +- frame/support/test/tests/issue2219.rs | 4 +- frame/support/test/tests/system.rs | 2 +- frame/system/Cargo.toml | 14 +- frame/system/benches/bench.rs | 2 +- frame/system/rpc/runtime-api/Cargo.toml | 4 +- frame/system/rpc/runtime-api/src/lib.rs | 2 +- frame/system/src/lib.rs | 6 +- frame/system/src/offchain.rs | 4 +- frame/timestamp/Cargo.toml | 12 +- frame/timestamp/src/lib.rs | 4 +- frame/transaction-payment/Cargo.toml | 10 +- frame/transaction-payment/rpc/Cargo.toml | 6 +- .../rpc/runtime-api/Cargo.toml | 10 +- .../rpc/runtime-api/src/lib.rs | 2 +- frame/transaction-payment/rpc/src/lib.rs | 2 +- frame/transaction-payment/src/lib.rs | 4 +- frame/treasury/Cargo.toml | 10 +- frame/treasury/src/lib.rs | 8 +- frame/utility/Cargo.toml | 10 +- frame/utility/src/lib.rs | 4 +- primitives/application-crypto/Cargo.toml | 10 +- primitives/application-crypto/src/ed25519.rs | 2 +- primitives/application-crypto/src/lib.rs | 6 +- primitives/application-crypto/src/sr25519.rs | 2 +- primitives/authority-discovery/Cargo.toml | 14 +- primitives/authority-discovery/src/lib.rs | 2 +- primitives/authorship/Cargo.toml | 4 +- .../block-builder/runtime-api/Cargo.toml | 14 +- .../block-builder/runtime-api/src/lib.rs | 6 +- primitives/blockchain/Cargo.toml | 8 +- primitives/blockchain/src/backend.rs | 6 +- primitives/blockchain/src/error.rs | 2 +- primitives/blockchain/src/header_metadata.rs | 2 +- primitives/consensus/aura/Cargo.toml | 16 +- primitives/consensus/aura/src/lib.rs | 4 +- primitives/consensus/babe/Cargo.toml | 18 +- primitives/consensus/babe/src/digest.rs | 4 +- primitives/consensus/babe/src/lib.rs | 4 +- primitives/consensus/common/Cargo.toml | 12 +- .../consensus/common/src/block_import.rs | 4 +- .../consensus/common/src/block_validation.rs | 2 +- primitives/consensus/common/src/evaluation.rs | 2 +- .../consensus/common/src/import_queue.rs | 2 +- .../common/src/import_queue/basic_queue.rs | 2 +- .../common/src/import_queue/buffered_link.rs | 6 +- primitives/consensus/common/src/lib.rs | 2 +- .../consensus/common/src/select_chain.rs | 2 +- primitives/consensus/pow/Cargo.toml | 14 +- primitives/consensus/pow/src/lib.rs | 4 +- primitives/core/Cargo.toml | 16 +- primitives/core/benches/bench.rs | 2 +- primitives/core/debug-derive/Cargo.toml | 2 +- primitives/core/debug-derive/src/lib.rs | 2 +- primitives/core/debug-derive/tests/tests.rs | 2 +- primitives/core/src/hash.rs | 2 +- primitives/core/src/lib.rs | 2 +- primitives/core/src/testing.rs | 2 +- primitives/core/src/uint.rs | 2 +- primitives/core/storage/Cargo.toml | 6 +- primitives/core/storage/src/lib.rs | 2 +- primitives/externalities/Cargo.toml | 6 +- primitives/externalities/src/extensions.rs | 2 +- primitives/finality-grandpa/Cargo.toml | 14 +- primitives/finality-grandpa/src/lib.rs | 4 +- primitives/finality-tracker/Cargo.toml | 4 +- primitives/inherents/Cargo.toml | 6 +- primitives/keyring/Cargo.toml | 6 +- primitives/keyring/src/ed25519.rs | 6 +- primitives/keyring/src/sr25519.rs | 6 +- primitives/offchain/Cargo.toml | 10 +- primitives/offchain/src/lib.rs | 4 +- primitives/panic-handler/Cargo.toml | 2 +- primitives/phragmen/Cargo.toml | 10 +- primitives/phragmen/benches/phragmen.rs | 4 +- primitives/phragmen/src/lib.rs | 6 +- primitives/phragmen/src/mock.rs | 2 +- primitives/phragmen/src/tests.rs | 2 +- primitives/rpc/Cargo.toml | 4 +- primitives/runtime-interface/Cargo.toml | 20 +- .../runtime-interface/proc-macro/Cargo.toml | 6 +- .../runtime-interface/proc-macro/src/lib.rs | 8 +- .../runtime-interface/proc-macro/src/utils.rs | 10 +- primitives/runtime-interface/src/lib.rs | 4 +- primitives/runtime-interface/src/pass_by.rs | 8 +- .../runtime-interface/test-wasm/Cargo.toml | 10 +- primitives/serializer/Cargo.toml | 2 +- primitives/session/Cargo.toml | 10 +- primitives/session/src/lib.rs | 6 +- primitives/sr-api/Cargo.toml | 18 +- primitives/sr-api/benches/bench.rs | 6 +- primitives/sr-api/proc-macro/Cargo.toml | 8 +- primitives/sr-api/proc-macro/src/lib.rs | 18 +- primitives/sr-api/proc-macro/src/utils.rs | 14 +- primitives/sr-api/src/lib.rs | 8 +- primitives/sr-api/test/Cargo.toml | 12 +- primitives/sr-api/test/tests/decl_and_impl.rs | 10 +- primitives/sr-api/test/tests/runtime_calls.rs | 2 +- .../test/tests/ui/adding_self_parameter.rs | 2 +- .../tests/ui/changed_in_unknown_version.rs | 4 +- .../test/tests/ui/declaring_old_block.rs | 4 +- .../test/tests/ui/declaring_old_block.stderr | 6 +- ...declaring_own_block_with_different_name.rs | 4 +- ...aring_own_block_with_different_name.stderr | 6 +- .../tests/ui/empty_impl_runtime_apis_call.rs | 6 +- .../ui/empty_impl_runtime_apis_call.stderr | 2 +- .../ui/impl_incorrect_method_signature.rs | 8 +- .../ui/impl_incorrect_method_signature.stderr | 10 +- .../ui/impl_two_traits_with_same_name.rs | 6 +- .../ui/impl_two_traits_with_same_name.stderr | 10 +- .../test/tests/ui/invalid_api_version.rs | 2 +- .../test/tests/ui/invalid_api_version.stderr | 4 +- .../test/tests/ui/invalid_api_version_2.rs | 2 +- .../tests/ui/invalid_api_version_2.stderr | 4 +- .../test/tests/ui/invalid_api_version_3.rs | 2 +- .../tests/ui/invalid_api_version_3.stderr | 4 +- .../ui/missing_block_generic_parameter.rs | 6 +- .../test/tests/ui/missing_path_for_trait.rs | 6 +- ...ype_reference_in_impl_runtime_apis_call.rs | 8 +- ...reference_in_impl_runtime_apis_call.stderr | 10 +- primitives/sr-arithmetic/Cargo.toml | 8 +- primitives/sr-arithmetic/benches/bench.rs | 2 +- primitives/sr-arithmetic/fuzzer/Cargo.toml | 4 +- .../sr-arithmetic/fuzzer/src/biguint.rs | 2 +- .../sr-arithmetic/fuzzer/src/rational128.rs | 2 +- primitives/sr-arithmetic/src/lib.rs | 2 +- primitives/sr-arithmetic/src/per_things.rs | 2 +- primitives/sr-arithmetic/src/rational128.rs | 2 +- primitives/sr-io/Cargo.toml | 16 +- primitives/sr-io/src/lib.rs | 4 +- primitives/sr-primitives/Cargo.toml | 14 +- primitives/sr-primitives/src/lib.rs | 8 +- primitives/sr-primitives/src/offchain/http.rs | 4 +- .../src/random_number_generator.rs | 4 +- primitives/sr-primitives/src/traits.rs | 2 +- primitives/sr-sandbox/Cargo.toml | 8 +- primitives/sr-staking-primitives/Cargo.toml | 8 +- .../sr-staking-primitives/src/offence.rs | 4 +- primitives/sr-std/Cargo.toml | 2 +- primitives/sr-std/src/lib.rs | 2 +- primitives/sr-version/Cargo.toml | 8 +- primitives/sr-version/src/lib.rs | 10 +- primitives/state-machine/Cargo.toml | 10 +- primitives/timestamp/Cargo.toml | 12 +- primitives/timestamp/src/lib.rs | 4 +- primitives/transaction-pool/Cargo.toml | 4 +- .../transaction-pool/runtime-api/Cargo.toml | 8 +- .../transaction-pool/runtime-api/src/lib.rs | 4 +- primitives/transaction-pool/src/error.rs | 2 +- primitives/transaction-pool/src/lib.rs | 6 +- primitives/trie/Cargo.toml | 6 +- primitives/trie/benches/bench.rs | 8 +- primitives/wasm-interface/Cargo.toml | 2 +- test/utils/chain-spec-builder/Cargo.toml | 4 +- test/utils/client/Cargo.toml | 18 +- test/utils/client/src/client_ext.rs | 6 +- test/utils/client/src/lib.rs | 4 +- test/utils/primitives/Cargo.toml | 6 +- test/utils/primitives/src/lib.rs | 10 +- test/utils/runtime/Cargo.toml | 46 +- test/utils/runtime/client/Cargo.toml | 10 +- .../runtime/client/src/block_builder_ext.rs | 2 +- test/utils/runtime/client/src/lib.rs | 2 +- test/utils/runtime/client/src/trait_tests.rs | 4 +- test/utils/runtime/src/genesismap.rs | 4 +- test/utils/runtime/src/lib.rs | 30 +- test/utils/runtime/src/system.rs | 12 +- test/utils/transaction-factory/Cargo.toml | 18 +- .../transaction-factory/src/complex_mode.rs | 6 +- test/utils/transaction-factory/src/lib.rs | 6 +- .../transaction-factory/src/simple_modes.rs | 6 +- utils/frame/rpc/support/Cargo.toml | 2 +- utils/frame/rpc/support/src/lib.rs | 2 +- utils/frame/rpc/system/Cargo.toml | 8 +- utils/frame/rpc/system/src/lib.rs | 4 +- 468 files changed, 3366 insertions(+), 3254 deletions(-) create mode 100644 .maintain/rename-crates-for-2.0.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 439fda5fab..91994487b7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -218,14 +218,14 @@ check-web-wasm: script: # WASM support is in progress. As more and more crates support WASM, we # should add entries here. See https://github.com/paritytech/substrate/issues/2416 - - time cargo build --target=wasm32-unknown-unknown -p sr-io - - time cargo build --target=wasm32-unknown-unknown -p sr-primitives - - time cargo build --target=wasm32-unknown-unknown -p sr-std - - time cargo build --target=wasm32-unknown-unknown -p substrate-client - - time cargo build --target=wasm32-unknown-unknown -p substrate-consensus-aura - - time cargo build --target=wasm32-unknown-unknown -p substrate-consensus-babe - - time cargo build --target=wasm32-unknown-unknown -p substrate-consensus-common - - time cargo build --target=wasm32-unknown-unknown -p substrate-telemetry + - time cargo build --target=wasm32-unknown-unknown -p sp-io + - time cargo build --target=wasm32-unknown-unknown -p sp-runtime + - time cargo build --target=wasm32-unknown-unknown -p sp-std + - time cargo build --target=wasm32-unknown-unknown -p sc-client + - time cargo build --target=wasm32-unknown-unknown -p sc-consensus-aura + - time cargo build --target=wasm32-unknown-unknown -p sc-consensus-babe + - time cargo build --target=wasm32-unknown-unknown -p sp-consensus + - time cargo build --target=wasm32-unknown-unknown -p sc-telemetry # Note: the command below is a bit weird because several Cargo issues prevent us from compiling the node in a more straight-forward way. - time cargo build --manifest-path=bin/node/cli/Cargo.toml --no-default-features --features "browser" --target=wasm32-unknown-unknown - sccache -s @@ -369,7 +369,7 @@ check_polkadot: - git grep -l "polkadot-master" | grep toml | xargs sed -i "s/branch.*=.*\"polkadot-master\"/rev = \"$COMMIT_HASH\"/; s~https://github.com/paritytech/substrate~file://$SUBSTRATE_PATH~; s/,\s*}/ }/" # Make sure 'Cargo.lock' matches 'Cargo.toml'. It's enough to update one # package, others are updated along the way. - - cargo update -p sr-io + - cargo update -p sp-io # Check whether Polkadot 'master' branch builds with this Substrate commit. - time cargo check - cd - diff --git a/.maintain/rename-crates-for-2.0.sh b/.maintain/rename-crates-for-2.0.sh new file mode 100644 index 0000000000..89bd2f9b33 --- /dev/null +++ b/.maintain/rename-crates-for-2.0.sh @@ -0,0 +1,112 @@ +#!/bin/bash + +function rust_rename() { + sed -i "s/$1/$2/g" `grep -Rl --include="*.rs" --include="*.stderr" "$1" *` > /dev/null +} + +function cargo_rename() { + find . -name "Cargo.toml" -exec sed -i "s/\(^\|[^\/]\)$1/\1$2/g" {} \; +} + +function rename_gitlabci() { + sed -i "s/$1/$2/g" .gitlab-ci.yml +} + +function rename() { + old=$(echo $1 | cut -f1 -d\ ); + new=$(echo $1 | cut -f2 -d\ ); + + echo "Renaming $old to $new" + # rename in Cargo.tomls + cargo_rename $old $new + rename_gitlabci $old $new + # and it appears, we have the same syntax in rust files + rust_rename $old $new + + # but generally we have the snail case syntax in rust files + old=$(echo $old | sed s/-/_/g ); + new=$(echo $new | sed s/-/_/g ); + + echo " > $old to $new" + rust_rename $old $new +} + +TO_RENAME=( + # OLD-CRATE-NAME NEW-CRATE-NAME + + # PRIMITIVES + "substrate-application-crypto sc-application-crypto" + "substrate-authority-discovery-primitives sp-authority-discovery" + "substrate-block-builder-runtime-api sp-block-builder" + "substrate-consensus-aura-primitives sp-consensus-aura" + "substrate-consensus-babe-primitives sp-consensus-babe" + "substrate-consensus-common sp-consensus" + "substrate-consensus-pow-primitives sp-consensus-pow" + "substrate-primitives sp-core" + "substrate-debug-derive sp-debug-derive" + "substrate-primitives-storage sp-storage" + "substrate-externalities sp-externalities" + "substrate-finality-grandpa-primitives sp-finality-granpda" + "substrate-inherents sp-inherents" + "substrate-keyring sp-keyring" + "substrate-offchain-primitives sp-offchain" + "substrate-panic-handler sp-panic-handler" + "substrate-phragmen sp-phragmen" + "substrate-rpc-primitives sp-rpc" + "substrate-runtime-interface sp-runtime-interface" + "substrate-runtime-interface-proc-macro sp-runtime-interface-proc-macro" + "substrate-runtime-interface-test-wasm sp-runtime-interface-test-wasm" + "substrate-serializer sp-serializer" + "substrate-session sp-sesssion" + "sr-api sp-api" + "sr-api-proc-macro sp-api-proc-macro" + "sr-api-test sp-api-test" + "sr-arithmetic sp-arithmetic" + "sr-arithmetic-fuzzer sp-arithmetic-fuzzer" + "sr-io sp-io" + "sr-primitives sp-runtime" + "sr-sandbox sp-sandbox" + "sr-staking-primitives sp-staking" + "sr-std sp-std" + "sr-version sp-version" + "substrate-state-machine sp-state-machine" + "substrate-transaction-pool-runtime-api sp-transaction-pool" + "substrate-trie sp-trie" + "substrate-wasm-interface sp-wasm-interface" + + # # CLIENT + "substrate-client sc-client" + "substrate-client-api sc-api" + "substrate-authority-discovery sc-authority-discovery" + "substrate-basic-authorship sc-basic-authority" + "substrate-block-builder sc-block-builder" + "substrate-chain-spec sc-chain-spec" + "substrate-chain-spec-derive sc-chain-spec-derive" + "substrate-cli sc-cli" + "substrate-consensus-aura sc-consensus-aura" + "substrate-consensus-babe sc-consensus-babe" + "substrate-consensus-pow sc-consensus-pow" + "substrate-consensus-slots sc-consensus-slots" + "substrate-consensus-uncles sc-consensus-uncles" + "substrate-client-db sc-database" + "substrate-executor sc-executor" + "substrate-runtime-test sc-runtime-test" + "substrate-finality-grandpa sc-finality-grandpa" + "substrate-keystore sc-keystore" + "substrate-network sc-network" + "substrate-offchain sc-offchain" + "substrate-peerset sc-peerset" + "substrate-rpc-servers sc-rpc-server" + "substrate-rpc sc-rpc" + "substrate-service sc-service" + "substrate-service-test sc-service-test" + "substrate-state-db sc-state-db" + "substrate-telemetry sc-telemetry" + "substrate-tracing sc-tracing" + +); + +for rule in "${TO_RENAME[@]}" +do + rename "$rule"; +done \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 2a5b8cde28..40f091db0f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -476,9 +476,9 @@ dependencies = [ "ansi_term 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", "node-cli 2.0.0", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-keystore 2.0.0", + "sp-core 2.0.0", "structopt 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "substrate-keystore 2.0.0", - "substrate-primitives 2.0.0", ] [[package]] @@ -1246,10 +1246,10 @@ dependencies = [ "pallet-transaction-payment 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "sr-std 2.0.0", - "substrate-primitives 2.0.0", + "sp-core 2.0.0", + "sp-io 2.0.0", + "sp-runtime 2.0.0", + "sp-std 2.0.0", ] [[package]] @@ -1258,8 +1258,8 @@ version = "2.0.0" dependencies = [ "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-std 2.0.0", - "substrate-primitives 2.0.0", + "sp-core 2.0.0", + "sp-std 2.0.0", ] [[package]] @@ -1277,13 +1277,13 @@ dependencies = [ "paste 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-arithmetic 2.0.0", - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "sr-std 2.0.0", - "substrate-inherents 2.0.0", - "substrate-primitives 2.0.0", - "substrate-state-machine 2.0.0", + "sp-arithmetic 2.0.0", + "sp-core 2.0.0", + "sp-inherents 2.0.0", + "sp-io 2.0.0", + "sp-runtime 2.0.0", + "sp-state-machine 2.0.0", + "sp-std 2.0.0", "tracing 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1325,11 +1325,11 @@ dependencies = [ "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "substrate-inherents 2.0.0", - "substrate-primitives 2.0.0", - "substrate-state-machine 2.0.0", + "sp-core 2.0.0", + "sp-inherents 2.0.0", + "sp-io 2.0.0", + "sp-runtime 2.0.0", + "sp-state-machine 2.0.0", "trybuild 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1343,11 +1343,11 @@ dependencies = [ "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "sr-std 2.0.0", - "sr-version 2.0.0", - "substrate-primitives 2.0.0", + "sp-core 2.0.0", + "sp-io 2.0.0", + "sp-runtime 2.0.0", + "sp-std 2.0.0", + "sp-version 2.0.0", ] [[package]] @@ -1355,7 +1355,7 @@ name = "frame-system-rpc-runtime-api" version = "2.0.0" dependencies = [ "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-api 2.0.0", + "sp-api 2.0.0", ] [[package]] @@ -1367,10 +1367,10 @@ dependencies = [ "pallet-balances 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "sr-std 2.0.0", - "substrate-primitives 2.0.0", + "sp-core 2.0.0", + "sp-io 2.0.0", + "sp-runtime 2.0.0", + "sp-std 2.0.0", ] [[package]] @@ -2990,38 +2990,38 @@ dependencies = [ "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "sc-transaction-pool 2.0.0", + "sc-authority-discovery 2.0.0", + "sc-basic-authority 2.0.0", + "sc-chain-spec 2.0.0", + "sc-cli 2.0.0", + "sc-client 2.0.0", + "sc-client-api 2.0.0", + "sc-client-db 2.0.0", + "sc-consensus-babe 2.0.0", + "sc-finality-grandpa 2.0.0", + "sc-keystore 2.0.0", + "sc-network 2.0.0", + "sc-offchain 2.0.0", + "sc-rpc 2.0.0", + "sc-service 2.0.0", + "sc-service-test 2.0.0", + "sc-telemetry 2.0.0", + "sc-tracing-pool 2.0.0", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-authority-discovery 2.0.0", + "sp-consensus 2.0.0", + "sp-consensus-babe 2.0.0", + "sp-core 2.0.0", + "sp-finality-granpda 2.0.0", "sp-finality-tracker 2.0.0", + "sp-inherents 2.0.0", + "sp-io 2.0.0", + "sp-keyring 2.0.0", + "sp-runtime 2.0.0", "sp-timestamp 2.0.0", "sp-transaction-pool-api 2.0.0", - "sr-io 2.0.0", - "sr-primitives 2.0.0", "structopt 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "substrate-authority-discovery 2.0.0", - "substrate-authority-discovery-primitives 2.0.0", - "substrate-basic-authorship 2.0.0", "substrate-build-script-utils 2.0.0", - "substrate-chain-spec 2.0.0", - "substrate-cli 2.0.0", - "substrate-client 2.0.0", - "substrate-client-api 2.0.0", - "substrate-client-db 2.0.0", - "substrate-consensus-babe 2.0.0", - "substrate-consensus-babe-primitives 2.0.0", - "substrate-consensus-common 2.0.0", - "substrate-finality-grandpa 2.0.0", - "substrate-finality-grandpa-primitives 2.0.0", - "substrate-inherents 2.0.0", - "substrate-keyring 2.0.0", - "substrate-keystore 2.0.0", - "substrate-network 2.0.0", - "substrate-offchain 2.0.0", - "substrate-primitives 2.0.0", - "substrate-rpc 2.0.0", - "substrate-service 2.0.0", - "substrate-service-test 2.0.0", - "substrate-telemetry 2.0.0", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", "transaction-factory 0.0.1", @@ -3049,13 +3049,13 @@ dependencies = [ "pallet-transaction-payment 2.0.0", "pallet-treasury 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "substrate-executor 2.0.0", - "substrate-primitives 2.0.0", - "substrate-state-machine 2.0.0", + "sc-executor 2.0.0", + "sp-core 2.0.0", + "sp-io 2.0.0", + "sp-runtime 2.0.0", + "sp-state-machine 2.0.0", + "sp-trie 2.0.0", "substrate-test-client 2.0.0", - "substrate-trie 2.0.0", "trie-root 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "wabt 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3065,9 +3065,9 @@ name = "node-primitives" version = "2.0.0" dependencies = [ "pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-primitives 2.0.0", - "substrate-primitives 2.0.0", - "substrate-serializer 2.0.0", + "sp-core 2.0.0", + "sp-runtime 2.0.0", + "sp-serializer 2.0.0", ] [[package]] @@ -3079,9 +3079,9 @@ dependencies = [ "node-runtime 2.0.0", "pallet-contracts-rpc 2.0.0", "pallet-transaction-payment-rpc 2.0.0", + "sc-client 2.0.0", + "sp-runtime 2.0.0", "sp-transaction-pool-api 2.0.0", - "sr-primitives 2.0.0", - "substrate-client 2.0.0", "substrate-frame-rpc-system 2.0.0", ] @@ -3095,7 +3095,7 @@ dependencies = [ "jsonrpc-core-client 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "node-primitives 2.0.0", - "substrate-rpc 2.0.0", + "sc-rpc 2.0.0", ] [[package]] @@ -3138,21 +3138,21 @@ dependencies = [ "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-api 2.0.0", + "sp-authority-discovery 2.0.0", + "sp-block-builder 2.0.0", + "sp-consensus-babe 2.0.0", + "sp-core 2.0.0", + "sp-inherents 2.0.0", + "sp-io 2.0.0", + "sp-keyring 2.0.0", + "sp-offchain 2.0.0", + "sp-runtime 2.0.0", + "sp-sesssion 2.0.0", + "sp-staking 2.0.0", + "sp-std 2.0.0", "sp-transaction-pool-runtime-api 2.0.0", - "sr-api 2.0.0", - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "sr-staking-primitives 2.0.0", - "sr-std 2.0.0", - "sr-version 2.0.0", - "substrate-authority-discovery-primitives 2.0.0", - "substrate-block-builder-runtime-api 2.0.0", - "substrate-consensus-babe-primitives 2.0.0", - "substrate-inherents 2.0.0", - "substrate-keyring 2.0.0", - "substrate-offchain-primitives 2.0.0", - "substrate-primitives 2.0.0", - "substrate-session 2.0.0", + "sp-version 2.0.0", "substrate-wasm-builder-runner 1.0.4", ] @@ -3167,24 +3167,24 @@ dependencies = [ "node-template-runtime 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sc-transaction-pool 2.0.0", + "sc-basic-authority 2.0.0", + "sc-cli 2.0.0", + "sc-client 2.0.0", + "sc-consensus-aura 2.0.0", + "sc-executor 2.0.0", + "sc-finality-grandpa 2.0.0", + "sc-network 2.0.0", + "sc-service 2.0.0", + "sc-tracing-pool 2.0.0", + "sp-consensus 2.0.0", + "sp-consensus-aura 2.0.0", + "sp-core 2.0.0", + "sp-finality-granpda 2.0.0", + "sp-inherents 2.0.0", + "sp-io 2.0.0", + "sp-runtime 2.0.0", "sp-transaction-pool-api 2.0.0", - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "substrate-basic-authorship 2.0.0", "substrate-build-script-utils 2.0.0", - "substrate-cli 2.0.0", - "substrate-client 2.0.0", - "substrate-consensus-aura 2.0.0", - "substrate-consensus-aura-primitives 2.0.0", - "substrate-consensus-common 2.0.0", - "substrate-executor 2.0.0", - "substrate-finality-grandpa 2.0.0", - "substrate-finality-grandpa-primitives 2.0.0", - "substrate-inherents 2.0.0", - "substrate-network 2.0.0", - "substrate-primitives 2.0.0", - "substrate-service 2.0.0", "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", "trie-root 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "vergen 3.0.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3208,18 +3208,18 @@ dependencies = [ "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-api 2.0.0", + "sp-block-builder 2.0.0", + "sp-consensus-aura 2.0.0", + "sp-core 2.0.0", + "sp-inherents 2.0.0", + "sp-io 2.0.0", + "sp-offchain 2.0.0", + "sp-runtime 2.0.0", + "sp-sesssion 2.0.0", + "sp-std 2.0.0", "sp-transaction-pool-runtime-api 2.0.0", - "sr-api 2.0.0", - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "sr-std 2.0.0", - "sr-version 2.0.0", - "substrate-block-builder-runtime-api 2.0.0", - "substrate-consensus-aura-primitives 2.0.0", - "substrate-inherents 2.0.0", - "substrate-offchain-primitives 2.0.0", - "substrate-primitives 2.0.0", - "substrate-session 2.0.0", + "sp-version 2.0.0", "substrate-wasm-builder-runner 1.0.4", ] @@ -3242,12 +3242,12 @@ dependencies = [ "pallet-transaction-payment 2.0.0", "pallet-treasury 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "substrate-client 2.0.0", - "substrate-executor 2.0.0", - "substrate-keyring 2.0.0", - "substrate-primitives 2.0.0", + "sc-client 2.0.0", + "sc-executor 2.0.0", + "sp-core 2.0.0", + "sp-io 2.0.0", + "sp-keyring 2.0.0", + "sp-runtime 2.0.0", "substrate-test-client 2.0.0", "wabt 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3404,10 +3404,10 @@ dependencies = [ "frame-system 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "sr-std 2.0.0", - "substrate-primitives 2.0.0", + "sp-core 2.0.0", + "sp-io 2.0.0", + "sp-runtime 2.0.0", + "sp-std 2.0.0", ] [[package]] @@ -3421,15 +3421,15 @@ dependencies = [ "pallet-timestamp 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-application-crypto 2.0.0", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-consensus-aura 2.0.0", + "sp-core 2.0.0", + "sp-inherents 2.0.0", + "sp-io 2.0.0", + "sp-runtime 2.0.0", + "sp-std 2.0.0", "sp-timestamp 2.0.0", - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "sr-std 2.0.0", - "substrate-application-crypto 2.0.0", - "substrate-consensus-aura-primitives 2.0.0", - "substrate-inherents 2.0.0", - "substrate-primitives 2.0.0", ] [[package]] @@ -3440,14 +3440,14 @@ dependencies = [ "frame-system 2.0.0", "pallet-session 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-application-crypto 2.0.0", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "sr-staking-primitives 2.0.0", - "sr-std 2.0.0", - "substrate-application-crypto 2.0.0", - "substrate-authority-discovery-primitives 2.0.0", - "substrate-primitives 2.0.0", + "sp-authority-discovery 2.0.0", + "sp-core 2.0.0", + "sp-io 2.0.0", + "sp-runtime 2.0.0", + "sp-staking 2.0.0", + "sp-std 2.0.0", ] [[package]] @@ -3459,11 +3459,11 @@ dependencies = [ "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "sp-authorship 2.0.0", - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "sr-std 2.0.0", - "substrate-inherents 2.0.0", - "substrate-primitives 2.0.0", + "sp-core 2.0.0", + "sp-inherents 2.0.0", + "sp-io 2.0.0", + "sp-runtime 2.0.0", + "sp-std 2.0.0", ] [[package]] @@ -3479,15 +3479,15 @@ dependencies = [ "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-consensus-babe 2.0.0", + "sp-core 2.0.0", + "sp-inherents 2.0.0", + "sp-io 2.0.0", + "sp-runtime 2.0.0", + "sp-staking 2.0.0", + "sp-std 2.0.0", "sp-timestamp 2.0.0", - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "sr-staking-primitives 2.0.0", - "sr-std 2.0.0", - "sr-version 2.0.0", - "substrate-consensus-babe-primitives 2.0.0", - "substrate-inherents 2.0.0", - "substrate-primitives 2.0.0", + "sp-version 2.0.0", "substrate-test-runtime 2.0.0", ] @@ -3501,10 +3501,10 @@ dependencies = [ "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "sr-std 2.0.0", - "substrate-primitives 2.0.0", + "sp-core 2.0.0", + "sp-io 2.0.0", + "sp-runtime 2.0.0", + "sp-std 2.0.0", ] [[package]] @@ -3518,10 +3518,10 @@ dependencies = [ "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "sr-std 2.0.0", - "substrate-primitives 2.0.0", + "sp-core 2.0.0", + "sp-io 2.0.0", + "sp-runtime 2.0.0", + "sp-std 2.0.0", ] [[package]] @@ -3539,11 +3539,11 @@ dependencies = [ "parity-wasm 0.41.0 (registry+https://github.com/rust-lang/crates.io-index)", "pwasm-utils 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "sr-sandbox 2.0.0", - "sr-std 2.0.0", - "substrate-primitives 2.0.0", + "sp-core 2.0.0", + "sp-io 2.0.0", + "sp-runtime 2.0.0", + "sp-sandbox 2.0.0", + "sp-std 2.0.0", "wabt 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", "wasmi-validation 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3559,9 +3559,9 @@ dependencies = [ "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-blockchain 2.0.0", - "sr-primitives 2.0.0", - "substrate-primitives 2.0.0", - "substrate-rpc-primitives 2.0.0", + "sp-core 2.0.0", + "sp-rpc 2.0.0", + "sp-runtime 2.0.0", ] [[package]] @@ -3570,9 +3570,9 @@ version = "2.0.0" dependencies = [ "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-api 2.0.0", - "sr-primitives 2.0.0", - "sr-std 2.0.0", + "sp-api 2.0.0", + "sp-runtime 2.0.0", + "sp-std 2.0.0", ] [[package]] @@ -3585,10 +3585,10 @@ dependencies = [ "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "sr-std 2.0.0", - "substrate-primitives 2.0.0", + "sp-core 2.0.0", + "sp-io 2.0.0", + "sp-runtime 2.0.0", + "sp-std 2.0.0", ] [[package]] @@ -3602,10 +3602,10 @@ dependencies = [ "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "sr-std 2.0.0", - "substrate-primitives 2.0.0", + "sp-core 2.0.0", + "sp-io 2.0.0", + "sp-runtime 2.0.0", + "sp-std 2.0.0", ] [[package]] @@ -3618,11 +3618,11 @@ dependencies = [ "pallet-balances 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "sr-std 2.0.0", - "substrate-phragmen 2.0.0", - "substrate-primitives 2.0.0", + "sp-core 2.0.0", + "sp-io 2.0.0", + "sp-phragmen 2.0.0", + "sp-runtime 2.0.0", + "sp-std 2.0.0", "substrate-test-utils 2.0.0", ] @@ -3640,10 +3640,10 @@ dependencies = [ "rlp 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sha3 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "sr-std 2.0.0", - "substrate-primitives 2.0.0", + "sp-core 2.0.0", + "sp-io 2.0.0", + "sp-runtime 2.0.0", + "sp-std 2.0.0", ] [[package]] @@ -3655,10 +3655,10 @@ dependencies = [ "pallet-balances 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "sr-std 2.0.0", - "substrate-primitives 2.0.0", + "sp-core 2.0.0", + "sp-io 2.0.0", + "sp-runtime 2.0.0", + "sp-std 2.0.0", ] [[package]] @@ -3670,12 +3670,12 @@ dependencies = [ "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-core 2.0.0", "sp-finality-tracker 2.0.0", - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "sr-std 2.0.0", - "substrate-inherents 2.0.0", - "substrate-primitives 2.0.0", + "sp-inherents 2.0.0", + "sp-io 2.0.0", + "sp-runtime 2.0.0", + "sp-std 2.0.0", ] [[package]] @@ -3686,10 +3686,10 @@ dependencies = [ "frame-system 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "sr-std 2.0.0", - "substrate-primitives 2.0.0", + "sp-core 2.0.0", + "sp-io 2.0.0", + "sp-runtime 2.0.0", + "sp-std 2.0.0", ] [[package]] @@ -3702,12 +3702,12 @@ dependencies = [ "pallet-session 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "sr-staking-primitives 2.0.0", - "sr-std 2.0.0", - "substrate-finality-grandpa-primitives 2.0.0", - "substrate-primitives 2.0.0", + "sp-core 2.0.0", + "sp-finality-granpda 2.0.0", + "sp-io 2.0.0", + "sp-runtime 2.0.0", + "sp-staking 2.0.0", + "sp-std 2.0.0", ] [[package]] @@ -3719,13 +3719,13 @@ dependencies = [ "pallet-authorship 0.1.0", "pallet-session 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-application-crypto 2.0.0", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "sr-staking-primitives 2.0.0", - "sr-std 2.0.0", - "substrate-application-crypto 2.0.0", - "substrate-primitives 2.0.0", + "sp-core 2.0.0", + "sp-io 2.0.0", + "sp-runtime 2.0.0", + "sp-staking 2.0.0", + "sp-std 2.0.0", ] [[package]] @@ -3738,11 +3738,11 @@ dependencies = [ "ref_thread_local 0.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "sr-std 2.0.0", - "substrate-keyring 2.0.0", - "substrate-primitives 2.0.0", + "sp-core 2.0.0", + "sp-io 2.0.0", + "sp-keyring 2.0.0", + "sp-runtime 2.0.0", + "sp-std 2.0.0", ] [[package]] @@ -3753,10 +3753,10 @@ dependencies = [ "frame-system 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "sr-std 2.0.0", - "substrate-primitives 2.0.0", + "sp-core 2.0.0", + "sp-io 2.0.0", + "sp-runtime 2.0.0", + "sp-std 2.0.0", ] [[package]] @@ -3768,10 +3768,10 @@ dependencies = [ "pallet-balances 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "sr-std 2.0.0", - "substrate-primitives 2.0.0", + "sp-core 2.0.0", + "sp-io 2.0.0", + "sp-runtime 2.0.0", + "sp-std 2.0.0", ] [[package]] @@ -3783,11 +3783,11 @@ dependencies = [ "pallet-balances 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "sr-staking-primitives 2.0.0", - "sr-std 2.0.0", - "substrate-primitives 2.0.0", + "sp-core 2.0.0", + "sp-io 2.0.0", + "sp-runtime 2.0.0", + "sp-staking 2.0.0", + "sp-std 2.0.0", ] [[package]] @@ -3798,10 +3798,10 @@ dependencies = [ "frame-system 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "sr-std 2.0.0", - "substrate-primitives 2.0.0", + "sp-core 2.0.0", + "sp-io 2.0.0", + "sp-runtime 2.0.0", + "sp-std 2.0.0", ] [[package]] @@ -3813,10 +3813,10 @@ dependencies = [ "pallet-balances 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "sr-std 2.0.0", - "substrate-primitives 2.0.0", + "sp-core 2.0.0", + "sp-io 2.0.0", + "sp-runtime 2.0.0", + "sp-std 2.0.0", ] [[package]] @@ -3830,14 +3830,14 @@ dependencies = [ "pallet-timestamp 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-application-crypto 2.0.0", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "sr-staking-primitives 2.0.0", - "sr-std 2.0.0", - "substrate-application-crypto 2.0.0", - "substrate-primitives 2.0.0", - "substrate-trie 2.0.0", + "sp-core 2.0.0", + "sp-io 2.0.0", + "sp-runtime 2.0.0", + "sp-staking 2.0.0", + "sp-std 2.0.0", + "sp-trie 2.0.0", ] [[package]] @@ -3854,13 +3854,13 @@ dependencies = [ "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "sr-staking-primitives 2.0.0", - "sr-std 2.0.0", - "substrate-keyring 2.0.0", - "substrate-phragmen 2.0.0", - "substrate-primitives 2.0.0", + "sp-core 2.0.0", + "sp-io 2.0.0", + "sp-keyring 2.0.0", + "sp-phragmen 2.0.0", + "sp-runtime 2.0.0", + "sp-staking 2.0.0", + "sp-std 2.0.0", "substrate-test-utils 2.0.0", ] @@ -3871,7 +3871,7 @@ dependencies = [ "proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-primitives 2.0.0", + "sp-runtime 2.0.0", "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3883,10 +3883,10 @@ dependencies = [ "frame-system 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "sr-std 2.0.0", - "substrate-primitives 2.0.0", + "sp-core 2.0.0", + "sp-io 2.0.0", + "sp-runtime 2.0.0", + "sp-std 2.0.0", ] [[package]] @@ -3898,12 +3898,12 @@ dependencies = [ "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-core 2.0.0", + "sp-inherents 2.0.0", + "sp-io 2.0.0", + "sp-runtime 2.0.0", + "sp-std 2.0.0", "sp-timestamp 2.0.0", - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "sr-std 2.0.0", - "substrate-inherents 2.0.0", - "substrate-primitives 2.0.0", ] [[package]] @@ -3915,10 +3915,10 @@ dependencies = [ "pallet-balances 2.0.0", "pallet-transaction-payment-rpc-runtime-api 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "sr-std 2.0.0", - "substrate-primitives 2.0.0", + "sp-core 2.0.0", + "sp-io 2.0.0", + "sp-runtime 2.0.0", + "sp-std 2.0.0", ] [[package]] @@ -3932,9 +3932,9 @@ dependencies = [ "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-blockchain 2.0.0", - "sr-primitives 2.0.0", - "substrate-primitives 2.0.0", - "substrate-rpc-primitives 2.0.0", + "sp-core 2.0.0", + "sp-rpc 2.0.0", + "sp-runtime 2.0.0", ] [[package]] @@ -3945,9 +3945,9 @@ dependencies = [ "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-api 2.0.0", - "sr-primitives 2.0.0", - "sr-std 2.0.0", + "sp-api 2.0.0", + "sp-runtime 2.0.0", + "sp-std 2.0.0", ] [[package]] @@ -3959,10 +3959,10 @@ dependencies = [ "pallet-balances 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "sr-std 2.0.0", - "substrate-primitives 2.0.0", + "sp-core 2.0.0", + "sp-io 2.0.0", + "sp-runtime 2.0.0", + "sp-std 2.0.0", ] [[package]] @@ -4801,1058 +4801,1215 @@ dependencies = [ ] [[package]] -name = "sc-rpc-api" +name = "sc-application-crypto" version = "2.0.0" dependencies = [ - "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core-client 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-derive 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-pubsub 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-transaction-pool-api 2.0.0", - "sr-version 2.0.0", - "substrate-primitives 2.0.0", - "substrate-rpc-primitives 2.0.0", + "sp-core 2.0.0", + "sp-io 2.0.0", + "sp-runtime 2.0.0", + "sp-std 2.0.0", + "substrate-test-runtime-client 2.0.0", ] [[package]] -name = "sc-transaction-graph" +name = "sc-authority-discovery" version = "2.0.0" dependencies = [ - "assert_matches 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "criterion 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", - "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-timer 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-transaction-pool-api 2.0.0", - "sr-primitives 2.0.0", - "substrate-primitives 2.0.0", - "substrate-test-runtime 2.0.0", + "prost 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "prost-build 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-client-api 2.0.0", + "sc-keystore 2.0.0", + "sc-network 2.0.0", + "sc-peerset 2.0.0", + "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-api 2.0.0", + "sp-authority-discovery 2.0.0", + "sp-blockchain 2.0.0", + "sp-core 2.0.0", + "sp-runtime 2.0.0", + "substrate-test-runtime-client 2.0.0", ] [[package]] -name = "sc-transaction-pool" +name = "sc-basic-authority" version = "2.0.0" dependencies = [ - "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sc-transaction-graph 2.0.0", + "sc-block-builder 2.0.0", + "sc-client 2.0.0", + "sc-client-api 2.0.0", + "sc-telemetry 2.0.0", + "sc-tracing-pool 2.0.0", "sp-blockchain 2.0.0", + "sp-consensus 2.0.0", + "sp-core 2.0.0", + "sp-inherents 2.0.0", + "sp-runtime 2.0.0", "sp-transaction-pool-api 2.0.0", - "sp-transaction-pool-runtime-api 2.0.0", - "sr-api 2.0.0", - "sr-primitives 2.0.0", - "substrate-client-api 2.0.0", - "substrate-keyring 2.0.0", - "substrate-primitives 2.0.0", "substrate-test-runtime-client 2.0.0", + "tokio-executor 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "schannel" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "schnorrkel" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" +name = "sc-block-builder" +version = "2.0.0" dependencies = [ - "curve25519-dalek 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "merlin 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "subtle 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "zeroize 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-api 2.0.0", + "sp-block-builder 2.0.0", + "sp-blockchain 2.0.0", + "sp-core 2.0.0", + "sp-runtime 2.0.0", + "sp-state-machine 2.0.0", ] [[package]] -name = "scopeguard" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "scopeguard" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "scroll" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" +name = "sc-chain-spec" +version = "2.0.0" dependencies = [ - "scroll_derive 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-chain-spec-derive 2.0.0", + "sc-network 2.0.0", + "sc-telemetry 2.0.0", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-core 2.0.0", + "sp-runtime 2.0.0", ] [[package]] -name = "scroll_derive" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" +name = "sc-chain-spec-derive" +version = "2.0.0" dependencies = [ + "proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "sct" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" +name = "sc-cli" +version = "2.0.0" dependencies = [ - "ring 0.16.9 (registry+https://github.com/rust-lang/crates.io-index)", - "untrusted 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ansi_term 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", + "app_dirs 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", + "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "fdlimit 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures01 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "names 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rpassword 4.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-client-api 2.0.0", + "sc-network 2.0.0", + "sc-service 2.0.0", + "sc-telemetry 2.0.0", + "sc-tracing 2.0.0", + "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-blockchain 2.0.0", + "sp-core 2.0.0", + "sp-keyring 2.0.0", + "sp-panic-handler 2.0.0", + "sp-runtime 2.0.0", + "sp-state-machine 2.0.0", + "structopt 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "security-framework" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" +name = "sc-client" +version = "2.0.0" dependencies = [ - "core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", - "core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "security-framework-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", + "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "kvdb 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "kvdb-memorydb 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-block-builder 2.0.0", + "sc-client-api 2.0.0", + "sc-client-db 2.0.0", + "sc-executor 2.0.0", + "sc-telemetry 2.0.0", + "sp-api 2.0.0", + "sp-blockchain 2.0.0", + "sp-consensus 2.0.0", + "sp-core 2.0.0", + "sp-externalities 2.0.0", + "sp-inherents 2.0.0", + "sp-keyring 2.0.0", + "sp-panic-handler 2.0.0", + "sp-runtime 2.0.0", + "sp-state-machine 2.0.0", + "sp-std 2.0.0", + "sp-trie 2.0.0", + "sp-version 2.0.0", + "substrate-test-runtime-client 2.0.0", + "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tracing 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "security-framework-sys" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" +name = "sc-client-api" +version = "2.0.0" dependencies = [ - "core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", + "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "kvdb 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "kvdb-memorydb 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-block-builder 2.0.0", + "sc-client-db 2.0.0", + "sc-executor 2.0.0", + "sc-telemetry 2.0.0", + "sp-api 2.0.0", + "sp-blockchain 2.0.0", + "sp-consensus 2.0.0", + "sp-core 2.0.0", + "sp-externalities 2.0.0", + "sp-inherents 2.0.0", + "sp-keyring 2.0.0", + "sp-panic-handler 2.0.0", + "sp-runtime 2.0.0", + "sp-state-machine 2.0.0", + "sp-std 2.0.0", + "sp-transaction-pool-api 2.0.0", + "sp-trie 2.0.0", + "sp-version 2.0.0", + "substrate-test-primitives 2.0.0", + "substrate-test-runtime-client 2.0.0", + "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "semver" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" +name = "sc-client-db" +version = "2.0.0" dependencies = [ - "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", + "kvdb 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "kvdb-memorydb 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "kvdb-rocksdb 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "quickcheck 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-client 2.0.0", + "sc-client-api 2.0.0", + "sc-executor 2.0.0", + "sc-state-db 2.0.0", + "sp-blockchain 2.0.0", + "sp-consensus 2.0.0", + "sp-core 2.0.0", + "sp-keyring 2.0.0", + "sp-runtime 2.0.0", + "sp-state-machine 2.0.0", + "sp-trie 2.0.0", + "substrate-test-runtime-client 2.0.0", ] [[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" +name = "sc-consensus-aura" +version = "2.0.0" dependencies = [ - "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-timer 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-application-crypto 2.0.0", + "sc-client 2.0.0", + "sc-client-api 2.0.0", + "sc-consensus-slots 2.0.0", + "sc-executor 2.0.0", + "sc-keystore 2.0.0", + "sc-network 2.0.0", + "sc-service 2.0.0", + "sc-telemetry 2.0.0", + "sp-api 2.0.0", + "sp-block-builder 2.0.0", + "sp-blockchain 2.0.0", + "sp-consensus 2.0.0", + "sp-consensus-aura 2.0.0", + "sp-core 2.0.0", + "sp-inherents 2.0.0", + "sp-io 2.0.0", + "sp-keyring 2.0.0", + "sp-runtime 2.0.0", + "sp-timestamp 2.0.0", + "sp-version 2.0.0", + "substrate-test-runtime-client 2.0.0", + "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "send_wrapper" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "serde" -version = "1.0.103" -source = "registry+https://github.com/rust-lang/crates.io-index" +name = "sc-consensus-babe" +version = "2.0.0" dependencies = [ - "serde_derive 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "fork-tree 2.0.0", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-timer 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "merlin 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "num-bigint 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "num-rational 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "pdqselect 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-application-crypto 2.0.0", + "sc-block-builder 2.0.0", + "sc-client 2.0.0", + "sc-client-api 2.0.0", + "sc-consensus-slots 2.0.0", + "sc-consensus-uncles 2.0.0", + "sc-executor 2.0.0", + "sc-keystore 2.0.0", + "sc-network 2.0.0", + "sc-service 2.0.0", + "sc-telemetry 2.0.0", + "schnorrkel 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-api 2.0.0", + "sp-block-builder 2.0.0", + "sp-blockchain 2.0.0", + "sp-consensus 2.0.0", + "sp-consensus-babe 2.0.0", + "sp-core 2.0.0", + "sp-inherents 2.0.0", + "sp-io 2.0.0", + "sp-keyring 2.0.0", + "sp-runtime 2.0.0", + "sp-timestamp 2.0.0", + "sp-version 2.0.0", + "substrate-test-runtime-client 2.0.0", + "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "serde_derive" -version = "1.0.103" -source = "registry+https://github.com/rust-lang/crates.io-index" +name = "sc-consensus-pow" +version = "2.0.0" dependencies = [ - "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-client-api 2.0.0", + "sp-block-builder 2.0.0", + "sp-blockchain 2.0.0", + "sp-consensus 2.0.0", + "sp-consensus-pow 2.0.0", + "sp-core 2.0.0", + "sp-inherents 2.0.0", + "sp-runtime 2.0.0", + "sp-timestamp 2.0.0", ] [[package]] -name = "serde_json" -version = "1.0.42" -source = "registry+https://github.com/rust-lang/crates.io-index" +name = "sc-consensus-slots" +version = "2.0.0" dependencies = [ - "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "ryu 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-timer 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-client-api 2.0.0", + "sc-telemetry 2.0.0", + "sp-blockchain 2.0.0", + "sp-consensus 2.0.0", + "sp-core 2.0.0", + "sp-inherents 2.0.0", + "sp-runtime 2.0.0", + "substrate-test-runtime-client 2.0.0", ] [[package]] -name = "sha-1" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" +name = "sc-consensus-uncles" +version = "2.0.0" dependencies = [ - "block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", - "digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-client-api 2.0.0", + "sp-authorship 2.0.0", + "sp-consensus 2.0.0", + "sp-core 2.0.0", + "sp-inherents 2.0.0", + "sp-runtime 2.0.0", ] [[package]] -name = "sha1" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "sha2" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" +name = "sc-executor" +version = "2.0.0" dependencies = [ - "block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", - "digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "assert_matches 1.3.0 (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-frontend 0.50.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cranelift-native 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)", + "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", + "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libsecp256k1 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-wasm 0.41.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-client-api 2.0.0", + "sc-offchain 2.0.0", + "sc-runtime-test 2.0.0", + "sp-core 2.0.0", + "sp-externalities 2.0.0", + "sp-io 2.0.0", + "sp-panic-handler 2.0.0", + "sp-runtime-interface 2.0.0", + "sp-serializer 2.0.0", + "sp-state-machine 2.0.0", + "sp-trie 2.0.0", + "sp-version 2.0.0", + "sp-wasm-interface 2.0.0", + "substrate-test-runtime 2.0.0", + "test-case 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "wabt 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmi 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmtime-environ 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmtime-jit 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmtime-runtime 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "sha3" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" +name = "sc-finality-grandpa" +version = "2.0.0" dependencies = [ - "block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", - "byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "keccak 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "finality-grandpa 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "fork-tree 2.0.0", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-client 2.0.0", + "sc-client-api 2.0.0", + "sc-keystore 2.0.0", + "sc-network 2.0.0", + "sc-telemetry 2.0.0", + "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-api 2.0.0", + "sp-blockchain 2.0.0", + "sp-consensus 2.0.0", + "sp-consensus-babe 2.0.0", + "sp-core 2.0.0", + "sp-finality-granpda 2.0.0", + "sp-finality-tracker 2.0.0", + "sp-inherents 2.0.0", + "sp-keyring 2.0.0", + "sp-runtime 2.0.0", + "sp-state-machine 2.0.0", + "substrate-test-runtime-client 2.0.0", + "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "shell32-sys" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" +name = "sc-keystore" +version = "2.0.0" dependencies = [ - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", + "hex 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-application-crypto 2.0.0", + "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-core 2.0.0", + "subtle 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "shlex" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "slab" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "slog" -version = "2.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" +name = "sc-network" +version = "2.0.0" dependencies = [ + "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", + "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "erased-serde 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "fork-tree 2.0.0", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-timer 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", + "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "linked_hash_set 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "lru 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "quickcheck 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-block-builder 2.0.0", + "sc-client 2.0.0", + "sc-client-api 2.0.0", + "sc-peerset 2.0.0", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", + "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "slog_derive 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-arithmetic 2.0.0", + "sp-blockchain 2.0.0", + "sp-consensus 2.0.0", + "sp-consensus-babe 2.0.0", + "sp-core 2.0.0", + "sp-keyring 2.0.0", + "sp-runtime 2.0.0", + "substrate-test-client 2.0.0", + "substrate-test-runtime 2.0.0", + "substrate-test-runtime-client 2.0.0", + "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "unsigned-varint 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "zeroize 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "slog-async" -version = "2.3.0" -source = "git+https://github.com/paritytech/slog-async#107848e7ded5e80dc43f6296c2b96039eb92c0a5" +name = "sc-offchain" +version = "2.0.0" dependencies = [ - "crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "take_mut 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-timer 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "hyper 0.12.35 (registry+https://github.com/rust-lang/crates.io-index)", + "hyper-rustls 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-client-api 2.0.0", + "sc-client-db 2.0.0", + "sc-keystore 2.0.0", + "sc-network 2.0.0", + "sc-tracing-pool 2.0.0", + "sp-api 2.0.0", + "sp-core 2.0.0", + "sp-offchain 2.0.0", + "sp-runtime 2.0.0", + "sp-transaction-pool-api 2.0.0", + "substrate-test-runtime-client 2.0.0", + "threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "slog-json" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" +name = "sc-peerset" +version = "2.0.0" dependencies = [ - "chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", - "erased-serde 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", - "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "slog-scope" -version = "4.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" +name = "sc-rpc" +version = "2.0.0" dependencies = [ - "arc-swap 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "assert_matches 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-pubsub 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-client 2.0.0", + "sc-client-api 2.0.0", + "sc-executor 2.0.0", + "sc-keystore 2.0.0", + "sc-network 2.0.0", + "sc-rpc-api 2.0.0", + "sc-tracing-pool 2.0.0", + "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-api 2.0.0", + "sp-blockchain 2.0.0", + "sp-core 2.0.0", + "sp-io 2.0.0", + "sp-rpc 2.0.0", + "sp-runtime 2.0.0", + "sp-sesssion 2.0.0", + "sp-state-machine 2.0.0", + "sp-transaction-pool-api 2.0.0", + "sp-version 2.0.0", + "substrate-test-runtime-client 2.0.0", + "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "slog_derive" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" +name = "sc-rpc-api" +version = "2.0.0" dependencies = [ - "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core-client 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-derive 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-pubsub 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-core 2.0.0", + "sp-rpc 2.0.0", + "sp-transaction-pool-api 2.0.0", + "sp-version 2.0.0", ] [[package]] -name = "smallvec" -version = "0.6.13" -source = "registry+https://github.com/rust-lang/crates.io-index" +name = "sc-rpc-server" +version = "2.0.0" dependencies = [ - "maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-http-server 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-pubsub 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-ws-server 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-runtime 2.0.0", ] [[package]] -name = "smallvec" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "snow" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" +name = "sc-runtime-test" +version = "2.0.0" dependencies = [ - "arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "ring 0.16.9 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "subtle 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-core 2.0.0", + "sp-io 2.0.0", + "sp-runtime 2.0.0", + "sp-sandbox 2.0.0", + "sp-std 2.0.0", + "substrate-wasm-builder-runner 1.0.4", ] [[package]] -name = "soketto" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" +name = "sc-service" +version = "2.0.0" dependencies = [ - "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "flate2 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", + "exit-future 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", - "httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "grafana-data-source 2.0.0", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-application-crypto 2.0.0", + "sc-chain-spec 2.0.0", + "sc-client 2.0.0", + "sc-client-api 2.0.0", + "sc-client-db 2.0.0", + "sc-executor 2.0.0", + "sc-finality-grandpa 2.0.0", + "sc-keystore 2.0.0", + "sc-network 2.0.0", + "sc-offchain 2.0.0", + "sc-rpc 2.0.0", + "sc-rpc-server 2.0.0", + "sc-telemetry 2.0.0", + "sc-tracing 2.0.0", + "sc-tracing-pool 2.0.0", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", + "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-api 2.0.0", + "sp-blockchain 2.0.0", + "sp-consensus 2.0.0", + "sp-consensus-babe 2.0.0", + "sp-core 2.0.0", + "sp-finality-granpda 2.0.0", + "sp-io 2.0.0", + "sp-runtime 2.0.0", + "sp-sesssion 2.0.0", + "sp-transaction-pool-api 2.0.0", + "sp-transaction-pool-runtime-api 2.0.0", + "substrate-test-runtime-client 2.0.0", + "sysinfo 0.9.6 (registry+https://github.com/rust-lang/crates.io-index)", + "target_info 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "tracing 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "sourcefile" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "sp-authorship" +name = "sc-service-test" version = "2.0.0" dependencies = [ - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-std 2.0.0", - "substrate-inherents 2.0.0", + "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "fdlimit 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-client 2.0.0", + "sc-network 2.0.0", + "sc-service 2.0.0", + "sp-consensus 2.0.0", + "sp-core 2.0.0", + "sp-runtime 2.0.0", + "sp-transaction-pool-api 2.0.0", + "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "sp-blockchain" +name = "sc-state-db" version = "2.0.0" dependencies = [ - "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "lru 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-primitives 2.0.0", - "substrate-block-builder-runtime-api 2.0.0", - "substrate-consensus-common 2.0.0", - "substrate-state-machine 2.0.0", + "sp-core 2.0.0", ] [[package]] -name = "sp-finality-tracker" +name = "sc-telemetry" version = "2.0.0" dependencies = [ - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-std 2.0.0", - "substrate-inherents 2.0.0", + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-timer 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "slog-async 2.3.0 (git+https://github.com/paritytech/slog-async)", + "slog-json 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "slog-scope 4.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "sp-timestamp" +name = "sc-tracing" version = "2.0.0" dependencies = [ - "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-api 2.0.0", - "sr-primitives 2.0.0", - "sr-std 2.0.0", - "substrate-inherents 2.0.0", + "erased-serde 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "grafana-data-source 2.0.0", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-telemetry 2.0.0", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", + "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "tracing 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "tracing-core 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "sp-transaction-pool-api" +name = "sc-tracing-graph" version = "2.0.0" dependencies = [ + "assert_matches 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "criterion 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-primitives 2.0.0", - "substrate-primitives 2.0.0", + "sp-core 2.0.0", + "sp-runtime 2.0.0", + "sp-transaction-pool-api 2.0.0", + "substrate-test-runtime 2.0.0", ] [[package]] -name = "sp-transaction-pool-runtime-api" +name = "sc-tracing-pool" version = "2.0.0" dependencies = [ - "sr-api 2.0.0", - "sr-primitives 2.0.0", - "substrate-primitives 2.0.0", + "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-client-api 2.0.0", + "sc-tracing-graph 2.0.0", + "sp-api 2.0.0", + "sp-blockchain 2.0.0", + "sp-core 2.0.0", + "sp-keyring 2.0.0", + "sp-runtime 2.0.0", + "sp-transaction-pool-api 2.0.0", + "sp-transaction-pool-runtime-api 2.0.0", + "substrate-test-runtime-client 2.0.0", ] [[package]] -name = "spin" -version = "0.5.2" +name = "schannel" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "sr-api" -version = "2.0.0" dependencies = [ - "criterion 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-api-proc-macro 2.0.0", - "sr-primitives 2.0.0", - "sr-std 2.0.0", - "sr-version 2.0.0", - "substrate-primitives 2.0.0", - "substrate-state-machine 2.0.0", - "substrate-test-runtime-client 2.0.0", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "sr-api-proc-macro" -version = "2.0.0" +name = "schnorrkel" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-api 2.0.0", - "sr-primitives 2.0.0", - "sr-version 2.0.0", - "substrate-test-runtime-client 2.0.0", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "curve25519-dalek 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "merlin 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "subtle 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "zeroize 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "sr-api-test" -version = "2.0.0" -dependencies = [ - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "rustversion 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-blockchain 2.0.0", - "sr-api 2.0.0", - "sr-primitives 2.0.0", - "sr-version 2.0.0", - "substrate-consensus-common 2.0.0", - "substrate-state-machine 2.0.0", - "substrate-test-runtime-client 2.0.0", - "trybuild 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)", -] +name = "scopeguard" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "sr-arithmetic" -version = "2.0.0" +name = "scopeguard" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "scroll" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "criterion 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "integer-sqrt 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "primitive-types 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-std 2.0.0", - "substrate-debug-derive 2.0.0", + "scroll_derive 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "sr-io" -version = "2.0.0" +name = "scroll_derive" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libsecp256k1 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-std 2.0.0", - "substrate-externalities 2.0.0", - "substrate-primitives 2.0.0", - "substrate-runtime-interface 2.0.0", - "substrate-state-machine 2.0.0", - "substrate-trie 2.0.0", + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "sr-primitives" -version = "2.0.0" +name = "sct" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "paste 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-arithmetic 2.0.0", - "sr-io 2.0.0", - "sr-std 2.0.0", - "substrate-application-crypto 2.0.0", - "substrate-inherents 2.0.0", - "substrate-primitives 2.0.0", + "ring 0.16.9 (registry+https://github.com/rust-lang/crates.io-index)", + "untrusted 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "sr-sandbox" -version = "2.0.0" +name = "security-framework" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "assert_matches 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-io 2.0.0", - "sr-std 2.0.0", - "substrate-primitives 2.0.0", - "wabt 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", - "wasmi 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "security-framework-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "sr-staking-primitives" -version = "2.0.0" +name = "security-framework-sys" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-primitives 2.0.0", - "sr-std 2.0.0", + "core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "sr-std" -version = "2.0.0" +name = "semver" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] -name = "sr-version" -version = "2.0.0" +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "impl-serde 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-primitives 2.0.0", - "sr-std 2.0.0", ] [[package]] -name = "stable_deref_trait" -version = "1.1.1" +name = "semver-parser" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "static_assertions" -version = "1.1.0" +name = "send_wrapper" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "stream-cipher" -version = "0.3.2" +name = "serde" +version = "1.0.103" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "string" -version = "0.2.1" +name = "serde_derive" +version = "1.0.103" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "string-interner" -version = "0.7.1" +name = "serde_json" +version = "1.0.42" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ + "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ryu 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "strsim" +name = "sha-1" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", + "digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "sha1" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "sha2" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", + "digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] -name = "structopt" -version = "0.3.4" +name = "sha3" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", - "structopt-derive 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", + "byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "keccak 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "structopt-derive" -version = "0.3.4" +name = "shell32-sys" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro-error 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "strum" -version = "0.16.0" +name = "shlex" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "slab" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "strum_macros 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] -name = "strum_macros" -version = "0.16.0" +name = "slog" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "erased-serde 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "subkey" -version = "2.0.0" +name = "slog-async" +version = "2.3.0" +source = "git+https://github.com/paritytech/slog-async#107848e7ded5e80dc43f6296c2b96039eb92c0a5" dependencies = [ - "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", - "frame-system 2.0.0", - "hex 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "node-primitives 2.0.0", - "node-runtime 2.0.0", - "pallet-balances 2.0.0", - "pallet-transaction-payment 2.0.0", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-primitives 2.0.0", - "substrate-bip39 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "substrate-primitives 2.0.0", - "tiny-bip39 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "take_mut 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "substrate-application-crypto" -version = "2.0.0" +name = "slog-json" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", + "erased-serde 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "sr-std 2.0.0", - "substrate-primitives 2.0.0", - "substrate-test-runtime-client 2.0.0", + "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", + "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "substrate-authority-discovery" -version = "2.0.0" +name = "slog-scope" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-timer 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "prost 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "prost-build 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-blockchain 2.0.0", - "sr-api 2.0.0", - "sr-primitives 2.0.0", - "substrate-authority-discovery-primitives 2.0.0", - "substrate-client-api 2.0.0", - "substrate-keystore 2.0.0", - "substrate-network 2.0.0", - "substrate-peerset 2.0.0", - "substrate-primitives 2.0.0", - "substrate-test-runtime-client 2.0.0", + "arc-swap 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "substrate-authority-discovery-primitives" -version = "2.0.0" +name = "slog_derive" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-api 2.0.0", - "sr-primitives 2.0.0", - "sr-std 2.0.0", - "substrate-application-crypto 2.0.0", + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "substrate-basic-authorship" -version = "2.0.0" +name = "smallvec" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sc-transaction-pool 2.0.0", - "sp-blockchain 2.0.0", - "sp-transaction-pool-api 2.0.0", - "sr-primitives 2.0.0", - "substrate-block-builder 2.0.0", - "substrate-client 2.0.0", - "substrate-client-api 2.0.0", - "substrate-consensus-common 2.0.0", - "substrate-inherents 2.0.0", - "substrate-primitives 2.0.0", - "substrate-telemetry 2.0.0", - "substrate-test-runtime-client 2.0.0", - "tokio-executor 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", + "maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "substrate-bip39" -version = "0.3.1" +name = "smallvec" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "hmac 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "pbkdf2 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "schnorrkel 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)", - "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] -name = "substrate-block-builder" -version = "2.0.0" +name = "snow" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-blockchain 2.0.0", - "sr-api 2.0.0", - "sr-primitives 2.0.0", - "substrate-block-builder-runtime-api 2.0.0", - "substrate-primitives 2.0.0", - "substrate-state-machine 2.0.0", + "arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "ring 0.16.9 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "subtle 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "substrate-block-builder-runtime-api" -version = "2.0.0" +name = "soketto" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-api 2.0.0", - "sr-primitives 2.0.0", - "sr-std 2.0.0", - "substrate-inherents 2.0.0", + "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "flate2 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "substrate-build-script-utils" -version = "2.0.0" +name = "sourcefile" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "substrate-chain-spec" +name = "sp-api" version = "2.0.0" dependencies = [ - "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-primitives 2.0.0", - "substrate-chain-spec-derive 2.0.0", - "substrate-network 2.0.0", - "substrate-primitives 2.0.0", - "substrate-telemetry 2.0.0", + "criterion 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-api-proc-macro 2.0.0", + "sp-core 2.0.0", + "sp-runtime 2.0.0", + "sp-state-machine 2.0.0", + "sp-std 2.0.0", + "sp-version 2.0.0", + "substrate-test-runtime-client 2.0.0", ] [[package]] -name = "substrate-chain-spec-derive" +name = "sp-api-proc-macro" version = "2.0.0" dependencies = [ + "blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-api 2.0.0", + "sp-runtime 2.0.0", + "sp-version 2.0.0", + "substrate-test-runtime-client 2.0.0", "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "substrate-cli" -version = "2.0.0" -dependencies = [ - "ansi_term 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", - "app_dirs 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", - "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", - "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", - "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "fdlimit 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures01 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "names 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rpassword 4.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-blockchain 2.0.0", - "sr-primitives 2.0.0", - "structopt 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "substrate-client-api 2.0.0", - "substrate-keyring 2.0.0", - "substrate-network 2.0.0", - "substrate-panic-handler 2.0.0", - "substrate-primitives 2.0.0", - "substrate-service 2.0.0", - "substrate-state-machine 2.0.0", - "substrate-telemetry 2.0.0", - "substrate-tracing 2.0.0", - "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "substrate-client" +name = "sp-api-test" version = "2.0.0" dependencies = [ - "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", - "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", - "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "kvdb 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "kvdb-memorydb 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustversion 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-api 2.0.0", "sp-blockchain 2.0.0", - "sr-api 2.0.0", - "sr-primitives 2.0.0", - "sr-std 2.0.0", - "sr-version 2.0.0", - "substrate-block-builder 2.0.0", - "substrate-client-api 2.0.0", - "substrate-client-db 2.0.0", - "substrate-consensus-common 2.0.0", - "substrate-executor 2.0.0", - "substrate-externalities 2.0.0", - "substrate-inherents 2.0.0", - "substrate-keyring 2.0.0", - "substrate-panic-handler 2.0.0", - "substrate-primitives 2.0.0", - "substrate-state-machine 2.0.0", - "substrate-telemetry 2.0.0", + "sp-consensus 2.0.0", + "sp-runtime 2.0.0", + "sp-state-machine 2.0.0", + "sp-version 2.0.0", "substrate-test-runtime-client 2.0.0", - "substrate-trie 2.0.0", - "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tracing 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "trybuild 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "substrate-client-api" +name = "sp-arithmetic" version = "2.0.0" dependencies = [ - "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", - "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", - "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "kvdb 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "kvdb-memorydb 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "criterion 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "integer-sqrt 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-blockchain 2.0.0", - "sp-transaction-pool-api 2.0.0", - "sr-api 2.0.0", - "sr-primitives 2.0.0", - "sr-std 2.0.0", - "sr-version 2.0.0", - "substrate-block-builder 2.0.0", - "substrate-client-db 2.0.0", - "substrate-consensus-common 2.0.0", - "substrate-executor 2.0.0", - "substrate-externalities 2.0.0", - "substrate-inherents 2.0.0", - "substrate-keyring 2.0.0", - "substrate-panic-handler 2.0.0", - "substrate-primitives 2.0.0", - "substrate-state-machine 2.0.0", - "substrate-telemetry 2.0.0", - "substrate-test-primitives 2.0.0", - "substrate-test-runtime-client 2.0.0", - "substrate-trie 2.0.0", - "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "primitive-types 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-debug-derive 2.0.0", + "sp-std 2.0.0", ] [[package]] -name = "substrate-client-db" +name = "sp-authority-discovery" version = "2.0.0" dependencies = [ - "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", - "kvdb 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "kvdb-memorydb 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "kvdb-rocksdb 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "quickcheck 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-blockchain 2.0.0", - "sr-primitives 2.0.0", - "substrate-client 2.0.0", - "substrate-client-api 2.0.0", - "substrate-consensus-common 2.0.0", - "substrate-executor 2.0.0", - "substrate-keyring 2.0.0", - "substrate-primitives 2.0.0", - "substrate-state-db 2.0.0", - "substrate-state-machine 2.0.0", - "substrate-test-runtime-client 2.0.0", - "substrate-trie 2.0.0", + "sc-application-crypto 2.0.0", + "sp-api 2.0.0", + "sp-runtime 2.0.0", + "sp-std 2.0.0", ] [[package]] -name = "substrate-consensus-aura" +name = "sp-authorship" version = "2.0.0" dependencies = [ - "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", - "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-timer 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-blockchain 2.0.0", - "sp-timestamp 2.0.0", - "sr-api 2.0.0", - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "sr-version 2.0.0", - "substrate-application-crypto 2.0.0", - "substrate-block-builder-runtime-api 2.0.0", - "substrate-client 2.0.0", - "substrate-client-api 2.0.0", - "substrate-consensus-aura-primitives 2.0.0", - "substrate-consensus-common 2.0.0", - "substrate-consensus-slots 2.0.0", - "substrate-executor 2.0.0", - "substrate-inherents 2.0.0", - "substrate-keyring 2.0.0", - "substrate-keystore 2.0.0", - "substrate-network 2.0.0", - "substrate-primitives 2.0.0", - "substrate-service 2.0.0", - "substrate-telemetry 2.0.0", - "substrate-test-runtime-client 2.0.0", - "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-inherents 2.0.0", + "sp-std 2.0.0", ] [[package]] -name = "substrate-consensus-aura-primitives" +name = "sp-block-builder" version = "2.0.0" dependencies = [ "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-timestamp 2.0.0", - "sr-api 2.0.0", - "sr-primitives 2.0.0", - "sr-std 2.0.0", - "substrate-application-crypto 2.0.0", - "substrate-inherents 2.0.0", + "sp-api 2.0.0", + "sp-inherents 2.0.0", + "sp-runtime 2.0.0", + "sp-std 2.0.0", ] [[package]] -name = "substrate-consensus-babe" +name = "sp-blockchain" version = "2.0.0" dependencies = [ "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", - "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "fork-tree 2.0.0", - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-timer 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "merlin 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "num-bigint 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "num-rational 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "lru 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "pdqselect 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "schnorrkel 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-blockchain 2.0.0", - "sp-timestamp 2.0.0", - "sr-api 2.0.0", - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "sr-version 2.0.0", - "substrate-application-crypto 2.0.0", - "substrate-block-builder 2.0.0", - "substrate-block-builder-runtime-api 2.0.0", - "substrate-client 2.0.0", - "substrate-client-api 2.0.0", - "substrate-consensus-babe-primitives 2.0.0", - "substrate-consensus-common 2.0.0", - "substrate-consensus-slots 2.0.0", - "substrate-consensus-uncles 2.0.0", - "substrate-executor 2.0.0", - "substrate-inherents 2.0.0", - "substrate-keyring 2.0.0", - "substrate-keystore 2.0.0", - "substrate-network 2.0.0", - "substrate-primitives 2.0.0", - "substrate-service 2.0.0", - "substrate-telemetry 2.0.0", - "substrate-test-runtime-client 2.0.0", - "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "substrate-consensus-babe-primitives" -version = "2.0.0" -dependencies = [ - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "schnorrkel 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-timestamp 2.0.0", - "sr-api 2.0.0", - "sr-primitives 2.0.0", - "sr-std 2.0.0", - "substrate-application-crypto 2.0.0", - "substrate-consensus-slots 2.0.0", - "substrate-inherents 2.0.0", + "sp-block-builder 2.0.0", + "sp-consensus 2.0.0", + "sp-runtime 2.0.0", + "sp-state-machine 2.0.0", ] [[package]] -name = "substrate-consensus-common" +name = "sp-consensus" version = "2.0.0" dependencies = [ "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5861,79 +6018,109 @@ dependencies = [ "libp2p 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-primitives 2.0.0", - "sr-std 2.0.0", - "sr-version 2.0.0", - "substrate-inherents 2.0.0", - "substrate-primitives 2.0.0", - "substrate-test-runtime-client 2.0.0", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-core 2.0.0", + "sp-inherents 2.0.0", + "sp-runtime 2.0.0", + "sp-std 2.0.0", + "sp-version 2.0.0", + "substrate-test-runtime-client 2.0.0", +] + +[[package]] +name = "sp-consensus-aura" +version = "2.0.0" +dependencies = [ + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-application-crypto 2.0.0", + "sp-api 2.0.0", + "sp-inherents 2.0.0", + "sp-runtime 2.0.0", + "sp-std 2.0.0", + "sp-timestamp 2.0.0", ] [[package]] -name = "substrate-consensus-pow" +name = "sp-consensus-babe" version = "2.0.0" dependencies = [ - "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-blockchain 2.0.0", + "sc-application-crypto 2.0.0", + "sc-consensus-slots 2.0.0", + "schnorrkel 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-api 2.0.0", + "sp-inherents 2.0.0", + "sp-runtime 2.0.0", + "sp-std 2.0.0", "sp-timestamp 2.0.0", - "sr-primitives 2.0.0", - "substrate-block-builder-runtime-api 2.0.0", - "substrate-client-api 2.0.0", - "substrate-consensus-common 2.0.0", - "substrate-consensus-pow-primitives 2.0.0", - "substrate-inherents 2.0.0", - "substrate-primitives 2.0.0", ] [[package]] -name = "substrate-consensus-pow-primitives" +name = "sp-consensus-pow" version = "2.0.0" dependencies = [ "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-api 2.0.0", - "sr-primitives 2.0.0", - "sr-std 2.0.0", - "substrate-primitives 2.0.0", + "sp-api 2.0.0", + "sp-core 2.0.0", + "sp-runtime 2.0.0", + "sp-std 2.0.0", ] [[package]] -name = "substrate-consensus-slots" +name = "sp-core" version = "2.0.0" dependencies = [ - "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-timer 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "criterion 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "ed25519-dalek 1.0.0-pre.2 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", + "hash256-std-hasher 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", + "hex 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "impl-serde 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libsecp256k1 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-blockchain 2.0.0", - "sr-primitives 2.0.0", - "substrate-client-api 2.0.0", - "substrate-consensus-common 2.0.0", - "substrate-inherents 2.0.0", - "substrate-primitives 2.0.0", - "substrate-telemetry 2.0.0", - "substrate-test-runtime-client 2.0.0", + "pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "primitive-types 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "schnorrkel 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", + "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-core-storage 2.0.0", + "sp-debug-derive 2.0.0", + "sp-externalities 2.0.0", + "sp-runtime-interface 2.0.0", + "sp-serializer 2.0.0", + "sp-std 2.0.0", + "substrate-bip39 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tiny-bip39 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "tiny-keccak 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "twox-hash 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmi 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "zeroize 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "substrate-consensus-uncles" +name = "sp-core-storage" version = "2.0.0" dependencies = [ - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-authorship 2.0.0", - "sr-primitives 2.0.0", - "substrate-client-api 2.0.0", - "substrate-consensus-common 2.0.0", - "substrate-inherents 2.0.0", - "substrate-primitives 2.0.0", + "impl-serde 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-debug-derive 2.0.0", + "sp-std 2.0.0", ] [[package]] -name = "substrate-debug-derive" +name = "sp-debug-derive" version = "2.0.0" dependencies = [ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5942,608 +6129,462 @@ dependencies = [ ] [[package]] -name = "substrate-executor" +name = "sp-externalities" version = "2.0.0" dependencies = [ - "assert_matches 1.3.0 (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-frontend 0.50.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift-native 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)", - "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", - "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libsecp256k1 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-wasm 0.41.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-io 2.0.0", - "sr-version 2.0.0", - "substrate-client-api 2.0.0", - "substrate-externalities 2.0.0", - "substrate-offchain 2.0.0", - "substrate-panic-handler 2.0.0", - "substrate-primitives 2.0.0", - "substrate-runtime-interface 2.0.0", - "substrate-runtime-test 2.0.0", - "substrate-serializer 2.0.0", - "substrate-state-machine 2.0.0", - "substrate-test-runtime 2.0.0", - "substrate-trie 2.0.0", - "substrate-wasm-interface 2.0.0", - "test-case 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "wabt 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", - "wasmi 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "wasmtime-environ 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "wasmtime-jit 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "wasmtime-runtime 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "environmental 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-core-storage 2.0.0", + "sp-std 2.0.0", ] [[package]] -name = "substrate-externalities" +name = "sp-finality-granpda" version = "2.0.0" dependencies = [ - "environmental 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-std 2.0.0", - "substrate-primitives-storage 2.0.0", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-application-crypto 2.0.0", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-api 2.0.0", + "sp-runtime 2.0.0", + "sp-std 2.0.0", ] [[package]] -name = "substrate-finality-grandpa" +name = "sp-finality-tracker" version = "2.0.0" dependencies = [ - "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "finality-grandpa 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "fork-tree 2.0.0", - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-blockchain 2.0.0", - "sp-finality-tracker 2.0.0", - "sr-api 2.0.0", - "sr-primitives 2.0.0", - "substrate-client 2.0.0", - "substrate-client-api 2.0.0", - "substrate-consensus-babe-primitives 2.0.0", - "substrate-consensus-common 2.0.0", - "substrate-finality-grandpa-primitives 2.0.0", - "substrate-inherents 2.0.0", - "substrate-keyring 2.0.0", - "substrate-keystore 2.0.0", - "substrate-network 2.0.0", - "substrate-primitives 2.0.0", - "substrate-state-machine 2.0.0", - "substrate-telemetry 2.0.0", - "substrate-test-runtime-client 2.0.0", - "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-inherents 2.0.0", + "sp-std 2.0.0", ] [[package]] -name = "substrate-finality-grandpa-primitives" +name = "sp-inherents" version = "2.0.0" dependencies = [ + "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-api 2.0.0", - "sr-primitives 2.0.0", - "sr-std 2.0.0", - "substrate-application-crypto 2.0.0", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-core 2.0.0", + "sp-std 2.0.0", ] [[package]] -name = "substrate-frame-rpc-support" +name = "sp-io" version = "2.0.0" dependencies = [ - "frame-support 2.0.0", - "frame-system 2.0.0", - "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-client-transports 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libsecp256k1 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "sc-rpc-api 2.0.0", - "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "substrate-primitives-storage 2.0.0", - "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-core 2.0.0", + "sp-externalities 2.0.0", + "sp-runtime-interface 2.0.0", + "sp-state-machine 2.0.0", + "sp-std 2.0.0", + "sp-trie 2.0.0", ] [[package]] -name = "substrate-frame-rpc-system" +name = "sp-keyring" version = "2.0.0" dependencies = [ - "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "frame-system-rpc-runtime-api 2.0.0", - "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core-client 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-derive 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "sc-transaction-pool 2.0.0", - "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-blockchain 2.0.0", - "sp-transaction-pool-api 2.0.0", - "sr-primitives 2.0.0", - "substrate-client 2.0.0", - "substrate-primitives 2.0.0", - "substrate-test-runtime-client 2.0.0", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-core 2.0.0", + "sp-runtime 2.0.0", + "strum 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "substrate-inherents" +name = "sp-offchain" version = "2.0.0" dependencies = [ - "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-std 2.0.0", - "substrate-primitives 2.0.0", + "sp-api 2.0.0", + "sp-runtime 2.0.0", ] [[package]] -name = "substrate-keyring" +name = "sp-panic-handler" version = "2.0.0" dependencies = [ - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-primitives 2.0.0", - "strum 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", - "substrate-primitives 2.0.0", + "backtrace 0.3.40 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "substrate-keystore" +name = "sp-phragmen" version = "2.0.0" dependencies = [ - "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", - "hex 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-io 2.0.0", + "sp-runtime 2.0.0", + "sp-std 2.0.0", + "substrate-test-utils 2.0.0", +] + +[[package]] +name = "sp-rpc" +version = "2.0.0" +dependencies = [ + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", - "substrate-application-crypto 2.0.0", - "substrate-primitives 2.0.0", - "subtle 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-core 2.0.0", ] [[package]] -name = "substrate-network" +name = "sp-runtime" version = "2.0.0" dependencies = [ - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", - "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "erased-serde 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "fork-tree 2.0.0", - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-timer 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", - "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "linked_hash_set 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "lru 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "quickcheck 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "paste 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-application-crypto 2.0.0", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", - "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "slog_derive 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-blockchain 2.0.0", - "sr-arithmetic 2.0.0", - "sr-primitives 2.0.0", - "substrate-block-builder 2.0.0", - "substrate-client 2.0.0", - "substrate-client-api 2.0.0", - "substrate-consensus-babe-primitives 2.0.0", - "substrate-consensus-common 2.0.0", - "substrate-keyring 2.0.0", - "substrate-peerset 2.0.0", - "substrate-primitives 2.0.0", - "substrate-test-client 2.0.0", - "substrate-test-runtime 2.0.0", - "substrate-test-runtime-client 2.0.0", - "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "unsigned-varint 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "zeroize 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-arithmetic 2.0.0", + "sp-core 2.0.0", + "sp-inherents 2.0.0", + "sp-io 2.0.0", + "sp-std 2.0.0", ] [[package]] -name = "substrate-offchain" +name = "sp-runtime-interface" version = "2.0.0" dependencies = [ - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-timer 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "hyper 0.12.35 (registry+https://github.com/rust-lang/crates.io-index)", - "hyper-rustls 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)", + "environmental 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "sc-transaction-pool 2.0.0", - "sp-transaction-pool-api 2.0.0", - "sr-api 2.0.0", - "sr-primitives 2.0.0", - "substrate-client-api 2.0.0", - "substrate-client-db 2.0.0", - "substrate-keystore 2.0.0", - "substrate-network 2.0.0", - "substrate-offchain-primitives 2.0.0", - "substrate-primitives 2.0.0", - "substrate-test-runtime-client 2.0.0", - "threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", + "primitive-types 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-executor 2.0.0", + "sp-core 2.0.0", + "sp-externalities 2.0.0", + "sp-io 2.0.0", + "sp-runtime-interface-proc-macro 2.0.0", + "sp-runtime-interface-test-wasm 2.0.0", + "sp-state-machine 2.0.0", + "sp-std 2.0.0", + "sp-wasm-interface 2.0.0", + "static_assertions 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "sp-runtime-interface-proc-macro" +version = "2.0.0" +dependencies = [ + "Inflector 0.11.4 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rustversion 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-externalities 2.0.0", + "sp-runtime-interface 2.0.0", + "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "trybuild 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "substrate-offchain-primitives" +name = "sp-runtime-interface-test-wasm" version = "2.0.0" dependencies = [ - "sr-api 2.0.0", - "sr-primitives 2.0.0", + "sp-core 2.0.0", + "sp-io 2.0.0", + "sp-runtime-interface 2.0.0", + "sp-std 2.0.0", + "substrate-wasm-builder-runner 1.0.4", ] [[package]] -name = "substrate-panic-handler" +name = "sp-sandbox" version = "2.0.0" dependencies = [ - "backtrace 0.3.40 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "assert_matches 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-core 2.0.0", + "sp-io 2.0.0", + "sp-std 2.0.0", + "wabt 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmi 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "substrate-peerset" +name = "sp-serializer" version = "2.0.0" dependencies = [ - "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "substrate-phragmen" +name = "sp-sesssion" version = "2.0.0" dependencies = [ - "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "sr-std 2.0.0", - "substrate-test-utils 2.0.0", + "sp-api 2.0.0", + "sp-runtime 2.0.0", + "sp-std 2.0.0", ] [[package]] -name = "substrate-primitives" +name = "sp-staking" +version = "2.0.0" +dependencies = [ + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-runtime 2.0.0", + "sp-std 2.0.0", +] + +[[package]] +name = "sp-state-machine" version = "2.0.0" dependencies = [ - "base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", - "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "criterion 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "ed25519-dalek 1.0.0-pre.2 (registry+https://github.com/rust-lang/crates.io-index)", "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", - "hash256-std-hasher 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", - "hex 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "impl-serde 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libsecp256k1 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "primitive-types 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "schnorrkel 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", - "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-std 2.0.0", - "substrate-bip39 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "substrate-debug-derive 2.0.0", - "substrate-externalities 2.0.0", - "substrate-primitives-storage 2.0.0", - "substrate-runtime-interface 2.0.0", - "substrate-serializer 2.0.0", - "tiny-bip39 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tiny-keccak 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "twox-hash 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "wasmi 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "zeroize 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-core 2.0.0", + "sp-externalities 2.0.0", + "sp-panic-handler 2.0.0", + "sp-trie 2.0.0", + "trie-db 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", + "trie-root 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "substrate-primitives-storage" +name = "sp-std" +version = "2.0.0" + +[[package]] +name = "sp-timestamp" version = "2.0.0" dependencies = [ - "impl-serde 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-std 2.0.0", - "substrate-debug-derive 2.0.0", + "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-api 2.0.0", + "sp-inherents 2.0.0", + "sp-runtime 2.0.0", + "sp-std 2.0.0", ] [[package]] -name = "substrate-rpc" +name = "sp-transaction-pool-api" version = "2.0.0" dependencies = [ - "assert_matches 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-pubsub 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "sc-rpc-api 2.0.0", - "sc-transaction-pool 2.0.0", - "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-blockchain 2.0.0", - "sp-transaction-pool-api 2.0.0", - "sr-api 2.0.0", - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "sr-version 2.0.0", - "substrate-client 2.0.0", - "substrate-client-api 2.0.0", - "substrate-executor 2.0.0", - "substrate-keystore 2.0.0", - "substrate-network 2.0.0", - "substrate-primitives 2.0.0", - "substrate-rpc-primitives 2.0.0", - "substrate-session 2.0.0", - "substrate-state-machine 2.0.0", - "substrate-test-runtime-client 2.0.0", - "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-core 2.0.0", + "sp-runtime 2.0.0", ] [[package]] -name = "substrate-rpc-primitives" +name = "sp-transaction-pool-runtime-api" version = "2.0.0" dependencies = [ - "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", - "substrate-primitives 2.0.0", + "sp-api 2.0.0", + "sp-core 2.0.0", + "sp-runtime 2.0.0", ] [[package]] -name = "substrate-rpc-servers" +name = "sp-trie" version = "2.0.0" dependencies = [ - "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-http-server 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-pubsub 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-ws-server 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-primitives 2.0.0", + "criterion 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", + "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "memory-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-core 2.0.0", + "sp-std 2.0.0", + "trie-bench 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)", + "trie-db 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", + "trie-root 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", + "trie-standardmap 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "substrate-runtime-interface" +name = "sp-version" version = "2.0.0" dependencies = [ - "environmental 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "impl-serde 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "primitive-types 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-io 2.0.0", - "sr-std 2.0.0", - "static_assertions 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "substrate-executor 2.0.0", - "substrate-externalities 2.0.0", - "substrate-primitives 2.0.0", - "substrate-runtime-interface-proc-macro 2.0.0", - "substrate-runtime-interface-test-wasm 2.0.0", - "substrate-state-machine 2.0.0", - "substrate-wasm-interface 2.0.0", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-runtime 2.0.0", + "sp-std 2.0.0", ] [[package]] -name = "substrate-runtime-interface-proc-macro" +name = "sp-wasm-interface" version = "2.0.0" dependencies = [ - "Inflector 0.11.4 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rustversion 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "substrate-externalities 2.0.0", - "substrate-runtime-interface 2.0.0", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "trybuild 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)", + "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmi 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "substrate-runtime-interface-test-wasm" -version = "2.0.0" +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "stable_deref_trait" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "stream-cipher" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "sr-io 2.0.0", - "sr-std 2.0.0", - "substrate-primitives 2.0.0", - "substrate-runtime-interface 2.0.0", - "substrate-wasm-builder-runner 1.0.4", + "generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "substrate-runtime-test" -version = "2.0.0" +name = "string" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "sr-sandbox 2.0.0", - "sr-std 2.0.0", - "substrate-primitives 2.0.0", - "substrate-wasm-builder-runner 1.0.4", + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "substrate-serializer" -version = "2.0.0" +name = "string-interner" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "substrate-service" -version = "2.0.0" +name = "strsim" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "structopt" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", - "exit-future 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "grafana-data-source 2.0.0", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sc-transaction-pool 2.0.0", - "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", - "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-blockchain 2.0.0", - "sp-transaction-pool-api 2.0.0", - "sp-transaction-pool-runtime-api 2.0.0", - "sr-api 2.0.0", - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "substrate-application-crypto 2.0.0", - "substrate-chain-spec 2.0.0", - "substrate-client 2.0.0", - "substrate-client-api 2.0.0", - "substrate-client-db 2.0.0", - "substrate-consensus-babe-primitives 2.0.0", - "substrate-consensus-common 2.0.0", - "substrate-executor 2.0.0", - "substrate-finality-grandpa 2.0.0", - "substrate-finality-grandpa-primitives 2.0.0", - "substrate-keystore 2.0.0", - "substrate-network 2.0.0", - "substrate-offchain 2.0.0", - "substrate-primitives 2.0.0", - "substrate-rpc 2.0.0", - "substrate-rpc-servers 2.0.0", - "substrate-session 2.0.0", - "substrate-telemetry 2.0.0", - "substrate-test-runtime-client 2.0.0", - "substrate-tracing 2.0.0", - "sysinfo 0.9.6 (registry+https://github.com/rust-lang/crates.io-index)", - "target_info 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "tracing 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt-derive 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "substrate-service-test" -version = "2.0.0" +name = "structopt-derive" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "fdlimit 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-transaction-pool-api 2.0.0", - "sr-primitives 2.0.0", - "substrate-client 2.0.0", - "substrate-consensus-common 2.0.0", - "substrate-network 2.0.0", - "substrate-primitives 2.0.0", - "substrate-service 2.0.0", - "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", + "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-error 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "substrate-session" -version = "2.0.0" +name = "strum" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "sr-api 2.0.0", - "sr-primitives 2.0.0", - "sr-std 2.0.0", + "strum_macros 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "substrate-state-db" -version = "2.0.0" +name = "strum_macros" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "substrate-primitives 2.0.0", + "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "substrate-state-machine" +name = "subkey" version = "2.0.0" dependencies = [ - "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", + "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", + "frame-system 2.0.0", + "hex 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "node-primitives 2.0.0", + "node-runtime 2.0.0", + "pallet-balances 2.0.0", + "pallet-transaction-payment 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "substrate-externalities 2.0.0", - "substrate-panic-handler 2.0.0", - "substrate-primitives 2.0.0", - "substrate-trie 2.0.0", - "trie-db 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", - "trie-root 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-core 2.0.0", + "sp-runtime 2.0.0", + "substrate-bip39 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tiny-bip39 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "substrate-bip39" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "hmac 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "pbkdf2 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "schnorrkel 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)", + "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "substrate-telemetry" +name = "substrate-build-script-utils" +version = "2.0.0" + +[[package]] +name = "substrate-frame-rpc-support" version = "2.0.0" dependencies = [ - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "frame-support 2.0.0", + "frame-system 2.0.0", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-timer 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-client-transports 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-rpc-api 2.0.0", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-core-storage 2.0.0", + "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "substrate-frame-rpc-system" +version = "2.0.0" +dependencies = [ + "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "frame-system-rpc-runtime-api 2.0.0", + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core-client 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-derive 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-client 2.0.0", + "sc-tracing-pool 2.0.0", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "slog-async 2.3.0 (git+https://github.com/paritytech/slog-async)", - "slog-json 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "slog-scope 4.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-blockchain 2.0.0", + "sp-core 2.0.0", + "sp-runtime 2.0.0", + "sp-transaction-pool-api 2.0.0", + "substrate-test-runtime-client 2.0.0", ] [[package]] @@ -6553,16 +6594,16 @@ dependencies = [ "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-client 2.0.0", + "sc-client-api 2.0.0", + "sc-client-db 2.0.0", + "sc-executor 2.0.0", "sp-blockchain 2.0.0", - "sr-primitives 2.0.0", - "substrate-client 2.0.0", - "substrate-client-api 2.0.0", - "substrate-client-db 2.0.0", - "substrate-consensus-common 2.0.0", - "substrate-executor 2.0.0", - "substrate-keyring 2.0.0", - "substrate-primitives 2.0.0", - "substrate-state-machine 2.0.0", + "sp-consensus 2.0.0", + "sp-core 2.0.0", + "sp-keyring 2.0.0", + "sp-runtime 2.0.0", + "sp-state-machine 2.0.0", ] [[package]] @@ -6570,10 +6611,10 @@ name = "substrate-test-primitives" version = "2.0.0" dependencies = [ "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-application-crypto 2.0.0", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-primitives 2.0.0", - "substrate-application-crypto 2.0.0", - "substrate-primitives 2.0.0", + "sp-core 2.0.0", + "sp-runtime 2.0.0", ] [[package]] @@ -6590,28 +6631,28 @@ dependencies = [ "pallet-babe 2.0.0", "pallet-timestamp 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-application-crypto 2.0.0", + "sc-client 2.0.0", + "sc-executor 2.0.0", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-api 2.0.0", + "sp-block-builder 2.0.0", + "sp-consensus-aura 2.0.0", + "sp-consensus-babe 2.0.0", + "sp-core 2.0.0", + "sp-inherents 2.0.0", + "sp-io 2.0.0", + "sp-keyring 2.0.0", + "sp-offchain 2.0.0", + "sp-runtime 2.0.0", + "sp-runtime-interface 2.0.0", + "sp-sesssion 2.0.0", + "sp-state-machine 2.0.0", + "sp-std 2.0.0", "sp-transaction-pool-runtime-api 2.0.0", - "sr-api 2.0.0", - "sr-io 2.0.0", - "sr-primitives 2.0.0", - "sr-std 2.0.0", - "sr-version 2.0.0", - "substrate-application-crypto 2.0.0", - "substrate-block-builder-runtime-api 2.0.0", - "substrate-client 2.0.0", - "substrate-consensus-aura-primitives 2.0.0", - "substrate-consensus-babe-primitives 2.0.0", - "substrate-executor 2.0.0", - "substrate-inherents 2.0.0", - "substrate-keyring 2.0.0", - "substrate-offchain-primitives 2.0.0", - "substrate-primitives 2.0.0", - "substrate-runtime-interface 2.0.0", - "substrate-session 2.0.0", - "substrate-state-machine 2.0.0", + "sp-trie 2.0.0", + "sp-version 2.0.0", "substrate-test-runtime-client 2.0.0", - "substrate-trie 2.0.0", "substrate-wasm-builder-runner 1.0.4", "trie-db 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -6622,12 +6663,12 @@ version = "2.0.0" dependencies = [ "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-block-builder 2.0.0", + "sc-client 2.0.0", + "sc-client-api 2.0.0", "sp-blockchain 2.0.0", - "sr-primitives 2.0.0", - "substrate-block-builder 2.0.0", - "substrate-client 2.0.0", - "substrate-client-api 2.0.0", - "substrate-primitives 2.0.0", + "sp-core 2.0.0", + "sp-runtime 2.0.0", "substrate-test-client 2.0.0", "substrate-test-runtime 2.0.0", ] @@ -6636,39 +6677,6 @@ dependencies = [ name = "substrate-test-utils" version = "2.0.0" -[[package]] -name = "substrate-tracing" -version = "2.0.0" -dependencies = [ - "erased-serde 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "grafana-data-source 2.0.0", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", - "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "substrate-telemetry 2.0.0", - "tracing 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "tracing-core 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "substrate-trie" -version = "2.0.0" -dependencies = [ - "criterion 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", - "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "memory-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-std 2.0.0", - "substrate-primitives 2.0.0", - "trie-bench 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)", - "trie-db 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", - "trie-root 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", - "trie-standardmap 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "substrate-wasm-builder" version = "1.0.8" @@ -6687,14 +6695,6 @@ dependencies = [ name = "substrate-wasm-builder-runner" version = "1.0.4" -[[package]] -name = "substrate-wasm-interface" -version = "2.0.0" -dependencies = [ - "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "wasmi 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "subtle" version = "1.0.0" @@ -7206,16 +7206,16 @@ version = "0.0.1" dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-cli 2.0.0", + "sc-client 2.0.0", + "sc-client-api 2.0.0", + "sc-service 2.0.0", + "sp-api 2.0.0", + "sp-block-builder 2.0.0", "sp-blockchain 2.0.0", - "sr-api 2.0.0", - "sr-primitives 2.0.0", - "substrate-block-builder-runtime-api 2.0.0", - "substrate-cli 2.0.0", - "substrate-client 2.0.0", - "substrate-client-api 2.0.0", - "substrate-consensus-common 2.0.0", - "substrate-primitives 2.0.0", - "substrate-service 2.0.0", + "sp-consensus 2.0.0", + "sp-core 2.0.0", + "sp-runtime 2.0.0", ] [[package]] diff --git a/bin/node-template/Cargo.toml b/bin/node-template/Cargo.toml index 09b438a0ac..37501cd96b 100644 --- a/bin/node-template/Cargo.toml +++ b/bin/node-template/Cargo.toml @@ -18,24 +18,24 @@ tokio = "0.1.22" parking_lot = "0.9.0" codec = { package = "parity-scale-codec", version = "1.0.0" } trie-root = "0.15.2" -sr-io = { path = "../../primitives/sr-io" } -substrate-cli = { path = "../../client/cli" } -primitives = { package = "substrate-primitives", path = "../../primitives/core" } -substrate-executor = { path = "../../client/executor" } -substrate-service = { path = "../../client/service" } -inherents = { package = "substrate-inherents", path = "../../primitives/inherents" } -txpool = { package = "sc-transaction-pool", path = "../../client/transaction-pool" } +sp-io = { path = "../../primitives/sr-io" } +sc-cli = { path = "../../client/cli" } +primitives = { package = "sp-core", path = "../../primitives/core" } +sc-executor = { path = "../../client/executor" } +sc-service = { path = "../../client/service" } +inherents = { package = "sp-inherents", path = "../../primitives/inherents" } +txpool = { package = "sc-tracing-pool", path = "../../client/transaction-pool" } txpool-api = { package = "sp-transaction-pool-api", path = "../../primitives/transaction-pool" } -network = { package = "substrate-network", path = "../../client/network" } -aura = { package = "substrate-consensus-aura", path = "../../client/consensus/aura" } -aura-primitives = { package = "substrate-consensus-aura-primitives", path = "../../primitives/consensus/aura" } -consensus-common = { package = "substrate-consensus-common", path = "../../primitives/consensus/common" } -grandpa = { package = "substrate-finality-grandpa", path = "../../client/finality-grandpa" } -grandpa-primitives = { package = "substrate-finality-grandpa-primitives", path = "../../primitives/finality-grandpa" } -substrate-client = { path = "../../client/" } +network = { package = "sc-network", path = "../../client/network" } +aura = { package = "sc-consensus-aura", path = "../../client/consensus/aura" } +aura-primitives = { package = "sp-consensus-aura", path = "../../primitives/consensus/aura" } +consensus-common = { package = "sp-consensus", path = "../../primitives/consensus/common" } +grandpa = { package = "sc-finality-grandpa", path = "../../client/finality-grandpa" } +grandpa-primitives = { package = "sp-finality-granpda", path = "../../primitives/finality-grandpa" } +sc-client = { path = "../../client/" } runtime = { package = "node-template-runtime", path = "runtime" } -sr-primitives = { path = "../../primitives/sr-primitives" } -basic-authorship = { package = "substrate-basic-authorship", path = "../../client/basic-authorship"} +sp-runtime = { path = "../../primitives/sr-primitives" } +basic-authorship = { package = "sc-basic-authority", path = "../../client/basic-authorship"} [build-dependencies] vergen = "3.0.4" diff --git a/bin/node-template/runtime/Cargo.toml b/bin/node-template/runtime/Cargo.toml index 46767e7098..1f71c426fe 100644 --- a/bin/node-template/runtime/Cargo.toml +++ b/bin/node-template/runtime/Cargo.toml @@ -6,31 +6,31 @@ edition = "2018" [dependencies] aura = { package = "pallet-aura", path = "../../../frame/aura", default-features = false } -aura-primitives = { package = "substrate-consensus-aura-primitives", path = "../../../primitives/consensus/aura", default-features = false } +aura-primitives = { package = "sp-consensus-aura", path = "../../../primitives/consensus/aura", default-features = false } balances = { package = "pallet-balances", path = "../../../frame/balances", default-features = false } -block-builder-api = { package = "substrate-block-builder-runtime-api", path = "../../../primitives/block-builder/runtime-api", default-features = false} +block-builder-api = { package = "sp-block-builder", path = "../../../primitives/block-builder/runtime-api", default-features = false} codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } executive = { package = "frame-executive", path = "../../../frame/executive", default-features = false } grandpa = { package = "pallet-grandpa", path = "../../../frame/grandpa", default-features = false } indices = { package = "pallet-indices", path = "../../../frame/indices", default-features = false } -inherents = { package = "substrate-inherents", path = "../../../primitives/inherents", default-features = false} -offchain-primitives = { package = "substrate-offchain-primitives", path = "../../../primitives/offchain", default-features = false } -primitives = { package = "substrate-primitives", path = "../../../primitives/core", default-features = false } +inherents = { package = "sp-inherents", path = "../../../primitives/inherents", default-features = false} +offchain-primitives = { package = "sp-offchain", path = "../../../primitives/offchain", default-features = false } +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 } -rstd = { package = "sr-std", path = "../../../primitives/sr-std", default-features = false } -runtime-io = { package = "sr-io", path = "../../../primitives/sr-io", default-features = false } +rstd = { package = "sp-std", path = "../../../primitives/sr-std", default-features = false } +runtime-io = { package = "sp-io", path = "../../../primitives/sr-io", default-features = false } safe-mix = { version = "1.0.0", default-features = false } serde = { version = "1.0.101", optional = true, features = ["derive"] } -sr-api = { path = "../../../primitives/sr-api", default-features = false } -sr-primitives = { path = "../../../primitives/sr-primitives", default-features = false } -substrate-session = { path = "../../../primitives/session", default-features = false } +sp-api = { path = "../../../primitives/sr-api", default-features = false } +sp-runtime = { path = "../../../primitives/sr-primitives", default-features = false } +sp-sesssion = { path = "../../../primitives/session", default-features = false } sudo = { package = "pallet-sudo", path = "../../../frame/sudo", default-features = false } support = { package = "frame-support", path = "../../../frame/support", default-features = false } system = { package = "frame-system", path = "../../../frame/system", default-features = false } timestamp = { package = "pallet-timestamp", path = "../../../frame/timestamp", default-features = false } transaction-payment = { package = "pallet-transaction-payment", path = "../../../frame/transaction-payment", default-features = false } txpool-runtime-api = { package = "sp-transaction-pool-runtime-api", path = "../../../primitives/transaction-pool/runtime-api", default-features = false } -version = { package = "sr-version", path = "../../../primitives/sr-version", default-features = false } +version = { package = "sp-version", path = "../../../primitives/sr-version", default-features = false } [build-dependencies] wasm-builder-runner = { package = "substrate-wasm-builder-runner", path = "../../../client/utils/wasm-builder-runner", version = "1.0.4" } @@ -54,9 +54,9 @@ std = [ "runtime-io/std", "safe-mix/std", "serde", - "sr-api/std", - "sr-primitives/std", - "substrate-session/std", + "sp-api/std", + "sp-runtime/std", + "sp-sesssion/std", "sudo/std", "support/std", "system/std", diff --git a/bin/node-template/runtime/src/lib.rs b/bin/node-template/runtime/src/lib.rs index 36edeecc6e..f16018da8f 100644 --- a/bin/node-template/runtime/src/lib.rs +++ b/bin/node-template/runtime/src/lib.rs @@ -10,14 +10,14 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); use rstd::prelude::*; use primitives::OpaqueMetadata; -use sr_primitives::{ +use sp_runtime::{ ApplyExtrinsicResult, transaction_validity::TransactionValidity, generic, create_runtime_str, impl_opaque_keys, MultiSignature }; -use sr_primitives::traits::{ +use sp_runtime::traits::{ NumberFor, BlakeTwo256, Block as BlockT, StaticLookup, Verify, ConvertInto, IdentifyAccount }; -use sr_api::impl_runtime_apis; +use sp_api::impl_runtime_apis; use aura_primitives::sr25519::AuthorityId as AuraId; use grandpa::AuthorityList as GrandpaAuthorityList; use grandpa::fg_primitives; @@ -27,10 +27,10 @@ use version::NativeVersion; // A few exports that help ease life for downstream crates. #[cfg(any(feature = "std", test))] -pub use sr_primitives::BuildStorage; +pub use sp_runtime::BuildStorage; pub use timestamp::Call as TimestampCall; pub use balances::Call as BalancesCall; -pub use sr_primitives::{Permill, Perbill}; +pub use sp_runtime::{Permill, Perbill}; pub use support::{ StorageValue, construct_runtime, parameter_types, traits::Randomness, @@ -73,7 +73,7 @@ mod template; pub mod opaque { use super::*; - pub use sr_primitives::OpaqueExtrinsic as UncheckedExtrinsic; + pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic; /// Opaque block header type. pub type Header = generic::Header; @@ -283,7 +283,7 @@ pub type CheckedExtrinsic = generic::CheckedExtrinsic, Runtime, AllModules>; impl_runtime_apis! { - impl sr_api::Core for Runtime { + impl sp_api::Core for Runtime { fn version() -> RuntimeVersion { VERSION } @@ -297,7 +297,7 @@ impl_runtime_apis! { } } - impl sr_api::Metadata for Runtime { + impl sp_api::Metadata for Runtime { fn metadata() -> OpaqueMetadata { Runtime::metadata().into() } @@ -350,7 +350,7 @@ impl_runtime_apis! { } } - impl substrate_session::SessionKeys for Runtime { + impl sp_sesssion::SessionKeys for Runtime { fn generate_session_keys(seed: Option>) -> Vec { opaque::SessionKeys::generate(seed) } diff --git a/bin/node-template/runtime/src/template.rs b/bin/node-template/runtime/src/template.rs index 33f0b6af7e..e3e053da53 100644 --- a/bin/node-template/runtime/src/template.rs +++ b/bin/node-template/runtime/src/template.rs @@ -71,7 +71,7 @@ mod tests { use primitives::H256; use support::{impl_outer_origin, assert_ok, parameter_types, weights::Weight}; - use sr_primitives::{ + use sp_runtime::{ traits::{BlakeTwo256, IdentityLookup}, testing::Header, Perbill, }; diff --git a/bin/node-template/src/chain_spec.rs b/bin/node-template/src/chain_spec.rs index 8d43e67304..6b979b16dd 100644 --- a/bin/node-template/src/chain_spec.rs +++ b/bin/node-template/src/chain_spec.rs @@ -5,14 +5,14 @@ use runtime::{ }; use aura_primitives::sr25519::{AuthorityId as AuraId}; use grandpa_primitives::{AuthorityId as GrandpaId}; -use substrate_service; -use sr_primitives::traits::{Verify, IdentifyAccount}; +use sc_service; +use sp_runtime::traits::{Verify, IdentifyAccount}; // Note this is the URL for the telemetry server //const STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/"; /// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type. -pub type ChainSpec = substrate_service::ChainSpec; +pub type ChainSpec = sc_service::ChainSpec; /// The chain specification option. This is expected to come in from the CLI and /// is little more than one of a number of alternatives which can easily be converted diff --git a/bin/node-template/src/cli.rs b/bin/node-template/src/cli.rs index edbe40feb8..5d29cdf8df 100644 --- a/bin/node-template/src/cli.rs +++ b/bin/node-template/src/cli.rs @@ -2,9 +2,9 @@ use crate::service; use futures::{future::{select, Map}, FutureExt, TryFutureExt, channel::oneshot, compat::Future01CompatExt}; use std::cell::RefCell; use tokio::runtime::Runtime; -pub use substrate_cli::{VersionInfo, IntoExit, error}; -use substrate_cli::{display_role, informant, parse_and_prepare, ParseAndPrepare, NoCustom}; -use substrate_service::{AbstractService, Roles as ServiceRoles, Configuration}; +pub use sc_cli::{VersionInfo, IntoExit, error}; +use sc_cli::{display_role, informant, parse_and_prepare, ParseAndPrepare, NoCustom}; +use sc_service::{AbstractService, Roles as ServiceRoles, Configuration}; use aura_primitives::sr25519::{AuthorityPair as AuraPair}; use crate::chain_spec; use log::info; diff --git a/bin/node-template/src/main.rs b/bin/node-template/src/main.rs index 1f286a2237..2942bb68a3 100644 --- a/bin/node-template/src/main.rs +++ b/bin/node-template/src/main.rs @@ -8,7 +8,7 @@ mod chain_spec; mod service; mod cli; -pub use substrate_cli::{VersionInfo, IntoExit, error}; +pub use sc_cli::{VersionInfo, IntoExit, error}; fn main() -> Result<(), cli::error::Error> { let version = VersionInfo { diff --git a/bin/node-template/src/service.rs b/bin/node-template/src/service.rs index 6fd4daed69..600ae2c5b2 100644 --- a/bin/node-template/src/service.rs +++ b/bin/node-template/src/service.rs @@ -2,13 +2,13 @@ use std::sync::Arc; use std::time::Duration; -use substrate_client::LongestChain; +use sc_client::LongestChain; use runtime::{self, GenesisConfig, opaque::Block, RuntimeApi}; -use substrate_service::{error::{Error as ServiceError}, AbstractService, Configuration, ServiceBuilder}; +use sc_service::{error::{Error as ServiceError}, AbstractService, Configuration, ServiceBuilder}; use inherents::InherentDataProviders; use network::{construct_simple_protocol}; -use substrate_executor::native_executor_instance; -pub use substrate_executor::NativeExecutor; +use sc_executor::native_executor_instance; +pub use sc_executor::NativeExecutor; use aura_primitives::sr25519::{AuthorityPair as AuraPair}; use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider}; use basic_authorship; @@ -34,11 +34,11 @@ macro_rules! new_full_start { let mut import_setup = None; let inherent_data_providers = inherents::InherentDataProviders::new(); - let builder = substrate_service::ServiceBuilder::new_full::< + let builder = sc_service::ServiceBuilder::new_full::< runtime::opaque::Block, runtime::RuntimeApi, crate::service::Executor >($config)? .with_select_chain(|_config, backend| { - Ok(substrate_client::LongestChain::new(backend.clone())) + Ok(sc_client::LongestChain::new(backend.clone())) })? .with_transaction_pool(|config, client, _fetcher| { let pool_api = txpool::FullChainApi::new(client.clone()); @@ -49,7 +49,7 @@ macro_rules! new_full_start { })? .with_import_queue(|_config, client, mut select_chain, transaction_pool| { let select_chain = select_chain.take() - .ok_or_else(|| substrate_service::Error::SelectChainRequired)?; + .ok_or_else(|| sc_service::Error::SelectChainRequired)?; let (grandpa_block_import, grandpa_link) = grandpa::block_import::<_, _, _, runtime::RuntimeApi, _>( diff --git a/bin/node/cli/Cargo.toml b/bin/node/cli/Cargo.toml index d04a0382b4..4d3556bd51 100644 --- a/bin/node/cli/Cargo.toml +++ b/bin/node/cli/Cargo.toml @@ -34,34 +34,34 @@ rand = "0.7.2" structopt = "0.3.3" # primitives -authority-discovery-primitives = { package = "substrate-authority-discovery-primitives", path = "../../../primitives/authority-discovery"} -babe-primitives = { package = "substrate-consensus-babe-primitives", path = "../../../primitives/consensus/babe" } -grandpa_primitives = { package = "substrate-finality-grandpa-primitives", path = "../../../primitives/finality-grandpa" } -primitives = { package = "substrate-primitives", path = "../../../primitives/core" } -sr-primitives = { path = "../../../primitives/sr-primitives" } +authority-discovery-primitives = { package = "sp-authority-discovery", path = "../../../primitives/authority-discovery"} +babe-primitives = { package = "sp-consensus-babe", path = "../../../primitives/consensus/babe" } +grandpa_primitives = { package = "sp-finality-granpda", path = "../../../primitives/finality-grandpa" } +primitives = { package = "sp-core", path = "../../../primitives/core" } +sp-runtime = { path = "../../../primitives/sr-primitives" } sp-timestamp = { path = "../../../primitives/timestamp", default-features = false } sp-finality-tracker = { path = "../../../primitives/finality-tracker", default-features = false } -inherents = { package = "substrate-inherents", path = "../../../primitives/inherents" } -keyring = { package = "substrate-keyring", path = "../../../primitives/keyring" } -runtime-io = { package = "sr-io", path = "../../../primitives/sr-io" } +inherents = { package = "sp-inherents", path = "../../../primitives/inherents" } +keyring = { package = "sp-keyring", path = "../../../primitives/keyring" } +runtime-io = { package = "sp-io", path = "../../../primitives/sr-io" } # client dependencies -client-api = { package = "substrate-client-api", path = "../../../client/api" } -client = { package = "substrate-client", path = "../../../client/" } -chain-spec = { package = "substrate-chain-spec", path = "../../../client/chain-spec" } -txpool = { package = "sc-transaction-pool", path = "../../../client/transaction-pool" } +client-api = { package = "sc-client-api", path = "../../../client/api" } +client = { package = "sc-client", path = "../../../client/" } +chain-spec = { package = "sc-chain-spec", path = "../../../client/chain-spec" } +txpool = { package = "sc-tracing-pool", path = "../../../client/transaction-pool" } txpool-api = { package = "sp-transaction-pool-api", path = "../../../primitives/transaction-pool" } -network = { package = "substrate-network", path = "../../../client/network" } -babe = { package = "substrate-consensus-babe", path = "../../../client/consensus/babe" } -grandpa = { package = "substrate-finality-grandpa", path = "../../../client/finality-grandpa" } -client_db = { package = "substrate-client-db", path = "../../../client/db", default-features = false } -offchain = { package = "substrate-offchain", path = "../../../client/offchain" } -substrate-rpc = { package = "substrate-rpc", path = "../../../client/rpc" } -substrate-basic-authorship = { path = "../../../client/basic-authorship" } -substrate-service = { path = "../../../client/service", default-features = false } -substrate-telemetry = { package = "substrate-telemetry", path = "../../../client/telemetry" } -authority-discovery = { package = "substrate-authority-discovery", path = "../../../client/authority-discovery"} -consensus-common = { package = "substrate-consensus-common", path = "../../../primitives/consensus/common" } +network = { package = "sc-network", path = "../../../client/network" } +babe = { package = "sc-consensus-babe", path = "../../../client/consensus/babe" } +grandpa = { package = "sc-finality-grandpa", path = "../../../client/finality-grandpa" } +client_db = { package = "sc-client-db", path = "../../../client/db", default-features = false } +offchain = { package = "sc-offchain", path = "../../../client/offchain" } +sc-rpc = { package = "sc-rpc", path = "../../../client/rpc" } +sc-basic-authority = { path = "../../../client/basic-authorship" } +sc-service = { path = "../../../client/service", default-features = false } +sc-telemetry = { package = "sc-telemetry", path = "../../../client/telemetry" } +authority-discovery = { package = "sc-authority-discovery", path = "../../../client/authority-discovery"} +consensus-common = { package = "sp-consensus", path = "../../../primitives/consensus/common" } # frame dependencies indices = { package = "pallet-indices", path = "../../../frame/indices" } @@ -82,7 +82,7 @@ node-executor = { path = "../executor" } # CLI-specific dependencies tokio = { version = "0.1.22", optional = true } -substrate-cli = { path = "../../../client/cli", optional = true } +sc-cli = { path = "../../../client/cli", optional = true } transaction-factory = { path = "../../../test/utils/transaction-factory", optional = true } ctrlc = { version = "3.1.3", features = ["termination"], optional = true } @@ -98,14 +98,14 @@ kvdb-memorydb = { version = "0.1.1", optional = true } rand6 = { package = "rand", version = "0.6", features = ["wasm-bindgen"], optional = true } # Imported just for the `wasm-bindgen` feature [dev-dependencies] -keystore = { package = "substrate-keystore", path = "../../../client/keystore" } -babe = { package = "substrate-consensus-babe", path = "../../../client/consensus/babe", features = ["test-helpers"] } -service-test = { package = "substrate-service-test", path = "../../../client/service/test" } +keystore = { package = "sc-keystore", path = "../../../client/keystore" } +babe = { package = "sc-consensus-babe", path = "../../../client/consensus/babe", features = ["test-helpers"] } +service-test = { package = "sc-service-test", path = "../../../client/service/test" } futures = "0.3.1" tempfile = "3.1.0" [build-dependencies] -substrate-cli = { package = "substrate-cli", path = "../../../client/cli" } +sc-cli = { package = "sc-cli", path = "../../../client/cli" } build-script-utils = { package = "substrate-build-script-utils", path = "../../../utils/build-script-utils" } structopt = "0.3.3" vergen = "3.0.4" @@ -125,16 +125,16 @@ browser = [ "rand6" ] cli = [ - "substrate-cli", + "sc-cli", "transaction-factory", "tokio", "ctrlc", - "substrate-service/rocksdb", + "sc-service/rocksdb", "node-executor/wasmi-errno", ] wasmtime = [ "cli", "node-executor/wasmtime", - "substrate-cli/wasmtime", - "substrate-service/wasmtime", + "sc-cli/wasmtime", + "sc-service/wasmtime", ] diff --git a/bin/node/cli/bin/main.rs b/bin/node/cli/bin/main.rs index 45cf173efb..338fbd081e 100644 --- a/bin/node/cli/bin/main.rs +++ b/bin/node/cli/bin/main.rs @@ -20,13 +20,13 @@ use futures::channel::oneshot; use futures::{future, FutureExt}; -use substrate_cli::VersionInfo; +use sc_cli::VersionInfo; use std::cell::RefCell; // handles ctrl-c struct Exit; -impl substrate_cli::IntoExit for Exit { +impl sc_cli::IntoExit for Exit { type Exit = future::Map, fn(Result<(), oneshot::Canceled>) -> ()>; fn into_exit(self) -> Self::Exit { // can't use signal directly here because CtrlC takes only `Fn`. @@ -43,7 +43,7 @@ impl substrate_cli::IntoExit for Exit { } } -fn main() -> Result<(), substrate_cli::error::Error> { +fn main() -> Result<(), sc_cli::error::Error> { let version = VersionInfo { name: "Substrate Node", commit: env!("VERGEN_SHA_SHORT"), diff --git a/bin/node/cli/build.rs b/bin/node/cli/build.rs index ae936ce4fb..44bbe8c5db 100644 --- a/bin/node/cli/build.rs +++ b/bin/node/cli/build.rs @@ -16,7 +16,7 @@ use std::{fs, env, path::Path}; use structopt::{StructOpt, clap::Shell}; -use substrate_cli::{NoCustom, CoreParams}; +use sc_cli::{NoCustom, CoreParams}; use vergen::{ConstantsFlags, generate_cargo_keys}; fn main() { diff --git a/bin/node/cli/src/browser.rs b/bin/node/cli/src/browser.rs index 93df41402b..b09bb74026 100644 --- a/bin/node/cli/src/browser.rs +++ b/bin/node/cli/src/browser.rs @@ -19,7 +19,7 @@ use futures01::{prelude::*, sync::oneshot, sync::mpsc}; use libp2p::wasm_ext; use log::{debug, info}; use std::sync::Arc; -use substrate_service::{AbstractService, RpcSession, Roles as ServiceRoles, Configuration, config::DatabaseConfig}; +use sc_service::{AbstractService, RpcSession, Roles as ServiceRoles, Configuration, config::DatabaseConfig}; use wasm_bindgen::prelude::*; /// Starts the client. diff --git a/bin/node/cli/src/chain_spec.rs b/bin/node/cli/src/chain_spec.rs index 792dd237ac..51ef7590ac 100644 --- a/bin/node/cli/src/chain_spec.rs +++ b/bin/node/cli/src/chain_spec.rs @@ -26,14 +26,14 @@ use node_runtime::{ }; use node_runtime::Block; use node_runtime::constants::currency::*; -use substrate_service; +use sc_service; use hex_literal::hex; -use substrate_telemetry::TelemetryEndpoints; +use sc_telemetry::TelemetryEndpoints; use grandpa_primitives::{AuthorityId as GrandpaId}; use babe_primitives::{AuthorityId as BabeId}; use im_online::sr25519::{AuthorityId as ImOnlineId}; use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId; -use sr_primitives::{Perbill, traits::{Verify, IdentifyAccount}}; +use sp_runtime::{Perbill, traits::{Verify, IdentifyAccount}}; pub use node_primitives::{AccountId, Balance, Signature}; pub use node_runtime::GenesisConfig; @@ -53,7 +53,7 @@ pub struct Extensions { } /// Specialized `ChainSpec`. -pub type ChainSpec = substrate_service::ChainSpec< +pub type ChainSpec = sc_service::ChainSpec< GenesisConfig, Extensions, >; @@ -347,7 +347,7 @@ pub fn local_testnet_config() -> ChainSpec { pub(crate) mod tests { use super::*; use crate::service::new_full; - use substrate_service::Roles; + use sc_service::Roles; use service_test; fn local_testnet_genesis_instant_single() -> GenesisConfig { diff --git a/bin/node/cli/src/cli.rs b/bin/node/cli/src/cli.rs index 3a83c3eb76..add6eaa590 100644 --- a/bin/node/cli/src/cli.rs +++ b/bin/node/cli/src/cli.rs @@ -14,14 +14,14 @@ // You should have received a copy of the GNU General Public License // along with Substrate. If not, see . -pub use substrate_cli::VersionInfo; +pub use sc_cli::VersionInfo; use tokio::prelude::Future; use tokio::runtime::{Builder as RuntimeBuilder, Runtime}; -use substrate_cli::{IntoExit, NoCustom, SharedParams, ImportParams, error}; -use substrate_service::{AbstractService, Roles as ServiceRoles, Configuration}; +use sc_cli::{IntoExit, NoCustom, SharedParams, ImportParams, error}; +use sc_service::{AbstractService, Roles as ServiceRoles, Configuration}; use log::info; use structopt::{StructOpt, clap::App}; -use substrate_cli::{display_role, parse_and_prepare, AugmentClap, GetLogFilter, ParseAndPrepare}; +use sc_cli::{display_role, parse_and_prepare, AugmentClap, GetLogFilter, ParseAndPrepare}; use crate::{service, ChainSpec, load_spec}; use crate::factory_impl::FactoryState; use transaction_factory::RuntimeAdapter; @@ -93,7 +93,7 @@ impl AugmentClap for FactoryCmd { } /// Parse command line arguments into service configuration. -pub fn run(args: I, exit: E, version: substrate_cli::VersionInfo) -> error::Result<()> where +pub fn run(args: I, exit: E, version: sc_cli::VersionInfo) -> error::Result<()> where I: IntoIterator, T: Into + Clone, E: IntoExit, @@ -135,13 +135,13 @@ pub fn run(args: I, exit: E, version: substrate_cli::VersionInfo) -> er ParseAndPrepare::RevertChain(cmd) => cmd.run_with_builder(|config: Config<_, _>| Ok(new_full_start!(config).0), load_spec), ParseAndPrepare::CustomCommand(CustomSubcommands::Factory(cli_args)) => { - let mut config: Config<_, _> = substrate_cli::create_config_with_db_path( + let mut config: Config<_, _> = sc_cli::create_config_with_db_path( load_spec, &cli_args.shared_params, &version, )?; - substrate_cli::fill_import_params(&mut config, &cli_args.import_params, ServiceRoles::FULL)?; + sc_cli::fill_import_params(&mut config, &cli_args.import_params, ServiceRoles::FULL)?; match ChainSpec::from(config.chain_spec.id()) { Some(ref c) if c == &ChainSpec::Development || c == &ChainSpec::LocalTestnet => {}, @@ -180,7 +180,7 @@ where let (exit_send, exit) = oneshot::channel(); - let informant = substrate_cli::informant::build(&service); + let informant = sc_cli::informant::build(&service); let future = select(informant, exit) .map(|_| Ok(())) diff --git a/bin/node/cli/src/factory_impl.rs b/bin/node/cli/src/factory_impl.rs index b47710b733..5f37615b1b 100644 --- a/bin/node/cli/src/factory_impl.rs +++ b/bin/node/cli/src/factory_impl.rs @@ -29,7 +29,7 @@ use node_runtime::{ }; use node_primitives::Signature; use primitives::{sr25519, crypto::Pair}; -use sr_primitives::{ +use sp_runtime::{ generic::Era, traits::{Block as BlockT, Header as HeaderT, SignedExtension, Verify, IdentifyAccount} }; use transaction_factory::RuntimeAdapter; @@ -71,7 +71,7 @@ impl RuntimeAdapter for FactoryState { type AccountId = node_primitives::AccountId; type Balance = node_primitives::Balance; type Block = node_primitives::Block; - type Phase = sr_primitives::generic::Phase; + type Phase = sp_runtime::generic::Phase; type Secret = sr25519::Pair; type Index = node_primitives::Index; diff --git a/bin/node/cli/src/service.rs b/bin/node/cli/src/service.rs index e6e54be6be..6dd08addc6 100644 --- a/bin/node/cli/src/service.rs +++ b/bin/node/cli/src/service.rs @@ -26,16 +26,16 @@ use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider}; use node_executor; use node_primitives::Block; use node_runtime::{GenesisConfig, RuntimeApi}; -use substrate_service::{ +use sc_service::{ AbstractService, ServiceBuilder, config::Configuration, error::{Error as ServiceError}, }; use inherents::InherentDataProviders; use network::construct_simple_protocol; -use substrate_service::{Service, NetworkStatus}; +use sc_service::{Service, NetworkStatus}; use client::{Client, LocalCallExecutor}; use client_db::Backend; -use sr_primitives::traits::Block as BlockT; +use sp_runtime::traits::Block as BlockT; use node_executor::NativeExecutor; use network::NetworkService; use offchain::OffchainWorkers; @@ -52,11 +52,11 @@ construct_simple_protocol! { /// be able to perform chain operations. macro_rules! new_full_start { ($config:expr) => {{ - type RpcExtension = jsonrpc_core::IoHandler; + type RpcExtension = jsonrpc_core::IoHandler; let mut import_setup = None; let inherent_data_providers = inherents::InherentDataProviders::new(); - let builder = substrate_service::ServiceBuilder::new_full::< + let builder = sc_service::ServiceBuilder::new_full::< node_primitives::Block, node_runtime::RuntimeApi, node_executor::Executor >($config)? .with_select_chain(|_config, backend| { @@ -71,7 +71,7 @@ macro_rules! new_full_start { })? .with_import_queue(|_config, client, mut select_chain, _transaction_pool| { let select_chain = select_chain.take() - .ok_or_else(|| substrate_service::Error::SelectChainRequired)?; + .ok_or_else(|| sc_service::Error::SelectChainRequired)?; let (grandpa_block_import, grandpa_link) = grandpa::block_import( client.clone(), &*client, @@ -160,14 +160,14 @@ macro_rules! new_full { ($with_startup_data)(&block_import, &babe_link); if participates_in_consensus { - let proposer = substrate_basic_authorship::ProposerFactory { + let proposer = sc_basic_authority::ProposerFactory { client: service.client(), transaction_pool: service.transaction_pool(), }; let client = service.client(); let select_chain = service.select_chain() - .ok_or(substrate_service::Error::SelectChainRequired)?; + .ok_or(sc_service::Error::SelectChainRequired)?; let can_author_with = consensus_common::CanAuthorWithNativeVersion::new(client.executor().clone()); @@ -314,7 +314,7 @@ pub fn new_full(config: NodeConfiguration) /// Builds a new service for a light client. pub fn new_light(config: NodeConfiguration) -> Result { - type RpcExtension = jsonrpc_core::IoHandler; + type RpcExtension = jsonrpc_core::IoHandler; let inherent_data_providers = InherentDataProviders::new(); let service = ServiceBuilder::new_light::(config)? @@ -394,7 +394,7 @@ mod tests { use node_runtime::constants::{currency::CENTS, time::SLOT_DURATION}; use codec::{Encode, Decode}; use primitives::{crypto::Pair as CryptoPair, H256}; - use sr_primitives::{ + use sp_runtime::{ generic::{BlockId, Era, Digest, SignedPayload}, traits::Block as BlockT, traits::Verify, @@ -403,9 +403,9 @@ mod tests { use sp_timestamp; use sp_finality_tracker; use keyring::AccountKeyring; - use substrate_service::{AbstractService, Roles}; + use sc_service::{AbstractService, Roles}; use crate::service::new_full; - use sr_primitives::traits::IdentifyAccount; + use sp_runtime::traits::IdentifyAccount; type AccountPublic = ::Signer; @@ -518,7 +518,7 @@ mod tests { let parent_id = BlockId::number(service.client().info().chain.best_number); let parent_header = service.client().header(&parent_id).unwrap().unwrap(); - let mut proposer_factory = substrate_basic_authorship::ProposerFactory { + let mut proposer_factory = sc_basic_authority::ProposerFactory { client: service.client(), transaction_pool: service.transaction_pool(), }; diff --git a/bin/node/executor/Cargo.toml b/bin/node/executor/Cargo.toml index aad3351e91..bafe514393 100644 --- a/bin/node/executor/Cargo.toml +++ b/bin/node/executor/Cargo.toml @@ -8,18 +8,18 @@ edition = "2018" [dependencies] trie-root = "0.15.2" codec = { package = "parity-scale-codec", version = "1.0.0" } -runtime_io = { package = "sr-io", path = "../../../primitives/sr-io" } -state_machine = { package = "substrate-state-machine", path = "../../../primitives/state-machine" } -substrate-executor = { path = "../../../client/executor" } -primitives = { package = "substrate-primitives", path = "../../../primitives/core" } -trie = { package = "substrate-trie", path = "../../../primitives/trie" } +runtime_io = { package = "sp-io", path = "../../../primitives/sr-io" } +state_machine = { package = "sp-state-machine", path = "../../../primitives/state-machine" } +sc-executor = { path = "../../../client/executor" } +primitives = { package = "sp-core", path = "../../../primitives/core" } +trie = { package = "sp-trie", path = "../../../primitives/trie" } node-primitives = { path = "../primitives" } node-runtime = { path = "../runtime" } [dev-dependencies] node-testing = { path = "../testing" } test-client = { package = "substrate-test-client", path = "../../../test/utils/client" } -sr-primitives = { path = "../../../primitives/sr-primitives" } +sp-runtime = { path = "../../../primitives/sr-primitives" } runtime_support = { package = "frame-support", path = "../../../frame/support" } balances = { package = "pallet-balances", path = "../../../frame/balances" } transaction-payment = { package = "pallet-transaction-payment", path = "../../../frame/transaction-payment" } @@ -35,10 +35,10 @@ criterion = "0.3.0" [features] wasmtime = [ - "substrate-executor/wasmtime", + "sc-executor/wasmtime", ] wasmi-errno = [ - "substrate-executor/wasmi-errno", + "sc-executor/wasmi-errno", ] stress-test = [] diff --git a/bin/node/executor/benches/bench.rs b/bin/node/executor/benches/bench.rs index e72c28467f..86a9c1c672 100644 --- a/bin/node/executor/benches/bench.rs +++ b/bin/node/executor/benches/bench.rs @@ -28,7 +28,7 @@ use primitives::storage::well_known_keys; use primitives::traits::CodeExecutor; use runtime_support::Hashable; use state_machine::TestExternalities as CoreTestExternalities; -use substrate_executor::{NativeExecutor, RuntimeInfo, WasmExecutionMethod, Externalities}; +use sc_executor::{NativeExecutor, RuntimeInfo, WasmExecutionMethod, Externalities}; criterion_group!(benches, bench_execute_block); criterion_main!(benches); diff --git a/bin/node/executor/src/lib.rs b/bin/node/executor/src/lib.rs index d85ec452c7..b2410ed15e 100644 --- a/bin/node/executor/src/lib.rs +++ b/bin/node/executor/src/lib.rs @@ -17,8 +17,8 @@ //! A `CodeExecutor` specialization which uses natively compiled runtime when the wasm to be //! executed is equivalent to the natively compiled code. -pub use substrate_executor::NativeExecutor; -use substrate_executor::native_executor_instance; +pub use sc_executor::NativeExecutor; +use sc_executor::native_executor_instance; // Declare an instance of the native executor named `Executor`. Include the wasm binary as the // equivalent wasm code. @@ -30,7 +30,7 @@ native_executor_instance!( #[cfg(test)] mod tests { - use substrate_executor::error::Result; + use sc_executor::error::Result; use super::Executor; use {balances, contracts, indices, system, timestamp}; use codec::{Encode, Decode, Joiner}; @@ -44,12 +44,12 @@ mod tests { Blake2Hasher, NeverNativeValue, NativeOrEncoded, map, traits::{CodeExecutor, Externalities}, storage::well_known_keys, }; - use sr_primitives::{ + use sp_runtime::{ Fixed64, traits::{Header as HeaderT, Hash as HashT, Convert}, ApplyExtrinsicResult, transaction_validity::InvalidTransaction, }; use contracts::ContractAddressFor; - use substrate_executor::{NativeExecutor, WasmExecutionMethod}; + use sc_executor::{NativeExecutor, WasmExecutionMethod}; use system::{EventRecord, Phase}; use node_runtime::{ Header, Block, UncheckedExtrinsic, CheckedExtrinsic, Call, Runtime, Balances, BuildStorage, diff --git a/bin/node/primitives/Cargo.toml b/bin/node/primitives/Cargo.toml index 1f632dda8d..6c8d1e22ad 100644 --- a/bin/node/primitives/Cargo.toml +++ b/bin/node/primitives/Cargo.toml @@ -5,16 +5,16 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -primitives = { package = "substrate-primitives", path = "../../../primitives/core", default-features = false } -sr-primitives = { path = "../../../primitives/sr-primitives", default-features = false } +primitives = { package = "sp-core", path = "../../../primitives/core", default-features = false } +sp-runtime = { path = "../../../primitives/sr-primitives", default-features = false } [dev-dependencies] -substrate-serializer = { path = "../../../primitives/serializer" } +sp-serializer = { path = "../../../primitives/serializer" } pretty_assertions = "0.6.1" [features] default = ["std"] std = [ "primitives/std", - "sr-primitives/std", + "sp-runtime/std", ] diff --git a/bin/node/primitives/src/lib.rs b/bin/node/primitives/src/lib.rs index b6a5ec0565..eeb03a1b9b 100644 --- a/bin/node/primitives/src/lib.rs +++ b/bin/node/primitives/src/lib.rs @@ -20,7 +20,7 @@ #![cfg_attr(not(feature = "std"), no_std)] -use sr_primitives::{ +use sp_runtime::{ generic, traits::{Verify, BlakeTwo256, IdentifyAccount}, OpaqueExtrinsic, MultiSignature }; diff --git a/bin/node/rpc-client/Cargo.toml b/bin/node/rpc-client/Cargo.toml index 882dd7ee2b..5ef06beb65 100644 --- a/bin/node/rpc-client/Cargo.toml +++ b/bin/node/rpc-client/Cargo.toml @@ -11,4 +11,4 @@ hyper = "0.12.35" jsonrpc-core-client = { version = "14.0.3", features = ["http", "ws"] } log = "0.4.8" node-primitives = { path = "../primitives" } -substrate-rpc = { path = "../../../client/rpc", version = "2.0.0" } +sc-rpc = { path = "../../../client/rpc", version = "2.0.0" } diff --git a/bin/node/rpc-client/src/main.rs b/bin/node/rpc-client/src/main.rs index fe057bcbea..3874556ef6 100644 --- a/bin/node/rpc-client/src/main.rs +++ b/bin/node/rpc-client/src/main.rs @@ -24,7 +24,7 @@ use futures::Future; use hyper::rt; use node_primitives::Hash; -use substrate_rpc::author::{ +use sc_rpc::author::{ AuthorClient, hash::ExtrinsicOrHash, }; diff --git a/bin/node/rpc/Cargo.toml b/bin/node/rpc/Cargo.toml index fb571e2706..56edc94d4e 100644 --- a/bin/node/rpc/Cargo.toml +++ b/bin/node/rpc/Cargo.toml @@ -5,11 +5,11 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -client = { package = "substrate-client", path = "../../../client/" } +client = { package = "sc-client", path = "../../../client/" } jsonrpc-core = "14.0.3" node-primitives = { path = "../primitives" } node-runtime = { path = "../runtime" } -sr-primitives = { path = "../../../primitives/sr-primitives" } +sp-runtime = { path = "../../../primitives/sr-primitives" } pallet-contracts-rpc = { path = "../../../frame/contracts/rpc/" } pallet-transaction-payment-rpc = { path = "../../../frame/transaction-payment/rpc/" } substrate-frame-rpc-system = { path = "../../../utils/frame/rpc/system" } diff --git a/bin/node/rpc/src/lib.rs b/bin/node/rpc/src/lib.rs index 06b0e33606..718250d1d4 100644 --- a/bin/node/rpc/src/lib.rs +++ b/bin/node/rpc/src/lib.rs @@ -18,7 +18,7 @@ //! //! Since `substrate` core functionality makes no assumptions //! about the modules used inside the runtime, so do -//! RPC methods defined in `substrate-rpc` crate. +//! RPC methods defined in `sc-rpc` crate. //! It means that `client/rpc` can't have any methods that //! need some strong assumptions about the particular runtime. //! @@ -33,7 +33,7 @@ use std::sync::Arc; use node_primitives::{Block, AccountId, Index, Balance}; use node_runtime::UncheckedExtrinsic; -use sr_primitives::traits::ProvideRuntimeApi; +use sp_runtime::traits::ProvideRuntimeApi; use txpool_api::TransactionPool; /// Light client extra dependencies. diff --git a/bin/node/runtime/Cargo.toml b/bin/node/runtime/Cargo.toml index c24e4eb4d0..18e307c55b 100644 --- a/bin/node/runtime/Cargo.toml +++ b/bin/node/runtime/Cargo.toml @@ -14,21 +14,21 @@ rustc-hex = { version = "2.0", optional = true } serde = { version = "1.0.102", optional = true } # primitives -authority-discovery-primitives = { package = "substrate-authority-discovery-primitives", path = "../../../primitives/authority-discovery", default-features = false } -babe-primitives = { package = "substrate-consensus-babe-primitives", path = "../../../primitives/consensus/babe", default-features = false } -block-builder-api = { package = "substrate-block-builder-runtime-api", path = "../../../primitives/block-builder/runtime-api", default-features = false} -inherents = { package = "substrate-inherents", path = "../../../primitives/inherents", default-features = false } +authority-discovery-primitives = { package = "sp-authority-discovery", path = "../../../primitives/authority-discovery", default-features = false } +babe-primitives = { package = "sp-consensus-babe", path = "../../../primitives/consensus/babe", default-features = false } +block-builder-api = { package = "sp-block-builder", path = "../../../primitives/block-builder/runtime-api", default-features = false} +inherents = { package = "sp-inherents", path = "../../../primitives/inherents", default-features = false } node-primitives = { path = "../primitives", default-features = false } -offchain-primitives = { package = "substrate-offchain-primitives", path = "../../../primitives/offchain", default-features = false } -primitives = { package = "substrate-primitives", path = "../../../primitives/core", default-features = false } -rstd = { package = "sr-std", path = "../../../primitives/sr-std", default-features = false } -sr-api = { path = "../../../primitives/sr-api", default-features = false } -sr-primitives = { path = "../../../primitives/sr-primitives", default-features = false } -sr-staking-primitives = { path = "../../../primitives/sr-staking-primitives", default-features = false } -substrate-keyring = { path = "../../../primitives/keyring", optional = true } -substrate-session = { path = "../../../primitives/session", default-features = false } +offchain-primitives = { package = "sp-offchain", path = "../../../primitives/offchain", default-features = false } +primitives = { package = "sp-core", path = "../../../primitives/core", default-features = false } +rstd = { package = "sp-std", path = "../../../primitives/sr-std", default-features = false } +sp-api = { path = "../../../primitives/sr-api", default-features = false } +sp-runtime = { path = "../../../primitives/sr-primitives", default-features = false } +sp-staking = { path = "../../../primitives/sr-staking-primitives", default-features = false } +sp-keyring = { path = "../../../primitives/keyring", optional = true } +sp-sesssion = { path = "../../../primitives/session", default-features = false } txpool-runtime-api = { package = "sp-transaction-pool-runtime-api", path = "../../../primitives/transaction-pool/runtime-api", default-features = false } -version = { package = "sr-version", path = "../../../primitives/sr-version", default-features = false } +version = { package = "sp-version", path = "../../../primitives/sr-version", default-features = false } # frame dependencies authority-discovery = { package = "pallet-authority-discovery", path = "../../../frame/authority-discovery", default-features = false } @@ -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 = "sr-io", path = "../../../primitives/sr-io" } +runtime_io = { package = "sp-io", path = "../../../primitives/sr-io" } [features] default = ["std"] @@ -102,12 +102,12 @@ std = [ "safe-mix/std", "serde", "session/std", - "sr-api/std", - "sr-primitives/std", - "sr-staking-primitives/std", + "sp-api/std", + "sp-runtime/std", + "sp-staking/std", "staking/std", - "substrate-keyring", - "substrate-session/std", + "sp-keyring", + "sp-sesssion/std", "sudo/std", "support/std", "system-rpc-runtime-api/std", diff --git a/bin/node/runtime/src/impls.rs b/bin/node/runtime/src/impls.rs index 1b9006e75e..a4547aa07b 100644 --- a/bin/node/runtime/src/impls.rs +++ b/bin/node/runtime/src/impls.rs @@ -17,8 +17,8 @@ //! Some configurable implementations as associated type for the substrate runtime. use node_primitives::Balance; -use sr_primitives::traits::{Convert, Saturating}; -use sr_primitives::{Fixed64, Perbill}; +use sp_runtime::traits::{Convert, Saturating}; +use sp_runtime::{Fixed64, Perbill}; use support::{traits::{OnUnbalanced, Currency, Get}, weights::Weight}; use crate::{Balances, System, Authorship, MaximumBlockWeight, NegativeImbalance}; @@ -115,7 +115,7 @@ impl> Convert for TargetedFeeAdjustment { #[cfg(test)] mod tests { use super::*; - use sr_primitives::assert_eq_error_rate; + use sp_runtime::assert_eq_error_rate; use crate::{MaximumBlockWeight, AvailableBlockRatio, Runtime}; use crate::{constants::currency::*, TransactionPayment, TargetBlockFullness}; use support::weights::Weight; diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 366f884735..90085ce801 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -28,11 +28,11 @@ use support::{ }; use primitives::u32_trait::{_1, _2, _3, _4}; use node_primitives::{AccountId, AccountIndex, Balance, BlockNumber, Hash, Index, Moment, Signature}; -use sr_api::impl_runtime_apis; -use sr_primitives::{Permill, Perbill, ApplyExtrinsicResult, impl_opaque_keys, generic, create_runtime_str}; -use sr_primitives::curve::PiecewiseLinear; -use sr_primitives::transaction_validity::TransactionValidity; -use sr_primitives::traits::{ +use sp_api::impl_runtime_apis; +use sp_runtime::{Permill, Perbill, ApplyExtrinsicResult, impl_opaque_keys, generic, create_runtime_str}; +use sp_runtime::curve::PiecewiseLinear; +use sp_runtime::transaction_validity::TransactionValidity; +use sp_runtime::traits::{ self, BlakeTwo256, Block as BlockT, NumberFor, StaticLookup, SaturatedConversion, OpaqueKeys, }; @@ -50,7 +50,7 @@ use system::offchain::TransactionSubmitter; use inherents::{InherentData, CheckInherentsResult}; #[cfg(any(feature = "std", test))] -pub use sr_primitives::BuildStorage; +pub use sp_runtime::BuildStorage; pub use timestamp::Call as TimestampCall; pub use balances::Call as BalancesCall; pub use contracts::Gas; @@ -248,7 +248,7 @@ pallet_staking_reward_curve::build! { } parameter_types! { - pub const SessionsPerEra: sr_staking_primitives::SessionIndex = 6; + pub const SessionsPerEra: sp_staking::SessionIndex = 6; pub const BondingDuration: staking::EraIndex = 24 * 28; pub const SlashDeferDuration: staking::EraIndex = 24 * 7; // 1/4 the bonding duration. pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE; @@ -571,7 +571,7 @@ pub type CheckedExtrinsic = generic::CheckedExtrinsic, Runtime, AllModules>; impl_runtime_apis! { - impl sr_api::Core for Runtime { + impl sp_api::Core for Runtime { fn version() -> RuntimeVersion { VERSION } @@ -585,7 +585,7 @@ impl_runtime_apis! { } } - impl sr_api::Metadata for Runtime { + impl sp_api::Metadata for Runtime { fn metadata() -> OpaqueMetadata { Runtime::metadata().into() } @@ -711,7 +711,7 @@ impl_runtime_apis! { } } - impl substrate_session::SessionKeys for Runtime { + impl sp_sesssion::SessionKeys for Runtime { fn generate_session_keys(seed: Option>) -> Vec { SessionKeys::generate(seed) } diff --git a/bin/node/testing/Cargo.toml b/bin/node/testing/Cargo.toml index 2bfdd58a65..4bbf14972d 100644 --- a/bin/node/testing/Cargo.toml +++ b/bin/node/testing/Cargo.toml @@ -7,22 +7,22 @@ edition = "2018" [dependencies] balances = { package = "pallet-balances", path = "../../../frame/balances" } -client = { package = "substrate-client", path = "../../../client/" } +client = { package = "sc-client", path = "../../../client/" } codec = { package = "parity-scale-codec", version = "1.0.0" } contracts = { package = "pallet-contracts", path = "../../../frame/contracts" } grandpa = { package = "pallet-grandpa", path = "../../../frame/grandpa" } indices = { package = "pallet-indices", path = "../../../frame/indices" } -keyring = { package = "substrate-keyring", path = "../../../primitives/keyring" } +keyring = { package = "sp-keyring", path = "../../../primitives/keyring" } node-executor = { path = "../executor" } node-primitives = { path = "../primitives" } node-runtime = { path = "../runtime" } -primitives = { package = "substrate-primitives", path = "../../../primitives/core" } -runtime-io = { package = "sr-io", path = "../../../primitives/sr-io" } +primitives = { package = "sp-core", path = "../../../primitives/core" } +runtime-io = { package = "sp-io", path = "../../../primitives/sr-io" } runtime_support = { package = "frame-support", path = "../../../frame/support" } session = { package = "pallet-session", path = "../../../frame/session" } -sr-primitives = { path = "../../../primitives/sr-primitives" } +sp-runtime = { path = "../../../primitives/sr-primitives" } staking = { package = "pallet-staking", path = "../../../frame/staking" } -substrate-executor = { path = "../../../client/executor" } +sc-executor = { path = "../../../client/executor" } system = { package = "frame-system", path = "../../../frame/system" } test-client = { package = "substrate-test-client", path = "../../../test/utils/client" } timestamp = { package = "pallet-timestamp", path = "../../../frame/timestamp" } diff --git a/bin/node/testing/src/client.rs b/bin/node/testing/src/client.rs index 3b16f2cbcb..b865a407fa 100644 --- a/bin/node/testing/src/client.rs +++ b/bin/node/testing/src/client.rs @@ -16,13 +16,13 @@ //! Utilites to build a `TestClient` for `node-runtime`. -use sr_primitives::BuildStorage; +use sp_runtime::BuildStorage; /// Re-export test-client utilities. pub use test_client::*; /// Call executor for `node-runtime` `TestClient`. -pub type Executor = substrate_executor::NativeExecutor; +pub type Executor = sc_executor::NativeExecutor; /// Default backend type. pub type Backend = client_db::Backend; diff --git a/bin/node/testing/src/genesis.rs b/bin/node/testing/src/genesis.rs index 1531ba1348..dae5c2c4a4 100644 --- a/bin/node/testing/src/genesis.rs +++ b/bin/node/testing/src/genesis.rs @@ -24,7 +24,7 @@ use node_runtime::{ }; use node_runtime::constants::currency::*; use primitives::ChangesTrieConfiguration; -use sr_primitives::Perbill; +use sp_runtime::Perbill; /// Create genesis runtime configuration for tests. diff --git a/bin/node/testing/src/keyring.rs b/bin/node/testing/src/keyring.rs index 9c4f11fcf3..620c26578a 100644 --- a/bin/node/testing/src/keyring.rs +++ b/bin/node/testing/src/keyring.rs @@ -19,7 +19,7 @@ use keyring::{AccountKeyring, Sr25519Keyring, Ed25519Keyring}; use node_primitives::{AccountId, Balance, Index}; use node_runtime::{CheckedExtrinsic, UncheckedExtrinsic, SessionKeys, SignedExtra}; -use sr_primitives::generic::Era; +use sp_runtime::generic::Era; use codec::Encode; /// Alice's account id. diff --git a/bin/subkey/Cargo.toml b/bin/subkey/Cargo.toml index c7edb4f397..19290b3ccc 100644 --- a/bin/subkey/Cargo.toml +++ b/bin/subkey/Cargo.toml @@ -5,10 +5,10 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -primitives = { package = "substrate-primitives", version = "*", path = "../../primitives/core" } +primitives = { package = "sp-core", version = "*", path = "../../primitives/core" } node-runtime = { version = "*", path = "../node/runtime" } node-primitives = { version = "*", path = "../node/primitives" } -sr-primitives = { version = "*", path = "../../primitives/sr-primitives" } +sp-runtime = { version = "*", path = "../../primitives/sr-primitives" } rand = "0.7.2" clap = "2.33.0" tiny-bip39 = "0.6.2" diff --git a/bin/subkey/src/main.rs b/bin/subkey/src/main.rs index b1dce36314..d0babc5802 100644 --- a/bin/subkey/src/main.rs +++ b/bin/subkey/src/main.rs @@ -28,7 +28,7 @@ use primitives::{ crypto::{set_default_ss58_version, Ss58AddressFormat, Ss58Codec}, ed25519, sr25519, ecdsa, Pair, Public, H256, hexdisplay::HexDisplay, }; -use sr_primitives::{traits::{IdentifyAccount, Verify}, generic::Era}; +use sp_runtime::{traits::{IdentifyAccount, Verify}, generic::Era}; use std::{ convert::{TryInto, TryFrom}, io::{stdin, Read}, diff --git a/client/Cargo.toml b/client/Cargo.toml index 7dadb1f847..13a98b7f80 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -1,41 +1,41 @@ [package] -name = "substrate-client" +name = "sc-client" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" [dependencies] -block-builder = { package = "substrate-block-builder", path = "block-builder" } -client-api = { package = "substrate-client-api", path = "api" } +block-builder = { package = "sc-block-builder", path = "block-builder" } +client-api = { package = "sc-client-api", path = "api" } codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } -consensus = { package = "substrate-consensus-common", path = "../primitives/consensus/common" } +consensus = { package = "sp-consensus", path = "../primitives/consensus/common" } derive_more = { version = "0.99.2" } -executor = { package = "substrate-executor", path = "executor" } -externalities = { package = "substrate-externalities", path = "../primitives/externalities" } +executor = { package = "sc-executor", path = "executor" } +externalities = { package = "sp-externalities", path = "../primitives/externalities" } fnv = { version = "1.0.6" } futures = { version = "0.3.1", features = ["compat"] } hash-db = { version = "0.15.2" } hex-literal = { version = "0.2.1" } -inherents = { package = "substrate-inherents", path = "../primitives/inherents" } -keyring = { package = "substrate-keyring", path = "../primitives/keyring" } +inherents = { package = "sp-inherents", path = "../primitives/inherents" } +keyring = { package = "sp-keyring", path = "../primitives/keyring" } kvdb = "0.1.1" log = { version = "0.4.8" } parking_lot = { version = "0.9.0" } -primitives = { package = "substrate-primitives", path = "../primitives/core" } -rstd = { package = "sr-std", path = "../primitives/sr-std" } -runtime-version = { package = "sr-version", path = "../primitives/sr-version" } -sr-api = { path = "../primitives/sr-api" } -sr-primitives = { path = "../primitives/sr-primitives" } +primitives = { package = "sp-core", path = "../primitives/core" } +rstd = { package = "sp-std", path = "../primitives/sr-std" } +runtime-version = { package = "sp-version", path = "../primitives/sr-version" } +sp-api = { path = "../primitives/sr-api" } +sp-runtime = { path = "../primitives/sr-primitives" } sp-blockchain = { path = "../primitives/blockchain" } -state-machine = { package = "substrate-state-machine", path = "../primitives/state-machine" } -substrate-telemetry = { path = "telemetry" } -trie = { package = "substrate-trie", path = "../primitives/trie" } +state-machine = { package = "sp-state-machine", path = "../primitives/state-machine" } +sc-telemetry = { path = "telemetry" } +trie = { package = "sp-trie", path = "../primitives/trie" } tracing = "0.1.10" [dev-dependencies] env_logger = "0.7.0" tempfile = "3.1.0" -client-db = { package = "substrate-client-db", path = "./db", features = ["kvdb-rocksdb"] } +client-db = { package = "sc-client-db", path = "./db", features = ["kvdb-rocksdb"] } test-client = { package = "substrate-test-runtime-client", path = "../test/utils/runtime/client" } kvdb-memorydb = "0.1.2" -panic-handler = { package = "substrate-panic-handler", path = "../primitives/panic-handler" } +panic-handler = { package = "sp-panic-handler", path = "../primitives/panic-handler" } diff --git a/client/api/Cargo.toml b/client/api/Cargo.toml index 90fab81ba9..38fe13cda2 100644 --- a/client/api/Cargo.toml +++ b/client/api/Cargo.toml @@ -1,42 +1,42 @@ [package] -name = "substrate-client-api" +name = "sc-client-api" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" [dependencies] -block-builder = { package = "substrate-block-builder", path = "../block-builder" } +block-builder = { package = "sc-block-builder", path = "../block-builder" } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -consensus = { package = "substrate-consensus-common", path = "../../primitives/consensus/common" } +consensus = { package = "sp-consensus", path = "../../primitives/consensus/common" } derive_more = { version = "0.99.2" } -executor = { package = "substrate-executor", path = "../executor" } -externalities = { package = "substrate-externalities", path = "../../primitives/externalities" } +executor = { package = "sc-executor", path = "../executor" } +externalities = { package = "sp-externalities", path = "../../primitives/externalities" } fnv = { version = "1.0.6" } futures = { version = "0.3.1" } hash-db = { version = "0.15.2", default-features = false } sp-blockchain = { path = "../../primitives/blockchain" } hex-literal = { version = "0.2.1" } -inherents = { package = "substrate-inherents", path = "../../primitives/inherents", default-features = false } -keyring = { package = "substrate-keyring", path = "../../primitives/keyring" } +inherents = { package = "sp-inherents", path = "../../primitives/inherents", default-features = false } +keyring = { package = "sp-keyring", path = "../../primitives/keyring" } kvdb = "0.1.1" log = { version = "0.4.8" } parking_lot = { version = "0.9.0" } -primitives = { package = "substrate-primitives", path = "../../primitives/core", default-features = false } -rstd = { package = "sr-std", path = "../../primitives/sr-std", default-features = false } -runtime-version = { package = "sr-version", path = "../../primitives/sr-version", default-features = false } -sr-api = { path = "../../primitives/sr-api" } -sr-primitives = { path = "../../primitives/sr-primitives", default-features = false } -state-machine = { package = "substrate-state-machine", path = "../../primitives/state-machine" } -substrate-telemetry = { path = "../telemetry" } -trie = { package = "substrate-trie", path = "../../primitives/trie" } +primitives = { package = "sp-core", path = "../../primitives/core", default-features = false } +rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +runtime-version = { package = "sp-version", path = "../../primitives/sr-version", default-features = false } +sp-api = { path = "../../primitives/sr-api" } +sp-runtime = { path = "../../primitives/sr-primitives", default-features = false } +state-machine = { package = "sp-state-machine", path = "../../primitives/state-machine" } +sc-telemetry = { path = "../telemetry" } +trie = { package = "sp-trie", path = "../../primitives/trie" } txpool-api = { package = "sp-transaction-pool-api", path = "../../primitives/transaction-pool" } [dev-dependencies] env_logger = "0.7.0" tempfile = "3.1.0" -client-db = { package = "substrate-client-db", path = ".././db", features = ["kvdb-rocksdb"] } +client-db = { package = "sc-client-db", path = ".././db", features = ["kvdb-rocksdb"] } test-primitives = { package = "substrate-test-primitives", path = "../../test/utils/primitives" } test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client" } kvdb-memorydb = "0.1.2" -panic-handler = { package = "substrate-panic-handler", path = "../../primitives/panic-handler" } +panic-handler = { package = "sp-panic-handler", path = "../../primitives/panic-handler" } diff --git a/client/api/src/backend.rs b/client/api/src/backend.rs index 220aede2f5..488cab6bb0 100644 --- a/client/api/src/backend.rs +++ b/client/api/src/backend.rs @@ -20,8 +20,8 @@ use std::sync::Arc; use std::collections::HashMap; use primitives::ChangesTrieConfiguration; use primitives::offchain::OffchainStorage; -use sr_primitives::{generic::BlockId, Justification, StorageOverlay, ChildrenStorageOverlay}; -use sr_primitives::traits::{Block as BlockT, NumberFor}; +use sp_runtime::{generic::BlockId, Justification, StorageOverlay, ChildrenStorageOverlay}; +use sp_runtime::traits::{Block as BlockT, NumberFor}; use state_machine::backend::Backend as StateBackend; use state_machine::{ChangesTrieStorage as StateChangesTrieStorage, ChangesTrieTransaction}; use crate::{ diff --git a/client/api/src/call_executor.rs b/client/api/src/call_executor.rs index 11a18d2e01..8bd4bb9015 100644 --- a/client/api/src/call_executor.rs +++ b/client/api/src/call_executor.rs @@ -18,7 +18,7 @@ use std::{cmp::Ord, panic::UnwindSafe, result, cell::RefCell}; use codec::{Encode, Decode}; -use sr_primitives::{ +use sp_runtime::{ generic::BlockId, traits::Block as BlockT, traits::NumberFor, }; use state_machine::{ @@ -30,7 +30,7 @@ use externalities::Extensions; use hash_db::Hasher; use primitives::{Blake2Hasher, NativeOrEncoded}; -use sr_api::{ProofRecorder, InitializeBlock}; +use sp_api::{ProofRecorder, InitializeBlock}; use sp_blockchain; /// Method call executor. diff --git a/client/api/src/client.rs b/client/api/src/client.rs index 73ce4f1080..d053e11732 100644 --- a/client/api/src/client.rs +++ b/client/api/src/client.rs @@ -19,7 +19,7 @@ use std::collections::HashMap; use futures::channel::mpsc; use primitives::storage::StorageKey; -use sr_primitives::{ +use sp_runtime::{ traits::{Block as BlockT, NumberFor}, generic::BlockId }; diff --git a/client/api/src/execution_extensions.rs b/client/api/src/execution_extensions.rs index 94ce6c573e..3e0cf44b84 100644 --- a/client/api/src/execution_extensions.rs +++ b/client/api/src/execution_extensions.rs @@ -27,7 +27,7 @@ use primitives::{ offchain::{self, OffchainExt, TransactionPoolExt}, traits::{BareCryptoStorePtr, KeystoreExt}, }; -use sr_primitives::{ +use sp_runtime::{ generic::BlockId, traits, }; diff --git a/client/api/src/lib.rs b/client/api/src/lib.rs index 97d7fb2a02..ab2f521df2 100644 --- a/client/api/src/lib.rs +++ b/client/api/src/lib.rs @@ -39,7 +39,7 @@ pub use state_machine::{StorageProof, ExecutionStrategy}; pub mod utils { use sp_blockchain::{HeaderBackend, HeaderMetadata, Error}; use primitives::H256; - use sr_primitives::traits::{Block as BlockT}; + use sp_runtime::traits::{Block as BlockT}; use std::borrow::Borrow; /// Returns a function for checking block ancestry, the returned function will diff --git a/client/api/src/light.rs b/client/api/src/light.rs index 56a18dcc1f..c368fdd108 100644 --- a/client/api/src/light.rs +++ b/client/api/src/light.rs @@ -20,7 +20,7 @@ use std::sync::Arc; use std::collections::{BTreeMap, HashMap}; use std::future::Future; -use sr_primitives::{ +use sp_runtime::{ traits::{ Block as BlockT, Header as HeaderT, NumberFor, }, diff --git a/client/api/src/notifications.rs b/client/api/src/notifications.rs index 0ddc4c72cd..1706f07b96 100644 --- a/client/api/src/notifications.rs +++ b/client/api/src/notifications.rs @@ -24,7 +24,7 @@ use std::{ use fnv::{FnvHashSet, FnvHashMap}; use futures::channel::mpsc; use primitives::storage::{StorageKey, StorageData}; -use sr_primitives::traits::Block as BlockT; +use sp_runtime::traits::Block as BlockT; /// Storage change set #[derive(Debug)] @@ -307,7 +307,7 @@ impl StorageNotifications { #[cfg(test)] mod tests { - use sr_primitives::testing::{H256 as Hash, Block as RawBlock, ExtrinsicWrapper}; + use sp_runtime::testing::{H256 as Hash, Block as RawBlock, ExtrinsicWrapper}; use super::*; use std::iter::{empty, Empty}; diff --git a/client/authority-discovery/Cargo.toml b/client/authority-discovery/Cargo.toml index 81cf48a720..0b1dad3744 100644 --- a/client/authority-discovery/Cargo.toml +++ b/client/authority-discovery/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "substrate-authority-discovery" +name = "sc-authority-discovery" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" @@ -9,25 +9,25 @@ build = "build.rs" prost-build = "0.5.0" [dependencies] -authority-discovery-primitives = { package = "substrate-authority-discovery-primitives", path = "../../primitives/authority-discovery" } +authority-discovery-primitives = { package = "sp-authority-discovery", path = "../../primitives/authority-discovery" } bytes = "0.4.12" -client-api = { package = "substrate-client-api", path = "../api" } +client-api = { package = "sc-client-api", path = "../api" } codec = { package = "parity-scale-codec", default-features = false, version = "1.0.3" } derive_more = "0.99.2" futures = "0.3.1" futures-timer = "2.0" -keystore = { package = "substrate-keystore", path = "../keystore" } +keystore = { package = "sc-keystore", path = "../keystore" } libp2p = { version = "0.13.0", default-features = false, features = ["secp256k1", "libp2p-websocket"] } log = "0.4.8" -network = { package = "substrate-network", path = "../network" } -primitives = { package = "substrate-primitives", path = "../../primitives/core" } +network = { package = "sc-network", path = "../network" } +primitives = { package = "sp-core", path = "../../primitives/core" } sp-blockchain = { path = "../../primitives/blockchain" } prost = "0.5.0" serde_json = "1.0.41" -sr-primitives = { path = "../../primitives/sr-primitives" } +sp-runtime = { path = "../../primitives/sr-primitives" } [dev-dependencies] parking_lot = "0.9.0" -peerset = { package = "substrate-peerset", path = "../peerset" } +peerset = { package = "sc-peerset", path = "../peerset" } test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client" } -sr-api = { path = "../../primitives/sr-api" } +sp-api = { path = "../../primitives/sr-api" } diff --git a/client/authority-discovery/src/lib.rs b/client/authority-discovery/src/lib.rs index f404ad3c43..cd43623730 100644 --- a/client/authority-discovery/src/lib.rs +++ b/client/authority-discovery/src/lib.rs @@ -64,8 +64,8 @@ use network::{DhtEvent, ExHashT}; use primitives::crypto::{key_types, Pair}; use primitives::traits::BareCryptoStorePtr; use prost::Message; -use sr_primitives::generic::BlockId; -use sr_primitives::traits::{Block as BlockT, ProvideRuntimeApi}; +use sp_runtime::generic::BlockId; +use sp_runtime::traits::{Block as BlockT, ProvideRuntimeApi}; type Interval = Box + Unpin + Send + Sync>; @@ -472,13 +472,13 @@ fn interval_at(start: Instant, duration: Duration) -> Interval { #[cfg(test)] mod tests { use super::*; - use sr_api::{ApiExt, Core, RuntimeVersion, StorageProof}; + use sp_api::{ApiExt, Core, RuntimeVersion, StorageProof}; use futures::channel::mpsc::channel; use futures::executor::block_on; use futures::future::poll_fn; use primitives::{ExecutionContext, NativeOrEncoded, testing::KeyStore}; - use sr_primitives::traits::Zero; - use sr_primitives::traits::{ApiRef, Block as BlockT, NumberFor, ProvideRuntimeApi}; + use sp_runtime::traits::Zero; + use sp_runtime::traits::{ApiRef, Block as BlockT, NumberFor, ProvideRuntimeApi}; use std::sync::{Arc, Mutex}; use test_client::runtime::Block; diff --git a/client/basic-authorship/Cargo.toml b/client/basic-authorship/Cargo.toml index c284f4b2ee..ba61625516 100644 --- a/client/basic-authorship/Cargo.toml +++ b/client/basic-authorship/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "substrate-basic-authorship" +name = "sc-basic-authority" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" @@ -8,19 +8,19 @@ edition = "2018" log = "0.4.8" futures = "0.3.1" codec = { package = "parity-scale-codec", version = "1.0.0" } -sr-primitives = { path = "../../primitives/sr-primitives" } -primitives = { package = "substrate-primitives", path = "../../primitives/core" } +sp-runtime = { path = "../../primitives/sr-primitives" } +primitives = { package = "sp-core", path = "../../primitives/core" } sp-blockchain = { path = "../../primitives/blockchain" } -client = { package = "substrate-client", path = "../" } -client-api = { package = "substrate-client-api", path = "../api" } -consensus_common = { package = "substrate-consensus-common", path = "../../primitives/consensus/common" } -inherents = { package = "substrate-inherents", path = "../../primitives/inherents" } -substrate-telemetry = { path = "../telemetry" } +client = { package = "sc-client", path = "../" } +client-api = { package = "sc-client-api", path = "../api" } +consensus_common = { package = "sp-consensus", path = "../../primitives/consensus/common" } +inherents = { package = "sp-inherents", path = "../../primitives/inherents" } +sc-telemetry = { path = "../telemetry" } txpool-api = { package = "sp-transaction-pool-api", path = "../../primitives/transaction-pool" } -block-builder = { package = "substrate-block-builder", path = "../block-builder" } +block-builder = { package = "sc-block-builder", path = "../block-builder" } tokio-executor = { version = "0.2.0-alpha.6", features = ["blocking"] } [dev-dependencies] -txpool = { package = "sc-transaction-pool", path = "../../client/transaction-pool" } +txpool = { package = "sc-tracing-pool", path = "../../client/transaction-pool" } test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client" } parking_lot = "0.9" diff --git a/client/basic-authorship/src/basic_authorship.rs b/client/basic-authorship/src/basic_authorship.rs index abffe8ee40..131a4e9f2d 100644 --- a/client/basic-authorship/src/basic_authorship.rs +++ b/client/basic-authorship/src/basic_authorship.rs @@ -16,7 +16,7 @@ //! A consensus proposer for "basic" chains which use the primitive inherent-data. -// FIXME #1021 move this into substrate-consensus-common +// FIXME #1021 move this into sp-consensus use std::{time, sync::Arc}; use client_api::CallExecutor; @@ -27,14 +27,14 @@ use consensus_common::{evaluation}; use inherents::InherentData; use log::{error, info, debug, trace}; use primitives::{H256, Blake2Hasher, ExecutionContext}; -use sr_primitives::{ +use sp_runtime::{ traits::{ Block as BlockT, Hash as HashT, Header as HeaderT, ProvideRuntimeApi, DigestFor, BlakeTwo256 }, generic::BlockId, }; use txpool_api::{TransactionPool, InPoolTransaction}; -use substrate_telemetry::{telemetry, CONSENSUS_INFO}; +use sc_telemetry::{telemetry, CONSENSUS_INFO}; use block_builder::BlockBuilderApi; /// Proposer factory. diff --git a/client/basic-authorship/src/lib.rs b/client/basic-authorship/src/lib.rs index de4a8af93b..f27ce9cb52 100644 --- a/client/basic-authorship/src/lib.rs +++ b/client/basic-authorship/src/lib.rs @@ -19,9 +19,9 @@ //! # Example //! //! ``` -//! # use substrate_basic_authorship::ProposerFactory; +//! # use sc_basic_authority::ProposerFactory; //! # use consensus_common::{Environment, Proposer}; -//! # use sr_primitives::generic::BlockId; +//! # use sp_runtime::generic::BlockId; //! # use std::{sync::Arc, time::Duration}; //! # use test_client::{self, runtime::{Extrinsic, Transfer}, AccountKeyring}; //! # use txpool::{BasicPool, FullChainApi}; diff --git a/client/block-builder/Cargo.toml b/client/block-builder/Cargo.toml index 7b39643aa5..1854d499fb 100644 --- a/client/block-builder/Cargo.toml +++ b/client/block-builder/Cargo.toml @@ -1,15 +1,15 @@ [package] -name = "substrate-block-builder" +name = "sc-block-builder" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" [dependencies] -state-machine = { package = "substrate-state-machine", path = "../../primitives/state-machine" } -sr-primitives = { path = "../../primitives/sr-primitives" } +state-machine = { package = "sp-state-machine", path = "../../primitives/state-machine" } +sp-runtime = { path = "../../primitives/sr-primitives" } sp-blockchain = { path = "../../primitives/blockchain" } -primitives = { package = "substrate-primitives", path = "../../primitives/core" } +primitives = { package = "sp-core", path = "../../primitives/core" } codec = { package = "parity-scale-codec", version = "1.0.6", features = ["derive"] } -runtime_api = { package = "substrate-block-builder-runtime-api", path = "../../primitives/block-builder/runtime-api" } -sr-api = { path = "../../primitives/sr-api" } +runtime_api = { package = "sp-block-builder", path = "../../primitives/block-builder/runtime-api" } +sp-api = { path = "../../primitives/sr-api" } diff --git a/client/block-builder/src/lib.rs b/client/block-builder/src/lib.rs index 6978473645..c378bede38 100644 --- a/client/block-builder/src/lib.rs +++ b/client/block-builder/src/lib.rs @@ -26,7 +26,7 @@ use codec::Encode; -use sr_primitives::{ +use sp_runtime::{ generic::BlockId, traits::{ Header as HeaderT, Hash, Block as BlockT, HashFor, ProvideRuntimeApi, ApiRef, DigestFor, @@ -36,7 +36,7 @@ use sr_primitives::{ use sp_blockchain::{ApplyExtrinsicFailed, Error}; use primitives::ExecutionContext; use state_machine::StorageProof; -use sr_api::{Core, ApiExt, ApiErrorFor}; +use sp_api::{Core, ApiExt, ApiErrorFor}; pub use runtime_api::BlockBuilder as BlockBuilderApi; diff --git a/client/chain-spec/Cargo.toml b/client/chain-spec/Cargo.toml index da9543e398..3e67a6cd48 100644 --- a/client/chain-spec/Cargo.toml +++ b/client/chain-spec/Cargo.toml @@ -1,15 +1,15 @@ [package] -name = "substrate-chain-spec" +name = "sc-chain-spec" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" [dependencies] -substrate-chain-spec-derive = { path = "./derive" } +sc-chain-spec-derive = { path = "./derive" } impl-trait-for-tuples = "0.1.3" -network = { package = "substrate-network", path = "../network" } -primitives = { package = "substrate-primitives", path = "../../primitives/core" } +network = { package = "sc-network", path = "../network" } +primitives = { package = "sp-core", path = "../../primitives/core" } serde = { version = "1.0.101", features = ["derive"] } serde_json = "1.0.41" -sr-primitives = { path = "../../primitives/sr-primitives" } -tel = { package = "substrate-telemetry", path = "../telemetry" } +sp-runtime = { path = "../../primitives/sr-primitives" } +tel = { package = "sc-telemetry", path = "../telemetry" } diff --git a/client/chain-spec/derive/Cargo.toml b/client/chain-spec/derive/Cargo.toml index 9fb8eabc60..1086440664 100644 --- a/client/chain-spec/derive/Cargo.toml +++ b/client/chain-spec/derive/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "substrate-chain-spec-derive" +name = "sc-chain-spec-derive" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" diff --git a/client/chain-spec/derive/src/impls.rs b/client/chain-spec/derive/src/impls.rs index cdc27aef0b..fb16823151 100644 --- a/client/chain-spec/derive/src/impls.rs +++ b/client/chain-spec/derive/src/impls.rs @@ -19,7 +19,7 @@ use quote::quote; use syn::{DeriveInput, Ident, Error}; use proc_macro_crate::crate_name; -const CRATE_NAME: &str = "substrate-chain-spec"; +const CRATE_NAME: &str = "sc-chain-spec"; const ATTRIBUTE_NAME: &str = "forks"; /// Implements `Extension's` `Group` accessor. diff --git a/client/chain-spec/src/chain_spec.rs b/client/chain-spec/src/chain_spec.rs index 0f69654b9e..2ebd814c03 100644 --- a/client/chain-spec/src/chain_spec.rs +++ b/client/chain-spec/src/chain_spec.rs @@ -23,7 +23,7 @@ use std::path::PathBuf; use std::rc::Rc; use serde::{Serialize, Deserialize}; use primitives::storage::{StorageKey, StorageData}; -use sr_primitives::{BuildStorage, StorageOverlay, ChildrenStorageOverlay}; +use sp_runtime::{BuildStorage, StorageOverlay, ChildrenStorageOverlay}; use serde_json as json; use crate::RuntimeGenesis; use network::Multiaddr; diff --git a/client/chain-spec/src/extension.rs b/client/chain-spec/src/extension.rs index 6b99928160..8a42408fba 100644 --- a/client/chain-spec/src/extension.rs +++ b/client/chain-spec/src/extension.rs @@ -253,9 +253,9 @@ impl Extension for Forks where #[cfg(test)] mod tests { use super::*; - use substrate_chain_spec_derive::{ChainSpecGroup, ChainSpecExtension}; + use sc_chain_spec_derive::{ChainSpecGroup, ChainSpecExtension}; // Make the proc macro work for tests and doc tests. - use crate as substrate_chain_spec; + use crate as sc_chain_spec; #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, ChainSpecGroup)] #[serde(deny_unknown_fields)] diff --git a/client/chain-spec/src/lib.rs b/client/chain-spec/src/lib.rs index 8c35c22d9b..d8876e8aa8 100644 --- a/client/chain-spec/src/lib.rs +++ b/client/chain-spec/src/lib.rs @@ -30,7 +30,7 @@ //! ```rust //! use std::collections::HashMap; //! use serde::{Serialize, Deserialize}; -//! use substrate_chain_spec::{ChainSpec, ChainSpecExtension}; +//! use sc_chain_spec::{ChainSpec, ChainSpecExtension}; //! //! #[derive(Clone, Debug, Serialize, Deserialize, ChainSpecExtension)] //! pub struct MyExtension { @@ -49,7 +49,7 @@ //! //! ```rust //! use serde::{Serialize, Deserialize}; -//! use substrate_chain_spec::{Forks, ChainSpec, ChainSpecGroup, ChainSpecExtension}; +//! use sc_chain_spec::{Forks, ChainSpec, ChainSpecGroup, ChainSpecExtension}; //! //! #[derive(Clone, Debug, Serialize, Deserialize, ChainSpecGroup)] //! pub struct ClientParams { @@ -84,7 +84,7 @@ //! //! ```rust //! use serde::{Serialize, Deserialize}; -//! use substrate_chain_spec::{Forks, ChainSpec, ChainSpecGroup, ChainSpecExtension}; +//! use sc_chain_spec::{Forks, ChainSpec, ChainSpecGroup, ChainSpecExtension}; //! //! #[derive(Clone, Debug, Serialize, Deserialize, ChainSpecGroup)] //! pub struct ClientParams { @@ -113,10 +113,10 @@ mod extension; pub use chain_spec::{ChainSpec, Properties, NoExtension}; pub use extension::{Group, Fork, Forks, Extension}; -pub use substrate_chain_spec_derive::{ChainSpecExtension, ChainSpecGroup}; +pub use sc_chain_spec_derive::{ChainSpecExtension, ChainSpecGroup}; use serde::{Serialize, de::DeserializeOwned}; -use sr_primitives::BuildStorage; +use sp_runtime::BuildStorage; /// A set of traits for the runtime genesis config. pub trait RuntimeGenesis: Serialize + DeserializeOwned + BuildStorage {} diff --git a/client/cli/Cargo.toml b/client/cli/Cargo.toml index 976242d24d..ea3023e7a8 100644 --- a/client/cli/Cargo.toml +++ b/client/cli/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "substrate-cli" +name = "sc-cli" version = "2.0.0" authors = ["Parity Technologies "] description = "Substrate CLI interface." @@ -21,20 +21,20 @@ futures = { version = "0.3.1", features = ["compat"] } futures01 = "0.1.29" fdlimit = "0.1.1" serde_json = "1.0.41" -panic-handler = { package = "substrate-panic-handler", path = "../../primitives/panic-handler" } -client-api = { package = "substrate-client-api", path = "../api" } +panic-handler = { package = "sp-panic-handler", path = "../../primitives/panic-handler" } +client-api = { package = "sc-client-api", path = "../api" } sp-blockchain = { path = "../../primitives/blockchain" } -network = { package = "substrate-network", path = "../network" } -sr-primitives = { path = "../../primitives/sr-primitives" } -primitives = { package = "substrate-primitives", path = "../../primitives/core" } -service = { package = "substrate-service", path = "../service", default-features = false } -state-machine = { package = "substrate-state-machine", path = "../../primitives/state-machine" } -substrate-telemetry = { path = "../telemetry" } -keyring = { package = "substrate-keyring", path = "../../primitives/keyring" } +network = { package = "sc-network", path = "../network" } +sp-runtime = { path = "../../primitives/sr-primitives" } +primitives = { package = "sp-core", path = "../../primitives/core" } +service = { package = "sc-service", path = "../service", default-features = false } +state-machine = { package = "sp-state-machine", path = "../../primitives/state-machine" } +sc-telemetry = { path = "../telemetry" } +keyring = { package = "sp-keyring", path = "../../primitives/keyring" } names = "0.11.0" structopt = "0.3.3" rpassword = "4.0.1" -substrate-tracing = { package = "substrate-tracing", path = "../tracing" } +sc-tracing = { package = "sc-tracing", path = "../tracing" } [dev-dependencies] tempfile = "3.1.0" diff --git a/client/cli/src/informant.rs b/client/cli/src/informant.rs index 46dca3e54c..169fb2a660 100644 --- a/client/cli/src/informant.rs +++ b/client/cli/src/informant.rs @@ -19,7 +19,7 @@ use client_api::BlockchainEvents; use futures::{StreamExt, TryStreamExt, FutureExt, future, compat::Stream01CompatExt}; use log::{info, warn}; -use sr_primitives::traits::Header; +use sp_runtime::traits::Header; use service::AbstractService; use std::time::Duration; diff --git a/client/cli/src/informant/display.rs b/client/cli/src/informant/display.rs index 76d3260472..e91b41b227 100644 --- a/client/cli/src/informant/display.rs +++ b/client/cli/src/informant/display.rs @@ -18,7 +18,7 @@ use ansi_term::Colour; use client_api::ClientInfo; use log::info; use network::SyncState; -use sr_primitives::traits::{Block as BlockT, CheckedDiv, NumberFor, Zero, Saturating}; +use sp_runtime::traits::{Block as BlockT, CheckedDiv, NumberFor, Zero, Saturating}; use service::NetworkStatus; use std::{convert::{TryFrom, TryInto}, fmt, time}; diff --git a/client/cli/src/lib.rs b/client/cli/src/lib.rs index c7b256c15f..25ec6a17b1 100644 --- a/client/cli/src/lib.rs +++ b/client/cli/src/lib.rs @@ -63,9 +63,9 @@ use log::info; use lazy_static::lazy_static; use futures::{Future, FutureExt, TryFutureExt}; use futures01::{Async, Future as _}; -use substrate_telemetry::TelemetryEndpoints; -use sr_primitives::generic::BlockId; -use sr_primitives::traits::Block as BlockT; +use sc_telemetry::TelemetryEndpoints; +use sp_runtime::generic::BlockId; +use sp_runtime::traits::Block as BlockT; /// default sub directory to store network config const DEFAULT_NETWORK_CONFIG_PATH : &'static str = "network"; @@ -970,8 +970,8 @@ fn init_logger(pattern: &str) { builder.filter(Some("ws"), log::LevelFilter::Off); builder.filter(Some("hyper"), log::LevelFilter::Warn); builder.filter(Some("cranelift_wasm"), log::LevelFilter::Warn); - // Always log the special target `substrate_tracing`, overrides global level - builder.filter(Some("substrate_tracing"), log::LevelFilter::Info); + // Always log the special target `sc_tracing`, overrides global level + builder.filter(Some("sc_tracing"), log::LevelFilter::Info); // Enable info for others. builder.filter(None, log::LevelFilter::Info); diff --git a/client/cli/src/params.rs b/client/cli/src/params.rs index 2ad6a9ea55..58d7cb3ca8 100644 --- a/client/cli/src/params.rs +++ b/client/cli/src/params.rs @@ -311,12 +311,12 @@ arg_enum! { } } -impl Into for TracingReceiver { - fn into(self) -> substrate_tracing::TracingReceiver { +impl Into for TracingReceiver { + fn into(self) -> sc_tracing::TracingReceiver { match self { - TracingReceiver::Log => substrate_tracing::TracingReceiver::Log, - TracingReceiver::Telemetry => substrate_tracing::TracingReceiver::Telemetry, - TracingReceiver::Grafana => substrate_tracing::TracingReceiver::Grafana, + TracingReceiver::Log => sc_tracing::TracingReceiver::Log, + TracingReceiver::Telemetry => sc_tracing::TracingReceiver::Telemetry, + TracingReceiver::Grafana => sc_tracing::TracingReceiver::Grafana, } } } diff --git a/client/consensus/aura/Cargo.toml b/client/consensus/aura/Cargo.toml index 7345a63dde..29c2914d28 100644 --- a/client/consensus/aura/Cargo.toml +++ b/client/consensus/aura/Cargo.toml @@ -1,41 +1,41 @@ [package] -name = "substrate-consensus-aura" +name = "sc-consensus-aura" version = "2.0.0" authors = ["Parity Technologies "] description = "Aura consensus algorithm for substrate" edition = "2018" [dependencies] -app-crypto = { package = "substrate-application-crypto", path = "../../../primitives/application-crypto" } -aura_primitives = { package = "substrate-consensus-aura-primitives", path = "../../../primitives/consensus/aura" } -block-builder-api = { package = "substrate-block-builder-runtime-api", path = "../../../primitives/block-builder/runtime-api" } -client = { package = "substrate-client", path = "../../" } -client-api = { package = "substrate-client-api", path = "../../api" } +app-crypto = { package = "sc-application-crypto", path = "../../../primitives/application-crypto" } +aura_primitives = { package = "sp-consensus-aura", path = "../../../primitives/consensus/aura" } +block-builder-api = { package = "sp-block-builder", path = "../../../primitives/block-builder/runtime-api" } +client = { package = "sc-client", path = "../../" } +client-api = { package = "sc-client-api", path = "../../api" } codec = { package = "parity-scale-codec", version = "1.0.0" } -consensus_common = { package = "substrate-consensus-common", path = "../../../primitives/consensus/common" } +consensus_common = { package = "sp-consensus", path = "../../../primitives/consensus/common" } derive_more = "0.99.2" futures = { version = "0.3.1", features = ["compat"] } futures01 = { package = "futures", version = "0.1" } futures-timer = "0.4.0" -inherents = { package = "substrate-inherents", path = "../../../primitives/inherents" } -keystore = { package = "substrate-keystore", path = "../../keystore" } +inherents = { package = "sp-inherents", path = "../../../primitives/inherents" } +keystore = { package = "sc-keystore", path = "../../keystore" } log = "0.4.8" parking_lot = "0.9.0" -primitives = { package = "substrate-primitives", path = "../../../primitives/core" } +primitives = { package = "sp-core", path = "../../../primitives/core" } sp-blockchain = { path = "../../../primitives/blockchain" } -runtime_io = { package = "sr-io", path = "../../../primitives/sr-io" } -runtime_version = { package = "sr-version", path = "../../../primitives/sr-version" } -slots = { package = "substrate-consensus-slots", path = "../slots" } -sr-api = { path = "../../../primitives/sr-api" } -sr-primitives = { path = "../../../primitives/sr-primitives" } +runtime_io = { package = "sp-io", path = "../../../primitives/sr-io" } +runtime_version = { package = "sp-version", path = "../../../primitives/sr-version" } +slots = { package = "sc-consensus-slots", path = "../slots" } +sp-api = { path = "../../../primitives/sr-api" } +sp-runtime = { path = "../../../primitives/sr-primitives" } sp-timestamp = { path = "../../../primitives/timestamp" } -substrate-telemetry = { path = "../../telemetry" } +sc-telemetry = { path = "../../telemetry" } [dev-dependencies] -keyring = { package = "substrate-keyring", path = "../../../primitives/keyring" } -substrate-executor = { path = "../../executor" } -network = { package = "substrate-network", path = "../../network", features = ["test-helpers"]} -service = { package = "substrate-service", path = "../../service" } +keyring = { package = "sp-keyring", path = "../../../primitives/keyring" } +sc-executor = { path = "../../executor" } +network = { package = "sc-network", path = "../../network", features = ["test-helpers"]} +service = { package = "sc-service", path = "../../service" } test-client = { package = "substrate-test-runtime-client", path = "../../../test/utils/runtime/client" } tokio = "0.1.22" env_logger = "0.7.0" diff --git a/client/consensus/aura/src/digest.rs b/client/consensus/aura/src/digest.rs index 3baa18587b..e788586616 100644 --- a/client/consensus/aura/src/digest.rs +++ b/client/consensus/aura/src/digest.rs @@ -21,7 +21,7 @@ use primitives::Pair; use aura_primitives::AURA_ENGINE_ID; -use sr_primitives::generic::{DigestItem, OpaqueDigestItemId}; +use sp_runtime::generic::{DigestItem, OpaqueDigestItemId}; use codec::{Encode, Codec}; use std::fmt::Debug; diff --git a/client/consensus/aura/src/lib.rs b/client/consensus/aura/src/lib.rs index 2e8ec1317c..7653be7259 100644 --- a/client/consensus/aura/src/lib.rs +++ b/client/consensus/aura/src/lib.rs @@ -48,8 +48,8 @@ use sp_blockchain::{ use block_builder_api::BlockBuilder as BlockBuilderApi; -use sr_primitives::{generic::{BlockId, OpaqueDigestItemId}, Justification}; -use sr_primitives::traits::{Block as BlockT, Header, DigestItemFor, ProvideRuntimeApi, Zero, Member}; +use sp_runtime::{generic::{BlockId, OpaqueDigestItemId}, Justification}; +use sp_runtime::traits::{Block as BlockT, Header, DigestItemFor, ProvideRuntimeApi, Zero, Member}; use primitives::crypto::Pair; use inherents::{InherentDataProviders, InherentData}; @@ -63,14 +63,14 @@ use sp_timestamp::{ TimestampInherentData, InherentType as TimestampInherent, InherentError as TIError }; -use substrate_telemetry::{telemetry, CONSENSUS_TRACE, CONSENSUS_DEBUG, CONSENSUS_INFO}; +use sc_telemetry::{telemetry, CONSENSUS_TRACE, CONSENSUS_DEBUG, CONSENSUS_INFO}; use slots::{CheckedHeader, SlotData, SlotWorker, SlotInfo, SlotCompatible}; use slots::check_equivocation; use keystore::KeyStorePtr; -use sr_api::ApiExt; +use sp_api::ApiExt; pub use aura_primitives::{ ConsensusLog, AuraApi, AURA_ENGINE_ID, @@ -256,7 +256,7 @@ impl slots::SimpleSlotWorker for AuraWorker Vec> { + fn pre_digest_data(&self, slot_number: u64, _claim: &Self::Claim) -> Vec> { vec![ as CompatibleDigestItem

>::aura_pre_digest(slot_number), ] @@ -720,7 +720,7 @@ mod tests { use consensus_common::NoNetwork as DummyOracle; use network::test::*; use network::test::{Block as TestBlock, PeersClient, PeersFullClient}; - use sr_primitives::traits::{Block as BlockT, DigestFor}; + use sp_runtime::traits::{Block as BlockT, DigestFor}; use network::config::ProtocolConfig; use parking_lot::Mutex; use tokio::runtime::current_thread; diff --git a/client/consensus/babe/Cargo.toml b/client/consensus/babe/Cargo.toml index a9dd0c5890..c7931d82b9 100644 --- a/client/consensus/babe/Cargo.toml +++ b/client/consensus/babe/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "substrate-consensus-babe" +name = "sc-consensus-babe" version = "2.0.0" authors = ["Parity Technologies "] description = "BABE consensus algorithm for substrate" @@ -7,27 +7,27 @@ edition = "2018" [dependencies] codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } -babe_primitives = { package = "substrate-consensus-babe-primitives", path = "../../../primitives/consensus/babe" } -primitives = { package = "substrate-primitives", path = "../../../primitives/core" } -app-crypto = { package = "substrate-application-crypto", path = "../../../primitives/application-crypto" } +babe_primitives = { package = "sp-consensus-babe", path = "../../../primitives/consensus/babe" } +primitives = { package = "sp-core", path = "../../../primitives/core" } +app-crypto = { package = "sc-application-crypto", path = "../../../primitives/application-crypto" } num-bigint = "0.2.3" num-rational = "0.2.2" num-traits = "0.2.8" -runtime-version = { package = "sr-version", path = "../../../primitives/sr-version" } -runtime-io = { package = "sr-io", path = "../../../primitives/sr-io" } -inherents = { package = "substrate-inherents", path = "../../../primitives/inherents" } +runtime-version = { package = "sp-version", path = "../../../primitives/sr-version" } +runtime-io = { package = "sp-io", path = "../../../primitives/sr-io" } +inherents = { package = "sp-inherents", path = "../../../primitives/inherents" } sp-timestamp = { path = "../../../primitives/timestamp" } -substrate-telemetry = { path = "../../telemetry" } -keystore = { package = "substrate-keystore", path = "../../keystore" } -client-api = { package = "substrate-client-api", path = "../../api" } -client = { package = "substrate-client", path = "../../" } -sr-api = { path = "../../../primitives/sr-api" } -block-builder-api = { package = "substrate-block-builder-runtime-api", path = "../../../primitives/block-builder/runtime-api" } +sc-telemetry = { path = "../../telemetry" } +keystore = { package = "sc-keystore", path = "../../keystore" } +client-api = { package = "sc-client-api", path = "../../api" } +client = { package = "sc-client", path = "../../" } +sp-api = { path = "../../../primitives/sr-api" } +block-builder-api = { package = "sp-block-builder", path = "../../../primitives/block-builder/runtime-api" } sp-blockchain = { path = "../../../primitives/blockchain" } -consensus-common = { package = "substrate-consensus-common", path = "../../../primitives/consensus/common" } -uncles = { package = "substrate-consensus-uncles", path = "../uncles" } -slots = { package = "substrate-consensus-slots", path = "../slots" } -sr-primitives = { path = "../../../primitives/sr-primitives" } +consensus-common = { package = "sp-consensus", path = "../../../primitives/consensus/common" } +uncles = { package = "sc-consensus-uncles", path = "../uncles" } +slots = { package = "sc-consensus-slots", path = "../slots" } +sp-runtime = { path = "../../../primitives/sr-primitives" } fork-tree = { path = "../../../utils/fork-tree" } futures = { version = "0.3.1", features = ["compat"] } futures01 = { package = "futures", version = "0.1" } @@ -41,12 +41,12 @@ pdqselect = "0.1.0" derive_more = "0.99.2" [dev-dependencies] -keyring = { package = "substrate-keyring", path = "../../../primitives/keyring" } -substrate-executor = { path = "../../executor" } -network = { package = "substrate-network", path = "../../network", features = ["test-helpers"]} -service = { package = "substrate-service", path = "../../service" } +keyring = { package = "sp-keyring", path = "../../../primitives/keyring" } +sc-executor = { path = "../../executor" } +network = { package = "sc-network", path = "../../network", features = ["test-helpers"]} +service = { package = "sc-service", path = "../../service" } test-client = { package = "substrate-test-runtime-client", path = "../../../test/utils/runtime/client" } -block-builder = { package = "substrate-block-builder", path = "../../block-builder" } +block-builder = { package = "sc-block-builder", path = "../../block-builder" } tokio = "0.1.22" env_logger = "0.7.0" tempfile = "3.1.0" diff --git a/client/consensus/babe/src/aux_schema.rs b/client/consensus/babe/src/aux_schema.rs index 288f20db97..f90c3e233a 100644 --- a/client/consensus/babe/src/aux_schema.rs +++ b/client/consensus/babe/src/aux_schema.rs @@ -21,7 +21,7 @@ use codec::{Decode, Encode}; use client_api::backend::AuxStore; use sp_blockchain::{Result as ClientResult, Error as ClientError}; -use sr_primitives::traits::Block as BlockT; +use sp_runtime::traits::Block as BlockT; use babe_primitives::BabeBlockWeight; use super::{epoch_changes::EpochChangesFor, SharedEpochChanges}; diff --git a/client/consensus/babe/src/epoch_changes.rs b/client/consensus/babe/src/epoch_changes.rs index a07235c4ff..5cb1c4f607 100644 --- a/client/consensus/babe/src/epoch_changes.rs +++ b/client/consensus/babe/src/epoch_changes.rs @@ -23,7 +23,7 @@ use std::sync::Arc; use babe_primitives::{Epoch, SlotNumber, NextEpochDescriptor}; use fork_tree::ForkTree; use parking_lot::{Mutex, MutexGuard}; -use sr_primitives::traits::{Block as BlockT, NumberFor, One, Zero}; +use sp_runtime::traits::{Block as BlockT, NumberFor, One, Zero}; use codec::{Encode, Decode}; use client_api::utils::is_descendent_of; use sp_blockchain::{HeaderMetadata, HeaderBackend, Error as ClientError}; diff --git a/client/consensus/babe/src/lib.rs b/client/consensus/babe/src/lib.rs index 026a49a160..de0efbbcc8 100644 --- a/client/consensus/babe/src/lib.rs +++ b/client/consensus/babe/src/lib.rs @@ -69,8 +69,8 @@ use consensus_common::{ImportResult, CanAuthorWith}; use consensus_common::import_queue::{ BoxJustificationImport, BoxFinalityProofImport, }; -use sr_primitives::{generic::{BlockId, OpaqueDigestItemId}, Justification}; -use sr_primitives::traits::{ +use sp_runtime::{generic::{BlockId, OpaqueDigestItemId}, Justification}; +use sp_runtime::traits::{ Block as BlockT, Header, DigestItemFor, ProvideRuntimeApi, Zero, }; @@ -78,7 +78,7 @@ use keystore::KeyStorePtr; use parking_lot::Mutex; use primitives::{Blake2Hasher, H256, Pair}; use inherents::{InherentDataProviders, InherentData}; -use substrate_telemetry::{telemetry, CONSENSUS_TRACE, CONSENSUS_DEBUG}; +use sc_telemetry::{telemetry, CONSENSUS_TRACE, CONSENSUS_DEBUG}; use consensus_common::{ self, BlockImport, Environment, Proposer, BlockCheckParams, ForkChoiceStrategy, BlockImportParams, BlockOrigin, Error as ConsensusError, @@ -107,7 +107,7 @@ use sp_blockchain::{ }; use schnorrkel::SignatureError; -use sr_api::ApiExt; +use sp_api::ApiExt; mod aux_schema; mod verification; @@ -411,7 +411,7 @@ impl slots::SimpleSlotWorker for BabeWorker Vec> { + fn pre_digest_data(&self, _slot_number: u64, claim: &Self::Claim) -> Vec> { vec![ as CompatibleDigestItem>::babe_pre_digest(claim.0.clone()), ] diff --git a/client/consensus/babe/src/tests.rs b/client/consensus/babe/src/tests.rs index 405443bc13..56482ef5fd 100644 --- a/client/consensus/babe/src/tests.rs +++ b/client/consensus/babe/src/tests.rs @@ -31,7 +31,7 @@ use consensus_common::import_queue::{ use network::test::*; use network::test::{Block as TestBlock, PeersClient}; use network::config::BoxFinalityProofRequestBuilder; -use sr_primitives::{generic::DigestItem, traits::{Block as BlockT, DigestFor}}; +use sp_runtime::{generic::DigestItem, traits::{Block as BlockT, DigestFor}}; use network::config::ProtocolConfig; use tokio::runtime::current_thread; use client_api::BlockchainEvents; @@ -540,7 +540,7 @@ fn propose_and_import_block( parent_pre_digest.slot_number() + 1 }); - let pre_digest = sr_primitives::generic::Digest { + let pre_digest = sp_runtime::generic::Digest { logs: vec![ Item::babe_pre_digest( BabePreDigest::Secondary { diff --git a/client/consensus/babe/src/verification.rs b/client/consensus/babe/src/verification.rs index 36e34dfb95..353fed808c 100644 --- a/client/consensus/babe/src/verification.rs +++ b/client/consensus/babe/src/verification.rs @@ -16,7 +16,7 @@ //! Verification for BABE headers. use schnorrkel::vrf::{VRFOutput, VRFProof}; -use sr_primitives::{traits::Header, traits::DigestItemFor}; +use sp_runtime::{traits::Header, traits::DigestItemFor}; use primitives::{Pair, Public}; use babe_primitives::{Epoch, BabePreDigest, CompatibleDigestItem, AuthorityId}; use babe_primitives::{AuthoritySignature, SlotNumber, AuthorityIndex, AuthorityPair}; diff --git a/client/consensus/pow/Cargo.toml b/client/consensus/pow/Cargo.toml index acdfb9e843..9ee579620a 100644 --- a/client/consensus/pow/Cargo.toml +++ b/client/consensus/pow/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "substrate-consensus-pow" +name = "sc-consensus-pow" version = "2.0.0" authors = ["Parity Technologies "] description = "PoW consensus algorithm for substrate" @@ -7,14 +7,14 @@ edition = "2018" [dependencies] codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } -primitives = { package = "substrate-primitives", path = "../../../primitives/core" } +primitives = { package = "sp-core", path = "../../../primitives/core" } sp-blockchain = { path = "../../../primitives/blockchain" } -sr-primitives = { path = "../../../primitives/sr-primitives" } -client-api = { package = "substrate-client-api", path = "../../api" } -block-builder-api = { package = "substrate-block-builder-runtime-api", path = "../../../primitives/block-builder/runtime-api" } -inherents = { package = "substrate-inherents", path = "../../../primitives/inherents" } -pow-primitives = { package = "substrate-consensus-pow-primitives", path = "../../../primitives/consensus/pow" } -consensus-common = { package = "substrate-consensus-common", path = "../../../primitives/consensus/common" } +sp-runtime = { path = "../../../primitives/sr-primitives" } +client-api = { package = "sc-client-api", path = "../../api" } +block-builder-api = { package = "sp-block-builder", path = "../../../primitives/block-builder/runtime-api" } +inherents = { package = "sp-inherents", path = "../../../primitives/inherents" } +pow-primitives = { package = "sp-consensus-pow", path = "../../../primitives/consensus/pow" } +consensus-common = { package = "sp-consensus", path = "../../../primitives/consensus/common" } log = "0.4.8" futures = { version = "0.3.1", features = ["compat"] } sp-timestamp = { path = "../../../primitives/timestamp" } diff --git a/client/consensus/pow/src/lib.rs b/client/consensus/pow/src/lib.rs index 914d484da7..c2029ec720 100644 --- a/client/consensus/pow/src/lib.rs +++ b/client/consensus/pow/src/lib.rs @@ -35,9 +35,9 @@ use std::collections::HashMap; use client_api::{BlockOf, backend::AuxStore}; use sp_blockchain::{HeaderBackend, ProvideCache, well_known_cache_keys::Id as CacheKeyId}; use block_builder_api::BlockBuilder as BlockBuilderApi; -use sr_primitives::{Justification, RuntimeString}; -use sr_primitives::generic::{BlockId, Digest, DigestItem}; -use sr_primitives::traits::{Block as BlockT, Header as HeaderT, ProvideRuntimeApi}; +use sp_runtime::{Justification, RuntimeString}; +use sp_runtime::generic::{BlockId, Digest, DigestItem}; +use sp_runtime::traits::{Block as BlockT, Header as HeaderT, ProvideRuntimeApi}; use sp_timestamp::{TimestampInherentData, InherentError as TIError}; use pow_primitives::{Seal, TotalDifficulty, POW_ENGINE_ID}; use primitives::H256; diff --git a/client/consensus/slots/Cargo.toml b/client/consensus/slots/Cargo.toml index 083ecdae11..3881906dad 100644 --- a/client/consensus/slots/Cargo.toml +++ b/client/consensus/slots/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "substrate-consensus-slots" +name = "sc-consensus-slots" version = "2.0.0" authors = ["Parity Technologies "] description = "Generic slots-based utilities for consensus" @@ -8,13 +8,13 @@ build = "build.rs" [dependencies] codec = { package = "parity-scale-codec", version = "1.0.0" } -client-api = { package = "substrate-client-api", path = "../../api" } -primitives = { package = "substrate-primitives", path = "../../../primitives/core" } +client-api = { package = "sc-client-api", path = "../../api" } +primitives = { package = "sp-core", path = "../../../primitives/core" } sp-blockchain = { path = "../../../primitives/blockchain" } -sr-primitives = { path = "../../../primitives/sr-primitives" } -substrate-telemetry = { path = "../../telemetry" } -consensus_common = { package = "substrate-consensus-common", path = "../../../primitives/consensus/common" } -inherents = { package = "substrate-inherents", path = "../../../primitives/inherents" } +sp-runtime = { path = "../../../primitives/sr-primitives" } +sc-telemetry = { path = "../../telemetry" } +consensus_common = { package = "sp-consensus", path = "../../../primitives/consensus/common" } +inherents = { package = "sp-inherents", path = "../../../primitives/inherents" } futures = "0.3.1" futures-timer = "2.0" parking_lot = "0.9.0" diff --git a/client/consensus/slots/src/aux_schema.rs b/client/consensus/slots/src/aux_schema.rs index 21e4d1256f..76f165e8d5 100644 --- a/client/consensus/slots/src/aux_schema.rs +++ b/client/consensus/slots/src/aux_schema.rs @@ -19,7 +19,7 @@ use codec::{Encode, Decode}; use client_api::backend::AuxStore; use sp_blockchain::{Result as ClientResult, Error as ClientError}; -use sr_primitives::traits::Header; +use sp_runtime::traits::Header; const SLOT_HEADER_MAP_KEY: &[u8] = b"slot_header_map"; const SLOT_HEADER_START: &[u8] = b"slot_header_start"; @@ -153,7 +153,7 @@ pub fn check_equivocation( mod test { use primitives::{sr25519, Pair}; use primitives::hash::H256; - use sr_primitives::testing::{Header as HeaderTest, Digest as DigestTest}; + use sp_runtime::testing::{Header as HeaderTest, Digest as DigestTest}; use test_client; use super::{MAX_SLOT_CAPACITY, PRUNING_BOUND, check_equivocation}; diff --git a/client/consensus/slots/src/lib.rs b/client/consensus/slots/src/lib.rs index 56d44d13b4..744942e107 100644 --- a/client/consensus/slots/src/lib.rs +++ b/client/consensus/slots/src/lib.rs @@ -36,10 +36,10 @@ use futures::{prelude::*, future::{self, Either}}; use futures_timer::Delay; use inherents::{InherentData, InherentDataProviders}; use log::{debug, error, info, warn}; -use sr_primitives::generic::BlockId; -use sr_primitives::traits::{ApiRef, Block as BlockT, Header, ProvideRuntimeApi}; +use sp_runtime::generic::BlockId; +use sp_runtime::traits::{ApiRef, Block as BlockT, Header, ProvideRuntimeApi}; use std::{fmt::Debug, ops::Deref, pin::Pin, sync::Arc, time::{Instant, Duration}}; -use substrate_telemetry::{telemetry, CONSENSUS_DEBUG, CONSENSUS_WARN, CONSENSUS_INFO}; +use sc_telemetry::{telemetry, CONSENSUS_DEBUG, CONSENSUS_WARN, CONSENSUS_INFO}; use parking_lot::Mutex; use client_api; @@ -94,7 +94,7 @@ pub trait SimpleSlotWorker { ) -> Option; /// Return the pre digest data to include in a block authored with the given claim. - fn pre_digest_data(&self, slot_number: u64, claim: &Self::Claim) -> Vec>; + fn pre_digest_data(&self, slot_number: u64, claim: &Self::Claim) -> Vec>; /// Returns a function which produces a `BlockImportParams`. fn block_import_params(&self) -> Box { // deadline our production to approx. the end of the slot let proposing = proposer.propose( slot_info.inherent_data, - sr_primitives::generic::Digest { + sp_runtime::generic::Digest { logs, }, slot_remaining_duration, @@ -448,7 +448,7 @@ impl SlotDuration { }) }), None => { - use sr_primitives::traits::Zero; + use sp_runtime::traits::Zero; let genesis_slot_duration = cb(client.runtime_api(), &BlockId::number(Zero::zero()))?; diff --git a/client/consensus/uncles/Cargo.toml b/client/consensus/uncles/Cargo.toml index 01e81ef198..b136c35ee2 100644 --- a/client/consensus/uncles/Cargo.toml +++ b/client/consensus/uncles/Cargo.toml @@ -1,15 +1,15 @@ [package] -name = "substrate-consensus-uncles" +name = "sc-consensus-uncles" version = "2.0.0" authors = ["Parity Technologies "] description = "Generic uncle inclusion utilities for consensus" edition = "2018" [dependencies] -client-api = { package = "substrate-client-api", path = "../../api" } -primitives = { package = "substrate-primitives", path = "../../../primitives/core" } -sr-primitives = { path = "../../../primitives/sr-primitives" } +client-api = { package = "sc-client-api", path = "../../api" } +primitives = { package = "sp-core", path = "../../../primitives/core" } +sp-runtime = { path = "../../../primitives/sr-primitives" } sp-authorship = { path = "../../../primitives/authorship" } -consensus_common = { package = "substrate-consensus-common", path = "../../../primitives/consensus/common" } -inherents = { package = "substrate-inherents", path = "../../../primitives/inherents" } +consensus_common = { package = "sp-consensus", path = "../../../primitives/consensus/common" } +inherents = { package = "sp-inherents", path = "../../../primitives/inherents" } log = "0.4.8" diff --git a/client/consensus/uncles/src/lib.rs b/client/consensus/uncles/src/lib.rs index abbd6d2b65..f7b1a8fa84 100644 --- a/client/consensus/uncles/src/lib.rs +++ b/client/consensus/uncles/src/lib.rs @@ -23,7 +23,7 @@ use consensus_common::SelectChain; use inherents::{InherentDataProviders}; use log::warn; use client_api::ProvideUncles; -use sr_primitives::traits::{Block as BlockT, Header}; +use sp_runtime::traits::{Block as BlockT, Header}; use std::sync::Arc; use sp_authorship; diff --git a/client/db/Cargo.toml b/client/db/Cargo.toml index d406298e0b..d8ad48f9b4 100644 --- a/client/db/Cargo.toml +++ b/client/db/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "substrate-client-db" +name = "sc-client-db" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" @@ -12,20 +12,20 @@ kvdb-rocksdb = { version = "0.2", optional = true } kvdb-memorydb = "0.1.2" linked-hash-map = "0.5.2" hash-db = "0.15.2" -client-api = { package = "substrate-client-api", path = "../api" } -primitives = { package = "substrate-primitives", path = "../../primitives/core" } -sr-primitives = { path = "../../primitives/sr-primitives" } -client = { package = "substrate-client", path = "../" } -state-machine = { package = "substrate-state-machine", path = "../../primitives/state-machine" } +client-api = { package = "sc-client-api", path = "../api" } +primitives = { package = "sp-core", path = "../../primitives/core" } +sp-runtime = { path = "../../primitives/sr-primitives" } +client = { package = "sc-client", path = "../" } +state-machine = { package = "sp-state-machine", path = "../../primitives/state-machine" } codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } -executor = { package = "substrate-executor", path = "../executor" } -state_db = { package = "substrate-state-db", path = "../state-db" } -trie = { package = "substrate-trie", path = "../../primitives/trie" } -consensus_common = { package = "substrate-consensus-common", path = "../../primitives/consensus/common" } +executor = { package = "sc-executor", path = "../executor" } +state_db = { package = "sc-state-db", path = "../state-db" } +trie = { package = "sp-trie", path = "../../primitives/trie" } +consensus_common = { package = "sp-consensus", path = "../../primitives/consensus/common" } sp-blockchain = { path = "../../primitives/blockchain" } [dev-dependencies] -substrate-keyring = { path = "../../primitives/keyring" } +sp-keyring = { path = "../../primitives/keyring" } test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client" } env_logger = "0.7.0" quickcheck = "0.9" diff --git a/client/db/src/cache/list_cache.rs b/client/db/src/cache/list_cache.rs index a36321df16..36219d479a 100644 --- a/client/db/src/cache/list_cache.rs +++ b/client/db/src/cache/list_cache.rs @@ -44,7 +44,7 @@ use std::collections::{BTreeSet, BTreeMap}; use log::warn; use sp_blockchain::{Error as ClientError, Result as ClientResult}; -use sr_primitives::traits::{ +use sp_runtime::traits::{ Block as BlockT, NumberFor, Zero, Bounded, CheckedSub }; @@ -651,7 +651,7 @@ pub fn destroy_fork, Tx: Stor /// Blockchain related functions. mod chain { - use sr_primitives::traits::Header as HeaderT; + use sp_runtime::traits::Header as HeaderT; use super::*; /// Is the block1 connected both ends of the range. @@ -725,8 +725,8 @@ fn read_forks>( #[cfg(test)] pub mod tests { use test_client::runtime::H256; - use sr_primitives::testing::{Header, Block as RawBlock, ExtrinsicWrapper}; - use sr_primitives::traits::Header as HeaderT; + use sp_runtime::testing::{Header, Block as RawBlock, ExtrinsicWrapper}; + use sp_runtime::traits::Header as HeaderT; use crate::cache::list_storage::tests::{DummyStorage, FaultyStorage, DummyTransaction}; use super::*; diff --git a/client/db/src/cache/list_entry.rs b/client/db/src/cache/list_entry.rs index b596863061..e00da3b57c 100644 --- a/client/db/src/cache/list_entry.rs +++ b/client/db/src/cache/list_entry.rs @@ -17,7 +17,7 @@ //! List-cache storage entries. use sp_blockchain::Result as ClientResult; -use sr_primitives::traits::{Block as BlockT, NumberFor}; +use sp_runtime::traits::{Block as BlockT, NumberFor}; use codec::{Encode, Decode}; use crate::cache::{CacheItemT, ComplexBlockId}; diff --git a/client/db/src/cache/list_storage.rs b/client/db/src/cache/list_storage.rs index 0615ae6aee..236feac88a 100644 --- a/client/db/src/cache/list_storage.rs +++ b/client/db/src/cache/list_storage.rs @@ -22,8 +22,8 @@ use kvdb::{KeyValueDB, DBTransaction}; use sp_blockchain::{Error as ClientError, Result as ClientResult}; use codec::{Encode, Decode}; -use sr_primitives::generic::BlockId; -use sr_primitives::traits::{Block as BlockT, Header as HeaderT, NumberFor}; +use sp_runtime::generic::BlockId; +use sp_runtime::traits::{Block as BlockT, Header as HeaderT, NumberFor}; use crate::utils::{self, db_err, meta_keys}; use crate::cache::{CacheItemT, ComplexBlockId}; diff --git a/client/db/src/cache/mod.rs b/client/db/src/cache/mod.rs index 068acb37ec..0087d34d19 100644 --- a/client/db/src/cache/mod.rs +++ b/client/db/src/cache/mod.rs @@ -24,8 +24,8 @@ use kvdb::{KeyValueDB, DBTransaction}; use client_api::blockchain::{well_known_cache_keys::{self, Id as CacheKeyId}, Cache as BlockchainCache}; use sp_blockchain::Result as ClientResult; use codec::{Encode, Decode}; -use sr_primitives::generic::BlockId; -use sr_primitives::traits::{Block as BlockT, Header as HeaderT, NumberFor, Zero}; +use sp_runtime::generic::BlockId; +use sp_runtime::traits::{Block as BlockT, Header as HeaderT, NumberFor, Zero}; use crate::utils::{self, COLUMN_META, db_err}; use self::list_cache::{ListCache, PruningStrategy}; diff --git a/client/db/src/lib.rs b/client/db/src/lib.rs index 253b48e6fa..d9365ce4bf 100644 --- a/client/db/src/lib.rs +++ b/client/db/src/lib.rs @@ -53,11 +53,11 @@ use trie::{MemoryDB, PrefixedMemoryDB, prefixed_key}; use parking_lot::{Mutex, RwLock}; use primitives::{H256, Blake2Hasher, ChangesTrieConfiguration, convert_hash, traits::CodeExecutor}; use primitives::storage::well_known_keys; -use sr_primitives::{ +use sp_runtime::{ generic::{BlockId, DigestItem}, Justification, StorageOverlay, ChildrenStorageOverlay, BuildStorage, }; -use sr_primitives::traits::{ +use sp_runtime::traits::{ Block as BlockT, Header as HeaderT, NumberFor, Zero, One, SaturatedConversion }; use executor::RuntimeInfo; @@ -1561,8 +1561,8 @@ mod tests { use crate::columns; use client_api::backend::{Backend as BTrait, BlockImportOperation as Op}; use client::blockchain::Backend as BLBTrait; - use sr_primitives::testing::{Header, Block as RawBlock, ExtrinsicWrapper}; - use sr_primitives::traits::{Hash, BlakeTwo256}; + use sp_runtime::testing::{Header, Block as RawBlock, ExtrinsicWrapper}; + use sp_runtime::traits::{Hash, BlakeTwo256}; use state_machine::{TrieMut, TrieDBMut, ChangesTrieRootsStorage, ChangesTrieStorage}; use sp_blockchain::{lowest_common_ancestor, tree_route}; @@ -1593,7 +1593,7 @@ mod tests { changes: Vec<(Vec, Vec)>, extrinsics_root: H256, ) -> H256 { - use sr_primitives::testing::Digest; + use sp_runtime::testing::Digest; let (changes_root, changes_trie_update) = prepare_changes(changes); let digest = Digest { logs: vec![ diff --git a/client/db/src/light.rs b/client/db/src/light.rs index 72f0d96986..9267a96b2f 100644 --- a/client/db/src/light.rs +++ b/client/db/src/light.rs @@ -36,8 +36,8 @@ use sp_blockchain::{ use client::light::blockchain::Storage as LightBlockchainStorage; use codec::{Decode, Encode}; use primitives::Blake2Hasher; -use sr_primitives::generic::{DigestItem, BlockId}; -use sr_primitives::traits::{Block as BlockT, Header as HeaderT, Zero, One, NumberFor}; +use sp_runtime::generic::{DigestItem, BlockId}; +use sp_runtime::traits::{Block as BlockT, Header as HeaderT, Zero, One, NumberFor}; use crate::cache::{DbCacheSync, DbCache, ComplexBlockId, EntryType as CacheEntryType}; use crate::utils::{self, meta_keys, Meta, db_err, read_db, block_id_to_lookup_key, read_meta}; use crate::DatabaseSettings; @@ -560,8 +560,8 @@ fn cht_key>(cht_type: u8, block: N) -> ClientResult<[u8; 5]> { #[cfg(test)] pub(crate) mod tests { use client::cht; - use sr_primitives::generic::DigestItem; - use sr_primitives::testing::{H256 as Hash, Header, Block as RawBlock, ExtrinsicWrapper}; + use sp_runtime::generic::DigestItem; + use sp_runtime::testing::{H256 as Hash, Header, Block as RawBlock, ExtrinsicWrapper}; use sp_blockchain::{lowest_common_ancestor, tree_route}; use super::*; diff --git a/client/db/src/storage_cache.rs b/client/db/src/storage_cache.rs index 3884857786..99266c7b61 100644 --- a/client/db/src/storage_cache.rs +++ b/client/db/src/storage_cache.rs @@ -21,7 +21,7 @@ use std::sync::Arc; use parking_lot::{Mutex, RwLock, RwLockUpgradableReadGuard}; use linked_hash_map::{LinkedHashMap, Entry}; use hash_db::Hasher; -use sr_primitives::traits::{Block as BlockT, Header}; +use sp_runtime::traits::{Block as BlockT, Header}; use primitives::hexdisplay::HexDisplay; use state_machine::{backend::Backend as StateBackend, TrieBackend}; use log::trace; @@ -596,7 +596,7 @@ impl, B: BlockT> StateBackend for CachingState< #[cfg(test)] mod tests { use super::*; - use sr_primitives::testing::{H256, Block as RawBlock, ExtrinsicWrapper}; + use sp_runtime::testing::{H256, Block as RawBlock, ExtrinsicWrapper}; use state_machine::backend::InMemory; use primitives::Blake2Hasher; @@ -844,7 +844,7 @@ mod qc { use quickcheck::{quickcheck, TestResult, Arbitrary}; use super::*; - use sr_primitives::testing::{H256, Block as RawBlock, ExtrinsicWrapper}; + use sp_runtime::testing::{H256, Block as RawBlock, ExtrinsicWrapper}; use state_machine::backend::InMemory; use primitives::Blake2Hasher; diff --git a/client/db/src/utils.rs b/client/db/src/utils.rs index b16a7ecdaa..5db1ff8d66 100644 --- a/client/db/src/utils.rs +++ b/client/db/src/utils.rs @@ -27,8 +27,8 @@ use log::debug; use codec::Decode; use trie::DBValue; -use sr_primitives::generic::BlockId; -use sr_primitives::traits::{ +use sp_runtime::generic::BlockId; +use sp_runtime::traits::{ Block as BlockT, Header as HeaderT, Zero, UniqueSaturatedFrom, UniqueSaturatedInto, }; @@ -184,7 +184,7 @@ pub fn block_id_to_lookup_key( id: BlockId ) -> Result>, sp_blockchain::Error> where Block: BlockT, - ::sr_primitives::traits::NumberFor: UniqueSaturatedFrom + UniqueSaturatedInto, + ::sp_runtime::traits::NumberFor: UniqueSaturatedFrom + UniqueSaturatedInto, { let res = match id { BlockId::Number(n) => db.get( @@ -357,7 +357,7 @@ pub fn read_meta(db: &dyn KeyValueDB, col_meta: Option, col_header: #[cfg(test)] mod tests { use super::*; - use sr_primitives::testing::{Block as RawBlock, ExtrinsicWrapper}; + use sp_runtime::testing::{Block as RawBlock, ExtrinsicWrapper}; type Block = RawBlock>; #[test] diff --git a/client/executor/Cargo.toml b/client/executor/Cargo.toml index 9aa201ce96..dff872dbc4 100644 --- a/client/executor/Cargo.toml +++ b/client/executor/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "substrate-executor" +name = "sc-executor" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" @@ -7,18 +7,18 @@ edition = "2018" [dependencies] derive_more = "0.99.2" codec = { package = "parity-scale-codec", version = "1.0.0" } -runtime_io = { package = "sr-io", path = "../../primitives/sr-io" } -primitives = { package = "substrate-primitives", path = "../../primitives/core" } -trie = { package = "substrate-trie", path = "../../primitives/trie" } -serializer = { package = "substrate-serializer", path = "../../primitives/serializer" } -runtime_version = { package = "sr-version", path = "../../primitives/sr-version" } -panic-handler = { package = "substrate-panic-handler", path = "../../primitives/panic-handler" } +runtime_io = { package = "sp-io", path = "../../primitives/sr-io" } +primitives = { package = "sp-core", path = "../../primitives/core" } +trie = { package = "sp-trie", path = "../../primitives/trie" } +serializer = { package = "sp-serializer", path = "../../primitives/serializer" } +runtime_version = { package = "sp-version", path = "../../primitives/sr-version" } +panic-handler = { package = "sp-panic-handler", path = "../../primitives/panic-handler" } wasmi = "0.6.2" parity-wasm = "0.41.0" lazy_static = "1.4.0" -wasm-interface = { package = "substrate-wasm-interface", path = "../../primitives/wasm-interface" } -runtime-interface = { package = "substrate-runtime-interface", path = "../../primitives/runtime-interface" } -externalities = { package = "substrate-externalities", path = "../../primitives/externalities" } +wasm-interface = { package = "sp-wasm-interface", path = "../../primitives/wasm-interface" } +runtime-interface = { package = "sp-runtime-interface", path = "../../primitives/runtime-interface" } +externalities = { package = "sp-externalities", path = "../../primitives/externalities" } parking_lot = "0.9.0" log = "0.4.8" libsecp256k1 = "0.3.2" @@ -36,12 +36,12 @@ wasmtime-runtime = { version = "0.8", optional = true } assert_matches = "1.3.0" wabt = "0.9.2" hex-literal = "0.2.1" -runtime-test = { package = "substrate-runtime-test", path = "runtime-test" } +runtime-test = { package = "sc-runtime-test", path = "runtime-test" } test-runtime = { package = "substrate-test-runtime", path = "../../test/utils/runtime" } -runtime-interface = { package = "substrate-runtime-interface", path = "../../primitives/runtime-interface" } -client-api = { package = "substrate-client-api", path = "../api" } -substrate-offchain = { path = "../offchain/" } -state_machine = { package = "substrate-state-machine", path = "../../primitives/state-machine" } +runtime-interface = { package = "sp-runtime-interface", path = "../../primitives/runtime-interface" } +client-api = { package = "sc-client-api", path = "../api" } +sc-offchain = { path = "../offchain/" } +state_machine = { package = "sp-state-machine", path = "../../primitives/state-machine" } test-case = "0.3.3" [features] diff --git a/client/executor/runtime-test/Cargo.toml b/client/executor/runtime-test/Cargo.toml index 610db45458..597417a17f 100644 --- a/client/executor/runtime-test/Cargo.toml +++ b/client/executor/runtime-test/Cargo.toml @@ -1,16 +1,16 @@ [package] -name = "substrate-runtime-test" +name = "sc-runtime-test" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" build = "build.rs" [dependencies] -rstd = { package = "sr-std", path = "../../../primitives/sr-std", default-features = false } -runtime_io = { package = "sr-io", path = "../../../primitives/sr-io", default-features = false } -sandbox = { package = "sr-sandbox", path = "../../../primitives/sr-sandbox", default-features = false } -primitives = { package = "substrate-primitives", path = "../../../primitives/core", default-features = false } -sr-primitives = { package = "sr-primitives", path = "../../../primitives/sr-primitives", default-features = false } +rstd = { package = "sp-std", path = "../../../primitives/sr-std", default-features = false } +runtime_io = { package = "sp-io", path = "../../../primitives/sr-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/sr-primitives", default-features = false } [build-dependencies] wasm-builder-runner = { package = "substrate-wasm-builder-runner", path = "../../../client/utils/wasm-builder-runner", version = "1.0.4" } diff --git a/client/executor/runtime-test/src/lib.rs b/client/executor/runtime-test/src/lib.rs index 63f89fca57..15b515d6c4 100644 --- a/client/executor/runtime-test/src/lib.rs +++ b/client/executor/runtime-test/src/lib.rs @@ -14,7 +14,7 @@ use runtime_io::{ crypto::{ed25519_verify, sr25519_verify}, }; #[cfg(not(feature = "std"))] -use sr_primitives::{print, traits::{BlakeTwo256, Hash}}; +use sp_runtime::{print, traits::{BlakeTwo256, Hash}}; #[cfg(not(feature = "std"))] use primitives::{ed25519, sr25519}; diff --git a/client/executor/src/deprecated_host_interface.rs b/client/executor/src/deprecated_host_interface.rs index f74a9597e5..e7f91443c0 100644 --- a/client/executor/src/deprecated_host_interface.rs +++ b/client/executor/src/deprecated_host_interface.rs @@ -79,13 +79,13 @@ impl_wasm_host_interface! { impl SubstrateExternals where context { ext_malloc(size: WordSize) -> Pointer { let r = context.allocate_memory(size)?; - debug_trace!(target: "sr-io", "malloc {} bytes at {:?}", size, r); + debug_trace!(target: "sp-io", "malloc {} bytes at {:?}", size, r); Ok(r) } ext_free(addr: Pointer) { context.deallocate_memory(addr)?; - debug_trace!(target: "sr-io", "free {:?}", addr); + debug_trace!(target: "sp-io", "free {:?}", addr); Ok(()) } diff --git a/client/executor/src/native_executor.rs b/client/executor/src/native_executor.rs index f5d02f274a..5a9bba7b52 100644 --- a/client/executor/src/native_executor.rs +++ b/client/executor/src/native_executor.rs @@ -265,7 +265,7 @@ impl CodeExecutor for NativeExecutor { /// # Example /// /// ``` -/// substrate_executor::native_executor_instance!( +/// sc_executor::native_executor_instance!( /// pub MyExecutor, /// test_runtime::api::dispatch, /// test_runtime::native_version, @@ -287,7 +287,7 @@ impl CodeExecutor for NativeExecutor { /// } /// } /// -/// substrate_executor::native_executor_instance!( +/// sc_executor::native_executor_instance!( /// pub MyExecutor, /// test_runtime::api::dispatch, /// test_runtime::native_version, diff --git a/client/executor/src/wasmi_execution.rs b/client/executor/src/wasmi_execution.rs index 7f48069579..2593de68c2 100644 --- a/client/executor/src/wasmi_execution.rs +++ b/client/executor/src/wasmi_execution.rs @@ -206,7 +206,7 @@ impl<'a> Sandbox for FunctionExecutor<'a> { return_val_len: WordSize, state: u32, ) -> WResult { - trace!(target: "sr-sandbox", "invoke, instance_idx={}", instance_id); + trace!(target: "sp-sandbox", "invoke, instance_idx={}", instance_id); // Deserialize arguments and convert them into wasmi types. let args = Vec::::decode(&mut &args[..]) diff --git a/client/executor/src/wasmtime/function_executor.rs b/client/executor/src/wasmtime/function_executor.rs index 5dc8f42b28..34a3007689 100644 --- a/client/executor/src/wasmtime/function_executor.rs +++ b/client/executor/src/wasmtime/function_executor.rs @@ -283,7 +283,7 @@ impl<'a> Sandbox for FunctionExecutor<'a> { return_val_len: u32, state: u32, ) -> WResult { - trace!(target: "sr-sandbox", "invoke, instance_idx={}", instance_id); + trace!(target: "sp-sandbox", "invoke, instance_idx={}", instance_id); // Deserialize arguments and convert them into wasmi types. let args = Vec::::decode(&mut &args[..]) diff --git a/client/finality-grandpa/Cargo.toml b/client/finality-grandpa/Cargo.toml index 71460966ad..8b053fcda6 100644 --- a/client/finality-grandpa/Cargo.toml +++ b/client/finality-grandpa/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "substrate-finality-grandpa" +name = "sc-finality-grandpa" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" @@ -14,29 +14,29 @@ tokio-executor = "0.1.8" tokio-timer = "0.2.11" rand = "0.7.2" codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } -sr-primitives = { path = "../../primitives/sr-primitives" } -consensus_common = { package = "substrate-consensus-common", path = "../../primitives/consensus/common" } -primitives = { package = "substrate-primitives", path = "../../primitives/core" } -substrate-telemetry = { path = "../telemetry" } -keystore = { package = "substrate-keystore", path = "../keystore" } +sp-runtime = { path = "../../primitives/sr-primitives" } +consensus_common = { package = "sp-consensus", path = "../../primitives/consensus/common" } +primitives = { package = "sp-core", path = "../../primitives/core" } +sc-telemetry = { path = "../telemetry" } +keystore = { package = "sc-keystore", path = "../keystore" } serde_json = "1.0.41" -client-api = { package = "substrate-client-api", path = "../api" } -client = { package = "substrate-client", path = "../" } -inherents = { package = "substrate-inherents", path = "../../primitives/inherents" } +client-api = { package = "sc-client-api", path = "../api" } +client = { package = "sc-client", path = "../" } +inherents = { package = "sp-inherents", path = "../../primitives/inherents" } sp-blockchain = { path = "../../primitives/blockchain" } -network = { package = "substrate-network", path = "../network" } +network = { package = "sc-network", path = "../network" } sp-finality-tracker = { path = "../../primitives/finality-tracker" } -fg_primitives = { package = "substrate-finality-grandpa-primitives", path = "../../primitives/finality-grandpa" } +fg_primitives = { package = "sp-finality-granpda", path = "../../primitives/finality-grandpa" } grandpa = { package = "finality-grandpa", version = "0.10.1", features = ["derive-codec"] } [dev-dependencies] grandpa = { package = "finality-grandpa", version = "0.10.1", features = ["derive-codec", "test-helpers"] } -network = { package = "substrate-network", path = "../network", features = ["test-helpers"] } -keyring = { package = "substrate-keyring", path = "../../primitives/keyring" } +network = { package = "sc-network", path = "../network", features = ["test-helpers"] } +keyring = { package = "sp-keyring", path = "../../primitives/keyring" } test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client"} -babe_primitives = { package = "substrate-consensus-babe-primitives", path = "../../primitives/consensus/babe" } -state_machine = { package = "substrate-state-machine", path = "../../primitives/state-machine" } +babe_primitives = { package = "sp-consensus-babe", path = "../../primitives/consensus/babe" } +state_machine = { package = "sp-state-machine", path = "../../primitives/state-machine" } env_logger = "0.7.0" tokio = "0.1.22" tempfile = "3.1.0" -sr-api = { path = "../../primitives/sr-api" } +sp-api = { path = "../../primitives/sr-api" } diff --git a/client/finality-grandpa/src/authorities.rs b/client/finality-grandpa/src/authorities.rs index 263f2dc076..4bc4e3c7b8 100644 --- a/client/finality-grandpa/src/authorities.rs +++ b/client/finality-grandpa/src/authorities.rs @@ -21,7 +21,7 @@ use parking_lot::RwLock; use grandpa::voter_set::VoterSet; use codec::{Encode, Decode}; use log::{debug, info}; -use substrate_telemetry::{telemetry, CONSENSUS_INFO}; +use sc_telemetry::{telemetry, CONSENSUS_INFO}; use fg_primitives::{AuthorityId, AuthorityList}; use std::cmp::Ord; diff --git a/client/finality-grandpa/src/aux_schema.rs b/client/finality-grandpa/src/aux_schema.rs index beb2103ec4..3e171a9441 100644 --- a/client/finality-grandpa/src/aux_schema.rs +++ b/client/finality-grandpa/src/aux_schema.rs @@ -23,7 +23,7 @@ use client_api::backend::AuxStore; use sp_blockchain::{Result as ClientResult, Error as ClientError}; use fork_tree::ForkTree; use grandpa::round::State as RoundState; -use sr_primitives::traits::{Block as BlockT, NumberFor}; +use sp_runtime::traits::{Block as BlockT, NumberFor}; use log::{info, warn}; use fg_primitives::{AuthorityList, SetId, RoundNumber}; diff --git a/client/finality-grandpa/src/communication/gossip.rs b/client/finality-grandpa/src/communication/gossip.rs index bd1b6197ea..9795121882 100644 --- a/client/finality-grandpa/src/communication/gossip.rs +++ b/client/finality-grandpa/src/communication/gossip.rs @@ -82,13 +82,13 @@ //! //! We only send polite messages to peers, -use sr_primitives::traits::{NumberFor, Block as BlockT, Zero}; +use sp_runtime::traits::{NumberFor, Block as BlockT, Zero}; use network::consensus_gossip::{self as network_gossip, MessageIntent, ValidatorContext}; use network::{config::Roles, PeerId}; use codec::{Encode, Decode}; use fg_primitives::AuthorityId; -use substrate_telemetry::{telemetry, CONSENSUS_DEBUG}; +use sc_telemetry::{telemetry, CONSENSUS_DEBUG}; use log::{trace, debug, warn}; use futures::prelude::*; use futures::sync::mpsc; diff --git a/client/finality-grandpa/src/communication/mod.rs b/client/finality-grandpa/src/communication/mod.rs index 247f9efd2d..8354d41bb0 100644 --- a/client/finality-grandpa/src/communication/mod.rs +++ b/client/finality-grandpa/src/communication/mod.rs @@ -39,8 +39,8 @@ use network::{consensus_gossip as network_gossip, NetworkService}; use network_gossip::ConsensusMessage; use codec::{Encode, Decode}; use primitives::Pair; -use sr_primitives::traits::{Block as BlockT, Hash as HashT, Header as HeaderT, NumberFor}; -use substrate_telemetry::{telemetry, CONSENSUS_DEBUG, CONSENSUS_INFO}; +use sp_runtime::traits::{Block as BlockT, Hash as HashT, Header as HeaderT, NumberFor}; +use sc_telemetry::{telemetry, CONSENSUS_DEBUG, CONSENSUS_INFO}; use tokio_executor::Executor; use crate::{ diff --git a/client/finality-grandpa/src/communication/periodic.rs b/client/finality-grandpa/src/communication/periodic.rs index 9dd662ce43..7db5fb692e 100644 --- a/client/finality-grandpa/src/communication/periodic.rs +++ b/client/finality-grandpa/src/communication/periodic.rs @@ -25,7 +25,7 @@ use log::{debug, warn}; use tokio_timer::Delay; use network::PeerId; -use sr_primitives::traits::{NumberFor, Block as BlockT}; +use sp_runtime::traits::{NumberFor, Block as BlockT}; use super::{gossip::{NeighborPacket, GossipMessage}, Network}; // how often to rebroadcast, if no other diff --git a/client/finality-grandpa/src/communication/tests.rs b/client/finality-grandpa/src/communication/tests.rs index e8b399aef3..2d08ecbde7 100644 --- a/client/finality-grandpa/src/communication/tests.rs +++ b/client/finality-grandpa/src/communication/tests.rs @@ -25,7 +25,7 @@ use tokio::runtime::current_thread; use std::sync::Arc; use keyring::Ed25519Keyring; use codec::Encode; -use sr_primitives::traits::NumberFor; +use sp_runtime::traits::NumberFor; use crate::environment::SharedVoterSetState; use fg_primitives::AuthorityList; diff --git a/client/finality-grandpa/src/environment.rs b/client/finality-grandpa/src/environment.rs index 0f70ac531d..52e1bea3e7 100644 --- a/client/finality-grandpa/src/environment.rs +++ b/client/finality-grandpa/src/environment.rs @@ -41,11 +41,11 @@ use grandpa::{ voter, voter_set::VoterSet, }; use primitives::{Blake2Hasher, H256, Pair}; -use sr_primitives::generic::BlockId; -use sr_primitives::traits::{ +use sp_runtime::generic::BlockId; +use sp_runtime::traits::{ Block as BlockT, Header as HeaderT, NumberFor, One, Zero, }; -use substrate_telemetry::{telemetry, CONSENSUS_INFO}; +use sc_telemetry::{telemetry, CONSENSUS_INFO}; use crate::{ CommandOrError, Commit, Config, Error, Network, Precommit, Prevote, diff --git a/client/finality-grandpa/src/finality_proof.rs b/client/finality-grandpa/src/finality_proof.rs index 209eb974b0..0420320e0b 100644 --- a/client/finality-grandpa/src/finality_proof.rs +++ b/client/finality-grandpa/src/finality_proof.rs @@ -46,12 +46,12 @@ use client_api::{ use client::Client; use codec::{Encode, Decode}; use grandpa::BlockNumberOps; -use sr_primitives::{ +use sp_runtime::{ Justification, generic::BlockId, traits::{NumberFor, Block as BlockT, Header as HeaderT, One}, }; use primitives::{H256, Blake2Hasher, storage::StorageKey}; -use substrate_telemetry::{telemetry, CONSENSUS_INFO}; +use sc_telemetry::{telemetry, CONSENSUS_INFO}; use fg_primitives::{AuthorityId, AuthorityList, VersionedAuthorityList, GRANDPA_AUTHORITIES_KEY}; use crate::justification::GrandpaJustification; diff --git a/client/finality-grandpa/src/import.rs b/client/finality-grandpa/src/import.rs index 2c18600ae9..e7cfa46d4a 100644 --- a/client/finality-grandpa/src/import.rs +++ b/client/finality-grandpa/src/import.rs @@ -30,9 +30,9 @@ use consensus_common::{ SelectChain, }; use fg_primitives::{GRANDPA_ENGINE_ID, ScheduledChange, ConsensusLog}; -use sr_primitives::Justification; -use sr_primitives::generic::{BlockId, OpaqueDigestItemId}; -use sr_primitives::traits::{ +use sp_runtime::Justification; +use sp_runtime::generic::{BlockId, OpaqueDigestItemId}; +use sp_runtime::traits::{ Block as BlockT, DigestFor, Header as HeaderT, NumberFor, Zero, }; use primitives::{H256, Blake2Hasher}; diff --git a/client/finality-grandpa/src/justification.rs b/client/finality-grandpa/src/justification.rs index 807a785ca8..2851fa2132 100644 --- a/client/finality-grandpa/src/justification.rs +++ b/client/finality-grandpa/src/justification.rs @@ -22,8 +22,8 @@ use sp_blockchain::Error as ClientError; use codec::{Encode, Decode}; use grandpa::voter_set::VoterSet; use grandpa::{Error as GrandpaError}; -use sr_primitives::generic::BlockId; -use sr_primitives::traits::{NumberFor, Block as BlockT, Header as HeaderT}; +use sp_runtime::generic::BlockId; +use sp_runtime::traits::{NumberFor, Block as BlockT, Header as HeaderT}; use primitives::{H256, Blake2Hasher}; use fg_primitives::AuthorityId; diff --git a/client/finality-grandpa/src/lib.rs b/client/finality-grandpa/src/lib.rs index 2b83488d59..29311b1e91 100644 --- a/client/finality-grandpa/src/lib.rs +++ b/client/finality-grandpa/src/lib.rs @@ -59,13 +59,13 @@ use client_api::{BlockchainEvents, CallExecutor, backend::Backend, ExecutionStra use sp_blockchain::{HeaderBackend, Error as ClientError}; use client::Client; use codec::{Decode, Encode}; -use sr_primitives::generic::BlockId; -use sr_primitives::traits::{NumberFor, Block as BlockT, DigestFor, Zero}; +use sp_runtime::generic::BlockId; +use sp_runtime::traits::{NumberFor, Block as BlockT, DigestFor, Zero}; use keystore::KeyStorePtr; use inherents::InherentDataProviders; use consensus_common::SelectChain; use primitives::{H256, Blake2Hasher, Pair}; -use substrate_telemetry::{telemetry, CONSENSUS_INFO, CONSENSUS_DEBUG, CONSENSUS_WARN}; +use sc_telemetry::{telemetry, CONSENSUS_INFO, CONSENSUS_DEBUG, CONSENSUS_WARN}; use serde_json; use sp_finality_tracker; diff --git a/client/finality-grandpa/src/light_import.rs b/client/finality-grandpa/src/light_import.rs index 579043751b..344c6110cc 100644 --- a/client/finality-grandpa/src/light_import.rs +++ b/client/finality-grandpa/src/light_import.rs @@ -28,10 +28,10 @@ use consensus_common::{ BlockCheckParams, Error as ConsensusError, }; use network::config::{BoxFinalityProofRequestBuilder, FinalityProofRequestBuilder}; -use sr_primitives::Justification; -use sr_primitives::traits::{NumberFor, Block as BlockT, Header as HeaderT, DigestFor}; +use sp_runtime::Justification; +use sp_runtime::traits::{NumberFor, Block as BlockT, Header as HeaderT, DigestFor}; use fg_primitives::{self, AuthorityList}; -use sr_primitives::generic::BlockId; +use sp_runtime::generic::BlockId; use primitives::{H256, Blake2Hasher}; use crate::GenesisAuthoritySetProvider; diff --git a/client/finality-grandpa/src/observer.rs b/client/finality-grandpa/src/observer.rs index 83c2fac275..2061764ac4 100644 --- a/client/finality-grandpa/src/observer.rs +++ b/client/finality-grandpa/src/observer.rs @@ -27,7 +27,7 @@ use log::{debug, info, warn}; use consensus_common::SelectChain; use client_api::{CallExecutor, backend::Backend}; use client::Client; -use sr_primitives::traits::{NumberFor, Block as BlockT}; +use sp_runtime::traits::{NumberFor, Block as BlockT}; use primitives::{H256, Blake2Hasher}; use crate::{ diff --git a/client/finality-grandpa/src/tests.rs b/client/finality-grandpa/src/tests.rs index 2ea15d9022..256c211e8b 100644 --- a/client/finality-grandpa/src/tests.rs +++ b/client/finality-grandpa/src/tests.rs @@ -27,15 +27,15 @@ use tokio::runtime::current_thread; use keyring::Ed25519Keyring; use client::LongestChain; use sp_blockchain::Result; -use sr_api::{Core, RuntimeVersion, ApiExt, StorageProof}; +use sp_api::{Core, RuntimeVersion, ApiExt, StorageProof}; use test_client::{self, runtime::BlockNumber}; use consensus_common::{BlockOrigin, ForkChoiceStrategy, ImportedAux, BlockImportParams, ImportResult}; use consensus_common::import_queue::{BoxBlockImport, BoxJustificationImport, BoxFinalityProofImport}; use std::collections::{HashMap, HashSet}; use std::result; use codec::Decode; -use sr_primitives::traits::{ApiRef, ProvideRuntimeApi, Header as HeaderT}; -use sr_primitives::generic::{BlockId, DigestItem}; +use sp_runtime::traits::{ApiRef, ProvideRuntimeApi, Header as HeaderT}; +use sp_runtime::generic::{BlockId, DigestItem}; use primitives::{NativeOrEncoded, ExecutionContext, crypto::Public}; use fg_primitives::{GRANDPA_ENGINE_ID, AuthorityList, GrandpaApi}; use state_machine::{backend::InMemory, prove_read, read_proof_check}; diff --git a/client/finality-grandpa/src/until_imported.rs b/client/finality-grandpa/src/until_imported.rs index fca67ab195..7e209e13b8 100644 --- a/client/finality-grandpa/src/until_imported.rs +++ b/client/finality-grandpa/src/until_imported.rs @@ -35,7 +35,7 @@ use futures::stream::Fuse; use futures03::{StreamExt as _, TryStreamExt as _}; use grandpa::voter; use parking_lot::Mutex; -use sr_primitives::traits::{Block as BlockT, Header as HeaderT, NumberFor}; +use sp_runtime::traits::{Block as BlockT, Header as HeaderT, NumberFor}; use tokio_timer::Interval; use std::collections::{HashMap, VecDeque}; diff --git a/client/finality-grandpa/src/voting_rule.rs b/client/finality-grandpa/src/voting_rule.rs index 7907515074..cfa28d03fe 100644 --- a/client/finality-grandpa/src/voting_rule.rs +++ b/client/finality-grandpa/src/voting_rule.rs @@ -23,8 +23,8 @@ use std::sync::Arc; use client_api::blockchain::HeaderBackend; -use sr_primitives::generic::BlockId; -use sr_primitives::traits::{Block as BlockT, Header, NumberFor, One, Zero}; +use sp_runtime::generic::BlockId; +use sp_runtime::traits::{Block as BlockT, Header, NumberFor, One, Zero}; /// A trait for custom voting rules in GRANDPA. pub trait VotingRule: Send + Sync where diff --git a/client/keystore/Cargo.toml b/client/keystore/Cargo.toml index 2d006b1314..0dd33a62da 100644 --- a/client/keystore/Cargo.toml +++ b/client/keystore/Cargo.toml @@ -1,13 +1,13 @@ [package] -name = "substrate-keystore" +name = "sc-keystore" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" [dependencies] derive_more = "0.99.2" -primitives = { package = "substrate-primitives", path = "../../primitives/core" } -app-crypto = { package = "substrate-application-crypto", path = "../../primitives/application-crypto" } +primitives = { package = "sp-core", path = "../../primitives/core" } +app-crypto = { package = "sc-application-crypto", path = "../../primitives/application-crypto" } hex = "0.4.0" rand = "0.7.2" serde_json = "1.0.41" diff --git a/client/network/Cargo.toml b/client/network/Cargo.toml index 1362747f71..1872645d55 100644 --- a/client/network/Cargo.toml +++ b/client/network/Cargo.toml @@ -1,6 +1,6 @@ [package] description = "Substrate network protocol" -name = "substrate-network" +name = "sc-network" version = "2.0.0" license = "GPL-3.0" authors = ["Parity Technologies "] @@ -24,16 +24,16 @@ rustc-hex = "2.0.1" rand = "0.7.2" libp2p = { version = "0.13.0", default-features = false, features = ["libp2p-websocket"] } fork-tree = { path = "../../utils/fork-tree" } -consensus = { package = "substrate-consensus-common", path = "../../primitives/consensus/common" } -client = { package = "substrate-client", path = "../" } -client-api = { package = "substrate-client-api", path = "../api" } +consensus = { package = "sp-consensus", path = "../../primitives/consensus/common" } +client = { package = "sc-client", path = "../" } +client-api = { package = "sc-client-api", path = "../api" } sp-blockchain = { path = "../../primitives/blockchain" } -sr-primitives = { path = "../../primitives/sr-primitives" } -sr-arithmetic = { path = "../../primitives/sr-arithmetic" } -primitives = { package = "substrate-primitives", path = "../../primitives/core" } -block-builder = { package = "substrate-block-builder", path = "../block-builder" } +sp-runtime = { path = "../../primitives/sr-primitives" } +sp-arithmetic = { path = "../../primitives/sr-arithmetic" } +primitives = { package = "sp-core", path = "../../primitives/core" } +block-builder = { package = "sc-block-builder", path = "../block-builder" } codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } -peerset = { package = "substrate-peerset", path = "../peerset" } +peerset = { package = "sc-peerset", path = "../peerset" } serde = { version = "1.0.101", features = ["derive"] } serde_json = "1.0.41" slog = { version = "2.5.2", features = ["nested-values"] } @@ -42,17 +42,17 @@ smallvec = "0.6.10" tokio-io = "0.1.12" tokio = { version = "0.1.22", optional = true } unsigned-varint = { version = "0.2.2", features = ["codec"] } -keyring = { package = "substrate-keyring", path = "../../primitives/keyring", optional = true } +keyring = { package = "sp-keyring", path = "../../primitives/keyring", optional = true } test_client = { package = "substrate-test-client", path = "../../test/utils/client", optional = true } test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client", optional = true } erased-serde = "0.3.9" void = "1.0.2" zeroize = "1.0.0" -babe-primitives = { package = "substrate-consensus-babe-primitives", path = "../../primitives/consensus/babe" } +babe-primitives = { package = "sp-consensus-babe", path = "../../primitives/consensus/babe" } [dev-dependencies] env_logger = "0.7.0" -keyring = { package = "substrate-keyring", path = "../../primitives/keyring" } +keyring = { package = "sp-keyring", path = "../../primitives/keyring" } quickcheck = "0.9.0" rand = "0.7.2" test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client" } diff --git a/client/network/src/behaviour.rs b/client/network/src/behaviour.rs index a0299bc340..fb1f39726a 100644 --- a/client/network/src/behaviour.rs +++ b/client/network/src/behaviour.rs @@ -27,7 +27,7 @@ use libp2p::kad::record; use libp2p::swarm::{NetworkBehaviourAction, NetworkBehaviourEventProcess}; use libp2p::core::{nodes::Substream, muxing::StreamMuxerBox}; use log::{debug, warn}; -use sr_primitives::traits::Block as BlockT; +use sp_runtime::traits::Block as BlockT; use std::iter; use void; diff --git a/client/network/src/chain.rs b/client/network/src/chain.rs index ac883987cd..671bdb27ca 100644 --- a/client/network/src/chain.rs +++ b/client/network/src/chain.rs @@ -20,9 +20,9 @@ use client::Client as SubstrateClient; use sp_blockchain::Error; use client_api::{ChangesProof, StorageProof, ClientInfo, CallExecutor}; use consensus::{BlockImport, BlockStatus, Error as ConsensusError}; -use sr_primitives::traits::{Block as BlockT, Header as HeaderT}; -use sr_primitives::generic::{BlockId}; -use sr_primitives::Justification; +use sp_runtime::traits::{Block as BlockT, Header as HeaderT}; +use sp_runtime::generic::{BlockId}; +use sp_runtime::Justification; use primitives::{H256, Blake2Hasher, storage::StorageKey}; /// Local client abstraction for the network. diff --git a/client/network/src/config.rs b/client/network/src/config.rs index 85e3e36cf6..a59ab97887 100644 --- a/client/network/src/config.rs +++ b/client/network/src/config.rs @@ -27,7 +27,7 @@ use crate::on_demand_layer::OnDemand; use crate::service::{ExHashT, TransactionPool}; use bitflags::bitflags; use consensus::{block_validation::BlockAnnounceValidator, import_queue::ImportQueue}; -use sr_primitives::traits::{Block as BlockT}; +use sp_runtime::traits::{Block as BlockT}; use libp2p::identity::{Keypair, ed25519}; use libp2p::wasm_ext; use libp2p::{PeerId, Multiaddr, multiaddr}; @@ -171,7 +171,7 @@ impl ProtocolId { /// # Example /// /// ``` -/// # use substrate_network::{Multiaddr, PeerId, config::parse_str_addr}; +/// # use sc_network::{Multiaddr, PeerId, config::parse_str_addr}; /// let (peer_id, addr) = parse_str_addr( /// "/ip4/198.51.100.19/tcp/30333/p2p/QmSk5HQbn6LhUwDiNMseVUjuRYhEtYj4aUZ6WfWoGURpdV" /// ).unwrap(); diff --git a/client/network/src/lib.rs b/client/network/src/lib.rs index 96efd49958..9b25992dd9 100644 --- a/client/network/src/lib.rs +++ b/client/network/src/lib.rs @@ -118,7 +118,7 @@ //! if necessary and open a unique substream for Substrate-based communications. If the PSM decides //! that we should disconnect a node, then that substream is closed. //! -//! For more information about the PSM, see the *substrate-peerset* crate. +//! For more information about the PSM, see the *sc-peerset* crate. //! //! Note that at the moment there is no mechanism in place to solve the issues that arise where the //! two sides of a connection open the unique substream simultaneously. In order to not run into @@ -151,7 +151,7 @@ //! //! # Usage //! -//! Using the `substrate-network` crate is done through the [`NetworkWorker`] struct. Create this +//! Using the `sc-network` crate is done through the [`NetworkWorker`] struct. Create this //! struct by passing a [`config::Params`], then poll it as if it was a `Future`. You can extract an //! `Arc` from the `NetworkWorker`, which can be shared amongst multiple places //! in order to give orders to the networking. @@ -202,7 +202,7 @@ pub use on_demand_layer::{OnDemand, RemoteResponse}; // Used by the `construct_simple_protocol!` macro. #[doc(hidden)] -pub use sr_primitives::traits::Block as BlockT; +pub use sp_runtime::traits::Block as BlockT; use libp2p::core::ConnectedPoint; use serde::{Deserialize, Serialize}; diff --git a/client/network/src/on_demand_layer.rs b/client/network/src/on_demand_layer.rs index 82c5ed6940..91c8464b78 100644 --- a/client/network/src/on_demand_layer.rs +++ b/client/network/src/on_demand_layer.rs @@ -26,7 +26,7 @@ use sp_blockchain::Error as ClientError; use client_api::{Fetcher, FetchChecker, RemoteHeaderRequest, RemoteCallRequest, RemoteReadRequest, RemoteChangesRequest, RemoteReadChildRequest, RemoteBodyRequest}; -use sr_primitives::traits::{Block as BlockT, Header as HeaderT, NumberFor}; +use sp_runtime::traits::{Block as BlockT, Header as HeaderT, NumberFor}; /// Implements the `Fetcher` trait of the client. Makes it possible for the light client to perform /// network requests for some state. diff --git a/client/network/src/protocol.rs b/client/network/src/protocol.rs index 35e3d2453f..6b9c0755c0 100644 --- a/client/network/src/protocol.rs +++ b/client/network/src/protocol.rs @@ -31,11 +31,11 @@ use consensus::{ import_queue::{BlockImportResult, BlockImportError, IncomingBlock, Origin} }; use codec::{Decode, Encode}; -use sr_primitives::{generic::BlockId, ConsensusEngineId, Justification}; -use sr_primitives::traits::{ +use sp_runtime::{generic::BlockId, ConsensusEngineId, Justification}; +use sp_runtime::traits::{ Block as BlockT, Header as HeaderT, NumberFor, One, Zero, CheckedSub }; -use sr_arithmetic::traits::SaturatedConversion; +use sp_arithmetic::traits::SaturatedConversion; use message::{BlockAnnounce, BlockAttributes, Direction, FromBlock, Message, RequestId}; use message::generic::{Message as GenericMessage, ConsensusMessage}; use consensus_gossip::{ConsensusGossip, MessageRecipient as GossipMessageRecipient}; diff --git a/client/network/src/protocol/consensus_gossip.rs b/client/network/src/protocol/consensus_gossip.rs index 8cde3c66fe..3062047952 100644 --- a/client/network/src/protocol/consensus_gossip.rs +++ b/client/network/src/protocol/consensus_gossip.rs @@ -51,8 +51,8 @@ use log::{trace, debug}; use futures03::channel::mpsc; use lru::LruCache; use libp2p::PeerId; -use sr_primitives::traits::{Block as BlockT, Hash, HashFor}; -use sr_primitives::ConsensusEngineId; +use sp_runtime::traits::{Block as BlockT, Hash, HashFor}; +use sp_runtime::ConsensusEngineId; pub use crate::message::generic::{Message, ConsensusMessage}; use crate::protocol::Context; use crate::config::Roles; @@ -632,7 +632,7 @@ impl Validator for DiscardAll { #[cfg(test)] mod tests { use std::sync::Arc; - use sr_primitives::testing::{H256, Block as RawBlock, ExtrinsicWrapper}; + use sp_runtime::testing::{H256, Block as RawBlock, ExtrinsicWrapper}; use futures03::executor::block_on_stream; use super::*; diff --git a/client/network/src/protocol/light_dispatch.rs b/client/network/src/protocol/light_dispatch.rs index afc7ac563b..7d37b49b6c 100644 --- a/client/network/src/protocol/light_dispatch.rs +++ b/client/network/src/protocol/light_dispatch.rs @@ -32,7 +32,7 @@ use client_api::{FetchChecker, RemoteHeaderRequest, use crate::message::{self, BlockAttributes, Direction, FromBlock, RequestId}; use libp2p::PeerId; use crate::config::Roles; -use sr_primitives::traits::{Block as BlockT, Header as HeaderT, NumberFor}; +use sp_runtime::traits::{Block as BlockT, Header as HeaderT, NumberFor}; /// Remote request timeout. const REQUEST_TIMEOUT: Duration = Duration::from_secs(15); @@ -676,7 +676,7 @@ pub mod tests { use std::sync::Arc; use std::time::Instant; use futures::{Future, sync::oneshot}; - use sr_primitives::traits::{Block as BlockT, NumberFor, Header as HeaderT}; + use sp_runtime::traits::{Block as BlockT, NumberFor, Header as HeaderT}; use sp_blockchain::{Error as ClientError, Result as ClientResult}; use client_api::{FetchChecker, RemoteHeaderRequest, ChangesProof, RemoteCallRequest, RemoteReadRequest, diff --git a/client/network/src/protocol/message.rs b/client/network/src/protocol/message.rs index 847c03f680..a05a254f16 100644 --- a/client/network/src/protocol/message.rs +++ b/client/network/src/protocol/message.rs @@ -17,7 +17,7 @@ //! Network packet message types. These get serialized and put into the lower level protocol payload. use bitflags::bitflags; -use sr_primitives::{ConsensusEngineId, traits::{Block as BlockT, Header as HeaderT}}; +use sp_runtime::{ConsensusEngineId, traits::{Block as BlockT, Header as HeaderT}}; use codec::{Encode, Decode, Input, Output, Error}; pub use self::generic::{ BlockAnnounce, RemoteCallRequest, RemoteReadRequest, @@ -138,7 +138,7 @@ pub struct RemoteReadResponse { /// Generic types. pub mod generic { use codec::{Encode, Decode, Input, Output}; - use sr_primitives::Justification; + use sp_runtime::Justification; use crate::config::Roles; use super::{ RemoteReadResponse, Transactions, Direction, diff --git a/client/network/src/protocol/specialization.rs b/client/network/src/protocol/specialization.rs index 1a15c47c87..7ccd38740a 100644 --- a/client/network/src/protocol/specialization.rs +++ b/client/network/src/protocol/specialization.rs @@ -20,7 +20,7 @@ pub use crate::protocol::event::{DhtEvent, Event}; use crate::protocol::Context; use libp2p::PeerId; -use sr_primitives::traits::Block as BlockT; +use sp_runtime::traits::Block as BlockT; /// A specialization of the substrate network protocol. Handles events and sends messages. pub trait NetworkSpecialization: Send + Sync + 'static { diff --git a/client/network/src/protocol/sync.rs b/client/network/src/protocol/sync.rs index affa8cae1e..01f36bd4da 100644 --- a/client/network/src/protocol/sync.rs +++ b/client/network/src/protocol/sync.rs @@ -43,7 +43,7 @@ use either::Either; use extra_requests::ExtraRequests; use libp2p::PeerId; use log::{debug, trace, warn, info, error}; -use sr_primitives::{ +use sp_runtime::{ Justification, generic::BlockId, traits::{Block as BlockT, Header, NumberFor, Zero, One, CheckedSub, SaturatedConversion} diff --git a/client/network/src/protocol/sync/blocks.rs b/client/network/src/protocol/sync/blocks.rs index 70e9889e1e..f89772a8e7 100644 --- a/client/network/src/protocol/sync/blocks.rs +++ b/client/network/src/protocol/sync/blocks.rs @@ -21,7 +21,7 @@ use std::collections::{HashMap, BTreeMap}; use std::collections::hash_map::Entry; use log::trace; use libp2p::PeerId; -use sr_primitives::traits::{Block as BlockT, NumberFor, One}; +use sp_runtime::traits::{Block as BlockT, NumberFor, One}; use crate::message; /// Block data with origin. @@ -215,7 +215,7 @@ impl BlockCollection { mod test { use super::{BlockCollection, BlockData, BlockRangeState}; use crate::{message, PeerId}; - use sr_primitives::testing::{Block as RawBlock, ExtrinsicWrapper}; + use sp_runtime::testing::{Block as RawBlock, ExtrinsicWrapper}; use primitives::H256; type Block = RawBlock>; diff --git a/client/network/src/protocol/sync/extra_requests.rs b/client/network/src/protocol/sync/extra_requests.rs index a96f855776..21a29975c0 100644 --- a/client/network/src/protocol/sync/extra_requests.rs +++ b/client/network/src/protocol/sync/extra_requests.rs @@ -19,7 +19,7 @@ use crate::protocol::sync::{PeerSync, PeerSyncState}; use fork_tree::ForkTree; use libp2p::PeerId; use log::{debug, warn}; -use sr_primitives::traits::{Block as BlockT, NumberFor, Zero}; +use sp_runtime::traits::{Block as BlockT, NumberFor, Zero}; use std::collections::{HashMap, HashSet, VecDeque}; use std::time::{Duration, Instant}; diff --git a/client/network/src/service.rs b/client/network/src/service.rs index 437e978f4b..4a60c3def7 100644 --- a/client/network/src/service.rs +++ b/client/network/src/service.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Substrate. If not, see . -//! Main entry point of the substrate-network crate. +//! Main entry point of the sc-network crate. //! //! There are two main structs in this module: [`NetworkWorker`] and [`NetworkService`]. //! The [`NetworkWorker`] *is* the network and implements the `Future` trait. It must be polled in @@ -38,7 +38,7 @@ use libp2p::core::{transport::boxed::Boxed, muxing::StreamMuxerBox}; use libp2p::swarm::NetworkBehaviour; use parking_lot::Mutex; use peerset::PeersetHandle; -use sr_primitives::{traits::{Block as BlockT, NumberFor}, ConsensusEngineId}; +use sp_runtime::{traits::{Block as BlockT, NumberFor}, ConsensusEngineId}; use crate::{behaviour::{Behaviour, BehaviourOut}, config::{parse_str_addr, parse_addr}}; use crate::{NetworkState, NetworkStateNotConnectedPeer, NetworkStatePeer}; @@ -607,7 +607,7 @@ pub trait NetworkStateInfo { impl NetworkStateInfo for NetworkService where - B: sr_primitives::traits::Block, + B: sp_runtime::traits::Block, S: NetworkSpecialization, H: ExHashT, { diff --git a/client/network/src/test/block_import.rs b/client/network/src/test/block_import.rs index 16114667ed..5cb7b6b606 100644 --- a/client/network/src/test/block_import.rs +++ b/client/network/src/test/block_import.rs @@ -22,7 +22,7 @@ use consensus::import_queue::{ }; use test_client::{self, prelude::*}; use test_client::runtime::{Block, Hash}; -use sr_primitives::generic::BlockId; +use sp_runtime::generic::BlockId; use super::*; fn prepare_good_block() -> (TestClient, Hash, u64, PeerId, IncomingBlock) { diff --git a/client/network/src/test/mod.rs b/client/network/src/test/mod.rs index 31b45d4efe..d0cac918e7 100644 --- a/client/network/src/test/mod.rs +++ b/client/network/src/test/mod.rs @@ -55,9 +55,9 @@ use libp2p::PeerId; use parking_lot::Mutex; use primitives::H256; use crate::protocol::{Context, ProtocolConfig}; -use sr_primitives::generic::{BlockId, OpaqueDigestItemId}; -use sr_primitives::traits::{Block as BlockT, Header, NumberFor}; -use sr_primitives::Justification; +use sp_runtime::generic::{BlockId, OpaqueDigestItemId}; +use sp_runtime::traits::{Block as BlockT, Header, NumberFor}; +use sp_runtime::Justification; use crate::service::TransactionPool; use crate::specialization::NetworkSpecialization; use test_client::{self, AccountKeyring}; diff --git a/client/offchain/Cargo.toml b/client/offchain/Cargo.toml index d7e0ba1e98..dafbffd39b 100644 --- a/client/offchain/Cargo.toml +++ b/client/offchain/Cargo.toml @@ -1,6 +1,6 @@ [package] description = "Substrate offchain workers" -name = "substrate-offchain" +name = "sc-offchain" version = "2.0.0" license = "GPL-3.0" authors = ["Parity Technologies "] @@ -8,8 +8,8 @@ edition = "2018" [dependencies] bytes = "0.4.12" -client-api = { package = "substrate-client-api", path = "../api" } -sr-api = { path = "../../primitives/sr-api" } +client-api = { package = "sc-client-api", path = "../api" } +sp-api = { path = "../../primitives/sr-api" } fnv = "1.0.6" futures01 = { package = "futures", version = "0.1" } futures = "0.3.1" @@ -17,25 +17,25 @@ futures-timer = "2.0" log = "0.4.8" threadpool = "1.7" num_cpus = "1.10" -offchain-primitives = { package = "substrate-offchain-primitives", path = "../../primitives/offchain" } +offchain-primitives = { package = "sp-offchain", path = "../../primitives/offchain" } codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } parking_lot = "0.9.0" -primitives = { package = "substrate-primitives", path = "../../primitives/core" } +primitives = { package = "sp-core", path = "../../primitives/core" } rand = "0.7.2" -sr-primitives = { path = "../../primitives/sr-primitives" } -network = { package = "substrate-network", path = "../network" } -keystore = { package = "substrate-keystore", path = "../keystore" } +sp-runtime = { path = "../../primitives/sr-primitives" } +network = { package = "sc-network", path = "../network" } +keystore = { package = "sc-keystore", path = "../keystore" } [target.'cfg(not(target_os = "unknown"))'.dependencies] hyper = "0.12.35" hyper-rustls = "0.17.1" [dev-dependencies] -client-db = { package = "substrate-client-db", path = "../db/", default-features = true } +client-db = { package = "sc-client-db", path = "../db/", default-features = true } env_logger = "0.7.0" test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client" } tokio = "0.1.22" -txpool = { package = "sc-transaction-pool", path = "../../client/transaction-pool" } +txpool = { package = "sc-tracing-pool", path = "../../client/transaction-pool" } txpool-api = { package = "sp-transaction-pool-api", path = "../../primitives/transaction-pool" } [features] diff --git a/client/offchain/src/lib.rs b/client/offchain/src/lib.rs index bf7965d308..174aee89d9 100644 --- a/client/offchain/src/lib.rs +++ b/client/offchain/src/lib.rs @@ -37,12 +37,12 @@ use std::{fmt, marker::PhantomData, sync::Arc}; use parking_lot::Mutex; use threadpool::ThreadPool; -use sr_api::ApiExt; +use sp_api::ApiExt; use futures::future::Future; use log::{debug, warn}; use network::NetworkStateInfo; use primitives::{offchain::{self, OffchainStorage}, ExecutionContext}; -use sr_primitives::{generic::BlockId, traits::{self, ProvideRuntimeApi}}; +use sp_runtime::{generic::BlockId, traits::{self, ProvideRuntimeApi}}; mod api; @@ -169,7 +169,7 @@ mod tests { fn submit_at( &self, at: &BlockId, - extrinsic: ::Extrinsic, + extrinsic: ::Extrinsic, ) -> Result<(), ()> { futures::executor::block_on(self.0.submit_one(&at, extrinsic)) .map(|_| ()) diff --git a/client/peerset/Cargo.toml b/client/peerset/Cargo.toml index 16a71b5f6d..31de04c497 100644 --- a/client/peerset/Cargo.toml +++ b/client/peerset/Cargo.toml @@ -2,7 +2,7 @@ description = "Connectivity manager based on reputation" homepage = "http://parity.io" license = "GPL-3.0" -name = "substrate-peerset" +name = "sc-peerset" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" diff --git a/client/peerset/tests/fuzz.rs b/client/peerset/tests/fuzz.rs index be29916c34..604bbcc831 100644 --- a/client/peerset/tests/fuzz.rs +++ b/client/peerset/tests/fuzz.rs @@ -19,7 +19,7 @@ use libp2p::PeerId; use rand::distributions::{Distribution, Uniform, WeightedIndex}; use rand::seq::IteratorRandom; use std::{collections::HashMap, collections::HashSet, iter, pin::Pin, task::Poll}; -use substrate_peerset::{IncomingIndex, Message, PeersetConfig, Peerset}; +use sc_peerset::{IncomingIndex, Message, PeersetConfig, Peerset}; #[test] fn run() { diff --git a/client/rpc-servers/Cargo.toml b/client/rpc-servers/Cargo.toml index c3b9802f56..5fd4d0d8eb 100644 --- a/client/rpc-servers/Cargo.toml +++ b/client/rpc-servers/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "substrate-rpc-servers" +name = "sc-rpc-server" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" @@ -10,7 +10,7 @@ pubsub = { package = "jsonrpc-pubsub", version = "14.0.3" } log = "0.4.8" serde = "1.0.101" serde_json = "1.0.41" -sr-primitives = { path = "../../primitives/sr-primitives" } +sp-runtime = { path = "../../primitives/sr-primitives" } [target.'cfg(not(target_os = "unknown"))'.dependencies] http = { package = "jsonrpc-http-server", version = "14.0.3" } diff --git a/client/rpc/Cargo.toml b/client/rpc/Cargo.toml index afc79ed026..b387a3099d 100644 --- a/client/rpc/Cargo.toml +++ b/client/rpc/Cargo.toml @@ -1,28 +1,28 @@ [package] -name = "substrate-rpc" +name = "sc-rpc" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" [dependencies] api = { package = "sc-rpc-api", path = "./api" } -client-api = { package = "substrate-client-api", path = "../api" } -client = { package = "substrate-client", path = "../" } -sr-api = { path = "../../primitives/sr-api" } +client-api = { package = "sc-client-api", path = "../api" } +client = { package = "sc-client", path = "../" } +sp-api = { path = "../../primitives/sr-api" } codec = { package = "parity-scale-codec", version = "1.0.0" } futures = { version = "0.3.1", features = ["compat"] } jsonrpc-pubsub = "14.0.3" log = "0.4.8" -primitives = { package = "substrate-primitives", path = "../../primitives/core" } +primitives = { package = "sp-core", path = "../../primitives/core" } rpc = { package = "jsonrpc-core", version = "14.0.3" } -runtime_version = { package = "sr-version", path = "../../primitives/sr-version" } +runtime_version = { package = "sp-version", path = "../../primitives/sr-version" } serde_json = "1.0.41" -session = { package = "substrate-session", path = "../../primitives/session" } -sr-primitives = { path = "../../primitives/sr-primitives" } -rpc-primitives = { package = "substrate-rpc-primitives", path = "../../primitives/rpc" } -state_machine = { package = "substrate-state-machine", path = "../../primitives/state-machine" } -substrate-executor = { path = "../executor" } -substrate-keystore = { path = "../keystore" } +session = { package = "sp-sesssion", path = "../../primitives/session" } +sp-runtime = { path = "../../primitives/sr-primitives" } +rpc-primitives = { package = "sp-rpc", path = "../../primitives/rpc" } +state_machine = { package = "sp-state-machine", path = "../../primitives/state-machine" } +sc-executor = { path = "../executor" } +sc-keystore = { path = "../keystore" } txpool-api = { package = "sp-transaction-pool-api", path = "../../primitives/transaction-pool" } sp-blockchain = { path = "../../primitives/blockchain" } hash-db = { version = "0.15.2", default-features = false } @@ -31,9 +31,9 @@ parking_lot = { version = "0.9.0" } [dev-dependencies] assert_matches = "1.3.0" futures01 = { package = "futures", version = "0.1.29" } -network = { package = "substrate-network", path = "../network" } +network = { package = "sc-network", path = "../network" } rustc-hex = "2.0.1" -sr-io = { path = "../../primitives/sr-io" } +sp-io = { path = "../../primitives/sr-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" } +txpool = { package = "sc-tracing-pool", path = "../transaction-pool" } diff --git a/client/rpc/api/Cargo.toml b/client/rpc/api/Cargo.toml index acc4aa1c00..533744ae84 100644 --- a/client/rpc/api/Cargo.toml +++ b/client/rpc/api/Cargo.toml @@ -14,9 +14,9 @@ jsonrpc-derive = "14.0.3" jsonrpc-pubsub = "14.0.3" log = "0.4.8" parking_lot = "0.9.0" -primitives = { package = "substrate-primitives", path = "../../../primitives/core" } -runtime_version = { package = "sr-version", path = "../../../primitives/sr-version" } +primitives = { package = "sp-core", path = "../../../primitives/core" } +runtime_version = { package = "sp-version", path = "../../../primitives/sr-version" } serde = { version = "1.0.101", features = ["derive"] } serde_json = "1.0.41" txpool-api = { package = "sp-transaction-pool-api", path = "../../../primitives/transaction-pool" } -rpc-primitives = { package = "substrate-rpc-primitives", path = "../../../primitives/rpc" } +rpc-primitives = { package = "sp-rpc", path = "../../../primitives/rpc" } diff --git a/client/rpc/src/author/mod.rs b/client/rpc/src/author/mod.rs index 9380bc46f5..2c101e3a80 100644 --- a/client/rpc/src/author/mod.rs +++ b/client/rpc/src/author/mod.rs @@ -35,8 +35,8 @@ use api::Subscriptions; use jsonrpc_pubsub::{typed::Subscriber, SubscriptionId}; use codec::{Encode, Decode}; use primitives::{Bytes, Blake2Hasher, H256, traits::BareCryptoStorePtr}; -use sr_api::ConstructRuntimeApi; -use sr_primitives::{generic, traits::{self, ProvideRuntimeApi}}; +use sp_api::ConstructRuntimeApi; +use sp_runtime::{generic, traits::{self, ProvideRuntimeApi}}; use txpool_api::{ TransactionPool, InPoolTransaction, TransactionStatus, BlockHash, TxHash, TransactionFor, IntoPoolError, diff --git a/client/rpc/src/chain/chain_full.rs b/client/rpc/src/chain/chain_full.rs index 945ed19838..aa11481a3e 100644 --- a/client/rpc/src/chain/chain_full.rs +++ b/client/rpc/src/chain/chain_full.rs @@ -23,7 +23,7 @@ use api::Subscriptions; use client_api::{CallExecutor, backend::Backend}; use client::Client; use primitives::{H256, Blake2Hasher}; -use sr_primitives::{ +use sp_runtime::{ generic::{BlockId, SignedBlock}, traits::{Block as BlockT}, }; diff --git a/client/rpc/src/chain/chain_light.rs b/client/rpc/src/chain/chain_light.rs index 94afc7a9d3..63cb067619 100644 --- a/client/rpc/src/chain/chain_light.rs +++ b/client/rpc/src/chain/chain_light.rs @@ -29,7 +29,7 @@ use client::{ }, }; use primitives::{H256, Blake2Hasher}; -use sr_primitives::{ +use sp_runtime::{ generic::{BlockId, SignedBlock}, traits::{Block as BlockT}, }; diff --git a/client/rpc/src/chain/mod.rs b/client/rpc/src/chain/mod.rs index 8c35df0bf7..42e04936a2 100644 --- a/client/rpc/src/chain/mod.rs +++ b/client/rpc/src/chain/mod.rs @@ -38,7 +38,7 @@ use client::{ use jsonrpc_pubsub::{typed::Subscriber, SubscriptionId}; use primitives::{H256, Blake2Hasher}; use rpc_primitives::{number::NumberOrHex, list::ListOrValue}; -use sr_primitives::{ +use sp_runtime::{ generic::{BlockId, SignedBlock}, traits::{Block as BlockT, Header, NumberFor}, }; diff --git a/client/rpc/src/state/mod.rs b/client/rpc/src/state/mod.rs index 491ea33969..df9a6709b9 100644 --- a/client/rpc/src/state/mod.rs +++ b/client/rpc/src/state/mod.rs @@ -33,11 +33,11 @@ use primitives::{ storage::{StorageKey, StorageData, StorageChangeSet}, }; use runtime_version::RuntimeVersion; -use sr_primitives::{ +use sp_runtime::{ traits::{Block as BlockT, ProvideRuntimeApi}, }; -use sr_api::Metadata; +use sp_api::Metadata; use self::error::{Error, FutureResult}; diff --git a/client/rpc/src/state/state_full.rs b/client/rpc/src/state/state_full.rs index 55b6e65d48..698d42f101 100644 --- a/client/rpc/src/state/state_full.rs +++ b/client/rpc/src/state/state_full.rs @@ -38,12 +38,12 @@ use primitives::{ }; use runtime_version::RuntimeVersion; use state_machine::ExecutionStrategy; -use sr_primitives::{ +use sp_runtime::{ generic::BlockId, traits::{Block as BlockT, Header, NumberFor, ProvideRuntimeApi, SaturatedConversion}, }; -use sr_api::Metadata; +use sp_api::Metadata; use super::{StateBackend, error::{FutureResult, Error, Result}, client_err}; diff --git a/client/rpc/src/state/state_light.rs b/client/rpc/src/state/state_light.rs index c246312749..62d3404d8e 100644 --- a/client/rpc/src/state/state_light.rs +++ b/client/rpc/src/state/state_light.rs @@ -53,7 +53,7 @@ use primitives::{ storage::{StorageKey, StorageData, StorageChangeSet}, }; use runtime_version::RuntimeVersion; -use sr_primitives::{ +use sp_runtime::{ generic::BlockId, traits::Block as BlockT, }; diff --git a/client/rpc/src/state/tests.rs b/client/rpc/src/state/tests.rs index f6658b272a..b77e5a8291 100644 --- a/client/rpc/src/state/tests.rs +++ b/client/rpc/src/state/tests.rs @@ -22,7 +22,7 @@ use std::sync::Arc; use assert_matches::assert_matches; use futures01::stream::Stream; use primitives::storage::well_known_keys; -use sr_io::hashing::blake2_256; +use sp_io::hashing::blake2_256; use test_client::{ prelude::*, consensus::BlockOrigin, diff --git a/client/rpc/src/system/mod.rs b/client/rpc/src/system/mod.rs index 88d2938665..d77b2583a5 100644 --- a/client/rpc/src/system/mod.rs +++ b/client/rpc/src/system/mod.rs @@ -21,7 +21,7 @@ mod tests; use futures::{channel::{mpsc, oneshot}, compat::Compat}; use api::Receiver; -use sr_primitives::traits::{self, Header as HeaderT}; +use sp_runtime::traits::{self, Header as HeaderT}; use self::error::Result; pub use api::system::*; diff --git a/client/service/Cargo.toml b/client/service/Cargo.toml index bf9491add3..ea69b14e42 100644 --- a/client/service/Cargo.toml +++ b/client/service/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "substrate-service" +name = "sc-service" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" @@ -10,7 +10,7 @@ default = ["rocksdb"] # a path to a database, an error will be produced at runtime. rocksdb = ["client_db/kvdb-rocksdb"] wasmtime = [ - "substrate-executor/wasmtime", + "sc-executor/wasmtime", ] [dependencies] @@ -28,37 +28,37 @@ serde = "1.0.101" serde_json = "1.0.41" sysinfo = "0.9.5" target_info = "0.1.0" -keystore = { package = "substrate-keystore", path = "../keystore" } -sr-io = { path = "../../primitives/sr-io" } -sr-primitives = { path = "../../primitives/sr-primitives" } +keystore = { package = "sc-keystore", path = "../keystore" } +sp-io = { path = "../../primitives/sr-io" } +sp-runtime = { path = "../../primitives/sr-primitives" } sp-blockchain = { path = "../../primitives/blockchain" } -primitives = { package = "substrate-primitives", path = "../../primitives/core" } -session = { package = "substrate-session", path = "../../primitives/session" } -app-crypto = { package = "substrate-application-crypto", path = "../../primitives/application-crypto" } -consensus_common = { package = "substrate-consensus-common", path = "../../primitives/consensus/common" } -network = { package = "substrate-network", path = "../network" } -chain-spec = { package = "substrate-chain-spec", path = "../chain-spec" } -client-api = { package = "substrate-client-api", path = "../api" } -client = { package = "substrate-client", path = "../" } -sr-api = { path = "../../primitives/sr-api" } +primitives = { package = "sp-core", path = "../../primitives/core" } +session = { package = "sp-sesssion", path = "../../primitives/session" } +app-crypto = { package = "sc-application-crypto", path = "../../primitives/application-crypto" } +consensus_common = { package = "sp-consensus", path = "../../primitives/consensus/common" } +network = { package = "sc-network", path = "../network" } +chain-spec = { package = "sc-chain-spec", path = "../chain-spec" } +client-api = { package = "sc-client-api", path = "../api" } +client = { package = "sc-client", path = "../" } +sp-api = { path = "../../primitives/sr-api" } txpool-runtime-api = { package = "sp-transaction-pool-runtime-api", path = "../../primitives/transaction-pool/runtime-api" } -client_db = { package = "substrate-client-db", path = "../db" } +client_db = { package = "sc-client-db", path = "../db" } codec = { package = "parity-scale-codec", version = "1.0.0" } -substrate-executor = { path = "../executor" } -txpool = { package = "sc-transaction-pool", path = "../transaction-pool" } +sc-executor = { path = "../executor" } +txpool = { package = "sc-tracing-pool", path = "../transaction-pool" } txpool-api = { package = "sp-transaction-pool-api", path = "../../primitives/transaction-pool" } -rpc-servers = { package = "substrate-rpc-servers", path = "../rpc-servers" } -rpc = { package = "substrate-rpc", path = "../rpc" } -tel = { package = "substrate-telemetry", path = "../telemetry" } -offchain = { package = "substrate-offchain", path = "../offchain" } +rpc-servers = { package = "sc-rpc-server", path = "../rpc-servers" } +rpc = { package = "sc-rpc", path = "../rpc" } +tel = { package = "sc-telemetry", path = "../telemetry" } +offchain = { package = "sc-offchain", path = "../offchain" } parity-multiaddr = { package = "parity-multiaddr", version = "0.5.0" } grafana-data-source = { path = "../grafana-data-source" } -substrate-tracing = { package = "substrate-tracing", path = "../tracing" } +sc-tracing = { package = "sc-tracing", path = "../tracing" } tracing = "0.1.10" [dev-dependencies] substrate-test-runtime-client = { path = "../../test/utils/runtime/client" } -babe-primitives = { package = "substrate-consensus-babe-primitives", path = "../../primitives/consensus/babe" } -grandpa = { package = "substrate-finality-grandpa", path = "../finality-grandpa" } -grandpa-primitives = { package = "substrate-finality-grandpa-primitives", path = "../../primitives/finality-grandpa" } +babe-primitives = { package = "sp-consensus-babe", path = "../../primitives/consensus/babe" } +grandpa = { package = "sc-finality-grandpa", path = "../finality-grandpa" } +grandpa-primitives = { package = "sp-finality-granpda", path = "../../primitives/finality-grandpa" } tokio = "0.1" diff --git a/client/service/src/builder.rs b/client/service/src/builder.rs index 2f67748337..48a1b374f5 100644 --- a/client/service/src/builder.rs +++ b/client/service/src/builder.rs @@ -40,12 +40,12 @@ use network::{config::BoxFinalityProofRequestBuilder, specialization::NetworkSpe use parking_lot::{Mutex, RwLock}; use primitives::{Blake2Hasher, H256, Hasher}; use rpc; -use sr_api::ConstructRuntimeApi; -use sr_primitives::generic::BlockId; -use sr_primitives::traits::{ +use sp_api::ConstructRuntimeApi; +use sp_runtime::generic::BlockId; +use sp_runtime::traits::{ Block as BlockT, ProvideRuntimeApi, NumberFor, Header, SaturatedConversion, }; -use substrate_executor::{NativeExecutor, NativeExecutionDispatch}; +use sc_executor::{NativeExecutor, NativeExecutionDispatch}; use std::{ io::{Read, Write, Seek}, marker::PhantomData, sync::Arc, time::SystemTime @@ -712,11 +712,11 @@ ServiceBuilder< > where Client: ProvideRuntimeApi, as ProvideRuntimeApi>::Api: - sr_api::Metadata + + sp_api::Metadata + offchain::OffchainWorkerApi + txpool_runtime_api::TaggedTransactionQueue + session::SessionKeys + - sr_api::ApiExt, + sp_api::ApiExt, TBl: BlockT::Out>, TRtApi: ConstructRuntimeApi> + 'static + Send + Sync, TCfg: Default, @@ -1119,7 +1119,7 @@ ServiceBuilder< // Instrumentation if let Some(tracing_targets) = config.tracing_targets.as_ref() { - let subscriber = substrate_tracing::ProfilingSubscriber::new( + let subscriber = sc_tracing::ProfilingSubscriber::new( config.tracing_receiver, tracing_targets ); match tracing::subscriber::set_global_default(subscriber) { diff --git a/client/service/src/chain_ops.rs b/client/service/src/chain_ops.rs index 239d8df71d..742167069a 100644 --- a/client/service/src/chain_ops.rs +++ b/client/service/src/chain_ops.rs @@ -26,10 +26,10 @@ use futures03::{ TryFutureExt as _, }; use primitives::{Blake2Hasher, Hasher}; -use sr_primitives::traits::{ +use sp_runtime::traits::{ Block as BlockT, NumberFor, One, Zero, Header, SaturatedConversion }; -use sr_primitives::generic::{BlockId, SignedBlock}; +use sp_runtime::generic::{BlockId, SignedBlock}; use codec::{Decode, Encode, IoReader}; use client::Client; use consensus_common::import_queue::{IncomingBlock, Link, BlockImportError, BlockImportResult, ImportQueue}; diff --git a/client/service/src/config.rs b/client/service/src/config.rs index 6ef2aa46ac..310d185b4d 100644 --- a/client/service/src/config.rs +++ b/client/service/src/config.rs @@ -19,7 +19,7 @@ pub use client::ExecutionStrategies; pub use client_db::{kvdb::KeyValueDB, PruningMode}; pub use network::config::{ExtTransport, NetworkConfiguration, Roles}; -pub use substrate_executor::WasmExecutionMethod; +pub use sc_executor::WasmExecutionMethod; use std::{path::PathBuf, net::SocketAddr, sync::Arc}; pub use txpool::txpool::Options as TransactionPoolOptions; @@ -103,7 +103,7 @@ pub struct Configuration { /// Tracing targets pub tracing_targets: Option, /// Tracing receiver - pub tracing_receiver: substrate_tracing::TracingReceiver, + pub tracing_receiver: sc_tracing::TracingReceiver, } /// Configuration of the database of the client. diff --git a/client/service/src/lib.rs b/client/service/src/lib.rs index 2115fd50a7..1a86e05b88 100644 --- a/client/service/src/lib.rs +++ b/client/service/src/lib.rs @@ -49,8 +49,8 @@ use network::{ use log::{log, warn, debug, error, Level}; use codec::{Encode, Decode}; use primitives::{Blake2Hasher, H256}; -use sr_primitives::generic::BlockId; -use sr_primitives::traits::{NumberFor, Block as BlockT}; +use sp_runtime::generic::BlockId; +use sp_runtime::traits::{NumberFor, Block as BlockT}; pub use self::error::Error; pub use self::builder::{ServiceBuilder, ServiceBuilderCommand}; @@ -595,7 +595,7 @@ fn transactions_to_propagate(pool: &Pool) where Pool: TransactionPool, B: BlockT, - H: std::hash::Hash + Eq + sr_primitives::traits::Member + sr_primitives::traits::MaybeSerialize, + H: std::hash::Hash + Eq + sp_runtime::traits::Member + sp_runtime::traits::MaybeSerialize, E: IntoPoolError + From, { pool.ready() @@ -614,7 +614,7 @@ where C: network::ClientHandle + Send + Sync, Pool: 'static + TransactionPool, B: BlockT, - H: std::hash::Hash + Eq + sr_primitives::traits::Member + sr_primitives::traits::MaybeSerialize, + H: std::hash::Hash + Eq + sp_runtime::traits::Member + sp_runtime::traits::MaybeSerialize, E: 'static + IntoPoolError + From, { fn transactions(&self) -> Vec<(H, ::Extrinsic)> { @@ -678,7 +678,7 @@ mod tests { use super::*; use futures03::executor::block_on; use consensus_common::SelectChain; - use sr_primitives::traits::BlindCheckable; + use sp_runtime::traits::BlindCheckable; use substrate_test_runtime_client::{prelude::*, runtime::{Extrinsic, Transfer}}; use txpool::{BasicPool, FullChainApi}; diff --git a/client/service/test/Cargo.toml b/client/service/test/Cargo.toml index fa7f834efa..b337521d96 100644 --- a/client/service/test/Cargo.toml +++ b/client/service/test/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "substrate-service-test" +name = "sc-service-test" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" @@ -12,10 +12,10 @@ log = "0.4.8" env_logger = "0.7.0" fdlimit = "0.1.1" futures03 = { package = "futures", version = "0.3.1", features = ["compat"] } -service = { package = "substrate-service", path = "../../service", default-features = false } -network = { package = "substrate-network", path = "../../network" } -consensus = { package = "substrate-consensus-common", path = "../../../primitives/consensus/common" } -client = { package = "substrate-client", path = "../../" } -sr-primitives = { path = "../../../primitives/sr-primitives" } -primitives = { package = "substrate-primitives", path = "../../../primitives/core" } +service = { package = "sc-service", path = "../../service", default-features = false } +network = { package = "sc-network", path = "../../network" } +consensus = { package = "sp-consensus", path = "../../../primitives/consensus/common" } +client = { package = "sc-client", path = "../../" } +sp-runtime = { path = "../../../primitives/sr-primitives" } +primitives = { package = "sp-core", path = "../../../primitives/core" } txpool-api = { package = "sp-transaction-pool-api", path = "../../../primitives/transaction-pool" } diff --git a/client/service/test/src/lib.rs b/client/service/test/src/lib.rs index 73dc551800..d9a5d417c4 100644 --- a/client/service/test/src/lib.rs +++ b/client/service/test/src/lib.rs @@ -35,7 +35,7 @@ use service::{ }; use network::{multiaddr, Multiaddr}; use network::config::{NetworkConfiguration, TransportConfig, NodeKeyConfig, Secret, NonReservedPeerMode}; -use sr_primitives::{generic::BlockId, traits::Block as BlockT}; +use sp_runtime::{generic::BlockId, traits::Block as BlockT}; use txpool_api::TransactionPool; /// Maximum duration of single wait call. diff --git a/client/src/call_executor.rs b/client/src/call_executor.rs index 2a2fc3ad55..e069885047 100644 --- a/client/src/call_executor.rs +++ b/client/src/call_executor.rs @@ -16,7 +16,7 @@ use std::{sync::Arc, panic::UnwindSafe, result, cell::RefCell}; use codec::{Encode, Decode}; -use sr_primitives::{ +use sp_runtime::{ generic::BlockId, traits::Block as BlockT, traits::NumberFor, }; use state_machine::{ @@ -30,7 +30,7 @@ use primitives::{ H256, Blake2Hasher, NativeOrEncoded, NeverNativeValue, traits::CodeExecutor, }; -use sr_api::{ProofRecorder, InitializeBlock}; +use sp_api::{ProofRecorder, InitializeBlock}; use client_api::{backend, call_executor::CallExecutor}; /// Call executor that executes methods locally, querying all required diff --git a/client/src/cht.rs b/client/src/cht.rs index 7e0552f2f2..15a3b7718c 100644 --- a/client/src/cht.rs +++ b/client/src/cht.rs @@ -28,7 +28,7 @@ use codec::Encode; use trie; use primitives::{H256, convert_hash}; -use sr_primitives::traits::{Header as HeaderT, SimpleArithmetic, Zero, One}; +use sp_runtime::traits::{Header as HeaderT, SimpleArithmetic, Zero, One}; use state_machine::backend::InMemory as InMemoryState; use state_machine::{MemoryDB, TrieBackend, Backend as StateBackend, StorageProof, prove_read_on_trie_backend, read_proof_check, read_proof_check_on_proving_backend}; diff --git a/client/src/client.rs b/client/src/client.rs index 6d6a690d84..88ecfecd21 100644 --- a/client/src/client.rs +++ b/client/src/client.rs @@ -31,8 +31,8 @@ use primitives::{ storage::{StorageKey, StorageData, well_known_keys}, traits::CodeExecutor, }; -use substrate_telemetry::{telemetry, SUBSTRATE_INFO}; -use sr_primitives::{ +use sc_telemetry::{telemetry, SUBSTRATE_INFO}; +use sp_runtime::{ Justification, BuildStorage, generic::{BlockId, SignedBlock, DigestItem}, traits::{ @@ -59,7 +59,7 @@ use sp_blockchain::{self as blockchain, HeaderMetadata, CachedHeaderMetadata, }; -use sr_api::{CallRuntimeAt, ConstructRuntimeApi, Core as CoreApi, ProofRecorder, InitializeBlock}; +use sp_api::{CallRuntimeAt, ConstructRuntimeApi, Core as CoreApi, ProofRecorder, InitializeBlock}; use block_builder::BlockBuilderApi; pub use client_api::{ @@ -1313,7 +1313,7 @@ impl ChainHeaderBackend for Client wher } } -impl sr_primitives::traits::BlockIdTo for Client where +impl sp_runtime::traits::BlockIdTo for Client where B: backend::Backend, E: CallExecutor + Send + Sync, Block: BlockT, @@ -1768,7 +1768,7 @@ pub(crate) mod tests { use std::collections::HashMap; use super::*; use primitives::blake2_256; - use sr_primitives::DigestItem; + use sp_runtime::DigestItem; use consensus::{BlockOrigin, SelectChain, BlockImport}; use test_client::{ prelude::*, diff --git a/client/src/genesis.rs b/client/src/genesis.rs index 94822466bb..d274316742 100644 --- a/client/src/genesis.rs +++ b/client/src/genesis.rs @@ -16,7 +16,7 @@ //! Tool for creating the genesis block. -use sr_primitives::traits::{Block as BlockT, Header as HeaderT, Hash as HashT, Zero}; +use sp_runtime::traits::{Block as BlockT, Header as HeaderT, Hash as HashT, Zero}; /// Create a genesis block, given the initial storage. pub fn construct_genesis_block< diff --git a/client/src/in_mem.rs b/client/src/in_mem.rs index e6140e6d74..e5964669c9 100644 --- a/client/src/in_mem.rs +++ b/client/src/in_mem.rs @@ -23,9 +23,9 @@ use primitives::{ChangesTrieConfiguration, storage::well_known_keys}; use primitives::offchain::storage::{ InMemOffchainStorage as OffchainStorage }; -use sr_primitives::generic::{BlockId, DigestItem}; -use sr_primitives::traits::{Block as BlockT, Header as HeaderT, Zero, NumberFor}; -use sr_primitives::{Justification, StorageOverlay, ChildrenStorageOverlay}; +use sp_runtime::generic::{BlockId, DigestItem}; +use sp_runtime::traits::{Block as BlockT, Header as HeaderT, Zero, NumberFor}; +use sp_runtime::{Justification, StorageOverlay, ChildrenStorageOverlay}; use state_machine::backend::{Backend as StateBackend, InMemory}; use state_machine::{self, InMemoryChangesTrieStorage, ChangesTrieAnchorBlockId, ChangesTrieTransaction}; use hash_db::{Hasher, Prefix}; diff --git a/client/src/leaves.rs b/client/src/leaves.rs index 83cfa59896..91ea00a2f3 100644 --- a/client/src/leaves.rs +++ b/client/src/leaves.rs @@ -19,7 +19,7 @@ use std::collections::BTreeMap; use std::cmp::Reverse; use kvdb::{KeyValueDB, DBTransaction}; -use sr_primitives::traits::SimpleArithmetic; +use sp_runtime::traits::SimpleArithmetic; use codec::{Encode, Decode}; use sp_blockchain::{Error, Result}; diff --git a/client/src/lib.rs b/client/src/lib.rs index 1bbfbe0270..00a0d8c269 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -28,7 +28,7 @@ //! Creating a [`Client`] is done by calling the `new` method and passing to it a //! [`Backend`](backend::Backend) and an [`Executor`](CallExecutor). //! -//! The former is typically provided by the `substrate-client-db` crate. +//! The former is typically provided by the `sc-client-db` crate. //! //! The latter typically requires passing one of: //! @@ -46,9 +46,9 @@ //! //! ``` //! use std::sync::Arc; -//! use substrate_client::{Client, in_mem::Backend, LocalCallExecutor}; +//! use sc_client::{Client, in_mem::Backend, LocalCallExecutor}; //! use primitives::Blake2Hasher; -//! use sr_primitives::{StorageOverlay, ChildrenStorageOverlay}; +//! use sp_runtime::{StorageOverlay, ChildrenStorageOverlay}; //! use executor::{NativeExecutor, WasmExecutionMethod}; //! //! // In this example, we're using the `Block` and `RuntimeApi` types from the diff --git a/client/src/light/backend.rs b/client/src/light/backend.rs index 2077713ba5..b8dc0c34d7 100644 --- a/client/src/light/backend.rs +++ b/client/src/light/backend.rs @@ -25,8 +25,8 @@ use state_machine::{ Backend as StateBackend, TrieBackend, backend::InMemory as InMemoryState, ChangesTrieTransaction }; use primitives::offchain::storage::InMemOffchainStorage; -use sr_primitives::{generic::BlockId, Justification, StorageOverlay, ChildrenStorageOverlay}; -use sr_primitives::traits::{Block as BlockT, NumberFor, Zero, Header}; +use sp_runtime::{generic::BlockId, Justification, StorageOverlay, ChildrenStorageOverlay}; +use sp_runtime::traits::{Block as BlockT, NumberFor, Zero, Header}; use crate::in_mem::{self, check_genesis_storage}; use sp_blockchain::{ Error as ClientError, Result as ClientResult }; use client_api::{ diff --git a/client/src/light/blockchain.rs b/client/src/light/blockchain.rs index 11982e4529..03ee035031 100644 --- a/client/src/light/blockchain.rs +++ b/client/src/light/blockchain.rs @@ -20,8 +20,8 @@ use std::future::Future; use std::sync::Arc; -use sr_primitives::{Justification, generic::BlockId}; -use sr_primitives::traits::{Block as BlockT, Header as HeaderT, NumberFor, Zero}; +use sp_runtime::{Justification, generic::BlockId}; +use sp_runtime::traits::{Block as BlockT, Header as HeaderT, NumberFor, Zero}; use sp_blockchain::{ HeaderMetadata, CachedHeaderMetadata, diff --git a/client/src/light/call_executor.rs b/client/src/light/call_executor.rs index c998ac0e45..8571c331b2 100644 --- a/client/src/light/call_executor.rs +++ b/client/src/light/call_executor.rs @@ -25,7 +25,7 @@ use primitives::{ H256, Blake2Hasher, convert_hash, NativeOrEncoded, traits::CodeExecutor, }; -use sr_primitives::{ +use sp_runtime::{ generic::BlockId, traits::{One, Block as BlockT, Header as HeaderT, NumberFor}, }; use externalities::Extensions; @@ -36,7 +36,7 @@ use state_machine::{ }; use hash_db::Hasher; -use sr_api::{ProofRecorder, InitializeBlock}; +use sp_api::{ProofRecorder, InitializeBlock}; use sp_blockchain::{Error as ClientError, Result as ClientResult}; @@ -460,7 +460,7 @@ mod tests { let remote_client = test_client::new(); for i in 1u32..3u32 { let mut digest = Digest::default(); - digest.push(sr_primitives::generic::DigestItem::Other::(i.to_le_bytes().to_vec())); + digest.push(sp_runtime::generic::DigestItem::Other::(i.to_le_bytes().to_vec())); remote_client.import_justified( BlockOrigin::Own, remote_client.new_block(digest).unwrap().bake().unwrap(), diff --git a/client/src/light/fetcher.rs b/client/src/light/fetcher.rs index 9db6dda172..9b2c308668 100644 --- a/client/src/light/fetcher.rs +++ b/client/src/light/fetcher.rs @@ -23,7 +23,7 @@ use std::marker::PhantomData; use hash_db::{HashDB, Hasher, EMPTY_PREFIX}; use codec::{Decode, Encode}; use primitives::{convert_hash, traits::CodeExecutor, H256}; -use sr_primitives::traits::{ +use sp_runtime::traits::{ Block as BlockT, Header as HeaderT, Hash, HashFor, NumberFor, SimpleArithmetic, CheckedConversion, Zero, }; @@ -340,7 +340,7 @@ pub mod tests { use crate::light::blockchain::tests::{DummyStorage, DummyBlockchain}; use primitives::{blake2_256, Blake2Hasher, H256}; use primitives::storage::{well_known_keys, StorageKey}; - use sr_primitives::generic::BlockId; + use sp_runtime::generic::BlockId; use state_machine::Backend; use super::*; diff --git a/client/src/light/mod.rs b/client/src/light/mod.rs index e9dec286f6..bd8040d22b 100644 --- a/client/src/light/mod.rs +++ b/client/src/light/mod.rs @@ -25,8 +25,8 @@ use std::sync::Arc; use executor::RuntimeInfo; use primitives::{H256, Blake2Hasher, traits::CodeExecutor}; -use sr_primitives::BuildStorage; -use sr_primitives::traits::Block as BlockT; +use sp_runtime::BuildStorage; +use sp_runtime::traits::Block as BlockT; use sp_blockchain::Result as ClientResult; use crate::call_executor::LocalCallExecutor; diff --git a/client/state-db/Cargo.toml b/client/state-db/Cargo.toml index d2752c14dd..175b38f7f0 100644 --- a/client/state-db/Cargo.toml +++ b/client/state-db/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "substrate-state-db" +name = "sc-state-db" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" @@ -7,7 +7,7 @@ edition = "2018" [dependencies] parking_lot = "0.9.0" log = "0.4.8" -primitives = { package = "substrate-primitives", path = "../../primitives/core" } +primitives = { package = "sp-core", path = "../../primitives/core" } codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } [dev-dependencies] diff --git a/client/telemetry/Cargo.toml b/client/telemetry/Cargo.toml index 07a296b02f..bb18268275 100644 --- a/client/telemetry/Cargo.toml +++ b/client/telemetry/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "substrate-telemetry" +name = "sc-telemetry" version = "2.0.0" authors = ["Parity Technologies "] description = "Telemetry utils" diff --git a/client/telemetry/src/lib.rs b/client/telemetry/src/lib.rs index 768fc2df84..b4cc756bf0 100644 --- a/client/telemetry/src/lib.rs +++ b/client/telemetry/src/lib.rs @@ -37,8 +37,8 @@ //! ```no_run //! use futures::prelude::*; //! -//! let telemetry = substrate_telemetry::init_telemetry(substrate_telemetry::TelemetryConfig { -//! endpoints: substrate_telemetry::TelemetryEndpoints::new(vec![ +//! let telemetry = sc_telemetry::init_telemetry(sc_telemetry::TelemetryConfig { +//! endpoints: sc_telemetry::TelemetryEndpoints::new(vec![ //! // The `0` is the maximum verbosity level of messages to send to this endpoint. //! ("wss://example.com".into(), 0) //! ]), @@ -52,7 +52,7 @@ //! }); //! //! // Sends a message on the telemetry. -//! substrate_telemetry::telemetry!(substrate_telemetry::SUBSTRATE_INFO; "test"; +//! sc_telemetry::telemetry!(sc_telemetry::SUBSTRATE_INFO; "test"; //! "foo" => "bar", //! ) //! ``` @@ -124,7 +124,7 @@ pub struct Telemetry { /// Behind the `Mutex` in `Telemetry`. /// /// Note that ideally we wouldn't have to make the `Telemetry` clonable, as that would remove the -/// need for a `Mutex`. However there is currently a weird hack in place in `substrate-service` +/// need for a `Mutex`. However there is currently a weird hack in place in `sc-service` /// where we extract the telemetry registration so that it continues running during the shutdown /// process. struct TelemetryInner { diff --git a/client/tracing/Cargo.toml b/client/tracing/Cargo.toml index 013135486a..b94059edcd 100644 --- a/client/tracing/Cargo.toml +++ b/client/tracing/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "substrate-tracing" +name = "sc-tracing" version = "2.0.0" license = "GPL-3.0" authors = ["Parity Technologies "] @@ -14,7 +14,7 @@ serde_json = "1.0.41" slog = { version = "2.5.2", features = ["nested-values"] } tracing-core = "0.1.7" -substrate-telemetry = { path = "../telemetry" } +sc-telemetry = { path = "../telemetry" } grafana-data-source = { path = "../grafana-data-source" } [dev-dependencies] diff --git a/client/tracing/src/lib.rs b/client/tracing/src/lib.rs index 1ab2931147..b87273bdaa 100644 --- a/client/tracing/src/lib.rs +++ b/client/tracing/src/lib.rs @@ -54,7 +54,7 @@ use tracing_core::{ }; use grafana_data_source::{self, record_metrics}; -use substrate_telemetry::{telemetry, SUBSTRATE_INFO}; +use sc_telemetry::{telemetry, SUBSTRATE_INFO}; /// Used to configure how to receive the metrics #[derive(Debug, Clone)] diff --git a/client/transaction-pool/Cargo.toml b/client/transaction-pool/Cargo.toml index 3f1c80c2de..ef84a21c8b 100644 --- a/client/transaction-pool/Cargo.toml +++ b/client/transaction-pool/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "sc-transaction-pool" +name = "sc-tracing-pool" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" @@ -10,15 +10,15 @@ derive_more = "0.99.2" futures = { version = "0.3.1", features = ["compat", "compat"] } log = "0.4.8" parking_lot = "0.9.0" -primitives = { package = "substrate-primitives", path = "../../primitives/core" } -sr-api = { path = "../../primitives/sr-api" } -sr-primitives = { path = "../../primitives/sr-primitives" } -txpool = { package = "sc-transaction-graph", path = "./graph" } +primitives = { package = "sp-core", path = "../../primitives/core" } +sp-api = { path = "../../primitives/sr-api" } +sp-runtime = { path = "../../primitives/sr-primitives" } +txpool = { package = "sc-tracing-graph", path = "./graph" } txpool-api = { package = "sp-transaction-pool-api", path = "../../primitives/transaction-pool" } txpool-runtime-api = { package = "sp-transaction-pool-runtime-api", path = "../../primitives/transaction-pool/runtime-api" } -client-api = { package = "substrate-client-api", path = "../api" } +client-api = { package = "sc-client-api", path = "../api" } sp-blockchain = { path = "../../primitives/blockchain" } [dev-dependencies] -keyring = { package = "substrate-keyring", path = "../../primitives/keyring" } +keyring = { package = "sp-keyring", path = "../../primitives/keyring" } test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client" } diff --git a/client/transaction-pool/graph/Cargo.toml b/client/transaction-pool/graph/Cargo.toml index c9dd98d8ba..870604d88c 100644 --- a/client/transaction-pool/graph/Cargo.toml +++ b/client/transaction-pool/graph/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "sc-transaction-graph" +name = "sc-tracing-graph" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" @@ -10,8 +10,8 @@ futures = "0.3.1" log = "0.4.8" parking_lot = "0.9.0" serde = { version = "1.0.101", features = ["derive"] } -primitives = { package = "substrate-primitives", path = "../../../primitives/core" } -sr-primitives = { path = "../../../primitives/sr-primitives" } +primitives = { package = "sp-core", path = "../../../primitives/core" } +sp-runtime = { path = "../../../primitives/sr-primitives" } txpool-api = { package = "sp-transaction-pool-api", path = "../../../primitives/transaction-pool" } [dev-dependencies] diff --git a/client/transaction-pool/graph/benches/basics.rs b/client/transaction-pool/graph/benches/basics.rs index 920facaa2c..b5dc63ed5b 100644 --- a/client/transaction-pool/graph/benches/basics.rs +++ b/client/transaction-pool/graph/benches/basics.rs @@ -17,11 +17,11 @@ use criterion::{criterion_group, criterion_main, Criterion}; use futures::executor::block_on; -use sc_transaction_graph::*; -use sr_primitives::transaction_validity::{ValidTransaction, InvalidTransaction}; +use sc_tracing_graph::*; +use sp_runtime::transaction_validity::{ValidTransaction, InvalidTransaction}; use codec::Encode; use test_runtime::{Block, Extrinsic, Transfer, H256, AccountId}; -use sr_primitives::{ +use sp_runtime::{ generic::BlockId, transaction_validity::{TransactionValidity, TransactionTag as Tag}, }; diff --git a/client/transaction-pool/graph/src/base_pool.rs b/client/transaction-pool/graph/src/base_pool.rs index ed2a5e2f6c..77ba175963 100644 --- a/client/transaction-pool/graph/src/base_pool.rs +++ b/client/transaction-pool/graph/src/base_pool.rs @@ -28,8 +28,8 @@ use std::{ use log::{trace, debug, warn}; use serde::Serialize; use primitives::hexdisplay::HexDisplay; -use sr_primitives::traits::Member; -use sr_primitives::transaction_validity::{ +use sp_runtime::traits::Member; +use sp_runtime::transaction_validity::{ TransactionTag as Tag, TransactionLongevity as Longevity, TransactionPriority as Priority, diff --git a/client/transaction-pool/graph/src/error.rs b/client/transaction-pool/graph/src/error.rs index 79006461c6..76a276bb49 100644 --- a/client/transaction-pool/graph/src/error.rs +++ b/client/transaction-pool/graph/src/error.rs @@ -16,7 +16,7 @@ //! Transaction pool errors. -use sr_primitives::transaction_validity::{ +use sp_runtime::transaction_validity::{ TransactionPriority as Priority, InvalidTransaction, UnknownTransaction, }; diff --git a/client/transaction-pool/graph/src/future.rs b/client/transaction-pool/graph/src/future.rs index 8b01e9d654..1c653cc6e6 100644 --- a/client/transaction-pool/graph/src/future.rs +++ b/client/transaction-pool/graph/src/future.rs @@ -23,7 +23,7 @@ use std::{ }; use primitives::hexdisplay::HexDisplay; -use sr_primitives::transaction_validity::{ +use sp_runtime::transaction_validity::{ TransactionTag as Tag, }; diff --git a/client/transaction-pool/graph/src/listener.rs b/client/transaction-pool/graph/src/listener.rs index f9b71555e2..c6a90b0c5b 100644 --- a/client/transaction-pool/graph/src/listener.rs +++ b/client/transaction-pool/graph/src/listener.rs @@ -22,7 +22,7 @@ use std::{ }; use serde::Serialize; use crate::watcher; -use sr_primitives::traits; +use sp_runtime::traits; use log::{debug, trace, warn}; /// Extrinsic pool default listener. diff --git a/client/transaction-pool/graph/src/pool.rs b/client/transaction-pool/graph/src/pool.rs index 7d91ebaf4a..cf5c7a5292 100644 --- a/client/transaction-pool/graph/src/pool.rs +++ b/client/transaction-pool/graph/src/pool.rs @@ -29,7 +29,7 @@ use futures::{ channel::mpsc, future::{Either, ready, join_all}, }; -use sr_primitives::{ +use sp_runtime::{ generic::BlockId, traits::{self, SaturatedConversion}, transaction_validity::{TransactionValidity, TransactionTag as Tag, TransactionValidityError}, @@ -441,7 +441,7 @@ mod tests { use futures::executor::block_on; use super::*; use txpool_api::TransactionStatus; - use sr_primitives::transaction_validity::{ValidTransaction, InvalidTransaction}; + use sp_runtime::transaction_validity::{ValidTransaction, InvalidTransaction}; use codec::Encode; use test_runtime::{Block, Extrinsic, Transfer, H256, AccountId}; use assert_matches::assert_matches; diff --git a/client/transaction-pool/graph/src/ready.rs b/client/transaction-pool/graph/src/ready.rs index 81c370625c..11354e6871 100644 --- a/client/transaction-pool/graph/src/ready.rs +++ b/client/transaction-pool/graph/src/ready.rs @@ -24,8 +24,8 @@ use std::{ use serde::Serialize; use log::debug; use parking_lot::RwLock; -use sr_primitives::traits::Member; -use sr_primitives::transaction_validity::{ +use sp_runtime::traits::Member; +use sp_runtime::transaction_validity::{ TransactionTag as Tag, }; use txpool_api::error; diff --git a/client/transaction-pool/graph/src/validated_pool.rs b/client/transaction-pool/graph/src/validated_pool.rs index f46c2b0cf6..e32dac88eb 100644 --- a/client/transaction-pool/graph/src/validated_pool.rs +++ b/client/transaction-pool/graph/src/validated_pool.rs @@ -31,7 +31,7 @@ use log::{debug, warn}; use futures::channel::mpsc; use parking_lot::{Mutex, RwLock}; -use sr_primitives::{ +use sp_runtime::{ generic::BlockId, traits::{self, SaturatedConversion}, transaction_validity::TransactionTag as Tag, diff --git a/client/transaction-pool/src/api.rs b/client/transaction-pool/src/api.rs index 87b494201d..434a317d67 100644 --- a/client/transaction-pool/src/api.rs +++ b/client/transaction-pool/src/api.rs @@ -25,7 +25,7 @@ use client_api::{ light::{Fetcher, RemoteCallRequest} }; use primitives::{H256, Blake2Hasher, Hasher}; -use sr_primitives::{generic::BlockId, traits::{self, Block as BlockT}, transaction_validity::TransactionValidity}; +use sp_runtime::{generic::BlockId, traits::{self, Block as BlockT}, transaction_validity::TransactionValidity}; use txpool_runtime_api::TaggedTransactionQueue; use crate::error::{self, Error}; @@ -58,7 +58,7 @@ impl txpool::ChainApi for FullChainApi where Block: BlockT, T: traits::ProvideRuntimeApi + traits::BlockIdTo + 'static + Send + Sync, T::Api: TaggedTransactionQueue, - sr_api::ApiErrorFor: Send, + sp_api::ApiErrorFor: Send, { type Block = Block; type Hash = H256; diff --git a/client/transaction-pool/src/lib.rs b/client/transaction-pool/src/lib.rs index 1499ab26d4..62e88af74e 100644 --- a/client/transaction-pool/src/lib.rs +++ b/client/transaction-pool/src/lib.rs @@ -33,7 +33,7 @@ pub use crate::maintainer::{FullBasicPoolMaintainer, LightBasicPoolMaintainer}; use std::{collections::HashMap, sync::Arc}; use futures::{Future, FutureExt}; -use sr_primitives::{ +use sp_runtime::{ generic::BlockId, traits::Block as BlockT, }; diff --git a/client/transaction-pool/src/maintainer.rs b/client/transaction-pool/src/maintainer.rs index f5eeb90b85..7c5d07e0f1 100644 --- a/client/transaction-pool/src/maintainer.rs +++ b/client/transaction-pool/src/maintainer.rs @@ -31,7 +31,7 @@ use client_api::{ light::{Fetcher, RemoteBodyRequest}, }; use primitives::{Blake2Hasher, H256}; -use sr_primitives::{ +use sp_runtime::{ generic::BlockId, traits::{Block as BlockT, Extrinsic, Header, NumberFor, ProvideRuntimeApi, SimpleArithmetic}, }; @@ -384,8 +384,8 @@ mod tests { let fetcher = Arc::new(test_client::new_light_fetcher() .with_remote_body(Some(Box::new(move |_| Ok(vec![fetcher_transaction.clone()])))) .with_remote_call(Some(Box::new(move |_| { - let validity: sr_primitives::transaction_validity::TransactionValidity = - Ok(sr_primitives::transaction_validity::ValidTransaction { + let validity: sp_runtime::transaction_validity::TransactionValidity = + Ok(sp_runtime::transaction_validity::ValidTransaction { priority: 0, requires: Vec::new(), provides: vec![vec![42]], @@ -449,7 +449,7 @@ mod tests { #[test] fn should_revalidate_transactions_at_light_pool() { use std::sync::atomic; - use sr_primitives::transaction_validity::*; + use sp_runtime::transaction_validity::*; let build_fetcher = || { let validated = Arc::new(atomic::AtomicBool::new(false)); diff --git a/client/transaction-pool/src/tests.rs b/client/transaction-pool/src/tests.rs index 60a9e0562f..65ca06c2c3 100644 --- a/client/transaction-pool/src/tests.rs +++ b/client/transaction-pool/src/tests.rs @@ -21,7 +21,7 @@ use codec::Encode; use futures::executor::block_on; use txpool::{self, Pool}; use test_client::{runtime::{AccountId, Block, Hash, Index, Extrinsic, Transfer}, AccountKeyring::{self, *}}; -use sr_primitives::{ +use sp_runtime::{ generic::{self, BlockId}, traits::{Hash as HashT, BlakeTwo256}, transaction_validity::{TransactionValidity, ValidTransaction}, diff --git a/frame/assets/Cargo.toml b/frame/assets/Cargo.toml index e24a3b187a..6cca26c621 100644 --- a/frame/assets/Cargo.toml +++ b/frame/assets/Cargo.toml @@ -8,23 +8,23 @@ edition = "2018" serde = { version = "1.0.101", optional = true } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } # Needed for various traits. In our case, `OnFinalize`. -sr-primitives = { path = "../../primitives/sr-primitives", default-features = false } +sp-runtime = { path = "../../primitives/sr-primitives", default-features = false } # Needed for type-safe access to storage DB. support = { package = "frame-support", path = "../support", default-features = false } # `system` module provides us with all sorts of useful stuff and macros depend on it being around. system = { package = "frame-system", path = "../system", default-features = false } [dev-dependencies] -primitives = { package = "substrate-primitives", path = "../../primitives/core" } -rstd = { package = "sr-std", path = "../../primitives/sr-std" } -runtime-io = { package = "sr-io", path = "../../primitives/sr-io" } +primitives = { package = "sp-core", path = "../../primitives/core" } +rstd = { package = "sp-std", path = "../../primitives/sr-std" } +runtime-io = { package = "sp-io", path = "../../primitives/sr-io" } [features] default = ["std"] std = [ "serde", "codec/std", - "sr-primitives/std", + "sp-runtime/std", "support/std", "system/std", ] diff --git a/frame/assets/src/lib.rs b/frame/assets/src/lib.rs index 314a8d4569..7810b75305 100644 --- a/frame/assets/src/lib.rs +++ b/frame/assets/src/lib.rs @@ -131,9 +131,9 @@ #![cfg_attr(not(feature = "std"), no_std)] use support::{Parameter, decl_module, decl_event, decl_storage, ensure}; -use sr_primitives::traits::{Member, SimpleArithmetic, Zero, StaticLookup}; +use sp_runtime::traits::{Member, SimpleArithmetic, Zero, StaticLookup}; use system::ensure_signed; -use sr_primitives::traits::One; +use sp_runtime::traits::One; /// The module configuration trait. pub trait Trait: system::Trait { @@ -244,7 +244,7 @@ mod tests { use primitives::H256; // The testing primitives are very useful for avoiding having to work with signatures // or public keys. `u64` is used as the `AccountId` and no `Signature`s are required. - use sr_primitives::{Perbill, traits::{BlakeTwo256, IdentityLookup}, testing::Header}; + use sp_runtime::{Perbill, traits::{BlakeTwo256, IdentityLookup}, testing::Header}; impl_outer_origin! { pub enum Origin for Test {} diff --git a/frame/aura/Cargo.toml b/frame/aura/Cargo.toml index a6700dbaf8..8c53f871cc 100644 --- a/frame/aura/Cargo.toml +++ b/frame/aura/Cargo.toml @@ -5,17 +5,17 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -app-crypto = { package = "substrate-application-crypto", path = "../../primitives/application-crypto", default-features = false } +app-crypto = { package = "sc-application-crypto", path = "../../primitives/application-crypto", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -inherents = { package = "substrate-inherents", path = "../../primitives/inherents", default-features = false } -primitives = { package = "substrate-primitives", path = "../../primitives/core", default-features = false } -rstd = { package = "sr-std", path = "../../primitives/sr-std", default-features = false } +inherents = { package = "sp-inherents", path = "../../primitives/inherents", default-features = false } +primitives = { package = "sp-core", path = "../../primitives/core", default-features = false } +rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } serde = { version = "1.0.101", optional = true } session = { package = "pallet-session", path = "../session", default-features = false } -sr-primitives = { path = "../../primitives/sr-primitives", default-features = false } -runtime-io ={ package = "sr-io", path = "../../primitives/sr-io", default-features = false } +sp-runtime = { path = "../../primitives/sr-primitives", default-features = false } +runtime-io ={ package = "sp-io", path = "../../primitives/sr-io", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } -substrate-consensus-aura-primitives = { path = "../../primitives/consensus/aura", default-features = false} +sp-consensus-aura = { path = "../../primitives/consensus/aura", default-features = false} system = { package = "frame-system", path = "../system", default-features = false } sp-timestamp = { package = "sp-timestamp", path = "../../primitives/timestamp", default-features = false } pallet-timestamp = { package = "pallet-timestamp", path = "../timestamp", default-features = false } @@ -35,9 +35,9 @@ std = [ "primitives/std", "rstd/std", "serde", - "sr-primitives/std", + "sp-runtime/std", "support/std", - "substrate-consensus-aura-primitives/std", + "sp-consensus-aura/std", "system/std", "sp-timestamp/std", "pallet-timestamp/std", diff --git a/frame/aura/src/lib.rs b/frame/aura/src/lib.rs index f1ae121e00..59fe2dbd21 100644 --- a/frame/aura/src/lib.rs +++ b/frame/aura/src/lib.rs @@ -40,8 +40,8 @@ //! //! If you're interested in hacking on this module, it is useful to understand the interaction with //! `substrate/primitives/inherents/src/lib.rs` and, specifically, the required implementation of -//! [`ProvideInherent`](../substrate_inherents/trait.ProvideInherent.html) and -//! [`ProvideInherentData`](../substrate_inherents/trait.ProvideInherentData.html) to create and check inherents. +//! [`ProvideInherent`](../sp_inherents/trait.ProvideInherent.html) and +//! [`ProvideInherentData`](../sp_inherents/trait.ProvideInherentData.html) to create and check inherents. #![cfg_attr(not(feature = "std"), no_std)] @@ -53,13 +53,13 @@ use support::{ decl_storage, decl_module, Parameter, traits::{Get, FindAuthor}, ConsensusEngineId, }; -use sr_primitives::{ +use sp_runtime::{ RuntimeAppPublic, traits::{SaturatedConversion, Saturating, Zero, Member, IsMember}, generic::DigestItem, }; use sp_timestamp::OnTimestampSet; use inherents::{InherentIdentifier, InherentData, ProvideInherent, MakeFatalError}; -use substrate_consensus_aura_primitives::{ +use sp_consensus_aura::{ AURA_ENGINE_ID, ConsensusLog, AuthorityIndex, inherents::{INHERENT_IDENTIFIER, AuraInherentData}, }; @@ -109,7 +109,7 @@ impl Module { } } -impl sr_primitives::BoundToRuntimeAppPublic for Module { +impl sp_runtime::BoundToRuntimeAppPublic for Module { type Public = T::AuthorityId; } diff --git a/frame/aura/src/mock.rs b/frame/aura/src/mock.rs index c95a36e131..49351ad159 100644 --- a/frame/aura/src/mock.rs +++ b/frame/aura/src/mock.rs @@ -19,8 +19,8 @@ #![cfg(test)] use crate::{Trait, Module, GenesisConfig}; -use substrate_consensus_aura_primitives::ed25519::AuthorityId; -use sr_primitives::{ +use sp_consensus_aura::ed25519::AuthorityId; +use sp_runtime::{ traits::IdentityLookup, Perbill, testing::{Header, UintAuthorityId}, }; @@ -50,7 +50,7 @@ impl system::Trait for Test { type BlockNumber = u64; type Call = (); type Hash = H256; - type Hashing = ::sr_primitives::traits::BlakeTwo256; + type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; diff --git a/frame/authority-discovery/Cargo.toml b/frame/authority-discovery/Cargo.toml index c0961671d8..84da66f12b 100644 --- a/frame/authority-discovery/Cargo.toml +++ b/frame/authority-discovery/Cargo.toml @@ -5,20 +5,20 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -authority-discovery-primitives = { package = "substrate-authority-discovery-primitives", path = "../../primitives/authority-discovery", default-features = false } -app-crypto = { package = "substrate-application-crypto", path = "../../primitives/application-crypto", default-features = false } +authority-discovery-primitives = { package = "sp-authority-discovery", path = "../../primitives/authority-discovery", default-features = false } +app-crypto = { package = "sc-application-crypto", path = "../../primitives/application-crypto", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -primitives = { package = "substrate-primitives", path = "../../primitives/core", default-features = false } -rstd = { package = "sr-std", path = "../../primitives/sr-std", default-features = false } +primitives = { package = "sp-core", path = "../../primitives/core", default-features = false } +rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } serde = { version = "1.0.101", optional = true } -runtime-io = { package = "sr-io", path = "../../primitives/sr-io", default-features = false } +runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } session = { package = "pallet-session", path = "../session", default-features = false, features = [ "historical" ] } -sr-primitives = { path = "../../primitives/sr-primitives", default-features = false } +sp-runtime = { path = "../../primitives/sr-primitives", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } system = { package = "frame-system", path = "../system", default-features = false } [dev-dependencies] -sr-staking-primitives = { path = "../../primitives/sr-staking-primitives", default-features = false } +sp-staking = { path = "../../primitives/sr-staking-primitives", default-features = false } [features] default = ["std"] @@ -31,7 +31,7 @@ std = [ "runtime-io/std", "serde", "session/std", - "sr-primitives/std", + "sp-runtime/std", "support/std", "system/std", ] diff --git a/frame/authority-discovery/src/lib.rs b/frame/authority-discovery/src/lib.rs index 6c9e316252..b24fe5e0eb 100644 --- a/frame/authority-discovery/src/lib.rs +++ b/frame/authority-discovery/src/lib.rs @@ -59,7 +59,7 @@ impl Module { } } -impl sr_primitives::BoundToRuntimeAppPublic for Module { +impl sp_runtime::BoundToRuntimeAppPublic for Module { type Public = AuthorityId; } @@ -96,7 +96,7 @@ mod tests { use app_crypto::Pair; use primitives::{crypto::key_types, H256}; use runtime_io::TestExternalities; - use sr_primitives::{ + use sp_runtime::{ testing::{Header, UintAuthorityId}, traits::{ConvertInto, IdentityLookup, OpaqueKeys}, Perbill, KeyTypeId, }; @@ -155,7 +155,7 @@ mod tests { type BlockNumber = BlockNumber; type Call = (); type Hash = H256; - type Hashing = ::sr_primitives::traits::BlakeTwo256; + type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AuthorityId; type Lookup = IdentityLookup; type Header = Header; diff --git a/frame/authorship/Cargo.toml b/frame/authorship/Cargo.toml index 508df216ae..e8e82cc4d8 100644 --- a/frame/authorship/Cargo.toml +++ b/frame/authorship/Cargo.toml @@ -6,15 +6,15 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -primitives = { package = "substrate-primitives", path = "../../primitives/core", default-features = false } +primitives = { package = "sp-core", path = "../../primitives/core", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -inherents = { package = "substrate-inherents", path = "../../primitives/inherents", default-features = false } +inherents = { package = "sp-inherents", path = "../../primitives/inherents", default-features = false } sp-authorship = { path = "../../primitives/authorship", default-features = false } -rstd = { package = "sr-std", path = "../../primitives/sr-std", default-features = false } -sr-primitives = { path = "../../primitives/sr-primitives", default-features = false } +rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +sp-runtime = { path = "../../primitives/sr-primitives", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } system = { package = "frame-system", path = "../system", default-features = false } -runtime-io ={ package = "sr-io", path = "../../primitives/sr-io", default-features = false } +runtime-io ={ package = "sp-io", path = "../../primitives/sr-io", default-features = false } impl-trait-for-tuples = "0.1.3" [features] @@ -23,7 +23,7 @@ std = [ "codec/std", "primitives/std", "inherents/std", - "sr-primitives/std", + "sp-runtime/std", "rstd/std", "support/std", "system/std", diff --git a/frame/authorship/src/lib.rs b/frame/authorship/src/lib.rs index de7a07520e..1f918e093a 100644 --- a/frame/authorship/src/lib.rs +++ b/frame/authorship/src/lib.rs @@ -27,7 +27,7 @@ use support::traits::{FindAuthor, VerifySeal, Get}; use support::dispatch::Result as DispatchResult; use codec::{Encode, Decode}; use system::ensure_none; -use sr_primitives::traits::{Header as HeaderT, One, Zero}; +use sp_runtime::traits::{Header as HeaderT, One, Zero}; use support::weights::SimpleDispatchInfo; use inherents::{InherentIdentifier, ProvideInherent, InherentData, MakeFatalError}; use sp_authorship::{ @@ -144,7 +144,7 @@ where } } -#[derive(Encode, Decode, sr_primitives::RuntimeDebug)] +#[derive(Encode, Decode, sp_runtime::RuntimeDebug)] #[cfg_attr(any(feature = "std", test), derive(PartialEq))] enum UncleEntryItem { InclusionHeight(BlockNumber), @@ -362,7 +362,7 @@ impl ProvideInherent for Module { mod tests { use super::*; use primitives::H256; - use sr_primitives::{ + use sp_runtime::{ traits::{BlakeTwo256, IdentityLookup}, testing::Header, generic::DigestItem, Perbill, }; use support::{parameter_types, impl_outer_origin, ConsensusEngineId, weights::Weight}; diff --git a/frame/babe/Cargo.toml b/frame/babe/Cargo.toml index 0ca099b845..c60b055b91 100644 --- a/frame/babe/Cargo.toml +++ b/frame/babe/Cargo.toml @@ -8,23 +8,23 @@ edition = "2018" hex-literal = "0.2.1" codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } serde = { version = "1.0.101", optional = true } -inherents = { package = "substrate-inherents", path = "../../primitives/inherents", default-features = false } -rstd = { package = "sr-std", path = "../../primitives/sr-std", default-features = false } -sr-primitives = { path = "../../primitives/sr-primitives", default-features = false } -sr-staking-primitives = { path = "../../primitives/sr-staking-primitives", default-features = false } +inherents = { package = "sp-inherents", path = "../../primitives/inherents", default-features = false } +rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +sp-runtime = { path = "../../primitives/sr-primitives", default-features = false } +sp-staking = { path = "../../primitives/sr-staking-primitives", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } system = { package = "frame-system", path = "../system", default-features = false } timestamp = { package = "pallet-timestamp", path = "../timestamp", default-features = false } sp-timestamp = { path = "../../primitives/timestamp", default-features = false } session = { package = "pallet-session", path = "../session", default-features = false } -babe-primitives = { package = "substrate-consensus-babe-primitives", path = "../../primitives/consensus/babe", default-features = false } -runtime-io ={ package = "sr-io", path = "../../primitives/sr-io", 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 } [dev-dependencies] lazy_static = "1.4.0" parking_lot = "0.9.0" -sr-version = { path = "../../primitives/sr-version", default-features = false } -primitives = { package = "substrate-primitives", path = "../../primitives/core" } +sp-version = { path = "../../primitives/sr-version", default-features = false } +primitives = { package = "sp-core", path = "../../primitives/core" } test-runtime = { package = "substrate-test-runtime", path = "../../test/utils/runtime" } [features] @@ -34,8 +34,8 @@ std = [ "codec/std", "rstd/std", "support/std", - "sr-primitives/std", - "sr-staking-primitives/std", + "sp-runtime/std", + "sp-staking/std", "system/std", "timestamp/std", "sp-timestamp/std", diff --git a/frame/babe/src/lib.rs b/frame/babe/src/lib.rs index d0585b340f..73a7adaaa3 100644 --- a/frame/babe/src/lib.rs +++ b/frame/babe/src/lib.rs @@ -26,9 +26,9 @@ use sp_timestamp; use rstd::{result, prelude::*}; use support::{decl_storage, decl_module, traits::FindAuthor, traits::Get}; use sp_timestamp::OnTimestampSet; -use sr_primitives::{generic::DigestItem, ConsensusEngineId, Perbill}; -use sr_primitives::traits::{IsMember, SaturatedConversion, Saturating, RandomnessBeacon}; -use sr_staking_primitives::{ +use sp_runtime::{generic::DigestItem, ConsensusEngineId, Perbill}; +use sp_runtime::traits::{IsMember, SaturatedConversion, Saturating, RandomnessBeacon}; +use sp_staking::{ SessionIndex, offence::{Offence, Kind}, }; @@ -306,7 +306,7 @@ impl Module { // epoch 0 as having started at the slot of block 1. We want to use // the same randomness and validator set as signalled in the genesis, // so we don't rotate the epoch. - now != sr_primitives::traits::One::one() && { + now != sp_runtime::traits::One::one() && { let diff = CurrentSlot::get().saturating_sub(Self::current_epoch_start()); diff >= T::EpochDuration::get() } @@ -472,7 +472,7 @@ impl OnTimestampSet for Module { fn on_timestamp_set(_moment: T::Moment) { } } -impl sr_primitives::BoundToRuntimeAppPublic for Module { +impl sp_runtime::BoundToRuntimeAppPublic for Module { type Public = AuthorityId; } diff --git a/frame/babe/src/mock.rs b/frame/babe/src/mock.rs index 847b2a75e1..4ca52e27e3 100644 --- a/frame/babe/src/mock.rs +++ b/frame/babe/src/mock.rs @@ -19,10 +19,10 @@ use super::{Trait, Module, GenesisConfig}; use babe_primitives::AuthorityId; -use sr_primitives::{ +use sp_runtime::{ traits::IdentityLookup, Perbill, testing::{Header, UintAuthorityId}, impl_opaque_keys, }; -use sr_version::RuntimeVersion; +use sp_version::RuntimeVersion; use support::{impl_outer_origin, parameter_types, weights::Weight}; use runtime_io; use primitives::{H256, Blake2Hasher}; @@ -56,7 +56,7 @@ impl system::Trait for Test { type Call = (); type Hash = H256; type Version = Version; - type Hashing = sr_primitives::traits::BlakeTwo256; + type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = DummyValidatorId; type Lookup = IdentityLookup; type Header = Header; diff --git a/frame/babe/src/tests.rs b/frame/babe/src/tests.rs index f860375de4..7ce256b43b 100644 --- a/frame/babe/src/tests.rs +++ b/frame/babe/src/tests.rs @@ -18,7 +18,7 @@ use super::*; use mock::{new_test_ext, Babe, Test}; -use sr_primitives::{traits::OnFinalize, testing::{Digest, DigestItem}}; +use sp_runtime::{traits::OnFinalize, testing::{Digest, DigestItem}}; use session::ShouldEndSession; const EMPTY_RANDOMNESS: [u8; 32] = [ diff --git a/frame/balances/Cargo.toml b/frame/balances/Cargo.toml index a2a69902b0..f6042ab33f 100644 --- a/frame/balances/Cargo.toml +++ b/frame/balances/Cargo.toml @@ -8,14 +8,14 @@ edition = "2018" serde = { version = "1.0.101", optional = true } safe-mix = { version = "1.0.0", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -rstd = { package = "sr-std", path = "../../primitives/sr-std", default-features = false } -sr-primitives = { path = "../../primitives/sr-primitives", default-features = false } +rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +sp-runtime = { path = "../../primitives/sr-primitives", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } system = { package = "frame-system", path = "../system", default-features = false } [dev-dependencies] -runtime-io = { package = "sr-io", path = "../../primitives/sr-io" } -primitives = { package = "substrate-primitives", path = "../../primitives/core" } +runtime-io = { package = "sp-io", path = "../../primitives/sr-io" } +primitives = { package = "sp-core", path = "../../primitives/core" } transaction-payment = { package = "pallet-transaction-payment", path = "../transaction-payment" } [features] @@ -26,6 +26,6 @@ std = [ "codec/std", "rstd/std", "support/std", - "sr-primitives/std", + "sp-runtime/std", "system/std", ] diff --git a/frame/balances/src/lib.rs b/frame/balances/src/lib.rs index 553592364b..d32d8551d9 100644 --- a/frame/balances/src/lib.rs +++ b/frame/balances/src/lib.rs @@ -122,7 +122,7 @@ //! //! ``` //! use support::traits::{WithdrawReasons, LockableCurrency}; -//! use sr_primitives::traits::Bounded; +//! use sp_runtime::traits::Bounded; //! pub trait Trait: system::Trait { //! type Currency: LockableCurrency; //! } @@ -172,7 +172,7 @@ use support::{ weights::SimpleDispatchInfo, dispatch::Result, }; -use sr_primitives::{ +use sp_runtime::{ RuntimeDebug, traits::{ Zero, SimpleArithmetic, StaticLookup, Member, CheckedAdd, CheckedSub, MaybeSerializeDeserialize, @@ -328,7 +328,7 @@ decl_storage! { // Total genesis `balance` minus `liquid` equals funds locked for vesting let locked = balance.saturating_sub(liquid); // Number of units unlocked per block after `begin` - let per_block = locked / length.max(sr_primitives::traits::One::one()); + let per_block = locked / length.max(sp_runtime::traits::One::one()); (who.clone(), VestingSchedule { locked: locked, diff --git a/frame/balances/src/mock.rs b/frame/balances/src/mock.rs index 1756c77ce2..029beb5cd2 100644 --- a/frame/balances/src/mock.rs +++ b/frame/balances/src/mock.rs @@ -16,7 +16,7 @@ //! Test utilities -use sr_primitives::{Perbill, traits::{ConvertInto, IdentityLookup}, testing::Header}; +use sp_runtime::{Perbill, traits::{ConvertInto, IdentityLookup}, testing::Header}; use primitives::H256; use runtime_io; use support::{impl_outer_origin, parameter_types}; @@ -65,7 +65,7 @@ impl system::Trait for Runtime { type BlockNumber = u64; type Call = (); type Hash = H256; - type Hashing = ::sr_primitives::traits::BlakeTwo256; + type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; diff --git a/frame/balances/src/tests.rs b/frame/balances/src/tests.rs index 3849df6764..b26ac5c691 100644 --- a/frame/balances/src/tests.rs +++ b/frame/balances/src/tests.rs @@ -18,7 +18,7 @@ use super::*; use mock::{Balances, ExtBuilder, Runtime, System, info_from_weight, CALL}; -use sr_primitives::traits::SignedExtension; +use sp_runtime::traits::SignedExtension; use support::{ assert_noop, assert_ok, assert_err, traits::{LockableCurrency, LockIdentifier, WithdrawReason, WithdrawReasons, diff --git a/frame/collective/Cargo.toml b/frame/collective/Cargo.toml index ed1244ff23..2208e6e604 100644 --- a/frame/collective/Cargo.toml +++ b/frame/collective/Cargo.toml @@ -8,10 +8,10 @@ edition = "2018" serde = { version = "1.0.101", optional = true } 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 = "substrate-primitives", path = "../../primitives/core", default-features = false } -rstd = { package = "sr-std", path = "../../primitives/sr-std", default-features = false } -runtime-io = { package = "sr-io", path = "../../primitives/sr-io", default-features = false } -sr-primitives = { path = "../../primitives/sr-primitives", default-features = false } +primitives = { package = "sp-core", path = "../../primitives/core", default-features = false } +rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } +sp-runtime = { path = "../../primitives/sr-primitives", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } system = { package = "frame-system", path = "../system", default-features = false } @@ -29,6 +29,6 @@ std = [ "serde", "runtime-io/std", "support/std", - "sr-primitives/std", + "sp-runtime/std", "system/std", ] diff --git a/frame/collective/src/lib.rs b/frame/collective/src/lib.rs index dec87da246..6ecaf3045f 100644 --- a/frame/collective/src/lib.rs +++ b/frame/collective/src/lib.rs @@ -25,8 +25,8 @@ use rstd::{prelude::*, result}; use primitives::u32_trait::Value as U32; -use sr_primitives::RuntimeDebug; -use sr_primitives::traits::{Hash, EnsureOrigin}; +use sp_runtime::RuntimeDebug; +use sp_runtime::traits::{Hash, EnsureOrigin}; use support::weights::SimpleDispatchInfo; use support::{ dispatch::{Dispatchable, Parameter}, codec::{Encode, Decode}, @@ -382,7 +382,7 @@ mod tests { use system::{EventRecord, Phase}; use hex_literal::hex; use primitives::H256; - use sr_primitives::{ + use sp_runtime::{ Perbill, traits::{BlakeTwo256, IdentityLookup, Block as BlockT}, testing::Header, BuildStorage, }; @@ -422,8 +422,8 @@ mod tests { type Event = Event; } - pub type Block = sr_primitives::generic::Block; - pub type UncheckedExtrinsic = sr_primitives::generic::UncheckedExtrinsic; + pub type Block = sp_runtime::generic::Block; + pub type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic; support::construct_runtime!( pub enum Test where diff --git a/frame/contracts/Cargo.toml b/frame/contracts/Cargo.toml index 4a870b18e4..90e2f57091 100644 --- a/frame/contracts/Cargo.toml +++ b/frame/contracts/Cargo.toml @@ -10,11 +10,11 @@ pwasm-utils = { version = "0.12.0", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } parity-wasm = { version = "0.41.0", default-features = false } wasmi-validation = { version = "0.3.0", default-features = false } -primitives = { package = "substrate-primitives", path = "../../primitives/core", default-features = false } -sr-primitives = { path = "../../primitives/sr-primitives", default-features = false } -runtime-io = { package = "sr-io", path = "../../primitives/sr-io", default-features = false } -rstd = { package = "sr-std", path = "../../primitives/sr-std", default-features = false } -sandbox = { package = "sr-sandbox", path = "../../primitives/sr-sandbox", default-features = false } +primitives = { package = "sp-core", path = "../../primitives/core", default-features = false } +sp-runtime = { path = "../../primitives/sr-primitives", default-features = false } +runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } +rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +sandbox = { package = "sp-sandbox", path = "../../primitives/sr-sandbox", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } system = { package = "frame-system", path = "../system", default-features = false } @@ -32,7 +32,7 @@ std = [ "serde", "codec/std", "primitives/std", - "sr-primitives/std", + "sp-runtime/std", "runtime-io/std", "rstd/std", "sandbox/std", diff --git a/frame/contracts/rpc/Cargo.toml b/frame/contracts/rpc/Cargo.toml index a06353831c..64b2318d08 100644 --- a/frame/contracts/rpc/Cargo.toml +++ b/frame/contracts/rpc/Cargo.toml @@ -10,8 +10,8 @@ jsonrpc-core = "14.0.3" jsonrpc-core-client = "14.0.3" jsonrpc-derive = "14.0.3" sp-blockchain = { path = "../../../primitives/blockchain" } -primitives = { package = "substrate-primitives", path = "../../../primitives/core" } -rpc-primitives = { package = "substrate-rpc-primitives", path = "../../../primitives/rpc" } +primitives = { package = "sp-core", path = "../../../primitives/core" } +rpc-primitives = { package = "sp-rpc", path = "../../../primitives/rpc" } serde = { version = "1.0.101", features = ["derive"] } -sr-primitives = { path = "../../../primitives/sr-primitives" } +sp-runtime = { path = "../../../primitives/sr-primitives" } pallet-contracts-rpc-runtime-api = { path = "./runtime-api" } diff --git a/frame/contracts/rpc/runtime-api/Cargo.toml b/frame/contracts/rpc/runtime-api/Cargo.toml index 87749fcd19..ae71345488 100644 --- a/frame/contracts/rpc/runtime-api/Cargo.toml +++ b/frame/contracts/rpc/runtime-api/Cargo.toml @@ -5,18 +5,18 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -sr-api = { path = "../../../../primitives/sr-api", default-features = false } +sp-api = { path = "../../../../primitives/sr-api", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -rstd = { package = "sr-std", path = "../../../../primitives/sr-std", default-features = false } +rstd = { package = "sp-std", path = "../../../../primitives/sr-std", default-features = false } serde = { version = "1.0.101", optional = true, features = ["derive"] } -sr-primitives = { path = "../../../../primitives/sr-primitives", default-features = false } +sp-runtime = { path = "../../../../primitives/sr-primitives", default-features = false } [features] default = ["std"] std = [ - "sr-api/std", + "sp-api/std", "codec/std", "rstd/std", "serde", - "sr-primitives/std", + "sp-runtime/std", ] diff --git a/frame/contracts/rpc/runtime-api/src/lib.rs b/frame/contracts/rpc/runtime-api/src/lib.rs index 6d9c4a27b1..2d3385d6d7 100644 --- a/frame/contracts/rpc/runtime-api/src/lib.rs +++ b/frame/contracts/rpc/runtime-api/src/lib.rs @@ -24,7 +24,7 @@ use rstd::vec::Vec; use codec::{Encode, Decode, Codec}; -use sr_primitives::RuntimeDebug; +use sp_runtime::RuntimeDebug; /// A result of execution of a contract. #[derive(Eq, PartialEq, Encode, Decode, RuntimeDebug)] @@ -59,7 +59,7 @@ pub enum GetStorageError { IsTombstone, } -sr_api::decl_runtime_apis! { +sp_api::decl_runtime_apis! { /// The API to interact with contracts without using executive. pub trait ContractsApi where AccountId: Codec, diff --git a/frame/contracts/rpc/src/lib.rs b/frame/contracts/rpc/src/lib.rs index 6f357f53b8..3deee80cc3 100644 --- a/frame/contracts/rpc/src/lib.rs +++ b/frame/contracts/rpc/src/lib.rs @@ -25,7 +25,7 @@ use jsonrpc_derive::rpc; use primitives::{H256, Bytes}; use rpc_primitives::number; use serde::{Deserialize, Serialize}; -use sr_primitives::{ +use sp_runtime::{ generic::BlockId, traits::{Block as BlockT, ProvideRuntimeApi}, }; diff --git a/frame/contracts/src/account_db.rs b/frame/contracts/src/account_db.rs index 5aa3a64fd9..77732db871 100644 --- a/frame/contracts/src/account_db.rs +++ b/frame/contracts/src/account_db.rs @@ -25,7 +25,7 @@ use rstd::cell::RefCell; use rstd::collections::btree_map::{BTreeMap, Entry}; use rstd::prelude::*; use runtime_io::hashing::blake2_256; -use sr_primitives::traits::{Bounded, Zero}; +use sp_runtime::traits::{Bounded, Zero}; use support::traits::{Currency, Get, Imbalance, SignedImbalance, UpdateBalanceOutcome}; use support::{storage::child, StorageMap}; use system; diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index b71f54b18b..12f71251e2 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -21,7 +21,7 @@ use crate::gas::{Gas, GasMeter, Token, approx_gas_for_balance}; use crate::rent; use rstd::prelude::*; -use sr_primitives::traits::{Bounded, CheckedAdd, CheckedSub, Zero}; +use sp_runtime::traits::{Bounded, CheckedAdd, CheckedSub, Zero}; use support::{ storage::unhashed, traits::{WithdrawReason, Currency, Time, Randomness}, @@ -64,7 +64,7 @@ impl ExecReturnValue { /// VM-specific errors during execution (eg. division by 0, OOB access, failure to satisfy some /// precondition of a system call, etc.) or errors with the orchestration (eg. out-of-gas errors, a /// non-existent destination contract, etc.). -#[cfg_attr(test, derive(sr_primitives::RuntimeDebug))] +#[cfg_attr(test, derive(sp_runtime::RuntimeDebug))] pub struct ExecError { pub reason: &'static str, /// This is an allocated buffer that may be reused. The buffer must be cleared explicitly @@ -239,7 +239,7 @@ impl Token for ExecFeeToken { } #[cfg_attr(any(feature = "std", test), derive(PartialEq, Eq, Clone))] -#[derive(sr_primitives::RuntimeDebug)] +#[derive(sp_runtime::RuntimeDebug)] pub enum DeferredAction { DepositEvent { /// A list of topics this event will be deposited with. diff --git a/frame/contracts/src/gas.rs b/frame/contracts/src/gas.rs index 64997fbe81..b791a4681b 100644 --- a/frame/contracts/src/gas.rs +++ b/frame/contracts/src/gas.rs @@ -16,7 +16,7 @@ use crate::{GasSpent, Module, Trait, BalanceOf, NegativeImbalanceOf}; use rstd::convert::TryFrom; -use sr_primitives::traits::{ +use sp_runtime::traits::{ CheckedMul, Zero, SaturatedConversion, SimpleArithmetic, UniqueSaturatedInto, }; use support::{ diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index e84214a019..166ee467b1 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -112,7 +112,7 @@ use primitives::crypto::UncheckedFrom; use rstd::{prelude::*, marker::PhantomData, fmt::Debug}; use codec::{Codec, Encode, Decode}; use runtime_io::hashing::blake2_256; -use sr_primitives::{ +use sp_runtime::{ traits::{Hash, StaticLookup, Zero, MaybeSerializeDeserialize, Member, SignedExtension}, transaction_validity::{ ValidTransaction, InvalidTransaction, TransactionValidity, TransactionValidityError, diff --git a/frame/contracts/src/rent.rs b/frame/contracts/src/rent.rs index e286ce307f..00bf4bf911 100644 --- a/frame/contracts/src/rent.rs +++ b/frame/contracts/src/rent.rs @@ -15,7 +15,7 @@ // along with Substrate. If not, see . use crate::{BalanceOf, ContractInfo, ContractInfoOf, TombstoneContractInfo, Trait, AliveContractInfo}; -use sr_primitives::traits::{Bounded, CheckedDiv, CheckedMul, Saturating, Zero, +use sp_runtime::traits::{Bounded, CheckedDiv, CheckedMul, Saturating, Zero, SaturatedConversion}; use support::traits::{Currency, ExistenceRequirement, Get, WithdrawReason, OnUnbalanced}; use support::StorageMap; diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 6129784d41..e2e45ef9c0 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -27,7 +27,7 @@ use crate::{ use assert_matches::assert_matches; use hex_literal::*; use codec::{Decode, Encode, KeyedVec}; -use sr_primitives::{ +use sp_runtime::{ Perbill, BuildStorage, transaction_validity::{InvalidTransaction, ValidTransaction}, traits::{BlakeTwo256, Hash, IdentityLookup, SignedExtension}, testing::{Digest, DigestItem, Header, UintAuthorityId, H256}, diff --git a/frame/contracts/src/wasm/code_cache.rs b/frame/contracts/src/wasm/code_cache.rs index e6702d29cf..2c5bd492e2 100644 --- a/frame/contracts/src/wasm/code_cache.rs +++ b/frame/contracts/src/wasm/code_cache.rs @@ -30,7 +30,7 @@ use crate::gas::{Gas, GasMeter, Token}; use crate::wasm::{prepare, runtime::Env, PrefabWasmModule}; use crate::{CodeHash, CodeStorage, PristineCode, Schedule, Trait}; use rstd::prelude::*; -use sr_primitives::traits::{Hash, Bounded}; +use sp_runtime::traits::{Hash, Bounded}; use support::StorageMap; /// Gas metering token that used for charging storing code into the code storage. diff --git a/frame/contracts/src/wasm/env_def/macros.rs b/frame/contracts/src/wasm/env_def/macros.rs index af83c36623..0f36095048 100644 --- a/frame/contracts/src/wasm/env_def/macros.rs +++ b/frame/contracts/src/wasm/env_def/macros.rs @@ -195,7 +195,7 @@ macro_rules! define_env { mod tests { use parity_wasm::elements::FunctionType; use parity_wasm::elements::ValueType; - use sr_primitives::traits::Zero; + use sp_runtime::traits::Zero; use sandbox::{self, ReturnValue, TypedValue}; use crate::wasm::tests::MockExt; use crate::wasm::Runtime; diff --git a/frame/contracts/src/wasm/prepare.rs b/frame/contracts/src/wasm/prepare.rs index 41269772a8..6a443d63e8 100644 --- a/frame/contracts/src/wasm/prepare.rs +++ b/frame/contracts/src/wasm/prepare.rs @@ -26,7 +26,7 @@ use parity_wasm::elements::{self, Internal, External, MemoryType, Type, ValueTyp use pwasm_utils; use pwasm_utils::rules; use rstd::prelude::*; -use sr_primitives::traits::{SaturatedConversion}; +use sp_runtime::traits::{SaturatedConversion}; struct ContractModule<'a> { /// A deserialized module. The module is valid (this is Guaranteed by `new` method). diff --git a/frame/contracts/src/wasm/runtime.rs b/frame/contracts/src/wasm/runtime.rs index e53cadaf7b..2e69d17bc2 100644 --- a/frame/contracts/src/wasm/runtime.rs +++ b/frame/contracts/src/wasm/runtime.rs @@ -27,7 +27,7 @@ use rstd::prelude::*; use rstd::convert::TryInto; use rstd::mem; use codec::{Decode, Encode}; -use sr_primitives::traits::{Bounded, SaturatedConversion}; +use sp_runtime::traits::{Bounded, SaturatedConversion}; /// The value returned from ext_call and ext_instantiate contract external functions if the call or /// instantiation traps. This value is chosen as if the execution does not trap, the return value @@ -824,7 +824,7 @@ define_env!(Env, , ext_println(ctx, str_ptr: u32, str_len: u32) => { let data = read_sandbox_memory(ctx, str_ptr, str_len)?; if let Ok(utf8) = core::str::from_utf8(&data) { - sr_primitives::print(utf8); + sp_runtime::print(utf8); } Ok(()) }, diff --git a/frame/democracy/Cargo.toml b/frame/democracy/Cargo.toml index b607e8af73..a9becc0944 100644 --- a/frame/democracy/Cargo.toml +++ b/frame/democracy/Cargo.toml @@ -8,14 +8,14 @@ edition = "2018" 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"] } -rstd = { package = "sr-std", path = "../../primitives/sr-std", default-features = false } -runtime-io = { package = "sr-io", path = "../../primitives/sr-io", default-features = false } -sr-primitives = { path = "../../primitives/sr-primitives", default-features = false } +rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } +sp-runtime = { path = "../../primitives/sr-primitives", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } system = { package = "frame-system", path = "../system", default-features = false } [dev-dependencies] -primitives = { package = "substrate-primitives", path = "../../primitives/core" } +primitives = { package = "sp-core", path = "../../primitives/core" } balances = { package = "pallet-balances", path = "../balances" } [features] @@ -27,6 +27,6 @@ std = [ "rstd/std", "runtime-io/std", "support/std", - "sr-primitives/std", + "sp-runtime/std", "system/std", ] diff --git a/frame/democracy/src/lib.rs b/frame/democracy/src/lib.rs index 988f82734c..54044cd1fa 100644 --- a/frame/democracy/src/lib.rs +++ b/frame/democracy/src/lib.rs @@ -20,7 +20,7 @@ use rstd::prelude::*; use rstd::{result, convert::TryFrom}; -use sr_primitives::{ +use sp_runtime::{ RuntimeDebug, traits::{Zero, Bounded, CheckedMul, CheckedDiv, EnsureOrigin, Hash, Dispatchable, Saturating}, }; @@ -597,7 +597,7 @@ decl_module! { fn on_initialize(n: T::BlockNumber) { if let Err(e) = Self::begin_block(n) { - sr_primitives::print(e); + sp_runtime::print(e); } } @@ -1092,7 +1092,7 @@ mod tests { weights::Weight, }; use primitives::H256; - use sr_primitives::{traits::{BlakeTwo256, IdentityLookup, Bounded}, testing::Header, Perbill}; + use sp_runtime::{traits::{BlakeTwo256, IdentityLookup, Bounded}, testing::Header, Perbill}; use balances::BalanceLock; use system::EnsureSignedBy; diff --git a/frame/democracy/src/vote_threshold.rs b/frame/democracy/src/vote_threshold.rs index 61e7e65359..4262f7d7cf 100644 --- a/frame/democracy/src/vote_threshold.rs +++ b/frame/democracy/src/vote_threshold.rs @@ -19,11 +19,11 @@ #[cfg(feature = "std")] use serde::{Serialize, Deserialize}; use codec::{Encode, Decode}; -use sr_primitives::traits::{Zero, IntegerSquareRoot}; +use sp_runtime::traits::{Zero, IntegerSquareRoot}; use rstd::ops::{Add, Mul, Div, Rem}; /// A means of determining if a vote is past pass threshold. -#[derive(Clone, Copy, PartialEq, Eq, Encode, Decode, sr_primitives::RuntimeDebug)] +#[derive(Clone, Copy, PartialEq, Eq, Encode, Decode, sp_runtime::RuntimeDebug)] #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] pub enum VoteThreshold { /// A supermajority of approvals is needed to pass this vote. diff --git a/frame/elections-phragmen/Cargo.toml b/frame/elections-phragmen/Cargo.toml index fbbc49380e..9e7039da91 100644 --- a/frame/elections-phragmen/Cargo.toml +++ b/frame/elections-phragmen/Cargo.toml @@ -6,17 +6,17 @@ edition = "2018" [dependencies] codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sr-primitives = { path = "../../primitives/sr-primitives", default-features = false } -phragmen = { package = "substrate-phragmen", path = "../../primitives/phragmen", default-features = false } +sp-runtime = { path = "../../primitives/sr-primitives", default-features = false } +phragmen = { package = "sp-phragmen", path = "../../primitives/phragmen", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } system = { package = "frame-system", path = "../system", default-features = false } -rstd = { package = "sr-std", path = "../../primitives/sr-std", default-features = false } +rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } [dev-dependencies] -runtime_io = { package = "sr-io", path = "../../primitives/sr-io" } +runtime_io = { package = "sp-io", path = "../../primitives/sr-io" } hex-literal = "0.2.1" balances = { package = "pallet-balances", path = "../balances" } -primitives = { package = "substrate-primitives", path = "../../primitives/core" } +primitives = { package = "sp-core", path = "../../primitives/core" } substrate-test-utils = { path = "../../test/utils" } serde = { version = "1.0.101" } @@ -25,7 +25,7 @@ default = ["std"] std = [ "codec/std", "support/std", - "sr-primitives/std", + "sp-runtime/std", "phragmen/std", "system/std", "rstd/std", diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index 338ceeba52..fe0ecede15 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -83,7 +83,7 @@ #![cfg_attr(not(feature = "std"), no_std)] use rstd::prelude::*; -use sr_primitives::{print, traits::{Zero, StaticLookup, Bounded, Convert}}; +use sp_runtime::{print, traits::{Zero, StaticLookup, Bounded, Convert}}; use support::weights::SimpleDispatchInfo; use support::{ decl_storage, decl_event, ensure, decl_module, dispatch, @@ -746,7 +746,7 @@ mod tests { use support::{assert_ok, assert_noop, parameter_types, weights::Weight}; use substrate_test_utils::assert_eq_uvec; use primitives::H256; - use sr_primitives::{ + use sp_runtime::{ Perbill, testing::Header, BuildStorage, traits::{BlakeTwo256, IdentityLookup, Block as BlockT}, }; @@ -857,8 +857,8 @@ mod tests { type BadReport = (); } - pub type Block = sr_primitives::generic::Block; - pub type UncheckedExtrinsic = sr_primitives::generic::UncheckedExtrinsic; + pub type Block = sp_runtime::generic::Block; + pub type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic; support::construct_runtime!( pub enum Test where diff --git a/frame/elections/Cargo.toml b/frame/elections/Cargo.toml index 62986f758d..1c0e06ac00 100644 --- a/frame/elections/Cargo.toml +++ b/frame/elections/Cargo.toml @@ -8,10 +8,10 @@ edition = "2018" serde = { version = "1.0.101", optional = true } 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 = "substrate-primitives", path = "../../primitives/core", default-features = false } -rstd = { package = "sr-std", path = "../../primitives/sr-std", default-features = false } -runtime-io = { package = "sr-io", path = "../../primitives/sr-io", default-features = false } -sr-primitives = { path = "../../primitives/sr-primitives", default-features = false } +primitives = { package = "sp-core", path = "../../primitives/core", default-features = false } +rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } +sp-runtime = { path = "../../primitives/sr-primitives", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } system = { package = "frame-system", path = "../system", default-features = false } @@ -29,6 +29,6 @@ std = [ "serde", "runtime-io/std", "support/std", - "sr-primitives/std", + "sp-runtime/std", "system/std", ] diff --git a/frame/elections/src/lib.rs b/frame/elections/src/lib.rs index e4426c22d8..1a289eb23f 100644 --- a/frame/elections/src/lib.rs +++ b/frame/elections/src/lib.rs @@ -24,7 +24,7 @@ #![recursion_limit="128"] use rstd::prelude::*; -use sr_primitives::{ +use sp_runtime::{ RuntimeDebug, print, traits::{Zero, One, StaticLookup, Bounded, Saturating}, diff --git a/frame/elections/src/mock.rs b/frame/elections/src/mock.rs index 173a45a248..692d42cc1b 100644 --- a/frame/elections/src/mock.rs +++ b/frame/elections/src/mock.rs @@ -25,7 +25,7 @@ use support::{ weights::Weight, }; use primitives::H256; -use sr_primitives::{ +use sp_runtime::{ Perbill, BuildStorage, testing::Header, traits::{BlakeTwo256, IdentityLookup, Block as BlockT}, }; use crate as elections; @@ -142,8 +142,8 @@ impl elections::Trait for Test { type DecayRatio = DecayRatio; } -pub type Block = sr_primitives::generic::Block; -pub type UncheckedExtrinsic = sr_primitives::generic::UncheckedExtrinsic; +pub type Block = sp_runtime::generic::Block; +pub type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic; support::construct_runtime!( pub enum Test where diff --git a/frame/evm/Cargo.toml b/frame/evm/Cargo.toml index 2318fe59a4..9cb59b6784 100644 --- a/frame/evm/Cargo.toml +++ b/frame/evm/Cargo.toml @@ -11,10 +11,10 @@ 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 } balances = { package = "pallet-balances", path = "../balances", default-features = false } -primitives = { package = "substrate-primitives", path = "../../primitives/core", default-features = false } -sr-primitives = { path = "../../primitives/sr-primitives", default-features = false } -rstd = { package = "sr-std", path = "../../primitives/sr-std", default-features = false } -runtime-io = { package = "sr-io", path = "../../primitives/sr-io", default-features = false } +primitives = { package = "sp-core", path = "../../primitives/core", default-features = false } +sp-runtime = { path = "../../primitives/sr-primitives", default-features = false } +rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +runtime-io = { package = "sp-io", path = "../../primitives/sr-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 } @@ -26,7 +26,7 @@ std = [ "serde", "codec/std", "primitives/std", - "sr-primitives/std", + "sp-runtime/std", "support/std", "system/std", "balances/std", diff --git a/frame/evm/src/backend.rs b/frame/evm/src/backend.rs index 1f3dfe309b..18d8a01158 100644 --- a/frame/evm/src/backend.rs +++ b/frame/evm/src/backend.rs @@ -4,7 +4,7 @@ use rstd::vec::Vec; use serde::{Serialize, Deserialize}; use codec::{Encode, Decode}; use primitives::{U256, H256, H160}; -use sr_primitives::traits::UniqueSaturatedInto; +use sp_runtime::traits::UniqueSaturatedInto; use support::storage::{StorageMap, StorageDoubleMap}; use sha3::{Keccak256, Digest}; use evm::Config; diff --git a/frame/evm/src/lib.rs b/frame/evm/src/lib.rs index 9a602d9077..13be83dccf 100644 --- a/frame/evm/src/lib.rs +++ b/frame/evm/src/lib.rs @@ -27,9 +27,9 @@ use rstd::vec::Vec; use support::{dispatch::Result, decl_module, decl_storage, decl_event}; use support::traits::{Currency, WithdrawReason, ExistenceRequirement}; use system::ensure_signed; -use sr_primitives::ModuleId; +use sp_runtime::ModuleId; use support::weights::SimpleDispatchInfo; -use sr_primitives::traits::{UniqueSaturatedInto, AccountIdConversion}; +use sp_runtime::traits::{UniqueSaturatedInto, AccountIdConversion}; use primitives::{U256, H256, H160}; use evm::{ExitReason, ExitSucceed, ExitError}; use evm::executor::StackExecutor; diff --git a/frame/example/Cargo.toml b/frame/example/Cargo.toml index bcad107a07..e76447b03a 100644 --- a/frame/example/Cargo.toml +++ b/frame/example/Cargo.toml @@ -10,19 +10,19 @@ codec = { package = "parity-scale-codec", version = "1.0.0", default-features = support = { package = "frame-support", path = "../support", default-features = false } system = { package = "frame-system", path = "../system", default-features = false } balances = { package = "pallet-balances", path = "../balances", default-features = false } -sr-primitives = { path = "../../primitives/sr-primitives", default-features = false } -rstd = { package = "sr-std", path = "../../primitives/sr-std", default-features = false } -runtime-io = { package = "sr-io", path = "../../primitives/sr-io", default-features = false } +sp-runtime = { path = "../../primitives/sr-primitives", default-features = false } +rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } [dev-dependencies] -primitives = { package = "substrate-primitives", path = "../../primitives/core" } +primitives = { package = "sp-core", path = "../../primitives/core" } [features] default = ["std"] std = [ "serde", "codec/std", - "sr-primitives/std", + "sp-runtime/std", "support/std", "system/std", "balances/std", diff --git a/frame/example/src/lib.rs b/frame/example/src/lib.rs index a73e0d2868..3e201f7a9b 100644 --- a/frame/example/src/lib.rs +++ b/frame/example/src/lib.rs @@ -260,7 +260,7 @@ use support::{ }; use system::{ensure_signed, ensure_root}; use codec::{Encode, Decode}; -use sr_primitives::{ +use sp_runtime::{ traits::{SignedExtension, Bounded, SaturatedConversion}, transaction_validity::{ ValidTransaction, TransactionValidityError, InvalidTransaction, TransactionValidity, @@ -581,7 +581,7 @@ impl Module { // sender of the transaction (if signed) are also provided. // // The full list of hooks that can be added to a signed extension can be found -// [here](https://crates.parity.io/sr_primitives/traits/trait.SignedExtension.html). +// [here](https://crates.parity.io/sp_runtime/traits/trait.SignedExtension.html). // // The signed extensions are aggregated in the runtime file of a substrate chain. All extensions // should be aggregated in a tuple and passed to the `CheckedExtrinsic` and `UncheckedExtrinsic` @@ -630,7 +630,7 @@ impl SignedExtension for WatchDummy { // check for `set_dummy` match call { Call::set_dummy(..) => { - sr_primitives::print("set_dummy was received."); + sp_runtime::print("set_dummy was received."); let mut valid_tx = ValidTransaction::default(); valid_tx.priority = Bounded::max_value(); @@ -649,7 +649,7 @@ mod tests { use primitives::H256; // The testing primitives are very useful for avoiding having to work with signatures // or public keys. `u64` is used as the `AccountId` and no `Signature`s are required. - use sr_primitives::{ + use sp_runtime::{ Perbill, testing::Header, traits::{BlakeTwo256, OnInitialize, OnFinalize, IdentityLookup}, }; diff --git a/frame/executive/Cargo.toml b/frame/executive/Cargo.toml index bc10d71f42..f4eb4fb76c 100644 --- a/frame/executive/Cargo.toml +++ b/frame/executive/Cargo.toml @@ -7,15 +7,15 @@ edition = "2018" [dependencies] serde = { version = "1.0.101", optional = true } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -rstd = { package = "sr-std", path = "../../primitives/sr-std", default-features = false } -runtime-io ={ package = "sr-io", path = "../../primitives/sr-io", default-features = false } -sr-primitives = { path = "../../primitives/sr-primitives", default-features = false } +rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +runtime-io ={ package = "sp-io", path = "../../primitives/sr-io", default-features = false } +sp-runtime = { path = "../../primitives/sr-primitives", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } system = { package = "frame-system", path = "../system", default-features = false } [dev-dependencies] hex-literal = "0.2.1" -primitives = { package = "substrate-primitives", path = "../../primitives/core" } +primitives = { package = "sp-core", path = "../../primitives/core" } pallet-indices = { path = "../indices" } balances = { package = "pallet-balances", path = "../balances" } transaction-payment = { package = "pallet-transaction-payment", path = "../transaction-payment" } @@ -27,7 +27,7 @@ std = [ "support/std", "serde", "codec/std", - "sr-primitives/std", + "sp-runtime/std", "runtime-io/std", "system/std", ] diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index d5dc5fa135..35d44f53e0 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -50,7 +50,7 @@ //! `Executive` type declaration from the node template. //! //! ``` -//! # use sr_primitives::generic; +//! # use sp_runtime::generic; //! # use frame_executive as executive; //! # pub struct UncheckedExtrinsic {}; //! # pub struct Header {}; @@ -59,9 +59,9 @@ //! # pub type Balances = u64; //! # pub type AllModules = u64; //! # pub enum Runtime {}; -//! # use sr_primitives::transaction_validity::{TransactionValidity, UnknownTransaction}; +//! # use sp_runtime::transaction_validity::{TransactionValidity, UnknownTransaction}; //! # #[allow(deprecated)] -//! # use sr_primitives::traits::ValidateUnsigned; +//! # use sp_runtime::traits::ValidateUnsigned; //! # #[allow(deprecated)] //! # impl ValidateUnsigned for Runtime { //! # type Call = (); @@ -78,7 +78,7 @@ use rstd::{prelude::*, marker::PhantomData}; use support::weights::{GetDispatchInfo, WeighBlock, DispatchInfo}; -use sr_primitives::{ +use sp_runtime::{ generic::Digest, ApplyExtrinsicResult, traits::{ self, Header, Zero, One, Checkable, Applyable, CheckEqual, OnFinalize, OnInitialize, @@ -87,7 +87,7 @@ use sr_primitives::{ transaction_validity::TransactionValidity, }; #[allow(deprecated)] -use sr_primitives::traits::ValidateUnsigned; +use sp_runtime::traits::ValidateUnsigned; use codec::{Codec, Encode}; use system::{extrinsics_root, DigestOf}; @@ -243,7 +243,7 @@ where let l = uxt.encode().len(); match Self::apply_extrinsic_with_len(uxt, l, None) { Ok(Ok(())) => (), - Ok(Err(e)) => sr_primitives::print(e), + Ok(Err(e)) => sp_runtime::print(e), Err(e) => { let err: &'static str = e.into(); panic!(err) }, } } @@ -320,7 +320,7 @@ where mod tests { use super::*; use primitives::H256; - use sr_primitives::{ + use sp_runtime::{ generic::Era, Perbill, DispatchError, testing::{Digest, Header, Block}, traits::{Bounded, Header as HeaderT, BlakeTwo256, IdentityLookup, ConvertInto}, transaction_validity::{InvalidTransaction, UnknownTransaction, TransactionValidityError}, @@ -468,7 +468,7 @@ mod tests { transaction_payment::ChargeTransactionPayment ); type AllModules = (System, Balances, Custom); - type TestXt = sr_primitives::testing::TestXt; + type TestXt = sp_runtime::testing::TestXt; type Executive = super::Executive, ChainContext, Runtime, AllModules>; fn extra(nonce: u64, fee: u64) -> SignedExtra { @@ -491,7 +491,7 @@ mod tests { balances: vec![(1, 211)], vesting: vec![], }.assimilate_storage(&mut t).unwrap(); - let xt = sr_primitives::testing::TestXt(sign_extra(1, 0, 0), Call::Balances(BalancesCall::transfer(2, 69))); + 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); t.execute_with(|| { @@ -572,7 +572,7 @@ mod tests { fn bad_extrinsic_not_inserted() { let mut t = new_test_ext(1); // bad nonce check! - let xt = sr_primitives::testing::TestXt(sign_extra(1, 30, 0), Call::Balances(BalancesCall::transfer(33, 69))); + let xt = sp_runtime::testing::TestXt(sign_extra(1, 30, 0), Call::Balances(BalancesCall::transfer(33, 69))); t.execute_with(|| { Executive::initialize_block(&Header::new( 1, @@ -590,7 +590,7 @@ mod tests { fn block_weight_limit_enforced() { let mut t = new_test_ext(10000); // given: TestXt uses the encoded len as fixed Len: - let xt = sr_primitives::testing::TestXt(sign_extra(1, 0, 0), Call::Balances(BalancesCall::transfer(33, 0))); + let xt = sp_runtime::testing::TestXt(sign_extra(1, 0, 0), Call::Balances(BalancesCall::transfer(33, 0))); let encoded = xt.encode(); let encoded_len = encoded.len() as Weight; let limit = AvailableBlockRatio::get() * MaximumBlockWeight::get() - 175; @@ -607,7 +607,7 @@ mod tests { assert_eq!(>::all_extrinsics_weight(), 175); for nonce in 0..=num_to_exhaust_block { - let xt = sr_primitives::testing::TestXt( + let xt = sp_runtime::testing::TestXt( sign_extra(1, nonce.into(), 0), Call::Balances(BalancesCall::transfer(33, 0)), ); let res = Executive::apply_extrinsic(xt); @@ -627,9 +627,9 @@ mod tests { #[test] fn block_weight_and_size_is_stored_per_tx() { - let xt = sr_primitives::testing::TestXt(sign_extra(1, 0, 0), Call::Balances(BalancesCall::transfer(33, 0))); - let x1 = sr_primitives::testing::TestXt(sign_extra(1, 1, 0), Call::Balances(BalancesCall::transfer(33, 0))); - let x2 = sr_primitives::testing::TestXt(sign_extra(1, 2, 0), Call::Balances(BalancesCall::transfer(33, 0))); + let xt = sp_runtime::testing::TestXt(sign_extra(1, 0, 0), Call::Balances(BalancesCall::transfer(33, 0))); + let x1 = sp_runtime::testing::TestXt(sign_extra(1, 1, 0), Call::Balances(BalancesCall::transfer(33, 0))); + let x2 = sp_runtime::testing::TestXt(sign_extra(1, 2, 0), Call::Balances(BalancesCall::transfer(33, 0))); let len = xt.clone().encode().len() as u32; let mut t = new_test_ext(1); t.execute_with(|| { @@ -653,7 +653,7 @@ mod tests { #[test] fn validate_unsigned() { - let xt = sr_primitives::testing::TestXt(None, Call::Balances(BalancesCall::set_balance(33, 69, 69))); + let xt = sp_runtime::testing::TestXt(None, Call::Balances(BalancesCall::set_balance(33, 69, 69))); let mut t = new_test_ext(1); t.execute_with(|| { @@ -682,7 +682,7 @@ mod tests { Bounded::max_value(), lock, ); - let xt = sr_primitives::testing::TestXt( + let xt = sp_runtime::testing::TestXt( sign_extra(1, 0, 0), Call::System(SystemCall::remark(vec![1u8])), ); diff --git a/frame/finality-tracker/Cargo.toml b/frame/finality-tracker/Cargo.toml index 6fb767f0d0..e3dd7b1428 100644 --- a/frame/finality-tracker/Cargo.toml +++ b/frame/finality-tracker/Cargo.toml @@ -7,17 +7,17 @@ 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 } -inherents = { package = "substrate-inherents", path = "../../primitives/inherents", default-features = false } -rstd = { package = "sr-std", path = "../../primitives/sr-std", default-features = false } -sr-primitives = { path = "../../primitives/sr-primitives", default-features = false } +inherents = { package = "sp-inherents", path = "../../primitives/inherents", default-features = false } +rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +sp-runtime = { path = "../../primitives/sr-primitives", default-features = false } sp-finality-tracker = { path = "../../primitives/finality-tracker", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } frame-system = { path = "../system", default-features = false } impl-trait-for-tuples = "0.1.3" [dev-dependencies] -primitives = { package = "substrate-primitives", path = "../../primitives/core", default-features = false } -runtime-io = { package = "sr-io", path = "../../primitives/sr-io", default-features = false } +primitives = { package = "sp-core", path = "../../primitives/core", default-features = false } +runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } [features] default = ["std"] @@ -26,7 +26,7 @@ std = [ "codec/std", "rstd/std", "support/std", - "sr-primitives/std", + "sp-runtime/std", "frame-system/std", "sp-finality-tracker/std", "inherents/std", diff --git a/frame/finality-tracker/src/lib.rs b/frame/finality-tracker/src/lib.rs index 2be496ab45..3cb842de24 100644 --- a/frame/finality-tracker/src/lib.rs +++ b/frame/finality-tracker/src/lib.rs @@ -19,7 +19,7 @@ #![cfg_attr(not(feature = "std"), no_std)] use inherents::{InherentIdentifier, ProvideInherent, InherentData, MakeFatalError}; -use sr_primitives::traits::{One, Zero, SaturatedConversion}; +use sp_runtime::traits::{One, Zero, SaturatedConversion}; use rstd::{prelude::*, result, cmp, vec}; use support::{decl_module, decl_storage}; use support::traits::Get; @@ -195,7 +195,7 @@ mod tests { use runtime_io::TestExternalities; use primitives::H256; - use sr_primitives::{ + use sp_runtime::{ testing::Header, Perbill, traits::{BlakeTwo256, IdentityLookup, OnFinalize, Header as HeaderT}, }; diff --git a/frame/generic-asset/Cargo.toml b/frame/generic-asset/Cargo.toml index f8ea4c020f..210bc7773a 100644 --- a/frame/generic-asset/Cargo.toml +++ b/frame/generic-asset/Cargo.toml @@ -7,14 +7,14 @@ edition = "2018" [dependencies] serde = { version = "1.0.101", optional = true } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -rstd = { package = "sr-std", path = "../../primitives/sr-std", default-features = false } -sr-primitives = { path = "../../primitives/sr-primitives", default-features = false } +rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +sp-runtime = { path = "../../primitives/sr-primitives", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } system = { package = "frame-system", path = "../system", default-features = false } [dev-dependencies] -runtime-io ={ package = "sr-io", path = "../../primitives/sr-io" } -primitives = { package = "substrate-primitives", path = "../../primitives/core" } +runtime-io ={ package = "sp-io", path = "../../primitives/sr-io" } +primitives = { package = "sp-core", path = "../../primitives/core" } [features] default = ["std"] @@ -22,7 +22,7 @@ std =[ "serde/std", "codec/std", "rstd/std", - "sr-primitives/std", + "sp-runtime/std", "support/std", "system/std", ] diff --git a/frame/generic-asset/src/lib.rs b/frame/generic-asset/src/lib.rs index a552880a34..57942ae186 100644 --- a/frame/generic-asset/src/lib.rs +++ b/frame/generic-asset/src/lib.rs @@ -153,8 +153,8 @@ use codec::{Decode, Encode, HasCompact, Input, Output, Error}; -use sr_primitives::RuntimeDebug; -use sr_primitives::traits::{ +use sp_runtime::RuntimeDebug; +use sp_runtime::traits::{ CheckedAdd, CheckedSub, MaybeSerializeDeserialize, Member, One, Saturating, SimpleArithmetic, Zero, Bounded, }; diff --git a/frame/generic-asset/src/mock.rs b/frame/generic-asset/src/mock.rs index 36dea84d66..28d6f96de1 100644 --- a/frame/generic-asset/src/mock.rs +++ b/frame/generic-asset/src/mock.rs @@ -20,7 +20,7 @@ #![cfg(test)] -use sr_primitives::{ +use sp_runtime::{ Perbill, testing::Header, traits::{BlakeTwo256, IdentityLookup}, diff --git a/frame/grandpa/Cargo.toml b/frame/grandpa/Cargo.toml index f086968a22..d463e216ed 100644 --- a/frame/grandpa/Cargo.toml +++ b/frame/grandpa/Cargo.toml @@ -7,18 +7,18 @@ edition = "2018" [dependencies] serde = { version = "1.0.101", optional = true, features = ["derive"] } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -primitives = { package = "substrate-primitives", path = "../../primitives/core", default-features = false } -substrate-finality-grandpa-primitives = { path = "../../primitives/finality-grandpa", default-features = false } -rstd = { package = "sr-std", path = "../../primitives/sr-std", default-features = false } -sr-primitives = { path = "../../primitives/sr-primitives", default-features = false } -sr-staking-primitives = { path = "../../primitives/sr-staking-primitives", default-features = false } +primitives = { package = "sp-core", path = "../../primitives/core", default-features = false } +sp-finality-granpda = { path = "../../primitives/finality-grandpa", default-features = false } +rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +sp-runtime = { path = "../../primitives/sr-primitives", default-features = false } +sp-staking = { path = "../../primitives/sr-staking-primitives", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } system = { package = "frame-system", path = "../system", default-features = false } session = { package = "pallet-session", path = "../session", default-features = false } finality-tracker = { package = "pallet-finality-tracker", path = "../finality-tracker", default-features = false } [dev-dependencies] -runtime-io ={ package = "sr-io", path = "../../primitives/sr-io" } +runtime-io ={ package = "sp-io", path = "../../primitives/sr-io" } [features] default = ["std"] @@ -26,11 +26,11 @@ std = [ "serde", "codec/std", "primitives/std", - "substrate-finality-grandpa-primitives/std", + "sp-finality-granpda/std", "rstd/std", "support/std", - "sr-primitives/std", - "sr-staking-primitives/std", + "sp-runtime/std", + "sp-staking/std", "system/std", "session/std", "finality-tracker/std", diff --git a/frame/grandpa/src/lib.rs b/frame/grandpa/src/lib.rs index 877521c974..0c4c6b202e 100644 --- a/frame/grandpa/src/lib.rs +++ b/frame/grandpa/src/lib.rs @@ -28,15 +28,15 @@ #![cfg_attr(not(feature = "std"), no_std)] // re-export since this is necessary for `impl_apis` in runtime. -pub use substrate_finality_grandpa_primitives as fg_primitives; +pub use sp_finality_granpda as fg_primitives; use rstd::prelude::*; use codec::{self as codec, Encode, Decode, Error}; use support::{decl_event, decl_storage, decl_module, dispatch::Result, storage}; -use sr_primitives::{ +use sp_runtime::{ generic::{DigestItem, OpaqueDigestItemId}, traits::Zero, Perbill, }; -use sr_staking_primitives::{ +use sp_staking::{ SessionIndex, offence::{Offence, Kind}, }; @@ -400,7 +400,7 @@ impl Module { } } -impl sr_primitives::BoundToRuntimeAppPublic for Module { +impl sp_runtime::BoundToRuntimeAppPublic for Module { type Public = AuthorityId; } diff --git a/frame/grandpa/src/mock.rs b/frame/grandpa/src/mock.rs index 3fdf807f24..75de98cdf9 100644 --- a/frame/grandpa/src/mock.rs +++ b/frame/grandpa/src/mock.rs @@ -18,13 +18,13 @@ #![cfg(test)] -use sr_primitives::{Perbill, DigestItem, traits::IdentityLookup, testing::{Header, UintAuthorityId}}; +use sp_runtime::{Perbill, DigestItem, traits::IdentityLookup, testing::{Header, UintAuthorityId}}; use runtime_io; use support::{impl_outer_origin, impl_outer_event, parameter_types, weights::Weight}; use primitives::H256; use codec::{Encode, Decode}; use crate::{AuthorityId, AuthorityList, GenesisConfig, Trait, Module, ConsensusLog}; -use substrate_finality_grandpa_primitives::GRANDPA_ENGINE_ID; +use sp_finality_granpda::GRANDPA_ENGINE_ID; impl_outer_origin!{ pub enum Origin for Test {} @@ -53,7 +53,7 @@ impl system::Trait for Test { type BlockNumber = u64; type Call = (); type Hash = H256; - type Hashing = sr_primitives::traits::BlakeTwo256; + type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; diff --git a/frame/grandpa/src/tests.rs b/frame/grandpa/src/tests.rs index 3d6a8752c5..9ca00fd169 100644 --- a/frame/grandpa/src/tests.rs +++ b/frame/grandpa/src/tests.rs @@ -18,7 +18,7 @@ #![cfg(test)] -use sr_primitives::{testing::Digest, traits::{Header, OnFinalize}}; +use sp_runtime::{testing::Digest, traits::{Header, OnFinalize}}; use crate::mock::*; use system::{EventRecord, Phase}; use codec::{Decode, Encode}; @@ -312,7 +312,7 @@ fn time_slot_have_sane_ord() { #[test] #[cfg(feature = "migrate-authorities")] fn authorities_migration() { - use sr_primitives::traits::OnInitialize; + use sp_runtime::traits::OnInitialize; with_externalities(&mut new_test_ext(vec![]), || { let authorities = to_authorities(vec![(1, 1), (2, 1), (3, 1)]); diff --git a/frame/im-online/Cargo.toml b/frame/im-online/Cargo.toml index d0959da892..3c7acb3b20 100644 --- a/frame/im-online/Cargo.toml +++ b/frame/im-online/Cargo.toml @@ -5,16 +5,16 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -app-crypto = { package = "substrate-application-crypto", path = "../../primitives/application-crypto", default-features = false } +app-crypto = { package = "sc-application-crypto", path = "../../primitives/application-crypto", default-features = false } authorship = { package = "pallet-authorship", path = "../authorship", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -primitives = { package="substrate-primitives", path = "../../primitives/core", default-features = false } -rstd = { package = "sr-std", path = "../../primitives/sr-std", default-features = false } +primitives = { package="sp-core", path = "../../primitives/core", default-features = false } +rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } serde = { version = "1.0.101", optional = true } session = { package = "pallet-session", path = "../session", default-features = false } -runtime-io = { package = "sr-io", path = "../../primitives/sr-io", default-features = false } -sr-primitives = { path = "../../primitives/sr-primitives", default-features = false } -sr-staking-primitives = { path = "../../primitives/sr-staking-primitives", default-features = false } +runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } +sp-runtime = { path = "../../primitives/sr-primitives", default-features = false } +sp-staking = { path = "../../primitives/sr-staking-primitives", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } system = { package = "frame-system", path = "../system", default-features = false } @@ -29,8 +29,8 @@ std = [ "serde", "session/std", "runtime-io/std", - "sr-primitives/std", - "sr-staking-primitives/std", + "sp-runtime/std", + "sp-staking/std", "support/std", "system/std", ] diff --git a/frame/im-online/src/lib.rs b/frame/im-online/src/lib.rs index 8f3361186f..7892054b7f 100644 --- a/frame/im-online/src/lib.rs +++ b/frame/im-online/src/lib.rs @@ -76,7 +76,7 @@ use primitives::offchain::{OpaqueNetworkState, StorageKind}; use rstd::prelude::*; use rstd::convert::TryInto; use session::historical::IdentificationTuple; -use sr_primitives::{ +use sp_runtime::{ RuntimeDebug, traits::{Convert, Member, Printable, Saturating}, Perbill, transaction_validity::{ @@ -84,7 +84,7 @@ use sr_primitives::{ TransactionPriority, }, }; -use sr_staking_primitives::{ +use sp_staking::{ SessionIndex, offence::{ReportOffence, Offence, Kind}, }; @@ -509,7 +509,7 @@ impl Module { } } -impl sr_primitives::BoundToRuntimeAppPublic for Module { +impl sp_runtime::BoundToRuntimeAppPublic for Module { type Public = T::AuthorityId; } diff --git a/frame/im-online/src/mock.rs b/frame/im-online/src/mock.rs index 650353e6f9..03cf96cd28 100644 --- a/frame/im-online/src/mock.rs +++ b/frame/im-online/src/mock.rs @@ -21,10 +21,10 @@ use std::cell::RefCell; use crate::{Module, Trait}; -use sr_primitives::Perbill; -use sr_staking_primitives::{SessionIndex, offence::ReportOffence}; -use sr_primitives::testing::{Header, UintAuthorityId, TestXt}; -use sr_primitives::traits::{IdentityLookup, BlakeTwo256, ConvertInto}; +use sp_runtime::Perbill; +use sp_staking::{SessionIndex, offence::ReportOffence}; +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}; diff --git a/frame/im-online/src/tests.rs b/frame/im-online/src/tests.rs index 788956ba6e..0145b7c4fe 100644 --- a/frame/im-online/src/tests.rs +++ b/frame/im-online/src/tests.rs @@ -27,7 +27,7 @@ use primitives::offchain::{ testing::{TestOffchainExt, TestTransactionPoolExt}, }; use support::{dispatch, assert_noop}; -use sr_primitives::testing::UintAuthorityId; +use sp_runtime::testing::UintAuthorityId; #[test] fn test_unresponsiveness_slash_fraction() { diff --git a/frame/indices/Cargo.toml b/frame/indices/Cargo.toml index 17fe99ed92..2d2a41a551 100644 --- a/frame/indices/Cargo.toml +++ b/frame/indices/Cargo.toml @@ -8,11 +8,11 @@ edition = "2018" serde = { version = "1.0.101", optional = true } safe-mix = { version = "1.0.0", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -substrate-keyring = { path = "../../primitives/keyring", optional = true } -rstd = { package = "sr-std", path = "../../primitives/sr-std", default-features = false } -runtime-io = { package = "sr-io", path = "../../primitives/sr-io", default-features = false } -sr-primitives = { path = "../../primitives/sr-primitives", default-features = false } -primitives = { package = "substrate-primitives", path = "../../primitives/core", default-features = false } +sp-keyring = { path = "../../primitives/keyring", optional = true } +rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } +sp-runtime = { path = "../../primitives/sr-primitives", default-features = false } +primitives = { package = "sp-core", path = "../../primitives/core", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } system = { package = "frame-system", path = "../system", default-features = false } @@ -24,12 +24,12 @@ default = ["std"] std = [ "serde", "safe-mix/std", - "substrate-keyring", + "sp-keyring", "codec/std", "primitives/std", "rstd/std", "runtime-io/std", "support/std", - "sr-primitives/std", + "sp-runtime/std", "system/std", ] diff --git a/frame/indices/src/address.rs b/frame/indices/src/address.rs index 21ee654cf2..cfc9bcabaa 100644 --- a/frame/indices/src/address.rs +++ b/frame/indices/src/address.rs @@ -24,7 +24,7 @@ use codec::{Encode, Decode, Input, Output, Error}; /// An indices-aware address, which can be either a direct `AccountId` or /// an index. -#[derive(PartialEq, Eq, Clone, sr_primitives::RuntimeDebug)] +#[derive(PartialEq, Eq, Clone, sp_runtime::RuntimeDebug)] #[cfg_attr(feature = "std", derive(Hash))] pub enum Address where AccountId: Member, diff --git a/frame/indices/src/lib.rs b/frame/indices/src/lib.rs index 31aa57276b..d53a26f77c 100644 --- a/frame/indices/src/lib.rs +++ b/frame/indices/src/lib.rs @@ -22,7 +22,7 @@ use rstd::{prelude::*, marker::PhantomData, convert::TryInto}; use codec::{Encode, Codec}; use support::{Parameter, decl_module, decl_event, decl_storage}; -use sr_primitives::traits::{One, SimpleArithmetic, StaticLookup, Member, LookupError}; +use sp_runtime::traits::{One, SimpleArithmetic, StaticLookup, Member, LookupError}; use system::{IsDeadAccount, OnNewAccount}; use self::address::Address as RawAddress; diff --git a/frame/indices/src/mock.rs b/frame/indices/src/mock.rs index 43b009a544..880ff5d66e 100644 --- a/frame/indices/src/mock.rs +++ b/frame/indices/src/mock.rs @@ -20,8 +20,8 @@ use std::collections::HashSet; use ref_thread_local::{ref_thread_local, RefThreadLocal}; -use sr_primitives::testing::Header; -use sr_primitives::Perbill; +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}; @@ -77,7 +77,7 @@ impl system::Trait for Runtime { type BlockNumber = u64; type Call = (); type Hash = H256; - type Hashing = ::sr_primitives::traits::BlakeTwo256; + type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = u64; type Lookup = Indices; type Header = Header; diff --git a/frame/membership/Cargo.toml b/frame/membership/Cargo.toml index 12c81aa741..9f8dbdbf06 100644 --- a/frame/membership/Cargo.toml +++ b/frame/membership/Cargo.toml @@ -7,21 +7,21 @@ edition = "2018" [dependencies] serde = { version = "1.0.101", optional = true } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } -rstd = { package = "sr-std", path = "../../primitives/sr-std", default-features = false } -runtime-io = { package = "sr-io", path = "../../primitives/sr-io", default-features = false } +rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } system = { package = "frame-system", path = "../system", default-features = false } -sr-primitives = { path = "../../primitives/sr-primitives", default-features = false } +sp-runtime = { path = "../../primitives/sr-primitives", default-features = false } [dev-dependencies] -primitives = { package = "substrate-primitives", path = "../../primitives/core" } +primitives = { package = "sp-core", path = "../../primitives/core" } [features] default = ["std"] std = [ "serde", "codec/std", - "sr-primitives/std", + "sp-runtime/std", "rstd/std", "runtime-io/std", "support/std", diff --git a/frame/membership/src/lib.rs b/frame/membership/src/lib.rs index 0adddc1816..d18c107d66 100644 --- a/frame/membership/src/lib.rs +++ b/frame/membership/src/lib.rs @@ -29,7 +29,7 @@ use support::{ weights::SimpleDispatchInfo, }; use system::ensure_root; -use sr_primitives::traits::EnsureOrigin; +use sp_runtime::traits::EnsureOrigin; pub trait Trait: system::Trait { /// The overarching event type. @@ -198,7 +198,7 @@ mod tests { use primitives::H256; // The testing primitives are very useful for avoiding having to work with signatures // or public keys. `u64` is used as the `AccountId` and no `Signature`s are requried. - use sr_primitives::{Perbill, traits::{BlakeTwo256, IdentityLookup}, testing::Header}; + use sp_runtime::{Perbill, traits::{BlakeTwo256, IdentityLookup}, testing::Header}; use system::EnsureSignedBy; impl_outer_origin! { diff --git a/frame/metadata/Cargo.toml b/frame/metadata/Cargo.toml index 0fc604bea4..5ed5293633 100644 --- a/frame/metadata/Cargo.toml +++ b/frame/metadata/Cargo.toml @@ -7,8 +7,8 @@ edition = "2018" [dependencies] codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } serde = { version = "1.0.101", optional = true, features = ["derive"] } -rstd = { package = "sr-std", path = "../../primitives/sr-std", default-features = false } -primitives = { package = "substrate-primitives", path = "../../primitives/core", default-features = false } +rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +primitives = { package = "sp-core", path = "../../primitives/core", default-features = false } [features] default = ["std"] diff --git a/frame/nicks/Cargo.toml b/frame/nicks/Cargo.toml index aa2df57af5..55abb0b27d 100644 --- a/frame/nicks/Cargo.toml +++ b/frame/nicks/Cargo.toml @@ -7,14 +7,14 @@ edition = "2018" [dependencies] serde = { version = "1.0.101", optional = true } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -rstd = { package = "sr-std", path = "../../primitives/sr-std", default-features = false } -runtime-io = { package = "sr-io", path = "../../primitives/sr-io", default-features = false } -sr-primitives = { path = "../../primitives/sr-primitives", default-features = false } +rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } +sp-runtime = { path = "../../primitives/sr-primitives", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } system = { package = "frame-system", path = "../system", default-features = false } [dev-dependencies] -primitives = { package = "substrate-primitives", path = "../../primitives/core" } +primitives = { package = "sp-core", path = "../../primitives/core" } balances = { package = "pallet-balances", path = "../balances", default-features = false } [features] @@ -24,7 +24,7 @@ std = [ "codec/std", "rstd/std", "runtime-io/std", - "sr-primitives/std", + "sp-runtime/std", "support/std", "system/std", ] diff --git a/frame/nicks/src/lib.rs b/frame/nicks/src/lib.rs index a82b3d15a9..cb35b1dba0 100644 --- a/frame/nicks/src/lib.rs +++ b/frame/nicks/src/lib.rs @@ -39,7 +39,7 @@ #![cfg_attr(not(feature = "std"), no_std)] use rstd::prelude::*; -use sr_primitives::{ +use sp_runtime::{ traits::{StaticLookup, EnsureOrigin, Zero} }; use support::{ @@ -234,7 +234,7 @@ mod tests { use system::EnsureSignedBy; // The testing primitives are very useful for avoiding having to work with signatures // or public keys. `u64` is used as the `AccountId` and no `Signature`s are required. - use sr_primitives::{ + use sp_runtime::{ Perbill, testing::Header, traits::{BlakeTwo256, IdentityLookup}, }; diff --git a/frame/offences/Cargo.toml b/frame/offences/Cargo.toml index 354de90e85..56be89d119 100644 --- a/frame/offences/Cargo.toml +++ b/frame/offences/Cargo.toml @@ -7,16 +7,16 @@ edition = "2018" [dependencies] balances = { package = "pallet-balances", path = "../balances", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -rstd = { package = "sr-std", path = "../../primitives/sr-std", default-features = false } +rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } serde = { version = "1.0.101", optional = true } -sr-primitives = { path = "../../primitives/sr-primitives", default-features = false } -sr-staking-primitives = { path = "../../primitives/sr-staking-primitives", default-features = false } +sp-runtime = { path = "../../primitives/sr-primitives", default-features = false } +sp-staking = { path = "../../primitives/sr-staking-primitives", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } system = { package = "frame-system", path = "../system", default-features = false } [dev-dependencies] -runtime-io = { package = "sr-io", path = "../../primitives/sr-io" } -substrate-primitives = { path = "../../primitives/core" } +runtime-io = { package = "sp-io", path = "../../primitives/sr-io" } +sp-core = { path = "../../primitives/core" } [features] default = ["std"] @@ -25,8 +25,8 @@ std = [ "codec/std", "rstd/std", "serde", - "sr-primitives/std", - "sr-staking-primitives/std", + "sp-runtime/std", + "sp-staking/std", "support/std", "system/std", ] diff --git a/frame/offences/src/lib.rs b/frame/offences/src/lib.rs index ce9a1a0a41..eb1f2abc3c 100644 --- a/frame/offences/src/lib.rs +++ b/frame/offences/src/lib.rs @@ -28,8 +28,8 @@ use rstd::vec::Vec; use support::{ decl_module, decl_event, decl_storage, Parameter, }; -use sr_primitives::traits::Hash; -use sr_staking_primitives::{ +use sp_runtime::traits::Hash; +use sp_staking::{ offence::{Offence, ReportOffence, Kind, OnOffenceHandler, OffenceDetails}, }; use codec::{Encode, Decode}; diff --git a/frame/offences/src/mock.rs b/frame/offences/src/mock.rs index dc331b3147..ad1d0f8b26 100644 --- a/frame/offences/src/mock.rs +++ b/frame/offences/src/mock.rs @@ -21,14 +21,14 @@ use std::cell::RefCell; use crate::{Module, Trait}; use codec::Encode; -use sr_primitives::Perbill; -use sr_staking_primitives::{ +use sp_runtime::Perbill; +use sp_staking::{ SessionIndex, offence::{self, Kind, OffenceDetails}, }; -use sr_primitives::testing::Header; -use sr_primitives::traits::{IdentityLookup, BlakeTwo256}; -use substrate_primitives::H256; +use sp_runtime::testing::Header; +use sp_runtime::traits::{IdentityLookup, BlakeTwo256}; +use sp_core::H256; use support::{ impl_outer_origin, impl_outer_event, parameter_types, StorageMap, StorageDoubleMap, weights::Weight, diff --git a/frame/offences/src/tests.rs b/frame/offences/src/tests.rs index aa71d1d620..134c7a3cb0 100644 --- a/frame/offences/src/tests.rs +++ b/frame/offences/src/tests.rs @@ -23,7 +23,7 @@ use crate::mock::{ Offences, System, Offence, TestEvent, KIND, new_test_ext, with_on_offence_fractions, offence_reports, }; -use sr_primitives::Perbill; +use sp_runtime::Perbill; use system::{EventRecord, Phase}; #[test] diff --git a/frame/randomness-collective-flip/Cargo.toml b/frame/randomness-collective-flip/Cargo.toml index b76f908500..291a321776 100644 --- a/frame/randomness-collective-flip/Cargo.toml +++ b/frame/randomness-collective-flip/Cargo.toml @@ -7,14 +7,14 @@ edition = "2018" [dependencies] safe-mix = { version = "1.0", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sr-primitives = { path = "../../primitives/sr-primitives", default-features = false } +sp-runtime = { path = "../../primitives/sr-primitives", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } system = { package = "frame-system", path = "../system", default-features = false } -rstd = { package = "sr-std", path = "../../primitives/sr-std", default-features = false } +rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } [dev-dependencies] -primitives = { package = "substrate-primitives", path = "../../primitives/core" } -runtime-io = { package = "sr-io", path = "../../primitives/sr-io" } +primitives = { package = "sp-core", path = "../../primitives/core" } +runtime-io = { package = "sp-io", path = "../../primitives/sr-io" } [features] default = ["std"] @@ -23,6 +23,6 @@ std = [ "system/std", "codec/std", "support/std", - "sr-primitives/std", + "sp-runtime/std", "rstd/std", ] diff --git a/frame/randomness-collective-flip/src/lib.rs b/frame/randomness-collective-flip/src/lib.rs index ba5f0f79f4..1a719ac915 100644 --- a/frame/randomness-collective-flip/src/lib.rs +++ b/frame/randomness-collective-flip/src/lib.rs @@ -53,7 +53,7 @@ #![cfg_attr(not(feature = "std"), no_std)] use rstd::{prelude::*, convert::TryInto}; -use sr_primitives::traits::Hash; +use sp_runtime::traits::Hash; use support::{decl_module, decl_storage, traits::Randomness}; use safe_mix::TripletMix; use codec::Encode; @@ -153,7 +153,7 @@ impl Randomness for Module { mod tests { use super::*; use primitives::H256; - use sr_primitives::{ + use sp_runtime::{ Perbill, traits::{BlakeTwo256, OnInitialize, Header as _, IdentityLookup}, testing::Header, }; use support::{impl_outer_origin, parameter_types, weights::Weight, traits::Randomness}; diff --git a/frame/scored-pool/Cargo.toml b/frame/scored-pool/Cargo.toml index cebb071003..2dd64dfb92 100644 --- a/frame/scored-pool/Cargo.toml +++ b/frame/scored-pool/Cargo.toml @@ -7,15 +7,15 @@ 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 = "sr-io", path = "../../primitives/sr-io", default-features = false } -sr-primitives = { path = "../../primitives/sr-primitives", default-features = false } -rstd = { package = "sr-std", path = "../../primitives/sr-std", default-features = false } +runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } +sp-runtime = { path = "../../primitives/sr-primitives", default-features = false } +rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } system = { package = "frame-system", path = "../system", default-features = false } [dev-dependencies] balances = { package = "pallet-balances", path = "../balances" } -primitives = { package = "substrate-primitives", path = "../../primitives/core" } +primitives = { package = "sp-core", path = "../../primitives/core" } [features] default = ["std"] @@ -23,7 +23,7 @@ std = [ "codec/std", "serde", "runtime-io/std", - "sr-primitives/std", + "sp-runtime/std", "rstd/std", "support/std", "system/std", diff --git a/frame/scored-pool/src/lib.rs b/frame/scored-pool/src/lib.rs index 39cffdb77f..8a2bfb9051 100644 --- a/frame/scored-pool/src/lib.rs +++ b/frame/scored-pool/src/lib.rs @@ -98,7 +98,7 @@ use support::{ traits::{ChangeMembers, InitializeMembers, Currency, Get, ReservableCurrency}, }; use system::{self, ensure_root, ensure_signed}; -use sr_primitives::{ +use sp_runtime::{ traits::{EnsureOrigin, SimpleArithmetic, MaybeSerializeDeserialize, Zero, StaticLookup}, }; diff --git a/frame/scored-pool/src/mock.rs b/frame/scored-pool/src/mock.rs index b2e1b29cbf..353e71882e 100644 --- a/frame/scored-pool/src/mock.rs +++ b/frame/scored-pool/src/mock.rs @@ -23,7 +23,7 @@ use support::{impl_outer_origin, parameter_types, weights::Weight}; use primitives::H256; // The testing primitives are very useful for avoiding having to work with signatures // or public keys. `u64` is used as the `AccountId` and no `Signature`s are requried. -use sr_primitives::{ +use sp_runtime::{ Perbill, traits::{BlakeTwo256, IdentityLookup}, testing::Header, }; use system::EnsureSignedBy; diff --git a/frame/scored-pool/src/tests.rs b/frame/scored-pool/src/tests.rs index 2f47b5da6f..20aff6618a 100644 --- a/frame/scored-pool/src/tests.rs +++ b/frame/scored-pool/src/tests.rs @@ -20,7 +20,7 @@ use super::*; use mock::*; use support::{assert_ok, assert_noop}; -use sr_primitives::traits::OnInitialize; +use sp_runtime::traits::OnInitialize; type ScoredPool = Module; type System = system::Module; diff --git a/frame/session/Cargo.toml b/frame/session/Cargo.toml index b93111d262..6265187912 100644 --- a/frame/session/Cargo.toml +++ b/frame/session/Cargo.toml @@ -8,33 +8,33 @@ edition = "2018" serde = { version = "1.0.101", optional = true } safe-mix = { version = "1.0.0", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -rstd = { package = "sr-std", path = "../../primitives/sr-std", default-features = false } -sr-primitives = { path = "../../primitives/sr-primitives", default-features = false } -sr-staking-primitives = { path = "../../primitives/sr-staking-primitives", default-features = false } +rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +sp-runtime = { path = "../../primitives/sr-primitives", default-features = false } +sp-staking = { path = "../../primitives/sr-staking-primitives", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } system = { package = "frame-system", path = "../system", default-features = false } timestamp = { package = "pallet-timestamp", path = "../timestamp", default-features = false } -substrate-trie = { path = "../../primitives/trie", default-features = false, optional = true } -runtime-io ={ package = "sr-io", path = "../../primitives/sr-io", 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 } impl-trait-for-tuples = "0.1.3" [dev-dependencies] -primitives = { package = "substrate-primitives", path = "../../primitives/core" } -app-crypto = { package = "substrate-application-crypto", path = "../../primitives/application-crypto" } +primitives = { package = "sp-core", path = "../../primitives/core" } +app-crypto = { package = "sc-application-crypto", path = "../../primitives/application-crypto" } lazy_static = "1.4.0" [features] default = ["std", "historical"] -historical = ["substrate-trie"] +historical = ["sp-trie"] std = [ "serde", "safe-mix/std", "codec/std", "rstd/std", "support/std", - "sr-primitives/std", - "sr-staking-primitives/std", + "sp-runtime/std", + "sp-staking/std", "timestamp/std", - "substrate-trie/std", + "sp-trie/std", "runtime-io/std", ] diff --git a/frame/session/src/historical.rs b/frame/session/src/historical.rs index 7975da4998..c693313327 100644 --- a/frame/session/src/historical.rs +++ b/frame/session/src/historical.rs @@ -27,12 +27,12 @@ use rstd::prelude::*; use codec::{Encode, Decode}; -use sr_primitives::KeyTypeId; -use sr_primitives::traits::{Convert, OpaqueKeys, Hash as HashT}; +use sp_runtime::KeyTypeId; +use sp_runtime::traits::{Convert, OpaqueKeys, Hash as HashT}; use support::{decl_module, decl_storage}; use support::{Parameter, print}; -use substrate_trie::{MemoryDB, Trie, TrieMut, Recorder, EMPTY_PREFIX}; -use substrate_trie::trie_types::{TrieDBMut, TrieDB}; +use sp_trie::{MemoryDB, Trie, TrieMut, Recorder, EMPTY_PREFIX}; +use sp_trie::trie_types::{TrieDBMut, TrieDB}; use super::{SessionIndex, Module as SessionModule}; type ValidatorCount = u32; @@ -214,7 +214,7 @@ impl ProvingTrie { } fn from_nodes(root: T::Hash, nodes: &[Vec]) -> Self { - use substrate_trie::HashDBT; + use sp_trie::HashDBT; let mut memory_db = MemoryDB::default(); for node in nodes { @@ -311,7 +311,7 @@ impl> support::traits::KeyOwnerProofSystem<(KeyTypeId, mod tests { use super::*; use primitives::crypto::key_types::DUMMY; - use sr_primitives::{traits::OnInitialize, testing::UintAuthorityId}; + use sp_runtime::{traits::OnInitialize, testing::UintAuthorityId}; use crate::mock::{ NEXT_VALIDATORS, force_new_session, set_next_validators, Test, System, Session, diff --git a/frame/session/src/lib.rs b/frame/session/src/lib.rs index 0e35ae45a6..cf73c9d0fb 100644 --- a/frame/session/src/lib.rs +++ b/frame/session/src/lib.rs @@ -121,10 +121,10 @@ use rstd::{prelude::*, marker::PhantomData, ops::{Sub, Rem}}; use codec::Decode; -use sr_primitives::{KeyTypeId, Perbill, RuntimeAppPublic, BoundToRuntimeAppPublic}; +use sp_runtime::{KeyTypeId, Perbill, RuntimeAppPublic, BoundToRuntimeAppPublic}; use support::weights::SimpleDispatchInfo; -use sr_primitives::traits::{Convert, Zero, Member, OpaqueKeys}; -use sr_staking_primitives::SessionIndex; +use sp_runtime::traits::{Convert, Zero, Member, OpaqueKeys}; +use sp_staking::SessionIndex; use support::{dispatch::Result, ConsensusEngineId, decl_module, decl_event, decl_storage}; use support::{ensure, traits::{OnFreeBalanceZero, Get, FindAuthor}, Parameter}; use system::{self, ensure_signed}; @@ -307,7 +307,7 @@ impl SessionHandler for Tuple { /// `SessionHandler` for tests that use `UintAuthorityId` as `Keys`. pub struct TestSessionHandler; impl SessionHandler for TestSessionHandler { - const KEY_TYPE_IDS: &'static [KeyTypeId] = &[sr_primitives::key_types::DUMMY]; + const KEY_TYPE_IDS: &'static [KeyTypeId] = &[sp_runtime::key_types::DUMMY]; fn on_genesis_session(_: &[(AId, Ks)]) {} @@ -716,7 +716,7 @@ mod tests { use super::*; use support::assert_ok; use primitives::crypto::key_types::DUMMY; - use sr_primitives::{traits::OnInitialize, testing::UintAuthorityId}; + use sp_runtime::{traits::OnInitialize, testing::UintAuthorityId}; use mock::{ NEXT_VALIDATORS, SESSION_CHANGED, TEST_SESSION_CHANGED, authorities, force_new_session, set_next_validators, set_session_length, session_changed, Test, Origin, System, Session, diff --git a/frame/session/src/mock.rs b/frame/session/src/mock.rs index 4a2c1d45c3..9ee95d208b 100644 --- a/frame/session/src/mock.rs +++ b/frame/session/src/mock.rs @@ -20,11 +20,11 @@ use super::*; use std::cell::RefCell; use support::{impl_outer_origin, parameter_types, weights::Weight}; use primitives::{crypto::key_types::DUMMY, H256}; -use sr_primitives::{ +use sp_runtime::{ Perbill, impl_opaque_keys, traits::{BlakeTwo256, IdentityLookup, ConvertInto}, testing::{Header, UintAuthorityId} }; -use sr_staking_primitives::SessionIndex; +use sp_staking::SessionIndex; impl_opaque_keys! { pub struct MockSessionKeys { @@ -66,7 +66,7 @@ impl ShouldEndSession for TestShouldEndSession { pub struct TestSessionHandler; impl SessionHandler for TestSessionHandler { - const KEY_TYPE_IDS: &'static [sr_primitives::KeyTypeId] = &[UintAuthorityId::ID]; + const KEY_TYPE_IDS: &'static [sp_runtime::KeyTypeId] = &[UintAuthorityId::ID]; fn on_genesis_session(_validators: &[(u64, T)]) {} fn on_new_session( changed: bool, @@ -204,7 +204,7 @@ impl Trait for Test { #[cfg(feature = "historical")] impl crate::historical::Trait for Test { type FullIdentification = u64; - type FullIdentificationOf = sr_primitives::traits::ConvertInto; + type FullIdentificationOf = sp_runtime::traits::ConvertInto; } pub type System = system::Module; diff --git a/frame/staking/Cargo.toml b/frame/staking/Cargo.toml index 110c3d868c..9f410395dd 100644 --- a/frame/staking/Cargo.toml +++ b/frame/staking/Cargo.toml @@ -8,19 +8,19 @@ edition = "2018" serde = { version = "1.0.101", optional = true } safe-mix = { version = "1.0.0", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -substrate-keyring = { path = "../../primitives/keyring", optional = true } -rstd = { package = "sr-std", path = "../../primitives/sr-std", default-features = false } -phragmen = { package = "substrate-phragmen", path = "../../primitives/phragmen", default-features = false } -runtime-io ={ package = "sr-io", path = "../../primitives/sr-io", default-features = false } -sr-primitives = { path = "../../primitives/sr-primitives", default-features = false } -sr-staking-primitives = { path = "../../primitives/sr-staking-primitives", default-features = false } +sp-keyring = { path = "../../primitives/keyring", optional = true } +rstd = { package = "sp-std", path = "../../primitives/sr-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-runtime = { path = "../../primitives/sr-primitives", default-features = false } +sp-staking = { path = "../../primitives/sr-staking-primitives", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } system = { package = "frame-system", path = "../system", default-features = false } session = { package = "pallet-session", path = "../session", default-features = false, features = ["historical"] } authorship = { package = "pallet-authorship", path = "../authorship", default-features = false } [dev-dependencies] -primitives = { package = "substrate-primitives", path = "../../primitives/core" } +primitives = { package = "sp-core", path = "../../primitives/core" } balances = { package = "pallet-balances", path = "../balances" } timestamp = { package = "pallet-timestamp", path = "../timestamp" } pallet-staking-reward-curve = { path = "../staking/reward-curve"} @@ -33,14 +33,14 @@ default = ["std", "equalize"] std = [ "serde", "safe-mix/std", - "substrate-keyring", + "sp-keyring", "codec/std", "rstd/std", "phragmen/std", "runtime-io/std", "support/std", - "sr-primitives/std", - "sr-staking-primitives/std", + "sp-runtime/std", + "sp-staking/std", "session/std", "system/std", "authorship/std", diff --git a/frame/staking/reward-curve/Cargo.toml b/frame/staking/reward-curve/Cargo.toml index 11ce7cefb4..0df68a43af 100644 --- a/frame/staking/reward-curve/Cargo.toml +++ b/frame/staking/reward-curve/Cargo.toml @@ -14,4 +14,4 @@ proc-macro2 = "1.0.6" proc-macro-crate = "0.1.4" [dev-dependencies] -sr-primitives = { path = "../../../primitives/sr-primitives" } +sp-runtime = { path = "../../../primitives/sr-primitives" } diff --git a/frame/staking/reward-curve/src/lib.rs b/frame/staking/reward-curve/src/lib.rs index 3bde53b55f..89a1980d19 100644 --- a/frame/staking/reward-curve/src/lib.rs +++ b/frame/staking/reward-curve/src/lib.rs @@ -42,7 +42,7 @@ use syn::parse::{Parse, ParseStream}; /// /// ``` /// # fn main() {} -/// use sr_primitives::curve::PiecewiseLinear; +/// use sp_runtime::curve::PiecewiseLinear; /// /// pallet_staking_reward_curve::build! { /// const I_NPOS: PiecewiseLinear<'static> = curve!( @@ -64,10 +64,10 @@ pub fn build(input: TokenStream) -> TokenStream { let declaration = generate_piecewise_linear(points); let test_module = generate_test_module(&input); - let imports = match crate_name("sr-primitives") { - Ok(sr_primitives) => { - let ident = syn::Ident::new(&sr_primitives, Span::call_site()); - quote!( extern crate #ident as _sr_primitives; ) + let imports = match crate_name("sp-runtime") { + Ok(sp_runtime) => { + let ident = syn::Ident::new(&sp_runtime, Span::call_site()); + quote!( extern crate #ident as _sp_runtime; ) }, Err(e) => syn::Error::new(Span::call_site(), &e).to_compile_error(), }; @@ -345,16 +345,16 @@ fn generate_piecewise_linear(points: Vec<(u32, u32)>) -> TokenStream2 { points_tokens.extend(quote!( ( - _sr_primitives::Perbill::from_parts(#x_perbill), - _sr_primitives::Perbill::from_parts(#y_perbill), + _sp_runtime::Perbill::from_parts(#x_perbill), + _sp_runtime::Perbill::from_parts(#y_perbill), ), )); } quote!( - _sr_primitives::curve::PiecewiseLinear::<'static> { + _sp_runtime::curve::PiecewiseLinear::<'static> { points: & [ #points_tokens ], - maximum: _sr_primitives::Perbill::from_parts(#max), + maximum: _sp_runtime::Perbill::from_parts(#max), } ) } diff --git a/frame/staking/reward-curve/tests/test.rs b/frame/staking/reward-curve/tests/test.rs index 4ed2def3fe..399bf7b9a7 100644 --- a/frame/staking/reward-curve/tests/test.rs +++ b/frame/staking/reward-curve/tests/test.rs @@ -19,7 +19,7 @@ mod test_small_falloff { pallet_staking_reward_curve::build! { - const REWARD_CURVE: sr_primitives::curve::PiecewiseLinear<'static> = curve!( + const REWARD_CURVE: sp_runtime::curve::PiecewiseLinear<'static> = curve!( min_inflation: 0_020_000, max_inflation: 0_200_000, ideal_stake: 0_600_000, @@ -32,7 +32,7 @@ mod test_small_falloff { mod test_big_falloff { pallet_staking_reward_curve::build! { - const REWARD_CURVE: sr_primitives::curve::PiecewiseLinear<'static> = curve!( + const REWARD_CURVE: sp_runtime::curve::PiecewiseLinear<'static> = curve!( min_inflation: 0_100_000, max_inflation: 0_400_000, ideal_stake: 0_400_000, diff --git a/frame/staking/src/inflation.rs b/frame/staking/src/inflation.rs index 914d2ee93a..902cc0a271 100644 --- a/frame/staking/src/inflation.rs +++ b/frame/staking/src/inflation.rs @@ -19,7 +19,7 @@ //! The staking rate in NPoS is the total amount of tokens staked by nominators and validators, //! divided by the total token supply. -use sr_primitives::{Perbill, traits::SimpleArithmetic, curve::PiecewiseLinear}; +use sp_runtime::{Perbill, traits::SimpleArithmetic, curve::PiecewiseLinear}; /// The total payout to all validators (and their nominators) per era. /// @@ -47,7 +47,7 @@ pub fn compute_total_payout( #[cfg(test)] mod test { - use sr_primitives::curve::PiecewiseLinear; + use sp_runtime::curve::PiecewiseLinear; pallet_staking_reward_curve::build! { const I_NPOS: PiecewiseLinear<'static> = curve!( diff --git a/frame/staking/src/lib.rs b/frame/staking/src/lib.rs index b2fb0c6e31..76619a142d 100644 --- a/frame/staking/src/lib.rs +++ b/frame/staking/src/lib.rs @@ -266,7 +266,7 @@ use support::{ } }; use session::{historical::OnSessionEnding, SelectInitialValidators}; -use sr_primitives::{ +use sp_runtime::{ Perbill, RuntimeDebug, curve::PiecewiseLinear, @@ -275,12 +275,12 @@ use sr_primitives::{ SimpleArithmetic, EnsureOrigin, } }; -use sr_staking_primitives::{ +use sp_staking::{ SessionIndex, offence::{OnOffenceHandler, OffenceDetails, Offence, ReportOffence}, }; #[cfg(feature = "std")] -use sr_primitives::{Serialize, Deserialize}; +use sp_runtime::{Serialize, Deserialize}; use system::{ensure_signed, ensure_root}; use phragmen::{ExtendedBalance, PhragmenStakedAssignment}; diff --git a/frame/staking/src/mock.rs b/frame/staking/src/mock.rs index 91cffb8b74..9bd60e2923 100644 --- a/frame/staking/src/mock.rs +++ b/frame/staking/src/mock.rs @@ -17,11 +17,11 @@ //! Test utilities use std::{collections::HashSet, cell::RefCell}; -use sr_primitives::{Perbill, KeyTypeId}; -use sr_primitives::curve::PiecewiseLinear; -use sr_primitives::traits::{IdentityLookup, Convert, OpaqueKeys, OnInitialize, SaturatedConversion}; -use sr_primitives::testing::{Header, UintAuthorityId}; -use sr_staking_primitives::{SessionIndex, offence::{OffenceDetails, OnOffenceHandler}}; +use sp_runtime::{Perbill, KeyTypeId}; +use sp_runtime::curve::PiecewiseLinear; +use sp_runtime::traits::{IdentityLookup, Convert, OpaqueKeys, OnInitialize, SaturatedConversion}; +use sp_runtime::testing::{Header, UintAuthorityId}; +use sp_staking::{SessionIndex, offence::{OffenceDetails, OnOffenceHandler}}; use primitives::{H256, crypto::key_types}; use runtime_io; use support::{ @@ -127,7 +127,7 @@ impl system::Trait for Test { type BlockNumber = BlockNumber; type Call = (); type Hash = H256; - type Hashing = ::sr_primitives::traits::BlakeTwo256; + type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; type Header = Header; diff --git a/frame/staking/src/slashing.rs b/frame/staking/src/slashing.rs index 23315a670a..e8515c0f40 100644 --- a/frame/staking/src/slashing.rs +++ b/frame/staking/src/slashing.rs @@ -52,7 +52,7 @@ use super::{ EraIndex, Trait, Module, Store, BalanceOf, Exposure, Perbill, SessionInterface, NegativeImbalanceOf, UnappliedSlash, }; -use sr_primitives::traits::{Zero, Saturating}; +use sp_runtime::traits::{Zero, Saturating}; use support::{ StorageMap, StorageDoubleMap, traits::{Currency, OnUnbalanced, Imbalance}, diff --git a/frame/staking/src/tests.rs b/frame/staking/src/tests.rs index 65fcd38507..0f0dbb4eba 100644 --- a/frame/staking/src/tests.rs +++ b/frame/staking/src/tests.rs @@ -18,8 +18,8 @@ use super::*; use mock::*; -use sr_primitives::{assert_eq_error_rate, traits::OnInitialize}; -use sr_staking_primitives::offence::OffenceDetails; +use sp_runtime::{assert_eq_error_rate, traits::OnInitialize}; +use sp_staking::offence::OffenceDetails; use support::{assert_ok, assert_noop, traits::{Currency, ReservableCurrency}}; use substrate_test_utils::assert_eq_uvec; diff --git a/frame/sudo/Cargo.toml b/frame/sudo/Cargo.toml index dc158c2b80..967fd06a4b 100644 --- a/frame/sudo/Cargo.toml +++ b/frame/sudo/Cargo.toml @@ -7,14 +7,14 @@ edition = "2018" [dependencies] serde = { version = "1.0.101", optional = true } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -rstd = { package = "sr-std", path = "../../primitives/sr-std", default-features = false } -runtime-io = { package = "sr-io", path = "../../primitives/sr-io", default-features = false } -sr-primitives = { path = "../../primitives/sr-primitives", default-features = false } +rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } +sp-runtime = { path = "../../primitives/sr-primitives", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } system = { package = "frame-system", path = "../system", default-features = false } [dev-dependencies] -primitives = { package = "substrate-primitives", path = "../../primitives/core" } +primitives = { package = "sp-core", path = "../../primitives/core" } [features] default = ["std"] @@ -23,7 +23,7 @@ std = [ "codec/std", "rstd/std", "runtime-io/std", - "sr-primitives/std", + "sp-runtime/std", "support/std", "system/std", ] diff --git a/frame/sudo/src/lib.rs b/frame/sudo/src/lib.rs index 082d1f6737..fa470b1785 100644 --- a/frame/sudo/src/lib.rs +++ b/frame/sudo/src/lib.rs @@ -87,7 +87,7 @@ #![cfg_attr(not(feature = "std"), no_std)] use rstd::prelude::*; -use sr_primitives::{ +use sp_runtime::{ traits::{StaticLookup, Dispatchable}, DispatchError, }; use support::{ @@ -129,7 +129,7 @@ decl_module! { Ok(_) => true, Err(e) => { let e: DispatchError = e.into(); - sr_primitives::print(e); + sp_runtime::print(e); false } }; @@ -179,7 +179,7 @@ decl_module! { Ok(_) => true, Err(e) => { let e: DispatchError = e.into(); - sr_primitives::print(e); + sp_runtime::print(e); false } }; diff --git a/frame/support/Cargo.toml b/frame/support/Cargo.toml index fea24fd6d6..f7af3a3627 100644 --- a/frame/support/Cargo.toml +++ b/frame/support/Cargo.toml @@ -9,16 +9,16 @@ log = "0.4" 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 } -rstd = { package = "sr-std", path = "../../primitives/sr-std", default-features = false } -runtime-io ={ package = "sr-io", path = "../../primitives/sr-io", default-features = false } -sr-primitives = { path = "../../primitives/sr-primitives", default-features = false } -primitives = { package = "substrate-primitives", path = "../../primitives/core", default-features = false } -sr-arithmetic = { path = "../../primitives/sr-arithmetic", default-features = false } -inherents = { package = "substrate-inherents", path = "../../primitives/inherents", default-features = false } +rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +runtime-io ={ package = "sp-io", path = "../../primitives/sr-io", default-features = false } +sp-runtime = { path = "../../primitives/sr-primitives", default-features = false } +primitives = { package = "sp-core", path = "../../primitives/core", default-features = false } +sp-arithmetic = { path = "../../primitives/sr-arithmetic", default-features = false } +inherents = { package = "sp-inherents", path = "../../primitives/inherents", default-features = false } frame-support-procedural = { package = "frame-support-procedural", path = "./procedural" } paste = "0.1.6" once_cell = { version = "0.2.4", default-features = false, optional = true } -state-machine = { package = "substrate-state-machine", path = "../../primitives/state-machine", optional = true } +state-machine = { package = "sp-state-machine", path = "../../primitives/state-machine", optional = true } bitmask = { version = "0.5.0", default-features = false } impl-trait-for-tuples = "0.1.3" tracing = { version = "0.1.10", optional = true } @@ -37,8 +37,8 @@ std = [ "runtime-io/std", "codec/std", "rstd/std", - "sr-primitives/std", - "sr-arithmetic/std", + "sp-runtime/std", + "sp-arithmetic/std", "frame-metadata/std", "inherents/std", "state-machine", diff --git a/frame/support/procedural/src/construct_runtime/mod.rs b/frame/support/procedural/src/construct_runtime/mod.rs index a7401557e1..184cb4d49d 100644 --- a/frame/support/procedural/src/construct_runtime/mod.rs +++ b/frame/support/procedural/src/construct_runtime/mod.rs @@ -93,10 +93,10 @@ fn construct_runtime_parsed(definition: RuntimeDefinition) -> Result( ) }); quote!( - #scrate::sr_primitives::impl_outer_config! { + #scrate::sp_runtime::impl_outer_config! { pub struct GenesisConfig for #runtime { #(#modules_tokens)* } diff --git a/frame/support/procedural/src/storage/genesis_config/mod.rs b/frame/support/procedural/src/storage/genesis_config/mod.rs index c222644f78..4102513cce 100644 --- a/frame/support/procedural/src/storage/genesis_config/mod.rs +++ b/frame/support/procedural/src/storage/genesis_config/mod.rs @@ -132,7 +132,7 @@ fn impl_build_storage( let builder_blocks = &builders.blocks; let build_storage_impl_trait = quote!( - #scrate::sr_primitives::BuildModuleGenesisStorage<#runtime_generic, #inherent_instance> + #scrate::sp_runtime::BuildModuleGenesisStorage<#runtime_generic, #inherent_instance> ); quote!{ @@ -140,8 +140,8 @@ fn impl_build_storage( impl#genesis_impl GenesisConfig#genesis_struct #genesis_where_clause { pub fn build_storage #fn_generic (&self) -> std::result::Result< ( - #scrate::sr_primitives::StorageOverlay, - #scrate::sr_primitives::ChildrenStorageOverlay, + #scrate::sp_runtime::StorageOverlay, + #scrate::sp_runtime::ChildrenStorageOverlay, ), String > #fn_where_clause { @@ -154,8 +154,8 @@ fn impl_build_storage( pub fn assimilate_storage #fn_generic ( &self, tuple_storage: &mut ( - #scrate::sr_primitives::StorageOverlay, - #scrate::sr_primitives::ChildrenStorageOverlay, + #scrate::sp_runtime::StorageOverlay, + #scrate::sp_runtime::ChildrenStorageOverlay, ), ) -> std::result::Result<(), String> #fn_where_clause { #scrate::BasicExternalities::execute_with_storage(tuple_storage, || { @@ -172,8 +172,8 @@ fn impl_build_storage( fn build_module_genesis_storage( &self, storage: &mut ( - #scrate::sr_primitives::StorageOverlay, - #scrate::sr_primitives::ChildrenStorageOverlay, + #scrate::sp_runtime::StorageOverlay, + #scrate::sp_runtime::ChildrenStorageOverlay, ), ) -> std::result::Result<(), String> { self.assimilate_storage::<#fn_traitinstance> (storage) diff --git a/frame/support/procedural/tools/src/lib.rs b/frame/support/procedural/tools/src/lib.rs index 5340bdbe59..10d3c4b59b 100644 --- a/frame/support/procedural/tools/src/lib.rs +++ b/frame/support/procedural/tools/src/lib.rs @@ -27,12 +27,12 @@ use quote::quote; pub mod syn_ext; -// FIXME #1569, remove the following functions, which are copied from sr-api-macros +// FIXME #1569, remove the following functions, which are copied from sp-api-macros use proc_macro2::{TokenStream, Span}; use syn::Ident; fn generate_hidden_includes_mod_name(unique_id: &str) -> Ident { - Ident::new(&format!("sr_api_hidden_includes_{}", unique_id), Span::call_site()) + Ident::new(&format!("sp_api_hidden_includes_{}", unique_id), Span::call_site()) } /// Generates the access to the `frame-support` crate. diff --git a/frame/support/src/dispatch.rs b/frame/support/src/dispatch.rs index 2421a62da9..7d7103b0a4 100644 --- a/frame/support/src/dispatch.rs +++ b/frame/support/src/dispatch.rs @@ -27,7 +27,7 @@ pub use crate::weights::{ SimpleDispatchInfo, GetDispatchInfo, DispatchInfo, WeighData, ClassifyDispatch, TransactionPriority, Weight, WeighBlock, PaysFee, }; -pub use sr_primitives::{ +pub use sp_runtime::{ traits::{Dispatchable, DispatchResult, ModuleDispatchError}, DispatchError, }; @@ -202,12 +202,12 @@ impl Parameter for T where T: Codec + EncodeLike + Clone + Eq + fmt::Debug {} /// The following reserved functions also take the block number (with type `T::BlockNumber`) as an optional input: /// /// * `on_initialize`: Executes at the beginning of a block. Using this function will -/// implement the [`OnInitialize`](../sr_primitives/traits/trait.OnInitialize.html) trait. +/// implement the [`OnInitialize`](../sp_runtime/traits/trait.OnInitialize.html) trait. /// * `on_finalize`: Executes at the end of a block. Using this function will -/// implement the [`OnFinalize`](../sr_primitives/traits/trait.OnFinalize.html) trait. +/// implement the [`OnFinalize`](../sp_runtime/traits/trait.OnFinalize.html) trait. /// * `offchain_worker`: Executes at the beginning of a block and produces extrinsics for a future block /// upon completion. Using this function will implement the -/// [`OffchainWorker`](../sr_primitives/traits/trait.OffchainWorker.html) trait. +/// [`OffchainWorker`](../sp_runtime/traits/trait.OffchainWorker.html) trait. #[macro_export] macro_rules! decl_module { // Entry point #1. @@ -861,7 +861,7 @@ macro_rules! decl_module { fn on_initialize() { $( $impl:tt )* } ) => { impl<$trait_instance: $trait_name$(, $instance: $instantiable)?> - $crate::sr_primitives::traits::OnInitialize<$trait_instance::BlockNumber> + $crate::sp_runtime::traits::OnInitialize<$trait_instance::BlockNumber> for $module<$trait_instance$(, $instance)?> where $( $other_where_bounds )* { fn on_initialize(_block_number_not_used: $trait_instance::BlockNumber) { @@ -883,7 +883,7 @@ macro_rules! decl_module { fn on_initialize($param:ident : $param_ty:ty) { $( $impl:tt )* } ) => { impl<$trait_instance: $trait_name$(, $instance: $instantiable)?> - $crate::sr_primitives::traits::OnInitialize<$trait_instance::BlockNumber> + $crate::sp_runtime::traits::OnInitialize<$trait_instance::BlockNumber> for $module<$trait_instance$(, $instance)?> where $( $other_where_bounds )* { fn on_initialize($param: $param_ty) { @@ -903,7 +903,7 @@ macro_rules! decl_module { { $( $other_where_bounds:tt )* } ) => { impl<$trait_instance: $trait_name$(, $instance: $instantiable)?> - $crate::sr_primitives::traits::OnInitialize<$trait_instance::BlockNumber> + $crate::sp_runtime::traits::OnInitialize<$trait_instance::BlockNumber> for $module<$trait_instance$(, $instance)?> where $( $other_where_bounds )* {} }; @@ -915,7 +915,7 @@ macro_rules! decl_module { fn on_finalize() { $( $impl:tt )* } ) => { impl<$trait_instance: $trait_name$(, $instance: $instantiable)?> - $crate::sr_primitives::traits::OnFinalize<$trait_instance::BlockNumber> + $crate::sp_runtime::traits::OnFinalize<$trait_instance::BlockNumber> for $module<$trait_instance$(, $instance)?> where $( $other_where_bounds )* { fn on_finalize(_block_number_not_used: $trait_instance::BlockNumber) { @@ -937,7 +937,7 @@ macro_rules! decl_module { fn on_finalize($param:ident : $param_ty:ty) { $( $impl:tt )* } ) => { impl<$trait_instance: $trait_name$(, $instance: $instantiable)?> - $crate::sr_primitives::traits::OnFinalize<$trait_instance::BlockNumber> + $crate::sp_runtime::traits::OnFinalize<$trait_instance::BlockNumber> for $module<$trait_instance$(, $instance)?> where $( $other_where_bounds )* { fn on_finalize($param: $param_ty) { @@ -957,7 +957,7 @@ macro_rules! decl_module { { $( $other_where_bounds:tt )* } ) => { impl<$trait_instance: $trait_name$(, $instance: $instantiable)?> - $crate::sr_primitives::traits::OnFinalize<$trait_instance::BlockNumber> + $crate::sp_runtime::traits::OnFinalize<$trait_instance::BlockNumber> for $module<$trait_instance$(, $instance)?> where $( $other_where_bounds )* { } @@ -998,7 +998,7 @@ macro_rules! decl_module { fn offchain_worker() { $( $impl:tt )* } ) => { impl<$trait_instance: $trait_name$(, $instance: $instantiable)?> - $crate::sr_primitives::traits::OffchainWorker<$trait_instance::BlockNumber> + $crate::sp_runtime::traits::OffchainWorker<$trait_instance::BlockNumber> for $module<$trait_instance$(, $instance)?> where $( $other_where_bounds )* { fn generate_extrinsics(_block_number_not_used: $trait_instance::BlockNumber) { $( $impl )* } @@ -1011,7 +1011,7 @@ macro_rules! decl_module { fn offchain_worker($param:ident : $param_ty:ty) { $( $impl:tt )* } ) => { impl<$trait_instance: $trait_name$(, $instance: $instantiable)?> - $crate::sr_primitives::traits::OffchainWorker<$trait_instance::BlockNumber> + $crate::sp_runtime::traits::OffchainWorker<$trait_instance::BlockNumber> for $module<$trait_instance$(, $instance)?> where $( $other_where_bounds )* { fn generate_extrinsics($param: $param_ty) { $( $impl )* } @@ -1023,7 +1023,7 @@ macro_rules! decl_module { { $( $other_where_bounds:tt )* } ) => { impl<$trait_instance: $trait_name$(, $instance: $instantiable)?> - $crate::sr_primitives::traits::OffchainWorker<$trait_instance::BlockNumber> + $crate::sp_runtime::traits::OffchainWorker<$trait_instance::BlockNumber> for $module<$trait_instance$(, $instance)?> where $( $other_where_bounds )* {} }; @@ -1885,7 +1885,7 @@ macro_rules! __check_reserved_fn_name { #[allow(dead_code)] mod tests { use super::*; - use crate::sr_primitives::traits::{OnInitialize, OnFinalize}; + use crate::sp_runtime::traits::{OnInitialize, OnFinalize}; use crate::weights::{DispatchInfo, DispatchClass}; pub trait Trait: system::Trait + Sized where Self::AccountId: From { diff --git a/frame/support/src/error.rs b/frame/support/src/error.rs index 87380c1a94..937be730f9 100644 --- a/frame/support/src/error.rs +++ b/frame/support/src/error.rs @@ -17,7 +17,7 @@ //! Macro for declaring a module error. #[doc(hidden)] -pub use sr_primitives::traits::LookupError; +pub use sp_runtime::traits::LookupError; pub use frame_metadata::{ModuleErrorMetadata, ErrorMetadata, DecodeDifferent}; /// Declare an error type for a runtime module. diff --git a/frame/support/src/inherent.rs b/frame/support/src/inherent.rs index 935d3b4e74..540a27f7cc 100644 --- a/frame/support/src/inherent.rs +++ b/frame/support/src/inherent.rs @@ -17,7 +17,7 @@ #[doc(hidden)] pub use crate::rstd::vec::Vec; #[doc(hidden)] -pub use crate::sr_primitives::traits::{Block as BlockT, Extrinsic}; +pub use crate::sp_runtime::traits::{Block as BlockT, Extrinsic}; #[doc(hidden)] pub use inherents::{InherentData, ProvideInherent, CheckInherentsResult, IsFatalError}; diff --git a/frame/support/src/lib.rs b/frame/support/src/lib.rs index ad599fac83..bdcde0f159 100644 --- a/frame/support/src/lib.rs +++ b/frame/support/src/lib.rs @@ -43,7 +43,7 @@ pub use state_machine::BasicExternalities; #[doc(hidden)] pub use runtime_io::storage::root as storage_root; #[doc(hidden)] -pub use sr_primitives::RuntimeDebug; +pub use sp_runtime::RuntimeDebug; #[macro_use] pub mod debug; @@ -69,7 +69,7 @@ pub mod weights; pub use self::hash::{Twox256, Twox128, Blake2_256, Blake2_128, Twox64Concat, Hashable}; pub use self::storage::{StorageValue, StorageMap, StorageLinkedMap, StorageDoubleMap}; pub use self::dispatch::{Parameter, Callable, IsSubType}; -pub use sr_primitives::{self, ConsensusEngineId, print, traits::Printable}; +pub use sp_runtime::{self, ConsensusEngineId, print, traits::Printable}; /// Macro for easily creating a new implementation of the `Get` trait. Use similarly to /// how you would declare a `const`: diff --git a/frame/support/src/traits.rs b/frame/support/src/traits.rs index d06d728454..3a9b0c2d8b 100644 --- a/frame/support/src/traits.rs +++ b/frame/support/src/traits.rs @@ -21,7 +21,7 @@ use rstd::{prelude::*, result, marker::PhantomData, ops::Div, fmt::Debug}; use codec::{FullCodec, Codec, Encode, Decode}; use primitives::u32_trait::Value as U32; -use sr_primitives::{ +use sp_runtime::{ ConsensusEngineId, traits::{MaybeSerializeDeserialize, SimpleArithmetic, Saturating}, }; diff --git a/frame/support/src/unsigned.rs b/frame/support/src/unsigned.rs index c6fafa8afa..37b66dc4b0 100644 --- a/frame/support/src/unsigned.rs +++ b/frame/support/src/unsigned.rs @@ -16,9 +16,9 @@ #[doc(hidden)] #[allow(deprecated)] -pub use crate::sr_primitives::traits::ValidateUnsigned; +pub use crate::sp_runtime::traits::ValidateUnsigned; #[doc(hidden)] -pub use crate::sr_primitives::transaction_validity::{ +pub use crate::sp_runtime::transaction_validity::{ TransactionValidity, UnknownTransaction, TransactionValidityError, }; diff --git a/frame/support/src/weights.rs b/frame/support/src/weights.rs index 8af418fc74..84198a7eca 100644 --- a/frame/support/src/weights.rs +++ b/frame/support/src/weights.rs @@ -39,15 +39,15 @@ use serde::{Serialize, Deserialize}; use impl_trait_for_tuples::impl_for_tuples; use codec::{Encode, Decode}; -use sr_arithmetic::traits::{Bounded, Zero}; -use sr_primitives::{ +use sp_arithmetic::traits::{Bounded, Zero}; +use sp_runtime::{ RuntimeDebug, traits::SignedExtension, generic::{CheckedExtrinsic, UncheckedExtrinsic}, }; /// Re-export priority as type -pub use sr_primitives::transaction_validity::TransactionPriority; +pub use sp_runtime::transaction_validity::TransactionPriority; /// Numeric range of a transaction weight. pub type Weight = u32; @@ -261,7 +261,7 @@ where /// Implementation for test extrinsic. #[cfg(feature = "std")] -impl GetDispatchInfo for sr_primitives::testing::TestXt { +impl GetDispatchInfo for sp_runtime::testing::TestXt { fn get_dispatch_info(&self) -> DispatchInfo { // for testing: weight == size. DispatchInfo { diff --git a/frame/support/test/Cargo.toml b/frame/support/test/Cargo.toml index 3d58898b0c..83b2d26157 100644 --- a/frame/support/test/Cargo.toml +++ b/frame/support/test/Cargo.toml @@ -7,12 +7,12 @@ 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 = "sr-io", path = "../../../primitives/sr-io", default-features = false } -state-machine ={ package = "substrate-state-machine", path = "../../../primitives/state-machine", optional = true } +runtime-io ={ package = "sp-io", path = "../../../primitives/sr-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 = "substrate-inherents", path = "../../../primitives/inherents", default-features = false } -sr-primitives = { package = "sr-primitives", path = "../../../primitives/sr-primitives", default-features = false } -primitives = { package = "substrate-primitives", path = "../../../primitives/core", default-features = false } +inherents = { package = "sp-inherents", path = "../../../primitives/inherents", default-features = false } +sp-runtime = { package = "sp-runtime", path = "../../../primitives/sr-primitives", default-features = false } +primitives = { package = "sp-core", path = "../../../primitives/core", default-features = false } trybuild = "1.0.17" pretty_assertions = "0.6.1" @@ -25,6 +25,6 @@ std = [ "support/std", "inherents/std", "primitives/std", - "sr-primitives/std", + "sp-runtime/std", "state-machine", ] diff --git a/frame/support/test/tests/instance.rs b/frame/support/test/tests/instance.rs index eff73ad6ea..a3ef6ba868 100644 --- a/frame/support/test/tests/instance.rs +++ b/frame/support/test/tests/instance.rs @@ -16,7 +16,7 @@ #![recursion_limit="128"] -use sr_primitives::{generic, BuildStorage, traits::{BlakeTwo256, Block as _, Verify}}; +use sp_runtime::{generic, BuildStorage, traits::{BlakeTwo256, Block as _, Verify}}; use support::{ Parameter, traits::Get, parameter_types, metadata::{ @@ -86,7 +86,7 @@ mod module1 { } } - #[derive(PartialEq, Eq, Clone, sr_primitives::RuntimeDebug)] + #[derive(PartialEq, Eq, Clone, sp_runtime::RuntimeDebug)] pub enum Origin, I> where T::BlockNumber: From { Members(u32), _Phantom(std::marker::PhantomData<(T, I)>), @@ -148,7 +148,7 @@ mod module2 { } } - #[derive(PartialEq, Eq, Clone, sr_primitives::RuntimeDebug)] + #[derive(PartialEq, Eq, Clone, sp_runtime::RuntimeDebug)] pub enum Origin, I=DefaultInstance> { Members(u32), _Phantom(std::marker::PhantomData<(T, I)>), diff --git a/frame/support/test/tests/issue2219.rs b/frame/support/test/tests/issue2219.rs index 72e0bc8caf..c5c7f77935 100644 --- a/frame/support/test/tests/issue2219.rs +++ b/frame/support/test/tests/issue2219.rs @@ -14,8 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Substrate. If not, see . -use support::sr_primitives::generic; -use support::sr_primitives::traits::{BlakeTwo256, Block as _, Verify}; +use support::sp_runtime::generic; +use support::sp_runtime::traits::{BlakeTwo256, Block as _, Verify}; use support::codec::{Encode, Decode}; use primitives::{H256, sr25519}; use serde::{Serialize, Deserialize}; diff --git a/frame/support/test/tests/system.rs b/frame/support/test/tests/system.rs index 2996724f62..fe977392dd 100644 --- a/frame/support/test/tests/system.rs +++ b/frame/support/test/tests/system.rs @@ -38,7 +38,7 @@ support::decl_error! { } /// Origin for the system module. -#[derive(PartialEq, Eq, Clone, sr_primitives::RuntimeDebug)] +#[derive(PartialEq, Eq, Clone, sp_runtime::RuntimeDebug)] pub enum RawOrigin { Root, Signed(AccountId), diff --git a/frame/system/Cargo.toml b/frame/system/Cargo.toml index 9f1019d688..7851663c33 100644 --- a/frame/system/Cargo.toml +++ b/frame/system/Cargo.toml @@ -8,11 +8,11 @@ edition = "2018" 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"] } -primitives = { package = "substrate-primitives", path = "../../primitives/core", default-features = false } -rstd = { package = "sr-std", path = "../../primitives/sr-std", default-features = false } -runtime-io ={ package = "sr-io", path = "../../primitives/sr-io", default-features = false } -sr-primitives = { path = "../../primitives/sr-primitives", default-features = false } -sr-version = { path = "../../primitives/sr-version", default-features = false } +primitives = { package = "sp-core", path = "../../primitives/core", default-features = false } +rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +runtime-io ={ package = "sp-io", path = "../../primitives/sr-io", default-features = false } +sp-runtime = { path = "../../primitives/sr-primitives", default-features = false } +sp-version = { path = "../../primitives/sr-version", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } impl-trait-for-tuples = "0.1.3" @@ -29,8 +29,8 @@ std = [ "rstd/std", "runtime-io/std", "support/std", - "sr-primitives/std", - "sr-version/std", + "sp-runtime/std", + "sp-version/std", ] [[bench]] diff --git a/frame/system/benches/bench.rs b/frame/system/benches/bench.rs index bdf3b83a38..461679ea38 100644 --- a/frame/system/benches/bench.rs +++ b/frame/system/benches/bench.rs @@ -18,7 +18,7 @@ use criterion::{Criterion, criterion_group, criterion_main, black_box}; use frame_system as system; use support::{decl_module, decl_event, impl_outer_origin, impl_outer_event, weights::Weight}; use primitives::H256; -use sr_primitives::{Perbill, traits::{BlakeTwo256, IdentityLookup}, testing::Header}; +use sp_runtime::{Perbill, traits::{BlakeTwo256, IdentityLookup}, testing::Header}; mod module { use super::*; diff --git a/frame/system/rpc/runtime-api/Cargo.toml b/frame/system/rpc/runtime-api/Cargo.toml index dd123cd69d..29b7b142eb 100644 --- a/frame/system/rpc/runtime-api/Cargo.toml +++ b/frame/system/rpc/runtime-api/Cargo.toml @@ -5,12 +5,12 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -sr-api = { path = "../../../../primitives/sr-api", default-features = false } +sp-api = { path = "../../../../primitives/sr-api", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } [features] default = ["std"] std = [ - "sr-api/std", + "sp-api/std", "codec/std", ] diff --git a/frame/system/rpc/runtime-api/src/lib.rs b/frame/system/rpc/runtime-api/src/lib.rs index 5c8c64902b..c3a9595af1 100644 --- a/frame/system/rpc/runtime-api/src/lib.rs +++ b/frame/system/rpc/runtime-api/src/lib.rs @@ -22,7 +22,7 @@ #![cfg_attr(not(feature = "std"), no_std)] -sr_api::decl_runtime_apis! { +sp_api::decl_runtime_apis! { /// The API to query account nonce (aka transaction index). pub trait AccountNonceApi where AccountId: codec::Codec, diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index 17fb3fbf0e..cce3468639 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -95,8 +95,8 @@ use rstd::prelude::*; use rstd::map; use rstd::marker::PhantomData; use rstd::fmt::Debug; -use sr_version::RuntimeVersion; -use sr_primitives::{ +use sp_version::RuntimeVersion; +use sp_runtime::{ RuntimeDebug, generic::{self, Era}, Perbill, DispatchOutcome, DispatchError, transaction_validity::{ @@ -1139,7 +1139,7 @@ impl Lookup for ChainContext { mod tests { use super::*; use primitives::H256; - use sr_primitives::{traits::{BlakeTwo256, IdentityLookup}, testing::Header, DispatchError}; + use sp_runtime::{traits::{BlakeTwo256, IdentityLookup}, testing::Header, DispatchError}; use support::{impl_outer_origin, parameter_types}; impl_outer_origin! { diff --git a/frame/system/src/offchain.rs b/frame/system/src/offchain.rs index 9f0a3ab1b2..492dfefb6b 100644 --- a/frame/system/src/offchain.rs +++ b/frame/system/src/offchain.rs @@ -17,8 +17,8 @@ //! Module helpers for offchain calls. use codec::Encode; -use sr_primitives::app_crypto::{self, RuntimeAppPublic}; -use sr_primitives::traits::{Extrinsic as ExtrinsicT, IdentifyAccount}; +use sp_runtime::app_crypto::{self, RuntimeAppPublic}; +use sp_runtime::traits::{Extrinsic as ExtrinsicT, IdentifyAccount}; /// A trait responsible for signing a payload using given account. pub trait Signer { diff --git a/frame/timestamp/Cargo.toml b/frame/timestamp/Cargo.toml index 247d219ea8..72e57951bd 100644 --- a/frame/timestamp/Cargo.toml +++ b/frame/timestamp/Cargo.toml @@ -7,17 +7,17 @@ edition = "2018" [dependencies] serde = { version = "1.0.101", optional = true } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -rstd = { package = "sr-std", path = "../../primitives/sr-std", default-features = false } -sr-primitives = { path = "../../primitives/sr-primitives", default-features = false } -inherents = { package = "substrate-inherents", path = "../../primitives/inherents", default-features = false } +rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +sp-runtime = { path = "../../primitives/sr-primitives", default-features = false } +inherents = { package = "sp-inherents", path = "../../primitives/inherents", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } system = { package = "frame-system", path = "../system", default-features = false } sp-timestamp = { path = "../../primitives/timestamp", default-features = false } impl-trait-for-tuples = "0.1.3" [dev-dependencies] -runtime-io ={ package = "sr-io", path = "../../primitives/sr-io" } -primitives = { package = "substrate-primitives", path = "../../primitives/core" } +runtime-io ={ package = "sp-io", path = "../../primitives/sr-io" } +primitives = { package = "sp-core", path = "../../primitives/core" } [features] default = ["std"] @@ -25,7 +25,7 @@ std = [ "inherents/std", "codec/std", "rstd/std", - "sr-primitives/std", + "sp-runtime/std", "support/std", "serde", "system/std", diff --git a/frame/timestamp/src/lib.rs b/frame/timestamp/src/lib.rs index 73f9cd71b6..9368c09b67 100644 --- a/frame/timestamp/src/lib.rs +++ b/frame/timestamp/src/lib.rs @@ -94,7 +94,7 @@ use rstd::{result, cmp}; use inherents::{ProvideInherent, InherentData, InherentIdentifier}; use support::{Parameter, decl_storage, decl_module}; use support::traits::{Time, Get}; -use sr_primitives::{ +use sp_runtime::{ RuntimeString, traits::{ SimpleArithmetic, Zero, SaturatedConversion, Scale @@ -243,7 +243,7 @@ mod tests { use support::{impl_outer_origin, assert_ok, parameter_types, weights::Weight}; use runtime_io::TestExternalities; use primitives::H256; - use sr_primitives::{Perbill, traits::{BlakeTwo256, IdentityLookup}, testing::Header}; + use sp_runtime::{Perbill, traits::{BlakeTwo256, IdentityLookup}, testing::Header}; impl_outer_origin! { pub enum Origin for Test {} diff --git a/frame/transaction-payment/Cargo.toml b/frame/transaction-payment/Cargo.toml index 70f0f2643c..fb84498d77 100644 --- a/frame/transaction-payment/Cargo.toml +++ b/frame/transaction-payment/Cargo.toml @@ -6,15 +6,15 @@ edition = "2018" [dependencies] codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -rstd = { package = "sr-std", path = "../../primitives/sr-std", default-features = false } -sr-primitives = { path = "../../primitives/sr-primitives", default-features = false } +rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +sp-runtime = { path = "../../primitives/sr-primitives", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } system = { package = "frame-system", path = "../system", default-features = false } transaction-payment-rpc-runtime-api = { package = "pallet-transaction-payment-rpc-runtime-api", path = "./rpc/runtime-api", default-features = false } [dev-dependencies] -runtime-io = { package = "sr-io", path = "../../primitives/sr-io" } -primitives = { package = "substrate-primitives", path = "../../primitives/core" } +runtime-io = { package = "sp-io", path = "../../primitives/sr-io" } +primitives = { package = "sp-core", path = "../../primitives/core" } balances = { package = "pallet-balances", path = "../balances" } [features] @@ -22,7 +22,7 @@ default = ["std"] std = [ "codec/std", "rstd/std", - "sr-primitives/std", + "sp-runtime/std", "support/std", "system/std", "transaction-payment-rpc-runtime-api/std" diff --git a/frame/transaction-payment/rpc/Cargo.toml b/frame/transaction-payment/rpc/Cargo.toml index 5ae6eafc19..c8596648f8 100644 --- a/frame/transaction-payment/rpc/Cargo.toml +++ b/frame/transaction-payment/rpc/Cargo.toml @@ -9,9 +9,9 @@ codec = { package = "parity-scale-codec", version = "1.0.0" } jsonrpc-core = "14.0.3" jsonrpc-core-client = "14.0.3" jsonrpc-derive = "14.0.3" -primitives = { package = "substrate-primitives", path = "../../../primitives/core" } -rpc-primitives = { package = "substrate-rpc-primitives", path = "../../../primitives/rpc" } +primitives = { package = "sp-core", path = "../../../primitives/core" } +rpc-primitives = { package = "sp-rpc", path = "../../../primitives/rpc" } serde = { version = "1.0.101", features = ["derive"] } -sr-primitives = { path = "../../../primitives/sr-primitives" } +sp-runtime = { path = "../../../primitives/sr-primitives" } sp-blockchain = { path = "../../../primitives/blockchain" } pallet-transaction-payment-rpc-runtime-api = { path = "./runtime-api" } diff --git a/frame/transaction-payment/rpc/runtime-api/Cargo.toml b/frame/transaction-payment/rpc/runtime-api/Cargo.toml index 008b5bb78c..e437b22fc0 100644 --- a/frame/transaction-payment/rpc/runtime-api/Cargo.toml +++ b/frame/transaction-payment/rpc/runtime-api/Cargo.toml @@ -6,10 +6,10 @@ edition = "2018" [dependencies] serde = { version = "1.0.101", optional = true, features = ["derive"] } -sr-api = { path = "../../../../primitives/sr-api", default-features = false } +sp-api = { path = "../../../../primitives/sr-api", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.6", default-features = false, features = ["derive"] } -rstd = { package = "sr-std", path = "../../../../primitives/sr-std", default-features = false } -sr-primitives = { path = "../../../../primitives/sr-primitives", default-features = false } +rstd = { package = "sp-std", path = "../../../../primitives/sr-std", default-features = false } +sp-runtime = { path = "../../../../primitives/sr-primitives", default-features = false } support = { package = "frame-support", path = "../../../support", default-features = false } [dev-dependencies] @@ -19,8 +19,8 @@ serde_json = "1.0.41" default = ["std"] std = [ "serde", - "sr-api/std", + "sp-api/std", "codec/std", "rstd/std", - "sr-primitives/std", + "sp-runtime/std", ] diff --git a/frame/transaction-payment/rpc/runtime-api/src/lib.rs b/frame/transaction-payment/rpc/runtime-api/src/lib.rs index 755e98a212..e922ff9e28 100644 --- a/frame/transaction-payment/rpc/runtime-api/src/lib.rs +++ b/frame/transaction-payment/rpc/runtime-api/src/lib.rs @@ -38,7 +38,7 @@ pub struct RuntimeDispatchInfo { pub partial_fee: Balance, } -sr_api::decl_runtime_apis! { +sp_api::decl_runtime_apis! { pub trait TransactionPaymentApi where Balance: Codec, Extrinsic: Codec, diff --git a/frame/transaction-payment/rpc/src/lib.rs b/frame/transaction-payment/rpc/src/lib.rs index 527bfc424a..35ad4a06ed 100644 --- a/frame/transaction-payment/rpc/src/lib.rs +++ b/frame/transaction-payment/rpc/src/lib.rs @@ -21,7 +21,7 @@ use codec::{Codec, Decode}; use sp_blockchain::HeaderBackend; use jsonrpc_core::{Error as RpcError, ErrorCode, Result}; use jsonrpc_derive::rpc; -use sr_primitives::{ +use sp_runtime::{ generic::BlockId, traits::{Block as BlockT, ProvideRuntimeApi}, }; diff --git a/frame/transaction-payment/src/lib.rs b/frame/transaction-payment/src/lib.rs index abb7518e35..eacf890d80 100644 --- a/frame/transaction-payment/src/lib.rs +++ b/frame/transaction-payment/src/lib.rs @@ -38,7 +38,7 @@ use support::{ traits::{Currency, Get, OnUnbalanced, ExistenceRequirement, WithdrawReason}, weights::{Weight, DispatchInfo, GetDispatchInfo}, }; -use sr_primitives::{ +use sp_runtime::{ Fixed64, transaction_validity::{ TransactionPriority, ValidTransaction, InvalidTransaction, TransactionValidityError, @@ -242,7 +242,7 @@ mod tests { weights::{DispatchClass, DispatchInfo, GetDispatchInfo, Weight}, }; use primitives::H256; - use sr_primitives::{ + use sp_runtime::{ Perbill, testing::{Header, TestXt}, traits::{BlakeTwo256, IdentityLookup, Extrinsic}, diff --git a/frame/treasury/Cargo.toml b/frame/treasury/Cargo.toml index a39802840f..2ecd11368f 100644 --- a/frame/treasury/Cargo.toml +++ b/frame/treasury/Cargo.toml @@ -7,15 +7,15 @@ edition = "2018" [dependencies] serde = { version = "1.0.101", optional = true, features = ["derive"] } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -rstd = { package = "sr-std", path = "../../primitives/sr-std", default-features = false } -sr-primitives = { path = "../../primitives/sr-primitives", default-features = false } +rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +sp-runtime = { path = "../../primitives/sr-primitives", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } system = { package = "frame-system", path = "../system", default-features = false } balances = { package = "pallet-balances", path = "../balances", default-features = false } [dev-dependencies] -runtime-io ={ package = "sr-io", path = "../../primitives/sr-io" } -primitives = { package = "substrate-primitives", path = "../../primitives/core" } +runtime-io ={ package = "sp-io", path = "../../primitives/sr-io" } +primitives = { package = "sp-core", path = "../../primitives/core" } [features] default = ["std"] @@ -23,7 +23,7 @@ std = [ "serde", "codec/std", "rstd/std", - "sr-primitives/std", + "sp-runtime/std", "support/std", "system/std", "balances/std", diff --git a/frame/treasury/src/lib.rs b/frame/treasury/src/lib.rs index 30ebc6f5a3..d5ca4b232e 100644 --- a/frame/treasury/src/lib.rs +++ b/frame/treasury/src/lib.rs @@ -65,8 +65,8 @@ use support::traits::{ Currency, ExistenceRequirement, Get, Imbalance, OnUnbalanced, ReservableCurrency, WithdrawReason }; -use sr_primitives::{Permill, ModuleId}; -use sr_primitives::traits::{ +use sp_runtime::{Permill, ModuleId}; +use sp_runtime::traits::{ Zero, EnsureOrigin, StaticLookup, AccountIdConversion, Saturating }; use support::weights::SimpleDispatchInfo; @@ -201,7 +201,7 @@ decl_module! { /// A spending proposal. #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] -#[derive(Encode, Decode, Clone, PartialEq, Eq, sr_primitives::RuntimeDebug)] +#[derive(Encode, Decode, Clone, PartialEq, Eq, sp_runtime::RuntimeDebug)] pub struct Proposal { proposer: AccountId, value: Balance, @@ -353,7 +353,7 @@ mod tests { use support::{assert_noop, assert_ok, impl_outer_origin, parameter_types, weights::Weight}; use primitives::H256; - use sr_primitives::{ + use sp_runtime::{ traits::{BlakeTwo256, OnFinalize, IdentityLookup}, testing::Header, Perbill }; diff --git a/frame/utility/Cargo.toml b/frame/utility/Cargo.toml index c6f5db29f9..f5c1170569 100644 --- a/frame/utility/Cargo.toml +++ b/frame/utility/Cargo.toml @@ -9,12 +9,12 @@ serde = { version = "1.0.101", optional = true } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } system = { package = "frame-system", path = "../system", default-features = false } -sr-primitives = { path = "../../primitives/sr-primitives", default-features = false } -rstd = { package = "sr-std", path = "../../primitives/sr-std", default-features = false } -runtime-io = { package = "sr-io", path = "../../primitives/sr-io", default-features = false } +sp-runtime = { path = "../../primitives/sr-primitives", default-features = false } +rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } [dev-dependencies] -primitives = { package = "substrate-primitives", path = "../../primitives/core" } +primitives = { package = "sp-core", path = "../../primitives/core" } balances = { package = "pallet-balances", path = "../balances" } [features] @@ -22,7 +22,7 @@ default = ["std"] std = [ "serde", "codec/std", - "sr-primitives/std", + "sp-runtime/std", "support/std", "system/std", "runtime-io/std", diff --git a/frame/utility/src/lib.rs b/frame/utility/src/lib.rs index 2fc5194f7d..20222766f4 100644 --- a/frame/utility/src/lib.rs +++ b/frame/utility/src/lib.rs @@ -23,7 +23,7 @@ use rstd::prelude::*; use support::{decl_module, decl_event, Parameter, weights::SimpleDispatchInfo}; use system::ensure_root; -use sr_primitives::{traits::Dispatchable, DispatchError}; +use sp_runtime::{traits::Dispatchable, DispatchError}; /// Configuration trait. pub trait Trait: system::Trait { @@ -68,7 +68,7 @@ mod tests { weights::Weight }; use primitives::H256; - use sr_primitives::{Perbill, traits::{BlakeTwo256, IdentityLookup}, testing::Header}; + use sp_runtime::{Perbill, traits::{BlakeTwo256, IdentityLookup}, testing::Header}; impl_outer_origin! { pub enum Origin for Test {} diff --git a/primitives/application-crypto/Cargo.toml b/primitives/application-crypto/Cargo.toml index 598f74ac15..6f012a3d89 100644 --- a/primitives/application-crypto/Cargo.toml +++ b/primitives/application-crypto/Cargo.toml @@ -1,20 +1,20 @@ [package] -name = "substrate-application-crypto" +name = "sc-application-crypto" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" description = "Provides facilities for generating application specific crypto wrapper types." [dependencies] -primitives = { package = "substrate-primitives", path = "../core", default-features = false } +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"] } -rstd = { package = "sr-std", path = "../sr-std", default-features = false } -runtime-io = { package = "sr-io", path = "../../primitives/sr-io", default-features = false } +rstd = { package = "sp-std", path = "../sr-std", default-features = false } +runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } [dev-dependencies] test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client" } -sr-primitives = { path = "../../primitives/sr-primitives" } +sp-runtime = { path = "../../primitives/sr-primitives" } [features] default = [ "std" ] diff --git a/primitives/application-crypto/src/ed25519.rs b/primitives/application-crypto/src/ed25519.rs index 468907a5c4..7ada97672a 100644 --- a/primitives/application-crypto/src/ed25519.rs +++ b/primitives/application-crypto/src/ed25519.rs @@ -57,7 +57,7 @@ impl RuntimePublic for Public { #[cfg(test)] mod tests { - use sr_primitives::{generic::BlockId, traits::ProvideRuntimeApi}; + use sp_runtime::{generic::BlockId, traits::ProvideRuntimeApi}; use primitives::{testing::{KeyStore, ED25519}, crypto::Pair}; use test_client::{ TestClientBuilder, DefaultTestClientBuilderExt, TestClientBuilderExt, diff --git a/primitives/application-crypto/src/lib.rs b/primitives/application-crypto/src/lib.rs index dd8b02fc1d..3a748e50c9 100644 --- a/primitives/application-crypto/src/lib.rs +++ b/primitives/application-crypto/src/lib.rs @@ -45,7 +45,7 @@ pub use traits::*; /// Application-specific types whose identifier is `$key_type`. /// /// ```rust -///# use substrate_application_crypto::{app_crypto, wrap, ed25519, KeyTypeId}; +///# use sc_application_crypto::{app_crypto, wrap, ed25519, KeyTypeId}; /// // Declare a new set of crypto types using Ed25519 logic that identifies as `KeyTypeId` /// // of value `b"fuba"`. /// app_crypto!(ed25519, KeyTypeId(*b"_uba")); @@ -66,7 +66,7 @@ macro_rules! app_crypto { /// Application-specific types whose identifier is `$key_type`. /// /// ```rust -///# use substrate_application_crypto::{app_crypto, wrap, ed25519, KeyTypeId}; +///# use sc_application_crypto::{app_crypto, wrap, ed25519, KeyTypeId}; /// // Declare a new set of crypto types using Ed25519 logic that identifies as `KeyTypeId` /// // of value `b"fuba"`. /// app_crypto!(ed25519, KeyTypeId(*b"_uba")); @@ -390,7 +390,7 @@ macro_rules! app_crypto_signature_common { /// Implement bidirectional `From` and on-way `AsRef`/`AsMut` for two types, `$inner` and `$outer`. /// /// ```rust -/// substrate_application_crypto::wrap! { +/// sc_application_crypto::wrap! { /// pub struct Wrapper(u32); /// } /// ``` diff --git a/primitives/application-crypto/src/sr25519.rs b/primitives/application-crypto/src/sr25519.rs index 2ad279a6bf..ebe2a5d353 100644 --- a/primitives/application-crypto/src/sr25519.rs +++ b/primitives/application-crypto/src/sr25519.rs @@ -57,7 +57,7 @@ impl RuntimePublic for Public { #[cfg(test)] mod tests { - use sr_primitives::{generic::BlockId, traits::ProvideRuntimeApi}; + use sp_runtime::{generic::BlockId, traits::ProvideRuntimeApi}; use primitives::{testing::{KeyStore, SR25519}, crypto::Pair}; use test_client::{ TestClientBuilder, DefaultTestClientBuilderExt, TestClientBuilderExt, diff --git a/primitives/authority-discovery/Cargo.toml b/primitives/authority-discovery/Cargo.toml index 1e975b5680..9a2daaff1c 100644 --- a/primitives/authority-discovery/Cargo.toml +++ b/primitives/authority-discovery/Cargo.toml @@ -1,16 +1,16 @@ [package] -name = "substrate-authority-discovery-primitives" +name = "sp-authority-discovery" version = "2.0.0" authors = ["Parity Technologies "] description = "Authority discovery primitives" edition = "2018" [dependencies] -app-crypto = { package = "substrate-application-crypto", path = "../application-crypto", default-features = false } +app-crypto = { package = "sc-application-crypto", path = "../application-crypto", default-features = false } codec = { package = "parity-scale-codec", default-features = false, version = "1.0.3" } -rstd = { package = "sr-std", path = "../sr-std", default-features = false } -sr-api = { path = "../sr-api", default-features = false } -sr-primitives = { path = "../sr-primitives", default-features = false } +rstd = { package = "sp-std", path = "../sr-std", default-features = false } +sp-api = { path = "../sr-api", default-features = false } +sp-runtime = { path = "../sr-primitives", default-features = false } [features] default = ["std"] @@ -18,6 +18,6 @@ std = [ "app-crypto/std", "codec/std", "rstd/std", - "sr-api/std", - "sr-primitives/std" + "sp-api/std", + "sp-runtime/std" ] diff --git a/primitives/authority-discovery/src/lib.rs b/primitives/authority-discovery/src/lib.rs index 0116ca02aa..8ce9757a59 100644 --- a/primitives/authority-discovery/src/lib.rs +++ b/primitives/authority-discovery/src/lib.rs @@ -35,7 +35,7 @@ pub type AuthorityId = app::Public; /// An authority discovery authority signature. pub type AuthoritySignature = app::Signature; -sr_api::decl_runtime_apis! { +sp_api::decl_runtime_apis! { /// The authority discovery api. /// /// This api is used by the `core/authority-discovery` module to retrieve identifiers diff --git a/primitives/authorship/Cargo.toml b/primitives/authorship/Cargo.toml index 1c95fed52f..3b9604c688 100644 --- a/primitives/authorship/Cargo.toml +++ b/primitives/authorship/Cargo.toml @@ -6,8 +6,8 @@ description = "Authorship primitives" edition = "2018" [dependencies] -sp-inherents = { package = "substrate-inherents", path = "../inherents", default-features = false } -rstd = { package = "sr-std", path = "../sr-std", default-features = false } +sp-inherents = { package = "sp-inherents", path = "../inherents", default-features = false } +rstd = { package = "sp-std", path = "../sr-std", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } [features] diff --git a/primitives/block-builder/runtime-api/Cargo.toml b/primitives/block-builder/runtime-api/Cargo.toml index 7f3b17fb21..323a4ad4c8 100644 --- a/primitives/block-builder/runtime-api/Cargo.toml +++ b/primitives/block-builder/runtime-api/Cargo.toml @@ -1,22 +1,22 @@ [package] -name = "substrate-block-builder-runtime-api" +name = "sp-block-builder" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" [dependencies] -sr-primitives = { path = "../../sr-primitives", default-features = false } -sr-api = { path = "../../sr-api", default-features = false } -rstd = { package = "sr-std", path = "../../sr-std", default-features = false } +sp-runtime = { path = "../../sr-primitives", default-features = false } +sp-api = { path = "../../sr-api", default-features = false } +rstd = { package = "sp-std", path = "../../sr-std", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.6", default-features = false } -inherents = { package = "substrate-inherents", path = "../../inherents", default-features = false } +inherents = { package = "sp-inherents", path = "../../inherents", default-features = false } [features] default = [ "std" ] std = [ - "sr-primitives/std", + "sp-runtime/std", "codec/std", "inherents/std", - "sr-api/std", + "sp-api/std", "rstd/std", ] diff --git a/primitives/block-builder/runtime-api/src/lib.rs b/primitives/block-builder/runtime-api/src/lib.rs index f8a5f93b99..441df3dd4a 100644 --- a/primitives/block-builder/runtime-api/src/lib.rs +++ b/primitives/block-builder/runtime-api/src/lib.rs @@ -18,7 +18,7 @@ #![cfg_attr(not(feature = "std"), no_std)] -use sr_primitives::{traits::Block as BlockT, ApplyExtrinsicResult}; +use sp_runtime::{traits::Block as BlockT, ApplyExtrinsicResult}; use inherents::{InherentData, CheckInherentsResult}; @@ -27,7 +27,7 @@ use inherents::{InherentData, CheckInherentsResult}; /// These definitions are taken from the 2c58e30246a029b53d51e5b24c31974ac539ee8b git revision. #[deprecated(note = "These definitions here are only for compatibility reasons")] pub mod compatability_v3 { - use sr_primitives::{DispatchOutcome, transaction_validity}; + use sp_runtime::{DispatchOutcome, transaction_validity}; use codec::{Encode, Decode}; #[derive(Eq, PartialEq, Clone, Copy, Decode, Encode, Debug)] @@ -41,7 +41,7 @@ pub mod compatability_v3 { pub type ApplyResult = Result; } -sr_api::decl_runtime_apis! { +sp_api::decl_runtime_apis! { /// The `BlockBuilder` api trait that provides the required functionality for building a block. #[api_version(4)] pub trait BlockBuilder { diff --git a/primitives/blockchain/Cargo.toml b/primitives/blockchain/Cargo.toml index 812c1dd668..6292906925 100644 --- a/primitives/blockchain/Cargo.toml +++ b/primitives/blockchain/Cargo.toml @@ -10,8 +10,8 @@ lru = "0.4.0" parking_lot = "0.9.0" derive_more = "0.99.2" parity-scale-codec = { version = "1.0.0", default-features = false, features = ["derive"] } -sp_consensus = { package = "substrate-consensus-common", path = "../consensus/common" } -sr-primitives = { path = "../sr-primitives" } -sp-block-builder-runtime-api = { package = "substrate-block-builder-runtime-api", path = "../block-builder/runtime-api" } -sp-state-machine = { package = "substrate-state-machine", path = "../state-machine" } +sp_consensus = { package = "sp-consensus", path = "../consensus/common" } +sp-runtime = { path = "../sr-primitives" } +sp-block-builder-runtime-api = { package = "sp-block-builder", path = "../block-builder/runtime-api" } +sp-state-machine = { package = "sp-state-machine", path = "../state-machine" } diff --git a/primitives/blockchain/src/backend.rs b/primitives/blockchain/src/backend.rs index c28a75f620..0baede8ab2 100644 --- a/primitives/blockchain/src/backend.rs +++ b/primitives/blockchain/src/backend.rs @@ -18,9 +18,9 @@ use std::sync::Arc; -use sr_primitives::traits::{Block as BlockT, Header as HeaderT, NumberFor}; -use sr_primitives::generic::BlockId; -use sr_primitives::Justification; +use sp_runtime::traits::{Block as BlockT, Header as HeaderT, NumberFor}; +use sp_runtime::generic::BlockId; +use sp_runtime::Justification; use log::warn; use parking_lot::RwLock; diff --git a/primitives/blockchain/src/error.rs b/primitives/blockchain/src/error.rs index 6302edb3d2..68a916b7d8 100644 --- a/primitives/blockchain/src/error.rs +++ b/primitives/blockchain/src/error.rs @@ -18,7 +18,7 @@ use std::{self, error, result}; use sp_state_machine; -use sr_primitives::transaction_validity::TransactionValidityError; +use sp_runtime::transaction_validity::TransactionValidityError; #[allow(deprecated)] use sp_block_builder_runtime_api::compatability_v3; use sp_consensus; diff --git a/primitives/blockchain/src/header_metadata.rs b/primitives/blockchain/src/header_metadata.rs index 5ec58ad754..450bf70e8e 100644 --- a/primitives/blockchain/src/header_metadata.rs +++ b/primitives/blockchain/src/header_metadata.rs @@ -17,7 +17,7 @@ //! Implements tree backend, cached header metadata and algorithms //! to compute routes efficiently over the tree of headers. -use sr_primitives::traits::{Block as BlockT, NumberFor, Header}; +use sp_runtime::traits::{Block as BlockT, NumberFor, Header}; use parking_lot::RwLock; use lru::LruCache; diff --git a/primitives/consensus/aura/Cargo.toml b/primitives/consensus/aura/Cargo.toml index bb772cb7a7..e36f7e44d1 100644 --- a/primitives/consensus/aura/Cargo.toml +++ b/primitives/consensus/aura/Cargo.toml @@ -1,17 +1,17 @@ [package] -name = "substrate-consensus-aura-primitives" +name = "sp-consensus-aura" version = "2.0.0" authors = ["Parity Technologies "] description = "Primitives for Aura consensus" edition = "2018" [dependencies] -app-crypto = { package = "substrate-application-crypto", path = "../../application-crypto", default-features = false } +app-crypto = { package = "sc-application-crypto", path = "../../application-crypto", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } -rstd = { package = "sr-std", path = "../../sr-std", default-features = false } -sr-api = { path = "../../sr-api", default-features = false } -sr-primitives = { path = "../../sr-primitives", default-features = false } -inherents = { package = "substrate-inherents", path = "../../inherents", default-features = false } +rstd = { package = "sp-std", path = "../../sr-std", default-features = false } +sp-api = { path = "../../sr-api", default-features = false } +sp-runtime = { path = "../../sr-primitives", default-features = false } +inherents = { package = "sp-inherents", path = "../../inherents", default-features = false } sp-timestamp = { path = "../../timestamp", default-features = false } [features] @@ -20,8 +20,8 @@ std = [ "app-crypto/std", "codec/std", "rstd/std", - "sr-api/std", - "sr-primitives/std", + "sp-api/std", + "sp-runtime/std", "inherents/std", "sp-timestamp/std", ] diff --git a/primitives/consensus/aura/src/lib.rs b/primitives/consensus/aura/src/lib.rs index 8a89452ac3..c866c041da 100644 --- a/primitives/consensus/aura/src/lib.rs +++ b/primitives/consensus/aura/src/lib.rs @@ -20,7 +20,7 @@ use codec::{Encode, Decode, Codec}; use rstd::vec::Vec; -use sr_primitives::ConsensusEngineId; +use sp_runtime::ConsensusEngineId; pub mod inherents; @@ -75,7 +75,7 @@ pub enum ConsensusLog { OnDisabled(AuthorityIndex), } -sr_api::decl_runtime_apis! { +sp_api::decl_runtime_apis! { /// API necessary for block authorship with aura. pub trait AuraApi { /// Return the slot duration in seconds for Aura. diff --git a/primitives/consensus/babe/Cargo.toml b/primitives/consensus/babe/Cargo.toml index bbdcbf9b66..236f6cdebe 100644 --- a/primitives/consensus/babe/Cargo.toml +++ b/primitives/consensus/babe/Cargo.toml @@ -1,19 +1,19 @@ [package] -name = "substrate-consensus-babe-primitives" +name = "sp-consensus-babe" version = "2.0.0" authors = ["Parity Technologies "] description = "Primitives for BABE consensus" edition = "2018" [dependencies] -app-crypto = { package = "substrate-application-crypto", path = "../../application-crypto", default-features = false } +app-crypto = { package = "sc-application-crypto", path = "../../application-crypto", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } -rstd = { package = "sr-std", path = "../../sr-std", default-features = false } +rstd = { package = "sp-std", path = "../../sr-std", default-features = false } schnorrkel = { version = "0.8.5", features = ["preaudit_deprecated"], optional = true } -slots = { package = "substrate-consensus-slots", path = "../../../client/consensus/slots", optional = true } -sr-api = { path = "../../sr-api", default-features = false } -sr-primitives = { path = "../../sr-primitives", default-features = false } -sp-inherents = { package = "substrate-inherents", path = "../../inherents", default-features = false } +slots = { package = "sc-consensus-slots", path = "../../../client/consensus/slots", optional = true } +sp-api = { path = "../../sr-api", default-features = false } +sp-runtime = { path = "../../sr-primitives", default-features = false } +sp-inherents = { package = "sp-inherents", path = "../../inherents", default-features = false } sp-timestamp = { path = "../../timestamp", default-features = false } [features] @@ -24,8 +24,8 @@ std = [ "rstd/std", "schnorrkel", "slots", - "sr-api/std", - "sr-primitives/std", + "sp-api/std", + "sp-runtime/std", "sp-inherents/std", "sp-timestamp/std", ] diff --git a/primitives/consensus/babe/src/digest.rs b/primitives/consensus/babe/src/digest.rs index 95dd247810..496c348e1d 100644 --- a/primitives/consensus/babe/src/digest.rs +++ b/primitives/consensus/babe/src/digest.rs @@ -22,7 +22,7 @@ use super::{BABE_ENGINE_ID, AuthoritySignature}; use super::{VRF_OUTPUT_LENGTH, VRF_PROOF_LENGTH}; use super::{AuthorityId, AuthorityIndex, SlotNumber, BabeAuthorityWeight}; #[cfg(feature = "std")] -use sr_primitives::{DigestItem, generic::OpaqueDigestItemId}; +use sp_runtime::{DigestItem, generic::OpaqueDigestItemId}; #[cfg(feature = "std")] use std::fmt::Debug; use codec::{Decode, Encode}; @@ -195,7 +195,7 @@ impl Decode for BabePreDigest { /// Information about the next epoch. This is broadcast in the first block /// of the epoch. -#[derive(Decode, Encode, Default, PartialEq, Eq, Clone, sr_primitives::RuntimeDebug)] +#[derive(Decode, Encode, Default, PartialEq, Eq, Clone, sp_runtime::RuntimeDebug)] pub struct NextEpochDescriptor { /// The authorities. pub authorities: Vec<(AuthorityId, BabeAuthorityWeight)>, diff --git a/primitives/consensus/babe/src/lib.rs b/primitives/consensus/babe/src/lib.rs index 532aaa6dc1..cf4bfd1e98 100644 --- a/primitives/consensus/babe/src/lib.rs +++ b/primitives/consensus/babe/src/lib.rs @@ -24,7 +24,7 @@ pub mod inherents; use codec::{Encode, Decode}; use rstd::vec::Vec; -use sr_primitives::{ConsensusEngineId, RuntimeDebug}; +use sp_runtime::{ConsensusEngineId, RuntimeDebug}; #[cfg(feature = "std")] pub use digest::{BabePreDigest, CompatibleDigestItem}; @@ -165,7 +165,7 @@ impl slots::SlotData for BabeConfiguration { const SLOT_KEY: &'static [u8] = b"babe_configuration"; } -sr_api::decl_runtime_apis! { +sp_api::decl_runtime_apis! { /// API necessary for block authorship with BABE. pub trait BabeApi { /// Return the configuration for BABE. Currently, diff --git a/primitives/consensus/common/Cargo.toml b/primitives/consensus/common/Cargo.toml index 02dc7b579f..b8f5efa4b8 100644 --- a/primitives/consensus/common/Cargo.toml +++ b/primitives/consensus/common/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "substrate-consensus-common" +name = "sp-consensus" version = "2.0.0" authors = ["Parity Technologies "] description = "Common utilities for substrate consensus" @@ -9,13 +9,13 @@ edition = "2018" derive_more = "0.99.2" libp2p = { version = "0.13.0", default-features = false } log = "0.4.8" -primitives = { package = "substrate-primitives", path= "../../core" } -inherents = { package = "substrate-inherents", path = "../../inherents" } +primitives = { package = "sp-core", path= "../../core" } +inherents = { package = "sp-inherents", path = "../../inherents" } futures = { version = "0.3.1", features = ["thread-pool"] } futures-timer = "0.4.0" -rstd = { package = "sr-std", path = "../../sr-std" } -runtime_version = { package = "sr-version", path = "../../sr-version" } -sr-primitives = { path = "../../sr-primitives" } +rstd = { package = "sp-std", path = "../../sr-std" } +runtime_version = { package = "sp-version", path = "../../sr-version" } +sp-runtime = { path = "../../sr-primitives" } codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } parking_lot = "0.9.0" diff --git a/primitives/consensus/common/src/block_import.rs b/primitives/consensus/common/src/block_import.rs index 344a79167b..aab70625ff 100644 --- a/primitives/consensus/common/src/block_import.rs +++ b/primitives/consensus/common/src/block_import.rs @@ -16,8 +16,8 @@ //! Block import helpers. -use sr_primitives::traits::{Block as BlockT, DigestItemFor, Header as HeaderT, NumberFor}; -use sr_primitives::Justification; +use sp_runtime::traits::{Block as BlockT, DigestItemFor, Header as HeaderT, NumberFor}; +use sp_runtime::Justification; use std::borrow::Cow; use std::collections::HashMap; use std::sync::Arc; diff --git a/primitives/consensus/common/src/block_validation.rs b/primitives/consensus/common/src/block_validation.rs index be181b05c6..42231bbf4c 100644 --- a/primitives/consensus/common/src/block_validation.rs +++ b/primitives/consensus/common/src/block_validation.rs @@ -17,7 +17,7 @@ //! Block announcement validation. use crate::BlockStatus; -use sr_primitives::{generic::BlockId, traits::Block}; +use sp_runtime::{generic::BlockId, traits::Block}; use std::{error::Error, sync::Arc}; /// A type which provides access to chain information. diff --git a/primitives/consensus/common/src/evaluation.rs b/primitives/consensus/common/src/evaluation.rs index 7a3e565aa0..875ce41e01 100644 --- a/primitives/consensus/common/src/evaluation.rs +++ b/primitives/consensus/common/src/evaluation.rs @@ -19,7 +19,7 @@ use super::MAX_BLOCK_SIZE; use codec::Encode; -use sr_primitives::traits::{Block as BlockT, Header as HeaderT, One, CheckedConversion}; +use sp_runtime::traits::{Block as BlockT, Header as HeaderT, One, CheckedConversion}; // This is just a best effort to encode the number. None indicated that it's too big to encode // in a u128. diff --git a/primitives/consensus/common/src/import_queue.rs b/primitives/consensus/common/src/import_queue.rs index 614609cc53..1d8ea0f0ce 100644 --- a/primitives/consensus/common/src/import_queue.rs +++ b/primitives/consensus/common/src/import_queue.rs @@ -26,7 +26,7 @@ //! queues to be instantiated simply. use std::collections::HashMap; -use sr_primitives::{Justification, traits::{Block as BlockT, Header as _, NumberFor}}; +use sp_runtime::{Justification, traits::{Block as BlockT, Header as _, NumberFor}}; use crate::error::Error as ConsensusError; use crate::block_import::{ BlockImport, BlockOrigin, BlockImportParams, ImportedAux, JustificationImport, ImportResult, diff --git a/primitives/consensus/common/src/import_queue/basic_queue.rs b/primitives/consensus/common/src/import_queue/basic_queue.rs index 2ab6d0c5e3..42a31ceb64 100644 --- a/primitives/consensus/common/src/import_queue/basic_queue.rs +++ b/primitives/consensus/common/src/import_queue/basic_queue.rs @@ -17,7 +17,7 @@ use std::{mem, pin::Pin, time::Duration}; use futures::{prelude::*, channel::mpsc, task::Context, task::Poll}; use futures_timer::Delay; -use sr_primitives::{Justification, traits::{Block as BlockT, Header as HeaderT, NumberFor}}; +use sp_runtime::{Justification, traits::{Block as BlockT, Header as HeaderT, NumberFor}}; use crate::block_import::BlockOrigin; use crate::import_queue::{ diff --git a/primitives/consensus/common/src/import_queue/buffered_link.rs b/primitives/consensus/common/src/import_queue/buffered_link.rs index b88f1bfd1e..70304bbe27 100644 --- a/primitives/consensus/common/src/import_queue/buffered_link.rs +++ b/primitives/consensus/common/src/import_queue/buffered_link.rs @@ -21,8 +21,8 @@ //! # Example //! //! ``` -//! use substrate_consensus_common::import_queue::Link; -//! # use substrate_consensus_common::import_queue::buffered_link::buffered_link; +//! use sp_consensus::import_queue::Link; +//! # use sp_consensus::import_queue::buffered_link::buffered_link; //! # use test_client::runtime::Block; //! # struct DummyLink; impl Link for DummyLink {} //! # let mut my_link = DummyLink; @@ -38,7 +38,7 @@ //! use futures::{prelude::*, channel::mpsc}; -use sr_primitives::traits::{Block as BlockT, NumberFor}; +use sp_runtime::traits::{Block as BlockT, NumberFor}; use std::{pin::Pin, task::Context, task::Poll}; use crate::import_queue::{Origin, Link, BlockImportResult, BlockImportError}; diff --git a/primitives/consensus/common/src/lib.rs b/primitives/consensus/common/src/lib.rs index 3dc1cc7a39..b662bf428a 100644 --- a/primitives/consensus/common/src/lib.rs +++ b/primitives/consensus/common/src/lib.rs @@ -31,7 +31,7 @@ use std::sync::Arc; use std::time::Duration; -use sr_primitives::{traits::{Block as BlockT, DigestFor}, generic::BlockId}; +use sp_runtime::{traits::{Block as BlockT, DigestFor}, generic::BlockId}; use futures::prelude::*; pub use inherents::InherentData; diff --git a/primitives/consensus/common/src/select_chain.rs b/primitives/consensus/common/src/select_chain.rs index e696db6b87..da0bae4900 100644 --- a/primitives/consensus/common/src/select_chain.rs +++ b/primitives/consensus/common/src/select_chain.rs @@ -15,7 +15,7 @@ // along with Substrate Consensus Common. If not, see . use crate::error::Error; -use sr_primitives::traits::{Block as BlockT, NumberFor}; +use sp_runtime::traits::{Block as BlockT, NumberFor}; /// The SelectChain trait defines the strategy upon which the head is chosen diff --git a/primitives/consensus/pow/Cargo.toml b/primitives/consensus/pow/Cargo.toml index 99aa00da8e..f6b658294b 100644 --- a/primitives/consensus/pow/Cargo.toml +++ b/primitives/consensus/pow/Cargo.toml @@ -1,23 +1,23 @@ [package] -name = "substrate-consensus-pow-primitives" +name = "sp-consensus-pow" version = "2.0.0" authors = ["Parity Technologies "] description = "Primitives for Aura consensus" edition = "2018" [dependencies] -sr-api = { path = "../../sr-api", default-features = false } -rstd = { package = "sr-std", path = "../../sr-std", default-features = false } -sr-primitives = { path = "../../sr-primitives", default-features = false } -primitives = { package = "substrate-primitives", path = "../../core", default-features = false } +sp-api = { path = "../../sr-api", default-features = false } +rstd = { package = "sp-std", path = "../../sr-std", default-features = false } +sp-runtime = { path = "../../sr-primitives", default-features = false } +primitives = { package = "sp-core", path = "../../core", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } [features] default = ["std"] std = [ "rstd/std", - "sr-api/std", - "sr-primitives/std", + "sp-api/std", + "sp-runtime/std", "primitives/std", "codec/std", ] diff --git a/primitives/consensus/pow/src/lib.rs b/primitives/consensus/pow/src/lib.rs index 400ed0594a..69e088bd9c 100644 --- a/primitives/consensus/pow/src/lib.rs +++ b/primitives/consensus/pow/src/lib.rs @@ -19,7 +19,7 @@ #![cfg_attr(not(feature = "std"), no_std)] use rstd::vec::Vec; -use sr_primitives::ConsensusEngineId; +use sp_runtime::ConsensusEngineId; use codec::Decode; /// The `ConsensusEngineId` of PoW. @@ -47,7 +47,7 @@ impl TotalDifficulty for u128 { } } -sr_api::decl_runtime_apis! { +sp_api::decl_runtime_apis! { /// API necessary for timestamp-based difficulty adjustment algorithms. pub trait TimestampApi { /// Return the timestamp in the current block. diff --git a/primitives/core/Cargo.toml b/primitives/core/Cargo.toml index e15c5ac49f..ee7cbb87c9 100644 --- a/primitives/core/Cargo.toml +++ b/primitives/core/Cargo.toml @@ -1,11 +1,11 @@ [package] -name = "substrate-primitives" +name = "sp-core" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" [dependencies] -rstd = { package = "sr-std", path = "../sr-std", default-features = false } +rstd = { package = "sp-std", path = "../sr-std", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } rustc-hex = { version = "2.0.1", default-features = false } log = { version = "0.4.8", default-features = false } @@ -33,13 +33,13 @@ lazy_static = { version = "1.4.0", default-features = false, optional = true } parking_lot = { version = "0.9.0", optional = true } libsecp256k1 = { version = "0.3.0", default-features = false, optional = true } tiny-keccak = { version = "2.0.1", features = ["keccak"], optional = true } -substrate-debug-derive = { version = "2.0.0", path = "./debug-derive" } -externalities = { package = "substrate-externalities", path = "../externalities", optional = true } -primitives-storage = { package = "substrate-primitives-storage", path = "storage", default-features = false } -runtime-interface = { package = "substrate-runtime-interface", path = "../runtime-interface", default-features = false } +sp-debug-derive = { version = "2.0.0", path = "./debug-derive" } +externalities = { package = "sp-externalities", path = "../externalities", optional = true } +primitives-storage = { package = "sp-core-storage", path = "storage", default-features = false } +runtime-interface = { package = "sp-runtime-interface", path = "../runtime-interface", default-features = false } [dev-dependencies] -substrate-serializer = { path = "../serializer" } +sp-serializer = { path = "../serializer" } pretty_assertions = "0.6.1" hex-literal = "0.2.1" rand = "0.7.2" @@ -89,7 +89,7 @@ std = [ "num-traits/std", "libsecp256k1", "tiny-keccak", - "substrate-debug-derive/std", + "sp-debug-derive/std", "externalities", "primitives-storage/std", "runtime-interface/std", diff --git a/primitives/core/benches/bench.rs b/primitives/core/benches/bench.rs index 5245af44a8..bac7eb41ca 100644 --- a/primitives/core/benches/bench.rs +++ b/primitives/core/benches/bench.rs @@ -16,7 +16,7 @@ #[macro_use] extern crate criterion; -use substrate_primitives as primitives; +use sp_core as primitives; use criterion::{Criterion, black_box, Bencher, Fun}; use std::time::Duration; use primitives::crypto::Pair as _; diff --git a/primitives/core/debug-derive/Cargo.toml b/primitives/core/debug-derive/Cargo.toml index a7bf90695a..9c65cb34f5 100644 --- a/primitives/core/debug-derive/Cargo.toml +++ b/primitives/core/debug-derive/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "substrate-debug-derive" +name = "sp-debug-derive" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" diff --git a/primitives/core/debug-derive/src/lib.rs b/primitives/core/debug-derive/src/lib.rs index 5e6cf6098b..ac63441124 100644 --- a/primitives/core/debug-derive/src/lib.rs +++ b/primitives/core/debug-derive/src/lib.rs @@ -25,7 +25,7 @@ //! blob from unneeded code. //! //! ```rust -//! #[derive(substrate_debug_derive::RuntimeDebug)] +//! #[derive(sp_debug_derive::RuntimeDebug)] //! struct MyStruct; //! //! assert_eq!(format!("{:?}", MyStruct), "MyStruct"); diff --git a/primitives/core/debug-derive/tests/tests.rs b/primitives/core/debug-derive/tests/tests.rs index 63ad6a3e8d..11f45fcc45 100644 --- a/primitives/core/debug-derive/tests/tests.rs +++ b/primitives/core/debug-derive/tests/tests.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Substrate. If not, see . -use substrate_debug_derive::RuntimeDebug; +use sp_debug_derive::RuntimeDebug; #[derive(RuntimeDebug)] struct Unnamed(u64, String); diff --git a/primitives/core/src/hash.rs b/primitives/core/src/hash.rs index c63463e32a..8b1f9a5233 100644 --- a/primitives/core/src/hash.rs +++ b/primitives/core/src/hash.rs @@ -31,7 +31,7 @@ pub fn convert_hash, H2: AsRef<[u8]>>(src: &H2) -> H1 #[cfg(test)] mod tests { use super::*; - use substrate_serializer as ser; + use sp_serializer as ser; #[test] fn test_h160() { diff --git a/primitives/core/src/lib.rs b/primitives/core/src/lib.rs index 900728afbf..902cd55b58 100644 --- a/primitives/core/src/lib.rs +++ b/primitives/core/src/lib.rs @@ -42,7 +42,7 @@ pub use serde; #[doc(hidden)] pub use codec::{Encode, Decode}; -pub use substrate_debug_derive::RuntimeDebug; +pub use sp_debug_derive::RuntimeDebug; #[cfg(feature = "std")] pub use impl_serde::serialize as bytes; diff --git a/primitives/core/src/testing.rs b/primitives/core/src/testing.rs index e5d301008e..c87c170d20 100644 --- a/primitives/core/src/testing.rs +++ b/primitives/core/src/testing.rs @@ -141,7 +141,7 @@ impl crate::traits::BareCryptoStore for KeyStore { /// # Example /// /// ``` -/// # use substrate_primitives::wasm_export_functions; +/// # use sp_core::wasm_export_functions; /// /// wasm_export_functions! { /// fn test_in_wasm(value: bool, another_value: Vec) -> bool { diff --git a/primitives/core/src/uint.rs b/primitives/core/src/uint.rs index c835cf5773..330fffb9f1 100644 --- a/primitives/core/src/uint.rs +++ b/primitives/core/src/uint.rs @@ -22,7 +22,7 @@ pub use primitive_types::U256; mod tests { use super::*; use codec::{Encode, Decode}; - use substrate_serializer as ser; + use sp_serializer as ser; macro_rules! test { ($name: ident, $test_name: ident) => { diff --git a/primitives/core/storage/Cargo.toml b/primitives/core/storage/Cargo.toml index 1e5d7ee8b4..243184d038 100644 --- a/primitives/core/storage/Cargo.toml +++ b/primitives/core/storage/Cargo.toml @@ -1,15 +1,15 @@ [package] -name = "substrate-primitives-storage" +name = "sp-core-storage" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" description = "Storage related primitives" [dependencies] -rstd = { package = "sr-std", path = "../../sr-std", default-features = false } +rstd = { package = "sp-std", path = "../../sr-std", default-features = false } serde = { version = "1.0.101", optional = true, features = ["derive"] } impl-serde = { version = "0.2.3", optional = true } -substrate-debug-derive = { version = "2.0.0", path = "../debug-derive" } +sp-debug-derive = { version = "2.0.0", path = "../debug-derive" } [features] default = [ "std" ] diff --git a/primitives/core/storage/src/lib.rs b/primitives/core/storage/src/lib.rs index ba36e2c80f..ebb23023b9 100644 --- a/primitives/core/storage/src/lib.rs +++ b/primitives/core/storage/src/lib.rs @@ -20,7 +20,7 @@ #[cfg(feature = "std")] use serde::{Serialize, Deserialize}; -use substrate_debug_derive::RuntimeDebug; +use sp_debug_derive::RuntimeDebug; use rstd::{vec::Vec, borrow::Cow}; diff --git a/primitives/externalities/Cargo.toml b/primitives/externalities/Cargo.toml index ec4fa9a9a5..5b5e8c1ee8 100644 --- a/primitives/externalities/Cargo.toml +++ b/primitives/externalities/Cargo.toml @@ -1,11 +1,11 @@ [package] -name = "substrate-externalities" +name = "sp-externalities" version = "2.0.0" license = "GPL-3.0" authors = ["Parity Technologies "] edition = "2018" [dependencies] -primitives-storage = { package = "substrate-primitives-storage", path = "../core/storage" } -rstd = { package = "sr-std", path = "../sr-std" } +primitives-storage = { package = "sp-core-storage", path = "../core/storage" } +rstd = { package = "sp-std", path = "../sr-std" } environmental = { version = "1.0.2" } diff --git a/primitives/externalities/src/extensions.rs b/primitives/externalities/src/extensions.rs index a1a83cb197..c5535d0bab 100644 --- a/primitives/externalities/src/extensions.rs +++ b/primitives/externalities/src/extensions.rs @@ -41,7 +41,7 @@ pub trait Extension: Send + Any { /// /// # Example /// ``` -/// # use substrate_externalities::decl_extension; +/// # use sp_externalities::decl_extension; /// decl_extension! { /// /// Some test extension /// struct TestExt(String); diff --git a/primitives/finality-grandpa/Cargo.toml b/primitives/finality-grandpa/Cargo.toml index e9a166d287..f176702775 100644 --- a/primitives/finality-grandpa/Cargo.toml +++ b/primitives/finality-grandpa/Cargo.toml @@ -1,16 +1,16 @@ [package] -name = "substrate-finality-grandpa-primitives" +name = "sp-finality-granpda" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" [dependencies] -app-crypto = { package = "substrate-application-crypto", path = "../application-crypto", default-features = false } +app-crypto = { package = "sc-application-crypto", path = "../application-crypto", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -rstd = { package = "sr-std", path = "../sr-std", default-features = false } +rstd = { package = "sp-std", path = "../sr-std", default-features = false } serde = { version = "1.0.101", optional = true, features = ["derive"] } -sr-api = { path = "../sr-api", default-features = false } -sr-primitives = { path = "../sr-primitives", default-features = false } +sp-api = { path = "../sr-api", default-features = false } +sp-runtime = { path = "../sr-primitives", default-features = false } [features] default = ["std"] @@ -19,6 +19,6 @@ std = [ "codec/std", "rstd/std", "serde", - "sr-api/std", - "sr-primitives/std", + "sp-api/std", + "sp-runtime/std", ] diff --git a/primitives/finality-grandpa/src/lib.rs b/primitives/finality-grandpa/src/lib.rs index ff26b6a68a..0e7ed9926f 100644 --- a/primitives/finality-grandpa/src/lib.rs +++ b/primitives/finality-grandpa/src/lib.rs @@ -24,7 +24,7 @@ extern crate alloc; #[cfg(feature = "std")] use serde::Serialize; use codec::{Encode, Decode, Input, Codec}; -use sr_primitives::{ConsensusEngineId, RuntimeDebug}; +use sp_runtime::{ConsensusEngineId, RuntimeDebug}; use rstd::borrow::Cow; use rstd::vec::Vec; @@ -210,7 +210,7 @@ impl<'a> Decode for VersionedAuthorityList<'a> { } } -sr_api::decl_runtime_apis! { +sp_api::decl_runtime_apis! { /// APIs for integrating the GRANDPA finality gadget into runtimes. /// This should be implemented on the runtime side. /// diff --git a/primitives/finality-tracker/Cargo.toml b/primitives/finality-tracker/Cargo.toml index 2f7ddf916b..812596beaa 100644 --- a/primitives/finality-tracker/Cargo.toml +++ b/primitives/finality-tracker/Cargo.toml @@ -6,8 +6,8 @@ edition = "2018" [dependencies] codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } -inherents = { package = "substrate-inherents", path = "../../primitives/inherents", default-features = false } -rstd = { package = "sr-std", path = "../../primitives/sr-std", default-features = false } +inherents = { package = "sp-inherents", path = "../../primitives/inherents", default-features = false } +rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } [features] default = ["std"] diff --git a/primitives/inherents/Cargo.toml b/primitives/inherents/Cargo.toml index f01bb9d3a9..0d33b961ed 100644 --- a/primitives/inherents/Cargo.toml +++ b/primitives/inherents/Cargo.toml @@ -1,13 +1,13 @@ [package] -name = "substrate-inherents" +name = "sp-inherents" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" [dependencies] parking_lot = { version = "0.9.0", optional = true } -rstd = { package = "sr-std", path = "../sr-std", default-features = false } -primitives = { package = "substrate-primitives", path = "../core", default-features = false } +rstd = { package = "sp-std", path = "../sr-std", default-features = false } +primitives = { package = "sp-core", path = "../core", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.6", default-features = false, features = ["derive"] } derive_more = { version = "0.99.2", optional = true } diff --git a/primitives/keyring/Cargo.toml b/primitives/keyring/Cargo.toml index 5960f7be16..25d8a33540 100644 --- a/primitives/keyring/Cargo.toml +++ b/primitives/keyring/Cargo.toml @@ -1,11 +1,11 @@ [package] -name = "substrate-keyring" +name = "sp-keyring" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" [dependencies] -primitives = { package = "substrate-primitives", path = "../core" } -sr-primitives = { path = "../sr-primitives" } +primitives = { package = "sp-core", path = "../core" } +sp-runtime = { path = "../sr-primitives" } lazy_static = "1.4.0" strum = { version = "0.16.0", features = ["derive"] } diff --git a/primitives/keyring/src/ed25519.rs b/primitives/keyring/src/ed25519.rs index 4a3e090c76..7174d1cc43 100644 --- a/primitives/keyring/src/ed25519.rs +++ b/primitives/keyring/src/ed25519.rs @@ -20,7 +20,7 @@ use std::{collections::HashMap, ops::Deref}; use lazy_static::lazy_static; use primitives::{ed25519::{Pair, Public, Signature}, Pair as PairT, Public as PublicT, H256}; pub use primitives::ed25519; -use sr_primitives::AccountId32; +use sp_runtime::AccountId32; /// Set of test accounts. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, strum::Display, strum::EnumIter)] @@ -106,9 +106,9 @@ impl From for &'static str { } } -impl From for sr_primitives::MultiSigner { +impl From for sp_runtime::MultiSigner { fn from(x: Keyring) -> Self { - sr_primitives::MultiSigner::Ed25519(x.into()) + sp_runtime::MultiSigner::Ed25519(x.into()) } } diff --git a/primitives/keyring/src/sr25519.rs b/primitives/keyring/src/sr25519.rs index ff132d8968..a14566bbab 100644 --- a/primitives/keyring/src/sr25519.rs +++ b/primitives/keyring/src/sr25519.rs @@ -21,7 +21,7 @@ use std::ops::Deref; use lazy_static::lazy_static; use primitives::{sr25519::{Pair, Public, Signature}, Pair as PairT, Public as PublicT, H256}; pub use primitives::sr25519; -use sr_primitives::AccountId32; +use sp_runtime::AccountId32; /// Set of test accounts. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, strum::Display, strum::EnumIter)] @@ -107,9 +107,9 @@ impl From for &'static str { } } -impl From for sr_primitives::MultiSigner { +impl From for sp_runtime::MultiSigner { fn from(x: Keyring) -> Self { - sr_primitives::MultiSigner::Sr25519(x.into()) + sp_runtime::MultiSigner::Sr25519(x.into()) } } diff --git a/primitives/offchain/Cargo.toml b/primitives/offchain/Cargo.toml index 5b451ee6d1..28a3ad198a 100644 --- a/primitives/offchain/Cargo.toml +++ b/primitives/offchain/Cargo.toml @@ -1,18 +1,18 @@ [package] description = "Substrate offchain workers primitives" -name = "substrate-offchain-primitives" +name = "sp-offchain" version = "2.0.0" license = "GPL-3.0" authors = ["Parity Technologies "] edition = "2018" [dependencies] -sr-api = { path = "../sr-api", default-features = false } -sr-primitives = { path = "../sr-primitives", default-features = false } +sp-api = { path = "../sr-api", default-features = false } +sp-runtime = { path = "../sr-primitives", default-features = false } [features] default = ["std"] std = [ - "sr-api/std", - "sr-primitives/std" + "sp-api/std", + "sp-runtime/std" ] diff --git a/primitives/offchain/src/lib.rs b/primitives/offchain/src/lib.rs index 876fcf49a2..db7efcd0cc 100644 --- a/primitives/offchain/src/lib.rs +++ b/primitives/offchain/src/lib.rs @@ -19,12 +19,12 @@ #![cfg_attr(not(feature = "std"), no_std)] #![warn(missing_docs)] -use sr_primitives::traits::NumberFor; +use sp_runtime::traits::NumberFor; /// Local Storage Prefix used by the Offchain Worker API to pub const STORAGE_PREFIX: &[u8] = b"storage"; -sr_api::decl_runtime_apis! { +sp_api::decl_runtime_apis! { /// The offchain worker api. pub trait OffchainWorkerApi { /// Starts the off-chain task for given block number. diff --git a/primitives/panic-handler/Cargo.toml b/primitives/panic-handler/Cargo.toml index 9724b92919..19e34352cf 100644 --- a/primitives/panic-handler/Cargo.toml +++ b/primitives/panic-handler/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "substrate-panic-handler" +name = "sp-panic-handler" version = "2.0.0" authors = ["Parity Technologies "] description = "Substrate panic handler." diff --git a/primitives/phragmen/Cargo.toml b/primitives/phragmen/Cargo.toml index 18dc3c29fb..656ce06acd 100644 --- a/primitives/phragmen/Cargo.toml +++ b/primitives/phragmen/Cargo.toml @@ -1,17 +1,17 @@ [package] -name = "substrate-phragmen" +name = "sp-phragmen" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" [dependencies] serde = { version = "1.0.101", optional = true, features = ["derive"] } -rstd = { package = "sr-std", path = "../sr-std", default-features = false } -sr-primitives = { path = "../../primitives/sr-primitives", default-features = false } +rstd = { package = "sp-std", path = "../sr-std", default-features = false } +sp-runtime = { path = "../../primitives/sr-primitives", default-features = false } [dev-dependencies] substrate-test-utils = { path = "../../test/utils" } -runtime-io ={ package = "sr-io", path = "../../primitives/sr-io" } +runtime-io ={ package = "sp-io", path = "../../primitives/sr-io" } rand = "0.7.2" [features] @@ -19,5 +19,5 @@ default = ["std"] std = [ "serde", "rstd/std", - "sr-primitives/std", + "sp-runtime/std", ] diff --git a/primitives/phragmen/benches/phragmen.rs b/primitives/phragmen/benches/phragmen.rs index b73811b33f..33b80ed5a6 100644 --- a/primitives/phragmen/benches/phragmen.rs +++ b/primitives/phragmen/benches/phragmen.rs @@ -23,11 +23,11 @@ extern crate test; use test::Bencher; use rand::{self, Rng}; -extern crate substrate_phragmen as phragmen; +extern crate sp_phragmen as phragmen; use phragmen::{Support, SupportMap, PhragmenStakedAssignment}; use std::collections::BTreeMap; -use sr_primitives::traits::{Convert, SaturatedConversion}; +use sp_runtime::traits::{Convert, SaturatedConversion}; const VALIDATORS: u64 = 1000; const NOMINATORS: u64 = 10_000; diff --git a/primitives/phragmen/src/lib.rs b/primitives/phragmen/src/lib.rs index d027bcfa8d..c5e9d97fc7 100644 --- a/primitives/phragmen/src/lib.rs +++ b/primitives/phragmen/src/lib.rs @@ -34,9 +34,9 @@ #![cfg_attr(not(feature = "std"), no_std)] use rstd::{prelude::*, collections::btree_map::BTreeMap}; -use sr_primitives::RuntimeDebug; -use sr_primitives::{helpers_128bit::multiply_by_rational, Perbill, Rational128}; -use sr_primitives::traits::{Zero, Convert, Member, SimpleArithmetic, Saturating, Bounded}; +use sp_runtime::RuntimeDebug; +use sp_runtime::{helpers_128bit::multiply_by_rational, Perbill, Rational128}; +use sp_runtime::traits::{Zero, Convert, Member, SimpleArithmetic, Saturating, Bounded}; #[cfg(test)] mod mock; diff --git a/primitives/phragmen/src/mock.rs b/primitives/phragmen/src/mock.rs index fdd218f4f4..edb0826b06 100644 --- a/primitives/phragmen/src/mock.rs +++ b/primitives/phragmen/src/mock.rs @@ -19,7 +19,7 @@ #![cfg(test)] use crate::{elect, PhragmenResult, PhragmenAssignment}; -use sr_primitives::{ +use sp_runtime::{ assert_eq_error_rate, Perbill, traits::{Convert, Member, SaturatedConversion} }; diff --git a/primitives/phragmen/src/tests.rs b/primitives/phragmen/src/tests.rs index 8aaa45dce0..eceedb8847 100644 --- a/primitives/phragmen/src/tests.rs +++ b/primitives/phragmen/src/tests.rs @@ -21,7 +21,7 @@ use crate::mock::*; use crate::{elect, PhragmenResult}; use substrate_test_utils::assert_eq_uvec; -use sr_primitives::Perbill; +use sp_runtime::Perbill; #[test] fn float_phragmen_poc_works() { diff --git a/primitives/rpc/Cargo.toml b/primitives/rpc/Cargo.toml index eb4cd5a723..9e44f407d0 100644 --- a/primitives/rpc/Cargo.toml +++ b/primitives/rpc/Cargo.toml @@ -1,12 +1,12 @@ [package] -name = "substrate-rpc-primitives" +name = "sp-rpc" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" [dependencies] serde = { version = "1.0.101", features = ["derive"] } -primitives = { package = "substrate-primitives", path = "../core" } +primitives = { package = "sp-core", path = "../core" } [dev-dependencies] serde_json = "1.0.41" diff --git a/primitives/runtime-interface/Cargo.toml b/primitives/runtime-interface/Cargo.toml index 7af9b8b088..e904633565 100644 --- a/primitives/runtime-interface/Cargo.toml +++ b/primitives/runtime-interface/Cargo.toml @@ -1,25 +1,25 @@ [package] -name = "substrate-runtime-interface" +name = "sp-runtime-interface" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" [dependencies] -wasm-interface = { package = "substrate-wasm-interface", path = "../wasm-interface", optional = true } -rstd = { package = "sr-std", path = "../sr-std", default-features = false } -substrate-runtime-interface-proc-macro = { path = "proc-macro" } -externalities = { package = "substrate-externalities", path = "../externalities", optional = true } +wasm-interface = { package = "sp-wasm-interface", path = "../wasm-interface", optional = true } +rstd = { package = "sp-std", path = "../sr-std", default-features = false } +sp-runtime-interface-proc-macro = { path = "proc-macro" } +externalities = { package = "sp-externalities", path = "../externalities", optional = true } codec = { package = "parity-scale-codec", version = "1.0.6", default-features = false } environmental = { version = "1.0.2", optional = true } static_assertions = "1.0.0" primitive-types = { version = "0.6.1", default-features = false } [dev-dependencies] -executor = { package = "substrate-executor", path = "../../client/executor" } -test-wasm = { package = "substrate-runtime-interface-test-wasm", path = "test-wasm" } -state_machine = { package = "substrate-state-machine", path = "../../primitives/state-machine" } -primitives = { package = "substrate-primitives", path = "../core" } -runtime-io = { package = "sr-io", path = "../sr-io" } +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" } [features] default = [ "std" ] diff --git a/primitives/runtime-interface/proc-macro/Cargo.toml b/primitives/runtime-interface/proc-macro/Cargo.toml index 0b073b8547..11a01a7a7c 100644 --- a/primitives/runtime-interface/proc-macro/Cargo.toml +++ b/primitives/runtime-interface/proc-macro/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "substrate-runtime-interface-proc-macro" +name = "sp-runtime-interface-proc-macro" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" @@ -15,9 +15,9 @@ Inflector = "0.11.4" proc-macro-crate = "0.1.4" [dev-dependencies] -runtime-interface = { package = "substrate-runtime-interface", path = ".." } +runtime-interface = { package = "sp-runtime-interface", path = ".." } codec = { package = "parity-scale-codec", version = "1.0.6", features = [ "derive" ] } -externalities = { package = "substrate-externalities", path = "../../externalities" } +externalities = { package = "sp-externalities", path = "../../externalities" } rustversion = "1.0.0" trybuild = "1.0.17" diff --git a/primitives/runtime-interface/proc-macro/src/lib.rs b/primitives/runtime-interface/proc-macro/src/lib.rs index 991fab7569..023a97c117 100644 --- a/primitives/runtime-interface/proc-macro/src/lib.rs +++ b/primitives/runtime-interface/proc-macro/src/lib.rs @@ -101,7 +101,7 @@ mod utils; /// .expect("`set_or_clear` called outside of an Externalities-provided environment.") /// } /// -/// /// This type implements the `HostFunctions` trait (from `substrate-wasm-interface`) and +/// /// This type implements the `HostFunctions` trait (from `sp-wasm-interface`) and /// /// provides the host implementation for the wasm side. The host implementation converts the /// /// arguments from wasm to native and calls the corresponding native function. /// /// @@ -132,7 +132,7 @@ mod utils; /// } /// } /// -/// /// The type is actually `ExchangeableFunction` (from `substrate-runtime-interface`). +/// /// The type is actually `ExchangeableFunction` (from `sp-runtime-interface`). /// /// /// /// This can be used to replace the implementation of the `call_some_complex_code` function. /// /// Instead of calling into the host, the callee will automatically call the other @@ -161,7 +161,7 @@ mod utils; /// # Argument types /// /// The macro supports any kind of argument type, as long as it implements `RIType` and the required -/// `FromFFIValue`/`IntoFFIValue` from `substrate-runtime-interface`. The macro will convert each +/// `FromFFIValue`/`IntoFFIValue` from `sp-runtime-interface`. The macro will convert each /// argument to the corresponding FFI representation and will call into the host using this FFI /// representation. On the host each argument is converted back to the native representation and /// the native implementation is called. Any return value is handled in the same way. @@ -174,7 +174,7 @@ mod utils; /// /// 1. The generated functions are not callable from the native side. /// 2. The trait as shown above is not implemented for `Externalities` and is instead implemented -/// for `FunctionExecutor` (from `substrate-wasm-interface`). +/// for `FunctionExecutor` (from `sp-wasm-interface`). #[proc_macro_attribute] pub fn runtime_interface( attrs: proc_macro::TokenStream, diff --git a/primitives/runtime-interface/proc-macro/src/utils.rs b/primitives/runtime-interface/proc-macro/src/utils.rs index d868452dce..d5ae107e0b 100644 --- a/primitives/runtime-interface/proc-macro/src/utils.rs +++ b/primitives/runtime-interface/proc-macro/src/utils.rs @@ -33,10 +33,10 @@ use inflector::Inflector; /// Generates the include for the runtime-interface crate. pub fn generate_runtime_interface_include() -> TokenStream { - if env::var("CARGO_PKG_NAME").unwrap() == "substrate-runtime-interface" { + if env::var("CARGO_PKG_NAME").unwrap() == "sp-runtime-interface" { TokenStream::new() } else { - match crate_name("substrate-runtime-interface") { + match crate_name("sp-runtime-interface") { Ok(crate_name) => { let crate_name = Ident::new(&crate_name, Span::call_site()); quote!( @@ -52,10 +52,10 @@ pub fn generate_runtime_interface_include() -> TokenStream { } } -/// Generates the access to the `substrate-runtime-interface` crate. +/// Generates the access to the `sp-runtime-interface` crate. pub fn generate_crate_access() -> TokenStream { - if env::var("CARGO_PKG_NAME").unwrap() == "substrate-runtime-interface" { - quote!( substrate_runtime_interface ) + if env::var("CARGO_PKG_NAME").unwrap() == "sp-runtime-interface" { + quote!( sp_runtime_interface ) } else { quote!( proc_macro_runtime_interface ) } diff --git a/primitives/runtime-interface/src/lib.rs b/primitives/runtime-interface/src/lib.rs index fb70d252a6..c6b006f4e6 100644 --- a/primitives/runtime-interface/src/lib.rs +++ b/primitives/runtime-interface/src/lib.rs @@ -59,7 +59,7 @@ //! Declaring a runtime interface is similar to declaring a trait in Rust: //! //! ``` -//! #[substrate_runtime_interface::runtime_interface] +//! #[sp_runtime_interface::runtime_interface] //! trait RuntimeInterface { //! fn some_function(value: &[u8]) -> bool { //! value.iter().all(|v| *v > 125) @@ -79,7 +79,7 @@ pub use wasm_interface; #[doc(hidden)] pub use rstd; -pub use substrate_runtime_interface_proc_macro::runtime_interface; +pub use sp_runtime_interface_proc_macro::runtime_interface; #[doc(hidden)] #[cfg(feature = "std")] diff --git a/primitives/runtime-interface/src/pass_by.rs b/primitives/runtime-interface/src/pass_by.rs index 46265237c0..3fcf04b1c4 100644 --- a/primitives/runtime-interface/src/pass_by.rs +++ b/primitives/runtime-interface/src/pass_by.rs @@ -35,7 +35,7 @@ use rstd::{marker::PhantomData, convert::TryFrom}; #[cfg(not(feature = "std"))] use rstd::{slice, vec::Vec}; -pub use substrate_runtime_interface_proc_macro::{PassByCodec, PassByInner, PassByEnum}; +pub use sp_runtime_interface_proc_macro::{PassByCodec, PassByInner, PassByEnum}; /// Something that should be passed between wasm and the host using the given strategy. /// @@ -145,7 +145,7 @@ impl FromFFIValue for T { /// /// # Example /// ``` -/// # use substrate_runtime_interface::pass_by::{PassBy, Codec}; +/// # use sp_runtime_interface::pass_by::{PassBy, Codec}; /// #[derive(codec::Encode, codec::Decode)] /// struct Test; /// @@ -237,7 +237,7 @@ pub trait PassByInner: Sized { /// /// # Example /// ``` -/// # use substrate_runtime_interface::pass_by::{PassBy, Inner, PassByInner}; +/// # use sp_runtime_interface::pass_by::{PassBy, Inner, PassByInner}; /// struct Test([u8; 32]); /// /// impl PassBy for Test { @@ -311,7 +311,7 @@ impl, I: RIType> RIType for Inner { /// /// # Example /// ``` -/// # use substrate_runtime_interface::pass_by::{PassBy, Enum}; +/// # use sp_runtime_interface::pass_by::{PassBy, Enum}; /// #[derive(Clone, Copy)] /// enum Test { /// Test1, diff --git a/primitives/runtime-interface/test-wasm/Cargo.toml b/primitives/runtime-interface/test-wasm/Cargo.toml index 13d6e25914..4df59d03b0 100644 --- a/primitives/runtime-interface/test-wasm/Cargo.toml +++ b/primitives/runtime-interface/test-wasm/Cargo.toml @@ -1,15 +1,15 @@ [package] -name = "substrate-runtime-interface-test-wasm" +name = "sp-runtime-interface-test-wasm" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" build = "build.rs" [dependencies] -runtime-interface = { package = "substrate-runtime-interface", path = "../", default-features = false } -rstd = { package = "sr-std", path = "../../sr-std", default-features = false } -runtime-io = { package = "sr-io", path = "../../sr-io", default-features = false } -primitives = { package = "substrate-primitives", path = "../../core", default-features = false } +runtime-interface = { package = "sp-runtime-interface", path = "../", default-features = false } +rstd = { package = "sp-std", path = "../../sr-std", default-features = false } +runtime-io = { package = "sp-io", path = "../../sr-io", default-features = false } +primitives = { package = "sp-core", path = "../../core", default-features = false } [build-dependencies] wasm-builder-runner = { package = "substrate-wasm-builder-runner", version = "1.0.3", path = "../../../client/utils/wasm-builder-runner" } diff --git a/primitives/serializer/Cargo.toml b/primitives/serializer/Cargo.toml index 4e0e706e2f..39fdeb0e7e 100644 --- a/primitives/serializer/Cargo.toml +++ b/primitives/serializer/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "substrate-serializer" +name = "sp-serializer" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" diff --git a/primitives/session/Cargo.toml b/primitives/session/Cargo.toml index d1490905c2..447cf8ad1b 100644 --- a/primitives/session/Cargo.toml +++ b/primitives/session/Cargo.toml @@ -1,14 +1,14 @@ [package] -name = "substrate-session" +name = "sp-sesssion" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" [dependencies] -sr-api = { path = "../sr-api", default-features = false } -rstd = { package = "sr-std", path = "../sr-std", default-features = false } -sr-primitives = { path = "../sr-primitives", optional = true } +sp-api = { path = "../sr-api", default-features = false } +rstd = { package = "sp-std", path = "../sr-std", default-features = false } +sp-runtime = { path = "../sr-primitives", optional = true } [features] default = [ "std" ] -std = [ "sr-api/std", "rstd/std", "sr-primitives" ] +std = [ "sp-api/std", "rstd/std", "sp-runtime" ] diff --git a/primitives/session/src/lib.rs b/primitives/session/src/lib.rs index adc7629c36..2c4b118d5b 100644 --- a/primitives/session/src/lib.rs +++ b/primitives/session/src/lib.rs @@ -21,9 +21,9 @@ use rstd::vec::Vec; #[cfg(feature = "std")] -use sr_primitives::{generic::BlockId, traits::{ProvideRuntimeApi, Block as BlockT}}; +use sp_runtime::{generic::BlockId, traits::{ProvideRuntimeApi, Block as BlockT}}; -sr_api::decl_runtime_apis! { +sp_api::decl_runtime_apis! { /// Session keys runtime api. pub trait SessionKeys { /// Generate a set of session keys with optionally using the given seed. @@ -44,7 +44,7 @@ pub fn generate_initial_session_keys( client: std::sync::Arc, at: &BlockId, seeds: Vec, -) -> Result<(), <::Api as sr_api::ApiExt>::Error> +) -> Result<(), <::Api as sp_api::ApiExt>::Error> where Block: BlockT, T: ProvideRuntimeApi, diff --git a/primitives/sr-api/Cargo.toml b/primitives/sr-api/Cargo.toml index a23a36284d..530c97478f 100644 --- a/primitives/sr-api/Cargo.toml +++ b/primitives/sr-api/Cargo.toml @@ -1,17 +1,17 @@ [package] -name = "sr-api" +name = "sp-api" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" [dependencies] codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } -sr-api-proc-macro = { path = "proc-macro" } -primitives = { package = "substrate-primitives", path = "../core", default-features = false } -rstd = { package = "sr-std", path = "../sr-std", default-features = false } -sr-primitives = { path = "../sr-primitives", default-features = false } -sr-version = { path = "../sr-version", default-features = false } -state-machine = { package = "substrate-state-machine", path = "../../primitives/state-machine", optional = true } +sp-api-proc-macro = { path = "proc-macro" } +primitives = { package = "sp-core", path = "../core", default-features = false } +rstd = { package = "sp-std", path = "../sr-std", default-features = false } +sp-runtime = { path = "../sr-primitives", default-features = false } +sp-version = { path = "../sr-version", default-features = false } +state-machine = { package = "sp-state-machine", path = "../../primitives/state-machine", optional = true } [dev-dependencies] criterion = "0.3.0" @@ -27,7 +27,7 @@ std = [ "codec/std", "primitives/std", "rstd/std", - "sr-primitives/std", + "sp-runtime/std", "state-machine", - "sr-version/std", + "sp-version/std", ] diff --git a/primitives/sr-api/benches/bench.rs b/primitives/sr-api/benches/bench.rs index 49c8e1e380..59bac57f13 100644 --- a/primitives/sr-api/benches/bench.rs +++ b/primitives/sr-api/benches/bench.rs @@ -19,10 +19,10 @@ use test_client::{ DefaultTestClientBuilderExt, TestClientBuilder, TestClientBuilderExt, runtime::TestAPI, }; -use sr_primitives::{generic::BlockId, traits::ProvideRuntimeApi}; +use sp_runtime::{generic::BlockId, traits::ProvideRuntimeApi}; use state_machine::ExecutionStrategy; -fn sr_api_benchmark(c: &mut Criterion) { +fn sp_api_benchmark(c: &mut Criterion) { c.bench_function("add one with same runtime api", |b| { let client = test_client::new(); let runtime_api = client.runtime_api(); @@ -68,5 +68,5 @@ fn sr_api_benchmark(c: &mut Criterion) { }); } -criterion_group!(benches, sr_api_benchmark); +criterion_group!(benches, sp_api_benchmark); criterion_main!(benches); diff --git a/primitives/sr-api/proc-macro/Cargo.toml b/primitives/sr-api/proc-macro/Cargo.toml index bd6418c458..7eb6bcdb8b 100644 --- a/primitives/sr-api/proc-macro/Cargo.toml +++ b/primitives/sr-api/proc-macro/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "sr-api-proc-macro" +name = "sp-api-proc-macro" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" @@ -15,9 +15,9 @@ blake2-rfc = "0.2.18" proc-macro-crate = "0.1.4" [dev-dependencies] -sr-api = { path = ".." } -sr-primitives = { path = "../../sr-primitives" } -sr-version = { path = "../../sr-version" } +sp-api = { path = ".." } +sp-runtime = { path = "../../sr-primitives" } +sp-version = { path = "../../sr-version" } test-client = { package = "substrate-test-runtime-client", path = "../../../test/utils/runtime/client" } # Required for the doc tests diff --git a/primitives/sr-api/proc-macro/src/lib.rs b/primitives/sr-api/proc-macro/src/lib.rs index 913e6e9d04..d82c31ec9f 100644 --- a/primitives/sr-api/proc-macro/src/lib.rs +++ b/primitives/sr-api/proc-macro/src/lib.rs @@ -44,9 +44,9 @@ mod utils; /// # Example /// /// ```rust -/// use sr_version::create_runtime_str; +/// use sp_version::create_runtime_str; /// # -/// # use sr_primitives::traits::GetNodeBlockType; +/// # use sp_runtime::traits::GetNodeBlockType; /// # use test_client::runtime::{Block, Header}; /// # /// # /// The declaration of the `Runtime` type and the implementation of the `GetNodeBlockType` @@ -56,7 +56,7 @@ mod utils; /// # type NodeBlock = Block; /// # } /// # -/// # sr_api::decl_runtime_apis! { +/// # sp_api::decl_runtime_apis! { /// # /// Declare the api trait. /// # pub trait Balance { /// # /// Get the balance. @@ -70,9 +70,9 @@ mod utils; /// # } /// /// /// All runtime api implementations need to be done in one call of the macro! -/// sr_api::impl_runtime_apis! { -/// # impl sr_api::Core for Runtime { -/// # fn version() -> sr_version::RuntimeVersion { +/// sp_api::impl_runtime_apis! { +/// # impl sp_api::Core for Runtime { +/// # fn version() -> sp_version::RuntimeVersion { /// # unimplemented!() /// # } /// # fn execute_block(_block: Block) {} @@ -96,7 +96,7 @@ mod utils; /// } /// /// /// Runtime version. This needs to be declared for each runtime. -/// pub const VERSION: sr_version::RuntimeVersion = sr_version::RuntimeVersion { +/// pub const VERSION: sp_version::RuntimeVersion = sp_version::RuntimeVersion { /// spec_name: create_runtime_str!("node"), /// impl_name: create_runtime_str!("test-node"), /// authoring_version: 1, @@ -127,7 +127,7 @@ pub fn impl_runtime_apis(input: TokenStream) -> TokenStream { /// # Example /// /// ```rust -/// sr_api::decl_runtime_apis! { +/// sp_api::decl_runtime_apis! { /// /// Declare the api trait. /// pub trait Balance { /// /// Get the balance. @@ -159,7 +159,7 @@ pub fn impl_runtime_apis(input: TokenStream) -> TokenStream { /// spec version!). Such a method also does not need to be implemented in the runtime. /// /// ```rust -/// sr_api::decl_runtime_apis! { +/// sp_api::decl_runtime_apis! { /// /// Declare the api trait. /// #[api_version(2)] /// pub trait Balance { diff --git a/primitives/sr-api/proc-macro/src/utils.rs b/primitives/sr-api/proc-macro/src/utils.rs index a46397be1b..859f37df56 100644 --- a/primitives/sr-api/proc-macro/src/utils.rs +++ b/primitives/sr-api/proc-macro/src/utils.rs @@ -32,22 +32,22 @@ pub fn unwrap_or_error(res: Result) -> TokenStream { } fn generate_hidden_includes_mod_name(unique_id: &'static str) -> Ident { - Ident::new(&format!("sr_api_hidden_includes_{}", unique_id), Span::call_site()) + Ident::new(&format!("sp_api_hidden_includes_{}", unique_id), Span::call_site()) } /// Generates the hidden includes that are required to make the macro independent from its scope. pub fn generate_hidden_includes(unique_id: &'static str) -> TokenStream { - if env::var("CARGO_PKG_NAME").unwrap() == "sr-api" { + if env::var("CARGO_PKG_NAME").unwrap() == "sp-api" { TokenStream::new() } else { let mod_name = generate_hidden_includes_mod_name(unique_id); - match crate_name("sr-api") { + match crate_name("sp-api") { Ok(client_name) => { let client_name = Ident::new(&client_name, Span::call_site()); quote!( #[doc(hidden)] mod #mod_name { - pub extern crate #client_name as sr_api; + pub extern crate #client_name as sp_api; } ) }, @@ -60,13 +60,13 @@ pub fn generate_hidden_includes(unique_id: &'static str) -> TokenStream { }.into() } -/// Generates the access to the `substrate_client` crate. +/// Generates the access to the `sc_client` crate. pub fn generate_crate_access(unique_id: &'static str) -> TokenStream { - if env::var("CARGO_PKG_NAME").unwrap() == "sr-api" { + if env::var("CARGO_PKG_NAME").unwrap() == "sp-api" { quote!( crate ) } else { let mod_name = generate_hidden_includes_mod_name(unique_id); - quote!( self::#mod_name::sr_api ) + quote!( self::#mod_name::sp_api ) }.into() } diff --git a/primitives/sr-api/src/lib.rs b/primitives/sr-api/src/lib.rs index 4a5cbf513f..edbf567ea6 100644 --- a/primitives/sr-api/src/lib.rs +++ b/primitives/sr-api/src/lib.rs @@ -40,7 +40,7 @@ pub use primitives::NativeOrEncoded; #[cfg(not(feature = "std"))] pub use primitives::to_substrate_wasm_fn_return_value; #[doc(hidden)] -pub use sr_primitives::{ +pub use sp_runtime::{ traits::{ Block as BlockT, GetNodeBlockType, GetRuntimeBlockType, Header as HeaderT, ApiRef, RuntimeApiInfo, Hash as HashT, @@ -50,7 +50,7 @@ pub use sr_primitives::{ #[doc(hidden)] pub use primitives::{offchain, ExecutionContext}; #[doc(hidden)] -pub use sr_version::{ApiId, RuntimeVersion, ApisVec, create_apis_vec}; +pub use sp_version::{ApiId, RuntimeVersion, ApisVec, create_apis_vec}; #[doc(hidden)] pub use rstd::{slice, mem}; #[cfg(feature = "std")] @@ -61,7 +61,7 @@ use primitives::OpaqueMetadata; #[cfg(feature = "std")] use std::{panic::UnwindSafe, cell::RefCell}; -pub use sr_api_proc_macro::{decl_runtime_apis, impl_runtime_apis}; +pub use sp_api_proc_macro::{decl_runtime_apis, impl_runtime_apis}; #[cfg(feature = "std")] /// A type that records all accessed trie nodes and generates a proof out of it. @@ -176,7 +176,7 @@ pub trait CallRuntimeAt { /// Extracts the `Api::Error` for a type that provides a runtime api. #[cfg(feature = "std")] pub type ApiErrorFor = < - ::Api as ApiExt + ::Api as ApiExt >::Error; decl_runtime_apis! { diff --git a/primitives/sr-api/test/Cargo.toml b/primitives/sr-api/test/Cargo.toml index 5cdbdc861e..af3aaf67fa 100644 --- a/primitives/sr-api/test/Cargo.toml +++ b/primitives/sr-api/test/Cargo.toml @@ -1,18 +1,18 @@ [package] -name = "sr-api-test" +name = "sp-api-test" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" [dependencies] -sr-api = { path = "../" } +sp-api = { path = "../" } test-client = { package = "substrate-test-runtime-client", path = "../../../test/utils/runtime/client" } -sr-version = { path = "../../sr-version" } -sr-primitives = { path = "../../sr-primitives" } +sp-version = { path = "../../sr-version" } +sp-runtime = { path = "../../sr-primitives" } sp-blockchain = { path = "../../blockchain" } -consensus_common = { package = "substrate-consensus-common", path = "../../../primitives/consensus/common" } +consensus_common = { package = "sp-consensus", path = "../../../primitives/consensus/common" } codec = { package = "parity-scale-codec", version = "1.0.0" } -state-machine = { package = "substrate-state-machine", path = "../../../primitives/state-machine" } +state-machine = { package = "sp-state-machine", path = "../../../primitives/state-machine" } trybuild = "1.0.17" rustversion = "1.0.0" diff --git a/primitives/sr-api/test/tests/decl_and_impl.rs b/primitives/sr-api/test/tests/decl_and_impl.rs index 6bc5ea908c..d52b5b4070 100644 --- a/primitives/sr-api/test/tests/decl_and_impl.rs +++ b/primitives/sr-api/test/tests/decl_and_impl.rs @@ -14,9 +14,9 @@ // You should have received a copy of the GNU General Public License // along with Substrate. If not, see . -use sr_api::{RuntimeApiInfo, decl_runtime_apis, impl_runtime_apis}; +use sp_api::{RuntimeApiInfo, decl_runtime_apis, impl_runtime_apis}; -use sr_primitives::{traits::{GetNodeBlockType, Block as BlockT}, generic::BlockId}; +use sp_runtime::{traits::{GetNodeBlockType, Block as BlockT}, generic::BlockId}; use test_client::runtime::Block; use sp_blockchain::Result; @@ -68,8 +68,8 @@ impl_runtime_apis! { fn same_name() {} } - impl sr_api::Core for Runtime { - fn version() -> sr_version::RuntimeVersion { + impl sp_api::Core for Runtime { + fn version() -> sp_version::RuntimeVersion { unimplemented!() } fn execute_block(_: Block) { @@ -124,5 +124,5 @@ fn check_runtime_api_versions_contains() { fn check_runtime_api_versions() { check_runtime_api_versions_contains::>(); check_runtime_api_versions_contains::>(); - check_runtime_api_versions_contains::>(); + check_runtime_api_versions_contains::>(); } diff --git a/primitives/sr-api/test/tests/runtime_calls.rs b/primitives/sr-api/test/tests/runtime_calls.rs index 031d547819..3b09d67a2c 100644 --- a/primitives/sr-api/test/tests/runtime_calls.rs +++ b/primitives/sr-api/test/tests/runtime_calls.rs @@ -19,7 +19,7 @@ use test_client::{ DefaultTestClientBuilderExt, TestClientBuilder, runtime::{TestAPI, DecodeFails, Transfer, Header}, }; -use sr_primitives::{ +use sp_runtime::{ generic::BlockId, traits::{ProvideRuntimeApi, Header as HeaderT, Hash as HashT}, }; diff --git a/primitives/sr-api/test/tests/ui/adding_self_parameter.rs b/primitives/sr-api/test/tests/ui/adding_self_parameter.rs index 9195598b5a..117fa26188 100644 --- a/primitives/sr-api/test/tests/ui/adding_self_parameter.rs +++ b/primitives/sr-api/test/tests/ui/adding_self_parameter.rs @@ -1,4 +1,4 @@ -sr_api::decl_runtime_apis! { +sp_api::decl_runtime_apis! { pub trait Api { fn test(&self); } diff --git a/primitives/sr-api/test/tests/ui/changed_in_unknown_version.rs b/primitives/sr-api/test/tests/ui/changed_in_unknown_version.rs index 1fcb5d4be1..818b504860 100644 --- a/primitives/sr-api/test/tests/ui/changed_in_unknown_version.rs +++ b/primitives/sr-api/test/tests/ui/changed_in_unknown_version.rs @@ -1,4 +1,4 @@ -use sr_primitives::traits::GetNodeBlockType; +use sp_runtime::traits::GetNodeBlockType; use test_client::runtime::Block; /// The declaration of the `Runtime` type and the implementation of the `GetNodeBlockType` @@ -8,7 +8,7 @@ impl GetNodeBlockType for Runtime { type NodeBlock = Block; } -sr_api::decl_runtime_apis! { +sp_api::decl_runtime_apis! { pub trait Api { #[changed_in(2)] fn test(data: u64); diff --git a/primitives/sr-api/test/tests/ui/declaring_old_block.rs b/primitives/sr-api/test/tests/ui/declaring_old_block.rs index 962aae4506..ba98bf9bf6 100644 --- a/primitives/sr-api/test/tests/ui/declaring_old_block.rs +++ b/primitives/sr-api/test/tests/ui/declaring_old_block.rs @@ -1,6 +1,6 @@ -use sr_primitives::traits::Block as BlockT; +use sp_runtime::traits::Block as BlockT; -sr_api::decl_runtime_apis! { +sp_api::decl_runtime_apis! { pub trait Api { fn test(); } diff --git a/primitives/sr-api/test/tests/ui/declaring_old_block.stderr b/primitives/sr-api/test/tests/ui/declaring_old_block.stderr index e27294692b..373e669c78 100644 --- a/primitives/sr-api/test/tests/ui/declaring_old_block.stderr +++ b/primitives/sr-api/test/tests/ui/declaring_old_block.stderr @@ -10,10 +10,10 @@ error: `Block: BlockT` generic parameter will be added automatically by the `dec 4 | pub trait Api { | ^^^^^^ -warning: unused import: `sr_primitives::traits::Block as BlockT` +warning: unused import: `sp_runtime::traits::Block as BlockT` --> $DIR/declaring_old_block.rs:1:5 | -1 | use sr_primitives::traits::Block as BlockT; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 | use sp_runtime::traits::Block as BlockT; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(unused_imports)]` on by default diff --git a/primitives/sr-api/test/tests/ui/declaring_own_block_with_different_name.rs b/primitives/sr-api/test/tests/ui/declaring_own_block_with_different_name.rs index 9a47148256..67bb9cab10 100644 --- a/primitives/sr-api/test/tests/ui/declaring_own_block_with_different_name.rs +++ b/primitives/sr-api/test/tests/ui/declaring_own_block_with_different_name.rs @@ -1,6 +1,6 @@ -use sr_primitives::traits::Block as BlockT; +use sp_runtime::traits::Block as BlockT; -sr_api::decl_runtime_apis! { +sp_api::decl_runtime_apis! { pub trait Api { fn test(); } diff --git a/primitives/sr-api/test/tests/ui/declaring_own_block_with_different_name.stderr b/primitives/sr-api/test/tests/ui/declaring_own_block_with_different_name.stderr index 88359f19af..fe445b822d 100644 --- a/primitives/sr-api/test/tests/ui/declaring_own_block_with_different_name.stderr +++ b/primitives/sr-api/test/tests/ui/declaring_own_block_with_different_name.stderr @@ -4,10 +4,10 @@ error: `Block: BlockT` generic parameter will be added automatically by the `dec 4 | pub trait Api { | ^^^^^^ -warning: unused import: `sr_primitives::traits::Block as BlockT` +warning: unused import: `sp_runtime::traits::Block as BlockT` --> $DIR/declaring_own_block_with_different_name.rs:1:5 | -1 | use sr_primitives::traits::Block as BlockT; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 | use sp_runtime::traits::Block as BlockT; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(unused_imports)]` on by default diff --git a/primitives/sr-api/test/tests/ui/empty_impl_runtime_apis_call.rs b/primitives/sr-api/test/tests/ui/empty_impl_runtime_apis_call.rs index fee4e475e3..6275979de2 100644 --- a/primitives/sr-api/test/tests/ui/empty_impl_runtime_apis_call.rs +++ b/primitives/sr-api/test/tests/ui/empty_impl_runtime_apis_call.rs @@ -1,4 +1,4 @@ -use sr_primitives::traits::GetNodeBlockType; +use sp_runtime::traits::GetNodeBlockType; use test_client::runtime::Block; /// The declaration of the `Runtime` type and the implementation of the `GetNodeBlockType` @@ -8,12 +8,12 @@ impl GetNodeBlockType for Runtime { type NodeBlock = Block; } -sr_api::decl_runtime_apis! { +sp_api::decl_runtime_apis! { pub trait Api { fn test(data: u64); } } -sr_api::impl_runtime_apis! {} +sp_api::impl_runtime_apis! {} fn main() {} diff --git a/primitives/sr-api/test/tests/ui/empty_impl_runtime_apis_call.stderr b/primitives/sr-api/test/tests/ui/empty_impl_runtime_apis_call.stderr index e7bf3b8563..f927912879 100644 --- a/primitives/sr-api/test/tests/ui/empty_impl_runtime_apis_call.stderr +++ b/primitives/sr-api/test/tests/ui/empty_impl_runtime_apis_call.stderr @@ -1,5 +1,5 @@ error: No api implementation given! --> $DIR/empty_impl_runtime_apis_call.rs:17:1 | -17 | sr_api::impl_runtime_apis! {} +17 | sp_api::impl_runtime_apis! {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ in this macro invocation diff --git a/primitives/sr-api/test/tests/ui/impl_incorrect_method_signature.rs b/primitives/sr-api/test/tests/ui/impl_incorrect_method_signature.rs index 08c3ce8320..cdc1dacb6a 100644 --- a/primitives/sr-api/test/tests/ui/impl_incorrect_method_signature.rs +++ b/primitives/sr-api/test/tests/ui/impl_incorrect_method_signature.rs @@ -1,4 +1,4 @@ -use sr_primitives::traits::{GetNodeBlockType, Block as BlockT}; +use sp_runtime::traits::{GetNodeBlockType, Block as BlockT}; use test_client::runtime::Block; /// The declaration of the `Runtime` type and the implementation of the `GetNodeBlockType` @@ -8,18 +8,18 @@ impl GetNodeBlockType for Runtime { type NodeBlock = Block; } -sr_api::decl_runtime_apis! { +sp_api::decl_runtime_apis! { pub trait Api { fn test(data: u64); } } -sr_api::impl_runtime_apis! { +sp_api::impl_runtime_apis! { impl self::Api for Runtime { fn test(data: String) {} } - impl sr_api::Core for Runtime { + impl sp_api::Core for Runtime { fn version() -> runtime_api::RuntimeVersion { unimplemented!() } diff --git a/primitives/sr-api/test/tests/ui/impl_incorrect_method_signature.stderr b/primitives/sr-api/test/tests/ui/impl_incorrect_method_signature.stderr index 2bf8da343f..d55e686a11 100644 --- a/primitives/sr-api/test/tests/ui/impl_incorrect_method_signature.stderr +++ b/primitives/sr-api/test/tests/ui/impl_incorrect_method_signature.stderr @@ -19,14 +19,14 @@ error[E0053]: method `test` has an incompatible type for trait error[E0053]: method `Api_test_runtime_api_impl` has an incompatible type for trait --> $DIR/impl_incorrect_method_signature.rs:17:1 | -11 | / sr_api::decl_runtime_apis! { +11 | / sp_api::decl_runtime_apis! { 12 | | pub trait Api { 13 | | fn test(data: u64); 14 | | } 15 | | } | |_- type in trait 16 | -17 | sr_api::impl_runtime_apis! { +17 | sp_api::impl_runtime_apis! { | -^^^^^^^^^^^^^^^^^^^^^^^^^ | | | _expected u64, found struct `std::string::String` @@ -39,13 +39,13 @@ error[E0053]: method `Api_test_runtime_api_impl` has an incompatible type for tr 33 | | } | |_- in this macro invocation | - = note: expected type `fn(&RuntimeApiImpl, &sr_api_hidden_includes_DECL_RUNTIME_APIS::sr_api::BlockId, substrate_test_runtime::Extrinsic>>, sr_api_hidden_includes_DECL_RUNTIME_APIS::sr_api::ExecutionContext, std::option::Option, std::vec::Vec) -> std::result::Result, , substrate_test_runtime::Extrinsic>>>::Error>` - found type `fn(&RuntimeApiImpl, &sr_api_hidden_includes_DECL_RUNTIME_APIS::sr_api::BlockId, substrate_test_runtime::Extrinsic>>, sr_api_hidden_includes_DECL_RUNTIME_APIS::sr_api::ExecutionContext, std::option::Option, std::vec::Vec) -> std::result::Result, , substrate_test_runtime::Extrinsic>>>::Error>` + = note: expected type `fn(&RuntimeApiImpl, &sp_api_hidden_includes_DECL_RUNTIME_APIS::sp_api::BlockId, substrate_test_runtime::Extrinsic>>, sp_api_hidden_includes_DECL_RUNTIME_APIS::sp_api::ExecutionContext, std::option::Option, std::vec::Vec) -> std::result::Result, , substrate_test_runtime::Extrinsic>>>::Error>` + found type `fn(&RuntimeApiImpl, &sp_api_hidden_includes_DECL_RUNTIME_APIS::sp_api::BlockId, substrate_test_runtime::Extrinsic>>, sp_api_hidden_includes_DECL_RUNTIME_APIS::sp_api::ExecutionContext, std::option::Option, std::vec::Vec) -> std::result::Result, , substrate_test_runtime::Extrinsic>>>::Error>` error[E0308]: mismatched types --> $DIR/impl_incorrect_method_signature.rs:17:1 | -17 | / sr_api::impl_runtime_apis! { +17 | / sp_api::impl_runtime_apis! { 18 | | impl self::Api for Runtime { 19 | | fn test(data: String) {} 20 | | } diff --git a/primitives/sr-api/test/tests/ui/impl_two_traits_with_same_name.rs b/primitives/sr-api/test/tests/ui/impl_two_traits_with_same_name.rs index 6aee0ec6c2..4c3ee6b27d 100644 --- a/primitives/sr-api/test/tests/ui/impl_two_traits_with_same_name.rs +++ b/primitives/sr-api/test/tests/ui/impl_two_traits_with_same_name.rs @@ -1,4 +1,4 @@ -use sr_primitives::traits::GetNodeBlockType; +use sp_runtime::traits::GetNodeBlockType; use test_client::runtime::Block; /// The declaration of the `Runtime` type and the implementation of the `GetNodeBlockType` @@ -8,7 +8,7 @@ impl GetNodeBlockType for Runtime { type NodeBlock = Block; } -sr_api::decl_runtime_apis! { +sp_api::decl_runtime_apis! { pub trait Api { fn test(data: u64); } @@ -24,7 +24,7 @@ mod second { } } -sr_api::impl_runtime_apis! { +sp_api::impl_runtime_apis! { impl self::Api for Runtime { fn test(data: u64) {} } diff --git a/primitives/sr-api/test/tests/ui/impl_two_traits_with_same_name.stderr b/primitives/sr-api/test/tests/ui/impl_two_traits_with_same_name.stderr index 9aa38805b9..cc267aaee0 100644 --- a/primitives/sr-api/test/tests/ui/impl_two_traits_with_same_name.stderr +++ b/primitives/sr-api/test/tests/ui/impl_two_traits_with_same_name.stderr @@ -13,7 +13,7 @@ error: cannot find macro `decl_runtime_apis` in this scope error[E0425]: cannot find function `test2_call_api_at` in `second::runtime_decl_for_Api` --> $DIR/impl_two_traits_with_same_name.rs:27:1 | -27 | / sr_api::impl_runtime_apis! { +27 | / sp_api::impl_runtime_apis! { 28 | | impl self::Api for Runtime { 29 | | fn test(data: u64) {} 30 | | } @@ -28,7 +28,7 @@ error[E0425]: cannot find function `test2_call_api_at` in `second::runtime_decl_ error[E0425]: cannot find function `test2_native_call_generator` in `second::runtime_decl_for_Api` --> $DIR/impl_two_traits_with_same_name.rs:27:1 | -27 | / sr_api::impl_runtime_apis! { +27 | / sp_api::impl_runtime_apis! { 28 | | impl self::Api for Runtime { 29 | | fn test(data: u64) {} 30 | | } @@ -49,7 +49,7 @@ error[E0576]: cannot find method or associated constant `test2` in `second::runt error[E0603]: module `runtime_decl_for_Api` is private --> $DIR/impl_two_traits_with_same_name.rs:27:1 | -27 | / sr_api::impl_runtime_apis! { +27 | / sp_api::impl_runtime_apis! { 28 | | impl self::Api for Runtime { 29 | | fn test(data: u64) {} 30 | | } @@ -58,7 +58,7 @@ error[E0603]: module `runtime_decl_for_Api` is private 35 | | } | |_^ -error[E0119]: conflicting implementations of trait `runtime_decl_for_Api::Api, substrate_test_runtime::Extrinsic>>` for type `Runtime`: +error[E0119]: conflicting implementations of trait `runtime_decl_for_Api::Api, substrate_test_runtime::Extrinsic>>` for type `Runtime`: --> $DIR/impl_two_traits_with_same_name.rs:32:2 | 28 | impl self::Api for Runtime { @@ -67,7 +67,7 @@ error[E0119]: conflicting implementations of trait `runtime_decl_for_Api::Api for Runtime { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Runtime` -error[E0119]: conflicting implementations of trait `Api, substrate_test_runtime::Extrinsic>>` for type `RuntimeApiImpl<_>`: +error[E0119]: conflicting implementations of trait `Api, substrate_test_runtime::Extrinsic>>` for type `RuntimeApiImpl<_>`: --> $DIR/impl_two_traits_with_same_name.rs:32:2 | 28 | impl self::Api for Runtime { diff --git a/primitives/sr-api/test/tests/ui/invalid_api_version.rs b/primitives/sr-api/test/tests/ui/invalid_api_version.rs index 0b7f5e88ff..e038dd0aa6 100644 --- a/primitives/sr-api/test/tests/ui/invalid_api_version.rs +++ b/primitives/sr-api/test/tests/ui/invalid_api_version.rs @@ -1,4 +1,4 @@ -sr_api::decl_runtime_apis! { +sp_api::decl_runtime_apis! { #[api_version] pub trait Api { fn test(data: u64); diff --git a/primitives/sr-api/test/tests/ui/invalid_api_version.stderr b/primitives/sr-api/test/tests/ui/invalid_api_version.stderr index 7e63eb8ebf..6d0bb8d9f3 100644 --- a/primitives/sr-api/test/tests/ui/invalid_api_version.stderr +++ b/primitives/sr-api/test/tests/ui/invalid_api_version.stderr @@ -1,7 +1,7 @@ error: can't qualify macro invocation with `pub` --> $DIR/invalid_api_version.rs:1:1 | -1 | / sr_api::decl_runtime_apis! { +1 | / sp_api::decl_runtime_apis! { 2 | | #[api_version] 3 | | pub trait Api { 4 | | fn test(data: u64); @@ -16,7 +16,7 @@ error: can't qualify macro invocation with `pub` error: Unexpected `api_version` attribute. The supported format is `api_version(1)` --> $DIR/invalid_api_version.rs:1:1 | -1 | / sr_api::decl_runtime_apis! { +1 | / sp_api::decl_runtime_apis! { 2 | | #[api_version] 3 | | pub trait Api { 4 | | fn test(data: u64); diff --git a/primitives/sr-api/test/tests/ui/invalid_api_version_2.rs b/primitives/sr-api/test/tests/ui/invalid_api_version_2.rs index 4e29d36e1b..bb8ed8ed11 100644 --- a/primitives/sr-api/test/tests/ui/invalid_api_version_2.rs +++ b/primitives/sr-api/test/tests/ui/invalid_api_version_2.rs @@ -1,4 +1,4 @@ -sr_api::decl_runtime_apis! { +sp_api::decl_runtime_apis! { #[api_version("1")] pub trait Api { fn test(data: u64); diff --git a/primitives/sr-api/test/tests/ui/invalid_api_version_2.stderr b/primitives/sr-api/test/tests/ui/invalid_api_version_2.stderr index e080b2dd1a..60d33bff41 100644 --- a/primitives/sr-api/test/tests/ui/invalid_api_version_2.stderr +++ b/primitives/sr-api/test/tests/ui/invalid_api_version_2.stderr @@ -1,7 +1,7 @@ error: can't qualify macro invocation with `pub` --> $DIR/invalid_api_version_2.rs:1:1 | -1 | / sr_api::decl_runtime_apis! { +1 | / sp_api::decl_runtime_apis! { 2 | | #[api_version("1")] 3 | | pub trait Api { 4 | | fn test(data: u64); @@ -16,7 +16,7 @@ error: can't qualify macro invocation with `pub` error: Unexpected `api_version` attribute. The supported format is `api_version(1)` --> $DIR/invalid_api_version_2.rs:1:1 | -1 | / sr_api::decl_runtime_apis! { +1 | / sp_api::decl_runtime_apis! { 2 | | #[api_version("1")] 3 | | pub trait Api { 4 | | fn test(data: u64); diff --git a/primitives/sr-api/test/tests/ui/invalid_api_version_3.rs b/primitives/sr-api/test/tests/ui/invalid_api_version_3.rs index bafe566840..d010866e23 100644 --- a/primitives/sr-api/test/tests/ui/invalid_api_version_3.rs +++ b/primitives/sr-api/test/tests/ui/invalid_api_version_3.rs @@ -1,4 +1,4 @@ -sr_api::decl_runtime_apis! { +sp_api::decl_runtime_apis! { #[api_version()] pub trait Api { fn test(data: u64); diff --git a/primitives/sr-api/test/tests/ui/invalid_api_version_3.stderr b/primitives/sr-api/test/tests/ui/invalid_api_version_3.stderr index fd6e15852f..c2b64657ff 100644 --- a/primitives/sr-api/test/tests/ui/invalid_api_version_3.stderr +++ b/primitives/sr-api/test/tests/ui/invalid_api_version_3.stderr @@ -1,7 +1,7 @@ error: can't qualify macro invocation with `pub` --> $DIR/invalid_api_version_3.rs:1:1 | -1 | / sr_api::decl_runtime_apis! { +1 | / sp_api::decl_runtime_apis! { 2 | | #[api_version()] 3 | | pub trait Api { 4 | | fn test(data: u64); @@ -16,7 +16,7 @@ error: can't qualify macro invocation with `pub` error: Unexpected `api_version` attribute. The supported format is `api_version(1)` --> $DIR/invalid_api_version_3.rs:1:1 | -1 | / sr_api::decl_runtime_apis! { +1 | / sp_api::decl_runtime_apis! { 2 | | #[api_version()] 3 | | pub trait Api { 4 | | fn test(data: u64); diff --git a/primitives/sr-api/test/tests/ui/missing_block_generic_parameter.rs b/primitives/sr-api/test/tests/ui/missing_block_generic_parameter.rs index d35253a721..4639ae328c 100644 --- a/primitives/sr-api/test/tests/ui/missing_block_generic_parameter.rs +++ b/primitives/sr-api/test/tests/ui/missing_block_generic_parameter.rs @@ -1,4 +1,4 @@ -use sr_primitives::traits::GetNodeBlockType; +use sp_runtime::traits::GetNodeBlockType; use test_client::runtime::Block; /// The declaration of the `Runtime` type and the implementation of the `GetNodeBlockType` @@ -8,13 +8,13 @@ impl GetNodeBlockType for Runtime { type NodeBlock = Block; } -sr_api::decl_runtime_apis! { +sp_api::decl_runtime_apis! { pub trait Api { fn test(data: u64); } } -sr_api::impl_runtime_apis! { +sp_api::impl_runtime_apis! { impl self::Api for Runtime { fn test(data: u64) { unimplemented!() diff --git a/primitives/sr-api/test/tests/ui/missing_path_for_trait.rs b/primitives/sr-api/test/tests/ui/missing_path_for_trait.rs index fb78374ebd..d90756ce1b 100644 --- a/primitives/sr-api/test/tests/ui/missing_path_for_trait.rs +++ b/primitives/sr-api/test/tests/ui/missing_path_for_trait.rs @@ -1,4 +1,4 @@ -use sr_primitives::traits::GetNodeBlockType; +use sp_runtime::traits::GetNodeBlockType; use test_client::runtime::Block; /// The declaration of the `Runtime` type and the implementation of the `GetNodeBlockType` @@ -8,13 +8,13 @@ impl GetNodeBlockType for Runtime { type NodeBlock = Block; } -sr_api::decl_runtime_apis! { +sp_api::decl_runtime_apis! { pub trait Api { fn test(data: u64); } } -sr_api::impl_runtime_apis! { +sp_api::impl_runtime_apis! { impl Api for Runtime { fn test(data: u64) { unimplemented!() diff --git a/primitives/sr-api/test/tests/ui/type_reference_in_impl_runtime_apis_call.rs b/primitives/sr-api/test/tests/ui/type_reference_in_impl_runtime_apis_call.rs index 41bbd8a9ee..809444cb30 100644 --- a/primitives/sr-api/test/tests/ui/type_reference_in_impl_runtime_apis_call.rs +++ b/primitives/sr-api/test/tests/ui/type_reference_in_impl_runtime_apis_call.rs @@ -1,4 +1,4 @@ -use sr_primitives::traits::{GetNodeBlockType, Block as BlockT}; +use sp_runtime::traits::{GetNodeBlockType, Block as BlockT}; use test_client::runtime::Block; /// The declaration of the `Runtime` type and the implementation of the `GetNodeBlockType` @@ -8,20 +8,20 @@ impl GetNodeBlockType for Runtime { type NodeBlock = Block; } -sr_api::decl_runtime_apis! { +sp_api::decl_runtime_apis! { pub trait Api { fn test(data: u64); } } -sr_api::impl_runtime_apis! { +sp_api::impl_runtime_apis! { impl self::Api for Runtime { fn test(data: &u64) { unimplemented!() } } - impl sr_api::Core for Runtime { + impl sp_api::Core for Runtime { fn version() -> runtime_api::RuntimeVersion { unimplemented!() } diff --git a/primitives/sr-api/test/tests/ui/type_reference_in_impl_runtime_apis_call.stderr b/primitives/sr-api/test/tests/ui/type_reference_in_impl_runtime_apis_call.stderr index 4614fe89b8..5129bb6c15 100644 --- a/primitives/sr-api/test/tests/ui/type_reference_in_impl_runtime_apis_call.stderr +++ b/primitives/sr-api/test/tests/ui/type_reference_in_impl_runtime_apis_call.stderr @@ -19,14 +19,14 @@ error[E0053]: method `test` has an incompatible type for trait error[E0053]: method `Api_test_runtime_api_impl` has an incompatible type for trait --> $DIR/type_reference_in_impl_runtime_apis_call.rs:17:1 | -11 | / sr_api::decl_runtime_apis! { +11 | / sp_api::decl_runtime_apis! { 12 | | pub trait Api { 13 | | fn test(data: u64); 14 | | } 15 | | } | |_- type in trait 16 | -17 | sr_api::impl_runtime_apis! { +17 | sp_api::impl_runtime_apis! { | -^^^^^^^^^^^^^^^^^^^^^^^^^ | | | _expected u64, found &u64 @@ -39,13 +39,13 @@ error[E0053]: method `Api_test_runtime_api_impl` has an incompatible type for tr 35 | | } | |_- in this macro invocation | - = note: expected type `fn(&RuntimeApiImpl, &sr_api_hidden_includes_DECL_RUNTIME_APIS::sr_api::BlockId, substrate_test_runtime::Extrinsic>>, sr_api_hidden_includes_DECL_RUNTIME_APIS::sr_api::ExecutionContext, std::option::Option, std::vec::Vec) -> std::result::Result, , substrate_test_runtime::Extrinsic>>>::Error>` - found type `fn(&RuntimeApiImpl, &sr_api_hidden_includes_DECL_RUNTIME_APIS::sr_api::BlockId, substrate_test_runtime::Extrinsic>>, sr_api_hidden_includes_DECL_RUNTIME_APIS::sr_api::ExecutionContext, std::option::Option<&u64>, std::vec::Vec) -> std::result::Result, , substrate_test_runtime::Extrinsic>>>::Error>` + = note: expected type `fn(&RuntimeApiImpl, &sp_api_hidden_includes_DECL_RUNTIME_APIS::sp_api::BlockId, substrate_test_runtime::Extrinsic>>, sp_api_hidden_includes_DECL_RUNTIME_APIS::sp_api::ExecutionContext, std::option::Option, std::vec::Vec) -> std::result::Result, , substrate_test_runtime::Extrinsic>>>::Error>` + found type `fn(&RuntimeApiImpl, &sp_api_hidden_includes_DECL_RUNTIME_APIS::sp_api::BlockId, substrate_test_runtime::Extrinsic>>, sp_api_hidden_includes_DECL_RUNTIME_APIS::sp_api::ExecutionContext, std::option::Option<&u64>, std::vec::Vec) -> std::result::Result, , substrate_test_runtime::Extrinsic>>>::Error>` error[E0308]: mismatched types --> $DIR/type_reference_in_impl_runtime_apis_call.rs:17:1 | -17 | / sr_api::impl_runtime_apis! { +17 | / sp_api::impl_runtime_apis! { 18 | | impl self::Api for Runtime { 19 | | fn test(data: &u64) { 20 | | unimplemented!() diff --git a/primitives/sr-arithmetic/Cargo.toml b/primitives/sr-arithmetic/Cargo.toml index 47b3315e86..84137a8f5a 100644 --- a/primitives/sr-arithmetic/Cargo.toml +++ b/primitives/sr-arithmetic/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "sr-arithmetic" +name = "sp-arithmetic" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" @@ -8,9 +8,9 @@ edition = "2018" codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } integer-sqrt = "0.1.2" num-traits = { version = "0.2.8", default-features = false } -rstd = { package = "sr-std", path = "../sr-std", default-features = false } +rstd = { package = "sp-std", path = "../sr-std", default-features = false } serde = { version = "1.0.101", optional = true, features = ["derive"] } -substrate-debug-derive = { path = "../../primitives/core/debug-derive", default-features = false } +sp-debug-derive = { path = "../../primitives/core/debug-derive", default-features = false } [dev-dependencies] primitive-types = "0.6.0" @@ -24,7 +24,7 @@ std = [ "num-traits/std", "rstd/std", "serde", - "substrate-debug-derive/std", + "sp-debug-derive/std", ] [[bench]] diff --git a/primitives/sr-arithmetic/benches/bench.rs b/primitives/sr-arithmetic/benches/bench.rs index 22c0ce6f56..ea6a2d2fd8 100644 --- a/primitives/sr-arithmetic/benches/bench.rs +++ b/primitives/sr-arithmetic/benches/bench.rs @@ -15,7 +15,7 @@ // along with Substrate. If not, see . use criterion::{Criterion, Throughput, BenchmarkId, criterion_group, criterion_main}; -use sr_arithmetic::biguint::{BigUint, Single}; +use sp_arithmetic::biguint::{BigUint, Single}; use rand::Rng; fn random_big_uint(size: usize) -> BigUint { diff --git a/primitives/sr-arithmetic/fuzzer/Cargo.toml b/primitives/sr-arithmetic/fuzzer/Cargo.toml index 482905c435..6784349394 100644 --- a/primitives/sr-arithmetic/fuzzer/Cargo.toml +++ b/primitives/sr-arithmetic/fuzzer/Cargo.toml @@ -1,11 +1,11 @@ [package] -name = "sr-arithmetic-fuzzer" +name = "sp-arithmetic-fuzzer" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" [dependencies] -sr-arithmetic = { path = ".." } +sp-arithmetic = { path = ".." } honggfuzz = "0.5" primitive-types = "0.6" num-bigint = "0.2" diff --git a/primitives/sr-arithmetic/fuzzer/src/biguint.rs b/primitives/sr-arithmetic/fuzzer/src/biguint.rs index bd270a97ca..c3dbe81212 100644 --- a/primitives/sr-arithmetic/fuzzer/src/biguint.rs +++ b/primitives/sr-arithmetic/fuzzer/src/biguint.rs @@ -27,7 +27,7 @@ //! [here](https://docs.rs/honggfuzz/). use honggfuzz::fuzz; -use sr_arithmetic::biguint::{BigUint, Single}; +use sp_arithmetic::biguint::{BigUint, Single}; use std::convert::TryFrom; fn main() { diff --git a/primitives/sr-arithmetic/fuzzer/src/rational128.rs b/primitives/sr-arithmetic/fuzzer/src/rational128.rs index b2a00d7545..f32caa9010 100644 --- a/primitives/sr-arithmetic/fuzzer/src/rational128.rs +++ b/primitives/sr-arithmetic/fuzzer/src/rational128.rs @@ -27,7 +27,7 @@ //! [here](https://docs.rs/honggfuzz/). use honggfuzz::fuzz; -use sr_arithmetic::{helpers_128bit::multiply_by_rational, traits::Zero}; +use sp_arithmetic::{helpers_128bit::multiply_by_rational, traits::Zero}; fn main() { loop { diff --git a/primitives/sr-arithmetic/src/lib.rs b/primitives/sr-arithmetic/src/lib.rs index 7b285002e5..fc1d75ae96 100644 --- a/primitives/sr-arithmetic/src/lib.rs +++ b/primitives/sr-arithmetic/src/lib.rs @@ -18,7 +18,7 @@ #![cfg_attr(not(feature = "std"), no_std)] -/// Copied from `sr-primitives` and documented there. +/// Copied from `sp-runtime` and documented there. #[cfg(test)] macro_rules! assert_eq_error_rate { ($x:expr, $y:expr, $error:expr $(,)?) => { diff --git a/primitives/sr-arithmetic/src/per_things.rs b/primitives/sr-arithmetic/src/per_things.rs index 2dd1e62d0b..ed63039c85 100644 --- a/primitives/sr-arithmetic/src/per_things.rs +++ b/primitives/sr-arithmetic/src/per_things.rs @@ -20,7 +20,7 @@ use serde::{Serialize, Deserialize}; use rstd::{ops, prelude::*, convert::TryInto}; use codec::{Encode, Decode, CompactAs}; use crate::traits::{SaturatedConversion, UniqueSaturatedInto, Saturating}; -use substrate_debug_derive::RuntimeDebug; +use sp_debug_derive::RuntimeDebug; macro_rules! implement_per_thing { ($name:ident, $test_mod:ident, [$($test_units:tt),+], $max:tt, $type:ty, $upper_type:ty, $title:expr $(,)?) => { diff --git a/primitives/sr-arithmetic/src/rational128.rs b/primitives/sr-arithmetic/src/rational128.rs index 3247321199..124d685a4f 100644 --- a/primitives/sr-arithmetic/src/rational128.rs +++ b/primitives/sr-arithmetic/src/rational128.rs @@ -17,7 +17,7 @@ use rstd::{cmp::Ordering, prelude::*}; use crate::helpers_128bit; use num_traits::Zero; -use substrate_debug_derive::RuntimeDebug; +use sp_debug_derive::RuntimeDebug; /// A wrapper for any rational number with a 128 bit numerator and denominator. #[derive(Clone, Copy, Default, Eq, RuntimeDebug)] diff --git a/primitives/sr-io/Cargo.toml b/primitives/sr-io/Cargo.toml index 52e175d2b8..79d25f2d96 100644 --- a/primitives/sr-io/Cargo.toml +++ b/primitives/sr-io/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "sr-io" +name = "sp-io" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" @@ -7,13 +7,13 @@ edition = "2018" [dependencies] codec = { package = "parity-scale-codec", version = "1.0.6", default-features = false } hash-db = { version = "0.15.2", default-features = false } -primitives = { package = "substrate-primitives", path = "../core", default-features = false } -rstd = { package = "sr-std", path = "../sr-std", default-features = false } +primitives = { package = "sp-core", path = "../core", default-features = false } +rstd = { package = "sp-std", path = "../sr-std", default-features = false } libsecp256k1 = { version = "0.3.0", optional = true } -substrate-state-machine = { path = "../../primitives/state-machine", optional = true } -runtime-interface = { package = "substrate-runtime-interface", path = "../runtime-interface", default-features = false } -trie = { package = "substrate-trie", path = "../../primitives/trie", optional = true } -externalities = { package = "substrate-externalities", path = "../externalities", optional = true } +sp-state-machine = { path = "../../primitives/state-machine", optional = true } +runtime-interface = { package = "sp-runtime-interface", path = "../runtime-interface", default-features = false } +trie = { package = "sp-trie", path = "../../primitives/trie", optional = true } +externalities = { package = "sp-externalities", path = "../externalities", optional = true } log = { version = "0.4.8", optional = true } [features] @@ -24,7 +24,7 @@ std = [ "rstd/std", "hash-db/std", "trie", - "substrate-state-machine", + "sp-state-machine", "libsecp256k1", "runtime-interface/std", "externalities", diff --git a/primitives/sr-io/src/lib.rs b/primitives/sr-io/src/lib.rs index 40d52db98b..d4b654ab29 100644 --- a/primitives/sr-io/src/lib.rs +++ b/primitives/sr-io/src/lib.rs @@ -781,7 +781,7 @@ pub extern fn oom(_: core::alloc::Layout) -> ! { /// Type alias for Externalities implementation used in tests. #[cfg(feature = "std")] -pub type TestExternalities = substrate_state_machine::TestExternalities; +pub type TestExternalities = sp_state_machine::TestExternalities; /// The host functions Substrate provides for the Wasm runtime environment. /// @@ -803,7 +803,7 @@ pub type SubstrateHostFunctions = ( mod tests { use super::*; use primitives::map; - use substrate_state_machine::BasicExternalities; + use sp_state_machine::BasicExternalities; #[test] fn storage_works() { diff --git a/primitives/sr-primitives/Cargo.toml b/primitives/sr-primitives/Cargo.toml index bd709c68bd..bfec26f0cc 100644 --- a/primitives/sr-primitives/Cargo.toml +++ b/primitives/sr-primitives/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "sr-primitives" +name = "sp-runtime" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" @@ -7,16 +7,16 @@ edition = "2018" [dependencies] serde = { version = "1.0.101", optional = true, features = ["derive"] } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -primitives = { package = "substrate-primitives", path = "../core", default-features = false } -app-crypto = { package = "substrate-application-crypto", path = "../application-crypto", default-features = false } -arithmetic = { package = "sr-arithmetic", path = "../sr-arithmetic", default-features = false } -rstd = { package = "sr-std", path = "../sr-std", default-features = false } -runtime_io = { package = "sr-io", path = "../sr-io", default-features = false } +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 } +rstd = { package = "sp-std", path = "../sr-std", default-features = false } +runtime_io = { package = "sp-io", path = "../sr-io", default-features = false } log = { version = "0.4.8", optional = true } paste = "0.1.6" rand = { version = "0.7.2", optional = true } impl-trait-for-tuples = "0.1.3" -inherents = { package = "substrate-inherents", path = "../inherents", default-features = false } +inherents = { package = "sp-inherents", path = "../inherents", default-features = false } [dev-dependencies] serde_json = "1.0.41" diff --git a/primitives/sr-primitives/src/lib.rs b/primitives/sr-primitives/src/lib.rs index 1bbf5ad55a..20fdd083db 100644 --- a/primitives/sr-primitives/src/lib.rs +++ b/primitives/sr-primitives/src/lib.rs @@ -583,15 +583,15 @@ macro_rules! impl_outer_config { /// /// ```rust /// # fn main() { -/// sr_primitives::assert_eq_error_rate!(10, 10, 0); -/// sr_primitives::assert_eq_error_rate!(10, 11, 1); -/// sr_primitives::assert_eq_error_rate!(12, 10, 2); +/// sp_runtime::assert_eq_error_rate!(10, 10, 0); +/// sp_runtime::assert_eq_error_rate!(10, 11, 1); +/// sp_runtime::assert_eq_error_rate!(12, 10, 2); /// # } /// ``` /// /// ```rust,should_panic /// # fn main() { -/// sr_primitives::assert_eq_error_rate!(12, 10, 1); +/// sp_runtime::assert_eq_error_rate!(12, 10, 1); /// # } /// ``` #[macro_export] diff --git a/primitives/sr-primitives/src/offchain/http.rs b/primitives/sr-primitives/src/offchain/http.rs index 50d536fc14..88df90893b 100644 --- a/primitives/sr-primitives/src/offchain/http.rs +++ b/primitives/sr-primitives/src/offchain/http.rs @@ -16,7 +16,7 @@ //! A high-level helpers for making HTTP requests from Offchain Workers. //! -//! `sr-io` crate exposes a low level methods to make and control HTTP requests +//! `sp-io` crate exposes a low level methods to make and control HTTP requests //! available only for Offchain Workers. Those might be hard to use //! and usually that level of control is not really necessary. //! This module aims to provide high-level wrappers for those APIs @@ -25,7 +25,7 @@ //! //! Example: //! ```rust,no_run -//! use sr_primitives::offchain::http::Request; +//! use sp_runtime::offchain::http::Request; //! //! // initiate a GET request to localhost:1234 //! let request: Request = Request::get("http://localhost:1234"); diff --git a/primitives/sr-primitives/src/random_number_generator.rs b/primitives/sr-primitives/src/random_number_generator.rs index cb9acfa028..487d3b9527 100644 --- a/primitives/sr-primitives/src/random_number_generator.rs +++ b/primitives/sr-primitives/src/random_number_generator.rs @@ -28,8 +28,8 @@ use crate::traits::{Hash, TrailingZeroInput}; /// /// Example: /// ``` -/// use sr_primitives::traits::{Hash, BlakeTwo256}; -/// use sr_primitives::RandomNumberGenerator; +/// use sp_runtime::traits::{Hash, BlakeTwo256}; +/// use sp_runtime::RandomNumberGenerator; /// let random_seed = BlakeTwo256::hash(b"Sixty-nine"); /// let mut rng = >::new(random_seed); /// assert_eq!(rng.pick_u32(100), 59); diff --git a/primitives/sr-primitives/src/traits.rs b/primitives/sr-primitives/src/traits.rs index 7c6a88acc2..e3b06b2260 100644 --- a/primitives/sr-primitives/src/traits.rs +++ b/primitives/sr-primitives/src/traits.rs @@ -1112,7 +1112,7 @@ macro_rules! count { /// `KeyTypeIdProviders` is set to the types given as fields. /// /// ```rust -/// use sr_primitives::{ +/// use sp_runtime::{ /// impl_opaque_keys, KeyTypeId, BoundToRuntimeAppPublic, app_crypto::{sr25519, ed25519} /// }; /// diff --git a/primitives/sr-sandbox/Cargo.toml b/primitives/sr-sandbox/Cargo.toml index 97d391d794..0380f5b591 100755 --- a/primitives/sr-sandbox/Cargo.toml +++ b/primitives/sr-sandbox/Cargo.toml @@ -1,14 +1,14 @@ [package] -name = "sr-sandbox" +name = "sp-sandbox" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" [dependencies] wasmi = { version = "0.6.2", optional = true } -primitives = { package = "substrate-primitives", path = "../core", default-features = false } -rstd = { package = "sr-std", path = "../sr-std", default-features = false } -runtime-io = { package = "sr-io", path = "../sr-io", default-features = false } +primitives = { package = "sp-core", path = "../core", default-features = false } +rstd = { package = "sp-std", path = "../sr-std", default-features = false } +runtime-io = { package = "sp-io", path = "../sr-io", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } [dev-dependencies] diff --git a/primitives/sr-staking-primitives/Cargo.toml b/primitives/sr-staking-primitives/Cargo.toml index 25e8f4ccf1..527364cfd0 100644 --- a/primitives/sr-staking-primitives/Cargo.toml +++ b/primitives/sr-staking-primitives/Cargo.toml @@ -1,18 +1,18 @@ [package] -name = "sr-staking-primitives" +name = "sp-staking" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" [dependencies] codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sr-primitives = { path = "../sr-primitives", default-features = false } -rstd = { package = "sr-std", path = "../sr-std", default-features = false } +sp-runtime = { path = "../sr-primitives", default-features = false } +rstd = { package = "sp-std", path = "../sr-std", default-features = false } [features] default = ["std"] std = [ "codec/std", - "sr-primitives/std", + "sp-runtime/std", "rstd/std", ] diff --git a/primitives/sr-staking-primitives/src/offence.rs b/primitives/sr-staking-primitives/src/offence.rs index 04d887fbe0..9a3eb1bbfe 100644 --- a/primitives/sr-staking-primitives/src/offence.rs +++ b/primitives/sr-staking-primitives/src/offence.rs @@ -20,7 +20,7 @@ use rstd::vec::Vec; use codec::{Encode, Decode}; -use sr_primitives::Perbill; +use sp_runtime::Perbill; use crate::SessionIndex; @@ -135,7 +135,7 @@ impl OnOffenceHandler for () { } /// A details about an offending authority for a particular kind of offence. -#[derive(Clone, PartialEq, Eq, Encode, Decode, sr_primitives::RuntimeDebug)] +#[derive(Clone, PartialEq, Eq, Encode, Decode, sp_runtime::RuntimeDebug)] pub struct OffenceDetails { /// The offending authority id pub offender: Offender, diff --git a/primitives/sr-std/Cargo.toml b/primitives/sr-std/Cargo.toml index 77021af935..7fdf7d1144 100644 --- a/primitives/sr-std/Cargo.toml +++ b/primitives/sr-std/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "sr-std" +name = "sp-std" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" diff --git a/primitives/sr-std/src/lib.rs b/primitives/sr-std/src/lib.rs index 5aa8e82235..18533e041b 100644 --- a/primitives/sr-std/src/lib.rs +++ b/primitives/sr-std/src/lib.rs @@ -37,7 +37,7 @@ macro_rules! map { /// # Example /// /// ``` -/// use sr_std::if_std; +/// use sp_std::if_std; /// /// if_std! { /// // This code is only being compiled and executed when the `std` feature is enabled. diff --git a/primitives/sr-version/Cargo.toml b/primitives/sr-version/Cargo.toml index 5be3048f82..a26487bfca 100644 --- a/primitives/sr-version/Cargo.toml +++ b/primitives/sr-version/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "sr-version" +name = "sp-version" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" @@ -8,8 +8,8 @@ edition = "2018" impl-serde = { version = "0.2.3", optional = true } serde = { version = "1.0.101", optional = true, features = ["derive"] } codec = { package = "parity-scale-codec", version = "1.0.5", default-features = false, features = ["derive"] } -rstd = { package = "sr-std", path = "../sr-std", default-features = false } -sr-primitives = { path = "../sr-primitives", default-features = false } +rstd = { package = "sp-std", path = "../sr-std", default-features = false } +sp-runtime = { path = "../sr-primitives", default-features = false } [features] default = ["std"] @@ -18,5 +18,5 @@ std = [ "serde", "codec/std", "rstd/std", - "sr-primitives/std", + "sp-runtime/std", ] diff --git a/primitives/sr-version/src/lib.rs b/primitives/sr-version/src/lib.rs index d7d829bd4b..9b9a311c08 100644 --- a/primitives/sr-version/src/lib.rs +++ b/primitives/sr-version/src/lib.rs @@ -25,16 +25,16 @@ use std::fmt; #[cfg(feature = "std")] use std::collections::HashSet; #[cfg(feature = "std")] -use sr_primitives::traits::RuntimeApiInfo; +use sp_runtime::traits::RuntimeApiInfo; use codec::Encode; #[cfg(feature = "std")] use codec::Decode; -use sr_primitives::RuntimeString; -pub use sr_primitives::create_runtime_str; +use sp_runtime::RuntimeString; +pub use sp_runtime::create_runtime_str; #[cfg(feature = "std")] -use sr_primitives::{traits::Block as BlockT, generic::BlockId}; +use sp_runtime::{traits::Block as BlockT, generic::BlockId}; /// The identity of a particular API interface that the runtime might provide. pub type ApiId = [u8; 8]; @@ -65,7 +65,7 @@ macro_rules! create_apis_vec { /// This triplet have different semantics and mis-interpretation could cause problems. /// In particular: bug fixes should result in an increment of `spec_version` and possibly `authoring_version`, /// absolutely not `impl_version` since they change the semantics of the runtime. -#[derive(Clone, PartialEq, Eq, Encode, Default, sr_primitives::RuntimeDebug)] +#[derive(Clone, PartialEq, Eq, Encode, Default, sp_runtime::RuntimeDebug)] #[cfg_attr(feature = "std", derive(Serialize, Deserialize, Decode))] #[cfg_attr(feature = "std", serde(rename_all = "camelCase"))] pub struct RuntimeVersion { diff --git a/primitives/state-machine/Cargo.toml b/primitives/state-machine/Cargo.toml index 36557803e1..cd721c17fd 100644 --- a/primitives/state-machine/Cargo.toml +++ b/primitives/state-machine/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "substrate-state-machine" +name = "sp-state-machine" version = "2.0.0" authors = ["Parity Technologies "] description = "Substrate State Machine" @@ -11,13 +11,13 @@ parking_lot = "0.9.0" hash-db = "0.15.2" trie-db = "0.16.0" trie-root = "0.15.2" -trie = { package = "substrate-trie", path = "../trie" } -primitives = { package = "substrate-primitives", path = "../core" } -panic-handler = { package = "substrate-panic-handler", path = "../panic-handler" } +trie = { package = "sp-trie", path = "../trie" } +primitives = { package = "sp-core", path = "../core" } +panic-handler = { package = "sp-panic-handler", path = "../panic-handler" } codec = { package = "parity-scale-codec", version = "1.0.0" } num-traits = "0.2.8" rand = "0.7.2" -externalities = { package = "substrate-externalities", path = "../externalities" } +externalities = { package = "sp-externalities", path = "../externalities" } [dev-dependencies] hex-literal = "0.2.1" diff --git a/primitives/timestamp/Cargo.toml b/primitives/timestamp/Cargo.toml index 013a0340ea..a41307fde9 100644 --- a/primitives/timestamp/Cargo.toml +++ b/primitives/timestamp/Cargo.toml @@ -5,19 +5,19 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -sr-api = { path = "../sr-api", default-features = false } -rstd = { package = "sr-std", path = "../sr-std", default-features = false } -sr-primitives = { path = "../sr-primitives", default-features = false } +sp-api = { path = "../sr-api", default-features = false } +rstd = { package = "sp-std", path = "../sr-std", default-features = false } +sp-runtime = { path = "../sr-primitives", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -inherents = { package = "substrate-inherents", path = "../inherents", default-features = false } +inherents = { package = "sp-inherents", path = "../inherents", default-features = false } impl-trait-for-tuples = "0.1.3" [features] default = [ "std" ] std = [ - "sr-api/std", + "sp-api/std", "rstd/std", - "sr-primitives/std", + "sp-runtime/std", "codec/std", "inherents/std", ] diff --git a/primitives/timestamp/src/lib.rs b/primitives/timestamp/src/lib.rs index 028f44f378..6b20e11ef4 100644 --- a/primitives/timestamp/src/lib.rs +++ b/primitives/timestamp/src/lib.rs @@ -25,7 +25,7 @@ use codec::Decode; use inherents::ProvideInherentData; use inherents::{InherentIdentifier, IsFatalError, InherentData}; -use sr_primitives::RuntimeString; +use sp_runtime::RuntimeString; /// The identifier for the `timestamp` inherent. pub const INHERENT_IDENTIFIER: InherentIdentifier = *b"timstap0"; @@ -33,7 +33,7 @@ pub const INHERENT_IDENTIFIER: InherentIdentifier = *b"timstap0"; pub type InherentType = u64; /// Errors that can occur while checking the timestamp inherent. -#[derive(Encode, sr_primitives::RuntimeDebug)] +#[derive(Encode, sp_runtime::RuntimeDebug)] #[cfg_attr(feature = "std", derive(Decode))] pub enum InherentError { /// The timestamp is valid in the future. diff --git a/primitives/transaction-pool/Cargo.toml b/primitives/transaction-pool/Cargo.toml index ce20c8acec..ce723fd61e 100644 --- a/primitives/transaction-pool/Cargo.toml +++ b/primitives/transaction-pool/Cargo.toml @@ -10,5 +10,5 @@ futures = "0.3.1" log = "0.4.8" serde = { version = "1.0.101", features = ["derive"] } codec = { package = "parity-scale-codec", version = "1.0.0" } -primitives = { package = "substrate-primitives", path = "../core" } -sr-primitives = { path = "../sr-primitives" } +primitives = { package = "sp-core", path = "../core" } +sp-runtime = { path = "../sr-primitives" } diff --git a/primitives/transaction-pool/runtime-api/Cargo.toml b/primitives/transaction-pool/runtime-api/Cargo.toml index 2a1014989d..4da08fbc7c 100644 --- a/primitives/transaction-pool/runtime-api/Cargo.toml +++ b/primitives/transaction-pool/runtime-api/Cargo.toml @@ -5,10 +5,10 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -primitives = { package = "substrate-primitives", path = "../../core", default-features = false } -sr-api = { path = "../../sr-api", default-features = false } -sr-primitives = { path = "../../sr-primitives", default-features = false } +primitives = { package = "sp-core", path = "../../core", default-features = false } +sp-api = { path = "../../sr-api", default-features = false } +sp-runtime = { path = "../../sr-primitives", default-features = false } [features] default = [ "std" ] -std = [ "sr-primitives/std", "primitives/std", "sr-api/std" ] +std = [ "sp-runtime/std", "primitives/std", "sp-api/std" ] diff --git a/primitives/transaction-pool/runtime-api/src/lib.rs b/primitives/transaction-pool/runtime-api/src/lib.rs index 48d0f8a85d..7017d90a80 100644 --- a/primitives/transaction-pool/runtime-api/src/lib.rs +++ b/primitives/transaction-pool/runtime-api/src/lib.rs @@ -18,9 +18,9 @@ #![cfg_attr(not(feature = "std"), no_std)] -use sr_primitives::{transaction_validity::TransactionValidity, traits::Block as BlockT}; +use sp_runtime::{transaction_validity::TransactionValidity, traits::Block as BlockT}; -sr_api::decl_runtime_apis! { +sp_api::decl_runtime_apis! { /// The `TaggedTransactionQueue` api trait for interfering with the transaction queue. pub trait TaggedTransactionQueue { /// Validate the given transaction. diff --git a/primitives/transaction-pool/src/error.rs b/primitives/transaction-pool/src/error.rs index 19270f349a..ce65eaf26c 100644 --- a/primitives/transaction-pool/src/error.rs +++ b/primitives/transaction-pool/src/error.rs @@ -16,7 +16,7 @@ //! Transaction pool errors. -use sr_primitives::transaction_validity::{ +use sp_runtime::transaction_validity::{ TransactionPriority as Priority, InvalidTransaction, UnknownTransaction, }; diff --git a/primitives/transaction-pool/src/lib.rs b/primitives/transaction-pool/src/lib.rs index 30671d4b1a..3f834d3253 100644 --- a/primitives/transaction-pool/src/lib.rs +++ b/primitives/transaction-pool/src/lib.rs @@ -21,7 +21,7 @@ pub mod error; pub use error::IntoPoolError; -pub use sr_primitives::transaction_validity::{ +pub use sp_runtime::transaction_validity::{ TransactionLongevity, TransactionPriority, TransactionTag, }; @@ -35,7 +35,7 @@ use futures::{ channel::mpsc, }; use serde::{Deserialize, Serialize}; -use sr_primitives::{ +use sp_runtime::{ generic::BlockId, traits::{Block as BlockT, Member}, }; @@ -98,7 +98,7 @@ pub type TransactionStatusStreamFor

= TransactionStatusStream, Bloc /// In-pool transaction interface. /// /// The pool is container of transactions that are implementing this trait. -/// See `sr_primitives::ValidTransaction` for details about every field. +/// See `sp_runtime::ValidTransaction` for details about every field. pub trait InPoolTransaction { /// Transaction type. type Transaction; diff --git a/primitives/trie/Cargo.toml b/primitives/trie/Cargo.toml index cc9d1b2dde..494a7754ae 100644 --- a/primitives/trie/Cargo.toml +++ b/primitives/trie/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "substrate-trie" +name = "sp-trie" version = "2.0.0" authors = ["Parity Technologies "] description = "Patricia trie stuff using a parity-scale-codec node format" @@ -13,12 +13,12 @@ harness = false [dependencies] codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } -rstd = { package = "sr-std", path = "../sr-std", default-features = false } +rstd = { package = "sp-std", path = "../sr-std", default-features = false } hash-db = { version = "0.15.2", default-features = false } trie-db = { version = "0.16.0", default-features = false } trie-root = { version = "0.15.2", default-features = false } memory-db = { version = "0.15.2", default-features = false } -primitives = { package = "substrate-primitives", path = "../core", default-features = false } +primitives = { package = "sp-core", path = "../core", default-features = false } [dev-dependencies] trie-bench = "0.17.0" diff --git a/primitives/trie/benches/bench.rs b/primitives/trie/benches/bench.rs index a8a4732222..347426d0c5 100644 --- a/primitives/trie/benches/bench.rs +++ b/primitives/trie/benches/bench.rs @@ -20,11 +20,11 @@ criterion_main!(benches); fn benchmark(c: &mut Criterion) { trie_bench::standard_benchmark::< - substrate_trie::Layout, - substrate_trie::TrieStream, + sp_trie::Layout, + sp_trie::TrieStream, >(c, "substrate-blake2"); trie_bench::standard_benchmark::< - substrate_trie::Layout, - substrate_trie::TrieStream, + sp_trie::Layout, + sp_trie::TrieStream, >(c, "substrate-keccak"); } diff --git a/primitives/wasm-interface/Cargo.toml b/primitives/wasm-interface/Cargo.toml index 90dc7b812d..8f44c8895c 100644 --- a/primitives/wasm-interface/Cargo.toml +++ b/primitives/wasm-interface/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "substrate-wasm-interface" +name = "sp-wasm-interface" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" diff --git a/test/utils/chain-spec-builder/Cargo.toml b/test/utils/chain-spec-builder/Cargo.toml index 7498880e0f..32829bdb51 100644 --- a/test/utils/chain-spec-builder/Cargo.toml +++ b/test/utils/chain-spec-builder/Cargo.toml @@ -7,8 +7,8 @@ build = "build.rs" [dependencies] ansi_term = "0.12.1" -keystore = { package = "substrate-keystore", path = "../../../client/keystore" } +keystore = { package = "sc-keystore", path = "../../../client/keystore" } node-cli = { path = "../../../bin/node/cli" } -primitives = { package = "substrate-primitives", path = "../../../primitives/core" } +primitives = { package = "sp-core", path = "../../../primitives/core" } rand = "0.7.2" structopt = "0.3.3" diff --git a/test/utils/client/Cargo.toml b/test/utils/client/Cargo.toml index e153604603..02f54b9ca9 100644 --- a/test/utils/client/Cargo.toml +++ b/test/utils/client/Cargo.toml @@ -5,16 +5,16 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -client-api = { package = "substrate-client-api", path = "../../../client/api" } -client = { package = "substrate-client", path = "../../../client/" } -client-db = { package = "substrate-client-db", path = "../../../client//db", features = ["test-helpers"] } -consensus = { package = "substrate-consensus-common", path = "../../../primitives/consensus/common" } -executor = { package = "substrate-executor", path = "../../../client/executor" } +client-api = { package = "sc-client-api", path = "../../../client/api" } +client = { package = "sc-client", path = "../../../client/" } +client-db = { package = "sc-client-db", path = "../../../client//db", features = ["test-helpers"] } +consensus = { package = "sp-consensus", path = "../../../primitives/consensus/common" } +executor = { package = "sc-executor", path = "../../../client/executor" } futures = "0.3.1" hash-db = "0.15.2" -keyring = { package = "substrate-keyring", path = "../../../primitives/keyring" } +keyring = { package = "sp-keyring", path = "../../../primitives/keyring" } codec = { package = "parity-scale-codec", version = "1.0.0" } -primitives = { package = "substrate-primitives", path = "../../../primitives/core" } -sr-primitives = { path = "../../../primitives/sr-primitives" } +primitives = { package = "sp-core", path = "../../../primitives/core" } +sp-runtime = { path = "../../../primitives/sr-primitives" } sp-blockchain = { path = "../../../primitives/blockchain" } -state_machine = { package = "substrate-state-machine", path = "../../../primitives/state-machine" } +state_machine = { package = "sp-state-machine", path = "../../../primitives/state-machine" } diff --git a/test/utils/client/src/client_ext.rs b/test/utils/client/src/client_ext.rs index 39010070e1..961d8570d8 100644 --- a/test/utils/client/src/client_ext.rs +++ b/test/utils/client/src/client_ext.rs @@ -23,9 +23,9 @@ use consensus::{ ForkChoiceStrategy, }; use hash_db::Hasher; -use sr_primitives::Justification; -use sr_primitives::traits::{Block as BlockT}; -use sr_primitives::generic::BlockId; +use sp_runtime::Justification; +use sp_runtime::traits::{Block as BlockT}; +use sp_runtime::generic::BlockId; use primitives::Blake2Hasher; use codec::alloc::collections::hash_map::HashMap; diff --git a/test/utils/client/src/lib.rs b/test/utils/client/src/lib.rs index c4f97aec1d..29370ba16c 100644 --- a/test/utils/client/src/lib.rs +++ b/test/utils/client/src/lib.rs @@ -32,14 +32,14 @@ pub use keyring::{ sr25519::Keyring as Sr25519Keyring, }; pub use primitives::{Blake2Hasher, traits::BareCryptoStorePtr}; -pub use sr_primitives::{StorageOverlay, ChildrenStorageOverlay}; +pub use sp_runtime::{StorageOverlay, ChildrenStorageOverlay}; pub use state_machine::ExecutionStrategy; use std::sync::Arc; use std::collections::HashMap; use hash_db::Hasher; use primitives::storage::well_known_keys; -use sr_primitives::traits::Block as BlockT; +use sp_runtime::traits::Block as BlockT; use client::LocalCallExecutor; /// Test client light database backend. diff --git a/test/utils/primitives/Cargo.toml b/test/utils/primitives/Cargo.toml index 92917fdd26..9b06e040fc 100644 --- a/test/utils/primitives/Cargo.toml +++ b/test/utils/primitives/Cargo.toml @@ -5,11 +5,11 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -app-crypto = { package = "substrate-application-crypto", path = "../../../primitives/application-crypto", default-features = false } +app-crypto = { package = "sc-application-crypto", path = "../../../primitives/application-crypto", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -primitives = { package = "substrate-primitives", path = "../../../primitives/core", default-features = false } +primitives = { package = "sp-core", path = "../../../primitives/core", default-features = false } serde = { version = "1.0.101", optional = true, features = ["derive"] } -sr-primitives = { path = "../../../primitives/sr-primitives", default-features = false } +sp-runtime = { path = "../../../primitives/sr-primitives", default-features = false } [features] default = [ diff --git a/test/utils/primitives/src/lib.rs b/test/utils/primitives/src/lib.rs index eebdbb165f..773e88066d 100644 --- a/test/utils/primitives/src/lib.rs +++ b/test/utils/primitives/src/lib.rs @@ -24,7 +24,7 @@ use app_crypto::sr25519; pub use app_crypto; pub use primitives::{hash::H256, RuntimeDebug}; -use sr_primitives::traits::{BlakeTwo256, Verify, Extrinsic as ExtrinsicT,}; +use sp_runtime::traits::{BlakeTwo256, Verify, Extrinsic as ExtrinsicT,}; /// Extrinsic for test-runtime. #[derive(Clone, PartialEq, Eq, Encode, Decode, RuntimeDebug)] @@ -69,10 +69,10 @@ pub type BlockNumber = u64; /// Index of a transaction. pub type Index = u64; /// The item of a block digest. -pub type DigestItem = sr_primitives::generic::DigestItem; +pub type DigestItem = sp_runtime::generic::DigestItem; /// The digest of a block. -pub type Digest = sr_primitives::generic::Digest; +pub type Digest = sp_runtime::generic::Digest; /// A test block. -pub type Block = sr_primitives::generic::Block; +pub type Block = sp_runtime::generic::Block; /// A test block's header. -pub type Header = sr_primitives::generic::Header; +pub type Header = sp_runtime::generic::Header; diff --git a/test/utils/runtime/Cargo.toml b/test/utils/runtime/Cargo.toml index f51bceb095..77224c2ef1 100644 --- a/test/utils/runtime/Cargo.toml +++ b/test/utils/runtime/Cargo.toml @@ -6,41 +6,41 @@ edition = "2018" build = "build.rs" [dependencies] -app-crypto = { package = "substrate-application-crypto", path = "../../../primitives/application-crypto", default-features = false } -aura-primitives = { package = "substrate-consensus-aura-primitives", path = "../../../primitives/consensus/aura", default-features = false } -babe-primitives = { package = "substrate-consensus-babe-primitives", path = "../../../primitives/consensus/babe", default-features = false } -block-builder-api = { package = "substrate-block-builder-runtime-api", path = "../../../primitives/block-builder/runtime-api", default-features = false } +app-crypto = { package = "sc-application-crypto", path = "../../../primitives/application-crypto", default-features = false } +aura-primitives = { package = "sp-consensus-aura", path = "../../../primitives/consensus/aura", default-features = false } +babe-primitives = { package = "sp-consensus-babe", path = "../../../primitives/consensus/babe", default-features = false } +block-builder-api = { package = "sp-block-builder", path = "../../../primitives/block-builder/runtime-api", default-features = false } cfg-if = "0.1.10" codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } executive = { package = "frame-executive", path = "../../../frame/executive", default-features = false } -inherents = { package = "substrate-inherents", path = "../../../primitives/inherents", default-features = false } -keyring = { package = "substrate-keyring", path = "../../../primitives/keyring", optional = true } +inherents = { package = "sp-inherents", path = "../../../primitives/inherents", default-features = false } +keyring = { package = "sp-keyring", path = "../../../primitives/keyring", optional = true } log = { version = "0.4.8", optional = true } memory-db = { version = "0.15.2", default-features = false } -offchain-primitives = { package = "substrate-offchain-primitives", path = "../../../primitives/offchain", default-features = false} -primitives = { package = "substrate-primitives", path = "../../../primitives/core", default-features = false } -rstd = { package = "sr-std", path = "../../../primitives/sr-std", default-features = false } -runtime-interface = { package = "substrate-runtime-interface", path = "../../../primitives/runtime-interface", default-features = false} -runtime_io = { package = "sr-io", path = "../../../primitives/sr-io", default-features = false } +offchain-primitives = { package = "sp-offchain", path = "../../../primitives/offchain", default-features = false} +primitives = { package = "sp-core", path = "../../../primitives/core", default-features = false } +rstd = { package = "sp-std", path = "../../../primitives/sr-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 } runtime_support = { package = "frame-support", path = "../../../frame/support", default-features = false } -runtime_version = { package = "sr-version", path = "../../../primitives/sr-version", default-features = false } +runtime_version = { package = "sp-version", path = "../../../primitives/sr-version", default-features = false } serde = { version = "1.0.101", optional = true, features = ["derive"] } -session = { package = "substrate-session", path = "../../../primitives/session", default-features = false } -sr-api = { path = "../../../primitives/sr-api", default-features = false } -sr-primitives = { path = "../../../primitives/sr-primitives", default-features = false } +session = { package = "sp-sesssion", path = "../../../primitives/session", default-features = false } +sp-api = { path = "../../../primitives/sr-api", default-features = false } +sp-runtime = { path = "../../../primitives/sr-primitives", default-features = false } pallet-babe = { path = "../../../frame/babe", default-features = false } frame-system = { path = "../../../frame/system", default-features = false } frame-system-rpc-runtime-api = { path = "../../../frame/system/rpc/runtime-api", default-features = false } pallet-timestamp = { path = "../../../frame/timestamp", default-features = false } -substrate-client = { path = "../../../client", optional = true } -substrate-trie = { path = "../../../primitives/trie", default-features = false } +sc-client = { path = "../../../client", optional = true } +sp-trie = { path = "../../../primitives/trie", default-features = false } txpool-runtime-api = { package = "sp-transaction-pool-runtime-api", path = "../../../primitives/transaction-pool/runtime-api", default-features = false } trie-db = { version = "0.16.0", default-features = false } [dev-dependencies] -substrate-executor = { path = "../../../client/executor" } +sc-executor = { path = "../../../client/executor" } substrate-test-runtime-client = { path = "./client" } -state_machine = { package = "substrate-state-machine", path = "../../../primitives/state-machine" } +state_machine = { package = "sp-state-machine", path = "../../../primitives/state-machine" } [build-dependencies] wasm-builder-runner = { package = "substrate-wasm-builder-runner", path = "../../../client/utils/wasm-builder-runner", version = "1.0.4" } @@ -70,14 +70,14 @@ std = [ "runtime_version/std", "serde", "session/std", - "sr-api/std", - "sr-primitives/std", + "sp-api/std", + "sp-runtime/std", "pallet-babe/std", "frame-system-rpc-runtime-api/std", "frame-system/std", "pallet-timestamp/std", - "substrate-client", - "substrate-trie/std", + "sc-client", + "sp-trie/std", "txpool-runtime-api/std", "trie-db/std", ] diff --git a/test/utils/runtime/client/Cargo.toml b/test/utils/runtime/client/Cargo.toml index 22758584c7..21b16c5496 100644 --- a/test/utils/runtime/client/Cargo.toml +++ b/test/utils/runtime/client/Cargo.toml @@ -5,13 +5,13 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -block-builder = { package = "substrate-block-builder", path = "../../../../client/block-builder" } +block-builder = { package = "sc-block-builder", path = "../../../../client/block-builder" } generic-test-client = { package = "substrate-test-client", path = "../../client" } -primitives = { package = "substrate-primitives", path = "../../../../primitives/core" } +primitives = { package = "sp-core", path = "../../../../primitives/core" } runtime = { package = "substrate-test-runtime", path = "../../runtime" } -sr-primitives = { path = "../../../../primitives/sr-primitives" } +sp-runtime = { path = "../../../../primitives/sr-primitives" } sp-blockchain = { path = "../../../../primitives/blockchain" } codec = { package = "parity-scale-codec", version = "1.0.0" } -client-api = { package = "substrate-client-api", path = "../../../../client/api" } -client = { package = "substrate-client", path = "../../../../client/" } +client-api = { package = "sc-client-api", path = "../../../../client/api" } +client = { package = "sc-client", path = "../../../../client/" } futures = "0.3.1" diff --git a/test/utils/runtime/client/src/block_builder_ext.rs b/test/utils/runtime/client/src/block_builder_ext.rs index e6e8ac3249..a1065c82a0 100644 --- a/test/utils/runtime/client/src/block_builder_ext.rs +++ b/test/utils/runtime/client/src/block_builder_ext.rs @@ -17,7 +17,7 @@ //! Block Builder extensions for tests. use runtime; -use sr_primitives::traits::ProvideRuntimeApi; +use sp_runtime::traits::ProvideRuntimeApi; use block_builder::BlockBuilderApi; diff --git a/test/utils/runtime/client/src/lib.rs b/test/utils/runtime/client/src/lib.rs index 57be949bca..cd815b7ea4 100644 --- a/test/utils/runtime/client/src/lib.rs +++ b/test/utils/runtime/client/src/lib.rs @@ -30,7 +30,7 @@ pub use runtime; use primitives::sr25519; use runtime::genesismap::{GenesisConfig, additional_storage_with_genesis}; -use sr_primitives::traits::{Block as BlockT, Header as HeaderT, Hash as HashT, NumberFor}; +use sp_runtime::traits::{Block as BlockT, Header as HeaderT, Hash as HashT, NumberFor}; use client::{ light::fetcher::{ Fetcher, diff --git a/test/utils/runtime/client/src/trait_tests.rs b/test/utils/runtime/client/src/trait_tests.rs index bfdab4d942..108924c4dd 100644 --- a/test/utils/runtime/client/src/trait_tests.rs +++ b/test/utils/runtime/client/src/trait_tests.rs @@ -28,8 +28,8 @@ use crate::{AccountKeyring, ClientExt, TestClientBuilder, TestClientBuilderExt}; use generic_test_client::consensus::BlockOrigin; use primitives::Blake2Hasher; use runtime::{self, Transfer}; -use sr_primitives::generic::BlockId; -use sr_primitives::traits::Block as BlockT; +use sp_runtime::generic::BlockId; +use sp_runtime::traits::Block as BlockT; /// helper to test the `leaves` implementation for various backends pub fn test_leaves_for_backend(backend: Arc) where diff --git a/test/utils/runtime/src/genesismap.rs b/test/utils/runtime/src/genesismap.rs index 79cba52323..eb2ee14404 100644 --- a/test/utils/runtime/src/genesismap.rs +++ b/test/utils/runtime/src/genesismap.rs @@ -21,7 +21,7 @@ use runtime_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}; -use sr_primitives::traits::{Block as BlockT, Hash as HashT, Header as HeaderT}; +use sp_runtime::traits::{Block as BlockT, Hash as HashT, Header as HeaderT}; /// Configuration of a general Substrate test genesis block. pub struct GenesisConfig { @@ -105,7 +105,7 @@ pub fn insert_genesis_block( let state_root = <<::Header as HeaderT>::Hashing as HashT>::trie_root( storage.0.clone().into_iter().chain(child_roots).collect() ); - let block: crate::Block = substrate_client::genesis::construct_genesis_block(state_root); + let block: crate::Block = sc_client::genesis::construct_genesis_block(state_root); let genesis_hash = block.header.hash(); storage.0.extend(additional_storage_with_genesis(&block)); genesis_hash diff --git a/test/utils/runtime/src/lib.rs b/test/utils/runtime/src/lib.rs index 7761cfb944..ec8998f597 100644 --- a/test/utils/runtime/src/lib.rs +++ b/test/utils/runtime/src/lib.rs @@ -29,11 +29,11 @@ use primitives::{Blake2Hasher, OpaqueMetadata, RuntimeDebug}; use app_crypto::{ed25519, sr25519, RuntimeAppPublic}; pub use app_crypto; use trie_db::{TrieMut, Trie}; -use substrate_trie::PrefixedMemoryDB; -use substrate_trie::trie_types::{TrieDB, TrieDBMut}; +use sp_trie::PrefixedMemoryDB; +use sp_trie::trie_types::{TrieDB, TrieDBMut}; -use sr_api::{decl_runtime_apis, impl_runtime_apis}; -use sr_primitives::{ +use sp_api::{decl_runtime_apis, impl_runtime_apis}; +use sp_runtime::{ ApplyExtrinsicResult, create_runtime_str, Perbill, impl_opaque_keys, transaction_validity::{ TransactionValidity, ValidTransaction, TransactionValidityError, InvalidTransaction, @@ -124,7 +124,7 @@ impl BlindCheckable for Extrinsic { match self { Extrinsic::AuthoritiesChange(new_auth) => Ok(Extrinsic::AuthoritiesChange(new_auth)), Extrinsic::Transfer(transfer, signature) => { - if sr_primitives::verify_encoded_lazy(&signature, &transfer, &transfer.from) { + if sp_runtime::verify_encoded_lazy(&signature, &transfer, &transfer.from) { Ok(Extrinsic::Transfer(transfer, signature)) } else { Err(InvalidTransaction::BadProof.into()) @@ -173,17 +173,17 @@ pub type BlockNumber = u64; /// Index of a transaction. pub type Index = u64; /// The item of a block digest. -pub type DigestItem = sr_primitives::generic::DigestItem; +pub type DigestItem = sp_runtime::generic::DigestItem; /// The digest of a block. -pub type Digest = sr_primitives::generic::Digest; +pub type Digest = sp_runtime::generic::Digest; /// A test block. -pub type Block = sr_primitives::generic::Block; +pub type Block = sp_runtime::generic::Block; /// A test block's header. -pub type Header = sr_primitives::generic::Header; +pub type Header = sp_runtime::generic::Header; /// Run whatever tests we have. pub fn run_tests(mut input: &[u8]) -> Vec { - use sr_primitives::print; + use sp_runtime::print; print("run_tests..."); let block = Block::decode(&mut input).unwrap(); @@ -457,7 +457,7 @@ static mut MUTABLE_STATIC: u64 = 32; cfg_if! { if #[cfg(feature = "std")] { impl_runtime_apis! { - impl sr_api::Core for Runtime { + impl sp_api::Core for Runtime { fn version() -> RuntimeVersion { version() } @@ -471,7 +471,7 @@ cfg_if! { } } - impl sr_api::Metadata for Runtime { + impl sp_api::Metadata for Runtime { fn metadata() -> OpaqueMetadata { unimplemented!() } @@ -642,7 +642,7 @@ cfg_if! { } } else { impl_runtime_apis! { - impl sr_api::Core for Runtime { + impl sp_api::Core for Runtime { fn version() -> RuntimeVersion { version() } @@ -656,7 +656,7 @@ cfg_if! { } } - impl sr_api::Metadata for Runtime { + impl sp_api::Metadata for Runtime { fn metadata() -> OpaqueMetadata { unimplemented!() } @@ -937,7 +937,7 @@ mod tests { DefaultTestClientBuilderExt, TestClientBuilder, runtime::TestAPI, }; - use sr_primitives::{ + use sp_runtime::{ generic::BlockId, traits::ProvideRuntimeApi, }; diff --git a/test/utils/runtime/src/system.rs b/test/utils/runtime/src/system.rs index 1a04da1764..a0c1a2769e 100644 --- a/test/utils/runtime/src/system.rs +++ b/test/utils/runtime/src/system.rs @@ -24,7 +24,7 @@ use runtime_io::{ }; use runtime_support::storage; use runtime_support::{decl_storage, decl_module}; -use sr_primitives::{ +use sp_runtime::{ traits::{Hash as HashT, BlakeTwo256, Header as _}, generic, ApplyExtrinsicResult, transaction_validity::{ TransactionValidity, ValidTransaction, InvalidTransaction, TransactionValidityError, @@ -257,7 +257,7 @@ pub fn finalize_block() -> Header { #[inline(always)] fn check_signature(utx: &Extrinsic) -> Result<(), TransactionValidityError> { - use sr_primitives::traits::BlindCheckable; + use sp_runtime::traits::BlindCheckable; utx.clone().check().map_err(|_| InvalidTransaction::BadProof.into()).map(|_| ()) } @@ -325,9 +325,9 @@ fn info_expect_equal_hash(given: &Hash, expected: &Hash) { #[cfg(not(feature = "std"))] fn info_expect_equal_hash(given: &Hash, expected: &Hash) { if given != expected { - sr_primitives::print("Hash not equal"); - sr_primitives::print(given.as_bytes()); - sr_primitives::print(expected.as_bytes()); + sp_runtime::print("Hash not equal"); + sp_runtime::print(given.as_bytes()); + sp_runtime::print(expected.as_bytes()); } } @@ -339,7 +339,7 @@ mod tests { use substrate_test_runtime_client::{AccountKeyring, Sr25519Keyring}; use crate::{Header, Transfer, WASM_BINARY}; use primitives::{NeverNativeValue, map, traits::CodeExecutor}; - use substrate_executor::{NativeExecutor, WasmExecutionMethod, native_executor_instance}; + use sc_executor::{NativeExecutor, WasmExecutionMethod, native_executor_instance}; use runtime_io::hashing::twox_128; // Declare an instance of the native executor dispatch for the test runtime. diff --git a/test/utils/transaction-factory/Cargo.toml b/test/utils/transaction-factory/Cargo.toml index 5c15a887c6..1414e3baa1 100644 --- a/test/utils/transaction-factory/Cargo.toml +++ b/test/utils/transaction-factory/Cargo.toml @@ -5,16 +5,16 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -block-builder-api = { package = "substrate-block-builder-runtime-api", path = "../../../primitives/block-builder/runtime-api" } -cli = { package = "substrate-cli", path = "../../../client/cli" } -client-api = { package = "substrate-client-api", path = "../../../client/api" } -client = { package = "substrate-client", path = "../../../client" } +block-builder-api = { package = "sp-block-builder", path = "../../../primitives/block-builder/runtime-api" } +cli = { package = "sc-cli", path = "../../../client/cli" } +client-api = { package = "sc-client-api", path = "../../../client/api" } +client = { package = "sc-client", path = "../../../client" } codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } -consensus_common = { package = "substrate-consensus-common", path = "../../../primitives/consensus/common" } +consensus_common = { package = "sp-consensus", path = "../../../primitives/consensus/common" } log = "0.4.8" -primitives = { package = "substrate-primitives", path = "../../../primitives/core" } -sr-api = { path = "../../../primitives/sr-api" } -sr-primitives = { path = "../../../primitives/sr-primitives" } -substrate-service = { path = "../../../client/service" } +primitives = { package = "sp-core", path = "../../../primitives/core" } +sp-api = { path = "../../../primitives/sr-api" } +sp-runtime = { path = "../../../primitives/sr-primitives" } +sc-service = { path = "../../../client/service" } sp-blockchain = { path = "../../../primitives/blockchain" } diff --git a/test/utils/transaction-factory/src/complex_mode.rs b/test/utils/transaction-factory/src/complex_mode.rs index bbc01c19ba..2c82be3b4c 100644 --- a/test/utils/transaction-factory/src/complex_mode.rs +++ b/test/utils/transaction-factory/src/complex_mode.rs @@ -43,10 +43,10 @@ use std::sync::Arc; use log::info; use client::Client; use block_builder_api::BlockBuilder; -use sr_api::ConstructRuntimeApi; +use sp_api::ConstructRuntimeApi; use primitives::{Blake2Hasher, Hasher}; -use sr_primitives::generic::BlockId; -use sr_primitives::traits::{Block as BlockT, ProvideRuntimeApi, One, Zero}; +use sp_runtime::generic::BlockId; +use sp_runtime::traits::{Block as BlockT, ProvideRuntimeApi, One, Zero}; use crate::{RuntimeAdapter, create_block}; diff --git a/test/utils/transaction-factory/src/lib.rs b/test/utils/transaction-factory/src/lib.rs index cab30b9a40..e9526e6259 100644 --- a/test/utils/transaction-factory/src/lib.rs +++ b/test/utils/transaction-factory/src/lib.rs @@ -28,7 +28,7 @@ use log::info; use client::Client; use block_builder_api::BlockBuilder; -use sr_api::ConstructRuntimeApi; +use sp_api::ConstructRuntimeApi; use consensus_common::{ BlockOrigin, BlockImportParams, InherentData, ForkChoiceStrategy, SelectChain @@ -36,8 +36,8 @@ use consensus_common::{ use consensus_common::block_import::BlockImport; use codec::{Decode, Encode}; use primitives::{Blake2Hasher, Hasher}; -use sr_primitives::generic::BlockId; -use sr_primitives::traits::{ +use sp_runtime::generic::BlockId; +use sp_runtime::traits::{ Block as BlockT, Header as HeaderT, ProvideRuntimeApi, SimpleArithmetic, One, Zero, }; diff --git a/test/utils/transaction-factory/src/simple_modes.rs b/test/utils/transaction-factory/src/simple_modes.rs index 973de45c7e..756708b17f 100644 --- a/test/utils/transaction-factory/src/simple_modes.rs +++ b/test/utils/transaction-factory/src/simple_modes.rs @@ -38,10 +38,10 @@ use std::sync::Arc; use log::info; use client::Client; use block_builder_api::BlockBuilder; -use sr_api::ConstructRuntimeApi; +use sp_api::ConstructRuntimeApi; use primitives::{Blake2Hasher, Hasher}; -use sr_primitives::traits::{Block as BlockT, ProvideRuntimeApi, One}; -use sr_primitives::generic::BlockId; +use sp_runtime::traits::{Block as BlockT, ProvideRuntimeApi, One}; +use sp_runtime::generic::BlockId; use crate::{Mode, RuntimeAdapter, create_block}; diff --git a/utils/frame/rpc/support/Cargo.toml b/utils/frame/rpc/support/Cargo.toml index 937acb8295..d2ca6c060e 100644 --- a/utils/frame/rpc/support/Cargo.toml +++ b/utils/frame/rpc/support/Cargo.toml @@ -11,7 +11,7 @@ jsonrpc-core = "14" parity-scale-codec = "1" serde = "1" frame-support = { path = "../../../../frame/support" } -substrate-primitives-storage = { path = "../../../../primitives/core/storage" } +sp-core-storage = { path = "../../../../primitives/core/storage" } sc-rpc-api = { path = "../../../../client/rpc/api" } [dev-dependencies] diff --git a/utils/frame/rpc/support/src/lib.rs b/utils/frame/rpc/support/src/lib.rs index c9163bdc30..c16e31f7e0 100644 --- a/utils/frame/rpc/support/src/lib.rs +++ b/utils/frame/rpc/support/src/lib.rs @@ -27,7 +27,7 @@ use serde::{de::DeserializeOwned, Serialize}; use frame_support::storage::generator::{ StorageDoubleMap, StorageLinkedMap, StorageMap, StorageValue }; -use substrate_primitives_storage::{StorageData, StorageKey}; +use sp_core_storage::{StorageData, StorageKey}; use sc_rpc_api::state::StateClient; /// A typed query on chain state usable from an RPC client. diff --git a/utils/frame/rpc/system/Cargo.toml b/utils/frame/rpc/system/Cargo.toml index 9b5b32919c..3bf8055551 100644 --- a/utils/frame/rpc/system/Cargo.toml +++ b/utils/frame/rpc/system/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -client = { package = "substrate-client", path = "../../../../client/" } +client = { package = "sc-client", path = "../../../../client/" } codec = { package = "parity-scale-codec", version = "1.0.0" } futures = "0.3.1" jsonrpc-core = "14.0.3" @@ -13,13 +13,13 @@ jsonrpc-core-client = "14.0.3" jsonrpc-derive = "14.0.3" log = "0.4.8" serde = { version = "1.0.101", features = ["derive"] } -sr-primitives = { path = "../../../../primitives/sr-primitives" } +sp-runtime = { path = "../../../../primitives/sr-primitives" } frame-system-rpc-runtime-api = { path = "../../../../frame/system/rpc/runtime-api" } -substrate-primitives = { path = "../../../../primitives/core" } +sp-core = { path = "../../../../primitives/core" } sp-blockchain = { path = "../../../../primitives/blockchain" } txpool-api = { package = "sp-transaction-pool-api", path = "../../../../primitives/transaction-pool" } [dev-dependencies] test-client = { package = "substrate-test-runtime-client", path = "../../../../test/utils/runtime/client" } env_logger = "0.7.0" -txpool = { package = "sc-transaction-pool", path = "../../../../client/transaction-pool" } +txpool = { package = "sc-tracing-pool", path = "../../../../client/transaction-pool" } diff --git a/utils/frame/rpc/system/src/lib.rs b/utils/frame/rpc/system/src/lib.rs index ebda962031..675965729d 100644 --- a/utils/frame/rpc/system/src/lib.rs +++ b/utils/frame/rpc/system/src/lib.rs @@ -33,11 +33,11 @@ use sp_blockchain::{ HeaderBackend, Error as ClientError }; -use sr_primitives::{ +use sp_runtime::{ generic::BlockId, traits, }; -use substrate_primitives::hexdisplay::HexDisplay; +use sp_core::hexdisplay::HexDisplay; use txpool_api::{TransactionPool, InPoolTransaction}; pub use frame_system_rpc_runtime_api::AccountNonceApi; -- GitLab From fe07382be51e3d97f06202bc1b3b9fa4f492ebf7 Mon Sep 17 00:00:00 2001 From: Benjamin Kampmann Date: Mon, 2 Dec 2019 12:19:53 +0100 Subject: [PATCH 059/172] Fix sc-tracing-* -> sc-transaction- (#4263) * fixing faulty tracing-rename * missed one --- Cargo.lock | 20 +++++++++---------- bin/node-template/Cargo.toml | 2 +- bin/node/cli/Cargo.toml | 2 +- client/basic-authorship/Cargo.toml | 2 +- client/offchain/Cargo.toml | 2 +- client/rpc/Cargo.toml | 2 +- client/service/Cargo.toml | 2 +- client/transaction-pool/Cargo.toml | 4 ++-- client/transaction-pool/graph/Cargo.toml | 2 +- .../transaction-pool/graph/benches/basics.rs | 2 +- utils/frame/rpc/system/Cargo.toml | 2 +- 11 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 40f091db0f..4cfd25f917 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3006,7 +3006,7 @@ dependencies = [ "sc-service 2.0.0", "sc-service-test 2.0.0", "sc-telemetry 2.0.0", - "sc-tracing-pool 2.0.0", + "sc-transaction-pool 2.0.0", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-authority-discovery 2.0.0", "sp-consensus 2.0.0", @@ -3175,7 +3175,7 @@ dependencies = [ "sc-finality-grandpa 2.0.0", "sc-network 2.0.0", "sc-service 2.0.0", - "sc-tracing-pool 2.0.0", + "sc-transaction-pool 2.0.0", "sp-consensus 2.0.0", "sp-consensus-aura 2.0.0", "sp-core 2.0.0", @@ -4852,7 +4852,7 @@ dependencies = [ "sc-client 2.0.0", "sc-client-api 2.0.0", "sc-telemetry 2.0.0", - "sc-tracing-pool 2.0.0", + "sc-transaction-pool 2.0.0", "sp-blockchain 2.0.0", "sp-consensus 2.0.0", "sp-core 2.0.0", @@ -5342,7 +5342,7 @@ dependencies = [ "sc-client-db 2.0.0", "sc-keystore 2.0.0", "sc-network 2.0.0", - "sc-tracing-pool 2.0.0", + "sc-transaction-pool 2.0.0", "sp-api 2.0.0", "sp-core 2.0.0", "sp-offchain 2.0.0", @@ -5384,7 +5384,7 @@ dependencies = [ "sc-keystore 2.0.0", "sc-network 2.0.0", "sc-rpc-api 2.0.0", - "sc-tracing-pool 2.0.0", + "sc-transaction-pool 2.0.0", "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", "sp-api 2.0.0", "sp-blockchain 2.0.0", @@ -5475,7 +5475,7 @@ dependencies = [ "sc-rpc-server 2.0.0", "sc-telemetry 2.0.0", "sc-tracing 2.0.0", - "sc-tracing-pool 2.0.0", + "sc-transaction-pool 2.0.0", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5568,7 +5568,7 @@ dependencies = [ ] [[package]] -name = "sc-tracing-graph" +name = "sc-transaction-graph" version = "2.0.0" dependencies = [ "assert_matches 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5587,7 +5587,7 @@ dependencies = [ ] [[package]] -name = "sc-tracing-pool" +name = "sc-transaction-pool" version = "2.0.0" dependencies = [ "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5596,7 +5596,7 @@ dependencies = [ "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sc-client-api 2.0.0", - "sc-tracing-graph 2.0.0", + "sc-transaction-graph 2.0.0", "sp-api 2.0.0", "sp-blockchain 2.0.0", "sp-core 2.0.0", @@ -6578,7 +6578,7 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "sc-client 2.0.0", - "sc-tracing-pool 2.0.0", + "sc-transaction-pool 2.0.0", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-blockchain 2.0.0", "sp-core 2.0.0", diff --git a/bin/node-template/Cargo.toml b/bin/node-template/Cargo.toml index 37501cd96b..bfe39ee0c7 100644 --- a/bin/node-template/Cargo.toml +++ b/bin/node-template/Cargo.toml @@ -24,7 +24,7 @@ primitives = { package = "sp-core", path = "../../primitives/core" } sc-executor = { path = "../../client/executor" } sc-service = { path = "../../client/service" } inherents = { package = "sp-inherents", path = "../../primitives/inherents" } -txpool = { package = "sc-tracing-pool", path = "../../client/transaction-pool" } +txpool = { package = "sc-transaction-pool", path = "../../client/transaction-pool" } txpool-api = { package = "sp-transaction-pool-api", path = "../../primitives/transaction-pool" } network = { package = "sc-network", path = "../../client/network" } aura = { package = "sc-consensus-aura", path = "../../client/consensus/aura" } diff --git a/bin/node/cli/Cargo.toml b/bin/node/cli/Cargo.toml index 4d3556bd51..6b61f7abe0 100644 --- a/bin/node/cli/Cargo.toml +++ b/bin/node/cli/Cargo.toml @@ -49,7 +49,7 @@ runtime-io = { package = "sp-io", path = "../../../primitives/sr-io" } client-api = { package = "sc-client-api", path = "../../../client/api" } client = { package = "sc-client", path = "../../../client/" } chain-spec = { package = "sc-chain-spec", path = "../../../client/chain-spec" } -txpool = { package = "sc-tracing-pool", path = "../../../client/transaction-pool" } +txpool = { package = "sc-transaction-pool", path = "../../../client/transaction-pool" } txpool-api = { package = "sp-transaction-pool-api", path = "../../../primitives/transaction-pool" } network = { package = "sc-network", path = "../../../client/network" } babe = { package = "sc-consensus-babe", path = "../../../client/consensus/babe" } diff --git a/client/basic-authorship/Cargo.toml b/client/basic-authorship/Cargo.toml index ba61625516..3f4cbb0bc6 100644 --- a/client/basic-authorship/Cargo.toml +++ b/client/basic-authorship/Cargo.toml @@ -21,6 +21,6 @@ block-builder = { package = "sc-block-builder", path = "../block-builder" } tokio-executor = { version = "0.2.0-alpha.6", features = ["blocking"] } [dev-dependencies] -txpool = { package = "sc-tracing-pool", path = "../../client/transaction-pool" } +txpool = { package = "sc-transaction-pool", path = "../../client/transaction-pool" } test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client" } parking_lot = "0.9" diff --git a/client/offchain/Cargo.toml b/client/offchain/Cargo.toml index dafbffd39b..1b30c2fcff 100644 --- a/client/offchain/Cargo.toml +++ b/client/offchain/Cargo.toml @@ -35,7 +35,7 @@ client-db = { package = "sc-client-db", path = "../db/", default-features = true env_logger = "0.7.0" test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client" } tokio = "0.1.22" -txpool = { package = "sc-tracing-pool", path = "../../client/transaction-pool" } +txpool = { package = "sc-transaction-pool", path = "../../client/transaction-pool" } txpool-api = { package = "sp-transaction-pool-api", path = "../../primitives/transaction-pool" } [features] diff --git a/client/rpc/Cargo.toml b/client/rpc/Cargo.toml index b387a3099d..5bb947eb0c 100644 --- a/client/rpc/Cargo.toml +++ b/client/rpc/Cargo.toml @@ -36,4 +36,4 @@ rustc-hex = "2.0.1" sp-io = { path = "../../primitives/sr-io" } test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client" } tokio = "0.1.22" -txpool = { package = "sc-tracing-pool", path = "../transaction-pool" } +txpool = { package = "sc-transaction-pool", path = "../transaction-pool" } diff --git a/client/service/Cargo.toml b/client/service/Cargo.toml index ea69b14e42..426c3a76dc 100644 --- a/client/service/Cargo.toml +++ b/client/service/Cargo.toml @@ -45,7 +45,7 @@ txpool-runtime-api = { package = "sp-transaction-pool-runtime-api", path = "../. client_db = { package = "sc-client-db", path = "../db" } codec = { package = "parity-scale-codec", version = "1.0.0" } sc-executor = { path = "../executor" } -txpool = { package = "sc-tracing-pool", path = "../transaction-pool" } +txpool = { package = "sc-transaction-pool", path = "../transaction-pool" } txpool-api = { package = "sp-transaction-pool-api", path = "../../primitives/transaction-pool" } rpc-servers = { package = "sc-rpc-server", path = "../rpc-servers" } rpc = { package = "sc-rpc", path = "../rpc" } diff --git a/client/transaction-pool/Cargo.toml b/client/transaction-pool/Cargo.toml index ef84a21c8b..9ae87d50ed 100644 --- a/client/transaction-pool/Cargo.toml +++ b/client/transaction-pool/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "sc-tracing-pool" +name = "sc-transaction-pool" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" @@ -13,7 +13,7 @@ parking_lot = "0.9.0" primitives = { package = "sp-core", path = "../../primitives/core" } sp-api = { path = "../../primitives/sr-api" } sp-runtime = { path = "../../primitives/sr-primitives" } -txpool = { package = "sc-tracing-graph", path = "./graph" } +txpool = { package = "sc-transaction-graph", path = "./graph" } txpool-api = { package = "sp-transaction-pool-api", path = "../../primitives/transaction-pool" } txpool-runtime-api = { package = "sp-transaction-pool-runtime-api", path = "../../primitives/transaction-pool/runtime-api" } client-api = { package = "sc-client-api", path = "../api" } diff --git a/client/transaction-pool/graph/Cargo.toml b/client/transaction-pool/graph/Cargo.toml index 870604d88c..392a39ab6d 100644 --- a/client/transaction-pool/graph/Cargo.toml +++ b/client/transaction-pool/graph/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "sc-tracing-graph" +name = "sc-transaction-graph" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" diff --git a/client/transaction-pool/graph/benches/basics.rs b/client/transaction-pool/graph/benches/basics.rs index b5dc63ed5b..884cffea74 100644 --- a/client/transaction-pool/graph/benches/basics.rs +++ b/client/transaction-pool/graph/benches/basics.rs @@ -17,7 +17,7 @@ use criterion::{criterion_group, criterion_main, Criterion}; use futures::executor::block_on; -use sc_tracing_graph::*; +use sc_transaction_graph::*; use sp_runtime::transaction_validity::{ValidTransaction, InvalidTransaction}; use codec::Encode; use test_runtime::{Block, Extrinsic, Transfer, H256, AccountId}; diff --git a/utils/frame/rpc/system/Cargo.toml b/utils/frame/rpc/system/Cargo.toml index 3bf8055551..8447eef7bc 100644 --- a/utils/frame/rpc/system/Cargo.toml +++ b/utils/frame/rpc/system/Cargo.toml @@ -22,4 +22,4 @@ txpool-api = { package = "sp-transaction-pool-api", path = "../../../../primitiv [dev-dependencies] test-client = { package = "substrate-test-runtime-client", path = "../../../../test/utils/runtime/client" } env_logger = "0.7.0" -txpool = { package = "sc-tracing-pool", path = "../../../../client/transaction-pool" } +txpool = { package = "sc-transaction-pool", path = "../../../../client/transaction-pool" } -- GitLab From a5739a99fbe41bf86a4731f6a0f9a0c54c40e879 Mon Sep 17 00:00:00 2001 From: thiolliere Date: Mon, 2 Dec 2019 13:01:29 +0100 Subject: [PATCH 060/172] Add `swap` and `decode_len` to `DoubleMap` finishing #3749 (#4264) * Add `swap` and `decode_len` to `DoubleMap` * Add tests to `swap` and `decode_len` for `DoubleMap` (WIP) * Address review comments * Remove function that is not in scope * fix test * better naming --- bin/node/runtime/src/lib.rs | 2 +- frame/support/src/lib.rs | 30 +++++++++++++ .../src/storage/generator/double_map.rs | 42 ++++++++++++++++++- frame/support/src/storage/mod.rs | 21 ++++++++++ frame/support/test/tests/decl_storage.rs | 16 +++++++ 5 files changed, 109 insertions(+), 2 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 90085ce801..3cb4912571 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -79,7 +79,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // implementation changes and behavior does not, then leave spec_version as // is and increment impl_version. spec_version: 197, - impl_version: 197, + impl_version: 198, apis: RUNTIME_API_VERSIONS, }; diff --git a/frame/support/src/lib.rs b/frame/support/src/lib.rs index bdcde0f159..0a7a967db8 100644 --- a/frame/support/src/lib.rs +++ b/frame/support/src/lib.rs @@ -292,6 +292,36 @@ mod tests { }); } + #[test] + fn double_map_swap_works() { + new_test_ext().execute_with(|| { + DataDM::insert(0, 1, 1); + DataDM::insert(1, 0, 2); + DataDM::insert(1, 1, 3); + + let get_all = || vec![ + DataDM::get(0, 1), + DataDM::get(1, 0), + DataDM::get(1, 1), + DataDM::get(2, 0), + DataDM::get(2, 1), + ]; + assert_eq!(get_all(), vec![1, 2, 3, 0, 0]); + + // Two existing + DataDM::swap(0, 1, 1, 0); + assert_eq!(get_all(), vec![2, 1, 3, 0, 0]); + + // Left existing + DataDM::swap(1, 0, 2, 0); + assert_eq!(get_all(), vec![2, 0, 3, 1, 0]); + + // Right existing + DataDM::swap(2, 1, 1, 1); + assert_eq!(get_all(), vec![2, 0, 0, 1, 3]); + }); + } + #[test] fn linked_map_basic_insert_remove_should_work() { new_test_ext().execute_with(|| { diff --git a/frame/support/src/storage/generator/double_map.rs b/frame/support/src/storage/generator/double_map.rs index 28378034b2..8917cbf952 100644 --- a/frame/support/src/storage/generator/double_map.rs +++ b/frame/support/src/storage/generator/double_map.rs @@ -17,7 +17,7 @@ use rstd::prelude::*; use rstd::borrow::Borrow; use codec::{Ref, FullCodec, FullEncode, Encode, EncodeLike, EncodeAppend}; -use crate::{storage::{self, unhashed}, hash::{StorageHasher, Twox128}}; +use crate::{storage::{self, unhashed}, hash::{StorageHasher, Twox128}, traits::Len}; /// Generator for `StorageDoubleMap` used by `decl_storage`. /// @@ -137,6 +137,29 @@ where G::from_optional_value_to_query(value) } + fn swap(x_k1: XKArg1, x_k2: XKArg2, y_k1: YKArg1, y_k2: YKArg2) + where + XKArg1: EncodeLike, + XKArg2: EncodeLike, + YKArg1: EncodeLike, + YKArg2: EncodeLike + { + let final_x_key = Self::storage_double_map_final_key(x_k1, x_k2); + let final_y_key = Self::storage_double_map_final_key(y_k1, y_k2); + + let v1 = unhashed::get_raw(&final_x_key); + if let Some(val) = unhashed::get_raw(&final_y_key) { + unhashed::put_raw(&final_x_key, &val); + } else { + unhashed::kill(&final_x_key) + } + if let Some(val) = v1 { + unhashed::put_raw(&final_y_key, &val); + } else { + unhashed::kill(&final_y_key) + } + } + fn insert(k1: KArg1, k2: KArg2, val: VArg) where KArg1: EncodeLike, @@ -225,4 +248,21 @@ where Self::append(Ref::from(&k1), Ref::from(&k2), items.clone()) .unwrap_or_else(|_| Self::insert(k1, k2, items)); } + + fn decode_len(key1: KArg1, key2: KArg2) -> Result + where KArg1: EncodeLike, + KArg2: EncodeLike, + V: codec::DecodeLength + Len, + { + let final_key = Self::storage_double_map_final_key(key1, key2); + if let Some(v) = unhashed::get_raw(&final_key) { + ::len(&v).map_err(|e| e.what()) + } else { + let len = G::from_query_to_optional_value(G::from_optional_value_to_query(None)) + .map(|v| v.len()) + .unwrap_or(0); + + Ok(len) + } + } } diff --git a/frame/support/src/storage/mod.rs b/frame/support/src/storage/mod.rs index 88818b84e2..7c8ce9c24f 100644 --- a/frame/support/src/storage/mod.rs +++ b/frame/support/src/storage/mod.rs @@ -284,6 +284,14 @@ pub trait StorageDoubleMap { KArg1: EncodeLike, KArg2: EncodeLike; + /// Swap the values of two key-pairs. + fn swap(x_k1: XKArg1, x_k2: XKArg2, y_k1: YKArg1, y_k2: YKArg2) + where + XKArg1: EncodeLike, + XKArg2: EncodeLike, + YKArg1: EncodeLike, + YKArg2: EncodeLike; + fn insert(k1: KArg1, k2: KArg2, val: VArg) where KArg1: EncodeLike, @@ -330,4 +338,17 @@ pub trait StorageDoubleMap { V: EncodeAppend, Items: IntoIterator + Clone + EncodeLike, Items::IntoIter: ExactSizeIterator; + + /// Read the length of the value in a fast way, without decoding the entire value. + /// + /// `V` is required to implement `Codec::DecodeLength`. + /// + /// Note that `0` is returned as the default value if no encoded value exists at the given key. + /// Therefore, this function cannot be used as a sign of _existence_. use the `::exists()` + /// function for this purpose. + fn decode_len(key1: KArg1, key2: KArg2) -> Result + where + KArg1: EncodeLike, + KArg2: EncodeLike, + V: codec::DecodeLength + Len; } diff --git a/frame/support/test/tests/decl_storage.rs b/frame/support/test/tests/decl_storage.rs index 396288d3be..cdd99275a6 100644 --- a/frame/support/test/tests/decl_storage.rs +++ b/frame/support/test/tests/decl_storage.rs @@ -521,6 +521,10 @@ mod test_append_and_len { MapVecWithDefault: map u32 => Vec = vec![6, 9]; OptionMapVec: map u32 => Option>; + DoubleMapVec: double_map u32, blake2_256(u32) => Vec; + DoubleMapVecWithDefault: double_map u32, blake2_256(u32) => Vec = vec![6, 9]; + OptionDoubleMapVec: double_map u32, blake2_256(u32) => Option>; + LinkedMapVec: linked_map u32 => Vec; LinkedMapVecWithDefault: linked_map u32 => Vec = vec![6, 9]; OptionLinkedMapVec: linked_map u32 => Option>; @@ -596,11 +600,13 @@ mod test_append_and_len { OptionVec::put(&vec![1, 2, 3, 4, 5]); MapVec::insert(1, &vec![1, 2, 3, 4, 5, 6]); LinkedMapVec::insert(2, &vec![1, 2, 3]); + DoubleMapVec::insert(0, 1, &vec![1, 2]); assert_eq!(JustVec::decode_len().unwrap(), 4); assert_eq!(OptionVec::decode_len().unwrap(), 5); assert_eq!(MapVec::decode_len(1).unwrap(), 6); assert_eq!(LinkedMapVec::decode_len(2).unwrap(), 3); + assert_eq!(DoubleMapVec::decode_len(0, 1).unwrap(), 2); }); } @@ -636,6 +642,16 @@ mod test_append_and_len { assert_eq!(OptionLinkedMapVec::get(0), None); assert_eq!(OptionLinkedMapVec::decode_len(0), Ok(0)); + + // Double map + assert_eq!(DoubleMapVec::get(0, 0), vec![]); + assert_eq!(DoubleMapVec::decode_len(0, 1), Ok(0)); + + assert_eq!(DoubleMapVecWithDefault::get(0, 0), vec![6, 9]); + assert_eq!(DoubleMapVecWithDefault::decode_len(0, 1), Ok(2)); + + assert_eq!(OptionDoubleMapVec::get(0, 0), None); + assert_eq!(OptionDoubleMapVec::decode_len(0, 1), Ok(0)); }); } } -- GitLab From d8d5da2c6b7c8bf0fda7b406c27ef659dba47cd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Mon, 2 Dec 2019 13:07:17 +0100 Subject: [PATCH 061/172] Improve error message on `can_author_with` failure (#4262) --- client/consensus/pow/src/lib.rs | 9 +++++---- client/consensus/slots/src/lib.rs | 19 ++++++++--------- primitives/consensus/common/src/lib.rs | 20 +++++++++--------- primitives/sr-version/src/lib.rs | 28 ++++++++++++++++++++++---- 4 files changed, 50 insertions(+), 26 deletions(-) diff --git a/client/consensus/pow/src/lib.rs b/client/consensus/pow/src/lib.rs index c2029ec720..087791ce89 100644 --- a/client/consensus/pow/src/lib.rs +++ b/client/consensus/pow/src/lib.rs @@ -467,11 +467,12 @@ fn mine_loop, C, Algorithm, E, SO, S, CAW>( }, }; - if can_author_with.can_author_with(&BlockId::Hash(best_hash)) { - debug!( + if let Err(err) = can_author_with.can_author_with(&BlockId::Hash(best_hash)) { + warn!( target: "pow", - "Skipping proposal `can_author_with` returned `false`. \ - Probably a node update is required!" + "Skipping proposal `can_author_with` returned: {} \ + Probably a node update is required!", + err, ); std::thread::sleep(std::time::Duration::from_secs(1)); continue 'outer diff --git a/client/consensus/slots/src/lib.rs b/client/consensus/slots/src/lib.rs index 744942e107..e6a5361c2f 100644 --- a/client/consensus/slots/src/lib.rs +++ b/client/consensus/slots/src/lib.rs @@ -348,7 +348,16 @@ where } }; - if can_author_with.can_author_with(&BlockId::Hash(chain_head.hash())) { + if let Err(err) = can_author_with.can_author_with(&BlockId::Hash(chain_head.hash())) { + warn!( + target: "slots", + "Unable to author block in slot {},. `can_author_with` returned: {} \ + Probably a node update is required!", + slot_num, + err, + ); + Either::Right(future::ready(Ok(()))) + } else { Either::Left( worker.on_slot(chain_head, slot_info) .map_err(|e| { @@ -356,14 +365,6 @@ where }) .or_else(|_| future::ready(Ok(()))) ) - } else { - warn!( - target: "slots", - "Unable to author block in slot {}. `can_author_with` returned `false`. \ - Probably a node update is required!", - slot_num, - ); - Either::Right(future::ready(Ok(()))) } }).then(|res| { if let Err(err) = res { diff --git a/primitives/consensus/common/src/lib.rs b/primitives/consensus/common/src/lib.rs index b662bf428a..3545083a42 100644 --- a/primitives/consensus/common/src/lib.rs +++ b/primitives/consensus/common/src/lib.rs @@ -137,7 +137,12 @@ impl SyncOracle for Arc where T: ?Sized, for<'r> &'r T: SyncOracle { /// at the given block. pub trait CanAuthorWith { /// See trait docs for more information. - fn can_author_with(&self, at: &BlockId) -> bool; + /// + /// # Return + /// + /// - Returns `Ok(())` when authoring is supported. + /// - Returns `Err(_)` when authoring is not supported. + fn can_author_with(&self, at: &BlockId) -> Result<(), String>; } /// Checks if the node can author blocks by using @@ -154,18 +159,15 @@ impl CanAuthorWithNativeVersion { impl, Block: BlockT> CanAuthorWith for CanAuthorWithNativeVersion { - fn can_author_with(&self, at: &BlockId) -> bool { + fn can_author_with(&self, at: &BlockId) -> Result<(), String> { match self.0.runtime_version(at) { Ok(version) => self.0.native_version().can_author_with(&version), Err(e) => { - error!( - target: "CanAuthorWithNativeVersion", + Err(format!( "Failed to get runtime version at `{}` and will disable authoring. Error: {}", at, e, - ); - - false + )) } } } @@ -175,7 +177,7 @@ impl, Block: BlockT> CanAuthorWith< pub struct AlwaysCanAuthor; impl CanAuthorWith for AlwaysCanAuthor { - fn can_author_with(&self, _: &BlockId) -> bool { - true + fn can_author_with(&self, _: &BlockId) -> Result<(), String> { + Ok(()) } } diff --git a/primitives/sr-version/src/lib.rs b/primitives/sr-version/src/lib.rs index 9b9a311c08..b567904b16 100644 --- a/primitives/sr-version/src/lib.rs +++ b/primitives/sr-version/src/lib.rs @@ -161,10 +161,30 @@ pub struct NativeVersion { #[cfg(feature = "std")] impl NativeVersion { /// Check if this version matches other version for authoring blocks. - pub fn can_author_with(&self, other: &RuntimeVersion) -> bool { - self.runtime_version.spec_name == other.spec_name && - (self.runtime_version.authoring_version == other.authoring_version || - self.can_author_with.contains(&other.authoring_version)) + /// + /// # Return + /// + /// - Returns `Ok(())` when authoring is supported. + /// - Returns `Err(_)` with a detailed error when authoring is not supported. + pub fn can_author_with(&self, other: &RuntimeVersion) -> Result<(), String> { + if self.runtime_version.spec_name != other.spec_name { + Err(format!( + "`spec_name` does not match `{}` vs `{}`", + self.runtime_version.spec_name, + other.spec_name, + )) + } else if (self.runtime_version.authoring_version != other.authoring_version + && !self.can_author_with.contains(&other.authoring_version)) + { + Err(format!( + "`authoring_version` does not match `{version}` vs `{other_version}` and \ + `can_author_with` not contains `{other_version}`", + version = self.runtime_version.authoring_version, + other_version = other.authoring_version, + )) + } else { + Ok(()) + } } } -- GitLab From b84b5ecd9e5ea6c767870ff12fab496e184bc686 Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Mon, 2 Dec 2019 14:21:32 +0100 Subject: [PATCH 062/172] Fix phragmen elections. (#4266) CC @kianenigma --- frame/elections-phragmen/src/lib.rs | 75 +++++++++++++++-------------- 1 file changed, 38 insertions(+), 37 deletions(-) diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index fe0ecede15..31e7cc9397 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -84,9 +84,8 @@ use rstd::prelude::*; use sp_runtime::{print, traits::{Zero, StaticLookup, Bounded, Convert}}; -use support::weights::SimpleDispatchInfo; use support::{ - decl_storage, decl_event, ensure, decl_module, dispatch, + decl_storage, decl_event, ensure, decl_module, dispatch, weights::SimpleDispatchInfo, traits::{ Currency, Get, LockableCurrency, LockIdentifier, ReservableCurrency, WithdrawReasons, ChangeMembers, OnUnbalanced, WithdrawReason @@ -391,11 +390,11 @@ decl_module! { /// Writes: O(do_phragmen) /// # #[weight = SimpleDispatchInfo::FixedOperational(2_000_000)] - fn remove_member(origin, who: ::Source) { + fn remove_member(origin, who: ::Source) -> dispatch::Result { ensure_root(origin)?; let who = T::Lookup::lookup(who)?; - return Self::remove_and_replace_member(&who).map(|had_replacement| { + Self::remove_and_replace_member(&who).map(|had_replacement| { let (imbalance, _) = T::Currency::slash_reserved(&who, T::CandidacyBond::get()); T::KickedMember::on_unbalanced(imbalance); Self::deposit_event(RawEvent::MemberKicked(who.clone())); @@ -403,8 +402,6 @@ decl_module! { if !had_replacement { Self::do_phragmen(); } - - () }) } @@ -452,37 +449,25 @@ impl Module { if let Ok(index) = members_with_stake.binary_search_by(|(ref m, ref _s)| m.cmp(who)) { members_with_stake.remove(index); - let mut runners_up = Self::runners_up(); - if let Some((replacement, stake)) = runners_up.pop() { - // replace the outgoing with the best runner up. - if let Err(index) = members_with_stake - .binary_search_by(|(ref m, ref _s)| m.cmp(&replacement)) - { - members_with_stake.insert(index, (replacement.clone(), stake)); - ElectionRounds::mutate(|v| *v += 1); - T::ChangeMembers::change_members_sorted( - &[replacement], - &[who.clone()], - &members_with_stake - .iter() - .map(|(m, _)| m.clone()) - .collect::>(), - ); - } - // else it would mean that the runner up was already a member. This cannot - // happen. If it does, not much that we can do about it. - - >::put(members_with_stake); - >::put(runners_up); - - Ok(true) - } else { - // update `Members` storage -- `do_phragmen` adds this to the candidate list. - >::put(members_with_stake); + let next_up = >::mutate(|runners_up| runners_up.pop()); + let maybe_replacement = next_up.and_then(|(replacement, stake)| + members_with_stake.binary_search_by(|(ref m, ref _s)| m.cmp(&replacement)) + .err() + .map(|index| { + members_with_stake.insert(index, (replacement.clone(), stake)); + replacement + }) + ); - // signal caller that no replacement has been found. - Ok(false) + >::put(&members_with_stake); + let members = members_with_stake.into_iter().map(|m| m.0).collect::>(); + let result = Ok(maybe_replacement.is_some()); + let old = [who.clone()]; + match maybe_replacement { + Some(new) => T::ChangeMembers::change_members_sorted(&[new], &old, &members), + None => T::ChangeMembers::change_members_sorted(&[], &old, &members), } + result } else { Err("not a member") } @@ -690,7 +675,7 @@ impl Module { T::ChangeMembers::change_members_sorted( &incoming, &outgoing.clone(), - &Self::members_ids(), + &new_members_ids, ); // outgoing candidates lose their bond. @@ -826,9 +811,25 @@ mod tests { fn get() -> u64 { TERM_DURATION.with(|v| *v.borrow()) } } + thread_local! { + pub static MEMBERS: RefCell> = RefCell::new(vec![]); +} + pub struct TestChangeMembers; impl ChangeMembers for TestChangeMembers { - fn change_members_sorted(_: &[u64], _: &[u64], _: &[u64]) {} + fn change_members_sorted(incoming: &[u64], outgoing: &[u64], new: &[u64]) { + let mut old_plus_incoming = MEMBERS.with(|m| m.borrow().to_vec()); + old_plus_incoming.extend_from_slice(incoming); + old_plus_incoming.sort(); + + let mut new_plus_outgoing = new.to_vec(); + new_plus_outgoing.extend_from_slice(outgoing); + new_plus_outgoing.sort(); + + assert_eq!(old_plus_incoming, new_plus_outgoing); + + MEMBERS.with(|m| *m.borrow_mut() = new.to_vec()); + } } /// Simple structure that exposes how u64 currency can be represented as... u64. -- GitLab From 8091a0e5360c7d26a03c099e703c832c81ee2e4d Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Mon, 2 Dec 2019 14:24:49 +0100 Subject: [PATCH 063/172] Whitespace fix from #4266 review. --- frame/elections-phragmen/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index 31e7cc9397..8a3e5d74b3 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -812,8 +812,8 @@ mod tests { } thread_local! { - pub static MEMBERS: RefCell> = RefCell::new(vec![]); -} + pub static MEMBERS: RefCell> = RefCell::new(vec![]); + } pub struct TestChangeMembers; impl ChangeMembers for TestChangeMembers { -- GitLab From ee3a1f1413ee2b712613a052848df5da4cfb7d47 Mon Sep 17 00:00:00 2001 From: Denis Pisarev Date: Mon, 2 Dec 2019 17:58:37 +0100 Subject: [PATCH 064/172] interruptible test and build jobs (#4271) --- .gitlab-ci.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 91994487b7..ede9f2fd7d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -15,6 +15,7 @@ stages: variables: GIT_STRATEGY: fetch + GIT_DEPTH: "3" CARGO_HOME: "/ci-cache/${CI_PROJECT_NAME}/cargo/${CI_JOB_NAME}" SCCACHE_DIR: "/ci-cache/${CI_PROJECT_NAME}/sccache" CARGO_INCREMENTAL: 0 @@ -55,6 +56,8 @@ variables: - runner_system_failure - unknown_failure - api_failure + dependencies: [] + interruptible: true tags: - linux-docker @@ -79,6 +82,7 @@ check-runtime: GITHUB_API_PROJECT: "parity%2Finfrastructure%2Fgithub-api" script: - ./.maintain/gitlab/check_runtime.sh + interruptible: true allow_failure: true @@ -90,6 +94,7 @@ check-line-width: - /^[0-9]+$/ script: - ./.maintain/gitlab/check_line_width.sh + interruptible: true allow_failure: true @@ -351,8 +356,6 @@ check_polkadot: stage: build <<: *docker-env allow_failure: true - dependencies: - - test-linux-stable script: - COMMIT_HASH=$(git rev-parse HEAD) - SUBSTRATE_PATH=$(pwd) -- GitLab From 561457e9be000c2c062ce3d3a76c98af3479ef3b Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Mon, 2 Dec 2019 19:24:25 +0000 Subject: [PATCH 065/172] Fix sp-session typo (#4273) * Fix sp-session typo * Remove erroneous whitespaces * Don't mess with the file, editor --- .maintain/rename-crates-for-2.0.sh | 8 ++++---- Cargo.lock | 12 ++++++------ bin/node-template/runtime/Cargo.toml | 4 ++-- bin/node-template/runtime/src/lib.rs | 2 +- bin/node/runtime/Cargo.toml | 4 ++-- bin/node/runtime/src/lib.rs | 2 +- client/rpc/Cargo.toml | 2 +- client/service/Cargo.toml | 2 +- primitives/session/Cargo.toml | 2 +- test/utils/runtime/Cargo.toml | 2 +- 10 files changed, 20 insertions(+), 20 deletions(-) diff --git a/.maintain/rename-crates-for-2.0.sh b/.maintain/rename-crates-for-2.0.sh index 89bd2f9b33..cd68abac98 100644 --- a/.maintain/rename-crates-for-2.0.sh +++ b/.maintain/rename-crates-for-2.0.sh @@ -22,7 +22,7 @@ function rename() { rename_gitlabci $old $new # and it appears, we have the same syntax in rust files rust_rename $old $new - + # but generally we have the snail case syntax in rust files old=$(echo $old | sed s/-/_/g ); new=$(echo $new | sed s/-/_/g ); @@ -57,7 +57,7 @@ TO_RENAME=( "substrate-runtime-interface-proc-macro sp-runtime-interface-proc-macro" "substrate-runtime-interface-test-wasm sp-runtime-interface-test-wasm" "substrate-serializer sp-serializer" - "substrate-session sp-sesssion" + "substrate-session sp-session" "sr-api sp-api" "sr-api-proc-macro sp-api-proc-macro" "sr-api-test sp-api-test" @@ -103,10 +103,10 @@ TO_RENAME=( "substrate-state-db sc-state-db" "substrate-telemetry sc-telemetry" "substrate-tracing sc-tracing" - + ); for rule in "${TO_RENAME[@]}" do rename "$rule"; -done \ No newline at end of file +done diff --git a/Cargo.lock b/Cargo.lock index 4cfd25f917..557d1dd1f2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3148,7 +3148,7 @@ dependencies = [ "sp-keyring 2.0.0", "sp-offchain 2.0.0", "sp-runtime 2.0.0", - "sp-sesssion 2.0.0", + "sp-session 2.0.0", "sp-staking 2.0.0", "sp-std 2.0.0", "sp-transaction-pool-runtime-api 2.0.0", @@ -3216,7 +3216,7 @@ dependencies = [ "sp-io 2.0.0", "sp-offchain 2.0.0", "sp-runtime 2.0.0", - "sp-sesssion 2.0.0", + "sp-session 2.0.0", "sp-std 2.0.0", "sp-transaction-pool-runtime-api 2.0.0", "sp-version 2.0.0", @@ -5392,7 +5392,7 @@ dependencies = [ "sp-io 2.0.0", "sp-rpc 2.0.0", "sp-runtime 2.0.0", - "sp-sesssion 2.0.0", + "sp-session 2.0.0", "sp-state-machine 2.0.0", "sp-transaction-pool-api 2.0.0", "sp-version 2.0.0", @@ -5487,7 +5487,7 @@ dependencies = [ "sp-finality-granpda 2.0.0", "sp-io 2.0.0", "sp-runtime 2.0.0", - "sp-sesssion 2.0.0", + "sp-session 2.0.0", "sp-transaction-pool-api 2.0.0", "sp-transaction-pool-runtime-api 2.0.0", "substrate-test-runtime-client 2.0.0", @@ -6319,7 +6319,7 @@ dependencies = [ ] [[package]] -name = "sp-sesssion" +name = "sp-session" version = "2.0.0" dependencies = [ "sp-api 2.0.0", @@ -6646,7 +6646,7 @@ dependencies = [ "sp-offchain 2.0.0", "sp-runtime 2.0.0", "sp-runtime-interface 2.0.0", - "sp-sesssion 2.0.0", + "sp-session 2.0.0", "sp-state-machine 2.0.0", "sp-std 2.0.0", "sp-transaction-pool-runtime-api 2.0.0", diff --git a/bin/node-template/runtime/Cargo.toml b/bin/node-template/runtime/Cargo.toml index 1f71c426fe..51f648185e 100644 --- a/bin/node-template/runtime/Cargo.toml +++ b/bin/node-template/runtime/Cargo.toml @@ -23,7 +23,7 @@ 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 } sp-runtime = { path = "../../../primitives/sr-primitives", default-features = false } -sp-sesssion = { path = "../../../primitives/session", default-features = false } +sp-session = { path = "../../../primitives/session", default-features = false } sudo = { package = "pallet-sudo", path = "../../../frame/sudo", default-features = false } support = { package = "frame-support", path = "../../../frame/support", default-features = false } system = { package = "frame-system", path = "../../../frame/system", default-features = false } @@ -56,7 +56,7 @@ std = [ "serde", "sp-api/std", "sp-runtime/std", - "sp-sesssion/std", + "sp-session/std", "sudo/std", "support/std", "system/std", diff --git a/bin/node-template/runtime/src/lib.rs b/bin/node-template/runtime/src/lib.rs index f16018da8f..3d1cf2d519 100644 --- a/bin/node-template/runtime/src/lib.rs +++ b/bin/node-template/runtime/src/lib.rs @@ -350,7 +350,7 @@ impl_runtime_apis! { } } - impl sp_sesssion::SessionKeys for Runtime { + impl sp_session::SessionKeys for Runtime { fn generate_session_keys(seed: Option>) -> Vec { opaque::SessionKeys::generate(seed) } diff --git a/bin/node/runtime/Cargo.toml b/bin/node/runtime/Cargo.toml index 18e307c55b..7744fb4737 100644 --- a/bin/node/runtime/Cargo.toml +++ b/bin/node/runtime/Cargo.toml @@ -26,7 +26,7 @@ sp-api = { path = "../../../primitives/sr-api", default-features = false } sp-runtime = { path = "../../../primitives/sr-primitives", default-features = false } sp-staking = { path = "../../../primitives/sr-staking-primitives", default-features = false } sp-keyring = { path = "../../../primitives/keyring", optional = true } -sp-sesssion = { path = "../../../primitives/session", default-features = false } +sp-session = { path = "../../../primitives/session", default-features = false } txpool-runtime-api = { package = "sp-transaction-pool-runtime-api", path = "../../../primitives/transaction-pool/runtime-api", default-features = false } version = { package = "sp-version", path = "../../../primitives/sr-version", default-features = false } @@ -107,7 +107,7 @@ std = [ "sp-staking/std", "staking/std", "sp-keyring", - "sp-sesssion/std", + "sp-session/std", "sudo/std", "support/std", "system-rpc-runtime-api/std", diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 3cb4912571..ca451db15e 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -711,7 +711,7 @@ impl_runtime_apis! { } } - impl sp_sesssion::SessionKeys for Runtime { + impl sp_session::SessionKeys for Runtime { fn generate_session_keys(seed: Option>) -> Vec { SessionKeys::generate(seed) } diff --git a/client/rpc/Cargo.toml b/client/rpc/Cargo.toml index 5bb947eb0c..20214d5796 100644 --- a/client/rpc/Cargo.toml +++ b/client/rpc/Cargo.toml @@ -17,7 +17,7 @@ primitives = { package = "sp-core", path = "../../primitives/core" } rpc = { package = "jsonrpc-core", version = "14.0.3" } runtime_version = { package = "sp-version", path = "../../primitives/sr-version" } serde_json = "1.0.41" -session = { package = "sp-sesssion", path = "../../primitives/session" } +session = { package = "sp-session", path = "../../primitives/session" } sp-runtime = { path = "../../primitives/sr-primitives" } rpc-primitives = { package = "sp-rpc", path = "../../primitives/rpc" } state_machine = { package = "sp-state-machine", path = "../../primitives/state-machine" } diff --git a/client/service/Cargo.toml b/client/service/Cargo.toml index 426c3a76dc..e03c263b80 100644 --- a/client/service/Cargo.toml +++ b/client/service/Cargo.toml @@ -33,7 +33,7 @@ sp-io = { path = "../../primitives/sr-io" } sp-runtime = { path = "../../primitives/sr-primitives" } sp-blockchain = { path = "../../primitives/blockchain" } primitives = { package = "sp-core", path = "../../primitives/core" } -session = { package = "sp-sesssion", path = "../../primitives/session" } +session = { package = "sp-session", path = "../../primitives/session" } app-crypto = { package = "sc-application-crypto", path = "../../primitives/application-crypto" } consensus_common = { package = "sp-consensus", path = "../../primitives/consensus/common" } network = { package = "sc-network", path = "../network" } diff --git a/primitives/session/Cargo.toml b/primitives/session/Cargo.toml index 447cf8ad1b..e1fbd3e9a9 100644 --- a/primitives/session/Cargo.toml +++ b/primitives/session/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "sp-sesssion" +name = "sp-session" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" diff --git a/test/utils/runtime/Cargo.toml b/test/utils/runtime/Cargo.toml index 77224c2ef1..ed7d98f064 100644 --- a/test/utils/runtime/Cargo.toml +++ b/test/utils/runtime/Cargo.toml @@ -25,7 +25,7 @@ runtime_io = { package = "sp-io", path = "../../../primitives/sr-io", default-fe 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"] } -session = { package = "sp-sesssion", path = "../../../primitives/session", default-features = false } +session = { package = "sp-session", path = "../../../primitives/session", default-features = false } sp-api = { path = "../../../primitives/sr-api", default-features = false } sp-runtime = { path = "../../../primitives/sr-primitives", default-features = false } pallet-babe = { path = "../../../frame/babe", default-features = false } -- GitLab From 90fc72346ca6f34a0649f508d7a0edab9b32983a Mon Sep 17 00:00:00 2001 From: Max Inden Date: Mon, 2 Dec 2019 20:44:09 +0100 Subject: [PATCH 066/172] docs/CODEOWNERS: Add mxinden to authority discovery modules (#4275) --- docs/CODEOWNERS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/CODEOWNERS b/docs/CODEOWNERS index 29f510a556..7b67cb30f8 100644 --- a/docs/CODEOWNERS +++ b/docs/CODEOWNERS @@ -66,3 +66,7 @@ # Support crates /frame/support/ @thiolliere @kianenigma + +# Authority discovery +/client/authority-discovery/ @mxinden +/frame/authority-discovery/ @mxinden -- GitLab From c837c8d9216d310a0e6938496c33161680ed2355 Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Mon, 2 Dec 2019 21:11:11 +0100 Subject: [PATCH 067/172] Another fix for elections-phragmen (#4276) * Another fix for elections phragmen CC @kianenigma * Test for correct sorting. --- frame/elections-phragmen/src/lib.rs | 45 ++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index 8a3e5d74b3..df7a223610 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -611,8 +611,12 @@ impl Module { ); if let Some(phragmen_result) = maybe_phragmen_result { - let old_members = >::take(); - let old_runners = >::take(); + let old_members_ids = >::take().into_iter() + .map(|(m, _)| m) + .collect::>(); + let old_runners_up_ids = >::take().into_iter() + .map(|(r, _)| r) + .collect::>(); // filter out those who had literally no votes at all. // AUDIT/NOTE: the need to do this is because all candidates, even those who have no @@ -645,32 +649,35 @@ impl Module { }) .collect::)>>(); - // split new set into winners and runner ups. + // split new set into winners and runners up. let split_point = desired_seats.min(new_set_with_stake.len()); let mut new_members = (&new_set_with_stake[..split_point]).to_vec(); + + // save the runners up as-is. They are sorted based on desirability. + // sort and save the members. + new_members.sort_by(|i, j| i.0.cmp(&j.0)); + + // new_members_ids is sorted by account id. let new_members_ids = new_members .iter() .map(|(m, _)| m.clone()) .collect::>(); + let new_runners_up = &new_set_with_stake[split_point..] .into_iter() .cloned() .rev() .collect::)>>(); + // new_runners_up remains sorted by desirability. let new_runners_up_ids = new_runners_up .iter() .map(|(r, _)| r.clone()) .collect::>(); - - // save the runners as-is. They are sorted based on desirability. - // sort and save the members. - new_members.sort(); - // report member changes. We compute diff because we need the outgoing list. let (incoming, outgoing) = T::ChangeMembers::compute_members_diff( &new_members_ids, - &old_members.into_iter().map(|(m, _)| m).collect::>(), + &old_members_ids, ); T::ChangeMembers::change_members_sorted( &incoming, @@ -685,7 +692,7 @@ impl Module { { let (_, outgoing) = T::ChangeMembers::compute_members_diff( &new_runners_up_ids, - &old_runners.into_iter().map(|(r, _)| r).collect::>(), + &old_runners_up_ids, ); to_burn_bond.extend(outgoing); } @@ -818,6 +825,24 @@ mod tests { pub struct TestChangeMembers; impl ChangeMembers for TestChangeMembers { fn change_members_sorted(incoming: &[u64], outgoing: &[u64], new: &[u64]) { + // new, incoming, outgoing must be sorted. + let mut new_sorted = new.to_vec(); + new_sorted.sort(); + assert_eq!(new, &new_sorted[..]); + + let mut incoming_sorted = incoming.to_vec(); + incoming_sorted.sort(); + assert_eq!(incoming, &incoming_sorted[..]); + + let mut outgoing_sorted = outgoing.to_vec(); + outgoing_sorted.sort(); + assert_eq!(outgoing, &outgoing_sorted[..]); + + // incoming and outgoing must be disjoint + for x in incoming.iter() { + assert!(outgoing.binary_search(x).is_err()); + } + let mut old_plus_incoming = MEMBERS.with(|m| m.borrow().to_vec()); old_plus_incoming.extend_from_slice(incoming); old_plus_incoming.sort(); -- GitLab From 368318c9b11c07596cde5dc37220258cfa7dfa76 Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Tue, 3 Dec 2019 00:49:27 +0100 Subject: [PATCH 068/172] Enumeratable dispatches using unhashed index in key. (#4278) --- bin/node/runtime/src/lib.rs | 2 +- frame/democracy/src/lib.rs | 2 +- primitives/sr-version/src/lib.rs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index ca451db15e..4ba355e8f3 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -78,7 +78,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // and set impl_version to equal spec_version. If only runtime // implementation changes and behavior does not, then leave spec_version as // is and increment impl_version. - spec_version: 197, + spec_version: 198, impl_version: 198, apis: RUNTIME_API_VERSIONS, }; diff --git a/frame/democracy/src/lib.rs b/frame/democracy/src/lib.rs index 54044cd1fa..33fe6453fc 100644 --- a/frame/democracy/src/lib.rs +++ b/frame/democracy/src/lib.rs @@ -283,7 +283,7 @@ decl_storage! { map ReferendumIndex => Option<(ReferendumInfo)>; /// Queue of successful referenda to be dispatched. pub DispatchQueue get(fn dispatch_queue): - map T::BlockNumber => Vec>; + map hasher(twox_64_concat) T::BlockNumber => Vec>; /// Get the voters for the current proposal. pub VotersFor get(fn voters_for): map ReferendumIndex => Vec; diff --git a/primitives/sr-version/src/lib.rs b/primitives/sr-version/src/lib.rs index b567904b16..edb4aa851e 100644 --- a/primitives/sr-version/src/lib.rs +++ b/primitives/sr-version/src/lib.rs @@ -173,8 +173,8 @@ impl NativeVersion { self.runtime_version.spec_name, other.spec_name, )) - } else if (self.runtime_version.authoring_version != other.authoring_version - && !self.can_author_with.contains(&other.authoring_version)) + } else if self.runtime_version.authoring_version != other.authoring_version + && !self.can_author_with.contains(&other.authoring_version) { Err(format!( "`authoring_version` does not match `{version}` vs `{other_version}` and \ -- GitLab From 186f9f871fc206acb827a33e13cdef3580db39db Mon Sep 17 00:00:00 2001 From: Keith Ingram Date: Tue, 3 Dec 2019 00:29:46 -0800 Subject: [PATCH 069/172] Council members (#4279) --- bin/node/cli/src/chain_spec.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/node/cli/src/chain_spec.rs b/bin/node/cli/src/chain_spec.rs index 51ef7590ac..2950843f68 100644 --- a/bin/node/cli/src/chain_spec.rs +++ b/bin/node/cli/src/chain_spec.rs @@ -258,11 +258,13 @@ pub fn testnet_genesis( }), democracy: Some(DemocracyConfig::default()), collective_Instance1: Some(CouncilConfig { - members: vec![], + members: endowed_accounts.iter().cloned() + .collect::>()[..5].to_vec(), phantom: Default::default(), }), collective_Instance2: Some(TechnicalCommitteeConfig { - members: vec![], + members: endowed_accounts.iter().cloned() + .collect::>()[..5].to_vec(), phantom: Default::default(), }), contracts: Some(ContractsConfig { -- GitLab From 042dc459f3875d65bec412068ba1939172c5e8c2 Mon Sep 17 00:00:00 2001 From: Arkadiy Paronyan Date: Tue, 3 Dec 2019 11:33:33 +0100 Subject: [PATCH 070/172] Reputation changes requires reason (#4277) --- .../src/communication/gossip.rs | 30 ++++--- .../finality-grandpa/src/communication/mod.rs | 52 +++++------ .../src/communication/tests.rs | 4 +- client/network/src/legacy_proto/behaviour.rs | 5 +- client/network/src/lib.rs | 1 + client/network/src/protocol.rs | 87 +++++++++++-------- .../network/src/protocol/consensus_gossip.rs | 30 ++++--- client/network/src/protocol/light_dispatch.rs | 13 +-- client/network/src/protocol/sync.rs | 75 +++++++++------- client/network/src/service.rs | 14 +-- client/network/src/test/mod.rs | 4 +- client/peerset/src/lib.rs | 68 +++++++++++---- client/peerset/tests/fuzz.rs | 4 +- client/service/src/lib.rs | 4 +- 14 files changed, 234 insertions(+), 157 deletions(-) diff --git a/client/finality-grandpa/src/communication/gossip.rs b/client/finality-grandpa/src/communication/gossip.rs index 9795121882..af08e76157 100644 --- a/client/finality-grandpa/src/communication/gossip.rs +++ b/client/finality-grandpa/src/communication/gossip.rs @@ -84,7 +84,7 @@ use sp_runtime::traits::{NumberFor, Block as BlockT, Zero}; use network::consensus_gossip::{self as network_gossip, MessageIntent, ValidatorContext}; -use network::{config::Roles, PeerId}; +use network::{config::Roles, PeerId, ReputationChange}; use codec::{Encode, Decode}; use fg_primitives::AuthorityId; @@ -114,7 +114,7 @@ const ROUND_DURATION: u32 = 4; // measured in gossip durations const MIN_LUCKY: usize = 5; -type Report = (PeerId, i32); +type Report = (PeerId, ReputationChange); /// An outcome of examining a message. #[derive(Debug, PartialEq, Clone, Copy)] @@ -384,14 +384,19 @@ pub(super) enum Misbehavior { } impl Misbehavior { - pub(super) fn cost(&self) -> i32 { + pub(super) fn cost(&self) -> ReputationChange { use Misbehavior::*; match *self { InvalidViewChange => cost::INVALID_VIEW_CHANGE, - UndecodablePacket(bytes) => bytes.saturating_mul(cost::PER_UNDECODABLE_BYTE), - BadCatchUpMessage { signatures_checked } => + UndecodablePacket(bytes) => ReputationChange::new( + bytes.saturating_mul(cost::PER_UNDECODABLE_BYTE), + "Grandpa: Bad packet", + ), + BadCatchUpMessage { signatures_checked } => ReputationChange::new( cost::PER_SIGNATURE_CHECKED.saturating_mul(signatures_checked), + "Grandpa: Bad cath-up message", + ), BadCommitMessage { signatures_checked, blocks_loaded, equivocations_caught } => { let cost = cost::PER_SIGNATURE_CHECKED .saturating_mul(signatures_checked) @@ -399,7 +404,7 @@ impl Misbehavior { let benefit = equivocations_caught.saturating_mul(benefit::PER_EQUIVOCATION); - (benefit as i32).saturating_add(cost as i32) + ReputationChange::new((benefit as i32).saturating_add(cost as i32), "Grandpa: Bad commit") }, FutureMessage => cost::FUTURE_MESSAGE, OutOfScopeMessage => cost::OUT_OF_SCOPE_MESSAGE, @@ -551,11 +556,11 @@ impl Peers { #[derive(Debug, PartialEq)] pub(super) enum Action { // repropagate under given topic, to the given peers, applying cost/benefit to originator. - Keep(H, i32), + Keep(H, ReputationChange), // discard and process. - ProcessAndDiscard(H, i32), + ProcessAndDiscard(H, ReputationChange), // discard, applying cost/benefit to originator. - Discard(i32), + Discard(ReputationChange), } /// State of catch up request handling. @@ -731,7 +736,7 @@ impl Inner { .unwrap_or(Consider::RejectOutOfScope) } - fn cost_past_rejection(&self, _who: &PeerId, _round: Round, _set_id: SetId) -> i32 { + fn cost_past_rejection(&self, _who: &PeerId, _round: Round, _set_id: SetId) -> ReputationChange { // hardcoded for now. cost::PAST_REJECTION } @@ -783,7 +788,6 @@ impl Inner { return Action::Discard(self.cost_past_rejection(who, full.round, full.set_id)), Consider::RejectOutOfScope => return Action::Discard(Misbehavior::OutOfScopeMessage.cost()), Consider::Accept => {}, - } if full.message.precommits.len() != full.message.auth_data.len() || full.message.precommits.is_empty() { @@ -1221,7 +1225,7 @@ impl GossipValidator { self.inner.write().note_catch_up_message_processed(); } - fn report(&self, who: PeerId, cost_benefit: i32) { + fn report(&self, who: PeerId, cost_benefit: ReputationChange) { let _ = self.report_sender.unbounded_send(PeerReport { who, cost_benefit }); } @@ -1443,7 +1447,7 @@ impl network_gossip::Validator for GossipValidator struct PeerReport { who: PeerId, - cost_benefit: i32, + cost_benefit: ReputationChange, } // wrapper around a stream of reports. diff --git a/client/finality-grandpa/src/communication/mod.rs b/client/finality-grandpa/src/communication/mod.rs index 8354d41bb0..f705812271 100644 --- a/client/finality-grandpa/src/communication/mod.rs +++ b/client/finality-grandpa/src/communication/mod.rs @@ -35,7 +35,7 @@ use futures03::stream::{StreamExt, TryStreamExt}; use grandpa::Message::{Prevote, Precommit, PrimaryPropose}; use grandpa::{voter, voter_set::VoterSet}; use log::{debug, trace}; -use network::{consensus_gossip as network_gossip, NetworkService}; +use network::{consensus_gossip as network_gossip, NetworkService, ReputationChange}; use network_gossip::ConsensusMessage; use codec::{Encode, Decode}; use primitives::Pair; @@ -65,33 +65,35 @@ pub use fg_primitives::GRANDPA_ENGINE_ID; // cost scalars for reporting peers. mod cost { - pub(super) const PAST_REJECTION: i32 = -50; - pub(super) const BAD_SIGNATURE: i32 = -100; - pub(super) const MALFORMED_CATCH_UP: i32 = -1000; - pub(super) const MALFORMED_COMMIT: i32 = -1000; - pub(super) const FUTURE_MESSAGE: i32 = -500; - pub(super) const UNKNOWN_VOTER: i32 = -150; - - pub(super) const INVALID_VIEW_CHANGE: i32 = -500; + use network::ReputationChange as Rep; + pub(super) const PAST_REJECTION: Rep = Rep::new(-50, "Grandpa: Past message"); + pub(super) const BAD_SIGNATURE: Rep = Rep::new(-100, "Grandpa: Bad signature"); + pub(super) const MALFORMED_CATCH_UP: Rep = Rep::new(-1000, "Grandpa: Malformed cath-up"); + pub(super) const MALFORMED_COMMIT: Rep = Rep::new(-1000, "Grandpa: Malformed commit"); + pub(super) const FUTURE_MESSAGE: Rep = Rep::new(-500, "Grandpa: Future message"); + pub(super) const UNKNOWN_VOTER: Rep = Rep::new(-150, "Grandpa: Uknown voter"); + + pub(super) const INVALID_VIEW_CHANGE: Rep = Rep::new(-500, "Grandpa: Invalid view change"); pub(super) const PER_UNDECODABLE_BYTE: i32 = -5; pub(super) const PER_SIGNATURE_CHECKED: i32 = -25; pub(super) const PER_BLOCK_LOADED: i32 = -10; - pub(super) const INVALID_CATCH_UP: i32 = -5000; - pub(super) const INVALID_COMMIT: i32 = -5000; - pub(super) const OUT_OF_SCOPE_MESSAGE: i32 = -500; - pub(super) const CATCH_UP_REQUEST_TIMEOUT: i32 = -200; + pub(super) const INVALID_CATCH_UP: Rep = Rep::new(-5000, "Grandpa: Invalid catch-up"); + pub(super) const INVALID_COMMIT: Rep = Rep::new(-5000, "Grandpa: Invalid commit"); + pub(super) const OUT_OF_SCOPE_MESSAGE: Rep = Rep::new(-500, "Grandpa: Out-of-scope message"); + pub(super) const CATCH_UP_REQUEST_TIMEOUT: Rep = Rep::new(-200, "Grandpa: Catch-up reqeust timeout"); // cost of answering a catch up request - pub(super) const CATCH_UP_REPLY: i32 = -200; - pub(super) const HONEST_OUT_OF_SCOPE_CATCH_UP: i32 = -200; + pub(super) const CATCH_UP_REPLY: Rep = Rep::new(-200, "Grandpa: Catch-up reply"); + pub(super) const HONEST_OUT_OF_SCOPE_CATCH_UP: Rep = Rep::new(-200, "Grandpa: Out-of-scope catch-up"); } // benefit scalars for reporting peers. mod benefit { - pub(super) const NEIGHBOR_MESSAGE: i32 = 100; - pub(super) const ROUND_MESSAGE: i32 = 100; - pub(super) const BASIC_VALIDATED_CATCH_UP: i32 = 200; - pub(super) const BASIC_VALIDATED_COMMIT: i32 = 100; + use network::ReputationChange as Rep; + pub(super) const NEIGHBOR_MESSAGE: Rep = Rep::new(100, "Grandpa: Neighbor message"); + pub(super) const ROUND_MESSAGE: Rep = Rep::new(100, "Grandpa: Round message"); + pub(super) const BASIC_VALIDATED_CATCH_UP: Rep = Rep::new(200, "Grandpa: Catch-up message"); + pub(super) const BASIC_VALIDATED_COMMIT: Rep = Rep::new(100, "Grandpa: Commit"); pub(super) const PER_EQUIVOCATION: i32 = 10; } @@ -125,7 +127,7 @@ pub trait Network: Clone + Send + 'static { fn send_message(&self, who: Vec, data: Vec); /// Report a peer's cost or benefit after some action. - fn report(&self, who: network::PeerId, cost_benefit: i32); + fn report(&self, who: network::PeerId, cost_benefit: ReputationChange); /// Inform peers that a block with given hash should be downloaded. fn announce(&self, block: Block::Hash, associated_data: Vec); @@ -217,7 +219,7 @@ impl Network for Arc> where }) } - fn report(&self, who: network::PeerId, cost_benefit: i32) { + fn report(&self, who: network::PeerId, cost_benefit: ReputationChange) { self.report_peer(who, cost_benefit) } @@ -803,7 +805,7 @@ fn check_compact_commit( voters: &VoterSet, round: Round, set_id: SetId, -) -> Result<(), i32> { +) -> Result<(), ReputationChange> { // 4f + 1 = equivocations from f voters. let f = voters.total_weight() - voters.threshold(); let full_threshold = voters.total_weight() + f; @@ -862,7 +864,7 @@ fn check_catch_up( msg: &CatchUp, voters: &VoterSet, set_id: SetId, -) -> Result<(), i32> { +) -> Result<(), ReputationChange> { // 4f + 1 = equivocations from f voters. let f = voters.total_weight() - voters.threshold(); let full_threshold = voters.total_weight() + f; @@ -872,7 +874,7 @@ fn check_catch_up( voters: &'a VoterSet, votes: impl Iterator, full_threshold: u64, - ) -> Result<(), i32> { + ) -> Result<(), ReputationChange> { let mut total_weight = 0; for id in votes { @@ -911,7 +913,7 @@ fn check_catch_up( round: RoundNumber, set_id: SetIdNumber, mut signatures_checked: usize, - ) -> Result where + ) -> Result where B: BlockT, I: Iterator, &'a AuthorityId, &'a AuthoritySignature)>, { diff --git a/client/finality-grandpa/src/communication/tests.rs b/client/finality-grandpa/src/communication/tests.rs index 2d08ecbde7..b36f8ad3e6 100644 --- a/client/finality-grandpa/src/communication/tests.rs +++ b/client/finality-grandpa/src/communication/tests.rs @@ -37,7 +37,7 @@ enum Event { RegisterValidator(Arc>), GossipMessage(Hash, Vec, bool), SendMessage(Vec, Vec), - Report(network::PeerId, i32), + Report(network::PeerId, network::ReputationChange), Announce(Hash), } @@ -85,7 +85,7 @@ impl super::Network for TestNetwork { } /// Report a peer's cost or benefit after some action. - fn report(&self, who: network::PeerId, cost_benefit: i32) { + fn report(&self, who: network::PeerId, cost_benefit: network::ReputationChange) { let _ = self.sender.unbounded_send(Event::Report(who, cost_benefit)); } diff --git a/client/network/src/legacy_proto/behaviour.rs b/client/network/src/legacy_proto/behaviour.rs index d1d378174a..f890219158 100644 --- a/client/network/src/legacy_proto/behaviour.rs +++ b/client/network/src/legacy_proto/behaviour.rs @@ -940,7 +940,10 @@ where // a different chain, or a node that doesn't speak the same protocol(s). We // decrease the node's reputation, hence lowering the chances we try this node // again in the short term. - self.peerset.report_peer(source.clone(), i32::min_value()); + self.peerset.report_peer( + source.clone(), + peerset::ReputationChange::new(i32::min_value(), "Protocol error") + ); self.disconnect_peer_inner(&source, Some(Duration::from_secs(5))); } } diff --git a/client/network/src/lib.rs b/client/network/src/lib.rs index 9b25992dd9..1816a21f97 100644 --- a/client/network/src/lib.rs +++ b/client/network/src/lib.rs @@ -199,6 +199,7 @@ pub use libp2p::multiaddr; pub use message::{generic as generic_message, RequestId, Status as StatusMessage}; pub use on_demand_layer::{OnDemand, RemoteResponse}; +pub use peerset::ReputationChange; // Used by the `construct_simple_protocol!` macro. #[doc(hidden)] diff --git a/client/network/src/protocol.rs b/client/network/src/protocol.rs index 6b9c0755c0..c8a4fadbff 100644 --- a/client/network/src/protocol.rs +++ b/client/network/src/protocol.rs @@ -88,23 +88,38 @@ const MAX_CONSENSUS_MESSAGES: usize = 256; /// and disconnect to free connection slot. const LIGHT_MAXIMAL_BLOCKS_DIFFERENCE: u64 = 8192; -/// Reputation change when a peer is "clogged", meaning that it's not fast enough to process our -/// messages. -const CLOGGED_PEER_REPUTATION_CHANGE: i32 = -(1 << 12); -/// Reputation change when a peer doesn't respond in time to our messages. -const TIMEOUT_REPUTATION_CHANGE: i32 = -(1 << 10); -/// Reputation change when a peer sends us a status message while we already received one. -const UNEXPECTED_STATUS_REPUTATION_CHANGE: i32 = -(1 << 20); -/// Reputation change when we are a light client and a peer is behind us. -const PEER_BEHIND_US_LIGHT_REPUTATION_CHANGE: i32 = -(1 << 8); -/// Reputation change when a peer sends us an extrinsic that we didn't know about. -const GOOD_EXTRINSIC_REPUTATION_CHANGE: i32 = 1 << 7; -/// Reputation change when a peer sends us a bad extrinsic. -const BAD_EXTRINSIC_REPUTATION_CHANGE: i32 = -(1 << 12); -/// We sent an RPC query to the given node, but it failed. -const RPC_FAILED_REPUTATION_CHANGE: i32 = -(1 << 12); -/// We received a message that failed to decode. -const BAD_MESSAGE_REPUTATION_CHANGE: i32 = -(1 << 12); +mod rep { + use peerset::ReputationChange as Rep; + /// Reputation change when a peer is "clogged", meaning that it's not fast enough to process our + /// messages. + pub const CLOGGED_PEER: Rep = Rep::new(-(1 << 12), "Clogged message queue"); + /// Reputation change when a peer doesn't respond in time to our messages. + pub const TIMEOUT: Rep = Rep::new(-(1 << 10), "Request timeout"); + /// Reputation change when a peer sends us a status message while we already received one. + pub const UNEXPECTED_STATUS: Rep = Rep::new(-(1 << 20), "Unexpected status message"); + /// Reputation change when we are a light client and a peer is behind us. + pub const PEER_BEHIND_US_LIGHT: Rep = Rep::new(-(1 << 8), "Useless for a light peer"); + /// Reputation change when a peer sends us an extrinsic that we didn't know about. + pub const GOOD_EXTRINSIC: Rep = Rep::new(1 << 7, "Good extrinsic"); + /// Reputation change when a peer sends us a bad extrinsic. + pub const BAD_EXTRINSIC: Rep = Rep::new(-(1 << 12), "Bad extrinsic"); + /// We sent an RPC query to the given node, but it failed. + pub const RPC_FAILED: Rep = Rep::new(-(1 << 12), "Remote call failed"); + /// We received a message that failed to decode. + pub const BAD_MESSAGE: Rep = Rep::new(-(1 << 12), "Bad message"); + /// We received an unexpected response. + pub const UNEXPECTED_RESPONSE: Rep = Rep::new_fatal("Unexpected response packet"); + /// We received an unexpected extrinsic packet. + pub const UNEXPECTED_EXTRINSICS: Rep = Rep::new_fatal("Unexpected extrinsics packet"); + /// We received an unexpected light node request. + pub const UNEXPECTED_REQUEST: Rep = Rep::new_fatal("Unexpected block request packet"); + /// Peer has different genesis. + pub const GENESIS_MISMATCH: Rep = Rep::new_fatal("Genesis mismatch"); + /// Peer is on unsupported protocol version. + pub const BAD_PROTOCOL: Rep = Rep::new_fatal("Unsupported protocol"); + /// Peer role does not match (e.g. light peer connecting to another light peer). + pub const BAD_ROLE: Rep = Rep::new_fatal("Unsupported role"); +} // Lock must always be taken in order declared here. pub struct Protocol, H: ExHashT> { @@ -183,7 +198,7 @@ struct LightDispatchIn<'a> { } impl<'a, B: BlockT> LightDispatchNetwork for LightDispatchIn<'a> { - fn report_peer(&mut self, who: &PeerId, reputation: i32) { + fn report_peer(&mut self, who: &PeerId, reputation: peerset::ReputationChange) { self.peerset.report_peer(who.clone(), reputation) } @@ -303,7 +318,7 @@ impl<'a, B: BlockT> LightDispatchNetwork for LightDispatchIn<'a> { pub trait Context { /// Adjusts the reputation of the peer. Use this to point out that a peer has been malign or /// irresponsible or appeared lazy. - fn report_peer(&mut self, who: PeerId, reputation: i32); + fn report_peer(&mut self, who: PeerId, reputation: peerset::ReputationChange); /// Force disconnecting from a peer. Use this when a peer misbehaved. fn disconnect_peer(&mut self, who: PeerId); @@ -333,7 +348,7 @@ impl<'a, B: BlockT + 'a, H: 'a + ExHashT> ProtocolContext<'a, B, H> { } impl<'a, B: BlockT + 'a, H: ExHashT + 'a> Context for ProtocolContext<'a, B, H> { - fn report_peer(&mut self, who: PeerId, reputation: i32) { + fn report_peer(&mut self, who: PeerId, reputation: peerset::ReputationChange) { self.peerset_handle.report_peer(who, reputation) } @@ -557,7 +572,7 @@ impl, H: ExHashT> Protocol { return request.map(|(_, r)| r) } trace!(target: "sync", "Unexpected response packet from {} ({})", who, response.id); - self.peerset_handle.report_peer(who.clone(), i32::min_value()); + self.peerset_handle.report_peer(who.clone(), rep::UNEXPECTED_RESPONSE); self.behaviour.disconnect_peer(&who); } None @@ -587,7 +602,7 @@ impl, H: ExHashT> Protocol { Ok(message) => message, Err(err) => { debug!(target: "sync", "Couldn't decode packet sent by {}: {:?}: {}", who, data, err.what()); - self.peerset_handle.report_peer(who.clone(), BAD_MESSAGE_REPUTATION_CHANGE); + self.peerset_handle.report_peer(who.clone(), rep::BAD_MESSAGE); return CustomMessageOutcome::None; } }; @@ -755,7 +770,7 @@ impl, H: ExHashT> Protocol { /// Called as a back-pressure mechanism if the networking detects that the peer cannot process /// our messaging rate fast enough. pub fn on_clogged_peer(&self, who: PeerId, _msg: Option>) { - self.peerset_handle.report_peer(who.clone(), CLOGGED_PEER_REPUTATION_CHANGE); + self.peerset_handle.report_peer(who.clone(), rep::CLOGGED_PEER); // Print some diagnostics. if let Some(peer) = self.context_data.peers.get(&who) { @@ -784,7 +799,7 @@ impl, H: ExHashT> Protocol { if !self.config.roles.is_full() { trace!(target: "sync", "Peer {} is trying to sync from the light node", peer); self.behaviour.disconnect_peer(&peer); - self.peerset_handle.report_peer(peer, i32::min_value()); + self.peerset_handle.report_peer(peer, rep::UNEXPECTED_REQUEST); return; } @@ -846,7 +861,7 @@ impl, H: ExHashT> Protocol { } /// Adjusts the reputation of a node. - pub fn report_peer(&self, who: PeerId, reputation: i32) { + pub fn report_peer(&self, who: PeerId, reputation: peerset::ReputationChange) { self.peerset_handle.report_peer(who, reputation) } @@ -953,7 +968,7 @@ impl, H: ExHashT> Protocol { ); for p in aborting { self.behaviour.disconnect_peer(&p); - self.peerset_handle.report_peer(p, TIMEOUT_REPUTATION_CHANGE); + self.peerset_handle.report_peer(p, rep::TIMEOUT); } } @@ -967,7 +982,7 @@ impl, H: ExHashT> Protocol { if self.important_peers.contains(&who) { Level::Warn } else { Level::Debug }, "Unexpected status packet from {}", who ); - self.peerset_handle.report_peer(who, UNEXPECTED_STATUS_REPUTATION_CHANGE); + self.peerset_handle.report_peer(who, rep::UNEXPECTED_STATUS); return; } if status.genesis_hash != self.genesis_hash { @@ -977,7 +992,7 @@ impl, H: ExHashT> Protocol { "Peer is on different chain (our genesis: {} theirs: {})", self.genesis_hash, status.genesis_hash ); - self.peerset_handle.report_peer(who.clone(), i32::min_value()); + self.peerset_handle.report_peer(who.clone(), rep::GENESIS_MISMATCH); self.behaviour.disconnect_peer(&who); return; } @@ -987,7 +1002,7 @@ impl, H: ExHashT> Protocol { if self.important_peers.contains(&who) { Level::Warn } else { Level::Trace }, "Peer {:?} using unsupported protocol version {}", who, status.version ); - self.peerset_handle.report_peer(who.clone(), i32::min_value()); + self.peerset_handle.report_peer(who.clone(), rep::BAD_PROTOCOL); self.behaviour.disconnect_peer(&who); return; } @@ -996,7 +1011,7 @@ impl, H: ExHashT> Protocol { // we're not interested in light peers if status.roles.is_light() { debug!(target: "sync", "Peer {} is unable to serve light requests", who); - self.peerset_handle.report_peer(who.clone(), i32::min_value()); + self.peerset_handle.report_peer(who.clone(), rep::BAD_ROLE); self.behaviour.disconnect_peer(&who); return; } @@ -1013,7 +1028,7 @@ impl, H: ExHashT> Protocol { .saturated_into::(); if blocks_difference > LIGHT_MAXIMAL_BLOCKS_DIFFERENCE { debug!(target: "sync", "Peer {} is far behind us and will unable to serve light requests", who); - self.peerset_handle.report_peer(who.clone(), PEER_BEHIND_US_LIGHT_REPUTATION_CHANGE); + self.peerset_handle.report_peer(who.clone(), rep::PEER_BEHIND_US_LIGHT); self.behaviour.disconnect_peer(&who); return; } @@ -1082,7 +1097,7 @@ impl, H: ExHashT> Protocol { if !self.config.roles.is_full() { trace!(target: "sync", "Peer {} is trying to send extrinsic to the light node", who); self.behaviour.disconnect_peer(&who); - self.peerset_handle.report_peer(who, i32::min_value()); + self.peerset_handle.report_peer(who, rep::UNEXPECTED_EXTRINSICS); return; } @@ -1100,8 +1115,8 @@ impl, H: ExHashT> Protocol { self.transaction_pool.import( self.peerset_handle.clone().into(), who.clone(), - GOOD_EXTRINSIC_REPUTATION_CHANGE, - BAD_EXTRINSIC_REPUTATION_CHANGE, + rep::GOOD_EXTRINSIC, + rep::BAD_EXTRINSIC, t, ); } @@ -1351,7 +1366,7 @@ impl, H: ExHashT> Protocol { request.block, error ); - self.peerset_handle.report_peer(who.clone(), RPC_FAILED_REPUTATION_CHANGE); + self.peerset_handle.report_peer(who.clone(), rep::RPC_FAILED); StorageProof::empty() } }; @@ -1679,7 +1694,7 @@ impl, H: ExHashT> Protocol { None }, }; - self.send_message( + self.send_message( &who, GenericMessage::FinalityProofResponse(message::FinalityProofResponse { id: 0, diff --git a/client/network/src/protocol/consensus_gossip.rs b/client/network/src/protocol/consensus_gossip.rs index 3062047952..24561debef 100644 --- a/client/network/src/protocol/consensus_gossip.rs +++ b/client/network/src/protocol/consensus_gossip.rs @@ -61,15 +61,19 @@ use crate::config::Roles; const KNOWN_MESSAGES_CACHE_SIZE: usize = 4096; const REBROADCAST_INTERVAL: time::Duration = time::Duration::from_secs(30); -/// Reputation change when a peer sends us a gossip message that we didn't know about. -const GOSSIP_SUCCESS_REPUTATION_CHANGE: i32 = 1 << 4; -/// Reputation change when a peer sends us a gossip message that we already knew about. -const DUPLICATE_GOSSIP_REPUTATION_CHANGE: i32 = -(1 << 2); -/// Reputation change when a peer sends us a gossip message for an unknown engine, whatever that -/// means. -const UNKNOWN_GOSSIP_REPUTATION_CHANGE: i32 = -(1 << 6); -/// Reputation change when a peer sends a message from a topic it isn't registered on. -const UNREGISTERED_TOPIC_REPUTATION_CHANGE: i32 = -(1 << 10); + +mod rep { + use peerset::ReputationChange as Rep; + /// Reputation change when a peer sends us a gossip message that we didn't know about. + pub const GOSSIP_SUCCESS: Rep = Rep::new(1 << 4, "Successfull gossip"); + /// Reputation change when a peer sends us a gossip message that we already knew about. + pub const DUPLICATE_GOSSIP: Rep = Rep::new(-(1 << 2), "Duplicate gossip"); + /// Reputation change when a peer sends us a gossip message for an unknown engine, whatever that + /// means. + pub const UNKNOWN_GOSSIP: Rep = Rep::new(-(1 << 6), "Unknown gossup message engine id"); + /// Reputation change when a peer sends a message from a topic it isn't registered on. + pub const UNREGISTERED_TOPIC: Rep = Rep::new(-(1 << 10), "Unregistered gossip message topic"); +} struct PeerConsensus { known_messages: HashSet, @@ -470,7 +474,7 @@ impl ConsensusGossip { if self.known_messages.contains(&message_hash) { trace!(target:"gossip", "Ignored already known message from {}", who); - protocol.report_peer(who.clone(), DUPLICATE_GOSSIP_REPUTATION_CHANGE); + protocol.report_peer(who.clone(), rep::DUPLICATE_GOSSIP); continue; } @@ -489,14 +493,14 @@ impl ConsensusGossip { Some(ValidationResult::Discard) => None, None => { trace!(target:"gossip", "Unknown message engine id {:?} from {}", engine_id, who); - protocol.report_peer(who.clone(), UNKNOWN_GOSSIP_REPUTATION_CHANGE); + protocol.report_peer(who.clone(), rep::UNKNOWN_GOSSIP); protocol.disconnect_peer(who.clone()); continue; } }; if let Some((topic, keep)) = validation_result { - protocol.report_peer(who.clone(), GOSSIP_SUCCESS_REPUTATION_CHANGE); + protocol.report_peer(who.clone(), rep::GOSSIP_SUCCESS); if let Some(ref mut peer) = self.peers.get_mut(&who) { peer.known_messages.insert(message_hash); if let Entry::Occupied(mut entry) = self.live_message_sinks.entry((engine_id, topic)) { @@ -519,7 +523,7 @@ impl ConsensusGossip { } } else { trace!(target:"gossip", "Ignored statement from unregistered peer {}", who); - protocol.report_peer(who.clone(), UNREGISTERED_TOPIC_REPUTATION_CHANGE); + protocol.report_peer(who.clone(), rep::UNREGISTERED_TOPIC); } } else { trace!(target:"gossip", "Handled valid one hop message from peer {}", who); diff --git a/client/network/src/protocol/light_dispatch.rs b/client/network/src/protocol/light_dispatch.rs index 7d37b49b6c..ef240cbf06 100644 --- a/client/network/src/protocol/light_dispatch.rs +++ b/client/network/src/protocol/light_dispatch.rs @@ -33,6 +33,7 @@ use crate::message::{self, BlockAttributes, Direction, FromBlock, RequestId}; use libp2p::PeerId; use crate::config::Roles; use sp_runtime::traits::{Block as BlockT, Header as HeaderT, NumberFor}; +use peerset::ReputationChange; /// Remote request timeout. const REQUEST_TIMEOUT: Duration = Duration::from_secs(15); @@ -44,7 +45,7 @@ const TIMEOUT_REPUTATION_CHANGE: i32 = -(1 << 8); /// Trait used by the `LightDispatch` service to communicate messages back to the network. pub trait LightDispatchNetwork { /// Adjusts the reputation of the given peer. - fn report_peer(&mut self, who: &PeerId, reputation_change: i32); + fn report_peer(&mut self, who: &PeerId, reputation_change: ReputationChange); /// Disconnect from the given peer. Used in case of misbehaviour. fn disconnect_peer(&mut self, who: &PeerId); @@ -267,7 +268,7 @@ impl LightDispatch where Some(request) => request, None => { info!("Invalid remote {} response from peer {}", rtype, peer); - network.report_peer(&peer, i32::min_value()); + network.report_peer(&peer, ReputationChange::new_fatal("Invalid remote response")); network.disconnect_peer(&peer); self.remove_peer(peer); return; @@ -279,7 +280,7 @@ impl LightDispatch where Accept::Ok => (retry_count, None), Accept::CheckFailed(error, retry_request_data) => { info!("Failed to check remote {} response from peer {}: {}", rtype, peer, error); - network.report_peer(&peer, i32::min_value()); + network.report_peer(&peer, ReputationChange::new_fatal("Failed remote response check")); network.disconnect_peer(&peer); self.remove_peer(peer); @@ -293,7 +294,7 @@ impl LightDispatch where }, Accept::Unexpected(retry_request_data) => { info!("Unexpected response to remote {} from peer", rtype); - network.report_peer(&peer, i32::min_value()); + network.report_peer(&peer, ReputationChange::new_fatal("Unexpected remote response")); network.disconnect_peer(&peer); self.remove_peer(peer); @@ -350,7 +351,7 @@ impl LightDispatch where let (bad_peer, request) = self.active_peers.pop_front().expect("front() is Some as checked above"); self.pending_requests.push_front(request); - network.report_peer(&bad_peer, TIMEOUT_REPUTATION_CHANGE); + network.report_peer(&bad_peer, ReputationChange::new(TIMEOUT_REPUTATION_CHANGE, "Light request timeout")); network.disconnect_peer(&bad_peer); } @@ -800,7 +801,7 @@ pub mod tests { } impl<'a, B: BlockT> LightDispatchNetwork for &'a mut DummyNetwork { - fn report_peer(&mut self, _: &PeerId, _: i32) {} + fn report_peer(&mut self, _: &PeerId, _: crate::ReputationChange) {} fn disconnect_peer(&mut self, who: &PeerId) { self.disconnected_peers.insert(who.clone()); } diff --git a/client/network/src/protocol/sync.rs b/client/network/src/protocol/sync.rs index 01f36bd4da..ca332d46f1 100644 --- a/client/network/src/protocol/sync.rs +++ b/client/network/src/protocol/sync.rs @@ -72,29 +72,34 @@ const MAJOR_SYNC_BLOCKS: u8 = 5; /// Number of recently announced blocks to track for each peer. const ANNOUNCE_HISTORY_SIZE: usize = 64; -/// Reputation change when a peer sent us a status message that led to a -/// database read error. -const BLOCKCHAIN_STATUS_READ_ERROR_REPUTATION_CHANGE: i32 = -(1 << 16); +mod rep { + use peerset::ReputationChange as Rep; + /// Reputation change when a peer sent us a message that led to a + /// database read error. + pub const BLOCKCHAIN_READ_ERROR: Rep = Rep::new(-(1 << 16), "DB Error"); -/// Reputation change when a peer failed to answer our legitimate ancestry -/// block search. -const ANCESTRY_BLOCK_ERROR_REPUTATION_CHANGE: i32 = -(1 << 9); + /// Reputation change when a peer sent us a status message with a different + /// genesis than us. + pub const GENESIS_MISMATCH: Rep = Rep::new(i32::min_value(), "Genesis mismatch"); -/// Reputation change when a peer sent us a status message with a different -/// genesis than us. -const GENESIS_MISMATCH_REPUTATION_CHANGE: i32 = i32::min_value() + 1; + /// Reputation change for peers which send us a block with an incomplete header. + pub const INCOMPLETE_HEADER: Rep = Rep::new(-(1 << 20), "Incomplete header"); -/// Reputation change for peers which send us a block with an incomplete header. -const INCOMPLETE_HEADER_REPUTATION_CHANGE: i32 = -(1 << 20); + /// Reputation change for peers which send us a block which we fail to verify. + pub const VERIFICATION_FAIL: Rep = Rep::new(-(1 << 20), "Block verification failed"); -/// Reputation change for peers which send us a block which we fail to verify. -const VERIFICATION_FAIL_REPUTATION_CHANGE: i32 = -(1 << 20); + /// Reputation change for peers which send us a known bad block. + pub const BAD_BLOCK: Rep = Rep::new(-(1 << 29), "Bad block"); -/// Reputation change for peers which send us a bad block. -const BAD_BLOCK_REPUTATION_CHANGE: i32 = -(1 << 29); + /// Reputation change for peers which send us a block with bad justifications. + pub const BAD_JUSTIFICATION: Rep = Rep::new(-(1 << 16), "Bad justification"); -/// Reputation change for peers which send us a block with bad justifications. -const BAD_JUSTIFICATION_REPUTATION_CHANGE: i32 = -(1 << 16); + /// Reputation change for peers which send us a block with bad finality proof. + pub const BAD_FINALITY_PROOF: Rep = Rep::new(-(1 << 16), "Bad finality proof"); + + /// Reputation change when a peer sent us invlid ancestry result. + pub const UNKNOWN_ANCESTOR:Rep = Rep::new(-(1 << 16), "DB Error"); +} /// The main data structure which contains all the state for a chains /// active syncing strategy. @@ -225,11 +230,11 @@ pub struct Status { /// A peer did not behave as expected and should be reported. #[derive(Debug, Clone, PartialEq, Eq)] -pub struct BadPeer(pub PeerId, pub i32); +pub struct BadPeer(pub PeerId, pub peerset::ReputationChange); impl fmt::Display for BadPeer { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "bad peer {}; reputation change: {}", self.0, self.1) + write!(f, "Bad peer {}; Reputation change: {:?}", self.0, self.1) } } @@ -358,16 +363,16 @@ impl ChainSync { match self.block_status(&best_hash) { Err(e) => { debug!(target:"sync", "Error reading blockchain: {:?}", e); - Err(BadPeer(who, BLOCKCHAIN_STATUS_READ_ERROR_REPUTATION_CHANGE)) + Err(BadPeer(who, rep::BLOCKCHAIN_READ_ERROR)) } Ok(BlockStatus::KnownBad) => { info!("New peer with known bad best block {} ({}).", best_hash, best_number); - Err(BadPeer(who, i32::min_value())) + Err(BadPeer(who, rep::BAD_BLOCK)) } Ok(BlockStatus::Unknown) => { if best_number.is_zero() { info!("New peer with unknown genesis hash {} ({}).", best_hash, best_number); - return Err(BadPeer(who, i32::min_value())) + return Err(BadPeer(who, rep::GENESIS_MISMATCH)); } // If there are more than `MAJOR_SYNC_BLOCKS` in the import queue then we have // enough to do in the import queue that it's not worth kicking off @@ -688,11 +693,11 @@ impl ChainSync { }, (None, _) => { debug!(target: "sync", "Invalid response when searching for ancestor from {}", who); - return Err(BadPeer(who, i32::min_value())) + return Err(BadPeer(who, rep::UNKNOWN_ANCESTOR)) }, (_, Err(e)) => { info!("Error answering legitimate blockchain query: {:?}", e); - return Err(BadPeer(who, ANCESTRY_BLOCK_ERROR_REPUTATION_CHANGE)) + return Err(BadPeer(who, rep::BLOCKCHAIN_READ_ERROR)) } }; if matching_hash.is_some() && peer.common_number < *num { @@ -700,7 +705,7 @@ impl ChainSync { } if matching_hash.is_none() && num.is_zero() { trace!(target:"sync", "Ancestry search: genesis mismatch for peer {}", who); - return Err(BadPeer(who, GENESIS_MISMATCH_REPUTATION_CHANGE)) + return Err(BadPeer(who, rep::GENESIS_MISMATCH)) } if let Some((next_state, next_num)) = handle_ancestor_search_state(state, *num, matching_hash.is_some()) { peer.state = PeerSyncState::AncestorSearch(next_num, next_state); @@ -790,9 +795,10 @@ impl ChainSync { if let Some(block) = response.blocks.into_iter().next() { if hash != block.hash { info!( + target: "sync", "Invalid block justification provided by {}: requested: {:?} got: {:?}", who, hash, block.hash ); - return Err(BadPeer(who, i32::min_value())) + return Err(BadPeer(who, rep::BAD_JUSTIFICATION)); } if let Some((peer, hash, number, j)) = self.extra_justifications.on_response(who, block.justification) { return Ok(OnBlockJustification::Import { peer, hash, number, justification: j }) @@ -825,8 +831,13 @@ impl ChainSync { // We only request one finality proof at a time. if hash != resp.block { - info!("Invalid block finality proof provided: requested: {:?} got: {:?}", hash, resp.block); - return Err(BadPeer(who, i32::min_value())) + info!( + target: "sync", + "Invalid block finality proof provided: requested: {:?} got: {:?}", + hash, + resp.block + ); + return Err(BadPeer(who, rep::BAD_FINALITY_PROOF)); } if let Some((peer, hash, number, p)) = self.extra_finality_proofs.on_response(who, resp.proof) { @@ -887,7 +898,7 @@ impl ChainSync { if aux.bad_justification { if let Some(peer) = who { info!("Sent block with bad justification to import"); - output.push(Err(BadPeer(peer, BAD_JUSTIFICATION_REPUTATION_CHANGE))); + output.push(Err(BadPeer(peer, rep::BAD_JUSTIFICATION))); } } @@ -903,21 +914,21 @@ impl ChainSync { Err(BlockImportError::IncompleteHeader(who)) => { if let Some(peer) = who { info!("Peer sent block with incomplete header to import"); - output.push(Err(BadPeer(peer, INCOMPLETE_HEADER_REPUTATION_CHANGE))); + output.push(Err(BadPeer(peer, rep::INCOMPLETE_HEADER))); output.extend(self.restart()); } }, Err(BlockImportError::VerificationFailed(who, e)) => { if let Some(peer) = who { info!("Verification failed from peer: {}", e); - output.push(Err(BadPeer(peer, VERIFICATION_FAIL_REPUTATION_CHANGE))); + output.push(Err(BadPeer(peer, rep::VERIFICATION_FAIL))); output.extend(self.restart()); } }, Err(BlockImportError::BadBlock(who)) => { if let Some(peer) = who { info!("Bad block"); - output.push(Err(BadPeer(peer, BAD_BLOCK_REPUTATION_CHANGE))); + output.push(Err(BadPeer(peer, rep::BAD_BLOCK))); output.extend(self.restart()); } }, diff --git a/client/network/src/service.rs b/client/network/src/service.rs index 4a60c3def7..85fd1c3ff5 100644 --- a/client/network/src/service.rs +++ b/client/network/src/service.rs @@ -42,7 +42,7 @@ use sp_runtime::{traits::{Block as BlockT, NumberFor}, ConsensusEngineId}; use crate::{behaviour::{Behaviour, BehaviourOut}, config::{parse_str_addr, parse_addr}}; use crate::{NetworkState, NetworkStateNotConnectedPeer, NetworkStatePeer}; -use crate::{transport, config::NonReservedPeerMode}; +use crate::{transport, config::NonReservedPeerMode, ReputationChange}; use crate::config::{Params, TransportConfig}; use crate::error::Error; use crate::protocol::{self, Protocol, Context, CustomMessageOutcome, PeerInfo}; @@ -71,8 +71,8 @@ pub trait TransactionPool: Send + Sync { &self, report_handle: ReportHandle, who: PeerId, - reputation_change_good: i32, - reputation_change_bad: i32, + reputation_change_good: ReputationChange, + reputation_change_bad: ReputationChange, transaction: B::Extrinsic, ); /// Notify the pool about transactions broadcast. @@ -94,7 +94,7 @@ impl From for ReportHandle { impl ReportHandle { /// Report a given peer as either beneficial (+) or costly (-) according to the /// given scalar. - pub fn report_peer(&self, who: PeerId, cost_benefit: i32) { + pub fn report_peer(&self, who: PeerId, cost_benefit: ReputationChange) { self.inner.report_peer(who, cost_benefit); } } @@ -449,7 +449,7 @@ impl, H: ExHashT> NetworkServic /// Report a given peer as either beneficial (+) or costly (-) according to the /// given scalar. - pub fn report_peer(&self, who: PeerId, cost_benefit: i32) { + pub fn report_peer(&self, who: PeerId, cost_benefit: ReputationChange) { self.peerset.report_peer(who, cost_benefit); } @@ -786,7 +786,7 @@ impl<'a, B: BlockT, S: NetworkSpecialization, H: ExHashT> Link for Network if !success { info!("Invalid justification provided by {} for #{}", who, hash); self.protocol.user_protocol_mut().disconnect_peer(&who); - self.protocol.user_protocol_mut().report_peer(who, i32::min_value()); + self.protocol.user_protocol_mut().report_peer(who, ReputationChange::new_fatal("Invalid justification")); } } fn request_justification(&mut self, hash: &B::Hash, number: NumberFor) { @@ -806,7 +806,7 @@ impl<'a, B: BlockT, S: NetworkSpecialization, H: ExHashT> Link for Network if !success { info!("Invalid finality proof provided by {} for #{}", who, request_block.0); self.protocol.user_protocol_mut().disconnect_peer(&who); - self.protocol.user_protocol_mut().report_peer(who, i32::min_value()); + self.protocol.user_protocol_mut().report_peer(who, ReputationChange::new_fatal("Invalid finality proof")); } } } diff --git a/client/network/src/test/mod.rs b/client/network/src/test/mod.rs index d0cac918e7..f016ef99d8 100644 --- a/client/network/src/test/mod.rs +++ b/client/network/src/test/mod.rs @@ -401,8 +401,8 @@ impl TransactionPool for EmptyTransactionPool { &self, _report_handle: ReportHandle, _who: PeerId, - _rep_change_good: i32, - _rep_change_bad: i32, + _rep_change_good: crate::ReputationChange, + _rep_change_bad: crate::ReputationChange, _transaction: Extrinsic ) {} diff --git a/client/peerset/src/lib.rs b/client/peerset/src/lib.rs index a243fd00bd..ab7942f60d 100644 --- a/client/peerset/src/lib.rs +++ b/client/peerset/src/lib.rs @@ -38,12 +38,33 @@ enum Action { AddReservedPeer(PeerId), RemoveReservedPeer(PeerId), SetReservedOnly(bool), - ReportPeer(PeerId, i32), + ReportPeer(PeerId, ReputationChange), SetPriorityGroup(String, HashSet), AddToPriorityGroup(String, PeerId), RemoveFromPriorityGroup(String, PeerId), } +/// Shared handle to the peer set manager (PSM). Distributed around the code. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct ReputationChange { + /// Reputation delta. + pub value: i32, + /// Reason for reputation change. + pub reason: &'static str, +} + +impl ReputationChange { + /// New reputation change with given delta and reason. + pub const fn new(value: i32, reason: &'static str) -> ReputationChange { + ReputationChange { value, reason } + } + + /// New reputation change that forces minimum possible reputation. + pub const fn new_fatal(reason: &'static str) -> ReputationChange { + ReputationChange { value: i32::min_value(), reason } + } +} + /// Shared handle to the peer set manager (PSM). Distributed around the code. #[derive(Debug, Clone)] pub struct PeersetHandle { @@ -75,7 +96,7 @@ impl PeersetHandle { } /// Reports an adjustment to the reputation of the given peer. - pub fn report_peer(&self, peer_id: PeerId, score_diff: i32) { + pub fn report_peer(&self, peer_id: PeerId, score_diff: ReputationChange) { let _ = self.tx.unbounded_send(Action::ReportPeer(peer_id, score_diff)); } @@ -258,20 +279,27 @@ impl Peerset { self.alloc_slots(); } - fn on_report_peer(&mut self, peer_id: PeerId, score_diff: i32) { + fn on_report_peer(&mut self, peer_id: PeerId, change: ReputationChange) { // We want reputations to be up-to-date before adjusting them. self.update_time(); match self.data.peer(&peer_id) { peersstate::Peer::Connected(mut peer) => { - peer.add_reputation(score_diff); + peer.add_reputation(change.value); if peer.reputation() < BANNED_THRESHOLD { + debug!(target: "peerset", "Report {}: {:+} to {}. Reason: {}, Disconnecting", + peer_id, change.value, peer.reputation(), change.reason + ); peer.disconnect(); self.message_queue.push_back(Message::Drop(peer_id)); + } else { + trace!(target: "peerset", "Report {}: {:+} to {}. Reason: {}", + peer_id, change.value, peer.reputation(), change.reason + ); } }, - peersstate::Peer::NotConnected(mut peer) => peer.add_reputation(score_diff), - peersstate::Peer::Unknown(peer) => peer.discover().add_reputation(score_diff), + peersstate::Peer::NotConnected(mut peer) => peer.add_reputation(change.value), + peersstate::Peer::Unknown(peer) => peer.discover().add_reputation(change.value), } } @@ -293,7 +321,7 @@ impl Peerset { // takes `ln(0.5) / ln(k)` seconds to reduce the reputation by half. Use this formula to // empirically determine a value of `k` that looks correct. for _ in 0..secs_diff { - for peer in self.data.peers().cloned().collect::>() { + for peer_id in self.data.peers().cloned().collect::>() { // We use `k = 0.98`, so we divide by `50`. With that value, it takes 34.3 seconds // to reduce the reputation by half. fn reput_tick(reput: i32) -> i32 { @@ -305,13 +333,21 @@ impl Peerset { } reput.saturating_sub(diff) } - match self.data.peer(&peer) { - peersstate::Peer::Connected(mut peer) => - peer.set_reputation(reput_tick(peer.reputation())), - peersstate::Peer::NotConnected(mut peer) => - peer.set_reputation(reput_tick(peer.reputation())), + match self.data.peer(&peer_id) { + peersstate::Peer::Connected(mut peer) => { + let before = peer.reputation(); + let after = reput_tick(before); + trace!(target: "peerset", "Fleeting {}: {} -> {}", peer_id, before, after); + peer.set_reputation(after) + } + peersstate::Peer::NotConnected(mut peer) => { + let before = peer.reputation(); + let after = reput_tick(before); + trace!(target: "peerset", "Fleeting {}: {} -> {}", peer_id, before, after); + peer.set_reputation(after) + } peersstate::Peer::Unknown(_) => unreachable!("We iterate over known peers; qed") - } + }; } } } @@ -432,7 +468,7 @@ impl Peerset { } /// Reports an adjustment to the reputation of the given peer. - pub fn report_peer(&mut self, peer_id: PeerId, score_diff: i32) { + pub fn report_peer(&mut self, peer_id: PeerId, score_diff: ReputationChange) { // We don't immediately perform the adjustments in order to have state consistency. We // don't want the reporting here to take priority over messages sent using the // `PeersetHandle`. @@ -510,7 +546,7 @@ impl Stream for Peerset { mod tests { use libp2p::PeerId; use futures::prelude::*; - use super::{PeersetConfig, Peerset, Message, IncomingIndex, BANNED_THRESHOLD}; + use super::{PeersetConfig, Peerset, Message, IncomingIndex, ReputationChange, BANNED_THRESHOLD}; use std::{pin::Pin, task::Poll, thread, time::Duration}; fn assert_messages(mut peerset: Peerset, messages: Vec) -> Peerset { @@ -620,7 +656,7 @@ mod tests { // We ban a node by setting its reputation under the threshold. let peer_id = PeerId::random(); - handle.report_peer(peer_id.clone(), BANNED_THRESHOLD - 1); + handle.report_peer(peer_id.clone(), ReputationChange::new(BANNED_THRESHOLD - 1, "")); let fut = futures::future::poll_fn(move |cx| { // We need one polling for the message to be processed. diff --git a/client/peerset/tests/fuzz.rs b/client/peerset/tests/fuzz.rs index 604bbcc831..55d8fabbad 100644 --- a/client/peerset/tests/fuzz.rs +++ b/client/peerset/tests/fuzz.rs @@ -19,7 +19,7 @@ use libp2p::PeerId; use rand::distributions::{Distribution, Uniform, WeightedIndex}; use rand::seq::IteratorRandom; use std::{collections::HashMap, collections::HashSet, iter, pin::Pin, task::Poll}; -use sc_peerset::{IncomingIndex, Message, PeersetConfig, Peerset}; +use sc_peerset::{IncomingIndex, Message, PeersetConfig, Peerset, ReputationChange}; #[test] fn run() { @@ -97,7 +97,7 @@ fn test_once() { // If we generate 2, adjust a random reputation. 2 => if let Some(id) = known_nodes.iter().choose(&mut rng) { let val = Uniform::new_inclusive(i32::min_value(), i32::max_value()).sample(&mut rng); - peerset_handle.report_peer(id.clone(), val); + peerset_handle.report_peer(id.clone(), ReputationChange::new(val, "")); } // If we generate 3, disconnect from a random node. diff --git a/client/service/src/lib.rs b/client/service/src/lib.rs index 1a86e05b88..8e2be43965 100644 --- a/client/service/src/lib.rs +++ b/client/service/src/lib.rs @@ -629,8 +629,8 @@ where &self, report_handle: ReportHandle, who: PeerId, - reputation_change_good: i32, - reputation_change_bad: i32, + reputation_change_good: network::ReputationChange, + reputation_change_bad: network::ReputationChange, transaction: B::Extrinsic ) { if !self.imports_external_transactions { -- GitLab From e2e3c246b9a61d3eda9beab3e86d6654d0c17d5b Mon Sep 17 00:00:00 2001 From: Max Inden Date: Tue, 3 Dec 2019 18:03:08 +0100 Subject: [PATCH 071/172] client: Introduce --sentry-nodes flag (#4285) * client/authority-discovery: Add smoke tests for intervall_at * client/authority-discovery: Fix interval_at to fire on start * .maintain/sentry-node: Update docker compose file * client: Introduce --sentry-nodes flag Enable operators to specify the public addresses of sentry nodes infront of a validator node so that the validator node can announce the sentry node addresses instead of its own public addresses on the DHT via the authority discovery module. * client/authority-discovery: Break lines at 100 characters Limit line length to 100 instead of 120 characters. --- .maintain/sentry-node/docker-compose.yml | 32 ++-- bin/node/cli/src/service.rs | 7 +- client/authority-discovery/src/lib.rs | 230 +++++++++++++++++------ client/cli/src/lib.rs | 4 +- client/cli/src/params.rs | 8 + client/network/src/config.rs | 3 + client/service/test/src/lib.rs | 1 + 7 files changed, 205 insertions(+), 80 deletions(-) diff --git a/.maintain/sentry-node/docker-compose.yml b/.maintain/sentry-node/docker-compose.yml index dd2aee6995..37f0bea6b4 100644 --- a/.maintain/sentry-node/docker-compose.yml +++ b/.maintain/sentry-node/docker-compose.yml @@ -38,13 +38,12 @@ services: - "--base-path" - "/tmp/alice" - "--chain=local" - - "--key" - - "//Alice" - "--port" - "30333" - "--validator" - - "--name" - - "AlicesNode" + - "--alice" + - "--sentry-nodes" + - "/dns4/sentry-a/tcp/30333/p2p/QmV7EhW6J6KgmNdr558RH1mPx2xGGznW7At4BhXzntRFsi" - "--reserved-nodes" - "/dns4/sentry-a/tcp/30333/p2p/QmV7EhW6J6KgmNdr558RH1mPx2xGGznW7At4BhXzntRFsi" # Not only bind to localhost. @@ -54,6 +53,8 @@ services: # - "sub-libp2p=trace" # - "--log" # - "afg=trace" + - "--log" + - "sub-authority-discovery=trace" - "--no-telemetry" - "--rpc-cors" - "all" @@ -74,28 +75,24 @@ services: - "--base-path" - "/tmp/sentry" - "--chain=local" - # Don't configure a key, as sentry-a is not a validator. - # - "--key" - # - "//Charlie" - "--port" - "30333" - # sentry-a is not a validator. - # - "--validator" - - "--name" - - "CharliesNode" + - "--charlie" - "--bootnodes" - "/dns4/validator-a/tcp/30333/p2p/QmRpheLN4JWdAnY7HGJfWFNbfkQCb6tFf4vvA6hgjMZKrR" - "--bootnodes" - "/dns4/validator-b/tcp/30333/p2p/QmSVnNf9HwVMT1Y4cK1P6aoJcEZjmoTXpjKBmAABLMnZEk" + - "--reserved-nodes" + - "/dns4/validator-a/tcp/30333/p2p/QmRpheLN4JWdAnY7HGJfWFNbfkQCb6tFf4vvA6hgjMZKrR" - "--no-telemetry" - "--rpc-cors" - "all" # Not only bind to localhost. - "--ws-external" - "--rpc-external" - # Make sure sentry-a still participates as a grandpa voter to forward - # grandpa finality gossip messages. - - "--grandpa-voter" + - "--log" + - "sub-authority-discovery=trace" + - "--sentry" validator-b: image: parity/substrate @@ -112,13 +109,10 @@ services: - "--base-path" - "/tmp/bob" - "--chain=local" - - "--key" - - "//Bob" - "--port" - "30333" - "--validator" - - "--name" - - "BobsNode" + - "--bob" - "--bootnodes" - "/dns4/validator-a/tcp/30333/p2p/QmRpheLN4JWdAnY7HGJfWFNbfkQCb6tFf4vvA6hgjMZKrR" - "--bootnodes" @@ -129,6 +123,8 @@ services: # Not only bind to localhost. - "--ws-external" - "--rpc-external" + - "--log" + - "sub-authority-discovery=trace" ui: image: polkadot-js/apps diff --git a/bin/node/cli/src/service.rs b/bin/node/cli/src/service.rs index 6dd08addc6..229050f818 100644 --- a/bin/node/cli/src/service.rs +++ b/bin/node/cli/src/service.rs @@ -125,12 +125,14 @@ macro_rules! new_full { is_authority, force_authoring, name, - disable_grandpa + disable_grandpa, + sentry_nodes, ) = ( $config.roles.is_authority(), $config.force_authoring, $config.name.clone(), - $config.disable_grandpa + $config.disable_grandpa, + $config.network.sentry_nodes.clone(), ); // sentry nodes announce themselves as authorities to the network @@ -194,6 +196,7 @@ macro_rules! new_full { let authority_discovery = authority_discovery::AuthorityDiscovery::new( service.client(), service.network(), + sentry_nodes, service.keystore(), future03_dht_event_rx, ); diff --git a/client/authority-discovery/src/lib.rs b/client/authority-discovery/src/lib.rs index cd43623730..9fb82f30c6 100644 --- a/client/authority-discovery/src/lib.rs +++ b/client/authority-discovery/src/lib.rs @@ -18,8 +18,9 @@ //! Substrate authority discovery. //! -//! This crate enables Substrate authorities to directly connect to other authorities. [`AuthorityDiscovery`] implements -//! the Future trait. By polling [`AuthorityDiscovery`] an authority: +//! This crate enables Substrate authorities to directly connect to other authorities. +//! [`AuthorityDiscovery`] implements the Future trait. By polling [`AuthorityDiscovery`] an +//! authority: //! //! //! 1. **Makes itself discoverable** @@ -54,11 +55,14 @@ use futures::task::{Context, Poll}; use futures::{Future, FutureExt, Stream, StreamExt}; use futures_timer::Delay; -use authority_discovery_primitives::{AuthorityDiscoveryApi, AuthorityId, AuthoritySignature, AuthorityPair}; +use authority_discovery_primitives::{ + AuthorityDiscoveryApi, AuthorityId, AuthoritySignature, AuthorityPair +}; use client_api::blockchain::HeaderBackend; use codec::{Decode, Encode}; use error::{Error, Result}; use log::{debug, error, log_enabled, warn}; +use libp2p::Multiaddr; use network::specialization::NetworkSpecialization; use network::{DhtEvent, ExHashT}; use primitives::crypto::{key_types, Pair}; @@ -78,7 +82,8 @@ mod schema { /// Upper bound estimation on how long one should wait before accessing the Kademlia DHT. const LIBP2P_KADEMLIA_BOOTSTRAP_TIME: Duration = Duration::from_secs(30); -/// Name of the Substrate peerset priority group for authorities discovered through the authority discovery module. +/// Name of the Substrate peerset priority group for authorities discovered through the authority +/// discovery module. const AUTHORITIES_PRIORITY_GROUP_NAME: &'static str = "authorities"; /// An `AuthorityDiscovery` makes a given authority discoverable and discovers other authorities. @@ -93,6 +98,14 @@ where client: Arc, network: Arc, + /// List of sentry node public addresses. + // + // There are 3 states: + // - None: No addresses were specified. + // - Some(vec![]): Addresses were specified, but none could be parsed as proper + // Multiaddresses. + // - Some(vec![a, b, c, ...]): Valid addresses were specified. + sentry_nodes: Option>, /// Channel we receive Dht events on. dht_event_rx: Pin + Send>>, @@ -103,11 +116,12 @@ where /// Interval on which to query for addresses of other authorities. query_interval: Interval, - /// The network peerset interface for priority groups lets us only set an entire group, but we retrieve the - /// addresses of other authorities one by one from the network. To use the peerset interface we need to cache the - /// addresses and always overwrite the entire peerset priority group. To ensure this map doesn't grow indefinitely - /// `purge_old_authorities_from_cache` function is called each time we add a new entry. - address_cache: HashMap>, + /// The network peerset interface for priority groups lets us only set an entire group, but we + /// retrieve the addresses of other authorities one by one from the network. To use the peerset + /// interface we need to cache the addresses and always overwrite the entire peerset priority + /// group. To ensure this map doesn't grow indefinitely `purge_old_authorities_from_cache` + /// function is called each time we add a new entry. + address_cache: HashMap>, phantom: PhantomData, } @@ -121,32 +135,54 @@ where Self: Future, { /// Return a new authority discovery. + /// + /// Note: When specifying `sentry_nodes` this module will not advertise the public addresses of + /// the node itself but only the public addresses of its sentry nodes. pub fn new( client: Arc, network: Arc, + sentry_nodes: Vec, key_store: BareCryptoStorePtr, dht_event_rx: Pin + Send>>, ) -> Self { - // Kademlia's default time-to-live for Dht records is 36h, republishing records every 24h. Given that a node - // could restart at any point in time, one can not depend on the republishing process, thus publishing own - // external addresses should happen on an interval < 36h. + // Kademlia's default time-to-live for Dht records is 36h, republishing records every 24h. + // Given that a node could restart at any point in time, one can not depend on the + // republishing process, thus publishing own external addresses should happen on an interval + // < 36h. let publish_interval = interval_at( Instant::now() + LIBP2P_KADEMLIA_BOOTSTRAP_TIME, Duration::from_secs(12 * 60 * 60), ); - // External addresses of other authorities can change at any given point in time. The interval on which to query - // for external addresses of other authorities is a trade off between efficiency and performance. + // External addresses of other authorities can change at any given point in time. The + // interval on which to query for external addresses of other authorities is a trade off + // between efficiency and performance. let query_interval = interval_at( Instant::now() + LIBP2P_KADEMLIA_BOOTSTRAP_TIME, Duration::from_secs(10 * 60), ); + let sentry_nodes = if !sentry_nodes.is_empty() { + Some(sentry_nodes.into_iter().filter_map(|a| match a.parse() { + Ok(addr) => Some(addr), + Err(e) => { + error!( + target: "sub-authority-discovery", + "Failed to parse sentry node public address '{:?}', continuing anyways.", e, + ); + None + } + }).collect()) + } else { + None + }; + let address_cache = HashMap::new(); AuthorityDiscovery { client, network, + sentry_nodes, dht_event_rx, key_store, publish_interval, @@ -156,18 +192,20 @@ where } } - fn publish_own_ext_addresses(&mut self) -> Result<()> { - let addresses = self - .network - .external_addresses() - .into_iter() - .map(|a| { - a.with(libp2p::core::multiaddr::Protocol::P2p( + /// Publish either our own or if specified the public addresses of our sentry nodes. + fn publish_ext_addresses(&mut self) -> Result<()> { + let addresses = match &self.sentry_nodes { + Some(addrs) => addrs.clone().into_iter() + .map(|a| a.to_vec()) + .collect(), + None => self.network.external_addresses() + .into_iter() + .map(|a| a.with(libp2p::core::multiaddr::Protocol::P2p( self.network.local_peer_id().into(), - )) - }) - .map(|a| a.to_vec()) - .collect(); + ))) + .map(|a| a.to_vec()) + .collect(), + }; let mut serialized_addresses = vec![]; schema::AuthorityAddresses { addresses } @@ -217,7 +255,10 @@ where DhtEvent::ValueFound(v) => { if log_enabled!(log::Level::Debug) { let hashes = v.iter().map(|(hash, _value)| hash.clone()); - debug!(target: "sub-authority-discovery", "Value for hash '{:?}' found on Dht.", hashes); + debug!( + target: "sub-authority-discovery", + "Value for hash '{:?}' found on Dht.", hashes, + ); } self.handle_dht_value_found_event(v)?; @@ -247,8 +288,9 @@ where let block_id = BlockId::hash(self.client.info().best_hash); - // From the Dht we only get the hashed authority id. In order to retrieve the actual authority id and to ensure - // it is actually an authority, we match the hash against the hash of the authority id of all other authorities. + // From the Dht we only get the hashed authority id. In order to retrieve the actual + // authority id and to ensure it is actually an authority, we match the hash against the + // hash of the authority id of all other authorities. let authorities = self.client.runtime_api().authorities(&block_id)?; self.purge_old_authorities_from_cache(&authorities); @@ -267,7 +309,8 @@ where signature, addresses, } = schema::SignedAuthorityAddresses::decode(value).map_err(Error::DecodingProto)?; - let signature = AuthoritySignature::decode(&mut &signature[..]).map_err(Error::EncodingDecodingScale)?; + let signature = AuthoritySignature::decode(&mut &signature[..]) + .map_err(Error::EncodingDecodingScale)?; if !AuthorityPair::verify(&signature, &addresses, authority_id) { return Err(Error::VerifyingDhtPayload); @@ -293,7 +336,10 @@ where .flatten(), ); - debug!(target: "sub-authority-discovery", "Applying priority group {:#?} to peerset.", addresses); + debug!( + target: "sub-authority-discovery", + "Applying priority group {:#?} to peerset.", addresses, + ); self.network .set_priority_group(AUTHORITIES_PRIORITY_GROUP_NAME.to_string(), addresses) .map_err(Error::SettingPeersetPriorityGroup)?; @@ -368,20 +414,20 @@ where self.handle_dht_events(cx)?; if let Poll::Ready(_) = self.publish_interval.poll_next_unpin(cx) { - // Make sure to call interval.poll until it returns Async::NotReady once. Otherwise, in case one of the - // function calls within this block do a `return`, we don't call `interval.poll` again and thereby the - // underlying Tokio task is never registered with Tokio's Reactor to be woken up on the next interval - // tick. + // Make sure to call interval.poll until it returns Async::NotReady once. Otherwise, + // in case one of the function calls within this block do a `return`, we don't call + // `interval.poll` again and thereby the underlying Tokio task is never registered + // with Tokio's Reactor to be woken up on the next interval tick. while let Poll::Ready(_) = self.publish_interval.poll_next_unpin(cx) {} - self.publish_own_ext_addresses()?; + self.publish_ext_addresses()?; } if let Poll::Ready(_) = self.query_interval.poll_next_unpin(cx) { - // Make sure to call interval.poll until it returns Async::NotReady once. Otherwise, in case one of the - // function calls within this block do a `return`, we don't call `interval.poll` again and thereby the - // underlying Tokio task is never registered with Tokio's Reactor to be woken up on the next interval - // tick. + // Make sure to call interval.poll until it returns Async::NotReady once. Otherwise, + // in case one of the function calls within this block do a `return`, we don't call + // `interval.poll` again and thereby the underlying Tokio task is never registered + // with Tokio's Reactor to be woken up on the next interval tick. while let Poll::Ready(_) = self.query_interval.poll_next_unpin(cx) {} self.request_addresses_of_others()?; @@ -395,13 +441,15 @@ where Err(e) => error!(target: "sub-authority-discovery", "Poll failure: {:?}", e), }; - // Make sure to always return NotReady as this is a long running task with the same lifetime as the node itself. + // Make sure to always return NotReady as this is a long running task with the same lifetime + // as the node itself. Poll::Pending } } -/// NetworkProvider provides AuthorityDiscovery with all necessary hooks into the underlying Substrate networking. Using -/// this trait abstraction instead of NetworkService directly is necessary to unit test AuthorityDiscovery. +/// NetworkProvider provides AuthorityDiscovery with all necessary hooks into the underlying +/// Substrate networking. Using this trait abstraction instead of NetworkService directly is +/// necessary to unit test AuthorityDiscovery. pub trait NetworkProvider { /// Returns the local external addresses. fn external_addresses(&self) -> Vec; @@ -457,14 +505,11 @@ fn hash_authority_id(id: &[u8]) -> Result { } fn interval_at(start: Instant, duration: Duration) -> Interval { - let stream = futures::stream::unfold((), move |_| { - let wait_time = start.saturating_duration_since(Instant::now()); + let stream = futures::stream::unfold(start, move |next| { + let time_until_next = next.saturating_duration_since(Instant::now()); - futures::future::join( - Delay::new(wait_time), - Delay::new(duration) - ).map(|_| Some(((), ()))) - }).map(drop); + Delay::new(time_until_next).map(move |_| Some(((), next + duration))) + }); Box::new(stream) } @@ -482,6 +527,67 @@ mod tests { use std::sync::{Arc, Mutex}; use test_client::runtime::Block; + #[test] + fn interval_at_with_start_now() { + let start = Instant::now(); + + let mut interval = interval_at( + std::time::Instant::now(), + std::time::Duration::from_secs(10), + ); + + futures::executor::block_on(async { + interval.next().await; + }); + + assert!( + Instant::now().saturating_duration_since(start) < Duration::from_secs(1), + "Expected low resolution instant interval to fire within less than a second.", + ); + } + + #[test] + fn interval_at_is_queuing_events() { + let start = Instant::now(); + + let interval = interval_at( + std::time::Instant::now(), + std::time::Duration::from_millis(10), + ); + + // Let's wait for 100ms, thus 10 elements should be queued up. + std::thread::sleep(Duration::from_millis(100)); + + futures::executor::block_on(async { + interval.take(10).collect::>().await; + }); + + // Make sure we did not just wait for yet another 100ms (10 elements). + assert!( + Instant::now().saturating_duration_since(start) < Duration::from_millis(150), + "Expect interval to /queue/ events when not polled for a while.", + ); + } + + #[test] + fn interval_at_with_initial_delay() { + let start = Instant::now(); + + let mut interval = interval_at( + std::time::Instant::now() + Duration::from_millis(100), + std::time::Duration::from_secs(10), + ); + + futures::executor::block_on(async { + interval.next().await; + }); + + assert!( + Instant::now().saturating_duration_since(start) > Duration::from_millis(100), + "Expected interval with initial delay not to fire right away.", + ); + } + #[derive(Clone)] struct TestApi { authorities: Vec, @@ -612,7 +718,8 @@ mod tests { #[derive(Default)] struct TestNetwork { - // Whenever functions on `TestNetwork` are called, the function arguments are added to the vectors below. + // Whenever functions on `TestNetwork` are called, the function arguments are added to the + // vectors below. pub put_value_call: Arc)>>>, pub get_value_call: Arc>>, pub set_priority_group_call: Arc)>>>, @@ -645,17 +752,20 @@ mod tests { } #[test] - fn publish_own_ext_addresses_puts_record_on_dht() { + fn publish_ext_addresses_puts_record_on_dht() { let (_dht_event_tx, dht_event_rx) = channel(1000); let network: Arc = Arc::new(Default::default()); let key_store = KeyStore::new(); - let public = key_store.write().sr25519_generate_new(key_types::AUTHORITY_DISCOVERY, None).unwrap(); + let public = key_store.write() + .sr25519_generate_new(key_types::AUTHORITY_DISCOVERY, None) + .unwrap(); let test_api = Arc::new(TestApi {authorities: vec![public.into()]}); - let mut authority_discovery = - AuthorityDiscovery::new(test_api, network.clone(), key_store, dht_event_rx.boxed()); + let mut authority_discovery = AuthorityDiscovery::new( + test_api, network.clone(), vec![], key_store, dht_event_rx.boxed(), + ); - authority_discovery.publish_own_ext_addresses().unwrap(); + authority_discovery.publish_ext_addresses().unwrap(); // Expect authority discovery to put a new record onto the dht. assert_eq!(network.put_value_call.lock().unwrap().len(), 1); @@ -676,8 +786,9 @@ mod tests { let network: Arc = Arc::new(Default::default()); let key_store = KeyStore::new(); - let mut authority_discovery = - AuthorityDiscovery::new(test_api, network.clone(), key_store, dht_event_rx.boxed()); + let mut authority_discovery = AuthorityDiscovery::new( + test_api, network.clone(), vec![], key_store, dht_event_rx.boxed(), + ); authority_discovery.request_addresses_of_others().unwrap(); @@ -695,8 +806,9 @@ mod tests { let network: Arc = Arc::new(Default::default()); let key_store = KeyStore::new(); - let mut authority_discovery = - AuthorityDiscovery::new(test_api, network.clone(), key_store, dht_event_rx.boxed()); + let mut authority_discovery = AuthorityDiscovery::new( + test_api, network.clone(), vec![], key_store, dht_event_rx.boxed(), + ); // Create sample dht event. diff --git a/client/cli/src/lib.rs b/client/cli/src/lib.rs index 25ec6a17b1..0f0edc2ba0 100644 --- a/client/cli/src/lib.rs +++ b/client/cli/src/lib.rs @@ -674,12 +674,14 @@ fn fill_network_configuration( config.boot_nodes.extend(cli.bootnodes.into_iter()); config.config_path = Some(config_path.to_string_lossy().into()); config.net_config_path = config.config_path.clone(); - config.reserved_nodes.extend(cli.reserved_nodes.into_iter()); + config.reserved_nodes.extend(cli.reserved_nodes.into_iter()); if cli.reserved_only { config.non_reserved_mode = NonReservedPeerMode::Deny; } + config.sentry_nodes.extend(cli.sentry_nodes.into_iter()); + for addr in cli.listen_addr.iter() { let addr = addr.parse().ok().ok_or(error::Error::InvalidListenMultiaddress)?; config.listen_addresses.push(addr); diff --git a/client/cli/src/params.rs b/client/cli/src/params.rs index 58d7cb3ca8..d81abaa724 100644 --- a/client/cli/src/params.rs +++ b/client/cli/src/params.rs @@ -177,6 +177,14 @@ pub struct NetworkConfigurationParams { #[structopt(long = "reserved-only")] pub reserved_only: bool, + /// Specify a list of sentry node public addresses. + #[structopt( + long = "sentry-nodes", + value_name = "URL", + conflicts_with_all = &[ "sentry" ] + )] + pub sentry_nodes: Vec, + /// Listen on this multiaddress. #[structopt(long = "listen-addr", value_name = "LISTEN_ADDR")] pub listen_addr: Vec, diff --git a/client/network/src/config.rs b/client/network/src/config.rs index a59ab97887..9a55be7fe9 100644 --- a/client/network/src/config.rs +++ b/client/network/src/config.rs @@ -255,6 +255,8 @@ pub struct NetworkConfiguration { pub reserved_nodes: Vec, /// The non-reserved peer mode. pub non_reserved_mode: NonReservedPeerMode, + /// List of sentry node public addresses. + pub sentry_nodes: Vec, /// Client identifier. Sent over the wire for debugging purposes. pub client_version: String, /// Name of the node. Sent over the wire for debugging purposes. @@ -278,6 +280,7 @@ impl Default for NetworkConfiguration { out_peers: 75, reserved_nodes: Vec::new(), non_reserved_mode: NonReservedPeerMode::Accept, + sentry_nodes: Vec::new(), client_version: "unknown".into(), node_name: "unknown".into(), transport: TransportConfig::Normal { diff --git a/client/service/test/src/lib.rs b/client/service/test/src/lib.rs index d9a5d417c4..e3b46c7720 100644 --- a/client/service/test/src/lib.rs +++ b/client/service/test/src/lib.rs @@ -155,6 +155,7 @@ fn node_config ( out_peers: 450, reserved_nodes: vec![], non_reserved_mode: NonReservedPeerMode::Accept, + sentry_nodes: vec![], client_version: "network/test/0.1".to_owned(), node_name: "unknown".to_owned(), transport: TransportConfig::Normal { -- GitLab From f6379625ba25ff51a386ea794e00ddba1d83fb68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Tue, 3 Dec 2019 18:03:27 +0100 Subject: [PATCH 072/172] Rename OffchainWorker internal method. (#4267) * Rename generate_extrinsics to offchain_worker * Some doc improvements. --- frame/executive/src/lib.rs | 2 +- frame/support/src/dispatch.rs | 4 ++-- primitives/sr-primitives/src/traits.rs | 16 ++++++++++------ 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index 35d44f53e0..9f42ac1a05 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -311,7 +311,7 @@ where /// Start an offchain worker and generate extrinsics. pub fn offchain_worker(n: System::BlockNumber) { - >::generate_extrinsics(n) + >::offchain_worker(n) } } diff --git a/frame/support/src/dispatch.rs b/frame/support/src/dispatch.rs index 7d7103b0a4..d80b8ca440 100644 --- a/frame/support/src/dispatch.rs +++ b/frame/support/src/dispatch.rs @@ -1001,7 +1001,7 @@ macro_rules! decl_module { $crate::sp_runtime::traits::OffchainWorker<$trait_instance::BlockNumber> for $module<$trait_instance$(, $instance)?> where $( $other_where_bounds )* { - fn generate_extrinsics(_block_number_not_used: $trait_instance::BlockNumber) { $( $impl )* } + fn offchain_worker(_block_number_not_used: $trait_instance::BlockNumber) { $( $impl )* } } }; @@ -1014,7 +1014,7 @@ macro_rules! decl_module { $crate::sp_runtime::traits::OffchainWorker<$trait_instance::BlockNumber> for $module<$trait_instance$(, $instance)?> where $( $other_where_bounds )* { - fn generate_extrinsics($param: $param_ty) { $( $impl )* } + fn offchain_worker($param: $param_ty) { $( $impl )* } } }; diff --git a/primitives/sr-primitives/src/traits.rs b/primitives/sr-primitives/src/traits.rs index e3b06b2260..5400c5d3af 100644 --- a/primitives/sr-primitives/src/traits.rs +++ b/primitives/sr-primitives/src/traits.rs @@ -346,18 +346,22 @@ pub trait OnInitialize { /// Off-chain computation trait. /// /// Implementing this trait on a module allows you to perform long-running tasks -/// that make validators generate extrinsics (either transactions or inherents) -/// with the results of those long-running computations. +/// that make (by default) validators generate transactions that feed results +/// of those long-running computations back on chain. /// /// NOTE: This function runs off-chain, so it can access the block state, -/// but cannot preform any alterations. +/// but cannot preform any alterations. More specifically alterations are +/// not forbidden, but they are not persisted in any way after the worker +/// has finished. #[impl_for_tuples(30)] pub trait OffchainWorker { - /// This function is being called on every block. + /// This function is being called after every block import (when fully synced). /// - /// Implement this and use special `extern`s to generate transactions or inherents. + /// Implement this and use any of the `Offchain` `sp_io` set of APIs + /// to perform offchain computations, calls and submit transactions + /// with results to trigger any on-chain changes. /// Any state alterations are lost and are not persisted. - fn generate_extrinsics(_n: BlockNumber) {} + fn offchain_worker(_n: BlockNumber) {} } /// Abstraction around hashing -- GitLab From 6e242a5a9fcc5d5ea34386864ec064a01677efff Mon Sep 17 00:00:00 2001 From: Wei Tang Date: Tue, 3 Dec 2019 18:04:17 +0100 Subject: [PATCH 073/172] pallet-evm: weight calculation for call/create based on gas provided (#4261) * pallet-evm: weight calculation for call/create based on gas provided * Update frame/evm/src/lib.rs Co-Authored-By: Niklas Adolfsson --- frame/evm/src/lib.rs | 41 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/frame/evm/src/lib.rs b/frame/evm/src/lib.rs index 13be83dccf..c02739885e 100644 --- a/frame/evm/src/lib.rs +++ b/frame/evm/src/lib.rs @@ -23,13 +23,14 @@ mod backend; pub use crate::backend::{Account, Log, Vicinity, Backend}; -use rstd::vec::Vec; +use rstd::{vec::Vec, marker::PhantomData}; use support::{dispatch::Result, decl_module, decl_storage, decl_event}; +use support::weights::{Weight, WeighData, ClassifyDispatch, DispatchClass, PaysFee}; use support::traits::{Currency, WithdrawReason, ExistenceRequirement}; use system::ensure_signed; use sp_runtime::ModuleId; use support::weights::SimpleDispatchInfo; -use sp_runtime::traits::{UniqueSaturatedInto, AccountIdConversion}; +use sp_runtime::traits::{UniqueSaturatedInto, AccountIdConversion, SaturatedConversion}; use primitives::{U256, H256, H160}; use evm::{ExitReason, ExitSucceed, ExitError}; use evm::executor::StackExecutor; @@ -82,6 +83,38 @@ impl Precompiles for () { } } +struct WeightForCallCreate(PhantomData); + +impl Default for WeightForCallCreate { + fn default() -> Self { + Self(PhantomData) + } +} + +impl WeighData<(&H160, &Vec, &U256, &u32)> for WeightForCallCreate { + fn weigh_data(&self, (_, _, _, gas_provided): (&H160, &Vec, &U256, &u32)) -> Weight { + F::gas_price().saturated_into::().saturating_mul(*gas_provided) + } +} + +impl WeighData<(&Vec, &U256, &u32)> for WeightForCallCreate { + fn weigh_data(&self, (_, _, gas_provided): (&Vec, &U256, &u32)) -> Weight { + F::gas_price().saturated_into::().saturating_mul(*gas_provided) + } +} + +impl ClassifyDispatch for WeightForCallCreate { + fn classify_dispatch(&self, _: T) -> DispatchClass { + DispatchClass::Normal + } +} + +impl PaysFee for WeightForCallCreate { + fn pays_fee(&self) -> bool { + true + } +} + /// EVM module trait pub trait Trait: system::Trait + timestamp::Trait { /// Calculator for current gas price. @@ -161,7 +194,7 @@ decl_module! { Ok(()) } - #[weight = SimpleDispatchInfo::FixedNormal(10_000)] + #[weight = WeightForCallCreate::::default()] fn call(origin, target: H160, input: Vec, value: U256, gas_limit: u32) -> Result { let sender = ensure_signed(origin)?; let source = T::ConvertAccountId::convert_account_id(&sender); @@ -212,7 +245,7 @@ decl_module! { ret } - #[weight = SimpleDispatchInfo::FixedNormal(10_000)] + #[weight = WeightForCallCreate::::default()] fn create(origin, init: Vec, value: U256, gas_limit: u32) -> Result { let sender = ensure_signed(origin)?; let source = T::ConvertAccountId::convert_account_id(&sender); -- GitLab From fc6914cdb8c322cea8a4591bbf9566dd23bfd143 Mon Sep 17 00:00:00 2001 From: Bryant Eisenbach <3859395+fubuloubu@users.noreply.github.com> Date: Tue, 3 Dec 2019 18:05:05 -0500 Subject: [PATCH 074/172] fix: Typo granpda -> grandpa (#4286) --- .maintain/rename-crates-for-2.0.sh | 2 +- Cargo.lock | 12 ++++++------ bin/node-template/Cargo.toml | 2 +- bin/node/cli/Cargo.toml | 2 +- client/finality-grandpa/Cargo.toml | 2 +- client/service/Cargo.toml | 2 +- frame/grandpa/Cargo.toml | 4 ++-- frame/grandpa/src/lib.rs | 2 +- frame/grandpa/src/mock.rs | 2 +- primitives/finality-grandpa/Cargo.toml | 2 +- 10 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.maintain/rename-crates-for-2.0.sh b/.maintain/rename-crates-for-2.0.sh index cd68abac98..9eefb2918c 100644 --- a/.maintain/rename-crates-for-2.0.sh +++ b/.maintain/rename-crates-for-2.0.sh @@ -46,7 +46,7 @@ TO_RENAME=( "substrate-debug-derive sp-debug-derive" "substrate-primitives-storage sp-storage" "substrate-externalities sp-externalities" - "substrate-finality-grandpa-primitives sp-finality-granpda" + "substrate-finality-grandpa-primitives sp-finality-grandpa" "substrate-inherents sp-inherents" "substrate-keyring sp-keyring" "substrate-offchain-primitives sp-offchain" diff --git a/Cargo.lock b/Cargo.lock index 557d1dd1f2..8ed94ad10e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3012,7 +3012,7 @@ dependencies = [ "sp-consensus 2.0.0", "sp-consensus-babe 2.0.0", "sp-core 2.0.0", - "sp-finality-granpda 2.0.0", + "sp-finality-grandpa 2.0.0", "sp-finality-tracker 2.0.0", "sp-inherents 2.0.0", "sp-io 2.0.0", @@ -3179,7 +3179,7 @@ dependencies = [ "sp-consensus 2.0.0", "sp-consensus-aura 2.0.0", "sp-core 2.0.0", - "sp-finality-granpda 2.0.0", + "sp-finality-grandpa 2.0.0", "sp-inherents 2.0.0", "sp-io 2.0.0", "sp-runtime 2.0.0", @@ -3703,7 +3703,7 @@ dependencies = [ "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0", - "sp-finality-granpda 2.0.0", + "sp-finality-grandpa 2.0.0", "sp-io 2.0.0", "sp-runtime 2.0.0", "sp-staking 2.0.0", @@ -5241,7 +5241,7 @@ dependencies = [ "sp-consensus 2.0.0", "sp-consensus-babe 2.0.0", "sp-core 2.0.0", - "sp-finality-granpda 2.0.0", + "sp-finality-grandpa 2.0.0", "sp-finality-tracker 2.0.0", "sp-inherents 2.0.0", "sp-keyring 2.0.0", @@ -5484,7 +5484,7 @@ dependencies = [ "sp-consensus 2.0.0", "sp-consensus-babe 2.0.0", "sp-core 2.0.0", - "sp-finality-granpda 2.0.0", + "sp-finality-grandpa 2.0.0", "sp-io 2.0.0", "sp-runtime 2.0.0", "sp-session 2.0.0", @@ -6138,7 +6138,7 @@ dependencies = [ ] [[package]] -name = "sp-finality-granpda" +name = "sp-finality-grandpa" version = "2.0.0" dependencies = [ "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/bin/node-template/Cargo.toml b/bin/node-template/Cargo.toml index bfe39ee0c7..859bedf15d 100644 --- a/bin/node-template/Cargo.toml +++ b/bin/node-template/Cargo.toml @@ -31,7 +31,7 @@ aura = { package = "sc-consensus-aura", path = "../../client/consensus/aura" } aura-primitives = { package = "sp-consensus-aura", path = "../../primitives/consensus/aura" } consensus-common = { package = "sp-consensus", path = "../../primitives/consensus/common" } grandpa = { package = "sc-finality-grandpa", path = "../../client/finality-grandpa" } -grandpa-primitives = { package = "sp-finality-granpda", path = "../../primitives/finality-grandpa" } +grandpa-primitives = { package = "sp-finality-grandpa", path = "../../primitives/finality-grandpa" } sc-client = { path = "../../client/" } runtime = { package = "node-template-runtime", path = "runtime" } sp-runtime = { path = "../../primitives/sr-primitives" } diff --git a/bin/node/cli/Cargo.toml b/bin/node/cli/Cargo.toml index 6b61f7abe0..d3340aa0ae 100644 --- a/bin/node/cli/Cargo.toml +++ b/bin/node/cli/Cargo.toml @@ -36,7 +36,7 @@ structopt = "0.3.3" # primitives authority-discovery-primitives = { package = "sp-authority-discovery", path = "../../../primitives/authority-discovery"} babe-primitives = { package = "sp-consensus-babe", path = "../../../primitives/consensus/babe" } -grandpa_primitives = { package = "sp-finality-granpda", path = "../../../primitives/finality-grandpa" } +grandpa_primitives = { package = "sp-finality-grandpa", path = "../../../primitives/finality-grandpa" } primitives = { package = "sp-core", path = "../../../primitives/core" } sp-runtime = { path = "../../../primitives/sr-primitives" } sp-timestamp = { path = "../../../primitives/timestamp", default-features = false } diff --git a/client/finality-grandpa/Cargo.toml b/client/finality-grandpa/Cargo.toml index 8b053fcda6..a1e2c86b8e 100644 --- a/client/finality-grandpa/Cargo.toml +++ b/client/finality-grandpa/Cargo.toml @@ -26,7 +26,7 @@ inherents = { package = "sp-inherents", path = "../../primitives/inherents" } sp-blockchain = { path = "../../primitives/blockchain" } network = { package = "sc-network", path = "../network" } sp-finality-tracker = { path = "../../primitives/finality-tracker" } -fg_primitives = { package = "sp-finality-granpda", path = "../../primitives/finality-grandpa" } +fg_primitives = { package = "sp-finality-grandpa", path = "../../primitives/finality-grandpa" } grandpa = { package = "finality-grandpa", version = "0.10.1", features = ["derive-codec"] } [dev-dependencies] diff --git a/client/service/Cargo.toml b/client/service/Cargo.toml index e03c263b80..a981daffcf 100644 --- a/client/service/Cargo.toml +++ b/client/service/Cargo.toml @@ -60,5 +60,5 @@ tracing = "0.1.10" substrate-test-runtime-client = { path = "../../test/utils/runtime/client" } babe-primitives = { package = "sp-consensus-babe", path = "../../primitives/consensus/babe" } grandpa = { package = "sc-finality-grandpa", path = "../finality-grandpa" } -grandpa-primitives = { package = "sp-finality-granpda", path = "../../primitives/finality-grandpa" } +grandpa-primitives = { package = "sp-finality-grandpa", path = "../../primitives/finality-grandpa" } tokio = "0.1" diff --git a/frame/grandpa/Cargo.toml b/frame/grandpa/Cargo.toml index d463e216ed..f14da4a395 100644 --- a/frame/grandpa/Cargo.toml +++ b/frame/grandpa/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" serde = { version = "1.0.101", optional = true, features = ["derive"] } 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-finality-granpda = { path = "../../primitives/finality-grandpa", default-features = false } +sp-finality-grandpa = { path = "../../primitives/finality-grandpa", default-features = false } rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } sp-runtime = { path = "../../primitives/sr-primitives", default-features = false } sp-staking = { path = "../../primitives/sr-staking-primitives", default-features = false } @@ -26,7 +26,7 @@ std = [ "serde", "codec/std", "primitives/std", - "sp-finality-granpda/std", + "sp-finality-grandpa/std", "rstd/std", "support/std", "sp-runtime/std", diff --git a/frame/grandpa/src/lib.rs b/frame/grandpa/src/lib.rs index 0c4c6b202e..12fb28546c 100644 --- a/frame/grandpa/src/lib.rs +++ b/frame/grandpa/src/lib.rs @@ -28,7 +28,7 @@ #![cfg_attr(not(feature = "std"), no_std)] // re-export since this is necessary for `impl_apis` in runtime. -pub use sp_finality_granpda as fg_primitives; +pub use sp_finality_grandpa as fg_primitives; use rstd::prelude::*; use codec::{self as codec, Encode, Decode, Error}; diff --git a/frame/grandpa/src/mock.rs b/frame/grandpa/src/mock.rs index 75de98cdf9..fb153d71cf 100644 --- a/frame/grandpa/src/mock.rs +++ b/frame/grandpa/src/mock.rs @@ -24,7 +24,7 @@ use support::{impl_outer_origin, impl_outer_event, parameter_types, weights::Wei use primitives::H256; use codec::{Encode, Decode}; use crate::{AuthorityId, AuthorityList, GenesisConfig, Trait, Module, ConsensusLog}; -use sp_finality_granpda::GRANDPA_ENGINE_ID; +use sp_finality_grandpa::GRANDPA_ENGINE_ID; impl_outer_origin!{ pub enum Origin for Test {} diff --git a/primitives/finality-grandpa/Cargo.toml b/primitives/finality-grandpa/Cargo.toml index f176702775..f02b8a68d5 100644 --- a/primitives/finality-grandpa/Cargo.toml +++ b/primitives/finality-grandpa/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "sp-finality-granpda" +name = "sp-finality-grandpa" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" -- GitLab From b517a82951edb3515e48ee1ee805b0b56ec4f13c Mon Sep 17 00:00:00 2001 From: Ashley Date: Wed, 4 Dec 2019 18:35:33 +0100 Subject: [PATCH 075/172] Update exit-future and make sc-cli compile on wasm (#4289) * updated exit-future (github repo) * Switch to broadcast crate * Migrate client/cli * Switch exit-future to modernize branch * Small changes * Switch to cargo version and fix fg tests * Revert "Small changes" This reverts commit a488106805d220cb4aee9e46a71481424c6d87d5. --- Cargo.lock | 38 +++++++------ client/cli/Cargo.toml | 7 ++- client/cli/src/lib.rs | 55 +++++++++++-------- .../finality-grandpa/src/communication/mod.rs | 17 +++++- .../src/communication/tests.rs | 11 ++-- client/finality-grandpa/src/lib.rs | 8 ++- client/finality-grandpa/src/observer.rs | 6 +- client/finality-grandpa/src/tests.rs | 10 ++-- client/service/Cargo.toml | 2 +- client/service/src/builder.rs | 16 +++--- client/service/src/lib.rs | 11 ++-- 11 files changed, 105 insertions(+), 76 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8ed94ad10e..ba45de4d29 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -418,6 +418,11 @@ dependencies = [ "iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "bytes" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "c2-chacha" version = "0.2.3" @@ -1097,11 +1102,10 @@ dependencies = [ [[package]] name = "exit-future" -version = "0.1.4" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1556,14 +1560,6 @@ dependencies = [ "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "futures01" -version = "0.1.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "fxhash" version = "0.2.1" @@ -2709,7 +2705,6 @@ name = "lock_api" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4912,7 +4907,6 @@ dependencies = [ "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "fdlimit 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures01 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "names 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4933,7 +4927,7 @@ dependencies = [ "structopt 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -5452,7 +5446,7 @@ name = "sc-service" version = "2.0.0" dependencies = [ "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", - "exit-future 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "exit-future 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "grafana-data-source 2.0.0", @@ -6910,6 +6904,15 @@ dependencies = [ "tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "tokio" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "pin-project-lite 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "tokio-buf" version = "0.1.1" @@ -7977,6 +7980,7 @@ dependencies = [ "checksum byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0fc10e8cc6b2580fda3f36eb6dc5316657f812a3df879a44a66fc9f0fdbc4855" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" "checksum bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" +"checksum bytes 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1c85319f157e4e26c703678e68e26ab71a46c0199286fa670b21cc9fec13d895" "checksum c2-chacha 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "214238caa1bf3a496ec3392968969cab8549f96ff30652c9e56885329315f6bb" "checksum c_linked_list 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4964518bd3b4a8190e832886cdc0da9794f12e8e6c1613a9e90ff331c4c8724b" "checksum cargo_metadata 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8d2d1617e838936c0d2323a65cc151e03ae19a7678dd24f72bccf27119b90a5d" @@ -8048,7 +8052,7 @@ dependencies = [ "checksum evm-core 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3bcde5af3d542874ddeb53de0919302d57586ea04b3f76f54d865f8a6cdc70ae" "checksum evm-gasometer 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b82bc9f275cb59d2bcc05d85c98736ddfaba003a7ef7b73893fa7c1c1fab29dc" "checksum evm-runtime 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0dbbc89d29618c3722c17ba78ddf432d40ace8ee27e3f8b28b52a85921112e4b" -"checksum exit-future 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d8013f441e38e31c670e7f34ec8f1d5d3a2bd9d303c1ff83976ca886005e8f48" +"checksum exit-future 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e43f2f1833d64e33f15592464d6fdd70f349dda7b1a53088eb83cd94014008c5" "checksum faerie 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f902f2af041f6c7177a2a04f805687cdc71e69c7cbef059a2755d8923f4cd7a8" "checksum failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f8273f13c977665c5db7eb2b99ae520952fe5ac831ae4cd09d80c4c7042b5ed9" "checksum failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0bc225b78e0391e4b8683440bf2e63c2deeeb2ce5189eab46e2b68c6d3725d08" @@ -8085,7 +8089,6 @@ dependencies = [ "checksum futures-timer 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a1de7508b218029b0f01662ed8f61b1c964b3ae99d6f25462d0f55a595109df6" "checksum futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c0d66274fb76985d3c62c886d1da7ac4c0903a8c9f754e8fe0f35a6a6cc39e76" "checksum futures-util-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)" = "5ce968633c17e5f97936bd2797b6e38fb56cf16a7422319f7ec2e30d3c470e8d" -"checksum futures01 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)" = "7ef8cbbf52909170053540c6c05a62433ddb60662dabee714e2a882caa864f22" "checksum fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" "checksum generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" @@ -8389,6 +8392,7 @@ dependencies = [ "checksum tiny-keccak 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2953ca5148619bc99695c1274cb54c5275bbb913c6adad87e72eaf8db9787f69" "checksum tinytemplate 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4574b75faccaacddb9b284faecdf0b544b80b6b294f3d062d325c5726a209c20" "checksum tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)" = "5a09c0b5bb588872ab2f09afa13ee6e9dac11e10a0ec9e8e3ba39a5a5d530af6" +"checksum tokio 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2e765bf9f550bd9b8a970633ca3b56b8120c4b6c5dcbe26a93744cb02fee4b17" "checksum tokio-buf 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8fb220f46c53859a4b7ec083e41dec9778ff0b1851c0942b211edb89e0ccdc46" "checksum tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5c501eceaf96f0e1793cf26beb63da3d11c738c4a943fdf3746d81d64684c39f" "checksum tokio-codec 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9f5d22fd1e84bd4045d28813491cb7d7caae34d45c80517c2213f09a85e8787a" diff --git a/client/cli/Cargo.toml b/client/cli/Cargo.toml index ea3023e7a8..817d411bd0 100644 --- a/client/cli/Cargo.toml +++ b/client/cli/Cargo.toml @@ -16,9 +16,8 @@ time = "0.1.42" ansi_term = "0.12.1" lazy_static = "1.4.0" app_dirs = "1.2.1" -tokio = "0.1.22" +tokio = "0.2.1" futures = { version = "0.3.1", features = ["compat"] } -futures01 = "0.1.29" fdlimit = "0.1.1" serde_json = "1.0.41" panic-handler = { package = "sp-panic-handler", path = "../../primitives/panic-handler" } @@ -33,9 +32,11 @@ sc-telemetry = { path = "../telemetry" } keyring = { package = "sp-keyring", path = "../../primitives/keyring" } names = "0.11.0" structopt = "0.3.3" -rpassword = "4.0.1" sc-tracing = { package = "sc-tracing", path = "../tracing" } +[target.'cfg(not(target_os = "unknown"))'.dependencies] +rpassword = "4.0.1" + [dev-dependencies] tempfile = "3.1.0" diff --git a/client/cli/src/lib.rs b/client/cli/src/lib.rs index 0f0edc2ba0..70beedc427 100644 --- a/client/cli/src/lib.rs +++ b/client/cli/src/lib.rs @@ -43,7 +43,7 @@ use primitives::H256; use std::{ io::{Write, Read, Seek, Cursor, stdin, stdout, ErrorKind}, iter, fs::{self, File}, - net::{Ipv4Addr, SocketAddr}, path::{Path, PathBuf}, str::FromStr, + net::{Ipv4Addr, SocketAddr}, path::{Path, PathBuf}, str::FromStr, pin::Pin, task::Poll }; use names::{Generator, Name}; @@ -61,8 +61,7 @@ pub use traits::{GetLogFilter, AugmentClap}; use app_dirs::{AppInfo, AppDataType}; use log::info; use lazy_static::lazy_static; -use futures::{Future, FutureExt, TryFutureExt}; -use futures01::{Async, Future as _}; +use futures::{Future, compat::Future01CompatExt, executor::block_on}; use sc_telemetry::TelemetryEndpoints; use sp_runtime::generic::BlockId; use sp_runtime::traits::Block as BlockT; @@ -396,23 +395,23 @@ impl<'a> ParseAndPrepareExport<'a> { // Note: while we would like the user to handle the exit themselves, we handle it here // for backwards compatibility reasons. let (exit_send, exit_recv) = std::sync::mpsc::channel(); - let exit = exit.into_exit() - .map(|_| Ok::<_, ()>(())) - .compat(); + let exit = exit.into_exit(); std::thread::spawn(move || { - let _ = exit.wait(); + block_on(exit); let _ = exit_send.send(()); }); - let mut export_fut = builder(config)?.export_blocks(file, from.into(), to.map(Into::into), json); - let fut = futures01::future::poll_fn(|| { + let mut export_fut = builder(config)? + .export_blocks(file, from.into(), to.map(Into::into), json) + .compat(); + let fut = futures::future::poll_fn(|cx| { if exit_recv.try_recv().is_ok() { - return Ok(Async::Ready(())); + return Poll::Ready(Ok(())); } - export_fut.poll() + Pin::new(&mut export_fut).poll(cx) }); - let mut runtime = tokio::runtime::current_thread::Runtime::new().unwrap(); + let mut runtime = tokio::runtime::Runtime::new().unwrap(); runtime.block_on(fut)?; Ok(()) } @@ -455,23 +454,23 @@ impl<'a> ParseAndPrepareImport<'a> { // Note: while we would like the user to handle the exit themselves, we handle it here // for backwards compatibility reasons. let (exit_send, exit_recv) = std::sync::mpsc::channel(); - let exit = exit.into_exit() - .map(|_| Ok::<_, ()>(())) - .compat(); + let exit = exit.into_exit(); std::thread::spawn(move || { - let _ = exit.wait(); + block_on(exit); let _ = exit_send.send(()); }); - let mut import_fut = builder(config)?.import_blocks(file, false); - let fut = futures01::future::poll_fn(|| { + let mut import_fut = builder(config)? + .import_blocks(file, false) + .compat(); + let fut = futures::future::poll_fn(|cx| { if exit_recv.try_recv().is_ok() { - return Ok(Async::Ready(())); + return Poll::Ready(Ok(())); } - import_fut.poll() + Pin::new(&mut import_fut).poll(cx) }); - let mut runtime = tokio::runtime::current_thread::Runtime::new().unwrap(); + let mut runtime = tokio::runtime::Runtime::new().unwrap(); runtime.block_on(fut)?; Ok(()) } @@ -513,8 +512,10 @@ impl<'a> CheckBlock<'a> { }; let start = std::time::Instant::now(); - let check = builder(config)?.check_block(block_id); - let mut runtime = tokio::runtime::current_thread::Runtime::new().unwrap(); + let check = builder(config)? + .check_block(block_id) + .compat(); + let mut runtime = tokio::runtime::Runtime::new().unwrap(); runtime.block_on(check)?; println!("Completed in {} ms.", start.elapsed().as_millis()); Ok(()) @@ -719,6 +720,7 @@ fn fill_network_configuration( Ok(()) } +#[cfg(not(target_os = "unknown"))] fn input_keystore_password() -> Result { rpassword::read_password_from_tty(Some("Keystore password: ")) .map_err(|e| format!("{:?}", e)) @@ -730,7 +732,12 @@ fn fill_config_keystore_password( cli: &RunCmd, ) -> Result<(), String> { config.keystore_password = if cli.password_interactive { - Some(input_keystore_password()?.into()) + #[cfg(not(target_os = "unknown"))] + { + Some(input_keystore_password()?.into()) + } + #[cfg(target_os = "unknown")] + None } else if let Some(ref file) = cli.password_filename { Some(fs::read_to_string(file).map_err(|e| format!("{}", e))?.into()) } else if let Some(ref password) = cli.password { diff --git a/client/finality-grandpa/src/communication/mod.rs b/client/finality-grandpa/src/communication/mod.rs index f705812271..d4a6363d1b 100644 --- a/client/finality-grandpa/src/communication/mod.rs +++ b/client/finality-grandpa/src/communication/mod.rs @@ -289,7 +289,7 @@ impl> NetworkBridge { service: N, config: crate::Config, set_state: crate::environment::SharedVoterSetState, - on_exit: impl Future + Clone + Send + 'static, + on_exit: impl futures03::Future + Clone + Send + Unpin + 'static, ) -> ( Self, impl Future + Send + 'static, @@ -350,9 +350,20 @@ impl> NetworkBridge { // lazily spawn these jobs onto their own tasks. the lazy future has access // to tokio globals, which aren't available outside. let mut executor = tokio_executor::DefaultExecutor::current(); - executor.spawn(Box::new(rebroadcast_job.select(on_exit.clone()).then(|_| Ok(())))) + + use futures03::{FutureExt, TryFutureExt}; + + let rebroadcast_job = rebroadcast_job + .select(on_exit.clone().map(Ok).compat()) + .then(|_| Ok(())); + + let reporting_job = reporting_job + .select(on_exit.clone().map(Ok).compat()) + .then(|_| Ok(())); + + executor.spawn(Box::new(rebroadcast_job)) .expect("failed to spawn grandpa rebroadcast job task"); - executor.spawn(Box::new(reporting_job.select(on_exit.clone()).then(|_| Ok(())))) + executor.spawn(Box::new(reporting_job)) .expect("failed to spawn grandpa reporting job task"); Ok(()) }); diff --git a/client/finality-grandpa/src/communication/tests.rs b/client/finality-grandpa/src/communication/tests.rs index b36f8ad3e6..f2a2276a47 100644 --- a/client/finality-grandpa/src/communication/tests.rs +++ b/client/finality-grandpa/src/communication/tests.rs @@ -26,7 +26,7 @@ use std::sync::Arc; use keyring::Ed25519Keyring; use codec::Encode; use sp_runtime::traits::NumberFor; - +use std::{pin::Pin, task::{Context, Poll}}; use crate::environment::SharedVoterSetState; use fg_primitives::AuthorityList; use super::gossip::{self, GossipValidator}; @@ -175,12 +175,11 @@ fn make_test_network() -> ( #[derive(Clone)] struct Exit; - impl Future for Exit { - type Item = (); - type Error = (); + impl futures03::Future for Exit { + type Output = (); - fn poll(&mut self) -> Poll<(), ()> { - Ok(Async::NotReady) + fn poll(self: Pin<&mut Self>, _: &mut Context) -> Poll<()> { + Poll::Pending } } diff --git a/client/finality-grandpa/src/lib.rs b/client/finality-grandpa/src/lib.rs index 29311b1e91..0890b6db0f 100644 --- a/client/finality-grandpa/src/lib.rs +++ b/client/finality-grandpa/src/lib.rs @@ -555,7 +555,7 @@ pub fn run_grandpa_voter, N, RA, SC, VR, X>( NumberFor: BlockNumberOps, DigestFor: Encode, RA: Send + Sync + 'static, - X: Future + Clone + Send + 'static, + X: futures03::Future + Clone + Send + Unpin + 'static, { let GrandpaParams { config, @@ -634,7 +634,9 @@ pub fn run_grandpa_voter, N, RA, SC, VR, X>( let telemetry_task = telemetry_task .then(|_| futures::future::empty::<(), ()>()); - Ok(voter_work.select(on_exit).select2(telemetry_task).then(|_| Ok(()))) + use futures03::{FutureExt, TryFutureExt}; + + Ok(voter_work.select(on_exit.map(Ok).compat()).select2(telemetry_task).then(|_| Ok(()))) } /// Future that powers the voter. @@ -889,7 +891,7 @@ pub fn run_grandpa, N, RA, SC, VR, X>( DigestFor: Encode, RA: Send + Sync + 'static, VR: VotingRule> + Clone + 'static, - X: Future + Clone + Send + 'static, + X: futures03::Future + Clone + Send + Unpin + 'static, { run_grandpa_voter(grandpa_params) } diff --git a/client/finality-grandpa/src/observer.rs b/client/finality-grandpa/src/observer.rs index 2061764ac4..cf09ae3b21 100644 --- a/client/finality-grandpa/src/observer.rs +++ b/client/finality-grandpa/src/observer.rs @@ -155,7 +155,7 @@ pub fn run_grandpa_observer, N, RA, SC>( config: Config, link: LinkHalf, network: N, - on_exit: impl Future + Clone + Send + 'static, + on_exit: impl futures03::Future + Clone + Send + Unpin + 'static, ) -> ::sp_blockchain::Result + Send + 'static> where B: Backend + 'static, E: CallExecutor + Send + Sync + 'static, @@ -195,7 +195,9 @@ pub fn run_grandpa_observer, N, RA, SC>( let observer_work = network_startup.and_then(move |()| observer_work); - Ok(observer_work.select(on_exit).map(|_| ()).map_err(|_| ())) + use futures03::{FutureExt, TryFutureExt}; + + Ok(observer_work.select(on_exit.map(Ok).compat()).map(|_| ()).map_err(|_| ())) } /// Future that powers the observer. diff --git a/client/finality-grandpa/src/tests.rs b/client/finality-grandpa/src/tests.rs index 256c211e8b..d9010bd02b 100644 --- a/client/finality-grandpa/src/tests.rs +++ b/client/finality-grandpa/src/tests.rs @@ -39,6 +39,7 @@ use sp_runtime::generic::{BlockId, DigestItem}; use primitives::{NativeOrEncoded, ExecutionContext, crypto::Public}; use fg_primitives::{GRANDPA_ENGINE_ID, AuthorityList, GrandpaApi}; use state_machine::{backend::InMemory, prove_read, read_proof_check}; +use std::{pin::Pin, task}; use authorities::AuthoritySet; use finality_proof::{FinalityProofProvider, AuthoritySetForFinalityProver, AuthoritySetForFinalityChecker}; @@ -175,12 +176,11 @@ impl TestNetFactory for GrandpaTestNet { #[derive(Clone)] struct Exit; -impl Future for Exit { - type Item = (); - type Error = (); +impl futures03::Future for Exit { + type Output = (); - fn poll(&mut self) -> Poll<(), ()> { - Ok(Async::NotReady) + fn poll(self: Pin<&mut Self>, _: &mut task::Context) -> task::Poll<()> { + task::Poll::Pending } } diff --git a/client/service/Cargo.toml b/client/service/Cargo.toml index a981daffcf..bbdc15f094 100644 --- a/client/service/Cargo.toml +++ b/client/service/Cargo.toml @@ -23,7 +23,7 @@ log = "0.4.8" slog = { version = "2.5.2", features = ["nested-values"] } tokio-executor = "0.1.8" tokio-timer = "0.2.11" -exit-future = "0.1.4" +exit-future = "0.2.0" serde = "1.0.101" serde_json = "1.0.41" sysinfo = "0.9.5" diff --git a/client/service/src/builder.rs b/client/service/src/builder.rs index 48a1b374f5..0ca842e4bc 100644 --- a/client/service/src/builder.rs +++ b/client/service/src/builder.rs @@ -28,7 +28,7 @@ use chain_spec::{RuntimeGenesis, Extension}; use consensus_common::import_queue::ImportQueue; use futures::{prelude::*, sync::mpsc}; use futures03::{ - compat::{Compat, Future01CompatExt}, + compat::Compat, FutureExt as _, TryFutureExt as _, StreamExt as _, TryStreamExt as _, future::{select, Either} @@ -880,7 +880,7 @@ ServiceBuilder< Ok(()) }) - .select(exit.clone()) + .select(exit.clone().map(Ok).compat()) .then(|_| Ok(())); let _ = to_spawn_tx.unbounded_send(Box::new(events)); } @@ -902,7 +902,7 @@ ServiceBuilder< ); Ok(()) }) - .select(exit.clone()) + .select(exit.clone().map(Ok).compat()) .then(|_| Ok(())); let _ = to_spawn_tx.unbounded_send(Box::new(events)); @@ -967,7 +967,7 @@ ServiceBuilder< ); Ok(()) - }).select(exit.clone()).then(|_| Ok(())); + }).select(exit.clone().map(Ok).compat()).then(|_| Ok(())); let _ = to_spawn_tx.unbounded_send(Box::new(tel_task)); // Periodically send the network state to the telemetry. @@ -980,7 +980,7 @@ ServiceBuilder< "state" => network_state, ); Ok(()) - }).select(exit.clone()).then(|_| Ok(())); + }).select(exit.clone().map(Ok).compat()).then(|_| Ok(())); let _ = to_spawn_tx.unbounded_send(Box::new(tel_task_2)); // RPC @@ -1054,7 +1054,7 @@ ServiceBuilder< dht_event_tx, ) .map_err(|_| ()) - .select(exit.clone()) + .select(exit.clone().map(Ok).compat()) .then(|_| Ok(())))); let telemetry_connection_sinks: Arc>>> = Default::default(); @@ -1099,7 +1099,7 @@ ServiceBuilder< Ok(()) }); let _ = to_spawn_tx.unbounded_send(Box::new(future - .select(exit.clone()) + .select(exit.clone().map(Ok).compat()) .then(|_| Ok(())))); telemetry }); @@ -1108,7 +1108,7 @@ ServiceBuilder< if let Some(port) = config.grafana_port { let future = select( grafana_data_source::run_server(port).boxed(), - exit.clone().compat() + exit.clone() ).map(|either| match either { Either::Left((result, _)) => result.map_err(|_| ()), Either::Right(_) => Ok(()) diff --git a/client/service/src/lib.rs b/client/service/src/lib.rs index 8e2be43965..2ce2f307fc 100644 --- a/client/service/src/lib.rs +++ b/client/service/src/lib.rs @@ -120,7 +120,8 @@ impl Executor + Send>> for SpawnTaskHandle &self, future: Box + Send>, ) -> Result<(), futures::future::ExecuteError + Send>>> { - let future = Box::new(future.select(self.on_exit.clone()).then(|_| Ok(()))); + let exit = self.on_exit.clone().map(Ok).compat(); + let future = Box::new(future.select(exit).then(|_| Ok(()))); if let Err(err) = self.sender.unbounded_send(future) { let kind = futures::future::ExecuteErrorKind::Shutdown; Err(futures::future::ExecuteError::new(kind, err.into_inner())) @@ -236,7 +237,8 @@ where } fn spawn_task(&self, task: impl Future + Send + 'static) { - let task = task.select(self.on_exit()).then(|_| Ok(())); + let exit = self.on_exit().map(Ok).compat(); + let task = task.select(exit).then(|_| Ok(())); let _ = self.to_spawn_tx.unbounded_send(Box::new(task)); } @@ -249,7 +251,8 @@ where let _ = essential_failed.send(()); Ok(()) }); - let task = essential_task.select(self.on_exit()).then(|_| Ok(())); + let exit = self.on_exit().map(Ok::<_, ()>).compat(); + let task = essential_task.select(exit).then(|_| Ok(())); let _ = self.to_spawn_tx.unbounded_send(Box::new(task)); } @@ -503,7 +506,7 @@ impl Drop for fn drop(&mut self) { debug!(target: "service", "Substrate service shutdown"); if let Some(signal) = self.signal.take() { - signal.fire(); + let _ = signal.fire(); } } } -- GitLab From 6ea8efa3fb203537d499822e36533645ac65f7b7 Mon Sep 17 00:00:00 2001 From: Ashley Date: Wed, 4 Dec 2019 18:49:12 +0100 Subject: [PATCH 076/172] Use timestamp deltas in grafana-data-store (#4199) * Optimize grafana storage slightly * Test on grafana test binary * Cast to f32 * Silence record_metrics warning * Add source for error * More changes * Fix record_metrics_slice * Test Database * Docs * Update client/grafana-data-source/src/lib.rs Co-Authored-By: Niklas Adolfsson * Fix macro * Update server.rs --- client/grafana-data-source/src/database.rs | 170 ++++++++++++++++++++ client/grafana-data-source/src/lib.rs | 59 +++++-- client/grafana-data-source/src/server.rs | 72 ++------- client/grafana-data-source/src/util.rs | 52 ------ client/grafana-data-source/test/src/main.rs | 10 +- client/service/src/builder.rs | 20 +-- client/tracing/src/lib.rs | 2 +- 7 files changed, 247 insertions(+), 138 deletions(-) create mode 100644 client/grafana-data-source/src/database.rs delete mode 100644 client/grafana-data-source/src/util.rs diff --git a/client/grafana-data-source/src/database.rs b/client/grafana-data-source/src/database.rs new file mode 100644 index 0000000000..21c6ed5b0b --- /dev/null +++ b/client/grafana-data-source/src/database.rs @@ -0,0 +1,170 @@ +// Copyright 2019 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Substrate is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Substrate. If not, see . + +use std::collections::HashMap; +use std::convert::TryFrom; +use crate::Error; + +pub struct Database { + base_timestamp: i64, + storage: HashMap> +} + +impl Database { + /// Create a new Database. + pub fn new() -> Self { + Self { + base_timestamp: now_millis(), + storage: HashMap::new() + } + } + + /// Produce an iterator for keys starting with a base string. + pub fn keys_starting_with<'a>(&'a self, base: &'a str) -> impl Iterator + 'a { + self.storage.keys() + .filter(move |key| key.starts_with(base)) + .cloned() + } + + /// Select `max_datapoints` datapoints that have been added between `from` and `to`. + pub fn datapoints_between(&self, key: &str, from: i64, to: i64, max_datapoints: usize) -> Option> { + self.storage.get(key) + .map(|vec| { + let from = find_index(vec, self.base_timestamp, from); + let to = find_index(vec, self.base_timestamp, to); + let slice = &vec[from .. to]; + + if max_datapoints == 0 { + Vec::new() + } else if max_datapoints >= slice.len() { + // Just convert the slice as-is + slice.iter() + .map(|dp| dp.make_absolute(self.base_timestamp)) + .collect() + } else { + // We have more datapoints than we need, so we need to skip some + (0 .. max_datapoints - 1) + .map(|i| &slice[i * slice.len() / (max_datapoints - 1)]) + .chain(slice.last()) + .map(|dp| dp.make_absolute(self.base_timestamp)) + .collect() + } + }) + } + + /// Push a new datapoint. Will error if the base timestamp hasn't been updated in `2^32` + /// milliseconds (49 days). + pub fn push(&mut self, key: &str, value: f32) -> Result<(), Error> { + self.storage.entry(key.into()) + .or_insert_with(Vec::new) + .push(Datapoint::new(self.base_timestamp, value)?); + + Ok(()) + } + + /// Set a new base timestamp, and remove metrics older than this new timestamp. Errors if the + /// difference between timestamps is greater than `2^32` milliseconds (49 days). + pub fn truncate(&mut self, new_base_timestamp: i64) -> Result<(), Error> { + // Ensure that the new base is older. + if self.base_timestamp >= new_base_timestamp { + return Ok(()); + } + + // If the old base timestamp was too long ago, the + let delta = u32::try_from(new_base_timestamp - self.base_timestamp) + .map_err(Error::Timestamp)?; + + for metric in self.storage.values_mut() { + // Find the index of the oldest allowed timestamp and cut out all those before it. + let index = find_index(&metric, self.base_timestamp, new_base_timestamp); + + *metric = metric.iter_mut() + .skip(index) + .map(|dp| { + dp.delta_timestamp -= delta; + *dp + }) + .collect(); + } + + self.base_timestamp = new_base_timestamp; + + Ok(()) + } +} + +#[derive(Clone, Copy)] +struct Datapoint { + delta_timestamp: u32, + value: f32 +} + +impl Datapoint { + fn new(base_timestamp: i64, value: f32) -> Result { + Ok(Self { + delta_timestamp: u32::try_from(now_millis() - base_timestamp) + .map_err(Error::Timestamp)?, + value + }) + } + + fn make_absolute(&self, base_timestamp: i64) -> (f32, i64) { + (self.value, base_timestamp + self.delta_timestamp as i64) + } +} + +fn find_index(slice: &[Datapoint], base_timestamp: i64, timestamp: i64) -> usize { + slice.binary_search_by_key(×tamp, |datapoint| { + base_timestamp + datapoint.delta_timestamp as i64 + }).unwrap_or_else(|index| index) +} + +/// Get the current unix timestamp in milliseconds. +fn now_millis() -> i64 { + chrono::Utc::now().timestamp_millis() +} + +#[test] +fn test() { + let mut database = Database::new(); + let start = now_millis(); + + database.push("test", 1.0).unwrap(); + database.push("test", 2.5).unwrap(); + database.push("test", 2.0).unwrap(); + database.push("test 2", 1.0).unwrap(); + + let mut keys: Vec<_> = database.keys_starting_with("test").collect(); + keys.sort(); + + assert_eq!(keys, ["test", "test 2"]); + assert_eq!(database.keys_starting_with("test ").collect::>(), ["test 2"]); + + assert_eq!( + database.datapoints_between("test", start - 1000, start + 1000, 4), + Some(vec![(1.0, start), (2.5, start), (2.0, start)]) + ); + + assert_eq!( + database.datapoints_between("test", start - 1000, start + 1000, 3), + Some(vec![(1.0, start), (2.5, start), (2.0, start)]) + ); + + assert_eq!( + database.datapoints_between("test", start - 1000, start + 1000, 2), + Some(vec![(1.0, start), (2.0, start)]) + ); +} diff --git a/client/grafana-data-source/src/lib.rs b/client/grafana-data-source/src/lib.rs index 09822adb58..a1841178e9 100644 --- a/client/grafana-data-source/src/lib.rs +++ b/client/grafana-data-source/src/lib.rs @@ -23,36 +23,65 @@ //! [Grafana]: https://grafana.com/ //! [`grafana-json-data-source`]: https://github.com/simPod/grafana-json-datasource +#![warn(missing_docs)] + use lazy_static::lazy_static; -use std::collections::HashMap; use parking_lot::RwLock; mod types; mod server; -mod util; #[cfg(not(target_os = "unknown"))] mod networking; +mod database; +use database::Database; pub use server::run_server; -pub use util::now_millis; - -type Metrics = HashMap>; +use std::num::TryFromIntError; lazy_static! { - /// The `RwLock` wrapping the metrics. Not intended to be used directly. - #[doc(hidden)] - pub static ref METRICS: RwLock = RwLock::new(Metrics::new()); + // The `RwLock` wrapping the metrics database. + static ref DATABASE: RwLock = RwLock::new(Database::new()); } /// Write metrics to `METRICS`. #[macro_export] macro_rules! record_metrics( - ($($key:expr => $value:expr),*) => { - use $crate::{METRICS, now_millis}; - let mut metrics = METRICS.write(); - let now = now_millis(); - $( - metrics.entry($key).or_insert_with(Vec::new).push(($value as f32, now)); - )* + ($($key:expr => $value:expr,)*) => { + $crate::record_metrics_slice(&[ + $( ($key, $value as f32), )* + ]); } ); + +/// Write metrics to `METRICS` as a slice. Intended to be only used via `record_metrics!`. +pub fn record_metrics_slice(metrics: &[(&str, f32)]) -> Result<(), Error> { + let mut database = crate::DATABASE.write(); + + for &(key, value) in metrics.iter() { + database.push(key, value)?; + } + + Ok(()) +} + +/// Error type that can be returned by either `record_metrics` or `run_server`. +#[derive(Debug, derive_more::Display, derive_more::From)] +pub enum Error { + Hyper(hyper::Error), + Serde(serde_json::Error), + Http(hyper::http::Error), + Timestamp(TryFromIntError), + Io(std::io::Error) +} + +impl std::error::Error for Error { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + match self { + Error::Hyper(error) => Some(error), + Error::Serde(error) => Some(error), + Error::Http(error) => Some(error), + Error::Timestamp(error) => Some(error), + Error::Io(error) => Some(error) + } + } +} diff --git a/client/grafana-data-source/src/server.rs b/client/grafana-data-source/src/server.rs index cb1efd67bd..37717fa244 100644 --- a/client/grafana-data-source/src/server.rs +++ b/client/grafana-data-source/src/server.rs @@ -19,45 +19,31 @@ use hyper::{Body, Request, Response, header, service::{service_fn, make_service_ use chrono::{Duration, Utc}; use futures_util::{FutureExt, future::{Future, select, Either}}; use futures_timer::Delay; -use crate::{METRICS, util, types::{Target, Query, TimeseriesData}}; - -#[derive(Debug, derive_more::Display)] -enum Error { - Hyper(hyper::Error), - Serde(serde_json::Error), - Http(hyper::http::Error) -} - -impl std::error::Error for Error {} +use crate::{DATABASE, Error, types::{Target, Query, TimeseriesData, Range}}; async fn api_response(req: Request) -> Result, Error> { match req.uri().path() { "/search" => { map_request_to_response(req, |target: Target| { // Filter and return metrics relating to the target - METRICS.read() - .keys() - .filter(|key| key.starts_with(&target.target)) - .cloned() + DATABASE.read() + .keys_starting_with(&target.target) .collect::>() }).await }, "/query" => { map_request_to_response(req, |query: Query| { - let metrics = METRICS.read(); + let metrics = DATABASE.read(); + + let Query { + range: Range { from, to }, + max_datapoints, .. + } = query; // Return timeseries data related to the specified metrics query.targets.iter() .map(|target| { - let datapoints = metrics.get(target.target.as_str()) - .map(|metric| { - let from = util::find_index(&metric, query.range.from); - let to = util::find_index(&metric, query.range.to); - - // Avoid returning more than `max_datapoints` (mostly to stop - // the web browser from having to do a ton of work) - util::select_points(&metric[from .. to], query.max_datapoints) - }) + let datapoints = metrics.datapoints_between(&target.target, from, to, max_datapoints) .unwrap_or_else(Vec::new); TimeseriesData { @@ -110,27 +96,9 @@ impl tokio_executor::TypedExecutor for Executor } } -/// An error that may occur during server runtime. -#[derive(Debug, derive_more::Display, derive_more::From)] -pub enum RunError { - /// Propagated hyper server error. - Hyper(hyper::Error), - /// Initial bind IO error. - Io(std::io::Error), -} - -impl std::error::Error for RunError { - fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - match *self { - Self::Hyper(ref e) => Some(e), - Self::Io(ref e) => Some(e), - } - } -} - /// Start the data source server. #[cfg(not(target_os = "unknown"))] -pub async fn run_server(mut address: std::net::SocketAddr) -> Result<(), RunError> { +pub async fn run_server(mut address: std::net::SocketAddr) -> Result<(), Error> { use async_std::{net, io}; use crate::networking::Incoming; @@ -172,33 +140,23 @@ pub async fn run_server(mut address: std::net::SocketAddr) -> Result<(), RunErro let result = match select(server, clean).await { Either::Left((result, _)) => result.map_err(Into::into), - Either::Right(_) => Ok(()) + Either::Right((result, _)) => result }; result } #[cfg(target_os = "unknown")] -pub async fn run_server(_: std::net::SocketAddr) -> Result<(), RunError> { +pub async fn run_server(_: std::net::SocketAddr) -> Result<(), Error> { Ok(()) } /// Periodically remove old metrics. -async fn clean_up(every: std::time::Duration, before: Duration) { +async fn clean_up(every: std::time::Duration, before: Duration) -> Result<(), Error> { loop { Delay::new(every).await; let oldest_allowed = (Utc::now() - before).timestamp_millis(); - - let mut metrics = METRICS.write(); - - for metric in metrics.values_mut() { - // Find the index of the oldest allowed timestamp and cut out all those before it. - let index = util::find_index(&metric, oldest_allowed); - - if index > 0 { - *metric = metric[index..].to_vec(); - } - } + DATABASE.write().truncate(oldest_allowed)?; } } diff --git a/client/grafana-data-source/src/util.rs b/client/grafana-data-source/src/util.rs deleted file mode 100644 index cd27c440f7..0000000000 --- a/client/grafana-data-source/src/util.rs +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2019 Parity Technologies (UK) Ltd. -// This file is part of Substrate. - -// Substrate is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Substrate is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Substrate. If not, see . - -/// Get the current unix timestamp in milliseconds. -pub fn now_millis() -> i64 { - chrono::Utc::now().timestamp_millis() -} - -// find the index of a timestamp -pub fn find_index(slice: &[(f32, i64)], timestamp: i64) -> usize { - slice.binary_search_by_key(×tamp, |&(_, timestamp)| timestamp) - .unwrap_or_else(|index| index) -} - -// Evenly select up to `num_points` points from a slice -pub fn select_points(slice: &[T], num_points: usize) -> Vec { - if num_points == 0 { - return Vec::new(); - } else if num_points >= slice.len() { - return slice.to_owned(); - } - - (0 .. num_points - 1) - .map(|i| slice[i * slice.len() / (num_points - 1)]) - .chain(slice.last().cloned()) - .collect() -} - -#[test] -fn test_select_points() { - let array = [1, 2, 3, 4, 5]; - assert_eq!(select_points(&array, 0), Vec::::new()); - assert_eq!(select_points(&array, 1), vec![5]); - assert_eq!(select_points(&array, 2), vec![1, 5]); - assert_eq!(select_points(&array, 3), vec![1, 3, 5]); - assert_eq!(select_points(&array, 4), vec![1, 2, 4, 5]); - assert_eq!(select_points(&array, 5), vec![1, 2, 3, 4, 5]); - assert_eq!(select_points(&array, 6), vec![1, 2, 3, 4, 5]); -} diff --git a/client/grafana-data-source/test/src/main.rs b/client/grafana-data-source/test/src/main.rs index a4769e2bbb..a723e7e476 100644 --- a/client/grafana-data-source/test/src/main.rs +++ b/client/grafana-data-source/test/src/main.rs @@ -25,10 +25,14 @@ async fn randomness() { let random = rand::thread_rng().gen_range(0.0, 1000.0); - record_metrics!( - "random data".to_owned() => random, - "random^2".to_owned() => random * random + let result = record_metrics!( + "random data" => random, + "random^2" => random * random, ); + + if let Err(error) = result { + eprintln!("{}", error); + } } } diff --git a/client/service/src/builder.rs b/client/service/src/builder.rs index 0ca842e4bc..157af7d296 100644 --- a/client/service/src/builder.rs +++ b/client/service/src/builder.rs @@ -954,16 +954,16 @@ ServiceBuilder< "bandwidth_upload" => bandwidth_upload, "used_state_cache_size" => used_state_cache_size, ); - record_metrics!( - "peers".to_owned() => num_peers, - "height".to_owned() => best_number, - "txcount".to_owned() => txpool_status.ready, - "cpu".to_owned() => cpu_usage, - "memory".to_owned() => memory, - "finalized_height".to_owned() => finalized_number, - "bandwidth_download".to_owned() => bandwidth_download, - "bandwidth_upload".to_owned() => bandwidth_upload, - "used_state_cache_size".to_owned() => used_state_cache_size + let _ = record_metrics!( + "peers" => num_peers, + "height" => best_number, + "txcount" => txpool_status.ready, + "cpu" => cpu_usage, + "memory" => memory, + "finalized_height" => finalized_number, + "bandwidth_download" => bandwidth_download, + "bandwidth_upload" => bandwidth_upload, + "used_state_cache_size" => used_state_cache_size, ); Ok(()) diff --git a/client/tracing/src/lib.rs b/client/tracing/src/lib.rs index b87273bdaa..4be87bc2f7 100644 --- a/client/tracing/src/lib.rs +++ b/client/tracing/src/lib.rs @@ -293,5 +293,5 @@ fn send_telemetry(span_datum: SpanDatum) { fn send_grafana(span_datum: SpanDatum) { let name = format!("{}::{}", span_datum.target, span_datum.name); - record_metrics!(name => span_datum.overall_time.as_nanos()); + record_metrics!(&name => span_datum.overall_time.as_nanos(),); } -- GitLab From 60f2b7d5ea93452e905682a1305961a8dfd41811 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Wed, 4 Dec 2019 19:16:00 +0100 Subject: [PATCH 077/172] Revalidate some transactions on every block import. (#4292) * Revalidate some transactions on every block import. * Fix endless loop in revalidate_ready. * Clean up logging a bit. * More clean ups. * Print status after resubmitting. * Remove env_logger. * Remove redundant log. --- Cargo.lock | 1 - client/transaction-pool/graph/Cargo.toml | 1 - client/transaction-pool/graph/src/pool.rs | 39 +++++++++-- client/transaction-pool/graph/src/ready.rs | 4 +- .../graph/src/validated_pool.rs | 9 ++- client/transaction-pool/src/maintainer.rs | 66 ++++++++++++------- 6 files changed, 85 insertions(+), 35 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ba45de4d29..2b7e5dffbd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5568,7 +5568,6 @@ dependencies = [ "assert_matches 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "criterion 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", - "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/client/transaction-pool/graph/Cargo.toml b/client/transaction-pool/graph/Cargo.toml index 392a39ab6d..869a206007 100644 --- a/client/transaction-pool/graph/Cargo.toml +++ b/client/transaction-pool/graph/Cargo.toml @@ -16,7 +16,6 @@ txpool-api = { package = "sp-transaction-pool-api", path = "../../../primitives/ [dev-dependencies] assert_matches = "1.3.0" -env_logger = "0.7.0" codec = { package = "parity-scale-codec", version = "1.0.0" } test_runtime = { package = "substrate-test-runtime", path = "../../../test/utils/runtime" } criterion = "0.3" diff --git a/client/transaction-pool/graph/src/pool.rs b/client/transaction-pool/graph/src/pool.rs index cf5c7a5292..d29a513d97 100644 --- a/client/transaction-pool/graph/src/pool.rs +++ b/client/transaction-pool/graph/src/pool.rs @@ -175,13 +175,39 @@ impl Pool { /// /// Returns future that performs validation of all ready transactions and /// then resubmits all transactions back to the pool. - pub fn revalidate_ready(&self, at: &BlockId) -> impl Future> { + pub fn revalidate_ready( + &self, + at: &BlockId, + max: Option, + ) -> impl Future> { + use std::time::Instant; + log::debug!(target: "txpool", + "Fetching ready transactions (up to: {})", + max.map(|x| format!("{}", x)).unwrap_or_else(|| "all".into()) + ); let validated_pool = self.validated_pool.clone(); - let ready = self.validated_pool.ready().map(|tx| tx.data.clone()); + let ready = self.validated_pool.ready() + .map(|tx| tx.data.clone()) + .take(max.unwrap_or_else(usize::max_value)); + + let now = Instant::now(); self.verify(at, ready, false) - .map(move |revalidated_transactions| revalidated_transactions.map( - move |revalidated_transactions| validated_pool.resubmit(revalidated_transactions) - )) + .map(move |revalidated_transactions| { + log::debug!(target: "txpool", + "Re-verified transactions, took {} ms. Resubmitting.", + now.elapsed().as_millis() + ); + let now = Instant::now(); + let res = revalidated_transactions.map( + |revalidated_transactions| validated_pool.resubmit(revalidated_transactions) + ); + log::debug!(target: "txpool", + "Resubmitted. Took {} ms. Status: {:?}", + now.elapsed().as_millis(), + validated_pool.status() + ); + res + }) } /// Prunes known ready transactions. @@ -927,7 +953,6 @@ mod tests { #[test] fn should_handle_pruning_in_the_middle_of_import() { - let _ = env_logger::try_init(); // given let (ready, is_ready) = std::sync::mpsc::sync_channel(0); let (tx, rx) = std::sync::mpsc::sync_channel(1); @@ -1014,7 +1039,7 @@ mod tests { pool.validated_pool.api().invalidate.lock().insert(hash3); pool.validated_pool.api().clear_requirements.lock().insert(hash1); pool.validated_pool.api().add_requirements.lock().insert(hash0); - block_on(pool.revalidate_ready(&BlockId::Number(0))).unwrap(); + block_on(pool.revalidate_ready(&BlockId::Number(0), None)).unwrap(); // then // hash0 now has unsatisfied requirements => it is moved to the future queue diff --git a/client/transaction-pool/graph/src/ready.rs b/client/transaction-pool/graph/src/ready.rs index 11354e6871..a358047dd7 100644 --- a/client/transaction-pool/graph/src/ready.rs +++ b/client/transaction-pool/graph/src/ready.rs @@ -22,7 +22,7 @@ use std::{ }; use serde::Serialize; -use log::debug; +use log::trace; use parking_lot::RwLock; use sp_runtime::traits::Member; use sp_runtime::transaction_validity::{ @@ -267,7 +267,7 @@ impl ReadyTransactions { to_remove.append(&mut tx.unlocks); // add to removed - debug!(target: "txpool", "[{:?}] Removed as invalid: ", hash); + trace!(target: "txpool", "[{:?}] Removed as part of the subtree.", hash); removed.push(tx.transaction.transaction); } } diff --git a/client/transaction-pool/graph/src/validated_pool.rs b/client/transaction-pool/graph/src/validated_pool.rs index e32dac88eb..321eed0b62 100644 --- a/client/transaction-pool/graph/src/validated_pool.rs +++ b/client/transaction-pool/graph/src/validated_pool.rs @@ -106,7 +106,12 @@ impl ValidatedPool { .map(|validated_tx| self.submit_one(validated_tx)) .collect::>(); - let removed = self.enforce_limits(); + // only enforce limits if there is at least one imported transaction + let removed = if results.iter().any(|res| res.is_ok()) { + self.enforce_limits() + } else { + Default::default() + }; results.into_iter().map(|res| match res { Ok(ref hash) if removed.contains(hash) => Err(error::Error::ImmediatelyDropped.into()), @@ -236,6 +241,8 @@ impl ValidatedPool { initial_statuses.insert(removed_hash.clone(), Status::Ready); txs_to_resubmit.push((removed_hash, tx_to_resubmit)); } + // make sure to remove the hash even if it's not present in the pool any more. + updated_transactions.remove(&hash); } // if we're rejecting future transactions, then insertion order matters here: diff --git a/client/transaction-pool/src/maintainer.rs b/client/transaction-pool/src/maintainer.rs index 7c5d07e0f1..84b780f4f3 100644 --- a/client/transaction-pool/src/maintainer.rs +++ b/client/transaction-pool/src/maintainer.rs @@ -23,7 +23,7 @@ use futures::{ Future, FutureExt, future::{Either, join, ready}, }; -use log::{warn, debug}; +use log::{warn, debug, trace}; use parking_lot::Mutex; use client_api::{ @@ -74,6 +74,11 @@ where id: &BlockId, retracted: &[Block::Hash], ) -> Box + Send + Unpin> { + let now = std::time::Instant::now(); + let took = move || format!("Took {} ms", now.elapsed().as_millis()); + + let id = *id; + trace!(target: "txpool", "[{:?}] Starting pool maintainance", id); // Put transactions from retracted blocks back into the pool. let client_copy = self.client.clone(); let retracted_transactions = retracted.to_vec().into_iter() @@ -82,13 +87,14 @@ where // if signed information is not present, attempt to resubmit anyway. .filter(|tx| tx.is_signed().unwrap_or(true)); let resubmit_future = self.pool - .submit_at(id, retracted_transactions, true) - .then(|resubmit_result| ready(match resubmit_result { - Ok(_) => (), - Err(e) => { - debug!(target: "txpool", "Error re-submitting transactions: {:?}", e); - () - } + .submit_at(&id, retracted_transactions, true) + .then(move |resubmit_result| ready(match resubmit_result { + Ok(_) => trace!(target: "txpool", + "[{:?}] Re-submitting retracted done. {}", id, took() + ), + Err(e) => debug!(target: "txpool", + "[{:?}] Error re-submitting transactions: {:?}", id, e + ), })); // Avoid calling into runtime if there is nothing to prune from the pool anyway. @@ -96,28 +102,42 @@ where return Box::new(resubmit_future) } - let block = (self.client.header(*id), self.client.block_body(id)); - match block { + let block = (self.client.header(id), self.client.block_body(&id)); + let prune_future = match block { (Ok(Some(header)), Ok(Some(extrinsics))) => { let parent_id = BlockId::hash(*header.parent_hash()); let prune_future = self.pool - .prune(id, &parent_id, &extrinsics) - .then(|prune_result| ready(match prune_result { - Ok(_) => (), - Err(e) => { - warn!("Error pruning transactions: {:?}", e); - () - } + .prune(&id, &parent_id, &extrinsics) + .then(move |prune_result| ready(match prune_result { + Ok(_) => trace!(target: "txpool", + "[{:?}] Pruning done. {}", id, took() + ), + Err(e) => warn!(target: "txpool", + "[{:?}] Error pruning transactions: {:?}", id, e + ), })); - Box::new(resubmit_future.then(|_| prune_future)) + Either::Left(resubmit_future.then(|_| prune_future)) }, - (Ok(_), Ok(_)) => Box::new(resubmit_future), + (Ok(_), Ok(_)) => Either::Right(resubmit_future), err => { - warn!("Error reading block: {:?}", err); - Box::new(resubmit_future) + warn!(target: "txpool", "[{:?}] Error reading block: {:?}", id, err); + Either::Right(resubmit_future) }, - } + }; + + let revalidate_future = self.pool + .revalidate_ready(&id, Some(16)) + .then(move |result| ready(match result { + Ok(_) => debug!(target: "txpool", + "[{:?}] Revalidation done: {}", id, took() + ), + Err(e) => warn!(target: "txpool", + "[{:?}] Encountered errors while revalidating transactions: {:?}", id, e + ), + })); + + Box::new(prune_future.then(|_| revalidate_future)) } } @@ -228,7 +248,7 @@ impl LightBasicPoolMaintainer { let revalidation_status = self.revalidation_status.clone(); Either::Left(self.pool - .revalidate_ready(id) + .revalidate_ready(id, None) .map(|r| r.map_err(|e| warn!("Error revalidating known transactions: {}", e))) .map(move |_| revalidation_status.lock().clear())) }, -- GitLab From 333f3a7d00771d15102bd40f5aade9e58b1b095f Mon Sep 17 00:00:00 2001 From: Max Inden Date: Wed, 4 Dec 2019 19:19:52 +0100 Subject: [PATCH 078/172] client/authority-discovery: Fix interval_at to fire on start (#4274) * client/authority-discovery: Add smoke tests for intervall_at * client/authority-discovery: Fix interval_at to fire on start -- GitLab From 7d99220d5bb433ba1d56134f141b9171c8ee7b95 Mon Sep 17 00:00:00 2001 From: Drew Stone Date: Thu, 5 Dec 2019 11:07:58 +0200 Subject: [PATCH 079/172] Add linear back-off for aura slot workers (#4293) * Add linear back-off for aura slot workers * logging * Use slot from header --- client/consensus/aura/src/lib.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/client/consensus/aura/src/lib.rs b/client/consensus/aura/src/lib.rs index 7653be7259..e07ab5f99a 100644 --- a/client/consensus/aura/src/lib.rs +++ b/client/consensus/aura/src/lib.rs @@ -302,6 +302,32 @@ impl slots::SimpleSlotWorker for AuraWorker Option { + // never give more than 20 times more lenience. + const BACKOFF_CAP: u64 = 20; + + let slot_remaining = self.slot_remaining_duration(slot_info); + let parent_slot = match find_pre_digest::(head) { + Err(_) => return Some(slot_remaining), + Ok(d) => d, + }; + + // we allow a lenience of the number of slots since the head of the + // chain was produced, minus 1 (since there is always a difference of at least 1) + // + // linear back-off. + // in normal cases we only attempt to issue blocks up to the end of the slot. + // when the chain has been stalled for a few slots, we give more lenience. + let slot_lenience = slot_info.number.saturating_sub(parent_slot + 1); + let slot_lenience = std::cmp::min(slot_lenience, BACKOFF_CAP); + let slot_lenience = Duration::from_secs(slot_lenience * slot_info.duration); + Some(slot_lenience + slot_remaining) + } } impl SlotWorker for AuraWorker where @@ -357,6 +383,10 @@ fn find_pre_digest(header: &B::Header) -> Result = None; for log in header.digest().logs() { trace!(target: "aura", "Checking log {:?}", log); -- GitLab From 0b0d9d4d21708e100eac080aab4b9b6d85f563c8 Mon Sep 17 00:00:00 2001 From: Spencer Judge Date: Thu, 5 Dec 2019 01:42:42 -0800 Subject: [PATCH 080/172] Expose some of session module's storage as public, as well as the set_keys transaction (#4175) * Expose some of session's storage as public, as well as set_keys Seemingly there's no reason not to do this, as anyone can always do it the "hard way" by constructing storage keys or extrinsics. * Use trait to expose `is_registered` function * Missed removing a pub keyword * Move trait to support, add docstrings --- frame/session/src/lib.rs | 8 +++++++- frame/support/src/traits.rs | 9 +++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/frame/session/src/lib.rs b/frame/session/src/lib.rs index cf73c9d0fb..69273b9a43 100644 --- a/frame/session/src/lib.rs +++ b/frame/session/src/lib.rs @@ -126,7 +126,7 @@ use support::weights::SimpleDispatchInfo; use sp_runtime::traits::{Convert, Zero, Member, OpaqueKeys}; use sp_staking::SessionIndex; use support::{dispatch::Result, ConsensusEngineId, decl_module, decl_event, decl_storage}; -use support::{ensure, traits::{OnFreeBalanceZero, Get, FindAuthor}, Parameter}; +use support::{ensure, traits::{OnFreeBalanceZero, Get, FindAuthor, ValidatorRegistration}, Parameter}; use system::{self, ensure_signed}; #[cfg(test)] @@ -333,6 +333,12 @@ impl SelectInitialValidators for () { } } +impl ValidatorRegistration for Module { + fn is_registered(id: &T::ValidatorId) -> bool { + Self::load_keys(id).is_some() + } +} + pub trait Trait: system::Trait { /// The overarching event type. type Event: From + Into<::Event>; diff --git a/frame/support/src/traits.rs b/frame/support/src/traits.rs index 3a9b0c2d8b..0a94483ec3 100644 --- a/frame/support/src/traits.rs +++ b/frame/support/src/traits.rs @@ -769,3 +769,12 @@ pub trait Randomness { Self::random(&[][..]) } } + +/// Implementors of this trait provide information about whether or not some validator has +/// been registered with them. The [Session module](../../pallet_session/index.html) is an implementor. +pub trait ValidatorRegistration { + /// Returns true if the provided validator ID has been registered with the implementing runtime + /// module + fn is_registered(id: &ValidatorId) -> bool; +} + -- GitLab From ff16e959cabc0b0fe7d352956288af8dc994ef74 Mon Sep 17 00:00:00 2001 From: Yuanchao Sun Date: Thu, 5 Dec 2019 20:00:45 +0800 Subject: [PATCH 081/172] Minor fix toml files (#4291) --- bin/node/cli/Cargo.toml | 2 +- client/api/Cargo.toml | 2 +- client/transaction-pool/Cargo.toml | 2 +- frame/authority-discovery/Cargo.toml | 2 +- frame/staking/reward-curve/Cargo.toml | 2 +- primitives/runtime-interface/proc-macro/Cargo.toml | 4 ++-- primitives/sr-api/proc-macro/Cargo.toml | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/bin/node/cli/Cargo.toml b/bin/node/cli/Cargo.toml index d3340aa0ae..ec89aef6fe 100644 --- a/bin/node/cli/Cargo.toml +++ b/bin/node/cli/Cargo.toml @@ -24,7 +24,7 @@ crate-type = ["cdylib", "rlib"] [dependencies] # third-party dependencies codec = { package = "parity-scale-codec", version = "1.0.6" } -serde = { version = "1.0.102", features = [ "derive" ] } +serde = { version = "1.0.102", features = ["derive"] } futures01 = { package = "futures", version = "0.1.29" } futures = { version = "0.3.1", features = ["compat"] } hex-literal = "0.2.1" diff --git a/client/api/Cargo.toml b/client/api/Cargo.toml index 38fe13cda2..212cf9b735 100644 --- a/client/api/Cargo.toml +++ b/client/api/Cargo.toml @@ -34,7 +34,7 @@ txpool-api = { package = "sp-transaction-pool-api", path = "../../primitives/tra [dev-dependencies] env_logger = "0.7.0" tempfile = "3.1.0" -client-db = { package = "sc-client-db", path = ".././db", features = ["kvdb-rocksdb"] } +client-db = { package = "sc-client-db", path = "../db", features = ["kvdb-rocksdb"] } test-primitives = { package = "substrate-test-primitives", path = "../../test/utils/primitives" } test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client" } kvdb-memorydb = "0.1.2" diff --git a/client/transaction-pool/Cargo.toml b/client/transaction-pool/Cargo.toml index 9ae87d50ed..d09b53860e 100644 --- a/client/transaction-pool/Cargo.toml +++ b/client/transaction-pool/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] codec = { package = "parity-scale-codec", version = "1.0.0" } derive_more = "0.99.2" -futures = { version = "0.3.1", features = ["compat", "compat"] } +futures = { version = "0.3.1", features = ["compat"] } log = "0.4.8" parking_lot = "0.9.0" primitives = { package = "sp-core", path = "../../primitives/core" } diff --git a/frame/authority-discovery/Cargo.toml b/frame/authority-discovery/Cargo.toml index 84da66f12b..7d44071822 100644 --- a/frame/authority-discovery/Cargo.toml +++ b/frame/authority-discovery/Cargo.toml @@ -12,7 +12,7 @@ primitives = { package = "sp-core", path = "../../primitives/core", default-fea rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } serde = { version = "1.0.101", optional = true } runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } -session = { package = "pallet-session", path = "../session", default-features = false, features = [ "historical" ] } +session = { package = "pallet-session", path = "../session", default-features = false, features = ["historical"] } sp-runtime = { path = "../../primitives/sr-primitives", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } system = { package = "frame-system", path = "../system", default-features = false } diff --git a/frame/staking/reward-curve/Cargo.toml b/frame/staking/reward-curve/Cargo.toml index 0df68a43af..2d9ae607df 100644 --- a/frame/staking/reward-curve/Cargo.toml +++ b/frame/staking/reward-curve/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" proc-macro = true [dependencies] -syn = { version = "1.0.7", features = [ "full", "visit" ] } +syn = { version = "1.0.7", features = ["full", "visit"] } quote = "1.0" proc-macro2 = "1.0.6" proc-macro-crate = "0.1.4" diff --git a/primitives/runtime-interface/proc-macro/Cargo.toml b/primitives/runtime-interface/proc-macro/Cargo.toml index 11a01a7a7c..2fcaa59447 100644 --- a/primitives/runtime-interface/proc-macro/Cargo.toml +++ b/primitives/runtime-interface/proc-macro/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" proc-macro = true [dependencies] -syn = { version = "1.0.5", features = [ "full", "visit", "fold", "extra-traits" ] } +syn = { version = "1.0.5", features = ["full", "visit", "fold", "extra-traits"] } quote = "1.0.2" proc-macro2 = "1.0.3" Inflector = "0.11.4" @@ -16,7 +16,7 @@ proc-macro-crate = "0.1.4" [dev-dependencies] runtime-interface = { package = "sp-runtime-interface", path = ".." } -codec = { package = "parity-scale-codec", version = "1.0.6", features = [ "derive" ] } +codec = { package = "parity-scale-codec", version = "1.0.6", features = ["derive"] } externalities = { package = "sp-externalities", path = "../../externalities" } rustversion = "1.0.0" trybuild = "1.0.17" diff --git a/primitives/sr-api/proc-macro/Cargo.toml b/primitives/sr-api/proc-macro/Cargo.toml index 7eb6bcdb8b..5654369fe1 100644 --- a/primitives/sr-api/proc-macro/Cargo.toml +++ b/primitives/sr-api/proc-macro/Cargo.toml @@ -9,7 +9,7 @@ proc-macro = true [dependencies] quote = "1.0.2" -syn = { version = "1.0.8", features = [ "full", "fold", "extra-traits", "visit" ] } +syn = { version = "1.0.8", features = ["full", "fold", "extra-traits", "visit"] } proc-macro2 = "1.0.6" blake2-rfc = "0.2.18" proc-macro-crate = "0.1.4" -- GitLab From 41d095f12d36d51e12e1accfeed4805c6789a704 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Thu, 5 Dec 2019 13:01:40 +0100 Subject: [PATCH 082/172] Use balance capped to u64 for transaction payment RPC. (#4290) * Use balance capped to u64 * Add debug. --- .../rpc/runtime-api/Cargo.toml | 1 + .../rpc/runtime-api/src/lib.rs | 40 ++++++++++++++++++- frame/transaction-payment/rpc/src/lib.rs | 12 +++--- 3 files changed, 45 insertions(+), 8 deletions(-) diff --git a/frame/transaction-payment/rpc/runtime-api/Cargo.toml b/frame/transaction-payment/rpc/runtime-api/Cargo.toml index e437b22fc0..7fc26b0888 100644 --- a/frame/transaction-payment/rpc/runtime-api/Cargo.toml +++ b/frame/transaction-payment/rpc/runtime-api/Cargo.toml @@ -23,4 +23,5 @@ std = [ "codec/std", "rstd/std", "sp-runtime/std", + "support/std", ] diff --git a/frame/transaction-payment/rpc/runtime-api/src/lib.rs b/frame/transaction-payment/rpc/runtime-api/src/lib.rs index e922ff9e28..549f67c98c 100644 --- a/frame/transaction-payment/rpc/runtime-api/src/lib.rs +++ b/frame/transaction-payment/rpc/runtime-api/src/lib.rs @@ -23,11 +23,11 @@ use support::weights::{Weight, DispatchClass}; use codec::{Encode, Codec, Decode}; #[cfg(feature = "std")] use serde::{Serialize, Deserialize}; +use sp_runtime::traits::{UniqueSaturatedInto, SaturatedConversion}; /// Some information related to a dispatchable that can be queried from the runtime. #[derive(Eq, PartialEq, Encode, Decode, Default)] -#[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))] -#[cfg_attr(feature = "std", serde(rename_all = "camelCase"))] +#[cfg_attr(feature = "std", derive(Debug))] pub struct RuntimeDispatchInfo { /// Weight of this dispatch. pub weight: Weight, @@ -38,6 +38,41 @@ pub struct RuntimeDispatchInfo { pub partial_fee: Balance, } +/// A capped version of `RuntimeDispatchInfo`. +/// +/// The `Balance` is capped (or expanded) to `u64` to avoid serde issues with `u128`. +#[derive(Eq, PartialEq, Encode, Decode, Default)] +#[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))] +#[cfg_attr(feature = "std", serde(rename_all = "camelCase"))] +pub struct CappedDispatchInfo { + /// Weight of this dispatch. + pub weight: Weight, + /// Class of this dispatch. + pub class: DispatchClass, + /// The partial inclusion fee of this dispatch. This does not include tip or anything else which + /// is dependent on the signature (aka. depends on a `SignedExtension`). + pub partial_fee: u64, +} + +impl CappedDispatchInfo { + /// Create a new `CappedDispatchInfo` from `RuntimeDispatchInfo`. + pub fn new>( + dispatch: RuntimeDispatchInfo, + ) -> Self { + let RuntimeDispatchInfo { + weight, + class, + partial_fee, + } = dispatch; + + Self { + weight, + class, + partial_fee: partial_fee.saturated_into(), + } + } +} + sp_api::decl_runtime_apis! { pub trait TransactionPaymentApi where Balance: Codec, @@ -59,6 +94,7 @@ mod tests { partial_fee: 1_000_000_u64, }; + let info = CappedDispatchInfo::new(info); assert_eq!( serde_json::to_string(&info).unwrap(), r#"{"weight":5,"class":"normal","partialFee":1000000}"#, diff --git a/frame/transaction-payment/rpc/src/lib.rs b/frame/transaction-payment/rpc/src/lib.rs index 35ad4a06ed..63a6b1827b 100644 --- a/frame/transaction-payment/rpc/src/lib.rs +++ b/frame/transaction-payment/rpc/src/lib.rs @@ -23,10 +23,10 @@ use jsonrpc_core::{Error as RpcError, ErrorCode, Result}; use jsonrpc_derive::rpc; use sp_runtime::{ generic::BlockId, - traits::{Block as BlockT, ProvideRuntimeApi}, + traits::{Block as BlockT, ProvideRuntimeApi, UniqueSaturatedInto}, }; use primitives::Bytes; -use pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo; +use pallet_transaction_payment_rpc_runtime_api::CappedDispatchInfo; pub use pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi as TransactionPaymentRuntimeApi; pub use self::gen_client::Client as TransactionPaymentClient; @@ -37,7 +37,7 @@ pub trait TransactionPaymentApi { &self, encoded_xt: Bytes, at: Option - ) -> Result>; + ) -> Result; } /// A struct that implements the [`TransactionPaymentApi`]. @@ -78,14 +78,14 @@ where C: ProvideRuntimeApi, C: HeaderBackend, C::Api: TransactionPaymentRuntimeApi, - Balance: Codec, + Balance: Codec + UniqueSaturatedInto, Extrinsic: Codec + Send + Sync + 'static, { fn query_info( &self, encoded_xt: Bytes, at: Option<::Hash> - ) -> Result> { + ) -> Result { let api = self.client.runtime_api(); let at = BlockId::hash(at.unwrap_or_else(|| // If the block hash is not supplied assume the best block. @@ -103,6 +103,6 @@ where code: ErrorCode::ServerError(Error::RuntimeError.into()), message: "Unable to query dispatch info.".into(), data: Some(format!("{:?}", e).into()), - }) + }).map(CappedDispatchInfo::new) } } -- GitLab From 2414f947ae017f68027512d1a71140dc7000a379 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Thu, 5 Dec 2019 13:02:22 +0100 Subject: [PATCH 083/172] Tone down warnings when resubmitting to the pool. (#4294) * Tone down warnings. * Fix the fix. * Add some debug info. * More logs. * Update logging. --- client/transaction-pool/graph/src/listener.rs | 8 ++++++-- client/transaction-pool/graph/src/validated_pool.rs | 8 ++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/client/transaction-pool/graph/src/listener.rs b/client/transaction-pool/graph/src/listener.rs index c6a90b0c5b..865255c9c7 100644 --- a/client/transaction-pool/graph/src/listener.rs +++ b/client/transaction-pool/graph/src/listener.rs @@ -91,8 +91,12 @@ impl Listene } /// Transaction was removed as invalid. - pub fn invalid(&mut self, tx: &H) { - warn!(target: "txpool", "Extrinsic invalid: {:?}", tx); + pub fn invalid(&mut self, tx: &H, warn: bool) { + if warn { + warn!(target: "txpool", "Extrinsic invalid: {:?}", tx); + } else { + debug!(target: "txpool", "Extrinsic invalid: {:?}", tx); + } self.fire(tx, |watcher| watcher.invalid()); } diff --git a/client/transaction-pool/graph/src/validated_pool.rs b/client/transaction-pool/graph/src/validated_pool.rs index 321eed0b62..7f9e407727 100644 --- a/client/transaction-pool/graph/src/validated_pool.rs +++ b/client/transaction-pool/graph/src/validated_pool.rs @@ -138,7 +138,7 @@ impl ValidatedPool { Err(err.into()) }, ValidatedTransaction::Unknown(hash, err) => { - self.listener.write().invalid(&hash); + self.listener.write().invalid(&hash, false); Err(err.into()) } } @@ -311,8 +311,8 @@ impl ValidatedPool { match final_status { Status::Future => listener.future(&hash), Status::Ready => listener.ready(&hash, None), - Status::Failed => listener.invalid(&hash), Status::Dropped => listener.dropped(&hash, None), + Status::Failed => listener.invalid(&hash, initial_status.is_some()), } } } @@ -478,7 +478,7 @@ impl ValidatedPool { let mut listener = self.listener.write(); for tx in &invalid { - listener.invalid(&tx.hash); + listener.invalid(&tx.hash, true); } invalid @@ -506,7 +506,7 @@ fn fire_events( base::Imported::Ready { ref promoted, ref failed, ref removed, ref hash } => { listener.ready(hash, None); for f in failed { - listener.invalid(f); + listener.invalid(f, true); } for r in removed { listener.dropped(&r.hash, Some(hash)); -- GitLab From 6e069eb4687ca2500c57ae4de8beca55b959d45b Mon Sep 17 00:00:00 2001 From: Max Inden Date: Thu, 5 Dec 2019 14:01:59 +0100 Subject: [PATCH 084/172] client/authority-discovery: Increase margins for interval test (#4297) `interval_at_is_queuing_ticks` test shows to be flaky. This commit increases the time margins while also reducing the amount of necessary time ticks. --- client/authority-discovery/src/lib.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/client/authority-discovery/src/lib.rs b/client/authority-discovery/src/lib.rs index 9fb82f30c6..7752b8dc9b 100644 --- a/client/authority-discovery/src/lib.rs +++ b/client/authority-discovery/src/lib.rs @@ -547,24 +547,26 @@ mod tests { } #[test] - fn interval_at_is_queuing_events() { + fn interval_at_is_queuing_ticks() { let start = Instant::now(); let interval = interval_at( - std::time::Instant::now(), - std::time::Duration::from_millis(10), + start, + std::time::Duration::from_millis(100), ); - // Let's wait for 100ms, thus 10 elements should be queued up. - std::thread::sleep(Duration::from_millis(100)); + // Let's wait for 200ms, thus 3 elements should be queued up (1st at 0ms, 2nd at 100ms, 3rd + // at 200ms). + std::thread::sleep(Duration::from_millis(200)); futures::executor::block_on(async { - interval.take(10).collect::>().await; + interval.take(3).collect::>().await; }); - // Make sure we did not just wait for yet another 100ms (10 elements). + // Make sure we did not wait for more than 300 ms, which would imply that `at_interval` is + // not queuing ticks. assert!( - Instant::now().saturating_duration_since(start) < Duration::from_millis(150), + Instant::now().saturating_duration_since(start) < Duration::from_millis(300), "Expect interval to /queue/ events when not polled for a while.", ); } -- GitLab From 75dadcf9ad1e2af5fcbba40b8a5a1fec9d4e9366 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Thu, 5 Dec 2019 14:02:48 +0100 Subject: [PATCH 085/172] Move legacy_proto to protocol (#4296) * Move legacy_proto to protocol * Edition 2018ize legacy_proto * Some basic documentation --- client/network/src/lib.rs | 1 - client/network/src/protocol.rs | 4 +++- .../src/{legacy_proto/mod.rs => protocol/legacy_proto.rs} | 6 ++++++ client/network/src/{ => protocol}/legacy_proto/behaviour.rs | 4 ++-- client/network/src/{ => protocol}/legacy_proto/handler.rs | 2 +- client/network/src/{ => protocol}/legacy_proto/tests.rs | 2 +- client/network/src/{ => protocol}/legacy_proto/upgrade.rs | 0 7 files changed, 13 insertions(+), 6 deletions(-) rename client/network/src/{legacy_proto/mod.rs => protocol/legacy_proto.rs} (72%) rename client/network/src/{ => protocol}/legacy_proto/behaviour.rs (99%) rename client/network/src/{ => protocol}/legacy_proto/handler.rs (99%) rename client/network/src/{ => protocol}/legacy_proto/tests.rs (99%) rename client/network/src/{ => protocol}/legacy_proto/upgrade.rs (100%) diff --git a/client/network/src/lib.rs b/client/network/src/lib.rs index 1816a21f97..05c8a1dc86 100644 --- a/client/network/src/lib.rs +++ b/client/network/src/lib.rs @@ -170,7 +170,6 @@ mod behaviour; mod chain; -mod legacy_proto; mod debug_info; mod discovery; mod on_demand_layer; diff --git a/client/network/src/protocol.rs b/client/network/src/protocol.rs index c8a4fadbff..88bc1ede52 100644 --- a/client/network/src/protocol.rs +++ b/client/network/src/protocol.rs @@ -15,7 +15,7 @@ // along with Substrate. If not, see . use crate::{DiscoveryNetBehaviour, config::ProtocolId}; -use crate::legacy_proto::{LegacyProto, LegacyProtoOut}; +use legacy_proto::{LegacyProto, LegacyProtoOut}; use crate::utils::interval; use bytes::BytesMut; use futures::prelude::*; @@ -55,7 +55,9 @@ use client_api::{FetchChecker, ChangesProof, StorageProof}; use crate::error; use util::LruHashSet; +mod legacy_proto; mod util; + pub mod consensus_gossip; pub mod message; pub mod event; diff --git a/client/network/src/legacy_proto/mod.rs b/client/network/src/protocol/legacy_proto.rs similarity index 72% rename from client/network/src/legacy_proto/mod.rs rename to client/network/src/protocol/legacy_proto.rs index bbe795528b..eee30117d9 100644 --- a/client/network/src/legacy_proto/mod.rs +++ b/client/network/src/protocol/legacy_proto.rs @@ -14,6 +14,12 @@ // You should have received a copy of the GNU General Public License // along with Substrate. If not, see . +//! Implementation of libp2p's `NetworkBehaviour` trait that opens a single substream with the +//! remote and then allows any communication with them. +//! +//! The `Protocol` struct uses `LegacyProto` in order to open substreams with the rest of the +//! network, then performs the Substrate protocol handling on top. + pub use self::behaviour::{LegacyProto, LegacyProtoOut}; mod behaviour; diff --git a/client/network/src/legacy_proto/behaviour.rs b/client/network/src/protocol/legacy_proto/behaviour.rs similarity index 99% rename from client/network/src/legacy_proto/behaviour.rs rename to client/network/src/protocol/legacy_proto/behaviour.rs index f890219158..ed3ea8af4d 100644 --- a/client/network/src/legacy_proto/behaviour.rs +++ b/client/network/src/protocol/legacy_proto/behaviour.rs @@ -15,8 +15,8 @@ // along with Substrate. If not, see . use crate::{DiscoveryNetBehaviour, config::ProtocolId}; -use crate::legacy_proto::handler::{CustomProtoHandlerProto, CustomProtoHandlerOut, CustomProtoHandlerIn}; -use crate::legacy_proto::upgrade::RegisteredProtocol; +use crate::protocol::legacy_proto::handler::{CustomProtoHandlerProto, CustomProtoHandlerOut, CustomProtoHandlerIn}; +use crate::protocol::legacy_proto::upgrade::RegisteredProtocol; use bytes::BytesMut; use fnv::FnvHashMap; use futures::prelude::*; diff --git a/client/network/src/legacy_proto/handler.rs b/client/network/src/protocol/legacy_proto/handler.rs similarity index 99% rename from client/network/src/legacy_proto/handler.rs rename to client/network/src/protocol/legacy_proto/handler.rs index 7bdbe4a31f..cbd0385734 100644 --- a/client/network/src/legacy_proto/handler.rs +++ b/client/network/src/protocol/legacy_proto/handler.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Substrate. If not, see . -use crate::legacy_proto::upgrade::{RegisteredProtocol, RegisteredProtocolEvent, RegisteredProtocolSubstream}; +use super::upgrade::{RegisteredProtocol, RegisteredProtocolEvent, RegisteredProtocolSubstream}; use bytes::BytesMut; use futures::prelude::*; use futures03::{compat::Compat, TryFutureExt as _}; diff --git a/client/network/src/legacy_proto/tests.rs b/client/network/src/protocol/legacy_proto/tests.rs similarity index 99% rename from client/network/src/legacy_proto/tests.rs rename to client/network/src/protocol/legacy_proto/tests.rs index dc6d40eb04..08c3a47c0e 100644 --- a/client/network/src/legacy_proto/tests.rs +++ b/client/network/src/protocol/legacy_proto/tests.rs @@ -26,7 +26,7 @@ use libp2p::{PeerId, Multiaddr, Transport}; use rand::seq::SliceRandom; use std::{io, time::Duration, time::Instant}; use crate::message::Message; -use crate::legacy_proto::{LegacyProto, LegacyProtoOut}; +use crate::protocol::legacy_proto::{LegacyProto, LegacyProtoOut}; use test_client::runtime::Block; /// Builds two nodes that have each other as bootstrap nodes. diff --git a/client/network/src/legacy_proto/upgrade.rs b/client/network/src/protocol/legacy_proto/upgrade.rs similarity index 100% rename from client/network/src/legacy_proto/upgrade.rs rename to client/network/src/protocol/legacy_proto/upgrade.rs -- GitLab From 2b473e4c04f7bf985cad00c167a6dcdef66d999f Mon Sep 17 00:00:00 2001 From: Max Inden Date: Thu, 5 Dec 2019 16:05:42 +0100 Subject: [PATCH 086/172] client/authority-discovery: Limit the amount of sentries per authority (#4302) When receiving more addresses for a given authority than a defined threshold (5), the authority discovery drops the remaining in order to prevent a single authority to fill all priority group slots. --- Cargo.lock | 1 + client/authority-discovery/Cargo.toml | 1 + client/authority-discovery/src/lib.rs | 21 ++++++++++++++++++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 2b7e5dffbd..4a32074c59 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4814,6 +4814,7 @@ version = "2.0.0" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures-timer 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/client/authority-discovery/Cargo.toml b/client/authority-discovery/Cargo.toml index 0b1dad3744..1f88f6619f 100644 --- a/client/authority-discovery/Cargo.toml +++ b/client/authority-discovery/Cargo.toml @@ -27,6 +27,7 @@ serde_json = "1.0.41" sp-runtime = { path = "../../primitives/sr-primitives" } [dev-dependencies] +env_logger = "0.7.0" parking_lot = "0.9.0" peerset = { package = "sc-peerset", path = "../peerset" } test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client" } diff --git a/client/authority-discovery/src/lib.rs b/client/authority-discovery/src/lib.rs index 7752b8dc9b..8f16dddcd5 100644 --- a/client/authority-discovery/src/lib.rs +++ b/client/authority-discovery/src/lib.rs @@ -86,6 +86,12 @@ const LIBP2P_KADEMLIA_BOOTSTRAP_TIME: Duration = Duration::from_secs(30); /// discovery module. const AUTHORITIES_PRIORITY_GROUP_NAME: &'static str = "authorities"; +/// The maximum number of sentry node public addresses that we accept per authority. +/// +/// Everything above this threshold should be dropped to prevent a single authority from filling up +/// our peer set priority group. +const MAX_NUM_SENTRY_ADDRESSES_PER_AUTHORITY: usize = 5; + /// An `AuthorityDiscovery` makes a given authority discoverable and discovers other authorities. pub struct AuthorityDiscovery where @@ -316,7 +322,7 @@ where return Err(Error::VerifyingDhtPayload); } - let addresses: Vec = schema::AuthorityAddresses::decode(addresses) + let mut addresses: Vec = schema::AuthorityAddresses::decode(addresses) .map(|a| a.addresses) .map_err(Error::DecodingProto)? .into_iter() @@ -324,6 +330,18 @@ where .collect::>() .map_err(Error::ParsingMultiaddress)?; + if addresses.len() > MAX_NUM_SENTRY_ADDRESSES_PER_AUTHORITY { + warn!( + target: "sub-authority-discovery", + "Got more than MAX_NUM_SENTRY_ADDRESSES_PER_AUTHORITY ({:?}) for Authority + '{:?}' from DHT, dropping the remainder.", + MAX_NUM_SENTRY_ADDRESSES_PER_AUTHORITY, authority_id, + ); + addresses = addresses.into_iter() + .take(MAX_NUM_SENTRY_ADDRESSES_PER_AUTHORITY) + .collect(); + } + self.address_cache.insert(authority_id.clone(), addresses); } @@ -800,6 +818,7 @@ mod tests { #[test] fn handle_dht_events_with_value_found_should_call_set_priority_group() { + let _ = ::env_logger::try_init(); // Create authority discovery. let (mut dht_event_tx, dht_event_rx) = channel(1000); -- GitLab From 403504e3783cc32aff16f1edde9145f4dc0c4e83 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Thu, 5 Dec 2019 16:05:54 +0100 Subject: [PATCH 087/172] Change order of events emitted from transfer. (#4301) --- frame/balances/src/lib.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/frame/balances/src/lib.rs b/frame/balances/src/lib.rs index d32d8551d9..6a3e701ac0 100644 --- a/frame/balances/src/lib.rs +++ b/frame/balances/src/lib.rs @@ -934,9 +934,14 @@ where if !>::exists(dest) { Self::new_account(dest, new_to_balance); } + + // Emit transfer event. + Self::deposit_event(RawEvent::Transfer(transactor.clone(), dest.clone(), value, fee)); + + // Take action on the set_free_balance call. + // This will emit events that _resulted_ from the transfer. Self::set_free_balance(dest, new_to_balance); T::TransferPayment::on_unbalanced(NegativeImbalance::new(fee)); - Self::deposit_event(RawEvent::Transfer(transactor.clone(), dest.clone(), value, fee)); } Ok(()) -- GitLab From e1c674cdd99174cd4a08215612c413e66d679de7 Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Thu, 5 Dec 2019 16:57:25 +0100 Subject: [PATCH 088/172] Allow members of groups to change their key (#4300) --- frame/membership/src/lib.rs | 40 ++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/frame/membership/src/lib.rs b/frame/membership/src/lib.rs index d18c107d66..acecd456ee 100644 --- a/frame/membership/src/lib.rs +++ b/frame/membership/src/lib.rs @@ -28,7 +28,7 @@ use support::{ traits::{ChangeMembers, InitializeMembers}, weights::SimpleDispatchInfo, }; -use system::ensure_root; +use system::{ensure_root, ensure_signed}; use sp_runtime::traits::EnsureOrigin; pub trait Trait: system::Trait { @@ -86,6 +86,8 @@ decl_event!( MembersSwapped, /// The membership was reset; see the transaction for who the new set is. MembersReset, + /// One of the members' keys changed. + KeyChanged, /// Phantom member, never used. Dummy(rstd::marker::PhantomData<(AccountId, Event)>), } @@ -186,6 +188,31 @@ decl_module! { Self::deposit_event(RawEvent::MembersReset); } + + /// Swap out the sending member for some other key `new`. + /// + /// May only be called from `Signed` origin of a current member. + #[weight = SimpleDispatchInfo::FixedNormal(50_000)] + fn change_key(origin, new: T::AccountId) { + let remove = ensure_signed(origin)?; + + if remove != new { + let mut members = >::get(); + let location = members.binary_search(&remove).ok().ok_or("not a member")?; + members[location] = new.clone(); + let _location = members.binary_search(&new).err().ok_or("already a member")?; + members.sort(); + >::put(&members); + + T::MembershipChanged::change_members_sorted( + &[new], + &[remove], + &members[..], + ); + } + + Self::deposit_event(RawEvent::KeyChanged); + } } } @@ -333,6 +360,17 @@ mod tests { }); } + #[test] + fn change_key_works() { + new_test_ext().execute_with(|| { + assert_noop!(Membership::change_key(Origin::signed(3), 25), "not a member"); + assert_noop!(Membership::change_key(Origin::signed(10), 20), "already a member"); + assert_ok!(Membership::change_key(Origin::signed(10), 40)); + assert_eq!(Membership::members(), vec![20, 30, 40]); + assert_eq!(MEMBERS.with(|m| m.borrow().clone()), Membership::members()); + }); + } + #[test] fn reset_members_works() { new_test_ext().execute_with(|| { -- GitLab From f8e9f847ec10f81e74e2373a30a604819633122c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Thu, 5 Dec 2019 21:04:19 +0100 Subject: [PATCH 089/172] Fix Contracts rpc output format. (#4304) --- Cargo.lock | 2 +- frame/contracts/rpc/Cargo.toml | 3 ++ frame/contracts/rpc/runtime-api/Cargo.toml | 2 - frame/contracts/rpc/runtime-api/src/lib.rs | 1 - frame/contracts/rpc/src/lib.rs | 52 ++++++++++++++++++++-- 5 files changed, 53 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4a32074c59..df85a5e703 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3553,6 +3553,7 @@ dependencies = [ "pallet-contracts-rpc-runtime-api 2.0.0", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", "sp-blockchain 2.0.0", "sp-core 2.0.0", "sp-rpc 2.0.0", @@ -3564,7 +3565,6 @@ name = "pallet-contracts-rpc-runtime-api" version = "2.0.0" dependencies = [ "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-api 2.0.0", "sp-runtime 2.0.0", "sp-std 2.0.0", diff --git a/frame/contracts/rpc/Cargo.toml b/frame/contracts/rpc/Cargo.toml index 64b2318d08..fa030cb9ff 100644 --- a/frame/contracts/rpc/Cargo.toml +++ b/frame/contracts/rpc/Cargo.toml @@ -15,3 +15,6 @@ rpc-primitives = { package = "sp-rpc", path = "../../../primitives/rpc" } serde = { version = "1.0.101", features = ["derive"] } sp-runtime = { path = "../../../primitives/sr-primitives" } pallet-contracts-rpc-runtime-api = { path = "./runtime-api" } + +[dev-dependencies] +serde_json = "1.0.41" diff --git a/frame/contracts/rpc/runtime-api/Cargo.toml b/frame/contracts/rpc/runtime-api/Cargo.toml index ae71345488..dc044e1aeb 100644 --- a/frame/contracts/rpc/runtime-api/Cargo.toml +++ b/frame/contracts/rpc/runtime-api/Cargo.toml @@ -8,7 +8,6 @@ edition = "2018" sp-api = { path = "../../../../primitives/sr-api", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } rstd = { package = "sp-std", path = "../../../../primitives/sr-std", default-features = false } -serde = { version = "1.0.101", optional = true, features = ["derive"] } sp-runtime = { path = "../../../../primitives/sr-primitives", default-features = false } [features] @@ -17,6 +16,5 @@ std = [ "sp-api/std", "codec/std", "rstd/std", - "serde", "sp-runtime/std", ] diff --git a/frame/contracts/rpc/runtime-api/src/lib.rs b/frame/contracts/rpc/runtime-api/src/lib.rs index 2d3385d6d7..a4ee568c98 100644 --- a/frame/contracts/rpc/runtime-api/src/lib.rs +++ b/frame/contracts/rpc/runtime-api/src/lib.rs @@ -28,7 +28,6 @@ use sp_runtime::RuntimeDebug; /// A result of execution of a contract. #[derive(Eq, PartialEq, Encode, Decode, RuntimeDebug)] -#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub enum ContractExecResult { /// The contract returned successfully. /// diff --git a/frame/contracts/rpc/src/lib.rs b/frame/contracts/rpc/src/lib.rs index 3deee80cc3..ab0f89bd56 100644 --- a/frame/contracts/rpc/src/lib.rs +++ b/frame/contracts/rpc/src/lib.rs @@ -80,6 +80,35 @@ pub struct CallRequest { input_data: Bytes, } +/// An RPC serializable result of contract execution +#[derive(Serialize, Deserialize)] +#[serde(deny_unknown_fields)] +#[serde(rename_all = "camelCase")] +pub enum RpcContractExecResult { + /// Successful execution + Success { + /// Status code + status: u8, + /// Output data + data: Bytes, + }, + /// Error execution + Error(()), +} + +impl From for RpcContractExecResult { + fn from(r: ContractExecResult) -> Self { + match r { + ContractExecResult::Success { status, data } => { + RpcContractExecResult::Success { status, data: data.into() } + }, + ContractExecResult::Error => { + RpcContractExecResult::Error(()) + }, + } + } +} + /// Contracts RPC methods. #[rpc] pub trait ContractsApi { @@ -94,7 +123,7 @@ pub trait ContractsApi { &self, call_request: CallRequest, at: Option, - ) -> Result; + ) -> Result; /// Returns the value under a specified storage `key` in a contract given by `address` param, /// or `None` if it is not set. @@ -138,7 +167,7 @@ where &self, call_request: CallRequest, at: Option<::Hash>, - ) -> Result { + ) -> Result { let api = self.client.runtime_api(); let at = BlockId::hash(at.unwrap_or_else(|| // If the block hash is not supplied assume the best block. @@ -178,7 +207,7 @@ where data: Some(format!("{:?}", e).into()), })?; - Ok(exec_result) + Ok(exec_result.into()) } fn get_storage( @@ -207,3 +236,20 @@ where Ok(get_storage_result) } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn should_serialize_deserialize_properly() { + fn test(expected: &str) { + let res: RpcContractExecResult = serde_json::from_str(expected).unwrap(); + let actual = serde_json::to_string(&res).unwrap(); + assert_eq!(actual, expected); + } + + test(r#"{"success":{"status":5,"data":"0x1234"}}"#); + test(r#"{"error":null}"#); + } +} -- GitLab From 665304397ff7e60d7cda177a0623a571e5909a2c Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Thu, 5 Dec 2019 21:35:12 +0100 Subject: [PATCH 090/172] Fix order of operation in membership (#4306) --- frame/membership/src/lib.rs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/frame/membership/src/lib.rs b/frame/membership/src/lib.rs index acecd456ee..10be4e06f7 100644 --- a/frame/membership/src/lib.rs +++ b/frame/membership/src/lib.rs @@ -154,8 +154,8 @@ decl_module! { let mut members = >::get(); let location = members.binary_search(&remove).ok().ok_or("not a member")?; + let _ = members.binary_search(&add).err().ok_or("already a member")?; members[location] = add.clone(); - let _location = members.binary_search(&add).err().ok_or("already a member")?; members.sort(); >::put(&members); @@ -199,8 +199,8 @@ decl_module! { if remove != new { let mut members = >::get(); let location = members.binary_search(&remove).ok().ok_or("not a member")?; + let _ = members.binary_search(&new).err().ok_or("already a member")?; members[location] = new.clone(); - let _location = members.binary_search(&new).err().ok_or("already a member")?; members.sort(); >::put(&members); @@ -360,6 +360,15 @@ mod tests { }); } + #[test] + fn swap_member_works_that_does_not_change_order() { + new_test_ext().execute_with(|| { + assert_ok!(Membership::swap_member(Origin::signed(3), 10, 5)); + assert_eq!(Membership::members(), vec![5, 20, 30]); + assert_eq!(MEMBERS.with(|m| m.borrow().clone()), Membership::members()); + }); + } + #[test] fn change_key_works() { new_test_ext().execute_with(|| { @@ -371,6 +380,15 @@ mod tests { }); } + #[test] + fn change_key_works_that_does_not_change_order() { + new_test_ext().execute_with(|| { + assert_ok!(Membership::change_key(Origin::signed(10), 5)); + assert_eq!(Membership::members(), vec![5, 20, 30]); + assert_eq!(MEMBERS.with(|m| m.borrow().clone()), Membership::members()); + }); + } + #[test] fn reset_members_works() { new_test_ext().execute_with(|| { -- GitLab From 3ee5d3b1721f22af1d29a9ee81dbcea0764a0654 Mon Sep 17 00:00:00 2001 From: Shaopeng Wang Date: Fri, 6 Dec 2019 21:52:42 +1300 Subject: [PATCH 091/172] Perthings: derive PartialOrd and Ord under no_std. (#4309) --- primitives/sr-arithmetic/src/per_things.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/primitives/sr-arithmetic/src/per_things.rs b/primitives/sr-arithmetic/src/per_things.rs index ed63039c85..4ab7f2f25a 100644 --- a/primitives/sr-arithmetic/src/per_things.rs +++ b/primitives/sr-arithmetic/src/per_things.rs @@ -27,8 +27,8 @@ macro_rules! implement_per_thing { /// A fixed point representation of a number between in the range [0, 1]. /// #[doc = $title] - #[cfg_attr(feature = "std", derive(Serialize, Deserialize, Ord, PartialOrd))] - #[derive(Encode, Decode, Default, Copy, Clone, PartialEq, Eq, RuntimeDebug, CompactAs)] + #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] + #[derive(Encode, Decode, Default, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, RuntimeDebug, CompactAs)] pub struct $name($type); impl $name { -- GitLab From 5f0b3dde3f0a097f380c62d0257cf3838a7d8281 Mon Sep 17 00:00:00 2001 From: Max Inden Date: Fri, 6 Dec 2019 13:42:28 +0100 Subject: [PATCH 092/172] client/authority-discovery: Warn when specifying too many sentry nodes (#4314) --- client/authority-discovery/src/lib.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/client/authority-discovery/src/lib.rs b/client/authority-discovery/src/lib.rs index 8f16dddcd5..80bf971f1d 100644 --- a/client/authority-discovery/src/lib.rs +++ b/client/authority-discovery/src/lib.rs @@ -169,7 +169,7 @@ where ); let sentry_nodes = if !sentry_nodes.is_empty() { - Some(sentry_nodes.into_iter().filter_map(|a| match a.parse() { + let addrs = sentry_nodes.into_iter().filter_map(|a| match a.parse() { Ok(addr) => Some(addr), Err(e) => { error!( @@ -178,11 +178,23 @@ where ); None } - }).collect()) + }).collect::>(); + + if addrs.len() > MAX_NUM_SENTRY_ADDRESSES_PER_AUTHORITY { + warn!( + target: "sub-authority-discovery", + "More than MAX_NUM_SENTRY_ADDRESSES_PER_AUTHORITY ({:?}) were specified. Other \ + nodes will likely ignore the remainder.", + MAX_NUM_SENTRY_ADDRESSES_PER_AUTHORITY, + ); + } + + Some(addrs) } else { None }; + let address_cache = HashMap::new(); AuthorityDiscovery { @@ -333,7 +345,7 @@ where if addresses.len() > MAX_NUM_SENTRY_ADDRESSES_PER_AUTHORITY { warn!( target: "sub-authority-discovery", - "Got more than MAX_NUM_SENTRY_ADDRESSES_PER_AUTHORITY ({:?}) for Authority + "Got more than MAX_NUM_SENTRY_ADDRESSES_PER_AUTHORITY ({:?}) for Authority \ '{:?}' from DHT, dropping the remainder.", MAX_NUM_SENTRY_ADDRESSES_PER_AUTHORITY, authority_id, ); @@ -793,6 +805,7 @@ mod tests { #[test] fn request_addresses_of_others_triggers_dht_get_query() { + let _ = ::env_logger::try_init(); let (_dht_event_tx, dht_event_rx) = channel(1000); // Generate authority keys -- GitLab From a4404bc1410ff599dd66b78de1244532b2854f97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Fri, 6 Dec 2019 17:24:17 +0100 Subject: [PATCH 093/172] Merge txpool-runtime-api with txpool-api (#4320) * Remove transaction-pool-runtime-api * Merge runtime-api with transaction-pool. --- Cargo.lock | 16 +- Cargo.toml | 1 - bin/node-template/runtime/Cargo.toml | 4 +- bin/node-template/runtime/src/lib.rs | 2 +- bin/node/runtime/Cargo.toml | 4 +- bin/node/runtime/src/lib.rs | 2 +- client/rpc/src/author/mod.rs | 2 +- client/service/Cargo.toml | 3 +- client/service/src/builder.rs | 4 +- client/service/src/lib.rs | 8 +- client/transaction-pool/Cargo.toml | 1 - client/transaction-pool/src/api.rs | 2 +- client/transaction-pool/src/error.rs | 8 +- client/transaction-pool/src/maintainer.rs | 2 +- primitives/transaction-pool/Cargo.toml | 27 +- .../transaction-pool/runtime-api/Cargo.toml | 14 - primitives/transaction-pool/src/error.rs | 6 +- primitives/transaction-pool/src/lib.rs | 313 +---------------- primitives/transaction-pool/src/pool.rs | 322 ++++++++++++++++++ .../src/lib.rs => src/runtime_api.rs} | 9 +- test/utils/runtime/Cargo.toml | 4 +- test/utils/runtime/src/lib.rs | 4 +- 22 files changed, 386 insertions(+), 372 deletions(-) delete mode 100644 primitives/transaction-pool/runtime-api/Cargo.toml create mode 100644 primitives/transaction-pool/src/pool.rs rename primitives/transaction-pool/{runtime-api/src/lib.rs => src/runtime_api.rs} (80%) diff --git a/Cargo.lock b/Cargo.lock index df85a5e703..07e0eb308e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3146,7 +3146,7 @@ dependencies = [ "sp-session 2.0.0", "sp-staking 2.0.0", "sp-std 2.0.0", - "sp-transaction-pool-runtime-api 2.0.0", + "sp-transaction-pool-api 2.0.0", "sp-version 2.0.0", "substrate-wasm-builder-runner 1.0.4", ] @@ -3213,7 +3213,7 @@ dependencies = [ "sp-runtime 2.0.0", "sp-session 2.0.0", "sp-std 2.0.0", - "sp-transaction-pool-runtime-api 2.0.0", + "sp-transaction-pool-api 2.0.0", "sp-version 2.0.0", "substrate-wasm-builder-runner 1.0.4", ] @@ -5484,7 +5484,6 @@ dependencies = [ "sp-runtime 2.0.0", "sp-session 2.0.0", "sp-transaction-pool-api 2.0.0", - "sp-transaction-pool-runtime-api 2.0.0", "substrate-test-runtime-client 2.0.0", "sysinfo 0.9.6 (registry+https://github.com/rust-lang/crates.io-index)", "target_info 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5597,7 +5596,6 @@ dependencies = [ "sp-keyring 2.0.0", "sp-runtime 2.0.0", "sp-transaction-pool-api 2.0.0", - "sp-transaction-pool-runtime-api 2.0.0", "substrate-test-runtime-client 2.0.0", ] @@ -6374,14 +6372,6 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-core 2.0.0", - "sp-runtime 2.0.0", -] - -[[package]] -name = "sp-transaction-pool-runtime-api" -version = "2.0.0" -dependencies = [ "sp-api 2.0.0", "sp-core 2.0.0", "sp-runtime 2.0.0", @@ -6643,7 +6633,7 @@ dependencies = [ "sp-session 2.0.0", "sp-state-machine 2.0.0", "sp-std 2.0.0", - "sp-transaction-pool-runtime-api 2.0.0", + "sp-transaction-pool-api 2.0.0", "sp-trie 2.0.0", "sp-version 2.0.0", "substrate-test-runtime-client 2.0.0", diff --git a/Cargo.toml b/Cargo.toml index 9b7ad19f83..c3b57affe0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -127,7 +127,6 @@ members = [ "primitives/state-machine", "primitives/timestamp", "primitives/transaction-pool", - "primitives/transaction-pool/runtime-api", "primitives/trie", "primitives/wasm-interface", "test/utils/chain-spec-builder", diff --git a/bin/node-template/runtime/Cargo.toml b/bin/node-template/runtime/Cargo.toml index 51f648185e..fe8a2ea564 100644 --- a/bin/node-template/runtime/Cargo.toml +++ b/bin/node-template/runtime/Cargo.toml @@ -29,7 +29,7 @@ support = { package = "frame-support", path = "../../../frame/support", default- system = { package = "frame-system", path = "../../../frame/system", default-features = false } timestamp = { package = "pallet-timestamp", path = "../../../frame/timestamp", default-features = false } transaction-payment = { package = "pallet-transaction-payment", path = "../../../frame/transaction-payment", default-features = false } -txpool-runtime-api = { package = "sp-transaction-pool-runtime-api", path = "../../../primitives/transaction-pool/runtime-api", default-features = false } +sp-transaction-pool = { package = "sp-transaction-pool-api", path = "../../../primitives/transaction-pool", default-features = false } version = { package = "sp-version", path = "../../../primitives/sr-version", default-features = false } [build-dependencies] @@ -62,6 +62,6 @@ std = [ "system/std", "timestamp/std", "transaction-payment/std", - "txpool-runtime-api/std", + "sp-transaction-pool/std", "version/std", ] diff --git a/bin/node-template/runtime/src/lib.rs b/bin/node-template/runtime/src/lib.rs index 3d1cf2d519..dbb30d3107 100644 --- a/bin/node-template/runtime/src/lib.rs +++ b/bin/node-template/runtime/src/lib.rs @@ -328,7 +328,7 @@ impl_runtime_apis! { } } - impl txpool_runtime_api::TaggedTransactionQueue for Runtime { + impl sp_transaction_pool::runtime_api::TaggedTransactionQueue for Runtime { fn validate_transaction(tx: ::Extrinsic) -> TransactionValidity { Executive::validate_transaction(tx) } diff --git a/bin/node/runtime/Cargo.toml b/bin/node/runtime/Cargo.toml index 7744fb4737..8c9990b857 100644 --- a/bin/node/runtime/Cargo.toml +++ b/bin/node/runtime/Cargo.toml @@ -27,7 +27,7 @@ sp-runtime = { path = "../../../primitives/sr-primitives", default-features = fa sp-staking = { path = "../../../primitives/sr-staking-primitives", default-features = false } sp-keyring = { path = "../../../primitives/keyring", optional = true } sp-session = { path = "../../../primitives/session", default-features = false } -txpool-runtime-api = { package = "sp-transaction-pool-runtime-api", path = "../../../primitives/transaction-pool/runtime-api", default-features = false } +sp-transaction-pool = { package = "sp-transaction-pool-api", path = "../../../primitives/transaction-pool", default-features = false } version = { package = "sp-version", path = "../../../primitives/sr-version", default-features = false } # frame dependencies @@ -116,7 +116,7 @@ std = [ "transaction-payment-rpc-runtime-api/std", "transaction-payment/std", "treasury/std", - "txpool-runtime-api/std", + "sp-transaction-pool/std", "utility/std", "version/std", ] diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 4ba355e8f3..614e31e721 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -613,7 +613,7 @@ impl_runtime_apis! { } } - impl txpool_runtime_api::TaggedTransactionQueue for Runtime { + impl sp_transaction_pool::runtime_api::TaggedTransactionQueue for Runtime { fn validate_transaction(tx: ::Extrinsic) -> TransactionValidity { Executive::validate_transaction(tx) } diff --git a/client/rpc/src/author/mod.rs b/client/rpc/src/author/mod.rs index 2c101e3a80..c710016003 100644 --- a/client/rpc/src/author/mod.rs +++ b/client/rpc/src/author/mod.rs @@ -39,7 +39,7 @@ use sp_api::ConstructRuntimeApi; use sp_runtime::{generic, traits::{self, ProvideRuntimeApi}}; use txpool_api::{ TransactionPool, InPoolTransaction, TransactionStatus, - BlockHash, TxHash, TransactionFor, IntoPoolError, + BlockHash, TxHash, TransactionFor, error::IntoPoolError, }; use session::SessionKeys; diff --git a/client/service/Cargo.toml b/client/service/Cargo.toml index bbdc15f094..d60d8c8abc 100644 --- a/client/service/Cargo.toml +++ b/client/service/Cargo.toml @@ -41,12 +41,11 @@ chain-spec = { package = "sc-chain-spec", path = "../chain-spec" } client-api = { package = "sc-client-api", path = "../api" } client = { package = "sc-client", path = "../" } sp-api = { path = "../../primitives/sr-api" } -txpool-runtime-api = { package = "sp-transaction-pool-runtime-api", path = "../../primitives/transaction-pool/runtime-api" } client_db = { package = "sc-client-db", path = "../db" } codec = { package = "parity-scale-codec", version = "1.0.0" } sc-executor = { path = "../executor" } txpool = { package = "sc-transaction-pool", path = "../transaction-pool" } -txpool-api = { package = "sp-transaction-pool-api", path = "../../primitives/transaction-pool" } +sp-transaction-pool = { package = "sp-transaction-pool-api", path = "../../primitives/transaction-pool" } rpc-servers = { package = "sc-rpc-server", path = "../rpc-servers" } rpc = { package = "sc-rpc", path = "../rpc" } tel = { package = "sc-telemetry", path = "../telemetry" } diff --git a/client/service/src/builder.rs b/client/service/src/builder.rs index 157af7d296..526983974a 100644 --- a/client/service/src/builder.rs +++ b/client/service/src/builder.rs @@ -52,7 +52,7 @@ use std::{ }; use sysinfo::{get_current_pid, ProcessExt, System, SystemExt}; use tel::{telemetry, SUBSTRATE_INFO}; -use txpool_api::{TransactionPool, TransactionPoolMaintainer}; +use sp_transaction_pool::{TransactionPool, TransactionPoolMaintainer}; use sp_blockchain; use grafana_data_source::{self, record_metrics}; @@ -714,7 +714,7 @@ ServiceBuilder< as ProvideRuntimeApi>::Api: sp_api::Metadata + offchain::OffchainWorkerApi + - txpool_runtime_api::TaggedTransactionQueue + + sp_transaction_pool::runtime_api::TaggedTransactionQueue + session::SessionKeys + sp_api::ApiExt, TBl: BlockT::Out>, diff --git a/client/service/src/lib.rs b/client/service/src/lib.rs index 2ce2f307fc..3ec785ff4a 100644 --- a/client/service/src/lib.rs +++ b/client/service/src/lib.rs @@ -56,7 +56,7 @@ pub use self::error::Error; pub use self::builder::{ServiceBuilder, ServiceBuilderCommand}; pub use config::{Configuration, Roles, PruningMode}; pub use chain_spec::{ChainSpec, Properties, RuntimeGenesis, Extension as ChainSpecExtension}; -pub use txpool_api::{TransactionPool, TransactionPoolMaintainer, InPoolTransaction, IntoPoolError}; +pub use sp_transaction_pool::{TransactionPool, TransactionPoolMaintainer, InPoolTransaction, error::IntoPoolError}; pub use txpool::txpool::Options as TransactionPoolOptions; pub use client::FinalityNotifications; pub use rpc::Metadata as RpcMetadata; @@ -599,7 +599,7 @@ where Pool: TransactionPool, B: BlockT, H: std::hash::Hash + Eq + sp_runtime::traits::Member + sp_runtime::traits::MaybeSerialize, - E: IntoPoolError + From, + E: IntoPoolError + From, { pool.ready() .filter(|t| t.is_propagateable()) @@ -618,7 +618,7 @@ where Pool: 'static + TransactionPool, B: BlockT, H: std::hash::Hash + Eq + sp_runtime::traits::Member + sp_runtime::traits::MaybeSerialize, - E: 'static + IntoPoolError + From, + E: 'static + IntoPoolError + From, { fn transactions(&self) -> Vec<(H, ::Extrinsic)> { transactions_to_propagate(&*self.pool) @@ -651,7 +651,7 @@ where match import_result { Ok(_) => report_handle.report_peer(who, reputation_change_good), Err(e) => match e.into_pool_error() { - Ok(txpool_api::error::Error::AlreadyImported(_)) => (), + Ok(sp_transaction_pool::error::Error::AlreadyImported(_)) => (), Ok(e) => { report_handle.report_peer(who, reputation_change_bad); debug!("Error adding transaction to the pool: {:?}", e) diff --git a/client/transaction-pool/Cargo.toml b/client/transaction-pool/Cargo.toml index d09b53860e..b30e879134 100644 --- a/client/transaction-pool/Cargo.toml +++ b/client/transaction-pool/Cargo.toml @@ -15,7 +15,6 @@ sp-api = { path = "../../primitives/sr-api" } sp-runtime = { path = "../../primitives/sr-primitives" } txpool = { package = "sc-transaction-graph", path = "./graph" } txpool-api = { package = "sp-transaction-pool-api", path = "../../primitives/transaction-pool" } -txpool-runtime-api = { package = "sp-transaction-pool-runtime-api", path = "../../primitives/transaction-pool/runtime-api" } client-api = { package = "sc-client-api", path = "../api" } sp-blockchain = { path = "../../primitives/blockchain" } diff --git a/client/transaction-pool/src/api.rs b/client/transaction-pool/src/api.rs index 434a317d67..8d2fdd9702 100644 --- a/client/transaction-pool/src/api.rs +++ b/client/transaction-pool/src/api.rs @@ -26,7 +26,7 @@ use client_api::{ }; use primitives::{H256, Blake2Hasher, Hasher}; use sp_runtime::{generic::BlockId, traits::{self, Block as BlockT}, transaction_validity::TransactionValidity}; -use txpool_runtime_api::TaggedTransactionQueue; +use txpool_api::runtime_api::TaggedTransactionQueue; use crate::error::{self, Error}; diff --git a/client/transaction-pool/src/error.rs b/client/transaction-pool/src/error.rs index d769944ad6..6ba1d8e825 100644 --- a/client/transaction-pool/src/error.rs +++ b/client/transaction-pool/src/error.rs @@ -16,6 +16,8 @@ //! Transaction pool error. +use txpool_api::error::Error as TxPoolError; + /// Transaction pool result. pub type Result = std::result::Result; @@ -23,7 +25,7 @@ pub type Result = std::result::Result; #[derive(Debug, derive_more::Display, derive_more::From)] pub enum Error { /// Pool error. - Pool(txpool_api::error::Error), + Pool(TxPoolError), /// Blockchain error. Blockchain(sp_blockchain::Error), /// Error while converting a `BlockId`. @@ -45,8 +47,8 @@ impl std::error::Error for Error { } } -impl txpool_api::IntoPoolError for Error { - fn into_pool_error(self) -> std::result::Result { +impl txpool_api::error::IntoPoolError for Error { + fn into_pool_error(self) -> std::result::Result { match self { Error::Pool(e) => Ok(e), e => Err(e), diff --git a/client/transaction-pool/src/maintainer.rs b/client/transaction-pool/src/maintainer.rs index 84b780f4f3..5867192dce 100644 --- a/client/transaction-pool/src/maintainer.rs +++ b/client/transaction-pool/src/maintainer.rs @@ -37,7 +37,7 @@ use sp_runtime::{ }; use sp_blockchain::HeaderBackend; use txpool_api::TransactionPoolMaintainer; -use txpool_runtime_api::TaggedTransactionQueue; +use txpool_api::runtime_api::TaggedTransactionQueue; use txpool::{self, ChainApi}; diff --git a/primitives/transaction-pool/Cargo.toml b/primitives/transaction-pool/Cargo.toml index ce723fd61e..32714463b6 100644 --- a/primitives/transaction-pool/Cargo.toml +++ b/primitives/transaction-pool/Cargo.toml @@ -5,10 +5,23 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -derive_more = "0.99.2" -futures = "0.3.1" -log = "0.4.8" -serde = { version = "1.0.101", features = ["derive"] } -codec = { package = "parity-scale-codec", version = "1.0.0" } -primitives = { package = "sp-core", path = "../core" } -sp-runtime = { path = "../sr-primitives" } +codec = { package = "parity-scale-codec", version = "1.0.0", optional = true } +derive_more = { version = "0.99.2", optional = true } +futures = { version = "0.3.1", optional = true } +log = { version = "0.4.8", optional = true } +primitives = { package = "sp-core", path = "../core", optional = true} +serde = { version = "1.0.101", features = ["derive"], optional = true} +sp-api = { path = "../sr-api", default-features = false } +sp-runtime = { path = "../sr-primitives", default-features = false } + +[features] +std = [ + "codec", + "derive_more", + "futures", + "log", + "primitives", + "serde", + "sp-api/std", + "sp-runtime/std", +] diff --git a/primitives/transaction-pool/runtime-api/Cargo.toml b/primitives/transaction-pool/runtime-api/Cargo.toml deleted file mode 100644 index 4da08fbc7c..0000000000 --- a/primitives/transaction-pool/runtime-api/Cargo.toml +++ /dev/null @@ -1,14 +0,0 @@ -[package] -name = "sp-transaction-pool-runtime-api" -version = "2.0.0" -authors = ["Parity Technologies "] -edition = "2018" - -[dependencies] -primitives = { package = "sp-core", path = "../../core", default-features = false } -sp-api = { path = "../../sr-api", default-features = false } -sp-runtime = { path = "../../sr-primitives", default-features = false } - -[features] -default = [ "std" ] -std = [ "sp-runtime/std", "primitives/std", "sp-api/std" ] diff --git a/primitives/transaction-pool/src/error.rs b/primitives/transaction-pool/src/error.rs index ce65eaf26c..bf1bcf354d 100644 --- a/primitives/transaction-pool/src/error.rs +++ b/primitives/transaction-pool/src/error.rs @@ -68,15 +68,15 @@ pub enum Error { impl std::error::Error for Error {} /// Transaction pool error conversion. -pub trait IntoPoolError: ::std::error::Error + Send + Sized { +pub trait IntoPoolError: std::error::Error + Send + Sized { /// Try to extract original `Error` /// /// This implementation is optional and used only to /// provide more descriptive error messages for end users /// of RPC API. - fn into_pool_error(self) -> ::std::result::Result { Err(self) } + fn into_pool_error(self) -> std::result::Result { Err(self) } } impl IntoPoolError for Error { - fn into_pool_error(self) -> ::std::result::Result { Ok(self) } + fn into_pool_error(self) -> std::result::Result { Ok(self) } } diff --git a/primitives/transaction-pool/src/lib.rs b/primitives/transaction-pool/src/lib.rs index 3f834d3253..29db338b62 100644 --- a/primitives/transaction-pool/src/lib.rs +++ b/primitives/transaction-pool/src/lib.rs @@ -14,315 +14,20 @@ // You should have received a copy of the GNU General Public License // along with Substrate. If not, see . -//! Transaction pool types. +//! Transaction pool primitives types & Runtime API. #![warn(missing_docs)] +#![cfg_attr(not(feature = "std"), no_std)] +pub mod runtime_api; +#[cfg(feature = "std")] pub mod error; +#[cfg(feature = "std")] +mod pool; + +#[cfg(feature = "std")] +pub use pool::*; -pub use error::IntoPoolError; pub use sp_runtime::transaction_validity::{ TransactionLongevity, TransactionPriority, TransactionTag, }; - -use std::{ - collections::HashMap, - hash::Hash, - sync::Arc, -}; -use futures::{ - Future, Stream, - channel::mpsc, -}; -use serde::{Deserialize, Serialize}; -use sp_runtime::{ - generic::BlockId, - traits::{Block as BlockT, Member}, -}; - -/// Transaction pool status. -#[derive(Debug)] -pub struct PoolStatus { - /// Number of transactions in the ready queue. - pub ready: usize, - /// Sum of bytes of ready transaction encodings. - pub ready_bytes: usize, - /// Number of transactions in the future queue. - pub future: usize, - /// Sum of bytes of ready transaction encodings. - pub future_bytes: usize, -} - -impl PoolStatus { - /// Returns true if the are no transactions in the pool. - pub fn is_empty(&self) -> bool { - self.ready == 0 && self.future == 0 - } -} - -/// Possible transaction status events. -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] -pub enum TransactionStatus { - /// Transaction is part of the future queue. - Future, - /// Transaction is part of the ready queue. - Ready, - /// Transaction has been finalized in block with given hash. - Finalized(BlockHash), - /// Some state change (perhaps another transaction was included) rendered this transaction invalid. - Usurped(Hash), - /// The transaction has been broadcast to the given peers. - Broadcast(Vec), - /// Transaction has been dropped from the pool because of the limit. - Dropped, - /// Transaction was detected as invalid. - Invalid, -} - -/// The stream of transaction events. -pub type TransactionStatusStream = dyn Stream> + Send + Unpin; - -/// The import notification event stream. -pub type ImportNotificationStream = mpsc::UnboundedReceiver<()>; - -/// Transaction hash type for a pool. -pub type TxHash

=

::Hash; -/// Block hash type for a pool. -pub type BlockHash

= <

::Block as BlockT>::Hash; -/// Transaction type for a pool. -pub type TransactionFor

= <

::Block as BlockT>::Extrinsic; -/// Type of transactions event stream for a pool. -pub type TransactionStatusStreamFor

= TransactionStatusStream, BlockHash

>; - -/// In-pool transaction interface. -/// -/// The pool is container of transactions that are implementing this trait. -/// See `sp_runtime::ValidTransaction` for details about every field. -pub trait InPoolTransaction { - /// Transaction type. - type Transaction; - /// Transaction hash type. - type Hash; - - /// Get the reference to the transaction data. - fn data(&self) -> &Self::Transaction; - /// Get hash of the transaction. - fn hash(&self) -> &Self::Hash; - /// Get priority of the transaction. - fn priority(&self) -> &TransactionPriority; - /// Get longevity of the transaction. - fn longevity(&self) ->&TransactionLongevity; - /// Get transaction dependencies. - fn requires(&self) -> &[TransactionTag]; - /// Get tags that transaction provides. - fn provides(&self) -> &[TransactionTag]; - /// Return a flag indicating if the transaction should be propagated to other peers. - fn is_propagateable(&self) -> bool; -} - -/// Transaction pool interface. -pub trait TransactionPool: Send + Sync { - /// Block type. - type Block: BlockT; - /// Transaction hash type. - type Hash: Hash + Eq + Member + Serialize; - /// In-pool transaction type. - type InPoolTransaction: InPoolTransaction< - Transaction = TransactionFor, - Hash = TxHash - >; - /// Error type. - type Error: From + IntoPoolError; - - /// Returns a future that imports a bunch of unverified transactions to the pool. - fn submit_at( - &self, - at: &BlockId, - xts: impl IntoIterator> + 'static, - ) -> Box, Self::Error>>, - Self::Error - >> + Send + Unpin>; - - /// Returns a future that imports one unverified transaction to the pool. - fn submit_one( - &self, - at: &BlockId, - xt: TransactionFor, - ) -> Box, - Self::Error - >> + Send + Unpin>; - - /// Returns a future that import a single transaction and starts to watch their progress in the pool. - fn submit_and_watch( - &self, - at: &BlockId, - xt: TransactionFor, - ) -> Box>, Self::Error>> + Send + Unpin>; - - /// Remove transactions identified by given hashes (and dependent transactions) from the pool. - fn remove_invalid(&self, hashes: &[TxHash]) -> Vec>; - - /// Returns pool status. - fn status(&self) -> PoolStatus; - - /// Get an iterator for ready transactions ordered by priority - fn ready(&self) -> Box>>; - - /// Return an event stream of transactions imported to the pool. - fn import_notification_stream(&self) -> ImportNotificationStream; - - /// Returns transaction hash - fn hash_of(&self, xt: &TransactionFor) -> TxHash; - - /// Notify the pool about transactions broadcast. - fn on_broadcasted(&self, propagations: HashMap, Vec>); -} - -/// An abstraction for transaction pool. -/// -/// This trait is used by offchain calls to be able to submit transactions. -/// The main use case is for offchain workers, to feed back the results of computations, -/// but since the transaction pool access is a separate `ExternalitiesExtension` it can -/// be also used in context of other offchain calls. For one may generate and submit -/// a transaction for some misbehavior reports (say equivocation). -pub trait OffchainSubmitTransaction: Send + Sync { - /// Submit transaction. - /// - /// The transaction will end up in the pool and be propagated to others. - fn submit_at( - &self, - at: &BlockId, - extrinsic: Block::Extrinsic, - ) -> Result<(), ()>; -} - -impl OffchainSubmitTransaction for TPool { - fn submit_at( - &self, - at: &BlockId, - extrinsic: ::Extrinsic, - ) -> Result<(), ()> { - log::debug!( - target: "txpool", - "(offchain call) Submitting a transaction to the pool: {:?}", - extrinsic - ); - - let result = futures::executor::block_on(self.submit_one(&at, extrinsic)); - - result.map(|_| ()) - .map_err(|e| log::warn!( - target: "txpool", - "(offchain call) Error submitting a transaction to the pool: {:?}", - e - )) - } -} - -/// Transaction pool maintainer interface. -pub trait TransactionPoolMaintainer: Send + Sync { - /// Block type. - type Block: BlockT; - /// Transaction Hash type. - type Hash: Hash + Eq + Member + Serialize; - - /// Returns a future that performs maintenance procedures on the pool when - /// with given hash is imported. - fn maintain( - &self, - id: &BlockId, - retracted: &[Self::Hash], - ) -> Box + Send + Unpin>; -} - -/// Maintainable pool implementation. -pub struct MaintainableTransactionPool { - pool: Pool, - maintainer: Maintainer, -} - -impl MaintainableTransactionPool { - /// Create new maintainable pool using underlying pool and maintainer. - pub fn new(pool: Pool, maintainer: Maintainer) -> Self { - MaintainableTransactionPool { pool, maintainer } - } -} - -impl TransactionPool for MaintainableTransactionPool - where - Pool: TransactionPool, - Maintainer: Send + Sync, -{ - type Block = Pool::Block; - type Hash = Pool::Hash; - type InPoolTransaction = Pool::InPoolTransaction; - type Error = Pool::Error; - - fn submit_at( - &self, - at: &BlockId, - xts: impl IntoIterator> + 'static, - ) -> Box, Self::Error>>, Self::Error>> + Send + Unpin> { - self.pool.submit_at(at, xts) - } - - fn submit_one( - &self, - at: &BlockId, - xt: TransactionFor, - ) -> Box, Self::Error>> + Send + Unpin> { - self.pool.submit_one(at, xt) - } - - fn submit_and_watch( - &self, - at: &BlockId, - xt: TransactionFor, - ) -> Box>, Self::Error>> + Send + Unpin> { - self.pool.submit_and_watch(at, xt) - } - - fn remove_invalid(&self, hashes: &[TxHash]) -> Vec> { - self.pool.remove_invalid(hashes) - } - - fn status(&self) -> PoolStatus { - self.pool.status() - } - - fn ready(&self) -> Box>> { - self.pool.ready() - } - - fn import_notification_stream(&self) -> ImportNotificationStream { - self.pool.import_notification_stream() - } - - fn hash_of(&self, xt: &TransactionFor) -> TxHash { - self.pool.hash_of(xt) - } - - fn on_broadcasted(&self, propagations: HashMap, Vec>) { - self.pool.on_broadcasted(propagations) - } -} - -impl TransactionPoolMaintainer for MaintainableTransactionPool - where - Pool: Send + Sync, - Maintainer: TransactionPoolMaintainer -{ - type Block = Maintainer::Block; - type Hash = Maintainer::Hash; - - fn maintain( - &self, - id: &BlockId, - retracted: &[Self::Hash], - ) -> Box + Send + Unpin> { - self.maintainer.maintain(id, retracted) - } -} diff --git a/primitives/transaction-pool/src/pool.rs b/primitives/transaction-pool/src/pool.rs new file mode 100644 index 0000000000..009b9c7863 --- /dev/null +++ b/primitives/transaction-pool/src/pool.rs @@ -0,0 +1,322 @@ +// Copyright 2019 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Substrate is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Substrate. If not, see . + +//! Transaction pool primitives types & Runtime API. + +use std::{ + collections::HashMap, + hash::Hash, + sync::Arc, +}; +use futures::{ + Future, Stream, + channel::mpsc, +}; +use serde::{Deserialize, Serialize}; +use sp_runtime::{ + generic::BlockId, + traits::{Block as BlockT, Member}, + transaction_validity::{ + TransactionLongevity, TransactionPriority, TransactionTag, + }, +}; + +/// Transaction pool status. +#[derive(Debug)] +pub struct PoolStatus { + /// Number of transactions in the ready queue. + pub ready: usize, + /// Sum of bytes of ready transaction encodings. + pub ready_bytes: usize, + /// Number of transactions in the future queue. + pub future: usize, + /// Sum of bytes of ready transaction encodings. + pub future_bytes: usize, +} + +impl PoolStatus { + /// Returns true if the are no transactions in the pool. + pub fn is_empty(&self) -> bool { + self.ready == 0 && self.future == 0 + } +} + +/// Possible transaction status events. +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub enum TransactionStatus { + /// Transaction is part of the future queue. + Future, + /// Transaction is part of the ready queue. + Ready, + /// Transaction has been finalized in block with given hash. + Finalized(BlockHash), + /// Some state change (perhaps another transaction was included) rendered this transaction invalid. + Usurped(Hash), + /// The transaction has been broadcast to the given peers. + Broadcast(Vec), + /// Transaction has been dropped from the pool because of the limit. + Dropped, + /// Transaction was detected as invalid. + Invalid, +} + +/// The stream of transaction events. +pub type TransactionStatusStream = dyn Stream> + Send + Unpin; + +/// The import notification event stream. +pub type ImportNotificationStream = mpsc::UnboundedReceiver<()>; + +/// Transaction hash type for a pool. +pub type TxHash

=

::Hash; +/// Block hash type for a pool. +pub type BlockHash

= <

::Block as BlockT>::Hash; +/// Transaction type for a pool. +pub type TransactionFor

= <

::Block as BlockT>::Extrinsic; +/// Type of transactions event stream for a pool. +pub type TransactionStatusStreamFor

= TransactionStatusStream, BlockHash

>; + +/// In-pool transaction interface. +/// +/// The pool is container of transactions that are implementing this trait. +/// See `sp_runtime::ValidTransaction` for details about every field. +pub trait InPoolTransaction { + /// Transaction type. + type Transaction; + /// Transaction hash type. + type Hash; + + /// Get the reference to the transaction data. + fn data(&self) -> &Self::Transaction; + /// Get hash of the transaction. + fn hash(&self) -> &Self::Hash; + /// Get priority of the transaction. + fn priority(&self) -> &TransactionPriority; + /// Get longevity of the transaction. + fn longevity(&self) ->&TransactionLongevity; + /// Get transaction dependencies. + fn requires(&self) -> &[TransactionTag]; + /// Get tags that transaction provides. + fn provides(&self) -> &[TransactionTag]; + /// Return a flag indicating if the transaction should be propagated to other peers. + fn is_propagateable(&self) -> bool; +} + +/// Transaction pool interface. +pub trait TransactionPool: Send + Sync { + /// Block type. + type Block: BlockT; + /// Transaction hash type. + type Hash: Hash + Eq + Member + Serialize; + /// In-pool transaction type. + type InPoolTransaction: InPoolTransaction< + Transaction = TransactionFor, + Hash = TxHash + >; + /// Error type. + type Error: From + crate::error::IntoPoolError; + + /// Returns a future that imports a bunch of unverified transactions to the pool. + fn submit_at( + &self, + at: &BlockId, + xts: impl IntoIterator> + 'static, + ) -> Box, Self::Error>>, + Self::Error + >> + Send + Unpin>; + + /// Returns a future that imports one unverified transaction to the pool. + fn submit_one( + &self, + at: &BlockId, + xt: TransactionFor, + ) -> Box, + Self::Error + >> + Send + Unpin>; + + /// Returns a future that import a single transaction and starts to watch their progress in the pool. + fn submit_and_watch( + &self, + at: &BlockId, + xt: TransactionFor, + ) -> Box>, Self::Error>> + Send + Unpin>; + + /// Remove transactions identified by given hashes (and dependent transactions) from the pool. + fn remove_invalid(&self, hashes: &[TxHash]) -> Vec>; + + /// Returns pool status. + fn status(&self) -> PoolStatus; + + /// Get an iterator for ready transactions ordered by priority + fn ready(&self) -> Box>>; + + /// Return an event stream of transactions imported to the pool. + fn import_notification_stream(&self) -> ImportNotificationStream; + + /// Returns transaction hash + fn hash_of(&self, xt: &TransactionFor) -> TxHash; + + /// Notify the pool about transactions broadcast. + fn on_broadcasted(&self, propagations: HashMap, Vec>); +} + +/// An abstraction for transaction pool. +/// +/// This trait is used by offchain calls to be able to submit transactions. +/// The main use case is for offchain workers, to feed back the results of computations, +/// but since the transaction pool access is a separate `ExternalitiesExtension` it can +/// be also used in context of other offchain calls. For one may generate and submit +/// a transaction for some misbehavior reports (say equivocation). +pub trait OffchainSubmitTransaction: Send + Sync { + /// Submit transaction. + /// + /// The transaction will end up in the pool and be propagated to others. + fn submit_at( + &self, + at: &BlockId, + extrinsic: Block::Extrinsic, + ) -> Result<(), ()>; +} + +impl OffchainSubmitTransaction for TPool { + fn submit_at( + &self, + at: &BlockId, + extrinsic: ::Extrinsic, + ) -> Result<(), ()> { + log::debug!( + target: "txpool", + "(offchain call) Submitting a transaction to the pool: {:?}", + extrinsic + ); + + let result = futures::executor::block_on(self.submit_one(&at, extrinsic)); + + result.map(|_| ()) + .map_err(|e| log::warn!( + target: "txpool", + "(offchain call) Error submitting a transaction to the pool: {:?}", + e + )) + } +} + +/// Transaction pool maintainer interface. +pub trait TransactionPoolMaintainer: Send + Sync { + /// Block type. + type Block: BlockT; + /// Transaction Hash type. + type Hash: Hash + Eq + Member + Serialize; + + /// Returns a future that performs maintenance procedures on the pool when + /// with given hash is imported. + fn maintain( + &self, + id: &BlockId, + retracted: &[Self::Hash], + ) -> Box + Send + Unpin>; +} + +/// Maintainable pool implementation. +pub struct MaintainableTransactionPool { + pool: Pool, + maintainer: Maintainer, +} + +impl MaintainableTransactionPool { + /// Create new maintainable pool using underlying pool and maintainer. + pub fn new(pool: Pool, maintainer: Maintainer) -> Self { + MaintainableTransactionPool { pool, maintainer } + } +} + +impl TransactionPool for MaintainableTransactionPool + where + Pool: TransactionPool, + Maintainer: Send + Sync, +{ + type Block = Pool::Block; + type Hash = Pool::Hash; + type InPoolTransaction = Pool::InPoolTransaction; + type Error = Pool::Error; + + fn submit_at( + &self, + at: &BlockId, + xts: impl IntoIterator> + 'static, + ) -> Box, Self::Error>>, Self::Error>> + Send + Unpin> { + self.pool.submit_at(at, xts) + } + + fn submit_one( + &self, + at: &BlockId, + xt: TransactionFor, + ) -> Box, Self::Error>> + Send + Unpin> { + self.pool.submit_one(at, xt) + } + + fn submit_and_watch( + &self, + at: &BlockId, + xt: TransactionFor, + ) -> Box>, Self::Error>> + Send + Unpin> { + self.pool.submit_and_watch(at, xt) + } + + fn remove_invalid(&self, hashes: &[TxHash]) -> Vec> { + self.pool.remove_invalid(hashes) + } + + fn status(&self) -> PoolStatus { + self.pool.status() + } + + fn ready(&self) -> Box>> { + self.pool.ready() + } + + fn import_notification_stream(&self) -> ImportNotificationStream { + self.pool.import_notification_stream() + } + + fn hash_of(&self, xt: &TransactionFor) -> TxHash { + self.pool.hash_of(xt) + } + + fn on_broadcasted(&self, propagations: HashMap, Vec>) { + self.pool.on_broadcasted(propagations) + } +} + +impl TransactionPoolMaintainer for MaintainableTransactionPool + where + Pool: Send + Sync, + Maintainer: TransactionPoolMaintainer +{ + type Block = Maintainer::Block; + type Hash = Maintainer::Hash; + + fn maintain( + &self, + id: &BlockId, + retracted: &[Self::Hash], + ) -> Box + Send + Unpin> { + self.maintainer.maintain(id, retracted) + } +} diff --git a/primitives/transaction-pool/runtime-api/src/lib.rs b/primitives/transaction-pool/src/runtime_api.rs similarity index 80% rename from primitives/transaction-pool/runtime-api/src/lib.rs rename to primitives/transaction-pool/src/runtime_api.rs index 7017d90a80..4ca47805b9 100644 --- a/primitives/transaction-pool/runtime-api/src/lib.rs +++ b/primitives/transaction-pool/src/runtime_api.rs @@ -1,4 +1,4 @@ -// Copyright 2018-2019 Parity Technologies (UK) Ltd. +// Copyright 2019 Parity Technologies (UK) Ltd. // This file is part of Substrate. // Substrate is free software: you can redistribute it and/or modify @@ -14,11 +14,10 @@ // You should have received a copy of the GNU General Public License // along with Substrate. If not, see . -//! Substrate runtime api for the transaction queue. +//! Tagged Transaction Queue Runtime API. -#![cfg_attr(not(feature = "std"), no_std)] - -use sp_runtime::{transaction_validity::TransactionValidity, traits::Block as BlockT}; +use sp_runtime::transaction_validity::TransactionValidity; +use sp_runtime::traits::Block as BlockT; sp_api::decl_runtime_apis! { /// The `TaggedTransactionQueue` api trait for interfering with the transaction queue. diff --git a/test/utils/runtime/Cargo.toml b/test/utils/runtime/Cargo.toml index ed7d98f064..e1a34caff8 100644 --- a/test/utils/runtime/Cargo.toml +++ b/test/utils/runtime/Cargo.toml @@ -34,7 +34,7 @@ frame-system-rpc-runtime-api = { path = "../../../frame/system/rpc/runtime-api", pallet-timestamp = { path = "../../../frame/timestamp", default-features = false } sc-client = { path = "../../../client", optional = true } sp-trie = { path = "../../../primitives/trie", default-features = false } -txpool-runtime-api = { package = "sp-transaction-pool-runtime-api", path = "../../../primitives/transaction-pool/runtime-api", default-features = false } +sp-transaction-pool = { package = "sp-transaction-pool-api", path = "../../../primitives/transaction-pool", default-features = false } trie-db = { version = "0.16.0", default-features = false } [dev-dependencies] @@ -78,6 +78,6 @@ std = [ "pallet-timestamp/std", "sc-client", "sp-trie/std", - "txpool-runtime-api/std", + "sp-transaction-pool/std", "trie-db/std", ] diff --git a/test/utils/runtime/src/lib.rs b/test/utils/runtime/src/lib.rs index ec8998f597..374ff0322e 100644 --- a/test/utils/runtime/src/lib.rs +++ b/test/utils/runtime/src/lib.rs @@ -477,7 +477,7 @@ cfg_if! { } } - impl txpool_runtime_api::TaggedTransactionQueue for Runtime { + impl sp_transaction_pool::runtime_api::TaggedTransactionQueue for Runtime { fn validate_transaction(utx: ::Extrinsic) -> TransactionValidity { if let Extrinsic::IncludeData(data) = utx { return Ok(ValidTransaction { @@ -662,7 +662,7 @@ cfg_if! { } } - impl txpool_runtime_api::TaggedTransactionQueue for Runtime { + impl sp_transaction_pool::runtime_api::TaggedTransactionQueue for Runtime { fn validate_transaction(utx: ::Extrinsic) -> TransactionValidity { if let Extrinsic::IncludeData(data) = utx { return Ok(ValidTransaction{ -- GitLab From 52aed2f01fc1cab23a871b72eb4769cdd8b9874d Mon Sep 17 00:00:00 2001 From: Ashley Date: Sat, 7 Dec 2019 15:29:50 +0100 Subject: [PATCH 094/172] Disable record_metrics_slice in grafana macro on wasm (#4312) * Disable record_metrics_slice in grafana macro on wasm * Update client/grafana-data-source/src/lib.rs * Revert "Update client/grafana-data-source/src/lib.rs" This reverts commit 888009a8e0b7051bd4bfbbfdb0448bcf2e2aae93. --- client/grafana-data-source/src/lib.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/client/grafana-data-source/src/lib.rs b/client/grafana-data-source/src/lib.rs index a1841178e9..229400066a 100644 --- a/client/grafana-data-source/src/lib.rs +++ b/client/grafana-data-source/src/lib.rs @@ -47,9 +47,13 @@ lazy_static! { #[macro_export] macro_rules! record_metrics( ($($key:expr => $value:expr,)*) => { - $crate::record_metrics_slice(&[ - $( ($key, $value as f32), )* - ]); + if cfg!(not(target_os = "unknown")) { + $crate::record_metrics_slice(&[ + $( ($key, $value as f32), )* + ]) + } else { + Ok(()) + } } ); -- GitLab From 91efa7bb4fa018a705f66d220af7b319ef5a015a Mon Sep 17 00:00:00 2001 From: ddorgan Date: Sat, 7 Dec 2019 15:30:05 +0100 Subject: [PATCH 095/172] New protocolid for flaming fir (#4323) --- bin/node/cli/res/flaming-fir.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/node/cli/res/flaming-fir.json b/bin/node/cli/res/flaming-fir.json index 5cd11eb97f..1e7d4424b5 100644 --- a/bin/node/cli/res/flaming-fir.json +++ b/bin/node/cli/res/flaming-fir.json @@ -18,7 +18,7 @@ "telemetryEndpoints": [ ["wss://telemetry.polkadot.io/submit/", 0] ], - "protocolId": "fir", + "protocolId": "fir2", "consensusEngine": null, "genesis": { "raw": [ -- GitLab From 89bc9cf2b38fa02a363fe3868ceead2f8ec984ec Mon Sep 17 00:00:00 2001 From: thiolliere Date: Sat, 7 Dec 2019 15:30:57 +0100 Subject: [PATCH 096/172] allow storage value build to put no value (#4319) --- .../src/storage/genesis_config/builder_def.rs | 38 ++++++++++++--- frame/support/test/tests/decl_storage.rs | 47 +++++++++++++++++-- 2 files changed, 75 insertions(+), 10 deletions(-) diff --git a/frame/support/procedural/src/storage/genesis_config/builder_def.rs b/frame/support/procedural/src/storage/genesis_config/builder_def.rs index fbab681949..78c659d466 100644 --- a/frame/support/procedural/src/storage/genesis_config/builder_def.rs +++ b/frame/support/procedural/src/storage/genesis_config/builder_def.rs @@ -44,32 +44,55 @@ impl BuilderDef { let storage_trait = &line.storage_trait; let value_type = &line.value_type; - // Contains the data to inset at genesis either from build or config. + // Defines the data variable to use for insert at genesis either from build or config. let mut data = None; if let Some(builder) = &line.build { is_generic |= ext::expr_contains_ident(&builder, &def.module_runtime_generic); is_generic |= line.is_generic; - data = Some(quote_spanned!(builder.span() => &(#builder)(self))); + data = Some(match &line.storage_type { + StorageLineTypeDef::Simple(_) if line.is_option => + quote_spanned!(builder.span() => + let data = (#builder)(self); + let data = Option::as_ref(&data); + ), + _ => quote_spanned!(builder.span() => let data = &(#builder)(self); ), + }); } else if let Some(config) = &line.config { is_generic |= line.is_generic; - data = Some(quote!(&self.#config;)); + data = Some(match &line.storage_type { + StorageLineTypeDef::Simple(_) if line.is_option => + quote!( let data = Some(&self.#config); ), + _ => quote!( let data = &self.#config; ), + }); }; if let Some(data) = data { blocks.push(match &line.storage_type { - StorageLineTypeDef::Simple(_) => { + StorageLineTypeDef::Simple(_) if line.is_option => { + quote!{{ + #data + let v: Option<&#value_type>= data; + if let Some(v) = v { + <#storage_struct as #scrate::#storage_trait>::put::<&#value_type>(v); + } + }} + }, + StorageLineTypeDef::Simple(_) if !line.is_option => { quote!{{ - let v: &#value_type = #data; + #data + let v: &#value_type = data; <#storage_struct as #scrate::#storage_trait>::put::<&#value_type>(v); }} }, + StorageLineTypeDef::Simple(_) => unreachable!(), StorageLineTypeDef::Map(map) | StorageLineTypeDef::LinkedMap(map) => { let key = &map.key; quote!{{ - let data: &#scrate::rstd::vec::Vec<(#key, #value_type)> = #data; + #data + let data: &#scrate::rstd::vec::Vec<(#key, #value_type)> = data; data.iter().for_each(|(k, v)| { <#storage_struct as #scrate::#storage_trait>::insert::< &#key, &#value_type @@ -81,7 +104,8 @@ impl BuilderDef { let key1 = &map.key1; let key2 = &map.key2; quote!{{ - let data: &#scrate::rstd::vec::Vec<(#key1, #key2, #value_type)> = #data; + #data + let data: &#scrate::rstd::vec::Vec<(#key1, #key2, #value_type)> = data; data.iter().for_each(|(k1, k2, v)| { <#storage_struct as #scrate::#storage_trait>::insert::< &#key1, &#key2, &#value_type diff --git a/frame/support/test/tests/decl_storage.rs b/frame/support/test/tests/decl_storage.rs index cdd99275a6..231dbdbdac 100644 --- a/frame/support/test/tests/decl_storage.rs +++ b/frame/support/test/tests/decl_storage.rs @@ -19,6 +19,7 @@ #[allow(dead_code)] mod tests { use support::metadata::*; + use runtime_io::TestExternalities; use std::marker::PhantomData; use codec::{Encode, Decode, EncodeLike}; @@ -44,7 +45,7 @@ mod tests { // getters: pub / $default // we need at least one type which uses T, otherwise GenesisConfig will complain. GETU32 get(fn u32_getter): T::Origin; - pub PUBGETU32 get(fn pub_u32_getter) build(|config: &GenesisConfig| config.u32_getter_with_config): u32; + pub PUBGETU32 get(fn pub_u32_getter): u32; GETU32WITHCONFIG get(fn u32_getter_with_config) config(): u32; pub PUBGETU32WITHCONFIG get(fn pub_u32_getter_with_config) config(): u32; GETU32MYDEF get(fn u32_getter_mydef): Option; @@ -53,6 +54,10 @@ mod tests { pub PUBGETU32WITHCONFIGMYDEF get(fn pub_u32_getter_with_config_mydef) config(): u32 = 1; PUBGETU32WITHCONFIGMYDEFOPT get(fn pub_u32_getter_with_config_mydef_opt) config(): Option; + GetU32WithBuilder get(fn u32_with_builder) build(|_| 1): u32; + GetOptU32WithBuilderSome get(fn opt_u32_with_builder_some) build(|_| Some(1)): Option; + GetOptU32WithBuilderNone get(fn opt_u32_with_builder_none) build(|_| None): Option; + // map non-getters: pub / $default MAPU32 : map u32 => Option; pub PUBMAPU32 : map u32 => Option; @@ -209,7 +214,33 @@ mod tests { ), documentation: DecodeDifferent::Encode(&[]), }, - + StorageEntryMetadata { + name: DecodeDifferent::Encode("GetU32WithBuilder"), + modifier: StorageEntryModifier::Default, + ty: StorageEntryType::Plain(DecodeDifferent::Encode("u32")), + default: DecodeDifferent::Encode( + DefaultByteGetter(&__GetByteStructGetU32WithBuilder(PhantomData::)) + ), + documentation: DecodeDifferent::Encode(&[]), + }, + StorageEntryMetadata { + name: DecodeDifferent::Encode("GetOptU32WithBuilderSome"), + modifier: StorageEntryModifier::Optional, + ty: StorageEntryType::Plain(DecodeDifferent::Encode("u32")), + default: DecodeDifferent::Encode( + DefaultByteGetter(&__GetByteStructGetOptU32WithBuilderSome(PhantomData::)) + ), + documentation: DecodeDifferent::Encode(&[]), + }, + StorageEntryMetadata { + name: DecodeDifferent::Encode("GetOptU32WithBuilderNone"), + modifier: StorageEntryModifier::Optional, + ty: StorageEntryType::Plain(DecodeDifferent::Encode("u32")), + default: DecodeDifferent::Encode( + DefaultByteGetter(&__GetByteStructGetOptU32WithBuilderNone(PhantomData::)) + ), + documentation: DecodeDifferent::Encode(&[]), + }, StorageEntryMetadata { name: DecodeDifferent::Encode("MAPU32"), modifier: StorageEntryModifier::Optional, @@ -412,7 +443,7 @@ mod tests { #[test] fn store_metadata() { let metadata = Module::::storage_metadata(); - assert_eq!(EXPECTED_METADATA, metadata); + pretty_assertions::assert_eq!(EXPECTED_METADATA, metadata); } #[test] @@ -427,6 +458,16 @@ mod tests { assert_eq!(config.pub_u32_getter_with_config_mydef_opt, 0u32); } + #[test] + fn check_builder_config() { + let config = GenesisConfig::default(); + let storage = config.build_storage().unwrap(); + TestExternalities::from(storage).execute_with(|| { + assert_eq!(Module::::u32_with_builder(), 1); + assert_eq!(Module::::opt_u32_with_builder_some(), Some(1)); + assert_eq!(Module::::opt_u32_with_builder_none(), None); + }) + } } #[cfg(test)] -- GitLab From 4795b81b0fd2849cb062aebaf240bfa6e29b237d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Sat, 7 Dec 2019 23:36:47 +0100 Subject: [PATCH 097/172] Fix `check_polkadot` CI check (#4317) * Fix `check_polkadot` CI check * Another try * Use path overrides * Last fix * Update .gitlab-ci.yml * Fix wasm builder * Update wasm_project.rs --- .gitlab-ci.yml | 15 +++++---------- utils/wasm-builder/src/wasm_project.rs | 1 + 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ede9f2fd7d..dee459cea7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -357,20 +357,15 @@ check_polkadot: <<: *docker-env allow_failure: true script: - - COMMIT_HASH=$(git rev-parse HEAD) - SUBSTRATE_PATH=$(pwd) # Clone the current Polkadot master branch into ./polkadot. - git clone --depth 1 https://gitlab.parity.io/parity/polkadot.git - cd polkadot - # Within Polkadot 'master' alter each Cargo.toml that references the - # Substrate 'polkadot-master' branch: - # 1. Replace the 'branch = "polkadot-master"' statements with the rev of our - # commit. - # 2. Replace 'git = "https://.*"' with 'git = "file://.*"' (the local - # checked out Substrate repository one folder above). - # 3. Remove any trailing commas. - - git grep -l "polkadot-master" | grep toml | xargs sed -i "s/branch.*=.*\"polkadot-master\"/rev = \"$COMMIT_HASH\"/; s~https://github.com/paritytech/substrate~file://$SUBSTRATE_PATH~; s/,\s*}/ }/" - # Make sure 'Cargo.lock' matches 'Cargo.toml'. It's enough to update one + # Make sure we override the crates in native and wasm build + - mkdir .cargo + - echo "paths = [ \"$SUBSTRATE_PATH\" ]" > .cargo/config + - mkdir -p target/debug/wbuild/.cargo + - echo "paths = [ \"$SUBSTRATE_PATH\" ]" > target/debug/wbuild/.cargo/config # package, others are updated along the way. - cargo update -p sp-io # Check whether Polkadot 'master' branch builds with this Substrate commit. diff --git a/utils/wasm-builder/src/wasm_project.rs b/utils/wasm-builder/src/wasm_project.rs index 701a50fe1c..bb32d62218 100644 --- a/utils/wasm-builder/src/wasm_project.rs +++ b/utils/wasm-builder/src/wasm_project.rs @@ -181,6 +181,7 @@ fn create_wasm_workspace_project(wasm_workspace: &Path, cargo_manifest: &Path) { .map(|d| d.into_path()) .filter(|p| p.is_dir() && !p.ends_with("target")) .filter_map(|p| p.file_name().map(|f| f.to_owned()).and_then(|s| s.into_string().ok())) + .filter(|f| !f.starts_with(".")) .collect::>(); let crate_metadata = MetadataCommand::new() -- GitLab From 21e4f08a72ca0adeb42cd5eca5fb277ef3e172bf Mon Sep 17 00:00:00 2001 From: Weiliang Li Date: Mon, 9 Dec 2019 16:49:32 +0900 Subject: [PATCH 098/172] Rename folder: primitives/sr-primitives -> primitives/runtime (#4280) * primitives/sr-primitives -> primitives/runtime * update --- Cargo.lock | 1387 +++++++++-------- Cargo.toml | 2 +- bin/node-template/Cargo.toml | 2 +- bin/node-template/runtime/Cargo.toml | 2 +- bin/node/cli/Cargo.toml | 12 +- bin/node/executor/Cargo.toml | 3 +- bin/node/primitives/Cargo.toml | 2 +- bin/node/rpc/Cargo.toml | 2 +- bin/node/runtime/Cargo.toml | 2 +- bin/node/testing/Cargo.toml | 2 +- bin/subkey/Cargo.toml | 2 +- client/Cargo.toml | 2 +- client/api/Cargo.toml | 3 +- client/authority-discovery/Cargo.toml | 2 +- client/basic-authorship/Cargo.toml | 2 +- client/block-builder/Cargo.toml | 3 +- client/chain-spec/Cargo.toml | 2 +- client/cli/Cargo.toml | 2 +- client/consensus/aura/Cargo.toml | 2 +- client/consensus/babe/Cargo.toml | 2 +- client/consensus/pow/Cargo.toml | 2 +- client/consensus/slots/Cargo.toml | 2 +- client/consensus/uncles/Cargo.toml | 2 +- client/db/Cargo.toml | 2 +- client/executor/runtime-test/Cargo.toml | 2 +- client/finality-grandpa/Cargo.toml | 2 +- client/network/Cargo.toml | 2 +- client/offchain/Cargo.toml | 2 +- client/rpc-servers/Cargo.toml | 2 +- client/rpc/Cargo.toml | 2 +- client/service/Cargo.toml | 2 +- client/service/test/Cargo.toml | 2 +- client/transaction-pool/Cargo.toml | 2 +- client/transaction-pool/graph/Cargo.toml | 2 +- docs/CODEOWNERS | 2 +- frame/assets/Cargo.toml | 2 +- frame/aura/Cargo.toml | 2 +- frame/authority-discovery/Cargo.toml | 4 +- frame/authorship/Cargo.toml | 2 +- frame/babe/Cargo.toml | 2 +- frame/balances/Cargo.toml | 2 +- frame/collective/Cargo.toml | 2 +- frame/contracts/Cargo.toml | 2 +- frame/contracts/rpc/Cargo.toml | 2 +- frame/contracts/rpc/runtime-api/Cargo.toml | 2 +- frame/democracy/Cargo.toml | 2 +- frame/elections-phragmen/Cargo.toml | 2 +- frame/elections/Cargo.toml | 2 +- frame/evm/Cargo.toml | 2 +- frame/example/Cargo.toml | 2 +- frame/executive/Cargo.toml | 2 +- frame/finality-tracker/Cargo.toml | 2 +- frame/generic-asset/Cargo.toml | 2 +- frame/grandpa/Cargo.toml | 2 +- frame/im-online/Cargo.toml | 2 +- frame/indices/Cargo.toml | 2 +- frame/membership/Cargo.toml | 2 +- frame/nicks/Cargo.toml | 2 +- frame/offences/Cargo.toml | 2 +- frame/randomness-collective-flip/Cargo.toml | 2 +- frame/scored-pool/Cargo.toml | 2 +- frame/session/Cargo.toml | 2 +- frame/staking/Cargo.toml | 2 +- frame/staking/reward-curve/Cargo.toml | 2 +- frame/sudo/Cargo.toml | 2 +- frame/support/Cargo.toml | 2 +- frame/support/test/Cargo.toml | 2 +- frame/system/Cargo.toml | 2 +- frame/timestamp/Cargo.toml | 2 +- frame/transaction-payment/Cargo.toml | 2 +- frame/transaction-payment/rpc/Cargo.toml | 2 +- .../rpc/runtime-api/Cargo.toml | 2 +- frame/treasury/Cargo.toml | 2 +- frame/utility/Cargo.toml | 2 +- primitives/application-crypto/Cargo.toml | 8 +- primitives/authority-discovery/Cargo.toml | 2 +- .../block-builder/runtime-api/Cargo.toml | 2 +- primitives/blockchain/Cargo.toml | 5 +- primitives/consensus/aura/Cargo.toml | 2 +- primitives/consensus/babe/Cargo.toml | 2 +- primitives/consensus/common/Cargo.toml | 2 +- primitives/consensus/pow/Cargo.toml | 2 +- primitives/finality-grandpa/Cargo.toml | 2 +- primitives/keyring/Cargo.toml | 2 +- primitives/offchain/Cargo.toml | 2 +- primitives/phragmen/Cargo.toml | 2 +- .../{sr-primitives => runtime}/Cargo.toml | 0 .../{sr-primitives => runtime}/src/curve.rs | 0 .../src/generic/block.rs | 0 .../src/generic/checked_extrinsic.rs | 0 .../src/generic/digest.rs | 0 .../src/generic/era.rs | 0 .../src/generic/header.rs | 0 .../src/generic/mod.rs | 0 .../src/generic/tests.rs | 0 .../src/generic/unchecked_extrinsic.rs | 0 .../{sr-primitives => runtime}/src/lib.rs | 0 .../src/offchain/http.rs | 0 .../src/offchain/mod.rs | 0 .../src/random_number_generator.rs | 0 .../{sr-primitives => runtime}/src/testing.rs | 0 .../{sr-primitives => runtime}/src/traits.rs | 0 .../src/transaction_validity.rs | 0 primitives/session/Cargo.toml | 2 +- primitives/sr-api/Cargo.toml | 2 +- primitives/sr-api/proc-macro/Cargo.toml | 2 +- primitives/sr-api/test/Cargo.toml | 2 +- primitives/sr-staking-primitives/Cargo.toml | 2 +- primitives/sr-version/Cargo.toml | 2 +- primitives/timestamp/Cargo.toml | 2 +- primitives/transaction-pool/Cargo.toml | 2 +- test/utils/client/Cargo.toml | 2 +- test/utils/primitives/Cargo.toml | 2 +- test/utils/runtime/Cargo.toml | 2 +- test/utils/runtime/client/Cargo.toml | 2 +- test/utils/transaction-factory/Cargo.toml | 3 +- utils/frame/rpc/system/Cargo.toml | 2 +- 117 files changed, 845 insertions(+), 765 deletions(-) rename primitives/{sr-primitives => runtime}/Cargo.toml (100%) rename primitives/{sr-primitives => runtime}/src/curve.rs (100%) rename primitives/{sr-primitives => runtime}/src/generic/block.rs (100%) rename primitives/{sr-primitives => runtime}/src/generic/checked_extrinsic.rs (100%) rename primitives/{sr-primitives => runtime}/src/generic/digest.rs (100%) rename primitives/{sr-primitives => runtime}/src/generic/era.rs (100%) rename primitives/{sr-primitives => runtime}/src/generic/header.rs (100%) rename primitives/{sr-primitives => runtime}/src/generic/mod.rs (100%) rename primitives/{sr-primitives => runtime}/src/generic/tests.rs (100%) rename primitives/{sr-primitives => runtime}/src/generic/unchecked_extrinsic.rs (100%) rename primitives/{sr-primitives => runtime}/src/lib.rs (100%) rename primitives/{sr-primitives => runtime}/src/offchain/http.rs (100%) rename primitives/{sr-primitives => runtime}/src/offchain/mod.rs (100%) rename primitives/{sr-primitives => runtime}/src/random_number_generator.rs (100%) rename primitives/{sr-primitives => runtime}/src/testing.rs (100%) rename primitives/{sr-primitives => runtime}/src/traits.rs (100%) rename primitives/{sr-primitives => runtime}/src/transaction_validity.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index 07e0eb308e..1e78423f41 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -47,7 +47,7 @@ dependencies = [ [[package]] name = "ahash" -version = "0.2.17" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "const-random 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -79,7 +79,7 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.19" +version = "1.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -95,7 +95,7 @@ dependencies = [ [[package]] name = "arc-swap" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -130,7 +130,7 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -149,7 +149,7 @@ dependencies = [ [[package]] name = "async-std" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "async-macros 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -164,7 +164,7 @@ dependencies = [ "kv-log-macro 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)", "mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)", "once_cell 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -186,7 +186,7 @@ name = "atty" version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -202,7 +202,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "backtrace-sys 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -211,8 +211,8 @@ name = "backtrace-sys" version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -254,7 +254,7 @@ dependencies = [ [[package]] name = "bindgen" -version = "0.49.2" +version = "0.49.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -286,7 +286,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "bitvec" -version = "0.14.0" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -359,6 +359,11 @@ dependencies = [ "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "bs58" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "bs58" version = "0.3.0" @@ -438,23 +443,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cargo_metadata" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cast" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "cc" -version = "1.0.47" +version = "1.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "jobserver 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", @@ -483,17 +491,16 @@ dependencies = [ "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "sc-keystore 2.0.0", "sp-core 2.0.0", - "structopt 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "chrono" -version = "0.4.9" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", "num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -504,7 +511,7 @@ version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -518,7 +525,7 @@ dependencies = [ "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -527,7 +534,7 @@ name = "clear_on_drop" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -543,7 +550,7 @@ name = "cmake" version = "0.1.42" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -552,7 +559,7 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -561,7 +568,7 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "web-sys 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)", + "web-sys 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -593,7 +600,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -623,7 +630,7 @@ dependencies = [ "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "thiserror 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "thiserror 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -679,8 +686,8 @@ dependencies = [ "cranelift-frontend 0.50.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "thiserror 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "wasmparser 0.39.2 (registry+https://github.com/rust-lang/crates.io-index)", + "thiserror 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmparser 0.39.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -697,22 +704,22 @@ version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", - "cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "cast 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", "criterion-plot 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "csv 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "itertools 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "itertools 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand_xoshiro 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rayon 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rayon-core 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rayon 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rayon-core 1.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", "tinytemplate 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "walkdir 2.2.9 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -723,20 +730,20 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", - "cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "cast 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", "criterion-plot 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "csv 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "itertools 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "itertools 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_os 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand_xoshiro 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rayon 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rayon 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", "tinytemplate 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "walkdir 2.2.9 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -747,8 +754,8 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "itertools 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "cast 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "itertools 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -756,8 +763,8 @@ name = "criterion-plot" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "itertools 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "cast 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "itertools 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -806,6 +813,14 @@ dependencies = [ "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "crossbeam-queue" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crossbeam-utils 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "crossbeam-utils" version = "0.6.6" @@ -873,7 +888,7 @@ version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -912,7 +927,7 @@ dependencies = [ "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "subtle 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "subtle 2.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -927,7 +942,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -958,7 +973,7 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "redox_users 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -997,7 +1012,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "elastic-array" -version = "0.10.2" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1046,7 +1061,7 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1056,19 +1071,20 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "evm" -version = "0.14.0" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "evm-core 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "evm-gasometer 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "evm-runtime 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "primitive-types 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rlp 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "rlp 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sha3 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1113,14 +1129,14 @@ name = "faerie" version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "anyhow 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)", - "goblin 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "anyhow 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", + "goblin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "scroll 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "string-interner 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "thiserror 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "thiserror 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1139,8 +1155,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "synstructure 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", + "synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1158,7 +1174,7 @@ name = "fdlimit" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1177,8 +1193,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1188,7 +1204,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "static_assertions 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1207,7 +1223,7 @@ dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "libz-sys 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", "miniz_oxide 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1235,7 +1251,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "fork-tree" version = "2.0.0" dependencies = [ - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1248,7 +1264,7 @@ dependencies = [ "pallet-balances 2.0.0", "pallet-indices 2.0.0", "pallet-transaction-payment 2.0.0", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0", "sp-io 2.0.0", @@ -1260,7 +1276,7 @@ dependencies = [ name = "frame-metadata" version = "2.0.0" dependencies = [ - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0", "sp-std 2.0.0", @@ -1277,7 +1293,7 @@ dependencies = [ "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "once_cell 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "paste 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1298,7 +1314,7 @@ dependencies = [ "frame-support-procedural-tools 2.0.0", "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1309,7 +1325,7 @@ dependencies = [ "proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1318,7 +1334,7 @@ version = "2.0.0" dependencies = [ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1326,7 +1342,7 @@ name = "frame-support-test" version = "2.0.0" dependencies = [ "frame-support 2.0.0", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0", @@ -1334,7 +1350,7 @@ dependencies = [ "sp-io 2.0.0", "sp-runtime 2.0.0", "sp-state-machine 2.0.0", - "trybuild 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)", + "trybuild 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1344,7 +1360,7 @@ dependencies = [ "criterion 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "frame-support 2.0.0", "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0", @@ -1358,7 +1374,7 @@ dependencies = [ name = "frame-system-rpc-runtime-api" version = "2.0.0" dependencies = [ - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "sp-api 2.0.0", ] @@ -1369,7 +1385,7 @@ dependencies = [ "frame-support 2.0.0", "frame-system 2.0.0", "pallet-balances 2.0.0", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0", "sp-io 2.0.0", @@ -1383,7 +1399,7 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1393,7 +1409,7 @@ name = "fs2" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1496,7 +1512,7 @@ dependencies = [ "proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1588,7 +1604,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "c_linked_list 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "get_if_addrs-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1598,7 +1614,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1607,9 +1623,9 @@ version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1648,7 +1664,7 @@ dependencies = [ [[package]] name = "goblin" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1660,8 +1676,8 @@ dependencies = [ name = "grafana-data-source" version = "2.0.0" dependencies = [ - "async-std 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", + "async-std 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "chrono 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", "futures-timer 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1671,7 +1687,7 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-executor 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1695,7 +1711,7 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1713,7 +1729,7 @@ dependencies = [ "futures-core-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", "futures-sink-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", "futures-util-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1750,7 +1766,7 @@ name = "hashbrown" version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "ahash 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", + "ahash 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1775,7 +1791,7 @@ name = "hermit-abi" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1821,7 +1837,7 @@ dependencies = [ [[package]] name = "http" -version = "0.1.19" +version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1836,7 +1852,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-buf 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1846,7 +1862,7 @@ version = "0.2.0-alpha.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1889,7 +1905,7 @@ dependencies = [ "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "h2 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "http-body 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1900,12 +1916,12 @@ dependencies = [ "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-buf 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-reactor 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-reactor 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-threadpool 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-threadpool 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", "want 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1919,7 +1935,7 @@ dependencies = [ "futures-core-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", "futures-util-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", "h2 0.2.0-alpha.3 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "http-body 0.2.0-alpha.3 (registry+https://github.com/rust-lang/crates.io-index)", "httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1970,7 +1986,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-normalization 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-normalization 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1980,7 +1996,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-normalization 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-normalization 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1988,7 +2004,7 @@ name = "impl-codec" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1996,7 +2012,7 @@ name = "impl-rlp" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rlp 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "rlp 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2014,7 +2030,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2040,7 +2056,7 @@ name = "iovec" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2050,7 +2066,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "itertools" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2067,88 +2083,88 @@ version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "getrandom 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "js-sys" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "wasm-bindgen 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "jsonrpc-client-transports" -version = "14.0.3" +version = "14.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.12.35 (registry+https://github.com/rust-lang/crates.io-index)", "hyper-tls 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-pubsub 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-pubsub 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "websocket 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)", + "websocket 0.24.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "jsonrpc-core" -version = "14.0.3" +version = "14.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "jsonrpc-core-client" -version = "14.0.3" +version = "14.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "jsonrpc-client-transports 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-client-transports 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "jsonrpc-derive" -version = "14.0.3" +version = "14.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "jsonrpc-http-server" -version = "14.0.3" +version = "14.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "hyper 0.12.35 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-server-utils 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-server-utils 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "unicase 2.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "unicase 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "jsonrpc-pubsub" -version = "14.0.3" +version = "14.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2156,26 +2172,26 @@ dependencies = [ [[package]] name = "jsonrpc-server-utils" -version = "14.0.3" +version = "14.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "globset 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "unicase 2.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "unicase 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "jsonrpc-ws-server" -version = "14.0.3" +version = "14.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-server-utils 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-server-utils 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2219,7 +2235,7 @@ name = "kvdb" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "elastic-array 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", + "elastic-array 0.10.3 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2237,7 +2253,7 @@ name = "kvdb-rocksdb" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "elastic-array 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", + "elastic-array 0.10.3 (registry+https://github.com/rust-lang/crates.io-index)", "fs-swap 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "interleaved-ordered 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2269,7 +2285,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.65" +version = "0.2.66" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -2277,29 +2293,29 @@ name = "libloading" version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p" -version = "0.13.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-core-derive 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-deflate 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-dns 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-floodsub 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-identify 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-kad 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-mdns 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-identify 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-kad 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-mdns 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-mplex 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-noise 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-ping 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-ping 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-plaintext 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-secio 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-swarm 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2308,19 +2324,19 @@ dependencies = [ "libp2p-wasm-ext 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-websocket 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-yamux 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multihash 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multihash 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-timer 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-core" -version = "0.13.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "asn1_der 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2334,8 +2350,8 @@ dependencies = [ "libsecp256k1 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "multistream-select 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multihash 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multihash 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2344,13 +2360,13 @@ dependencies = [ "rw-stream-sink 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "untrusted 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-timer 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "zeroize 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "zeroize 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2369,7 +2385,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "flate2 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2379,7 +2395,7 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-dns-unofficial 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2394,7 +2410,7 @@ dependencies = [ "cuckoofilter 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-swarm 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2404,15 +2420,15 @@ dependencies = [ [[package]] name = "libp2p-identify" -version = "0.13.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-swarm 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2423,7 +2439,7 @@ dependencies = [ [[package]] name = "libp2p-kad" -version = "0.13.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2431,11 +2447,11 @@ dependencies = [ "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-swarm 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multihash 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multihash 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2450,21 +2466,21 @@ dependencies = [ [[package]] name = "libp2p-mdns" -version = "0.13.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "dns-parser 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-swarm 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-reactor 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-reactor 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-udp 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-timer 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2478,7 +2494,7 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2495,28 +2511,28 @@ dependencies = [ "curve25519-dalek 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.16.9 (registry+https://github.com/rust-lang/crates.io-index)", - "snow 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "snow 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "x25519-dalek 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "zeroize 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "zeroize 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libp2p-ping" -version = "0.13.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", "libp2p-swarm 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2530,7 +2546,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "rw-stream-sink 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2548,9 +2564,9 @@ dependencies = [ "ctr 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "hmac 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "protobuf 2.8.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2562,9 +2578,9 @@ dependencies = [ "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "twofish 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "untrusted 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-futures 0.3.27 (registry+https://github.com/rust-lang/crates.io-index)", - "web-sys 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)", + "web-sys 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2573,7 +2589,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2589,11 +2605,11 @@ dependencies = [ "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "get_if_addrs 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "ipnet 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2602,7 +2618,7 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2613,11 +2629,11 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-futures 0.3.27 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2628,7 +2644,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "rw-stream-sink 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "soketto 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2645,7 +2661,7 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p-core 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p-core 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "yamux 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2656,10 +2672,10 @@ name = "librocksdb-sys" version = "6.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bindgen 0.49.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)", + "bindgen 0.49.4 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)", "glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2672,7 +2688,7 @@ dependencies = [ "hmac-drbg 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "subtle 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "subtle 2.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2681,10 +2697,10 @@ name = "libz-sys" version = "1.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)", - "vcpkg 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "vcpkg 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2718,7 +2734,7 @@ dependencies = [ [[package]] name = "lock_api" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2742,7 +2758,7 @@ dependencies = [ [[package]] name = "lru" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "hashbrown 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2753,7 +2769,7 @@ name = "mach" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2762,8 +2778,8 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "synstructure 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", + "synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2781,7 +2797,7 @@ name = "memchr" version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2794,9 +2810,10 @@ dependencies = [ [[package]] name = "memory-db" -version = "0.15.2" +version = "0.15.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ + "ahash 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "hashbrown 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", "parity-util-mem 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2809,13 +2826,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "merlin" -version = "1.2.1" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "keccak 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "zeroize 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2836,14 +2853,15 @@ dependencies = [ [[package]] name = "mio" -version = "0.6.19" +version = "0.6.21" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2853,12 +2871,12 @@ dependencies = [ [[package]] name = "mio-extras" -version = "2.0.5" +version = "2.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2868,8 +2886,8 @@ version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2920,13 +2938,13 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl 0.10.25 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl 0.10.26 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.52 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.53 (registry+https://github.com/rust-lang/crates.io-index)", "schannel 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", - "security-framework 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "security-framework 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "security-framework-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2937,7 +2955,7 @@ version = "0.2.33" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2947,9 +2965,9 @@ version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2966,10 +2984,10 @@ dependencies = [ "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb-memorydb 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "node-executor 2.0.0", "node-primitives 2.0.0", @@ -2982,7 +3000,7 @@ dependencies = [ "pallet-indices 2.0.0", "pallet-timestamp 2.0.0", "pallet-transaction-payment 2.0.0", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "sc-authority-discovery 2.0.0", @@ -3015,13 +3033,13 @@ dependencies = [ "sp-runtime 2.0.0", "sp-timestamp 2.0.0", "sp-transaction-pool-api 2.0.0", - "structopt 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-build-script-utils 2.0.0", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", "transaction-factory 0.0.1", "vergen 3.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-futures 0.3.27 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3043,7 +3061,7 @@ dependencies = [ "pallet-timestamp 2.0.0", "pallet-transaction-payment 2.0.0", "pallet-treasury 2.0.0", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "sc-executor 2.0.0", "sp-core 2.0.0", "sp-io 2.0.0", @@ -3069,7 +3087,7 @@ dependencies = [ name = "node-rpc" version = "2.0.0" dependencies = [ - "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "node-primitives 2.0.0", "node-runtime 2.0.0", "pallet-contracts-rpc 2.0.0", @@ -3087,7 +3105,7 @@ dependencies = [ "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.12.35 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core-client 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core-client 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "node-primitives 2.0.0", "sc-rpc 2.0.0", @@ -3129,7 +3147,7 @@ dependencies = [ "pallet-transaction-payment 2.0.0", "pallet-transaction-payment-rpc-runtime-api 2.0.0", "pallet-treasury 2.0.0", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3160,7 +3178,7 @@ dependencies = [ "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "node-template-runtime 2.0.0", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sc-basic-authority 2.0.0", "sc-cli 2.0.0", @@ -3200,7 +3218,7 @@ dependencies = [ "pallet-sudo 2.0.0", "pallet-timestamp 2.0.0", "pallet-transaction-payment 2.0.0", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-api 2.0.0", @@ -3236,7 +3254,7 @@ dependencies = [ "pallet-timestamp 2.0.0", "pallet-transaction-payment 2.0.0", "pallet-treasury 2.0.0", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "sc-client 2.0.0", "sc-executor 2.0.0", "sp-core 2.0.0", @@ -3273,7 +3291,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3282,7 +3300,7 @@ version = "0.1.41" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3293,12 +3311,12 @@ dependencies = [ "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "num-bigint 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "num-traits" -version = "0.2.8" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3310,7 +3328,7 @@ version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "hermit-abi 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3347,15 +3365,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "openssl" -version = "0.10.25" +version = "0.10.26" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.52 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.53 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3365,14 +3383,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "openssl-sys" -version = "0.9.52" +version = "0.9.53" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)", - "vcpkg 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "vcpkg 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3397,7 +3415,7 @@ version = "2.0.0" dependencies = [ "frame-support 2.0.0", "frame-system 2.0.0", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0", "sp-io 2.0.0", @@ -3414,7 +3432,7 @@ dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "pallet-session 2.0.0", "pallet-timestamp 2.0.0", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sc-application-crypto 2.0.0", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3434,7 +3452,7 @@ dependencies = [ "frame-support 2.0.0", "frame-system 2.0.0", "pallet-session 2.0.0", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "sc-application-crypto 2.0.0", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-authority-discovery 2.0.0", @@ -3452,7 +3470,7 @@ dependencies = [ "frame-support 2.0.0", "frame-system 2.0.0", "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "sp-authorship 2.0.0", "sp-core 2.0.0", "sp-inherents 2.0.0", @@ -3471,7 +3489,7 @@ dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "pallet-session 2.0.0", "pallet-timestamp 2.0.0", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-consensus-babe 2.0.0", @@ -3493,7 +3511,7 @@ dependencies = [ "frame-support 2.0.0", "frame-system 2.0.0", "pallet-transaction-payment 2.0.0", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0", @@ -3510,7 +3528,7 @@ dependencies = [ "frame-system 2.0.0", "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "pallet-balances 2.0.0", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0", @@ -3530,7 +3548,7 @@ dependencies = [ "pallet-balances 2.0.0", "pallet-randomness-collective-flip 2.0.0", "pallet-timestamp 2.0.0", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-wasm 0.41.0 (registry+https://github.com/rust-lang/crates.io-index)", "pwasm-utils 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3547,13 +3565,13 @@ dependencies = [ name = "pallet-contracts-rpc" version = "2.0.0" dependencies = [ - "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core-client 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-derive 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core-client 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-derive 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "pallet-contracts-rpc-runtime-api 2.0.0", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", "sp-blockchain 2.0.0", "sp-core 2.0.0", "sp-rpc 2.0.0", @@ -3564,7 +3582,7 @@ dependencies = [ name = "pallet-contracts-rpc-runtime-api" version = "2.0.0" dependencies = [ - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "sp-api 2.0.0", "sp-runtime 2.0.0", "sp-std 2.0.0", @@ -3577,7 +3595,7 @@ dependencies = [ "frame-support 2.0.0", "frame-system 2.0.0", "pallet-balances 2.0.0", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0", @@ -3594,7 +3612,7 @@ dependencies = [ "frame-system 2.0.0", "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "pallet-balances 2.0.0", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0", @@ -3611,7 +3629,7 @@ dependencies = [ "frame-system 2.0.0", "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "pallet-balances 2.0.0", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0", "sp-io 2.0.0", @@ -3625,14 +3643,14 @@ dependencies = [ name = "pallet-evm" version = "2.0.0" dependencies = [ - "evm 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", + "evm 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", "frame-support 2.0.0", "frame-system 2.0.0", "pallet-balances 2.0.0", "pallet-timestamp 2.0.0", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "primitive-types 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rlp 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "rlp 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sha3 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0", @@ -3648,7 +3666,7 @@ dependencies = [ "frame-support 2.0.0", "frame-system 2.0.0", "pallet-balances 2.0.0", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0", "sp-io 2.0.0", @@ -3663,7 +3681,7 @@ dependencies = [ "frame-support 2.0.0", "frame-system 2.0.0", "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0", "sp-finality-tracker 2.0.0", @@ -3679,7 +3697,7 @@ version = "2.0.0" dependencies = [ "frame-support 2.0.0", "frame-system 2.0.0", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0", "sp-io 2.0.0", @@ -3695,7 +3713,7 @@ dependencies = [ "frame-system 2.0.0", "pallet-finality-tracker 2.0.0", "pallet-session 2.0.0", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0", "sp-finality-grandpa 2.0.0", @@ -3713,7 +3731,7 @@ dependencies = [ "frame-system 2.0.0", "pallet-authorship 0.1.0", "pallet-session 2.0.0", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "sc-application-crypto 2.0.0", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0", @@ -3729,7 +3747,7 @@ version = "2.0.0" dependencies = [ "frame-support 2.0.0", "frame-system 2.0.0", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "ref_thread_local 0.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3746,7 +3764,7 @@ version = "2.0.0" dependencies = [ "frame-support 2.0.0", "frame-system 2.0.0", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0", "sp-io 2.0.0", @@ -3761,7 +3779,7 @@ dependencies = [ "frame-support 2.0.0", "frame-system 2.0.0", "pallet-balances 2.0.0", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0", "sp-io 2.0.0", @@ -3776,7 +3794,7 @@ dependencies = [ "frame-support 2.0.0", "frame-system 2.0.0", "pallet-balances 2.0.0", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0", "sp-io 2.0.0", @@ -3791,7 +3809,7 @@ version = "2.0.0" dependencies = [ "frame-support 2.0.0", "frame-system 2.0.0", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0", "sp-io 2.0.0", @@ -3806,7 +3824,7 @@ dependencies = [ "frame-support 2.0.0", "frame-system 2.0.0", "pallet-balances 2.0.0", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0", "sp-io 2.0.0", @@ -3823,7 +3841,7 @@ dependencies = [ "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "pallet-timestamp 2.0.0", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "sc-application-crypto 2.0.0", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3846,7 +3864,7 @@ dependencies = [ "pallet-session 2.0.0", "pallet-staking-reward-curve 2.0.0", "pallet-timestamp 2.0.0", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0", @@ -3867,7 +3885,7 @@ dependencies = [ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "sp-runtime 2.0.0", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3876,7 +3894,7 @@ version = "2.0.0" dependencies = [ "frame-support 2.0.0", "frame-system 2.0.0", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0", "sp-io 2.0.0", @@ -3891,7 +3909,7 @@ dependencies = [ "frame-support 2.0.0", "frame-system 2.0.0", "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0", "sp-inherents 2.0.0", @@ -3909,7 +3927,7 @@ dependencies = [ "frame-system 2.0.0", "pallet-balances 2.0.0", "pallet-transaction-payment-rpc-runtime-api 2.0.0", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0", "sp-io 2.0.0", "sp-runtime 2.0.0", @@ -3920,11 +3938,11 @@ dependencies = [ name = "pallet-transaction-payment-rpc" version = "2.0.0" dependencies = [ - "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core-client 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-derive 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core-client 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-derive 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "pallet-transaction-payment-rpc-runtime-api 2.0.0", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-blockchain 2.0.0", "sp-core 2.0.0", @@ -3937,9 +3955,9 @@ name = "pallet-transaction-payment-rpc-runtime-api" version = "2.0.0" dependencies = [ "frame-support 2.0.0", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", "sp-api 2.0.0", "sp-runtime 2.0.0", "sp-std 2.0.0", @@ -3952,7 +3970,7 @@ dependencies = [ "frame-support 2.0.0", "frame-system 2.0.0", "pallet-balances 2.0.0", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0", "sp-io 2.0.0", @@ -3967,7 +3985,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "parity-multiaddr" -version = "0.5.1" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "bs58 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multihash 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "unsigned-varint 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "parity-multiaddr" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3975,7 +4010,7 @@ dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multihash 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multihash 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3984,7 +4019,21 @@ dependencies = [ [[package]] name = "parity-multihash" -version = "0.1.4" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "blake2 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "sha-1 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sha3 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", + "unsigned-varint 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "parity-multihash" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "blake2 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3998,25 +4047,25 @@ dependencies = [ [[package]] name = "parity-scale-codec" -version = "1.0.6" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "arrayvec 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "bitvec 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", + "arrayvec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bitvec 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "byte-slice-cast 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec-derive 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec-derive 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "parity-scale-codec-derive" -version = "1.0.3" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4071,7 +4120,7 @@ name = "parking_lot" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lock_api 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "lock_api 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot_core 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4081,7 +4130,7 @@ name = "parking_lot_core" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4095,7 +4144,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4110,7 +4159,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4134,7 +4183,7 @@ dependencies = [ "proc-macro-hack 0.5.11 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4189,7 +4238,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4255,7 +4304,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4265,7 +4314,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4306,7 +4355,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "itertools 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "itertools 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "multimap 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "petgraph 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4322,7 +4371,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "itertools 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "itertools 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4389,7 +4438,7 @@ name = "rand" version = "0.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4399,7 +4448,7 @@ version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4411,7 +4460,7 @@ version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4429,7 +4478,7 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "getrandom 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4503,7 +4552,7 @@ name = "rand_jitter" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4515,10 +4564,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4571,28 +4620,28 @@ version = "7.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rayon" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-deque 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "rayon-core 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rayon-core 1.6.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rayon-core" -version = "1.6.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-deque 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-queue 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4656,7 +4705,7 @@ version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4674,18 +4723,18 @@ name = "ring" version = "0.16.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "spin 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "untrusted 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "web-sys 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)", + "web-sys 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rlp" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4696,16 +4745,16 @@ name = "rocksdb" version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "librocksdb-sys 6.2.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rpassword" -version = "4.0.1" +version = "4.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4756,7 +4805,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4799,7 +4848,7 @@ dependencies = [ name = "sc-application-crypto" version = "2.0.0" dependencies = [ - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0", "sp-io 2.0.0", @@ -4817,9 +4866,9 @@ dependencies = [ "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures-timer 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "prost 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "prost-build 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4827,7 +4876,7 @@ dependencies = [ "sc-keystore 2.0.0", "sc-network 2.0.0", "sc-peerset 2.0.0", - "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", "sp-api 2.0.0", "sp-authority-discovery 2.0.0", "sp-blockchain 2.0.0", @@ -4842,7 +4891,7 @@ version = "2.0.0" dependencies = [ "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sc-block-builder 2.0.0", "sc-client 2.0.0", @@ -4863,7 +4912,7 @@ dependencies = [ name = "sc-block-builder" version = "2.0.0" dependencies = [ - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "sp-api 2.0.0", "sp-block-builder 2.0.0", "sp-blockchain 2.0.0", @@ -4881,7 +4930,7 @@ dependencies = [ "sc-network 2.0.0", "sc-telemetry 2.0.0", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0", "sp-runtime 2.0.0", ] @@ -4893,7 +4942,7 @@ dependencies = [ "proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4912,23 +4961,23 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "names 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rpassword 4.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rpassword 4.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "sc-client-api 2.0.0", "sc-network 2.0.0", "sc-service 2.0.0", "sc-telemetry 2.0.0", "sc-tracing 2.0.0", - "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", "sp-blockchain 2.0.0", "sp-core 2.0.0", "sp-keyring 2.0.0", "sp-panic-handler 2.0.0", "sp-runtime 2.0.0", "sp-state-machine 2.0.0", - "structopt 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4944,7 +4993,7 @@ dependencies = [ "kvdb 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb-memorydb 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sc-block-builder 2.0.0", "sc-client-api 2.0.0", @@ -4982,7 +5031,7 @@ dependencies = [ "kvdb 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb-memorydb 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sc-block-builder 2.0.0", "sc-client-db 2.0.0", @@ -5018,7 +5067,7 @@ dependencies = [ "kvdb-rocksdb 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "quickcheck 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sc-client 2.0.0", @@ -5045,7 +5094,7 @@ dependencies = [ "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures-timer 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sc-application-crypto 2.0.0", "sc-client 2.0.0", @@ -5084,11 +5133,11 @@ dependencies = [ "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures-timer 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "merlin 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "merlin 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "num-bigint 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "num-rational 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "pdqselect 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5128,7 +5177,7 @@ dependencies = [ "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "sc-client-api 2.0.0", "sp-block-builder 2.0.0", "sp-blockchain 2.0.0", @@ -5147,7 +5196,7 @@ dependencies = [ "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures-timer 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sc-client-api 2.0.0", "sc-telemetry 2.0.0", @@ -5187,7 +5236,7 @@ dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "libsecp256k1 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-wasm 0.41.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sc-client-api 2.0.0", @@ -5222,7 +5271,7 @@ dependencies = [ "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "sc-client 2.0.0", @@ -5230,7 +5279,7 @@ dependencies = [ "sc-keystore 2.0.0", "sc-network 2.0.0", "sc-telemetry 2.0.0", - "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", "sp-api 2.0.0", "sp-blockchain 2.0.0", "sp-consensus 2.0.0", @@ -5245,8 +5294,8 @@ dependencies = [ "substrate-test-runtime-client 2.0.0", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -5258,9 +5307,9 @@ dependencies = [ "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "sc-application-crypto 2.0.0", - "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0", - "subtle 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "subtle 2.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5279,12 +5328,12 @@ dependencies = [ "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures-timer 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "linked_hash_set 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "lru 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "lru 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "quickcheck 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5294,7 +5343,7 @@ dependencies = [ "sc-client-api 2.0.0", "sc-peerset 2.0.0", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "slog_derive 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5313,7 +5362,7 @@ dependencies = [ "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "unsigned-varint 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "zeroize 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "zeroize 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -5330,7 +5379,7 @@ dependencies = [ "hyper-rustls 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "sc-client-api 2.0.0", @@ -5353,10 +5402,10 @@ name = "sc-peerset" version = "2.0.0" dependencies = [ "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -5367,10 +5416,10 @@ dependencies = [ "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-pubsub 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-pubsub 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "sc-client 2.0.0", @@ -5380,7 +5429,7 @@ dependencies = [ "sc-network 2.0.0", "sc-rpc-api 2.0.0", "sc-transaction-pool 2.0.0", - "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", "sp-api 2.0.0", "sp-blockchain 2.0.0", "sp-core 2.0.0", @@ -5401,15 +5450,15 @@ version = "2.0.0" dependencies = [ "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core-client 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-derive 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-pubsub 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core-client 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-derive 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-pubsub 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0", "sp-rpc 2.0.0", "sp-transaction-pool-api 2.0.0", @@ -5420,13 +5469,13 @@ dependencies = [ name = "sc-rpc-server" version = "2.0.0" dependencies = [ - "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-http-server 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-pubsub 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-ws-server 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-http-server 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-pubsub 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-ws-server 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", "sp-runtime 2.0.0", ] @@ -5453,8 +5502,8 @@ dependencies = [ "grafana-data-source 2.0.0", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-multiaddr 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sc-application-crypto 2.0.0", "sc-chain-spec 2.0.0", @@ -5472,7 +5521,7 @@ dependencies = [ "sc-tracing 2.0.0", "sc-transaction-pool 2.0.0", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "sp-api 2.0.0", "sp-blockchain 2.0.0", @@ -5488,8 +5537,8 @@ dependencies = [ "sysinfo 0.9.6 (registry+https://github.com/rust-lang/crates.io-index)", "target_info 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", "tracing 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5519,7 +5568,7 @@ version = "2.0.0" dependencies = [ "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0", ] @@ -5532,7 +5581,7 @@ dependencies = [ "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures-timer 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5555,7 +5604,7 @@ dependencies = [ "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sc-telemetry 2.0.0", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "tracing 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "tracing-core 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5570,7 +5619,7 @@ dependencies = [ "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0", @@ -5586,7 +5635,7 @@ dependencies = [ "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sc-client-api 2.0.0", "sc-transaction-graph 2.0.0", @@ -5615,12 +5664,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "curve25519-dalek 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "merlin 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "merlin 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "subtle 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "subtle 2.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "zeroize 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5649,7 +5698,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -5663,12 +5712,12 @@ dependencies = [ [[package]] name = "security-framework" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "security-framework-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5722,12 +5771,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_json" -version = "1.0.42" +version = "1.0.44" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5817,10 +5866,10 @@ name = "slog-json" version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", + "chrono 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "erased-serde 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5829,7 +5878,7 @@ name = "slog-scope" version = "4.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "arc-swap 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "arc-swap 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5841,7 +5890,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -5859,14 +5908,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "snow" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.16.9 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "subtle 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "subtle 2.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -5878,7 +5927,7 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5898,7 +5947,7 @@ name = "sp-api" version = "2.0.0" dependencies = [ "criterion 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "sp-api-proc-macro 2.0.0", "sp-core 2.0.0", "sp-runtime 2.0.0", @@ -5920,14 +5969,14 @@ dependencies = [ "sp-runtime 2.0.0", "sp-version 2.0.0", "substrate-test-runtime-client 2.0.0", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "sp-api-test" version = "2.0.0" dependencies = [ - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustversion 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "sp-api 2.0.0", "sp-blockchain 2.0.0", @@ -5936,7 +5985,7 @@ dependencies = [ "sp-state-machine 2.0.0", "sp-version 2.0.0", "substrate-test-runtime-client 2.0.0", - "trybuild 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)", + "trybuild 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -5945,8 +5994,8 @@ version = "2.0.0" dependencies = [ "criterion 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "integer-sqrt 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "primitive-types 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5958,7 +6007,7 @@ dependencies = [ name = "sp-authority-discovery" version = "2.0.0" dependencies = [ - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "sc-application-crypto 2.0.0", "sp-api 2.0.0", "sp-runtime 2.0.0", @@ -5969,7 +6018,7 @@ dependencies = [ name = "sp-authorship" version = "2.0.0" dependencies = [ - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "sp-inherents 2.0.0", "sp-std 2.0.0", ] @@ -5978,7 +6027,7 @@ dependencies = [ name = "sp-block-builder" version = "2.0.0" dependencies = [ - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "sp-api 2.0.0", "sp-inherents 2.0.0", "sp-runtime 2.0.0", @@ -5991,8 +6040,8 @@ version = "2.0.0" dependencies = [ "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "lru 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "lru 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sp-block-builder 2.0.0", "sp-consensus 2.0.0", @@ -6007,9 +6056,9 @@ dependencies = [ "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures-timer 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libp2p 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0", "sp-inherents 2.0.0", @@ -6023,7 +6072,7 @@ dependencies = [ name = "sp-consensus-aura" version = "2.0.0" dependencies = [ - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "sc-application-crypto 2.0.0", "sp-api 2.0.0", "sp-inherents 2.0.0", @@ -6036,7 +6085,7 @@ dependencies = [ name = "sp-consensus-babe" version = "2.0.0" dependencies = [ - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "sc-application-crypto 2.0.0", "sc-consensus-slots 2.0.0", "schnorrkel 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -6051,7 +6100,7 @@ dependencies = [ name = "sp-consensus-pow" version = "2.0.0" dependencies = [ - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "sp-api 2.0.0", "sp-core 2.0.0", "sp-runtime 2.0.0", @@ -6075,8 +6124,8 @@ dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "libsecp256k1 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "primitive-types 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -6085,7 +6134,7 @@ dependencies = [ "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "schnorrkel 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core-storage 2.0.0", "sp-debug-derive 2.0.0", @@ -6098,7 +6147,7 @@ dependencies = [ "tiny-keccak 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "twox-hash 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "wasmi 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "zeroize 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "zeroize 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -6117,7 +6166,7 @@ version = "2.0.0" dependencies = [ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -6133,7 +6182,7 @@ dependencies = [ name = "sp-finality-grandpa" version = "2.0.0" dependencies = [ - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "sc-application-crypto 2.0.0", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-api 2.0.0", @@ -6145,7 +6194,7 @@ dependencies = [ name = "sp-finality-tracker" version = "2.0.0" dependencies = [ - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "sp-inherents 2.0.0", "sp-std 2.0.0", ] @@ -6155,7 +6204,7 @@ name = "sp-inherents" version = "2.0.0" dependencies = [ "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0", "sp-std 2.0.0", @@ -6168,7 +6217,7 @@ dependencies = [ "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "libsecp256k1 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0", "sp-externalities 2.0.0", "sp-runtime-interface 2.0.0", @@ -6220,7 +6269,7 @@ name = "sp-rpc" version = "2.0.0" dependencies = [ "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0", ] @@ -6230,12 +6279,12 @@ version = "2.0.0" dependencies = [ "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "paste 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "sc-application-crypto 2.0.0", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", "sp-arithmetic 2.0.0", "sp-core 2.0.0", "sp-inherents 2.0.0", @@ -6248,7 +6297,7 @@ name = "sp-runtime-interface" version = "2.0.0" dependencies = [ "environmental 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "primitive-types 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "sc-executor 2.0.0", "sp-core 2.0.0", @@ -6267,15 +6316,15 @@ name = "sp-runtime-interface-proc-macro" version = "2.0.0" dependencies = [ "Inflector 0.11.4 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustversion 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "sp-externalities 2.0.0", "sp-runtime-interface 2.0.0", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "trybuild 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", + "trybuild 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -6294,7 +6343,7 @@ name = "sp-sandbox" version = "2.0.0" dependencies = [ "assert_matches 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0", "sp-io 2.0.0", "sp-std 2.0.0", @@ -6307,7 +6356,7 @@ name = "sp-serializer" version = "2.0.0" dependencies = [ "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -6323,7 +6372,7 @@ dependencies = [ name = "sp-staking" version = "2.0.0" dependencies = [ - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "sp-runtime 2.0.0", "sp-std 2.0.0", ] @@ -6335,8 +6384,8 @@ dependencies = [ "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0", @@ -6356,7 +6405,7 @@ name = "sp-timestamp" version = "2.0.0" dependencies = [ "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "sp-api 2.0.0", "sp-inherents 2.0.0", "sp-runtime 2.0.0", @@ -6370,7 +6419,7 @@ dependencies = [ "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-api 2.0.0", "sp-core 2.0.0", @@ -6384,8 +6433,8 @@ dependencies = [ "criterion 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "memory-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "memory-db 0.15.3 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0", "sp-std 2.0.0", "trie-bench 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -6399,7 +6448,7 @@ name = "sp-version" version = "2.0.0" dependencies = [ "impl-serde 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-runtime 2.0.0", "sp-std 2.0.0", @@ -6459,23 +6508,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "structopt" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", - "structopt-derive 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "structopt-derive 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "structopt-derive" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro-error 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -6494,7 +6543,7 @@ dependencies = [ "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -6509,7 +6558,7 @@ dependencies = [ "node-runtime 2.0.0", "pallet-balances 2.0.0", "pallet-transaction-payment 2.0.0", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0", @@ -6540,9 +6589,9 @@ dependencies = [ "frame-support 2.0.0", "frame-system 2.0.0", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-client-transports 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-client-transports 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "sc-rpc-api 2.0.0", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core-storage 2.0.0", @@ -6556,11 +6605,11 @@ dependencies = [ "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "frame-system-rpc-runtime-api 2.0.0", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-core-client 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "jsonrpc-derive 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-core-client 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "jsonrpc-derive 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "sc-client 2.0.0", "sc-transaction-pool 2.0.0", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", @@ -6577,7 +6626,7 @@ version = "2.0.0" dependencies = [ "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "sc-client 2.0.0", "sc-client-api 2.0.0", "sc-client-db 2.0.0", @@ -6594,7 +6643,7 @@ dependencies = [ name = "substrate-test-primitives" version = "2.0.0" dependencies = [ - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "sc-application-crypto 2.0.0", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0", @@ -6611,10 +6660,10 @@ dependencies = [ "frame-system 2.0.0", "frame-system-rpc-runtime-api 2.0.0", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "memory-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", + "memory-db 0.15.3 (registry+https://github.com/rust-lang/crates.io-index)", "pallet-babe 2.0.0", "pallet-timestamp 2.0.0", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "sc-application-crypto 2.0.0", "sc-client 2.0.0", "sc-executor 2.0.0", @@ -6646,7 +6695,7 @@ name = "substrate-test-runtime-client" version = "2.0.0" dependencies = [ "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "sc-block-builder 2.0.0", "sc-client 2.0.0", "sc-client-api 2.0.0", @@ -6667,7 +6716,7 @@ version = "1.0.8" dependencies = [ "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", "build-helper 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "cargo_metadata 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cargo_metadata 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "fs2 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -6686,7 +6735,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "subtle" -version = "2.2.1" +version = "2.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -6701,7 +6750,7 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.8" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -6711,12 +6760,12 @@ dependencies = [ [[package]] name = "synstructure" -version = "0.12.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -6727,8 +6776,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "doc-comment 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "rayon 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", + "rayon 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -6753,7 +6802,7 @@ version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", "remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -6776,7 +6825,7 @@ dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", "version_check 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -6785,25 +6834,25 @@ name = "textwrap" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "thiserror" -version = "1.0.5" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "thiserror-impl 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "thiserror-impl 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "thiserror-impl" -version = "1.0.5" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -6827,7 +6876,7 @@ name = "time" version = "0.1.42" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -6868,7 +6917,7 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -6878,25 +6927,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-fs 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-reactor 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-reactor 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-sync 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-threadpool 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-threadpool 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-udp 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tokio" -version = "0.2.2" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -6941,7 +6990,7 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -6957,7 +7006,7 @@ dependencies = [ [[package]] name = "tokio-executor" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -6981,7 +7030,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-threadpool 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-threadpool 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -7008,18 +7057,18 @@ dependencies = [ [[package]] name = "tokio-reactor" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-sync 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -7064,14 +7113,14 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-reactor 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-reactor 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tokio-threadpool" -version = "0.1.16" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-deque 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -7082,18 +7131,18 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tokio-timer" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -7114,10 +7163,10 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-reactor 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-reactor 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -7128,13 +7177,13 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)", "mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-reactor 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-reactor 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -7176,7 +7225,7 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -7198,7 +7247,7 @@ name = "transaction-factory" version = "0.0.1" dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "sc-cli 2.0.0", "sc-client 2.0.0", "sc-client-api 2.0.0", @@ -7219,8 +7268,8 @@ dependencies = [ "criterion 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hasher 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", - "memory-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "memory-db 0.15.3 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "trie-db 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", "trie-root 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "trie-standardmap 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -7231,7 +7280,7 @@ name = "trie-db" version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "elastic-array 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", + "elastic-array 0.10.3 (registry+https://github.com/rust-lang/crates.io-index)", "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "hashbrown 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -7262,13 +7311,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "trybuild" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -7322,10 +7371,10 @@ dependencies = [ [[package]] name = "unicase" -version = "2.5.1" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "version_check 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -7338,10 +7387,10 @@ dependencies = [ [[package]] name = "unicode-normalization" -version = "0.1.9" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -7351,7 +7400,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "unicode-width" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -7400,7 +7449,7 @@ dependencies = [ [[package]] name = "vcpkg" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -7414,7 +7463,7 @@ version = "3.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", + "chrono 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -7440,7 +7489,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", "wabt-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -7449,7 +7498,7 @@ name = "wabt-sys" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)", "cmake 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -7490,16 +7539,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "wasm-bindgen" -version = "0.2.54" +version = "0.2.55" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-macro 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-macro 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.54" +version = "0.2.55" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bumpalo 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -7507,8 +7556,8 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-shared 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-shared 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -7518,49 +7567,49 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", - "web-sys 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "web-sys 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.54" +version = "0.2.55" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-macro-support 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-macro-support 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.54" +version = "0.2.55" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-backend 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-shared 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-backend 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-shared 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.54" +version = "0.2.55" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "wasm-bindgen-webidl" -version = "0.2.54" +version = "0.2.55" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "anyhow 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)", + "anyhow 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-backend 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-backend 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "weedle 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -7580,11 +7629,11 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)", "send_wrapper 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", - "web-sys 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "web-sys 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -7593,10 +7642,10 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "memory_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "num-rational 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "parity-wasm 0.41.0 (registry+https://github.com/rust-lang/crates.io-index)", "wasmi-validation 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -7611,7 +7660,7 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.39.2" +version = "0.39.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -7619,7 +7668,7 @@ name = "wasmtime-debug" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "anyhow 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)", + "anyhow 1.0.25 (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)", @@ -7627,8 +7676,8 @@ dependencies = [ "gimli 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", "more-asserts 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "thiserror 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "wasmparser 0.39.2 (registry+https://github.com/rust-lang/crates.io-index)", + "thiserror 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmparser 0.39.3 (registry+https://github.com/rust-lang/crates.io-index)", "wasmtime-environ 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -7647,16 +7696,16 @@ dependencies = [ "file-per-thread-logger 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "more-asserts 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rayon 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rayon 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "spin 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "thiserror 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "thiserror 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", - "wasmparser 0.39.2 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmparser 0.39.3 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "zstd 0.5.1+zstd.1.4.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -7666,7 +7715,7 @@ name = "wasmtime-jit" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "anyhow 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)", + "anyhow 1.0.25 (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-frontend 0.50.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -7674,8 +7723,8 @@ dependencies = [ "more-asserts 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "thiserror 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "wasmparser 0.39.2 (registry+https://github.com/rust-lang/crates.io-index)", + "thiserror 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", + "wasmparser 0.39.3 (registry+https://github.com/rust-lang/crates.io-index)", "wasmtime-debug 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "wasmtime-environ 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "wasmtime-runtime 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -7687,31 +7736,31 @@ name = "wasmtime-runtime" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.48 (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)", "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "memoffset 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "more-asserts 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "thiserror 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "thiserror 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", "wasmtime-environ 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "web-sys" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "anyhow 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)", - "js-sys 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)", + "anyhow 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)", "sourcefile 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-webidl 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-webidl 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -7741,7 +7790,27 @@ dependencies = [ [[package]] name = "websocket" -version = "0.23.0" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "hyper 0.10.16 (registry+https://github.com/rust-lang/crates.io-index)", + "native-tls 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-reactor 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-tls 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "websocket-base 0.24.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "websocket-base" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -7749,17 +7818,13 @@ dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "hyper 0.10.16 (registry+https://github.com/rust-lang/crates.io-index)", "native-tls 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-reactor 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-tls 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -7776,7 +7841,7 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -7834,8 +7899,8 @@ dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", "httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", - "mio-extras 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)", + "mio-extras 2.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "sha-1 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -7889,8 +7954,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "zeroize" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "zeroize_derive 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "zeroize_derive" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", + "synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "zstd" @@ -7905,7 +7984,7 @@ name = "zstd-safe" version = "2.0.3+zstd.1.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", "zstd-sys 1.4.15+zstd.1.4.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -7914,9 +7993,9 @@ name = "zstd-sys" version = "1.4.15+zstd.1.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)", "glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", ] [metadata] @@ -7925,13 +8004,13 @@ dependencies = [ "checksum aes-ctr 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d2e5b0458ea3beae0d1d8c0f3946564f8e10f90646cf78c06b4351052058d1ee" "checksum aes-soft 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cfd7e7ae3f9a1fb5c03b389fc6bb9a51400d0c13053f0dca698c832bfd893a0d" "checksum aesni 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f70a6b5f971e473091ab7cfb5ffac6cde81666c4556751d8d5620ead8abf100" -"checksum ahash 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)" = "2f00e10d4814aa20900e7948174384f79f1317f24f0ba7494e735111653fc330" +"checksum ahash 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "6f33b5018f120946c1dcf279194f238a9f146725593ead1c08fa47ff22b0b5d3" "checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d" "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" "checksum ansi_term 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" -"checksum anyhow 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)" = "57114fc2a6cc374bce195d3482057c846e706d252ff3604363449695684d7a0d" +"checksum anyhow 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "9267dff192e68f3399525901e709a48c1d3982c9c072fa32f2127a0cb0babf14" "checksum app_dirs 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e73a24bad9bd6a94d6395382a6c69fe071708ae4409f763c5475e14ee896313d" -"checksum arc-swap 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f1a1eca3195b729bbd64e292ef2f5fff6b1c28504fed762ce2b1013dde4d8e92" +"checksum arc-swap 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d7b8a9123b8027467bce0099fe556c628a53c8d83df0507084c31e9ba2e39aff" "checksum arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0d382e583f07208808f6b1249e60848879ba3543f57c32277bf52d69c2f0f0ee" "checksum arrayvec 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "cd9fd44efafa8690358b7408d253adf110036b88f55672a933f01d616ad9b1b9" "checksum arrayvec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8" @@ -7939,7 +8018,7 @@ dependencies = [ "checksum asn1_der_derive 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0d0864d84b8e07b145449be9a8537db86bf9de5ce03b913214694643b4743502" "checksum assert_matches 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7deb0a829ca7bcfaf5da70b073a8d128619259a7be8216a355e23f00763059e5" "checksum async-macros 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "644a5a8de80f2085a1e7e57cd1544a2a7438f6e003c0790999bd43b92a77cdb2" -"checksum async-std 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "56933da6903b273923d13f4746d829f66ff9b444173f6743d831e80f4da15446" +"checksum async-std 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "513ee3c49800679a319912340f5601afda9e72848d7dea3a48bab489e8c1a46f" "checksum async-task 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "de6bd58f7b9cc49032559422595c81cbfcf04db2f2133592f70af19e258a1ced" "checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" "checksum autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" @@ -7950,10 +8029,10 @@ dependencies = [ "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 bindgen 0.49.2 (registry+https://github.com/rust-lang/crates.io-index)" = "846a1fba6535362a01487ef6b10f0275faa12e5c5d835c5c1c627aabc46ccbd6" +"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" -"checksum bitvec 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9633b74910e1870f50f5af189b08487195cdb83c0e27a71d6f64d5e09dd0538b" +"checksum bitvec 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a993f74b4c99c1908d156b8d2e0fb6277736b0ecbd833982fd1241d39b2766a6" "checksum blake2 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "94cb07b0da6a73955f8fb85d24c466778e70cda767a568229b104f0264089330" "checksum blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6d530bdd2d52966a6d03b7a964add7ae1a288d25214066fd4b600f0f796400" "checksum blake2b_simd 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b83b7baab1e671718d78204225800d6b170e648188ac7dc992e9d6bddf87d0c0" @@ -7961,6 +8040,7 @@ dependencies = [ "checksum block-cipher-trait 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1c924d49bd09e7c06003acda26cd9742e796e34282ec6c1189404dee0c1f4774" "checksum block-padding 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" "checksum broadcaster 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "07a1446420a56f1030271649ba0da46d23239b3a68c73591cea5247f15a788a0" +"checksum bs58 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "c95ee6bba9d950218b6cc910cf62bc9e0a171d0f4537e3627b0f54d08549b188" "checksum bs58 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b170cd256a3f9fa6b9edae3e44a7dfdfc77e8124dbc3e2612d75f9c3e2396dae" "checksum bstr 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8d6c2c5b58ab920a4f5aeaaca34b4488074e8cc7596af94e6f8c6ff247c60245" "checksum build-helper 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bdce191bf3fa4995ce948c8c83b4640a1745457a149e73c6db75b4ffe36aad5f" @@ -7973,12 +8053,12 @@ dependencies = [ "checksum bytes 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1c85319f157e4e26c703678e68e26ab71a46c0199286fa670b21cc9fec13d895" "checksum c2-chacha 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "214238caa1bf3a496ec3392968969cab8549f96ff30652c9e56885329315f6bb" "checksum c_linked_list 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4964518bd3b4a8190e832886cdc0da9794f12e8e6c1613a9e90ff331c4c8724b" -"checksum cargo_metadata 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8d2d1617e838936c0d2323a65cc151e03ae19a7678dd24f72bccf27119b90a5d" -"checksum cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "926013f2860c46252efceabb19f4a6b308197505082c609025aa6706c011d427" -"checksum cc 1.0.47 (registry+https://github.com/rust-lang/crates.io-index)" = "aa87058dce70a3ff5621797f1506cb837edd02ac4c0ae642b4542dce802908b8" +"checksum cargo_metadata 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "46e3374c604fb39d1a2f35ed5e4a4e30e60d01fab49446e08f1b3e9a90aef202" +"checksum cast 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4b9434b9a5aa1450faa3f9cb14ea0e8c53bb5d2b3c1bfd1ab4fc03e9f33fbfb0" +"checksum cc 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)" = "f52a465a666ca3d838ebbf08b241383421412fe7ebb463527bba275526d89f76" "checksum cexpr 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "fce5b5fb86b0c57c20c834c1b412fd09c77c8a59b9473f86272709e78874cd1d" "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" -"checksum chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e8493056968583b0193c1bb04d6f7684586f3726992d6c573261941a895dbd68" +"checksum chrono 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "31850b4a4d6bae316f7a09e691c944c28299298837edc0a03f755618c23cbc01" "checksum clang-sys 0.28.1 (registry+https://github.com/rust-lang/crates.io-index)" = "81de550971c976f176130da4b2978d3b524eaa0fd9ac31f3ceb5ae1231fb4853" "checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" "checksum clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "97276801e127ffb46b66ce23f35cc96bd454fa311294bced4bbace7baa8b1d17" @@ -8009,6 +8089,7 @@ dependencies = [ "checksum crossbeam-deque 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c3aa945d63861bfe624b55d153a39684da1e8c0bc8fba932f7ee3a3c16cea3ca" "checksum crossbeam-epoch 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5064ebdbf05ce3cb95e45c8b086f72263f4166b29b97f6baff7ef7fe047b55ac" "checksum crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c979cd6cfe72335896575c6b5688da489e420d36a27a0b9eb0c73db574b4a4b" +"checksum crossbeam-queue 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dfd6515864a82d2f877b42813d4553292c6659498c9a2aa31bab5a15243c2700" "checksum crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6" "checksum crossbeam-utils 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ce446db02cdc3165b94ae73111e570793400d0794e46125cc4056c81cbb039f4" "checksum crunchy 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" @@ -8031,14 +8112,14 @@ dependencies = [ "checksum doc-comment 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "923dea538cea0aa3025e8685b20d6ee21ef99c4f77e954a30febbaac5ec73a97" "checksum ed25519-dalek 1.0.0-pre.2 (registry+https://github.com/rust-lang/crates.io-index)" = "845aaacc16f01178f33349e7c992ecd0cee095aa5e577f0f4dee35971bd36455" "checksum either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" -"checksum elastic-array 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "073be79b6538296faf81c631872676600616073817dd9a440c477ad09b408983" +"checksum elastic-array 0.10.3 (registry+https://github.com/rust-lang/crates.io-index)" = "580f3768bd6465780d063f5b8213a2ebd506e139b345e4a81eb301ceae3d61e1" "checksum env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3" "checksum env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" "checksum environmental 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "34f8467a0284de039e6bd0e25c14519538462ba5beb548bb1f03e645097837a8" "checksum erased-serde 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3beee4bc16478a1b26f2e80ad819a52d24745e292f521a63c16eea5f74b7eb60" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" -"checksum evm 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1138816a9b7f9a9d1fcabb1b8a7afed2687d035692baf297bd3fea122acdc96f" +"checksum evm 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "32a2c6961fdc9952371fc5f0416f03a9d90378a9dfb6862f6a7a9a3b8986b8dd" "checksum evm-core 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3bcde5af3d542874ddeb53de0919302d57586ea04b3f76f54d865f8a6cdc70ae" "checksum evm-gasometer 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b82bc9f275cb59d2bcc05d85c98736ddfaba003a7ef7b73893fa7c1c1fab29dc" "checksum evm-runtime 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0dbbc89d29618c3722c17ba78ddf432d40ace8ee27e3f8b28b52a85921112e4b" @@ -8089,7 +8170,7 @@ dependencies = [ "checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" "checksum glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" "checksum globset 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "925aa2cac82d8834e2b2a4415b6f6879757fb5c0928fc445ae76461a12eed8f2" -"checksum goblin 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5e6040506480da04a63de51a478e8021892d65d8411f29b2a422c2648bdd8bcb" +"checksum goblin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "88a79ef1f0dad46fd78075b6f80f92d97710eddf87b3e18a15a66761e8942672" "checksum h2 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)" = "a5b34c246847f938a410a03c5458c7fee2274436675e76d8b903c08efc29c462" "checksum h2 0.2.0-alpha.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0f107db1419ef8271686187b1a5d47c6431af4a7f4d98b495e7b7fc249bb0a78" "checksum hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d23bd4e7b5eda0d0f3a307e8b381fdc8ba9000f26fbe912250c0a4cc3956364a" @@ -8104,7 +8185,7 @@ dependencies = [ "checksum hex-literal-impl 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9d4c5c844e2fee0bf673d54c2c177f1713b3d2af2ff6e666b49cb7572e6cf42d" "checksum hmac 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5dcb5e64cda4c23119ab41ba960d1e170a774c8e4b9d9e6a9bc18aabf5e59695" "checksum hmac-drbg 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c6e570451493f10f6581b48cdd530413b63ea9e780f544bfd3bdcaa0d89d1a7b" -"checksum http 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)" = "d7e06e336150b178206af098a055e3621e8336027e2b4d126bda0bc64824baaf" +"checksum http 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)" = "d6ccf5ede3a895d8856620237b2f02972c1bbc78d2965ad7fe8838d4a0ed41f0" "checksum http-body 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6741c859c1b2463a423a1dbce98d418e6c3c3fc720fb0d45528657320920292d" "checksum http-body 0.2.0-alpha.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1f3aef6f3de2bd8585f5b366f3f550b5774500b4764d00cf00f903c95749eec3" "checksum httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" @@ -8125,18 +8206,18 @@ dependencies = [ "checksum interleaved-ordered 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "141340095b15ed7491bd3d4ced9d20cebfb826174b6bb03386381f62b01e3d77" "checksum iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" "checksum ipnet 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f2f4b06b21db0228860c8dfd17d2106c49c7c6bd07477a4036985347d84def04" -"checksum itertools 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "87fa75c9dea7b07be3138c49abbb83fd4bea199b5cdc76f9804458edc5da0d6e" +"checksum itertools 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f56a2d0bc861f9165be4eb3442afd3c236d8a98afd426f65d92324ae1091a484" "checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" "checksum jobserver 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "f2b1d42ef453b30b7387e113da1c83ab1605d90c5b4e0eb8e96d016ed3b8c160" -"checksum js-sys 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)" = "d8657b7ca06a6044ece477f6900bf7670f8b5fd0cce177a1d7094eef51e0adf4" -"checksum jsonrpc-client-transports 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d389a085cb2184604dff060390cadb8cba1f063c7fd0ad710272c163c88b9f20" -"checksum jsonrpc-core 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "34651edf3417637cc45e70ed0182ecfa9ced0b7e8131805fccf7400d989845ca" -"checksum jsonrpc-core-client 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9dbaec1d57271ff952f24ca79d37d716cfd749c855b058d9aa5f053a6b8ae4ef" -"checksum jsonrpc-derive 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d5d5c31575cc70a8b21542599028472c80a9248394aeea4d8918a045a0ab08a3" -"checksum jsonrpc-http-server 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "aa54c4c2d88cb5e04b251a5031ba0f2ee8c6ef30970e31228955b89a80c3b611" -"checksum jsonrpc-pubsub 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3ee1b8da0b9219a231c4b7cbc7110bfdb457cbcd8d90a6224d0b3cab8aae8443" -"checksum jsonrpc-server-utils 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "87bc3c0a9a282211b2ec14abb3e977de33016bbec495332e9f7be858de7c5117" -"checksum jsonrpc-ws-server 14.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "af36a129cef77a9db8028ac7552d927e1bb7b6928cd96b23dd25cc38bff974ab" +"checksum js-sys 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)" = "1c840fdb2167497b0bd0db43d6dfe61e91637fa72f9d061f8bd17ddc44ba6414" +"checksum jsonrpc-client-transports 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0a9ae166c4d1f702d297cd76d4b55758ace80272ffc6dbb139fdc1bf810de40b" +"checksum jsonrpc-core 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fe3b688648f1ef5d5072229e2d672ecb92cbff7d1c79bcf3fd5898f3f3df0970" +"checksum jsonrpc-core-client 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "080dc110be17701097df238fad3c816d4a478a1899dfbcf8ec8957dd40ec7304" +"checksum jsonrpc-derive 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8609af8f63b626e8e211f52441fcdb6ec54f1a446606b10d5c89ae9bf8a20058" +"checksum jsonrpc-http-server 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "2d83d348120edee487c560b7cdd2565055d61cda053aa0d0ef0f8b6a18429048" +"checksum jsonrpc-pubsub 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3453625f0f0f5cd6d6776d389d73b7d70fcc98620b7cbb1cbbb1f6a36e95f39a" +"checksum jsonrpc-server-utils 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "95b7635e618a0edbbe0d2a2bbbc69874277c49383fcf6c3c0414491cfb517d22" +"checksum jsonrpc-ws-server 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "b34faa167c3ac9705aeecb986c0da6056529f348425dbe0441db60a2c4cc41d1" "checksum keccak 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7" "checksum keccak-hasher 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3468207deea1359a0e921591ae9b4c928733d94eb9d6a2eeda994cfd59f42cf8" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" @@ -8147,20 +8228,20 @@ dependencies = [ "checksum language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a" "checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" "checksum lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" -"checksum libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)" = "1a31a0627fdf1f6a39ec0dd577e101440b7db22672c0901fe00a9a6fbb5c24e8" +"checksum libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)" = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558" "checksum libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753" -"checksum libp2p 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9aa3d728b96c06763b2e919b4c99a334d698303c49489671b5ffe3a4b0fd4c9c" -"checksum libp2p-core 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "07759706a4cb4a90903c67d92cb9575acd8df90f583dfdc46d57afdeaead4c82" +"checksum libp2p 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8fab3090cd3af0f0ff5e6c2cc0f6fe6607e9f9282680cf7cd3bdd4cda38ea722" +"checksum libp2p-core 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4a3def059145c191b6975e51784d5edc59e77e1ed5b25402fccac704dd7731f3" "checksum libp2p-core-derive 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1eeb2704ac14c60f31967e351ed928b848526a5fc6db4104520020665012826f" "checksum libp2p-deflate 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ef2b0bf5d37692ac90e2bffa436bec26c0b0def6c0cab7ea85ff67a353d58aaa" "checksum libp2p-dns 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e3175fb0fc9016c95c8517a297bbdb5fb6bfbd5665bacd2eb23495d1cbdeb033" "checksum libp2p-floodsub 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "92c11b95281e8cb87eb83c204b3ca4988fa665ed9351199b5bcc323056f49816" -"checksum libp2p-identify 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4eba6103329e9a1a2aa940671efe5600c758a295e61172139d7a900166da0017" -"checksum libp2p-kad 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "84ceb0faa267b96560ef883dc5bc6dddd9de1662e35a4070208623b391deefca" -"checksum libp2p-mdns 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ab1eec2958fc74883ed8ecb0c38324941a44195a58fea87fcfc2bd17da34d1fa" +"checksum libp2p-identify 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b4e4b0b4bcf410f77361b08335022d5705df34970dc1744ff58d4bb902309547" +"checksum libp2p-kad 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7fd25360fc12b23edb1ed13f73426325a38d32e0927a46fec26ddb6873d7644d" +"checksum libp2p-mdns 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c4c2e225a7dfc571c3ad77a0a5ecccc9537afe42d72289ac9f19768567cd677d" "checksum libp2p-mplex 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2fe584816d993dc0f893396521a3c93191d78a6f28a892b150baa714a12c3e5" "checksum libp2p-noise 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a30ec2640262a7ad6b1a8b28f6cd8281e620a6802f700adf9ff26e61487c333a" -"checksum libp2p-ping 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e4e1682cdae649394d2793758ded2bfd4d9d440f807e3b4d9f70981f377aa28a" +"checksum libp2p-ping 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5b975ad345eb9bb29ddc64670664a50a8ab3e66e28357abb0f83cfc0a9ca2d78" "checksum libp2p-plaintext 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7f4fe82189f5c20e8f0a11deaa04d492703c501cefd2428ad68f4f64aefab76f" "checksum libp2p-secio 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7ee09e259ceb7633a52fd17f187bedf94e3545b1746487beedbd3a0a07d99817" "checksum libp2p-swarm 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cd55bc9f5f9eac2bb1ff24ca3c8a655810a566ac38c7a6ee1f30aced5a62905b" @@ -8176,23 +8257,23 @@ dependencies = [ "checksum linked_hash_set 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3c7c91c4c7bbeb4f2f7c4e5be11e6a05bd6830bc37249c47ce1ad86ad453ff9c" "checksum lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c" "checksum lock_api 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ed946d4529956a20f2d63ebe1b69996d5a2137c91913fe3ebbeff957f5bca7ff" -"checksum lock_api 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f8912e782533a93a167888781b836336a6ca5da6175c05944c86cf28c31104dc" +"checksum lock_api 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e57b3997725d2b60dbec1297f6c2e2957cc383db1cebd6be812163f969c7d586" "checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" "checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" -"checksum lru 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "26b0dca4ac5b5083c5169ab12205e6473df1c7659940e4978b94f363c6b54b22" +"checksum lru 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9a57ada89b072a15fa9e1b9d1e18d0e161fd25a47e0a3ae4868cf53aada8ba97" "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" "checksum malloc_size_of_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e37c5d4cd9473c5f4c9c111f033f15d4df9bd378fdf615944e360a4f55a05f0b" "checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" "checksum maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" "checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e" "checksum memoffset 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "75189eb85871ea5c2e2c15abbdd541185f63b408415e5051f5cac122d8c774b9" -"checksum memory-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ef49315991403ba5fa225a70399df5e115f57b274cb0b1b4bcd6e734fa5bd783" +"checksum memory-db 0.15.3 (registry+https://github.com/rust-lang/crates.io-index)" = "5dabfe0a8c69954ae3bcfc5fc14260a85fb80e1bf9f86a155f668d10a67e93dd" "checksum memory_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "71d96e3f3c0b6325d8ccd83c33b28acb183edcb6c67938ba104ec546854b0882" -"checksum merlin 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "de2d16d3b15fec5943d1144f861f61f279d165fdd60998ca262913b9bf1c8adb" +"checksum merlin 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2b0942b357c1b4d0dc43ba724674ec89c3218e6ca2b3e8269e7cb53bcecd2f6e" "checksum mime 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ba626b8a6de5da682e1caa06bdb42a335aee5a84db8e5046a3e8ab17ba0a3ae0" "checksum miniz_oxide 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6f3f74f726ae935c3f514300cc6773a0c9492abc5e972d42ba0c0ebb88757625" -"checksum mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)" = "83f51996a3ed004ef184e16818edc51fadffe8e7ca68be67f9dee67d84d0ff23" -"checksum mio-extras 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "46e73a04c2fa6250b8d802134d56d554a9ec2922bf977777c805ea5def61ce40" +"checksum mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)" = "302dec22bcf6bae6dfb69c647187f4b4d0fb6f535521f7bc022430ce8e12008f" +"checksum mio-extras 2.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "52403fe290012ce777c4626790c8951324a2b9e3316b3143779c72b029742f19" "checksum mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "966257a94e196b11bb43aca423754d87429960a768de9414f3691d6957abf125" "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" "checksum more-asserts 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0debeb9fcf88823ea64d64e4a815ab1643f33127d995978e099942ce38f25238" @@ -8208,23 +8289,25 @@ dependencies = [ "checksum num-bigint 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f9c3f34cdd24f334cb265d9bf8bfa8a241920d026916785747a92f0e55541a1a" "checksum num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "b85e541ef8255f6cf42bbfe4ef361305c6c135d10919ecc26126c4e5ae94bc09" "checksum num-rational 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f2885278d5fe2adc2f75ced642d52d879bffaceb5a2e0b1d4309ffdfb239b454" -"checksum num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "6ba9a427cfca2be13aa6f6403b0b7e7368fe982bfa16fccc450ce74c46cd9b32" +"checksum num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c81ffc11c212fa327657cb19dd85eb7419e163b5b076bede2bdb5c974c07e4" "checksum num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "76dac5ed2a876980778b8b85f75a71b6cbf0db0b1232ee12f826bccb00d09d72" "checksum ole32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5d2c49021782e5233cd243168edfa8037574afed4eba4bbaf538b3d8d1789d8c" "checksum once_cell 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "532c29a261168a45ce28948f9537ddd7a5dd272cc513b3017b1e82a88f962c37" "checksum once_cell 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d584f08c2d717d5c23a6414fc2822b71c651560713e54fa7eace675f758a355e" "checksum once_cell 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "891f486f630e5c5a4916c7e16c4b24a53e78c860b646e9f8e005e4f16847bfed" "checksum opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" -"checksum openssl 0.10.25 (registry+https://github.com/rust-lang/crates.io-index)" = "2f372b2b53ce10fb823a337aaa674e3a7d072b957c6264d0f4ff0bd86e657449" +"checksum openssl 0.10.26 (registry+https://github.com/rust-lang/crates.io-index)" = "3a3cc5799d98e1088141b8e01ff760112bbd9f19d850c124500566ca6901a585" "checksum openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" -"checksum openssl-sys 0.9.52 (registry+https://github.com/rust-lang/crates.io-index)" = "c977d08e1312e2f7e4b86f9ebaa0ed3b19d1daff75fae88bbb88108afbd801fc" +"checksum openssl-sys 0.9.53 (registry+https://github.com/rust-lang/crates.io-index)" = "465d16ae7fc0e313318f7de5cecf57b2fbe7511fd213978b457e1c96ff46736f" "checksum output_vt100 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "53cdc5b785b7a58c5aad8216b3dfa114df64b0b06ae6e1501cef91df2fbdf8f9" "checksum owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "49a4b8ea2179e6a2e27411d3bca09ca6dd630821cf6894c6c7c8467a8ee7ef13" "checksum parity-bytes 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0c276d76c5333b8c2579e02d49a06733a55b8282d2d9b13e8d53b6406bd7e30a" -"checksum parity-multiaddr 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7dbc379f41150dedda75cbbdb5b9beb2bf786a07e56c2c99ec89aeaaa894662c" -"checksum parity-multihash 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "340ed03f939e02e4cb71a5a127b5507ba4dab506e41a05f8f467e28d8ce529f4" -"checksum parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "001fbbb956d8593f321c7a784f64d16b2c99b2657823976eea729006ad2c3668" -"checksum parity-scale-codec-derive 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "42af752f59119656fa3cb31e8852ed24e895b968c0bdb41847da7f0cea6d155f" +"checksum parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "045b3c7af871285146300da35b1932bb6e4639b66c7c98e85d06a32cbc4e8fa7" +"checksum parity-multiaddr 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "82afcb7461eae5d122543d8be1c57d306ed89af2d6ff7f8b0f5a3cc8f7e511bc" +"checksum parity-multihash 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "df3a17dc27848fd99e4f87eb0f8c9baba6ede0a6d555400c850ca45254ef4ce3" +"checksum parity-multihash 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c70cad855872dd51ce6679e823efb6434061a2c1782a1686438aabf506392cdd" +"checksum parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f9f9d99dae413590a5f37e43cd99b94d4e62a244160562899126913ea7108673" +"checksum parity-scale-codec-derive 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "492ac3aa93d6caa5d20e4e3e0b75d08e2dcd9dd8a50d19529548b6fe11b3f295" "checksum parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aa9777aa91b8ad9dd5aaa04a9b6bcb02c7f1deb952fca5a66034d5e63afc5c6f" "checksum parity-util-mem 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "570093f39f786beea92dcc09e45d8aae7841516ac19a50431953ac82a0e8f85c" "checksum parity-wasm 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "16ad52817c4d343339b3bc2e26861bd21478eda0b7509acf83505727000512ac" @@ -8288,8 +8371,8 @@ dependencies = [ "checksum rand_xoshiro 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "03b418169fb9c46533f326efd6eed2576699c44ca92d3052a066214a8d828929" "checksum rand_xoshiro 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0e18c91676f670f6f0312764c759405f13afb98d5d73819840cf72a518487bff" "checksum raw-cpuid 7.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4a349ca83373cfa5d6dbb66fd76e58b2cca08da71a5f6400de0a0a6a9bceeaf" -"checksum rayon 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "83a27732a533a1be0a0035a111fe76db89ad312f6f0347004c220c57f209a123" -"checksum rayon-core 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "98dcf634205083b17d0861252431eb2acbfb698ab7478a2d20de07954f47ec7b" +"checksum rayon 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "43739f8831493b276363637423d3622d4bd6394ab6f0a9c4a552e208aeb7fddd" +"checksum rayon-core 1.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f8bf17de6f23b05473c437eb958b9c850bfc8af0961fe17b4cc92d5a627b4791" "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" "checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" "checksum redox_users 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4ecedbca3bf205f8d8f5c2b44d83cd0690e39ee84b951ed649e9f1841132b66d" @@ -8300,9 +8383,9 @@ dependencies = [ "checksum region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "448e868c6e4cfddfa49b6a72c95906c04e8547465e9536575b95c70a4044f856" "checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" "checksum ring 0.16.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6747f8da1f2b1fabbee1aaa4eb8a11abf9adef0bf58a41cee45db5d59cecdfac" -"checksum rlp 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8376a3f725ebb53f69263bbebb42196361fdfd551212409c8a721239aab4f09f" +"checksum rlp 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3a44d5ae8afcb238af8b75640907edc6c931efcfab2c854e81ed35fa080f84cd" "checksum rocksdb 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "12069b106981c6103d3eab7dd1c86751482d0779a520b7c14954c8b586c1e643" -"checksum rpassword 4.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f072d931f11a96546efd97642e1e75e807345aced86b947f9239102f262d0fcd" +"checksum rpassword 4.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d59f0e97173c514b9036cd450c195a6483ba81055c6fa0f1bff3ab563f47d44a" "checksum rust-argon2 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4ca4eaef519b494d1f2848fc602d18816fed808a981aedf4f1f00ceb7c9d32cf" "checksum rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" "checksum rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "403bb3a286107a04825a5f82e1270acc1e14028d3d554d7a1e08914549575ab8" @@ -8321,7 +8404,7 @@ dependencies = [ "checksum scroll 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "abb2332cb595d33f7edd5700f4cbf94892e680c7f0ae56adab58a35190b66cb1" "checksum scroll_derive 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f8584eea9b9ff42825b46faf46a8c24d2cff13ec152fa2a50df788b87c07ee28" "checksum sct 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e3042af939fca8c3453b7af0f1c66e533a15a86169e39de2657310ade8f98d3c" -"checksum security-framework 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "301c862a6d0ee78f124c5e1710205965fc5c553100dcda6d98f13ef87a763f04" +"checksum security-framework 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8ef2429d7cefe5fd28bd1d2ed41c944547d4ff84776f5935b456da44593a16df" "checksum security-framework-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e31493fc37615debb8c5090a7aeb4a9730bc61e77ab10b9af59f1a202284f895" "checksum semver 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a3186ec9e65071a2095434b1f5bb24838d4e8e130f584c790f6033c79943537" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" @@ -8329,7 +8412,7 @@ dependencies = [ "checksum send_wrapper 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a0eddf2e8f50ced781f288c19f18621fa72a3779e3cb58dbf23b07469b0abeb4" "checksum serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)" = "1217f97ab8e8904b57dd22eb61cde455fa7446a9c1cf43966066da047c1f3702" "checksum serde_derive 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)" = "a8c6faef9a2e64b0064f48570289b4bf8823b7581f1d6157c1b52152306651d0" -"checksum serde_json 1.0.42 (registry+https://github.com/rust-lang/crates.io-index)" = "1a3351dcbc1f067e2c92ab7c3c1f288ad1a4cffc470b5aaddb4c2e0a3ae80043" +"checksum serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)" = "48c575e0cc52bdd09b47f330f646cf59afc586e9c4e3ccd6fc1f625b8ea1dad7" "checksum sha-1 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "23962131a91661d643c98940b20fcaffe62d776a823247be80a48fcb8b6fce68" "checksum sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" "checksum sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b4d8bfd0e469f417657573d8451fb33d16cfe0989359b93baf3a1ffc639543d" @@ -8344,7 +8427,7 @@ dependencies = [ "checksum slog_derive 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a945ec7f7ce853e89ffa36be1e27dce9a43e82ff9093bf3461c30d5da74ed11b" "checksum smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "f7b0758c52e15a8b5e3691eae6cc559f08eee9406e548a4477ba4e67770a82b6" "checksum smallvec 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ecf3b85f68e8abaa7555aa5abdb1153079387e60b718283d732f03897fcfc86" -"checksum snow 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "91eecae35b461ed26bda7a76bea2cc5bda2bf4b8dd06761879f19e6fdd50c2dd" +"checksum snow 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "afb767eee7d257ba202f0b9b08673bc13b22281632ef45267b19f13100accd2f" "checksum soketto 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bceb1a3a15232d013d9a3b7cac9e5ce8e2313f348f01d4bc1097e5e53aa07095" "checksum sourcefile 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4bf77cb82ba8453b42b6ae1d692e4cdc92f9a47beaf89a847c8be83f4e328ad3" "checksum spin 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" @@ -8354,16 +8437,16 @@ dependencies = [ "checksum string 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d24114bfcceb867ca7f71a0d3fe45d45619ec47a6fbfa98cb14e14250bfa5d6d" "checksum string-interner 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd710eadff449a1531351b0e43eb81ea404336fa2f56c777427ab0e32a4cf183" "checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" -"checksum structopt 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c167b61c7d4c126927f5346a4327ce20abf8a186b8041bbeb1ce49e5db49587b" -"checksum structopt-derive 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "519621841414165d2ad0d4c92be8f41844203f2b67e245f9345a5a12d40c69d7" +"checksum structopt 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "30b3a3e93f5ad553c38b3301c8a0a0cec829a36783f6a0c467fc4bf553a5f5bf" +"checksum structopt-derive 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea692d40005b3ceba90a9fe7a78fa8d4b82b0ce627eebbffc329aab850f3410e" "checksum strum 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6138f8f88a16d90134763314e3fc76fa3ed6a7db4725d6acf9a3ef95a3188d22" "checksum strum_macros 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0054a7df764039a6cd8592b9de84be4bec368ff081d203a7d5371cbfa8e65c81" "checksum substrate-bip39 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3be511be555a3633e71739a79e4ddff6a6aaa6579fa6114182a51d72c3eb93c5" "checksum subtle 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" -"checksum subtle 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ab3af2eb31c42e8f0ccf43548232556c42737e01a96db6e1777b0be108e79799" +"checksum subtle 2.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c65d530b10ccaeac294f349038a597e435b18fb456aadd0840a623f83b9e941" "checksum syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)" = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" -"checksum syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "661641ea2aa15845cddeb97dad000d22070bb5c1fb456b96c1cba883ec691e92" -"checksum synstructure 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "575be94ccb86e8da37efb894a87e2b660be299b41d8ef347f9d6d79fbe61b1ba" +"checksum syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)" = "dff0acdb207ae2fe6d5976617f887eb1e35a2ba52c13c7234c790960cdad9238" +"checksum synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545" "checksum sysinfo 0.9.6 (registry+https://github.com/rust-lang/crates.io-index)" = "6f4b2468c629cffba39c0a4425849ab3cdb03d9dfacba69684609aea04d08ff9" "checksum take_mut 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60" "checksum target-lexicon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6f4c118a7a38378f305a9e111fcb2f7f838c0be324bfb31a77ea04f7f6e684b4" @@ -8372,8 +8455,8 @@ dependencies = [ "checksum termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "96d6098003bde162e4277c70665bd87c326f5a0c3f3fbfb285787fa482d54e6e" "checksum test-case 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a605baa797821796a751f4a959e1206079b24a4b7e1ed302b7d785d81a9276c9" "checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -"checksum thiserror 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f9fb62ff737e573b1e677459bea6fd023cd5d6e868c3242d3cdf3ef2f0554824" -"checksum thiserror-impl 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "24069c0ba08aab54289d6a25f5036d94afc61e1538bbc42ae5501df141c9027d" +"checksum thiserror 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6f357d1814b33bc2dc221243f8424104bfe72dbe911d5b71b3816a2dff1c977e" +"checksum thiserror-impl 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "eb2e25d25307eb8436894f727aba8f65d07adf02e5b35a13cebed48bd282bfef" "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" "checksum threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e2f0c90a5f3459330ac8bc0d2f879c693bb7a2f59689c1083fc4ef83834da865" "checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" @@ -8382,24 +8465,24 @@ dependencies = [ "checksum tiny-keccak 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2953ca5148619bc99695c1274cb54c5275bbb913c6adad87e72eaf8db9787f69" "checksum tinytemplate 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4574b75faccaacddb9b284faecdf0b544b80b6b294f3d062d325c5726a209c20" "checksum tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)" = "5a09c0b5bb588872ab2f09afa13ee6e9dac11e10a0ec9e8e3ba39a5a5d530af6" -"checksum tokio 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2e765bf9f550bd9b8a970633ca3b56b8120c4b6c5dcbe26a93744cb02fee4b17" +"checksum tokio 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "bcced6bb623d4bff3739c176c415f13c418f426395c169c9c3cd9a492c715b16" "checksum tokio-buf 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8fb220f46c53859a4b7ec083e41dec9778ff0b1851c0942b211edb89e0ccdc46" "checksum tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5c501eceaf96f0e1793cf26beb63da3d11c738c4a943fdf3746d81d64684c39f" "checksum tokio-codec 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9f5d22fd1e84bd4045d28813491cb7d7caae34d45c80517c2213f09a85e8787a" "checksum tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "d16217cad7f1b840c5a97dfb3c43b0c871fef423a6e8d2118c604e843662a443" "checksum tokio-dns-unofficial 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "82c65483db54eb91b4ef3a9389a3364558590faf30ce473141707c0e16fda975" -"checksum tokio-executor 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "0f27ee0e6db01c5f0b2973824547ce7e637b2ed79b891a9677b0de9bd532b6ac" +"checksum tokio-executor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "ca6df436c42b0c3330a82d855d2ef017cd793090ad550a6bc2184f4b933532ab" "checksum tokio-executor 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9ee9ceecf69145923834ea73f32ba40c790fd877b74a7817dd0b089f1eb9c7c8" "checksum tokio-fs 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "3fe6dc22b08d6993916647d108a1a7d15b9cd29c4f4496c62b92c45b5041b7af" "checksum tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "5090db468dad16e1a7a54c8c67280c5e4b544f3d3e018f0b913b400261f85926" "checksum tokio-io 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)" = "112784d5543df30660b04a72ca423bfbd90e8bb32f94dcf610f15401218b22c5" -"checksum tokio-reactor 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "c56391be9805bc80163151c0b9e5164ee64f4b0200962c346fea12773158f22d" +"checksum tokio-reactor 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "6732fe6b53c8d11178dcb77ac6d9682af27fc6d4cb87789449152e5377377146" "checksum tokio-rustls 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1df2fa53ac211c136832f530ccb081af9af891af22d685a9493e232c7a359bc2" "checksum tokio-sync 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "d06554cce1ae4a50f42fba8023918afa931413aded705b560e29600ccf7c6d76" "checksum tokio-sync 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)" = "4f1aaeb685540f7407ea0e27f1c9757d258c7c6bf4e3eb19da6fc59b747239d2" "checksum tokio-tcp 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1d14b10654be682ac43efee27401d792507e30fd8d26389e1da3b185de2e4119" -"checksum tokio-threadpool 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "2bd2c6a3885302581f4401c82af70d792bb9df1700e7437b0aeb4ada94d5388c" -"checksum tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "f2106812d500ed25a4f38235b9cae8f78a09edf43203e16e59c3b769a342a60e" +"checksum tokio-threadpool 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "f0c32ffea4827978e9aa392d2f743d973c1dfa3730a2ed3f22ce1e6984da848c" +"checksum tokio-timer 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)" = "1739638e364e558128461fc1ad84d997702c8e31c2e6b18fb99842268199e827" "checksum tokio-tls 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "354b8cd83825b3c20217a9dc174d6a0c67441a2fae5c41bcb1ea6679f6ae0f7c" "checksum tokio-udp 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f02298505547f73e60f568359ef0d016d5acd6e830ab9bc7c4a5b3403440121b" "checksum tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "037ffc3ba0e12a0ab4aca92e5234e0dedeb48fddf6ccd260f1f150a36a9f2445" @@ -8415,25 +8498,25 @@ dependencies = [ "checksum trie-root 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0b779f7c1c8fe9276365d9d5be5c4b5adeacf545117bb3f64c974305789c5c0b" "checksum trie-standardmap 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c3161ba520ab28cd8e6b68e1126f1009f6e335339d1a73b978139011703264c8" "checksum try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382" -"checksum trybuild 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)" = "e6851bf8351876984fbab8a2391de6378947b898410d8714edd12164d2137127" +"checksum trybuild 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)" = "b75e31d624df08744532e935f1d4bfedd319a277d5a162c5b15f6ced59307575" "checksum twofish 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712d261e83e727c8e2dbb75dacac67c36e35db36a958ee504f2164fc052434e1" "checksum twox-hash 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3bfd5b7557925ce778ff9b9ef90e3ade34c524b5ff10e239c69a42d546d2af56" "checksum typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1410f6f91f21d1612654e7cc69193b0334f909dcf2c790c4826254fbb86f8887" "checksum typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6d2783fe2d6b8c1101136184eb41be8b1ad379e4657050b8aaff0c79ee7575f9" "checksum uint 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e75a4cdd7b87b28840dba13c483b9a88ee6bbf16ba5c951ee1ecfcf723078e0d" "checksum unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7f4765f83163b74f957c797ad9253caf97f103fb064d3999aea9568d09fc8a33" -"checksum unicase 2.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2e2e6bd1e59e56598518beb94fd6db628ded570326f0a98c679a304bd9f00150" +"checksum unicase 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" -"checksum unicode-normalization 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "09c8070a9942f5e7cfccd93f490fdebd230ee3c3c9f107cb25bad5351ef671cf" +"checksum unicode-normalization 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b561e267b2326bb4cebfc0ef9e68355c7abe6c6f522aeac2f5bf95d56c59bdcf" "checksum unicode-segmentation 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" -"checksum unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7007dbd421b92cc6e28410fe7362e2e0a2503394908f417b68ec8d1c364c4e20" +"checksum unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" "checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" "checksum unsigned-varint 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a7f0023a96687fe169081e8adce3f65e3874426b7886e9234d490af2dc077959" "checksum untrusted 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "60369ef7a31de49bcb3f6ca728d4ba7300d9a1658f94c727d4cab8c8d9f4aece" "checksum url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a" "checksum url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "75b414f6c464c879d7f9babf951f23bc3743fb7313c081b2e6ca719067ea9d61" -"checksum vcpkg 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "33dd455d0f96e90a75803cfeb7f948768c08d70a6de9a8d2362461935698bf95" +"checksum vcpkg 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3fc439f2794e98976c88a2a2dafce96b930fe8010b0a256b3c2199a773933168" "checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" "checksum vergen 3.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6aba5e34f93dc7051dfad05b98a18e9156f27e7b431fe1d2398cb6061c0a1dba" "checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" @@ -8445,27 +8528,28 @@ dependencies = [ "checksum want 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b6395efa4784b027708f7451087e647ec73cc74f5d9bc2e418404248d679a230" "checksum want 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" "checksum wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b89c3ce4ce14bdc6fb6beaf9ec7928ca331de5df7e5ea278375642a2f478570d" -"checksum wasm-bindgen 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)" = "c4568ae1b4e07ca907b1a4de41174eaa3e5be4066c024475586b7842725f69a9" -"checksum wasm-bindgen-backend 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)" = "5a00cfdce37367770062065fd3abb9278cbae86a0d918cacd0978a7acd51b481" +"checksum wasm-bindgen 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)" = "29ae32af33bacd663a9a28241abecf01f2be64e6a185c6139b04f18b6385c5f2" +"checksum wasm-bindgen-backend 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)" = "1845584bd3593442dc0de6e6d9f84454a59a057722f36f005e44665d6ab19d85" "checksum wasm-bindgen-futures 0.3.27 (registry+https://github.com/rust-lang/crates.io-index)" = "83420b37346c311b9ed822af41ec2e82839bfe99867ec6c54e2da43b7538771c" -"checksum wasm-bindgen-macro 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)" = "7c568f4d3cf6d7c1d72b165daf778fb0d6e09a24f96ac14fc8c4f66a96e86b72" -"checksum wasm-bindgen-macro-support 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)" = "430d12539ae324d16097b399e9d07a6d5ce0173b2a61a2d02346ca7c198daffe" -"checksum wasm-bindgen-shared 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)" = "8ae7167f0bbffd7fac2b12da0fa1f834c1d84671a1ae3c93ac8bde2e97179c39" -"checksum wasm-bindgen-webidl 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)" = "3021567c515a746a64ad0b269d120d46e687c0c95702a4750623db935ae6b5e7" +"checksum wasm-bindgen-macro 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)" = "87fcc747e6b73c93d22c947a6334644d22cfec5abd8b66238484dc2b0aeb9fe4" +"checksum wasm-bindgen-macro-support 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)" = "3dc4b3f2c4078c8c4a5f363b92fcf62604c5913cbd16c6ff5aaf0f74ec03f570" +"checksum wasm-bindgen-shared 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)" = "ca0b78d6d3be8589b95d1d49cdc0794728ca734adf36d7c9f07e6459508bb53d" +"checksum wasm-bindgen-webidl 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)" = "3126356474ceb717c8fb5549ae387c9fbf4872818454f4d87708bee997214bb5" "checksum wasm-gc-api 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d0c32691b6c7e6c14e7f8fd55361a9088b507aa49620fcd06c09b3a1082186b9" "checksum wasm-timer 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "aa3e01d234bb71760e685cfafa5e2c96f8ad877c161a721646356651069e26ac" "checksum wasmi 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bf617d864d25af3587aa745529f7aaa541066c876d57e050c0d0c85c61c92aff" "checksum wasmi-validation 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea78c597064ba73596099281e2f4cfc019075122a65cdda3205af94f0b264d93" -"checksum wasmparser 0.39.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e5083b449454f7de0b15f131eee17de54b5a71dcb9adcf11df2b2f78fad0cd82" +"checksum wasmparser 0.39.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c702914acda5feeeffbc29e4d953e5b9ce79d8b98da4dbf18a77086e116c5470" "checksum wasmtime-debug 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5008729ad53f75020f28fa0d682269335d6f0eac0b3ffafe31f185b2f33aca74" "checksum wasmtime-environ 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a3947662a0b8e05b1418465e64f16de9114f9fec18cc3f56e0ed5aa7737b89d0" "checksum wasmtime-jit 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6ed7922689461a7b5bd0d9c7350cac526c8a520a23b3ffd7f5b446ac51dfc51f" "checksum wasmtime-runtime 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "781d6bb8b346efaa3dc39746386957cd79b8d841e8652ed9b02d77bcf64fb514" -"checksum web-sys 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)" = "ce8e893e021539beb87de8f06e77bdb390a3ab0db4cfeb569c4e377b55ed20de" +"checksum web-sys 0.3.32 (registry+https://github.com/rust-lang/crates.io-index)" = "98405c0a2e722ed3db341b4c5b70eb9fe0021621f7350bab76df93b09b649bbf" "checksum webpki 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d7e664e770ac0110e2384769bcc59ed19e329d81f555916a6e072714957b81b4" "checksum webpki-roots 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a262ae37dd9d60f60dd473d1158f9fbebf110ba7b6a5051c8160460f6043718b" "checksum webpki-roots 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)" = "91cd5736df7f12a964a5067a12c62fa38e1bd8080aff1f80bc29be7c80d19ab4" -"checksum websocket 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b255b190f412e45000c35be7fe9b48b39a2ac5eb90d093d421694e5dae8b335c" +"checksum websocket 0.24.0 (registry+https://github.com/rust-lang/crates.io-index)" = "413b37840b9e27b340ce91b319ede10731de8c72f5bc4cb0206ec1ca4ce581d0" +"checksum websocket-base 0.24.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5e3810f0d00c4dccb54c30a4eee815e703232819dec7b007db115791c42aa374" "checksum weedle 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3bb43f70885151e629e2a19ce9e50bd730fd436cfd4b666894c9ce4de9141164" "checksum which 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b57acb10231b9493c8472b20cb57317d0679a49e0bdbee44b3b803a6473af164" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" @@ -8481,7 +8565,8 @@ dependencies = [ "checksum xdg 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d089681aa106a86fade1b0128fb5daf07d5867a509ab036d99988dec80429a57" "checksum yamux 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2758f29014c1cb7a6e74c1b1160ac8c8203be342d35b73462fc6a13cc6385423" "checksum zeroize 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "45af6a010d13e4cf5b54c94ba5a2b2eba5596b9e46bf5875612d332a1f2b3f86" -"checksum zeroize 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cdc979d9b5ead18184c357c4d8a3f81b579aae264e32507223032e64715462d3" +"checksum zeroize 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3cbac2ed2ba24cc90f5e06485ac8c7c1e5449fe8911aef4d8877218af021a5b8" +"checksum zeroize_derive 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "de251eec69fc7c1bc3923403d18ececb929380e016afe103da75f396704f8ca2" "checksum zstd 0.5.1+zstd.1.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5c5d978b793ae64375b80baf652919b148f6a496ac8802922d9999f5a553194f" "checksum zstd-safe 2.0.3+zstd.1.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "bee25eac9753cfedd48133fa1736cbd23b774e253d89badbeac7d12b23848d3f" "checksum zstd-sys 1.4.15+zstd.1.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "89719b034dc22d240d5b407fb0a3fe6d29952c181cff9a9f95c0bd40b4f8f7d8" diff --git a/Cargo.toml b/Cargo.toml index c3b57affe0..dd424b4d76 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -119,7 +119,7 @@ members = [ "primitives/sr-api/test", "primitives/sr-arithmetic", "primitives/sr-io", - "primitives/sr-primitives", + "primitives/runtime", "primitives/sr-sandbox", "primitives/sr-staking-primitives", "primitives/sr-std", diff --git a/bin/node-template/Cargo.toml b/bin/node-template/Cargo.toml index 859bedf15d..a60cbf4ff1 100644 --- a/bin/node-template/Cargo.toml +++ b/bin/node-template/Cargo.toml @@ -34,7 +34,7 @@ grandpa = { package = "sc-finality-grandpa", path = "../../client/finality-grand grandpa-primitives = { package = "sp-finality-grandpa", path = "../../primitives/finality-grandpa" } sc-client = { path = "../../client/" } runtime = { package = "node-template-runtime", path = "runtime" } -sp-runtime = { path = "../../primitives/sr-primitives" } +sp-runtime = { path = "../../primitives/runtime" } basic-authorship = { package = "sc-basic-authority", path = "../../client/basic-authorship"} [build-dependencies] diff --git a/bin/node-template/runtime/Cargo.toml b/bin/node-template/runtime/Cargo.toml index fe8a2ea564..de1fbd6ed3 100644 --- a/bin/node-template/runtime/Cargo.toml +++ b/bin/node-template/runtime/Cargo.toml @@ -22,7 +22,7 @@ runtime-io = { package = "sp-io", path = "../../../primitives/sr-io", default-fe 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 } -sp-runtime = { path = "../../../primitives/sr-primitives", default-features = false } +sp-runtime = { path = "../../../primitives/runtime", default-features = false } sp-session = { path = "../../../primitives/session", default-features = false } sudo = { package = "pallet-sudo", path = "../../../frame/sudo", default-features = false } support = { package = "frame-support", path = "../../../frame/support", default-features = false } diff --git a/bin/node/cli/Cargo.toml b/bin/node/cli/Cargo.toml index ec89aef6fe..107fe6bb30 100644 --- a/bin/node/cli/Cargo.toml +++ b/bin/node/cli/Cargo.toml @@ -36,14 +36,15 @@ structopt = "0.3.3" # primitives authority-discovery-primitives = { package = "sp-authority-discovery", path = "../../../primitives/authority-discovery"} babe-primitives = { package = "sp-consensus-babe", path = "../../../primitives/consensus/babe" } -grandpa_primitives = { package = "sp-finality-grandpa", path = "../../../primitives/finality-grandpa" } +grandpa-primitives = { package = "sp-finality-grandpa", path = "../../../primitives/finality-grandpa" } primitives = { package = "sp-core", path = "../../../primitives/core" } -sp-runtime = { path = "../../../primitives/sr-primitives" } +sp-runtime = { path = "../../../primitives/runtime" } sp-timestamp = { path = "../../../primitives/timestamp", default-features = false } 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" } +consensus-common = { package = "sp-consensus", path = "../../../primitives/consensus/common" } # client dependencies client-api = { package = "sc-client-api", path = "../../../client/api" } @@ -54,14 +55,13 @@ txpool-api = { package = "sp-transaction-pool-api", path = "../../../primitives/ network = { package = "sc-network", path = "../../../client/network" } babe = { package = "sc-consensus-babe", path = "../../../client/consensus/babe" } grandpa = { package = "sc-finality-grandpa", path = "../../../client/finality-grandpa" } -client_db = { package = "sc-client-db", path = "../../../client/db", default-features = false } +client-db = { package = "sc-client-db", path = "../../../client/db", default-features = false } offchain = { package = "sc-offchain", path = "../../../client/offchain" } -sc-rpc = { package = "sc-rpc", path = "../../../client/rpc" } +sc-rpc = { path = "../../../client/rpc" } sc-basic-authority = { path = "../../../client/basic-authorship" } sc-service = { path = "../../../client/service", default-features = false } -sc-telemetry = { package = "sc-telemetry", path = "../../../client/telemetry" } +sc-telemetry = { path = "../../../client/telemetry" } authority-discovery = { package = "sc-authority-discovery", path = "../../../client/authority-discovery"} -consensus-common = { package = "sp-consensus", path = "../../../primitives/consensus/common" } # frame dependencies indices = { package = "pallet-indices", path = "../../../frame/indices" } diff --git a/bin/node/executor/Cargo.toml b/bin/node/executor/Cargo.toml index bafe514393..f386a2d929 100644 --- a/bin/node/executor/Cargo.toml +++ b/bin/node/executor/Cargo.toml @@ -19,7 +19,7 @@ node-runtime = { path = "../runtime" } [dev-dependencies] node-testing = { path = "../testing" } test-client = { package = "substrate-test-client", path = "../../../test/utils/client" } -sp-runtime = { path = "../../../primitives/sr-primitives" } +sp-runtime = { path = "../../../primitives/runtime" } runtime_support = { package = "frame-support", path = "../../../frame/support" } balances = { package = "pallet-balances", path = "../../../frame/balances" } transaction-payment = { package = "pallet-transaction-payment", path = "../../../frame/transaction-payment" } @@ -45,4 +45,3 @@ stress-test = [] [[bench]] name = "bench" harness = false - diff --git a/bin/node/primitives/Cargo.toml b/bin/node/primitives/Cargo.toml index 6c8d1e22ad..7141dbbbca 100644 --- a/bin/node/primitives/Cargo.toml +++ b/bin/node/primitives/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" [dependencies] primitives = { package = "sp-core", path = "../../../primitives/core", default-features = false } -sp-runtime = { path = "../../../primitives/sr-primitives", default-features = false } +sp-runtime = { path = "../../../primitives/runtime", default-features = false } [dev-dependencies] sp-serializer = { path = "../../../primitives/serializer" } diff --git a/bin/node/rpc/Cargo.toml b/bin/node/rpc/Cargo.toml index 56edc94d4e..f3d5536a75 100644 --- a/bin/node/rpc/Cargo.toml +++ b/bin/node/rpc/Cargo.toml @@ -9,7 +9,7 @@ client = { package = "sc-client", path = "../../../client/" } jsonrpc-core = "14.0.3" node-primitives = { path = "../primitives" } node-runtime = { path = "../runtime" } -sp-runtime = { path = "../../../primitives/sr-primitives" } +sp-runtime = { path = "../../../primitives/runtime" } pallet-contracts-rpc = { path = "../../../frame/contracts/rpc/" } pallet-transaction-payment-rpc = { path = "../../../frame/transaction-payment/rpc/" } substrate-frame-rpc-system = { path = "../../../utils/frame/rpc/system" } diff --git a/bin/node/runtime/Cargo.toml b/bin/node/runtime/Cargo.toml index 8c9990b857..662716c822 100644 --- a/bin/node/runtime/Cargo.toml +++ b/bin/node/runtime/Cargo.toml @@ -23,7 +23,7 @@ offchain-primitives = { package = "sp-offchain", path = "../../../primitives/off primitives = { package = "sp-core", path = "../../../primitives/core", default-features = false } rstd = { package = "sp-std", path = "../../../primitives/sr-std", default-features = false } sp-api = { path = "../../../primitives/sr-api", default-features = false } -sp-runtime = { path = "../../../primitives/sr-primitives", default-features = false } +sp-runtime = { path = "../../../primitives/runtime", default-features = false } sp-staking = { path = "../../../primitives/sr-staking-primitives", default-features = false } sp-keyring = { path = "../../../primitives/keyring", optional = true } sp-session = { path = "../../../primitives/session", default-features = false } diff --git a/bin/node/testing/Cargo.toml b/bin/node/testing/Cargo.toml index 4bbf14972d..b4723cc3f4 100644 --- a/bin/node/testing/Cargo.toml +++ b/bin/node/testing/Cargo.toml @@ -20,7 +20,7 @@ primitives = { package = "sp-core", path = "../../../primitives/core" } runtime-io = { package = "sp-io", path = "../../../primitives/sr-io" } runtime_support = { package = "frame-support", path = "../../../frame/support" } session = { package = "pallet-session", path = "../../../frame/session" } -sp-runtime = { path = "../../../primitives/sr-primitives" } +sp-runtime = { path = "../../../primitives/runtime" } staking = { package = "pallet-staking", path = "../../../frame/staking" } sc-executor = { path = "../../../client/executor" } system = { package = "frame-system", path = "../../../frame/system" } diff --git a/bin/subkey/Cargo.toml b/bin/subkey/Cargo.toml index 19290b3ccc..50cffad7de 100644 --- a/bin/subkey/Cargo.toml +++ b/bin/subkey/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" primitives = { package = "sp-core", version = "*", path = "../../primitives/core" } node-runtime = { version = "*", path = "../node/runtime" } node-primitives = { version = "*", path = "../node/primitives" } -sp-runtime = { version = "*", path = "../../primitives/sr-primitives" } +sp-runtime = { version = "*", path = "../../primitives/runtime" } rand = "0.7.2" clap = "2.33.0" tiny-bip39 = "0.6.2" diff --git a/client/Cargo.toml b/client/Cargo.toml index 13a98b7f80..819ef2e74b 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -25,7 +25,7 @@ primitives = { package = "sp-core", path = "../primitives/core" } rstd = { package = "sp-std", path = "../primitives/sr-std" } runtime-version = { package = "sp-version", path = "../primitives/sr-version" } sp-api = { path = "../primitives/sr-api" } -sp-runtime = { path = "../primitives/sr-primitives" } +sp-runtime = { path = "../primitives/runtime" } sp-blockchain = { path = "../primitives/blockchain" } state-machine = { package = "sp-state-machine", path = "../primitives/state-machine" } sc-telemetry = { path = "telemetry" } diff --git a/client/api/Cargo.toml b/client/api/Cargo.toml index 212cf9b735..494763363a 100644 --- a/client/api/Cargo.toml +++ b/client/api/Cargo.toml @@ -25,7 +25,7 @@ primitives = { package = "sp-core", path = "../../primitives/core", default-feat rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } runtime-version = { package = "sp-version", path = "../../primitives/sr-version", default-features = false } sp-api = { path = "../../primitives/sr-api" } -sp-runtime = { path = "../../primitives/sr-primitives", default-features = false } +sp-runtime = { path = "../../primitives/runtime", default-features = false } state-machine = { package = "sp-state-machine", path = "../../primitives/state-machine" } sc-telemetry = { path = "../telemetry" } trie = { package = "sp-trie", path = "../../primitives/trie" } @@ -39,4 +39,3 @@ test-primitives = { package = "substrate-test-primitives", path = "../../test/ut test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client" } kvdb-memorydb = "0.1.2" panic-handler = { package = "sp-panic-handler", path = "../../primitives/panic-handler" } - diff --git a/client/authority-discovery/Cargo.toml b/client/authority-discovery/Cargo.toml index 1f88f6619f..4608e5ca43 100644 --- a/client/authority-discovery/Cargo.toml +++ b/client/authority-discovery/Cargo.toml @@ -24,7 +24,7 @@ primitives = { package = "sp-core", path = "../../primitives/core" } sp-blockchain = { path = "../../primitives/blockchain" } prost = "0.5.0" serde_json = "1.0.41" -sp-runtime = { path = "../../primitives/sr-primitives" } +sp-runtime = { path = "../../primitives/runtime" } [dev-dependencies] env_logger = "0.7.0" diff --git a/client/basic-authorship/Cargo.toml b/client/basic-authorship/Cargo.toml index 3f4cbb0bc6..1132ec3c90 100644 --- a/client/basic-authorship/Cargo.toml +++ b/client/basic-authorship/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" log = "0.4.8" futures = "0.3.1" codec = { package = "parity-scale-codec", version = "1.0.0" } -sp-runtime = { path = "../../primitives/sr-primitives" } +sp-runtime = { path = "../../primitives/runtime" } primitives = { package = "sp-core", path = "../../primitives/core" } sp-blockchain = { path = "../../primitives/blockchain" } client = { package = "sc-client", path = "../" } diff --git a/client/block-builder/Cargo.toml b/client/block-builder/Cargo.toml index 1854d499fb..7986948c0e 100644 --- a/client/block-builder/Cargo.toml +++ b/client/block-builder/Cargo.toml @@ -6,10 +6,9 @@ edition = "2018" [dependencies] state-machine = { package = "sp-state-machine", path = "../../primitives/state-machine" } -sp-runtime = { path = "../../primitives/sr-primitives" } +sp-runtime = { path = "../../primitives/runtime" } sp-blockchain = { path = "../../primitives/blockchain" } primitives = { package = "sp-core", path = "../../primitives/core" } codec = { package = "parity-scale-codec", version = "1.0.6", features = ["derive"] } runtime_api = { package = "sp-block-builder", path = "../../primitives/block-builder/runtime-api" } sp-api = { path = "../../primitives/sr-api" } - diff --git a/client/chain-spec/Cargo.toml b/client/chain-spec/Cargo.toml index 3e67a6cd48..f1035e8d56 100644 --- a/client/chain-spec/Cargo.toml +++ b/client/chain-spec/Cargo.toml @@ -11,5 +11,5 @@ network = { package = "sc-network", path = "../network" } primitives = { package = "sp-core", path = "../../primitives/core" } serde = { version = "1.0.101", features = ["derive"] } serde_json = "1.0.41" -sp-runtime = { path = "../../primitives/sr-primitives" } +sp-runtime = { path = "../../primitives/runtime" } tel = { package = "sc-telemetry", path = "../telemetry" } diff --git a/client/cli/Cargo.toml b/client/cli/Cargo.toml index 817d411bd0..7e65e59faa 100644 --- a/client/cli/Cargo.toml +++ b/client/cli/Cargo.toml @@ -24,7 +24,7 @@ panic-handler = { package = "sp-panic-handler", path = "../../primitives/panic-h client-api = { package = "sc-client-api", path = "../api" } sp-blockchain = { path = "../../primitives/blockchain" } network = { package = "sc-network", path = "../network" } -sp-runtime = { path = "../../primitives/sr-primitives" } +sp-runtime = { path = "../../primitives/runtime" } primitives = { package = "sp-core", path = "../../primitives/core" } service = { package = "sc-service", path = "../service", default-features = false } state-machine = { package = "sp-state-machine", path = "../../primitives/state-machine" } diff --git a/client/consensus/aura/Cargo.toml b/client/consensus/aura/Cargo.toml index 29c2914d28..16ce2eed27 100644 --- a/client/consensus/aura/Cargo.toml +++ b/client/consensus/aura/Cargo.toml @@ -27,7 +27,7 @@ runtime_io = { package = "sp-io", path = "../../../primitives/sr-io" } runtime_version = { package = "sp-version", path = "../../../primitives/sr-version" } slots = { package = "sc-consensus-slots", path = "../slots" } sp-api = { path = "../../../primitives/sr-api" } -sp-runtime = { path = "../../../primitives/sr-primitives" } +sp-runtime = { path = "../../../primitives/runtime" } sp-timestamp = { path = "../../../primitives/timestamp" } sc-telemetry = { path = "../../telemetry" } diff --git a/client/consensus/babe/Cargo.toml b/client/consensus/babe/Cargo.toml index c7931d82b9..068fb90dec 100644 --- a/client/consensus/babe/Cargo.toml +++ b/client/consensus/babe/Cargo.toml @@ -27,7 +27,7 @@ sp-blockchain = { path = "../../../primitives/blockchain" } consensus-common = { package = "sp-consensus", path = "../../../primitives/consensus/common" } uncles = { package = "sc-consensus-uncles", path = "../uncles" } slots = { package = "sc-consensus-slots", path = "../slots" } -sp-runtime = { path = "../../../primitives/sr-primitives" } +sp-runtime = { path = "../../../primitives/runtime" } fork-tree = { path = "../../../utils/fork-tree" } futures = { version = "0.3.1", features = ["compat"] } futures01 = { package = "futures", version = "0.1" } diff --git a/client/consensus/pow/Cargo.toml b/client/consensus/pow/Cargo.toml index 9ee579620a..60b88d46e7 100644 --- a/client/consensus/pow/Cargo.toml +++ b/client/consensus/pow/Cargo.toml @@ -9,7 +9,7 @@ edition = "2018" codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } primitives = { package = "sp-core", path = "../../../primitives/core" } sp-blockchain = { path = "../../../primitives/blockchain" } -sp-runtime = { path = "../../../primitives/sr-primitives" } +sp-runtime = { path = "../../../primitives/runtime" } client-api = { package = "sc-client-api", path = "../../api" } block-builder-api = { package = "sp-block-builder", path = "../../../primitives/block-builder/runtime-api" } inherents = { package = "sp-inherents", path = "../../../primitives/inherents" } diff --git a/client/consensus/slots/Cargo.toml b/client/consensus/slots/Cargo.toml index 3881906dad..81629d2e32 100644 --- a/client/consensus/slots/Cargo.toml +++ b/client/consensus/slots/Cargo.toml @@ -11,7 +11,7 @@ codec = { package = "parity-scale-codec", version = "1.0.0" } client-api = { package = "sc-client-api", path = "../../api" } primitives = { package = "sp-core", path = "../../../primitives/core" } sp-blockchain = { path = "../../../primitives/blockchain" } -sp-runtime = { path = "../../../primitives/sr-primitives" } +sp-runtime = { path = "../../../primitives/runtime" } sc-telemetry = { path = "../../telemetry" } consensus_common = { package = "sp-consensus", path = "../../../primitives/consensus/common" } inherents = { package = "sp-inherents", path = "../../../primitives/inherents" } diff --git a/client/consensus/uncles/Cargo.toml b/client/consensus/uncles/Cargo.toml index b136c35ee2..62fc7476f1 100644 --- a/client/consensus/uncles/Cargo.toml +++ b/client/consensus/uncles/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" [dependencies] client-api = { package = "sc-client-api", path = "../../api" } primitives = { package = "sp-core", path = "../../../primitives/core" } -sp-runtime = { path = "../../../primitives/sr-primitives" } +sp-runtime = { path = "../../../primitives/runtime" } sp-authorship = { path = "../../../primitives/authorship" } consensus_common = { package = "sp-consensus", path = "../../../primitives/consensus/common" } inherents = { package = "sp-inherents", path = "../../../primitives/inherents" } diff --git a/client/db/Cargo.toml b/client/db/Cargo.toml index d8ad48f9b4..631d89ce48 100644 --- a/client/db/Cargo.toml +++ b/client/db/Cargo.toml @@ -14,7 +14,7 @@ linked-hash-map = "0.5.2" hash-db = "0.15.2" client-api = { package = "sc-client-api", path = "../api" } primitives = { package = "sp-core", path = "../../primitives/core" } -sp-runtime = { path = "../../primitives/sr-primitives" } +sp-runtime = { path = "../../primitives/runtime" } client = { package = "sc-client", path = "../" } state-machine = { package = "sp-state-machine", path = "../../primitives/state-machine" } codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } diff --git a/client/executor/runtime-test/Cargo.toml b/client/executor/runtime-test/Cargo.toml index 597417a17f..6ae8967837 100644 --- a/client/executor/runtime-test/Cargo.toml +++ b/client/executor/runtime-test/Cargo.toml @@ -10,7 +10,7 @@ rstd = { package = "sp-std", path = "../../../primitives/sr-std", default-featur runtime_io = { package = "sp-io", path = "../../../primitives/sr-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/sr-primitives", default-features = false } +sp-runtime = { package = "sp-runtime", path = "../../../primitives/runtime", default-features = false } [build-dependencies] wasm-builder-runner = { package = "substrate-wasm-builder-runner", path = "../../../client/utils/wasm-builder-runner", version = "1.0.4" } diff --git a/client/finality-grandpa/Cargo.toml b/client/finality-grandpa/Cargo.toml index a1e2c86b8e..cbadd6dba6 100644 --- a/client/finality-grandpa/Cargo.toml +++ b/client/finality-grandpa/Cargo.toml @@ -14,7 +14,7 @@ tokio-executor = "0.1.8" tokio-timer = "0.2.11" rand = "0.7.2" codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } -sp-runtime = { path = "../../primitives/sr-primitives" } +sp-runtime = { path = "../../primitives/runtime" } consensus_common = { package = "sp-consensus", path = "../../primitives/consensus/common" } primitives = { package = "sp-core", path = "../../primitives/core" } sc-telemetry = { path = "../telemetry" } diff --git a/client/network/Cargo.toml b/client/network/Cargo.toml index 1872645d55..98ca2b610c 100644 --- a/client/network/Cargo.toml +++ b/client/network/Cargo.toml @@ -28,7 +28,7 @@ consensus = { package = "sp-consensus", path = "../../primitives/consensus/commo client = { package = "sc-client", path = "../" } client-api = { package = "sc-client-api", path = "../api" } sp-blockchain = { path = "../../primitives/blockchain" } -sp-runtime = { path = "../../primitives/sr-primitives" } +sp-runtime = { path = "../../primitives/runtime" } sp-arithmetic = { path = "../../primitives/sr-arithmetic" } primitives = { package = "sp-core", path = "../../primitives/core" } block-builder = { package = "sc-block-builder", path = "../block-builder" } diff --git a/client/offchain/Cargo.toml b/client/offchain/Cargo.toml index 1b30c2fcff..953f525d5c 100644 --- a/client/offchain/Cargo.toml +++ b/client/offchain/Cargo.toml @@ -22,7 +22,7 @@ codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive parking_lot = "0.9.0" primitives = { package = "sp-core", path = "../../primitives/core" } rand = "0.7.2" -sp-runtime = { path = "../../primitives/sr-primitives" } +sp-runtime = { path = "../../primitives/runtime" } network = { package = "sc-network", path = "../network" } keystore = { package = "sc-keystore", path = "../keystore" } diff --git a/client/rpc-servers/Cargo.toml b/client/rpc-servers/Cargo.toml index 5fd4d0d8eb..eb63193ace 100644 --- a/client/rpc-servers/Cargo.toml +++ b/client/rpc-servers/Cargo.toml @@ -10,7 +10,7 @@ pubsub = { package = "jsonrpc-pubsub", version = "14.0.3" } log = "0.4.8" serde = "1.0.101" serde_json = "1.0.41" -sp-runtime = { path = "../../primitives/sr-primitives" } +sp-runtime = { path = "../../primitives/runtime" } [target.'cfg(not(target_os = "unknown"))'.dependencies] http = { package = "jsonrpc-http-server", version = "14.0.3" } diff --git a/client/rpc/Cargo.toml b/client/rpc/Cargo.toml index 20214d5796..e167e26a67 100644 --- a/client/rpc/Cargo.toml +++ b/client/rpc/Cargo.toml @@ -18,7 +18,7 @@ rpc = { package = "jsonrpc-core", version = "14.0.3" } runtime_version = { package = "sp-version", path = "../../primitives/sr-version" } serde_json = "1.0.41" session = { package = "sp-session", path = "../../primitives/session" } -sp-runtime = { path = "../../primitives/sr-primitives" } +sp-runtime = { path = "../../primitives/runtime" } rpc-primitives = { package = "sp-rpc", path = "../../primitives/rpc" } state_machine = { package = "sp-state-machine", path = "../../primitives/state-machine" } sc-executor = { path = "../executor" } diff --git a/client/service/Cargo.toml b/client/service/Cargo.toml index d60d8c8abc..b5b3db284c 100644 --- a/client/service/Cargo.toml +++ b/client/service/Cargo.toml @@ -30,7 +30,7 @@ sysinfo = "0.9.5" target_info = "0.1.0" keystore = { package = "sc-keystore", path = "../keystore" } sp-io = { path = "../../primitives/sr-io" } -sp-runtime = { path = "../../primitives/sr-primitives" } +sp-runtime = { path = "../../primitives/runtime" } sp-blockchain = { path = "../../primitives/blockchain" } primitives = { package = "sp-core", path = "../../primitives/core" } session = { package = "sp-session", path = "../../primitives/session" } diff --git a/client/service/test/Cargo.toml b/client/service/test/Cargo.toml index b337521d96..87b4bfface 100644 --- a/client/service/test/Cargo.toml +++ b/client/service/test/Cargo.toml @@ -16,6 +16,6 @@ service = { package = "sc-service", path = "../../service", default-features = f network = { package = "sc-network", path = "../../network" } consensus = { package = "sp-consensus", path = "../../../primitives/consensus/common" } client = { package = "sc-client", path = "../../" } -sp-runtime = { path = "../../../primitives/sr-primitives" } +sp-runtime = { path = "../../../primitives/runtime" } primitives = { package = "sp-core", path = "../../../primitives/core" } txpool-api = { package = "sp-transaction-pool-api", path = "../../../primitives/transaction-pool" } diff --git a/client/transaction-pool/Cargo.toml b/client/transaction-pool/Cargo.toml index b30e879134..01d9bfcdf8 100644 --- a/client/transaction-pool/Cargo.toml +++ b/client/transaction-pool/Cargo.toml @@ -12,7 +12,7 @@ log = "0.4.8" parking_lot = "0.9.0" primitives = { package = "sp-core", path = "../../primitives/core" } sp-api = { path = "../../primitives/sr-api" } -sp-runtime = { path = "../../primitives/sr-primitives" } +sp-runtime = { path = "../../primitives/runtime" } txpool = { package = "sc-transaction-graph", path = "./graph" } txpool-api = { package = "sp-transaction-pool-api", path = "../../primitives/transaction-pool" } client-api = { package = "sc-client-api", path = "../api" } diff --git a/client/transaction-pool/graph/Cargo.toml b/client/transaction-pool/graph/Cargo.toml index 869a206007..9e128557d2 100644 --- a/client/transaction-pool/graph/Cargo.toml +++ b/client/transaction-pool/graph/Cargo.toml @@ -11,7 +11,7 @@ log = "0.4.8" parking_lot = "0.9.0" serde = { version = "1.0.101", features = ["derive"] } primitives = { package = "sp-core", path = "../../../primitives/core" } -sp-runtime = { path = "../../../primitives/sr-primitives" } +sp-runtime = { path = "../../../primitives/runtime" } txpool-api = { package = "sp-transaction-pool-api", path = "../../../primitives/transaction-pool" } [dev-dependencies] diff --git a/docs/CODEOWNERS b/docs/CODEOWNERS index 7b67cb30f8..5b00436bfd 100644 --- a/docs/CODEOWNERS +++ b/docs/CODEOWNERS @@ -62,7 +62,7 @@ /bin/node/executor/ @kianenigma # Transaction weight stuff -/primitives/sr-primitives/src/weights.rs @kianenigma +/primitives/runtime/src/weights.rs @kianenigma # Support crates /frame/support/ @thiolliere @kianenigma diff --git a/frame/assets/Cargo.toml b/frame/assets/Cargo.toml index 6cca26c621..bbb9c30daa 100644 --- a/frame/assets/Cargo.toml +++ b/frame/assets/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 } # Needed for various traits. In our case, `OnFinalize`. -sp-runtime = { path = "../../primitives/sr-primitives", default-features = false } +sp-runtime = { path = "../../primitives/runtime", default-features = false } # Needed for type-safe access to storage DB. support = { package = "frame-support", path = "../support", default-features = false } # `system` module provides us with all sorts of useful stuff and macros depend on it being around. diff --git a/frame/aura/Cargo.toml b/frame/aura/Cargo.toml index 8c53f871cc..e9f3e85f34 100644 --- a/frame/aura/Cargo.toml +++ b/frame/aura/Cargo.toml @@ -12,7 +12,7 @@ primitives = { package = "sp-core", path = "../../primitives/core", default-fea rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } serde = { version = "1.0.101", optional = true } session = { package = "pallet-session", path = "../session", default-features = false } -sp-runtime = { path = "../../primitives/sr-primitives", default-features = false } +sp-runtime = { path = "../../primitives/runtime", default-features = false } runtime-io ={ package = "sp-io", path = "../../primitives/sr-io", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } sp-consensus-aura = { path = "../../primitives/consensus/aura", default-features = false} diff --git a/frame/authority-discovery/Cargo.toml b/frame/authority-discovery/Cargo.toml index 7d44071822..e3db707a6a 100644 --- a/frame/authority-discovery/Cargo.toml +++ b/frame/authority-discovery/Cargo.toml @@ -12,8 +12,8 @@ primitives = { package = "sp-core", path = "../../primitives/core", default-fea rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } serde = { version = "1.0.101", optional = true } runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } -session = { package = "pallet-session", path = "../session", default-features = false, features = ["historical"] } -sp-runtime = { path = "../../primitives/sr-primitives", 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 } system = { package = "frame-system", path = "../system", default-features = false } diff --git a/frame/authorship/Cargo.toml b/frame/authorship/Cargo.toml index e8e82cc4d8..496c4a1122 100644 --- a/frame/authorship/Cargo.toml +++ b/frame/authorship/Cargo.toml @@ -11,7 +11,7 @@ codec = { package = "parity-scale-codec", version = "1.0.0", default-features = inherents = { package = "sp-inherents", path = "../../primitives/inherents", default-features = false } sp-authorship = { path = "../../primitives/authorship", default-features = false } rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } -sp-runtime = { path = "../../primitives/sr-primitives", 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 } diff --git a/frame/babe/Cargo.toml b/frame/babe/Cargo.toml index c60b055b91..a81865860d 100644 --- a/frame/babe/Cargo.toml +++ b/frame/babe/Cargo.toml @@ -10,7 +10,7 @@ codec = { package = "parity-scale-codec", version = "1.0.0", default-features = serde = { version = "1.0.101", optional = true } inherents = { package = "sp-inherents", path = "../../primitives/inherents", default-features = false } rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } -sp-runtime = { path = "../../primitives/sr-primitives", 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 } system = { package = "frame-system", path = "../system", default-features = false } diff --git a/frame/balances/Cargo.toml b/frame/balances/Cargo.toml index f6042ab33f..f0dd86a444 100644 --- a/frame/balances/Cargo.toml +++ b/frame/balances/Cargo.toml @@ -9,7 +9,7 @@ serde = { version = "1.0.101", optional = true } safe-mix = { version = "1.0.0", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } -sp-runtime = { path = "../../primitives/sr-primitives", 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 } diff --git a/frame/collective/Cargo.toml b/frame/collective/Cargo.toml index 2208e6e604..c7baa61346 100644 --- a/frame/collective/Cargo.toml +++ b/frame/collective/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 } rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } -sp-runtime = { path = "../../primitives/sr-primitives", 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 } diff --git a/frame/contracts/Cargo.toml b/frame/contracts/Cargo.toml index 90e2f57091..b961fba232 100644 --- a/frame/contracts/Cargo.toml +++ b/frame/contracts/Cargo.toml @@ -11,7 +11,7 @@ codec = { package = "parity-scale-codec", version = "1.0.0", default-features = 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/sr-primitives", default-features = false } +sp-runtime = { path = "../../primitives/runtime", default-features = false } runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } sandbox = { package = "sp-sandbox", path = "../../primitives/sr-sandbox", default-features = false } diff --git a/frame/contracts/rpc/Cargo.toml b/frame/contracts/rpc/Cargo.toml index fa030cb9ff..8e69b4fb8e 100644 --- a/frame/contracts/rpc/Cargo.toml +++ b/frame/contracts/rpc/Cargo.toml @@ -13,7 +13,7 @@ sp-blockchain = { path = "../../../primitives/blockchain" } primitives = { package = "sp-core", path = "../../../primitives/core" } rpc-primitives = { package = "sp-rpc", path = "../../../primitives/rpc" } serde = { version = "1.0.101", features = ["derive"] } -sp-runtime = { path = "../../../primitives/sr-primitives" } +sp-runtime = { path = "../../../primitives/runtime" } pallet-contracts-rpc-runtime-api = { path = "./runtime-api" } [dev-dependencies] diff --git a/frame/contracts/rpc/runtime-api/Cargo.toml b/frame/contracts/rpc/runtime-api/Cargo.toml index dc044e1aeb..b0e84c7a28 100644 --- a/frame/contracts/rpc/runtime-api/Cargo.toml +++ b/frame/contracts/rpc/runtime-api/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" sp-api = { path = "../../../../primitives/sr-api", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } rstd = { package = "sp-std", path = "../../../../primitives/sr-std", default-features = false } -sp-runtime = { path = "../../../../primitives/sr-primitives", default-features = false } +sp-runtime = { path = "../../../../primitives/runtime", default-features = false } [features] default = ["std"] diff --git a/frame/democracy/Cargo.toml b/frame/democracy/Cargo.toml index a9becc0944..f3e23672af 100644 --- a/frame/democracy/Cargo.toml +++ b/frame/democracy/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"] } rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } -sp-runtime = { path = "../../primitives/sr-primitives", 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 } diff --git a/frame/elections-phragmen/Cargo.toml b/frame/elections-phragmen/Cargo.toml index 9e7039da91..b1fa40741a 100644 --- a/frame/elections-phragmen/Cargo.toml +++ b/frame/elections-phragmen/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" [dependencies] codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-runtime = { path = "../../primitives/sr-primitives", default-features = false } +sp-runtime = { path = "../../primitives/runtime", default-features = false } phragmen = { package = "sp-phragmen", path = "../../primitives/phragmen", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } system = { package = "frame-system", path = "../system", default-features = false } diff --git a/frame/elections/Cargo.toml b/frame/elections/Cargo.toml index 1c0e06ac00..c27b447aeb 100644 --- a/frame/elections/Cargo.toml +++ b/frame/elections/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 } rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } -sp-runtime = { path = "../../primitives/sr-primitives", 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 } diff --git a/frame/evm/Cargo.toml b/frame/evm/Cargo.toml index 9cb59b6784..245d715665 100644 --- a/frame/evm/Cargo.toml +++ b/frame/evm/Cargo.toml @@ -12,7 +12,7 @@ system = { package = "frame-system", path = "../system", default-features = fals timestamp = { package = "pallet-timestamp", path = "../timestamp", default-features = false } balances = { package = "pallet-balances", path = "../balances", default-features = false } primitives = { package = "sp-core", path = "../../primitives/core", default-features = false } -sp-runtime = { path = "../../primitives/sr-primitives", default-features = false } +sp-runtime = { path = "../../primitives/runtime", default-features = false } rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } primitive-types = { version = "0.6", default-features = false, features = ["rlp"] } diff --git a/frame/example/Cargo.toml b/frame/example/Cargo.toml index e76447b03a..ccddd2ce1a 100644 --- a/frame/example/Cargo.toml +++ b/frame/example/Cargo.toml @@ -10,7 +10,7 @@ codec = { package = "parity-scale-codec", version = "1.0.0", default-features = support = { package = "frame-support", path = "../support", default-features = false } system = { package = "frame-system", path = "../system", default-features = false } balances = { package = "pallet-balances", path = "../balances", default-features = false } -sp-runtime = { path = "../../primitives/sr-primitives", default-features = false } +sp-runtime = { path = "../../primitives/runtime", default-features = false } rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } diff --git a/frame/executive/Cargo.toml b/frame/executive/Cargo.toml index f4eb4fb76c..e18d0fdb0b 100644 --- a/frame/executive/Cargo.toml +++ b/frame/executive/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"] } rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } runtime-io ={ package = "sp-io", path = "../../primitives/sr-io", default-features = false } -sp-runtime = { path = "../../primitives/sr-primitives", 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 } diff --git a/frame/finality-tracker/Cargo.toml b/frame/finality-tracker/Cargo.toml index e3dd7b1428..a9ead70d05 100644 --- a/frame/finality-tracker/Cargo.toml +++ b/frame/finality-tracker/Cargo.toml @@ -9,7 +9,7 @@ serde = { version = "1.0.101", default-features = false, features = ["derive"] } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } inherents = { package = "sp-inherents", path = "../../primitives/inherents", default-features = false } rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } -sp-runtime = { path = "../../primitives/sr-primitives", default-features = false } +sp-runtime = { path = "../../primitives/runtime", default-features = false } sp-finality-tracker = { path = "../../primitives/finality-tracker", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } frame-system = { path = "../system", default-features = false } diff --git a/frame/generic-asset/Cargo.toml b/frame/generic-asset/Cargo.toml index 210bc7773a..2889e66012 100644 --- a/frame/generic-asset/Cargo.toml +++ b/frame/generic-asset/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"] } rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } -sp-runtime = { path = "../../primitives/sr-primitives", 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 } diff --git a/frame/grandpa/Cargo.toml b/frame/grandpa/Cargo.toml index f14da4a395..0af02724f8 100644 --- a/frame/grandpa/Cargo.toml +++ b/frame/grandpa/Cargo.toml @@ -10,7 +10,7 @@ codec = { package = "parity-scale-codec", version = "1.0.0", default-features = primitives = { package = "sp-core", path = "../../primitives/core", default-features = false } sp-finality-grandpa = { path = "../../primitives/finality-grandpa", default-features = false } rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } -sp-runtime = { path = "../../primitives/sr-primitives", 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 } system = { package = "frame-system", path = "../system", default-features = false } diff --git a/frame/im-online/Cargo.toml b/frame/im-online/Cargo.toml index 3c7acb3b20..53aa39ca51 100644 --- a/frame/im-online/Cargo.toml +++ b/frame/im-online/Cargo.toml @@ -13,7 +13,7 @@ rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features 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-runtime = { path = "../../primitives/sr-primitives", 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 } system = { package = "frame-system", path = "../system", default-features = false } diff --git a/frame/indices/Cargo.toml b/frame/indices/Cargo.toml index 2d2a41a551..7571dc1e98 100644 --- a/frame/indices/Cargo.toml +++ b/frame/indices/Cargo.toml @@ -11,7 +11,7 @@ codec = { package = "parity-scale-codec", version = "1.0.0", default-features = sp-keyring = { path = "../../primitives/keyring", optional = true } rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } -sp-runtime = { path = "../../primitives/sr-primitives", 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 } system = { package = "frame-system", path = "../system", default-features = false } diff --git a/frame/membership/Cargo.toml b/frame/membership/Cargo.toml index 9f8dbdbf06..d09ab23051 100644 --- a/frame/membership/Cargo.toml +++ b/frame/membership/Cargo.toml @@ -11,7 +11,7 @@ rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features runtime-io = { package = "sp-io", path = "../../primitives/sr-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/sr-primitives", default-features = false } +sp-runtime = { path = "../../primitives/runtime", default-features = false } [dev-dependencies] primitives = { package = "sp-core", path = "../../primitives/core" } diff --git a/frame/nicks/Cargo.toml b/frame/nicks/Cargo.toml index 55abb0b27d..5f7ad53e3b 100644 --- a/frame/nicks/Cargo.toml +++ b/frame/nicks/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"] } rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } -sp-runtime = { path = "../../primitives/sr-primitives", 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 } diff --git a/frame/offences/Cargo.toml b/frame/offences/Cargo.toml index 56be89d119..27d6344222 100644 --- a/frame/offences/Cargo.toml +++ b/frame/offences/Cargo.toml @@ -9,7 +9,7 @@ balances = { package = "pallet-balances", path = "../balances", default-features codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } serde = { version = "1.0.101", optional = true } -sp-runtime = { path = "../../primitives/sr-primitives", 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 } system = { package = "frame-system", path = "../system", default-features = false } diff --git a/frame/randomness-collective-flip/Cargo.toml b/frame/randomness-collective-flip/Cargo.toml index 291a321776..bd8aef96f2 100644 --- a/frame/randomness-collective-flip/Cargo.toml +++ b/frame/randomness-collective-flip/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] safe-mix = { version = "1.0", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-runtime = { path = "../../primitives/sr-primitives", 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 } rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } diff --git a/frame/scored-pool/Cargo.toml b/frame/scored-pool/Cargo.toml index 2dd64dfb92..d61806c27c 100644 --- a/frame/scored-pool/Cargo.toml +++ b/frame/scored-pool/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" 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-runtime = { path = "../../primitives/sr-primitives", default-features = false } +sp-runtime = { path = "../../primitives/runtime", default-features = false } rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } system = { package = "frame-system", path = "../system", default-features = false } diff --git a/frame/session/Cargo.toml b/frame/session/Cargo.toml index 6265187912..f5ccfa34f9 100644 --- a/frame/session/Cargo.toml +++ b/frame/session/Cargo.toml @@ -9,7 +9,7 @@ serde = { version = "1.0.101", optional = true } safe-mix = { version = "1.0.0", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } -sp-runtime = { path = "../../primitives/sr-primitives", 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 } system = { package = "frame-system", path = "../system", default-features = false } diff --git a/frame/staking/Cargo.toml b/frame/staking/Cargo.toml index 9f410395dd..0b042d5ca0 100644 --- a/frame/staking/Cargo.toml +++ b/frame/staking/Cargo.toml @@ -12,7 +12,7 @@ sp-keyring = { path = "../../primitives/keyring", optional = true } rstd = { package = "sp-std", path = "../../primitives/sr-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-runtime = { path = "../../primitives/sr-primitives", 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 } system = { package = "frame-system", path = "../system", default-features = false } diff --git a/frame/staking/reward-curve/Cargo.toml b/frame/staking/reward-curve/Cargo.toml index 2d9ae607df..530b11f2c3 100644 --- a/frame/staking/reward-curve/Cargo.toml +++ b/frame/staking/reward-curve/Cargo.toml @@ -14,4 +14,4 @@ proc-macro2 = "1.0.6" proc-macro-crate = "0.1.4" [dev-dependencies] -sp-runtime = { path = "../../../primitives/sr-primitives" } +sp-runtime = { path = "../../../primitives/runtime" } diff --git a/frame/sudo/Cargo.toml b/frame/sudo/Cargo.toml index 967fd06a4b..5e7cf92812 100644 --- a/frame/sudo/Cargo.toml +++ b/frame/sudo/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"] } rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } -sp-runtime = { path = "../../primitives/sr-primitives", 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 } diff --git a/frame/support/Cargo.toml b/frame/support/Cargo.toml index f7af3a3627..c74b6b03e2 100644 --- a/frame/support/Cargo.toml +++ b/frame/support/Cargo.toml @@ -11,7 +11,7 @@ codec = { package = "parity-scale-codec", version = "1.0.6", default-features = frame-metadata = { path = "../metadata", default-features = false } rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } runtime-io ={ package = "sp-io", path = "../../primitives/sr-io", default-features = false } -sp-runtime = { path = "../../primitives/sr-primitives", 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 } inherents = { package = "sp-inherents", path = "../../primitives/inherents", default-features = false } diff --git a/frame/support/test/Cargo.toml b/frame/support/test/Cargo.toml index 83b2d26157..6fa380e86d 100644 --- a/frame/support/test/Cargo.toml +++ b/frame/support/test/Cargo.toml @@ -11,7 +11,7 @@ runtime-io ={ package = "sp-io", path = "../../../primitives/sr-io", default-fea 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 } -sp-runtime = { package = "sp-runtime", path = "../../../primitives/sr-primitives", default-features = false } +sp-runtime = { package = "sp-runtime", path = "../../../primitives/runtime", default-features = false } primitives = { package = "sp-core", path = "../../../primitives/core", default-features = false } trybuild = "1.0.17" pretty_assertions = "0.6.1" diff --git a/frame/system/Cargo.toml b/frame/system/Cargo.toml index 7851663c33..93356c0ca6 100644 --- a/frame/system/Cargo.toml +++ b/frame/system/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 } rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } runtime-io ={ package = "sp-io", path = "../../primitives/sr-io", default-features = false } -sp-runtime = { path = "../../primitives/sr-primitives", 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 } impl-trait-for-tuples = "0.1.3" diff --git a/frame/timestamp/Cargo.toml b/frame/timestamp/Cargo.toml index 72e57951bd..c6eac45f98 100644 --- a/frame/timestamp/Cargo.toml +++ b/frame/timestamp/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"] } rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } -sp-runtime = { path = "../../primitives/sr-primitives", default-features = false } +sp-runtime = { path = "../../primitives/runtime", default-features = false } inherents = { package = "sp-inherents", path = "../../primitives/inherents", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } system = { package = "frame-system", path = "../system", default-features = false } diff --git a/frame/transaction-payment/Cargo.toml b/frame/transaction-payment/Cargo.toml index fb84498d77..9163a0a7d8 100644 --- a/frame/transaction-payment/Cargo.toml +++ b/frame/transaction-payment/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } -sp-runtime = { path = "../../primitives/sr-primitives", 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 } transaction-payment-rpc-runtime-api = { package = "pallet-transaction-payment-rpc-runtime-api", path = "./rpc/runtime-api", default-features = false } diff --git a/frame/transaction-payment/rpc/Cargo.toml b/frame/transaction-payment/rpc/Cargo.toml index c8596648f8..71817ab05e 100644 --- a/frame/transaction-payment/rpc/Cargo.toml +++ b/frame/transaction-payment/rpc/Cargo.toml @@ -12,6 +12,6 @@ jsonrpc-derive = "14.0.3" primitives = { package = "sp-core", path = "../../../primitives/core" } rpc-primitives = { package = "sp-rpc", path = "../../../primitives/rpc" } serde = { version = "1.0.101", features = ["derive"] } -sp-runtime = { path = "../../../primitives/sr-primitives" } +sp-runtime = { path = "../../../primitives/runtime" } sp-blockchain = { path = "../../../primitives/blockchain" } pallet-transaction-payment-rpc-runtime-api = { path = "./runtime-api" } diff --git a/frame/transaction-payment/rpc/runtime-api/Cargo.toml b/frame/transaction-payment/rpc/runtime-api/Cargo.toml index 7fc26b0888..559d59e808 100644 --- a/frame/transaction-payment/rpc/runtime-api/Cargo.toml +++ b/frame/transaction-payment/rpc/runtime-api/Cargo.toml @@ -9,7 +9,7 @@ serde = { version = "1.0.101", optional = true, features = ["derive"] } sp-api = { path = "../../../../primitives/sr-api", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.6", default-features = false, features = ["derive"] } rstd = { package = "sp-std", path = "../../../../primitives/sr-std", default-features = false } -sp-runtime = { path = "../../../../primitives/sr-primitives", default-features = false } +sp-runtime = { path = "../../../../primitives/runtime", default-features = false } support = { package = "frame-support", path = "../../../support", default-features = false } [dev-dependencies] diff --git a/frame/treasury/Cargo.toml b/frame/treasury/Cargo.toml index 2ecd11368f..6f3d53af5e 100644 --- a/frame/treasury/Cargo.toml +++ b/frame/treasury/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" serde = { version = "1.0.101", optional = true, features = ["derive"] } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } -sp-runtime = { path = "../../primitives/sr-primitives", 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 } balances = { package = "pallet-balances", path = "../balances", default-features = false } diff --git a/frame/utility/Cargo.toml b/frame/utility/Cargo.toml index f5c1170569..149db67a63 100644 --- a/frame/utility/Cargo.toml +++ b/frame/utility/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 } support = { package = "frame-support", path = "../support", default-features = false } system = { package = "frame-system", path = "../system", default-features = false } -sp-runtime = { path = "../../primitives/sr-primitives", default-features = false } +sp-runtime = { path = "../../primitives/runtime", default-features = false } rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } diff --git a/primitives/application-crypto/Cargo.toml b/primitives/application-crypto/Cargo.toml index 6f012a3d89..7a38b28e83 100644 --- a/primitives/application-crypto/Cargo.toml +++ b/primitives/application-crypto/Cargo.toml @@ -14,15 +14,15 @@ runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-featu [dev-dependencies] test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client" } -sp-runtime = { path = "../../primitives/sr-primitives" } +sp-runtime = { path = "../../primitives/runtime" } [features] default = [ "std" ] std = [ "full_crypto", "primitives/std", "codec/std", "serde", "rstd/std", "runtime-io/std" ] -# This feature enables all crypto primitives for `no_std` builds like microcontrollers -# or Intel SGX. +# This feature enables all crypto primitives for `no_std` builds like microcontrollers +# or Intel SGX. # For the regular wasm runtime builds this should not be used. full_crypto = [ "primitives/full_crypto" -] \ No newline at end of file +] diff --git a/primitives/authority-discovery/Cargo.toml b/primitives/authority-discovery/Cargo.toml index 9a2daaff1c..f96d4c8e48 100644 --- a/primitives/authority-discovery/Cargo.toml +++ b/primitives/authority-discovery/Cargo.toml @@ -10,7 +10,7 @@ app-crypto = { package = "sc-application-crypto", path = "../application-crypto" codec = { package = "parity-scale-codec", default-features = false, version = "1.0.3" } rstd = { package = "sp-std", path = "../sr-std", default-features = false } sp-api = { path = "../sr-api", default-features = false } -sp-runtime = { path = "../sr-primitives", default-features = false } +sp-runtime = { path = "../runtime", default-features = false } [features] default = ["std"] diff --git a/primitives/block-builder/runtime-api/Cargo.toml b/primitives/block-builder/runtime-api/Cargo.toml index 323a4ad4c8..36ee35e3eb 100644 --- a/primitives/block-builder/runtime-api/Cargo.toml +++ b/primitives/block-builder/runtime-api/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -sp-runtime = { path = "../../sr-primitives", default-features = false } +sp-runtime = { path = "../../runtime", default-features = false } sp-api = { path = "../../sr-api", default-features = false } rstd = { package = "sp-std", path = "../../sr-std", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.6", default-features = false } diff --git a/primitives/blockchain/Cargo.toml b/primitives/blockchain/Cargo.toml index 6292906925..67bb815cf4 100644 --- a/primitives/blockchain/Cargo.toml +++ b/primitives/blockchain/Cargo.toml @@ -8,10 +8,9 @@ edition = "2018" log = "0.4.8" lru = "0.4.0" parking_lot = "0.9.0" -derive_more = "0.99.2" +derive_more = "0.99.2" parity-scale-codec = { version = "1.0.0", default-features = false, features = ["derive"] } sp_consensus = { package = "sp-consensus", path = "../consensus/common" } -sp-runtime = { path = "../sr-primitives" } +sp-runtime = { path = "../runtime" } sp-block-builder-runtime-api = { package = "sp-block-builder", path = "../block-builder/runtime-api" } sp-state-machine = { package = "sp-state-machine", path = "../state-machine" } - diff --git a/primitives/consensus/aura/Cargo.toml b/primitives/consensus/aura/Cargo.toml index e36f7e44d1..4bc83206a2 100644 --- a/primitives/consensus/aura/Cargo.toml +++ b/primitives/consensus/aura/Cargo.toml @@ -10,7 +10,7 @@ app-crypto = { package = "sc-application-crypto", path = "../../application-cryp codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } rstd = { package = "sp-std", path = "../../sr-std", default-features = false } sp-api = { path = "../../sr-api", default-features = false } -sp-runtime = { path = "../../sr-primitives", default-features = false } +sp-runtime = { path = "../../runtime", default-features = false } inherents = { package = "sp-inherents", path = "../../inherents", default-features = false } sp-timestamp = { path = "../../timestamp", default-features = false } diff --git a/primitives/consensus/babe/Cargo.toml b/primitives/consensus/babe/Cargo.toml index 236f6cdebe..645ea5b44e 100644 --- a/primitives/consensus/babe/Cargo.toml +++ b/primitives/consensus/babe/Cargo.toml @@ -12,7 +12,7 @@ rstd = { package = "sp-std", path = "../../sr-std", default-features = false } schnorrkel = { version = "0.8.5", features = ["preaudit_deprecated"], optional = true } slots = { package = "sc-consensus-slots", path = "../../../client/consensus/slots", optional = true } sp-api = { path = "../../sr-api", default-features = false } -sp-runtime = { path = "../../sr-primitives", default-features = false } +sp-runtime = { path = "../../runtime", default-features = false } sp-inherents = { package = "sp-inherents", path = "../../inherents", default-features = false } sp-timestamp = { path = "../../timestamp", default-features = false } diff --git a/primitives/consensus/common/Cargo.toml b/primitives/consensus/common/Cargo.toml index b8f5efa4b8..75a62ead0f 100644 --- a/primitives/consensus/common/Cargo.toml +++ b/primitives/consensus/common/Cargo.toml @@ -15,7 +15,7 @@ futures = { version = "0.3.1", features = ["thread-pool"] } futures-timer = "0.4.0" rstd = { package = "sp-std", path = "../../sr-std" } runtime_version = { package = "sp-version", path = "../../sr-version" } -sp-runtime = { path = "../../sr-primitives" } +sp-runtime = { path = "../../runtime" } codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } parking_lot = "0.9.0" diff --git a/primitives/consensus/pow/Cargo.toml b/primitives/consensus/pow/Cargo.toml index f6b658294b..ef64333e29 100644 --- a/primitives/consensus/pow/Cargo.toml +++ b/primitives/consensus/pow/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" [dependencies] sp-api = { path = "../../sr-api", default-features = false } rstd = { package = "sp-std", path = "../../sr-std", default-features = false } -sp-runtime = { path = "../../sr-primitives", default-features = false } +sp-runtime = { path = "../../runtime", default-features = false } primitives = { package = "sp-core", path = "../../core", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } diff --git a/primitives/finality-grandpa/Cargo.toml b/primitives/finality-grandpa/Cargo.toml index f02b8a68d5..78f28b7591 100644 --- a/primitives/finality-grandpa/Cargo.toml +++ b/primitives/finality-grandpa/Cargo.toml @@ -10,7 +10,7 @@ codec = { package = "parity-scale-codec", version = "1.0.0", default-features = rstd = { package = "sp-std", path = "../sr-std", default-features = false } serde = { version = "1.0.101", optional = true, features = ["derive"] } sp-api = { path = "../sr-api", default-features = false } -sp-runtime = { path = "../sr-primitives", default-features = false } +sp-runtime = { path = "../runtime", default-features = false } [features] default = ["std"] diff --git a/primitives/keyring/Cargo.toml b/primitives/keyring/Cargo.toml index 25d8a33540..9053266184 100644 --- a/primitives/keyring/Cargo.toml +++ b/primitives/keyring/Cargo.toml @@ -6,6 +6,6 @@ edition = "2018" [dependencies] primitives = { package = "sp-core", path = "../core" } -sp-runtime = { path = "../sr-primitives" } +sp-runtime = { path = "../runtime" } lazy_static = "1.4.0" strum = { version = "0.16.0", features = ["derive"] } diff --git a/primitives/offchain/Cargo.toml b/primitives/offchain/Cargo.toml index 28a3ad198a..0a85e487c3 100644 --- a/primitives/offchain/Cargo.toml +++ b/primitives/offchain/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" [dependencies] sp-api = { path = "../sr-api", default-features = false } -sp-runtime = { path = "../sr-primitives", default-features = false } +sp-runtime = { path = "../runtime", default-features = false } [features] default = ["std"] diff --git a/primitives/phragmen/Cargo.toml b/primitives/phragmen/Cargo.toml index 656ce06acd..06071c79db 100644 --- a/primitives/phragmen/Cargo.toml +++ b/primitives/phragmen/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] serde = { version = "1.0.101", optional = true, features = ["derive"] } rstd = { package = "sp-std", path = "../sr-std", default-features = false } -sp-runtime = { path = "../../primitives/sr-primitives", default-features = false } +sp-runtime = { path = "../../primitives/runtime", default-features = false } [dev-dependencies] substrate-test-utils = { path = "../../test/utils" } diff --git a/primitives/sr-primitives/Cargo.toml b/primitives/runtime/Cargo.toml similarity index 100% rename from primitives/sr-primitives/Cargo.toml rename to primitives/runtime/Cargo.toml diff --git a/primitives/sr-primitives/src/curve.rs b/primitives/runtime/src/curve.rs similarity index 100% rename from primitives/sr-primitives/src/curve.rs rename to primitives/runtime/src/curve.rs diff --git a/primitives/sr-primitives/src/generic/block.rs b/primitives/runtime/src/generic/block.rs similarity index 100% rename from primitives/sr-primitives/src/generic/block.rs rename to primitives/runtime/src/generic/block.rs diff --git a/primitives/sr-primitives/src/generic/checked_extrinsic.rs b/primitives/runtime/src/generic/checked_extrinsic.rs similarity index 100% rename from primitives/sr-primitives/src/generic/checked_extrinsic.rs rename to primitives/runtime/src/generic/checked_extrinsic.rs diff --git a/primitives/sr-primitives/src/generic/digest.rs b/primitives/runtime/src/generic/digest.rs similarity index 100% rename from primitives/sr-primitives/src/generic/digest.rs rename to primitives/runtime/src/generic/digest.rs diff --git a/primitives/sr-primitives/src/generic/era.rs b/primitives/runtime/src/generic/era.rs similarity index 100% rename from primitives/sr-primitives/src/generic/era.rs rename to primitives/runtime/src/generic/era.rs diff --git a/primitives/sr-primitives/src/generic/header.rs b/primitives/runtime/src/generic/header.rs similarity index 100% rename from primitives/sr-primitives/src/generic/header.rs rename to primitives/runtime/src/generic/header.rs diff --git a/primitives/sr-primitives/src/generic/mod.rs b/primitives/runtime/src/generic/mod.rs similarity index 100% rename from primitives/sr-primitives/src/generic/mod.rs rename to primitives/runtime/src/generic/mod.rs diff --git a/primitives/sr-primitives/src/generic/tests.rs b/primitives/runtime/src/generic/tests.rs similarity index 100% rename from primitives/sr-primitives/src/generic/tests.rs rename to primitives/runtime/src/generic/tests.rs diff --git a/primitives/sr-primitives/src/generic/unchecked_extrinsic.rs b/primitives/runtime/src/generic/unchecked_extrinsic.rs similarity index 100% rename from primitives/sr-primitives/src/generic/unchecked_extrinsic.rs rename to primitives/runtime/src/generic/unchecked_extrinsic.rs diff --git a/primitives/sr-primitives/src/lib.rs b/primitives/runtime/src/lib.rs similarity index 100% rename from primitives/sr-primitives/src/lib.rs rename to primitives/runtime/src/lib.rs diff --git a/primitives/sr-primitives/src/offchain/http.rs b/primitives/runtime/src/offchain/http.rs similarity index 100% rename from primitives/sr-primitives/src/offchain/http.rs rename to primitives/runtime/src/offchain/http.rs diff --git a/primitives/sr-primitives/src/offchain/mod.rs b/primitives/runtime/src/offchain/mod.rs similarity index 100% rename from primitives/sr-primitives/src/offchain/mod.rs rename to primitives/runtime/src/offchain/mod.rs diff --git a/primitives/sr-primitives/src/random_number_generator.rs b/primitives/runtime/src/random_number_generator.rs similarity index 100% rename from primitives/sr-primitives/src/random_number_generator.rs rename to primitives/runtime/src/random_number_generator.rs diff --git a/primitives/sr-primitives/src/testing.rs b/primitives/runtime/src/testing.rs similarity index 100% rename from primitives/sr-primitives/src/testing.rs rename to primitives/runtime/src/testing.rs diff --git a/primitives/sr-primitives/src/traits.rs b/primitives/runtime/src/traits.rs similarity index 100% rename from primitives/sr-primitives/src/traits.rs rename to primitives/runtime/src/traits.rs diff --git a/primitives/sr-primitives/src/transaction_validity.rs b/primitives/runtime/src/transaction_validity.rs similarity index 100% rename from primitives/sr-primitives/src/transaction_validity.rs rename to primitives/runtime/src/transaction_validity.rs diff --git a/primitives/session/Cargo.toml b/primitives/session/Cargo.toml index e1fbd3e9a9..4feda93487 100644 --- a/primitives/session/Cargo.toml +++ b/primitives/session/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] sp-api = { path = "../sr-api", default-features = false } rstd = { package = "sp-std", path = "../sr-std", default-features = false } -sp-runtime = { path = "../sr-primitives", optional = true } +sp-runtime = { path = "../runtime", optional = true } [features] default = [ "std" ] diff --git a/primitives/sr-api/Cargo.toml b/primitives/sr-api/Cargo.toml index 530c97478f..608d9e30dd 100644 --- a/primitives/sr-api/Cargo.toml +++ b/primitives/sr-api/Cargo.toml @@ -9,7 +9,7 @@ codec = { package = "parity-scale-codec", version = "1.0.0", default-features = sp-api-proc-macro = { path = "proc-macro" } primitives = { package = "sp-core", path = "../core", default-features = false } rstd = { package = "sp-std", path = "../sr-std", default-features = false } -sp-runtime = { path = "../sr-primitives", default-features = false } +sp-runtime = { path = "../runtime", default-features = false } sp-version = { path = "../sr-version", default-features = false } state-machine = { package = "sp-state-machine", path = "../../primitives/state-machine", optional = true } diff --git a/primitives/sr-api/proc-macro/Cargo.toml b/primitives/sr-api/proc-macro/Cargo.toml index 5654369fe1..a4f2ee5d28 100644 --- a/primitives/sr-api/proc-macro/Cargo.toml +++ b/primitives/sr-api/proc-macro/Cargo.toml @@ -16,7 +16,7 @@ proc-macro-crate = "0.1.4" [dev-dependencies] sp-api = { path = ".." } -sp-runtime = { path = "../../sr-primitives" } +sp-runtime = { path = "../../runtime" } sp-version = { path = "../../sr-version" } test-client = { package = "substrate-test-runtime-client", path = "../../../test/utils/runtime/client" } diff --git a/primitives/sr-api/test/Cargo.toml b/primitives/sr-api/test/Cargo.toml index af3aaf67fa..61d3a87547 100644 --- a/primitives/sr-api/test/Cargo.toml +++ b/primitives/sr-api/test/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" sp-api = { path = "../" } test-client = { package = "substrate-test-runtime-client", path = "../../../test/utils/runtime/client" } sp-version = { path = "../../sr-version" } -sp-runtime = { path = "../../sr-primitives" } +sp-runtime = { path = "../../runtime" } sp-blockchain = { path = "../../blockchain" } consensus_common = { package = "sp-consensus", path = "../../../primitives/consensus/common" } codec = { package = "parity-scale-codec", version = "1.0.0" } diff --git a/primitives/sr-staking-primitives/Cargo.toml b/primitives/sr-staking-primitives/Cargo.toml index 527364cfd0..671df45a56 100644 --- a/primitives/sr-staking-primitives/Cargo.toml +++ b/primitives/sr-staking-primitives/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" [dependencies] codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-runtime = { path = "../sr-primitives", default-features = false } +sp-runtime = { path = "../runtime", default-features = false } rstd = { package = "sp-std", path = "../sr-std", default-features = false } [features] diff --git a/primitives/sr-version/Cargo.toml b/primitives/sr-version/Cargo.toml index a26487bfca..3469fead36 100644 --- a/primitives/sr-version/Cargo.toml +++ b/primitives/sr-version/Cargo.toml @@ -9,7 +9,7 @@ impl-serde = { version = "0.2.3", optional = true } serde = { version = "1.0.101", optional = true, features = ["derive"] } codec = { package = "parity-scale-codec", version = "1.0.5", default-features = false, features = ["derive"] } rstd = { package = "sp-std", path = "../sr-std", default-features = false } -sp-runtime = { path = "../sr-primitives", default-features = false } +sp-runtime = { path = "../runtime", default-features = false } [features] default = ["std"] diff --git a/primitives/timestamp/Cargo.toml b/primitives/timestamp/Cargo.toml index a41307fde9..f4cabd6d12 100644 --- a/primitives/timestamp/Cargo.toml +++ b/primitives/timestamp/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] sp-api = { path = "../sr-api", default-features = false } rstd = { package = "sp-std", path = "../sr-std", default-features = false } -sp-runtime = { path = "../sr-primitives", default-features = false } +sp-runtime = { path = "../runtime", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } inherents = { package = "sp-inherents", path = "../inherents", default-features = false } impl-trait-for-tuples = "0.1.3" diff --git a/primitives/transaction-pool/Cargo.toml b/primitives/transaction-pool/Cargo.toml index 32714463b6..13563cc08f 100644 --- a/primitives/transaction-pool/Cargo.toml +++ b/primitives/transaction-pool/Cargo.toml @@ -12,7 +12,7 @@ log = { version = "0.4.8", optional = true } primitives = { package = "sp-core", path = "../core", optional = true} serde = { version = "1.0.101", features = ["derive"], optional = true} sp-api = { path = "../sr-api", default-features = false } -sp-runtime = { path = "../sr-primitives", default-features = false } +sp-runtime = { path = "../runtime", default-features = false } [features] std = [ diff --git a/test/utils/client/Cargo.toml b/test/utils/client/Cargo.toml index 02f54b9ca9..e3375099e3 100644 --- a/test/utils/client/Cargo.toml +++ b/test/utils/client/Cargo.toml @@ -15,6 +15,6 @@ hash-db = "0.15.2" keyring = { package = "sp-keyring", path = "../../../primitives/keyring" } codec = { package = "parity-scale-codec", version = "1.0.0" } primitives = { package = "sp-core", path = "../../../primitives/core" } -sp-runtime = { path = "../../../primitives/sr-primitives" } +sp-runtime = { path = "../../../primitives/runtime" } sp-blockchain = { path = "../../../primitives/blockchain" } state_machine = { package = "sp-state-machine", path = "../../../primitives/state-machine" } diff --git a/test/utils/primitives/Cargo.toml b/test/utils/primitives/Cargo.toml index 9b06e040fc..f0199032a4 100644 --- a/test/utils/primitives/Cargo.toml +++ b/test/utils/primitives/Cargo.toml @@ -9,7 +9,7 @@ app-crypto = { package = "sc-application-crypto", path = "../../../primitives/ap codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } primitives = { package = "sp-core", path = "../../../primitives/core", default-features = false } serde = { version = "1.0.101", optional = true, features = ["derive"] } -sp-runtime = { path = "../../../primitives/sr-primitives", default-features = false } +sp-runtime = { path = "../../../primitives/runtime", default-features = false } [features] default = [ diff --git a/test/utils/runtime/Cargo.toml b/test/utils/runtime/Cargo.toml index e1a34caff8..2523593499 100644 --- a/test/utils/runtime/Cargo.toml +++ b/test/utils/runtime/Cargo.toml @@ -27,7 +27,7 @@ runtime_version = { package = "sp-version", path = "../../../primitives/sr-versi serde = { version = "1.0.101", optional = true, features = ["derive"] } session = { package = "sp-session", path = "../../../primitives/session", default-features = false } sp-api = { path = "../../../primitives/sr-api", default-features = false } -sp-runtime = { path = "../../../primitives/sr-primitives", default-features = false } +sp-runtime = { path = "../../../primitives/runtime", default-features = false } pallet-babe = { path = "../../../frame/babe", default-features = false } frame-system = { path = "../../../frame/system", default-features = false } frame-system-rpc-runtime-api = { path = "../../../frame/system/rpc/runtime-api", default-features = false } diff --git a/test/utils/runtime/client/Cargo.toml b/test/utils/runtime/client/Cargo.toml index 21b16c5496..34b9a73fdc 100644 --- a/test/utils/runtime/client/Cargo.toml +++ b/test/utils/runtime/client/Cargo.toml @@ -9,7 +9,7 @@ block-builder = { package = "sc-block-builder", path = "../../../../client/block generic-test-client = { package = "substrate-test-client", path = "../../client" } primitives = { package = "sp-core", path = "../../../../primitives/core" } runtime = { package = "substrate-test-runtime", path = "../../runtime" } -sp-runtime = { path = "../../../../primitives/sr-primitives" } +sp-runtime = { path = "../../../../primitives/runtime" } sp-blockchain = { path = "../../../../primitives/blockchain" } codec = { package = "parity-scale-codec", version = "1.0.0" } client-api = { package = "sc-client-api", path = "../../../../client/api" } diff --git a/test/utils/transaction-factory/Cargo.toml b/test/utils/transaction-factory/Cargo.toml index 1414e3baa1..1cfc1b7696 100644 --- a/test/utils/transaction-factory/Cargo.toml +++ b/test/utils/transaction-factory/Cargo.toml @@ -14,7 +14,6 @@ consensus_common = { package = "sp-consensus", path = "../../../primitives/conse log = "0.4.8" primitives = { package = "sp-core", path = "../../../primitives/core" } sp-api = { path = "../../../primitives/sr-api" } -sp-runtime = { path = "../../../primitives/sr-primitives" } +sp-runtime = { path = "../../../primitives/runtime" } sc-service = { path = "../../../client/service" } sp-blockchain = { path = "../../../primitives/blockchain" } - diff --git a/utils/frame/rpc/system/Cargo.toml b/utils/frame/rpc/system/Cargo.toml index 8447eef7bc..d2273f941d 100644 --- a/utils/frame/rpc/system/Cargo.toml +++ b/utils/frame/rpc/system/Cargo.toml @@ -13,7 +13,7 @@ jsonrpc-core-client = "14.0.3" jsonrpc-derive = "14.0.3" log = "0.4.8" serde = { version = "1.0.101", features = ["derive"] } -sp-runtime = { path = "../../../../primitives/sr-primitives" } +sp-runtime = { path = "../../../../primitives/runtime" } frame-system-rpc-runtime-api = { path = "../../../../frame/system/rpc/runtime-api" } sp-core = { path = "../../../../primitives/core" } sp-blockchain = { path = "../../../../primitives/blockchain" } -- GitLab From 3d0c93f4d60be73ed4b11fd0777795902d4b78a9 Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Mon, 9 Dec 2019 14:47:46 +0100 Subject: [PATCH 099/172] Use header metadata in state full and refactor. (#3757) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Use header metadata in state full and refactor. * better log Co-Authored-By: Tomasz Drwięga * Apply review suggestions. --- client/rpc/src/state/state_full.rs | 125 +++++++++++++++-------------- client/rpc/src/state/tests.rs | 93 +++++++++++++++++++++ 2 files changed, 158 insertions(+), 60 deletions(-) diff --git a/client/rpc/src/state/state_full.rs b/client/rpc/src/state/state_full.rs index 698d42f101..582d3a0e7e 100644 --- a/client/rpc/src/state/state_full.rs +++ b/client/rpc/src/state/state_full.rs @@ -29,7 +29,9 @@ use rpc::{ use api::Subscriptions; use client_api::backend::Backend; -use sp_blockchain::Result as ClientResult; +use sp_blockchain::{ + Result as ClientResult, Error as ClientError, HeaderMetadata, CachedHeaderMetadata +}; use client::{ Client, CallExecutor, BlockchainEvents, }; @@ -40,7 +42,7 @@ use runtime_version::RuntimeVersion; use state_machine::ExecutionStrategy; use sp_runtime::{ generic::BlockId, - traits::{Block as BlockT, Header, NumberFor, ProvideRuntimeApi, SaturatedConversion}, + traits::{Block as BlockT, NumberFor, ProvideRuntimeApi, SaturatedConversion}, }; use sp_api::Metadata; @@ -91,59 +93,49 @@ impl FullState from: Block::Hash, to: Option ) -> Result> { - let to = self.block_or_best(to).map_err(client_err)?; - let from_hdr = self.client.header(&BlockId::hash(from)).map_err(client_err)?; - let to_hdr = self.client.header(&BlockId::hash(to)).map_err(client_err)?; - match (from_hdr, to_hdr) { - (Some(ref from), Some(ref to)) if from.number() <= to.number() => { - // check if we can get from `to` to `from` by going through parent_hashes. - let from_number = *from.number(); - let blocks = { - let mut blocks = vec![to.hash()]; - let mut last = to.clone(); - while *last.number() > from_number { - let hdr = self.client - .header(&BlockId::hash(*last.parent_hash())) - .map_err(client_err)?; - if let Some(hdr) = hdr { - blocks.push(hdr.hash()); - last = hdr; - } else { - return Err(invalid_block_range( - Some(from), - Some(to), - format!("Parent of {} ({}) not found", last.number(), last.hash()), - )) - } - } - if last.hash() != from.hash() { - return Err(invalid_block_range( - Some(from), - Some(to), - format!("Expected to reach `from`, got {} ({})", last.number(), last.hash()), - )) - } - blocks.reverse(); - blocks - }; - // check if we can filter blocks-with-changes from some (sub)range using changes tries - let changes_trie_range = self.client - .max_key_changes_range(from_number, BlockId::Hash(to.hash())) - .map_err(client_err)?; - let filtered_range_begin = changes_trie_range - .map(|(begin, _)| (begin - from_number).saturated_into::()); - let (unfiltered_range, filtered_range) = split_range(blocks.len(), filtered_range_begin); - Ok(QueryStorageRange { - hashes: blocks, - first_number: from_number, - unfiltered_range, - filtered_range, - }) - }, - (from, to) => Err( - invalid_block_range(from.as_ref(), to.as_ref(), "Invalid range or unknown block".into()) - ), + let to = self.block_or_best(to).map_err(|e| invalid_block::(from, to, e.to_string()))?; + + let invalid_block_err = |e: ClientError| invalid_block::(from, Some(to), e.to_string()); + let from_meta = self.client.header_metadata(from).map_err(invalid_block_err)?; + let to_meta = self.client.header_metadata(to).map_err(invalid_block_err)?; + + if from_meta.number >= to_meta.number { + return Err(invalid_block_range(&from_meta, &to_meta, "from number >= to number".to_owned())) } + + // check if we can get from `to` to `from` by going through parent_hashes. + let from_number = from_meta.number; + let hashes = { + let mut hashes = vec![to_meta.hash]; + let mut last = to_meta.clone(); + while last.number > from_number { + let header_metadata = self.client + .header_metadata(last.parent) + .map_err(|e| invalid_block_range::(&last, &to_meta, e.to_string()))?; + hashes.push(header_metadata.hash); + last = header_metadata; + } + if last.hash != from_meta.hash { + return Err(invalid_block_range(&from_meta, &to_meta, "from and to are on different forks".to_owned())) + } + hashes.reverse(); + hashes + }; + + // check if we can filter blocks-with-changes from some (sub)range using changes tries + let changes_trie_range = self.client + .max_key_changes_range(from_number, BlockId::Hash(to_meta.hash)) + .map_err(client_err)?; + let filtered_range_begin = changes_trie_range + .map(|(begin, _)| (begin - from_number).saturated_into::()); + let (unfiltered_range, filtered_range) = split_range(hashes.len(), filtered_range_begin); + + Ok(QueryStorageRange { + hashes, + first_number: from_number, + unfiltered_range, + filtered_range, + }) } /// Iterates through range.unfiltered_range and check each block for changes of keys' values. @@ -501,15 +493,28 @@ pub(crate) fn split_range(size: usize, middle: Option) -> (Range, (range1, range2) } -fn invalid_block_range(from: Option<&H>, to: Option<&H>, reason: String) -> Error { - let to_string = |x: Option<&H>| match x { - None => "unknown hash".into(), - Some(h) => format!("{} ({})", h.number(), h.hash()), - }; +fn invalid_block_range( + from: &CachedHeaderMetadata, + to: &CachedHeaderMetadata, + details: String, +) -> Error { + let to_string = |h: &CachedHeaderMetadata| format!("{} ({:?})", h.number, h.hash); Error::InvalidBlockRange { from: to_string(from), to: to_string(to), - details: reason, + details, + } +} + +fn invalid_block( + from: B::Hash, + to: Option, + details: String, +) -> Error { + Error::InvalidBlockRange { + from: format!("{:?}", from), + to: format!("{:?}", to), + details, } } diff --git a/client/rpc/src/state/tests.rs b/client/rpc/src/state/tests.rs index b77e5a8291..2ae22df1a0 100644 --- a/client/rpc/src/state/tests.rs +++ b/client/rpc/src/state/tests.rs @@ -22,6 +22,7 @@ use std::sync::Arc; use assert_matches::assert_matches; use futures01::stream::Stream; use primitives::storage::well_known_keys; +use primitives::hash::H256; use sp_io::hashing::blake2_256; use test_client::{ prelude::*, @@ -255,6 +256,98 @@ fn should_query_storage() { ], }); assert_eq!(result.wait().unwrap(), expected); + + // Query changes up to block2. + let result = api.query_storage( + keys.clone(), + genesis_hash, + Some(block2_hash), + ); + + assert_eq!(result.wait().unwrap(), expected); + + // Inverted range. + let result = api.query_storage( + keys.clone(), + block1_hash, + Some(genesis_hash), + ); + + assert_eq!( + result.wait().map_err(|e| e.to_string()), + Err(Error::InvalidBlockRange { + from: format!("1 ({:?})", block1_hash), + to: format!("0 ({:?})", genesis_hash), + details: "from number >= to number".to_owned(), + }).map_err(|e| e.to_string()) + ); + + let random_hash1 = H256::random(); + let random_hash2 = H256::random(); + + // Invalid second hash. + let result = api.query_storage( + keys.clone(), + genesis_hash, + Some(random_hash1), + ); + + assert_eq!( + result.wait().map_err(|e| e.to_string()), + Err(Error::InvalidBlockRange { + from: format!("{:?}", genesis_hash), + to: format!("{:?}", Some(random_hash1)), + details: format!("UnknownBlock: header not found in db: {}", random_hash1), + }).map_err(|e| e.to_string()) + ); + + // Invalid first hash with Some other hash. + let result = api.query_storage( + keys.clone(), + random_hash1, + Some(genesis_hash), + ); + + assert_eq!( + result.wait().map_err(|e| e.to_string()), + Err(Error::InvalidBlockRange { + from: format!("{:?}", random_hash1), + to: format!("{:?}", Some(genesis_hash)), + details: format!("UnknownBlock: header not found in db: {}", random_hash1), + }).map_err(|e| e.to_string()), + ); + + // Invalid first hash with None. + let result = api.query_storage( + keys.clone(), + random_hash1, + None, + ); + + assert_eq!( + result.wait().map_err(|e| e.to_string()), + Err(Error::InvalidBlockRange { + from: format!("{:?}", random_hash1), + to: format!("{:?}", Some(block2_hash)), // Best block hash. + details: format!("UnknownBlock: header not found in db: {}", random_hash1), + }).map_err(|e| e.to_string()), + ); + + // Both hashes invalid. + let result = api.query_storage( + keys.clone(), + random_hash1, + Some(random_hash2), + ); + + assert_eq!( + result.wait().map_err(|e| e.to_string()), + Err(Error::InvalidBlockRange { + from: format!("{:?}", random_hash1), // First hash not found. + to: format!("{:?}", Some(random_hash2)), + details: format!("UnknownBlock: header not found in db: {}", random_hash1), + }).map_err(|e| e.to_string()), + ); } run_tests(Arc::new(test_client::new())); -- GitLab From 8fe4b7178198c02e594f2a9964506ddcb8600d2c Mon Sep 17 00:00:00 2001 From: Benjamin Kampmann Date: Mon, 9 Dec 2019 15:47:29 +0100 Subject: [PATCH 100/172] Remove slog-async Github (#4329) * add local copy of async-record * Minor clean ups to latest rust and necessity * styling fixes * nitpicky fixes --- Cargo.lock | 23 +--- client/telemetry/Cargo.toml | 4 +- client/telemetry/src/async_record.rs | 156 +++++++++++++++++++++++++++ client/telemetry/src/lib.rs | 7 +- 4 files changed, 162 insertions(+), 28 deletions(-) create mode 100644 client/telemetry/src/async_record.rs diff --git a/Cargo.lock b/Cargo.lock index 1e78423f41..4d200d1ea8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -767,14 +767,6 @@ dependencies = [ "itertools 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "crossbeam-channel" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "crossbeam-channel" version = "0.4.0" @@ -5587,9 +5579,9 @@ dependencies = [ "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "slog-async 2.3.0 (git+https://github.com/paritytech/slog-async)", "slog-json 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "slog-scope 4.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "take_mut 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5850,17 +5842,6 @@ dependencies = [ "erased-serde 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "slog-async" -version = "2.3.0" -source = "git+https://github.com/paritytech/slog-async#107848e7ded5e80dc43f6296c2b96039eb92c0a5" -dependencies = [ - "crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "take_mut 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "slog-json" version = "2.3.0" @@ -8084,7 +8065,6 @@ dependencies = [ "checksum criterion 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "938703e165481c8d612ea3479ac8342e5615185db37765162e762ec3523e2fc6" "checksum criterion-plot 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "76f9212ddf2f4a9eb2d401635190600656a1f88a932ef53d06e7fa4c7e02fb8e" "checksum criterion-plot 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "eccdc6ce8bbe352ca89025bee672aa6d24f4eb8c53e3a8b5d1bc58011da072a2" -"checksum crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c8ec7fcd21571dc78f96cc96243cab8d8f035247c3efd16c687be154c3fa9efa" "checksum crossbeam-channel 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "acec9a3b0b3559f15aee4f90746c4e5e293b701c0f7d3925d24e01645267b68c" "checksum crossbeam-deque 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c3aa945d63861bfe624b55d153a39684da1e8c0bc8fba932f7ee3a3c16cea3ca" "checksum crossbeam-epoch 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5064ebdbf05ce3cb95e45c8b086f72263f4166b29b97f6baff7ef7fe047b55ac" @@ -8421,7 +8401,6 @@ dependencies = [ "checksum shlex 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2" "checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" "checksum slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1cc9c640a4adbfbcc11ffb95efe5aa7af7309e002adab54b185507dbf2377b99" -"checksum slog-async 2.3.0 (git+https://github.com/paritytech/slog-async)" = "" "checksum slog-json 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ddc0d2aff1f8f325ef660d9a0eb6e6dcd20b30b3f581a5897f58bf42d061c37a" "checksum slog-scope 4.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7c44c89dd8b0ae4537d1ae318353eaf7840b4869c536e31c41e963d1ea523ee6" "checksum slog_derive 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a945ec7f7ce853e89ffa36be1e27dce9a43e82ff9093bf3461c30d5da74ed11b" diff --git a/client/telemetry/Cargo.toml b/client/telemetry/Cargo.toml index bb18268275..0fdacc5d79 100644 --- a/client/telemetry/Cargo.toml +++ b/client/telemetry/Cargo.toml @@ -16,10 +16,8 @@ log = "0.4.8" rand = "0.7.2" serde = { version = "1.0.101", features = ["derive"] } slog = { version = "2.5.2", features = ["nested-values"] } -# TODO: we're using slog-async just to be able to clone records; See https://github.com/slog-rs/slog/issues/221, -# https://github.com/paritytech/substrate/issues/2823 and https://github.com/paritytech/substrate/issues/3260 -slog-async = { git = "https://github.com/paritytech/slog-async", features = ["nested-values"] } slog-json = { version = "2.3.0", features = ["nested-values"] } slog-scope = "4.1.2" tokio-io = "0.1.12" +take_mut = "0.2.2" void = "1.0.2" diff --git a/client/telemetry/src/async_record.rs b/client/telemetry/src/async_record.rs new file mode 100644 index 0000000000..302c98c1a5 --- /dev/null +++ b/client/telemetry/src/async_record.rs @@ -0,0 +1,156 @@ +//! # Internal types to ssync drain slog +//! FIXME: REMOVE THIS ONCE THE PR WAS MERGE +//! https://github.com/slog-rs/async/pull/14 + +use slog::{Record, RecordStatic, Level, SingleKV, KV, BorrowedKV}; +use slog::{Serializer, OwnedKVList, Key}; + +use std::fmt; +use take_mut::take; + +struct ToSendSerializer { + kv: Box, +} + +impl ToSendSerializer { + fn new() -> Self { + ToSendSerializer { kv: Box::new(()) } + } + + fn finish(self) -> Box { + self.kv + } +} + +impl Serializer for ToSendSerializer { + fn emit_bool(&mut self, key: Key, val: bool) -> slog::Result { + take(&mut self.kv, |kv| Box::new((kv, SingleKV(key, val)))); + Ok(()) + } + fn emit_unit(&mut self, key: Key) -> slog::Result { + take(&mut self.kv, |kv| Box::new((kv, SingleKV(key, ())))); + Ok(()) + } + fn emit_none(&mut self, key: Key) -> slog::Result { + let val: Option<()> = None; + take(&mut self.kv, |kv| Box::new((kv, SingleKV(key, val)))); + Ok(()) + } + fn emit_char(&mut self, key: Key, val: char) -> slog::Result { + take(&mut self.kv, |kv| Box::new((kv, SingleKV(key, val)))); + Ok(()) + } + fn emit_u8(&mut self, key: Key, val: u8) -> slog::Result { + take(&mut self.kv, |kv| Box::new((kv, SingleKV(key, val)))); + Ok(()) + } + fn emit_i8(&mut self, key: Key, val: i8) -> slog::Result { + take(&mut self.kv, |kv| Box::new((kv, SingleKV(key, val)))); + Ok(()) + } + fn emit_u16(&mut self, key: Key, val: u16) -> slog::Result { + take(&mut self.kv, |kv| Box::new((kv, SingleKV(key, val)))); + Ok(()) + } + fn emit_i16(&mut self, key: Key, val: i16) -> slog::Result { + take(&mut self.kv, |kv| Box::new((kv, SingleKV(key, val)))); + Ok(()) + } + fn emit_u32(&mut self, key: Key, val: u32) -> slog::Result { + take(&mut self.kv, |kv| Box::new((kv, SingleKV(key, val)))); + Ok(()) + } + fn emit_i32(&mut self, key: Key, val: i32) -> slog::Result { + take(&mut self.kv, |kv| Box::new((kv, SingleKV(key, val)))); + Ok(()) + } + fn emit_f32(&mut self, key: Key, val: f32) -> slog::Result { + take(&mut self.kv, |kv| Box::new((kv, SingleKV(key, val)))); + Ok(()) + } + fn emit_u64(&mut self, key: Key, val: u64) -> slog::Result { + take(&mut self.kv, |kv| Box::new((kv, SingleKV(key, val)))); + Ok(()) + } + fn emit_i64(&mut self, key: Key, val: i64) -> slog::Result { + take(&mut self.kv, |kv| Box::new((kv, SingleKV(key, val)))); + Ok(()) + } + fn emit_f64(&mut self, key: Key, val: f64) -> slog::Result { + take(&mut self.kv, |kv| Box::new((kv, SingleKV(key, val)))); + Ok(()) + } + fn emit_usize(&mut self, key: Key, val: usize) -> slog::Result { + take(&mut self.kv, |kv| Box::new((kv, SingleKV(key, val)))); + Ok(()) + } + fn emit_isize(&mut self, key: Key, val: isize) -> slog::Result { + take(&mut self.kv, |kv| Box::new((kv, SingleKV(key, val)))); + Ok(()) + } + fn emit_str(&mut self, key: Key, val: &str) -> slog::Result { + let val = val.to_owned(); + take(&mut self.kv, |kv| Box::new((kv, SingleKV(key, val)))); + Ok(()) + } + fn emit_arguments( + &mut self, + key: Key, + val: &fmt::Arguments, + ) -> slog::Result { + let val = fmt::format(*val); + take(&mut self.kv, |kv| Box::new((kv, SingleKV(key, val)))); + Ok(()) + } + + #[cfg(feature = "nested-values")] + fn emit_serde(&mut self, key: Key, value: &slog::SerdeValue) -> slog::Result { + let val = value.to_sendable(); + take(&mut self.kv, |kv| Box::new((kv, SingleKV(key, val)))); + Ok(()) + } +} + +pub(crate) struct AsyncRecord { + msg: String, + level: Level, + location: Box, + tag: String, + logger_values: OwnedKVList, + kv: Box, +} + +impl AsyncRecord { + /// Serializes a `Record` and an `OwnedKVList`. + pub fn from(record: &Record, logger_values: &OwnedKVList) -> Self { + let mut ser = ToSendSerializer::new(); + record + .kv() + .serialize(record, &mut ser) + .expect("`ToSendSerializer` can't fail"); + + AsyncRecord { + msg: fmt::format(*record.msg()), + level: record.level(), + location: Box::new(*record.location()), + tag: String::from(record.tag()), + logger_values: logger_values.clone(), + kv: ser.finish(), + } + } + + /// Deconstruct this `AsyncRecord` into a record and `OwnedKVList`. + pub fn as_record_values(&self, mut f: impl FnMut(&Record, &OwnedKVList)) { + let rs = RecordStatic { + location: &*self.location, + level: self.level, + tag: &self.tag, + }; + + f(&Record::new( + &rs, + &format_args!("{}", self.msg), + BorrowedKV(&self.kv), + ), &self.logger_values) + } +} \ No newline at end of file diff --git a/client/telemetry/src/lib.rs b/client/telemetry/src/lib.rs index b4cc756bf0..bc2e9aa691 100644 --- a/client/telemetry/src/lib.rs +++ b/client/telemetry/src/lib.rs @@ -68,6 +68,7 @@ use std::{pin::Pin, sync::Arc, task::{Context, Poll}, time::{Duration, Instant}} pub use slog_scope::with_logger; pub use slog; +mod async_record; mod worker; /// Configuration for telemetry. @@ -131,13 +132,13 @@ struct TelemetryInner { /// Worker for the telemetry. worker: worker::TelemetryWorker, /// Receives log entries for them to be dispatched to the worker. - receiver: mpsc::Receiver, + receiver: mpsc::Receiver, } /// Implements `slog::Drain`. struct TelemetryDrain { /// Sends log entries. - sender: std::panic::AssertUnwindSafe>, + sender: std::panic::AssertUnwindSafe>, } /// Initializes the telemetry. See the crate root documentation for more information. @@ -241,7 +242,7 @@ impl slog::Drain for TelemetryDrain { fn log(&self, record: &slog::Record, values: &slog::OwnedKVList) -> Result { let before = Instant::now(); - let serialized = slog_async::AsyncRecord::from(record, values); + let serialized = async_record::AsyncRecord::from(record, values); // Note: interestingly, `try_send` requires a `&mut` because it modifies some internal value, while `clone()` // is lock-free. if let Err(err) = self.sender.clone().try_send(serialized) { -- GitLab From 9bc29f8cc762444d15041a9a2f3b9169dd2c345b Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Mon, 9 Dec 2019 16:28:20 +0100 Subject: [PATCH 101/172] More comprehensive identity system (#4326) * Initial prototype * Work on test harness. * Minor removal * Add some tests * Fix tests * More tests * Final tests * General documentation * Function-level docs. * Function-level docs. * Identity fields. * Fix dependency * Docs * Spelling nits * Address grumbles. --- Cargo.lock | 36 ++ Cargo.toml | 1 + frame/identity/Cargo.toml | 31 ++ frame/identity/src/lib.rs | 1042 +++++++++++++++++++++++++++++++++++++ frame/nicks/Cargo.toml | 2 +- 5 files changed, 1111 insertions(+), 1 deletion(-) create mode 100644 frame/identity/Cargo.toml create mode 100644 frame/identity/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 4d200d1ea8..0fab5b2a5c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1010,6 +1010,24 @@ dependencies = [ "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "enumflags2" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "enumflags2_derive 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "enumflags2_derive" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "env_logger" version = "0.6.2" @@ -3715,6 +3733,22 @@ dependencies = [ "sp-std 2.0.0", ] +[[package]] +name = "pallet-identity" +version = "2.0.0" +dependencies = [ + "enumflags2 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "frame-support 2.0.0", + "frame-system 2.0.0", + "pallet-balances 2.0.0", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-core 2.0.0", + "sp-io 2.0.0", + "sp-runtime 2.0.0", + "sp-std 2.0.0", +] + [[package]] name = "pallet-im-online" version = "0.1.0" @@ -8093,6 +8127,8 @@ dependencies = [ "checksum ed25519-dalek 1.0.0-pre.2 (registry+https://github.com/rust-lang/crates.io-index)" = "845aaacc16f01178f33349e7c992ecd0cee095aa5e577f0f4dee35971bd36455" "checksum either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" "checksum elastic-array 0.10.3 (registry+https://github.com/rust-lang/crates.io-index)" = "580f3768bd6465780d063f5b8213a2ebd506e139b345e4a81eb301ceae3d61e1" +"checksum enumflags2 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "33121c8782ba948ba332dab29311b026a8716dc65a1599e5b88f392d38496af8" +"checksum enumflags2_derive 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ecf634c5213044b8d54a46dd282cf5dd1f86bb5cb53e92c409cb4680a7fb9894" "checksum env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3" "checksum env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" "checksum environmental 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "34f8467a0284de039e6bd0e25c14519538462ba5beb548bb1f03e645097837a8" diff --git a/Cargo.toml b/Cargo.toml index dd424b4d76..1ba46daebd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -63,6 +63,7 @@ members = [ "frame/finality-tracker", "frame/generic-asset", "frame/grandpa", + "frame/identity", "frame/im-online", "frame/indices", "frame/membership", diff --git a/frame/identity/Cargo.toml b/frame/identity/Cargo.toml new file mode 100644 index 0000000000..6b81433f0b --- /dev/null +++ b/frame/identity/Cargo.toml @@ -0,0 +1,31 @@ +[package] +name = "pallet-identity" +version = "2.0.0" +authors = ["Parity Technologies "] +edition = "2018" + +[dependencies] +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" } +rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +runtime-io = { package = "sp-io", path = "../../primitives/sr-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 } + +[dev-dependencies] +primitives = { package = "sp-core", path = "../../primitives/core" } +balances = { package = "pallet-balances", path = "../balances" } + +[features] +default = ["std"] +std = [ + "serde", + "codec/std", + "rstd/std", + "runtime-io/std", + "sp-runtime/std", + "support/std", + "system/std", +] diff --git a/frame/identity/src/lib.rs b/frame/identity/src/lib.rs new file mode 100644 index 0000000000..e51df5eed2 --- /dev/null +++ b/frame/identity/src/lib.rs @@ -0,0 +1,1042 @@ +// Copyright 2019 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Substrate is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Substrate. If not, see . + +//! # Identity Module +//! +//! - [`identity::Trait`](./trait.Trait.html) +//! - [`Call`](./enum.Call.html) +//! +//! ## Overview +//! +//! A federated naming system, allowing for multiple registrars to be added from a specified origin. +//! Registrars can set a fee to provide identity-verification service. Anyone can put forth a +//! proposed identity for a fixed deposit and ask for review by any number of registrars (paying +//! each of their fees). Registrar judgements are given as an `enum`, allowing for sophisticated, +//! multi-tier opinions. +//! +//! Some judgements are identified as *sticky*, which means they cannot be removed except by +//! complete removal of the identity, or by the registrar. Judgements are allowed to represent a +//! portion of funds that have been reserved for the registrar. +//! +//! A super-user can remove accounts and in doing so, slash the deposit. +//! +//! All accounts may also have a limited number of sub-accounts which may be specified by the owner; +//! by definition, these have equivalent ownership and each has an individual name. +//! +//! The number of registrars should be limited, and the deposit made sufficiently large, to ensure +//! no state-bloat attack is viable. +//! +//! ## Interface +//! +//! ### Dispatchable Functions +//! +//! #### For general users +//! * `set_identity` - Set the associated identity of an account; a small deposit is reserved if not +//! already taken. +//! * `set_subs` - Set the sub-accounts of an identity. +//! * `clear_identity` - Remove an account's associated identity; the deposit is returned. +//! * `request_judgement` - Request a judgement from a registrar, paying a fee. +//! * `cancel_request` - Cancel the previous request for a judgement. +//! +//! #### For registrars +//! * `set_fee` - Set the fee required to be paid for a judgement to be given by the registrar. +//! * `set_fields` - Set the fields that a registrar cares about in their judgements. +//! * `provide_judgement` - Provide a judgement to an identity. +//! +//! #### For super-users +//! * `add_registrar` - Add a new registrar to the system. +//! * `kill_identity` - Forcibly remove the associated identity; the deposit is lost. +//! +//! [`Call`]: ./enum.Call.html +//! [`Trait`]: ./trait.Trait.html + +#![cfg_attr(not(feature = "std"), no_std)] + +use rstd::prelude::*; +use rstd::{fmt::Debug, ops::Add, iter::once}; +use enumflags2::BitFlags; +use codec::{Encode, Decode}; +use sp_runtime::{traits::{StaticLookup, EnsureOrigin, Zero}, RuntimeDebug}; +use support::{ + decl_module, decl_event, decl_storage, ensure, dispatch::Result, + traits::{Currency, ReservableCurrency, OnUnbalanced, Get}, + weights::SimpleDispatchInfo, +}; +use system::{ensure_signed, ensure_root}; + +type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; +type NegativeImbalanceOf = <::Currency as Currency<::AccountId>>::NegativeImbalance; + +pub trait Trait: system::Trait { + /// The overarching event type. + type Event: From> + Into<::Event>; + + /// The currency trait. + type Currency: ReservableCurrency; + + /// The amount held on deposit for a registered identity. + type BasicDeposit: Get>; + + /// The amount held on deposit per additional field for a registered identity. + type FieldDeposit: Get>; + + /// The amount held on deposit for a registered subaccount. + type SubAccountDeposit: Get>; + + /// The amount held on deposit for a registered subaccount. + type MaximumSubAccounts: Get; + + /// What to do with slashed funds. + type Slashed: OnUnbalanced>; + + /// The origin which may forcibly set or remove a name. Root can always do this. + type ForceOrigin: EnsureOrigin; + + /// The origin which may add or remove registrars. Root can always do this. + type RegistrarOrigin: EnsureOrigin; +} + +/// Either underlying data blob if it is at most 32 bytes, or a hash of it. If the data is greater +/// than 32-bytes then it will be truncated when encoding. +/// +/// Can also be `None`. +#[derive(Clone, Eq, PartialEq, RuntimeDebug)] +pub enum Data { + /// No data here. + None, + /// The data is stored directly. + Raw(Vec), + /// Only the Blake2 hash of the data is stored. The preimage of the hash may be retrieved + /// through some hash-lookup service. + BlakeTwo256([u8; 32]), + /// Only the SHA2-256 hash of the data is stored. The preimage of the hash may be retrieved + /// through some hash-lookup service. + Sha256([u8; 32]), + /// Only the Keccak-256 hash of the data is stored. The preimage of the hash may be retrieved + /// through some hash-lookup service. + Keccak256([u8; 32]), + /// Only the SHA3-256 hash of the data is stored. The preimage of the hash may be retrieved + /// through some hash-lookup service. + ShaThree256([u8; 32]), +} + +impl Decode for Data { + fn decode(input: &mut I) -> rstd::result::Result { + let b = input.read_byte()?; + Ok(match b { + 0 => Data::None, + n @ 1 ..= 33 => { + let mut r = vec![0u8; n as usize - 1]; + input.read(&mut r[..])?; + Data::Raw(r) + } + 34 => Data::BlakeTwo256(<[u8; 32]>::decode(input)?), + 35 => Data::Sha256(<[u8; 32]>::decode(input)?), + 36 => Data::Keccak256(<[u8; 32]>::decode(input)?), + 37 => Data::ShaThree256(<[u8; 32]>::decode(input)?), + _ => return Err(codec::Error::from("invalid leading byte")), + }) + } +} + +impl Encode for Data { + fn encode(&self) -> Vec { + match self { + Data::None => vec![0u8; 1], + Data::Raw(ref x) => { + let l = x.len().min(32); + let mut r = vec![l as u8 + 1; l + 1]; + &mut r[1..].copy_from_slice(&x[..l as usize]); + r + } + Data::BlakeTwo256(ref h) => once(34u8).chain(h.iter().cloned()).collect(), + Data::Sha256(ref h) => once(35u8).chain(h.iter().cloned()).collect(), + Data::Keccak256(ref h) => once(36u8).chain(h.iter().cloned()).collect(), + Data::ShaThree256(ref h) => once(37u8).chain(h.iter().cloned()).collect(), + } + } +} +impl codec::EncodeLike for Data {} + +impl Default for Data { + fn default() -> Self { + Self::None + } +} + +/// An identifier for a single name registrar/identity verification service. +pub type RegistrarIndex = u32; + +/// An attestation of a registrar over how accurate some `IdentityInfo` is in describing an account. +/// +/// NOTE: Registrars may pay little attention to some fields. Registrars may want to make clear +/// which fields their attestation is relevant for by off-chain means. +#[derive(Copy, Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug)] +pub enum Judgement< + Balance: Encode + Decode + Copy + Clone + Debug + Eq + PartialEq +> { + /// The default value; no opinion is held. + Unknown, + /// No judgement is yet in place, but a deposit is reserved as payment for providing one. + FeePaid(Balance), + /// The data appears to be reasonably acceptable in terms of its accuracy, however no in depth + /// checks (such as in-person meetings or formal KYC) have been conducted. + Reasonable, + /// The target is known directly by the registrar and can fully attest to being accurate. + KnownGood, + /// The data was once good but is currently out of date. There is no malicious intent in the + /// inaccuracy. This judgement can be removed through updating the data. + OutOfDate, + /// The data is imprecise or of sufficiently low-quality to be problematic. It is not + /// indicative of malicious intent. This judgement can be removed through updating the data. + LowQuality, + /// The data is erroneous. This may be indicative of malicious intent. This cannot be removed + /// except by the registrar. + Erroneous, +} + +impl< + Balance: Encode + Decode + Copy + Clone + Debug + Eq + PartialEq +> Judgement { + /// Returns `true` if this judgement is indicative of a deposit being currently held. This means + /// it should not be cleared or replaced except by an operation which utilizes the deposit. + fn has_deposit(&self) -> bool { + match self { + Judgement::FeePaid(_) => true, + _ => false, + } + } + + /// Returns `true` if this judgement is one that should not be generally be replaced outside + /// of specialized handlers. Examples include "malicious" judgements and deposit-holding + /// judgements. + fn is_sticky(&self) -> bool { + match self { + Judgement::FeePaid(_) | Judgement::Erroneous => true, + _ => false, + } + } +} + +/// The fields that we use to identify the owner of an account with. Each corresponds to a field +/// in the `IdentityInfo` struct. +#[repr(u64)] +#[derive(Encode, Decode, Clone, Copy, PartialEq, Eq, BitFlags, RuntimeDebug)] +pub enum IdentityField { + Display = 0b0000000000000000000000000000000000000000000000000000000000000001, + Legal = 0b0000000000000000000000000000000000000000000000000000000000000010, + Web = 0b0000000000000000000000000000000000000000000000000000000000000100, + Riot = 0b0000000000000000000000000000000000000000000000000000000000001000, + Email = 0b0000000000000000000000000000000000000000000000000000000000010000, + PgpFingerprint = 0b0000000000000000000000000000000000000000000000000000000000100000, + Image = 0b0000000000000000000000000000000000000000000000000000000001000000, +} + +/// Wrapper type for `BitFlags` that implements `Codec`. +#[derive(Clone, Copy, PartialEq, Default, RuntimeDebug)] +pub struct IdentityFields(BitFlags); + +impl Eq for IdentityFields {} +impl Encode for IdentityFields { + fn using_encoded R>(&self, f: F) -> R { + self.0.bits().using_encoded(f) + } +} +impl Decode for IdentityFields { + fn decode(input: &mut I) -> rstd::result::Result { + let field = u64::decode(input)?; + Ok(Self(>::from_bits(field as u64).map_err(|_| "invalid value")?)) + } +} + +/// Information concerning the identity of the controller of an account. +/// +/// NOTE: This should be stored at the end of the storage item to facilitate the addition of extra +/// fields in a backwards compatible way through a specialized `Decode` impl. +#[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug)] +#[cfg_attr(test, derive(Default))] +pub struct IdentityInfo { + /// Additional fields of the identity that are not catered for with the structs explicit + /// fields. + pub additional: Vec<(Data, Data)>, + + /// A reasonable display name for the controller of the account. This should be whatever is it + /// that it is typically known as and should not be confusable with other entities, given + /// reasonable context. + /// + /// Stored as UTF-8. + pub display: Data, + + /// The full legal name in the local jurisdiction of the entity. This might be a bit + /// long-winded. + /// + /// Stored as UTF-8. + pub legal: Data, + + /// A representative website held by the controller of the account. + /// + /// NOTE: `https://` is automatically prepended. + /// + /// Stored as UTF-8. + pub web: Data, + + /// The Riot handle held by the controller of the account. + /// + /// Stored as UTF-8. + pub riot: Data, + + /// The email address of the controller of the account. + /// + /// Stored as UTF-8. + pub email: Data, + + /// The PGP/GPG public key of the controller of the account. + pub pgp_fingerprint: Option<[u8; 20]>, + + /// An graphic image representing the controller of the account. Should be a company, + /// organization or project logo or a headshot in the case of a human. + pub image: Data, +} + +/// Information concerning the identity of the controller of an account. +/// +/// NOTE: This is stored separately primarily to facilitate the addition of extra fields in a +/// backwards compatible way through a specialized `Decode` impl. +#[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug)] +pub struct Registration< + Balance: Encode + Decode + Copy + Clone + Debug + Eq + PartialEq +> { + /// Judgements from the registrars on this identity. Stored ordered by RegistrarIndex. There + /// may be only a single judgement from each registrar. + pub judgements: Vec<(RegistrarIndex, Judgement)>, + + /// Amount held on deposit for this information. + pub deposit: Balance, + + /// Information on the identity. + pub info: IdentityInfo, +} + +impl < + Balance: Encode + Decode + Copy + Clone + Debug + Eq + PartialEq + Zero + Add, +> Registration { + fn total_deposit(&self) -> Balance { + self.deposit + self.judgements.iter() + .map(|(_, ref j)| if let Judgement::FeePaid(fee) = j { *fee } else { Zero::zero() }) + .fold(Zero::zero(), |a, i| a + i) + } +} + +/// Information concerning the a registrar. +#[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug)] +pub struct RegistrarInfo< + Balance: Encode + Decode + Clone + Debug + Eq + PartialEq, + AccountId: Encode + Decode + Clone + Debug + Eq + PartialEq +> { + /// The account of the registrar. + pub account: AccountId, + + /// Amount required to be given to the registrar for them to check the account. + pub fee: Balance, + + /// Relevant fields for this registrar. Registrar judgements are limited to attestations on + /// these fields. + pub fields: IdentityFields, +} + +decl_storage! { + trait Store for Module as Sudo { + /// Information that is pertinent to identify the entity behind an account. + pub IdentityOf get(fn identity): map T::AccountId => Option>>; + + /// Alternative "sub" identities of this account. + /// + /// The first item is the deposit, the second is a vector of the accounts together with + /// their "local" name (i.e. in the context of the identity). + pub SubsOf get(fn subs): map T::AccountId => (BalanceOf, Vec<(T::AccountId, Data)>); + + /// The set of registrars. Not expected to get very big as can only be added through a + /// special origin (likely a council motion). + /// + /// The index into this can be cast to `RegistrarIndex` to get a valid value. + pub Registrars get(fn registrars): Vec, T::AccountId>>>; + } +} + +decl_event!( + pub enum Event where AccountId = ::AccountId, Balance = BalanceOf { + /// A name was set or reset (which will remove all judgements). + IdentitySet(AccountId), + /// A name was cleared, and the given balance returned. + IdentityCleared(AccountId, Balance), + /// A name was removed and the given balance slashed. + IdentityKilled(AccountId, Balance), + /// A judgement was asked from a registrar. + JudgementRequested(AccountId, RegistrarIndex), + /// A judgement request was retracted. + JudgementUnrequested(AccountId, RegistrarIndex), + /// A judgement was given by a registrar. + JudgementGiven(AccountId, RegistrarIndex), + /// A registrar was added. + RegistrarAdded(RegistrarIndex), + } +); + +decl_module! { + // Simple declaration of the `Module` type. Lets the macro know what it's working on. + pub struct Module for enum Call where origin: T::Origin { + fn deposit_event() = default; + + /// Add a registrar to the system. + /// + /// The dispatch origin for this call must be `RegistrarOrigin` or `Root`. + /// + /// - `account`: the account of the registrar. + /// + /// Emits `RegistrarAdded` if successful. + /// + /// # + /// - `O(R)` where `R` registrar-count (governance-bounded). + /// - One storage mutation (codec `O(R)`). + /// - One event. + /// # + #[weight = SimpleDispatchInfo::FixedNormal(10_000)] + fn add_registrar(origin, account: T::AccountId) { + T::RegistrarOrigin::try_origin(origin) + .map(|_| ()) + .or_else(ensure_root) + .map_err(|_| "bad origin")?; + + let i = >::mutate(|r| { + r.push(Some(RegistrarInfo { account, fee: Zero::zero(), fields: Default::default() })); + (r.len() - 1) as RegistrarIndex + }); + + Self::deposit_event(RawEvent::RegistrarAdded(i)); + } + + /// Set an account's identity information and reserve the appropriate deposit. + /// + /// If the account already has identity information, the deposit is taken as part payment + /// for the new deposit. + /// + /// The dispatch origin for this call must be _Signed_ and the sender must have a registered + /// identity. + /// + /// - `info`: The identity information. + /// + /// Emits `IdentitySet` if successful. + /// + /// # + /// - `O(X + R)` where `X` additional-field-count (deposit-bounded). + /// - At most two balance operations. + /// - One storage mutation (codec `O(X + R)`). + /// - One event. + /// # + #[weight = SimpleDispatchInfo::FixedNormal(50_000)] + fn set_identity(origin, info: IdentityInfo) { + let sender = ensure_signed(origin)?; + let fd = >::from(info.additional.len() as u32) * T::FieldDeposit::get(); + + let mut id = match >::get(&sender) { + Some(mut id) => { + // Only keep non-positive judgements. + id.judgements.retain(|j| j.1.is_sticky()); + id.info = info; + id + } + None => Registration { info, judgements: Vec::new(), deposit: Zero::zero() }, + }; + + let old_deposit = id.deposit; + id.deposit = T::BasicDeposit::get() + fd; + if id.deposit > old_deposit { + T::Currency::reserve(&sender, id.deposit - old_deposit)?; + } + if old_deposit > id.deposit { + let _ = T::Currency::unreserve(&sender, old_deposit - id.deposit); + } + + >::insert(&sender, id); + Self::deposit_event(RawEvent::IdentitySet(sender)); + } + + /// Set the sub-accounts of the sender. + /// + /// Payment: Any aggregate balance reserved by previous `set_subs` calls will be returned + /// and an amount `SubAccountDeposit` will be reserved for each item in `subs`. + /// + /// The dispatch origin for this call must be _Signed_ and the sender must have a registered + /// identity. + /// + /// - `subs`: The identity's sub-accounts. + /// + /// # + /// - `O(S)` where `S` subs-count (hard- and deposit-bounded). + /// - At most two balance operations. + /// - One storage mutation (codec `O(S)`); one storage-exists. + /// # + fn set_subs(origin, subs: Vec<(T::AccountId, Data)>) { + let sender = ensure_signed(origin)?; + ensure!(>::exists(&sender), "not found"); + ensure!(subs.len() <= T::MaximumSubAccounts::get() as usize, "too many subs"); + + let old_deposit = >::get(&sender).0; + let new_deposit = T::SubAccountDeposit::get() * >::from(subs.len() as u32); + + if old_deposit < new_deposit { + T::Currency::reserve(&sender, new_deposit - old_deposit)?; + } + // do nothing if they're equal. + if old_deposit > new_deposit { + let _ = T::Currency::unreserve(&sender, old_deposit - new_deposit); + } + + if subs.is_empty() { + >::remove(&sender); + } else { + >::insert(&sender, (new_deposit, subs)); + } + } + + /// Clear an account's identity info and all sub-account and return all deposits. + /// + /// Payment: All reserved balances on the account are returned. + /// + /// The dispatch origin for this call must be _Signed_ and the sender must have a registered + /// identity. + /// + /// Emits `IdentityCleared` if successful. + /// + /// # + /// - `O(R + S + X)`. + /// - One balance-reserve operation. + /// - Two storage mutations. + /// - One event. + /// # + fn clear_identity(origin) { + let sender = ensure_signed(origin)?; + + let deposit = >::take(&sender).ok_or("not named")?.total_deposit() + + >::take(&sender).0; + + let _ = T::Currency::unreserve(&sender, deposit.clone()); + + Self::deposit_event(RawEvent::IdentityCleared(sender, deposit)); + } + + /// Request a judgement from a registrar. + /// + /// Payment: At most `max_fee` will be reserved for payment to the registrar if judgement + /// given. + /// + /// The dispatch origin for this call must be _Signed_ and the sender must have a + /// registered identity. + /// + /// - `reg_index`: The index of the registrar whose judgement is requested. + /// - `max_fee`: The maximum fee that may be paid. This should just be auto-populated as: + /// + /// ```nocompile + /// Self::registrars(reg_index).uwnrap().fee + /// ``` + /// + /// Emits `JudgementRequested` if successful. + /// + /// # + /// - `O(R + X)`. + /// - One balance-reserve operation. + /// - Storage: 1 read `O(R)`, 1 mutate `O(X + R)`. + /// - One event. + /// # + #[weight = SimpleDispatchInfo::FixedNormal(50_000)] + fn request_judgement(origin, + #[compact] reg_index: RegistrarIndex, + #[compact] max_fee: BalanceOf, + ) { + let sender = ensure_signed(origin)?; + let registrars = >::get(); + let registrar = registrars.get(reg_index as usize).and_then(Option::as_ref) + .ok_or("empty index")?; + ensure!(max_fee >= registrar.fee, "fee changed"); + let mut id = >::get(&sender).ok_or("no identity")?; + + let item = (reg_index, Judgement::FeePaid(registrar.fee)); + match id.judgements.binary_search_by_key(®_index, |x| x.0) { + Ok(i) => if id.judgements[i].1.is_sticky() { + return Err("sticky judgement") + } else { + id.judgements[i] = item + }, + Err(i) => id.judgements.insert(i, item), + } + + T::Currency::reserve(&sender, registrar.fee)?; + + >::insert(&sender, id); + + Self::deposit_event(RawEvent::JudgementRequested(sender, reg_index)); + } + + /// Cancel a previous request. + /// + /// Payment: A previously reserved deposit is returned on success. + /// + /// The dispatch origin for this call must be _Signed_ and the sender must have a + /// registered identity. + /// + /// - `reg_index`: The index of the registrar whose judgement is no longer requested. + /// + /// Emits `JudgementUnrequested` if successful. + /// + /// # + /// - `O(R + X)`. + /// - One balance-reserve operation. + /// - One storage mutation `O(R + X)`. + /// - One event. + /// # + #[weight = SimpleDispatchInfo::FixedNormal(50_000)] + fn cancel_request(origin, reg_index: RegistrarIndex) { + let sender = ensure_signed(origin)?; + let mut id = >::get(&sender).ok_or("no identity")?; + + let pos = id.judgements.binary_search_by_key(®_index, |x| x.0) + .map_err(|_| "not found")?; + let fee = if let Judgement::FeePaid(fee) = id.judgements.remove(pos).1 { + fee + } else { + return Err("judgement given") + }; + + let _ = T::Currency::unreserve(&sender, fee); + >::insert(&sender, id); + + Self::deposit_event(RawEvent::JudgementUnrequested(sender, reg_index)); + } + + /// Set the fee required for a judgement to be requested from a registrar. + /// + /// The dispatch origin for this call must be _Signed_ and the sender must be the account + /// of the registrar whose index is `index`. + /// + /// - `index`: the index of the registrar whose fee is to be set. + /// - `fee`: the new fee. + /// + /// # + /// - `O(R)`. + /// - One storage mutation `O(R)`. + /// # + #[weight = SimpleDispatchInfo::FixedNormal(50_000)] + fn set_fee(origin, + #[compact] index: RegistrarIndex, + #[compact] fee: BalanceOf, + ) -> Result { + let who = ensure_signed(origin)?; + + >::mutate(|rs| + rs.get_mut(index as usize) + .and_then(|x| x.as_mut()) + .and_then(|r| if r.account == who { r.fee = fee; Some(()) } else { None }) + .ok_or("invalid index") + ) + } + + /// Set the field information for a registrar. + /// + /// The dispatch origin for this call must be _Signed_ and the sender must be the account + /// of the registrar whose index is `index`. + /// + /// - `index`: the index of the registrar whose fee is to be set. + /// - `fields`: the fields that the registrar concerns themselves with. + /// + /// # + /// - `O(R)`. + /// - One storage mutation `O(R)`. + /// # + #[weight = SimpleDispatchInfo::FixedNormal(50_000)] + fn set_fields(origin, + #[compact] index: RegistrarIndex, + fields: IdentityFields, + ) -> Result { + let who = ensure_signed(origin)?; + + >::mutate(|rs| + rs.get_mut(index as usize) + .and_then(|x| x.as_mut()) + .and_then(|r| if r.account == who { r.fields = fields; Some(()) } else { None }) + .ok_or("invalid index") + ) + } + + /// Provide a judgement for an account's identity. + /// + /// The dispatch origin for this call must be _Signed_ and the sender must be the account + /// of the registrar whose index is `reg_index`. + /// + /// - `reg_index`: the index of the registrar whose judgement is being made. + /// - `target`: the account whose identity the judgement is upon. This must be an account + /// with a registered identity. + /// - `judgement`: the judgement of the registrar of index `reg_index` about `target`. + /// + /// Emits `JudgementGiven` if successful. + /// + /// # + /// - `O(R + X)`. + /// - One balance-transfer operation. + /// - Up to one account-lookup operation. + /// - Storage: 1 read `O(R)`, 1 mutate `O(R + X)`. + /// - One event. + /// # + #[weight = SimpleDispatchInfo::FixedNormal(50_000)] + fn provide_judgement(origin, + #[compact] reg_index: RegistrarIndex, + target: ::Source, + judgement: Judgement>, + ) { + let sender = ensure_signed(origin)?; + let target = T::Lookup::lookup(target)?; + ensure!(!judgement.has_deposit(), "invalid judgement"); + >::get() + .get(reg_index as usize) + .and_then(Option::as_ref) + .and_then(|r| if r.account == sender { Some(r) } else { None }) + .ok_or("invalid index")?; + let mut id = >::get(&target).ok_or("invalid target")?; + + let item = (reg_index, judgement); + match id.judgements.binary_search_by_key(®_index, |x| x.0) { + Ok(position) => { + if let Judgement::FeePaid(fee) = id.judgements[position].1 { + let _ = T::Currency::repatriate_reserved(&target, &sender, fee); + } + id.judgements[position] = item + } + Err(position) => id.judgements.insert(position, item), + } + >::insert(&target, id); + Self::deposit_event(RawEvent::JudgementGiven(target, reg_index)); + } + + /// Remove an account's identity and sub-account information and slash the deposits. + /// + /// Payment: Reserved balances from `set_subs` and `set_identity` are slashed and handled by + /// `Slash`. Verification request deposits are not returned; they should be cancelled + /// manually using `cancel_request`. + /// + /// The dispatch origin for this call must be _Root_ or match `T::ForceOrigin`. + /// + /// - `target`: the account whose identity the judgement is upon. This must be an account + /// with a registered identity. + /// + /// Emits `IdentityKilled` if successful. + /// + /// # + /// - `O(R + S + X)`. + /// - One balance-reserve operation. + /// - Two storage mutations. + /// - One event. + /// # + #[weight = SimpleDispatchInfo::FreeOperational] + fn kill_identity(origin, target: ::Source) { + T::ForceOrigin::try_origin(origin) + .map(|_| ()) + .or_else(ensure_root) + .map_err(|_| "bad origin")?; + + // Figure out who we're meant to be clearing. + let target = T::Lookup::lookup(target)?; + // Grab their deposit (and check that they have one). + let deposit = >::take(&target).ok_or("not named")?.total_deposit() + + >::take(&target).0; + // Slash their deposit from them. + T::Slashed::on_unbalanced(T::Currency::slash_reserved(&target, deposit).0); + + Self::deposit_event(RawEvent::IdentityKilled(target, deposit)); + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + use support::{assert_ok, assert_noop, impl_outer_origin, parameter_types, weights::Weight}; + use primitives::H256; + use system::EnsureSignedBy; + // The testing primitives are very useful for avoiding having to work with signatures + // or public keys. `u64` is used as the `AccountId` and no `Signature`s are required. + use sp_runtime::{ + Perbill, testing::Header, traits::{BlakeTwo256, IdentityLookup}, + }; + + impl_outer_origin! { + pub enum Origin for Test {} + } + + // For testing the module, we construct most of a mock runtime. This means + // first constructing a configuration type (`Test`) which `impl`s each of the + // configuration traits of modules we want to use. + #[derive(Clone, Eq, PartialEq)] + pub struct Test; + parameter_types! { + pub const BlockHashCount: u64 = 250; + pub const MaximumBlockWeight: Weight = 1024; + pub const MaximumBlockLength: u32 = 2 * 1024; + pub const AvailableBlockRatio: Perbill = Perbill::one(); + } + impl system::Trait for Test { + type Origin = Origin; + type Index = u64; + type BlockNumber = u64; + type Hash = H256; + type Call = (); + type Hashing = BlakeTwo256; + type AccountId = u64; + type Lookup = IdentityLookup; + type Header = Header; + type Event = (); + type BlockHashCount = BlockHashCount; + type MaximumBlockWeight = MaximumBlockWeight; + type MaximumBlockLength = MaximumBlockLength; + type AvailableBlockRatio = AvailableBlockRatio; + type Version = (); + } + parameter_types! { + pub const ExistentialDeposit: u64 = 0; + pub const TransferFee: u64 = 0; + pub const CreationFee: u64 = 0; + } + impl balances::Trait for Test { + type Balance = u64; + type OnFreeBalanceZero = (); + type OnNewAccount = (); + type Event = (); + type TransferPayment = (); + type DustRemoval = (); + type ExistentialDeposit = ExistentialDeposit; + type TransferFee = TransferFee; + type CreationFee = CreationFee; + } + parameter_types! { + pub const BasicDeposit: u64 = 10; + pub const FieldDeposit: u64 = 10; + pub const SubAccountDeposit: u64 = 10; + pub const MaximumSubAccounts: u32 = 2; + pub const One: u64 = 1; + pub const Two: u64 = 2; + } + impl Trait for Test { + type Event = (); + type Currency = Balances; + type Slashed = (); + type BasicDeposit = BasicDeposit; + type FieldDeposit = FieldDeposit; + type SubAccountDeposit = SubAccountDeposit; + type MaximumSubAccounts = MaximumSubAccounts; + type RegistrarOrigin = EnsureSignedBy; + type ForceOrigin = EnsureSignedBy; + } + type Balances = balances::Module; + type Identity = Module; + + // This function basically just builds a genesis storage key/value store according to + // our desired mockup. + fn new_test_ext() -> runtime_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:: { + balances: vec![ + (1, 10), + (2, 10), + (3, 10), + (10, 100), + (20, 100), + (30, 100), + ], + vesting: vec![], + }.assimilate_storage(&mut t).unwrap(); + t.into() + } + + fn ten() -> IdentityInfo { + IdentityInfo { + display: Data::Raw(b"ten".to_vec()), + legal: Data::Raw(b"The Right Ordinal Ten, Esq.".to_vec()), + .. Default::default() + } + } + + #[test] + fn adding_registrar_should_work() { + new_test_ext().execute_with(|| { + assert_ok!(Identity::add_registrar(Origin::signed(1), 3)); + assert_ok!(Identity::set_fee(Origin::signed(3), 0, 10)); + let fields = IdentityFields(IdentityField::Display | IdentityField::Legal); + assert_ok!(Identity::set_fields(Origin::signed(3), 0, fields)); + assert_eq!(Identity::registrars(), vec![ + Some(RegistrarInfo { account: 3, fee: 10, fields }) + ]); + }); + } + + #[test] + fn registration_should_work() { + new_test_ext().execute_with(|| { + assert_ok!(Identity::add_registrar(Origin::signed(1), 3)); + assert_ok!(Identity::set_fee(Origin::signed(3), 0, 10)); + assert_ok!(Identity::set_identity(Origin::signed(10), ten())); + assert_eq!(Identity::identity(10).unwrap().info, ten()); + assert_eq!(Balances::free_balance(10), 90); + assert_ok!(Identity::clear_identity(Origin::signed(10))); + assert_eq!(Balances::free_balance(10), 100); + assert_noop!(Identity::clear_identity(Origin::signed(10)), "not named"); + }); + } + + #[test] + fn uninvited_judgement_should_work() { + new_test_ext().execute_with(|| { + assert_noop!( + Identity::provide_judgement(Origin::signed(3), 0, 10, Judgement::Reasonable), + "invalid index" + ); + + assert_ok!(Identity::add_registrar(Origin::signed(1), 3)); + assert_noop!( + Identity::provide_judgement(Origin::signed(3), 0, 10, Judgement::Reasonable), + "invalid target" + ); + + assert_ok!(Identity::set_identity(Origin::signed(10), ten())); + assert_noop!( + Identity::provide_judgement(Origin::signed(10), 0, 10, Judgement::Reasonable), + "invalid index" + ); + assert_noop!( + Identity::provide_judgement(Origin::signed(3), 0, 10, Judgement::FeePaid(1)), + "invalid judgement" + ); + + assert_ok!(Identity::provide_judgement(Origin::signed(3), 0, 10, Judgement::Reasonable)); + assert_eq!(Identity::identity(10).unwrap().judgements, vec![(0, Judgement::Reasonable)]); + }); + } + + #[test] + fn clearing_judgement_should_work() { + new_test_ext().execute_with(|| { + assert_ok!(Identity::add_registrar(Origin::signed(1), 3)); + assert_ok!(Identity::set_identity(Origin::signed(10), ten())); + assert_ok!(Identity::provide_judgement(Origin::signed(3), 0, 10, Judgement::Reasonable)); + assert_ok!(Identity::clear_identity(Origin::signed(10))); + assert_eq!(Identity::identity(10), None); + }); + } + + #[test] + fn killing_slashing_should_work() { + new_test_ext().execute_with(|| { + assert_ok!(Identity::set_identity(Origin::signed(10), ten())); + assert_noop!(Identity::kill_identity(Origin::signed(1), 10), "bad origin"); + assert_ok!(Identity::kill_identity(Origin::signed(2), 10)); + assert_eq!(Identity::identity(10), None); + assert_eq!(Balances::free_balance(10), 90); + assert_noop!(Identity::kill_identity(Origin::signed(2), 10), "not named"); + }); + } + + #[test] + fn setting_subaccounts_should_work() { + new_test_ext().execute_with(|| { + let mut subs = vec![(20, Data::Raw(vec![40; 1]))]; + assert_noop!(Identity::set_subs(Origin::signed(10), subs.clone()), "not found"); + + assert_ok!(Identity::set_identity(Origin::signed(10), ten())); + assert_ok!(Identity::set_subs(Origin::signed(10), subs.clone())); + assert_eq!(Balances::free_balance(10), 80); + assert_eq!(Identity::subs(10), (10, subs.clone())); + + assert_ok!(Identity::set_subs(Origin::signed(10), vec![])); + assert_eq!(Balances::free_balance(10), 90); + assert_eq!(Identity::subs(10), (0, vec![])); + + subs.push((30, Data::Raw(vec![41; 1]))); + subs.push((40, Data::Raw(vec![42; 1]))); + assert_noop!(Identity::set_subs(Origin::signed(10), subs.clone()), "too many subs"); + }); + } + + #[test] + fn cancelling_requested_judgement_should_work() { + new_test_ext().execute_with(|| { + assert_ok!(Identity::add_registrar(Origin::signed(1), 3)); + assert_ok!(Identity::set_fee(Origin::signed(3), 0, 10)); + assert_noop!(Identity::cancel_request(Origin::signed(10), 0), "no identity"); + assert_ok!(Identity::set_identity(Origin::signed(10), ten())); + assert_ok!(Identity::request_judgement(Origin::signed(10), 0, 10)); + assert_ok!(Identity::cancel_request(Origin::signed(10), 0)); + assert_eq!(Balances::free_balance(10), 90); + assert_noop!(Identity::cancel_request(Origin::signed(10), 0), "not found"); + + assert_ok!(Identity::provide_judgement(Origin::signed(3), 0, 10, Judgement::Reasonable)); + assert_noop!(Identity::cancel_request(Origin::signed(10), 0), "judgement given"); + }); + } + + #[test] + fn requesting_judgement_should_work() { + new_test_ext().execute_with(|| { + assert_ok!(Identity::add_registrar(Origin::signed(1), 3)); + assert_ok!(Identity::set_fee(Origin::signed(3), 0, 10)); + assert_ok!(Identity::set_identity(Origin::signed(10), ten())); + assert_noop!(Identity::request_judgement(Origin::signed(10), 0, 9), "fee changed"); + assert_ok!(Identity::request_judgement(Origin::signed(10), 0, 10)); + // 10 for the judgement request, 10 for the identity. + assert_eq!(Balances::free_balance(10), 80); + + // Re-requesting won't work as we already paid. + assert_noop!(Identity::request_judgement(Origin::signed(10), 0, 10), "sticky judgement"); + assert_ok!(Identity::provide_judgement(Origin::signed(3), 0, 10, Judgement::Erroneous)); + // Registrar got their payment now. + assert_eq!(Balances::free_balance(3), 20); + + // Re-requesting still won't work as it's erroneous. + assert_noop!(Identity::request_judgement(Origin::signed(10), 0, 10), "sticky judgement"); + + // Requesting from a second registrar still works. + assert_ok!(Identity::add_registrar(Origin::signed(1), 4)); + assert_ok!(Identity::request_judgement(Origin::signed(10), 1, 10)); + + // Re-requesting after the judgement has been reduced works. + assert_ok!(Identity::provide_judgement(Origin::signed(3), 0, 10, Judgement::OutOfDate)); + assert_ok!(Identity::request_judgement(Origin::signed(10), 0, 10)); + }); + } + + #[test] + fn field_deposit_should_work() { + new_test_ext().execute_with(|| { + assert_ok!(Identity::add_registrar(Origin::signed(1), 3)); + assert_ok!(Identity::set_fee(Origin::signed(3), 0, 10)); + assert_ok!(Identity::set_identity(Origin::signed(10), IdentityInfo { + additional: vec![ + (Data::Raw(b"number".to_vec()), Data::Raw(10u32.encode())), + (Data::Raw(b"text".to_vec()), Data::Raw(b"10".to_vec())), + ], .. Default::default() + })); + assert_eq!(Balances::free_balance(10), 70); + }); + } +} diff --git a/frame/nicks/Cargo.toml b/frame/nicks/Cargo.toml index 5f7ad53e3b..70f6f9ba2f 100644 --- a/frame/nicks/Cargo.toml +++ b/frame/nicks/Cargo.toml @@ -15,7 +15,7 @@ system = { package = "frame-system", path = "../system", default-features = fals [dev-dependencies] primitives = { package = "sp-core", path = "../../primitives/core" } -balances = { package = "pallet-balances", path = "../balances", default-features = false } +balances = { package = "pallet-balances", path = "../balances" } [features] default = ["std"] -- GitLab From 4f81d2e0ba82159f04d7c5d98fcc306019bbd440 Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Mon, 9 Dec 2019 17:47:57 +0000 Subject: [PATCH 102/172] sp-transaction-pool-api: make default std, remove unused sp-core dependency (#4335) * transaction-pool-api: use primitives/std * transaction-pool-api: make primitives default-features = false * transaction-pool-api: make default feature std * transaction-pool-api: remove redundant primitives dependency --- Cargo.lock | 1 - primitives/transaction-pool/Cargo.toml | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0fab5b2a5c..e85290ceec 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6437,7 +6437,6 @@ dependencies = [ "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-api 2.0.0", - "sp-core 2.0.0", "sp-runtime 2.0.0", ] diff --git a/primitives/transaction-pool/Cargo.toml b/primitives/transaction-pool/Cargo.toml index 13563cc08f..456d1f94e6 100644 --- a/primitives/transaction-pool/Cargo.toml +++ b/primitives/transaction-pool/Cargo.toml @@ -9,18 +9,17 @@ codec = { package = "parity-scale-codec", version = "1.0.0", optional = true } derive_more = { version = "0.99.2", optional = true } futures = { version = "0.3.1", optional = true } log = { version = "0.4.8", optional = true } -primitives = { package = "sp-core", path = "../core", optional = true} serde = { version = "1.0.101", features = ["derive"], optional = true} sp-api = { path = "../sr-api", default-features = false } sp-runtime = { path = "../runtime", default-features = false } [features] +default = [ "std" ] std = [ "codec", "derive_more", "futures", "log", - "primitives", "serde", "sp-api/std", "sp-runtime/std", -- GitLab From 0a6817b41110a1c279e77276bd2392e84c5ed05e Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Mon, 9 Dec 2019 20:10:41 +0100 Subject: [PATCH 103/172] Limit number of uncles that can be provided. (#4298) * Limit number of uncles that can be provided. * Check length of uncles vector on inherent. * Set fatal error to true for too many uncles. * Take max uncles in create_inherent. --- Cargo.lock | 1 + frame/authorship/src/lib.rs | 26 +++++++++++++++++++------- primitives/authorship/Cargo.toml | 1 + primitives/authorship/src/lib.rs | 18 +++++++++++++++++- 4 files changed, 38 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e85290ceec..69030e5357 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6035,6 +6035,7 @@ version = "2.0.0" dependencies = [ "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "sp-inherents 2.0.0", + "sp-runtime 2.0.0", "sp-std 2.0.0", ] diff --git a/frame/authorship/src/lib.rs b/frame/authorship/src/lib.rs index 1f918e093a..73a38b0ead 100644 --- a/frame/authorship/src/lib.rs +++ b/frame/authorship/src/lib.rs @@ -22,7 +22,7 @@ use rstd::{result, prelude::*}; use rstd::collections::btree_set::BTreeSet; -use support::{decl_module, decl_storage}; +use support::{decl_module, decl_storage, ensure}; use support::traits::{FindAuthor, VerifySeal, Get}; use support::dispatch::Result as DispatchResult; use codec::{Encode, Decode}; @@ -30,9 +30,9 @@ use system::ensure_none; use sp_runtime::traits::{Header as HeaderT, One, Zero}; use support::weights::SimpleDispatchInfo; use inherents::{InherentIdentifier, ProvideInherent, InherentData, MakeFatalError}; -use sp_authorship::{ - INHERENT_IDENTIFIER, UnclesInherentData, -}; +use sp_authorship::{INHERENT_IDENTIFIER, UnclesInherentData, InherentError}; + +const MAX_UNCLES: usize = 10; pub trait Trait: system::Trait { /// Find the author of a block. @@ -187,6 +187,7 @@ decl_module! { #[weight = SimpleDispatchInfo::FixedOperational(10_000)] fn set_uncles(origin, new_uncles: Vec) -> DispatchResult { ensure_none(origin)?; + ensure!(new_uncles.len() <= MAX_UNCLES, "Too many uncles"); if ::DidSetUncles::get() { return Err("Uncles already set in block."); @@ -314,7 +315,7 @@ impl Module { impl ProvideInherent for Module { type Call = Call; - type Error = MakeFatalError<()>; + type Error = InherentError; const INHERENT_IDENTIFIER: InherentIdentifier = INHERENT_IDENTIFIER; fn create_inherent(data: &InherentData) -> Option { @@ -338,6 +339,10 @@ impl ProvideInherent for Module { let hash = uncle.hash(); set_uncles.push(uncle); existing_hashes.push(hash); + + if set_uncles.len() == MAX_UNCLES { + break + } } Err(_) => { // skip this uncle @@ -353,8 +358,15 @@ impl ProvideInherent for Module { } } - fn check_inherent(_call: &Self::Call, _data: &InherentData) -> result::Result<(), Self::Error> { - Ok(()) + fn check_inherent(call: &Self::Call, _data: &InherentData) -> result::Result<(), Self::Error> { + match call { + Call::set_uncles(ref uncles) if uncles.len() > MAX_UNCLES => { + Err(InherentError::Uncles("Too many uncles".into())) + }, + _ => { + Ok(()) + }, + } } } diff --git a/primitives/authorship/Cargo.toml b/primitives/authorship/Cargo.toml index 3b9604c688..4db66e6421 100644 --- a/primitives/authorship/Cargo.toml +++ b/primitives/authorship/Cargo.toml @@ -7,6 +7,7 @@ edition = "2018" [dependencies] sp-inherents = { package = "sp-inherents", path = "../inherents", default-features = false } +sr-primitives = { package = "sp-runtime", path = "../sr-primitives", default-features = false } rstd = { package = "sp-std", path = "../sr-std", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } diff --git a/primitives/authorship/src/lib.rs b/primitives/authorship/src/lib.rs index e381c97094..b80102f41c 100644 --- a/primitives/authorship/src/lib.rs +++ b/primitives/authorship/src/lib.rs @@ -21,11 +21,27 @@ use rstd::{result::Result, prelude::*}; use codec::{Encode, Decode}; -use sp_inherents::{Error, InherentIdentifier, InherentData}; +use sp_inherents::{Error, InherentIdentifier, InherentData, IsFatalError}; +use sr_primitives::RuntimeString; /// The identifier for the `uncles` inherent. pub const INHERENT_IDENTIFIER: InherentIdentifier = *b"uncles00"; +/// Errors that can occur while checking the authorship inherent. +#[derive(Encode, sr_primitives::RuntimeDebug)] +#[cfg_attr(feature = "std", derive(Decode))] +pub enum InherentError { + Uncles(RuntimeString), +} + +impl IsFatalError for InherentError { + fn is_fatal_error(&self) -> bool { + match self { + InherentError::Uncles(_) => true, + } + } +} + /// Auxiliary trait to extract uncles inherent data. pub trait UnclesInherentData { /// Get uncles. -- GitLab From afe6befbb378615b25503a19de5b136107c48d2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Mon, 9 Dec 2019 20:26:12 +0100 Subject: [PATCH 104/172] Don't assume a fixed length for `endowed_accounts` (#4330) --- bin/node/cli/src/chain_spec.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/node/cli/src/chain_spec.rs b/bin/node/cli/src/chain_spec.rs index 2950843f68..fd65ec0624 100644 --- a/bin/node/cli/src/chain_spec.rs +++ b/bin/node/cli/src/chain_spec.rs @@ -219,6 +219,7 @@ pub fn testnet_genesis( get_account_id_from_seed::("Ferdie//stash"), ] }); + let num_endowed_accounts = endowed_accounts.len(); const ENDOWMENT: Balance = 10_000_000 * DOLLARS; const STASH: Balance = 100 * DOLLARS; @@ -259,12 +260,12 @@ pub fn testnet_genesis( democracy: Some(DemocracyConfig::default()), collective_Instance1: Some(CouncilConfig { members: endowed_accounts.iter().cloned() - .collect::>()[..5].to_vec(), + .collect::>()[..(num_endowed_accounts + 1) / 2].to_vec(), phantom: Default::default(), }), collective_Instance2: Some(TechnicalCommitteeConfig { members: endowed_accounts.iter().cloned() - .collect::>()[..5].to_vec(), + .collect::>()[..(num_endowed_accounts + 1) / 2].to_vec(), phantom: Default::default(), }), contracts: Some(ContractsConfig { -- GitLab From 1caae8b62e910637ca2e6f3b716f5f3c4f1ea019 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Mon, 9 Dec 2019 20:40:52 +0100 Subject: [PATCH 105/172] Fix panic in telemetry (#4336) --- client/telemetry/src/async_record.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/client/telemetry/src/async_record.rs b/client/telemetry/src/async_record.rs index 302c98c1a5..209118070e 100644 --- a/client/telemetry/src/async_record.rs +++ b/client/telemetry/src/async_record.rs @@ -103,7 +103,6 @@ impl Serializer for ToSendSerializer { Ok(()) } - #[cfg(feature = "nested-values")] fn emit_serde(&mut self, key: Key, value: &slog::SerdeValue) -> slog::Result { let val = value.to_sendable(); take(&mut self.kv, |kv| Box::new((kv, SingleKV(key, val)))); @@ -153,4 +152,4 @@ impl AsyncRecord { BorrowedKV(&self.kv), ), &self.logger_values) } -} \ No newline at end of file +} -- GitLab From 6b70f127a150ccbe7521750729b00ba62efe0ae7 Mon Sep 17 00:00:00 2001 From: thiolliere Date: Mon, 9 Dec 2019 20:55:11 +0100 Subject: [PATCH 106/172] Introduce prefixed storage with enumeration (#4185) * Introduce storage_next allowing iteration. (without childtries) * Implement prefixed storage * impl cache in client_storage_cache (needs test) * switch overlay change to btreemap * Revert "impl cache in client_storage_cache" This reverts commit c91a4848916eba87184b3dc4722cea81aec9339d. the storage cache cannot be used this way * Revert "Implement prefixed storage" This reverts commit 4931088126a427082d7310ed7e83b8eea966bc20. * Impl StoragePrefixedMap for all map storages * remove comment * Move all overlays to BTreeMap * btreemap iteration improvment * impl for child tries * impl tests for childs * fix * remove cache comment * Fix grumble --- client/db/src/lib.rs | 8 + client/db/src/storage_cache.rs | 8 + client/src/light/backend.rs | 16 ++ frame/support/procedural/src/lib.rs | 3 + frame/support/procedural/src/storage/mod.rs | 3 +- .../procedural/src/storage/storage_struct.rs | 36 +++++ frame/support/src/lib.rs | 4 +- frame/support/src/storage/mod.rs | 127 ++++++++++++++- frame/support/test/tests/final_keys.rs | 20 ++- frame/support/test/tests/instance.rs | 2 +- primitives/core/storage/src/lib.rs | 2 +- primitives/externalities/src/lib.rs | 6 + primitives/sr-io/src/lib.rs | 11 ++ primitives/state-machine/src/backend.rs | 60 +++++-- primitives/state-machine/src/basic.rs | 47 ++++-- .../state-machine/src/changes_trie/build.rs | 2 +- primitives/state-machine/src/ext.rs | 101 ++++++++++++ primitives/state-machine/src/lib.rs | 4 +- .../state-machine/src/overlayed_changes.rs | 147 ++++++++++++++++-- .../state-machine/src/proving_backend.rs | 8 + primitives/state-machine/src/testing.rs | 4 +- primitives/state-machine/src/trie_backend.rs | 8 + .../state-machine/src/trie_backend_essence.rs | 114 ++++++++++++++ test/utils/runtime/client/src/lib.rs | 6 +- test/utils/runtime/src/genesismap.rs | 22 +-- 25 files changed, 711 insertions(+), 58 deletions(-) diff --git a/client/db/src/lib.rs b/client/db/src/lib.rs index d9365ce4bf..9f1316253b 100644 --- a/client/db/src/lib.rs +++ b/client/db/src/lib.rs @@ -151,6 +151,14 @@ impl StateBackend for RefTrackingState { self.state.exists_child_storage(storage_key, key) } + fn next_storage_key(&self, key: &[u8]) -> Result>, Self::Error> { + self.state.next_storage_key(key) + } + + fn next_child_storage_key(&self, storage_key: &[u8], key: &[u8]) -> Result>, Self::Error> { + self.state.next_child_storage_key(storage_key, key) + } + fn for_keys_with_prefix(&self, prefix: &[u8], f: F) { self.state.for_keys_with_prefix(prefix, f) } diff --git a/client/db/src/storage_cache.rs b/client/db/src/storage_cache.rs index 99266c7b61..2b8e356d9c 100644 --- a/client/db/src/storage_cache.rs +++ b/client/db/src/storage_cache.rs @@ -544,6 +544,14 @@ impl, B: BlockT> StateBackend for CachingState< self.state.exists_child_storage(storage_key, key) } + fn next_storage_key(&self, key: &[u8]) -> Result>, Self::Error> { + self.state.next_storage_key(key) + } + + fn next_child_storage_key(&self, storage_key: &[u8], key: &[u8]) -> Result>, Self::Error> { + self.state.next_child_storage_key(storage_key, key) + } + fn for_keys_in_child_storage(&self, storage_key: &[u8], f: F) { self.state.for_keys_in_child_storage(storage_key, f) } diff --git a/client/src/light/backend.rs b/client/src/light/backend.rs index b8dc0c34d7..0d974411a9 100644 --- a/client/src/light/backend.rs +++ b/client/src/light/backend.rs @@ -365,6 +365,22 @@ impl StateBackend for GenesisOrUnavailableState } } + fn next_storage_key(&self, key: &[u8]) -> Result>, Self::Error> { + match *self { + GenesisOrUnavailableState::Genesis(ref state) => + Ok(state.next_storage_key(key).expect(IN_MEMORY_EXPECT_PROOF)), + GenesisOrUnavailableState::Unavailable => Err(ClientError::NotAvailableOnLightClient), + } + } + + fn next_child_storage_key(&self, storage_key: &[u8], key: &[u8]) -> Result>, Self::Error> { + match *self { + GenesisOrUnavailableState::Genesis(ref state) => + Ok(state.next_child_storage_key(storage_key, key).expect(IN_MEMORY_EXPECT_PROOF)), + GenesisOrUnavailableState::Unavailable => Err(ClientError::NotAvailableOnLightClient), + } + } + fn for_keys_with_prefix(&self, prefix: &[u8], action: A) { match *self { GenesisOrUnavailableState::Genesis(ref state) => state.for_keys_with_prefix(prefix, action), diff --git a/frame/support/procedural/src/lib.rs b/frame/support/procedural/src/lib.rs index 506e55fa17..d9c2fe03c9 100644 --- a/frame/support/procedural/src/lib.rs +++ b/frame/support/procedural/src/lib.rs @@ -69,6 +69,7 @@ use proc_macro::TokenStream; /// * Map: `Foo: map hasher($hash) type => type`: Implements the /// [`StorageMap`](../frame_support/storage/trait.StorageMap.html) trait using the /// [`StorageMap generator`](../frame_support/storage/generator/trait.StorageMap.html). +/// And [`StoragePrefixedMap`](../frame_support/storage/trait.StoragePrefixedMap.html). /// /// `$hash` representing a choice of hashing algorithms available in the /// [`Hashable`](../frame_support/trait.Hashable.html) trait. @@ -89,6 +90,7 @@ use proc_macro::TokenStream; /// * Linked map: `Foo: linked_map hasher($hash) type => type`: Implements the /// [`StorageLinkedMap`](../frame_support/storage/trait.StorageLinkedMap.html) trait using the /// [`StorageLinkedMap generator`](../frame_support/storage/generator/trait.StorageLinkedMap.html). +/// And [`StoragePrefixedMap`](../frame_support/storage/trait.StoragePrefixedMap.html). /// /// `$hash` representing a choice of hashing algorithms available in the /// [`Hashable`](../frame_support/trait.Hashable.html) trait. @@ -118,6 +120,7 @@ use proc_macro::TokenStream; /// * Double map: `Foo: double_map hasher($hash1) u32, $hash2(u32) => u32`: Implements the /// [`StorageDoubleMap`](../frame_support/storage/trait.StorageDoubleMap.html) trait using the /// [`StorageDoubleMap generator`](../frame_support/storage/generator/trait.StorageDoubleMap.html). +/// And [`StoragePrefixedMap`](../frame_support/storage/trait.StoragePrefixedMap.html). /// /// `$hash1` and `$hash2` representing choices of hashing algorithms available in the /// [`Hashable`](../frame_support/trait.Hashable.html) trait. They must be choosen with care, see diff --git a/frame/support/procedural/src/storage/mod.rs b/frame/support/procedural/src/storage/mod.rs index 0ec266a8a0..8fbb97d916 100644 --- a/frame/support/procedural/src/storage/mod.rs +++ b/frame/support/procedural/src/storage/mod.rs @@ -418,7 +418,8 @@ pub fn decl_storage_impl(input: proc_macro::TokenStream) -> proc_macro::TokenStr StorageValue as _, StorageMap as _, StorageLinkedMap as _, - StorageDoubleMap as _ + StorageDoubleMap as _, + StoragePrefixedMap as _, }; #scrate_decl diff --git a/frame/support/procedural/src/storage/storage_struct.rs b/frame/support/procedural/src/storage/storage_struct.rs index 017e6cf2ff..97aea3567d 100644 --- a/frame/support/procedural/src/storage/storage_struct.rs +++ b/frame/support/procedural/src/storage/storage_struct.rs @@ -122,6 +122,18 @@ pub fn decl_and_impl(scrate: &TokenStream, def: &DeclStorageDefExt) -> TokenStre StorageLineTypeDef::Map(map) => { let hasher = map.hasher.to_storage_hasher_struct(); quote!( + impl<#impl_trait> #scrate::storage::StoragePrefixedMap<#value_type> + for #storage_struct #optional_storage_where_clause + { + fn module_prefix() -> &'static [u8] { + #instance_or_inherent::PREFIX.as_bytes() + } + + fn storage_prefix() -> &'static [u8] { + #storage_name_str.as_bytes() + } + } + impl<#impl_trait> #scrate::#storage_generator_trait for #storage_struct #optional_storage_where_clause { @@ -155,6 +167,18 @@ pub fn decl_and_impl(scrate: &TokenStream, def: &DeclStorageDefExt) -> TokenStre ); quote!( + impl<#impl_trait> #scrate::storage::StoragePrefixedMap<#value_type> + for #storage_struct #optional_storage_where_clause + { + fn module_prefix() -> &'static [u8] { + #instance_or_inherent::PREFIX.as_bytes() + } + + fn storage_prefix() -> &'static [u8] { + #storage_name_str.as_bytes() + } + } + impl<#impl_trait> #scrate::#storage_generator_trait for #storage_struct #optional_storage_where_clause { @@ -191,6 +215,18 @@ pub fn decl_and_impl(scrate: &TokenStream, def: &DeclStorageDefExt) -> TokenStre let hasher1 = map.hasher1.to_storage_hasher_struct(); let hasher2 = map.hasher2.to_storage_hasher_struct(); quote!( + impl<#impl_trait> #scrate::storage::StoragePrefixedMap<#value_type> + for #storage_struct #optional_storage_where_clause + { + fn module_prefix() -> &'static [u8] { + #instance_or_inherent::PREFIX.as_bytes() + } + + fn storage_prefix() -> &'static [u8] { + #storage_name_str.as_bytes() + } + } + impl<#impl_trait> #scrate::#storage_generator_trait for #storage_struct #optional_storage_where_clause { diff --git a/frame/support/src/lib.rs b/frame/support/src/lib.rs index 0a7a967db8..35962eba88 100644 --- a/frame/support/src/lib.rs +++ b/frame/support/src/lib.rs @@ -67,7 +67,9 @@ pub mod traits; pub mod weights; pub use self::hash::{Twox256, Twox128, Blake2_256, Blake2_128, Twox64Concat, Hashable}; -pub use self::storage::{StorageValue, StorageMap, StorageLinkedMap, StorageDoubleMap}; +pub use self::storage::{ + StorageValue, StorageMap, StorageLinkedMap, StorageDoubleMap, StoragePrefixedMap +}; pub use self::dispatch::{Parameter, Callable, IsSubType}; pub use sp_runtime::{self, ConsensusEngineId, print, traits::Printable}; diff --git a/frame/support/src/storage/mod.rs b/frame/support/src/storage/mod.rs index 7c8ce9c24f..08d45571d1 100644 --- a/frame/support/src/storage/mod.rs +++ b/frame/support/src/storage/mod.rs @@ -16,9 +16,9 @@ //! Stuff to do with the runtime's storage. -use rstd::prelude::*; +use rstd::{prelude::*, marker::PhantomData}; use codec::{FullCodec, FullEncode, Encode, EncodeAppend, EncodeLike, Decode}; -use crate::traits::Len; +use crate::{traits::Len, hash::{Twox128, StorageHasher}}; pub mod unhashed; pub mod hashed; @@ -352,3 +352,126 @@ pub trait StorageDoubleMap { KArg2: EncodeLike, V: codec::DecodeLength + Len; } + +/// Iterator for prefixed map. +pub struct PrefixIterator { + prefix: Vec, + previous_key: Vec, + phantom_data: PhantomData, +} + +impl Iterator for PrefixIterator { + type Item = Value; + + fn next(&mut self) -> Option { + match runtime_io::storage::next_key(&self.previous_key) { + Some(next_key) if next_key.starts_with(&self.prefix[..]) => { + let value = unhashed::get(&next_key); + + if value.is_none() { + runtime_print!( + "ERROR: returned next_key has no value:\nkey is {:?}\nnext_key is {:?}", + &self.previous_key, &next_key, + ); + } + + self.previous_key = next_key; + + value + }, + _ => None, + } + } +} + +/// Trait for maps that store all its value after a unique prefix. +/// +/// By default the final prefix is: +/// ```nocompile +/// Twox128(module_prefix) ++ Twox128(storage_prefix) +/// ``` +pub trait StoragePrefixedMap { + + /// Module prefix. Used for generating final key. + fn module_prefix() -> &'static [u8]; + + /// Storage prefix. Used for generating final key. + fn storage_prefix() -> &'static [u8]; + + fn final_prefix() -> [u8; 32] { + let mut final_key = [0u8; 32]; + final_key[0..16].copy_from_slice(&Twox128::hash(Self::module_prefix())); + final_key[16..32].copy_from_slice(&Twox128::hash(Self::storage_prefix())); + final_key + } + + fn remove_all() { + runtime_io::storage::clear_prefix(&Self::final_prefix()) + } + + fn iter() -> PrefixIterator { + let prefix = Self::final_prefix(); + PrefixIterator { + prefix: prefix.to_vec(), + previous_key: prefix.to_vec(), + phantom_data: Default::default(), + } + } +} + +#[cfg(test)] +mod test { + use primitives::hashing::twox_128; + use runtime_io::TestExternalities; + use crate::storage::{unhashed, StoragePrefixedMap}; + + #[test] + fn prefixed_map_works() { + TestExternalities::default().execute_with(|| { + struct MyStorage; + impl StoragePrefixedMap for MyStorage { + fn module_prefix() -> &'static [u8] { + b"MyModule" + } + + fn storage_prefix() -> &'static [u8] { + b"MyStorage" + } + } + + let key_before = { + let mut k = MyStorage::final_prefix(); + let last = k.iter_mut().last().unwrap(); + *last = last.checked_sub(1).unwrap(); + k + }; + let key_after = { + let mut k = MyStorage::final_prefix(); + let last = k.iter_mut().last().unwrap(); + *last = last.checked_add(1).unwrap(); + k + }; + + unhashed::put(&key_before[..], &32u64); + unhashed::put(&key_after[..], &33u64); + + let k = [twox_128(b"MyModule"), twox_128(b"MyStorage")].concat(); + assert_eq!(MyStorage::final_prefix().to_vec(), k); + + assert_eq!(MyStorage::iter().collect::>(), vec![]); + + unhashed::put(&[&k[..], &vec![1][..]].concat(), &1u64); + unhashed::put(&[&k[..], &vec![1, 1][..]].concat(), &2u64); + unhashed::put(&[&k[..], &vec![8][..]].concat(), &3u64); + unhashed::put(&[&k[..], &vec![10][..]].concat(), &4u64); + + assert_eq!(MyStorage::iter().collect::>(), vec![1, 2, 3, 4]); + + MyStorage::remove_all(); + + assert_eq!(MyStorage::iter().collect::>(), vec![]); + assert_eq!(unhashed::get(&key_before[..]), Some(32u64)); + assert_eq!(unhashed::get(&key_after[..]), Some(33u64)); + }); + } +} diff --git a/frame/support/test/tests/final_keys.rs b/frame/support/test/tests/final_keys.rs index 365aa5779d..3c9e1058a8 100644 --- a/frame/support/test/tests/final_keys.rs +++ b/frame/support/test/tests/final_keys.rs @@ -16,7 +16,7 @@ use support::storage::unhashed; use codec::Encode; -use support::{StorageDoubleMap, StorageLinkedMap, StorageMap, StorageValue}; +use support::{StorageDoubleMap, StorageLinkedMap, StorageMap, StorageValue, StoragePrefixedMap}; use runtime_io::{TestExternalities, hashing::{twox_128, blake2_128, blake2_256}}; mod no_instance { @@ -96,11 +96,13 @@ fn final_keys_no_instance() { let mut k = [twox_128(b"FinalKeysNone"), twox_128(b"Map")].concat(); k.extend(1u32.using_encoded(blake2_256).to_vec()); assert_eq!(unhashed::get::(&k), Some(2u32)); + assert_eq!(&k[..32], &::final_prefix()); no_instance::Map2::insert(1, 2); let mut k = [twox_128(b"FinalKeysNone"), twox_128(b"Map2")].concat(); k.extend(1u32.using_encoded(twox_128).to_vec()); assert_eq!(unhashed::get::(&k), Some(2u32)); + assert_eq!(&k[..32], &::final_prefix()); let head = [twox_128(b"FinalKeysNone"), twox_128(b"HeadOfLinkedMap")].concat(); assert_eq!(unhashed::get::(&head), None); @@ -110,23 +112,27 @@ fn final_keys_no_instance() { k.extend(1u32.using_encoded(blake2_256).to_vec()); assert_eq!(unhashed::get::(&k), Some(2u32)); assert_eq!(unhashed::get::(&head), Some(1u32)); + assert_eq!(&k[..32], &::final_prefix()); no_instance::LinkedMap2::insert(1, 2); let mut k = [twox_128(b"FinalKeysNone"), twox_128(b"LinkedMap2")].concat(); k.extend(1u32.using_encoded(twox_128).to_vec()); assert_eq!(unhashed::get::(&k), Some(2u32)); + assert_eq!(&k[..32], &::final_prefix()); no_instance::DoubleMap::insert(&1, &2, &3); let mut k = [twox_128(b"FinalKeysNone"), twox_128(b"DoubleMap")].concat(); k.extend(1u32.using_encoded(blake2_256).to_vec()); k.extend(2u32.using_encoded(blake2_256).to_vec()); assert_eq!(unhashed::get::(&k), Some(3u32)); + assert_eq!(&k[..32], &::final_prefix()); no_instance::DoubleMap2::insert(&1, &2, &3); let mut k = [twox_128(b"FinalKeysNone"), twox_128(b"DoubleMap2")].concat(); k.extend(1u32.using_encoded(twox_128).to_vec()); k.extend(2u32.using_encoded(blake2_128).to_vec()); assert_eq!(unhashed::get::(&k), Some(3u32)); + assert_eq!(&k[..32], &::final_prefix()); }); } @@ -141,11 +147,13 @@ fn final_keys_default_instance() { let mut k = [twox_128(b"FinalKeysSome"), twox_128(b"Map")].concat(); k.extend(1u32.using_encoded(blake2_256).to_vec()); assert_eq!(unhashed::get::(&k), Some(2u32)); + assert_eq!(&k[..32], &>::final_prefix()); >::insert(1, 2); let mut k = [twox_128(b"FinalKeysSome"), twox_128(b"Map2")].concat(); k.extend(1u32.using_encoded(twox_128).to_vec()); assert_eq!(unhashed::get::(&k), Some(2u32)); + assert_eq!(&k[..32], &>::final_prefix()); let head = [twox_128(b"FinalKeysSome"), twox_128(b"HeadOfLinkedMap")].concat(); assert_eq!(unhashed::get::(&head), None); @@ -155,23 +163,27 @@ fn final_keys_default_instance() { k.extend(1u32.using_encoded(blake2_256).to_vec()); assert_eq!(unhashed::get::(&k), Some(2u32)); assert_eq!(unhashed::get::(&head), Some(1u32)); + assert_eq!(&k[..32], &>::final_prefix()); >::insert(1, 2); let mut k = [twox_128(b"FinalKeysSome"), twox_128(b"LinkedMap2")].concat(); k.extend(1u32.using_encoded(twox_128).to_vec()); assert_eq!(unhashed::get::(&k), Some(2u32)); + assert_eq!(&k[..32], &>::final_prefix()); >::insert(&1, &2, &3); let mut k = [twox_128(b"FinalKeysSome"), twox_128(b"DoubleMap")].concat(); k.extend(1u32.using_encoded(blake2_256).to_vec()); k.extend(2u32.using_encoded(blake2_256).to_vec()); assert_eq!(unhashed::get::(&k), Some(3u32)); + assert_eq!(&k[..32], &>::final_prefix()); >::insert(&1, &2, &3); let mut k = [twox_128(b"FinalKeysSome"), twox_128(b"DoubleMap2")].concat(); k.extend(1u32.using_encoded(twox_128).to_vec()); k.extend(2u32.using_encoded(blake2_128).to_vec()); assert_eq!(unhashed::get::(&k), Some(3u32)); + assert_eq!(&k[..32], &>::final_prefix()); }); } @@ -186,11 +198,13 @@ fn final_keys_instance_2() { let mut k = [twox_128(b"Instance2FinalKeysSome"), twox_128(b"Map")].concat(); k.extend(1u32.using_encoded(blake2_256).to_vec()); assert_eq!(unhashed::get::(&k), Some(2u32)); + assert_eq!(&k[..32], &>::final_prefix()); >::insert(1, 2); let mut k = [twox_128(b"Instance2FinalKeysSome"), twox_128(b"Map2")].concat(); k.extend(1u32.using_encoded(twox_128).to_vec()); assert_eq!(unhashed::get::(&k), Some(2u32)); + assert_eq!(&k[..32], &>::final_prefix()); let head = [twox_128(b"Instance2FinalKeysSome"), twox_128(b"HeadOfLinkedMap")].concat(); assert_eq!(unhashed::get::(&head), None); @@ -200,22 +214,26 @@ fn final_keys_instance_2() { k.extend(1u32.using_encoded(blake2_256).to_vec()); assert_eq!(unhashed::get::(&k), Some(2u32)); assert_eq!(unhashed::get::(&head), Some(1u32)); + assert_eq!(&k[..32], &>::final_prefix()); >::insert(1, 2); let mut k = [twox_128(b"Instance2FinalKeysSome"), twox_128(b"LinkedMap2")].concat(); k.extend(1u32.using_encoded(twox_128).to_vec()); assert_eq!(unhashed::get::(&k), Some(2u32)); + assert_eq!(&k[..32], &>::final_prefix()); >::insert(&1, &2, &3); let mut k = [twox_128(b"Instance2FinalKeysSome"), twox_128(b"DoubleMap")].concat(); k.extend(1u32.using_encoded(blake2_256).to_vec()); k.extend(2u32.using_encoded(blake2_256).to_vec()); assert_eq!(unhashed::get::(&k), Some(3u32)); + assert_eq!(&k[..32], &>::final_prefix()); >::insert(&1, &2, &3); let mut k = [twox_128(b"Instance2FinalKeysSome"), twox_128(b"DoubleMap2")].concat(); k.extend(1u32.using_encoded(twox_128).to_vec()); k.extend(2u32.using_encoded(blake2_128).to_vec()); assert_eq!(unhashed::get::(&k), Some(3u32)); + assert_eq!(&k[..32], &>::final_prefix()); }); } diff --git a/frame/support/test/tests/instance.rs b/frame/support/test/tests/instance.rs index a3ef6ba868..fb8575f2ea 100644 --- a/frame/support/test/tests/instance.rs +++ b/frame/support/test/tests/instance.rs @@ -300,7 +300,7 @@ fn new_test_ext() -> runtime_io::TestExternalities { #[test] fn storage_instance_independance() { - let mut storage = (std::collections::HashMap::new(), std::collections::HashMap::new()); + let mut storage = Default::default(); state_machine::BasicExternalities::execute_with_storage(&mut storage, || { module2::Value::::put(0); module2::Value::::put(0); diff --git a/primitives/core/storage/src/lib.rs b/primitives/core/storage/src/lib.rs index ebb23023b9..3fd883788c 100644 --- a/primitives/core/storage/src/lib.rs +++ b/primitives/core/storage/src/lib.rs @@ -42,7 +42,7 @@ pub struct StorageData( /// A set of key value pairs for storage. #[cfg(feature = "std")] -pub type StorageOverlay = std::collections::HashMap, Vec>; +pub type StorageOverlay = std::collections::BTreeMap, Vec>; /// A set of key value pairs for children storage; #[cfg(feature = "std")] diff --git a/primitives/externalities/src/lib.rs b/primitives/externalities/src/lib.rs index da3fe16d77..05121f34d3 100644 --- a/primitives/externalities/src/lib.rs +++ b/primitives/externalities/src/lib.rs @@ -106,6 +106,12 @@ pub trait Externalities: ExtensionStore { self.child_storage(storage_key, key).is_some() } + /// Returns the key immediately following the given key, if it exists. + fn next_storage_key(&self, key: &[u8]) -> Option>; + + /// Returns the key immediately following the given key, if it exists, in child storage. + fn next_child_storage_key(&self, storage_key: ChildStorageKey, key: &[u8]) -> Option>; + /// Clear an entire child storage. fn kill_child_storage(&mut self, storage_key: ChildStorageKey); diff --git a/primitives/sr-io/src/lib.rs b/primitives/sr-io/src/lib.rs index d4b654ab29..7fdab1ab3b 100644 --- a/primitives/sr-io/src/lib.rs +++ b/primitives/sr-io/src/lib.rs @@ -213,6 +213,17 @@ pub trait Storage { fn changes_root(&mut self, parent_hash: &[u8]) -> Option> { self.storage_changes_root(parent_hash).ok().and_then(|h| h) } + + /// Get the next key in storage after the given one in lexicographic order. + fn next_key(&mut self, key: &[u8]) -> Option> { + self.next_storage_key(&key) + } + + /// Get the next key in storage after the given one in lexicographic order in child storage. + fn child_next_key(&mut self, child_storage_key: &[u8], key: &[u8]) -> Option> { + let storage_key = child_storage_key_or_panic(child_storage_key); + self.next_child_storage_key(storage_key, key) + } } /// Interface that provides trie related functionality. diff --git a/primitives/state-machine/src/backend.rs b/primitives/state-machine/src/backend.rs index 366634ae1a..78e08df6b9 100644 --- a/primitives/state-machine/src/backend.rs +++ b/primitives/state-machine/src/backend.rs @@ -16,7 +16,7 @@ //! State machine backends. These manage the code and storage of contracts. -use std::{error, fmt, cmp::Ord, collections::HashMap, marker::PhantomData}; +use std::{error, fmt, cmp::Ord, collections::{HashMap, BTreeMap}, marker::PhantomData, ops}; use log::warn; use hash_db::Hasher; use crate::trie_backend::TrieBackend; @@ -67,6 +67,16 @@ pub trait Backend: std::fmt::Debug { Ok(self.child_storage(storage_key, key)?.is_some()) } + /// Return the next key in storage in lexicographic order or `None` if there is no value. + fn next_storage_key(&self, key: &[u8]) -> Result>, Self::Error>; + + /// Return the next key in child storage in lexicographic order or `None` if there is no value. + fn next_child_storage_key( + &self, + storage_key: &[u8], + key: &[u8] + ) -> Result>, Self::Error>; + /// Retrieve all entries keys of child storage and call `f` for each of those keys. fn for_keys_in_child_storage(&self, storage_key: &[u8], f: F); @@ -171,6 +181,14 @@ impl<'a, T: Backend, H: Hasher> Backend for &'a T { (*self).child_storage(storage_key, key) } + fn next_storage_key(&self, key: &[u8]) -> Result>, Self::Error> { + (*self).next_storage_key(key) + } + + fn next_child_storage_key(&self, storage_key: &[u8], key: &[u8]) -> Result>, Self::Error> { + (*self).next_child_storage_key(storage_key, key) + } + fn for_keys_in_child_storage(&self, storage_key: &[u8], f: F) { (*self).for_keys_in_child_storage(storage_key, f) } @@ -250,7 +268,7 @@ impl error::Error for Void { /// In-memory backend. Fully recomputes tries each time `as_trie_backend` is called but useful for /// tests and proof checking. pub struct InMemory { - inner: HashMap>, HashMap, Vec>>, + inner: HashMap>, BTreeMap, Vec>>, // This field is only needed for returning reference in `as_trie_backend`. trie: Option, H>>, _hasher: PhantomData, @@ -291,7 +309,7 @@ impl PartialEq for InMemory { impl InMemory where H::Out: Codec { /// Copy the state, with applied updates pub fn update(&self, changes: >::Transaction) -> Self { - let mut inner: HashMap<_, _> = self.inner.clone(); + let mut inner = self.inner.clone(); for (storage_key, key, val) in changes { match val { Some(v) => { inner.entry(storage_key).or_default().insert(key, v); }, @@ -303,8 +321,8 @@ impl InMemory where H::Out: Codec { } } -impl From>, HashMap, Vec>>> for InMemory { - fn from(inner: HashMap>, HashMap, Vec>>) -> Self { +impl From>, BTreeMap, Vec>>> for InMemory { + fn from(inner: HashMap>, BTreeMap, Vec>>) -> Self { InMemory { inner: inner, trie: None, @@ -314,14 +332,14 @@ impl From>, HashMap, Vec>>> for In } impl From<( - HashMap, Vec>, - HashMap, HashMap, Vec>>, + BTreeMap, Vec>, + HashMap, BTreeMap, Vec>>, )> for InMemory { fn from(inners: ( - HashMap, Vec>, - HashMap, HashMap, Vec>>, + BTreeMap, Vec>, + HashMap, BTreeMap, Vec>>, )) -> Self { - let mut inner: HashMap>, HashMap, Vec>> + let mut inner: HashMap>, BTreeMap, Vec>> = inners.1.into_iter().map(|(k, v)| (Some(k), v)).collect(); inner.insert(None, inners.0); InMemory { @@ -332,8 +350,8 @@ impl From<( } } -impl From, Vec>> for InMemory { - fn from(inner: HashMap, Vec>) -> Self { +impl From, Vec>> for InMemory { + fn from(inner: BTreeMap, Vec>) -> Self { let mut expanded = HashMap::new(); expanded.insert(None, inner); InMemory { @@ -346,7 +364,7 @@ impl From, Vec>> for InMemory { impl From>, Vec, Option>)>> for InMemory { fn from(inner: Vec<(Option>, Vec, Option>)>) -> Self { - let mut expanded: HashMap>, HashMap, Vec>> = HashMap::new(); + let mut expanded: HashMap>, BTreeMap, Vec>> = HashMap::new(); for (child_key, key, value) in inner { if let Some(value) = value { expanded.entry(child_key).or_default().insert(key, value); @@ -380,6 +398,22 @@ impl Backend for InMemory where H::Out: Codec { Ok(self.inner.get(&None).map(|map| map.get(key).is_some()).unwrap_or(false)) } + fn next_storage_key(&self, key: &[u8]) -> Result>, Self::Error> { + let range = (ops::Bound::Excluded(key), ops::Bound::Unbounded); + let next_key = self.inner.get(&None) + .and_then(|map| map.range::<[u8], _>(range).next().map(|(k, _)| k).cloned()); + + Ok(next_key) + } + + fn next_child_storage_key(&self, storage_key: &[u8], key: &[u8]) -> Result>, Self::Error> { + let range = (ops::Bound::Excluded(key), ops::Bound::Unbounded); + let next_key = self.inner.get(&Some(storage_key.to_vec())) + .and_then(|map| map.range::<[u8], _>(range).next().map(|(k, _)| k).cloned()); + + Ok(next_key) + } + fn for_keys_with_prefix(&self, prefix: &[u8], f: F) { self.inner.get(&None).map(|map| map.keys().filter(|key| key.starts_with(prefix)).map(|k| &**k).for_each(f)); } diff --git a/primitives/state-machine/src/basic.rs b/primitives/state-machine/src/basic.rs index 82a0c21f20..deae7f2852 100644 --- a/primitives/state-machine/src/basic.rs +++ b/primitives/state-machine/src/basic.rs @@ -16,7 +16,9 @@ //! Basic implementation for Externalities. -use std::{collections::HashMap, any::{TypeId, Any}, iter::FromIterator}; +use std::{ + collections::{HashMap, BTreeMap}, any::{TypeId, Any}, iter::FromIterator, mem, ops::Bound +}; use crate::backend::{Backend, InMemory}; use hash_db::Hasher; use trie::{TrieConfiguration, default_child_trie_root}; @@ -54,8 +56,8 @@ impl BasicExternalities { /// Consume self and returns inner storages pub fn into_storages(self) -> ( - HashMap, Vec>, - HashMap, HashMap, Vec>>, + BTreeMap, Vec>, + HashMap, BTreeMap, Vec>>, ) { (self.top, self.children) } @@ -68,8 +70,8 @@ impl BasicExternalities { f: impl FnOnce() -> R, ) -> R { let mut ext = Self { - top: storage.0.drain().collect(), - children: storage.1.drain().collect(), + top: mem::replace(&mut storage.0, BTreeMap::default()), + children: mem::replace(&mut storage.1, HashMap::default()), }; let r = ext.execute_with(f); @@ -105,8 +107,8 @@ impl Default for BasicExternalities { fn default() -> Self { Self::new(Default::default(), Default::default()) } } -impl From, Vec>> for BasicExternalities { - fn from(hashmap: HashMap, Vec>) -> Self { +impl From, Vec>> for BasicExternalities { + fn from(hashmap: BTreeMap, Vec>) -> Self { BasicExternalities { top: hashmap, children: Default::default(), @@ -151,6 +153,17 @@ impl Externalities for BasicExternalities { Externalities::child_storage(self, storage_key, key) } + fn next_storage_key(&self, key: &[u8]) -> Option> { + let range = (Bound::Excluded(key), Bound::Unbounded); + self.top.range::<[u8], _>(range).next().map(|(k, _)| k).cloned() + } + + fn next_child_storage_key(&self, storage_key: ChildStorageKey, key: &[u8]) -> Option> { + let range = (Bound::Excluded(key), Bound::Unbounded); + self.children.get(storage_key.as_ref()) + .and_then(|child| child.range::<[u8], _>(range).next().map(|(k, _)| k).cloned()) + } + fn place_storage(&mut self, key: Vec, maybe_value: Option>) { if is_child_storage_key(&key) { warn!(target: "trie", "Refuse to set child storage key via main storage"); @@ -190,12 +203,28 @@ impl Externalities for BasicExternalities { return; } - self.top.retain(|key, _| !key.starts_with(prefix)); + let to_remove = self.top.range::<[u8], _>((Bound::Included(prefix), Bound::Unbounded)) + .map(|(k, _)| k) + .take_while(|k| k.starts_with(prefix)) + .cloned() + .collect::>(); + + for key in to_remove { + self.top.remove(&key); + } } fn clear_child_prefix(&mut self, storage_key: ChildStorageKey, prefix: &[u8]) { if let Some(child) = self.children.get_mut(storage_key.as_ref()) { - child.retain(|key, _| !key.starts_with(prefix)); + let to_remove = child.range::<[u8], _>((Bound::Included(prefix), Bound::Unbounded)) + .map(|(k, _)| k) + .take_while(|k| k.starts_with(prefix)) + .cloned() + .collect::>(); + + for key in to_remove { + child.remove(&key); + } } } diff --git a/primitives/state-machine/src/changes_trie/build.rs b/primitives/state-machine/src/changes_trie/build.rs index 6c50c028ca..7e082ad832 100644 --- a/primitives/state-machine/src/changes_trie/build.rs +++ b/primitives/state-machine/src/changes_trie/build.rs @@ -352,7 +352,7 @@ mod test { (vec![103], vec![255]), (vec![104], vec![255]), (vec![105], vec![255]), - ].into_iter().collect::<::std::collections::HashMap<_, _>>().into(); + ].into_iter().collect::<::std::collections::BTreeMap<_, _>>().into(); let child_trie_key1 = b"1".to_vec(); let child_trie_key2 = b"2".to_vec(); let storage = InMemoryStorage::with_inputs(vec![ diff --git a/primitives/state-machine/src/ext.rs b/primitives/state-machine/src/ext.rs index 57197a4ae3..3ac8c19048 100644 --- a/primitives/state-machine/src/ext.rs +++ b/primitives/state-machine/src/ext.rs @@ -336,6 +336,40 @@ where result } + fn next_storage_key(&self, key: &[u8]) -> Option> { + let next_backend_key = self.backend.next_storage_key(key).expect(EXT_NOT_ALLOWED_TO_FAIL); + let next_overlay_key_change = self.overlay.next_storage_key_change(key); + + match (next_backend_key, next_overlay_key_change) { + (Some(backend_key), Some(overlay_key)) if &backend_key[..] < overlay_key.0 => Some(backend_key), + (backend_key, None) => backend_key, + (_, Some(overlay_key)) => if overlay_key.1.value.is_some() { + Some(overlay_key.0.to_vec()) + } else { + self.next_storage_key(&overlay_key.0[..]) + }, + } + } + + fn next_child_storage_key(&self, storage_key: ChildStorageKey, key: &[u8]) -> Option> { + let next_backend_key = self.backend.next_child_storage_key(storage_key.as_ref(), key) + .expect(EXT_NOT_ALLOWED_TO_FAIL); + let next_overlay_key_change = self.overlay.next_child_storage_key_change( + storage_key.as_ref(), + key + ); + + match (next_backend_key, next_overlay_key_change) { + (Some(backend_key), Some(overlay_key)) if &backend_key[..] < overlay_key.0 => Some(backend_key), + (backend_key, None) => backend_key, + (_, Some(overlay_key)) => if overlay_key.1.value.is_some() { + Some(overlay_key.0.to_vec()) + } else { + self.next_child_storage_key(storage_key, &overlay_key.0[..]) + }, + } + } + fn place_storage(&mut self, key: Vec, value: Option>) { trace!(target: "state-trace", "{:04x}: Put {}={:?}", self.id, @@ -619,4 +653,71 @@ mod tests { Some(hex!("96f5aae4690e7302737b6f9b7f8567d5bbb9eac1c315f80101235a92d9ec27f4").to_vec()), ); } + + #[test] + fn next_storage_key_works() { + let mut overlay = OverlayedChanges::default(); + overlay.set_storage(vec![20], None); + overlay.set_storage(vec![30], Some(vec![31])); + let backend = vec![ + (None, vec![10], Some(vec![10])), + (None, vec![20], Some(vec![20])), + (None, vec![40], Some(vec![40])), + ].into(); + + let ext = TestExt::new(&mut overlay, &backend, None, None); + + // next_backend < next_overlay + assert_eq!(ext.next_storage_key(&[5]), Some(vec![10])); + + // next_backend == next_overlay but next_overlay is a delete + assert_eq!(ext.next_storage_key(&[10]), Some(vec![30])); + + // next_overlay < next_backend + assert_eq!(ext.next_storage_key(&[20]), Some(vec![30])); + + // next_backend exist but next_overlay doesn't exist + assert_eq!(ext.next_storage_key(&[30]), Some(vec![40])); + + drop(ext); + overlay.set_storage(vec![50], Some(vec![50])); + let ext = TestExt::new(&mut overlay, &backend, None, None); + + // next_overlay exist but next_backend doesn't exist + assert_eq!(ext.next_storage_key(&[40]), Some(vec![50])); + } + + #[test] + fn next_child_storage_key_works() { + let child = || ChildStorageKey::from_slice(b":child_storage:default:Child1").unwrap(); + let mut overlay = OverlayedChanges::default(); + overlay.set_child_storage(child().as_ref().to_vec(), vec![20], None); + overlay.set_child_storage(child().as_ref().to_vec(), vec![30], Some(vec![31])); + let backend = vec![ + (Some(child().as_ref().to_vec()), vec![10], Some(vec![10])), + (Some(child().as_ref().to_vec()), vec![20], Some(vec![20])), + (Some(child().as_ref().to_vec()), vec![40], Some(vec![40])), + ].into(); + + let ext = TestExt::new(&mut overlay, &backend, None, None); + + // next_backend < next_overlay + assert_eq!(ext.next_child_storage_key(child(), &[5]), Some(vec![10])); + + // next_backend == next_overlay but next_overlay is a delete + assert_eq!(ext.next_child_storage_key(child(), &[10]), Some(vec![30])); + + // next_overlay < next_backend + assert_eq!(ext.next_child_storage_key(child(), &[20]), Some(vec![30])); + + // next_backend exist but next_overlay doesn't exist + assert_eq!(ext.next_child_storage_key(child(), &[30]), Some(vec![40])); + + drop(ext); + overlay.set_child_storage(child().as_ref().to_vec(), vec![50], Some(vec![50])); + let ext = TestExt::new(&mut overlay, &backend, None, None); + + // next_overlay exist but next_backend doesn't exist + assert_eq!(ext.next_child_storage_key(child(), &[40]), Some(vec![50])); + } } diff --git a/primitives/state-machine/src/lib.rs b/primitives/state-machine/src/lib.rs index d4798ad4fb..594e539b25 100644 --- a/primitives/state-machine/src/lib.rs +++ b/primitives/state-machine/src/lib.rs @@ -731,7 +731,7 @@ fn try_read_overlay_value( #[cfg(test)] mod tests { - use std::collections::HashMap; + use std::collections::BTreeMap; use codec::Encode; use overlayed_changes::OverlayedValue; use super::*; @@ -921,7 +921,7 @@ mod tests { #[test] fn clear_prefix_in_ext_works() { - let initial: HashMap<_, _> = map![ + let initial: BTreeMap<_, _> = map![ b"aaa".to_vec() => b"0".to_vec(), b"abb".to_vec() => b"1".to_vec(), b"abc".to_vec() => b"2".to_vec(), diff --git a/primitives/state-machine/src/overlayed_changes.rs b/primitives/state-machine/src/overlayed_changes.rs index 9bbfd68f67..d61d14961d 100644 --- a/primitives/state-machine/src/overlayed_changes.rs +++ b/primitives/state-machine/src/overlayed_changes.rs @@ -18,10 +18,11 @@ #[cfg(test)] use std::iter::FromIterator; -use std::collections::{HashMap, BTreeSet}; +use std::collections::{HashMap, BTreeMap, BTreeSet}; use codec::Decode; use crate::changes_trie::{NO_EXTRINSIC_INDEX, Configuration as ChangesTrieConfig}; use primitives::storage::well_known_keys::EXTRINSIC_INDEX; +use std::{mem, ops}; /// The overlayed changes to state to be queried on top of the backend. /// @@ -54,9 +55,9 @@ pub struct OverlayedValue { #[cfg_attr(test, derive(PartialEq))] pub struct OverlayedChangeSet { /// Top level storage changes. - pub top: HashMap, OverlayedValue>, + pub top: BTreeMap, OverlayedValue>, /// Child storage changes. - pub children: HashMap, HashMap, OverlayedValue>>, + pub children: HashMap, BTreeMap, OverlayedValue>>, } #[cfg(test)] @@ -274,9 +275,10 @@ impl OverlayedChanges { /// Commit prospective changes to state. pub fn commit_prospective(&mut self) { if self.committed.is_empty() { - ::std::mem::swap(&mut self.prospective, &mut self.committed); + mem::swap(&mut self.prospective, &mut self.committed); } else { - for (key, val) in self.prospective.top.drain() { + let top_to_commit = mem::replace(&mut self.prospective.top, BTreeMap::new()); + for (key, val) in top_to_commit.into_iter() { let entry = self.committed.top.entry(key).or_default(); entry.value = val.value; @@ -285,9 +287,9 @@ impl OverlayedChanges { .extend(prospective_extrinsics); } } - for (storage_key, mut map) in self.prospective.children.drain() { + for (storage_key, map) in self.prospective.children.drain() { let map_dest = self.committed.children.entry(storage_key).or_default(); - for (key, val) in map.drain() { + for (key, val) in map.into_iter() { let entry = map_dest.entry(key).or_default(); entry.value = val.value; @@ -339,6 +341,56 @@ impl OverlayedChanges { false => None, } } + + /// Returns the next (in lexicographic order) storage key in the overlayed alongside its value. + /// If no value is next then `None` is returned. + pub fn next_storage_key_change(&self, key: &[u8]) -> Option<(&[u8], &OverlayedValue)> { + let range = (ops::Bound::Excluded(key), ops::Bound::Unbounded); + + let next_prospective_key = self.prospective.top + .range::<[u8], _>(range) + .next() + .map(|(k, v)| (&k[..], v)); + + let next_committed_key = self.committed.top + .range::<[u8], _>(range) + .next() + .map(|(k, v)| (&k[..], v)); + + match (next_committed_key, next_prospective_key) { + // Committed is strictly less than prospective + (Some(committed_key), Some(prospective_key)) if committed_key.0 < prospective_key.0 => + Some(committed_key), + (committed_key, None) => committed_key, + // Prospective key is less or equal to committed or committed doesn't exist + (_, prospective_key) => prospective_key, + } + } + + /// Returns the next (in lexicographic order) child storage key in the overlayed alongside its + /// value. If no value is next then `None` is returned. + pub fn next_child_storage_key_change( + &self, + storage_key: &[u8], + key: &[u8] + ) -> Option<(&[u8], &OverlayedValue)> { + let range = (ops::Bound::Excluded(key), ops::Bound::Unbounded); + + let next_prospective_key = self.prospective.children.get(storage_key) + .and_then(|map| map.range::<[u8], _>(range).next().map(|(k, v)| (&k[..], v))); + + let next_committed_key = self.committed.children.get(storage_key) + .and_then(|map| map.range::<[u8], _>(range).next().map(|(k, v)| (&k[..], v))); + + match (next_committed_key, next_prospective_key) { + // Committed is strictly less than prospective + (Some(committed_key), Some(prospective_key)) if committed_key.0 < prospective_key.0 => + Some(committed_key), + (committed_key, None) => committed_key, + // Prospective key is less or equal to committed or committed doesn't exist + (_, prospective_key) => prospective_key, + } + } } #[cfg(test)] @@ -359,8 +411,8 @@ mod tests { use crate::ext::Ext; use super::*; - fn strip_extrinsic_index(map: &HashMap, OverlayedValue>) - -> HashMap, OverlayedValue> + fn strip_extrinsic_index(map: &BTreeMap, OverlayedValue>) + -> BTreeMap, OverlayedValue> { let mut clone = map.clone(); clone.remove(&EXTRINSIC_INDEX.to_vec()); @@ -397,7 +449,7 @@ mod tests { #[test] fn overlayed_storage_root_works() { - let initial: HashMap<_, _> = vec![ + let initial: BTreeMap<_, _> = vec![ (b"doe".to_vec(), b"reindeer".to_vec()), (b"dog".to_vec(), b"puppyXXX".to_vec()), (b"dogglesworth".to_vec(), b"catXXX".to_vec()), @@ -543,4 +595,79 @@ mod tests { assert_eq!(overlay.prospective, Default::default()); } + + #[test] + fn next_storage_key_change_works() { + let mut overlay = OverlayedChanges::default(); + overlay.set_storage(vec![20], Some(vec![20])); + overlay.set_storage(vec![30], Some(vec![30])); + overlay.set_storage(vec![40], Some(vec![40])); + overlay.commit_prospective(); + overlay.set_storage(vec![10], Some(vec![10])); + overlay.set_storage(vec![30], None); + + // next_prospective < next_committed + let next_to_5 = overlay.next_storage_key_change(&[5]).unwrap(); + assert_eq!(next_to_5.0.to_vec(), vec![10]); + assert_eq!(next_to_5.1.value, Some(vec![10])); + + // next_committed < next_prospective + let next_to_10 = overlay.next_storage_key_change(&[10]).unwrap(); + assert_eq!(next_to_10.0.to_vec(), vec![20]); + assert_eq!(next_to_10.1.value, Some(vec![20])); + + // next_committed == next_prospective + let next_to_20 = overlay.next_storage_key_change(&[20]).unwrap(); + assert_eq!(next_to_20.0.to_vec(), vec![30]); + assert_eq!(next_to_20.1.value, None); + + // next_committed, no next_prospective + let next_to_30 = overlay.next_storage_key_change(&[30]).unwrap(); + assert_eq!(next_to_30.0.to_vec(), vec![40]); + assert_eq!(next_to_30.1.value, Some(vec![40])); + + overlay.set_storage(vec![50], Some(vec![50])); + // next_prospective, no next_committed + let next_to_40 = overlay.next_storage_key_change(&[40]).unwrap(); + assert_eq!(next_to_40.0.to_vec(), vec![50]); + assert_eq!(next_to_40.1.value, Some(vec![50])); + } + + #[test] + fn next_child_storage_key_change_works() { + let child = b"Child1".to_vec(); + let mut overlay = OverlayedChanges::default(); + overlay.set_child_storage(child.clone(), vec![20], Some(vec![20])); + overlay.set_child_storage(child.clone(), vec![30], Some(vec![30])); + overlay.set_child_storage(child.clone(), vec![40], Some(vec![40])); + overlay.commit_prospective(); + overlay.set_child_storage(child.clone(), vec![10], Some(vec![10])); + overlay.set_child_storage(child.clone(), vec![30], None); + + // next_prospective < next_committed + let next_to_5 = overlay.next_child_storage_key_change(&child, &[5]).unwrap(); + assert_eq!(next_to_5.0.to_vec(), vec![10]); + assert_eq!(next_to_5.1.value, Some(vec![10])); + + // next_committed < next_prospective + let next_to_10 = overlay.next_child_storage_key_change(&child, &[10]).unwrap(); + assert_eq!(next_to_10.0.to_vec(), vec![20]); + assert_eq!(next_to_10.1.value, Some(vec![20])); + + // next_committed == next_prospective + let next_to_20 = overlay.next_child_storage_key_change(&child, &[20]).unwrap(); + assert_eq!(next_to_20.0.to_vec(), vec![30]); + assert_eq!(next_to_20.1.value, None); + + // next_committed, no next_prospective + let next_to_30 = overlay.next_child_storage_key_change(&child, &[30]).unwrap(); + assert_eq!(next_to_30.0.to_vec(), vec![40]); + assert_eq!(next_to_30.1.value, Some(vec![40])); + + overlay.set_child_storage(child.clone(), vec![50], Some(vec![50])); + // next_prospective, no next_committed + let next_to_40 = overlay.next_child_storage_key_change(&child, &[40]).unwrap(); + assert_eq!(next_to_40.0.to_vec(), vec![50]); + assert_eq!(next_to_40.1.value, Some(vec![50])); + } } diff --git a/primitives/state-machine/src/proving_backend.rs b/primitives/state-machine/src/proving_backend.rs index 446dc635e1..2a9146dfce 100644 --- a/primitives/state-machine/src/proving_backend.rs +++ b/primitives/state-machine/src/proving_backend.rs @@ -272,6 +272,14 @@ impl<'a, S, H> Backend for ProvingBackend<'a, S, H> self.0.child_storage(storage_key, key) } + fn next_storage_key(&self, key: &[u8]) -> Result>, Self::Error> { + self.0.next_storage_key(key) + } + + fn next_child_storage_key(&self, storage_key: &[u8], key: &[u8]) -> Result>, Self::Error> { + self.0.next_child_storage_key(storage_key, key) + } + fn for_keys_in_child_storage(&self, storage_key: &[u8], f: F) { self.0.for_keys_in_child_storage(storage_key, f) } diff --git a/primitives/state-machine/src/testing.rs b/primitives/state-machine/src/testing.rs index dd4f7c557e..85c9260fba 100644 --- a/primitives/state-machine/src/testing.rs +++ b/primitives/state-machine/src/testing.rs @@ -16,7 +16,7 @@ //! Test implementation for Externalities. -use std::{collections::HashMap, any::{Any, TypeId}}; +use std::{collections::{HashMap, BTreeMap}, any::{Any, TypeId}}; use hash_db::Hasher; use crate::{ backend::{InMemory, Backend}, OverlayedChanges, @@ -35,7 +35,7 @@ use primitives::{ use codec::Encode; use externalities::{Extensions, Extension}; -type StorageTuple = (HashMap, Vec>, HashMap, HashMap, Vec>>); +type StorageTuple = (BTreeMap, Vec>, HashMap, BTreeMap, Vec>>); /// Simple HashMap-based Externalities impl. pub struct TestExternalities=Blake2Hasher, N: ChangesTrieBlockNumber=u64> { diff --git a/primitives/state-machine/src/trie_backend.rs b/primitives/state-machine/src/trie_backend.rs index a2ca5c5d4a..f24c47c891 100644 --- a/primitives/state-machine/src/trie_backend.rs +++ b/primitives/state-machine/src/trie_backend.rs @@ -79,6 +79,14 @@ impl, H: Hasher> Backend for TrieBackend where self.essence.child_storage(storage_key, key) } + fn next_storage_key(&self, key: &[u8]) -> Result>, Self::Error> { + self.essence.next_storage_key(key) + } + + fn next_child_storage_key(&self, storage_key: &[u8], key: &[u8]) -> Result>, Self::Error> { + self.essence.next_child_storage_key(storage_key, key) + } + fn for_keys_with_prefix(&self, prefix: &[u8], f: F) { self.essence.for_keys_with_prefix(prefix, f) } diff --git a/primitives/state-machine/src/trie_backend_essence.rs b/primitives/state-machine/src/trie_backend_essence.rs index a8572aff60..6a38f56e0b 100644 --- a/primitives/state-machine/src/trie_backend_essence.rs +++ b/primitives/state-machine/src/trie_backend_essence.rs @@ -64,6 +64,76 @@ impl, H: Hasher> TrieBackendEssence where H::Out: self.storage } + /// Return the next key in the trie i.e. the minimum key that is strictly superior to `key` in + /// lexicographic order. + pub fn next_storage_key(&self, key: &[u8]) -> Result>, String> { + self.next_storage_key_from_root(&self.root, key) + } + + /// Return the next key in the child trie i.e. the minimum key that is strictly superior to + /// `key` in lexicographic order. + pub fn next_child_storage_key( + &self, + storage_key: &[u8], + key: &[u8], + ) -> Result>, String> { + let child_root = match self.storage(storage_key)? { + Some(child_root) => child_root, + None => return Ok(None), + }; + + let mut hash = H::Out::default(); + + if child_root.len() != hash.as_ref().len() { + return Err(format!("Invalid child storage hash at {:?}", storage_key)); + } + // note: child_root and hash must be same size, panics otherwise. + hash.as_mut().copy_from_slice(&child_root[..]); + + self.next_storage_key_from_root(&hash, key) + } + + /// Return next key from main trie or child trie by providing corresponding root. + fn next_storage_key_from_root( + &self, + root: &H::Out, + key: &[u8], + ) -> Result>, String> { + let mut read_overlay = S::Overlay::default(); + let eph = Ephemeral { + storage: &self.storage, + overlay: &mut read_overlay, + }; + + let trie = TrieDB::::new(&eph, root) + .map_err(|e| format!("TrieDB creation error: {}", e))?; + let mut iter = trie.iter() + .map_err(|e| format!("TrieDB iteration error: {}", e))?; + + // 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). + let mut potential_next_key = Vec::with_capacity(key.len() + 1); + potential_next_key.extend_from_slice(key); + potential_next_key.push(0); + + iter.seek(&potential_next_key) + .map_err(|e| format!("TrieDB iterator seek error: {}", e))?; + + let next_element = iter.next(); + + let next_key = if let Some(next_element) = next_element { + let (next_key, _) = next_element + .map_err(|e| format!("TrieDB iterator next error: {}", e))?; + Some(next_key) + } else { + None + }; + + Ok(next_key) + } + /// Get the value of storage at given key. pub fn storage(&self, key: &[u8]) -> Result>, String> { let mut read_overlay = S::Overlay::default(); @@ -345,3 +415,47 @@ impl TrieBackendStorage for MemoryDB { Ok(hash_db::HashDB::get(self, key, prefix)) } } + +#[cfg(test)] +mod test { + use primitives::{Blake2Hasher, H256}; + use trie::{TrieMut, PrefixedMemoryDB, trie_types::TrieDBMut}; + use super::*; + + #[test] + fn next_storage_key_and_next_child_storage_key_work() { + // Contains values + let mut root_1 = H256::default(); + // Contains child trie + let mut root_2 = H256::default(); + + let mut mdb = PrefixedMemoryDB::::default(); + { + let mut trie = TrieDBMut::new(&mut mdb, &mut root_1); + trie.insert(b"3", &[1]).expect("insert failed"); + trie.insert(b"4", &[1]).expect("insert failed"); + trie.insert(b"6", &[1]).expect("insert failed"); + } + { + let mut trie = TrieDBMut::new(&mut mdb, &mut root_2); + trie.insert(b"MyChild", root_1.as_ref()).expect("insert failed"); + }; + + let essence_1 = TrieBackendEssence::new(mdb, root_1); + + assert_eq!(essence_1.next_storage_key(b"2"), Ok(Some(b"3".to_vec()))); + assert_eq!(essence_1.next_storage_key(b"3"), Ok(Some(b"4".to_vec()))); + assert_eq!(essence_1.next_storage_key(b"4"), Ok(Some(b"6".to_vec()))); + assert_eq!(essence_1.next_storage_key(b"5"), Ok(Some(b"6".to_vec()))); + assert_eq!(essence_1.next_storage_key(b"6"), Ok(None)); + + let mdb = essence_1.into_storage(); + let essence_2 = TrieBackendEssence::new(mdb, root_2); + + assert_eq!(essence_2.next_child_storage_key(b"MyChild", b"2"), Ok(Some(b"3".to_vec()))); + assert_eq!(essence_2.next_child_storage_key(b"MyChild", b"3"), Ok(Some(b"4".to_vec()))); + assert_eq!(essence_2.next_child_storage_key(b"MyChild", b"4"), Ok(Some(b"6".to_vec()))); + assert_eq!(essence_2.next_child_storage_key(b"MyChild", b"5"), Ok(Some(b"6".to_vec()))); + assert_eq!(essence_2.next_child_storage_key(b"MyChild", b"6"), Ok(None)); + } +} diff --git a/test/utils/runtime/client/src/lib.rs b/test/utils/runtime/client/src/lib.rs index cd815b7ea4..8511750bc2 100644 --- a/test/utils/runtime/client/src/lib.rs +++ b/test/utils/runtime/client/src/lib.rs @@ -23,7 +23,7 @@ pub mod trait_tests; mod block_builder_ext; use std::sync::Arc; -use std::collections::HashMap; +use std::collections::{HashMap, BTreeMap}; pub use block_builder_ext::BlockBuilderExt; pub use generic_test_client::*; pub use runtime; @@ -97,8 +97,8 @@ pub type LightExecutor = client::light::call_executor::GenesisCallExecutor< pub struct GenesisParameters { support_changes_trie: bool, heap_pages_override: Option, - extra_storage: HashMap, Vec>, - child_extra_storage: HashMap, HashMap, Vec>>, + extra_storage: BTreeMap, Vec>, + child_extra_storage: HashMap, BTreeMap, Vec>>, } impl GenesisParameters { diff --git a/test/utils/runtime/src/genesismap.rs b/test/utils/runtime/src/genesismap.rs index eb2ee14404..fc4acfefe2 100644 --- a/test/utils/runtime/src/genesismap.rs +++ b/test/utils/runtime/src/genesismap.rs @@ -16,7 +16,7 @@ //! Tool for creating the genesis block. -use std::collections::HashMap; +use std::collections::{BTreeMap, HashMap}; use runtime_io::hashing::{blake2_256, twox_128}; use super::{AuthorityId, AccountId, WASM_BINARY, system}; use codec::{Encode, KeyedVec, Joiner}; @@ -30,8 +30,8 @@ pub struct GenesisConfig { balances: Vec<(AccountId, u64)>, heap_pages_override: Option, /// Additional storage key pairs that will be added to the genesis map. - extra_storage: HashMap, Vec>, - child_extra_storage: HashMap, HashMap, Vec>>, + extra_storage: BTreeMap, Vec>, + child_extra_storage: HashMap, BTreeMap, Vec>>, } impl GenesisConfig { @@ -41,8 +41,8 @@ impl GenesisConfig { endowed_accounts: Vec, balance: u64, heap_pages_override: Option, - extra_storage: HashMap, Vec>, - child_extra_storage: HashMap, HashMap, Vec>>, + extra_storage: BTreeMap, Vec>, + child_extra_storage: HashMap, BTreeMap, Vec>>, ) -> Self { GenesisConfig { changes_trie_config: match support_changes_trie { @@ -58,11 +58,11 @@ impl GenesisConfig { } pub fn genesis_map(&self) -> ( - HashMap, Vec>, - HashMap, HashMap, Vec>>, + BTreeMap, Vec>, + HashMap, BTreeMap, Vec>>, ) { let wasm_runtime = WASM_BINARY.to_vec(); - let mut map: HashMap, Vec> = self.balances.iter() + let mut map: BTreeMap, Vec> = self.balances.iter() .map(|&(ref account, balance)| (account.to_keyed_vec(b"balance:"), vec![].and(&balance))) .map(|(k, v)| (blake2_256(&k[..])[..].to_vec(), v.to_vec())) .chain(vec![ @@ -92,8 +92,8 @@ impl GenesisConfig { pub fn insert_genesis_block( storage: &mut ( - HashMap, Vec>, - HashMap, HashMap, Vec>>, + BTreeMap, Vec>, + HashMap, BTreeMap, Vec>>, ) ) -> primitives::hash::H256 { let child_roots = storage.1.iter().map(|(sk, child_map)| { @@ -111,7 +111,7 @@ pub fn insert_genesis_block( genesis_hash } -pub fn additional_storage_with_genesis(genesis_block: &crate::Block) -> HashMap, Vec> { +pub fn additional_storage_with_genesis(genesis_block: &crate::Block) -> BTreeMap, Vec> { map![ twox_128(&b"latest"[..]).to_vec() => genesis_block.hash().as_fixed_bytes().to_vec() ] -- GitLab From af370c710a87908fcfb5296fe2a8202e1808ee64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Mon, 9 Dec 2019 21:18:29 +0100 Subject: [PATCH 107/172] Fix compilation of `sp-authorship` (#4337) --- primitives/authorship/Cargo.toml | 11 ++++++----- primitives/authorship/src/lib.rs | 6 +++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/primitives/authorship/Cargo.toml b/primitives/authorship/Cargo.toml index 4db66e6421..26093b0136 100644 --- a/primitives/authorship/Cargo.toml +++ b/primitives/authorship/Cargo.toml @@ -6,15 +6,16 @@ description = "Authorship primitives" edition = "2018" [dependencies] -sp-inherents = { package = "sp-inherents", path = "../inherents", default-features = false } -sr-primitives = { package = "sp-runtime", path = "../sr-primitives", default-features = false } +sp-inherents = { path = "../inherents", default-features = false } +sp-runtime = { path = "../runtime", default-features = false } rstd = { package = "sp-std", path = "../sr-std", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } [features] default = [ "std" ] std = [ - "codec/std", - "rstd/std", - "sp-inherents/std", + "codec/std", + "rstd/std", + "sp-inherents/std", + "sp-runtime/std", ] diff --git a/primitives/authorship/src/lib.rs b/primitives/authorship/src/lib.rs index b80102f41c..c143e752b2 100644 --- a/primitives/authorship/src/lib.rs +++ b/primitives/authorship/src/lib.rs @@ -22,13 +22,13 @@ use rstd::{result::Result, prelude::*}; use codec::{Encode, Decode}; use sp_inherents::{Error, InherentIdentifier, InherentData, IsFatalError}; -use sr_primitives::RuntimeString; +use sp_runtime::RuntimeString; /// The identifier for the `uncles` inherent. pub const INHERENT_IDENTIFIER: InherentIdentifier = *b"uncles00"; /// Errors that can occur while checking the authorship inherent. -#[derive(Encode, sr_primitives::RuntimeDebug)] +#[derive(Encode, sp_runtime::RuntimeDebug)] #[cfg_attr(feature = "std", derive(Decode))] pub enum InherentError { Uncles(RuntimeString), @@ -88,4 +88,4 @@ where F: Fn() -> Vec fn error_to_string(&self, _error: &[u8]) -> Option { Some(format!("no further information")) } -} \ No newline at end of file +} -- GitLab From 8cb06da9853d50aea0f81d1a94c48f64618a58fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Mon, 9 Dec 2019 23:37:33 +0100 Subject: [PATCH 108/172] Remove depenendcy on sc-consensus-slots (#4321) --- Cargo.lock | 2 +- client/consensus/aura/src/lib.rs | 4 ++-- client/consensus/babe/src/lib.rs | 4 ++-- client/consensus/slots/src/lib.rs | 19 +------------------ primitives/consensus/babe/Cargo.toml | 8 ++++---- primitives/consensus/babe/src/lib.rs | 2 +- primitives/consensus/common/src/lib.rs | 17 +++++++++++++++++ 7 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 69030e5357..6d255ea2f4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6103,9 +6103,9 @@ version = "2.0.0" dependencies = [ "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "sc-application-crypto 2.0.0", - "sc-consensus-slots 2.0.0", "schnorrkel 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)", "sp-api 2.0.0", + "sp-consensus 2.0.0", "sp-inherents 2.0.0", "sp-runtime 2.0.0", "sp-std 2.0.0", diff --git a/client/consensus/aura/src/lib.rs b/client/consensus/aura/src/lib.rs index e07ab5f99a..745c0bebe2 100644 --- a/client/consensus/aura/src/lib.rs +++ b/client/consensus/aura/src/lib.rs @@ -33,7 +33,7 @@ use std::{sync::Arc, time::Duration, thread, marker::PhantomData, hash::Hash, fm use codec::{Encode, Decode, Codec}; use consensus_common::{ self, BlockImport, Environment, Proposer, CanAuthorWith, ForkChoiceStrategy, BlockImportParams, - BlockOrigin, Error as ConsensusError, SelectChain, + BlockOrigin, Error as ConsensusError, SelectChain, SlotData, }; use consensus_common::import_queue::{ Verifier, BasicQueue, BoxBlockImport, BoxJustificationImport, BoxFinalityProofImport, @@ -65,7 +65,7 @@ use sp_timestamp::{ use sc_telemetry::{telemetry, CONSENSUS_TRACE, CONSENSUS_DEBUG, CONSENSUS_INFO}; -use slots::{CheckedHeader, SlotData, SlotWorker, SlotInfo, SlotCompatible}; +use slots::{CheckedHeader, SlotWorker, SlotInfo, SlotCompatible}; use slots::check_equivocation; use keystore::KeyStorePtr; diff --git a/client/consensus/babe/src/lib.rs b/client/consensus/babe/src/lib.rs index de0efbbcc8..9bdc08b883 100644 --- a/client/consensus/babe/src/lib.rs +++ b/client/consensus/babe/src/lib.rs @@ -82,10 +82,10 @@ use sc_telemetry::{telemetry, CONSENSUS_TRACE, CONSENSUS_DEBUG}; use consensus_common::{ self, BlockImport, Environment, Proposer, BlockCheckParams, ForkChoiceStrategy, BlockImportParams, BlockOrigin, Error as ConsensusError, + SelectChain, SlotData, }; use babe_primitives::inherents::BabeInherentData; use sp_timestamp::{TimestampInherentData, InherentType as TimestampInherent}; -use consensus_common::SelectChain; use consensus_common::import_queue::{Verifier, BasicQueue, CacheKeyId}; use client_api::{ backend::{AuxStore, Backend}, @@ -99,7 +99,7 @@ use block_builder_api::BlockBuilder as BlockBuilderApi; use slots::{CheckedHeader, check_equivocation}; use futures::prelude::*; use log::{warn, debug, info, trace}; -use slots::{SlotWorker, SlotData, SlotInfo, SlotCompatible}; +use slots::{SlotWorker, SlotInfo, SlotCompatible}; use epoch_changes::descendent_query; use sp_blockchain::{ Result as ClientResult, Error as ClientError, diff --git a/client/consensus/slots/src/lib.rs b/client/consensus/slots/src/lib.rs index e6a5361c2f..e95974fb92 100644 --- a/client/consensus/slots/src/lib.rs +++ b/client/consensus/slots/src/lib.rs @@ -31,7 +31,7 @@ use slots::Slots; pub use aux_schema::{check_equivocation, MAX_SLOT_CAPACITY, PRUNING_BOUND}; use codec::{Decode, Encode}; -use consensus_common::{BlockImport, Proposer, SyncOracle, SelectChain, CanAuthorWith}; +use consensus_common::{BlockImport, Proposer, SyncOracle, SelectChain, CanAuthorWith, SlotData}; use futures::{prelude::*, future::{self, Either}}; use futures_timer::Delay; use inherents::{InherentData, InherentDataProviders}; @@ -386,23 +386,6 @@ pub enum CheckedHeader { Checked(H, S), } -/// A type from which a slot duration can be obtained. -pub trait SlotData { - /// Gets the slot duration. - fn slot_duration(&self) -> u64; - - /// The static slot key - const SLOT_KEY: &'static [u8]; -} - -impl SlotData for u64 { - fn slot_duration(&self) -> u64 { - *self - } - - const SLOT_KEY: &'static [u8] = b"aura_slot_duration"; -} - /// A slot duration. Create with `get_or_compute`. // The internal member should stay private here to maintain invariants of // `get_or_compute`. diff --git a/primitives/consensus/babe/Cargo.toml b/primitives/consensus/babe/Cargo.toml index 645ea5b44e..d4d867c373 100644 --- a/primitives/consensus/babe/Cargo.toml +++ b/primitives/consensus/babe/Cargo.toml @@ -10,10 +10,10 @@ app-crypto = { package = "sc-application-crypto", path = "../../application-cryp codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } rstd = { package = "sp-std", path = "../../sr-std", default-features = false } schnorrkel = { version = "0.8.5", features = ["preaudit_deprecated"], optional = true } -slots = { package = "sc-consensus-slots", path = "../../../client/consensus/slots", optional = true } sp-api = { path = "../../sr-api", default-features = false } -sp-runtime = { path = "../../runtime", default-features = false } +sp-consensus = { path = "../common", optional = true } sp-inherents = { package = "sp-inherents", path = "../../inherents", default-features = false } +sp-runtime = { path = "../../runtime", default-features = false } sp-timestamp = { path = "../../timestamp", default-features = false } [features] @@ -23,9 +23,9 @@ std = [ "codec/std", "rstd/std", "schnorrkel", - "slots", "sp-api/std", - "sp-runtime/std", + "sp-consensus", "sp-inherents/std", + "sp-runtime/std", "sp-timestamp/std", ] diff --git a/primitives/consensus/babe/src/lib.rs b/primitives/consensus/babe/src/lib.rs index cf4bfd1e98..552b841733 100644 --- a/primitives/consensus/babe/src/lib.rs +++ b/primitives/consensus/babe/src/lib.rs @@ -157,7 +157,7 @@ pub struct BabeConfiguration { } #[cfg(feature = "std")] -impl slots::SlotData for BabeConfiguration { +impl sp_consensus::SlotData for BabeConfiguration { fn slot_duration(&self) -> u64 { self.slot_duration } diff --git a/primitives/consensus/common/src/lib.rs b/primitives/consensus/common/src/lib.rs index 3545083a42..cc5d0105ad 100644 --- a/primitives/consensus/common/src/lib.rs +++ b/primitives/consensus/common/src/lib.rs @@ -181,3 +181,20 @@ impl CanAuthorWith for AlwaysCanAuthor { Ok(()) } } + +/// A type from which a slot duration can be obtained. +pub trait SlotData { + /// Gets the slot duration. + fn slot_duration(&self) -> u64; + + /// The static slot key + const SLOT_KEY: &'static [u8]; +} + +impl SlotData for u64 { + fn slot_duration(&self) -> u64 { + *self + } + + const SLOT_KEY: &'static [u8] = b"aura_slot_duration"; +} -- GitLab From 67476cefe5ff1896aa6216b251ffdf6c1a9b7427 Mon Sep 17 00:00:00 2001 From: Weiliang Li Date: Tue, 10 Dec 2019 15:38:43 +0900 Subject: [PATCH 109/172] Fix build for full_crypto (#4339) * fix tests for full_crypto * fix * bump libsecp256k1 * try fixing polkadot * Update .gitlab-ci.yml * Update .gitlab-ci.yml --- Cargo.lock | 35 +++++++++++++++++++++++------------ primitives/core/Cargo.toml | 19 +++++++++++-------- 2 files changed, 34 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6d255ea2f4..a7355677a6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -922,6 +922,18 @@ dependencies = [ "subtle 2.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "curve25519-dalek" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "subtle 2.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "zeroize 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "data-encoding" version = "2.1.2" @@ -986,14 +998,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "ed25519-dalek" -version = "1.0.0-pre.2" +version = "1.0.0-pre.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "curve25519-dalek 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "curve25519-dalek 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2352,7 +2362,7 @@ dependencies = [ "asn1_der 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", "bs58 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "ed25519-dalek 1.0.0-pre.2 (registry+https://github.com/rust-lang/crates.io-index)", + "ed25519-dalek 1.0.0-pre.3 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2768,7 +2778,7 @@ dependencies = [ [[package]] name = "lru" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "hashbrown 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5358,7 +5368,7 @@ dependencies = [ "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "linked_hash_set 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "lru 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "lru 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "quickcheck 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -6056,7 +6066,7 @@ version = "2.0.0" dependencies = [ "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "lru 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "lru 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sp-block-builder 2.0.0", @@ -6131,7 +6141,7 @@ dependencies = [ "blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "criterion 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "ed25519-dalek 1.0.0-pre.2 (registry+https://github.com/rust-lang/crates.io-index)", + "ed25519-dalek 1.0.0-pre.3 (registry+https://github.com/rust-lang/crates.io-index)", "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "hash256-std-hasher 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "hex 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -8116,6 +8126,7 @@ dependencies = [ "checksum ctrlc 3.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c7dfd2d8b4c82121dfdff120f818e09fc4380b0b7e17a742081a89b94853e87f" "checksum cuckoofilter 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8dd43f7cfaffe0a386636a10baea2ee05cc50df3b77bea4a456c9572a939bf1f" "checksum curve25519-dalek 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8b7dcd30ba50cdf88b55b033456138b7c0ac4afdc436d82e1b79f370f24cc66d" +"checksum curve25519-dalek 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "26778518a7f6cffa1d25a44b602b62b979bd88adb9e99ffec546998cf3404839" "checksum data-encoding 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f4f47ca1860a761136924ddd2422ba77b2ea54fe8cc75b9040804a0d9d32ad97" "checksum derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2159be042979966de68315bce7034bb000c775f22e3e834e1c52ff78f041cae8" "checksum difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" @@ -8124,7 +8135,7 @@ dependencies = [ "checksum dirs-sys 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "afa0b23de8fd801745c471deffa6e12d248f962c9fd4b4c33787b055599bde7b" "checksum dns-parser 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c4d33be9473d06f75f58220f71f7a9317aca647dc061dbd3c361b0bef505fbea" "checksum doc-comment 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "923dea538cea0aa3025e8685b20d6ee21ef99c4f77e954a30febbaac5ec73a97" -"checksum ed25519-dalek 1.0.0-pre.2 (registry+https://github.com/rust-lang/crates.io-index)" = "845aaacc16f01178f33349e7c992ecd0cee095aa5e577f0f4dee35971bd36455" +"checksum ed25519-dalek 1.0.0-pre.3 (registry+https://github.com/rust-lang/crates.io-index)" = "978710b352437433c97b2bff193f2fb1dfd58a093f863dd95e225a19baa599a2" "checksum either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" "checksum elastic-array 0.10.3 (registry+https://github.com/rust-lang/crates.io-index)" = "580f3768bd6465780d063f5b8213a2ebd506e139b345e4a81eb301ceae3d61e1" "checksum enumflags2 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "33121c8782ba948ba332dab29311b026a8716dc65a1599e5b88f392d38496af8" @@ -8276,7 +8287,7 @@ dependencies = [ "checksum lock_api 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e57b3997725d2b60dbec1297f6c2e2957cc383db1cebd6be812163f969c7d586" "checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" "checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" -"checksum lru 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9a57ada89b072a15fa9e1b9d1e18d0e161fd25a47e0a3ae4868cf53aada8ba97" +"checksum lru 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "79aea63cd4aa0930b66807632cc61c74db9ea687358fc1f165bab053bcce4a7a" "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" "checksum malloc_size_of_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e37c5d4cd9473c5f4c9c111f033f15d4df9bd378fdf615944e360a4f55a05f0b" "checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" diff --git a/primitives/core/Cargo.toml b/primitives/core/Cargo.toml index ee7cbb87c9..d3a8ee8b1b 100644 --- a/primitives/core/Cargo.toml +++ b/primitives/core/Cargo.toml @@ -10,32 +10,35 @@ codec = { package = "parity-scale-codec", version = "1.0.0", default-features = rustc-hex = { version = "2.0.1", default-features = false } log = { version = "0.4.8", default-features = false } serde = { version = "1.0.101", optional = true, features = ["derive"] } -twox-hash = { version = "1.5.0", default-features = false, optional = true } byteorder = { version = "1.3.2", default-features = false } primitive-types = { version = "0.6", default-features = false, features = ["codec"] } impl-serde = { version = "0.2.3", optional = true } wasmi = { version = "0.6.2", optional = true } hash-db = { version = "0.15.2", default-features = false } hash256-std-hasher = { version = "0.15.2", default-features = false } -ed25519-dalek = { version = "1.0.0-pre.2", default-features = false, features = ["u64_backend"], optional = true } base58 = { version = "0.1.0", optional = true } -blake2-rfc = { version = "0.2.18", default-features = false, optional = true } -schnorrkel = { version = "0.8.5", features = ["preaudit_deprecated"], default-features = false, optional = true } rand = { version = "0.7.2", optional = true } -sha2 = { version = "0.8.0", default-features = false, optional = true } substrate-bip39 = { version = "0.3.1", optional = true } tiny-bip39 = { version = "0.6.2", optional = true } -hex = { version = "0.4", default-features = false, optional = true } regex = { version = "1.3.1", optional = true } num-traits = { version = "0.2.8", default-features = false } zeroize = { version = "1.0.0", default-features = false } lazy_static = { version = "1.4.0", default-features = false, optional = true } parking_lot = { version = "0.9.0", optional = true } -libsecp256k1 = { version = "0.3.0", default-features = false, optional = true } -tiny-keccak = { version = "2.0.1", features = ["keccak"], optional = true } sp-debug-derive = { version = "2.0.0", path = "./debug-derive" } externalities = { package = "sp-externalities", path = "../externalities", optional = true } primitives-storage = { package = "sp-core-storage", path = "storage", default-features = false } + +# full crypto +ed25519-dalek = { version = "1.0.0-pre.3", default-features = false, features = ["u64_backend", "alloc"], optional = true } +blake2-rfc = { version = "0.2.18", default-features = false, optional = true } +tiny-keccak = { version = "2.0.1", features = ["keccak"], optional = true } +schnorrkel = { version = "0.8.5", features = ["preaudit_deprecated", "u64_backend"], default-features = false, optional = true } +libsecp256k1 = { version = "0.3.2", default-features = false, optional = true } +sha2 = { version = "0.8.0", default-features = false, optional = true } +hex = { version = "0.4", default-features = false, optional = true } +twox-hash = { version = "1.5.0", default-features = false, optional = true } + runtime-interface = { package = "sp-runtime-interface", path = "../runtime-interface", default-features = false } [dev-dependencies] -- GitLab From a9f49ad0fd3f0fa568be797c71f78679fa1b498f Mon Sep 17 00:00:00 2001 From: Weiliang Li Date: Tue, 10 Dec 2019 15:39:21 +0900 Subject: [PATCH 110/172] Fix check-polkadot (#4341) Follows #4317 --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index dee459cea7..04b1616f6a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -367,7 +367,7 @@ check_polkadot: - mkdir -p target/debug/wbuild/.cargo - echo "paths = [ \"$SUBSTRATE_PATH\" ]" > target/debug/wbuild/.cargo/config # package, others are updated along the way. - - cargo update -p sp-io + - cargo update # Check whether Polkadot 'master' branch builds with this Substrate commit. - time cargo check - cd - -- GitLab From f588aa53af54029c6b45f26342204482f2e946c5 Mon Sep 17 00:00:00 2001 From: Weiliang Li Date: Tue, 10 Dec 2019 16:26:27 +0900 Subject: [PATCH 111/172] Rename: primitives/sr-std -> primitives/sp-std (#4327) * primitives/sr-std -> primitives/std * fix * fix conflict * rstd -> sp-std * git mv * fix review * fix merge --- Cargo.toml | 2 +- bin/node-template/runtime/Cargo.toml | 4 +- bin/node-template/runtime/src/lib.rs | 2 +- bin/node/runtime/Cargo.toml | 4 +- bin/node/runtime/src/impls.rs | 4 +- bin/node/runtime/src/lib.rs | 2 +- client/Cargo.toml | 2 +- client/api/Cargo.toml | 2 +- client/executor/runtime-test/Cargo.toml | 4 +- client/executor/runtime-test/src/lib.rs | 2 +- frame/assets/Cargo.toml | 2 +- frame/aura/Cargo.toml | 4 +- frame/aura/src/lib.rs | 2 +- frame/authority-discovery/Cargo.toml | 4 +- frame/authority-discovery/src/lib.rs | 2 +- frame/authorship/Cargo.toml | 4 +- frame/authorship/src/lib.rs | 8 +-- frame/babe/Cargo.toml | 4 +- frame/babe/src/lib.rs | 4 +- frame/balances/Cargo.toml | 4 +- frame/balances/src/lib.rs | 6 +- frame/collective/Cargo.toml | 4 +- frame/collective/src/lib.rs | 14 ++--- frame/contracts/Cargo.toml | 4 +- frame/contracts/rpc/runtime-api/Cargo.toml | 4 +- frame/contracts/rpc/runtime-api/src/lib.rs | 2 +- frame/contracts/src/account_db.rs | 6 +- frame/contracts/src/exec.rs | 2 +- frame/contracts/src/gas.rs | 2 +- frame/contracts/src/lib.rs | 14 ++--- frame/contracts/src/wasm/code_cache.rs | 2 +- frame/contracts/src/wasm/mod.rs | 2 +- frame/contracts/src/wasm/prepare.rs | 2 +- frame/contracts/src/wasm/runtime.rs | 6 +- frame/democracy/Cargo.toml | 4 +- frame/democracy/src/lib.rs | 4 +- frame/democracy/src/vote_threshold.rs | 2 +- frame/elections-phragmen/Cargo.toml | 4 +- frame/elections-phragmen/src/lib.rs | 2 +- frame/elections/Cargo.toml | 4 +- frame/elections/src/lib.rs | 2 +- frame/evm/Cargo.toml | 4 +- frame/evm/src/backend.rs | 4 +- frame/evm/src/lib.rs | 2 +- frame/example/Cargo.toml | 4 +- frame/example/src/lib.rs | 8 +-- frame/executive/Cargo.toml | 4 +- frame/executive/src/lib.rs | 2 +- frame/finality-tracker/Cargo.toml | 4 +- frame/finality-tracker/src/lib.rs | 2 +- frame/generic-asset/Cargo.toml | 4 +- frame/generic-asset/src/lib.rs | 24 +++---- frame/grandpa/Cargo.toml | 4 +- frame/grandpa/src/lib.rs | 2 +- frame/identity/Cargo.toml | 4 +- frame/identity/src/lib.rs | 8 +-- frame/im-online/Cargo.toml | 4 +- frame/im-online/src/lib.rs | 4 +- frame/indices/Cargo.toml | 4 +- frame/indices/src/address.rs | 2 +- frame/indices/src/lib.rs | 2 +- frame/membership/Cargo.toml | 4 +- frame/membership/src/lib.rs | 6 +- frame/metadata/Cargo.toml | 4 +- frame/metadata/src/lib.rs | 18 +++--- frame/nicks/Cargo.toml | 4 +- frame/nicks/src/lib.rs | 2 +- frame/offences/Cargo.toml | 4 +- frame/offences/src/lib.rs | 2 +- frame/randomness-collective-flip/Cargo.toml | 4 +- frame/randomness-collective-flip/src/lib.rs | 2 +- frame/scored-pool/Cargo.toml | 4 +- frame/scored-pool/src/lib.rs | 7 +-- frame/session/Cargo.toml | 4 +- frame/session/src/historical.rs | 6 +- frame/session/src/lib.rs | 6 +- frame/staking/Cargo.toml | 4 +- frame/staking/src/lib.rs | 12 ++-- frame/staking/src/migration.rs | 2 +- frame/staking/src/slashing.rs | 10 +-- frame/sudo/Cargo.toml | 4 +- frame/sudo/src/lib.rs | 2 +- frame/support/Cargo.toml | 4 +- .../src/storage/genesis_config/builder_def.rs | 4 +- .../procedural/src/storage/metadata.rs | 10 +-- .../procedural/src/storage/storage_struct.rs | 2 +- frame/support/src/debug.rs | 4 +- frame/support/src/dispatch.rs | 18 +++--- frame/support/src/event.rs | 6 +- frame/support/src/hash.rs | 2 +- frame/support/src/inherent.rs | 2 +- frame/support/src/lib.rs | 4 +- frame/support/src/origin.rs | 8 +-- frame/support/src/storage/child.rs | 2 +- .../src/storage/generator/double_map.rs | 4 +- .../src/storage/generator/linked_map.rs | 2 +- frame/support/src/storage/generator/map.rs | 4 +- frame/support/src/storage/generator/value.rs | 2 +- frame/support/src/storage/hashed.rs | 2 +- frame/support/src/storage/mod.rs | 2 +- frame/support/src/storage/unhashed.rs | 2 +- frame/support/src/traits.rs | 3 +- frame/system/Cargo.toml | 4 +- frame/system/src/lib.rs | 62 +++++++++---------- frame/system/src/offchain.rs | 4 +- frame/timestamp/Cargo.toml | 4 +- frame/timestamp/src/lib.rs | 2 +- frame/transaction-payment/Cargo.toml | 4 +- .../rpc/runtime-api/Cargo.toml | 4 +- .../rpc/runtime-api/src/lib.rs | 2 +- frame/transaction-payment/src/lib.rs | 13 ++-- frame/treasury/Cargo.toml | 4 +- frame/treasury/src/lib.rs | 2 +- frame/utility/Cargo.toml | 4 +- frame/utility/src/lib.rs | 2 +- primitives/application-crypto/Cargo.toml | 4 +- primitives/application-crypto/src/ed25519.rs | 2 +- primitives/application-crypto/src/lib.rs | 6 +- primitives/application-crypto/src/sr25519.rs | 2 +- primitives/application-crypto/src/traits.rs | 10 +-- primitives/authority-discovery/Cargo.toml | 4 +- primitives/authority-discovery/src/lib.rs | 2 +- primitives/authorship/Cargo.toml | 4 +- primitives/authorship/src/lib.rs | 2 +- .../block-builder/runtime-api/Cargo.toml | 4 +- .../block-builder/runtime-api/src/lib.rs | 2 +- primitives/consensus/aura/Cargo.toml | 4 +- primitives/consensus/aura/src/inherents.rs | 2 +- primitives/consensus/aura/src/lib.rs | 2 +- primitives/consensus/babe/Cargo.toml | 4 +- primitives/consensus/babe/src/digest.rs | 2 +- primitives/consensus/babe/src/inherents.rs | 2 +- primitives/consensus/babe/src/lib.rs | 2 +- primitives/consensus/common/Cargo.toml | 2 +- primitives/consensus/pow/Cargo.toml | 4 +- primitives/consensus/pow/src/lib.rs | 2 +- primitives/core/Cargo.toml | 4 +- primitives/core/src/changes_trie.rs | 16 ++--- primitives/core/src/crypto.rs | 24 +++---- primitives/core/src/ecdsa.rs | 18 +++--- primitives/core/src/ed25519.rs | 26 ++++---- primitives/core/src/hexdisplay.rs | 8 +-- primitives/core/src/lib.rs | 14 ++--- primitives/core/src/offchain/mod.rs | 2 +- primitives/core/src/sandbox.rs | 2 +- primitives/core/src/sr25519.rs | 26 ++++---- primitives/core/src/testing.rs | 4 +- primitives/core/storage/Cargo.toml | 4 +- primitives/core/storage/src/lib.rs | 2 +- primitives/externalities/Cargo.toml | 2 +- primitives/finality-grandpa/Cargo.toml | 4 +- primitives/finality-grandpa/src/lib.rs | 4 +- primitives/finality-tracker/Cargo.toml | 4 +- primitives/inherents/Cargo.toml | 4 +- primitives/inherents/src/lib.rs | 2 +- primitives/phragmen/Cargo.toml | 4 +- primitives/phragmen/src/lib.rs | 2 +- primitives/phragmen/src/mock.rs | 10 +-- primitives/runtime-interface/Cargo.toml | 4 +- .../proc-macro/src/pass_by/enum_.rs | 4 +- primitives/runtime-interface/src/impls.rs | 12 ++-- primitives/runtime-interface/src/lib.rs | 2 +- primitives/runtime-interface/src/pass_by.rs | 4 +- primitives/runtime-interface/src/wasm.rs | 2 +- .../runtime-interface/test-wasm/Cargo.toml | 4 +- .../runtime-interface/test-wasm/src/lib.rs | 8 +-- primitives/runtime/Cargo.toml | 4 +- primitives/runtime/src/generic/block.rs | 2 +- primitives/runtime/src/generic/digest.rs | 2 +- primitives/runtime/src/generic/header.rs | 10 +-- primitives/runtime/src/generic/mod.rs | 4 +- .../src/generic/unchecked_extrinsic.rs | 4 +- primitives/runtime/src/lib.rs | 12 ++-- primitives/runtime/src/offchain/http.rs | 10 +-- primitives/runtime/src/traits.rs | 36 +++++------ .../runtime/src/transaction_validity.rs | 2 +- primitives/session/Cargo.toml | 4 +- primitives/session/src/lib.rs | 2 +- primitives/sr-api/Cargo.toml | 4 +- primitives/sr-api/src/lib.rs | 4 +- primitives/sr-arithmetic/Cargo.toml | 4 +- primitives/sr-arithmetic/fuzzer/Cargo.lock | 30 ++++----- primitives/sr-arithmetic/src/biguint.rs | 10 +-- primitives/sr-arithmetic/src/fixed64.rs | 8 +-- .../sr-arithmetic/src/helpers_128bit.rs | 2 +- primitives/sr-arithmetic/src/per_things.rs | 2 +- primitives/sr-arithmetic/src/rational128.rs | 2 +- primitives/sr-arithmetic/src/traits.rs | 4 +- primitives/sr-io/Cargo.toml | 4 +- primitives/sr-io/src/lib.rs | 6 +- primitives/sr-sandbox/Cargo.toml | 4 +- primitives/sr-sandbox/src/lib.rs | 2 +- primitives/sr-sandbox/with_std.rs | 4 +- primitives/sr-sandbox/without_std.rs | 4 +- primitives/sr-staking-primitives/Cargo.toml | 4 +- .../sr-staking-primitives/src/offence.rs | 2 +- primitives/sr-version/Cargo.toml | 4 +- primitives/{sr-std => std}/Cargo.toml | 0 primitives/{sr-std => std}/src/lib.rs | 0 primitives/{sr-std => std}/with_std.rs | 0 primitives/{sr-std => std}/without_std.rs | 0 primitives/timestamp/Cargo.toml | 4 +- primitives/trie/Cargo.toml | 4 +- primitives/trie/src/lib.rs | 6 +- primitives/trie/src/node_codec.rs | 17 +++-- primitives/trie/src/node_header.rs | 8 +-- primitives/trie/src/trie_stream.rs | 6 +- test/utils/runtime/Cargo.toml | 4 +- test/utils/runtime/src/lib.rs | 4 +- test/utils/runtime/src/system.rs | 2 +- 210 files changed, 552 insertions(+), 556 deletions(-) rename primitives/{sr-std => std}/Cargo.toml (100%) rename primitives/{sr-std => std}/src/lib.rs (100%) rename primitives/{sr-std => std}/with_std.rs (100%) rename primitives/{sr-std => std}/without_std.rs (100%) diff --git a/Cargo.toml b/Cargo.toml index 1ba46daebd..6f3c24be2b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -123,7 +123,7 @@ members = [ "primitives/runtime", "primitives/sr-sandbox", "primitives/sr-staking-primitives", - "primitives/sr-std", + "primitives/std", "primitives/sr-version", "primitives/state-machine", "primitives/timestamp", diff --git a/bin/node-template/runtime/Cargo.toml b/bin/node-template/runtime/Cargo.toml index de1fbd6ed3..3c55cd68fb 100644 --- a/bin/node-template/runtime/Cargo.toml +++ b/bin/node-template/runtime/Cargo.toml @@ -17,7 +17,7 @@ inherents = { package = "sp-inherents", path = "../../../primitives/inherents", offchain-primitives = { package = "sp-offchain", path = "../../../primitives/offchain", default-features = false } 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 } -rstd = { package = "sp-std", path = "../../../primitives/sr-std", default-features = false } +sp-std = { path = "../../../primitives/std", default-features = false } runtime-io = { package = "sp-io", path = "../../../primitives/sr-io", default-features = false } safe-mix = { version = "1.0.0", default-features = false } serde = { version = "1.0.101", optional = true, features = ["derive"] } @@ -50,7 +50,7 @@ std = [ "offchain-primitives/std", "primitives/std", "randomness-collective-flip/std", - "rstd/std", + "sp-std/std", "runtime-io/std", "safe-mix/std", "serde", diff --git a/bin/node-template/runtime/src/lib.rs b/bin/node-template/runtime/src/lib.rs index dbb30d3107..7abe43c066 100644 --- a/bin/node-template/runtime/src/lib.rs +++ b/bin/node-template/runtime/src/lib.rs @@ -8,7 +8,7 @@ #[cfg(feature = "std")] include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); -use rstd::prelude::*; +use sp_std::prelude::*; use primitives::OpaqueMetadata; use sp_runtime::{ ApplyExtrinsicResult, transaction_validity::TransactionValidity, generic, create_runtime_str, diff --git a/bin/node/runtime/Cargo.toml b/bin/node/runtime/Cargo.toml index 662716c822..5a95961bec 100644 --- a/bin/node/runtime/Cargo.toml +++ b/bin/node/runtime/Cargo.toml @@ -21,7 +21,7 @@ inherents = { package = "sp-inherents", path = "../../../primitives/inherents", node-primitives = { path = "../primitives", default-features = false } offchain-primitives = { package = "sp-offchain", path = "../../../primitives/offchain", default-features = false } primitives = { package = "sp-core", path = "../../../primitives/core", default-features = false } -rstd = { package = "sp-std", path = "../../../primitives/sr-std", default-features = false } +sp-std = { path = "../../../primitives/std", default-features = false } sp-api = { path = "../../../primitives/sr-api", default-features = false } sp-runtime = { path = "../../../primitives/runtime", default-features = false } sp-staking = { path = "../../../primitives/sr-staking-primitives", default-features = false } @@ -97,7 +97,7 @@ std = [ "offences/std", "primitives/std", "randomness-collective-flip/std", - "rstd/std", + "sp-std/std", "rustc-hex", "safe-mix/std", "serde", diff --git a/bin/node/runtime/src/impls.rs b/bin/node/runtime/src/impls.rs index a4547aa07b..aa6e0554be 100644 --- a/bin/node/runtime/src/impls.rs +++ b/bin/node/runtime/src/impls.rs @@ -47,7 +47,7 @@ impl Convert for CurrencyToVoteHandler { /// Convert from weight to balance via a simple coefficient multiplication /// The associated type C encapsulates a constant in units of balance per weight -pub struct LinearWeightToFee(rstd::marker::PhantomData); +pub struct LinearWeightToFee(sp_std::marker::PhantomData); impl> Convert for LinearWeightToFee { fn convert(w: Weight) -> Balance { @@ -66,7 +66,7 @@ impl> Convert for LinearWeightToFee { /// /// Where `target_weight` must be given as the `Get` implementation of the `T` generic type. /// https://research.web3.foundation/en/latest/polkadot/Token%20Economics/#relay-chain-transaction-fees -pub struct TargetedFeeAdjustment(rstd::marker::PhantomData); +pub struct TargetedFeeAdjustment(sp_std::marker::PhantomData); impl> Convert for TargetedFeeAdjustment { fn convert(multiplier: Fixed64) -> Fixed64 { diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 614e31e721..e78e873142 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -20,7 +20,7 @@ // `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256. #![recursion_limit="256"] -use rstd::prelude::*; +use sp_std::prelude::*; use support::{ construct_runtime, parameter_types, weights::Weight, diff --git a/client/Cargo.toml b/client/Cargo.toml index 819ef2e74b..b62a004416 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -22,7 +22,7 @@ kvdb = "0.1.1" log = { version = "0.4.8" } parking_lot = { version = "0.9.0" } primitives = { package = "sp-core", path = "../primitives/core" } -rstd = { package = "sp-std", path = "../primitives/sr-std" } +sp-std = { path = "../primitives/std" } runtime-version = { package = "sp-version", path = "../primitives/sr-version" } sp-api = { path = "../primitives/sr-api" } sp-runtime = { path = "../primitives/runtime" } diff --git a/client/api/Cargo.toml b/client/api/Cargo.toml index 494763363a..9b524f2be0 100644 --- a/client/api/Cargo.toml +++ b/client/api/Cargo.toml @@ -22,7 +22,7 @@ kvdb = "0.1.1" log = { version = "0.4.8" } parking_lot = { version = "0.9.0" } primitives = { package = "sp-core", path = "../../primitives/core", default-features = false } -rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +sp-std = { path = "../../primitives/std", default-features = false } runtime-version = { package = "sp-version", path = "../../primitives/sr-version", default-features = false } sp-api = { path = "../../primitives/sr-api" } sp-runtime = { path = "../../primitives/runtime", default-features = false } diff --git a/client/executor/runtime-test/Cargo.toml b/client/executor/runtime-test/Cargo.toml index 6ae8967837..75b9d510bd 100644 --- a/client/executor/runtime-test/Cargo.toml +++ b/client/executor/runtime-test/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" build = "build.rs" [dependencies] -rstd = { package = "sp-std", path = "../../../primitives/sr-std", default-features = false } +sp-std = { path = "../../../primitives/std", default-features = false } runtime_io = { package = "sp-io", path = "../../../primitives/sr-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 } @@ -17,4 +17,4 @@ wasm-builder-runner = { package = "substrate-wasm-builder-runner", path = "../.. [features] default = [ "std" ] -std = ["runtime_io/std", "sandbox/std", "rstd/std"] +std = ["runtime_io/std", "sandbox/std", "sp-std/std"] diff --git a/client/executor/runtime-test/src/lib.rs b/client/executor/runtime-test/src/lib.rs index 15b515d6c4..7229d9b1a4 100644 --- a/client/executor/runtime-test/src/lib.rs +++ b/client/executor/runtime-test/src/lib.rs @@ -6,7 +6,7 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); #[cfg(not(feature = "std"))] -use rstd::{vec::Vec, vec}; +use sp_std::{vec::Vec, vec}; #[cfg(not(feature = "std"))] use runtime_io::{ diff --git a/frame/assets/Cargo.toml b/frame/assets/Cargo.toml index bbb9c30daa..85c3623cfe 100644 --- a/frame/assets/Cargo.toml +++ b/frame/assets/Cargo.toml @@ -16,7 +16,7 @@ system = { package = "frame-system", path = "../system", default-features = fals [dev-dependencies] primitives = { package = "sp-core", path = "../../primitives/core" } -rstd = { package = "sp-std", path = "../../primitives/sr-std" } +sp-std = { path = "../../primitives/std" } runtime-io = { package = "sp-io", path = "../../primitives/sr-io" } [features] diff --git a/frame/aura/Cargo.toml b/frame/aura/Cargo.toml index e9f3e85f34..88194574f2 100644 --- a/frame/aura/Cargo.toml +++ b/frame/aura/Cargo.toml @@ -9,7 +9,7 @@ app-crypto = { package = "sc-application-crypto", path = "../../primitives/appl codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } inherents = { package = "sp-inherents", path = "../../primitives/inherents", default-features = false } primitives = { package = "sp-core", path = "../../primitives/core", default-features = false } -rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +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 } @@ -33,7 +33,7 @@ std = [ "inherents/std", "runtime-io/std", "primitives/std", - "rstd/std", + "sp-std/std", "serde", "sp-runtime/std", "support/std", diff --git a/frame/aura/src/lib.rs b/frame/aura/src/lib.rs index 59fe2dbd21..3e691e14cb 100644 --- a/frame/aura/src/lib.rs +++ b/frame/aura/src/lib.rs @@ -47,7 +47,7 @@ use pallet_timestamp; -use rstd::{result, prelude::*}; +use sp_std::{result, prelude::*}; use codec::{Encode, Decode}; use support::{ decl_storage, decl_module, Parameter, traits::{Get, FindAuthor}, diff --git a/frame/authority-discovery/Cargo.toml b/frame/authority-discovery/Cargo.toml index e3db707a6a..40fb6122f5 100644 --- a/frame/authority-discovery/Cargo.toml +++ b/frame/authority-discovery/Cargo.toml @@ -9,7 +9,7 @@ authority-discovery-primitives = { package = "sp-authority-discovery", path = ". app-crypto = { package = "sc-application-crypto", path = "../../primitives/application-crypto", 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 } -rstd = { package = "sp-std", path = "../../primitives/sr-std", 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 } session = { package = "pallet-session", path = "../session", default-features = false, features = ["historical" ] } @@ -27,7 +27,7 @@ std = [ "authority-discovery-primitives/std", "codec/std", "primitives/std", - "rstd/std", + "sp-std/std", "runtime-io/std", "serde", "session/std", diff --git a/frame/authority-discovery/src/lib.rs b/frame/authority-discovery/src/lib.rs index b24fe5e0eb..92dcb2277d 100644 --- a/frame/authority-discovery/src/lib.rs +++ b/frame/authority-discovery/src/lib.rs @@ -22,7 +22,7 @@ // Ensure we're `no_std` when compiling for Wasm. #![cfg_attr(not(feature = "std"), no_std)] -use rstd::prelude::*; +use sp_std::prelude::*; use support::{decl_module, decl_storage}; use authority_discovery_primitives::AuthorityId; diff --git a/frame/authorship/Cargo.toml b/frame/authorship/Cargo.toml index 496c4a1122..65b299dc29 100644 --- a/frame/authorship/Cargo.toml +++ b/frame/authorship/Cargo.toml @@ -10,7 +10,7 @@ primitives = { package = "sp-core", path = "../../primitives/core", default-fea codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } inherents = { package = "sp-inherents", path = "../../primitives/inherents", default-features = false } sp-authorship = { path = "../../primitives/authorship", default-features = false } -rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +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 } @@ -24,7 +24,7 @@ std = [ "primitives/std", "inherents/std", "sp-runtime/std", - "rstd/std", + "sp-std/std", "support/std", "system/std", "runtime-io/std", diff --git a/frame/authorship/src/lib.rs b/frame/authorship/src/lib.rs index 73a38b0ead..edb01b7d2a 100644 --- a/frame/authorship/src/lib.rs +++ b/frame/authorship/src/lib.rs @@ -20,8 +20,8 @@ #![cfg_attr(not(feature = "std"), no_std)] -use rstd::{result, prelude::*}; -use rstd::collections::btree_set::BTreeSet; +use sp_std::{result, prelude::*}; +use sp_std::collections::btree_set::BTreeSet; use support::{decl_module, decl_storage, ensure}; use support::traits::{FindAuthor, VerifySeal, Get}; use support::dispatch::Result as DispatchResult; @@ -98,7 +98,7 @@ impl FilterUncle for () { /// A filter on uncles which verifies seals and does no additional checks. /// This is well-suited to consensus modes such as PoW where the cost of /// equivocating is high. -pub struct SealVerify(rstd::marker::PhantomData); +pub struct SealVerify(sp_std::marker::PhantomData); impl> FilterUncle for SealVerify @@ -116,7 +116,7 @@ impl> FilterUncle /// one uncle included per author per height. /// /// This does O(n log n) work in the number of uncles included. -pub struct OnePerAuthorPerHeight(rstd::marker::PhantomData<(T, N)>); +pub struct OnePerAuthorPerHeight(sp_std::marker::PhantomData<(T, N)>); impl FilterUncle for OnePerAuthorPerHeight diff --git a/frame/babe/Cargo.toml b/frame/babe/Cargo.toml index a81865860d..8124ba6a59 100644 --- a/frame/babe/Cargo.toml +++ b/frame/babe/Cargo.toml @@ -9,7 +9,7 @@ hex-literal = "0.2.1" codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } serde = { version = "1.0.101", optional = true } inherents = { package = "sp-inherents", path = "../../primitives/inherents", default-features = false } -rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +sp-std = { path = "../../primitives/std", 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 } @@ -32,7 +32,7 @@ default = ["std"] std = [ "serde", "codec/std", - "rstd/std", + "sp-std/std", "support/std", "sp-runtime/std", "sp-staking/std", diff --git a/frame/babe/src/lib.rs b/frame/babe/src/lib.rs index 73a7adaaa3..a5db17e3bd 100644 --- a/frame/babe/src/lib.rs +++ b/frame/babe/src/lib.rs @@ -23,7 +23,7 @@ pub use timestamp; use sp_timestamp; -use rstd::{result, prelude::*}; +use sp_std::{result, prelude::*}; use support::{decl_storage, decl_module, traits::FindAuthor, traits::Get}; use sp_timestamp::OnTimestampSet; use sp_runtime::{generic::DigestItem, ConsensusEngineId, Perbill}; @@ -445,7 +445,7 @@ impl Module { /// randomness. Returns the new randomness. fn randomness_change_epoch(next_epoch_index: u64) -> [u8; RANDOMNESS_LENGTH] { let this_randomness = NextRandomness::get(); - let segment_idx: u32 = ::mutate(|s| rstd::mem::replace(s, 0)); + let segment_idx: u32 = ::mutate(|s| sp_std::mem::replace(s, 0)); // overestimate to the segment being full. let rho_size = segment_idx.saturating_add(1) as usize * UNDER_CONSTRUCTION_SEGMENT_LENGTH; diff --git a/frame/balances/Cargo.toml b/frame/balances/Cargo.toml index f0dd86a444..f4c6d9f5a1 100644 --- a/frame/balances/Cargo.toml +++ b/frame/balances/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" serde = { version = "1.0.101", optional = true } safe-mix = { version = "1.0.0", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +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 } @@ -24,7 +24,7 @@ std = [ "serde", "safe-mix/std", "codec/std", - "rstd/std", + "sp-std/std", "support/std", "sp-runtime/std", "system/std", diff --git a/frame/balances/src/lib.rs b/frame/balances/src/lib.rs index 6a3e701ac0..96737c64db 100644 --- a/frame/balances/src/lib.rs +++ b/frame/balances/src/lib.rs @@ -159,8 +159,8 @@ #![cfg_attr(not(feature = "std"), no_std)] -use rstd::prelude::*; -use rstd::{cmp, result, mem, fmt::Debug}; +use sp_std::prelude::*; +use sp_std::{cmp, result, mem, fmt::Debug}; use codec::{Codec, Encode, Decode}; use support::{ StorageValue, Parameter, decl_event, decl_storage, decl_module, @@ -614,7 +614,7 @@ mod imbalances { result, Subtrait, DefaultInstance, Imbalance, Trait, Zero, Instance, Saturating, StorageValue, TryDrop, }; - use rstd::mem; + use sp_std::mem; /// Opaque, move-only struct with private fields that serves as a token denoting that /// funds have been created without any equal and opposite accounting. diff --git a/frame/collective/Cargo.toml b/frame/collective/Cargo.toml index c7baa61346..8472a13186 100644 --- a/frame/collective/Cargo.toml +++ b/frame/collective/Cargo.toml @@ -9,7 +9,7 @@ serde = { version = "1.0.101", optional = true } 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 } -rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +sp-std = { path = "../../primitives/std", default-features = false } runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } @@ -25,7 +25,7 @@ std = [ "safe-mix/std", "codec/std", "primitives/std", - "rstd/std", + "sp-std/std", "serde", "runtime-io/std", "support/std", diff --git a/frame/collective/src/lib.rs b/frame/collective/src/lib.rs index 6ecaf3045f..176967636d 100644 --- a/frame/collective/src/lib.rs +++ b/frame/collective/src/lib.rs @@ -23,7 +23,7 @@ #![cfg_attr(not(feature = "std"), no_std)] #![recursion_limit="128"] -use rstd::{prelude::*, result}; +use sp_std::{prelude::*, result}; use primitives::u32_trait::Value as U32; use sp_runtime::RuntimeDebug; use sp_runtime::traits::{Hash, EnsureOrigin}; @@ -63,7 +63,7 @@ pub enum RawOrigin { /// It has been condoned by a single member of the collective. Member(AccountId), /// Dummy to manage the fact we have instancing. - _Phantom(rstd::marker::PhantomData), + _Phantom(sp_std::marker::PhantomData), } /// Origin for the collective module. @@ -96,7 +96,7 @@ decl_storage! { pub Members get(fn members): Vec; } add_extra_genesis { - config(phantom): rstd::marker::PhantomData; + config(phantom): sp_std::marker::PhantomData; config(members): Vec; build(|config| Module::::initialize_members(&config.members)) } @@ -306,7 +306,7 @@ where } } -pub struct EnsureMember(rstd::marker::PhantomData<(AccountId, I)>); +pub struct EnsureMember(sp_std::marker::PhantomData<(AccountId, I)>); impl< O: Into, O>> + From>, AccountId, @@ -321,7 +321,7 @@ impl< } } -pub struct EnsureMembers(rstd::marker::PhantomData<(N, AccountId, I)>); +pub struct EnsureMembers(sp_std::marker::PhantomData<(N, AccountId, I)>); impl< O: Into, O>> + From>, N: U32, @@ -338,7 +338,7 @@ impl< } pub struct EnsureProportionMoreThan( - rstd::marker::PhantomData<(N, D, AccountId, I)> + sp_std::marker::PhantomData<(N, D, AccountId, I)> ); impl< O: Into, O>> + From>, @@ -357,7 +357,7 @@ impl< } pub struct EnsureProportionAtLeast( - rstd::marker::PhantomData<(N, D, AccountId, I)> + sp_std::marker::PhantomData<(N, D, AccountId, I)> ); impl< O: Into, O>> + From>, diff --git a/frame/contracts/Cargo.toml b/frame/contracts/Cargo.toml index b961fba232..f5c9ec5fdb 100644 --- a/frame/contracts/Cargo.toml +++ b/frame/contracts/Cargo.toml @@ -13,7 +13,7 @@ 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 } -rstd = { package = "sp-std", path = "../../primitives/sr-std", 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 } system = { package = "frame-system", path = "../system", default-features = false } @@ -34,7 +34,7 @@ std = [ "primitives/std", "sp-runtime/std", "runtime-io/std", - "rstd/std", + "sp-std/std", "sandbox/std", "support/std", "system/std", diff --git a/frame/contracts/rpc/runtime-api/Cargo.toml b/frame/contracts/rpc/runtime-api/Cargo.toml index b0e84c7a28..ab127a7361 100644 --- a/frame/contracts/rpc/runtime-api/Cargo.toml +++ b/frame/contracts/rpc/runtime-api/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] sp-api = { path = "../../../../primitives/sr-api", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -rstd = { package = "sp-std", path = "../../../../primitives/sr-std", default-features = false } +sp-std = { path = "../../../../primitives/std", default-features = false } sp-runtime = { path = "../../../../primitives/runtime", default-features = false } [features] @@ -15,6 +15,6 @@ default = ["std"] std = [ "sp-api/std", "codec/std", - "rstd/std", + "sp-std/std", "sp-runtime/std", ] diff --git a/frame/contracts/rpc/runtime-api/src/lib.rs b/frame/contracts/rpc/runtime-api/src/lib.rs index a4ee568c98..73e937cf6c 100644 --- a/frame/contracts/rpc/runtime-api/src/lib.rs +++ b/frame/contracts/rpc/runtime-api/src/lib.rs @@ -22,7 +22,7 @@ #![cfg_attr(not(feature = "std"), no_std)] -use rstd::vec::Vec; +use sp_std::vec::Vec; use codec::{Encode, Decode, Codec}; use sp_runtime::RuntimeDebug; diff --git a/frame/contracts/src/account_db.rs b/frame/contracts/src/account_db.rs index 77732db871..962dadff2a 100644 --- a/frame/contracts/src/account_db.rs +++ b/frame/contracts/src/account_db.rs @@ -21,9 +21,9 @@ use super::{ TrieIdGenerator, }; use crate::exec::StorageKey; -use rstd::cell::RefCell; -use rstd::collections::btree_map::{BTreeMap, Entry}; -use rstd::prelude::*; +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_runtime::traits::{Bounded, Zero}; use support::traits::{Currency, Get, Imbalance, SignedImbalance, UpdateBalanceOutcome}; diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index 12f71251e2..9243d9f8c1 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -20,7 +20,7 @@ use crate::account_db::{AccountDb, DirectAccountDb, OverlayAccountDb}; use crate::gas::{Gas, GasMeter, Token, approx_gas_for_balance}; use crate::rent; -use rstd::prelude::*; +use sp_std::prelude::*; use sp_runtime::traits::{Bounded, CheckedAdd, CheckedSub, Zero}; use support::{ storage::unhashed, diff --git a/frame/contracts/src/gas.rs b/frame/contracts/src/gas.rs index b791a4681b..b9faaf298f 100644 --- a/frame/contracts/src/gas.rs +++ b/frame/contracts/src/gas.rs @@ -15,7 +15,7 @@ // along with Substrate. If not, see . use crate::{GasSpent, Module, Trait, BalanceOf, NegativeImbalanceOf}; -use rstd::convert::TryFrom; +use sp_std::convert::TryFrom; use sp_runtime::traits::{ CheckedMul, Zero, SaturatedConversion, SimpleArithmetic, UniqueSaturatedInto, }; diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index 166ee467b1..e288fba2cc 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -109,7 +109,7 @@ pub use crate::exec::{ExecResult, ExecReturnValue, ExecError, StatusCode}; #[cfg(feature = "std")] use serde::{Serialize, Deserialize}; use primitives::crypto::UncheckedFrom; -use rstd::{prelude::*, marker::PhantomData, fmt::Debug}; +use sp_std::{prelude::*, marker::PhantomData, fmt::Debug}; use codec::{Codec, Encode, Decode}; use runtime_io::hashing::blake2_256; use sp_runtime::{ @@ -233,7 +233,7 @@ impl RawTombstoneContractInfo where H: Member + MaybeSerializeDeserialize+ Debug + AsRef<[u8]> + AsMut<[u8]> + Copy + Default - + rstd::hash::Hash + Codec, + + sp_std::hash::Hash + Codec, Hasher: Hash, { fn new(storage_root: &[u8], code_hash: H) -> Self { @@ -680,7 +680,7 @@ impl Module { pub fn get_storage( address: T::AccountId, key: [u8; 32], - ) -> rstd::result::Result>, GetStorageError> { + ) -> sp_std::result::Result>, GetStorageError> { let contract_info = >::get(&address) .ok_or(GetStorageError::ContractDoesntExist)? .get_alive() @@ -1018,14 +1018,14 @@ impl Default for CheckBlockGasLimit { } } -impl rstd::fmt::Debug for CheckBlockGasLimit { +impl sp_std::fmt::Debug for CheckBlockGasLimit { #[cfg(feature = "std")] - fn fmt(&self, f: &mut rstd::fmt::Formatter) -> rstd::fmt::Result { + fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { write!(f, "CheckBlockGasLimit") } #[cfg(not(feature = "std"))] - fn fmt(&self, _: &mut rstd::fmt::Formatter) -> rstd::fmt::Result { + fn fmt(&self, _: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { Ok(()) } } @@ -1037,7 +1037,7 @@ impl SignedExtension for CheckBlockGasLimit { type DispatchInfo = DispatchInfo; type Pre = (); - fn additional_signed(&self) -> rstd::result::Result<(), TransactionValidityError> { Ok(()) } + fn additional_signed(&self) -> sp_std::result::Result<(), TransactionValidityError> { Ok(()) } fn validate( &self, diff --git a/frame/contracts/src/wasm/code_cache.rs b/frame/contracts/src/wasm/code_cache.rs index 2c5bd492e2..7264122397 100644 --- a/frame/contracts/src/wasm/code_cache.rs +++ b/frame/contracts/src/wasm/code_cache.rs @@ -29,7 +29,7 @@ use crate::gas::{Gas, GasMeter, Token}; use crate::wasm::{prepare, runtime::Env, PrefabWasmModule}; use crate::{CodeHash, CodeStorage, PristineCode, Schedule, Trait}; -use rstd::prelude::*; +use sp_std::prelude::*; use sp_runtime::traits::{Hash, Bounded}; use support::StorageMap; diff --git a/frame/contracts/src/wasm/mod.rs b/frame/contracts/src/wasm/mod.rs index b1010d7b14..273b7fb037 100644 --- a/frame/contracts/src/wasm/mod.rs +++ b/frame/contracts/src/wasm/mod.rs @@ -22,7 +22,7 @@ use crate::wasm::env_def::FunctionImplProvider; use crate::exec::{Ext, ExecResult}; use crate::gas::GasMeter; -use rstd::prelude::*; +use sp_std::prelude::*; use codec::{Encode, Decode}; use sandbox; diff --git a/frame/contracts/src/wasm/prepare.rs b/frame/contracts/src/wasm/prepare.rs index 6a443d63e8..f9a40489d9 100644 --- a/frame/contracts/src/wasm/prepare.rs +++ b/frame/contracts/src/wasm/prepare.rs @@ -25,7 +25,7 @@ use crate::Schedule; use parity_wasm::elements::{self, Internal, External, MemoryType, Type, ValueType}; use pwasm_utils; use pwasm_utils::rules; -use rstd::prelude::*; +use sp_std::prelude::*; use sp_runtime::traits::{SaturatedConversion}; struct ContractModule<'a> { diff --git a/frame/contracts/src/wasm/runtime.rs b/frame/contracts/src/wasm/runtime.rs index 2e69d17bc2..0204d4eba0 100644 --- a/frame/contracts/src/wasm/runtime.rs +++ b/frame/contracts/src/wasm/runtime.rs @@ -23,9 +23,9 @@ use crate::exec::{ use crate::gas::{Gas, GasMeter, Token, GasMeterResult, approx_gas_for_balance}; use sandbox; use system; -use rstd::prelude::*; -use rstd::convert::TryInto; -use rstd::mem; +use sp_std::prelude::*; +use sp_std::convert::TryInto; +use sp_std::mem; use codec::{Decode, Encode}; use sp_runtime::traits::{Bounded, SaturatedConversion}; diff --git a/frame/democracy/Cargo.toml b/frame/democracy/Cargo.toml index f3e23672af..62e4f60f8e 100644 --- a/frame/democracy/Cargo.toml +++ b/frame/democracy/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" 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"] } -rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +sp-std = { path = "../../primitives/std", default-features = false } runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } @@ -24,7 +24,7 @@ std = [ "serde", "safe-mix/std", "codec/std", - "rstd/std", + "sp-std/std", "runtime-io/std", "support/std", "sp-runtime/std", diff --git a/frame/democracy/src/lib.rs b/frame/democracy/src/lib.rs index 33fe6453fc..2bbef15d60 100644 --- a/frame/democracy/src/lib.rs +++ b/frame/democracy/src/lib.rs @@ -18,8 +18,8 @@ #![recursion_limit="128"] #![cfg_attr(not(feature = "std"), no_std)] -use rstd::prelude::*; -use rstd::{result, convert::TryFrom}; +use sp_std::prelude::*; +use sp_std::{result, convert::TryFrom}; use sp_runtime::{ RuntimeDebug, traits::{Zero, Bounded, CheckedMul, CheckedDiv, EnsureOrigin, Hash, Dispatchable, Saturating}, diff --git a/frame/democracy/src/vote_threshold.rs b/frame/democracy/src/vote_threshold.rs index 4262f7d7cf..d5e215fe32 100644 --- a/frame/democracy/src/vote_threshold.rs +++ b/frame/democracy/src/vote_threshold.rs @@ -20,7 +20,7 @@ use serde::{Serialize, Deserialize}; use codec::{Encode, Decode}; use sp_runtime::traits::{Zero, IntegerSquareRoot}; -use rstd::ops::{Add, Mul, Div, Rem}; +use sp_std::ops::{Add, Mul, Div, Rem}; /// A means of determining if a vote is past pass threshold. #[derive(Clone, Copy, PartialEq, Eq, Encode, Decode, sp_runtime::RuntimeDebug)] diff --git a/frame/elections-phragmen/Cargo.toml b/frame/elections-phragmen/Cargo.toml index b1fa40741a..979ed48ca2 100644 --- a/frame/elections-phragmen/Cargo.toml +++ b/frame/elections-phragmen/Cargo.toml @@ -10,7 +10,7 @@ sp-runtime = { path = "../../primitives/runtime", default-features = false } phragmen = { package = "sp-phragmen", path = "../../primitives/phragmen", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } system = { package = "frame-system", path = "../system", default-features = false } -rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +sp-std = { path = "../../primitives/std", default-features = false } [dev-dependencies] runtime_io = { package = "sp-io", path = "../../primitives/sr-io" } @@ -28,5 +28,5 @@ std = [ "sp-runtime/std", "phragmen/std", "system/std", - "rstd/std", + "sp-std/std", ] diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index df7a223610..e87a0e7275 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -82,7 +82,7 @@ #![cfg_attr(not(feature = "std"), no_std)] -use rstd::prelude::*; +use sp_std::prelude::*; use sp_runtime::{print, traits::{Zero, StaticLookup, Bounded, Convert}}; use support::{ decl_storage, decl_event, ensure, decl_module, dispatch, weights::SimpleDispatchInfo, diff --git a/frame/elections/Cargo.toml b/frame/elections/Cargo.toml index c27b447aeb..4077d98879 100644 --- a/frame/elections/Cargo.toml +++ b/frame/elections/Cargo.toml @@ -9,7 +9,7 @@ serde = { version = "1.0.101", optional = true } 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 } -rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +sp-std = { path = "../../primitives/std", default-features = false } runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } @@ -25,7 +25,7 @@ std = [ "safe-mix/std", "codec/std", "primitives/std", - "rstd/std", + "sp-std/std", "serde", "runtime-io/std", "support/std", diff --git a/frame/elections/src/lib.rs b/frame/elections/src/lib.rs index 1a289eb23f..530ffad963 100644 --- a/frame/elections/src/lib.rs +++ b/frame/elections/src/lib.rs @@ -23,7 +23,7 @@ #![cfg_attr(not(feature = "std"), no_std)] #![recursion_limit="128"] -use rstd::prelude::*; +use sp_std::prelude::*; use sp_runtime::{ RuntimeDebug, print, diff --git a/frame/evm/Cargo.toml b/frame/evm/Cargo.toml index 245d715665..b933c45382 100644 --- a/frame/evm/Cargo.toml +++ b/frame/evm/Cargo.toml @@ -13,7 +13,7 @@ timestamp = { package = "pallet-timestamp", path = "../timestamp", default-featu balances = { package = "pallet-balances", path = "../balances", default-features = false } primitives = { package = "sp-core", path = "../../primitives/core", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } -rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +sp-std = { path = "../../primitives/std", default-features = false } runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } primitive-types = { version = "0.6", default-features = false, features = ["rlp"] } rlp = { version = "0.4", default-features = false } @@ -31,7 +31,7 @@ std = [ "system/std", "balances/std", "runtime-io/std", - "rstd/std", + "sp-std/std", "sha3/std", "rlp/std", "primitive-types/std", diff --git a/frame/evm/src/backend.rs b/frame/evm/src/backend.rs index 18d8a01158..ab0ed43cc9 100644 --- a/frame/evm/src/backend.rs +++ b/frame/evm/src/backend.rs @@ -1,5 +1,5 @@ -use rstd::marker::PhantomData; -use rstd::vec::Vec; +use sp_std::marker::PhantomData; +use sp_std::vec::Vec; #[cfg(feature = "std")] use serde::{Serialize, Deserialize}; use codec::{Encode, Decode}; diff --git a/frame/evm/src/lib.rs b/frame/evm/src/lib.rs index c02739885e..8ad7fbc139 100644 --- a/frame/evm/src/lib.rs +++ b/frame/evm/src/lib.rs @@ -23,7 +23,7 @@ mod backend; pub use crate::backend::{Account, Log, Vicinity, Backend}; -use rstd::{vec::Vec, marker::PhantomData}; +use sp_std::{vec::Vec, marker::PhantomData}; use support::{dispatch::Result, decl_module, decl_storage, decl_event}; use support::weights::{Weight, WeighData, ClassifyDispatch, DispatchClass, PaysFee}; use support::traits::{Currency, WithdrawReason, ExistenceRequirement}; diff --git a/frame/example/Cargo.toml b/frame/example/Cargo.toml index ccddd2ce1a..9a6be32519 100644 --- a/frame/example/Cargo.toml +++ b/frame/example/Cargo.toml @@ -11,7 +11,7 @@ support = { package = "frame-support", path = "../support", default-features = f system = { package = "frame-system", path = "../system", default-features = false } balances = { package = "pallet-balances", path = "../balances", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } -rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +sp-std = { path = "../../primitives/std", default-features = false } runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } [dev-dependencies] @@ -27,5 +27,5 @@ std = [ "system/std", "balances/std", "runtime-io/std", - "rstd/std" + "sp-std/std" ] diff --git a/frame/example/src/lib.rs b/frame/example/src/lib.rs index 3e201f7a9b..f591b3c9d7 100644 --- a/frame/example/src/lib.rs +++ b/frame/example/src/lib.rs @@ -253,7 +253,7 @@ // Ensure we're `no_std` when compiling for Wasm. #![cfg_attr(not(feature = "std"), no_std)] -use rstd::marker::PhantomData; +use sp_std::marker::PhantomData; use support::{ dispatch::Result, decl_module, decl_storage, decl_event, weights::{SimpleDispatchInfo, DispatchInfo, DispatchClass, ClassifyDispatch, WeighData, Weight, PaysFee}, @@ -596,8 +596,8 @@ impl Module { #[derive(Encode, Decode, Clone, Eq, PartialEq)] pub struct WatchDummy(PhantomData); -impl rstd::fmt::Debug for WatchDummy { - fn fmt(&self, f: &mut rstd::fmt::Formatter) -> rstd::fmt::Result { +impl sp_std::fmt::Debug for WatchDummy { + fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { write!(f, "WatchDummy") } } @@ -613,7 +613,7 @@ impl SignedExtension for WatchDummy { type DispatchInfo = DispatchInfo; type Pre = (); - fn additional_signed(&self) -> rstd::result::Result<(), TransactionValidityError> { Ok(()) } + fn additional_signed(&self) -> sp_std::result::Result<(), TransactionValidityError> { Ok(()) } fn validate( &self, diff --git a/frame/executive/Cargo.toml b/frame/executive/Cargo.toml index e18d0fdb0b..0e2e748066 100644 --- a/frame/executive/Cargo.toml +++ b/frame/executive/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] serde = { version = "1.0.101", optional = true } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +sp-std = { path = "../../primitives/std", default-features = false } runtime-io ={ package = "sp-io", path = "../../primitives/sr-io", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } @@ -23,7 +23,7 @@ transaction-payment = { package = "pallet-transaction-payment", path = "../trans [features] default = ["std"] std = [ - "rstd/std", + "sp-std/std", "support/std", "serde", "codec/std", diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index 9f42ac1a05..7c94c9c012 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -76,7 +76,7 @@ #![cfg_attr(not(feature = "std"), no_std)] -use rstd::{prelude::*, marker::PhantomData}; +use sp_std::{prelude::*, marker::PhantomData}; use support::weights::{GetDispatchInfo, WeighBlock, DispatchInfo}; use sp_runtime::{ generic::Digest, ApplyExtrinsicResult, diff --git a/frame/finality-tracker/Cargo.toml b/frame/finality-tracker/Cargo.toml index a9ead70d05..29e304e692 100644 --- a/frame/finality-tracker/Cargo.toml +++ b/frame/finality-tracker/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" serde = { version = "1.0.101", default-features = false, features = ["derive"] } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } inherents = { package = "sp-inherents", path = "../../primitives/inherents", default-features = false } -rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +sp-std = { path = "../../primitives/std", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } sp-finality-tracker = { path = "../../primitives/finality-tracker", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } @@ -24,7 +24,7 @@ default = ["std"] std = [ "serde/std", "codec/std", - "rstd/std", + "sp-std/std", "support/std", "sp-runtime/std", "frame-system/std", diff --git a/frame/finality-tracker/src/lib.rs b/frame/finality-tracker/src/lib.rs index 3cb842de24..d15953d5ae 100644 --- a/frame/finality-tracker/src/lib.rs +++ b/frame/finality-tracker/src/lib.rs @@ -20,7 +20,7 @@ use inherents::{InherentIdentifier, ProvideInherent, InherentData, MakeFatalError}; use sp_runtime::traits::{One, Zero, SaturatedConversion}; -use rstd::{prelude::*, result, cmp, vec}; +use sp_std::{prelude::*, result, cmp, vec}; use support::{decl_module, decl_storage}; use support::traits::Get; use frame_system::{ensure_none, Trait as SystemTrait}; diff --git a/frame/generic-asset/Cargo.toml b/frame/generic-asset/Cargo.toml index 2889e66012..1cdbc47394 100644 --- a/frame/generic-asset/Cargo.toml +++ b/frame/generic-asset/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] serde = { version = "1.0.101", optional = true } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +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 } @@ -21,7 +21,7 @@ default = ["std"] std =[ "serde/std", "codec/std", - "rstd/std", + "sp-std/std", "sp-runtime/std", "support/std", "system/std", diff --git a/frame/generic-asset/src/lib.rs b/frame/generic-asset/src/lib.rs index 57942ae186..ba7cdae7df 100644 --- a/frame/generic-asset/src/lib.rs +++ b/frame/generic-asset/src/lib.rs @@ -159,8 +159,8 @@ use sp_runtime::traits::{ Zero, Bounded, }; -use rstd::prelude::*; -use rstd::{cmp, result, fmt::Debug}; +use sp_std::prelude::*; +use sp_std::{cmp, result, fmt::Debug}; use support::dispatch::Result; use support::{ decl_event, decl_module, decl_storage, ensure, @@ -625,7 +625,7 @@ impl Module { /// NOTE: This is different behavior than `reserve`. pub fn unreserve(asset_id: &T::AssetId, who: &T::AccountId, amount: T::Balance) -> T::Balance { let b = Self::reserved_balance(asset_id, who); - let actual = rstd::cmp::min(b, amount); + let actual = sp_std::cmp::min(b, amount); let original_free_balance = Self::free_balance(asset_id, who); let new_free_balance = original_free_balance + actual; Self::set_free_balance(asset_id, who, new_free_balance); @@ -642,7 +642,7 @@ impl Module { /// the caller will do this. fn slash(asset_id: &T::AssetId, who: &T::AccountId, amount: T::Balance) -> Option { let free_balance = Self::free_balance(asset_id, who); - let free_slash = rstd::cmp::min(free_balance, amount); + let free_slash = sp_std::cmp::min(free_balance, amount); let new_free_balance = free_balance - free_slash; Self::set_free_balance(asset_id, who, new_free_balance); if free_slash < amount { @@ -660,7 +660,7 @@ impl Module { /// the caller will do this. fn slash_reserved(asset_id: &T::AssetId, who: &T::AccountId, amount: T::Balance) -> Option { let original_reserve_balance = Self::reserved_balance(asset_id, who); - let slash = rstd::cmp::min(original_reserve_balance, amount); + let slash = sp_std::cmp::min(original_reserve_balance, amount); let new_reserve_balance = original_reserve_balance - slash; Self::set_reserved_balance(asset_id, who, new_reserve_balance); if amount == slash { @@ -684,7 +684,7 @@ impl Module { amount: T::Balance, ) -> T::Balance { let b = Self::reserved_balance(asset_id, who); - let slash = rstd::cmp::min(b, amount); + let slash = sp_std::cmp::min(b, amount); let original_free_balance = Self::free_balance(asset_id, beneficiary); let new_free_balance = original_free_balance + slash; @@ -866,14 +866,14 @@ mod imbalances { use super::{ result, AssetIdProvider, Imbalance, Saturating, StorageMap, Subtrait, Zero, TryDrop }; - use rstd::mem; + use sp_std::mem; /// Opaque, move-only struct with private fields that serves as a token denoting that /// funds have been created without any equal and opposite accounting. #[must_use] pub struct PositiveImbalance>( T::Balance, - rstd::marker::PhantomData, + sp_std::marker::PhantomData, ); impl PositiveImbalance where @@ -890,7 +890,7 @@ mod imbalances { #[must_use] pub struct NegativeImbalance>( T::Balance, - rstd::marker::PhantomData, + sp_std::marker::PhantomData, ); impl NegativeImbalance where @@ -1091,7 +1091,7 @@ impl Trait for ElevatedTrait { } #[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug)] -pub struct AssetCurrency(rstd::marker::PhantomData, rstd::marker::PhantomData); +pub struct AssetCurrency(sp_std::marker::PhantomData, sp_std::marker::PhantomData); impl Currency for AssetCurrency where @@ -1264,7 +1264,7 @@ where } } -pub struct StakingAssetIdProvider(rstd::marker::PhantomData); +pub struct StakingAssetIdProvider(sp_std::marker::PhantomData); impl AssetIdProvider for StakingAssetIdProvider { type AssetId = T::AssetId; @@ -1273,7 +1273,7 @@ impl AssetIdProvider for StakingAssetIdProvider { } } -pub struct SpendingAssetIdProvider(rstd::marker::PhantomData); +pub struct SpendingAssetIdProvider(sp_std::marker::PhantomData); impl AssetIdProvider for SpendingAssetIdProvider { type AssetId = T::AssetId; diff --git a/frame/grandpa/Cargo.toml b/frame/grandpa/Cargo.toml index 0af02724f8..ebb1143e1f 100644 --- a/frame/grandpa/Cargo.toml +++ b/frame/grandpa/Cargo.toml @@ -9,7 +9,7 @@ serde = { version = "1.0.101", optional = true, features = ["derive"] } 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-finality-grandpa = { path = "../../primitives/finality-grandpa", default-features = false } -rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +sp-std = { path = "../../primitives/std", 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 } @@ -27,7 +27,7 @@ std = [ "codec/std", "primitives/std", "sp-finality-grandpa/std", - "rstd/std", + "sp-std/std", "support/std", "sp-runtime/std", "sp-staking/std", diff --git a/frame/grandpa/src/lib.rs b/frame/grandpa/src/lib.rs index 12fb28546c..f80974a31a 100644 --- a/frame/grandpa/src/lib.rs +++ b/frame/grandpa/src/lib.rs @@ -30,7 +30,7 @@ // re-export since this is necessary for `impl_apis` in runtime. pub use sp_finality_grandpa as fg_primitives; -use rstd::prelude::*; +use sp_std::prelude::*; use codec::{self as codec, Encode, Decode, Error}; use support::{decl_event, decl_storage, decl_module, dispatch::Result, storage}; use sp_runtime::{ diff --git a/frame/identity/Cargo.toml b/frame/identity/Cargo.toml index 6b81433f0b..8fcc01b0c8 100644 --- a/frame/identity/Cargo.toml +++ b/frame/identity/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"] } enumflags2 = { version = "0.6.2" } -rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +sp-std = { path = "../../primitives/std", default-features = false } runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } @@ -23,7 +23,7 @@ default = ["std"] std = [ "serde", "codec/std", - "rstd/std", + "sp-std/std", "runtime-io/std", "sp-runtime/std", "support/std", diff --git a/frame/identity/src/lib.rs b/frame/identity/src/lib.rs index e51df5eed2..8422382057 100644 --- a/frame/identity/src/lib.rs +++ b/frame/identity/src/lib.rs @@ -65,8 +65,8 @@ #![cfg_attr(not(feature = "std"), no_std)] -use rstd::prelude::*; -use rstd::{fmt::Debug, ops::Add, iter::once}; +use sp_std::prelude::*; +use sp_std::{fmt::Debug, ops::Add, iter::once}; use enumflags2::BitFlags; use codec::{Encode, Decode}; use sp_runtime::{traits::{StaticLookup, EnsureOrigin, Zero}, RuntimeDebug}; @@ -134,7 +134,7 @@ pub enum Data { } impl Decode for Data { - fn decode(input: &mut I) -> rstd::result::Result { + fn decode(input: &mut I) -> sp_std::result::Result { let b = input.read_byte()?; Ok(match b { 0 => Data::None, @@ -256,7 +256,7 @@ impl Encode for IdentityFields { } } impl Decode for IdentityFields { - fn decode(input: &mut I) -> rstd::result::Result { + fn decode(input: &mut I) -> sp_std::result::Result { let field = u64::decode(input)?; Ok(Self(>::from_bits(field as u64).map_err(|_| "invalid value")?)) } diff --git a/frame/im-online/Cargo.toml b/frame/im-online/Cargo.toml index 53aa39ca51..e9b9e049a5 100644 --- a/frame/im-online/Cargo.toml +++ b/frame/im-online/Cargo.toml @@ -9,7 +9,7 @@ app-crypto = { package = "sc-application-crypto", path = "../../primitives/appli authorship = { package = "pallet-authorship", path = "../authorship", 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 } -rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +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 } @@ -25,7 +25,7 @@ std = [ "authorship/std", "codec/std", "primitives/std", - "rstd/std", + "sp-std/std", "serde", "session/std", "runtime-io/std", diff --git a/frame/im-online/src/lib.rs b/frame/im-online/src/lib.rs index 7892054b7f..24556b717e 100644 --- a/frame/im-online/src/lib.rs +++ b/frame/im-online/src/lib.rs @@ -73,8 +73,8 @@ mod tests; use app_crypto::RuntimeAppPublic; use codec::{Encode, Decode}; use primitives::offchain::{OpaqueNetworkState, StorageKind}; -use rstd::prelude::*; -use rstd::convert::TryInto; +use sp_std::prelude::*; +use sp_std::convert::TryInto; use session::historical::IdentificationTuple; use sp_runtime::{ RuntimeDebug, diff --git a/frame/indices/Cargo.toml b/frame/indices/Cargo.toml index 7571dc1e98..05e5bfd451 100644 --- a/frame/indices/Cargo.toml +++ b/frame/indices/Cargo.toml @@ -9,7 +9,7 @@ serde = { version = "1.0.101", optional = true } 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 } -rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +sp-std = { path = "../../primitives/std", default-features = false } runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } primitives = { package = "sp-core", path = "../../primitives/core", default-features = false } @@ -27,7 +27,7 @@ std = [ "sp-keyring", "codec/std", "primitives/std", - "rstd/std", + "sp-std/std", "runtime-io/std", "support/std", "sp-runtime/std", diff --git a/frame/indices/src/address.rs b/frame/indices/src/address.rs index cfc9bcabaa..2f0d343345 100644 --- a/frame/indices/src/address.rs +++ b/frame/indices/src/address.rs @@ -18,7 +18,7 @@ #[cfg(feature = "std")] use std::fmt; -use rstd::convert::TryInto; +use sp_std::convert::TryInto; use crate::Member; use codec::{Encode, Decode, Input, Output, Error}; diff --git a/frame/indices/src/lib.rs b/frame/indices/src/lib.rs index d53a26f77c..f74991e4ac 100644 --- a/frame/indices/src/lib.rs +++ b/frame/indices/src/lib.rs @@ -19,7 +19,7 @@ #![cfg_attr(not(feature = "std"), no_std)] -use rstd::{prelude::*, marker::PhantomData, convert::TryInto}; +use sp_std::{prelude::*, marker::PhantomData, convert::TryInto}; use codec::{Encode, Codec}; use support::{Parameter, decl_module, decl_event, decl_storage}; use sp_runtime::traits::{One, SimpleArithmetic, StaticLookup, Member, LookupError}; diff --git a/frame/membership/Cargo.toml b/frame/membership/Cargo.toml index d09ab23051..1973dfba19 100644 --- a/frame/membership/Cargo.toml +++ b/frame/membership/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] serde = { version = "1.0.101", optional = true } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } -rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +sp-std = { path = "../../primitives/std", default-features = false } runtime-io = { package = "sp-io", path = "../../primitives/sr-io", 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-runtime/std", - "rstd/std", + "sp-std/std", "runtime-io/std", "support/std", "system/std", diff --git a/frame/membership/src/lib.rs b/frame/membership/src/lib.rs index 10be4e06f7..a7bbceaf27 100644 --- a/frame/membership/src/lib.rs +++ b/frame/membership/src/lib.rs @@ -22,7 +22,7 @@ // Ensure we're `no_std` when compiling for Wasm. #![cfg_attr(not(feature = "std"), no_std)] -use rstd::prelude::*; +use sp_std::prelude::*; use support::{ decl_module, decl_storage, decl_event, traits::{ChangeMembers, InitializeMembers}, @@ -63,7 +63,7 @@ decl_storage! { } add_extra_genesis { config(members): Vec; - config(phantom): rstd::marker::PhantomData; + config(phantom): sp_std::marker::PhantomData; build(|config: &Self| { let mut members = config.members.clone(); members.sort(); @@ -89,7 +89,7 @@ decl_event!( /// One of the members' keys changed. KeyChanged, /// Phantom member, never used. - Dummy(rstd::marker::PhantomData<(AccountId, Event)>), + Dummy(sp_std::marker::PhantomData<(AccountId, Event)>), } ); diff --git a/frame/metadata/Cargo.toml b/frame/metadata/Cargo.toml index 5ed5293633..0feeb14d59 100644 --- a/frame/metadata/Cargo.toml +++ b/frame/metadata/Cargo.toml @@ -7,14 +7,14 @@ edition = "2018" [dependencies] codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } serde = { version = "1.0.101", optional = true, features = ["derive"] } -rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +sp-std = { path = "../../primitives/std", default-features = false } primitives = { package = "sp-core", path = "../../primitives/core", default-features = false } [features] default = ["std"] std = [ "codec/std", - "rstd/std", + "sp-std/std", "primitives/std", "serde", ] diff --git a/frame/metadata/src/lib.rs b/frame/metadata/src/lib.rs index 113273be02..e37733fc9d 100644 --- a/frame/metadata/src/lib.rs +++ b/frame/metadata/src/lib.rs @@ -27,7 +27,7 @@ use serde::Serialize; #[cfg(feature = "std")] use codec::{Decode, Input, Error}; use codec::{Encode, Output}; -use rstd::vec::Vec; +use sp_std::vec::Vec; use primitives::RuntimeDebug; #[cfg(feature = "std")] @@ -85,12 +85,12 @@ impl Eq for DecodeDifferent where B: Encode + Eq + PartialEq + 'static, O: Encode + Eq + PartialEq + 'static {} -impl rstd::fmt::Debug for DecodeDifferent +impl sp_std::fmt::Debug for DecodeDifferent where - B: rstd::fmt::Debug + Eq + 'static, - O: rstd::fmt::Debug + Eq + 'static, + B: sp_std::fmt::Debug + Eq + 'static, + O: sp_std::fmt::Debug + Eq + 'static, { - fn fmt(&self, f: &mut rstd::fmt::Formatter) -> rstd::fmt::Result { + fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { match self { DecodeDifferent::Encode(b) => b.fmt(f), DecodeDifferent::Decoded(o) => o.fmt(f), @@ -151,8 +151,8 @@ impl PartialEq for FnEncode { } } -impl rstd::fmt::Debug for FnEncode { - fn fmt(&self, f: &mut rstd::fmt::Formatter) -> rstd::fmt::Result { +impl sp_std::fmt::Debug for FnEncode { + fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { self.0().fmt(f) } } @@ -261,8 +261,8 @@ impl serde::Serialize for DefaultByteGetter { } } -impl rstd::fmt::Debug for DefaultByteGetter { - fn fmt(&self, f: &mut rstd::fmt::Formatter) -> rstd::fmt::Result { +impl sp_std::fmt::Debug for DefaultByteGetter { + fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { self.0.default_byte().fmt(f) } } diff --git a/frame/nicks/Cargo.toml b/frame/nicks/Cargo.toml index 70f6f9ba2f..d7d94a564d 100644 --- a/frame/nicks/Cargo.toml +++ b/frame/nicks/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] serde = { version = "1.0.101", optional = true } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +sp-std = { path = "../../primitives/std", default-features = false } runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } @@ -22,7 +22,7 @@ default = ["std"] std = [ "serde", "codec/std", - "rstd/std", + "sp-std/std", "runtime-io/std", "sp-runtime/std", "support/std", diff --git a/frame/nicks/src/lib.rs b/frame/nicks/src/lib.rs index cb35b1dba0..60b1d3e5cb 100644 --- a/frame/nicks/src/lib.rs +++ b/frame/nicks/src/lib.rs @@ -38,7 +38,7 @@ #![cfg_attr(not(feature = "std"), no_std)] -use rstd::prelude::*; +use sp_std::prelude::*; use sp_runtime::{ traits::{StaticLookup, EnsureOrigin, Zero} }; diff --git a/frame/offences/Cargo.toml b/frame/offences/Cargo.toml index 27d6344222..3f3a6d8b4c 100644 --- a/frame/offences/Cargo.toml +++ b/frame/offences/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] balances = { package = "pallet-balances", path = "../balances", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +sp-std = { path = "../../primitives/std", default-features = false } serde = { version = "1.0.101", optional = true } sp-runtime = { path = "../../primitives/runtime", default-features = false } sp-staking = { path = "../../primitives/sr-staking-primitives", default-features = false } @@ -23,7 +23,7 @@ default = ["std"] std = [ "balances/std", "codec/std", - "rstd/std", + "sp-std/std", "serde", "sp-runtime/std", "sp-staking/std", diff --git a/frame/offences/src/lib.rs b/frame/offences/src/lib.rs index eb1f2abc3c..6d83de3652 100644 --- a/frame/offences/src/lib.rs +++ b/frame/offences/src/lib.rs @@ -24,7 +24,7 @@ mod mock; mod tests; -use rstd::vec::Vec; +use sp_std::vec::Vec; use support::{ decl_module, decl_event, decl_storage, Parameter, }; diff --git a/frame/randomness-collective-flip/Cargo.toml b/frame/randomness-collective-flip/Cargo.toml index bd8aef96f2..1ef171ab54 100644 --- a/frame/randomness-collective-flip/Cargo.toml +++ b/frame/randomness-collective-flip/Cargo.toml @@ -10,7 +10,7 @@ codec = { package = "parity-scale-codec", version = "1.0.0", default-features = 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 } -rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +sp-std = { path = "../../primitives/std", default-features = false } [dev-dependencies] primitives = { package = "sp-core", path = "../../primitives/core" } @@ -24,5 +24,5 @@ std = [ "codec/std", "support/std", "sp-runtime/std", - "rstd/std", + "sp-std/std", ] diff --git a/frame/randomness-collective-flip/src/lib.rs b/frame/randomness-collective-flip/src/lib.rs index 1a719ac915..a250f50092 100644 --- a/frame/randomness-collective-flip/src/lib.rs +++ b/frame/randomness-collective-flip/src/lib.rs @@ -52,7 +52,7 @@ #![cfg_attr(not(feature = "std"), no_std)] -use rstd::{prelude::*, convert::TryInto}; +use sp_std::{prelude::*, convert::TryInto}; use sp_runtime::traits::Hash; use support::{decl_module, decl_storage, traits::Randomness}; use safe_mix::TripletMix; diff --git a/frame/scored-pool/Cargo.toml b/frame/scored-pool/Cargo.toml index d61806c27c..a21998fcb7 100644 --- a/frame/scored-pool/Cargo.toml +++ b/frame/scored-pool/Cargo.toml @@ -9,7 +9,7 @@ codec = { package = "parity-scale-codec", version = "1.0.0", default-features = serde = { version = "1.0.101", optional = true } runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } -rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +sp-std = { path = "../../primitives/std", 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", "runtime-io/std", "sp-runtime/std", - "rstd/std", + "sp-std/std", "support/std", "system/std", ] diff --git a/frame/scored-pool/src/lib.rs b/frame/scored-pool/src/lib.rs index 8a2bfb9051..9645560d53 100644 --- a/frame/scored-pool/src/lib.rs +++ b/frame/scored-pool/src/lib.rs @@ -89,7 +89,7 @@ mod mock; mod tests; use codec::FullCodec; -use rstd::{ +use sp_std::{ fmt::Debug, prelude::*, }; @@ -175,7 +175,7 @@ decl_storage! { } add_extra_genesis { config(members): Vec; - config(phantom): rstd::marker::PhantomData; + config(phantom): sp_std::marker::PhantomData; build(|config| { let mut pool = config.pool.clone(); @@ -218,7 +218,7 @@ decl_event!( /// See the transaction for who. CandidateScored, /// Phantom member, never used. - Dummy(rstd::marker::PhantomData<(AccountId, I)>), + Dummy(sp_std::marker::PhantomData<(AccountId, I)>), } ); @@ -453,4 +453,3 @@ impl, I: Instance> Module { Ok(()) } } - diff --git a/frame/session/Cargo.toml b/frame/session/Cargo.toml index f5ccfa34f9..e55c6b7bb2 100644 --- a/frame/session/Cargo.toml +++ b/frame/session/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" serde = { version = "1.0.101", optional = true } safe-mix = { version = "1.0.0", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +sp-std = { path = "../../primitives/std", 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 } @@ -30,7 +30,7 @@ std = [ "serde", "safe-mix/std", "codec/std", - "rstd/std", + "sp-std/std", "support/std", "sp-runtime/std", "sp-staking/std", diff --git a/frame/session/src/historical.rs b/frame/session/src/historical.rs index c693313327..32e7203150 100644 --- a/frame/session/src/historical.rs +++ b/frame/session/src/historical.rs @@ -25,7 +25,7 @@ //! These roots and proofs of inclusion can be generated at any time during the current session. //! Afterwards, the proofs can be fed to a consensus module when reporting misbehavior. -use rstd::prelude::*; +use sp_std::prelude::*; use codec::{Encode, Decode}; use sp_runtime::KeyTypeId; use sp_runtime::traits::{Convert, OpaqueKeys, Hash as HashT}; @@ -79,7 +79,7 @@ impl Module { None => return, // nothing to prune. }; - let up_to = rstd::cmp::min(up_to, end); + let up_to = sp_std::cmp::min(up_to, end); if up_to < start { return // out of bounds. harmless. @@ -108,7 +108,7 @@ pub trait OnSessionEnding: crate::OnSessionEndi /// An `OnSessionEnding` implementation that wraps an inner `I` and also /// sets the historical trie root of the ending session. -pub struct NoteHistoricalRoot(rstd::marker::PhantomData<(T, I)>); +pub struct NoteHistoricalRoot(sp_std::marker::PhantomData<(T, I)>); impl crate::OnSessionEnding for NoteHistoricalRoot where I: OnSessionEnding diff --git a/frame/session/src/lib.rs b/frame/session/src/lib.rs index 69273b9a43..c71d2dbfba 100644 --- a/frame/session/src/lib.rs +++ b/frame/session/src/lib.rs @@ -119,7 +119,7 @@ #![cfg_attr(not(feature = "std"), no_std)] -use rstd::{prelude::*, marker::PhantomData, ops::{Sub, Rem}}; +use sp_std::{prelude::*, marker::PhantomData, ops::{Sub, Rem}}; use codec::Decode; use sp_runtime::{KeyTypeId, Perbill, RuntimeAppPublic, BoundToRuntimeAppPublic}; use support::weights::SimpleDispatchInfo; @@ -625,7 +625,7 @@ impl Module { /// Returns `Ok(true)` if more than `DisabledValidatorsThreshold` validators in current /// session is already disabled. /// If used with the staking module it allows to force a new era in such case. - pub fn disable(c: &T::ValidatorId) -> rstd::result::Result { + pub fn disable(c: &T::ValidatorId) -> sp_std::result::Result { Self::validators().iter().position(|i| i == c).map(Self::disable_index).ok_or(()) } @@ -702,7 +702,7 @@ impl OnFreeBalanceZero for Module { /// Wraps the author-scraping logic for consensus engines that can recover /// the canonical index of an author. This then transforms it into the /// registering account-ID of that session key index. -pub struct FindAccountFromAuthorIndex(rstd::marker::PhantomData<(T, Inner)>); +pub struct FindAccountFromAuthorIndex(sp_std::marker::PhantomData<(T, Inner)>); impl> FindAuthor for FindAccountFromAuthorIndex diff --git a/frame/staking/Cargo.toml b/frame/staking/Cargo.toml index 0b042d5ca0..501527847e 100644 --- a/frame/staking/Cargo.toml +++ b/frame/staking/Cargo.toml @@ -9,7 +9,7 @@ serde = { version = "1.0.101", optional = true } 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 } -rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +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-runtime = { path = "../../primitives/runtime", default-features = false } @@ -35,7 +35,7 @@ std = [ "safe-mix/std", "sp-keyring", "codec/std", - "rstd/std", + "sp-std/std", "phragmen/std", "runtime-io/std", "support/std", diff --git a/frame/staking/src/lib.rs b/frame/staking/src/lib.rs index 76619a142d..952c0cbd62 100644 --- a/frame/staking/src/lib.rs +++ b/frame/staking/src/lib.rs @@ -255,7 +255,7 @@ mod slashing; pub mod inflation; -use rstd::{prelude::*, result}; +use sp_std::{prelude::*, result}; use codec::{HasCompact, Encode, Decode}; use support::{ decl_module, decl_event, decl_storage, ensure, @@ -445,7 +445,7 @@ impl StakingLedger where // don't leave a dust balance in the staking system. if *target <= minimum_balance { slash_from_target += *target; - *value += rstd::mem::replace(target, Zero::zero()); + *value += sp_std::mem::replace(target, Zero::zero()); } *total_remaining = total_remaining.saturating_sub(slash_from_target); @@ -1304,7 +1304,7 @@ impl Module { let points = CurrentEraPointsEarned::take(); let now = T::Time::now(); let previous_era_start = >::mutate(|v| { - rstd::mem::replace(v, now) + sp_std::mem::replace(v, now) }); let era_duration = now - previous_era_start; if !era_duration.is_zero() { @@ -1641,7 +1641,7 @@ impl authorship::EventHandler(rstd::marker::PhantomData); +pub struct StashOf(sp_std::marker::PhantomData); impl Convert> for StashOf { fn convert(controller: T::AccountId) -> Option { @@ -1651,7 +1651,7 @@ impl Convert> for StashOf { /// A typed conversion from stash account ID to the current exposure of nominators /// on that account. -pub struct ExposureOf(rstd::marker::PhantomData); +pub struct ExposureOf(sp_std::marker::PhantomData); impl Convert>>> for ExposureOf @@ -1751,7 +1751,7 @@ impl OnOffenceHandler { - _inner: rstd::marker::PhantomData<(T, R)>, + _inner: sp_std::marker::PhantomData<(T, R)>, } impl ReportOffence diff --git a/frame/staking/src/migration.rs b/frame/staking/src/migration.rs index e89c6af1b9..4c4306253e 100644 --- a/frame/staking/src/migration.rs +++ b/frame/staking/src/migration.rs @@ -26,7 +26,7 @@ pub const CURRENT_VERSION: VersionNumber = 1; mod inner { use crate::{Store, Module, Trait}; use support::{StorageLinkedMap, StorageValue}; - use rstd::vec::Vec; + use sp_std::vec::Vec; use super::{CURRENT_VERSION, VersionNumber}; // the minimum supported version of the migration logic. diff --git a/frame/staking/src/slashing.rs b/frame/staking/src/slashing.rs index e8515c0f40..54b14a0cf8 100644 --- a/frame/staking/src/slashing.rs +++ b/frame/staking/src/slashing.rs @@ -57,7 +57,7 @@ use support::{ StorageMap, StorageDoubleMap, traits::{Currency, OnUnbalanced, Imbalance}, }; -use rstd::vec::Vec; +use sp_std::vec::Vec; use codec::{Encode, Decode}; /// The proportion of the slashing reward to be paid out on the first slashing detection. @@ -133,7 +133,7 @@ impl SlashingSpans { SlashingSpan { index, start, length: Some(length) } }); - rstd::iter::once(last).chain(prior) + sp_std::iter::once(last).chain(prior) } /// Yields the era index where the last (current) slashing span started. @@ -161,7 +161,7 @@ impl SlashingSpans { }; // readjust the ongoing span, if it started before the beginning of the window. - self.last_start = rstd::cmp::max(self.last_start, window_start); + self.last_start = sp_std::cmp::max(self.last_start, window_start); pruned } } @@ -419,7 +419,7 @@ struct InspectingSpans<'a, T: Trait + 'a> { paid_out: &'a mut BalanceOf, slash_of: &'a mut BalanceOf, reward_proportion: Perbill, - _marker: rstd::marker::PhantomData, + _marker: sp_std::marker::PhantomData, } // fetches the slashing spans record for a stash account, initializing it if necessary. @@ -444,7 +444,7 @@ fn fetch_spans<'a, T: Trait + 'a>( slash_of, paid_out, reward_proportion, - _marker: rstd::marker::PhantomData, + _marker: sp_std::marker::PhantomData, } } diff --git a/frame/sudo/Cargo.toml b/frame/sudo/Cargo.toml index 5e7cf92812..f16c0013b8 100644 --- a/frame/sudo/Cargo.toml +++ b/frame/sudo/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] serde = { version = "1.0.101", optional = true } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +sp-std = { path = "../../primitives/std", default-features = false } runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } @@ -21,7 +21,7 @@ default = ["std"] std = [ "serde", "codec/std", - "rstd/std", + "sp-std/std", "runtime-io/std", "sp-runtime/std", "support/std", diff --git a/frame/sudo/src/lib.rs b/frame/sudo/src/lib.rs index fa470b1785..13daa23971 100644 --- a/frame/sudo/src/lib.rs +++ b/frame/sudo/src/lib.rs @@ -86,7 +86,7 @@ #![cfg_attr(not(feature = "std"), no_std)] -use rstd::prelude::*; +use sp_std::prelude::*; use sp_runtime::{ traits::{StaticLookup, Dispatchable}, DispatchError, }; diff --git a/frame/support/Cargo.toml b/frame/support/Cargo.toml index c74b6b03e2..0f897bcda8 100644 --- a/frame/support/Cargo.toml +++ b/frame/support/Cargo.toml @@ -9,7 +9,7 @@ log = "0.4" 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 } -rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +sp-std = { path = "../../primitives/std", default-features = false } runtime-io ={ package = "sp-io", path = "../../primitives/sr-io", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } primitives = { package = "sp-core", path = "../../primitives/core", default-features = false } @@ -36,7 +36,7 @@ std = [ "serde", "runtime-io/std", "codec/std", - "rstd/std", + "sp-std/std", "sp-runtime/std", "sp-arithmetic/std", "frame-metadata/std", diff --git a/frame/support/procedural/src/storage/genesis_config/builder_def.rs b/frame/support/procedural/src/storage/genesis_config/builder_def.rs index 78c659d466..7edee59de8 100644 --- a/frame/support/procedural/src/storage/genesis_config/builder_def.rs +++ b/frame/support/procedural/src/storage/genesis_config/builder_def.rs @@ -92,7 +92,7 @@ impl BuilderDef { let key = &map.key; quote!{{ #data - let data: &#scrate::rstd::vec::Vec<(#key, #value_type)> = data; + let data: &#scrate::sp_std::vec::Vec<(#key, #value_type)> = data; data.iter().for_each(|(k, v)| { <#storage_struct as #scrate::#storage_trait>::insert::< &#key, &#value_type @@ -105,7 +105,7 @@ impl BuilderDef { let key2 = &map.key2; quote!{{ #data - let data: &#scrate::rstd::vec::Vec<(#key1, #key2, #value_type)> = data; + let data: &#scrate::sp_std::vec::Vec<(#key1, #key2, #value_type)> = data; data.iter().for_each(|(k1, k2, v)| { <#storage_struct as #scrate::#storage_trait>::insert::< &#key1, &#key2, &#value_type diff --git a/frame/support/procedural/src/storage/metadata.rs b/frame/support/procedural/src/storage/metadata.rs index b5ccb8a07a..17ad250f66 100644 --- a/frame/support/procedural/src/storage/metadata.rs +++ b/frame/support/procedural/src/storage/metadata.rs @@ -104,11 +104,11 @@ fn default_byte_getter( #[doc(hidden)] pub struct #struct_name< #runtime_generic, #optional_instance_bound_optional_default - >(pub #scrate::rstd::marker::PhantomData<(#runtime_generic #optional_comma_instance)>); + >(pub #scrate::sp_std::marker::PhantomData<(#runtime_generic #optional_comma_instance)>); #[cfg(feature = "std")] #[allow(non_upper_case_globals)] - static #cache_name: #scrate::once_cell::sync::OnceCell<#scrate::rstd::vec::Vec> = + static #cache_name: #scrate::once_cell::sync::OnceCell<#scrate::sp_std::vec::Vec> = #scrate::once_cell::sync::OnceCell::new(); #[cfg(feature = "std")] @@ -117,7 +117,7 @@ fn default_byte_getter( for #struct_name<#runtime_generic, #optional_instance> #where_clause { - fn default_byte(&self) -> #scrate::rstd::vec::Vec { + fn default_byte(&self) -> #scrate::sp_std::vec::Vec { use #scrate::codec::Encode; #cache_name.get_or_init(|| { let def_val: #query_type = #default; @@ -138,7 +138,7 @@ fn default_byte_getter( for #struct_name<#runtime_generic, #optional_instance> #where_clause { - fn default_byte(&self) -> #scrate::rstd::vec::Vec { + fn default_byte(&self) -> #scrate::sp_std::vec::Vec { use #scrate::codec::Encode; let def_val: #query_type = #default; <#query_type as Encode>::encode(&def_val) @@ -146,7 +146,7 @@ fn default_byte_getter( } }; let struct_instance = quote!( - #struct_name::<#runtime_generic, #optional_instance>(#scrate::rstd::marker::PhantomData) + #struct_name::<#runtime_generic, #optional_instance>(#scrate::sp_std::marker::PhantomData) ); (struct_def, struct_instance) diff --git a/frame/support/procedural/src/storage/storage_struct.rs b/frame/support/procedural/src/storage/storage_struct.rs index 97aea3567d..fdb1dbb161 100644 --- a/frame/support/procedural/src/storage/storage_struct.rs +++ b/frame/support/procedural/src/storage/storage_struct.rs @@ -68,7 +68,7 @@ pub fn decl_and_impl(scrate: &TokenStream, def: &DeclStorageDefExt) -> TokenStre #visibility struct #name< #optional_storage_runtime_bound_comma #optional_instance_bound_optional_default >( - #scrate::rstd::marker::PhantomData< + #scrate::sp_std::marker::PhantomData< (#optional_storage_runtime_comma #optional_instance) > ) #optional_storage_where_clause; diff --git a/frame/support/src/debug.rs b/frame/support/src/debug.rs index feb8e6d873..c872bc79df 100644 --- a/frame/support/src/debug.rs +++ b/frame/support/src/debug.rs @@ -86,8 +86,8 @@ //! native::print!("My struct: {:?}", x); //! ``` -use rstd::vec::Vec; -use rstd::fmt::{self, Debug}; +use sp_std::vec::Vec; +use sp_std::fmt::{self, Debug}; pub use log::{info, debug, error, trace, warn}; pub use crate::runtime_print as print; diff --git a/frame/support/src/dispatch.rs b/frame/support/src/dispatch.rs index d80b8ca440..8432dd2cec 100644 --- a/frame/support/src/dispatch.rs +++ b/frame/support/src/dispatch.rs @@ -17,7 +17,7 @@ //! Dispatch system. Contains a macro for defining runtime modules and //! generating values representing lazy module function calls. -pub use crate::rstd::{result, fmt, prelude::{Vec, Clone, Eq, PartialEq}, marker}; +pub use crate::sp_std::{result, fmt, prelude::{Vec, Clone, Eq, PartialEq}, marker}; pub use crate::codec::{Codec, EncodeLike, Decode, Encode, Input, Output, HasCompact, EncodeAsRef}; pub use frame_metadata::{ FunctionMetadata, DecodeDifferent, DecodeDifferentArray, FunctionArgumentMetadata, @@ -865,7 +865,7 @@ macro_rules! decl_module { for $module<$trait_instance$(, $instance)?> where $( $other_where_bounds )* { fn on_initialize(_block_number_not_used: $trait_instance::BlockNumber) { - use $crate::rstd::if_std; + use $crate::sp_std::if_std; if_std! { use $crate::tracing; let span = tracing::span!(tracing::Level::DEBUG, "on_initialize"); @@ -887,7 +887,7 @@ macro_rules! decl_module { for $module<$trait_instance$(, $instance)?> where $( $other_where_bounds )* { fn on_initialize($param: $param_ty) { - use $crate::rstd::if_std; + use $crate::sp_std::if_std; if_std! { use $crate::tracing; let span = tracing::span!(tracing::Level::DEBUG, "on_initialize"); @@ -919,7 +919,7 @@ macro_rules! decl_module { for $module<$trait_instance$(, $instance)?> where $( $other_where_bounds )* { fn on_finalize(_block_number_not_used: $trait_instance::BlockNumber) { - use $crate::rstd::if_std; + use $crate::sp_std::if_std; if_std! { use $crate::tracing; let span = tracing::span!(tracing::Level::DEBUG, "on_finalize"); @@ -941,7 +941,7 @@ macro_rules! decl_module { for $module<$trait_instance$(, $instance)?> where $( $other_where_bounds )* { fn on_finalize($param: $param_ty) { - use $crate::rstd::if_std; + use $crate::sp_std::if_std; if_std! { use $crate::tracing; let span = tracing::span!(tracing::Level::DEBUG, "on_finalize"); @@ -1044,7 +1044,7 @@ macro_rules! decl_module { $vis fn $name( $origin: $origin_ty $(, $param: $param_ty )* ) -> $crate::dispatch::DispatchResult<$error_type> { - use $crate::rstd::if_std; + use $crate::sp_std::if_std; if_std! { use $crate::tracing; let span = tracing::span!(tracing::Level::DEBUG, stringify!($name)); @@ -1070,7 +1070,7 @@ macro_rules! decl_module { ) => { $(#[doc = $doc_attr])* $vis fn $name($origin: $origin_ty $(, $param: $param_ty )* ) -> $result { - use $crate::rstd::if_std; + use $crate::sp_std::if_std; if_std! { use $crate::tracing; let span = tracing::span!(tracing::Level::DEBUG, stringify!($name)); @@ -1193,7 +1193,7 @@ macro_rules! decl_module { { #[doc(hidden)] #[codec(skip)] - __PhantomItem($crate::rstd::marker::PhantomData<($trait_instance $(, $instance)?)>, $crate::dispatch::Never), + __PhantomItem($crate::sp_std::marker::PhantomData<($trait_instance $(, $instance)?)>, $crate::dispatch::Never), $( $generated_variants )* } }; @@ -1231,7 +1231,7 @@ macro_rules! decl_module { pub struct $mod_type< $trait_instance: $trait_name $(, $instance: $instantiable $( = $module_default_instance)?)? - >($crate::rstd::marker::PhantomData<($trait_instance $(, $instance)?)>) where + >($crate::sp_std::marker::PhantomData<($trait_instance $(, $instance)?)>) where $( $other_where_bounds )*; $crate::decl_module! { diff --git a/frame/support/src/event.rs b/frame/support/src/event.rs index c2e962ffb2..5b8ce1830e 100644 --- a/frame/support/src/event.rs +++ b/frame/support/src/event.rs @@ -280,7 +280,7 @@ macro_rules! __decl_generic_event { $( #[doc(hidden)] #[codec(skip)] - PhantomData($crate::rstd::marker::PhantomData<$instance>), + PhantomData($crate::sp_std::marker::PhantomData<$instance>), )? } impl<$( $generic_param ),* $(, $instance)? > From> for () { @@ -486,12 +486,12 @@ macro_rules! impl_outer_event { $name::[< $module_name $(_ $generic_instance )? >](x) } } - impl $crate::rstd::convert::TryInto< + impl $crate::sp_std::convert::TryInto< $module_name::Event < $( $generic_param, )? $( $module_name::$generic_instance )? > > for $name { type Error = (); - fn try_into(self) -> $crate::rstd::result::Result< + fn try_into(self) -> $crate::sp_std::result::Result< $module_name::Event < $( $generic_param, )? $( $module_name::$generic_instance )? >, Self::Error > { match self { diff --git a/frame/support/src/hash.rs b/frame/support/src/hash.rs index d51df162e5..74a061dfc4 100644 --- a/frame/support/src/hash.rs +++ b/frame/support/src/hash.rs @@ -17,7 +17,7 @@ //! Hash utilities. use codec::Codec; -use rstd::prelude::Vec; +use sp_std::prelude::Vec; use runtime_io::hashing::{blake2_128, blake2_256, twox_64, twox_128, twox_256}; // This trait must be kept coherent with frame-support-procedural HasherKind usage diff --git a/frame/support/src/inherent.rs b/frame/support/src/inherent.rs index 540a27f7cc..5dfb1bade8 100644 --- a/frame/support/src/inherent.rs +++ b/frame/support/src/inherent.rs @@ -15,7 +15,7 @@ // along with Substrate. If not, see . #[doc(hidden)] -pub use crate::rstd::vec::Vec; +pub use crate::sp_std::vec::Vec; #[doc(hidden)] pub use crate::sp_runtime::traits::{Block as BlockT, Extrinsic}; #[doc(hidden)] diff --git a/frame/support/src/lib.rs b/frame/support/src/lib.rs index 35962eba88..7c121d7ebf 100644 --- a/frame/support/src/lib.rs +++ b/frame/support/src/lib.rs @@ -29,7 +29,7 @@ pub extern crate tracing; #[cfg(feature = "std")] pub use serde; #[doc(hidden)] -pub use rstd; +pub use sp_std; #[doc(hidden)] pub use codec; #[cfg(feature = "std")] @@ -204,7 +204,7 @@ mod tests { DecodeDifferent, StorageEntryMetadata, StorageMetadata, StorageEntryType, StorageEntryModifier, DefaultByteGetter, StorageHasher, }; - use rstd::marker::PhantomData; + use sp_std::marker::PhantomData; pub trait Trait { type BlockNumber: Codec + EncodeLike + Default; diff --git a/frame/support/src/origin.rs b/frame/support/src/origin.rs index 6da9bc1385..22e5c99e90 100644 --- a/frame/support/src/origin.rs +++ b/frame/support/src/origin.rs @@ -178,8 +178,8 @@ macro_rules! impl_outer_origin { $name::system(x) } } - impl Into<$crate::rstd::result::Result<$system::Origin<$runtime>, $name>> for $name { - fn into(self) -> $crate::rstd::result::Result<$system::Origin<$runtime>, Self> { + impl Into<$crate::sp_std::result::Result<$system::Origin<$runtime>, $name>> for $name { + fn into(self) -> $crate::sp_std::result::Result<$system::Origin<$runtime>, Self> { if let $name::system(l) = self { Ok(l) } else { @@ -200,12 +200,12 @@ macro_rules! impl_outer_origin { } } impl Into< - $crate::rstd::result::Result< + $crate::sp_std::result::Result< $module::Origin < $( $generic )? $(, $module::$generic_instance )? >, $name, >> for $name { - fn into(self) -> $crate::rstd::result::Result< + fn into(self) -> $crate::sp_std::result::Result< $module::Origin < $( $generic )? $(, $module::$generic_instance )? >, Self, > { diff --git a/frame/support/src/storage/child.rs b/frame/support/src/storage/child.rs index bc6150c52f..1930de57bb 100644 --- a/frame/support/src/storage/child.rs +++ b/frame/support/src/storage/child.rs @@ -21,7 +21,7 @@ //! avoid collision from a resistant hash function (which unique implies)). // NOTE: could replace unhashed by having only one kind of storage (root being null storage key (storage_key can become Option<&[u8]>). -use crate::rstd::prelude::*; +use crate::sp_std::prelude::*; use codec::{Codec, Encode, Decode}; /// Return the value of the item in storage under `key`, or `None` if there is no explicit entry. diff --git a/frame/support/src/storage/generator/double_map.rs b/frame/support/src/storage/generator/double_map.rs index 8917cbf952..fd938001ae 100644 --- a/frame/support/src/storage/generator/double_map.rs +++ b/frame/support/src/storage/generator/double_map.rs @@ -14,8 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Substrate. If not, see . -use rstd::prelude::*; -use rstd::borrow::Borrow; +use sp_std::prelude::*; +use sp_std::borrow::Borrow; use codec::{Ref, FullCodec, FullEncode, Encode, EncodeLike, EncodeAppend}; use crate::{storage::{self, unhashed}, hash::{StorageHasher, Twox128}, traits::Len}; diff --git a/frame/support/src/storage/generator/linked_map.rs b/frame/support/src/storage/generator/linked_map.rs index fb0603fce7..b4b6daf276 100644 --- a/frame/support/src/storage/generator/linked_map.rs +++ b/frame/support/src/storage/generator/linked_map.rs @@ -16,7 +16,7 @@ use codec::{FullCodec, Encode, Decode, EncodeLike, Ref}; use crate::{storage::{self, unhashed}, hash::{StorageHasher, Twox128}, traits::Len}; -use rstd::{prelude::*, marker::PhantomData}; +use sp_std::{prelude::*, marker::PhantomData}; /// Generator for `StorageLinkedMap` used by `decl_storage`. /// diff --git a/frame/support/src/storage/generator/map.rs b/frame/support/src/storage/generator/map.rs index 926fe8748d..fd9f1f901d 100644 --- a/frame/support/src/storage/generator/map.rs +++ b/frame/support/src/storage/generator/map.rs @@ -15,8 +15,8 @@ // along with Substrate. If not, see . #[cfg(not(feature = "std"))] -use rstd::prelude::*; -use rstd::borrow::Borrow; +use sp_std::prelude::*; +use sp_std::borrow::Borrow; use codec::{FullCodec, FullEncode, Encode, EncodeLike, Ref, EncodeAppend}; use crate::{storage::{self, unhashed}, hash::{StorageHasher, Twox128}, traits::Len}; diff --git a/frame/support/src/storage/generator/value.rs b/frame/support/src/storage/generator/value.rs index 0cf143bac1..cc45439f5b 100644 --- a/frame/support/src/storage/generator/value.rs +++ b/frame/support/src/storage/generator/value.rs @@ -15,7 +15,7 @@ // along with Substrate. If not, see . #[cfg(not(feature = "std"))] -use rstd::prelude::*; +use sp_std::prelude::*; use codec::{FullCodec, Encode, EncodeAppend, EncodeLike, Decode}; use crate::{storage::{self, unhashed}, hash::{Twox128, StorageHasher}, traits::Len}; diff --git a/frame/support/src/storage/hashed.rs b/frame/support/src/storage/hashed.rs index 2eca8f5bca..d4740795db 100644 --- a/frame/support/src/storage/hashed.rs +++ b/frame/support/src/storage/hashed.rs @@ -17,7 +17,7 @@ //! Operation on runtime storage using hashed keys. use super::unhashed; -use rstd::prelude::*; +use sp_std::prelude::*; use codec::{Encode, Decode}; /// Return the value of the item in storage under `key`, or `None` if there is no explicit entry. diff --git a/frame/support/src/storage/mod.rs b/frame/support/src/storage/mod.rs index 08d45571d1..d6de37ca7a 100644 --- a/frame/support/src/storage/mod.rs +++ b/frame/support/src/storage/mod.rs @@ -16,7 +16,7 @@ //! Stuff to do with the runtime's storage. -use rstd::{prelude::*, marker::PhantomData}; +use sp_std::{prelude::*, marker::PhantomData}; use codec::{FullCodec, FullEncode, Encode, EncodeAppend, EncodeLike, Decode}; use crate::{traits::Len, hash::{Twox128, StorageHasher}}; diff --git a/frame/support/src/storage/unhashed.rs b/frame/support/src/storage/unhashed.rs index a128f6bf18..c13686cf93 100644 --- a/frame/support/src/storage/unhashed.rs +++ b/frame/support/src/storage/unhashed.rs @@ -16,7 +16,7 @@ //! Operation on unhashed runtime storage. -use rstd::prelude::*; +use sp_std::prelude::*; use codec::{Encode, Decode}; /// Return the value of the item in storage under `key`, or `None` if there is no explicit entry. diff --git a/frame/support/src/traits.rs b/frame/support/src/traits.rs index 0a94483ec3..ae1695b3d3 100644 --- a/frame/support/src/traits.rs +++ b/frame/support/src/traits.rs @@ -18,7 +18,7 @@ //! //! NOTE: If you're looking for `parameter_types`, it has moved in to the top-level module. -use rstd::{prelude::*, result, marker::PhantomData, ops::Div, fmt::Debug}; +use sp_std::{prelude::*, result, marker::PhantomData, ops::Div, fmt::Debug}; use codec::{FullCodec, Codec, Encode, Decode}; use primitives::u32_trait::Value as U32; use sp_runtime::{ @@ -777,4 +777,3 @@ pub trait ValidatorRegistration { /// module fn is_registered(id: &ValidatorId) -> bool; } - diff --git a/frame/system/Cargo.toml b/frame/system/Cargo.toml index 93356c0ca6..81390d2d0e 100644 --- a/frame/system/Cargo.toml +++ b/frame/system/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"] } primitives = { package = "sp-core", path = "../../primitives/core", default-features = false } -rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +sp-std = { path = "../../primitives/std", default-features = false } runtime-io ={ package = "sp-io", path = "../../primitives/sr-io", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } sp-version = { path = "../../primitives/sr-version", default-features = false } @@ -26,7 +26,7 @@ std = [ "safe-mix/std", "codec/std", "primitives/std", - "rstd/std", + "sp-std/std", "runtime-io/std", "support/std", "sp-runtime/std", diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index cce3468639..cec92d7f82 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -90,11 +90,11 @@ #[cfg(feature = "std")] use serde::Serialize; -use rstd::prelude::*; +use sp_std::prelude::*; #[cfg(any(feature = "std", test))] -use rstd::map; -use rstd::marker::PhantomData; -use rstd::fmt::Debug; +use sp_std::map; +use sp_std::marker::PhantomData; +use sp_std::fmt::Debug; use sp_version::RuntimeVersion; use sp_runtime::{ RuntimeDebug, @@ -172,12 +172,12 @@ pub trait Trait: 'static + Eq + Clone { /// The block number type used by the runtime. type BlockNumber: Parameter + Member + MaybeSerializeDeserialize + Debug + MaybeDisplay + SimpleArithmetic - + Default + Bounded + Copy + rstd::hash::Hash; + + Default + Bounded + Copy + sp_std::hash::Hash; /// The output of the `Hashing` function. type Hash: Parameter + Member + MaybeSerializeDeserialize + Debug + MaybeDisplay + SimpleBitOps - + Default + Copy + CheckEqual + rstd::hash::Hash + AsRef<[u8]> + AsMut<[u8]>; + + Default + Copy + CheckEqual + sp_std::hash::Hash + AsRef<[u8]> + AsMut<[u8]>; /// The hashing system (algorithm) being used in the runtime (e.g. Blake2). type Hashing: Hash; @@ -435,7 +435,7 @@ decl_storage! { } } -pub struct EnsureRoot(rstd::marker::PhantomData); +pub struct EnsureRoot(sp_std::marker::PhantomData); impl< O: Into, O>> + From>, AccountId, @@ -449,7 +449,7 @@ impl< } } -pub struct EnsureSigned(rstd::marker::PhantomData); +pub struct EnsureSigned(sp_std::marker::PhantomData); impl< O: Into, O>> + From>, AccountId, @@ -463,7 +463,7 @@ impl< } } -pub struct EnsureSignedBy(rstd::marker::PhantomData<(Who, AccountId)>); +pub struct EnsureSignedBy(sp_std::marker::PhantomData<(Who, AccountId)>); impl< O: Into, O>> + From>, Who: Contains, @@ -478,7 +478,7 @@ impl< } } -pub struct EnsureNone(rstd::marker::PhantomData); +pub struct EnsureNone(sp_std::marker::PhantomData); impl< O: Into, O>> + From>, AccountId, @@ -492,7 +492,7 @@ impl< } } -pub struct EnsureNever(rstd::marker::PhantomData); +pub struct EnsureNever(sp_std::marker::PhantomData); impl EnsureOrigin for EnsureNever { type Success = T; fn try_origin(o: O) -> Result { @@ -859,7 +859,7 @@ impl SignedExtension for CheckWeight { type DispatchInfo = DispatchInfo; type Pre = (); - fn additional_signed(&self) -> rstd::result::Result<(), TransactionValidityError> { Ok(()) } + fn additional_signed(&self) -> sp_std::result::Result<(), TransactionValidityError> { Ok(()) } fn pre_dispatch( self, @@ -899,12 +899,12 @@ impl SignedExtension for CheckWeight { impl Debug for CheckWeight { #[cfg(feature = "std")] - fn fmt(&self, f: &mut rstd::fmt::Formatter) -> rstd::fmt::Result { + fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { write!(f, "CheckWeight") } #[cfg(not(feature = "std"))] - fn fmt(&self, _: &mut rstd::fmt::Formatter) -> rstd::fmt::Result { + fn fmt(&self, _: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { Ok(()) } } @@ -922,12 +922,12 @@ impl CheckNonce { impl Debug for CheckNonce { #[cfg(feature = "std")] - fn fmt(&self, f: &mut rstd::fmt::Formatter) -> rstd::fmt::Result { + fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { self.0.fmt(f) } #[cfg(not(feature = "std"))] - fn fmt(&self, _: &mut rstd::fmt::Formatter) -> rstd::fmt::Result { + fn fmt(&self, _: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { Ok(()) } } @@ -939,7 +939,7 @@ impl SignedExtension for CheckNonce { type DispatchInfo = DispatchInfo; type Pre = (); - fn additional_signed(&self) -> rstd::result::Result<(), TransactionValidityError> { Ok(()) } + fn additional_signed(&self) -> sp_std::result::Result<(), TransactionValidityError> { Ok(()) } fn pre_dispatch( self, @@ -995,23 +995,23 @@ impl SignedExtension for CheckNonce { /// Check for transaction mortality. #[derive(Encode, Decode, Clone, Eq, PartialEq)] -pub struct CheckEra((Era, rstd::marker::PhantomData)); +pub struct CheckEra((Era, sp_std::marker::PhantomData)); impl CheckEra { /// utility constructor. Used only in client/factory code. pub fn from(era: Era) -> Self { - Self((era, rstd::marker::PhantomData)) + Self((era, sp_std::marker::PhantomData)) } } impl Debug for CheckEra { #[cfg(feature = "std")] - fn fmt(&self, f: &mut rstd::fmt::Formatter) -> rstd::fmt::Result { + fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { self.0.fmt(f) } #[cfg(not(feature = "std"))] - fn fmt(&self, _: &mut rstd::fmt::Formatter) -> rstd::fmt::Result { + fn fmt(&self, _: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { Ok(()) } } @@ -1051,16 +1051,16 @@ impl SignedExtension for CheckEra { /// Nonce check and increment to give replay protection for transactions. #[derive(Encode, Decode, Clone, Eq, PartialEq)] -pub struct CheckGenesis(rstd::marker::PhantomData); +pub struct CheckGenesis(sp_std::marker::PhantomData); impl Debug for CheckGenesis { #[cfg(feature = "std")] - fn fmt(&self, f: &mut rstd::fmt::Formatter) -> rstd::fmt::Result { + fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { write!(f, "CheckGenesis") } #[cfg(not(feature = "std"))] - fn fmt(&self, _: &mut rstd::fmt::Formatter) -> rstd::fmt::Result { + fn fmt(&self, _: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { Ok(()) } } @@ -1068,7 +1068,7 @@ impl Debug for CheckGenesis { impl CheckGenesis { /// Creates new `SignedExtension` to check genesis hash. pub fn new() -> Self { - Self(rstd::marker::PhantomData) + Self(sp_std::marker::PhantomData) } } @@ -1086,16 +1086,16 @@ impl SignedExtension for CheckGenesis { /// Ensure the runtime version registered in the transaction is the same as at present. #[derive(Encode, Decode, Clone, Eq, PartialEq)] -pub struct CheckVersion(rstd::marker::PhantomData); +pub struct CheckVersion(sp_std::marker::PhantomData); impl Debug for CheckVersion { #[cfg(feature = "std")] - fn fmt(&self, f: &mut rstd::fmt::Formatter) -> rstd::fmt::Result { + fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { write!(f, "CheckVersion") } #[cfg(not(feature = "std"))] - fn fmt(&self, _: &mut rstd::fmt::Formatter) -> rstd::fmt::Result { + fn fmt(&self, _: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { Ok(()) } } @@ -1103,7 +1103,7 @@ impl Debug for CheckVersion { impl CheckVersion { /// Create new `SignedExtension` to check runtime version. pub fn new() -> Self { - Self(rstd::marker::PhantomData) + Self(sp_std::marker::PhantomData) } } @@ -1119,10 +1119,10 @@ impl SignedExtension for CheckVersion { } } -pub struct ChainContext(rstd::marker::PhantomData); +pub struct ChainContext(sp_std::marker::PhantomData); impl Default for ChainContext { fn default() -> Self { - ChainContext(rstd::marker::PhantomData) + ChainContext(sp_std::marker::PhantomData) } } diff --git a/frame/system/src/offchain.rs b/frame/system/src/offchain.rs index 492dfefb6b..a12c9c3d06 100644 --- a/frame/system/src/offchain.rs +++ b/frame/system/src/offchain.rs @@ -41,7 +41,7 @@ impl Signer for AppPublic where Signature: From< <::Signature as app_crypto::AppSignature>::Generic >, - Public: rstd::convert::TryInto<::Generic> + Public: sp_std::convert::TryInto<::Generic> { fn sign(public: Public, raw_payload: &Payload) -> Option { raw_payload.using_encoded(|payload| { @@ -132,7 +132,7 @@ pub trait SubmitUnsignedTransaction { /// A default type used to submit transactions to the pool. pub struct TransactionSubmitter { - _signer: rstd::marker::PhantomData<(S, C, E)>, + _signer: sp_std::marker::PhantomData<(S, C, E)>, } impl Default for TransactionSubmitter { diff --git a/frame/timestamp/Cargo.toml b/frame/timestamp/Cargo.toml index c6eac45f98..e23bcec013 100644 --- a/frame/timestamp/Cargo.toml +++ b/frame/timestamp/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] serde = { version = "1.0.101", optional = true } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +sp-std = { path = "../../primitives/std", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } inherents = { package = "sp-inherents", path = "../../primitives/inherents", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } @@ -24,7 +24,7 @@ default = ["std"] std = [ "inherents/std", "codec/std", - "rstd/std", + "sp-std/std", "sp-runtime/std", "support/std", "serde", diff --git a/frame/timestamp/src/lib.rs b/frame/timestamp/src/lib.rs index 9368c09b67..0c415dbe9a 100644 --- a/frame/timestamp/src/lib.rs +++ b/frame/timestamp/src/lib.rs @@ -90,7 +90,7 @@ #![cfg_attr(not(feature = "std"), no_std)] -use rstd::{result, cmp}; +use sp_std::{result, cmp}; use inherents::{ProvideInherent, InherentData, InherentIdentifier}; use support::{Parameter, decl_storage, decl_module}; use support::traits::{Time, Get}; diff --git a/frame/transaction-payment/Cargo.toml b/frame/transaction-payment/Cargo.toml index 9163a0a7d8..696b5e4b6b 100644 --- a/frame/transaction-payment/Cargo.toml +++ b/frame/transaction-payment/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" [dependencies] codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +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 } @@ -21,7 +21,7 @@ balances = { package = "pallet-balances", path = "../balances" } default = ["std"] std = [ "codec/std", - "rstd/std", + "sp-std/std", "sp-runtime/std", "support/std", "system/std", diff --git a/frame/transaction-payment/rpc/runtime-api/Cargo.toml b/frame/transaction-payment/rpc/runtime-api/Cargo.toml index 559d59e808..d55919a60d 100644 --- a/frame/transaction-payment/rpc/runtime-api/Cargo.toml +++ b/frame/transaction-payment/rpc/runtime-api/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" serde = { version = "1.0.101", optional = true, features = ["derive"] } sp-api = { path = "../../../../primitives/sr-api", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.6", default-features = false, features = ["derive"] } -rstd = { package = "sp-std", path = "../../../../primitives/sr-std", default-features = false } +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 } @@ -21,7 +21,7 @@ std = [ "serde", "sp-api/std", "codec/std", - "rstd/std", + "sp-std/std", "sp-runtime/std", "support/std", ] diff --git a/frame/transaction-payment/rpc/runtime-api/src/lib.rs b/frame/transaction-payment/rpc/runtime-api/src/lib.rs index 549f67c98c..8de2e847ac 100644 --- a/frame/transaction-payment/rpc/runtime-api/src/lib.rs +++ b/frame/transaction-payment/rpc/runtime-api/src/lib.rs @@ -18,7 +18,7 @@ #![cfg_attr(not(feature = "std"), no_std)] -use rstd::prelude::*; +use sp_std::prelude::*; use support::weights::{Weight, DispatchClass}; use codec::{Encode, Codec, Decode}; #[cfg(feature = "std")] diff --git a/frame/transaction-payment/src/lib.rs b/frame/transaction-payment/src/lib.rs index eacf890d80..e51468b4f6 100644 --- a/frame/transaction-payment/src/lib.rs +++ b/frame/transaction-payment/src/lib.rs @@ -31,7 +31,7 @@ #![cfg_attr(not(feature = "std"), no_std)] -use rstd::prelude::*; +use sp_std::prelude::*; use codec::{Encode, Decode}; use support::{ decl_storage, decl_module, @@ -179,13 +179,13 @@ impl ChargeTransactionPayment { } } -impl rstd::fmt::Debug for ChargeTransactionPayment { +impl sp_std::fmt::Debug for ChargeTransactionPayment { #[cfg(feature = "std")] - fn fmt(&self, f: &mut rstd::fmt::Formatter) -> rstd::fmt::Result { + fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { write!(f, "ChargeTransactionPayment<{:?}>", self.0) } #[cfg(not(feature = "std"))] - fn fmt(&self, _: &mut rstd::fmt::Formatter) -> rstd::fmt::Result { + fn fmt(&self, _: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { Ok(()) } } @@ -198,7 +198,7 @@ impl SignedExtension for ChargeTransactionPayment type AdditionalSigned = (); type DispatchInfo = DispatchInfo; type Pre = (); - fn additional_signed(&self) -> rstd::result::Result<(), TransactionValidityError> { Ok(()) } + fn additional_signed(&self) -> sp_std::result::Result<(), TransactionValidityError> { Ok(()) } fn validate( &self, @@ -248,7 +248,7 @@ mod tests { traits::{BlakeTwo256, IdentityLookup, Extrinsic}, }; use balances::Call as BalancesCall; - use rstd::cell::RefCell; + use sp_std::cell::RefCell; use transaction_payment_rpc_runtime_api::RuntimeDispatchInfo; const CALL: &::Call = &Call::Balances(BalancesCall::transfer(2, 69)); @@ -543,4 +543,3 @@ mod tests { }); } } - diff --git a/frame/treasury/Cargo.toml b/frame/treasury/Cargo.toml index 6f3d53af5e..5b4acd9808 100644 --- a/frame/treasury/Cargo.toml +++ b/frame/treasury/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] serde = { version = "1.0.101", optional = true, features = ["derive"] } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +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 } @@ -22,7 +22,7 @@ default = ["std"] std = [ "serde", "codec/std", - "rstd/std", + "sp-std/std", "sp-runtime/std", "support/std", "system/std", diff --git a/frame/treasury/src/lib.rs b/frame/treasury/src/lib.rs index d5ca4b232e..510dc5348d 100644 --- a/frame/treasury/src/lib.rs +++ b/frame/treasury/src/lib.rs @@ -59,7 +59,7 @@ #[cfg(feature = "std")] use serde::{Serialize, Deserialize}; -use rstd::prelude::*; +use sp_std::prelude::*; use support::{decl_module, decl_storage, decl_event, ensure, print}; use support::traits::{ Currency, ExistenceRequirement, Get, Imbalance, OnUnbalanced, diff --git a/frame/utility/Cargo.toml b/frame/utility/Cargo.toml index 149db67a63..5246e86c82 100644 --- a/frame/utility/Cargo.toml +++ b/frame/utility/Cargo.toml @@ -10,7 +10,7 @@ codec = { package = "parity-scale-codec", version = "1.0.0", default-features = 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 } -rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +sp-std = { path = "../../primitives/std", default-features = false } runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } [dev-dependencies] @@ -26,5 +26,5 @@ std = [ "support/std", "system/std", "runtime-io/std", - "rstd/std" + "sp-std/std" ] diff --git a/frame/utility/src/lib.rs b/frame/utility/src/lib.rs index 20222766f4..0565997e3d 100644 --- a/frame/utility/src/lib.rs +++ b/frame/utility/src/lib.rs @@ -20,7 +20,7 @@ // Ensure we're `no_std` when compiling for Wasm. #![cfg_attr(not(feature = "std"), no_std)] -use rstd::prelude::*; +use sp_std::prelude::*; use support::{decl_module, decl_event, Parameter, weights::SimpleDispatchInfo}; use system::ensure_root; use sp_runtime::{traits::Dispatchable, DispatchError}; diff --git a/primitives/application-crypto/Cargo.toml b/primitives/application-crypto/Cargo.toml index 7a38b28e83..e13427d256 100644 --- a/primitives/application-crypto/Cargo.toml +++ b/primitives/application-crypto/Cargo.toml @@ -9,7 +9,7 @@ description = "Provides facilities for generating application specific crypto wr 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"] } -rstd = { package = "sp-std", path = "../sr-std", default-features = false } +sp-std = { path = "../std", default-features = false } runtime-io = { package = "sp-io", path = "../../primitives/sr-io", default-features = false } [dev-dependencies] @@ -18,7 +18,7 @@ sp-runtime = { path = "../../primitives/runtime" } [features] default = [ "std" ] -std = [ "full_crypto", "primitives/std", "codec/std", "serde", "rstd/std", "runtime-io/std" ] +std = [ "full_crypto", "primitives/std", "codec/std", "serde", "sp-std/std", "runtime-io/std" ] # This feature enables all crypto primitives for `no_std` builds like microcontrollers # or Intel SGX. diff --git a/primitives/application-crypto/src/ed25519.rs b/primitives/application-crypto/src/ed25519.rs index 7ada97672a..358e5f657e 100644 --- a/primitives/application-crypto/src/ed25519.rs +++ b/primitives/application-crypto/src/ed25519.rs @@ -18,7 +18,7 @@ use crate::{RuntimePublic, KeyTypeId}; -use rstd::vec::Vec; +use sp_std::vec::Vec; pub use primitives::ed25519::*; diff --git a/primitives/application-crypto/src/lib.rs b/primitives/application-crypto/src/lib.rs index 3a748e50c9..d7c303e338 100644 --- a/primitives/application-crypto/src/lib.rs +++ b/primitives/application-crypto/src/lib.rs @@ -33,7 +33,7 @@ pub use codec; #[cfg(feature = "std")] pub use serde; #[doc(hidden)] -pub use rstd::{ops::Deref, vec::Vec}; +pub use sp_std::{ops::Deref, vec::Vec}; pub mod ed25519; pub mod sr25519; @@ -102,7 +102,7 @@ macro_rules! app_crypto_pair { type Seed = <$pair as $crate::Pair>::Seed; type Signature = Signature; type DeriveError = <$pair as $crate::Pair>::DeriveError; - + #[cfg(feature = "std")] fn generate_with_phrase(password: Option<&str>) -> (Self, String, Self::Seed) { let r = <$pair>::generate_with_phrase(password); @@ -353,7 +353,7 @@ macro_rules! app_crypto_signature_not_full_crypto { )] pub struct Signature($sig); } - + impl $crate::CryptoType for Signature {} impl $crate::AppKey for Signature { diff --git a/primitives/application-crypto/src/sr25519.rs b/primitives/application-crypto/src/sr25519.rs index ebe2a5d353..749e3db21f 100644 --- a/primitives/application-crypto/src/sr25519.rs +++ b/primitives/application-crypto/src/sr25519.rs @@ -18,7 +18,7 @@ use crate::{RuntimePublic, KeyTypeId}; -use rstd::vec::Vec; +use sp_std::vec::Vec; pub use primitives::sr25519::*; diff --git a/primitives/application-crypto/src/traits.rs b/primitives/application-crypto/src/traits.rs index 0575d2ba06..741bbc48c9 100644 --- a/primitives/application-crypto/src/traits.rs +++ b/primitives/application-crypto/src/traits.rs @@ -19,7 +19,7 @@ use primitives::crypto::Pair; use codec::Codec; use primitives::crypto::{KeyTypeId, CryptoType, IsWrappedBy, Public}; -use rstd::{fmt::Debug, vec::Vec}; +use sp_std::{fmt::Debug, vec::Vec}; /// An application-specific key. pub trait AppKey: 'static + Send + Sync + Sized + CryptoType + Clone { @@ -42,9 +42,9 @@ pub trait AppKey: 'static + Send + Sync + Sized + CryptoType + Clone { /// Type which implements Hash in std, not when no-std (std variant). #[cfg(any(feature = "std", feature = "full_crypto"))] -pub trait MaybeHash: rstd::hash::Hash {} +pub trait MaybeHash: sp_std::hash::Hash {} #[cfg(any(feature = "std", feature = "full_crypto"))] -impl MaybeHash for T {} +impl MaybeHash for T {} /// Type which implements Hash in std, not when no-std (no-std variant). #[cfg(all(not(feature = "std"), not(feature = "full_crypto")))] @@ -54,9 +54,9 @@ impl MaybeHash for T {} /// Type which implements Debug and Hash in std, not when no-std (no-std variant with crypto). #[cfg(all(not(feature = "std"), feature = "full_crypto"))] -pub trait MaybeDebugHash: rstd::hash::Hash {} +pub trait MaybeDebugHash: sp_std::hash::Hash {} #[cfg(all(not(feature = "std"), feature = "full_crypto"))] -impl MaybeDebugHash for T {} +impl MaybeDebugHash for T {} /// A application's public key. pub trait AppPublic: diff --git a/primitives/authority-discovery/Cargo.toml b/primitives/authority-discovery/Cargo.toml index f96d4c8e48..1924add0a6 100644 --- a/primitives/authority-discovery/Cargo.toml +++ b/primitives/authority-discovery/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" [dependencies] app-crypto = { package = "sc-application-crypto", path = "../application-crypto", default-features = false } codec = { package = "parity-scale-codec", default-features = false, version = "1.0.3" } -rstd = { package = "sp-std", path = "../sr-std", default-features = false } +sp-std = { path = "../std", default-features = false } sp-api = { path = "../sr-api", default-features = false } sp-runtime = { path = "../runtime", default-features = false } @@ -17,7 +17,7 @@ default = ["std"] std = [ "app-crypto/std", "codec/std", - "rstd/std", + "sp-std/std", "sp-api/std", "sp-runtime/std" ] diff --git a/primitives/authority-discovery/src/lib.rs b/primitives/authority-discovery/src/lib.rs index 8ce9757a59..811bcc261b 100644 --- a/primitives/authority-discovery/src/lib.rs +++ b/primitives/authority-discovery/src/lib.rs @@ -18,7 +18,7 @@ #![cfg_attr(not(feature = "std"), no_std)] -use rstd::vec::Vec; +use sp_std::vec::Vec; mod app { use app_crypto::{app_crypto, key_types::AUTHORITY_DISCOVERY, sr25519}; diff --git a/primitives/authorship/Cargo.toml b/primitives/authorship/Cargo.toml index 26093b0136..f996a75aae 100644 --- a/primitives/authorship/Cargo.toml +++ b/primitives/authorship/Cargo.toml @@ -8,14 +8,14 @@ edition = "2018" [dependencies] sp-inherents = { path = "../inherents", default-features = false } sp-runtime = { path = "../runtime", default-features = false } -rstd = { package = "sp-std", path = "../sr-std", default-features = false } +sp-std = { path = "../std", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } [features] default = [ "std" ] std = [ "codec/std", - "rstd/std", + "sp-std/std", "sp-inherents/std", "sp-runtime/std", ] diff --git a/primitives/authorship/src/lib.rs b/primitives/authorship/src/lib.rs index c143e752b2..7494e58338 100644 --- a/primitives/authorship/src/lib.rs +++ b/primitives/authorship/src/lib.rs @@ -18,7 +18,7 @@ #![cfg_attr(not(feature = "std"), no_std)] -use rstd::{result::Result, prelude::*}; +use sp_std::{result::Result, prelude::*}; use codec::{Encode, Decode}; use sp_inherents::{Error, InherentIdentifier, InherentData, IsFatalError}; diff --git a/primitives/block-builder/runtime-api/Cargo.toml b/primitives/block-builder/runtime-api/Cargo.toml index 36ee35e3eb..ba6705fa2a 100644 --- a/primitives/block-builder/runtime-api/Cargo.toml +++ b/primitives/block-builder/runtime-api/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] sp-runtime = { path = "../../runtime", default-features = false } sp-api = { path = "../../sr-api", default-features = false } -rstd = { package = "sp-std", path = "../../sr-std", default-features = false } +sp-std = { path = "../../std", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.6", default-features = false } inherents = { package = "sp-inherents", path = "../../inherents", default-features = false } @@ -18,5 +18,5 @@ std = [ "codec/std", "inherents/std", "sp-api/std", - "rstd/std", + "sp-std/std", ] diff --git a/primitives/block-builder/runtime-api/src/lib.rs b/primitives/block-builder/runtime-api/src/lib.rs index 441df3dd4a..3b0a615ae5 100644 --- a/primitives/block-builder/runtime-api/src/lib.rs +++ b/primitives/block-builder/runtime-api/src/lib.rs @@ -64,7 +64,7 @@ sp_api::decl_runtime_apis! { /// Generate inherent extrinsics. The inherent data will vary from chain to chain. fn inherent_extrinsics( inherent: InherentData, - ) -> rstd::vec::Vec<::Extrinsic>; + ) -> sp_std::vec::Vec<::Extrinsic>; /// Check that the inherents are valid. The inherent data will vary from chain to chain. fn check_inherents(block: Block, data: InherentData) -> CheckInherentsResult; /// Generate a random seed. diff --git a/primitives/consensus/aura/Cargo.toml b/primitives/consensus/aura/Cargo.toml index 4bc83206a2..ef0af6d292 100644 --- a/primitives/consensus/aura/Cargo.toml +++ b/primitives/consensus/aura/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" [dependencies] app-crypto = { package = "sc-application-crypto", path = "../../application-crypto", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } -rstd = { package = "sp-std", path = "../../sr-std", default-features = false } +sp-std = { path = "../../std", default-features = false } sp-api = { path = "../../sr-api", default-features = false } sp-runtime = { path = "../../runtime", default-features = false } inherents = { package = "sp-inherents", path = "../../inherents", default-features = false } @@ -19,7 +19,7 @@ default = ["std"] std = [ "app-crypto/std", "codec/std", - "rstd/std", + "sp-std/std", "sp-api/std", "sp-runtime/std", "inherents/std", diff --git a/primitives/consensus/aura/src/inherents.rs b/primitives/consensus/aura/src/inherents.rs index 11a429b817..5899e7b272 100644 --- a/primitives/consensus/aura/src/inherents.rs +++ b/primitives/consensus/aura/src/inherents.rs @@ -18,7 +18,7 @@ use sp_timestamp::TimestampInherentData; use inherents::{InherentIdentifier, InherentData, Error}; -use rstd::result::Result; +use sp_std::result::Result; use codec::Decode; #[cfg(feature = "std")] diff --git a/primitives/consensus/aura/src/lib.rs b/primitives/consensus/aura/src/lib.rs index c866c041da..1ed1da96ec 100644 --- a/primitives/consensus/aura/src/lib.rs +++ b/primitives/consensus/aura/src/lib.rs @@ -19,7 +19,7 @@ #![cfg_attr(not(feature = "std"), no_std)] use codec::{Encode, Decode, Codec}; -use rstd::vec::Vec; +use sp_std::vec::Vec; use sp_runtime::ConsensusEngineId; pub mod inherents; diff --git a/primitives/consensus/babe/Cargo.toml b/primitives/consensus/babe/Cargo.toml index d4d867c373..a77813aee9 100644 --- a/primitives/consensus/babe/Cargo.toml +++ b/primitives/consensus/babe/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" [dependencies] app-crypto = { package = "sc-application-crypto", path = "../../application-crypto", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } -rstd = { package = "sp-std", path = "../../sr-std", default-features = false } +sp-std = { path = "../../std", default-features = false } schnorrkel = { version = "0.8.5", features = ["preaudit_deprecated"], optional = true } sp-api = { path = "../../sr-api", default-features = false } sp-consensus = { path = "../common", optional = true } @@ -21,7 +21,7 @@ default = ["std"] std = [ "app-crypto/std", "codec/std", - "rstd/std", + "sp-std/std", "schnorrkel", "sp-api/std", "sp-consensus", diff --git a/primitives/consensus/babe/src/digest.rs b/primitives/consensus/babe/src/digest.rs index 496c348e1d..343cec4db7 100644 --- a/primitives/consensus/babe/src/digest.rs +++ b/primitives/consensus/babe/src/digest.rs @@ -33,7 +33,7 @@ use schnorrkel::{ SignatureError, errors::MultiSignatureStage, vrf::{VRFProof, VRFOutput, VRF_OUTPUT_LENGTH, VRF_PROOF_LENGTH} }; -use rstd::vec::Vec; +use sp_std::vec::Vec; /// A BABE pre-runtime digest. This contains all data required to validate a diff --git a/primitives/consensus/babe/src/inherents.rs b/primitives/consensus/babe/src/inherents.rs index 0ebefaaaf0..5a4e042352 100644 --- a/primitives/consensus/babe/src/inherents.rs +++ b/primitives/consensus/babe/src/inherents.rs @@ -23,7 +23,7 @@ use sp_timestamp::TimestampInherentData; #[cfg(feature = "std")] use codec::Decode; -use rstd::result::Result; +use sp_std::result::Result; /// The BABE inherent identifier. pub const INHERENT_IDENTIFIER: InherentIdentifier = *b"babeslot"; diff --git a/primitives/consensus/babe/src/lib.rs b/primitives/consensus/babe/src/lib.rs index 552b841733..90e8855b57 100644 --- a/primitives/consensus/babe/src/lib.rs +++ b/primitives/consensus/babe/src/lib.rs @@ -23,7 +23,7 @@ mod digest; pub mod inherents; use codec::{Encode, Decode}; -use rstd::vec::Vec; +use sp_std::vec::Vec; use sp_runtime::{ConsensusEngineId, RuntimeDebug}; #[cfg(feature = "std")] diff --git a/primitives/consensus/common/Cargo.toml b/primitives/consensus/common/Cargo.toml index 75a62ead0f..ea2ee3891c 100644 --- a/primitives/consensus/common/Cargo.toml +++ b/primitives/consensus/common/Cargo.toml @@ -13,7 +13,7 @@ primitives = { package = "sp-core", path= "../../core" } inherents = { package = "sp-inherents", path = "../../inherents" } futures = { version = "0.3.1", features = ["thread-pool"] } futures-timer = "0.4.0" -rstd = { package = "sp-std", path = "../../sr-std" } +sp-std = { path = "../../std" } runtime_version = { package = "sp-version", path = "../../sr-version" } sp-runtime = { path = "../../runtime" } codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } diff --git a/primitives/consensus/pow/Cargo.toml b/primitives/consensus/pow/Cargo.toml index ef64333e29..dfe646c00d 100644 --- a/primitives/consensus/pow/Cargo.toml +++ b/primitives/consensus/pow/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] sp-api = { path = "../../sr-api", default-features = false } -rstd = { package = "sp-std", path = "../../sr-std", default-features = false } +sp-std = { path = "../../std", default-features = false } sp-runtime = { path = "../../runtime", default-features = false } primitives = { package = "sp-core", path = "../../core", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } @@ -15,7 +15,7 @@ codec = { package = "parity-scale-codec", version = "1.0.0", default-features = [features] default = ["std"] std = [ - "rstd/std", + "sp-std/std", "sp-api/std", "sp-runtime/std", "primitives/std", diff --git a/primitives/consensus/pow/src/lib.rs b/primitives/consensus/pow/src/lib.rs index 69e088bd9c..005e2f5325 100644 --- a/primitives/consensus/pow/src/lib.rs +++ b/primitives/consensus/pow/src/lib.rs @@ -18,7 +18,7 @@ #![cfg_attr(not(feature = "std"), no_std)] -use rstd::vec::Vec; +use sp_std::vec::Vec; use sp_runtime::ConsensusEngineId; use codec::Decode; diff --git a/primitives/core/Cargo.toml b/primitives/core/Cargo.toml index d3a8ee8b1b..d8e2513879 100644 --- a/primitives/core/Cargo.toml +++ b/primitives/core/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -rstd = { package = "sp-std", path = "../sr-std", default-features = false } +sp-std = { path = "../std", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } rustc-hex = { version = "2.0.1", default-features = false } log = { version = "0.4.8", default-features = false } @@ -73,7 +73,7 @@ std = [ "codec/std", "hash256-std-hasher/std", "hash-db/std", - "rstd/std", + "sp-std/std", "serde", "rustc-hex/std", "twox-hash/std", diff --git a/primitives/core/src/changes_trie.rs b/primitives/core/src/changes_trie.rs index 5e88485a03..f746e1dc8d 100644 --- a/primitives/core/src/changes_trie.rs +++ b/primitives/core/src/changes_trie.rs @@ -57,8 +57,8 @@ impl ChangesTrieConfiguration { ) -> bool where Number: From + PartialEq + - ::rstd::ops::Rem + ::rstd::ops::Sub + - ::rstd::cmp::PartialOrd + Zero, + ::sp_std::ops::Rem + ::sp_std::ops::Sub + + ::sp_std::cmp::PartialOrd + Zero, { block > zero && self.is_digest_build_enabled() @@ -92,8 +92,8 @@ impl ChangesTrieConfiguration { ) -> Option where Number: Clone + From + PartialOrd + PartialEq + - ::rstd::ops::Add + ::rstd::ops::Sub + - ::rstd::ops::Div + ::rstd::ops::Mul + Zero, + ::sp_std::ops::Add + ::sp_std::ops::Sub + + ::sp_std::ops::Div + ::sp_std::ops::Mul + Zero, { if block <= zero { return None; @@ -126,8 +126,8 @@ impl ChangesTrieConfiguration { ) -> Option<(Number, Number)> where Number: Clone + From + PartialOrd + PartialEq + - ::rstd::ops::Add + ::rstd::ops::Sub + - ::rstd::ops::Div + ::rstd::ops::Mul, + ::sp_std::ops::Add + ::sp_std::ops::Sub + + ::sp_std::ops::Div + ::sp_std::ops::Mul, { if !self.is_digest_build_enabled() { return None; @@ -160,8 +160,8 @@ impl ChangesTrieConfiguration { pub fn digest_level_at_block(&self, zero: Number, block: Number) -> Option<(u32, u32, u32)> where Number: Clone + From + PartialEq + - ::rstd::ops::Rem + ::rstd::ops::Sub + - ::rstd::cmp::PartialOrd + Zero, + ::sp_std::ops::Rem + ::sp_std::ops::Sub + + ::sp_std::cmp::PartialOrd + Zero, { if !self.is_digest_build_required_at_block(zero.clone(), block.clone()) { return None; diff --git a/primitives/core/src/crypto.rs b/primitives/core/src/crypto.rs index f5484efed7..3d020bcde0 100644 --- a/primitives/core/src/crypto.rs +++ b/primitives/core/src/crypto.rs @@ -18,10 +18,10 @@ //! Cryptographic utilities. // end::description[] -use rstd::{vec::Vec, hash::Hash}; +use sp_std::{vec::Vec, hash::Hash}; #[cfg(feature = "std")] -use rstd::convert::TryInto; -use rstd::convert::TryFrom; +use sp_std::convert::TryInto; +use sp_std::convert::TryFrom; #[cfg(feature = "std")] use parking_lot::Mutex; #[cfg(feature = "std")] @@ -34,7 +34,7 @@ use base58::{FromBase58, ToBase58}; use zeroize::Zeroize; #[doc(hidden)] -pub use rstd::ops::Deref; +pub use sp_std::ops::Deref; use runtime_interface::pass_by::PassByInner; /// The root phrase for our publicly known keys. @@ -86,7 +86,7 @@ impl AsRef for Protected { } } -impl rstd::ops::Deref for Protected { +impl sp_std::ops::Deref for Protected { type Target = T; fn deref(&self) -> &T { @@ -552,7 +552,7 @@ impl From<[u8; 32]> for AccountId32 { } } -impl<'a> rstd::convert::TryFrom<&'a [u8]> for AccountId32 { +impl<'a> sp_std::convert::TryFrom<&'a [u8]> for AccountId32 { type Error = (); fn try_from(x: &'a [u8]) -> Result { if x.len() == 32 { @@ -578,15 +578,15 @@ impl std::fmt::Display for AccountId32 { } } -impl rstd::fmt::Debug for AccountId32 { +impl sp_std::fmt::Debug for AccountId32 { #[cfg(feature = "std")] - fn fmt(&self, f: &mut rstd::fmt::Formatter) -> rstd::fmt::Result { + fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { let s = self.to_ss58check(); write!(f, "{} ({}...)", crate::hexdisplay::HexDisplay::from(&self.0), &s[0..8]) } #[cfg(not(feature = "std"))] - fn fmt(&self, _: &mut rstd::fmt::Formatter) -> rstd::fmt::Result { + fn fmt(&self, _: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { Ok(()) } } @@ -625,7 +625,7 @@ mod dummy { fn as_mut(&mut self) -> &mut[u8] { unsafe { #[allow(mutable_transmutes)] - rstd::mem::transmute::<_, &'static mut [u8]>(&b""[..]) + sp_std::mem::transmute::<_, &'static mut [u8]>(&b""[..]) } } } @@ -772,8 +772,8 @@ pub trait Pair: CryptoType + Sized + Clone + Send + Sync + 'static { /// /// `None` is returned if no matches are found. #[cfg(feature = "std")] - fn from_string_with_seed(s: &str, password_override: Option<&str>) - -> Result<(Self, Option), SecretStringError> + fn from_string_with_seed(s: &str, password_override: Option<&str>) + -> Result<(Self, Option), SecretStringError> { let re = Regex::new(r"^(?P[\d\w ]+)?(?P(//?[^/]+)*)(///(?P.*))?$") .expect("constructed from known-good static value; qed"); diff --git a/primitives/core/src/ecdsa.rs b/primitives/core/src/ecdsa.rs index 50ad9ddfa0..e097d0c5e6 100644 --- a/primitives/core/src/ecdsa.rs +++ b/primitives/core/src/ecdsa.rs @@ -19,9 +19,9 @@ // end::description[] #[cfg(feature = "full_crypto")] -use rstd::vec::Vec; +use sp_std::vec::Vec; -use rstd::cmp::Ordering; +use sp_std::cmp::Ordering; use codec::{Encode, Decode}; #[cfg(feature = "full_crypto")] @@ -102,7 +102,7 @@ impl AsMut<[u8]> for Public { } } -impl rstd::convert::TryFrom<&[u8]> for Public { +impl sp_std::convert::TryFrom<&[u8]> for Public { type Error = (); fn try_from(data: &[u8]) -> Result { @@ -166,8 +166,8 @@ impl<'de> Deserialize<'de> for Public { } #[cfg(feature = "full_crypto")] -impl rstd::hash::Hash for Public { - fn hash(&self, state: &mut H) { +impl sp_std::hash::Hash for Public { + fn hash(&self, state: &mut H) { self.0.hash(state); } } @@ -176,7 +176,7 @@ impl rstd::hash::Hash for Public { #[derive(Encode, Decode)] pub struct Signature([u8; 65]); -impl rstd::convert::TryFrom<&[u8]> for Signature { +impl sp_std::convert::TryFrom<&[u8]> for Signature { type Error = (); fn try_from(data: &[u8]) -> Result { @@ -261,9 +261,9 @@ impl std::fmt::Debug for Signature { } #[cfg(feature = "full_crypto")] -impl rstd::hash::Hash for Signature { - fn hash(&self, state: &mut H) { - rstd::hash::Hash::hash(&self.0[..], state); +impl sp_std::hash::Hash for Signature { + fn hash(&self, state: &mut H) { + sp_std::hash::Hash::hash(&self.0[..], state); } } diff --git a/primitives/core/src/ed25519.rs b/primitives/core/src/ed25519.rs index 34ec0d6c8d..0b40ea8bb6 100644 --- a/primitives/core/src/ed25519.rs +++ b/primitives/core/src/ed25519.rs @@ -19,7 +19,7 @@ // end::description[] #[cfg(feature = "full_crypto")] -use rstd::vec::Vec; +use sp_std::vec::Vec; use crate::{hash::H256, hash::H512}; use codec::{Encode, Decode}; @@ -40,7 +40,7 @@ use crate::crypto::Ss58Codec; use serde::{de, Serializer, Serialize, Deserializer, Deserialize}; use crate::{crypto::{Public as TraitPublic, UncheckedFrom, CryptoType, Derive}}; use runtime_interface::pass_by::PassByInner; -use rstd::ops::Deref; +use sp_std::ops::Deref; /// A secret seed. It's not called a "secret key" because ring doesn't expose the secret keys /// of the key pair (yeah, dumb); as such we're forced to remember the seed manually if we @@ -94,7 +94,7 @@ impl Deref for Public { } } -impl rstd::convert::TryFrom<&[u8]> for Public { +impl sp_std::convert::TryFrom<&[u8]> for Public { type Error = (); fn try_from(data: &[u8]) -> Result { @@ -155,15 +155,15 @@ impl std::fmt::Display for Public { } } -impl rstd::fmt::Debug for Public { +impl sp_std::fmt::Debug for Public { #[cfg(feature = "std")] - fn fmt(&self, f: &mut rstd::fmt::Formatter) -> rstd::fmt::Result { + fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { let s = self.to_ss58check(); write!(f, "{} ({}...)", crate::hexdisplay::HexDisplay::from(&self.0), &s[0..8]) } #[cfg(not(feature = "std"))] - fn fmt(&self, _: &mut rstd::fmt::Formatter) -> rstd::fmt::Result { + fn fmt(&self, _: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { Ok(()) } } @@ -187,7 +187,7 @@ impl<'de> Deserialize<'de> for Public { #[derive(Encode, Decode, PassByInner)] pub struct Signature(pub [u8; 64]); -impl rstd::convert::TryFrom<&[u8]> for Signature { +impl sp_std::convert::TryFrom<&[u8]> for Signature { type Error = (); fn try_from(data: &[u8]) -> Result { @@ -270,22 +270,22 @@ impl AsMut<[u8]> for Signature { } } -impl rstd::fmt::Debug for Signature { +impl sp_std::fmt::Debug for Signature { #[cfg(feature = "std")] - fn fmt(&self, f: &mut rstd::fmt::Formatter) -> rstd::fmt::Result { + fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { write!(f, "{}", crate::hexdisplay::HexDisplay::from(&self.0)) } #[cfg(not(feature = "std"))] - fn fmt(&self, _: &mut rstd::fmt::Formatter) -> rstd::fmt::Result { + fn fmt(&self, _: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { Ok(()) } } #[cfg(feature = "full_crypto")] -impl rstd::hash::Hash for Signature { - fn hash(&self, state: &mut H) { - rstd::hash::Hash::hash(&self.0[..], state); +impl sp_std::hash::Hash for Signature { + fn hash(&self, state: &mut H) { + sp_std::hash::Hash::hash(&self.0[..], state); } } diff --git a/primitives/core/src/hexdisplay.rs b/primitives/core/src/hexdisplay.rs index 2c8533e25b..104aaf812e 100644 --- a/primitives/core/src/hexdisplay.rs +++ b/primitives/core/src/hexdisplay.rs @@ -24,8 +24,8 @@ impl<'a> HexDisplay<'a> { pub fn from(d: &'a R) -> Self { HexDisplay(d.as_bytes_ref()) } } -impl<'a> rstd::fmt::Display for HexDisplay<'a> { - fn fmt(&self, f: &mut rstd::fmt::Formatter) -> Result<(), rstd::fmt::Error> { +impl<'a> sp_std::fmt::Display for HexDisplay<'a> { + fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> Result<(), sp_std::fmt::Error> { if self.0.len() < 1027 { for byte in self.0 { f.write_fmt(format_args!("{:02x}", byte))?; @@ -43,8 +43,8 @@ impl<'a> rstd::fmt::Display for HexDisplay<'a> { } } -impl<'a> rstd::fmt::Debug for HexDisplay<'a> { - fn fmt(&self, f: &mut rstd::fmt::Formatter) -> Result<(), rstd::fmt::Error> { +impl<'a> sp_std::fmt::Debug for HexDisplay<'a> { + fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> Result<(), sp_std::fmt::Error> { for byte in self.0 { f.write_fmt(format_args!("{:02x}", byte))?; } diff --git a/primitives/core/src/lib.rs b/primitives/core/src/lib.rs index 902cd55b58..888f401243 100644 --- a/primitives/core/src/lib.rs +++ b/primitives/core/src/lib.rs @@ -31,8 +31,8 @@ macro_rules! map { ); } -use rstd::prelude::*; -use rstd::ops::Deref; +use sp_std::prelude::*; +use sp_std::ops::Deref; #[cfg(feature = "std")] use std::borrow::Cow; #[cfg(feature = "std")] @@ -87,7 +87,7 @@ pub use self::hasher::blake2::Blake2Hasher; pub use primitives_storage as storage; #[doc(hidden)] -pub use rstd; +pub use sp_std; /// Context for executing a call into the runtime. pub enum ExecutionContext { @@ -147,7 +147,7 @@ impl OpaqueMetadata { } } -impl rstd::ops::Deref for OpaqueMetadata { +impl sp_std::ops::Deref for OpaqueMetadata { type Target = Vec; fn deref(&self) -> &Self::Target { @@ -165,8 +165,8 @@ pub enum NativeOrEncoded { } #[cfg(feature = "std")] -impl rstd::fmt::Debug for NativeOrEncoded { - fn fmt(&self, f: &mut rstd::fmt::Formatter) -> rstd::fmt::Result { +impl sp_std::fmt::Debug for NativeOrEncoded { + fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { hexdisplay::HexDisplay::from(&self.as_encoded().as_ref()).fmt(f) } } @@ -305,7 +305,7 @@ pub fn to_substrate_wasm_fn_return_value(value: &impl Encode) -> u64 { // Leak the output vector to avoid it being freed. // This is fine in a WASM context since the heap // will be discarded after the call. - rstd::mem::forget(encoded); + sp_std::mem::forget(encoded); res } diff --git a/primitives/core/src/offchain/mod.rs b/primitives/core/src/offchain/mod.rs index 8afabc0392..4b7423c253 100644 --- a/primitives/core/src/offchain/mod.rs +++ b/primitives/core/src/offchain/mod.rs @@ -17,7 +17,7 @@ //! Offchain workers types use codec::{Encode, Decode}; -use rstd::{prelude::{Vec, Box}, convert::TryFrom}; +use sp_std::{prelude::{Vec, Box}, convert::TryFrom}; use crate::RuntimeDebug; use runtime_interface::pass_by::{PassByCodec, PassByInner, PassByEnum}; diff --git a/primitives/core/src/sandbox.rs b/primitives/core/src/sandbox.rs index dd91ad6a1f..cc82b4bd4c 100644 --- a/primitives/core/src/sandbox.rs +++ b/primitives/core/src/sandbox.rs @@ -17,7 +17,7 @@ //! Definition of a sandbox environment. use codec::{Encode, Decode}; -use rstd::vec::Vec; +use sp_std::vec::Vec; /// Error error that can be returned from host function. #[derive(Encode, Decode)] diff --git a/primitives/core/src/sr25519.rs b/primitives/core/src/sr25519.rs index 9521e3bb6c..05b128d288 100644 --- a/primitives/core/src/sr25519.rs +++ b/primitives/core/src/sr25519.rs @@ -21,7 +21,7 @@ //! for this to work. // end::description[] #[cfg(feature = "full_crypto")] -use rstd::vec::Vec; +use sp_std::vec::Vec; #[cfg(feature = "full_crypto")] use schnorrkel::{signing_context, ExpansionMode, Keypair, SecretKey, MiniSecretKey, PublicKey, derive::{Derivation, ChainCode, CHAIN_CODE_LENGTH} @@ -42,7 +42,7 @@ use crate::crypto::Ss58Codec; use crate::{crypto::{Public as TraitPublic, UncheckedFrom, CryptoType, Derive}}; use crate::hash::{H256, H512}; use codec::{Encode, Decode}; -use rstd::ops::Deref; +use sp_std::ops::Deref; #[cfg(feature = "std")] use serde::{de, Deserialize, Deserializer, Serialize, Serializer}; @@ -121,7 +121,7 @@ impl std::str::FromStr for Public { } } -impl rstd::convert::TryFrom<&[u8]> for Public { +impl sp_std::convert::TryFrom<&[u8]> for Public { type Error = (); fn try_from(data: &[u8]) -> Result { @@ -154,15 +154,15 @@ impl std::fmt::Display for Public { } } -impl rstd::fmt::Debug for Public { +impl sp_std::fmt::Debug for Public { #[cfg(feature = "std")] - fn fmt(&self, f: &mut rstd::fmt::Formatter) -> rstd::fmt::Result { + fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { let s = self.to_ss58check(); write!(f, "{} ({}...)", crate::hexdisplay::HexDisplay::from(&self.0), &s[0..8]) } #[cfg(not(feature = "std"))] - fn fmt(&self, _: &mut rstd::fmt::Formatter) -> rstd::fmt::Result { + fn fmt(&self, _: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { Ok(()) } } @@ -188,7 +188,7 @@ impl<'de> Deserialize<'de> for Public { #[derive(Encode, Decode, PassByInner)] pub struct Signature(pub [u8; 64]); -impl rstd::convert::TryFrom<&[u8]> for Signature { +impl sp_std::convert::TryFrom<&[u8]> for Signature { type Error = (); fn try_from(data: &[u8]) -> Result { @@ -278,22 +278,22 @@ impl From for Signature { } } -impl rstd::fmt::Debug for Signature { +impl sp_std::fmt::Debug for Signature { #[cfg(feature = "std")] - fn fmt(&self, f: &mut rstd::fmt::Formatter) -> rstd::fmt::Result { + fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { write!(f, "{}", crate::hexdisplay::HexDisplay::from(&self.0)) } #[cfg(not(feature = "std"))] - fn fmt(&self, _: &mut rstd::fmt::Formatter) -> rstd::fmt::Result { + fn fmt(&self, _: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { Ok(()) } } #[cfg(feature = "full_crypto")] -impl rstd::hash::Hash for Signature { - fn hash(&self, state: &mut H) { - rstd::hash::Hash::hash(&self.0[..], state); +impl sp_std::hash::Hash for Signature { + fn hash(&self, state: &mut H) { + sp_std::hash::Hash::hash(&self.0[..], state); } } diff --git a/primitives/core/src/testing.rs b/primitives/core/src/testing.rs index c87c170d20..b5a8c0aad6 100644 --- a/primitives/core/src/testing.rs +++ b/primitives/core/src/testing.rs @@ -184,7 +184,7 @@ macro_rules! wasm_export_functions { &[0u8; 0] } else { unsafe { - $crate::rstd::slice::from_raw_parts(input_data, input_len) + $crate::sp_std::slice::from_raw_parts(input_data, input_len) } }; @@ -212,7 +212,7 @@ macro_rules! wasm_export_functions { &[0u8; 0] } else { unsafe { - $crate::rstd::slice::from_raw_parts(input_data, input_len) + $crate::sp_std::slice::from_raw_parts(input_data, input_len) } }; diff --git a/primitives/core/storage/Cargo.toml b/primitives/core/storage/Cargo.toml index 243184d038..d124dd47e1 100644 --- a/primitives/core/storage/Cargo.toml +++ b/primitives/core/storage/Cargo.toml @@ -6,11 +6,11 @@ edition = "2018" description = "Storage related primitives" [dependencies] -rstd = { package = "sp-std", path = "../../sr-std", default-features = false } +sp-std = { path = "../../std", default-features = false } serde = { version = "1.0.101", optional = true, features = ["derive"] } impl-serde = { version = "0.2.3", optional = true } sp-debug-derive = { version = "2.0.0", path = "../debug-derive" } [features] default = [ "std" ] -std = [ "rstd/std", "serde", "impl-serde" ] +std = [ "sp-std/std", "serde", "impl-serde" ] diff --git a/primitives/core/storage/src/lib.rs b/primitives/core/storage/src/lib.rs index 3fd883788c..9d10d692e5 100644 --- a/primitives/core/storage/src/lib.rs +++ b/primitives/core/storage/src/lib.rs @@ -22,7 +22,7 @@ use serde::{Serialize, Deserialize}; use sp_debug_derive::RuntimeDebug; -use rstd::{vec::Vec, borrow::Cow}; +use sp_std::{vec::Vec, borrow::Cow}; /// Storage key. #[derive(PartialEq, Eq, RuntimeDebug)] diff --git a/primitives/externalities/Cargo.toml b/primitives/externalities/Cargo.toml index 5b5e8c1ee8..8a89a0be08 100644 --- a/primitives/externalities/Cargo.toml +++ b/primitives/externalities/Cargo.toml @@ -7,5 +7,5 @@ edition = "2018" [dependencies] primitives-storage = { package = "sp-core-storage", path = "../core/storage" } -rstd = { package = "sp-std", path = "../sr-std" } +sp-std = { path = "../std" } environmental = { version = "1.0.2" } diff --git a/primitives/finality-grandpa/Cargo.toml b/primitives/finality-grandpa/Cargo.toml index 78f28b7591..d12b2d9bbf 100644 --- a/primitives/finality-grandpa/Cargo.toml +++ b/primitives/finality-grandpa/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] app-crypto = { package = "sc-application-crypto", path = "../application-crypto", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -rstd = { package = "sp-std", path = "../sr-std", default-features = false } +sp-std = { path = "../std", default-features = false } serde = { version = "1.0.101", optional = true, features = ["derive"] } sp-api = { path = "../sr-api", default-features = false } sp-runtime = { path = "../runtime", default-features = false } @@ -17,7 +17,7 @@ default = ["std"] std = [ "app-crypto/std", "codec/std", - "rstd/std", + "sp-std/std", "serde", "sp-api/std", "sp-runtime/std", diff --git a/primitives/finality-grandpa/src/lib.rs b/primitives/finality-grandpa/src/lib.rs index 0e7ed9926f..ef61092b9c 100644 --- a/primitives/finality-grandpa/src/lib.rs +++ b/primitives/finality-grandpa/src/lib.rs @@ -25,8 +25,8 @@ extern crate alloc; use serde::Serialize; use codec::{Encode, Decode, Input, Codec}; use sp_runtime::{ConsensusEngineId, RuntimeDebug}; -use rstd::borrow::Cow; -use rstd::vec::Vec; +use sp_std::borrow::Cow; +use sp_std::vec::Vec; mod app { use app_crypto::{app_crypto, key_types::GRANDPA, ed25519}; diff --git a/primitives/finality-tracker/Cargo.toml b/primitives/finality-tracker/Cargo.toml index 812596beaa..919fc0bab4 100644 --- a/primitives/finality-tracker/Cargo.toml +++ b/primitives/finality-tracker/Cargo.toml @@ -7,12 +7,12 @@ edition = "2018" [dependencies] codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } inherents = { package = "sp-inherents", path = "../../primitives/inherents", default-features = false } -rstd = { package = "sp-std", path = "../../primitives/sr-std", default-features = false } +sp-std = { path = "../../primitives/std", default-features = false } [features] default = ["std"] std = [ "codec/std", - "rstd/std", + "sp-std/std", "inherents/std", ] diff --git a/primitives/inherents/Cargo.toml b/primitives/inherents/Cargo.toml index 0d33b961ed..d8f67031f9 100644 --- a/primitives/inherents/Cargo.toml +++ b/primitives/inherents/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" [dependencies] parking_lot = { version = "0.9.0", optional = true } -rstd = { package = "sp-std", path = "../sr-std", default-features = false } +sp-std = { path = "../std", default-features = false } primitives = { package = "sp-core", path = "../core", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.6", default-features = false, features = ["derive"] } derive_more = { version = "0.99.2", optional = true } @@ -15,7 +15,7 @@ derive_more = { version = "0.99.2", optional = true } default = [ "std" ] std = [ "parking_lot", - "rstd/std", + "sp-std/std", "codec/std", "primitives/std", "derive_more", diff --git a/primitives/inherents/src/lib.rs b/primitives/inherents/src/lib.rs index b398e43997..8f26a50822 100644 --- a/primitives/inherents/src/lib.rs +++ b/primitives/inherents/src/lib.rs @@ -35,7 +35,7 @@ use codec::{Encode, Decode}; -use rstd::{collections::btree_map::{BTreeMap, IntoIter, Entry}, vec::Vec}; +use sp_std::{collections::btree_map::{BTreeMap, IntoIter, Entry}, vec::Vec}; #[cfg(feature = "std")] use parking_lot::RwLock; diff --git a/primitives/phragmen/Cargo.toml b/primitives/phragmen/Cargo.toml index 06071c79db..656ce8b9b2 100644 --- a/primitives/phragmen/Cargo.toml +++ b/primitives/phragmen/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" [dependencies] serde = { version = "1.0.101", optional = true, features = ["derive"] } -rstd = { package = "sp-std", path = "../sr-std", default-features = false } +sp-std = { path = "../std", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } [dev-dependencies] @@ -18,6 +18,6 @@ rand = "0.7.2" default = ["std"] std = [ "serde", - "rstd/std", + "sp-std/std", "sp-runtime/std", ] diff --git a/primitives/phragmen/src/lib.rs b/primitives/phragmen/src/lib.rs index c5e9d97fc7..a06ef9497b 100644 --- a/primitives/phragmen/src/lib.rs +++ b/primitives/phragmen/src/lib.rs @@ -33,7 +33,7 @@ #![cfg_attr(not(feature = "std"), no_std)] -use rstd::{prelude::*, collections::btree_map::BTreeMap}; +use sp_std::{prelude::*, collections::btree_map::BTreeMap}; use sp_runtime::RuntimeDebug; use sp_runtime::{helpers_128bit::multiply_by_rational, Perbill, Rational128}; use sp_runtime::traits::{Zero, Convert, Member, SimpleArithmetic, Saturating, Bounded}; diff --git a/primitives/phragmen/src/mock.rs b/primitives/phragmen/src/mock.rs index edb0826b06..3074258bbb 100644 --- a/primitives/phragmen/src/mock.rs +++ b/primitives/phragmen/src/mock.rs @@ -23,7 +23,7 @@ use sp_runtime::{ assert_eq_error_rate, Perbill, traits::{Convert, Member, SaturatedConversion} }; -use rstd::collections::btree_map::BTreeMap; +use sp_std::collections::btree_map::BTreeMap; pub(crate) struct TestCurrencyToVote; impl Convert for TestCurrencyToVote { @@ -149,7 +149,7 @@ pub(crate) fn elect_float( if let Some(winner) = candidates .iter_mut() .filter(|c| !c.elected) - .min_by(|x, y| x.score.partial_cmp(&y.score).unwrap_or(rstd::cmp::Ordering::Equal)) + .min_by(|x, y| x.score.partial_cmp(&y.score).unwrap_or(sp_std::cmp::Ordering::Equal)) { winner.elected = true; for n in &mut voters { @@ -250,10 +250,10 @@ pub(crate) fn do_equalize_float( if backing_backed_stake.len() > 0 { let max_stake = backing_backed_stake .iter() - .max_by(|x, y| x.partial_cmp(&y).unwrap_or(rstd::cmp::Ordering::Equal)) + .max_by(|x, y| x.partial_cmp(&y).unwrap_or(sp_std::cmp::Ordering::Equal)) .expect("vector with positive length will have a max; qed"); let min_stake = backed_stakes_iter - .min_by(|x, y| x.partial_cmp(&y).unwrap_or(rstd::cmp::Ordering::Equal)) + .min_by(|x, y| x.partial_cmp(&y).unwrap_or(sp_std::cmp::Ordering::Equal)) .expect("iterator with positive length will have a min; qed"); difference = max_stake - min_stake; @@ -277,7 +277,7 @@ pub(crate) fn do_equalize_float( elected_edges.sort_unstable_by(|x, y| support_map.get(&x.0) .and_then(|x| support_map.get(&y.0).and_then(|y| x.total.partial_cmp(&y.total))) - .unwrap_or(rstd::cmp::Ordering::Equal) + .unwrap_or(sp_std::cmp::Ordering::Equal) ); let mut cumulative_stake = 0.0; diff --git a/primitives/runtime-interface/Cargo.toml b/primitives/runtime-interface/Cargo.toml index e904633565..af0ca7a5f6 100644 --- a/primitives/runtime-interface/Cargo.toml +++ b/primitives/runtime-interface/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" [dependencies] wasm-interface = { package = "sp-wasm-interface", path = "../wasm-interface", optional = true } -rstd = { package = "sp-std", path = "../sr-std", default-features = false } +sp-std = { path = "../std", default-features = false } sp-runtime-interface-proc-macro = { path = "proc-macro" } externalities = { package = "sp-externalities", path = "../externalities", optional = true } codec = { package = "parity-scale-codec", version = "1.0.6", default-features = false } @@ -25,7 +25,7 @@ runtime-io = { package = "sp-io", path = "../sr-io" } default = [ "std" ] std = [ "wasm-interface", - "rstd/std", + "sp-std/std", "codec/std", "externalities", "environmental", diff --git a/primitives/runtime-interface/proc-macro/src/pass_by/enum_.rs b/primitives/runtime-interface/proc-macro/src/pass_by/enum_.rs index ac5e675520..c650a8cb5c 100644 --- a/primitives/runtime-interface/proc-macro/src/pass_by/enum_.rs +++ b/primitives/runtime-interface/proc-macro/src/pass_by/enum_.rs @@ -50,10 +50,10 @@ pub fn derive_impl(input: DeriveInput) -> Result { type PassBy = #crate_::pass_by::Enum<#ident>; } - impl #crate_::rstd::convert::TryFrom for #ident { + impl #crate_::sp_std::convert::TryFrom for #ident { type Error = (); - fn try_from(inner: u8) -> #crate_::rstd::result::Result { + fn try_from(inner: u8) -> #crate_::sp_std::result::Result { match inner { #( #try_from_variants, )* _ => Err(()), diff --git a/primitives/runtime-interface/src/impls.rs b/primitives/runtime-interface/src/impls.rs index c2821ce6ec..0410d15321 100644 --- a/primitives/runtime-interface/src/impls.rs +++ b/primitives/runtime-interface/src/impls.rs @@ -30,13 +30,13 @@ use wasm_interface::{FunctionContext, Result}; use codec::{Encode, Decode}; -use rstd::{any::TypeId, mem, vec::Vec}; +use sp_std::{any::TypeId, mem, vec::Vec}; #[cfg(feature = "std")] -use rstd::borrow::Cow; +use sp_std::borrow::Cow; #[cfg(not(feature = "std"))] -use rstd::{slice, boxed::Box}; +use sp_std::{slice, boxed::Box}; // Make sure that our assumptions for storing a pointer + its size in `u64` is valid. #[cfg(all(not(feature = "std"), not(feature = "disable_target_static_assertions")))] @@ -48,7 +48,7 @@ assert_eq_size!(*const u8, u32); pub fn pointer_and_len_to_u64(ptr: u32, len: u32) -> u64 { // The static assertions from above are changed into a runtime check. #[cfg(all(not(feature = "std"), feature = "disable_target_static_assertions"))] - assert_eq!(4, rstd::mem::size_of::()); + assert_eq!(4, sp_std::mem::size_of::()); (u64::from(len) << 32) | u64::from(ptr) } @@ -57,7 +57,7 @@ pub fn pointer_and_len_to_u64(ptr: u32, len: u32) -> u64 { pub fn pointer_and_len_from_u64(val: u64) -> (u32, u32) { // The static assertions from above are changed into a runtime check. #[cfg(all(not(feature = "std"), feature = "disable_target_static_assertions"))] - assert_eq!(4, rstd::mem::size_of::()); + assert_eq!(4, sp_std::mem::size_of::()); let ptr = (val & (!0u32 as u64)) as u32; let len = (val >> 32) as u32; @@ -373,7 +373,7 @@ impl_traits_for_arrays! { 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, } -impl PassBy for rstd::result::Result { +impl PassBy for sp_std::result::Result { type PassBy = Codec; } diff --git a/primitives/runtime-interface/src/lib.rs b/primitives/runtime-interface/src/lib.rs index c6b006f4e6..bce5dbfec2 100644 --- a/primitives/runtime-interface/src/lib.rs +++ b/primitives/runtime-interface/src/lib.rs @@ -77,7 +77,7 @@ pub use wasm_interface; #[doc(hidden)] -pub use rstd; +pub use sp_std; pub use sp_runtime_interface_proc_macro::runtime_interface; diff --git a/primitives/runtime-interface/src/pass_by.rs b/primitives/runtime-interface/src/pass_by.rs index 3fcf04b1c4..96cd6314ba 100644 --- a/primitives/runtime-interface/src/pass_by.rs +++ b/primitives/runtime-interface/src/pass_by.rs @@ -30,10 +30,10 @@ use crate::wasm::*; #[cfg(feature = "std")] use wasm_interface::{FunctionContext, Pointer, Result}; -use rstd::{marker::PhantomData, convert::TryFrom}; +use sp_std::{marker::PhantomData, convert::TryFrom}; #[cfg(not(feature = "std"))] -use rstd::{slice, vec::Vec}; +use sp_std::{slice, vec::Vec}; pub use sp_runtime_interface_proc_macro::{PassByCodec, PassByInner, PassByEnum}; diff --git a/primitives/runtime-interface/src/wasm.rs b/primitives/runtime-interface/src/wasm.rs index 7ac890a3ca..508f0c4f26 100644 --- a/primitives/runtime-interface/src/wasm.rs +++ b/primitives/runtime-interface/src/wasm.rs @@ -18,7 +18,7 @@ use crate::RIType; -use rstd::cell::Cell; +use sp_std::cell::Cell; /// Something that can be created from a ffi value. /// diff --git a/primitives/runtime-interface/test-wasm/Cargo.toml b/primitives/runtime-interface/test-wasm/Cargo.toml index 4df59d03b0..0d9288de05 100644 --- a/primitives/runtime-interface/test-wasm/Cargo.toml +++ b/primitives/runtime-interface/test-wasm/Cargo.toml @@ -7,7 +7,7 @@ build = "build.rs" [dependencies] runtime-interface = { package = "sp-runtime-interface", path = "../", default-features = false } -rstd = { package = "sp-std", path = "../../sr-std", default-features = false } +sp-std = { path = "../../std", default-features = false } runtime-io = { package = "sp-io", path = "../../sr-io", default-features = false } primitives = { package = "sp-core", path = "../../core", default-features = false } @@ -16,4 +16,4 @@ wasm-builder-runner = { package = "substrate-wasm-builder-runner", version = "1. [features] default = [ "std" ] -std = [ "runtime-interface/std", "rstd/std", "primitives/std", "runtime-io/std" ] +std = [ "runtime-interface/std", "sp-std/std", "primitives/std", "runtime-io/std" ] diff --git a/primitives/runtime-interface/test-wasm/src/lib.rs b/primitives/runtime-interface/test-wasm/src/lib.rs index d61315c521..93e9f5b29b 100644 --- a/primitives/runtime-interface/test-wasm/src/lib.rs +++ b/primitives/runtime-interface/test-wasm/src/lib.rs @@ -21,7 +21,7 @@ use runtime_interface::runtime_interface; #[cfg(not(feature = "std"))] -use rstd::{vec, vec::Vec, mem, convert::TryFrom}; +use sp_std::{vec, vec::Vec, mem, convert::TryFrom}; use primitives::{sr25519::Public, wasm_export_functions}; @@ -95,8 +95,8 @@ extern "C" { /// Make sure the old runtime interface needs to be imported. #[no_mangle] pub fn force_old_runtime_interface_import() { - unsafe { ext_clear_storage(rstd::ptr::null(), 0); } - unsafe { ext_keccak_256(rstd::ptr::null(), 0, rstd::ptr::null_mut()); } + unsafe { ext_clear_storage(sp_std::ptr::null(), 0); } + 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`. @@ -173,7 +173,7 @@ wasm_export_functions! { fn test_invalid_utf8_data_should_return_an_error() { let data = vec![0, 159, 146, 150]; // I'm an evil hacker, trying to hack! - let data_str = unsafe { rstd::str::from_utf8_unchecked(&data) }; + let data_str = unsafe { sp_std::str::from_utf8_unchecked(&data) }; test_api::invalid_utf8_data(data_str); } diff --git a/primitives/runtime/Cargo.toml b/primitives/runtime/Cargo.toml index bfec26f0cc..8c855d7bb0 100644 --- a/primitives/runtime/Cargo.toml +++ b/primitives/runtime/Cargo.toml @@ -10,7 +10,7 @@ codec = { package = "parity-scale-codec", version = "1.0.0", default-features = 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 } -rstd = { package = "sp-std", path = "../sr-std", default-features = false } +sp-std = { path = "../std", default-features = false } runtime_io = { package = "sp-io", path = "../sr-io", default-features = false } log = { version = "0.4.8", optional = true } paste = "0.1.6" @@ -32,7 +32,7 @@ std = [ "log", "primitives/std", "rand", - "rstd/std", + "sp-std/std", "runtime_io/std", "serde", "inherents/std", diff --git a/primitives/runtime/src/generic/block.rs b/primitives/runtime/src/generic/block.rs index 3383e25760..12b2f82eac 100644 --- a/primitives/runtime/src/generic/block.rs +++ b/primitives/runtime/src/generic/block.rs @@ -22,7 +22,7 @@ use std::fmt; #[cfg(feature = "std")] use serde::{Deserialize, Serialize}; -use rstd::prelude::*; +use sp_std::prelude::*; use primitives::RuntimeDebug; use crate::codec::{Codec, Encode, Decode}; use crate::traits::{self, Member, Block as BlockT, Header as HeaderT, MaybeSerialize}; diff --git a/primitives/runtime/src/generic/digest.rs b/primitives/runtime/src/generic/digest.rs index 83f2c6f174..c74d09076b 100644 --- a/primitives/runtime/src/generic/digest.rs +++ b/primitives/runtime/src/generic/digest.rs @@ -19,7 +19,7 @@ #[cfg(feature = "std")] use serde::{Deserialize, Serialize}; -use rstd::prelude::*; +use sp_std::prelude::*; use crate::ConsensusEngineId; use crate::codec::{Decode, Encode, Input, Error}; diff --git a/primitives/runtime/src/generic/header.rs b/primitives/runtime/src/generic/header.rs index 75994749c5..aa47966956 100644 --- a/primitives/runtime/src/generic/header.rs +++ b/primitives/runtime/src/generic/header.rs @@ -25,7 +25,7 @@ use crate::traits::{ }; use crate::generic::Digest; use primitives::U256; -use rstd::{ +use sp_std::{ convert::TryFrom, fmt::Debug, }; @@ -104,10 +104,10 @@ impl codec::EncodeLike for Header where {} impl traits::Header for Header where - Number: Member + MaybeSerializeDeserialize + Debug + rstd::hash::Hash + MaybeDisplay + + Number: Member + MaybeSerializeDeserialize + Debug + sp_std::hash::Hash + MaybeDisplay + SimpleArithmetic + Codec + Copy + Into + TryFrom, Hash: HashT, - Hash::Output: Default + rstd::hash::Hash + Copy + Member + + Hash::Output: Default + sp_std::hash::Hash + Copy + Member + MaybeSerialize + Debug + MaybeDisplay + SimpleBitOps + Codec, { type Number = Number; @@ -152,9 +152,9 @@ impl traits::Header for Header where } impl Header where - Number: Member + rstd::hash::Hash + Copy + MaybeDisplay + SimpleArithmetic + Codec + Into + TryFrom, + Number: Member + sp_std::hash::Hash + Copy + MaybeDisplay + SimpleArithmetic + Codec + Into + TryFrom, Hash: HashT, - Hash::Output: Default + rstd::hash::Hash + Copy + Member + MaybeDisplay + SimpleBitOps + Codec, + Hash::Output: Default + sp_std::hash::Hash + Copy + Member + MaybeDisplay + SimpleBitOps + Codec, { /// Convenience helper for computing the hash of the header without having /// to import the trait. diff --git a/primitives/runtime/src/generic/mod.rs b/primitives/runtime/src/generic/mod.rs index 0138a15aee..79e0d912b9 100644 --- a/primitives/runtime/src/generic/mod.rs +++ b/primitives/runtime/src/generic/mod.rs @@ -37,10 +37,10 @@ pub use self::digest::{ }; use crate::codec::Encode; -use rstd::prelude::*; +use sp_std::prelude::*; fn encode_with_vec_prefix)>(encoder: F) -> Vec { - let size = ::rstd::mem::size_of::(); + let size = ::sp_std::mem::size_of::(); let reserve = match size { 0..=0b00111111 => 1, 0..=0b00111111_11111111 => 2, diff --git a/primitives/runtime/src/generic/unchecked_extrinsic.rs b/primitives/runtime/src/generic/unchecked_extrinsic.rs index e2bda54a31..a018dedf2a 100644 --- a/primitives/runtime/src/generic/unchecked_extrinsic.rs +++ b/primitives/runtime/src/generic/unchecked_extrinsic.rs @@ -16,7 +16,7 @@ //! Generic implementation of an unchecked (pre-verification) extrinsic. -use rstd::{fmt, prelude::*}; +use sp_std::{fmt, prelude::*}; use runtime_io::hashing::blake2_256; use codec::{Decode, Encode, EncodeLike, Input, Error}; use crate::{ @@ -322,7 +322,7 @@ mod tests { type DispatchInfo = (); type Pre = (); - fn additional_signed(&self) -> rstd::result::Result<(), TransactionValidityError> { Ok(()) } + fn additional_signed(&self) -> sp_std::result::Result<(), TransactionValidityError> { Ok(()) } } type Ex = UncheckedExtrinsic; diff --git a/primitives/runtime/src/lib.rs b/primitives/runtime/src/lib.rs index 20fdd083db..c4433b9076 100644 --- a/primitives/runtime/src/lib.rs +++ b/primitives/runtime/src/lib.rs @@ -29,7 +29,7 @@ pub use codec; #[doc(hidden)] pub use serde; #[doc(hidden)] -pub use rstd; +pub use sp_std; #[doc(hidden)] pub use paste; @@ -40,8 +40,8 @@ pub use app_crypto; #[cfg(feature = "std")] pub use primitives::storage::{StorageOverlay, ChildrenStorageOverlay}; -use rstd::prelude::*; -use rstd::convert::TryFrom; +use sp_std::prelude::*; +use sp_std::convert::TryFrom; use primitives::{crypto, ed25519, sr25519, ecdsa, hash::{H256, H512}}; use codec::{Encode, Decode}; @@ -613,14 +613,14 @@ macro_rules! assert_eq_error_rate { #[derive(PartialEq, Eq, Clone, Default, Encode, Decode)] pub struct OpaqueExtrinsic(pub Vec); -impl rstd::fmt::Debug for OpaqueExtrinsic { +impl sp_std::fmt::Debug for OpaqueExtrinsic { #[cfg(feature = "std")] - fn fmt(&self, fmt: &mut rstd::fmt::Formatter) -> rstd::fmt::Result { + fn fmt(&self, fmt: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { write!(fmt, "{}", primitives::hexdisplay::HexDisplay::from(&self.0)) } #[cfg(not(feature = "std"))] - fn fmt(&self, _fmt: &mut rstd::fmt::Formatter) -> rstd::fmt::Result { + fn fmt(&self, _fmt: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { Ok(()) } } diff --git a/primitives/runtime/src/offchain/http.rs b/primitives/runtime/src/offchain/http.rs index 88df90893b..8fc6ac025c 100644 --- a/primitives/runtime/src/offchain/http.rs +++ b/primitives/runtime/src/offchain/http.rs @@ -47,10 +47,10 @@ //! assert_eq!(body.error(), &None); //! ``` -use rstd::str; -use rstd::prelude::Vec; +use sp_std::str; +use sp_std::prelude::Vec; #[cfg(not(feature = "std"))] -use rstd::prelude::vec; +use sp_std::prelude::vec; use primitives::RuntimeDebug; use primitives::offchain::{ Timestamp, @@ -111,7 +111,7 @@ mod header { /// Returns the name of this header. pub fn name(&self) -> &str { // Header keys are always produced from `&str` so this is safe. - // we don't store them as `Strings` to avoid bringing `alloc::String` to rstd + // we don't store them as `Strings` to avoid bringing `alloc::String` to sp-std // or here. unsafe { str::from_utf8_unchecked(&self.name) } } @@ -119,7 +119,7 @@ mod header { /// Returns the value of this header. pub fn value(&self) -> &str { // Header values are always produced from `&str` so this is safe. - // we don't store them as `Strings` to avoid bringing `alloc::String` to rstd + // we don't store them as `Strings` to avoid bringing `alloc::String` to sp-std // or here. unsafe { str::from_utf8_unchecked(&self.value) } } diff --git a/primitives/runtime/src/traits.rs b/primitives/runtime/src/traits.rs index 5400c5d3af..a18783782a 100644 --- a/primitives/runtime/src/traits.rs +++ b/primitives/runtime/src/traits.rs @@ -16,8 +16,8 @@ //! Primitives for the runtime modules. -use rstd::prelude::*; -use rstd::{self, result, marker::PhantomData, convert::{TryFrom, TryInto}, fmt::Debug}; +use sp_std::prelude::*; +use sp_std::{self, result, marker::PhantomData, convert::{TryFrom, TryInto}, fmt::Debug}; use runtime_io; #[cfg(feature = "std")] use std::fmt::Display; @@ -316,15 +316,15 @@ impl Clear for T { /// A meta trait for all bit ops. pub trait SimpleBitOps: Sized + Clear + - rstd::ops::BitOr + - rstd::ops::BitXor + - rstd::ops::BitAnd + sp_std::ops::BitOr + + sp_std::ops::BitXor + + sp_std::ops::BitAnd {} impl + - rstd::ops::BitXor + - rstd::ops::BitAnd + sp_std::ops::BitOr + + sp_std::ops::BitXor + + sp_std::ops::BitAnd > SimpleBitOps for T {} /// The block finalization trait. Implementing this lets you express what should happen @@ -369,7 +369,7 @@ pub trait OffchainWorker { // traits must be fulfilled by all type parameters. pub trait Hash: 'static + MaybeSerializeDeserialize + Debug + Clone + Eq + PartialEq { /// The hash type produced. - type Output: Member + MaybeSerializeDeserialize + Debug + rstd::hash::Hash + type Output: Member + MaybeSerializeDeserialize + Debug + sp_std::hash::Hash + AsRef<[u8]> + AsMut<[u8]> + Copy + Default + Encode + Decode; /// The associated hash_db Hasher type. @@ -481,7 +481,7 @@ impl_maybe_marker!( MaybeDisplay: Display; /// A type that implements Hash when in std environment. - MaybeHash: rstd::hash::Hash; + MaybeHash: sp_std::hash::Hash; /// A type that implements Serialize when in std environment. MaybeSerialize: Serialize; @@ -523,10 +523,10 @@ pub trait IsMember { /// You can also create a `new` one from those fields. pub trait Header: Clone + Send + Sync + Codec + Eq + MaybeSerialize + Debug + 'static { /// Header number. - type Number: Member + MaybeSerializeDeserialize + Debug + rstd::hash::Hash + type Number: Member + MaybeSerializeDeserialize + Debug + sp_std::hash::Hash + Copy + MaybeDisplay + SimpleArithmetic + Codec; /// Header hash type - type Hash: Member + MaybeSerializeDeserialize + Debug + rstd::hash::Hash + type Hash: Member + MaybeSerializeDeserialize + Debug + sp_std::hash::Hash + Copy + MaybeDisplay + Default + SimpleBitOps + Codec + AsRef<[u8]> + AsMut<[u8]>; /// Hashing algorithm type Hashing: Hash; @@ -581,7 +581,7 @@ pub trait Block: Clone + Send + Sync + Codec + Eq + MaybeSerialize + Debug + 'st /// Header type. type Header: Header; /// Block hash type. - type Hash: Member + MaybeSerializeDeserialize + Debug + rstd::hash::Hash + type Hash: Member + MaybeSerializeDeserialize + Debug + sp_std::hash::Hash + Copy + MaybeDisplay + Default + SimpleBitOps + Codec + AsRef<[u8]> + AsMut<[u8]>; /// Returns a reference to the header. @@ -865,7 +865,7 @@ impl SignedExtension for () { type Call = (); type Pre = (); type DispatchInfo = (); - fn additional_signed(&self) -> rstd::result::Result<(), TransactionValidityError> { Ok(()) } + fn additional_signed(&self) -> sp_std::result::Result<(), TransactionValidityError> { Ok(()) } } /// An "executable" piece of information, used by the standard Substrate Executive in order to @@ -906,7 +906,7 @@ pub trait Applyable: Sized + Send + Sync { } /// Auxiliary wrapper that holds an api instance and binds it to the given lifetime. -pub struct ApiRef<'a, T>(T, rstd::marker::PhantomData<&'a ()>); +pub struct ApiRef<'a, T>(T, sp_std::marker::PhantomData<&'a ()>); impl<'a, T> From for ApiRef<'a, T> { fn from(api: T) -> Self { @@ -914,7 +914,7 @@ impl<'a, T> From for ApiRef<'a, T> { } } -impl<'a, T> rstd::ops::Deref for ApiRef<'a, T> { +impl<'a, T> sp_std::ops::Deref for ApiRef<'a, T> { type Target = T; fn deref(&self) -> &Self::Target { @@ -922,7 +922,7 @@ impl<'a, T> rstd::ops::Deref for ApiRef<'a, T> { } } -impl<'a, T> rstd::ops::DerefMut for ApiRef<'a, T> { +impl<'a, T> sp_std::ops::DerefMut for ApiRef<'a, T> { fn deref_mut(&mut self) -> &mut T { &mut self.0 } @@ -1161,7 +1161,7 @@ macro_rules! impl_opaque_keys { /// The generated key pairs are stored in the keystore. /// /// Returns the concatenated SCALE encoded public keys. - pub fn generate(seed: Option<$crate::rstd::vec::Vec>) -> $crate::rstd::vec::Vec { + pub fn generate(seed: Option<$crate::sp_std::vec::Vec>) -> $crate::sp_std::vec::Vec { let keys = Self{ $( $field: < diff --git a/primitives/runtime/src/transaction_validity.rs b/primitives/runtime/src/transaction_validity.rs index be9a1d0fd9..b08455aab6 100644 --- a/primitives/runtime/src/transaction_validity.rs +++ b/primitives/runtime/src/transaction_validity.rs @@ -16,7 +16,7 @@ //! Transaction validity interface. -use rstd::prelude::*; +use sp_std::prelude::*; use crate::codec::{Encode, Decode}; use crate::RuntimeDebug; diff --git a/primitives/session/Cargo.toml b/primitives/session/Cargo.toml index 4feda93487..ab37c021ec 100644 --- a/primitives/session/Cargo.toml +++ b/primitives/session/Cargo.toml @@ -6,9 +6,9 @@ edition = "2018" [dependencies] sp-api = { path = "../sr-api", default-features = false } -rstd = { package = "sp-std", path = "../sr-std", default-features = false } +sp-std = { path = "../std", default-features = false } sp-runtime = { path = "../runtime", optional = true } [features] default = [ "std" ] -std = [ "sp-api/std", "rstd/std", "sp-runtime" ] +std = [ "sp-api/std", "sp-std/std", "sp-runtime" ] diff --git a/primitives/session/src/lib.rs b/primitives/session/src/lib.rs index 2c4b118d5b..f6be084a67 100644 --- a/primitives/session/src/lib.rs +++ b/primitives/session/src/lib.rs @@ -18,7 +18,7 @@ #![cfg_attr(not(feature = "std"), no_std)] -use rstd::vec::Vec; +use sp_std::vec::Vec; #[cfg(feature = "std")] use sp_runtime::{generic::BlockId, traits::{ProvideRuntimeApi, Block as BlockT}}; diff --git a/primitives/sr-api/Cargo.toml b/primitives/sr-api/Cargo.toml index 608d9e30dd..c56f936a6b 100644 --- a/primitives/sr-api/Cargo.toml +++ b/primitives/sr-api/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } sp-api-proc-macro = { path = "proc-macro" } primitives = { package = "sp-core", path = "../core", default-features = false } -rstd = { package = "sp-std", path = "../sr-std", default-features = false } +sp-std = { path = "../std", default-features = false } sp-runtime = { path = "../runtime", default-features = false } sp-version = { path = "../sr-version", default-features = false } state-machine = { package = "sp-state-machine", path = "../../primitives/state-machine", optional = true } @@ -26,7 +26,7 @@ default = [ "std" ] std = [ "codec/std", "primitives/std", - "rstd/std", + "sp-std/std", "sp-runtime/std", "state-machine", "sp-version/std", diff --git a/primitives/sr-api/src/lib.rs b/primitives/sr-api/src/lib.rs index edbf567ea6..47f5b1489b 100644 --- a/primitives/sr-api/src/lib.rs +++ b/primitives/sr-api/src/lib.rs @@ -52,9 +52,9 @@ pub use primitives::{offchain, ExecutionContext}; #[doc(hidden)] pub use sp_version::{ApiId, RuntimeVersion, ApisVec, create_apis_vec}; #[doc(hidden)] -pub use rstd::{slice, mem}; +pub use sp_std::{slice, mem}; #[cfg(feature = "std")] -use rstd::result; +use sp_std::result; #[doc(hidden)] pub use codec::{Encode, Decode}; use primitives::OpaqueMetadata; diff --git a/primitives/sr-arithmetic/Cargo.toml b/primitives/sr-arithmetic/Cargo.toml index 84137a8f5a..7b6b8cc64c 100644 --- a/primitives/sr-arithmetic/Cargo.toml +++ b/primitives/sr-arithmetic/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } integer-sqrt = "0.1.2" num-traits = { version = "0.2.8", default-features = false } -rstd = { package = "sp-std", path = "../sr-std", default-features = false } +sp-std = { path = "../std", default-features = false } serde = { version = "1.0.101", optional = true, features = ["derive"] } sp-debug-derive = { path = "../../primitives/core/debug-derive", default-features = false } @@ -22,7 +22,7 @@ default = ["std"] std = [ "codec/std", "num-traits/std", - "rstd/std", + "sp-std/std", "serde", "sp-debug-derive/std", ] diff --git a/primitives/sr-arithmetic/fuzzer/Cargo.lock b/primitives/sr-arithmetic/fuzzer/Cargo.lock index 83fcd3db3d..de8a764f1f 100644 --- a/primitives/sr-arithmetic/fuzzer/Cargo.lock +++ b/primitives/sr-arithmetic/fuzzer/Cargo.lock @@ -285,39 +285,30 @@ dependencies = [ ] [[package]] -name = "sr-arithmetic" +name = "sp-arithmetic" version = "2.0.0" dependencies = [ "integer-sqrt 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-std 2.0.0", - "substrate-debug-derive 2.0.0", + "sp-debug-derive 2.0.0", + "sp-std 2.0.0", ] [[package]] -name = "sr-arithmetic-fuzzer" +name = "sp-arithmetic-fuzzer" version = "2.0.0" dependencies = [ "honggfuzz 0.5.45 (registry+https://github.com/rust-lang/crates.io-index)", "num-bigint 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "primitive-types 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "sr-arithmetic 2.0.0", + "sp-arithmetic 2.0.0", ] [[package]] -name = "sr-std" -version = "2.0.0" - -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "substrate-debug-derive" +name = "sp-debug-derive" version = "2.0.0" dependencies = [ "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -325,6 +316,15 @@ dependencies = [ "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "sp-std" +version = "2.0.0" + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "syn" version = "0.15.44" diff --git a/primitives/sr-arithmetic/src/biguint.rs b/primitives/sr-arithmetic/src/biguint.rs index 1a701a5ebd..9d69ccad81 100644 --- a/primitives/sr-arithmetic/src/biguint.rs +++ b/primitives/sr-arithmetic/src/biguint.rs @@ -17,7 +17,7 @@ //! Infinite precision unsigned integer for substrate runtime. use num_traits::Zero; -use rstd::{cmp::Ordering, ops, prelude::*, cell::RefCell, convert::TryFrom}; +use sp_std::{cmp::Ordering, ops, prelude::*, cell::RefCell, convert::TryFrom}; // A sensible value for this would be half of the dword size of the host machine. Since the // runtime is compiled to 32bit webassembly, using 32 and 64 for single and double respectively @@ -427,9 +427,9 @@ impl BigUint { } } -impl rstd::fmt::Debug for BigUint { +impl sp_std::fmt::Debug for BigUint { #[cfg(feature = "std")] - fn fmt(&self, f: &mut rstd::fmt::Formatter<'_>) -> rstd::fmt::Result { + fn fmt(&self, f: &mut sp_std::fmt::Formatter<'_>) -> sp_std::fmt::Result { write!( f, "BigUint {{ {:?} ({:?})}}", @@ -439,7 +439,7 @@ impl rstd::fmt::Debug for BigUint { } #[cfg(not(feature = "std"))] - fn fmt(&self, _: &mut rstd::fmt::Formatter<'_>) -> rstd::fmt::Result { + fn fmt(&self, _: &mut sp_std::fmt::Formatter<'_>) -> sp_std::fmt::Result { Ok(()) } @@ -646,7 +646,7 @@ pub mod tests { #[test] fn can_try_build_numbers_from_types() { - use rstd::convert::TryFrom; + use sp_std::convert::TryFrom; assert_eq!(u64::try_from(with_limbs(1)).unwrap(), 1); assert_eq!(u64::try_from(with_limbs(2)).unwrap(), u32::max_value() as u64 + 2); assert_eq!( diff --git a/primitives/sr-arithmetic/src/fixed64.rs b/primitives/sr-arithmetic/src/fixed64.rs index 5c68cc5529..6f906b0b29 100644 --- a/primitives/sr-arithmetic/src/fixed64.rs +++ b/primitives/sr-arithmetic/src/fixed64.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Substrate. If not, see . -use rstd::{ +use sp_std::{ ops, prelude::*, convert::{TryFrom, TryInto}, }; @@ -179,14 +179,14 @@ impl CheckedDiv for Fixed64 { } } -impl rstd::fmt::Debug for Fixed64 { +impl sp_std::fmt::Debug for Fixed64 { #[cfg(feature = "std")] - fn fmt(&self, f: &mut rstd::fmt::Formatter) -> rstd::fmt::Result { + fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { write!(f, "Fixed64({},{})", self.0 / DIV, (self.0 % DIV) / 1000) } #[cfg(not(feature = "std"))] - fn fmt(&self, _: &mut rstd::fmt::Formatter) -> rstd::fmt::Result { + fn fmt(&self, _: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { Ok(()) } } diff --git a/primitives/sr-arithmetic/src/helpers_128bit.rs b/primitives/sr-arithmetic/src/helpers_128bit.rs index 10cc94ae77..475d802f3f 100644 --- a/primitives/sr-arithmetic/src/helpers_128bit.rs +++ b/primitives/sr-arithmetic/src/helpers_128bit.rs @@ -21,7 +21,7 @@ use crate::biguint; use num_traits::Zero; -use rstd::{cmp::{min, max}, convert::TryInto, mem}; +use sp_std::{cmp::{min, max}, convert::TryInto, mem}; /// Helper gcd function used in Rational128 implementation. pub fn gcd(a: u128, b: u128) -> u128 { diff --git a/primitives/sr-arithmetic/src/per_things.rs b/primitives/sr-arithmetic/src/per_things.rs index 4ab7f2f25a..47dfc98f3b 100644 --- a/primitives/sr-arithmetic/src/per_things.rs +++ b/primitives/sr-arithmetic/src/per_things.rs @@ -17,7 +17,7 @@ #[cfg(feature = "std")] use serde::{Serialize, Deserialize}; -use rstd::{ops, prelude::*, convert::TryInto}; +use sp_std::{ops, prelude::*, convert::TryInto}; use codec::{Encode, Decode, CompactAs}; use crate::traits::{SaturatedConversion, UniqueSaturatedInto, Saturating}; use sp_debug_derive::RuntimeDebug; diff --git a/primitives/sr-arithmetic/src/rational128.rs b/primitives/sr-arithmetic/src/rational128.rs index 124d685a4f..a747be84a8 100644 --- a/primitives/sr-arithmetic/src/rational128.rs +++ b/primitives/sr-arithmetic/src/rational128.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Substrate. If not, see . -use rstd::{cmp::Ordering, prelude::*}; +use sp_std::{cmp::Ordering, prelude::*}; use crate::helpers_128bit; use num_traits::Zero; use sp_debug_derive::RuntimeDebug; diff --git a/primitives/sr-arithmetic/src/traits.rs b/primitives/sr-arithmetic/src/traits.rs index d02425066f..d8a46ffd30 100644 --- a/primitives/sr-arithmetic/src/traits.rs +++ b/primitives/sr-arithmetic/src/traits.rs @@ -16,14 +16,14 @@ //! Primitives for the runtime modules. -use rstd::{self, convert::{TryFrom, TryInto}}; +use sp_std::{self, convert::{TryFrom, TryInto}}; use codec::HasCompact; pub use integer_sqrt::IntegerSquareRoot; pub use num_traits::{ Zero, One, Bounded, CheckedAdd, CheckedSub, CheckedMul, CheckedDiv, CheckedShl, CheckedShr }; -use rstd::ops::{ +use sp_std::ops::{ Add, Sub, Mul, Div, Rem, AddAssign, SubAssign, MulAssign, DivAssign, RemAssign, Shl, Shr }; diff --git a/primitives/sr-io/Cargo.toml b/primitives/sr-io/Cargo.toml index 79d25f2d96..b124ef7843 100644 --- a/primitives/sr-io/Cargo.toml +++ b/primitives/sr-io/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" codec = { package = "parity-scale-codec", version = "1.0.6", default-features = false } hash-db = { version = "0.15.2", default-features = false } primitives = { package = "sp-core", path = "../core", default-features = false } -rstd = { package = "sp-std", path = "../sr-std", default-features = false } +sp-std = { path = "../std", default-features = false } libsecp256k1 = { version = "0.3.0", optional = true } sp-state-machine = { path = "../../primitives/state-machine", optional = true } runtime-interface = { package = "sp-runtime-interface", path = "../runtime-interface", default-features = false } @@ -21,7 +21,7 @@ default = ["std"] std = [ "primitives/std", "codec/std", - "rstd/std", + "sp-std/std", "hash-db/std", "trie", "sp-state-machine", diff --git a/primitives/sr-io/src/lib.rs b/primitives/sr-io/src/lib.rs index 7fdab1ab3b..ad92b01964 100644 --- a/primitives/sr-io/src/lib.rs +++ b/primitives/sr-io/src/lib.rs @@ -28,10 +28,10 @@ #![cfg_attr(not(feature = "std"), doc = "Substrate's runtime standard library as compiled without Rust's standard library.")] -use rstd::vec::Vec; +use sp_std::vec::Vec; #[cfg(feature = "std")] -use rstd::ops::Deref; +use sp_std::ops::Deref; #[cfg(feature = "std")] use primitives::{ @@ -775,7 +775,7 @@ mod allocator_impl { #[no_mangle] pub fn panic(info: &core::panic::PanicInfo) -> ! { unsafe { - let message = rstd::alloc::format!("{}", info); + let message = sp_std::alloc::format!("{}", info); logging::log(LogLevel::Error, "runtime", message.as_bytes()); core::intrinsics::abort() } diff --git a/primitives/sr-sandbox/Cargo.toml b/primitives/sr-sandbox/Cargo.toml index 0380f5b591..4cd946ef66 100755 --- a/primitives/sr-sandbox/Cargo.toml +++ b/primitives/sr-sandbox/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] wasmi = { version = "0.6.2", optional = true } primitives = { package = "sp-core", path = "../core", default-features = false } -rstd = { package = "sp-std", path = "../sr-std", default-features = false } +sp-std = { path = "../std", default-features = false } runtime-io = { package = "sp-io", path = "../sr-io", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } @@ -20,7 +20,7 @@ default = ["std"] std = [ "wasmi", "primitives/std", - "rstd/std", + "sp-std/std", "codec/std", "runtime-io/std", ] diff --git a/primitives/sr-sandbox/src/lib.rs b/primitives/sr-sandbox/src/lib.rs index 17b2cb7c1e..a006655c78 100755 --- a/primitives/sr-sandbox/src/lib.rs +++ b/primitives/sr-sandbox/src/lib.rs @@ -38,7 +38,7 @@ #![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), feature(core_intrinsics))] -use rstd::prelude::*; +use sp_std::prelude::*; pub use primitives::sandbox::{TypedValue, ReturnValue, HostError}; diff --git a/primitives/sr-sandbox/with_std.rs b/primitives/sr-sandbox/with_std.rs index afc092686e..dacaa3a198 100755 --- a/primitives/sr-sandbox/with_std.rs +++ b/primitives/sr-sandbox/with_std.rs @@ -14,8 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Substrate. If not, see . -use rstd::collections::btree_map::BTreeMap; -use rstd::fmt; +use sp_std::collections::btree_map::BTreeMap; +use sp_std::fmt; use wasmi::{ Externals, FuncInstance, FuncRef, GlobalDescriptor, GlobalRef, ImportResolver, diff --git a/primitives/sr-sandbox/without_std.rs b/primitives/sr-sandbox/without_std.rs index d7fffbf88b..fb3267a91c 100755 --- a/primitives/sr-sandbox/without_std.rs +++ b/primitives/sr-sandbox/without_std.rs @@ -14,14 +14,14 @@ // You should have received a copy of the GNU General Public License // along with Substrate. If not, see . -use rstd::{prelude::*, slice, marker, mem, vec, rc::Rc}; +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; mod ffi { - use rstd::mem; + use sp_std::mem; use super::HostFuncType; /// Index into the default table that points to a `HostFuncType`. diff --git a/primitives/sr-staking-primitives/Cargo.toml b/primitives/sr-staking-primitives/Cargo.toml index 671df45a56..2cac41bd40 100644 --- a/primitives/sr-staking-primitives/Cargo.toml +++ b/primitives/sr-staking-primitives/Cargo.toml @@ -7,12 +7,12 @@ edition = "2018" [dependencies] codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } sp-runtime = { path = "../runtime", default-features = false } -rstd = { package = "sp-std", path = "../sr-std", default-features = false } +sp-std = { path = "../std", default-features = false } [features] default = ["std"] std = [ "codec/std", "sp-runtime/std", - "rstd/std", + "sp-std/std", ] diff --git a/primitives/sr-staking-primitives/src/offence.rs b/primitives/sr-staking-primitives/src/offence.rs index 9a3eb1bbfe..33170193ec 100644 --- a/primitives/sr-staking-primitives/src/offence.rs +++ b/primitives/sr-staking-primitives/src/offence.rs @@ -17,7 +17,7 @@ //! Common traits and types that are useful for describing offences for usage in environments //! that use staking. -use rstd::vec::Vec; +use sp_std::vec::Vec; use codec::{Encode, Decode}; use sp_runtime::Perbill; diff --git a/primitives/sr-version/Cargo.toml b/primitives/sr-version/Cargo.toml index 3469fead36..626313a702 100644 --- a/primitives/sr-version/Cargo.toml +++ b/primitives/sr-version/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" impl-serde = { version = "0.2.3", optional = true } serde = { version = "1.0.101", optional = true, features = ["derive"] } codec = { package = "parity-scale-codec", version = "1.0.5", default-features = false, features = ["derive"] } -rstd = { package = "sp-std", path = "../sr-std", default-features = false } +sp-std = { path = "../std", default-features = false } sp-runtime = { path = "../runtime", default-features = false } [features] @@ -17,6 +17,6 @@ std = [ "impl-serde", "serde", "codec/std", - "rstd/std", + "sp-std/std", "sp-runtime/std", ] diff --git a/primitives/sr-std/Cargo.toml b/primitives/std/Cargo.toml similarity index 100% rename from primitives/sr-std/Cargo.toml rename to primitives/std/Cargo.toml diff --git a/primitives/sr-std/src/lib.rs b/primitives/std/src/lib.rs similarity index 100% rename from primitives/sr-std/src/lib.rs rename to primitives/std/src/lib.rs diff --git a/primitives/sr-std/with_std.rs b/primitives/std/with_std.rs similarity index 100% rename from primitives/sr-std/with_std.rs rename to primitives/std/with_std.rs diff --git a/primitives/sr-std/without_std.rs b/primitives/std/without_std.rs similarity index 100% rename from primitives/sr-std/without_std.rs rename to primitives/std/without_std.rs diff --git a/primitives/timestamp/Cargo.toml b/primitives/timestamp/Cargo.toml index f4cabd6d12..f8f4fc9315 100644 --- a/primitives/timestamp/Cargo.toml +++ b/primitives/timestamp/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" [dependencies] sp-api = { path = "../sr-api", default-features = false } -rstd = { package = "sp-std", path = "../sr-std", default-features = false } +sp-std = { path = "../std", default-features = false } sp-runtime = { path = "../runtime", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } inherents = { package = "sp-inherents", path = "../inherents", default-features = false } @@ -16,7 +16,7 @@ impl-trait-for-tuples = "0.1.3" default = [ "std" ] std = [ "sp-api/std", - "rstd/std", + "sp-std/std", "sp-runtime/std", "codec/std", "inherents/std", diff --git a/primitives/trie/Cargo.toml b/primitives/trie/Cargo.toml index 494a7754ae..e77d5665b4 100644 --- a/primitives/trie/Cargo.toml +++ b/primitives/trie/Cargo.toml @@ -13,7 +13,7 @@ harness = false [dependencies] codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } -rstd = { package = "sp-std", path = "../sr-std", default-features = false } +sp-std = { path = "../std", default-features = false } hash-db = { version = "0.15.2", default-features = false } trie-db = { version = "0.16.0", default-features = false } trie-root = { version = "0.15.2", default-features = false } @@ -29,7 +29,7 @@ hex-literal = "0.2.1" [features] default = ["std"] std = [ - "rstd/std", + "sp-std/std", "codec/std", "hash-db/std", "memory-db/std", diff --git a/primitives/trie/src/lib.rs b/primitives/trie/src/lib.rs index e1315f011f..711ce302f0 100644 --- a/primitives/trie/src/lib.rs +++ b/primitives/trie/src/lib.rs @@ -23,8 +23,8 @@ mod node_header; mod node_codec; mod trie_stream; -use rstd::boxed::Box; -use rstd::vec::Vec; +use sp_std::boxed::Box; +use sp_std::vec::Vec; use hash_db::Hasher; /// Our `NodeCodec`-specific error. pub use error::Error; @@ -44,7 +44,7 @@ pub use hash_db::{HashDB as HashDBT, EMPTY_PREFIX}; #[derive(Default)] /// substrate trie layout -pub struct Layout(rstd::marker::PhantomData); +pub struct Layout(sp_std::marker::PhantomData); impl TrieLayout for Layout { const USE_EXTENSION: bool = false; diff --git a/primitives/trie/src/node_codec.rs b/primitives/trie/src/node_codec.rs index e31ce8cc91..0b48941ca6 100644 --- a/primitives/trie/src/node_codec.rs +++ b/primitives/trie/src/node_codec.rs @@ -16,10 +16,10 @@ //! `NodeCodec` implementation for Substrate's trie format. -use rstd::marker::PhantomData; -use rstd::ops::Range; -use rstd::vec::Vec; -use rstd::borrow::Borrow; +use sp_std::marker::PhantomData; +use sp_std::ops::Range; +use sp_std::vec::Vec; +use sp_std::borrow::Borrow; use codec::{Encode, Decode, Input, Compact}; use hash_db::Hasher; use trie_db::{self, node::{NibbleSlicePlan, NodePlan, NodeHandlePlan}, ChildReference, @@ -30,7 +30,7 @@ use super::{node_header::{NodeHeader, NodeKind}}; /// Helper struct for trie node decoder. This implements `codec::Input` on a byte slice, while /// tracking the absolute position. This is similar to `std::io::Cursor` but does not implement -/// `Read` and `io` is not in `rstd`. +/// `Read` and `io` is not in `sp-std`. struct ByteSliceInput<'a> { data: &'a [u8], offset: usize, @@ -94,7 +94,7 @@ impl NodeCodecT for NodeCodec { H::hash(::empty_node()) } - fn decode_plan(data: &[u8]) -> rstd::result::Result { + fn decode_plan(data: &[u8]) -> sp_std::result::Result { let mut input = ByteSliceInput::new(data); match NodeHeader::decode(&mut input)? { NodeHeader::Null => Ok(NodePlan::Empty), @@ -229,7 +229,7 @@ fn partial_from_iterator_encode>( nibble_count: usize, node_kind: NodeKind, ) -> Vec { - let nibble_count = rstd::cmp::min(trie_constants::NIBBLE_SIZE_BOUND, nibble_count); + let nibble_count = sp_std::cmp::min(trie_constants::NIBBLE_SIZE_BOUND, nibble_count); let mut output = Vec::with_capacity(3 + (nibble_count / nibble_ops::NIBBLE_PER_BYTE)); match node_kind { @@ -247,7 +247,7 @@ fn partial_encode(partial: Partial, node_kind: NodeKind) -> Vec { let number_nibble_encoded = (partial.0).0 as usize; let nibble_count = partial.1.len() * nibble_ops::NIBBLE_PER_BYTE + number_nibble_encoded; - let nibble_count = rstd::cmp::min(trie_constants::NIBBLE_SIZE_BOUND, nibble_count); + let nibble_count = sp_std::cmp::min(trie_constants::NIBBLE_SIZE_BOUND, nibble_count); let mut output = Vec::with_capacity(3 + partial.1.len()); match node_kind { @@ -290,4 +290,3 @@ impl Bitmap { dest[1] = (bitmap / 256) as u8; } } - diff --git a/primitives/trie/src/node_header.rs b/primitives/trie/src/node_header.rs index 616273e574..34586d8b52 100644 --- a/primitives/trie/src/node_header.rs +++ b/primitives/trie/src/node_header.rs @@ -18,7 +18,7 @@ use crate::trie_constants; use codec::{Encode, Decode, Input, Output}; -use rstd::iter::once; +use sp_std::iter::once; /// A node header #[derive(Copy, Clone, PartialEq, Eq)] @@ -72,9 +72,9 @@ impl Decode for NodeHeader { /// Size encoding allows unlimited, length unefficient, representation, but /// is bounded to 16 bit maximum value to avoid possible DOS. pub(crate) fn size_and_prefix_iterator(size: usize, prefix: u8) -> impl Iterator { - let size = rstd::cmp::min(trie_constants::NIBBLE_SIZE_BOUND, size); + let size = sp_std::cmp::min(trie_constants::NIBBLE_SIZE_BOUND, size); - let l1 = rstd::cmp::min(62, size); + let l1 = sp_std::cmp::min(62, size); let (first_byte, mut rem) = if size == l1 { (once(prefix + l1 as u8), 0) } else { @@ -94,7 +94,7 @@ pub(crate) fn size_and_prefix_iterator(size: usize, prefix: u8) -> impl Iterator None } }; - first_byte.chain(rstd::iter::from_fn(next_bytes)) + first_byte.chain(sp_std::iter::from_fn(next_bytes)) } /// Encodes size and prefix to a stream output. diff --git a/primitives/trie/src/trie_stream.rs b/primitives/trie/src/trie_stream.rs index 2629cefac8..926397346f 100644 --- a/primitives/trie/src/trie_stream.rs +++ b/primitives/trie/src/trie_stream.rs @@ -19,7 +19,7 @@ use hash_db::Hasher; use trie_root; use codec::Encode; -use rstd::vec::Vec; +use sp_std::vec::Vec; use crate::trie_constants; use crate::node_header::{NodeKind, size_and_prefix_iterator}; use crate::node_codec::Bitmap; @@ -51,7 +51,7 @@ fn branch_node_bit_mask(has_children: impl Iterator) -> (u8, u8) { /// Create a leaf/branch node, encoding a number of nibbles. fn fuse_nibbles_node<'a>(nibbles: &'a [u8], kind: NodeKind) -> impl Iterator + 'a { - let size = rstd::cmp::min(trie_constants::NIBBLE_SIZE_BOUND, nibbles.len()); + let size = sp_std::cmp::min(trie_constants::NIBBLE_SIZE_BOUND, nibbles.len()); let iter_start = match kind { NodeKind::Leaf => size_and_prefix_iterator(size, trie_constants::LEAF_PREFIX_MASK), @@ -125,7 +125,7 @@ fn branch_node(has_value: bool, has_children: impl Iterator) -> [u8 result } -fn branch_node_buffered(has_value: bool, has_children: I, output: &mut[u8]) +fn branch_node_buffered(has_value: bool, has_children: I, output: &mut[u8]) where I: Iterator, { diff --git a/test/utils/runtime/Cargo.toml b/test/utils/runtime/Cargo.toml index 2523593499..40a5f17837 100644 --- a/test/utils/runtime/Cargo.toml +++ b/test/utils/runtime/Cargo.toml @@ -19,7 +19,7 @@ log = { version = "0.4.8", optional = true } memory-db = { version = "0.15.2", default-features = false } offchain-primitives = { package = "sp-offchain", path = "../../../primitives/offchain", default-features = false} primitives = { package = "sp-core", path = "../../../primitives/core", default-features = false } -rstd = { package = "sp-std", path = "../../../primitives/sr-std", 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 } runtime_support = { package = "frame-support", path = "../../../frame/support", default-features = false } @@ -63,7 +63,7 @@ std = [ "offchain-primitives/std", "primitives/std", "primitives/std", - "rstd/std", + "sp-std/std", "runtime-interface/std", "runtime_io/std", "runtime_support/std", diff --git a/test/utils/runtime/src/lib.rs b/test/utils/runtime/src/lib.rs index 374ff0322e..4a0a5859c4 100644 --- a/test/utils/runtime/src/lib.rs +++ b/test/utils/runtime/src/lib.rs @@ -22,7 +22,7 @@ pub mod genesismap; pub mod system; -use rstd::{prelude::*, marker::PhantomData}; +use sp_std::{prelude::*, marker::PhantomData}; use codec::{Encode, Decode, Input, Error}; use primitives::{Blake2Hasher, OpaqueMetadata, RuntimeDebug}; @@ -415,7 +415,7 @@ fn code_using_trie() -> u64 { ].to_vec(); let mut mdb = PrefixedMemoryDB::default(); - let mut root = rstd::default::Default::default(); + let mut root = sp_std::default::Default::default(); let _ = { let v = &pairs; let mut t = TrieDBMut::::new(&mut mdb, &mut root); diff --git a/test/utils/runtime/src/system.rs b/test/utils/runtime/src/system.rs index a0c1a2769e..c936ba0444 100644 --- a/test/utils/runtime/src/system.rs +++ b/test/utils/runtime/src/system.rs @@ -17,7 +17,7 @@ //! System manager: Handles all of the top-level stuff; executing block/transaction, setting code //! and depositing logs. -use rstd::prelude::*; +use sp_std::prelude::*; use runtime_io::{ storage::root as storage_root, storage::changes_root as storage_changes_root, hashing::blake2_256, -- GitLab From 90a82ecd876f53d34765c188146df1f1b71486d0 Mon Sep 17 00:00:00 2001 From: h4x3rotab Date: Tue, 10 Dec 2019 17:31:02 +0800 Subject: [PATCH 112/172] Wrong feature name `disable_allocator` in sr-io (#4342) This fixes the inconsistency: - Cargo.toml: `disable_allocator` - lib.rs: `disable_global_allocator` --- primitives/sr-io/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/primitives/sr-io/src/lib.rs b/primitives/sr-io/src/lib.rs index ad92b01964..b232bfd914 100644 --- a/primitives/sr-io/src/lib.rs +++ b/primitives/sr-io/src/lib.rs @@ -750,7 +750,7 @@ pub trait Sandbox { #[cfg(not(feature = "std"))] struct WasmAllocator; -#[cfg(all(not(feature = "disable_global_allocator"), not(feature = "std")))] +#[cfg(all(not(feature = "disable_allocator"), not(feature = "std")))] #[global_allocator] static ALLOCATOR: WasmAllocator = WasmAllocator; -- GitLab From 36a704b6ac7b0557aeb188d5cd79f3d11f0d6246 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Tue, 10 Dec 2019 12:02:10 +0100 Subject: [PATCH 113/172] Remove cycling dependency from `sp-api` (#4343) --- Cargo.lock | 4 - primitives/sr-api/Cargo.toml | 2 + primitives/sr-api/proc-macro/Cargo.toml | 6 - primitives/sr-api/proc-macro/src/lib.rs | 153 --------------------- primitives/sr-api/proc-macro/src/utils.rs | 2 +- primitives/sr-api/src/lib.rs | 160 +++++++++++++++++++++- 6 files changed, 162 insertions(+), 165 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a7355677a6..d6952c3cc1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5990,10 +5990,6 @@ dependencies = [ "proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-api 2.0.0", - "sp-runtime 2.0.0", - "sp-version 2.0.0", - "substrate-test-runtime-client 2.0.0", "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", ] diff --git a/primitives/sr-api/Cargo.toml b/primitives/sr-api/Cargo.toml index c56f936a6b..68287c1fda 100644 --- a/primitives/sr-api/Cargo.toml +++ b/primitives/sr-api/Cargo.toml @@ -16,6 +16,8 @@ state-machine = { package = "sp-state-machine", path = "../../primitives/state-m [dev-dependencies] criterion = "0.3.0" test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client" } +sp-runtime = { path = "../runtime" } +sp-version = { path = "../sr-version" } [[bench]] name = "bench" diff --git a/primitives/sr-api/proc-macro/Cargo.toml b/primitives/sr-api/proc-macro/Cargo.toml index a4f2ee5d28..122c889add 100644 --- a/primitives/sr-api/proc-macro/Cargo.toml +++ b/primitives/sr-api/proc-macro/Cargo.toml @@ -14,12 +14,6 @@ proc-macro2 = "1.0.6" blake2-rfc = "0.2.18" proc-macro-crate = "0.1.4" -[dev-dependencies] -sp-api = { path = ".." } -sp-runtime = { path = "../../runtime" } -sp-version = { path = "../../sr-version" } -test-client = { package = "substrate-test-runtime-client", path = "../../../test/utils/runtime/client" } - # Required for the doc tests [features] default = [ "std" ] diff --git a/primitives/sr-api/proc-macro/src/lib.rs b/primitives/sr-api/proc-macro/src/lib.rs index d82c31ec9f..30b1c26945 100644 --- a/primitives/sr-api/proc-macro/src/lib.rs +++ b/primitives/sr-api/proc-macro/src/lib.rs @@ -25,164 +25,11 @@ mod impl_runtime_apis; mod decl_runtime_apis; mod utils; -/// Tags given trait implementations as runtime apis. -/// -/// All traits given to this macro, need to be declared with the `decl_runtime_apis!` macro. -/// The implementation of the trait should follow the declaration given to the `decl_runtime_apis!` -/// macro, besides the `Block` type that is required as first generic parameter for each runtime -/// api trait. When implementing a runtime api trait, it is required that the trait is referenced -/// by a path, e.g. `impl my_trait::MyTrait for Runtime`. The macro will use this path to access -/// the declaration of the trait for the runtime side. -/// -/// The macro also generates the api implementations for the client side and provides it through -/// the `RuntimeApi` type. The `RuntimeApi` is hidden behind a `feature` called `std`. -/// -/// To expose version information about all implemented api traits, the constant -/// `RUNTIME_API_VERSIONS` is generated. This constant should be used to instantiate the `apis` -/// field of `RuntimeVersion`. -/// -/// # Example -/// -/// ```rust -/// use sp_version::create_runtime_str; -/// # -/// # use sp_runtime::traits::GetNodeBlockType; -/// # use test_client::runtime::{Block, Header}; -/// # -/// # /// The declaration of the `Runtime` type and the implementation of the `GetNodeBlockType` -/// # /// trait are done by the `construct_runtime!` macro in a real runtime. -/// # pub struct Runtime {} -/// # impl GetNodeBlockType for Runtime { -/// # type NodeBlock = Block; -/// # } -/// # -/// # sp_api::decl_runtime_apis! { -/// # /// Declare the api trait. -/// # pub trait Balance { -/// # /// Get the balance. -/// # fn get_balance() -> u64; -/// # /// Set the balance. -/// # fn set_balance(val: u64); -/// # } -/// # pub trait BlockBuilder { -/// # fn build_block() -> Block; -/// # } -/// # } -/// -/// /// All runtime api implementations need to be done in one call of the macro! -/// sp_api::impl_runtime_apis! { -/// # impl sp_api::Core for Runtime { -/// # fn version() -> sp_version::RuntimeVersion { -/// # unimplemented!() -/// # } -/// # fn execute_block(_block: Block) {} -/// # fn initialize_block(_header: &Header) {} -/// # } -/// -/// impl self::Balance for Runtime { -/// fn get_balance() -> u64 { -/// 1 -/// } -/// fn set_balance(_bal: u64) { -/// // Store the balance -/// } -/// } -/// -/// impl self::BlockBuilder for Runtime { -/// fn build_block() -> Block { -/// unimplemented!("Please implement me!") -/// } -/// } -/// } -/// -/// /// Runtime version. This needs to be declared for each runtime. -/// pub const VERSION: sp_version::RuntimeVersion = sp_version::RuntimeVersion { -/// spec_name: create_runtime_str!("node"), -/// impl_name: create_runtime_str!("test-node"), -/// authoring_version: 1, -/// spec_version: 1, -/// impl_version: 0, -/// // Here we are exposing the runtime api versions. -/// apis: RUNTIME_API_VERSIONS, -/// }; -/// -/// # fn main() {} -/// ``` #[proc_macro] pub fn impl_runtime_apis(input: TokenStream) -> TokenStream { impl_runtime_apis::impl_runtime_apis_impl(input) } -/// Declares given traits as runtime apis. -/// -/// The macro will create two declarations, one for using on the client side and one for using -/// on the runtime side. The declaration for the runtime side is hidden in its own module. -/// The client side declaration gets two extra parameters per function, -/// `&self` and `at: &BlockId`. The runtime side declaration will match the given trait -/// declaration. Besides one exception, the macro adds an extra generic parameter `Block: BlockT` -/// to the client side and the runtime side. This generic parameter is usable by the user. -/// -/// For implementing these macros you should use the `impl_runtime_apis!` macro. -/// -/// # Example -/// -/// ```rust -/// sp_api::decl_runtime_apis! { -/// /// Declare the api trait. -/// pub trait Balance { -/// /// Get the balance. -/// fn get_balance() -> u64; -/// /// Set the balance. -/// fn set_balance(val: u64); -/// } -/// -/// /// You can declare multiple api traits in one macro call. -/// /// In one module you can call the macro at maximum one time. -/// pub trait BlockBuilder { -/// /// The macro adds an explicit `Block: BlockT` generic parameter for you. -/// /// You can use this generic parameter as you would defined it manually. -/// fn build_block() -> Block; -/// } -/// } -/// -/// # fn main() {} -/// ``` -/// -/// # Runtime api trait versioning -/// -/// To support versioning of the traits, the macro supports the attribute `#[api_version(1)]`. -/// The attribute supports any `u32` as version. By default, each trait is at version `1`, if no -/// version is provided. We also support changing the signature of a method. This signature -/// change is highlighted with the `#[changed_in(2)]` attribute above a method. A method that is -/// tagged with this attribute is callable by the name `METHOD_before_version_VERSION`. This -/// method will only support calling into wasm, trying to call into native will fail (change the -/// spec version!). Such a method also does not need to be implemented in the runtime. -/// -/// ```rust -/// sp_api::decl_runtime_apis! { -/// /// Declare the api trait. -/// #[api_version(2)] -/// pub trait Balance { -/// /// Get the balance. -/// fn get_balance() -> u64; -/// /// Set balance. -/// fn set_balance(val: u64); -/// /// Set balance, old version. -/// /// -/// /// Is callable by `set_balance_before_version_2`. -/// #[changed_in(2)] -/// fn set_balance(val: u16); -/// /// In version 2, we added this new function. -/// fn increase_balance(val: u64); -/// } -/// } -/// -/// # fn main() {} -/// ``` -/// -/// To check if a given runtime implements a runtime api trait, the `RuntimeVersion` has the -/// function `has_api()`. Also the `ApiExt` provides a function `has_api(at: &BlockId)` to -/// check if the runtime at the given block id implements the requested runtime api trait. #[proc_macro] pub fn decl_runtime_apis(input: TokenStream) -> TokenStream { decl_runtime_apis::decl_runtime_apis_impl(input) diff --git a/primitives/sr-api/proc-macro/src/utils.rs b/primitives/sr-api/proc-macro/src/utils.rs index 859f37df56..afa4142641 100644 --- a/primitives/sr-api/proc-macro/src/utils.rs +++ b/primitives/sr-api/proc-macro/src/utils.rs @@ -63,7 +63,7 @@ pub fn generate_hidden_includes(unique_id: &'static str) -> TokenStream { /// Generates the access to the `sc_client` crate. pub fn generate_crate_access(unique_id: &'static str) -> TokenStream { if env::var("CARGO_PKG_NAME").unwrap() == "sp-api" { - quote!( crate ) + quote!( sp_api ) } else { let mod_name = generate_hidden_includes_mod_name(unique_id); quote!( self::#mod_name::sp_api ) diff --git a/primitives/sr-api/src/lib.rs b/primitives/sr-api/src/lib.rs index 47f5b1489b..9892bbddf6 100644 --- a/primitives/sr-api/src/lib.rs +++ b/primitives/sr-api/src/lib.rs @@ -30,6 +30,9 @@ #![cfg_attr(not(feature = "std"), no_std)] +// Make doc tests happy +extern crate self as sp_api; + #[doc(hidden)] #[cfg(feature = "std")] pub use state_machine::{OverlayedChanges, StorageProof}; @@ -61,7 +64,162 @@ use primitives::OpaqueMetadata; #[cfg(feature = "std")] use std::{panic::UnwindSafe, cell::RefCell}; -pub use sp_api_proc_macro::{decl_runtime_apis, impl_runtime_apis}; +/// Declares given traits as runtime apis. +/// +/// The macro will create two declarations, one for using on the client side and one for using +/// on the runtime side. The declaration for the runtime side is hidden in its own module. +/// The client side declaration gets two extra parameters per function, +/// `&self` and `at: &BlockId`. The runtime side declaration will match the given trait +/// declaration. Besides one exception, the macro adds an extra generic parameter `Block: BlockT` +/// to the client side and the runtime side. This generic parameter is usable by the user. +/// +/// For implementing these macros you should use the `impl_runtime_apis!` macro. +/// +/// # Example +/// +/// ```rust +/// sp_api::decl_runtime_apis! { +/// /// Declare the api trait. +/// pub trait Balance { +/// /// Get the balance. +/// fn get_balance() -> u64; +/// /// Set the balance. +/// fn set_balance(val: u64); +/// } +/// +/// /// You can declare multiple api traits in one macro call. +/// /// In one module you can call the macro at maximum one time. +/// pub trait BlockBuilder { +/// /// The macro adds an explicit `Block: BlockT` generic parameter for you. +/// /// You can use this generic parameter as you would defined it manually. +/// fn build_block() -> Block; +/// } +/// } +/// +/// # fn main() {} +/// ``` +/// +/// # Runtime api trait versioning +/// +/// To support versioning of the traits, the macro supports the attribute `#[api_version(1)]`. +/// The attribute supports any `u32` as version. By default, each trait is at version `1`, if no +/// version is provided. We also support changing the signature of a method. This signature +/// change is highlighted with the `#[changed_in(2)]` attribute above a method. A method that is +/// tagged with this attribute is callable by the name `METHOD_before_version_VERSION`. This +/// method will only support calling into wasm, trying to call into native will fail (change the +/// spec version!). Such a method also does not need to be implemented in the runtime. +/// +/// ```rust +/// sp_api::decl_runtime_apis! { +/// /// Declare the api trait. +/// #[api_version(2)] +/// pub trait Balance { +/// /// Get the balance. +/// fn get_balance() -> u64; +/// /// Set balance. +/// fn set_balance(val: u64); +/// /// Set balance, old version. +/// /// +/// /// Is callable by `set_balance_before_version_2`. +/// #[changed_in(2)] +/// fn set_balance(val: u16); +/// /// In version 2, we added this new function. +/// fn increase_balance(val: u64); +/// } +/// } +/// +/// # fn main() {} +/// ``` +/// +/// To check if a given runtime implements a runtime api trait, the `RuntimeVersion` has the +/// function `has_api()`. Also the `ApiExt` provides a function `has_api(at: &BlockId)` to +/// check if the runtime at the given block id implements the requested runtime api trait. +pub use sp_api_proc_macro::decl_runtime_apis; + +/// Tags given trait implementations as runtime apis. +/// +/// All traits given to this macro, need to be declared with the `decl_runtime_apis!` macro. +/// The implementation of the trait should follow the declaration given to the `decl_runtime_apis!` +/// macro, besides the `Block` type that is required as first generic parameter for each runtime +/// api trait. When implementing a runtime api trait, it is required that the trait is referenced +/// by a path, e.g. `impl my_trait::MyTrait for Runtime`. The macro will use this path to access +/// the declaration of the trait for the runtime side. +/// +/// The macro also generates the api implementations for the client side and provides it through +/// the `RuntimeApi` type. The `RuntimeApi` is hidden behind a `feature` called `std`. +/// +/// To expose version information about all implemented api traits, the constant +/// `RUNTIME_API_VERSIONS` is generated. This constant should be used to instantiate the `apis` +/// field of `RuntimeVersion`. +/// +/// # Example +/// +/// ```rust +/// use sp_version::create_runtime_str; +/// # +/// # use sp_runtime::traits::GetNodeBlockType; +/// # use test_client::runtime::{Block, Header}; +/// # +/// # /// The declaration of the `Runtime` type and the implementation of the `GetNodeBlockType` +/// # /// trait are done by the `construct_runtime!` macro in a real runtime. +/// # pub struct Runtime {} +/// # impl GetNodeBlockType for Runtime { +/// # type NodeBlock = Block; +/// # } +/// # +/// # sp_api::decl_runtime_apis! { +/// # /// Declare the api trait. +/// # pub trait Balance { +/// # /// Get the balance. +/// # fn get_balance() -> u64; +/// # /// Set the balance. +/// # fn set_balance(val: u64); +/// # } +/// # pub trait BlockBuilder { +/// # fn build_block() -> Block; +/// # } +/// # } +/// +/// /// All runtime api implementations need to be done in one call of the macro! +/// sp_api::impl_runtime_apis! { +/// # impl sp_api::Core for Runtime { +/// # fn version() -> sp_version::RuntimeVersion { +/// # unimplemented!() +/// # } +/// # fn execute_block(_block: Block) {} +/// # fn initialize_block(_header: &Header) {} +/// # } +/// +/// impl self::Balance for Runtime { +/// fn get_balance() -> u64 { +/// 1 +/// } +/// fn set_balance(_bal: u64) { +/// // Store the balance +/// } +/// } +/// +/// impl self::BlockBuilder for Runtime { +/// fn build_block() -> Block { +/// unimplemented!("Please implement me!") +/// } +/// } +/// } +/// +/// /// Runtime version. This needs to be declared for each runtime. +/// pub const VERSION: sp_version::RuntimeVersion = sp_version::RuntimeVersion { +/// spec_name: create_runtime_str!("node"), +/// impl_name: create_runtime_str!("test-node"), +/// authoring_version: 1, +/// spec_version: 1, +/// impl_version: 0, +/// // Here we are exposing the runtime api versions. +/// apis: RUNTIME_API_VERSIONS, +/// }; +/// +/// # fn main() {} +/// ``` +pub use sp_api_proc_macro::impl_runtime_apis; #[cfg(feature = "std")] /// A type that records all accessed trie nodes and generates a proof out of it. -- GitLab From 2b80f06b3882f48fe423586824534f9c68c40791 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Tue, 10 Dec 2019 14:21:34 +0100 Subject: [PATCH 114/172] Fix warnings when compiling runtime. (#4332) * Remove warnings when compiling runtime. * Remove dispatch::Result imports. * Add missing imports. * Fix missing vecs. #4333 * Fix oom function. * Remove superfluous import. * More warnings. --- bin/node-template/runtime/src/template.rs | 4 +- client/tracing/src/lib.rs | 4 +- frame/assets/src/lib.rs | 4 +- frame/authorship/src/lib.rs | 9 ++-- frame/democracy/src/lib.rs | 24 +++++------ frame/evm/src/lib.rs | 12 +++--- frame/generic-asset/src/lib.rs | 43 +++++++++++-------- frame/grandpa/src/lib.rs | 8 ++-- frame/im-online/src/lib.rs | 4 +- frame/randomness-collective-flip/src/lib.rs | 4 +- frame/scored-pool/src/lib.rs | 4 +- frame/session/src/lib.rs | 6 +-- frame/staking/src/lib.rs | 4 +- frame/sudo/src/lib.rs | 4 +- .../procedural/src/construct_runtime/parse.rs | 2 +- frame/support/src/dispatch.rs | 18 ++++---- .../src/storage/generator/double_map.rs | 2 +- frame/support/src/storage/generator/map.rs | 2 +- frame/support/src/storage/generator/value.rs | 2 +- .../tests/reserved_keyword/on_initialize.rs | 8 ++-- frame/system/src/lib.rs | 4 +- frame/timestamp/src/lib.rs | 4 +- primitives/consensus/aura/src/inherents.rs | 7 +-- primitives/core/src/crypto.rs | 4 +- primitives/sr-io/src/lib.rs | 4 +- 25 files changed, 104 insertions(+), 87 deletions(-) diff --git a/bin/node-template/runtime/src/template.rs b/bin/node-template/runtime/src/template.rs index e3e053da53..6cdadc72ff 100644 --- a/bin/node-template/runtime/src/template.rs +++ b/bin/node-template/runtime/src/template.rs @@ -8,7 +8,7 @@ /// For more guidance on Substrate modules, see the example module /// https://github.com/paritytech/substrate/blob/master/frame/example/src/lib.rs -use support::{decl_module, decl_storage, decl_event, dispatch::Result}; +use support::{decl_module, decl_storage, decl_event, dispatch}; use system::ensure_signed; /// The module's configuration trait. @@ -40,7 +40,7 @@ decl_module! { // Just a dummy entry point. // function that can be called by the external world as an extrinsics call // takes a parameter of the type `AccountId`, stores it and emits an event - pub fn do_something(origin, something: u32) -> Result { + pub fn do_something(origin, something: u32) -> dispatch::Result { // TODO: You only need this if you want to check it was signed. let who = ensure_signed(origin)?; diff --git a/client/tracing/src/lib.rs b/client/tracing/src/lib.rs index 4be87bc2f7..288d5e7019 100644 --- a/client/tracing/src/lib.rs +++ b/client/tracing/src/lib.rs @@ -293,5 +293,7 @@ fn send_telemetry(span_datum: SpanDatum) { fn send_grafana(span_datum: SpanDatum) { let name = format!("{}::{}", span_datum.target, span_datum.name); - record_metrics!(&name => span_datum.overall_time.as_nanos(),); + if let Err(e) = record_metrics!(&name => span_datum.overall_time.as_nanos(),) { + log::warn!("Unable to send metrics to grafana: {:?}", e); + } } diff --git a/frame/assets/src/lib.rs b/frame/assets/src/lib.rs index 7810b75305..306ac30d09 100644 --- a/frame/assets/src/lib.rs +++ b/frame/assets/src/lib.rs @@ -84,14 +84,14 @@ //! ### Simple Code Snippet //! //! ```rust,ignore -//! use support::{decl_module, dispatch::Result}; +//! use support::{decl_module, dispatch}; //! use system::ensure_signed; //! //! pub trait Trait: assets::Trait { } //! //! decl_module! { //! pub struct Module for enum Call where origin: T::Origin { -//! pub fn issue_token_airdrop(origin) -> Result { +//! pub fn issue_token_airdrop(origin) -> dispatch::Result { //! const ACCOUNT_ALICE: u64 = 1; //! const ACCOUNT_BOB: u64 = 2; //! const COUNT_AIRDROP_RECIPIENTS = 2; diff --git a/frame/authorship/src/lib.rs b/frame/authorship/src/lib.rs index edb01b7d2a..a5a032165d 100644 --- a/frame/authorship/src/lib.rs +++ b/frame/authorship/src/lib.rs @@ -22,14 +22,13 @@ use sp_std::{result, prelude::*}; use sp_std::collections::btree_set::BTreeSet; -use support::{decl_module, decl_storage, ensure}; +use support::{decl_module, decl_storage, dispatch, ensure}; use support::traits::{FindAuthor, VerifySeal, Get}; -use support::dispatch::Result as DispatchResult; use codec::{Encode, Decode}; use system::ensure_none; use sp_runtime::traits::{Header as HeaderT, One, Zero}; use support::weights::SimpleDispatchInfo; -use inherents::{InherentIdentifier, ProvideInherent, InherentData, MakeFatalError}; +use inherents::{InherentIdentifier, ProvideInherent, InherentData}; use sp_authorship::{INHERENT_IDENTIFIER, UnclesInherentData, InherentError}; const MAX_UNCLES: usize = 10; @@ -185,7 +184,7 @@ decl_module! { /// Provide a set of uncles. #[weight = SimpleDispatchInfo::FixedOperational(10_000)] - fn set_uncles(origin, new_uncles: Vec) -> DispatchResult { + fn set_uncles(origin, new_uncles: Vec) -> dispatch::Result { ensure_none(origin)?; ensure!(new_uncles.len() <= MAX_UNCLES, "Too many uncles"); @@ -220,7 +219,7 @@ impl Module { } } - fn verify_and_import_uncles(new_uncles: Vec) -> DispatchResult { + fn verify_and_import_uncles(new_uncles: Vec) -> dispatch::Result { let now = >::block_number(); let mut uncles = ::Uncles::get(); diff --git a/frame/democracy/src/lib.rs b/frame/democracy/src/lib.rs index 2bbef15d60..d5d8850645 100644 --- a/frame/democracy/src/lib.rs +++ b/frame/democracy/src/lib.rs @@ -27,6 +27,7 @@ use sp_runtime::{ use codec::{Ref, Encode, Decode, Input, Output, Error}; use support::{ decl_module, decl_storage, decl_event, ensure, + dispatch, Parameter, weights::SimpleDispatchInfo, traits::{ @@ -34,7 +35,6 @@ use support::{ OnFreeBalanceZero, OnUnbalanced } }; -use support::dispatch::Result; use system::{ensure_signed, ensure_root}; mod vote_threshold; @@ -445,7 +445,7 @@ decl_module! { fn vote(origin, #[compact] ref_index: ReferendumIndex, vote: Vote - ) -> Result { + ) -> dispatch::Result { let who = ensure_signed(origin)?; Self::do_vote(who, ref_index, vote) } @@ -461,7 +461,7 @@ decl_module! { fn proxy_vote(origin, #[compact] ref_index: ReferendumIndex, vote: Vote - ) -> Result { + ) -> dispatch::Result { let who = Self::proxy(ensure_signed(origin)?).ok_or("not a proxy")?; Self::do_vote(who, ref_index, vote) } @@ -885,7 +885,7 @@ impl Module { // private. /// Actually enact a vote, if legit. - fn do_vote(who: T::AccountId, ref_index: ReferendumIndex, vote: Vote) -> Result { + fn do_vote(who: T::AccountId, ref_index: ReferendumIndex, vote: Vote) -> dispatch::Result { ensure!(Self::is_active_referendum(ref_index), "vote given for invalid referendum."); if !>::exists((ref_index, &who)) { >::append_or_insert(ref_index, &[&who][..]); @@ -927,7 +927,7 @@ impl Module { } /// Enact a proposal from a referendum. - fn enact_proposal(proposal_hash: T::Hash, index: ReferendumIndex) -> Result { + fn enact_proposal(proposal_hash: T::Hash, index: ReferendumIndex) -> dispatch::Result { if let Some((encoded_proposal, who, amount, _)) = >::take(&proposal_hash) { if let Ok(proposal) = T::Proposal::decode(&mut &encoded_proposal[..]) { let _ = T::Currency::unreserve(&who, amount); @@ -949,7 +949,7 @@ impl Module { } /// Table the next waiting proposal for a vote. - fn launch_next(now: T::BlockNumber) -> Result { + fn launch_next(now: T::BlockNumber) -> dispatch::Result { if LastTabledWasExternal::take() { Self::launch_public(now).or_else(|_| Self::launch_external(now)) } else { @@ -958,7 +958,7 @@ impl Module { } /// Table the waiting external proposal for a vote, if there is one. - fn launch_external(now: T::BlockNumber) -> Result { + fn launch_external(now: T::BlockNumber) -> dispatch::Result { if let Some((proposal, threshold)) = >::take() { LastTabledWasExternal::put(true); Self::deposit_event(RawEvent::ExternalTabled); @@ -975,7 +975,7 @@ impl Module { } /// Table the waiting public proposal with the highest backing for a vote. - fn launch_public(now: T::BlockNumber) -> Result { + fn launch_public(now: T::BlockNumber) -> dispatch::Result { let mut public_props = Self::public_props(); if let Some((winner_index, _)) = public_props.iter() .enumerate() @@ -1009,7 +1009,7 @@ impl Module { now: T::BlockNumber, index: ReferendumIndex, info: ReferendumInfo - ) -> Result { + ) -> dispatch::Result { let (approve, against, capital) = Self::tally(index); let total_issuance = T::Currency::total_issuance(); let approved = info.threshold.approved(approve, against, capital, total_issuance); @@ -1056,7 +1056,7 @@ impl Module { } /// Current era is ending; we should finish up any proposals. - fn begin_block(now: T::BlockNumber) -> Result { + fn begin_block(now: T::BlockNumber) -> dispatch::Result { // pick out another public referendum if it's time. if (now % T::LaunchPeriod::get()).is_zero() { // Errors come from the queue being empty. we don't really care about that, and even if @@ -1241,7 +1241,7 @@ mod tests { h } - fn propose_set_balance(who: u64, value: u64, delay: u64) -> super::Result { + fn propose_set_balance(who: u64, value: u64, delay: u64) -> dispatch::Result { Democracy::propose( Origin::signed(who), set_balance_proposal_hash(value), @@ -1249,7 +1249,7 @@ mod tests { ) } - fn propose_set_balance_and_note(who: u64, value: u64, delay: u64) -> super::Result { + fn propose_set_balance_and_note(who: u64, value: u64, delay: u64) -> dispatch::Result { Democracy::propose( Origin::signed(who), set_balance_proposal_hash_and_note(value), diff --git a/frame/evm/src/lib.rs b/frame/evm/src/lib.rs index 8ad7fbc139..4a62dae9ad 100644 --- a/frame/evm/src/lib.rs +++ b/frame/evm/src/lib.rs @@ -24,7 +24,7 @@ mod backend; pub use crate::backend::{Account, Log, Vicinity, Backend}; use sp_std::{vec::Vec, marker::PhantomData}; -use support::{dispatch::Result, decl_module, decl_storage, decl_event}; +use support::{dispatch, decl_module, decl_storage, decl_event}; use support::weights::{Weight, WeighData, ClassifyDispatch, DispatchClass, PaysFee}; use support::traits::{Currency, WithdrawReason, ExistenceRequirement}; use system::ensure_signed; @@ -150,7 +150,7 @@ decl_module! { fn deposit_event() = default; #[weight = SimpleDispatchInfo::FixedNormal(10_000)] - fn deposit_balance(origin, value: BalanceOf) -> Result { + fn deposit_balance(origin, value: BalanceOf) -> dispatch::Result { let sender = ensure_signed(origin)?; let imbalance = T::Currency::withdraw( @@ -171,7 +171,7 @@ decl_module! { } #[weight = SimpleDispatchInfo::FixedNormal(10_000)] - fn withdraw_balance(origin, value: BalanceOf) -> Result { + fn withdraw_balance(origin, value: BalanceOf) -> dispatch::Result { let sender = ensure_signed(origin)?; let address = T::ConvertAccountId::convert_account_id(&sender); let bvalue = U256::from(UniqueSaturatedInto::::unique_saturated_into(value)); @@ -195,7 +195,9 @@ decl_module! { } #[weight = WeightForCallCreate::::default()] - fn call(origin, target: H160, input: Vec, value: U256, gas_limit: u32) -> Result { + fn call(origin, target: H160, input: Vec, value: U256, gas_limit: u32) + -> dispatch::Result + { let sender = ensure_signed(origin)?; let source = T::ConvertAccountId::convert_account_id(&sender); let gas_price = T::FeeCalculator::gas_price(); @@ -246,7 +248,7 @@ decl_module! { } #[weight = WeightForCallCreate::::default()] - fn create(origin, init: Vec, value: U256, gas_limit: u32) -> Result { + fn create(origin, init: Vec, value: U256, gas_limit: u32) -> dispatch::Result { let sender = ensure_signed(origin)?; let source = T::ConvertAccountId::convert_account_id(&sender); let gas_price = T::FeeCalculator::gas_price(); diff --git a/frame/generic-asset/src/lib.rs b/frame/generic-asset/src/lib.rs index ba7cdae7df..9315b36674 100644 --- a/frame/generic-asset/src/lib.rs +++ b/frame/generic-asset/src/lib.rs @@ -115,15 +115,15 @@ //! //! ``` //! use support::{ +//! dispatch, //! traits::{Currency, ExistenceRequirement, WithdrawReason}, -//! dispatch::Result, //! }; //! # pub trait Trait: system::Trait { //! # type Currency: Currency; //! # } //! type AssetOf = <::Currency as Currency<::AccountId>>::Balance; //! -//! fn charge_fee(transactor: &T::AccountId, amount: AssetOf) -> Result { +//! fn charge_fee(transactor: &T::AccountId, amount: AssetOf) -> dispatch::Result { //! // ... //! T::Currency::withdraw( //! transactor, @@ -135,7 +135,7 @@ //! Ok(()) //! } //! -//! fn refund_fee(transactor: &T::AccountId, amount: AssetOf) -> Result { +//! fn refund_fee(transactor: &T::AccountId, amount: AssetOf) -> dispatch::Result { //! // ... //! T::Currency::deposit_into_existing(transactor, amount)?; //! // ... @@ -161,9 +161,8 @@ use sp_runtime::traits::{ use sp_std::prelude::*; use sp_std::{cmp, result, fmt::Debug}; -use support::dispatch::Result; use support::{ - decl_event, decl_module, decl_storage, ensure, + decl_event, decl_module, decl_storage, ensure, dispatch, traits::{ Currency, ExistenceRequirement, Imbalance, LockIdentifier, LockableCurrency, ReservableCurrency, SignedImbalance, UpdateBalanceOutcome, WithdrawReason, WithdrawReasons, TryDrop, @@ -326,7 +325,7 @@ decl_module! { fn deposit_event() = default; /// Create a new kind of asset. - fn create(origin, options: AssetOptions) -> Result { + fn create(origin, options: AssetOptions) -> dispatch::Result { let origin = ensure_signed(origin)?; let id = Self::next_asset_id(); @@ -359,7 +358,7 @@ decl_module! { origin, #[compact] asset_id: T::AssetId, new_permission: PermissionLatest - ) -> Result { + ) -> dispatch::Result { let origin = ensure_signed(origin)?; let permissions: PermissionVersions = new_permission.into(); @@ -377,7 +376,9 @@ decl_module! { /// Mints an asset, increases its total issuance. /// The origin must have `mint` permissions. - fn mint(origin, #[compact] asset_id: T::AssetId, to: T::AccountId, amount: T::Balance) -> Result { + fn mint(origin, #[compact] asset_id: T::AssetId, to: T::AccountId, amount: T::Balance) + -> dispatch::Result + { let origin = ensure_signed(origin)?; if Self::check_permission(&asset_id, &origin, &PermissionType::Mint) { let original_free_balance = Self::free_balance(&asset_id, &to); @@ -401,7 +402,9 @@ decl_module! { /// Burns an asset, decreases its total issuance. /// /// The `origin` must have `burn` permissions. - fn burn(origin, #[compact] asset_id: T::AssetId, to: T::AccountId, amount: T::Balance) -> Result { + fn burn(origin, #[compact] asset_id: T::AssetId, to: T::AccountId, amount: T::Balance) + -> dispatch::Result + { let origin = ensure_signed(origin)?; if Self::check_permission(&asset_id, &origin, &PermissionType::Burn) { @@ -427,7 +430,11 @@ decl_module! { /// Can be used to create reserved tokens. /// Requires Root call. - fn create_reserved(origin, asset_id: T::AssetId, options: AssetOptions) -> Result { + fn create_reserved( + origin, + asset_id: T::AssetId, + options: AssetOptions + ) -> dispatch::Result { ensure_root(origin)?; Self::create_asset(Some(asset_id), None, options) } @@ -536,7 +543,7 @@ impl Module { asset_id: Option, from_account: Option, options: AssetOptions, - ) -> Result { + ) -> dispatch::Result { let asset_id = if let Some(asset_id) = asset_id { ensure!(!>::exists(&asset_id), "Asset id already taken."); ensure!(asset_id < Self::next_asset_id(), "Asset id not available."); @@ -569,7 +576,7 @@ impl Module { from: &T::AccountId, to: &T::AccountId, amount: T::Balance - ) -> Result { + ) -> dispatch::Result { let new_balance = Self::free_balance(asset_id, from) .checked_sub(&amount) .ok_or_else(|| "balance too low to send amount")?; @@ -590,7 +597,7 @@ impl Module { from: &T::AccountId, to: &T::AccountId, amount: T::Balance, - ) -> Result { + ) -> dispatch::Result { Self::make_transfer(asset_id, from, to, amount)?; if from != to { @@ -604,7 +611,9 @@ impl Module { /// /// If the free balance is lower than `amount`, then no funds will be moved and an `Err` will /// be returned. This is different behavior than `unreserve`. - pub fn reserve(asset_id: &T::AssetId, who: &T::AccountId, amount: T::Balance) -> Result { + pub fn reserve(asset_id: &T::AssetId, who: &T::AccountId, amount: T::Balance) + -> dispatch::Result + { // Do we need to consider that this is an atomic transaction? let original_reserve_balance = Self::reserved_balance(asset_id, who); let original_free_balance = Self::free_balance(asset_id, who); @@ -742,7 +751,7 @@ impl Module { _amount: T::Balance, reasons: WithdrawReasons, new_balance: T::Balance, - ) -> Result { + ) -> dispatch::Result { if asset_id != &Self::staking_asset_id() { return Ok(()); } @@ -1124,7 +1133,7 @@ where dest: &T::AccountId, value: Self::Balance, _: ExistenceRequirement, // no existential deposit policy for generic asset - ) -> Result { + ) -> dispatch::Result { >::make_transfer(&U::asset_id(), transactor, dest, value) } @@ -1133,7 +1142,7 @@ where amount: Self::Balance, reasons: WithdrawReasons, new_balance: Self::Balance, - ) -> Result { + ) -> dispatch::Result { >::ensure_can_withdraw(&U::asset_id(), who, amount, reasons, new_balance) } diff --git a/frame/grandpa/src/lib.rs b/frame/grandpa/src/lib.rs index f80974a31a..301a09d107 100644 --- a/frame/grandpa/src/lib.rs +++ b/frame/grandpa/src/lib.rs @@ -32,7 +32,7 @@ pub use sp_finality_grandpa as fg_primitives; use sp_std::prelude::*; use codec::{self as codec, Encode, Decode, Error}; -use support::{decl_event, decl_storage, decl_module, dispatch::Result, storage}; +use support::{decl_event, decl_storage, decl_module, dispatch, storage}; use sp_runtime::{ generic::{DigestItem, OpaqueDigestItemId}, traits::Zero, Perbill, }; @@ -264,7 +264,7 @@ impl Module { /// Schedule GRANDPA to pause starting in the given number of blocks. /// Cannot be done when already paused. - pub fn schedule_pause(in_blocks: T::BlockNumber) -> Result { + pub fn schedule_pause(in_blocks: T::BlockNumber) -> dispatch::Result { if let StoredState::Live = >::get() { let scheduled_at = >::block_number(); >::put(StoredState::PendingPause { @@ -280,7 +280,7 @@ impl Module { } /// Schedule a resume of GRANDPA after pausing. - pub fn schedule_resume(in_blocks: T::BlockNumber) -> Result { + pub fn schedule_resume(in_blocks: T::BlockNumber) -> dispatch::Result { if let StoredState::Paused = >::get() { let scheduled_at = >::block_number(); >::put(StoredState::PendingResume { @@ -313,7 +313,7 @@ impl Module { next_authorities: AuthorityList, in_blocks: T::BlockNumber, forced: Option, - ) -> Result { + ) -> dispatch::Result { if !>::exists() { let scheduled_at = >::block_number(); diff --git a/frame/im-online/src/lib.rs b/frame/im-online/src/lib.rs index 24556b717e..70ffc40378 100644 --- a/frame/im-online/src/lib.rs +++ b/frame/im-online/src/lib.rs @@ -42,7 +42,7 @@ //! ## Usage //! //! ``` -//! use support::{decl_module, dispatch::Result}; +//! use support::{decl_module, dispatch}; //! use system::ensure_signed; //! use pallet_im_online::{self as im_online}; //! @@ -50,7 +50,7 @@ //! //! decl_module! { //! pub struct Module for enum Call where origin: T::Origin { -//! pub fn is_online(origin, authority_index: u32) -> Result { +//! pub fn is_online(origin, authority_index: u32) -> dispatch::Result { //! let _sender = ensure_signed(origin)?; //! let _is_online = >::is_online(authority_index); //! Ok(()) diff --git a/frame/randomness-collective-flip/src/lib.rs b/frame/randomness-collective-flip/src/lib.rs index a250f50092..a4c568abd0 100644 --- a/frame/randomness-collective-flip/src/lib.rs +++ b/frame/randomness-collective-flip/src/lib.rs @@ -35,13 +35,13 @@ //! ### Example - Get random seed for the current block //! //! ``` -//! use support::{decl_module, dispatch::Result, traits::Randomness}; +//! use support::{decl_module, dispatch, traits::Randomness}; //! //! pub trait Trait: system::Trait {} //! //! decl_module! { //! pub struct Module for enum Call where origin: T::Origin { -//! pub fn random_module_example(origin) -> Result { +//! pub fn random_module_example(origin) -> dispatch::Result { //! let _random_seed = >::random_seed(); //! Ok(()) //! } diff --git a/frame/scored-pool/src/lib.rs b/frame/scored-pool/src/lib.rs index 9645560d53..30dfbbbccf 100644 --- a/frame/scored-pool/src/lib.rs +++ b/frame/scored-pool/src/lib.rs @@ -53,7 +53,7 @@ //! ## Usage //! //! ``` -//! use support::{decl_module, dispatch::Result}; +//! use support::{decl_module, dispatch}; //! use system::ensure_signed; //! use pallet_scored_pool::{self as scored_pool}; //! @@ -61,7 +61,7 @@ //! //! decl_module! { //! pub struct Module for enum Call where origin: T::Origin { -//! pub fn candidate(origin) -> Result { +//! pub fn candidate(origin) -> dispatch::Result { //! let who = ensure_signed(origin)?; //! //! let _ = >::submit_candidacy( diff --git a/frame/session/src/lib.rs b/frame/session/src/lib.rs index c71d2dbfba..6c6be7a573 100644 --- a/frame/session/src/lib.rs +++ b/frame/session/src/lib.rs @@ -125,7 +125,7 @@ use sp_runtime::{KeyTypeId, Perbill, RuntimeAppPublic, BoundToRuntimeAppPublic}; use support::weights::SimpleDispatchInfo; use sp_runtime::traits::{Convert, Zero, Member, OpaqueKeys}; use sp_staking::SessionIndex; -use support::{dispatch::Result, ConsensusEngineId, decl_module, decl_event, decl_storage}; +use support::{dispatch, ConsensusEngineId, decl_module, decl_event, decl_storage}; use support::{ensure, traits::{OnFreeBalanceZero, Get, FindAuthor, ValidatorRegistration}, Parameter}; use system::{self, ensure_signed}; @@ -483,7 +483,7 @@ decl_module! { /// - One extra DB entry. /// # #[weight = SimpleDispatchInfo::FixedNormal(150_000)] - fn set_keys(origin, keys: T::Keys, proof: Vec) -> Result { + fn set_keys(origin, keys: T::Keys, proof: Vec) -> dispatch::Result { let who = ensure_signed(origin)?; ensure!(keys.ownership_proof_is_valid(&proof), "invalid ownership proof"); @@ -631,7 +631,7 @@ impl Module { // perform the set_key operation, checking for duplicates. // does not set `Changed`. - fn do_set_keys(who: &T::ValidatorId, keys: T::Keys) -> Result { + fn do_set_keys(who: &T::ValidatorId, keys: T::Keys) -> dispatch::Result { let old_keys = Self::load_keys(&who); for id in T::Keys::key_ids() { diff --git a/frame/staking/src/lib.rs b/frame/staking/src/lib.rs index 952c0cbd62..d468b110c5 100644 --- a/frame/staking/src/lib.rs +++ b/frame/staking/src/lib.rs @@ -138,7 +138,7 @@ //! ### Example: Rewarding a validator by id. //! //! ``` -//! use support::{decl_module, dispatch::Result}; +//! use support::{decl_module, dispatch}; //! use system::ensure_signed; //! use pallet_staking::{self as staking}; //! @@ -147,7 +147,7 @@ //! decl_module! { //! pub struct Module for enum Call where origin: T::Origin { //! /// Reward a validator. -//! pub fn reward_myself(origin) -> Result { +//! pub fn reward_myself(origin) -> dispatch::Result { //! let reported = ensure_signed(origin)?; //! >::reward_by_ids(vec![(reported, 10)]); //! Ok(()) diff --git a/frame/sudo/src/lib.rs b/frame/sudo/src/lib.rs index 13daa23971..95ff953904 100644 --- a/frame/sudo/src/lib.rs +++ b/frame/sudo/src/lib.rs @@ -51,14 +51,14 @@ //! This is an example of a module that exposes a privileged function: //! //! ``` -//! use support::{decl_module, dispatch::Result}; +//! use support::{decl_module, dispatch}; //! use system::ensure_root; //! //! pub trait Trait: system::Trait {} //! //! decl_module! { //! pub struct Module for enum Call where origin: T::Origin { -//! pub fn privileged_function(origin) -> Result { +//! pub fn privileged_function(origin) -> dispatch::Result { //! ensure_root(origin)?; //! //! // do something... diff --git a/frame/support/procedural/src/construct_runtime/parse.rs b/frame/support/procedural/src/construct_runtime/parse.rs index b3f602824c..a5338bb8af 100644 --- a/frame/support/procedural/src/construct_runtime/parse.rs +++ b/frame/support/procedural/src/construct_runtime/parse.rs @@ -238,7 +238,7 @@ impl ModuleDeclaration { fn default_modules(span: Span) -> Vec { let mut res: Vec<_> = ["Module", "Call", "Storage"] - .into_iter() + .iter() .map(|name| ModulePart::with_name(name, span)) .collect(); res.extend( diff --git a/frame/support/src/dispatch.rs b/frame/support/src/dispatch.rs index 8432dd2cec..ca535a6a3b 100644 --- a/frame/support/src/dispatch.rs +++ b/frame/support/src/dispatch.rs @@ -61,21 +61,21 @@ impl Parameter for T where T: Codec + EncodeLike + Clone + Eq + fmt::Debug {} /// ``` /// # #[macro_use] /// # extern crate frame_support; -/// # use frame_support::dispatch::Result; +/// # use frame_support::dispatch; /// # use frame_system::{self as system, Trait, ensure_signed}; /// decl_module! { /// pub struct Module for enum Call where origin: T::Origin { /// /// // Private functions are dispatchable, but not available to other /// // SRML modules. -/// fn my_function(origin, var: u64) -> Result { +/// fn my_function(origin, var: u64) -> dispatch::Result { /// // Your implementation /// Ok(()) /// } /// /// // Public functions are both dispatchable and available to other /// // SRML modules. -/// pub fn my_public_function(origin) -> Result { +/// pub fn my_public_function(origin) -> dispatch::Result { /// // Your implementation /// Ok(()) /// } @@ -101,12 +101,12 @@ impl Parameter for T where T: Codec + EncodeLike + Clone + Eq + fmt::Debug {} /// ``` /// # #[macro_use] /// # extern crate frame_support; -/// # use frame_support::dispatch::Result; +/// # use frame_support::dispatch; /// # use frame_system::{self as system, Trait, ensure_signed}; /// decl_module! { /// pub struct Module for enum Call where origin: T::Origin { /// -/// fn my_long_function(origin) -> Result { +/// fn my_long_function(origin) -> dispatch::Result { /// // Your implementation /// Ok(()) /// } @@ -126,11 +126,11 @@ impl Parameter for T where T: Codec + EncodeLike + Clone + Eq + fmt::Debug {} /// ``` /// # #[macro_use] /// # extern crate frame_support; -/// # use frame_support::dispatch::Result; +/// # use frame_support::dispatch; /// # use frame_system::{self as system, Trait, ensure_signed, ensure_root}; /// decl_module! { /// pub struct Module for enum Call where origin: T::Origin { -/// fn my_privileged_function(origin) -> Result { +/// fn my_privileged_function(origin) -> dispatch::Result { /// ensure_root(origin)?; /// // Your implementation /// Ok(()) @@ -150,7 +150,7 @@ impl Parameter for T where T: Codec + EncodeLike + Clone + Eq + fmt::Debug {} /// ``` /// # #[macro_use] /// # extern crate frame_support; -/// # use frame_support::dispatch::Result; +/// # use frame_support::dispatch; /// # use frame_system::{self as system, ensure_signed}; /// # pub struct DefaultInstance; /// # pub trait Instance {} @@ -178,7 +178,7 @@ impl Parameter for T where T: Codec + EncodeLike + Clone + Eq + fmt::Debug {} /// ``` /// # #[macro_use] /// # extern crate frame_support; -/// # use frame_support::dispatch::Result; +/// # use frame_support::dispatch; /// # use frame_system::{self as system, ensure_signed}; /// pub trait Trait: system::Trait where Self::AccountId: From {} /// diff --git a/frame/support/src/storage/generator/double_map.rs b/frame/support/src/storage/generator/double_map.rs index fd938001ae..5edd8ee90f 100644 --- a/frame/support/src/storage/generator/double_map.rs +++ b/frame/support/src/storage/generator/double_map.rs @@ -218,7 +218,7 @@ where .unwrap_or_else(|| { match G::from_query_to_optional_value(G::from_optional_value_to_query(None)) { Some(value) => value.encode(), - None => vec![], + None => Vec::new(), } }); diff --git a/frame/support/src/storage/generator/map.rs b/frame/support/src/storage/generator/map.rs index fd9f1f901d..0a6cc1f9ae 100644 --- a/frame/support/src/storage/generator/map.rs +++ b/frame/support/src/storage/generator/map.rs @@ -143,7 +143,7 @@ impl> storage::StorageMap .unwrap_or_else(|| { match G::from_query_to_optional_value(G::from_optional_value_to_query(None)) { Some(value) => value.encode(), - None => vec![], + None => Vec::new(), } }); diff --git a/frame/support/src/storage/generator/value.rs b/frame/support/src/storage/generator/value.rs index cc45439f5b..f259b795ce 100644 --- a/frame/support/src/storage/generator/value.rs +++ b/frame/support/src/storage/generator/value.rs @@ -127,7 +127,7 @@ impl> storage::StorageValue for G { .unwrap_or_else(|| { match G::from_query_to_optional_value(G::from_optional_value_to_query(None)) { Some(value) => value.encode(), - None => vec![], + None => Vec::new(), } }); diff --git a/frame/support/test/tests/reserved_keyword/on_initialize.rs b/frame/support/test/tests/reserved_keyword/on_initialize.rs index f9604c9487..80ee52a982 100644 --- a/frame/support/test/tests/reserved_keyword/on_initialize.rs +++ b/frame/support/test/tests/reserved_keyword/on_initialize.rs @@ -2,7 +2,7 @@ macro_rules! reserved { ($($reserved:ident)*) => { $( mod $reserved { - pub use support::dispatch::Result; + pub use support::dispatch; pub trait Trait { type Origin; @@ -10,16 +10,16 @@ macro_rules! reserved { } pub mod system { - use support::dispatch::Result; + use support::dispatch; - pub fn ensure_root(_: R) -> Result { + pub fn ensure_root(_: R) -> dispatch::Result { Ok(()) } } support::decl_module! { pub struct Module for enum Call where origin: T::Origin { - fn $reserved(_origin) -> Result { unreachable!() } + fn $reserved(_origin) -> dispatch::Result { unreachable!() } } } } diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index cec92d7f82..b05326a5cf 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -68,14 +68,14 @@ //! ### Example - Get extrinsic count and parent hash for the current block //! //! ``` -//! use support::{decl_module, dispatch::Result}; +//! use support::{decl_module, dispatch}; //! use frame_system::{self as system, ensure_signed}; //! //! pub trait Trait: system::Trait {} //! //! decl_module! { //! pub struct Module for enum Call where origin: T::Origin { -//! pub fn system_module_example(origin) -> Result { +//! pub fn system_module_example(origin) -> dispatch::Result { //! let _sender = ensure_signed(origin)?; //! let _extrinsic_count = >::extrinsic_count(); //! let _parent_hash = >::parent_hash(); diff --git a/frame/timestamp/src/lib.rs b/frame/timestamp/src/lib.rs index 0c415dbe9a..065901ea54 100644 --- a/frame/timestamp/src/lib.rs +++ b/frame/timestamp/src/lib.rs @@ -61,7 +61,7 @@ //! ### Get current timestamp //! //! ``` -//! use support::{decl_module, dispatch::Result}; +//! use support::{decl_module, dispatch}; //! # use pallet_timestamp as timestamp; //! use system::ensure_signed; //! @@ -69,7 +69,7 @@ //! //! decl_module! { //! pub struct Module for enum Call where origin: T::Origin { -//! pub fn get_time(origin) -> Result { +//! pub fn get_time(origin) -> dispatch::Result { //! let _sender = ensure_signed(origin)?; //! let _now = >::get(); //! Ok(()) diff --git a/primitives/consensus/aura/src/inherents.rs b/primitives/consensus/aura/src/inherents.rs index 5899e7b272..9a7c7c0c5b 100644 --- a/primitives/consensus/aura/src/inherents.rs +++ b/primitives/consensus/aura/src/inherents.rs @@ -16,10 +16,7 @@ /// Contains the inherents for the AURA module -use sp_timestamp::TimestampInherentData; use inherents::{InherentIdentifier, InherentData, Error}; -use sp_std::result::Result; -use codec::Decode; #[cfg(feature = "std")] use inherents::{InherentDataProviders, ProvideInherentData}; @@ -86,12 +83,16 @@ impl ProvideInherentData for InherentDataProvider { &self, inherent_data: &mut InherentData, ) ->Result<(), Error> { + use sp_timestamp::TimestampInherentData; + let timestamp = inherent_data.timestamp_inherent_data()?; let slot_num = timestamp / self.slot_duration; inherent_data.put_data(INHERENT_IDENTIFIER, &slot_num) } fn error_to_string(&self, error: &[u8]) -> Option { + use codec::Decode; + inherents::Error::decode(&mut &error[..]).map(|e| e.into_string()).ok() } } diff --git a/primitives/core/src/crypto.rs b/primitives/core/src/crypto.rs index 3d020bcde0..91fd19291f 100644 --- a/primitives/core/src/crypto.rs +++ b/primitives/core/src/crypto.rs @@ -18,7 +18,9 @@ //! Cryptographic utilities. // end::description[] -use sp_std::{vec::Vec, hash::Hash}; +use sp_std::hash::Hash; +#[cfg(feature = "full_crypto")] +use sp_std::vec::Vec; #[cfg(feature = "std")] use sp_std::convert::TryInto; use sp_std::convert::TryFrom; diff --git a/primitives/sr-io/src/lib.rs b/primitives/sr-io/src/lib.rs index b232bfd914..ef4334808a 100644 --- a/primitives/sr-io/src/lib.rs +++ b/primitives/sr-io/src/lib.rs @@ -770,6 +770,7 @@ mod allocator_impl { } } +/// A default panic handler for WASM environment. #[cfg(all(not(feature = "disable_panic_handler"), not(feature = "std")))] #[panic_handler] #[no_mangle] @@ -781,9 +782,10 @@ pub fn panic(info: &core::panic::PanicInfo) -> ! { } } +/// A default OOM handler for WASM environment. #[cfg(all(not(feature = "disable_oom"), not(feature = "std")))] #[alloc_error_handler] -pub extern fn oom(_: core::alloc::Layout) -> ! { +pub fn oom(_: core::alloc::Layout) -> ! { unsafe { logging::log(LogLevel::Error, "runtime", b"Runtime memory exhausted. Aborting"); core::intrinsics::abort(); -- GitLab From b2a6bd9bea4cb6ce26e7d03443268f244a5e78a0 Mon Sep 17 00:00:00 2001 From: Weiliang Li Date: Wed, 11 Dec 2019 00:08:35 +0900 Subject: [PATCH 115/172] Rename: primitives/sr-io -> primitives/sp-io (#4328) * primitives/sr-io -> primitives/io * fix * rename * runtime-io -> sp-io * git mv * fix ci * remove package name * fix * fix * try minimizing diff * try minimizing diff again * try minimizing diff again --- Cargo.lock | 7 +- Cargo.toml | 2 +- bin/node-template/Cargo.toml | 2 +- bin/node-template/runtime/Cargo.toml | 4 +- bin/node-template/runtime/src/template.rs | 2 +- bin/node/cli/Cargo.toml | 2 +- bin/node/cli/src/factory_impl.rs | 2 +- bin/node/executor/Cargo.toml | 2 +- bin/node/runtime/Cargo.toml | 2 +- bin/node/runtime/src/impls.rs | 2 +- bin/node/testing/Cargo.toml | 2 +- bin/node/testing/src/keyring.rs | 2 +- client/consensus/aura/Cargo.toml | 2 +- client/consensus/babe/Cargo.toml | 2 +- client/executor/Cargo.toml | 2 +- client/executor/runtime-test/Cargo.toml | 4 +- client/executor/runtime-test/src/lib.rs | 34 ++++---- .../executor/src/deprecated_host_interface.rs | 85 +++++++++---------- client/executor/src/integration_tests/mod.rs | 3 +- client/executor/src/lib.rs | 4 +- client/executor/src/native_executor.rs | 2 +- client/executor/src/wasm_runtime.rs | 2 +- client/rpc/Cargo.toml | 2 +- client/service/Cargo.toml | 2 +- docs/CODEOWNERS | 2 +- frame/assets/Cargo.toml | 2 +- frame/assets/src/lib.rs | 2 +- frame/aura/Cargo.toml | 4 +- frame/aura/src/mock.rs | 4 +- frame/authority-discovery/Cargo.toml | 4 +- frame/authority-discovery/src/lib.rs | 2 +- frame/authorship/Cargo.toml | 4 +- frame/authorship/src/lib.rs | 2 +- frame/babe/Cargo.toml | 4 +- frame/babe/src/lib.rs | 2 +- frame/babe/src/mock.rs | 4 +- frame/balances/Cargo.toml | 2 +- frame/balances/src/mock.rs | 4 +- frame/collective/Cargo.toml | 4 +- frame/collective/src/lib.rs | 2 +- frame/contracts/Cargo.toml | 4 +- frame/contracts/src/account_db.rs | 2 +- frame/contracts/src/lib.rs | 4 +- frame/contracts/src/rent.rs | 6 +- frame/contracts/src/tests.rs | 4 +- frame/democracy/Cargo.toml | 4 +- frame/democracy/src/lib.rs | 4 +- frame/elections-phragmen/Cargo.toml | 2 +- frame/elections-phragmen/src/lib.rs | 2 +- frame/elections/Cargo.toml | 4 +- frame/elections/src/mock.rs | 4 +- frame/evm/Cargo.toml | 4 +- frame/evm/src/backend.rs | 2 +- frame/example/Cargo.toml | 4 +- frame/example/src/lib.rs | 4 +- frame/executive/Cargo.toml | 4 +- frame/executive/src/lib.rs | 4 +- frame/finality-tracker/Cargo.toml | 2 +- frame/finality-tracker/src/lib.rs | 2 +- frame/generic-asset/Cargo.toml | 2 +- frame/generic-asset/src/mock.rs | 4 +- frame/grandpa/Cargo.toml | 2 +- frame/grandpa/src/mock.rs | 4 +- frame/identity/Cargo.toml | 4 +- frame/identity/src/lib.rs | 2 +- frame/im-online/Cargo.toml | 4 +- frame/im-online/src/lib.rs | 10 +-- frame/im-online/src/mock.rs | 4 +- frame/im-online/src/tests.rs | 4 +- frame/indices/Cargo.toml | 4 +- frame/indices/src/mock.rs | 4 +- frame/membership/Cargo.toml | 4 +- frame/membership/src/lib.rs | 2 +- frame/nicks/Cargo.toml | 4 +- frame/nicks/src/lib.rs | 2 +- frame/offences/Cargo.toml | 2 +- frame/offences/src/mock.rs | 4 +- frame/randomness-collective-flip/Cargo.toml | 2 +- frame/randomness-collective-flip/src/lib.rs | 2 +- frame/scored-pool/Cargo.toml | 4 +- frame/scored-pool/src/mock.rs | 2 +- frame/session/Cargo.toml | 4 +- frame/session/src/historical.rs | 4 +- frame/session/src/lib.rs | 4 +- frame/staking/Cargo.toml | 4 +- frame/staking/src/mock.rs | 6 +- frame/sudo/Cargo.toml | 4 +- frame/support/Cargo.toml | 4 +- frame/support/src/debug.rs | 4 +- frame/support/src/hash.rs | 2 +- frame/support/src/lib.rs | 4 +- frame/support/src/storage/child.rs | 14 +-- frame/support/src/storage/generator/mod.rs | 2 +- frame/support/src/storage/mod.rs | 6 +- frame/support/src/storage/unhashed.rs | 14 +-- frame/support/test/Cargo.toml | 4 +- frame/support/test/tests/decl_storage.rs | 4 +- frame/support/test/tests/final_keys.rs | 2 +- frame/support/test/tests/instance.rs | 2 +- frame/system/Cargo.toml | 4 +- frame/system/benches/bench.rs | 2 +- frame/system/src/lib.rs | 14 +-- frame/system/src/offchain.rs | 4 +- frame/timestamp/Cargo.toml | 2 +- frame/timestamp/src/lib.rs | 2 +- frame/transaction-payment/Cargo.toml | 2 +- frame/transaction-payment/src/lib.rs | 2 +- frame/treasury/Cargo.toml | 2 +- frame/treasury/src/lib.rs | 4 +- frame/utility/Cargo.toml | 4 +- frame/utility/src/lib.rs | 2 +- primitives/application-crypto/Cargo.toml | 4 +- primitives/application-crypto/src/ed25519.rs | 8 +- primitives/application-crypto/src/sr25519.rs | 8 +- primitives/core/src/lib.rs | 2 +- primitives/{sr-io => io}/Cargo.toml | 0 primitives/{sr-io => io}/src/lib.rs | 0 primitives/phragmen/Cargo.toml | 2 +- primitives/runtime-interface/Cargo.toml | 2 +- primitives/runtime-interface/src/lib.rs | 2 +- .../runtime-interface/test-wasm/Cargo.toml | 4 +- .../runtime-interface/test-wasm/src/lib.rs | 8 +- primitives/runtime/Cargo.toml | 4 +- .../src/generic/unchecked_extrinsic.rs | 4 +- primitives/runtime/src/lib.rs | 8 +- primitives/runtime/src/offchain/http.rs | 16 ++-- primitives/runtime/src/traits.rs | 22 ++--- primitives/sr-sandbox/Cargo.toml | 4 +- primitives/sr-sandbox/without_std.rs | 2 +- .../state-machine/src/trie_backend_essence.rs | 2 +- test/utils/runtime/Cargo.toml | 4 +- test/utils/runtime/src/genesismap.rs | 2 +- test/utils/runtime/src/lib.rs | 16 ++-- test/utils/runtime/src/system.rs | 6 +- 134 files changed, 312 insertions(+), 315 deletions(-) rename primitives/{sr-io => io}/Cargo.toml (100%) rename primitives/{sr-io => io}/src/lib.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index d6952c3cc1..412d6191d3 100644 --- a/Cargo.lock +++ b/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/Cargo.toml b/Cargo.toml index 6f3c24be2b..fbae35a522 100644 --- a/Cargo.toml +++ b/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/bin/node-template/Cargo.toml b/bin/node-template/Cargo.toml index a60cbf4ff1..af39bd47f4 100644 --- a/bin/node-template/Cargo.toml +++ b/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/bin/node-template/runtime/Cargo.toml b/bin/node-template/runtime/Cargo.toml index 3c55cd68fb..438a9f93ed 100644 --- a/bin/node-template/runtime/Cargo.toml +++ b/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/bin/node-template/runtime/src/template.rs b/bin/node-template/runtime/src/template.rs index 6cdadc72ff..231f9b9a2b 100644 --- a/bin/node-template/runtime/src/template.rs +++ b/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/bin/node/cli/Cargo.toml b/bin/node/cli/Cargo.toml index 107fe6bb30..753e22bb42 100644 --- a/bin/node/cli/Cargo.toml +++ b/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/bin/node/cli/src/factory_impl.rs b/bin/node/cli/src/factory_impl.rs index 5f37615b1b..af0633ab64 100644 --- a/bin/node/cli/src/factory_impl.rs +++ b/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/bin/node/executor/Cargo.toml b/bin/node/executor/Cargo.toml index f386a2d929..a86ca7a391 100644 --- a/bin/node/executor/Cargo.toml +++ b/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/bin/node/runtime/Cargo.toml b/bin/node/runtime/Cargo.toml index 5a95961bec..9a43cc08af 100644 --- a/bin/node/runtime/Cargo.toml +++ b/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/bin/node/runtime/src/impls.rs b/bin/node/runtime/src/impls.rs index aa6e0554be..3d034a2fb1 100644 --- a/bin/node/runtime/src/impls.rs +++ b/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/bin/node/testing/Cargo.toml b/bin/node/testing/Cargo.toml index b4723cc3f4..799ba86289 100644 --- a/bin/node/testing/Cargo.toml +++ b/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/bin/node/testing/src/keyring.rs b/bin/node/testing/src/keyring.rs index 620c26578a..53dac68096 100644 --- a/bin/node/testing/src/keyring.rs +++ b/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/client/consensus/aura/Cargo.toml b/client/consensus/aura/Cargo.toml index 16ce2eed27..a2f0eeda38 100644 --- a/client/consensus/aura/Cargo.toml +++ b/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/client/consensus/babe/Cargo.toml b/client/consensus/babe/Cargo.toml index 068fb90dec..7f86960c0c 100644 --- a/client/consensus/babe/Cargo.toml +++ b/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/client/executor/Cargo.toml b/client/executor/Cargo.toml index dff872dbc4..d40e426e3f 100644 --- a/client/executor/Cargo.toml +++ b/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/client/executor/runtime-test/Cargo.toml b/client/executor/runtime-test/Cargo.toml index 75b9d510bd..9b103aa1ca 100644 --- a/client/executor/runtime-test/Cargo.toml +++ b/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/client/executor/runtime-test/src/lib.rs b/client/executor/runtime-test/src/lib.rs index 7229d9b1a4..7a97aebc90 100644 --- a/client/executor/runtime-test/src/lib.rs +++ b/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/client/executor/src/deprecated_host_interface.rs b/client/executor/src/deprecated_host_interface.rs index e7f91443c0..7ea3687bb9 100644 --- a/client/executor/src/deprecated_host_interface.rs +++ b/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/client/executor/src/integration_tests/mod.rs b/client/executor/src/integration_tests/mod.rs index fce39bb400..3cdb9fdafe 100644 --- a/client/executor/src/integration_tests/mod.rs +++ b/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/client/executor/src/lib.rs b/client/executor/src/lib.rs index 5037b490dd..97bdb0e20d 100644 --- a/client/executor/src/lib.rs +++ b/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/client/executor/src/native_executor.rs b/client/executor/src/native_executor.rs index 5a9bba7b52..635acc8716 100644 --- a/client/executor/src/native_executor.rs +++ b/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/client/executor/src/wasm_runtime.rs b/client/executor/src/wasm_runtime.rs index 5014c05816..e033285232 100644 --- a/client/executor/src/wasm_runtime.rs +++ b/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/client/rpc/Cargo.toml b/client/rpc/Cargo.toml index e167e26a67..534764bfd2 100644 --- a/client/rpc/Cargo.toml +++ b/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/client/service/Cargo.toml b/client/service/Cargo.toml index b5b3db284c..8dfb81996f 100644 --- a/client/service/Cargo.toml +++ b/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/docs/CODEOWNERS b/docs/CODEOWNERS index 5b00436bfd..edb10617f4 100644 --- a/docs/CODEOWNERS +++ b/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/frame/assets/Cargo.toml b/frame/assets/Cargo.toml index 85c3623cfe..4618c2a831 100644 --- a/frame/assets/Cargo.toml +++ b/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/frame/assets/src/lib.rs b/frame/assets/src/lib.rs index 306ac30d09..af2baae62b 100644 --- a/frame/assets/src/lib.rs +++ b/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/frame/aura/Cargo.toml b/frame/aura/Cargo.toml index 88194574f2..76b54caf12 100644 --- a/frame/aura/Cargo.toml +++ b/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/frame/aura/src/mock.rs b/frame/aura/src/mock.rs index 49351ad159..241f904617 100644 --- a/frame/aura/src/mock.rs +++ b/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/frame/authority-discovery/Cargo.toml b/frame/authority-discovery/Cargo.toml index 40fb6122f5..7d52faf3f8 100644 --- a/frame/authority-discovery/Cargo.toml +++ b/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/frame/authority-discovery/src/lib.rs b/frame/authority-discovery/src/lib.rs index 92dcb2277d..467b494907 100644 --- a/frame/authority-discovery/src/lib.rs +++ b/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/frame/authorship/Cargo.toml b/frame/authorship/Cargo.toml index 65b299dc29..40a045998c 100644 --- a/frame/authorship/Cargo.toml +++ b/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/frame/authorship/src/lib.rs b/frame/authorship/src/lib.rs index a5a032165d..4aa188cf71 100644 --- a/frame/authorship/src/lib.rs +++ b/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/frame/babe/Cargo.toml b/frame/babe/Cargo.toml index 8124ba6a59..c51b7a2ab4 100644 --- a/frame/babe/Cargo.toml +++ b/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/frame/babe/src/lib.rs b/frame/babe/src/lib.rs index a5db17e3bd..663f29ee0c 100644 --- a/frame/babe/src/lib.rs +++ b/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/frame/babe/src/mock.rs b/frame/babe/src/mock.rs index 4ca52e27e3..35a423e2ad 100644 --- a/frame/babe/src/mock.rs +++ b/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/frame/balances/Cargo.toml b/frame/balances/Cargo.toml index f4c6d9f5a1..9c71401b36 100644 --- a/frame/balances/Cargo.toml +++ b/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/frame/balances/src/mock.rs b/frame/balances/src/mock.rs index 029beb5cd2..944aab1493 100644 --- a/frame/balances/src/mock.rs +++ b/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/frame/collective/Cargo.toml b/frame/collective/Cargo.toml index 8472a13186..5e24e72228 100644 --- a/frame/collective/Cargo.toml +++ b/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/frame/collective/src/lib.rs b/frame/collective/src/lib.rs index 176967636d..279c720e85 100644 --- a/frame/collective/src/lib.rs +++ b/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/frame/contracts/Cargo.toml b/frame/contracts/Cargo.toml index f5c9ec5fdb..06bc0925bb 100644 --- a/frame/contracts/Cargo.toml +++ b/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/frame/contracts/src/account_db.rs b/frame/contracts/src/account_db.rs index 962dadff2a..2971f46f37 100644 --- a/frame/contracts/src/account_db.rs +++ b/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/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index e288fba2cc..f342a36a7a 100644 --- a/frame/contracts/src/lib.rs +++ b/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/frame/contracts/src/rent.rs b/frame/contracts/src/rent.rs index 00bf4bf911..cf96ee2c1b 100644 --- a/frame/contracts/src/rent.rs +++ b/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/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index e2e45ef9c0..153a70d54b 100644 --- a/frame/contracts/src/tests.rs +++ b/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/frame/democracy/Cargo.toml b/frame/democracy/Cargo.toml index 62e4f60f8e..5772f11af1 100644 --- a/frame/democracy/Cargo.toml +++ b/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/frame/democracy/src/lib.rs b/frame/democracy/src/lib.rs index d5d8850645..82aecc8557 100644 --- a/frame/democracy/src/lib.rs +++ b/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/frame/elections-phragmen/Cargo.toml b/frame/elections-phragmen/Cargo.toml index 979ed48ca2..7415107cd2 100644 --- a/frame/elections-phragmen/Cargo.toml +++ b/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/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index e87a0e7275..9d5ee4e6b6 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/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/frame/elections/Cargo.toml b/frame/elections/Cargo.toml index 4077d98879..9a1216f38c 100644 --- a/frame/elections/Cargo.toml +++ b/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/frame/elections/src/mock.rs b/frame/elections/src/mock.rs index 692d42cc1b..7e3c762427 100644 --- a/frame/elections/src/mock.rs +++ b/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/frame/evm/Cargo.toml b/frame/evm/Cargo.toml index b933c45382..c6a8083a2f 100644 --- a/frame/evm/Cargo.toml +++ b/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/frame/evm/src/backend.rs b/frame/evm/src/backend.rs index ab0ed43cc9..aec3371f0b 100644 --- a/frame/evm/src/backend.rs +++ b/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/frame/example/Cargo.toml b/frame/example/Cargo.toml index 9a6be32519..496d4e64a5 100644 --- a/frame/example/Cargo.toml +++ b/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/frame/example/src/lib.rs b/frame/example/src/lib.rs index f591b3c9d7..10f075ec6d 100644 --- a/frame/example/src/lib.rs +++ b/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/frame/executive/Cargo.toml b/frame/executive/Cargo.toml index 0e2e748066..3220e2ba49 100644 --- a/frame/executive/Cargo.toml +++ b/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/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index 7c94c9c012..efe963a6d3 100644 --- a/frame/executive/src/lib.rs +++ b/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/frame/finality-tracker/Cargo.toml b/frame/finality-tracker/Cargo.toml index 29e304e692..6169ba8c03 100644 --- a/frame/finality-tracker/Cargo.toml +++ b/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/frame/finality-tracker/src/lib.rs b/frame/finality-tracker/src/lib.rs index d15953d5ae..14aba50834 100644 --- a/frame/finality-tracker/src/lib.rs +++ b/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/frame/generic-asset/Cargo.toml b/frame/generic-asset/Cargo.toml index 1cdbc47394..2b4b5e3ac0 100644 --- a/frame/generic-asset/Cargo.toml +++ b/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/frame/generic-asset/src/mock.rs b/frame/generic-asset/src/mock.rs index 28d6f96de1..461fb0aeca 100644 --- a/frame/generic-asset/src/mock.rs +++ b/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/frame/grandpa/Cargo.toml b/frame/grandpa/Cargo.toml index ebb1143e1f..c7e61844c9 100644 --- a/frame/grandpa/Cargo.toml +++ b/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/frame/grandpa/src/mock.rs b/frame/grandpa/src/mock.rs index fb153d71cf..8826414cfc 100644 --- a/frame/grandpa/src/mock.rs +++ b/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/frame/identity/Cargo.toml b/frame/identity/Cargo.toml index 8fcc01b0c8..c1518bfcfc 100644 --- a/frame/identity/Cargo.toml +++ b/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/frame/identity/src/lib.rs b/frame/identity/src/lib.rs index 8422382057..bea85f6a14 100644 --- a/frame/identity/src/lib.rs +++ b/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/frame/im-online/Cargo.toml b/frame/im-online/Cargo.toml index e9b9e049a5..5110f511d1 100644 --- a/frame/im-online/Cargo.toml +++ b/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/frame/im-online/src/lib.rs b/frame/im-online/src/lib.rs index 70ffc40378..c9991cf690 100644 --- a/frame/im-online/src/lib.rs +++ b/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/frame/im-online/src/mock.rs b/frame/im-online/src/mock.rs index 03cf96cd28..48af849195 100644 --- a/frame/im-online/src/mock.rs +++ b/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/frame/im-online/src/tests.rs b/frame/im-online/src/tests.rs index 0145b7c4fe..db91a215de 100644 --- a/frame/im-online/src/tests.rs +++ b/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/frame/indices/Cargo.toml b/frame/indices/Cargo.toml index 05e5bfd451..2503d0ea60 100644 --- a/frame/indices/Cargo.toml +++ b/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/frame/indices/src/mock.rs b/frame/indices/src/mock.rs index 880ff5d66e..ea24f46e13 100644 --- a/frame/indices/src/mock.rs +++ b/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/frame/membership/Cargo.toml b/frame/membership/Cargo.toml index 1973dfba19..13c6fba9f9 100644 --- a/frame/membership/Cargo.toml +++ b/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/frame/membership/src/lib.rs b/frame/membership/src/lib.rs index a7bbceaf27..2c441f2d72 100644 --- a/frame/membership/src/lib.rs +++ b/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/frame/nicks/Cargo.toml b/frame/nicks/Cargo.toml index d7d94a564d..924d706d51 100644 --- a/frame/nicks/Cargo.toml +++ b/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/frame/nicks/src/lib.rs b/frame/nicks/src/lib.rs index 60b1d3e5cb..95fd6f5b82 100644 --- a/frame/nicks/src/lib.rs +++ b/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/frame/offences/Cargo.toml b/frame/offences/Cargo.toml index 3f3a6d8b4c..4aac6d0860 100644 --- a/frame/offences/Cargo.toml +++ b/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/frame/offences/src/mock.rs b/frame/offences/src/mock.rs index ad1d0f8b26..abe84fe5f5 100644 --- a/frame/offences/src/mock.rs +++ b/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/frame/randomness-collective-flip/Cargo.toml b/frame/randomness-collective-flip/Cargo.toml index 1ef171ab54..1840e795f5 100644 --- a/frame/randomness-collective-flip/Cargo.toml +++ b/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/frame/randomness-collective-flip/src/lib.rs b/frame/randomness-collective-flip/src/lib.rs index a4c568abd0..17b681d2e0 100644 --- a/frame/randomness-collective-flip/src/lib.rs +++ b/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/frame/scored-pool/Cargo.toml b/frame/scored-pool/Cargo.toml index a21998fcb7..5ac049d1e2 100644 --- a/frame/scored-pool/Cargo.toml +++ b/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/frame/scored-pool/src/mock.rs b/frame/scored-pool/src/mock.rs index 353e71882e..06e11e62eb 100644 --- a/frame/scored-pool/src/mock.rs +++ b/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/frame/session/Cargo.toml b/frame/session/Cargo.toml index e55c6b7bb2..3df9b868f9 100644 --- a/frame/session/Cargo.toml +++ b/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/frame/session/src/historical.rs b/frame/session/src/historical.rs index 32e7203150..e116e6ac34 100644 --- a/frame/session/src/historical.rs +++ b/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/frame/session/src/lib.rs b/frame/session/src/lib.rs index 6c6be7a573..2fb08540c0 100644 --- a/frame/session/src/lib.rs +++ b/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/frame/staking/Cargo.toml b/frame/staking/Cargo.toml index 501527847e..320a82ac2d 100644 --- a/frame/staking/Cargo.toml +++ b/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/frame/staking/src/mock.rs b/frame/staking/src/mock.rs index 9bd60e2923..91c6b3c2a1 100644 --- a/frame/staking/src/mock.rs +++ b/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/frame/sudo/Cargo.toml b/frame/sudo/Cargo.toml index f16c0013b8..1487df43b5 100644 --- a/frame/sudo/Cargo.toml +++ b/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/frame/support/Cargo.toml b/frame/support/Cargo.toml index 0f897bcda8..94b392fb50 100644 --- a/frame/support/Cargo.toml +++ b/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/frame/support/src/debug.rs b/frame/support/src/debug.rs index c872bc79df..0609148092 100644 --- a/frame/support/src/debug.rs +++ b/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/frame/support/src/hash.rs b/frame/support/src/hash.rs index 74a061dfc4..d9c1247f7b 100644 --- a/frame/support/src/hash.rs +++ b/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/frame/support/src/lib.rs b/frame/support/src/lib.rs index 7c121d7ebf..1ddc6db65c 100644 --- a/frame/support/src/lib.rs +++ b/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/frame/support/src/storage/child.rs b/frame/support/src/storage/child.rs index 1930de57bb..6fb8ce87b7 100644 --- a/frame/support/src/storage/child.rs +++ b/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/frame/support/src/storage/generator/mod.rs b/frame/support/src/storage/generator/mod.rs index 2db3e08ccf..27df37a5c5 100644 --- a/frame/support/src/storage/generator/mod.rs +++ b/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/frame/support/src/storage/mod.rs b/frame/support/src/storage/mod.rs index d6de37ca7a..1d575d0794 100644 --- a/frame/support/src/storage/mod.rs +++ b/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/frame/support/src/storage/unhashed.rs b/frame/support/src/storage/unhashed.rs index c13686cf93..55f99f3d81 100644 --- a/frame/support/src/storage/unhashed.rs +++ b/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/frame/support/test/Cargo.toml b/frame/support/test/Cargo.toml index 6fa380e86d..abd44f7a95 100644 --- a/frame/support/test/Cargo.toml +++ b/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/frame/support/test/tests/decl_storage.rs b/frame/support/test/tests/decl_storage.rs index 231dbdbdac..1c7ff1ce0a 100644 --- a/frame/support/test/tests/decl_storage.rs +++ b/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/frame/support/test/tests/final_keys.rs b/frame/support/test/tests/final_keys.rs index 3c9e1058a8..21f91e4f78 100644 --- a/frame/support/test/tests/final_keys.rs +++ b/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/frame/support/test/tests/instance.rs b/frame/support/test/tests/instance.rs index fb8575f2ea..c2ba694f7d 100644 --- a/frame/support/test/tests/instance.rs +++ b/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/frame/system/Cargo.toml b/frame/system/Cargo.toml index 81390d2d0e..3fb128e96b 100644 --- a/frame/system/Cargo.toml +++ b/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/frame/system/benches/bench.rs b/frame/system/benches/bench.rs index 461679ea38..731cadb579 100644 --- a/frame/system/benches/bench.rs +++ b/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/frame/system/src/lib.rs b/frame/system/src/lib.rs index b05326a5cf..d7485db096 100644 --- a/frame/system/src/lib.rs +++ b/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/frame/system/src/offchain.rs b/frame/system/src/offchain.rs index a12c9c3d06..b6f260d9e7 100644 --- a/frame/system/src/offchain.rs +++ b/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/frame/timestamp/Cargo.toml b/frame/timestamp/Cargo.toml index e23bcec013..ab2e40d021 100644 --- a/frame/timestamp/Cargo.toml +++ b/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/frame/timestamp/src/lib.rs b/frame/timestamp/src/lib.rs index 065901ea54..90c9f9ef6c 100644 --- a/frame/timestamp/src/lib.rs +++ b/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/frame/transaction-payment/Cargo.toml b/frame/transaction-payment/Cargo.toml index 696b5e4b6b..e8c163fb34 100644 --- a/frame/transaction-payment/Cargo.toml +++ b/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/frame/transaction-payment/src/lib.rs b/frame/transaction-payment/src/lib.rs index e51468b4f6..6f35f79f14 100644 --- a/frame/transaction-payment/src/lib.rs +++ b/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/frame/treasury/Cargo.toml b/frame/treasury/Cargo.toml index 5b4acd9808..0f588e910e 100644 --- a/frame/treasury/Cargo.toml +++ b/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/frame/treasury/src/lib.rs b/frame/treasury/src/lib.rs index 510dc5348d..92749d5eee 100644 --- a/frame/treasury/src/lib.rs +++ b/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/frame/utility/Cargo.toml b/frame/utility/Cargo.toml index 5246e86c82..3341fd50ec 100644 --- a/frame/utility/Cargo.toml +++ b/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/frame/utility/src/lib.rs b/frame/utility/src/lib.rs index 0565997e3d..7639d0c77a 100644 --- a/frame/utility/src/lib.rs +++ b/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/primitives/application-crypto/Cargo.toml b/primitives/application-crypto/Cargo.toml index e13427d256..1c7c647bb6 100644 --- a/primitives/application-crypto/Cargo.toml +++ b/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/primitives/application-crypto/src/ed25519.rs b/primitives/application-crypto/src/ed25519.rs index 358e5f657e..5097b8e4dc 100644 --- a/primitives/application-crypto/src/ed25519.rs +++ b/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/primitives/application-crypto/src/sr25519.rs b/primitives/application-crypto/src/sr25519.rs index 749e3db21f..e7b5c7f164 100644 --- a/primitives/application-crypto/src/sr25519.rs +++ b/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/primitives/core/src/lib.rs b/primitives/core/src/lib.rs index 888f401243..3241f9b4ff 100644 --- a/primitives/core/src/lib.rs +++ b/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/primitives/sr-io/Cargo.toml b/primitives/io/Cargo.toml similarity index 100% rename from primitives/sr-io/Cargo.toml rename to primitives/io/Cargo.toml diff --git a/primitives/sr-io/src/lib.rs b/primitives/io/src/lib.rs similarity index 100% rename from primitives/sr-io/src/lib.rs rename to primitives/io/src/lib.rs diff --git a/primitives/phragmen/Cargo.toml b/primitives/phragmen/Cargo.toml index 656ce8b9b2..8c546b7349 100644 --- a/primitives/phragmen/Cargo.toml +++ b/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/primitives/runtime-interface/Cargo.toml b/primitives/runtime-interface/Cargo.toml index af0ca7a5f6..cebc5286f6 100644 --- a/primitives/runtime-interface/Cargo.toml +++ b/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/primitives/runtime-interface/src/lib.rs b/primitives/runtime-interface/src/lib.rs index bce5dbfec2..3a2a780d2d 100644 --- a/primitives/runtime-interface/src/lib.rs +++ b/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/primitives/runtime-interface/test-wasm/Cargo.toml b/primitives/runtime-interface/test-wasm/Cargo.toml index 0d9288de05..553693f248 100644 --- a/primitives/runtime-interface/test-wasm/Cargo.toml +++ b/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/primitives/runtime-interface/test-wasm/src/lib.rs b/primitives/runtime-interface/test-wasm/src/lib.rs index 93e9f5b29b..dd75a9cb8a 100644 --- a/primitives/runtime-interface/test-wasm/src/lib.rs +++ b/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/primitives/runtime/Cargo.toml b/primitives/runtime/Cargo.toml index 8c855d7bb0..94f841d10a 100644 --- a/primitives/runtime/Cargo.toml +++ b/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/primitives/runtime/src/generic/unchecked_extrinsic.rs b/primitives/runtime/src/generic/unchecked_extrinsic.rs index a018dedf2a..5b760ba7d1 100644 --- a/primitives/runtime/src/generic/unchecked_extrinsic.rs +++ b/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/primitives/runtime/src/lib.rs b/primitives/runtime/src/lib.rs index c4433b9076..426e29c407 100644 --- a/primitives/runtime/src/lib.rs +++ b/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/primitives/runtime/src/offchain/http.rs b/primitives/runtime/src/offchain/http.rs index 8fc6ac025c..5110aede13 100644 --- a/primitives/runtime/src/offchain/http.rs +++ b/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/primitives/runtime/src/traits.rs b/primitives/runtime/src/traits.rs index a18783782a..de74c949db 100644 --- a/primitives/runtime/src/traits.rs +++ b/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/primitives/sr-sandbox/Cargo.toml b/primitives/sr-sandbox/Cargo.toml index 4cd946ef66..6f8d518c49 100755 --- a/primitives/sr-sandbox/Cargo.toml +++ b/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/primitives/sr-sandbox/without_std.rs b/primitives/sr-sandbox/without_std.rs index fb3267a91c..68956db8bf 100755 --- a/primitives/sr-sandbox/without_std.rs +++ b/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/primitives/state-machine/src/trie_backend_essence.rs b/primitives/state-machine/src/trie_backend_essence.rs index 6a38f56e0b..f071d19a94 100644 --- a/primitives/state-machine/src/trie_backend_essence.rs +++ b/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/test/utils/runtime/Cargo.toml b/test/utils/runtime/Cargo.toml index 40a5f17837..8a2f516fb1 100644 --- a/test/utils/runtime/Cargo.toml +++ b/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/test/utils/runtime/src/genesismap.rs b/test/utils/runtime/src/genesismap.rs index fc4acfefe2..5b65b54dce 100644 --- a/test/utils/runtime/src/genesismap.rs +++ b/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/test/utils/runtime/src/lib.rs b/test/utils/runtime/src/lib.rs index 4a0a5859c4..dcb76e27ef 100644 --- a/test/utils/runtime/src/lib.rs +++ b/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/test/utils/runtime/src/system.rs b/test/utils/runtime/src/system.rs index c936ba0444..d305220d5f 100644 --- a/test/utils/runtime/src/system.rs +++ b/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!( -- GitLab From 051db42534867caded43ff1653490933137edf63 Mon Sep 17 00:00:00 2001 From: Benjamin Kampmann Date: Tue, 10 Dec 2019 17:50:15 +0100 Subject: [PATCH 116/172] remove unnecessary client-db dependency (#4348) --- Cargo.lock | 1 - client/Cargo.toml | 1 - 2 files changed, 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 412d6191d3..c10da00c18 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5032,7 +5032,6 @@ dependencies = [ "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sc-block-builder 2.0.0", "sc-client-api 2.0.0", - "sc-client-db 2.0.0", "sc-executor 2.0.0", "sc-telemetry 2.0.0", "sp-api 2.0.0", diff --git a/client/Cargo.toml b/client/Cargo.toml index b62a004416..e87ce727dd 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -35,7 +35,6 @@ tracing = "0.1.10" [dev-dependencies] env_logger = "0.7.0" tempfile = "3.1.0" -client-db = { package = "sc-client-db", path = "./db", features = ["kvdb-rocksdb"] } test-client = { package = "substrate-test-runtime-client", path = "../test/utils/runtime/client" } kvdb-memorydb = "0.1.2" panic-handler = { package = "sp-panic-handler", path = "../primitives/panic-handler" } -- GitLab From 5e6429f76b4c4ac230e7c0da09da6045a1fc1beb Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Tue, 10 Dec 2019 17:53:23 +0100 Subject: [PATCH 117/172] remove unnecessary block-builder dependency (#4351) --- Cargo.lock | 1 - client/api/Cargo.toml | 1 - 2 files changed, 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c10da00c18..1e55146e2a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5067,7 +5067,6 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sc-block-builder 2.0.0", "sc-client-db 2.0.0", "sc-executor 2.0.0", "sc-telemetry 2.0.0", diff --git a/client/api/Cargo.toml b/client/api/Cargo.toml index 9b524f2be0..0946a863d2 100644 --- a/client/api/Cargo.toml +++ b/client/api/Cargo.toml @@ -5,7 +5,6 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -block-builder = { package = "sc-block-builder", path = "../block-builder" } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } consensus = { package = "sp-consensus", path = "../../primitives/consensus/common" } derive_more = { version = "0.99.2" } -- GitLab From 52373bfe63d49aae7a17b10b17116a3d470d30bf Mon Sep 17 00:00:00 2001 From: Benjamin Kampmann Date: Tue, 10 Dec 2019 20:18:01 +0100 Subject: [PATCH 118/172] break sp-api dependency cycle (#4352) * move benches into tests, ignore non-passing doctests * Rename sr-api folder * Move test-primitives to primitives, use that for sp-api doctests --- .maintain/rename-crates-for-2.0.sh | 1 + Cargo.lock | 28 +++++++++---------- Cargo.toml | 8 +++--- bin/node-template/runtime/Cargo.toml | 2 +- bin/node/runtime/Cargo.toml | 2 +- client/Cargo.toml | 2 +- client/api/Cargo.toml | 4 +-- client/authority-discovery/Cargo.toml | 2 +- client/block-builder/Cargo.toml | 2 +- client/consensus/aura/Cargo.toml | 2 +- client/consensus/babe/Cargo.toml | 2 +- client/finality-grandpa/Cargo.toml | 2 +- client/offchain/Cargo.toml | 2 +- client/rpc/Cargo.toml | 2 +- client/service/Cargo.toml | 2 +- client/transaction-pool/Cargo.toml | 2 +- frame/contracts/rpc/runtime-api/Cargo.toml | 2 +- frame/system/rpc/runtime-api/Cargo.toml | 2 +- .../rpc/runtime-api/Cargo.toml | 2 +- primitives/{sr-api => api}/Cargo.toml | 9 +----- .../{sr-api => api}/proc-macro/Cargo.toml | 0 .../proc-macro/src/decl_runtime_apis.rs | 0 .../proc-macro/src/impl_runtime_apis.rs | 0 .../{sr-api => api}/proc-macro/src/lib.rs | 0 .../{sr-api => api}/proc-macro/src/utils.rs | 0 primitives/{sr-api => api}/src/lib.rs | 2 +- primitives/{sr-api => api}/test/Cargo.toml | 8 ++++++ .../{sr-api => api/test}/benches/bench.rs | 0 .../test/tests/decl_and_impl.rs | 0 .../test/tests/runtime_calls.rs | 0 .../{sr-api => api}/test/tests/trybuild.rs | 0 .../test/tests/ui/adding_self_parameter.rs | 0 .../tests/ui/adding_self_parameter.stderr | 0 .../tests/ui/changed_in_unknown_version.rs | 0 .../ui/changed_in_unknown_version.stderr | 0 .../test/tests/ui/declaring_old_block.rs | 0 .../test/tests/ui/declaring_old_block.stderr | 0 ...declaring_own_block_with_different_name.rs | 0 ...aring_own_block_with_different_name.stderr | 0 .../tests/ui/empty_impl_runtime_apis_call.rs | 0 .../ui/empty_impl_runtime_apis_call.stderr | 0 .../ui/impl_incorrect_method_signature.rs | 0 .../ui/impl_incorrect_method_signature.stderr | 0 .../ui/impl_two_traits_with_same_name.rs | 0 .../ui/impl_two_traits_with_same_name.stderr | 0 .../test/tests/ui/invalid_api_version.rs | 0 .../test/tests/ui/invalid_api_version.stderr | 0 .../test/tests/ui/invalid_api_version_2.rs | 0 .../tests/ui/invalid_api_version_2.stderr | 0 .../test/tests/ui/invalid_api_version_3.rs | 0 .../tests/ui/invalid_api_version_3.stderr | 0 .../ui/missing_block_generic_parameter.rs | 0 .../ui/missing_block_generic_parameter.stderr | 0 .../test/tests/ui/missing_path_for_trait.rs | 0 .../tests/ui/missing_path_for_trait.stderr | 0 ...ype_reference_in_impl_runtime_apis_call.rs | 0 ...reference_in_impl_runtime_apis_call.stderr | 0 primitives/authority-discovery/Cargo.toml | 2 +- .../block-builder/runtime-api/Cargo.toml | 2 +- primitives/consensus/aura/Cargo.toml | 2 +- primitives/consensus/babe/Cargo.toml | 2 +- primitives/consensus/pow/Cargo.toml | 2 +- primitives/finality-grandpa/Cargo.toml | 2 +- primitives/offchain/Cargo.toml | 2 +- primitives/session/Cargo.toml | 2 +- .../test-primitives}/Cargo.toml | 8 +++--- .../test-primitives}/src/lib.rs | 0 primitives/timestamp/Cargo.toml | 2 +- primitives/transaction-pool/Cargo.toml | 2 +- test/utils/runtime/Cargo.toml | 2 +- test/utils/transaction-factory/Cargo.toml | 2 +- 71 files changed, 62 insertions(+), 60 deletions(-) rename primitives/{sr-api => api}/Cargo.toml (76%) rename primitives/{sr-api => api}/proc-macro/Cargo.toml (100%) rename primitives/{sr-api => api}/proc-macro/src/decl_runtime_apis.rs (100%) rename primitives/{sr-api => api}/proc-macro/src/impl_runtime_apis.rs (100%) rename primitives/{sr-api => api}/proc-macro/src/lib.rs (100%) rename primitives/{sr-api => api}/proc-macro/src/utils.rs (100%) rename primitives/{sr-api => api}/src/lib.rs (99%) rename primitives/{sr-api => api}/test/Cargo.toml (80%) rename primitives/{sr-api => api/test}/benches/bench.rs (100%) rename primitives/{sr-api => api}/test/tests/decl_and_impl.rs (100%) rename primitives/{sr-api => api}/test/tests/runtime_calls.rs (100%) rename primitives/{sr-api => api}/test/tests/trybuild.rs (100%) rename primitives/{sr-api => api}/test/tests/ui/adding_self_parameter.rs (100%) rename primitives/{sr-api => api}/test/tests/ui/adding_self_parameter.stderr (100%) rename primitives/{sr-api => api}/test/tests/ui/changed_in_unknown_version.rs (100%) rename primitives/{sr-api => api}/test/tests/ui/changed_in_unknown_version.stderr (100%) rename primitives/{sr-api => api}/test/tests/ui/declaring_old_block.rs (100%) rename primitives/{sr-api => api}/test/tests/ui/declaring_old_block.stderr (100%) rename primitives/{sr-api => api}/test/tests/ui/declaring_own_block_with_different_name.rs (100%) rename primitives/{sr-api => api}/test/tests/ui/declaring_own_block_with_different_name.stderr (100%) rename primitives/{sr-api => api}/test/tests/ui/empty_impl_runtime_apis_call.rs (100%) rename primitives/{sr-api => api}/test/tests/ui/empty_impl_runtime_apis_call.stderr (100%) rename primitives/{sr-api => api}/test/tests/ui/impl_incorrect_method_signature.rs (100%) rename primitives/{sr-api => api}/test/tests/ui/impl_incorrect_method_signature.stderr (100%) rename primitives/{sr-api => api}/test/tests/ui/impl_two_traits_with_same_name.rs (100%) rename primitives/{sr-api => api}/test/tests/ui/impl_two_traits_with_same_name.stderr (100%) rename primitives/{sr-api => api}/test/tests/ui/invalid_api_version.rs (100%) rename primitives/{sr-api => api}/test/tests/ui/invalid_api_version.stderr (100%) rename primitives/{sr-api => api}/test/tests/ui/invalid_api_version_2.rs (100%) rename primitives/{sr-api => api}/test/tests/ui/invalid_api_version_2.stderr (100%) rename primitives/{sr-api => api}/test/tests/ui/invalid_api_version_3.rs (100%) rename primitives/{sr-api => api}/test/tests/ui/invalid_api_version_3.stderr (100%) rename primitives/{sr-api => api}/test/tests/ui/missing_block_generic_parameter.rs (100%) rename primitives/{sr-api => api}/test/tests/ui/missing_block_generic_parameter.stderr (100%) rename primitives/{sr-api => api}/test/tests/ui/missing_path_for_trait.rs (100%) rename primitives/{sr-api => api}/test/tests/ui/missing_path_for_trait.stderr (100%) rename primitives/{sr-api => api}/test/tests/ui/type_reference_in_impl_runtime_apis_call.rs (100%) rename primitives/{sr-api => api}/test/tests/ui/type_reference_in_impl_runtime_apis_call.stderr (100%) rename {test/utils/primitives => primitives/test-primitives}/Cargo.toml (54%) rename {test/utils/primitives => primitives/test-primitives}/src/lib.rs (100%) diff --git a/.maintain/rename-crates-for-2.0.sh b/.maintain/rename-crates-for-2.0.sh index 9eefb2918c..ecfbfd4453 100644 --- a/.maintain/rename-crates-for-2.0.sh +++ b/.maintain/rename-crates-for-2.0.sh @@ -102,6 +102,7 @@ TO_RENAME=( "substrate-service-test sc-service-test" "substrate-state-db sc-state-db" "substrate-telemetry sc-telemetry" + "substrate-test-primitives sp-test-primitives" "substrate-tracing sc-tracing" ); diff --git a/Cargo.lock b/Cargo.lock index 1e55146e2a..616f5a600e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5081,10 +5081,10 @@ dependencies = [ "sp-runtime 2.0.0", "sp-state-machine 2.0.0", "sp-std 2.0.0", + "sp-test-primitives 2.0.0", "sp-transaction-pool-api 2.0.0", "sp-trie 2.0.0", "sp-version 2.0.0", - "substrate-test-primitives 2.0.0", "substrate-test-runtime-client 2.0.0", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5968,15 +5968,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "sp-api" version = "2.0.0" dependencies = [ - "criterion 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "sp-api-proc-macro 2.0.0", "sp-core 2.0.0", "sp-runtime 2.0.0", "sp-state-machine 2.0.0", "sp-std 2.0.0", + "sp-test-primitives 2.0.0", "sp-version 2.0.0", - "substrate-test-runtime-client 2.0.0", ] [[package]] @@ -5994,6 +5993,7 @@ dependencies = [ name = "sp-api-test" version = "2.0.0" dependencies = [ + "criterion 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustversion 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "sp-api 2.0.0", @@ -6419,6 +6419,17 @@ dependencies = [ name = "sp-std" version = "2.0.0" +[[package]] +name = "sp-test-primitives" +version = "2.0.0" +dependencies = [ + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-application-crypto 2.0.0", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-core 2.0.0", + "sp-runtime 2.0.0", +] + [[package]] name = "sp-timestamp" version = "2.0.0" @@ -6657,17 +6668,6 @@ dependencies = [ "sp-state-machine 2.0.0", ] -[[package]] -name = "substrate-test-primitives" -version = "2.0.0" -dependencies = [ - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sc-application-crypto 2.0.0", - "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-core 2.0.0", - "sp-runtime 2.0.0", -] - [[package]] name = "substrate-test-runtime" version = "2.0.0" diff --git a/Cargo.toml b/Cargo.toml index fbae35a522..1c4ad549b9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -115,9 +115,9 @@ members = [ "primitives/runtime-interface/test-wasm", "primitives/serializer", "primitives/session", - "primitives/sr-api", - "primitives/sr-api/proc-macro", - "primitives/sr-api/test", + "primitives/api", + "primitives/api/proc-macro", + "primitives/api/test", "primitives/sr-arithmetic", "primitives/io", "primitives/runtime", @@ -127,12 +127,12 @@ members = [ "primitives/sr-version", "primitives/state-machine", "primitives/timestamp", + "primitives/test-primitives", "primitives/transaction-pool", "primitives/trie", "primitives/wasm-interface", "test/utils/chain-spec-builder", "test/utils/client", - "test/utils/primitives", "test/utils/runtime", "test/utils/runtime/client", "test/utils/transaction-factory", diff --git a/bin/node-template/runtime/Cargo.toml b/bin/node-template/runtime/Cargo.toml index 438a9f93ed..0df7c99016 100644 --- a/bin/node-template/runtime/Cargo.toml +++ b/bin/node-template/runtime/Cargo.toml @@ -21,7 +21,7 @@ sp-std = { path = "../../../primitives/std", 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 } +sp-api = { path = "../../../primitives/api", default-features = false } sp-runtime = { path = "../../../primitives/runtime", default-features = false } sp-session = { path = "../../../primitives/session", default-features = false } sudo = { package = "pallet-sudo", path = "../../../frame/sudo", default-features = false } diff --git a/bin/node/runtime/Cargo.toml b/bin/node/runtime/Cargo.toml index 9a43cc08af..978583f8cc 100644 --- a/bin/node/runtime/Cargo.toml +++ b/bin/node/runtime/Cargo.toml @@ -22,7 +22,7 @@ node-primitives = { path = "../primitives", default-features = false } offchain-primitives = { package = "sp-offchain", path = "../../../primitives/offchain", default-features = false } primitives = { package = "sp-core", path = "../../../primitives/core", default-features = false } sp-std = { path = "../../../primitives/std", default-features = false } -sp-api = { path = "../../../primitives/sr-api", default-features = false } +sp-api = { path = "../../../primitives/api", default-features = false } sp-runtime = { path = "../../../primitives/runtime", default-features = false } sp-staking = { path = "../../../primitives/sr-staking-primitives", default-features = false } sp-keyring = { path = "../../../primitives/keyring", optional = true } diff --git a/client/Cargo.toml b/client/Cargo.toml index e87ce727dd..42158f88ef 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -24,7 +24,7 @@ parking_lot = { version = "0.9.0" } primitives = { package = "sp-core", path = "../primitives/core" } sp-std = { path = "../primitives/std" } runtime-version = { package = "sp-version", path = "../primitives/sr-version" } -sp-api = { path = "../primitives/sr-api" } +sp-api = { path = "../primitives/api" } sp-runtime = { path = "../primitives/runtime" } sp-blockchain = { path = "../primitives/blockchain" } state-machine = { package = "sp-state-machine", path = "../primitives/state-machine" } diff --git a/client/api/Cargo.toml b/client/api/Cargo.toml index 0946a863d2..6aa4a144f6 100644 --- a/client/api/Cargo.toml +++ b/client/api/Cargo.toml @@ -23,7 +23,7 @@ parking_lot = { version = "0.9.0" } primitives = { package = "sp-core", path = "../../primitives/core", default-features = false } sp-std = { path = "../../primitives/std", default-features = false } runtime-version = { package = "sp-version", path = "../../primitives/sr-version", default-features = false } -sp-api = { path = "../../primitives/sr-api" } +sp-api = { path = "../../primitives/api" } sp-runtime = { path = "../../primitives/runtime", default-features = false } state-machine = { package = "sp-state-machine", path = "../../primitives/state-machine" } sc-telemetry = { path = "../telemetry" } @@ -34,7 +34,7 @@ txpool-api = { package = "sp-transaction-pool-api", path = "../../primitives/tra env_logger = "0.7.0" tempfile = "3.1.0" client-db = { package = "sc-client-db", path = "../db", features = ["kvdb-rocksdb"] } -test-primitives = { package = "substrate-test-primitives", path = "../../test/utils/primitives" } +test-primitives = { package = "sp-test-primitives", path = "../../primitives/test-primitives" } test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client" } kvdb-memorydb = "0.1.2" panic-handler = { package = "sp-panic-handler", path = "../../primitives/panic-handler" } diff --git a/client/authority-discovery/Cargo.toml b/client/authority-discovery/Cargo.toml index 4608e5ca43..330165e0aa 100644 --- a/client/authority-discovery/Cargo.toml +++ b/client/authority-discovery/Cargo.toml @@ -31,4 +31,4 @@ env_logger = "0.7.0" parking_lot = "0.9.0" peerset = { package = "sc-peerset", path = "../peerset" } test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client" } -sp-api = { path = "../../primitives/sr-api" } +sp-api = { path = "../../primitives/api" } diff --git a/client/block-builder/Cargo.toml b/client/block-builder/Cargo.toml index 7986948c0e..4ef763d037 100644 --- a/client/block-builder/Cargo.toml +++ b/client/block-builder/Cargo.toml @@ -11,4 +11,4 @@ sp-blockchain = { path = "../../primitives/blockchain" } primitives = { package = "sp-core", path = "../../primitives/core" } codec = { package = "parity-scale-codec", version = "1.0.6", features = ["derive"] } runtime_api = { package = "sp-block-builder", path = "../../primitives/block-builder/runtime-api" } -sp-api = { path = "../../primitives/sr-api" } +sp-api = { path = "../../primitives/api" } diff --git a/client/consensus/aura/Cargo.toml b/client/consensus/aura/Cargo.toml index a2f0eeda38..f9b56fd399 100644 --- a/client/consensus/aura/Cargo.toml +++ b/client/consensus/aura/Cargo.toml @@ -26,7 +26,7 @@ sp-blockchain = { path = "../../../primitives/blockchain" } 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" } +sp-api = { path = "../../../primitives/api" } sp-runtime = { path = "../../../primitives/runtime" } sp-timestamp = { path = "../../../primitives/timestamp" } sc-telemetry = { path = "../../telemetry" } diff --git a/client/consensus/babe/Cargo.toml b/client/consensus/babe/Cargo.toml index 7f86960c0c..4d6e77a0b8 100644 --- a/client/consensus/babe/Cargo.toml +++ b/client/consensus/babe/Cargo.toml @@ -21,7 +21,7 @@ sc-telemetry = { path = "../../telemetry" } keystore = { package = "sc-keystore", path = "../../keystore" } client-api = { package = "sc-client-api", path = "../../api" } client = { package = "sc-client", path = "../../" } -sp-api = { path = "../../../primitives/sr-api" } +sp-api = { path = "../../../primitives/api" } block-builder-api = { package = "sp-block-builder", path = "../../../primitives/block-builder/runtime-api" } sp-blockchain = { path = "../../../primitives/blockchain" } consensus-common = { package = "sp-consensus", path = "../../../primitives/consensus/common" } diff --git a/client/finality-grandpa/Cargo.toml b/client/finality-grandpa/Cargo.toml index cbadd6dba6..121491fd3d 100644 --- a/client/finality-grandpa/Cargo.toml +++ b/client/finality-grandpa/Cargo.toml @@ -39,4 +39,4 @@ state_machine = { package = "sp-state-machine", path = "../../primitives/state-m env_logger = "0.7.0" tokio = "0.1.22" tempfile = "3.1.0" -sp-api = { path = "../../primitives/sr-api" } +sp-api = { path = "../../primitives/api" } diff --git a/client/offchain/Cargo.toml b/client/offchain/Cargo.toml index 953f525d5c..3d3046ff41 100644 --- a/client/offchain/Cargo.toml +++ b/client/offchain/Cargo.toml @@ -9,7 +9,7 @@ edition = "2018" [dependencies] bytes = "0.4.12" client-api = { package = "sc-client-api", path = "../api" } -sp-api = { path = "../../primitives/sr-api" } +sp-api = { path = "../../primitives/api" } fnv = "1.0.6" futures01 = { package = "futures", version = "0.1" } futures = "0.3.1" diff --git a/client/rpc/Cargo.toml b/client/rpc/Cargo.toml index 534764bfd2..0b3282c7c2 100644 --- a/client/rpc/Cargo.toml +++ b/client/rpc/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" api = { package = "sc-rpc-api", path = "./api" } client-api = { package = "sc-client-api", path = "../api" } client = { package = "sc-client", path = "../" } -sp-api = { path = "../../primitives/sr-api" } +sp-api = { path = "../../primitives/api" } codec = { package = "parity-scale-codec", version = "1.0.0" } futures = { version = "0.3.1", features = ["compat"] } jsonrpc-pubsub = "14.0.3" diff --git a/client/service/Cargo.toml b/client/service/Cargo.toml index 8dfb81996f..cdd5b948ca 100644 --- a/client/service/Cargo.toml +++ b/client/service/Cargo.toml @@ -40,7 +40,7 @@ network = { package = "sc-network", path = "../network" } chain-spec = { package = "sc-chain-spec", path = "../chain-spec" } client-api = { package = "sc-client-api", path = "../api" } client = { package = "sc-client", path = "../" } -sp-api = { path = "../../primitives/sr-api" } +sp-api = { path = "../../primitives/api" } client_db = { package = "sc-client-db", path = "../db" } codec = { package = "parity-scale-codec", version = "1.0.0" } sc-executor = { path = "../executor" } diff --git a/client/transaction-pool/Cargo.toml b/client/transaction-pool/Cargo.toml index 01d9bfcdf8..ff2a5e8f79 100644 --- a/client/transaction-pool/Cargo.toml +++ b/client/transaction-pool/Cargo.toml @@ -11,7 +11,7 @@ futures = { version = "0.3.1", features = ["compat"] } log = "0.4.8" parking_lot = "0.9.0" primitives = { package = "sp-core", path = "../../primitives/core" } -sp-api = { path = "../../primitives/sr-api" } +sp-api = { path = "../../primitives/api" } sp-runtime = { path = "../../primitives/runtime" } txpool = { package = "sc-transaction-graph", path = "./graph" } txpool-api = { package = "sp-transaction-pool-api", path = "../../primitives/transaction-pool" } diff --git a/frame/contracts/rpc/runtime-api/Cargo.toml b/frame/contracts/rpc/runtime-api/Cargo.toml index ab127a7361..05fb0d5609 100644 --- a/frame/contracts/rpc/runtime-api/Cargo.toml +++ b/frame/contracts/rpc/runtime-api/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -sp-api = { path = "../../../../primitives/sr-api", default-features = false } +sp-api = { path = "../../../../primitives/api", 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 } sp-runtime = { path = "../../../../primitives/runtime", default-features = false } diff --git a/frame/system/rpc/runtime-api/Cargo.toml b/frame/system/rpc/runtime-api/Cargo.toml index 29b7b142eb..dfe18b11c2 100644 --- a/frame/system/rpc/runtime-api/Cargo.toml +++ b/frame/system/rpc/runtime-api/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -sp-api = { path = "../../../../primitives/sr-api", default-features = false } +sp-api = { path = "../../../../primitives/api", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } [features] diff --git a/frame/transaction-payment/rpc/runtime-api/Cargo.toml b/frame/transaction-payment/rpc/runtime-api/Cargo.toml index d55919a60d..076bd2afc7 100644 --- a/frame/transaction-payment/rpc/runtime-api/Cargo.toml +++ b/frame/transaction-payment/rpc/runtime-api/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" [dependencies] serde = { version = "1.0.101", optional = true, features = ["derive"] } -sp-api = { path = "../../../../primitives/sr-api", default-features = false } +sp-api = { path = "../../../../primitives/api", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.6", default-features = false, features = ["derive"] } sp-std = { path = "../../../../primitives/std", default-features = false } sp-runtime = { path = "../../../../primitives/runtime", default-features = false } diff --git a/primitives/sr-api/Cargo.toml b/primitives/api/Cargo.toml similarity index 76% rename from primitives/sr-api/Cargo.toml rename to primitives/api/Cargo.toml index 68287c1fda..fb41802e4e 100644 --- a/primitives/sr-api/Cargo.toml +++ b/primitives/api/Cargo.toml @@ -14,14 +14,7 @@ sp-version = { path = "../sr-version", default-features = false } state-machine = { package = "sp-state-machine", path = "../../primitives/state-machine", optional = true } [dev-dependencies] -criterion = "0.3.0" -test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client" } -sp-runtime = { path = "../runtime" } -sp-version = { path = "../sr-version" } - -[[bench]] -name = "bench" -harness = false +sp-test-primitives = { path = "../test-primitives" } [features] default = [ "std" ] diff --git a/primitives/sr-api/proc-macro/Cargo.toml b/primitives/api/proc-macro/Cargo.toml similarity index 100% rename from primitives/sr-api/proc-macro/Cargo.toml rename to primitives/api/proc-macro/Cargo.toml diff --git a/primitives/sr-api/proc-macro/src/decl_runtime_apis.rs b/primitives/api/proc-macro/src/decl_runtime_apis.rs similarity index 100% rename from primitives/sr-api/proc-macro/src/decl_runtime_apis.rs rename to primitives/api/proc-macro/src/decl_runtime_apis.rs diff --git a/primitives/sr-api/proc-macro/src/impl_runtime_apis.rs b/primitives/api/proc-macro/src/impl_runtime_apis.rs similarity index 100% rename from primitives/sr-api/proc-macro/src/impl_runtime_apis.rs rename to primitives/api/proc-macro/src/impl_runtime_apis.rs diff --git a/primitives/sr-api/proc-macro/src/lib.rs b/primitives/api/proc-macro/src/lib.rs similarity index 100% rename from primitives/sr-api/proc-macro/src/lib.rs rename to primitives/api/proc-macro/src/lib.rs diff --git a/primitives/sr-api/proc-macro/src/utils.rs b/primitives/api/proc-macro/src/utils.rs similarity index 100% rename from primitives/sr-api/proc-macro/src/utils.rs rename to primitives/api/proc-macro/src/utils.rs diff --git a/primitives/sr-api/src/lib.rs b/primitives/api/src/lib.rs similarity index 99% rename from primitives/sr-api/src/lib.rs rename to primitives/api/src/lib.rs index 9892bbddf6..7d1f91e339 100644 --- a/primitives/sr-api/src/lib.rs +++ b/primitives/api/src/lib.rs @@ -158,7 +158,7 @@ pub use sp_api_proc_macro::decl_runtime_apis; /// use sp_version::create_runtime_str; /// # /// # use sp_runtime::traits::GetNodeBlockType; -/// # use test_client::runtime::{Block, Header}; +/// # use sp_test_primitives::{Block, Header}; /// # /// # /// The declaration of the `Runtime` type and the implementation of the `GetNodeBlockType` /// # /// trait are done by the `construct_runtime!` macro in a real runtime. diff --git a/primitives/sr-api/test/Cargo.toml b/primitives/api/test/Cargo.toml similarity index 80% rename from primitives/sr-api/test/Cargo.toml rename to primitives/api/test/Cargo.toml index 61d3a87547..489069a170 100644 --- a/primitives/sr-api/test/Cargo.toml +++ b/primitives/api/test/Cargo.toml @@ -16,6 +16,14 @@ state-machine = { package = "sp-state-machine", path = "../../../primitives/stat trybuild = "1.0.17" rustversion = "1.0.0" +[dev-dependencies] +criterion = "0.3.0" +test-client = { package = "substrate-test-runtime-client", path = "../../../test/utils/runtime/client" } + +[[bench]] +name = "bench" +harness = false + # We only need this to generate the correct code. [features] default = [ "std" ] diff --git a/primitives/sr-api/benches/bench.rs b/primitives/api/test/benches/bench.rs similarity index 100% rename from primitives/sr-api/benches/bench.rs rename to primitives/api/test/benches/bench.rs diff --git a/primitives/sr-api/test/tests/decl_and_impl.rs b/primitives/api/test/tests/decl_and_impl.rs similarity index 100% rename from primitives/sr-api/test/tests/decl_and_impl.rs rename to primitives/api/test/tests/decl_and_impl.rs diff --git a/primitives/sr-api/test/tests/runtime_calls.rs b/primitives/api/test/tests/runtime_calls.rs similarity index 100% rename from primitives/sr-api/test/tests/runtime_calls.rs rename to primitives/api/test/tests/runtime_calls.rs diff --git a/primitives/sr-api/test/tests/trybuild.rs b/primitives/api/test/tests/trybuild.rs similarity index 100% rename from primitives/sr-api/test/tests/trybuild.rs rename to primitives/api/test/tests/trybuild.rs diff --git a/primitives/sr-api/test/tests/ui/adding_self_parameter.rs b/primitives/api/test/tests/ui/adding_self_parameter.rs similarity index 100% rename from primitives/sr-api/test/tests/ui/adding_self_parameter.rs rename to primitives/api/test/tests/ui/adding_self_parameter.rs diff --git a/primitives/sr-api/test/tests/ui/adding_self_parameter.stderr b/primitives/api/test/tests/ui/adding_self_parameter.stderr similarity index 100% rename from primitives/sr-api/test/tests/ui/adding_self_parameter.stderr rename to primitives/api/test/tests/ui/adding_self_parameter.stderr diff --git a/primitives/sr-api/test/tests/ui/changed_in_unknown_version.rs b/primitives/api/test/tests/ui/changed_in_unknown_version.rs similarity index 100% rename from primitives/sr-api/test/tests/ui/changed_in_unknown_version.rs rename to primitives/api/test/tests/ui/changed_in_unknown_version.rs diff --git a/primitives/sr-api/test/tests/ui/changed_in_unknown_version.stderr b/primitives/api/test/tests/ui/changed_in_unknown_version.stderr similarity index 100% rename from primitives/sr-api/test/tests/ui/changed_in_unknown_version.stderr rename to primitives/api/test/tests/ui/changed_in_unknown_version.stderr diff --git a/primitives/sr-api/test/tests/ui/declaring_old_block.rs b/primitives/api/test/tests/ui/declaring_old_block.rs similarity index 100% rename from primitives/sr-api/test/tests/ui/declaring_old_block.rs rename to primitives/api/test/tests/ui/declaring_old_block.rs diff --git a/primitives/sr-api/test/tests/ui/declaring_old_block.stderr b/primitives/api/test/tests/ui/declaring_old_block.stderr similarity index 100% rename from primitives/sr-api/test/tests/ui/declaring_old_block.stderr rename to primitives/api/test/tests/ui/declaring_old_block.stderr diff --git a/primitives/sr-api/test/tests/ui/declaring_own_block_with_different_name.rs b/primitives/api/test/tests/ui/declaring_own_block_with_different_name.rs similarity index 100% rename from primitives/sr-api/test/tests/ui/declaring_own_block_with_different_name.rs rename to primitives/api/test/tests/ui/declaring_own_block_with_different_name.rs diff --git a/primitives/sr-api/test/tests/ui/declaring_own_block_with_different_name.stderr b/primitives/api/test/tests/ui/declaring_own_block_with_different_name.stderr similarity index 100% rename from primitives/sr-api/test/tests/ui/declaring_own_block_with_different_name.stderr rename to primitives/api/test/tests/ui/declaring_own_block_with_different_name.stderr diff --git a/primitives/sr-api/test/tests/ui/empty_impl_runtime_apis_call.rs b/primitives/api/test/tests/ui/empty_impl_runtime_apis_call.rs similarity index 100% rename from primitives/sr-api/test/tests/ui/empty_impl_runtime_apis_call.rs rename to primitives/api/test/tests/ui/empty_impl_runtime_apis_call.rs diff --git a/primitives/sr-api/test/tests/ui/empty_impl_runtime_apis_call.stderr b/primitives/api/test/tests/ui/empty_impl_runtime_apis_call.stderr similarity index 100% rename from primitives/sr-api/test/tests/ui/empty_impl_runtime_apis_call.stderr rename to primitives/api/test/tests/ui/empty_impl_runtime_apis_call.stderr diff --git a/primitives/sr-api/test/tests/ui/impl_incorrect_method_signature.rs b/primitives/api/test/tests/ui/impl_incorrect_method_signature.rs similarity index 100% rename from primitives/sr-api/test/tests/ui/impl_incorrect_method_signature.rs rename to primitives/api/test/tests/ui/impl_incorrect_method_signature.rs diff --git a/primitives/sr-api/test/tests/ui/impl_incorrect_method_signature.stderr b/primitives/api/test/tests/ui/impl_incorrect_method_signature.stderr similarity index 100% rename from primitives/sr-api/test/tests/ui/impl_incorrect_method_signature.stderr rename to primitives/api/test/tests/ui/impl_incorrect_method_signature.stderr diff --git a/primitives/sr-api/test/tests/ui/impl_two_traits_with_same_name.rs b/primitives/api/test/tests/ui/impl_two_traits_with_same_name.rs similarity index 100% rename from primitives/sr-api/test/tests/ui/impl_two_traits_with_same_name.rs rename to primitives/api/test/tests/ui/impl_two_traits_with_same_name.rs diff --git a/primitives/sr-api/test/tests/ui/impl_two_traits_with_same_name.stderr b/primitives/api/test/tests/ui/impl_two_traits_with_same_name.stderr similarity index 100% rename from primitives/sr-api/test/tests/ui/impl_two_traits_with_same_name.stderr rename to primitives/api/test/tests/ui/impl_two_traits_with_same_name.stderr diff --git a/primitives/sr-api/test/tests/ui/invalid_api_version.rs b/primitives/api/test/tests/ui/invalid_api_version.rs similarity index 100% rename from primitives/sr-api/test/tests/ui/invalid_api_version.rs rename to primitives/api/test/tests/ui/invalid_api_version.rs diff --git a/primitives/sr-api/test/tests/ui/invalid_api_version.stderr b/primitives/api/test/tests/ui/invalid_api_version.stderr similarity index 100% rename from primitives/sr-api/test/tests/ui/invalid_api_version.stderr rename to primitives/api/test/tests/ui/invalid_api_version.stderr diff --git a/primitives/sr-api/test/tests/ui/invalid_api_version_2.rs b/primitives/api/test/tests/ui/invalid_api_version_2.rs similarity index 100% rename from primitives/sr-api/test/tests/ui/invalid_api_version_2.rs rename to primitives/api/test/tests/ui/invalid_api_version_2.rs diff --git a/primitives/sr-api/test/tests/ui/invalid_api_version_2.stderr b/primitives/api/test/tests/ui/invalid_api_version_2.stderr similarity index 100% rename from primitives/sr-api/test/tests/ui/invalid_api_version_2.stderr rename to primitives/api/test/tests/ui/invalid_api_version_2.stderr diff --git a/primitives/sr-api/test/tests/ui/invalid_api_version_3.rs b/primitives/api/test/tests/ui/invalid_api_version_3.rs similarity index 100% rename from primitives/sr-api/test/tests/ui/invalid_api_version_3.rs rename to primitives/api/test/tests/ui/invalid_api_version_3.rs diff --git a/primitives/sr-api/test/tests/ui/invalid_api_version_3.stderr b/primitives/api/test/tests/ui/invalid_api_version_3.stderr similarity index 100% rename from primitives/sr-api/test/tests/ui/invalid_api_version_3.stderr rename to primitives/api/test/tests/ui/invalid_api_version_3.stderr diff --git a/primitives/sr-api/test/tests/ui/missing_block_generic_parameter.rs b/primitives/api/test/tests/ui/missing_block_generic_parameter.rs similarity index 100% rename from primitives/sr-api/test/tests/ui/missing_block_generic_parameter.rs rename to primitives/api/test/tests/ui/missing_block_generic_parameter.rs diff --git a/primitives/sr-api/test/tests/ui/missing_block_generic_parameter.stderr b/primitives/api/test/tests/ui/missing_block_generic_parameter.stderr similarity index 100% rename from primitives/sr-api/test/tests/ui/missing_block_generic_parameter.stderr rename to primitives/api/test/tests/ui/missing_block_generic_parameter.stderr diff --git a/primitives/sr-api/test/tests/ui/missing_path_for_trait.rs b/primitives/api/test/tests/ui/missing_path_for_trait.rs similarity index 100% rename from primitives/sr-api/test/tests/ui/missing_path_for_trait.rs rename to primitives/api/test/tests/ui/missing_path_for_trait.rs diff --git a/primitives/sr-api/test/tests/ui/missing_path_for_trait.stderr b/primitives/api/test/tests/ui/missing_path_for_trait.stderr similarity index 100% rename from primitives/sr-api/test/tests/ui/missing_path_for_trait.stderr rename to primitives/api/test/tests/ui/missing_path_for_trait.stderr diff --git a/primitives/sr-api/test/tests/ui/type_reference_in_impl_runtime_apis_call.rs b/primitives/api/test/tests/ui/type_reference_in_impl_runtime_apis_call.rs similarity index 100% rename from primitives/sr-api/test/tests/ui/type_reference_in_impl_runtime_apis_call.rs rename to primitives/api/test/tests/ui/type_reference_in_impl_runtime_apis_call.rs diff --git a/primitives/sr-api/test/tests/ui/type_reference_in_impl_runtime_apis_call.stderr b/primitives/api/test/tests/ui/type_reference_in_impl_runtime_apis_call.stderr similarity index 100% rename from primitives/sr-api/test/tests/ui/type_reference_in_impl_runtime_apis_call.stderr rename to primitives/api/test/tests/ui/type_reference_in_impl_runtime_apis_call.stderr diff --git a/primitives/authority-discovery/Cargo.toml b/primitives/authority-discovery/Cargo.toml index 1924add0a6..79df9e4169 100644 --- a/primitives/authority-discovery/Cargo.toml +++ b/primitives/authority-discovery/Cargo.toml @@ -9,7 +9,7 @@ edition = "2018" app-crypto = { package = "sc-application-crypto", path = "../application-crypto", default-features = false } codec = { package = "parity-scale-codec", default-features = false, version = "1.0.3" } sp-std = { path = "../std", default-features = false } -sp-api = { path = "../sr-api", default-features = false } +sp-api = { path = "../api", default-features = false } sp-runtime = { path = "../runtime", default-features = false } [features] diff --git a/primitives/block-builder/runtime-api/Cargo.toml b/primitives/block-builder/runtime-api/Cargo.toml index ba6705fa2a..f8983fcdd2 100644 --- a/primitives/block-builder/runtime-api/Cargo.toml +++ b/primitives/block-builder/runtime-api/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" [dependencies] sp-runtime = { path = "../../runtime", default-features = false } -sp-api = { path = "../../sr-api", default-features = false } +sp-api = { path = "../../api", default-features = false } sp-std = { path = "../../std", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.6", default-features = false } inherents = { package = "sp-inherents", path = "../../inherents", default-features = false } diff --git a/primitives/consensus/aura/Cargo.toml b/primitives/consensus/aura/Cargo.toml index ef0af6d292..599083b17f 100644 --- a/primitives/consensus/aura/Cargo.toml +++ b/primitives/consensus/aura/Cargo.toml @@ -9,7 +9,7 @@ edition = "2018" app-crypto = { package = "sc-application-crypto", path = "../../application-crypto", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } sp-std = { path = "../../std", default-features = false } -sp-api = { path = "../../sr-api", default-features = false } +sp-api = { path = "../../api", default-features = false } sp-runtime = { path = "../../runtime", default-features = false } inherents = { package = "sp-inherents", path = "../../inherents", default-features = false } sp-timestamp = { path = "../../timestamp", default-features = false } diff --git a/primitives/consensus/babe/Cargo.toml b/primitives/consensus/babe/Cargo.toml index a77813aee9..675363e5a9 100644 --- a/primitives/consensus/babe/Cargo.toml +++ b/primitives/consensus/babe/Cargo.toml @@ -10,7 +10,7 @@ app-crypto = { package = "sc-application-crypto", path = "../../application-cryp codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } sp-std = { path = "../../std", default-features = false } schnorrkel = { version = "0.8.5", features = ["preaudit_deprecated"], optional = true } -sp-api = { path = "../../sr-api", default-features = false } +sp-api = { path = "../../api", default-features = false } sp-consensus = { path = "../common", optional = true } sp-inherents = { package = "sp-inherents", path = "../../inherents", default-features = false } sp-runtime = { path = "../../runtime", default-features = false } diff --git a/primitives/consensus/pow/Cargo.toml b/primitives/consensus/pow/Cargo.toml index dfe646c00d..0baff76a9b 100644 --- a/primitives/consensus/pow/Cargo.toml +++ b/primitives/consensus/pow/Cargo.toml @@ -6,7 +6,7 @@ description = "Primitives for Aura consensus" edition = "2018" [dependencies] -sp-api = { path = "../../sr-api", default-features = false } +sp-api = { path = "../../api", default-features = false } sp-std = { path = "../../std", default-features = false } sp-runtime = { path = "../../runtime", default-features = false } primitives = { package = "sp-core", path = "../../core", default-features = false } diff --git a/primitives/finality-grandpa/Cargo.toml b/primitives/finality-grandpa/Cargo.toml index d12b2d9bbf..0e05cab228 100644 --- a/primitives/finality-grandpa/Cargo.toml +++ b/primitives/finality-grandpa/Cargo.toml @@ -9,7 +9,7 @@ app-crypto = { package = "sc-application-crypto", path = "../application-crypto" codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } sp-std = { path = "../std", default-features = false } serde = { version = "1.0.101", optional = true, features = ["derive"] } -sp-api = { path = "../sr-api", default-features = false } +sp-api = { path = "../api", default-features = false } sp-runtime = { path = "../runtime", default-features = false } [features] diff --git a/primitives/offchain/Cargo.toml b/primitives/offchain/Cargo.toml index 0a85e487c3..4b739dc45b 100644 --- a/primitives/offchain/Cargo.toml +++ b/primitives/offchain/Cargo.toml @@ -7,7 +7,7 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -sp-api = { path = "../sr-api", default-features = false } +sp-api = { path = "../api", default-features = false } sp-runtime = { path = "../runtime", default-features = false } [features] diff --git a/primitives/session/Cargo.toml b/primitives/session/Cargo.toml index ab37c021ec..56a7660c74 100644 --- a/primitives/session/Cargo.toml +++ b/primitives/session/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -sp-api = { path = "../sr-api", default-features = false } +sp-api = { path = "../api", default-features = false } sp-std = { path = "../std", default-features = false } sp-runtime = { path = "../runtime", optional = true } diff --git a/test/utils/primitives/Cargo.toml b/primitives/test-primitives/Cargo.toml similarity index 54% rename from test/utils/primitives/Cargo.toml rename to primitives/test-primitives/Cargo.toml index f0199032a4..e54a6f5095 100644 --- a/test/utils/primitives/Cargo.toml +++ b/primitives/test-primitives/Cargo.toml @@ -1,15 +1,15 @@ [package] -name = "substrate-test-primitives" +name = "sp-test-primitives" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" [dependencies] -app-crypto = { package = "sc-application-crypto", path = "../../../primitives/application-crypto", default-features = false } +app-crypto = { package = "sc-application-crypto", path = "../application-crypto", 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 } +primitives = { package = "sp-core", path = "../core", default-features = false } serde = { version = "1.0.101", optional = true, features = ["derive"] } -sp-runtime = { path = "../../../primitives/runtime", default-features = false } +sp-runtime = { path = "../runtime", default-features = false } [features] default = [ diff --git a/test/utils/primitives/src/lib.rs b/primitives/test-primitives/src/lib.rs similarity index 100% rename from test/utils/primitives/src/lib.rs rename to primitives/test-primitives/src/lib.rs diff --git a/primitives/timestamp/Cargo.toml b/primitives/timestamp/Cargo.toml index f8f4fc9315..8661a44a44 100644 --- a/primitives/timestamp/Cargo.toml +++ b/primitives/timestamp/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -sp-api = { path = "../sr-api", default-features = false } +sp-api = { path = "../api", default-features = false } sp-std = { path = "../std", default-features = false } sp-runtime = { path = "../runtime", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } diff --git a/primitives/transaction-pool/Cargo.toml b/primitives/transaction-pool/Cargo.toml index 456d1f94e6..e1a55d6b37 100644 --- a/primitives/transaction-pool/Cargo.toml +++ b/primitives/transaction-pool/Cargo.toml @@ -10,7 +10,7 @@ derive_more = { version = "0.99.2", optional = true } futures = { version = "0.3.1", optional = true } log = { version = "0.4.8", optional = true } serde = { version = "1.0.101", features = ["derive"], optional = true} -sp-api = { path = "../sr-api", default-features = false } +sp-api = { path = "../api", default-features = false } sp-runtime = { path = "../runtime", default-features = false } [features] diff --git a/test/utils/runtime/Cargo.toml b/test/utils/runtime/Cargo.toml index 8a2f516fb1..87f9fd75bb 100644 --- a/test/utils/runtime/Cargo.toml +++ b/test/utils/runtime/Cargo.toml @@ -26,7 +26,7 @@ runtime_support = { package = "frame-support", path = "../../../frame/support", runtime_version = { package = "sp-version", path = "../../../primitives/sr-version", default-features = false } serde = { version = "1.0.101", optional = true, features = ["derive"] } session = { package = "sp-session", path = "../../../primitives/session", default-features = false } -sp-api = { path = "../../../primitives/sr-api", default-features = false } +sp-api = { path = "../../../primitives/api", default-features = false } sp-runtime = { path = "../../../primitives/runtime", default-features = false } pallet-babe = { path = "../../../frame/babe", default-features = false } frame-system = { path = "../../../frame/system", default-features = false } diff --git a/test/utils/transaction-factory/Cargo.toml b/test/utils/transaction-factory/Cargo.toml index 1cfc1b7696..f0c6c25ccc 100644 --- a/test/utils/transaction-factory/Cargo.toml +++ b/test/utils/transaction-factory/Cargo.toml @@ -13,7 +13,7 @@ codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive consensus_common = { package = "sp-consensus", path = "../../../primitives/consensus/common" } log = "0.4.8" primitives = { package = "sp-core", path = "../../../primitives/core" } -sp-api = { path = "../../../primitives/sr-api" } +sp-api = { path = "../../../primitives/api" } sp-runtime = { path = "../../../primitives/runtime" } sc-service = { path = "../../../client/service" } sp-blockchain = { path = "../../../primitives/blockchain" } -- GitLab From d7c3fa29532f50a5945cc8dfbd0de322b9954683 Mon Sep 17 00:00:00 2001 From: Benjamin Kampmann Date: Tue, 10 Dec 2019 22:12:57 +0100 Subject: [PATCH 119/172] Break appcrypto dep cycle (#4347) * move application-crypto tests into seperate crate * Fix crate name, update script and add docs * pressing 'save' helps * remove useless lines * adding header * split into actual modules --- .maintain/rename-crates-for-2.0.sh | 3 +- Cargo.lock | 63 ++++++++++--------- Cargo.toml | 1 + client/consensus/aura/Cargo.toml | 2 +- client/consensus/babe/Cargo.toml | 2 +- client/keystore/Cargo.toml | 2 +- client/service/Cargo.toml | 2 +- docs/Upgrade.md | 5 ++ frame/aura/Cargo.toml | 2 +- frame/authority-discovery/Cargo.toml | 2 +- frame/im-online/Cargo.toml | 2 +- frame/session/Cargo.toml | 2 +- primitives/application-crypto/Cargo.toml | 6 +- primitives/application-crypto/src/ed25519.rs | 23 ------- primitives/application-crypto/src/lib.rs | 6 +- primitives/application-crypto/src/sr25519.rs | 26 +------- primitives/application-crypto/test/Cargo.toml | 12 ++++ .../application-crypto/test/src/ed25519.rs | 38 +++++++++++ primitives/application-crypto/test/src/lib.rs | 22 +++++++ .../application-crypto/test/src/sr25519.rs | 39 ++++++++++++ primitives/authority-discovery/Cargo.toml | 2 +- primitives/consensus/aura/Cargo.toml | 2 +- primitives/consensus/babe/Cargo.toml | 2 +- primitives/finality-grandpa/Cargo.toml | 2 +- primitives/runtime/Cargo.toml | 2 +- primitives/test-primitives/Cargo.toml | 2 +- test/utils/runtime/Cargo.toml | 2 +- 27 files changed, 174 insertions(+), 100 deletions(-) create mode 100644 docs/Upgrade.md create mode 100644 primitives/application-crypto/test/Cargo.toml create mode 100644 primitives/application-crypto/test/src/ed25519.rs create mode 100644 primitives/application-crypto/test/src/lib.rs create mode 100644 primitives/application-crypto/test/src/sr25519.rs diff --git a/.maintain/rename-crates-for-2.0.sh b/.maintain/rename-crates-for-2.0.sh index ecfbfd4453..8cf5a71c0e 100644 --- a/.maintain/rename-crates-for-2.0.sh +++ b/.maintain/rename-crates-for-2.0.sh @@ -35,7 +35,8 @@ TO_RENAME=( # OLD-CRATE-NAME NEW-CRATE-NAME # PRIMITIVES - "substrate-application-crypto sc-application-crypto" + "substrate-application-crypto sp-application-crypto" + "sc-application-crypto sp-application-crypto" "substrate-authority-discovery-primitives sp-authority-discovery" "substrate-block-builder-runtime-api sp-block-builder" "substrate-consensus-aura-primitives sp-consensus-aura" diff --git a/Cargo.lock b/Cargo.lock index 616f5a600e..89e8ccd33a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3453,8 +3453,8 @@ dependencies = [ "pallet-timestamp 2.0.0", "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sc-application-crypto 2.0.0", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-application-crypto 2.0.0", "sp-consensus-aura 2.0.0", "sp-core 2.0.0", "sp-inherents 2.0.0", @@ -3472,8 +3472,8 @@ dependencies = [ "frame-system 2.0.0", "pallet-session 2.0.0", "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sc-application-crypto 2.0.0", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-application-crypto 2.0.0", "sp-authority-discovery 2.0.0", "sp-core 2.0.0", "sp-io 2.0.0", @@ -3767,8 +3767,8 @@ dependencies = [ "pallet-authorship 0.1.0", "pallet-session 2.0.0", "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sc-application-crypto 2.0.0", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-application-crypto 2.0.0", "sp-core 2.0.0", "sp-io 2.0.0", "sp-runtime 2.0.0", @@ -3878,8 +3878,8 @@ dependencies = [ "pallet-timestamp 2.0.0", "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sc-application-crypto 2.0.0", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-application-crypto 2.0.0", "sp-core 2.0.0", "sp-io 2.0.0", "sp-runtime 2.0.0", @@ -4879,19 +4879,6 @@ dependencies = [ "winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "sc-application-crypto" -version = "2.0.0" -dependencies = [ - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-core 2.0.0", - "sp-io 2.0.0", - "sp-runtime 2.0.0", - "sp-std 2.0.0", - "substrate-test-runtime-client 2.0.0", -] - [[package]] name = "sc-authority-discovery" version = "2.0.0" @@ -5129,7 +5116,6 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sc-application-crypto 2.0.0", "sc-client 2.0.0", "sc-client-api 2.0.0", "sc-consensus-slots 2.0.0", @@ -5139,6 +5125,7 @@ dependencies = [ "sc-service 2.0.0", "sc-telemetry 2.0.0", "sp-api 2.0.0", + "sp-application-crypto 2.0.0", "sp-block-builder 2.0.0", "sp-blockchain 2.0.0", "sp-consensus 2.0.0", @@ -5174,7 +5161,6 @@ dependencies = [ "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "pdqselect 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "sc-application-crypto 2.0.0", "sc-block-builder 2.0.0", "sc-client 2.0.0", "sc-client-api 2.0.0", @@ -5187,6 +5173,7 @@ dependencies = [ "sc-telemetry 2.0.0", "schnorrkel 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)", "sp-api 2.0.0", + "sp-application-crypto 2.0.0", "sp-block-builder 2.0.0", "sp-blockchain 2.0.0", "sp-consensus 2.0.0", @@ -5339,8 +5326,8 @@ dependencies = [ "hex 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "sc-application-crypto 2.0.0", "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-application-crypto 2.0.0", "sp-core 2.0.0", "subtle 2.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5538,7 +5525,6 @@ dependencies = [ "parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sc-application-crypto 2.0.0", "sc-chain-spec 2.0.0", "sc-client 2.0.0", "sc-client-api 2.0.0", @@ -5557,6 +5543,7 @@ dependencies = [ "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "sp-api 2.0.0", + "sp-application-crypto 2.0.0", "sp-blockchain 2.0.0", "sp-consensus 2.0.0", "sp-consensus-babe 2.0.0", @@ -6006,6 +5993,26 @@ dependencies = [ "trybuild 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "sp-application-crypto" +version = "2.0.0" +dependencies = [ + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-core 2.0.0", + "sp-io 2.0.0", + "sp-std 2.0.0", +] + +[[package]] +name = "sp-application-crypto-test" +version = "2.0.0" +dependencies = [ + "sp-core 2.0.0", + "sp-runtime 2.0.0", + "substrate-test-runtime-client 2.0.0", +] + [[package]] name = "sp-arithmetic" version = "2.0.0" @@ -6026,8 +6033,8 @@ name = "sp-authority-discovery" version = "2.0.0" dependencies = [ "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sc-application-crypto 2.0.0", "sp-api 2.0.0", + "sp-application-crypto 2.0.0", "sp-runtime 2.0.0", "sp-std 2.0.0", ] @@ -6092,8 +6099,8 @@ name = "sp-consensus-aura" version = "2.0.0" dependencies = [ "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sc-application-crypto 2.0.0", "sp-api 2.0.0", + "sp-application-crypto 2.0.0", "sp-inherents 2.0.0", "sp-runtime 2.0.0", "sp-std 2.0.0", @@ -6105,9 +6112,9 @@ name = "sp-consensus-babe" version = "2.0.0" dependencies = [ "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sc-application-crypto 2.0.0", "schnorrkel 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)", "sp-api 2.0.0", + "sp-application-crypto 2.0.0", "sp-consensus 2.0.0", "sp-inherents 2.0.0", "sp-runtime 2.0.0", @@ -6202,9 +6209,9 @@ name = "sp-finality-grandpa" version = "2.0.0" dependencies = [ "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sc-application-crypto 2.0.0", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-api 2.0.0", + "sp-application-crypto 2.0.0", "sp-runtime 2.0.0", "sp-std 2.0.0", ] @@ -6301,9 +6308,9 @@ dependencies = [ "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "paste 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "sc-application-crypto 2.0.0", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-application-crypto 2.0.0", "sp-arithmetic 2.0.0", "sp-core 2.0.0", "sp-inherents 2.0.0", @@ -6424,8 +6431,8 @@ name = "sp-test-primitives" version = "2.0.0" dependencies = [ "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sc-application-crypto 2.0.0", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-application-crypto 2.0.0", "sp-core 2.0.0", "sp-runtime 2.0.0", ] @@ -6682,11 +6689,11 @@ dependencies = [ "pallet-babe 2.0.0", "pallet-timestamp 2.0.0", "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sc-application-crypto 2.0.0", "sc-client 2.0.0", "sc-executor 2.0.0", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-api 2.0.0", + "sp-application-crypto 2.0.0", "sp-block-builder 2.0.0", "sp-consensus-aura 2.0.0", "sp-consensus-babe 2.0.0", diff --git a/Cargo.toml b/Cargo.toml index 1c4ad549b9..d1b105ab8b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -90,6 +90,7 @@ members = [ "frame/treasury", "frame/utility", "primitives/application-crypto", + "primitives/application-crypto/test", "primitives/authority-discovery", "primitives/authorship", "primitives/block-builder/runtime-api", diff --git a/client/consensus/aura/Cargo.toml b/client/consensus/aura/Cargo.toml index f9b56fd399..181b144333 100644 --- a/client/consensus/aura/Cargo.toml +++ b/client/consensus/aura/Cargo.toml @@ -6,7 +6,7 @@ description = "Aura consensus algorithm for substrate" edition = "2018" [dependencies] -app-crypto = { package = "sc-application-crypto", path = "../../../primitives/application-crypto" } +app-crypto = { package = "sp-application-crypto", path = "../../../primitives/application-crypto" } aura_primitives = { package = "sp-consensus-aura", path = "../../../primitives/consensus/aura" } block-builder-api = { package = "sp-block-builder", path = "../../../primitives/block-builder/runtime-api" } client = { package = "sc-client", path = "../../" } diff --git a/client/consensus/babe/Cargo.toml b/client/consensus/babe/Cargo.toml index 4d6e77a0b8..8c61f10b68 100644 --- a/client/consensus/babe/Cargo.toml +++ b/client/consensus/babe/Cargo.toml @@ -9,7 +9,7 @@ edition = "2018" codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } babe_primitives = { package = "sp-consensus-babe", path = "../../../primitives/consensus/babe" } primitives = { package = "sp-core", path = "../../../primitives/core" } -app-crypto = { package = "sc-application-crypto", path = "../../../primitives/application-crypto" } +app-crypto = { package = "sp-application-crypto", path = "../../../primitives/application-crypto" } num-bigint = "0.2.3" num-rational = "0.2.2" num-traits = "0.2.8" diff --git a/client/keystore/Cargo.toml b/client/keystore/Cargo.toml index 0dd33a62da..32bd3d460b 100644 --- a/client/keystore/Cargo.toml +++ b/client/keystore/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] derive_more = "0.99.2" primitives = { package = "sp-core", path = "../../primitives/core" } -app-crypto = { package = "sc-application-crypto", path = "../../primitives/application-crypto" } +app-crypto = { package = "sp-application-crypto", path = "../../primitives/application-crypto" } hex = "0.4.0" rand = "0.7.2" serde_json = "1.0.41" diff --git a/client/service/Cargo.toml b/client/service/Cargo.toml index cdd5b948ca..f09fad08de 100644 --- a/client/service/Cargo.toml +++ b/client/service/Cargo.toml @@ -34,7 +34,7 @@ sp-runtime = { path = "../../primitives/runtime" } sp-blockchain = { path = "../../primitives/blockchain" } primitives = { package = "sp-core", path = "../../primitives/core" } session = { package = "sp-session", path = "../../primitives/session" } -app-crypto = { package = "sc-application-crypto", path = "../../primitives/application-crypto" } +app-crypto = { package = "sp-application-crypto", path = "../../primitives/application-crypto" } consensus_common = { package = "sp-consensus", path = "../../primitives/consensus/common" } network = { package = "sc-network", path = "../network" } chain-spec = { package = "sc-chain-spec", path = "../chain-spec" } diff --git a/docs/Upgrade.md b/docs/Upgrade.md new file mode 100644 index 0000000000..4908d53f57 --- /dev/null +++ b/docs/Upgrade.md @@ -0,0 +1,5 @@ +# Upgrade path for you building on substrate + +## master + - crate rename has been fixed `sp-application-crypto` (was `sc-application-crypto`); `.maintain/rename-crates-for-2.0.sh` has been updated accordingly, you can use it to upgrade to latest naming convention + - crates have been renamed, run `bash .maintain/rename-crates-for-2.0.sh` \ No newline at end of file diff --git a/frame/aura/Cargo.toml b/frame/aura/Cargo.toml index 76b54caf12..68083e075f 100644 --- a/frame/aura/Cargo.toml +++ b/frame/aura/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -app-crypto = { package = "sc-application-crypto", path = "../../primitives/application-crypto", default-features = false } +app-crypto = { package = "sp-application-crypto", path = "../../primitives/application-crypto", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } inherents = { package = "sp-inherents", path = "../../primitives/inherents", default-features = false } primitives = { package = "sp-core", path = "../../primitives/core", default-features = false } diff --git a/frame/authority-discovery/Cargo.toml b/frame/authority-discovery/Cargo.toml index 7d52faf3f8..7909006901 100644 --- a/frame/authority-discovery/Cargo.toml +++ b/frame/authority-discovery/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" [dependencies] authority-discovery-primitives = { package = "sp-authority-discovery", path = "../../primitives/authority-discovery", default-features = false } -app-crypto = { package = "sc-application-crypto", path = "../../primitives/application-crypto", default-features = false } +app-crypto = { package = "sp-application-crypto", path = "../../primitives/application-crypto", 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 } diff --git a/frame/im-online/Cargo.toml b/frame/im-online/Cargo.toml index 5110f511d1..cac2d49c5c 100644 --- a/frame/im-online/Cargo.toml +++ b/frame/im-online/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -app-crypto = { package = "sc-application-crypto", path = "../../primitives/application-crypto", default-features = false } +app-crypto = { package = "sp-application-crypto", path = "../../primitives/application-crypto", default-features = false } authorship = { package = "pallet-authorship", path = "../authorship", 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 } diff --git a/frame/session/Cargo.toml b/frame/session/Cargo.toml index 3df9b868f9..b5a6efc476 100644 --- a/frame/session/Cargo.toml +++ b/frame/session/Cargo.toml @@ -20,7 +20,7 @@ impl-trait-for-tuples = "0.1.3" [dev-dependencies] primitives = { package = "sp-core", path = "../../primitives/core" } -app-crypto = { package = "sc-application-crypto", path = "../../primitives/application-crypto" } +app-crypto = { package = "sp-application-crypto", path = "../../primitives/application-crypto" } lazy_static = "1.4.0" [features] diff --git a/primitives/application-crypto/Cargo.toml b/primitives/application-crypto/Cargo.toml index 1c7c647bb6..79b3f35f6b 100644 --- a/primitives/application-crypto/Cargo.toml +++ b/primitives/application-crypto/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "sc-application-crypto" +name = "sp-application-crypto" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" @@ -12,10 +12,6 @@ serde = { version = "1.0.101", optional = true, features = ["derive"] } sp-std = { path = "../std", 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" } -sp-runtime = { path = "../../primitives/runtime" } - [features] default = [ "std" ] std = [ "full_crypto", "primitives/std", "codec/std", "serde", "sp-std/std", "sp-io/std" ] diff --git a/primitives/application-crypto/src/ed25519.rs b/primitives/application-crypto/src/ed25519.rs index 5097b8e4dc..2ac94ac423 100644 --- a/primitives/application-crypto/src/ed25519.rs +++ b/primitives/application-crypto/src/ed25519.rs @@ -55,26 +55,3 @@ impl RuntimePublic for Public { } } -#[cfg(test)] -mod tests { - use sp_runtime::{generic::BlockId, traits::ProvideRuntimeApi}; - use primitives::{testing::{KeyStore, ED25519}, crypto::Pair}; - use test_client::{ - TestClientBuilder, DefaultTestClientBuilderExt, TestClientBuilderExt, - runtime::{TestAPI, app_crypto::ed25519::{AppPair, AppPublic}}, - }; - - #[test] - fn ed25519_works_in_runtime() { - let keystore = KeyStore::new(); - let test_client = TestClientBuilder::new().set_keystore(keystore.clone()).build(); - let (signature, public) = test_client.runtime_api() - .test_ed25519_crypto(&BlockId::Number(0)) - .expect("Tests `ed25519` crypto."); - - let key_pair = keystore.read().ed25519_key_pair(ED25519, &public.as_ref()) - .expect("There should be at a `ed25519` key in the keystore for the given public key."); - - assert!(AppPair::verify(&signature, "ed25519", &AppPublic::from(key_pair.public()))); - } -} diff --git a/primitives/application-crypto/src/lib.rs b/primitives/application-crypto/src/lib.rs index d7c303e338..12972b4707 100644 --- a/primitives/application-crypto/src/lib.rs +++ b/primitives/application-crypto/src/lib.rs @@ -45,7 +45,7 @@ pub use traits::*; /// Application-specific types whose identifier is `$key_type`. /// /// ```rust -///# use sc_application_crypto::{app_crypto, wrap, ed25519, KeyTypeId}; +///# use sp_application_crypto::{app_crypto, wrap, ed25519, KeyTypeId}; /// // Declare a new set of crypto types using Ed25519 logic that identifies as `KeyTypeId` /// // of value `b"fuba"`. /// app_crypto!(ed25519, KeyTypeId(*b"_uba")); @@ -66,7 +66,7 @@ macro_rules! app_crypto { /// Application-specific types whose identifier is `$key_type`. /// /// ```rust -///# use sc_application_crypto::{app_crypto, wrap, ed25519, KeyTypeId}; +///# use sp_application_crypto::{app_crypto, wrap, ed25519, KeyTypeId}; /// // Declare a new set of crypto types using Ed25519 logic that identifies as `KeyTypeId` /// // of value `b"fuba"`. /// app_crypto!(ed25519, KeyTypeId(*b"_uba")); @@ -390,7 +390,7 @@ macro_rules! app_crypto_signature_common { /// Implement bidirectional `From` and on-way `AsRef`/`AsMut` for two types, `$inner` and `$outer`. /// /// ```rust -/// sc_application_crypto::wrap! { +/// sp_application_crypto::wrap! { /// pub struct Wrapper(u32); /// } /// ``` diff --git a/primitives/application-crypto/src/sr25519.rs b/primitives/application-crypto/src/sr25519.rs index e7b5c7f164..d49fc46cc2 100644 --- a/primitives/application-crypto/src/sr25519.rs +++ b/primitives/application-crypto/src/sr25519.rs @@ -53,28 +53,4 @@ impl RuntimePublic for Public { fn verify>(&self, msg: &M, signature: &Self::Signature) -> bool { sp_io::crypto::sr25519_verify(&signature, msg.as_ref(), self) } -} - -#[cfg(test)] -mod tests { - use sp_runtime::{generic::BlockId, traits::ProvideRuntimeApi}; - use primitives::{testing::{KeyStore, SR25519}, crypto::Pair}; - use test_client::{ - TestClientBuilder, DefaultTestClientBuilderExt, TestClientBuilderExt, - runtime::{TestAPI, app_crypto::sr25519::{AppPair, AppPublic}}, - }; - - #[test] - fn sr25519_works_in_runtime() { - let keystore = KeyStore::new(); - let test_client = TestClientBuilder::new().set_keystore(keystore.clone()).build(); - let (signature, public) = test_client.runtime_api() - .test_sr25519_crypto(&BlockId::Number(0)) - .expect("Tests `sr25519` crypto."); - - let key_pair = keystore.read().sr25519_key_pair(SR25519, public.as_ref()) - .expect("There should be at a `sr25519` key in the keystore for the given public key."); - - assert!(AppPair::verify(&signature, "sr25519", &AppPublic::from(key_pair.public()))); - } -} +} \ No newline at end of file diff --git a/primitives/application-crypto/test/Cargo.toml b/primitives/application-crypto/test/Cargo.toml new file mode 100644 index 0000000000..e5eed8f5b3 --- /dev/null +++ b/primitives/application-crypto/test/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "sp-application-crypto-test" +version = "2.0.0" +authors = ["Parity Technologies "] +edition = "2018" +description = "Integration tests for application-crypto" +publish = false + +[dependencies] +primitives = { package = "sp-core", path = "../../core", default-features = false } +test-client = { package = "substrate-test-runtime-client", path = "../../../test/utils/runtime/client" } +sp-runtime = { path = "../../runtime" } \ No newline at end of file diff --git a/primitives/application-crypto/test/src/ed25519.rs b/primitives/application-crypto/test/src/ed25519.rs new file mode 100644 index 0000000000..0e66e5b3ff --- /dev/null +++ b/primitives/application-crypto/test/src/ed25519.rs @@ -0,0 +1,38 @@ +// Copyright 2019 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Substrate is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Substrate. If not, see . + +//! Integration tests for ed25519 + +use sp_runtime::{generic::BlockId, traits::ProvideRuntimeApi}; +use primitives::{testing::{KeyStore, ED25519}, crypto::Pair}; +use test_client::{ + TestClientBuilder, DefaultTestClientBuilderExt, TestClientBuilderExt, + runtime::{TestAPI, app_crypto::ed25519::{AppPair, AppPublic}}, +}; + +#[test] +fn ed25519_works_in_runtime() { + let keystore = KeyStore::new(); + let test_client = TestClientBuilder::new().set_keystore(keystore.clone()).build(); + let (signature, public) = test_client.runtime_api() + .test_ed25519_crypto(&BlockId::Number(0)) + .expect("Tests `ed25519` crypto."); + + let key_pair = keystore.read().ed25519_key_pair(ED25519, &public.as_ref()) + .expect("There should be at a `ed25519` key in the keystore for the given public key."); + + assert!(AppPair::verify(&signature, "ed25519", &AppPublic::from(key_pair.public()))); +} \ No newline at end of file diff --git a/primitives/application-crypto/test/src/lib.rs b/primitives/application-crypto/test/src/lib.rs new file mode 100644 index 0000000000..282ace5b1f --- /dev/null +++ b/primitives/application-crypto/test/src/lib.rs @@ -0,0 +1,22 @@ +// Copyright 2019 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Substrate is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Substrate. If not, see . + +//! Integration tests for application crypto + +#[cfg(test)] +mod ed25519; +#[cfg(test)] +mod sr25519; \ No newline at end of file diff --git a/primitives/application-crypto/test/src/sr25519.rs b/primitives/application-crypto/test/src/sr25519.rs new file mode 100644 index 0000000000..50981f4677 --- /dev/null +++ b/primitives/application-crypto/test/src/sr25519.rs @@ -0,0 +1,39 @@ +// Copyright 2019 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Substrate is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Substrate. If not, see . + +//! Integration tests for sr25519 + + +use sp_runtime::{generic::BlockId, traits::ProvideRuntimeApi}; +use primitives::{testing::{KeyStore, SR25519}, crypto::Pair}; +use test_client::{ + TestClientBuilder, DefaultTestClientBuilderExt, TestClientBuilderExt, + runtime::{TestAPI, app_crypto::sr25519::{AppPair, AppPublic}}, +}; + +#[test] +fn sr25519_works_in_runtime() { + let keystore = KeyStore::new(); + let test_client = TestClientBuilder::new().set_keystore(keystore.clone()).build(); + let (signature, public) = test_client.runtime_api() + .test_sr25519_crypto(&BlockId::Number(0)) + .expect("Tests `sr25519` crypto."); + + let key_pair = keystore.read().sr25519_key_pair(SR25519, public.as_ref()) + .expect("There should be at a `sr25519` key in the keystore for the given public key."); + + assert!(AppPair::verify(&signature, "sr25519", &AppPublic::from(key_pair.public()))); +} \ No newline at end of file diff --git a/primitives/authority-discovery/Cargo.toml b/primitives/authority-discovery/Cargo.toml index 79df9e4169..aa8fa926ca 100644 --- a/primitives/authority-discovery/Cargo.toml +++ b/primitives/authority-discovery/Cargo.toml @@ -6,7 +6,7 @@ description = "Authority discovery primitives" edition = "2018" [dependencies] -app-crypto = { package = "sc-application-crypto", path = "../application-crypto", default-features = false } +app-crypto = { package = "sp-application-crypto", path = "../application-crypto", default-features = false } codec = { package = "parity-scale-codec", default-features = false, version = "1.0.3" } sp-std = { path = "../std", default-features = false } sp-api = { path = "../api", default-features = false } diff --git a/primitives/consensus/aura/Cargo.toml b/primitives/consensus/aura/Cargo.toml index 599083b17f..2a46cf015c 100644 --- a/primitives/consensus/aura/Cargo.toml +++ b/primitives/consensus/aura/Cargo.toml @@ -6,7 +6,7 @@ description = "Primitives for Aura consensus" edition = "2018" [dependencies] -app-crypto = { package = "sc-application-crypto", path = "../../application-crypto", default-features = false } +app-crypto = { package = "sp-application-crypto", path = "../../application-crypto", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } sp-std = { path = "../../std", default-features = false } sp-api = { path = "../../api", default-features = false } diff --git a/primitives/consensus/babe/Cargo.toml b/primitives/consensus/babe/Cargo.toml index 675363e5a9..0889f6f639 100644 --- a/primitives/consensus/babe/Cargo.toml +++ b/primitives/consensus/babe/Cargo.toml @@ -6,7 +6,7 @@ description = "Primitives for BABE consensus" edition = "2018" [dependencies] -app-crypto = { package = "sc-application-crypto", path = "../../application-crypto", default-features = false } +app-crypto = { package = "sp-application-crypto", path = "../../application-crypto", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } sp-std = { path = "../../std", default-features = false } schnorrkel = { version = "0.8.5", features = ["preaudit_deprecated"], optional = true } diff --git a/primitives/finality-grandpa/Cargo.toml b/primitives/finality-grandpa/Cargo.toml index 0e05cab228..6017745180 100644 --- a/primitives/finality-grandpa/Cargo.toml +++ b/primitives/finality-grandpa/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -app-crypto = { package = "sc-application-crypto", path = "../application-crypto", default-features = false } +app-crypto = { package = "sp-application-crypto", path = "../application-crypto", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } sp-std = { path = "../std", default-features = false } serde = { version = "1.0.101", optional = true, features = ["derive"] } diff --git a/primitives/runtime/Cargo.toml b/primitives/runtime/Cargo.toml index 94f841d10a..d149aa089e 100644 --- a/primitives/runtime/Cargo.toml +++ b/primitives/runtime/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" serde = { version = "1.0.101", optional = true, features = ["derive"] } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } primitives = { package = "sp-core", path = "../core", default-features = false } -app-crypto = { package = "sc-application-crypto", path = "../application-crypto", default-features = false } +app-crypto = { package = "sp-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 } sp-io = { path = "../io", default-features = false } diff --git a/primitives/test-primitives/Cargo.toml b/primitives/test-primitives/Cargo.toml index e54a6f5095..d8d66e91c4 100644 --- a/primitives/test-primitives/Cargo.toml +++ b/primitives/test-primitives/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -app-crypto = { package = "sc-application-crypto", path = "../application-crypto", default-features = false } +app-crypto = { package = "sp-application-crypto", path = "../application-crypto", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } primitives = { package = "sp-core", path = "../core", default-features = false } serde = { version = "1.0.101", optional = true, features = ["derive"] } diff --git a/test/utils/runtime/Cargo.toml b/test/utils/runtime/Cargo.toml index 87f9fd75bb..69a4396f4a 100644 --- a/test/utils/runtime/Cargo.toml +++ b/test/utils/runtime/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" build = "build.rs" [dependencies] -app-crypto = { package = "sc-application-crypto", path = "../../../primitives/application-crypto", default-features = false } +app-crypto = { package = "sp-application-crypto", path = "../../../primitives/application-crypto", default-features = false } aura-primitives = { package = "sp-consensus-aura", path = "../../../primitives/consensus/aura", default-features = false } babe-primitives = { package = "sp-consensus-babe", path = "../../../primitives/consensus/babe", default-features = false } block-builder-api = { package = "sp-block-builder", path = "../../../primitives/block-builder/runtime-api", default-features = false } -- GitLab From 600843e26fb0a31ed3374d3a493fb47f7509d7fd Mon Sep 17 00:00:00 2001 From: joe petrowski <25483142+joepetrowski@users.noreply.github.com> Date: Tue, 10 Dec 2019 23:31:27 +0100 Subject: [PATCH 120/172] fix typos in identity pallet docs (#4350) --- frame/identity/src/lib.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/frame/identity/src/lib.rs b/frame/identity/src/lib.rs index bea85f6a14..a4e6a46b6b 100644 --- a/frame/identity/src/lib.rs +++ b/frame/identity/src/lib.rs @@ -195,7 +195,8 @@ pub enum Judgement< /// The data appears to be reasonably acceptable in terms of its accuracy, however no in depth /// checks (such as in-person meetings or formal KYC) have been conducted. Reasonable, - /// The target is known directly by the registrar and can fully attest to being accurate. + /// The target is known directly by the registrar and the registrar can fully attest to the + /// the data's accuracy. KnownGood, /// The data was once good but is currently out of date. There is no malicious intent in the /// inaccuracy. This judgement can be removed through updating the data. @@ -269,11 +270,11 @@ impl Decode for IdentityFields { #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug)] #[cfg_attr(test, derive(Default))] pub struct IdentityInfo { - /// Additional fields of the identity that are not catered for with the structs explicit + /// Additional fields of the identity that are not catered for with the struct's explicit /// fields. pub additional: Vec<(Data, Data)>, - /// A reasonable display name for the controller of the account. This should be whatever is it + /// A reasonable display name for the controller of the account. This should be whatever it is /// that it is typically known as and should not be confusable with other entities, given /// reasonable context. /// @@ -306,7 +307,7 @@ pub struct IdentityInfo { /// The PGP/GPG public key of the controller of the account. pub pgp_fingerprint: Option<[u8; 20]>, - /// An graphic image representing the controller of the account. Should be a company, + /// A graphic image representing the controller of the account. Should be a company, /// organization or project logo or a headshot in the case of a human. pub image: Data, } @@ -319,7 +320,7 @@ pub struct IdentityInfo { pub struct Registration< Balance: Encode + Decode + Copy + Clone + Debug + Eq + PartialEq > { - /// Judgements from the registrars on this identity. Stored ordered by RegistrarIndex. There + /// Judgements from the registrars on this identity. Stored ordered by `RegistrarIndex`. There /// may be only a single judgement from each registrar. pub judgements: Vec<(RegistrarIndex, Judgement)>, @@ -340,7 +341,7 @@ impl < } } -/// Information concerning the a registrar. +/// Information concerning a registrar. #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug)] pub struct RegistrarInfo< Balance: Encode + Decode + Clone + Debug + Eq + PartialEq, @@ -349,7 +350,7 @@ pub struct RegistrarInfo< /// The account of the registrar. pub account: AccountId, - /// Amount required to be given to the registrar for them to check the account. + /// Amount required to be given to the registrar for them to provide judgement. pub fee: Balance, /// Relevant fields for this registrar. Registrar judgements are limited to attestations on -- GitLab From de0377779c99438c23b01a98496d107b08230ffb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Wed, 11 Dec 2019 09:32:11 +0100 Subject: [PATCH 121/172] Fix cycle dependency in `sp-runtime-interface` (#4353) * Fix cycle dependency in `sp-runtime-interface` * Fixes tests --- Cargo.lock | 7 +- primitives/runtime-interface/Cargo.toml | 2 + .../runtime-interface/proc-macro/Cargo.toml | 12 -- .../runtime-interface/proc-macro/src/lib.rs | 200 ------------------ primitives/runtime-interface/src/lib.rs | 144 +++++++++++++ primitives/runtime-interface/src/pass_by.rs | 65 +++++- .../{proc-macro => }/tests/ui.rs | 0 .../tests/ui/no_generic_parameters.rs | 2 +- .../tests/ui/no_generic_parameters.stderr | 0 .../tests/ui/no_method_implementation.rs | 2 +- .../tests/ui/no_method_implementation.stderr | 0 .../tests/ui/pass_by_enum_with_struct.rs | 2 +- .../tests/ui/pass_by_enum_with_struct.stderr | 0 .../ui/pass_by_enum_with_value_variant.rs | 2 +- .../ui/pass_by_enum_with_value_variant.stderr | 0 .../tests/ui/pass_by_inner_with_two_fields.rs | 2 +- .../ui/pass_by_inner_with_two_fields.stderr | 0 .../tests/ui/take_self_by_value.rs | 2 +- .../tests/ui/take_self_by_value.stderr | 0 19 files changed, 218 insertions(+), 224 deletions(-) rename primitives/runtime-interface/{proc-macro => }/tests/ui.rs (100%) rename primitives/runtime-interface/{proc-macro => }/tests/ui/no_generic_parameters.rs (61%) rename primitives/runtime-interface/{proc-macro => }/tests/ui/no_generic_parameters.stderr (100%) rename primitives/runtime-interface/{proc-macro => }/tests/ui/no_method_implementation.rs (58%) rename primitives/runtime-interface/{proc-macro => }/tests/ui/no_method_implementation.stderr (100%) rename primitives/runtime-interface/{proc-macro => }/tests/ui/pass_by_enum_with_struct.rs (51%) rename primitives/runtime-interface/{proc-macro => }/tests/ui/pass_by_enum_with_struct.stderr (100%) rename primitives/runtime-interface/{proc-macro => }/tests/ui/pass_by_enum_with_value_variant.rs (57%) rename primitives/runtime-interface/{proc-macro => }/tests/ui/pass_by_enum_with_value_variant.stderr (100%) rename primitives/runtime-interface/{proc-macro => }/tests/ui/pass_by_inner_with_two_fields.rs (62%) rename primitives/runtime-interface/{proc-macro => }/tests/ui/pass_by_inner_with_two_fields.stderr (100%) rename primitives/runtime-interface/{proc-macro => }/tests/ui/take_self_by_value.rs (60%) rename primitives/runtime-interface/{proc-macro => }/tests/ui/take_self_by_value.stderr (100%) diff --git a/Cargo.lock b/Cargo.lock index 89e8ccd33a..b57ca6e54e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6325,6 +6325,7 @@ dependencies = [ "environmental 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "primitive-types 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rustversion 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "sc-executor 2.0.0", "sp-core 2.0.0", "sp-externalities 2.0.0", @@ -6335,6 +6336,7 @@ dependencies = [ "sp-std 2.0.0", "sp-wasm-interface 2.0.0", "static_assertions 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "trybuild 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -6342,15 +6344,10 @@ name = "sp-runtime-interface-proc-macro" version = "2.0.0" dependencies = [ "Inflector 0.11.4 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rustversion 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-externalities 2.0.0", - "sp-runtime-interface 2.0.0", "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", - "trybuild 1.0.18 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] diff --git a/primitives/runtime-interface/Cargo.toml b/primitives/runtime-interface/Cargo.toml index cebc5286f6..704ae1b243 100644 --- a/primitives/runtime-interface/Cargo.toml +++ b/primitives/runtime-interface/Cargo.toml @@ -20,6 +20,8 @@ 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" } sp-io = { path = "../io" } +rustversion = "1.0.0" +trybuild = "1.0.17" [features] default = [ "std" ] diff --git a/primitives/runtime-interface/proc-macro/Cargo.toml b/primitives/runtime-interface/proc-macro/Cargo.toml index 2fcaa59447..a5d12de0a6 100644 --- a/primitives/runtime-interface/proc-macro/Cargo.toml +++ b/primitives/runtime-interface/proc-macro/Cargo.toml @@ -13,15 +13,3 @@ quote = "1.0.2" proc-macro2 = "1.0.3" Inflector = "0.11.4" proc-macro-crate = "0.1.4" - -[dev-dependencies] -runtime-interface = { package = "sp-runtime-interface", path = ".." } -codec = { package = "parity-scale-codec", version = "1.0.6", features = ["derive"] } -externalities = { package = "sp-externalities", path = "../../externalities" } -rustversion = "1.0.0" -trybuild = "1.0.17" - -# We actually don't need the `std` feature in this crate, but the tests require it. -[features] -default = [ "std" ] -std = [] diff --git a/primitives/runtime-interface/proc-macro/src/lib.rs b/primitives/runtime-interface/proc-macro/src/lib.rs index 023a97c117..af18165457 100644 --- a/primitives/runtime-interface/proc-macro/src/lib.rs +++ b/primitives/runtime-interface/proc-macro/src/lib.rs @@ -33,148 +33,6 @@ mod pass_by; mod runtime_interface; mod utils; -/// Attribute macro for transforming a trait declaration into a runtime interface. -/// -/// A runtime interface is a fixed interface between a Substrate compatible runtime and the native -/// node. This interface is callable from a native and a wasm runtime. The macro will generate the -/// corresponding code for the native implementation and the code for calling from the wasm -/// side to the native implementation. -/// -/// The macro expects the runtime interface declaration as trait declaration: -/// -/// ``` -/// # use runtime_interface::runtime_interface; -/// -/// #[runtime_interface] -/// trait Interface { -/// /// A function that can be called from native/wasm. -/// /// -/// /// The implementation given to this function is only compiled on native. -/// fn call_some_complex_code(data: &[u8]) -> Vec { -/// // Here you could call some rather complex code that only compiles on native or -/// // is way faster in native than executing it in wasm. -/// Vec::new() -/// } -/// -/// /// A function can take a `&self` or `&mut self` argument to get access to the -/// /// `Externalities`. (The generated method does not require -/// /// this argument, so the function can be called just with the `optional` argument) -/// fn set_or_clear(&mut self, optional: Option>) { -/// match optional { -/// Some(value) => self.set_storage([1, 2, 3, 4].to_vec(), value), -/// None => self.clear_storage(&[1, 2, 3, 4]), -/// } -/// } -/// } -/// ``` -/// -/// -/// The given example will generate roughly the following code for native: -/// -/// ``` -/// // The name of the trait is converted to snake case and used as mod name. -/// // -/// // Be aware that this module is not `public`, the visibility of the module is determined based -/// // on the visibility of the trait declaration. -/// mod interface { -/// trait Interface { -/// fn call_some_complex_code(data: &[u8]) -> Vec; -/// fn set_or_clear(&mut self, optional: Option>); -/// } -/// -/// impl Interface for &mut dyn externalities::Externalities { -/// fn call_some_complex_code(data: &[u8]) -> Vec { Vec::new() } -/// fn set_or_clear(&mut self, optional: Option>) { -/// match optional { -/// Some(value) => self.set_storage([1, 2, 3, 4].to_vec(), value), -/// None => self.clear_storage(&[1, 2, 3, 4]), -/// } -/// } -/// } -/// -/// pub fn call_some_complex_code(data: &[u8]) -> Vec { -/// <&mut dyn externalities::Externalities as Interface>::call_some_complex_code(data) -/// } -/// -/// pub fn set_or_clear(optional: Option>) { -/// externalities::with_externalities(|mut ext| Interface::set_or_clear(&mut ext, optional)) -/// .expect("`set_or_clear` called outside of an Externalities-provided environment.") -/// } -/// -/// /// This type implements the `HostFunctions` trait (from `sp-wasm-interface`) and -/// /// provides the host implementation for the wasm side. The host implementation converts the -/// /// arguments from wasm to native and calls the corresponding native function. -/// /// -/// /// This type needs to be passed to the wasm executor, so that the host functions will be -/// /// registered in the executor. -/// pub struct HostFunctions; -/// } -/// ``` -/// -/// -/// The given example will generate roughly the following code for wasm: -/// -/// ``` -/// mod interface { -/// mod extern_host_functions_impls { -/// extern "C" { -/// /// Every function is exported as `ext_TRAIT_NAME_FUNCTION_NAME_version_VERSION`. -/// /// -/// /// `TRAIT_NAME` is converted into snake case. -/// /// -/// /// The type for each argument of the exported function depends on -/// /// `::FFIType`. -/// /// -/// /// `data` holds the pointer and the length to the `[u8]` slice. -/// pub fn ext_Interface_call_some_complex_code_version_1(data: u64) -> u64; -/// /// `optional` holds the pointer and the length of the encoded value. -/// pub fn ext_Interface_set_or_clear_version_1(optional: u64); -/// } -/// } -/// -/// /// The type is actually `ExchangeableFunction` (from `sp-runtime-interface`). -/// /// -/// /// This can be used to replace the implementation of the `call_some_complex_code` function. -/// /// Instead of calling into the host, the callee will automatically call the other -/// /// implementation. -/// /// -/// /// To replace the implementation: -/// /// -/// /// `host_call_some_complex_code.replace_implementation(some_other_impl)` -/// pub static host_call_some_complex_code: () = (); -/// pub static host_set_or_clear: () = (); -/// -/// pub fn call_some_complex_code(data: &[u8]) -> Vec { -/// // This is the actual call: `host_call_some_complex_code.get()(data)` -/// // -/// // But that does not work for several reasons in this example, so we just return an -/// // empty vector. -/// Vec::new() -/// } -/// -/// pub fn set_or_clear(optional: Option>) { -/// // Same as above -/// } -/// } -/// ``` -/// -/// # Argument types -/// -/// The macro supports any kind of argument type, as long as it implements `RIType` and the required -/// `FromFFIValue`/`IntoFFIValue` from `sp-runtime-interface`. The macro will convert each -/// argument to the corresponding FFI representation and will call into the host using this FFI -/// representation. On the host each argument is converted back to the native representation and -/// the native implementation is called. Any return value is handled in the same way. -/// -/// # Wasm only interfaces -/// -/// Some interfaces are only required from within the wasm runtime e.g. the allocator interface. -/// To support this, the macro can be called like `#[runtime_interface(wasm_only)]`. This instructs -/// the macro to make two significant changes to the generated code: -/// -/// 1. The generated functions are not callable from the native side. -/// 2. The trait as shown above is not implemented for `Externalities` and is instead implemented -/// for `FunctionExecutor` (from `sp-wasm-interface`). #[proc_macro_attribute] pub fn runtime_interface( attrs: proc_macro::TokenStream, @@ -188,76 +46,18 @@ pub fn runtime_interface( .into() } -/// Derive macro for implementing `PassBy` with the `Codec` strategy. -/// -/// This requires that the type implements `Encode` and `Decode` from `parity-scale-codec`. -/// -/// # Example -/// -/// ``` -/// # use runtime_interface::pass_by::PassByCodec; -/// # use codec::{Encode, Decode}; -/// #[derive(PassByCodec, Encode, Decode)] -/// struct EncodableType { -/// name: Vec, -/// param: u32, -/// } -/// ``` #[proc_macro_derive(PassByCodec)] pub fn pass_by_codec(input: proc_macro::TokenStream) -> proc_macro::TokenStream { let input = parse_macro_input!(input as DeriveInput); pass_by::codec_derive_impl(input).unwrap_or_else(|e| e.to_compile_error()).into() } -/// Derive macro for implementing `PassBy` with the `Inner` strategy. -/// -/// Besides implementing `PassBy`, this derive also implements the helper trait `PassByInner`. -/// -/// The type is required to be a struct with just one field. The field type needs to implement -/// the required traits to pass it between the wasm and the native side. (See the runtime interface -/// crate for more information about these traits.) -/// -/// # Example -/// -/// ``` -/// # use runtime_interface::pass_by::PassByInner; -/// #[derive(PassByInner)] -/// struct Data([u8; 32]); -/// ``` -/// -/// ``` -/// # use runtime_interface::pass_by::PassByInner; -/// #[derive(PassByInner)] -/// struct Data { -/// data: [u8; 32], -/// } -/// ``` #[proc_macro_derive(PassByInner)] pub fn pass_by_inner(input: proc_macro::TokenStream) -> proc_macro::TokenStream { let input = parse_macro_input!(input as DeriveInput); pass_by::inner_derive_impl(input).unwrap_or_else(|e| e.to_compile_error()).into() } -/// Derive macro for implementing `PassBy` with the `Enum` strategy. -/// -/// Besides implementing `PassBy`, this derive also implements `TryFrom` and `From for u8` -/// for the type. -/// -/// The type is required to be an enum with only unit variants and at maximum `256` variants. Also -/// it is required that the type implements `Copy`. -/// -/// # Example -/// -/// ``` -/// # use runtime_interface::pass_by::PassByEnum; -/// #[derive(PassByEnum, Copy, Clone)] -/// enum Data { -/// Okay, -/// NotOkay, -/// // This will not work with the derive. -/// //Why(u32), -/// } -/// ``` #[proc_macro_derive(PassByEnum)] pub fn pass_by_enum(input: proc_macro::TokenStream) -> proc_macro::TokenStream { let input = parse_macro_input!(input as DeriveInput); diff --git a/primitives/runtime-interface/src/lib.rs b/primitives/runtime-interface/src/lib.rs index 3a2a780d2d..ac172a9bc8 100644 --- a/primitives/runtime-interface/src/lib.rs +++ b/primitives/runtime-interface/src/lib.rs @@ -72,6 +72,8 @@ #![cfg_attr(not(feature = "std"), no_std)] +extern crate self as sp_runtime_interface; + #[doc(hidden)] #[cfg(feature = "std")] pub use wasm_interface; @@ -79,6 +81,148 @@ pub use wasm_interface; #[doc(hidden)] pub use sp_std; +/// Attribute macro for transforming a trait declaration into a runtime interface. +/// +/// A runtime interface is a fixed interface between a Substrate compatible runtime and the native +/// node. This interface is callable from a native and a wasm runtime. The macro will generate the +/// corresponding code for the native implementation and the code for calling from the wasm +/// side to the native implementation. +/// +/// The macro expects the runtime interface declaration as trait declaration: +/// +/// ``` +/// # use sp_runtime_interface::runtime_interface; +/// +/// #[runtime_interface] +/// trait Interface { +/// /// A function that can be called from native/wasm. +/// /// +/// /// The implementation given to this function is only compiled on native. +/// fn call_some_complex_code(data: &[u8]) -> Vec { +/// // Here you could call some rather complex code that only compiles on native or +/// // is way faster in native than executing it in wasm. +/// Vec::new() +/// } +/// +/// /// A function can take a `&self` or `&mut self` argument to get access to the +/// /// `Externalities`. (The generated method does not require +/// /// this argument, so the function can be called just with the `optional` argument) +/// fn set_or_clear(&mut self, optional: Option>) { +/// match optional { +/// Some(value) => self.set_storage([1, 2, 3, 4].to_vec(), value), +/// None => self.clear_storage(&[1, 2, 3, 4]), +/// } +/// } +/// } +/// ``` +/// +/// +/// The given example will generate roughly the following code for native: +/// +/// ``` +/// // The name of the trait is converted to snake case and used as mod name. +/// // +/// // Be aware that this module is not `public`, the visibility of the module is determined based +/// // on the visibility of the trait declaration. +/// mod interface { +/// trait Interface { +/// fn call_some_complex_code(data: &[u8]) -> Vec; +/// fn set_or_clear(&mut self, optional: Option>); +/// } +/// +/// impl Interface for &mut dyn externalities::Externalities { +/// fn call_some_complex_code(data: &[u8]) -> Vec { Vec::new() } +/// fn set_or_clear(&mut self, optional: Option>) { +/// match optional { +/// Some(value) => self.set_storage([1, 2, 3, 4].to_vec(), value), +/// None => self.clear_storage(&[1, 2, 3, 4]), +/// } +/// } +/// } +/// +/// pub fn call_some_complex_code(data: &[u8]) -> Vec { +/// <&mut dyn externalities::Externalities as Interface>::call_some_complex_code(data) +/// } +/// +/// pub fn set_or_clear(optional: Option>) { +/// externalities::with_externalities(|mut ext| Interface::set_or_clear(&mut ext, optional)) +/// .expect("`set_or_clear` called outside of an Externalities-provided environment.") +/// } +/// +/// /// This type implements the `HostFunctions` trait (from `sp-wasm-interface`) and +/// /// provides the host implementation for the wasm side. The host implementation converts the +/// /// arguments from wasm to native and calls the corresponding native function. +/// /// +/// /// This type needs to be passed to the wasm executor, so that the host functions will be +/// /// registered in the executor. +/// pub struct HostFunctions; +/// } +/// ``` +/// +/// +/// The given example will generate roughly the following code for wasm: +/// +/// ``` +/// mod interface { +/// mod extern_host_functions_impls { +/// extern "C" { +/// /// Every function is exported as `ext_TRAIT_NAME_FUNCTION_NAME_version_VERSION`. +/// /// +/// /// `TRAIT_NAME` is converted into snake case. +/// /// +/// /// The type for each argument of the exported function depends on +/// /// `::FFIType`. +/// /// +/// /// `data` holds the pointer and the length to the `[u8]` slice. +/// pub fn ext_Interface_call_some_complex_code_version_1(data: u64) -> u64; +/// /// `optional` holds the pointer and the length of the encoded value. +/// pub fn ext_Interface_set_or_clear_version_1(optional: u64); +/// } +/// } +/// +/// /// The type is actually `ExchangeableFunction` (from `sp-runtime-interface`). +/// /// +/// /// This can be used to replace the implementation of the `call_some_complex_code` function. +/// /// Instead of calling into the host, the callee will automatically call the other +/// /// implementation. +/// /// +/// /// To replace the implementation: +/// /// +/// /// `host_call_some_complex_code.replace_implementation(some_other_impl)` +/// pub static host_call_some_complex_code: () = (); +/// pub static host_set_or_clear: () = (); +/// +/// pub fn call_some_complex_code(data: &[u8]) -> Vec { +/// // This is the actual call: `host_call_some_complex_code.get()(data)` +/// // +/// // But that does not work for several reasons in this example, so we just return an +/// // empty vector. +/// Vec::new() +/// } +/// +/// pub fn set_or_clear(optional: Option>) { +/// // Same as above +/// } +/// } +/// ``` +/// +/// # Argument types +/// +/// The macro supports any kind of argument type, as long as it implements [`RIType`] and the +/// required `FromFFIValue`/`IntoFFIValue`. The macro will convert each +/// argument to the corresponding FFI representation and will call into the host using this FFI +/// representation. On the host each argument is converted back to the native representation and +/// the native implementation is called. Any return value is handled in the same way. +/// +/// # Wasm only interfaces +/// +/// Some interfaces are only required from within the wasm runtime e.g. the allocator interface. +/// To support this, the macro can be called like `#[runtime_interface(wasm_only)]`. This instructs +/// the macro to make two significant changes to the generated code: +/// +/// 1. The generated functions are not callable from the native side. +/// 2. The trait as shown above is not implemented for `Externalities` and is instead implemented +/// for `FunctionExecutor` (from `sp-wasm-interface`). pub use sp_runtime_interface_proc_macro::runtime_interface; #[doc(hidden)] diff --git a/primitives/runtime-interface/src/pass_by.rs b/primitives/runtime-interface/src/pass_by.rs index 96cd6314ba..5d5b98244e 100644 --- a/primitives/runtime-interface/src/pass_by.rs +++ b/primitives/runtime-interface/src/pass_by.rs @@ -35,7 +35,70 @@ use sp_std::{marker::PhantomData, convert::TryFrom}; #[cfg(not(feature = "std"))] use sp_std::{slice, vec::Vec}; -pub use sp_runtime_interface_proc_macro::{PassByCodec, PassByInner, PassByEnum}; +/// Derive macro for implementing [`PassBy`] with the [`Codec`] strategy. +/// +/// This requires that the type implements [`Encode`](codec::Encode) and [`Decode`](codec::Decode) +/// from `parity-scale-codec`. +/// +/// # Example +/// +/// ``` +/// # use sp_runtime_interface::pass_by::PassByCodec; +/// # use codec::{Encode, Decode}; +/// #[derive(PassByCodec, Encode, Decode)] +/// struct EncodableType { +/// name: Vec, +/// param: u32, +/// } +/// ``` +pub use sp_runtime_interface_proc_macro::PassByCodec; + +/// Derive macro for implementing [`PassBy`] with the [`Inner`] strategy. +/// +/// Besides implementing [`PassBy`], this derive also implements the helper trait [`PassByInner`]. +/// +/// The type is required to be a struct with just one field. The field type needs to implement +/// the required traits to pass it between the wasm and the native side. (See the runtime interface +/// crate for more information about these traits.) +/// +/// # Example +/// +/// ``` +/// # use sp_runtime_interface::pass_by::PassByInner; +/// #[derive(PassByInner)] +/// struct Data([u8; 32]); +/// ``` +/// +/// ``` +/// # use sp_runtime_interface::pass_by::PassByInner; +/// #[derive(PassByInner)] +/// struct Data { +/// data: [u8; 32], +/// } +/// ``` +pub use sp_runtime_interface_proc_macro::PassByInner; + +/// Derive macro for implementing [`PassBy`] with the [`Enum`] strategy. +/// +/// Besides implementing [`PassBy`], this derive also implements `TryFrom` and +/// `From for u8` for the type. +/// +/// The type is required to be an enum with only unit variants and at maximum `256` variants. Also +/// it is required that the type implements `Copy`. +/// +/// # Example +/// +/// ``` +/// # use sp_runtime_interface::pass_by::PassByEnum; +/// #[derive(PassByEnum, Copy, Clone)] +/// enum Data { +/// Okay, +/// NotOkay, +/// // This will not work with the derive. +/// //Why(u32), +/// } +/// ``` +pub use sp_runtime_interface_proc_macro::PassByEnum; /// Something that should be passed between wasm and the host using the given strategy. /// diff --git a/primitives/runtime-interface/proc-macro/tests/ui.rs b/primitives/runtime-interface/tests/ui.rs similarity index 100% rename from primitives/runtime-interface/proc-macro/tests/ui.rs rename to primitives/runtime-interface/tests/ui.rs diff --git a/primitives/runtime-interface/proc-macro/tests/ui/no_generic_parameters.rs b/primitives/runtime-interface/tests/ui/no_generic_parameters.rs similarity index 61% rename from primitives/runtime-interface/proc-macro/tests/ui/no_generic_parameters.rs rename to primitives/runtime-interface/tests/ui/no_generic_parameters.rs index 489fe5d9b4..17ddb00fab 100644 --- a/primitives/runtime-interface/proc-macro/tests/ui/no_generic_parameters.rs +++ b/primitives/runtime-interface/tests/ui/no_generic_parameters.rs @@ -1,4 +1,4 @@ -use runtime_interface::runtime_interface; +use sp_runtime_interface::runtime_interface; #[runtime_interface] trait Test { diff --git a/primitives/runtime-interface/proc-macro/tests/ui/no_generic_parameters.stderr b/primitives/runtime-interface/tests/ui/no_generic_parameters.stderr similarity index 100% rename from primitives/runtime-interface/proc-macro/tests/ui/no_generic_parameters.stderr rename to primitives/runtime-interface/tests/ui/no_generic_parameters.stderr diff --git a/primitives/runtime-interface/proc-macro/tests/ui/no_method_implementation.rs b/primitives/runtime-interface/tests/ui/no_method_implementation.rs similarity index 58% rename from primitives/runtime-interface/proc-macro/tests/ui/no_method_implementation.rs rename to primitives/runtime-interface/tests/ui/no_method_implementation.rs index 5291942420..e3cd93e4a9 100644 --- a/primitives/runtime-interface/proc-macro/tests/ui/no_method_implementation.rs +++ b/primitives/runtime-interface/tests/ui/no_method_implementation.rs @@ -1,4 +1,4 @@ -use runtime_interface::runtime_interface; +use sp_runtime_interface::runtime_interface; #[runtime_interface] trait Test { diff --git a/primitives/runtime-interface/proc-macro/tests/ui/no_method_implementation.stderr b/primitives/runtime-interface/tests/ui/no_method_implementation.stderr similarity index 100% rename from primitives/runtime-interface/proc-macro/tests/ui/no_method_implementation.stderr rename to primitives/runtime-interface/tests/ui/no_method_implementation.stderr diff --git a/primitives/runtime-interface/proc-macro/tests/ui/pass_by_enum_with_struct.rs b/primitives/runtime-interface/tests/ui/pass_by_enum_with_struct.rs similarity index 51% rename from primitives/runtime-interface/proc-macro/tests/ui/pass_by_enum_with_struct.rs rename to primitives/runtime-interface/tests/ui/pass_by_enum_with_struct.rs index a729e0a99a..6f4ae37ea4 100644 --- a/primitives/runtime-interface/proc-macro/tests/ui/pass_by_enum_with_struct.rs +++ b/primitives/runtime-interface/tests/ui/pass_by_enum_with_struct.rs @@ -1,4 +1,4 @@ -use runtime_interface::pass_by::PassByEnum; +use sp_runtime_interface::pass_by::PassByEnum; #[derive(PassByEnum)] struct Test; diff --git a/primitives/runtime-interface/proc-macro/tests/ui/pass_by_enum_with_struct.stderr b/primitives/runtime-interface/tests/ui/pass_by_enum_with_struct.stderr similarity index 100% rename from primitives/runtime-interface/proc-macro/tests/ui/pass_by_enum_with_struct.stderr rename to primitives/runtime-interface/tests/ui/pass_by_enum_with_struct.stderr diff --git a/primitives/runtime-interface/proc-macro/tests/ui/pass_by_enum_with_value_variant.rs b/primitives/runtime-interface/tests/ui/pass_by_enum_with_value_variant.rs similarity index 57% rename from primitives/runtime-interface/proc-macro/tests/ui/pass_by_enum_with_value_variant.rs rename to primitives/runtime-interface/tests/ui/pass_by_enum_with_value_variant.rs index d2558e7977..a03bfdc1ae 100644 --- a/primitives/runtime-interface/proc-macro/tests/ui/pass_by_enum_with_value_variant.rs +++ b/primitives/runtime-interface/tests/ui/pass_by_enum_with_value_variant.rs @@ -1,4 +1,4 @@ -use runtime_interface::pass_by::PassByEnum; +use sp_runtime_interface::pass_by::PassByEnum; #[derive(PassByEnum)] enum Test { diff --git a/primitives/runtime-interface/proc-macro/tests/ui/pass_by_enum_with_value_variant.stderr b/primitives/runtime-interface/tests/ui/pass_by_enum_with_value_variant.stderr similarity index 100% rename from primitives/runtime-interface/proc-macro/tests/ui/pass_by_enum_with_value_variant.stderr rename to primitives/runtime-interface/tests/ui/pass_by_enum_with_value_variant.stderr diff --git a/primitives/runtime-interface/proc-macro/tests/ui/pass_by_inner_with_two_fields.rs b/primitives/runtime-interface/tests/ui/pass_by_inner_with_two_fields.rs similarity index 62% rename from primitives/runtime-interface/proc-macro/tests/ui/pass_by_inner_with_two_fields.rs rename to primitives/runtime-interface/tests/ui/pass_by_inner_with_two_fields.rs index eab79eae19..f496bc3700 100644 --- a/primitives/runtime-interface/proc-macro/tests/ui/pass_by_inner_with_two_fields.rs +++ b/primitives/runtime-interface/tests/ui/pass_by_inner_with_two_fields.rs @@ -1,4 +1,4 @@ -use runtime_interface::pass_by::PassByInner; +use sp_runtime_interface::pass_by::PassByInner; #[derive(PassByInner)] struct Test { diff --git a/primitives/runtime-interface/proc-macro/tests/ui/pass_by_inner_with_two_fields.stderr b/primitives/runtime-interface/tests/ui/pass_by_inner_with_two_fields.stderr similarity index 100% rename from primitives/runtime-interface/proc-macro/tests/ui/pass_by_inner_with_two_fields.stderr rename to primitives/runtime-interface/tests/ui/pass_by_inner_with_two_fields.stderr diff --git a/primitives/runtime-interface/proc-macro/tests/ui/take_self_by_value.rs b/primitives/runtime-interface/tests/ui/take_self_by_value.rs similarity index 60% rename from primitives/runtime-interface/proc-macro/tests/ui/take_self_by_value.rs rename to primitives/runtime-interface/tests/ui/take_self_by_value.rs index f01c2de21e..9c12614d93 100644 --- a/primitives/runtime-interface/proc-macro/tests/ui/take_self_by_value.rs +++ b/primitives/runtime-interface/tests/ui/take_self_by_value.rs @@ -1,4 +1,4 @@ -use runtime_interface::runtime_interface; +use sp_runtime_interface::runtime_interface; #[runtime_interface] trait Test { diff --git a/primitives/runtime-interface/proc-macro/tests/ui/take_self_by_value.stderr b/primitives/runtime-interface/tests/ui/take_self_by_value.stderr similarity index 100% rename from primitives/runtime-interface/proc-macro/tests/ui/take_self_by_value.stderr rename to primitives/runtime-interface/tests/ui/take_self_by_value.stderr -- GitLab From 545c1e9505a2906a0da5586a1304cdf4d3e71e0c Mon Sep 17 00:00:00 2001 From: Jake Naviasky Date: Wed, 11 Dec 2019 03:42:19 -0500 Subject: [PATCH 122/172] Including runners-up in check for defunct phragmen voter. (#4349) --- frame/elections-phragmen/src/lib.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index 9d5ee4e6b6..0b8cdba22f 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -536,7 +536,7 @@ impl Module { if Self::is_voter(who) { Self::votes_of(who) .iter() - .all(|v| !Self::is_member(v) && !Self::is_candidate(v).is_ok()) + .all(|v| !Self::is_member(v) && !Self::is_runner(v) && !Self::is_candidate(v).is_ok()) } else { false } @@ -1323,13 +1323,15 @@ mod tests { #[test] fn can_detect_defunct_voter() { - ExtBuilder::default().build().execute_with(|| { - assert_ok!(Elections::submit_candidacy(Origin::signed(5))); + ExtBuilder::default().desired_runners_up(2).build().execute_with(|| { assert_ok!(Elections::submit_candidacy(Origin::signed(4))); + assert_ok!(Elections::submit_candidacy(Origin::signed(5))); + assert_ok!(Elections::submit_candidacy(Origin::signed(6))); assert_ok!(Elections::vote(Origin::signed(5), vec![5], 50)); assert_ok!(Elections::vote(Origin::signed(4), vec![4], 40)); assert_ok!(Elections::vote(Origin::signed(2), vec![4, 5], 20)); + assert_ok!(Elections::vote(Origin::signed(6), vec![6], 30)); // will be soon a defunct voter. assert_ok!(Elections::vote(Origin::signed(3), vec![3], 30)); @@ -1337,12 +1339,14 @@ mod tests { assert_ok!(Elections::end_block(System::block_number())); assert_eq!(Elections::members_ids(), vec![4, 5]); + assert_eq!(Elections::runners_up_ids(), vec![6]); assert_eq!(Elections::candidates(), vec![]); - // all of them have a member that they voted for. + // all of them have a member or runner-up that they voted for. assert_eq!(Elections::is_defunct_voter(&5), false); assert_eq!(Elections::is_defunct_voter(&4), false); assert_eq!(Elections::is_defunct_voter(&2), false); + assert_eq!(Elections::is_defunct_voter(&6), false); // defunct assert_eq!(Elections::is_defunct_voter(&3), true); -- GitLab From 19835b413706914d9325e54f229bb33d061fddf3 Mon Sep 17 00:00:00 2001 From: Benjamin Kampmann Date: Wed, 11 Dec 2019 10:27:34 +0100 Subject: [PATCH 123/172] Fix a bunch of low work dependency cycles (#4354) * take test-client off sp-consensus * use test primitives rather than test client in authority discovery tests * move runtime-interface tests * don't forget to remove the dev-dependency * remove more unneeded dev deps * add changes_trie_config to test prrimitives * Separate network crates from its integration tests * Fix up consensus crates for networking test changes * remove unnecessary dependencies * remove unused addition * remove unnecessary dev-dependencies * fixing finality grandpa tests * removing unnecessary executor dependencies --- Cargo.lock | 57 ++++++++-- Cargo.toml | 2 + client/api/Cargo.toml | 8 +- client/authority-discovery/Cargo.toml | 2 +- client/authority-discovery/src/lib.rs | 2 +- client/consensus/aura/Cargo.toml | 3 +- client/consensus/aura/src/lib.rs | 5 +- client/consensus/babe/Cargo.toml | 3 +- client/consensus/babe/src/tests.rs | 7 +- client/executor/Cargo.toml | 2 - client/finality-grandpa/Cargo.toml | 3 +- .../src/communication/gossip.rs | 2 +- .../src/communication/tests.rs | 2 +- client/finality-grandpa/src/tests.rs | 6 +- client/network/Cargo.toml | 3 +- client/network/src/lib.rs | 5 +- .../src/protocol/legacy_proto/tests.rs | 2 +- client/network/src/protocol/light_dispatch.rs | 2 +- .../src/protocol/sync/extra_requests.rs | 2 +- client/network/test/Cargo.toml | 30 +++++ .../{src/test => test/src}/block_import.rs | 0 .../{src/test/mod.rs => test/src/lib.rs} | 28 +++-- client/network/{src/test => test/src}/sync.rs | 2 +- primitives/consensus/common/Cargo.toml | 2 +- .../common/src/import_queue/buffered_link.rs | 4 +- primitives/runtime-interface/Cargo.toml | 1 - primitives/runtime-interface/src/lib.rs | 95 +--------------- primitives/runtime-interface/test/Cargo.toml | 14 +++ primitives/runtime-interface/test/src/lib.rs | 107 ++++++++++++++++++ primitives/test-primitives/src/lib.rs | 9 ++ 30 files changed, 249 insertions(+), 161 deletions(-) create mode 100644 client/network/test/Cargo.toml rename client/network/{src/test => test/src}/block_import.rs (100%) rename client/network/{src/test/mod.rs => test/src/lib.rs} (97%) rename client/network/{src/test => test/src}/sync.rs (99%) create mode 100644 primitives/runtime-interface/test/Cargo.toml create mode 100644 primitives/runtime-interface/test/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index b57ca6e54e..d94d228919 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4904,7 +4904,7 @@ dependencies = [ "sp-blockchain 2.0.0", "sp-core 2.0.0", "sp-runtime 2.0.0", - "substrate-test-runtime-client 2.0.0", + "sp-test-primitives 2.0.0", ] [[package]] @@ -5044,17 +5044,14 @@ name = "sc-client-api" version = "2.0.0" dependencies = [ "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", - "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "kvdb-memorydb 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sc-client-db 2.0.0", "sc-executor 2.0.0", "sc-telemetry 2.0.0", "sp-api 2.0.0", @@ -5064,7 +5061,6 @@ dependencies = [ "sp-externalities 2.0.0", "sp-inherents 2.0.0", "sp-keyring 2.0.0", - "sp-panic-handler 2.0.0", "sp-runtime 2.0.0", "sp-state-machine 2.0.0", "sp-std 2.0.0", @@ -5072,8 +5068,6 @@ dependencies = [ "sp-transaction-pool-api 2.0.0", "sp-trie 2.0.0", "sp-version 2.0.0", - "substrate-test-runtime-client 2.0.0", - "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -5122,6 +5116,7 @@ dependencies = [ "sc-executor 2.0.0", "sc-keystore 2.0.0", "sc-network 2.0.0", + "sc-network-test 2.0.0", "sc-service 2.0.0", "sc-telemetry 2.0.0", "sp-api 2.0.0", @@ -5169,6 +5164,7 @@ dependencies = [ "sc-executor 2.0.0", "sc-keystore 2.0.0", "sc-network 2.0.0", + "sc-network-test 2.0.0", "sc-service 2.0.0", "sc-telemetry 2.0.0", "schnorrkel 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5259,8 +5255,6 @@ dependencies = [ "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-wasm 0.41.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sc-client-api 2.0.0", - "sc-offchain 2.0.0", "sc-runtime-test 2.0.0", "sp-core 2.0.0", "sp-externalities 2.0.0", @@ -5298,6 +5292,7 @@ dependencies = [ "sc-client-api 2.0.0", "sc-keystore 2.0.0", "sc-network 2.0.0", + "sc-network-test 2.0.0", "sc-telemetry 2.0.0", "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", "sp-api 2.0.0", @@ -5374,8 +5369,8 @@ dependencies = [ "sp-core 2.0.0", "sp-keyring 2.0.0", "sp-runtime 2.0.0", + "sp-test-primitives 2.0.0", "substrate-test-client 2.0.0", - "substrate-test-runtime 2.0.0", "substrate-test-runtime-client 2.0.0", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5385,6 +5380,33 @@ dependencies = [ "zeroize 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "sc-network-test" +version = "2.0.0" +dependencies = [ + "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-timer 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-block-builder 2.0.0", + "sc-client 2.0.0", + "sc-client-api 2.0.0", + "sc-network 2.0.0", + "sp-blockchain 2.0.0", + "sp-consensus 2.0.0", + "sp-consensus-babe 2.0.0", + "sp-core 2.0.0", + "sp-runtime 2.0.0", + "substrate-test-runtime 2.0.0", + "substrate-test-runtime-client 2.0.0", + "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "sc-offchain" version = "2.0.0" @@ -6090,8 +6112,8 @@ dependencies = [ "sp-inherents 2.0.0", "sp-runtime 2.0.0", "sp-std 2.0.0", + "sp-test-primitives 2.0.0", "sp-version 2.0.0", - "substrate-test-runtime-client 2.0.0", ] [[package]] @@ -6326,7 +6348,6 @@ dependencies = [ "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "primitive-types 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustversion 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sc-executor 2.0.0", "sp-core 2.0.0", "sp-externalities 2.0.0", "sp-io 2.0.0", @@ -6350,6 +6371,18 @@ dependencies = [ "syn 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "sp-runtime-interface-test" +version = "2.0.0" +dependencies = [ + "sc-executor 2.0.0", + "sp-core 2.0.0", + "sp-io 2.0.0", + "sp-runtime-interface 2.0.0", + "sp-runtime-interface-test-wasm 2.0.0", + "sp-state-machine 2.0.0", +] + [[package]] name = "sp-runtime-interface-test-wasm" version = "2.0.0" diff --git a/Cargo.toml b/Cargo.toml index d1b105ab8b..6b59b68e1c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,6 +30,7 @@ members = [ "client/tracing", "client/keystore", "client/network", + "client/network/test", "client/offchain", "client/peerset", "client/rpc-servers", @@ -114,6 +115,7 @@ members = [ "primitives/runtime-interface", "primitives/runtime-interface/proc-macro", "primitives/runtime-interface/test-wasm", + "primitives/runtime-interface/test", "primitives/serializer", "primitives/session", "primitives/api", diff --git a/client/api/Cargo.toml b/client/api/Cargo.toml index 6aa4a144f6..b8a77bde07 100644 --- a/client/api/Cargo.toml +++ b/client/api/Cargo.toml @@ -31,10 +31,4 @@ trie = { package = "sp-trie", path = "../../primitives/trie" } txpool-api = { package = "sp-transaction-pool-api", path = "../../primitives/transaction-pool" } [dev-dependencies] -env_logger = "0.7.0" -tempfile = "3.1.0" -client-db = { package = "sc-client-db", path = "../db", features = ["kvdb-rocksdb"] } -test-primitives = { package = "sp-test-primitives", path = "../../primitives/test-primitives" } -test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client" } -kvdb-memorydb = "0.1.2" -panic-handler = { package = "sp-panic-handler", path = "../../primitives/panic-handler" } +test-primitives = { package = "sp-test-primitives", path = "../../primitives/test-primitives" } \ No newline at end of file diff --git a/client/authority-discovery/Cargo.toml b/client/authority-discovery/Cargo.toml index 330165e0aa..72e4345166 100644 --- a/client/authority-discovery/Cargo.toml +++ b/client/authority-discovery/Cargo.toml @@ -30,5 +30,5 @@ sp-runtime = { path = "../../primitives/runtime" } env_logger = "0.7.0" parking_lot = "0.9.0" peerset = { package = "sc-peerset", path = "../peerset" } -test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client" } +sp-test-primitives = { path = "../../primitives/test-primitives" } sp-api = { path = "../../primitives/api" } diff --git a/client/authority-discovery/src/lib.rs b/client/authority-discovery/src/lib.rs index 80bf971f1d..a70683f682 100644 --- a/client/authority-discovery/src/lib.rs +++ b/client/authority-discovery/src/lib.rs @@ -555,7 +555,7 @@ mod tests { use sp_runtime::traits::Zero; use sp_runtime::traits::{ApiRef, Block as BlockT, NumberFor, ProvideRuntimeApi}; use std::sync::{Arc, Mutex}; - use test_client::runtime::Block; + use sp_test_primitives::Block; #[test] fn interval_at_with_start_now() { diff --git a/client/consensus/aura/Cargo.toml b/client/consensus/aura/Cargo.toml index 181b144333..5823a6ce6b 100644 --- a/client/consensus/aura/Cargo.toml +++ b/client/consensus/aura/Cargo.toml @@ -34,7 +34,8 @@ sc-telemetry = { path = "../../telemetry" } [dev-dependencies] keyring = { package = "sp-keyring", path = "../../../primitives/keyring" } sc-executor = { path = "../../executor" } -network = { package = "sc-network", path = "../../network", features = ["test-helpers"]} +sc-network = { path = "../../network" } +sc-network-test = { path = "../../network/test" } service = { package = "sc-service", path = "../../service" } test-client = { package = "substrate-test-runtime-client", path = "../../../test/utils/runtime/client" } tokio = "0.1.22" diff --git a/client/consensus/aura/src/lib.rs b/client/consensus/aura/src/lib.rs index 745c0bebe2..c9be311b11 100644 --- a/client/consensus/aura/src/lib.rs +++ b/client/consensus/aura/src/lib.rs @@ -748,10 +748,9 @@ pub fn import_queue( mod tests { use super::*; use consensus_common::NoNetwork as DummyOracle; - use network::test::*; - use network::test::{Block as TestBlock, PeersClient, PeersFullClient}; + use sc_network_test::{Block as TestBlock, *}; use sp_runtime::traits::{Block as BlockT, DigestFor}; - use network::config::ProtocolConfig; + use sc_network::config::ProtocolConfig; use parking_lot::Mutex; use tokio::runtime::current_thread; use keyring::sr25519::Keyring; diff --git a/client/consensus/babe/Cargo.toml b/client/consensus/babe/Cargo.toml index 8c61f10b68..8f68da5bbc 100644 --- a/client/consensus/babe/Cargo.toml +++ b/client/consensus/babe/Cargo.toml @@ -43,7 +43,8 @@ derive_more = "0.99.2" [dev-dependencies] keyring = { package = "sp-keyring", path = "../../../primitives/keyring" } sc-executor = { path = "../../executor" } -network = { package = "sc-network", path = "../../network", features = ["test-helpers"]} +sc-network = { path = "../../network" } +sc-network-test = { path = "../../network/test" } service = { package = "sc-service", path = "../../service" } test-client = { package = "substrate-test-runtime-client", path = "../../../test/utils/runtime/client" } block-builder = { package = "sc-block-builder", path = "../../block-builder" } diff --git a/client/consensus/babe/src/tests.rs b/client/consensus/babe/src/tests.rs index 56482ef5fd..48b58eacd8 100644 --- a/client/consensus/babe/src/tests.rs +++ b/client/consensus/babe/src/tests.rs @@ -28,11 +28,10 @@ use consensus_common::NoNetwork as DummyOracle; use consensus_common::import_queue::{ BoxBlockImport, BoxJustificationImport, BoxFinalityProofImport, }; -use network::test::*; -use network::test::{Block as TestBlock, PeersClient}; -use network::config::BoxFinalityProofRequestBuilder; +use sc_network_test::*; +use sc_network_test::{Block as TestBlock, PeersClient}; +use sc_network::config::{BoxFinalityProofRequestBuilder, ProtocolConfig}; use sp_runtime::{generic::DigestItem, traits::{Block as BlockT, DigestFor}}; -use network::config::ProtocolConfig; use tokio::runtime::current_thread; use client_api::BlockchainEvents; use test_client; diff --git a/client/executor/Cargo.toml b/client/executor/Cargo.toml index d40e426e3f..6a0723099b 100644 --- a/client/executor/Cargo.toml +++ b/client/executor/Cargo.toml @@ -39,8 +39,6 @@ hex-literal = "0.2.1" runtime-test = { package = "sc-runtime-test", path = "runtime-test" } test-runtime = { package = "substrate-test-runtime", path = "../../test/utils/runtime" } runtime-interface = { package = "sp-runtime-interface", path = "../../primitives/runtime-interface" } -client-api = { package = "sc-client-api", path = "../api" } -sc-offchain = { path = "../offchain/" } state_machine = { package = "sp-state-machine", path = "../../primitives/state-machine" } test-case = "0.3.3" diff --git a/client/finality-grandpa/Cargo.toml b/client/finality-grandpa/Cargo.toml index 121491fd3d..1ba0cfa766 100644 --- a/client/finality-grandpa/Cargo.toml +++ b/client/finality-grandpa/Cargo.toml @@ -31,7 +31,8 @@ grandpa = { package = "finality-grandpa", version = "0.10.1", features = ["deriv [dev-dependencies] grandpa = { package = "finality-grandpa", version = "0.10.1", features = ["derive-codec", "test-helpers"] } -network = { package = "sc-network", path = "../network", features = ["test-helpers"] } +network = { package = "sc-network", path = "../network" } +sc-network-test = { path = "../network/test" } keyring = { package = "sp-keyring", path = "../../primitives/keyring" } test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client"} babe_primitives = { package = "sp-consensus-babe", path = "../../primitives/consensus/babe" } diff --git a/client/finality-grandpa/src/communication/gossip.rs b/client/finality-grandpa/src/communication/gossip.rs index af08e76157..298d68d58f 100644 --- a/client/finality-grandpa/src/communication/gossip.rs +++ b/client/finality-grandpa/src/communication/gossip.rs @@ -1506,7 +1506,7 @@ mod tests { use super::*; use super::environment::SharedVoterSetState; use network_gossip::Validator as GossipValidatorT; - use network::test::Block; + use sc_network_test::Block; use primitives::{crypto::Public, H256}; // some random config (not really needed) diff --git a/client/finality-grandpa/src/communication/tests.rs b/client/finality-grandpa/src/communication/tests.rs index f2a2276a47..86bbdb8f64 100644 --- a/client/finality-grandpa/src/communication/tests.rs +++ b/client/finality-grandpa/src/communication/tests.rs @@ -19,7 +19,7 @@ use futures::sync::mpsc; use futures::prelude::*; use network::consensus_gossip as network_gossip; -use network::test::{Block, Hash}; +use sc_network_test::{Block, Hash}; use network_gossip::Validator; use tokio::runtime::current_thread; use std::sync::Arc; diff --git a/client/finality-grandpa/src/tests.rs b/client/finality-grandpa/src/tests.rs index d9010bd02b..ece9bf167b 100644 --- a/client/finality-grandpa/src/tests.rs +++ b/client/finality-grandpa/src/tests.rs @@ -18,8 +18,8 @@ use super::*; use environment::HasVoted; -use network::test::{Block, DummySpecialization, Hash, TestNetFactory, Peer, PeersClient}; -use network::test::{PassThroughVerifier}; +use sc_network_test::{Block, DummySpecialization, Hash, TestNetFactory, Peer, PeersClient}; +use sc_network_test::{PassThroughVerifier}; use network::config::{ProtocolConfig, Roles, BoxFinalityProofRequestBuilder}; use parking_lot::Mutex; use futures03::{StreamExt as _, TryStreamExt as _}; @@ -1553,7 +1553,7 @@ fn voter_catches_up_to_latest_round_when_behind() { #[test] fn grandpa_environment_respects_voting_rules() { use grandpa::Chain; - use network::test::TestClient; + use sc_network_test::TestClient; let peers = &[Ed25519Keyring::Alice]; let voters = make_ids(peers); diff --git a/client/network/Cargo.toml b/client/network/Cargo.toml index 98ca2b610c..ac00c48cd7 100644 --- a/client/network/Cargo.toml +++ b/client/network/Cargo.toml @@ -51,12 +51,11 @@ zeroize = "1.0.0" babe-primitives = { package = "sp-consensus-babe", path = "../../primitives/consensus/babe" } [dev-dependencies] +sp-test-primitives = { path = "../../primitives/test-primitives" } env_logger = "0.7.0" keyring = { package = "sp-keyring", path = "../../primitives/keyring" } quickcheck = "0.9.0" rand = "0.7.2" -test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client" } -test_runtime = { package = "substrate-test-runtime", path = "../../test/utils/runtime" } tempfile = "3.1.0" tokio = "0.1.22" diff --git a/client/network/src/lib.rs b/client/network/src/lib.rs index 05c8a1dc86..755ae803fe 100644 --- a/client/network/src/lib.rs +++ b/client/network/src/lib.rs @@ -181,15 +181,12 @@ mod utils; pub mod config; pub mod error; -#[cfg(any(test, feature = "test-helpers"))] -pub mod test; - pub use chain::{Client as ClientHandle, FinalityProofProvider}; pub use service::{ NetworkService, NetworkWorker, TransactionPool, ExHashT, ReportHandle, NetworkStateInfo, }; -pub use protocol::{PeerInfo, Context, consensus_gossip, message, specialization}; +pub use protocol::{PeerInfo, Context, ProtocolConfig, consensus_gossip, message, specialization}; pub use protocol::event::{Event, DhtEvent}; pub use protocol::sync::SyncState; pub use libp2p::{Multiaddr, PeerId}; diff --git a/client/network/src/protocol/legacy_proto/tests.rs b/client/network/src/protocol/legacy_proto/tests.rs index 08c3a47c0e..32af2198b7 100644 --- a/client/network/src/protocol/legacy_proto/tests.rs +++ b/client/network/src/protocol/legacy_proto/tests.rs @@ -27,7 +27,7 @@ use rand::seq::SliceRandom; use std::{io, time::Duration, time::Instant}; use crate::message::Message; use crate::protocol::legacy_proto::{LegacyProto, LegacyProtoOut}; -use test_client::runtime::Block; +use sp_test_primitives::Block; /// Builds two nodes that have each other as bootstrap nodes. /// This is to be used only for testing, and a panic will happen if something goes wrong. diff --git a/client/network/src/protocol/light_dispatch.rs b/client/network/src/protocol/light_dispatch.rs index ef240cbf06..869fd703ca 100644 --- a/client/network/src/protocol/light_dispatch.rs +++ b/client/network/src/protocol/light_dispatch.rs @@ -686,7 +686,7 @@ pub mod tests { use crate::message::{self, BlockAttributes, Direction, FromBlock, RequestId}; use libp2p::PeerId; use super::{REQUEST_TIMEOUT, LightDispatch, LightDispatchNetwork, RequestData, StorageProof}; - use test_client::runtime::{changes_trie_config, Block, Extrinsic, Header}; + use sp_test_primitives::{changes_trie_config, Block, Extrinsic, Header}; struct DummyFetchChecker { ok: bool } diff --git a/client/network/src/protocol/sync/extra_requests.rs b/client/network/src/protocol/sync/extra_requests.rs index 21a29975c0..ecd6fdca99 100644 --- a/client/network/src/protocol/sync/extra_requests.rs +++ b/client/network/src/protocol/sync/extra_requests.rs @@ -288,7 +288,7 @@ mod tests { use rand::Rng; use std::collections::{HashMap, HashSet}; use super::*; - use test_client::runtime::{Block, BlockNumber, Hash}; + use sp_test_primitives::{Block, BlockNumber, Hash}; #[test] fn requests_are_processed_in_order() { diff --git a/client/network/test/Cargo.toml b/client/network/test/Cargo.toml new file mode 100644 index 0000000000..3ebb7ac6b4 --- /dev/null +++ b/client/network/test/Cargo.toml @@ -0,0 +1,30 @@ +[package] +description = "Integration tests for Substrate network protocol" +name = "sc-network-test" +version = "2.0.0" +license = "GPL-3.0" +authors = ["Parity Technologies "] +edition = "2018" + +[dependencies] +sc-network = { path = "../" } +log = "0.4.8" +parking_lot = "0.9.0" +futures = "0.1.29" +futures03 = { package = "futures", version = "0.3.1", features = ["compat"] } +futures-timer = "0.4.0" +rand = "0.7.2" +libp2p = { version = "0.13.0", default-features = false, features = ["libp2p-websocket"] } +consensus = { package = "sp-consensus", path = "../../../primitives/consensus/common" } +client = { package = "sc-client", path = "../../" } +client-api = { package = "sc-client-api", path = "../../api" } +sp-blockchain = { path = "../../../primitives/blockchain" } +sp-runtime = { path = "../../../primitives/runtime" } +primitives = { package = "sp-core", path = "../../../primitives/core" } +block-builder = { package = "sc-block-builder", path = "../../block-builder" } +babe-primitives = { package = "sp-consensus-babe", path = "../../../primitives/consensus/babe" } +env_logger = "0.7.0" +test-client = { package = "substrate-test-runtime-client", path = "../../../test/utils/runtime/client" } +test_runtime = { package = "substrate-test-runtime", path = "../../../test/utils/runtime" } +tempfile = "3.1.0" +tokio = "0.1.22" diff --git a/client/network/src/test/block_import.rs b/client/network/test/src/block_import.rs similarity index 100% rename from client/network/src/test/block_import.rs rename to client/network/test/src/block_import.rs diff --git a/client/network/src/test/mod.rs b/client/network/test/src/lib.rs similarity index 97% rename from client/network/src/test/mod.rs rename to client/network/test/src/lib.rs index f016ef99d8..cc81789e24 100644 --- a/client/network/src/test/mod.rs +++ b/client/network/test/src/lib.rs @@ -24,9 +24,9 @@ mod sync; use std::collections::HashMap; use std::sync::Arc; -use crate::config::build_multiaddr; +use libp2p::build_multiaddr; use log::trace; -use crate::chain::FinalityProofProvider; +use sc_network::FinalityProofProvider; use sp_blockchain::{ Result as ClientResult, well_known_cache_keys::{self, Id as CacheKeyId}, }; @@ -38,7 +38,7 @@ use client_api::{ }; use block_builder::BlockBuilder; use client::LongestChain; -use crate::config::Roles; +use sc_network::config::Roles; use consensus::block_validation::DefaultBlockAnnounceValidator; use consensus::import_queue::BasicQueue; use consensus::import_queue::{ @@ -49,17 +49,17 @@ use consensus::Error as ConsensusError; use consensus::{BlockOrigin, ForkChoiceStrategy, BlockImportParams, BlockCheckParams, JustificationImport}; use futures::prelude::*; use futures03::{StreamExt as _, TryStreamExt as _}; -use crate::{NetworkWorker, NetworkService, ReportHandle, config::ProtocolId}; -use crate::config::{NetworkConfiguration, TransportConfig, BoxFinalityProofRequestBuilder}; +use sc_network::{NetworkWorker, NetworkService, ReportHandle, config::ProtocolId}; +use sc_network::config::{NetworkConfiguration, TransportConfig, BoxFinalityProofRequestBuilder}; use libp2p::PeerId; use parking_lot::Mutex; use primitives::H256; -use crate::protocol::{Context, ProtocolConfig}; +use sc_network::{Context, ProtocolConfig}; use sp_runtime::generic::{BlockId, OpaqueDigestItemId}; use sp_runtime::traits::{Block as BlockT, Header, NumberFor}; use sp_runtime::Justification; -use crate::service::TransactionPool; -use crate::specialization::NetworkSpecialization; +use sc_network::TransactionPool; +use sc_network::specialization::NetworkSpecialization; use test_client::{self, AccountKeyring}; pub use test_client::runtime::{Block, Extrinsic, Hash, Transfer}; @@ -67,13 +67,11 @@ pub use test_client::{TestClient, TestClientBuilder, TestClientBuilderExt}; type AuthorityId = babe_primitives::AuthorityId; -#[cfg(any(test, feature = "test-helpers"))] /// A Verifier that accepts all blocks and passes them on with the configured /// finality to be imported. #[derive(Clone)] pub struct PassThroughVerifier(pub bool); -#[cfg(any(test, feature = "test-helpers"))] /// This `Verifier` accepts all data as valid. impl Verifier for PassThroughVerifier { fn verify( @@ -117,7 +115,7 @@ impl NetworkSpecialization for DummySpecialization { &mut self, _ctx: &mut dyn Context, _peer_id: PeerId, - _status: crate::message::Status + _status: sc_network::message::Status ) {} fn on_disconnect(&mut self, _ctx: &mut dyn Context, _peer_id: PeerId) {} @@ -401,8 +399,8 @@ impl TransactionPool for EmptyTransactionPool { &self, _report_handle: ReportHandle, _who: PeerId, - _rep_change_good: crate::ReputationChange, - _rep_change_bad: crate::ReputationChange, + _rep_change_good: sc_network::ReputationChange, + _rep_change_bad: sc_network::ReputationChange, _transaction: Extrinsic ) {} @@ -563,7 +561,7 @@ pub trait TestNetFactory: Sized { let listen_addr = build_multiaddr![Memory(rand::random::())]; - let network = NetworkWorker::new(crate::config::Params { + let network = NetworkWorker::new(sc_network::config::Params { roles: config.roles, network_config: NetworkConfiguration { listen_addresses: vec![listen_addr.clone()], @@ -637,7 +635,7 @@ pub trait TestNetFactory: Sized { let listen_addr = build_multiaddr![Memory(rand::random::())]; - let network = NetworkWorker::new(crate::config::Params { + let network = NetworkWorker::new(sc_network::config::Params { roles: config.roles, network_config: NetworkConfiguration { listen_addresses: vec![listen_addr.clone()], diff --git a/client/network/src/test/sync.rs b/client/network/test/src/sync.rs similarity index 99% rename from client/network/src/test/sync.rs rename to client/network/test/src/sync.rs index 9868bd0ed2..b4e166be67 100644 --- a/client/network/src/test/sync.rs +++ b/client/network/test/src/sync.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Substrate. If not, see . -use crate::config::Roles; +use sc_network::config::Roles; use consensus::BlockOrigin; use futures03::TryFutureExt as _; use std::time::Duration; diff --git a/primitives/consensus/common/Cargo.toml b/primitives/consensus/common/Cargo.toml index ea2ee3891c..128d42c20c 100644 --- a/primitives/consensus/common/Cargo.toml +++ b/primitives/consensus/common/Cargo.toml @@ -20,7 +20,7 @@ codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive parking_lot = "0.9.0" [dev-dependencies] -test-client = { package = "substrate-test-runtime-client", path = "../../../test/utils/runtime/client" } +sp-test-primitives = { path = "../../test-primitives" } [features] default = [] diff --git a/primitives/consensus/common/src/import_queue/buffered_link.rs b/primitives/consensus/common/src/import_queue/buffered_link.rs index 70304bbe27..4772af92f1 100644 --- a/primitives/consensus/common/src/import_queue/buffered_link.rs +++ b/primitives/consensus/common/src/import_queue/buffered_link.rs @@ -23,7 +23,7 @@ //! ``` //! use sp_consensus::import_queue::Link; //! # use sp_consensus::import_queue::buffered_link::buffered_link; -//! # use test_client::runtime::Block; +//! # use sp_test_primitives::Block; //! # struct DummyLink; impl Link for DummyLink {} //! # let mut my_link = DummyLink; //! let (mut tx, mut rx) = buffered_link::(); @@ -161,7 +161,7 @@ impl BufferedLinkReceiver { #[cfg(test)] mod tests { - use test_client::runtime::Block; + use sp_test_primitives::Block; #[test] fn is_closed() { diff --git a/primitives/runtime-interface/Cargo.toml b/primitives/runtime-interface/Cargo.toml index 704ae1b243..c451407681 100644 --- a/primitives/runtime-interface/Cargo.toml +++ b/primitives/runtime-interface/Cargo.toml @@ -15,7 +15,6 @@ static_assertions = "1.0.0" primitive-types = { version = "0.6.1", default-features = false } [dev-dependencies] -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" } diff --git a/primitives/runtime-interface/src/lib.rs b/primitives/runtime-interface/src/lib.rs index ac172a9bc8..9baf47df27 100644 --- a/primitives/runtime-interface/src/lib.rs +++ b/primitives/runtime-interface/src/lib.rs @@ -260,97 +260,4 @@ pub type Pointer = *mut T; /// A pointer that can be used in a runtime interface function signature. #[cfg(feature = "std")] -pub type Pointer = wasm_interface::Pointer; - -#[cfg(test)] -mod tests { - use super::*; - use test_wasm::{WASM_BINARY, test_api::HostFunctions}; - use wasm_interface::HostFunctions as HostFunctionsT; - - type TestExternalities = state_machine::TestExternalities; - - fn call_wasm_method(method: &str) -> TestExternalities { - let mut ext = TestExternalities::default(); - let mut ext_ext = ext.ext(); - - executor::call_in_wasm::< - _, - ( - HF, - sp_io::SubstrateHostFunctions, - executor::deprecated_host_interface::SubstrateExternals - ) - >( - method, - &[], - executor::WasmExecutionMethod::Interpreted, - &mut ext_ext, - &WASM_BINARY[..], - 8, - ).expect(&format!("Executes `{}`", method)); - - ext - } - - #[test] - fn test_return_data() { - call_wasm_method::("test_return_data"); - } - - #[test] - fn test_return_option_data() { - call_wasm_method::("test_return_option_data"); - } - - #[test] - fn test_set_storage() { - let mut ext = call_wasm_method::("test_set_storage"); - - let expected = "world"; - assert_eq!(expected.as_bytes(), &ext.ext().storage("hello".as_bytes()).unwrap()[..]); - } - - #[test] - fn test_return_value_into_mutable_reference() { - call_wasm_method::("test_return_value_into_mutable_reference"); - } - - #[test] - fn test_get_and_return_array() { - call_wasm_method::("test_get_and_return_array"); - } - - #[test] - fn test_array_as_mutable_reference() { - call_wasm_method::("test_array_as_mutable_reference"); - } - - #[test] - fn test_return_input_public_key() { - call_wasm_method::("test_return_input_public_key"); - } - - #[test] - #[should_panic( - expected = "Other(\"Instantiation: Export ext_test_api_return_input_version_1 not found\")" - )] - fn host_function_not_found() { - call_wasm_method::<()>("test_return_data"); - } - - #[test] - #[should_panic( - expected = - "FunctionExecution(\"ext_test_api_invalid_utf8_data_version_1\", \ - \"Invalid utf8 data provided\")" - )] - fn test_invalid_utf8_data_should_return_an_error() { - call_wasm_method::("test_invalid_utf8_data_should_return_an_error"); - } - - #[test] - fn test_overwrite_native_function_implementation() { - call_wasm_method::("test_overwrite_native_function_implementation"); - } -} +pub type Pointer = wasm_interface::Pointer; \ No newline at end of file diff --git a/primitives/runtime-interface/test/Cargo.toml b/primitives/runtime-interface/test/Cargo.toml new file mode 100644 index 0000000000..269e8bc4aa --- /dev/null +++ b/primitives/runtime-interface/test/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "sp-runtime-interface-test" +version = "2.0.0" +authors = ["Parity Technologies "] +edition = "2018" +publish = false + +[dependencies] +sp-runtime-interface = { path = "../" } +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" } +sp-io = { path = "../../io" } diff --git a/primitives/runtime-interface/test/src/lib.rs b/primitives/runtime-interface/test/src/lib.rs new file mode 100644 index 0000000000..3de5e1ddc1 --- /dev/null +++ b/primitives/runtime-interface/test/src/lib.rs @@ -0,0 +1,107 @@ +// Copyright 2019 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Substrate is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Substrate. If not, see . + +//! Integration tests for runtime interface primitives + +use sp_runtime_interface::*; +use test_wasm::{WASM_BINARY, test_api::HostFunctions}; +use wasm_interface::HostFunctions as HostFunctionsT; + +type TestExternalities = state_machine::TestExternalities; + +fn call_wasm_method(method: &str) -> TestExternalities { + let mut ext = TestExternalities::default(); + let mut ext_ext = ext.ext(); + + executor::call_in_wasm::< + _, + ( + HF, + sp_io::SubstrateHostFunctions, + executor::deprecated_host_interface::SubstrateExternals + ) + >( + method, + &[], + executor::WasmExecutionMethod::Interpreted, + &mut ext_ext, + &WASM_BINARY[..], + 8, + ).expect(&format!("Executes `{}`", method)); + + ext +} + +#[test] +fn test_return_data() { + call_wasm_method::("test_return_data"); +} + +#[test] +fn test_return_option_data() { + call_wasm_method::("test_return_option_data"); +} + +#[test] +fn test_set_storage() { + let mut ext = call_wasm_method::("test_set_storage"); + + let expected = "world"; + assert_eq!(expected.as_bytes(), &ext.ext().storage("hello".as_bytes()).unwrap()[..]); +} + +#[test] +fn test_return_value_into_mutable_reference() { + call_wasm_method::("test_return_value_into_mutable_reference"); +} + +#[test] +fn test_get_and_return_array() { + call_wasm_method::("test_get_and_return_array"); +} + +#[test] +fn test_array_as_mutable_reference() { + call_wasm_method::("test_array_as_mutable_reference"); +} + +#[test] +fn test_return_input_public_key() { + call_wasm_method::("test_return_input_public_key"); +} + +#[test] +#[should_panic( + expected = "Other(\"Instantiation: Export ext_test_api_return_input_version_1 not found\")" +)] +fn host_function_not_found() { + call_wasm_method::<()>("test_return_data"); +} + +#[test] +#[should_panic( + expected = + "FunctionExecution(\"ext_test_api_invalid_utf8_data_version_1\", \ + \"Invalid utf8 data provided\")" +)] +fn test_invalid_utf8_data_should_return_an_error() { + call_wasm_method::("test_invalid_utf8_data_should_return_an_error"); +} + +#[test] +fn test_overwrite_native_function_implementation() { + call_wasm_method::("test_overwrite_native_function_implementation"); +} diff --git a/primitives/test-primitives/src/lib.rs b/primitives/test-primitives/src/lib.rs index 773e88066d..4acf10bbdf 100644 --- a/primitives/test-primitives/src/lib.rs +++ b/primitives/test-primitives/src/lib.rs @@ -76,3 +76,12 @@ pub type Digest = sp_runtime::generic::Digest; pub type Block = sp_runtime::generic::Block; /// A test block's header. pub type Header = sp_runtime::generic::Header; + + +/// Changes trie configuration (optionally) used in tests. +pub fn changes_trie_config() -> primitives::ChangesTrieConfiguration { + primitives::ChangesTrieConfiguration { + digest_interval: 4, + digest_levels: 2, + } +} \ No newline at end of file -- GitLab From 824009b48482a244f295d299e1a1dd9f358cec63 Mon Sep 17 00:00:00 2001 From: Benjamin Kampmann Date: Wed, 11 Dec 2019 11:36:29 +0100 Subject: [PATCH 124/172] Fix folder names in primitives (#4358) * sr-arithmetic -> arithmetic * sr-sandbox -> sandbox * primitives/sr-staking-primitives -> primitives/staking * primitives/sr-version -> primitives/version * primitives/block-builder/runtime-api -> primitives/block-builder --- Cargo.toml | 10 +++++----- bin/node-template/runtime/Cargo.toml | 4 ++-- bin/node/runtime/Cargo.toml | 6 +++--- client/Cargo.toml | 2 +- client/api/Cargo.toml | 2 +- client/block-builder/Cargo.toml | 2 +- client/consensus/aura/Cargo.toml | 4 ++-- client/consensus/babe/Cargo.toml | 4 ++-- client/consensus/pow/Cargo.toml | 2 +- client/executor/Cargo.toml | 2 +- client/executor/runtime-test/Cargo.toml | 2 +- client/network/Cargo.toml | 2 +- client/rpc/Cargo.toml | 2 +- client/rpc/api/Cargo.toml | 2 +- frame/authority-discovery/Cargo.toml | 2 +- frame/babe/Cargo.toml | 4 ++-- frame/contracts/Cargo.toml | 2 +- frame/grandpa/Cargo.toml | 2 +- frame/im-online/Cargo.toml | 2 +- frame/offences/Cargo.toml | 2 +- frame/session/Cargo.toml | 2 +- frame/staking/Cargo.toml | 2 +- frame/support/Cargo.toml | 2 +- frame/system/Cargo.toml | 2 +- primitives/api/Cargo.toml | 2 +- primitives/api/test/Cargo.toml | 2 +- primitives/{sr-arithmetic => arithmetic}/Cargo.toml | 0 .../{sr-arithmetic => arithmetic}/benches/bench.rs | 0 .../{sr-arithmetic => arithmetic}/fuzzer/.gitignore | 0 .../{sr-arithmetic => arithmetic}/fuzzer/Cargo.lock | 0 .../{sr-arithmetic => arithmetic}/fuzzer/Cargo.toml | 0 .../fuzzer/src/biguint.rs | 0 .../fuzzer/src/rational128.rs | 0 .../{sr-arithmetic => arithmetic}/src/biguint.rs | 0 .../{sr-arithmetic => arithmetic}/src/fixed64.rs | 0 .../src/helpers_128bit.rs | 0 primitives/{sr-arithmetic => arithmetic}/src/lib.rs | 0 .../{sr-arithmetic => arithmetic}/src/per_things.rs | 0 .../{sr-arithmetic => arithmetic}/src/rational128.rs | 0 primitives/{sr-arithmetic => arithmetic}/src/traits.rs | 0 primitives/block-builder/{runtime-api => }/Cargo.toml | 8 ++++---- primitives/block-builder/{runtime-api => }/src/lib.rs | 0 primitives/blockchain/Cargo.toml | 2 +- primitives/consensus/common/Cargo.toml | 2 +- primitives/runtime/Cargo.toml | 2 +- primitives/{sr-sandbox => sandbox}/Cargo.toml | 0 primitives/{sr-sandbox => sandbox}/src/lib.rs | 0 primitives/{sr-sandbox => sandbox}/with_std.rs | 0 primitives/{sr-sandbox => sandbox}/without_std.rs | 0 .../{sr-staking-primitives => staking}/Cargo.toml | 0 .../{sr-staking-primitives => staking}/src/lib.rs | 0 .../{sr-staking-primitives => staking}/src/offence.rs | 0 primitives/{sr-version => version}/Cargo.toml | 0 primitives/{sr-version => version}/src/lib.rs | 0 test/utils/runtime/Cargo.toml | 4 ++-- test/utils/transaction-factory/Cargo.toml | 2 +- 56 files changed, 46 insertions(+), 46 deletions(-) rename primitives/{sr-arithmetic => arithmetic}/Cargo.toml (100%) rename primitives/{sr-arithmetic => arithmetic}/benches/bench.rs (100%) rename primitives/{sr-arithmetic => arithmetic}/fuzzer/.gitignore (100%) rename primitives/{sr-arithmetic => arithmetic}/fuzzer/Cargo.lock (100%) rename primitives/{sr-arithmetic => arithmetic}/fuzzer/Cargo.toml (100%) rename primitives/{sr-arithmetic => arithmetic}/fuzzer/src/biguint.rs (100%) rename primitives/{sr-arithmetic => arithmetic}/fuzzer/src/rational128.rs (100%) rename primitives/{sr-arithmetic => arithmetic}/src/biguint.rs (100%) rename primitives/{sr-arithmetic => arithmetic}/src/fixed64.rs (100%) rename primitives/{sr-arithmetic => arithmetic}/src/helpers_128bit.rs (100%) rename primitives/{sr-arithmetic => arithmetic}/src/lib.rs (100%) rename primitives/{sr-arithmetic => arithmetic}/src/per_things.rs (100%) rename primitives/{sr-arithmetic => arithmetic}/src/rational128.rs (100%) rename primitives/{sr-arithmetic => arithmetic}/src/traits.rs (100%) rename primitives/block-builder/{runtime-api => }/Cargo.toml (56%) rename primitives/block-builder/{runtime-api => }/src/lib.rs (100%) rename primitives/{sr-sandbox => sandbox}/Cargo.toml (100%) rename primitives/{sr-sandbox => sandbox}/src/lib.rs (100%) rename primitives/{sr-sandbox => sandbox}/with_std.rs (100%) rename primitives/{sr-sandbox => sandbox}/without_std.rs (100%) rename primitives/{sr-staking-primitives => staking}/Cargo.toml (100%) rename primitives/{sr-staking-primitives => staking}/src/lib.rs (100%) rename primitives/{sr-staking-primitives => staking}/src/offence.rs (100%) rename primitives/{sr-version => version}/Cargo.toml (100%) rename primitives/{sr-version => version}/src/lib.rs (100%) diff --git a/Cargo.toml b/Cargo.toml index 6b59b68e1c..6c0da92499 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -94,7 +94,7 @@ members = [ "primitives/application-crypto/test", "primitives/authority-discovery", "primitives/authorship", - "primitives/block-builder/runtime-api", + "primitives/block-builder", "primitives/blockchain", "primitives/consensus/aura", "primitives/consensus/babe", @@ -121,13 +121,13 @@ members = [ "primitives/api", "primitives/api/proc-macro", "primitives/api/test", - "primitives/sr-arithmetic", + "primitives/arithmetic", "primitives/io", "primitives/runtime", - "primitives/sr-sandbox", - "primitives/sr-staking-primitives", + "primitives/sandbox", + "primitives/staking", "primitives/std", - "primitives/sr-version", + "primitives/version", "primitives/state-machine", "primitives/timestamp", "primitives/test-primitives", diff --git a/bin/node-template/runtime/Cargo.toml b/bin/node-template/runtime/Cargo.toml index 0df7c99016..f4e1ecb972 100644 --- a/bin/node-template/runtime/Cargo.toml +++ b/bin/node-template/runtime/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" aura = { package = "pallet-aura", path = "../../../frame/aura", default-features = false } aura-primitives = { package = "sp-consensus-aura", path = "../../../primitives/consensus/aura", default-features = false } balances = { package = "pallet-balances", path = "../../../frame/balances", default-features = false } -block-builder-api = { package = "sp-block-builder", path = "../../../primitives/block-builder/runtime-api", default-features = false} +block-builder-api = { package = "sp-block-builder", path = "../../../primitives/block-builder", default-features = false} codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } executive = { package = "frame-executive", path = "../../../frame/executive", default-features = false } grandpa = { package = "pallet-grandpa", path = "../../../frame/grandpa", default-features = false } @@ -30,7 +30,7 @@ system = { package = "frame-system", path = "../../../frame/system", default-fea timestamp = { package = "pallet-timestamp", path = "../../../frame/timestamp", default-features = false } transaction-payment = { package = "pallet-transaction-payment", path = "../../../frame/transaction-payment", default-features = false } sp-transaction-pool = { package = "sp-transaction-pool-api", path = "../../../primitives/transaction-pool", default-features = false } -version = { package = "sp-version", path = "../../../primitives/sr-version", default-features = false } +version = { package = "sp-version", path = "../../../primitives/version", default-features = false } [build-dependencies] wasm-builder-runner = { package = "substrate-wasm-builder-runner", path = "../../../client/utils/wasm-builder-runner", version = "1.0.4" } diff --git a/bin/node/runtime/Cargo.toml b/bin/node/runtime/Cargo.toml index 978583f8cc..e1971e8162 100644 --- a/bin/node/runtime/Cargo.toml +++ b/bin/node/runtime/Cargo.toml @@ -16,7 +16,7 @@ serde = { version = "1.0.102", optional = true } # primitives authority-discovery-primitives = { package = "sp-authority-discovery", path = "../../../primitives/authority-discovery", default-features = false } babe-primitives = { package = "sp-consensus-babe", path = "../../../primitives/consensus/babe", default-features = false } -block-builder-api = { package = "sp-block-builder", path = "../../../primitives/block-builder/runtime-api", default-features = false} +block-builder-api = { package = "sp-block-builder", path = "../../../primitives/block-builder", default-features = false} inherents = { package = "sp-inherents", path = "../../../primitives/inherents", default-features = false } node-primitives = { path = "../primitives", default-features = false } offchain-primitives = { package = "sp-offchain", path = "../../../primitives/offchain", default-features = false } @@ -24,11 +24,11 @@ primitives = { package = "sp-core", path = "../../../primitives/core", default- sp-std = { path = "../../../primitives/std", default-features = false } sp-api = { path = "../../../primitives/api", default-features = false } sp-runtime = { path = "../../../primitives/runtime", default-features = false } -sp-staking = { path = "../../../primitives/sr-staking-primitives", default-features = false } +sp-staking = { path = "../../../primitives/staking", default-features = false } sp-keyring = { path = "../../../primitives/keyring", optional = true } sp-session = { path = "../../../primitives/session", default-features = false } sp-transaction-pool = { package = "sp-transaction-pool-api", path = "../../../primitives/transaction-pool", default-features = false } -version = { package = "sp-version", path = "../../../primitives/sr-version", default-features = false } +version = { package = "sp-version", path = "../../../primitives/version", default-features = false } # frame dependencies authority-discovery = { package = "pallet-authority-discovery", path = "../../../frame/authority-discovery", default-features = false } diff --git a/client/Cargo.toml b/client/Cargo.toml index 42158f88ef..328a61d43a 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -23,7 +23,7 @@ log = { version = "0.4.8" } parking_lot = { version = "0.9.0" } primitives = { package = "sp-core", path = "../primitives/core" } sp-std = { path = "../primitives/std" } -runtime-version = { package = "sp-version", path = "../primitives/sr-version" } +runtime-version = { package = "sp-version", path = "../primitives/version" } sp-api = { path = "../primitives/api" } sp-runtime = { path = "../primitives/runtime" } sp-blockchain = { path = "../primitives/blockchain" } diff --git a/client/api/Cargo.toml b/client/api/Cargo.toml index b8a77bde07..ccaad2b86d 100644 --- a/client/api/Cargo.toml +++ b/client/api/Cargo.toml @@ -22,7 +22,7 @@ log = { version = "0.4.8" } parking_lot = { version = "0.9.0" } primitives = { package = "sp-core", path = "../../primitives/core", default-features = false } sp-std = { path = "../../primitives/std", default-features = false } -runtime-version = { package = "sp-version", path = "../../primitives/sr-version", default-features = false } +runtime-version = { package = "sp-version", path = "../../primitives/version", default-features = false } sp-api = { path = "../../primitives/api" } sp-runtime = { path = "../../primitives/runtime", default-features = false } state-machine = { package = "sp-state-machine", path = "../../primitives/state-machine" } diff --git a/client/block-builder/Cargo.toml b/client/block-builder/Cargo.toml index 4ef763d037..3ed6d56ba8 100644 --- a/client/block-builder/Cargo.toml +++ b/client/block-builder/Cargo.toml @@ -10,5 +10,5 @@ sp-runtime = { path = "../../primitives/runtime" } sp-blockchain = { path = "../../primitives/blockchain" } primitives = { package = "sp-core", path = "../../primitives/core" } codec = { package = "parity-scale-codec", version = "1.0.6", features = ["derive"] } -runtime_api = { package = "sp-block-builder", path = "../../primitives/block-builder/runtime-api" } +runtime_api = { package = "sp-block-builder", path = "../../primitives/block-builder" } sp-api = { path = "../../primitives/api" } diff --git a/client/consensus/aura/Cargo.toml b/client/consensus/aura/Cargo.toml index 5823a6ce6b..ad0e5621e2 100644 --- a/client/consensus/aura/Cargo.toml +++ b/client/consensus/aura/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" [dependencies] app-crypto = { package = "sp-application-crypto", path = "../../../primitives/application-crypto" } aura_primitives = { package = "sp-consensus-aura", path = "../../../primitives/consensus/aura" } -block-builder-api = { package = "sp-block-builder", path = "../../../primitives/block-builder/runtime-api" } +block-builder-api = { package = "sp-block-builder", path = "../../../primitives/block-builder" } client = { package = "sc-client", path = "../../" } client-api = { package = "sc-client-api", path = "../../api" } codec = { package = "parity-scale-codec", version = "1.0.0" } @@ -24,7 +24,7 @@ parking_lot = "0.9.0" primitives = { package = "sp-core", path = "../../../primitives/core" } sp-blockchain = { path = "../../../primitives/blockchain" } sp-io = { path = "../../../primitives/io" } -runtime_version = { package = "sp-version", path = "../../../primitives/sr-version" } +runtime_version = { package = "sp-version", path = "../../../primitives/version" } slots = { package = "sc-consensus-slots", path = "../slots" } sp-api = { path = "../../../primitives/api" } sp-runtime = { path = "../../../primitives/runtime" } diff --git a/client/consensus/babe/Cargo.toml b/client/consensus/babe/Cargo.toml index 8f68da5bbc..5003a4bb0e 100644 --- a/client/consensus/babe/Cargo.toml +++ b/client/consensus/babe/Cargo.toml @@ -13,7 +13,7 @@ app-crypto = { package = "sp-application-crypto", path = "../../../primitives/ap 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-version = { package = "sp-version", path = "../../../primitives/version" } sp-io = { path = "../../../primitives/io" } inherents = { package = "sp-inherents", path = "../../../primitives/inherents" } sp-timestamp = { path = "../../../primitives/timestamp" } @@ -22,7 +22,7 @@ keystore = { package = "sc-keystore", path = "../../keystore" } client-api = { package = "sc-client-api", path = "../../api" } client = { package = "sc-client", path = "../../" } sp-api = { path = "../../../primitives/api" } -block-builder-api = { package = "sp-block-builder", path = "../../../primitives/block-builder/runtime-api" } +block-builder-api = { package = "sp-block-builder", path = "../../../primitives/block-builder" } sp-blockchain = { path = "../../../primitives/blockchain" } consensus-common = { package = "sp-consensus", path = "../../../primitives/consensus/common" } uncles = { package = "sc-consensus-uncles", path = "../uncles" } diff --git a/client/consensus/pow/Cargo.toml b/client/consensus/pow/Cargo.toml index 60b88d46e7..b4195c0e0e 100644 --- a/client/consensus/pow/Cargo.toml +++ b/client/consensus/pow/Cargo.toml @@ -11,7 +11,7 @@ primitives = { package = "sp-core", path = "../../../primitives/core" } sp-blockchain = { path = "../../../primitives/blockchain" } sp-runtime = { path = "../../../primitives/runtime" } client-api = { package = "sc-client-api", path = "../../api" } -block-builder-api = { package = "sp-block-builder", path = "../../../primitives/block-builder/runtime-api" } +block-builder-api = { package = "sp-block-builder", path = "../../../primitives/block-builder" } inherents = { package = "sp-inherents", path = "../../../primitives/inherents" } pow-primitives = { package = "sp-consensus-pow", path = "../../../primitives/consensus/pow" } consensus-common = { package = "sp-consensus", path = "../../../primitives/consensus/common" } diff --git a/client/executor/Cargo.toml b/client/executor/Cargo.toml index 6a0723099b..84ba2a9da0 100644 --- a/client/executor/Cargo.toml +++ b/client/executor/Cargo.toml @@ -11,7 +11,7 @@ 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" } -runtime_version = { package = "sp-version", path = "../../primitives/sr-version" } +runtime_version = { package = "sp-version", path = "../../primitives/version" } panic-handler = { package = "sp-panic-handler", path = "../../primitives/panic-handler" } wasmi = "0.6.2" parity-wasm = "0.41.0" diff --git a/client/executor/runtime-test/Cargo.toml b/client/executor/runtime-test/Cargo.toml index 9b103aa1ca..07b0dac21d 100644 --- a/client/executor/runtime-test/Cargo.toml +++ b/client/executor/runtime-test/Cargo.toml @@ -8,7 +8,7 @@ build = "build.rs" [dependencies] sp-std = { path = "../../../primitives/std", default-features = false } sp-io = { path = "../../../primitives/io", default-features = false } -sandbox = { package = "sp-sandbox", path = "../../../primitives/sr-sandbox", default-features = false } +sandbox = { package = "sp-sandbox", path = "../../../primitives/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 } diff --git a/client/network/Cargo.toml b/client/network/Cargo.toml index ac00c48cd7..e2a8e688ad 100644 --- a/client/network/Cargo.toml +++ b/client/network/Cargo.toml @@ -29,7 +29,7 @@ client = { package = "sc-client", path = "../" } client-api = { package = "sc-client-api", path = "../api" } sp-blockchain = { path = "../../primitives/blockchain" } sp-runtime = { path = "../../primitives/runtime" } -sp-arithmetic = { path = "../../primitives/sr-arithmetic" } +sp-arithmetic = { path = "../../primitives/arithmetic" } primitives = { package = "sp-core", path = "../../primitives/core" } block-builder = { package = "sc-block-builder", path = "../block-builder" } codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } diff --git a/client/rpc/Cargo.toml b/client/rpc/Cargo.toml index 0b3282c7c2..4ecc413f58 100644 --- a/client/rpc/Cargo.toml +++ b/client/rpc/Cargo.toml @@ -15,7 +15,7 @@ jsonrpc-pubsub = "14.0.3" log = "0.4.8" primitives = { package = "sp-core", path = "../../primitives/core" } rpc = { package = "jsonrpc-core", version = "14.0.3" } -runtime_version = { package = "sp-version", path = "../../primitives/sr-version" } +runtime_version = { package = "sp-version", path = "../../primitives/version" } serde_json = "1.0.41" session = { package = "sp-session", path = "../../primitives/session" } sp-runtime = { path = "../../primitives/runtime" } diff --git a/client/rpc/api/Cargo.toml b/client/rpc/api/Cargo.toml index 533744ae84..6ec73965df 100644 --- a/client/rpc/api/Cargo.toml +++ b/client/rpc/api/Cargo.toml @@ -15,7 +15,7 @@ jsonrpc-pubsub = "14.0.3" log = "0.4.8" parking_lot = "0.9.0" primitives = { package = "sp-core", path = "../../../primitives/core" } -runtime_version = { package = "sp-version", path = "../../../primitives/sr-version" } +runtime_version = { package = "sp-version", path = "../../../primitives/version" } serde = { version = "1.0.101", features = ["derive"] } serde_json = "1.0.41" txpool-api = { package = "sp-transaction-pool-api", path = "../../../primitives/transaction-pool" } diff --git a/frame/authority-discovery/Cargo.toml b/frame/authority-discovery/Cargo.toml index 7909006901..a6c5d65659 100644 --- a/frame/authority-discovery/Cargo.toml +++ b/frame/authority-discovery/Cargo.toml @@ -18,7 +18,7 @@ support = { package = "frame-support", path = "../support", default-features = f system = { package = "frame-system", path = "../system", default-features = false } [dev-dependencies] -sp-staking = { path = "../../primitives/sr-staking-primitives", default-features = false } +sp-staking = { path = "../../primitives/staking", default-features = false } [features] default = ["std"] diff --git a/frame/babe/Cargo.toml b/frame/babe/Cargo.toml index c51b7a2ab4..4cc325c0e1 100644 --- a/frame/babe/Cargo.toml +++ b/frame/babe/Cargo.toml @@ -11,7 +11,7 @@ serde = { version = "1.0.101", optional = true } inherents = { package = "sp-inherents", path = "../../primitives/inherents", default-features = false } sp-std = { path = "../../primitives/std", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } -sp-staking = { path = "../../primitives/sr-staking-primitives", default-features = false } +sp-staking = { path = "../../primitives/staking", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } system = { package = "frame-system", path = "../system", default-features = false } timestamp = { package = "pallet-timestamp", path = "../timestamp", default-features = false } @@ -23,7 +23,7 @@ sp-io ={ path = "../../primitives/io", default-features = false } [dev-dependencies] lazy_static = "1.4.0" parking_lot = "0.9.0" -sp-version = { path = "../../primitives/sr-version", default-features = false } +sp-version = { path = "../../primitives/version", default-features = false } primitives = { package = "sp-core", path = "../../primitives/core" } test-runtime = { package = "substrate-test-runtime", path = "../../test/utils/runtime" } diff --git a/frame/contracts/Cargo.toml b/frame/contracts/Cargo.toml index 06bc0925bb..b5bd460dee 100644 --- a/frame/contracts/Cargo.toml +++ b/frame/contracts/Cargo.toml @@ -14,7 +14,7 @@ primitives = { package = "sp-core", path = "../../primitives/core", default-fea sp-runtime = { path = "../../primitives/runtime", 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 } +sandbox = { package = "sp-sandbox", path = "../../primitives/sandbox", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } system = { package = "frame-system", path = "../system", default-features = false } diff --git a/frame/grandpa/Cargo.toml b/frame/grandpa/Cargo.toml index c7e61844c9..49cb393315 100644 --- a/frame/grandpa/Cargo.toml +++ b/frame/grandpa/Cargo.toml @@ -11,7 +11,7 @@ primitives = { package = "sp-core", path = "../../primitives/core", default-fea sp-finality-grandpa = { path = "../../primitives/finality-grandpa", default-features = false } sp-std = { path = "../../primitives/std", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } -sp-staking = { path = "../../primitives/sr-staking-primitives", default-features = false } +sp-staking = { path = "../../primitives/staking", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } system = { package = "frame-system", path = "../system", default-features = false } session = { package = "pallet-session", path = "../session", default-features = false } diff --git a/frame/im-online/Cargo.toml b/frame/im-online/Cargo.toml index cac2d49c5c..e71a2f41c4 100644 --- a/frame/im-online/Cargo.toml +++ b/frame/im-online/Cargo.toml @@ -14,7 +14,7 @@ serde = { version = "1.0.101", optional = true } session = { package = "pallet-session", path = "../session", 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 } +sp-staking = { path = "../../primitives/staking", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } system = { package = "frame-system", path = "../system", default-features = false } diff --git a/frame/offences/Cargo.toml b/frame/offences/Cargo.toml index 4aac6d0860..db60c463a0 100644 --- a/frame/offences/Cargo.toml +++ b/frame/offences/Cargo.toml @@ -10,7 +10,7 @@ codec = { package = "parity-scale-codec", version = "1.0.0", default-features = sp-std = { path = "../../primitives/std", default-features = false } serde = { version = "1.0.101", optional = true } sp-runtime = { path = "../../primitives/runtime", default-features = false } -sp-staking = { path = "../../primitives/sr-staking-primitives", default-features = false } +sp-staking = { path = "../../primitives/staking", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } system = { package = "frame-system", path = "../system", default-features = false } diff --git a/frame/session/Cargo.toml b/frame/session/Cargo.toml index b5a6efc476..98f5221cf1 100644 --- a/frame/session/Cargo.toml +++ b/frame/session/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-std = { path = "../../primitives/std", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } -sp-staking = { path = "../../primitives/sr-staking-primitives", default-features = false } +sp-staking = { path = "../../primitives/staking", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } system = { package = "frame-system", path = "../system", default-features = false } timestamp = { package = "pallet-timestamp", path = "../timestamp", default-features = false } diff --git a/frame/staking/Cargo.toml b/frame/staking/Cargo.toml index 320a82ac2d..b125327f18 100644 --- a/frame/staking/Cargo.toml +++ b/frame/staking/Cargo.toml @@ -13,7 +13,7 @@ sp-std = { path = "../../primitives/std", default-features = false } phragmen = { package = "sp-phragmen", path = "../../primitives/phragmen", 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 } +sp-staking = { path = "../../primitives/staking", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } system = { package = "frame-system", path = "../system", default-features = false } session = { package = "pallet-session", path = "../session", default-features = false, features = ["historical"] } diff --git a/frame/support/Cargo.toml b/frame/support/Cargo.toml index 94b392fb50..4312cbceeb 100644 --- a/frame/support/Cargo.toml +++ b/frame/support/Cargo.toml @@ -13,7 +13,7 @@ sp-std = { path = "../../primitives/std", 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 } +sp-arithmetic = { path = "../../primitives/arithmetic", default-features = false } inherents = { package = "sp-inherents", path = "../../primitives/inherents", default-features = false } frame-support-procedural = { package = "frame-support-procedural", path = "./procedural" } paste = "0.1.6" diff --git a/frame/system/Cargo.toml b/frame/system/Cargo.toml index 3fb128e96b..78c8884e42 100644 --- a/frame/system/Cargo.toml +++ b/frame/system/Cargo.toml @@ -12,7 +12,7 @@ primitives = { package = "sp-core", path = "../../primitives/core", default-fea sp-std = { path = "../../primitives/std", 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 } +sp-version = { path = "../../primitives/version", default-features = false } support = { package = "frame-support", path = "../support", default-features = false } impl-trait-for-tuples = "0.1.3" diff --git a/primitives/api/Cargo.toml b/primitives/api/Cargo.toml index fb41802e4e..ef36a7b47a 100644 --- a/primitives/api/Cargo.toml +++ b/primitives/api/Cargo.toml @@ -10,7 +10,7 @@ sp-api-proc-macro = { path = "proc-macro" } primitives = { package = "sp-core", path = "../core", default-features = false } sp-std = { path = "../std", default-features = false } sp-runtime = { path = "../runtime", default-features = false } -sp-version = { path = "../sr-version", default-features = false } +sp-version = { path = "../version", default-features = false } state-machine = { package = "sp-state-machine", path = "../../primitives/state-machine", optional = true } [dev-dependencies] diff --git a/primitives/api/test/Cargo.toml b/primitives/api/test/Cargo.toml index 489069a170..9e0718a0d5 100644 --- a/primitives/api/test/Cargo.toml +++ b/primitives/api/test/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] sp-api = { path = "../" } test-client = { package = "substrate-test-runtime-client", path = "../../../test/utils/runtime/client" } -sp-version = { path = "../../sr-version" } +sp-version = { path = "../../version" } sp-runtime = { path = "../../runtime" } sp-blockchain = { path = "../../blockchain" } consensus_common = { package = "sp-consensus", path = "../../../primitives/consensus/common" } diff --git a/primitives/sr-arithmetic/Cargo.toml b/primitives/arithmetic/Cargo.toml similarity index 100% rename from primitives/sr-arithmetic/Cargo.toml rename to primitives/arithmetic/Cargo.toml diff --git a/primitives/sr-arithmetic/benches/bench.rs b/primitives/arithmetic/benches/bench.rs similarity index 100% rename from primitives/sr-arithmetic/benches/bench.rs rename to primitives/arithmetic/benches/bench.rs diff --git a/primitives/sr-arithmetic/fuzzer/.gitignore b/primitives/arithmetic/fuzzer/.gitignore similarity index 100% rename from primitives/sr-arithmetic/fuzzer/.gitignore rename to primitives/arithmetic/fuzzer/.gitignore diff --git a/primitives/sr-arithmetic/fuzzer/Cargo.lock b/primitives/arithmetic/fuzzer/Cargo.lock similarity index 100% rename from primitives/sr-arithmetic/fuzzer/Cargo.lock rename to primitives/arithmetic/fuzzer/Cargo.lock diff --git a/primitives/sr-arithmetic/fuzzer/Cargo.toml b/primitives/arithmetic/fuzzer/Cargo.toml similarity index 100% rename from primitives/sr-arithmetic/fuzzer/Cargo.toml rename to primitives/arithmetic/fuzzer/Cargo.toml diff --git a/primitives/sr-arithmetic/fuzzer/src/biguint.rs b/primitives/arithmetic/fuzzer/src/biguint.rs similarity index 100% rename from primitives/sr-arithmetic/fuzzer/src/biguint.rs rename to primitives/arithmetic/fuzzer/src/biguint.rs diff --git a/primitives/sr-arithmetic/fuzzer/src/rational128.rs b/primitives/arithmetic/fuzzer/src/rational128.rs similarity index 100% rename from primitives/sr-arithmetic/fuzzer/src/rational128.rs rename to primitives/arithmetic/fuzzer/src/rational128.rs diff --git a/primitives/sr-arithmetic/src/biguint.rs b/primitives/arithmetic/src/biguint.rs similarity index 100% rename from primitives/sr-arithmetic/src/biguint.rs rename to primitives/arithmetic/src/biguint.rs diff --git a/primitives/sr-arithmetic/src/fixed64.rs b/primitives/arithmetic/src/fixed64.rs similarity index 100% rename from primitives/sr-arithmetic/src/fixed64.rs rename to primitives/arithmetic/src/fixed64.rs diff --git a/primitives/sr-arithmetic/src/helpers_128bit.rs b/primitives/arithmetic/src/helpers_128bit.rs similarity index 100% rename from primitives/sr-arithmetic/src/helpers_128bit.rs rename to primitives/arithmetic/src/helpers_128bit.rs diff --git a/primitives/sr-arithmetic/src/lib.rs b/primitives/arithmetic/src/lib.rs similarity index 100% rename from primitives/sr-arithmetic/src/lib.rs rename to primitives/arithmetic/src/lib.rs diff --git a/primitives/sr-arithmetic/src/per_things.rs b/primitives/arithmetic/src/per_things.rs similarity index 100% rename from primitives/sr-arithmetic/src/per_things.rs rename to primitives/arithmetic/src/per_things.rs diff --git a/primitives/sr-arithmetic/src/rational128.rs b/primitives/arithmetic/src/rational128.rs similarity index 100% rename from primitives/sr-arithmetic/src/rational128.rs rename to primitives/arithmetic/src/rational128.rs diff --git a/primitives/sr-arithmetic/src/traits.rs b/primitives/arithmetic/src/traits.rs similarity index 100% rename from primitives/sr-arithmetic/src/traits.rs rename to primitives/arithmetic/src/traits.rs diff --git a/primitives/block-builder/runtime-api/Cargo.toml b/primitives/block-builder/Cargo.toml similarity index 56% rename from primitives/block-builder/runtime-api/Cargo.toml rename to primitives/block-builder/Cargo.toml index f8983fcdd2..c454a1516d 100644 --- a/primitives/block-builder/runtime-api/Cargo.toml +++ b/primitives/block-builder/Cargo.toml @@ -5,11 +5,11 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -sp-runtime = { path = "../../runtime", default-features = false } -sp-api = { path = "../../api", default-features = false } -sp-std = { path = "../../std", default-features = false } +sp-runtime = { path = "../runtime", default-features = false } +sp-api = { path = "../api", default-features = false } +sp-std = { path = "../std", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.6", default-features = false } -inherents = { package = "sp-inherents", path = "../../inherents", default-features = false } +inherents = { package = "sp-inherents", path = "../inherents", default-features = false } [features] default = [ "std" ] diff --git a/primitives/block-builder/runtime-api/src/lib.rs b/primitives/block-builder/src/lib.rs similarity index 100% rename from primitives/block-builder/runtime-api/src/lib.rs rename to primitives/block-builder/src/lib.rs diff --git a/primitives/blockchain/Cargo.toml b/primitives/blockchain/Cargo.toml index 67bb815cf4..598af8153e 100644 --- a/primitives/blockchain/Cargo.toml +++ b/primitives/blockchain/Cargo.toml @@ -12,5 +12,5 @@ derive_more = "0.99.2" parity-scale-codec = { version = "1.0.0", default-features = false, features = ["derive"] } sp_consensus = { package = "sp-consensus", path = "../consensus/common" } sp-runtime = { path = "../runtime" } -sp-block-builder-runtime-api = { package = "sp-block-builder", path = "../block-builder/runtime-api" } +sp-block-builder-runtime-api = { package = "sp-block-builder", path = "../block-builder" } sp-state-machine = { package = "sp-state-machine", path = "../state-machine" } diff --git a/primitives/consensus/common/Cargo.toml b/primitives/consensus/common/Cargo.toml index 128d42c20c..17aec7bca2 100644 --- a/primitives/consensus/common/Cargo.toml +++ b/primitives/consensus/common/Cargo.toml @@ -14,7 +14,7 @@ inherents = { package = "sp-inherents", path = "../../inherents" } futures = { version = "0.3.1", features = ["thread-pool"] } futures-timer = "0.4.0" sp-std = { path = "../../std" } -runtime_version = { package = "sp-version", path = "../../sr-version" } +runtime_version = { package = "sp-version", path = "../../version" } sp-runtime = { path = "../../runtime" } codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } parking_lot = "0.9.0" diff --git a/primitives/runtime/Cargo.toml b/primitives/runtime/Cargo.toml index d149aa089e..3c8377666a 100644 --- a/primitives/runtime/Cargo.toml +++ b/primitives/runtime/Cargo.toml @@ -9,7 +9,7 @@ serde = { version = "1.0.101", optional = true, features = ["derive"] } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } primitives = { package = "sp-core", path = "../core", default-features = false } app-crypto = { package = "sp-application-crypto", path = "../application-crypto", default-features = false } -arithmetic = { package = "sp-arithmetic", path = "../sr-arithmetic", default-features = false } +arithmetic = { package = "sp-arithmetic", path = "../arithmetic", default-features = false } sp-std = { path = "../std", default-features = false } sp-io = { path = "../io", default-features = false } log = { version = "0.4.8", optional = true } diff --git a/primitives/sr-sandbox/Cargo.toml b/primitives/sandbox/Cargo.toml similarity index 100% rename from primitives/sr-sandbox/Cargo.toml rename to primitives/sandbox/Cargo.toml diff --git a/primitives/sr-sandbox/src/lib.rs b/primitives/sandbox/src/lib.rs similarity index 100% rename from primitives/sr-sandbox/src/lib.rs rename to primitives/sandbox/src/lib.rs diff --git a/primitives/sr-sandbox/with_std.rs b/primitives/sandbox/with_std.rs similarity index 100% rename from primitives/sr-sandbox/with_std.rs rename to primitives/sandbox/with_std.rs diff --git a/primitives/sr-sandbox/without_std.rs b/primitives/sandbox/without_std.rs similarity index 100% rename from primitives/sr-sandbox/without_std.rs rename to primitives/sandbox/without_std.rs diff --git a/primitives/sr-staking-primitives/Cargo.toml b/primitives/staking/Cargo.toml similarity index 100% rename from primitives/sr-staking-primitives/Cargo.toml rename to primitives/staking/Cargo.toml diff --git a/primitives/sr-staking-primitives/src/lib.rs b/primitives/staking/src/lib.rs similarity index 100% rename from primitives/sr-staking-primitives/src/lib.rs rename to primitives/staking/src/lib.rs diff --git a/primitives/sr-staking-primitives/src/offence.rs b/primitives/staking/src/offence.rs similarity index 100% rename from primitives/sr-staking-primitives/src/offence.rs rename to primitives/staking/src/offence.rs diff --git a/primitives/sr-version/Cargo.toml b/primitives/version/Cargo.toml similarity index 100% rename from primitives/sr-version/Cargo.toml rename to primitives/version/Cargo.toml diff --git a/primitives/sr-version/src/lib.rs b/primitives/version/src/lib.rs similarity index 100% rename from primitives/sr-version/src/lib.rs rename to primitives/version/src/lib.rs diff --git a/test/utils/runtime/Cargo.toml b/test/utils/runtime/Cargo.toml index 69a4396f4a..549cbd24e7 100644 --- a/test/utils/runtime/Cargo.toml +++ b/test/utils/runtime/Cargo.toml @@ -9,7 +9,7 @@ build = "build.rs" app-crypto = { package = "sp-application-crypto", path = "../../../primitives/application-crypto", default-features = false } aura-primitives = { package = "sp-consensus-aura", path = "../../../primitives/consensus/aura", default-features = false } babe-primitives = { package = "sp-consensus-babe", path = "../../../primitives/consensus/babe", default-features = false } -block-builder-api = { package = "sp-block-builder", path = "../../../primitives/block-builder/runtime-api", default-features = false } +block-builder-api = { package = "sp-block-builder", path = "../../../primitives/block-builder", default-features = false } cfg-if = "0.1.10" codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } executive = { package = "frame-executive", path = "../../../frame/executive", default-features = false } @@ -23,7 +23,7 @@ sp-std = { path = "../../../primitives/std", default-features = false } runtime-interface = { package = "sp-runtime-interface", path = "../../../primitives/runtime-interface", 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 } +runtime_version = { package = "sp-version", path = "../../../primitives/version", default-features = false } serde = { version = "1.0.101", optional = true, features = ["derive"] } session = { package = "sp-session", path = "../../../primitives/session", default-features = false } sp-api = { path = "../../../primitives/api", default-features = false } diff --git a/test/utils/transaction-factory/Cargo.toml b/test/utils/transaction-factory/Cargo.toml index f0c6c25ccc..956e58b88a 100644 --- a/test/utils/transaction-factory/Cargo.toml +++ b/test/utils/transaction-factory/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -block-builder-api = { package = "sp-block-builder", path = "../../../primitives/block-builder/runtime-api" } +block-builder-api = { package = "sp-block-builder", path = "../../../primitives/block-builder" } cli = { package = "sc-cli", path = "../../../client/cli" } client-api = { package = "sc-client-api", path = "../../../client/api" } client = { package = "sc-client", path = "../../../client" } -- GitLab From 9a264a7a9aa5823a2306344cad905d5bf69fb623 Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Wed, 11 Dec 2019 13:13:58 +0100 Subject: [PATCH 125/172] Fix token economics url. (#4355) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix token economics url. Co-Authored-By: Bastian Köcher --- frame/staking/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/staking/src/lib.rs b/frame/staking/src/lib.rs index d468b110c5..d2a6ec7c13 100644 --- a/frame/staking/src/lib.rs +++ b/frame/staking/src/lib.rs @@ -173,7 +173,7 @@ //! calculated using the era duration and the staking rate (the total amount of tokens staked by //! nominators and validators, divided by the total token supply). It aims to incentivise toward a //! defined staking rate. The full specification can be found -//! [here](https://research.web3.foundation/en/latest/polkadot/Token%20Economics/#inflation-model). +//! [here](https://research.web3.foundation/en/latest/polkadot/Token%20Economics.html#inflation-model). //! //! Total reward is split among validators and their nominators depending on the number of points //! they received during the era. Points are added to a validator using -- GitLab From 09917a50941922c3eb226acf93461b1ac5bb9fc9 Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Wed, 11 Dec 2019 13:15:27 +0100 Subject: [PATCH 126/172] Improve is_member and is_runner. (#4356) --- frame/elections-phragmen/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index 0b8cdba22f..0fa0515751 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -492,14 +492,14 @@ impl Module { /// /// Limited number of members. Binary search. Constant time factor. O(1) fn is_member(who: &T::AccountId) -> bool { - Self::members_ids().binary_search(who).is_ok() + Self::members().binary_search_by(|(a, _b)| a.cmp(who)).is_ok() } /// Check if `who` is currently an active runner. /// /// Limited number of runners-up. Binary search. Constant time factor. O(1) fn is_runner(who: &T::AccountId) -> bool { - Self::runners_up_ids().binary_search(who).is_ok() + Self::runners_up().binary_search_by(|(a, _b)| a.cmp(who)).is_ok() } /// Returns number of desired members. -- GitLab From 9ce7e1f7d6c953bdeb3432cf48982855822c40e0 Mon Sep 17 00:00:00 2001 From: Benjamin Kampmann Date: Wed, 11 Dec 2019 15:33:00 +0100 Subject: [PATCH 127/172] Clean up crate names and locations (#4361) * rename crate: sp-transaction-pool-api -> sp-transaction-pool * move primitives/core/derive-debug -> primitives/derive-debug; primitives/core/storage -> primitives/storage * rename crate sp-core-storage -> sp-storage * rename and move: test/utils/transaction-factory -> client/transaction-factory * move transaction-factory -> node/transaction-factory * fix missing rename * Move chain-spec-builder into bin/utils * move subkey into bin/utils * Update new subkey location * Update docs to reflect new location for utils * fixing import name --- .gitlab-ci.yml | 4 +- .maintain/rename-crates-for-2.0.sh | 7 +- Cargo.lock | 98 +++++++++---------- Cargo.toml | 10 +- bin/node-template/Cargo.toml | 2 +- bin/node-template/runtime/Cargo.toml | 2 +- bin/node/cli/Cargo.toml | 6 +- bin/node/cli/src/cli.rs | 6 +- bin/node/cli/src/factory_impl.rs | 4 +- bin/node/rpc/Cargo.toml | 2 +- bin/node/runtime/Cargo.toml | 2 +- bin/node/transaction-factory/Cargo.toml | 19 ++++ .../transaction-factory/src/complex_mode.rs | 0 .../node}/transaction-factory/src/lib.rs | 0 .../node}/transaction-factory/src/modes.rs | 0 .../transaction-factory/src/simple_modes.rs | 0 .../utils/chain-spec-builder/Cargo.toml | 2 +- .../utils/chain-spec-builder/build.rs | 0 .../utils/chain-spec-builder/src/main.rs | 0 bin/{ => utils}/subkey/Cargo.toml | 14 +-- bin/{ => utils}/subkey/README.adoc | 0 bin/{ => utils}/subkey/src/main.rs | 0 bin/{ => utils}/subkey/src/vanity.rs | 0 client/api/Cargo.toml | 2 +- client/basic-authorship/Cargo.toml | 2 +- client/offchain/Cargo.toml | 2 +- client/rpc/Cargo.toml | 2 +- client/rpc/api/Cargo.toml | 2 +- client/service/Cargo.toml | 2 +- client/service/test/Cargo.toml | 2 +- client/transaction-pool/Cargo.toml | 2 +- client/transaction-pool/graph/Cargo.toml | 2 +- docs/Structure.adoc | 9 +- primitives/arithmetic/Cargo.toml | 2 +- primitives/core/Cargo.toml | 4 +- primitives/{core => }/debug-derive/Cargo.toml | 0 .../{core => }/debug-derive/src/impls.rs | 0 primitives/{core => }/debug-derive/src/lib.rs | 0 .../{core => }/debug-derive/tests/tests.rs | 0 primitives/externalities/Cargo.toml | 2 +- primitives/{core => }/storage/Cargo.toml | 4 +- primitives/{core => }/storage/src/lib.rs | 0 primitives/transaction-pool/Cargo.toml | 2 +- test/utils/runtime/Cargo.toml | 2 +- test/utils/transaction-factory/Cargo.toml | 22 ++--- utils/frame/rpc/support/Cargo.toml | 2 +- utils/frame/rpc/support/src/lib.rs | 2 +- utils/frame/rpc/system/Cargo.toml | 2 +- 48 files changed, 138 insertions(+), 111 deletions(-) create mode 100644 bin/node/transaction-factory/Cargo.toml rename {test/utils => bin/node}/transaction-factory/src/complex_mode.rs (100%) rename {test/utils => bin/node}/transaction-factory/src/lib.rs (100%) rename {test/utils => bin/node}/transaction-factory/src/modes.rs (100%) rename {test/utils => bin/node}/transaction-factory/src/simple_modes.rs (100%) rename {test => bin}/utils/chain-spec-builder/Cargo.toml (88%) rename {test => bin}/utils/chain-spec-builder/build.rs (100%) rename {test => bin}/utils/chain-spec-builder/src/main.rs (100%) rename bin/{ => utils}/subkey/Cargo.toml (53%) rename bin/{ => utils}/subkey/README.adoc (100%) rename bin/{ => utils}/subkey/src/main.rs (100%) rename bin/{ => utils}/subkey/src/vanity.rs (100%) rename primitives/{core => }/debug-derive/Cargo.toml (100%) rename primitives/{core => }/debug-derive/src/impls.rs (100%) rename primitives/{core => }/debug-derive/src/lib.rs (100%) rename primitives/{core => }/debug-derive/tests/tests.rs (100%) rename primitives/{core => }/storage/Cargo.toml (83%) rename primitives/{core => }/storage/src/lib.rs (100%) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 04b1616f6a..496de058d1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -122,7 +122,7 @@ cargo-check-subkey: except: - /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1 script: - - cd ./bin/subkey + - cd ./bin/utils/subkey - BUILD_DUMMY_WASM_BINARY=1 time cargo check --release - sccache -s @@ -300,7 +300,7 @@ build-linux-subkey: variables: - $DEPLOY_TAG script: - - cd ./bin/subkey + - cd ./bin/utils/subkey - BUILD_DUMMY_WASM_BINARY=1 time cargo build --release --verbose - cd - - sccache -s diff --git a/.maintain/rename-crates-for-2.0.sh b/.maintain/rename-crates-for-2.0.sh index 8cf5a71c0e..36d2076147 100644 --- a/.maintain/rename-crates-for-2.0.sh +++ b/.maintain/rename-crates-for-2.0.sh @@ -34,9 +34,14 @@ function rename() { TO_RENAME=( # OLD-CRATE-NAME NEW-CRATE-NAME + # post initial rename fixes + "sc-application-crypto sp-application-crypto" + "sp-transaction-pool-api sp-transaction-pool" + "sp-core-storage sp-storage" + "transaction-factory node-transaction-factory" + # PRIMITIVES "substrate-application-crypto sp-application-crypto" - "sc-application-crypto sp-application-crypto" "substrate-authority-discovery-primitives sp-authority-discovery" "substrate-block-builder-runtime-api sp-block-builder" "substrate-consensus-aura-primitives sp-consensus-aura" diff --git a/Cargo.lock b/Cargo.lock index d94d228919..e301f48c07 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3012,6 +3012,7 @@ dependencies = [ "node-primitives 2.0.0", "node-rpc 2.0.0", "node-runtime 2.0.0", + "node-transaction-factory 0.0.1", "pallet-authority-discovery 0.1.0", "pallet-balances 2.0.0", "pallet-contracts 2.0.0", @@ -3051,12 +3052,11 @@ dependencies = [ "sp-keyring 2.0.0", "sp-runtime 2.0.0", "sp-timestamp 2.0.0", - "sp-transaction-pool-api 2.0.0", + "sp-transaction-pool 2.0.0", "structopt 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-build-script-utils 2.0.0", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", - "transaction-factory 0.0.1", "vergen 3.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-futures 0.3.27 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3113,7 +3113,7 @@ dependencies = [ "pallet-transaction-payment-rpc 2.0.0", "sc-client 2.0.0", "sp-runtime 2.0.0", - "sp-transaction-pool-api 2.0.0", + "sp-transaction-pool 2.0.0", "substrate-frame-rpc-system 2.0.0", ] @@ -3183,7 +3183,7 @@ dependencies = [ "sp-session 2.0.0", "sp-staking 2.0.0", "sp-std 2.0.0", - "sp-transaction-pool-api 2.0.0", + "sp-transaction-pool 2.0.0", "sp-version 2.0.0", "substrate-wasm-builder-runner 1.0.4", ] @@ -3215,7 +3215,7 @@ dependencies = [ "sp-inherents 2.0.0", "sp-io 2.0.0", "sp-runtime 2.0.0", - "sp-transaction-pool-api 2.0.0", + "sp-transaction-pool 2.0.0", "substrate-build-script-utils 2.0.0", "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", "trie-root 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3250,7 +3250,7 @@ dependencies = [ "sp-runtime 2.0.0", "sp-session 2.0.0", "sp-std 2.0.0", - "sp-transaction-pool-api 2.0.0", + "sp-transaction-pool 2.0.0", "sp-version 2.0.0", "substrate-wasm-builder-runner 1.0.4", ] @@ -3284,6 +3284,24 @@ dependencies = [ "wabt 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "node-transaction-factory" +version = "0.0.1" +dependencies = [ + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-cli 2.0.0", + "sc-client 2.0.0", + "sc-client-api 2.0.0", + "sc-service 2.0.0", + "sp-api 2.0.0", + "sp-block-builder 2.0.0", + "sp-blockchain 2.0.0", + "sp-consensus 2.0.0", + "sp-core 2.0.0", + "sp-runtime 2.0.0", +] + [[package]] name = "nodrop" version = "0.1.14" @@ -4925,7 +4943,7 @@ dependencies = [ "sp-core 2.0.0", "sp-inherents 2.0.0", "sp-runtime 2.0.0", - "sp-transaction-pool-api 2.0.0", + "sp-transaction-pool 2.0.0", "substrate-test-runtime-client 2.0.0", "tokio-executor 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5065,7 +5083,7 @@ dependencies = [ "sp-state-machine 2.0.0", "sp-std 2.0.0", "sp-test-primitives 2.0.0", - "sp-transaction-pool-api 2.0.0", + "sp-transaction-pool 2.0.0", "sp-trie 2.0.0", "sp-version 2.0.0", ] @@ -5433,7 +5451,7 @@ dependencies = [ "sp-core 2.0.0", "sp-offchain 2.0.0", "sp-runtime 2.0.0", - "sp-transaction-pool-api 2.0.0", + "sp-transaction-pool 2.0.0", "substrate-test-runtime-client 2.0.0", "threadpool 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5480,7 +5498,7 @@ dependencies = [ "sp-runtime 2.0.0", "sp-session 2.0.0", "sp-state-machine 2.0.0", - "sp-transaction-pool-api 2.0.0", + "sp-transaction-pool 2.0.0", "sp-version 2.0.0", "substrate-test-runtime-client 2.0.0", "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5503,7 +5521,7 @@ dependencies = [ "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0", "sp-rpc 2.0.0", - "sp-transaction-pool-api 2.0.0", + "sp-transaction-pool 2.0.0", "sp-version 2.0.0", ] @@ -5574,7 +5592,7 @@ dependencies = [ "sp-io 2.0.0", "sp-runtime 2.0.0", "sp-session 2.0.0", - "sp-transaction-pool-api 2.0.0", + "sp-transaction-pool 2.0.0", "substrate-test-runtime-client 2.0.0", "sysinfo 0.9.6 (registry+https://github.com/rust-lang/crates.io-index)", "target_info 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5599,7 +5617,7 @@ dependencies = [ "sp-consensus 2.0.0", "sp-core 2.0.0", "sp-runtime 2.0.0", - "sp-transaction-pool-api 2.0.0", + "sp-transaction-pool 2.0.0", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -5666,7 +5684,7 @@ dependencies = [ "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-core 2.0.0", "sp-runtime 2.0.0", - "sp-transaction-pool-api 2.0.0", + "sp-transaction-pool 2.0.0", "substrate-test-runtime 2.0.0", ] @@ -5686,7 +5704,7 @@ dependencies = [ "sp-core 2.0.0", "sp-keyring 2.0.0", "sp-runtime 2.0.0", - "sp-transaction-pool-api 2.0.0", + "sp-transaction-pool 2.0.0", "substrate-test-runtime-client 2.0.0", ] @@ -6184,12 +6202,12 @@ dependencies = [ "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-core-storage 2.0.0", "sp-debug-derive 2.0.0", "sp-externalities 2.0.0", "sp-runtime-interface 2.0.0", "sp-serializer 2.0.0", "sp-std 2.0.0", + "sp-storage 2.0.0", "substrate-bip39 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "tiny-bip39 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "tiny-keccak 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -6198,16 +6216,6 @@ dependencies = [ "zeroize 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "sp-core-storage" -version = "2.0.0" -dependencies = [ - "impl-serde 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-debug-derive 2.0.0", - "sp-std 2.0.0", -] - [[package]] name = "sp-debug-derive" version = "2.0.0" @@ -6222,8 +6230,8 @@ name = "sp-externalities" version = "2.0.0" dependencies = [ "environmental 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-core-storage 2.0.0", "sp-std 2.0.0", + "sp-storage 2.0.0", ] [[package]] @@ -6456,6 +6464,16 @@ dependencies = [ name = "sp-std" version = "2.0.0" +[[package]] +name = "sp-storage" +version = "2.0.0" +dependencies = [ + "impl-serde 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-debug-derive 2.0.0", + "sp-std 2.0.0", +] + [[package]] name = "sp-test-primitives" version = "2.0.0" @@ -6480,7 +6498,7 @@ dependencies = [ ] [[package]] -name = "sp-transaction-pool-api" +name = "sp-transaction-pool" version = "2.0.0" dependencies = [ "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -6660,7 +6678,7 @@ dependencies = [ "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "sc-rpc-api 2.0.0", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-core-storage 2.0.0", + "sp-storage 2.0.0", "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -6682,7 +6700,7 @@ dependencies = [ "sp-blockchain 2.0.0", "sp-core 2.0.0", "sp-runtime 2.0.0", - "sp-transaction-pool-api 2.0.0", + "sp-transaction-pool 2.0.0", "substrate-test-runtime-client 2.0.0", ] @@ -6737,7 +6755,7 @@ dependencies = [ "sp-session 2.0.0", "sp-state-machine 2.0.0", "sp-std 2.0.0", - "sp-transaction-pool-api 2.0.0", + "sp-transaction-pool 2.0.0", "sp-trie 2.0.0", "sp-version 2.0.0", "substrate-test-runtime-client 2.0.0", @@ -7297,24 +7315,6 @@ name = "traitobject" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "transaction-factory" -version = "0.0.1" -dependencies = [ - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sc-cli 2.0.0", - "sc-client 2.0.0", - "sc-client-api 2.0.0", - "sc-service 2.0.0", - "sp-api 2.0.0", - "sp-block-builder 2.0.0", - "sp-blockchain 2.0.0", - "sp-consensus 2.0.0", - "sp-core 2.0.0", - "sp-runtime 2.0.0", -] - [[package]] name = "trie-bench" version = "0.17.0" diff --git a/Cargo.toml b/Cargo.toml index 6c0da92499..b423ecbd38 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,9 @@ members = [ "bin/node/rpc", "bin/node/runtime", "bin/node/testing", - "bin/subkey", + "bin/node/transaction-factory", + "bin/utils/subkey", + "bin/utils/chain-spec-builder", "client", "client/api", "client/authority-discovery", @@ -101,8 +103,8 @@ members = [ "primitives/consensus/common", "primitives/consensus/pow", "primitives/core", - "primitives/core/debug-derive", - "primitives/core/storage", + "primitives/debug-derive", + "primitives/storage", "primitives/externalities", "primitives/finality-tracker", "primitives/finality-grandpa", @@ -134,11 +136,9 @@ members = [ "primitives/transaction-pool", "primitives/trie", "primitives/wasm-interface", - "test/utils/chain-spec-builder", "test/utils/client", "test/utils/runtime", "test/utils/runtime/client", - "test/utils/transaction-factory", "utils/build-script-utils", "utils/fork-tree", "utils/frame/rpc/support", diff --git a/bin/node-template/Cargo.toml b/bin/node-template/Cargo.toml index af39bd47f4..966c03549f 100644 --- a/bin/node-template/Cargo.toml +++ b/bin/node-template/Cargo.toml @@ -25,7 +25,7 @@ sc-executor = { path = "../../client/executor" } sc-service = { path = "../../client/service" } inherents = { package = "sp-inherents", path = "../../primitives/inherents" } txpool = { package = "sc-transaction-pool", path = "../../client/transaction-pool" } -txpool-api = { package = "sp-transaction-pool-api", path = "../../primitives/transaction-pool" } +txpool-api = { package = "sp-transaction-pool", path = "../../primitives/transaction-pool" } network = { package = "sc-network", path = "../../client/network" } aura = { package = "sc-consensus-aura", path = "../../client/consensus/aura" } aura-primitives = { package = "sp-consensus-aura", path = "../../primitives/consensus/aura" } diff --git a/bin/node-template/runtime/Cargo.toml b/bin/node-template/runtime/Cargo.toml index f4e1ecb972..bc4833e6e7 100644 --- a/bin/node-template/runtime/Cargo.toml +++ b/bin/node-template/runtime/Cargo.toml @@ -29,7 +29,7 @@ support = { package = "frame-support", path = "../../../frame/support", default- system = { package = "frame-system", path = "../../../frame/system", default-features = false } timestamp = { package = "pallet-timestamp", path = "../../../frame/timestamp", default-features = false } transaction-payment = { package = "pallet-transaction-payment", path = "../../../frame/transaction-payment", default-features = false } -sp-transaction-pool = { package = "sp-transaction-pool-api", path = "../../../primitives/transaction-pool", default-features = false } +sp-transaction-pool = { package = "sp-transaction-pool", path = "../../../primitives/transaction-pool", default-features = false } version = { package = "sp-version", path = "../../../primitives/version", default-features = false } [build-dependencies] diff --git a/bin/node/cli/Cargo.toml b/bin/node/cli/Cargo.toml index 753e22bb42..3d356ce5e4 100644 --- a/bin/node/cli/Cargo.toml +++ b/bin/node/cli/Cargo.toml @@ -51,7 +51,7 @@ client-api = { package = "sc-client-api", path = "../../../client/api" } client = { package = "sc-client", path = "../../../client/" } chain-spec = { package = "sc-chain-spec", path = "../../../client/chain-spec" } txpool = { package = "sc-transaction-pool", path = "../../../client/transaction-pool" } -txpool-api = { package = "sp-transaction-pool-api", path = "../../../primitives/transaction-pool" } +txpool-api = { package = "sp-transaction-pool", path = "../../../primitives/transaction-pool" } network = { package = "sc-network", path = "../../../client/network" } babe = { package = "sc-consensus-babe", path = "../../../client/consensus/babe" } grandpa = { package = "sc-finality-grandpa", path = "../../../client/finality-grandpa" } @@ -83,8 +83,8 @@ node-executor = { path = "../executor" } # CLI-specific dependencies tokio = { version = "0.1.22", optional = true } sc-cli = { path = "../../../client/cli", optional = true } -transaction-factory = { path = "../../../test/utils/transaction-factory", optional = true } ctrlc = { version = "3.1.3", features = ["termination"], optional = true } +node-transaction-factory = { path = "../transaction-factory", optional = true } # WASM-specific dependencies libp2p = { version = "0.13.0", default-features = false, optional = true } @@ -126,7 +126,7 @@ browser = [ ] cli = [ "sc-cli", - "transaction-factory", + "node-transaction-factory", "tokio", "ctrlc", "sc-service/rocksdb", diff --git a/bin/node/cli/src/cli.rs b/bin/node/cli/src/cli.rs index add6eaa590..6e8afc6133 100644 --- a/bin/node/cli/src/cli.rs +++ b/bin/node/cli/src/cli.rs @@ -24,7 +24,7 @@ use structopt::{StructOpt, clap::App}; use sc_cli::{display_role, parse_and_prepare, AugmentClap, GetLogFilter, ParseAndPrepare}; use crate::{service, ChainSpec, load_spec}; use crate::factory_impl::FactoryState; -use transaction_factory::RuntimeAdapter; +use node_transaction_factory::RuntimeAdapter; /// Custom subcommands. #[derive(Clone, Debug, StructOpt)] @@ -70,7 +70,7 @@ pub struct FactoryCmd { /// /// These three modes control manufacturing. #[structopt(long="mode", default_value = "MasterToN")] - pub mode: transaction_factory::Mode, + pub mode: node_transaction_factory::Mode, /// Number of transactions to generate. In mode `MasterNToNToM` this is /// the number of transactions per round. @@ -155,7 +155,7 @@ pub fn run(args: I, exit: E, version: sc_cli::VersionInfo) -> error::Re ); let service_builder = new_full_start!(config).0; - transaction_factory::factory::, _, _, _, _, _>( + node_transaction_factory::factory::, _, _, _, _, _>( factory_state, service_builder.client(), service_builder.select_chain() diff --git a/bin/node/cli/src/factory_impl.rs b/bin/node/cli/src/factory_impl.rs index af0633ab64..b586337a2b 100644 --- a/bin/node/cli/src/factory_impl.rs +++ b/bin/node/cli/src/factory_impl.rs @@ -32,8 +32,8 @@ use primitives::{sr25519, crypto::Pair}; use sp_runtime::{ generic::Era, traits::{Block as BlockT, Header as HeaderT, SignedExtension, Verify, IdentifyAccount} }; -use transaction_factory::RuntimeAdapter; -use transaction_factory::modes::Mode; +use node_transaction_factory::RuntimeAdapter; +use node_transaction_factory::modes::Mode; use inherents::InherentData; use sp_timestamp; use sp_finality_tracker; diff --git a/bin/node/rpc/Cargo.toml b/bin/node/rpc/Cargo.toml index f3d5536a75..2aead3b969 100644 --- a/bin/node/rpc/Cargo.toml +++ b/bin/node/rpc/Cargo.toml @@ -13,4 +13,4 @@ sp-runtime = { path = "../../../primitives/runtime" } pallet-contracts-rpc = { path = "../../../frame/contracts/rpc/" } pallet-transaction-payment-rpc = { path = "../../../frame/transaction-payment/rpc/" } substrate-frame-rpc-system = { path = "../../../utils/frame/rpc/system" } -txpool-api = { package = "sp-transaction-pool-api", path = "../../../primitives/transaction-pool" } +txpool-api = { package = "sp-transaction-pool", path = "../../../primitives/transaction-pool" } diff --git a/bin/node/runtime/Cargo.toml b/bin/node/runtime/Cargo.toml index e1971e8162..3c0a0f236c 100644 --- a/bin/node/runtime/Cargo.toml +++ b/bin/node/runtime/Cargo.toml @@ -27,7 +27,7 @@ sp-runtime = { path = "../../../primitives/runtime", default-features = false } sp-staking = { path = "../../../primitives/staking", default-features = false } sp-keyring = { path = "../../../primitives/keyring", optional = true } sp-session = { path = "../../../primitives/session", default-features = false } -sp-transaction-pool = { package = "sp-transaction-pool-api", path = "../../../primitives/transaction-pool", default-features = false } +sp-transaction-pool = { package = "sp-transaction-pool", path = "../../../primitives/transaction-pool", default-features = false } version = { package = "sp-version", path = "../../../primitives/version", default-features = false } # frame dependencies diff --git a/bin/node/transaction-factory/Cargo.toml b/bin/node/transaction-factory/Cargo.toml new file mode 100644 index 0000000000..ab17c52b0d --- /dev/null +++ b/bin/node/transaction-factory/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "node-transaction-factory" +version = "0.0.1" +authors = ["Parity Technologies "] +edition = "2018" + +[dependencies] +block-builder-api = { package = "sp-block-builder", path = "../../../primitives/block-builder" } +cli = { package = "sc-cli", path = "../../../client/cli" } +client-api = { package = "sc-client-api", path = "../../../client/api" } +client = { package = "sc-client", path = "../../../client" } +codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } +consensus_common = { package = "sp-consensus", path = "../../../primitives/consensus/common" } +log = "0.4.8" +primitives = { package = "sp-core", path = "../../../primitives/core" } +sp-api = { path = "../../../primitives/api" } +sp-runtime = { path = "../../../primitives/runtime" } +sc-service = { path = "../../../client/service" } +sp-blockchain = { path = "../../../primitives/blockchain" } diff --git a/test/utils/transaction-factory/src/complex_mode.rs b/bin/node/transaction-factory/src/complex_mode.rs similarity index 100% rename from test/utils/transaction-factory/src/complex_mode.rs rename to bin/node/transaction-factory/src/complex_mode.rs diff --git a/test/utils/transaction-factory/src/lib.rs b/bin/node/transaction-factory/src/lib.rs similarity index 100% rename from test/utils/transaction-factory/src/lib.rs rename to bin/node/transaction-factory/src/lib.rs diff --git a/test/utils/transaction-factory/src/modes.rs b/bin/node/transaction-factory/src/modes.rs similarity index 100% rename from test/utils/transaction-factory/src/modes.rs rename to bin/node/transaction-factory/src/modes.rs diff --git a/test/utils/transaction-factory/src/simple_modes.rs b/bin/node/transaction-factory/src/simple_modes.rs similarity index 100% rename from test/utils/transaction-factory/src/simple_modes.rs rename to bin/node/transaction-factory/src/simple_modes.rs diff --git a/test/utils/chain-spec-builder/Cargo.toml b/bin/utils/chain-spec-builder/Cargo.toml similarity index 88% rename from test/utils/chain-spec-builder/Cargo.toml rename to bin/utils/chain-spec-builder/Cargo.toml index 32829bdb51..4d317d3a54 100644 --- a/test/utils/chain-spec-builder/Cargo.toml +++ b/bin/utils/chain-spec-builder/Cargo.toml @@ -8,7 +8,7 @@ build = "build.rs" [dependencies] ansi_term = "0.12.1" keystore = { package = "sc-keystore", path = "../../../client/keystore" } -node-cli = { path = "../../../bin/node/cli" } +node-cli = { path = "../../node/cli" } primitives = { package = "sp-core", path = "../../../primitives/core" } rand = "0.7.2" structopt = "0.3.3" diff --git a/test/utils/chain-spec-builder/build.rs b/bin/utils/chain-spec-builder/build.rs similarity index 100% rename from test/utils/chain-spec-builder/build.rs rename to bin/utils/chain-spec-builder/build.rs diff --git a/test/utils/chain-spec-builder/src/main.rs b/bin/utils/chain-spec-builder/src/main.rs similarity index 100% rename from test/utils/chain-spec-builder/src/main.rs rename to bin/utils/chain-spec-builder/src/main.rs diff --git a/bin/subkey/Cargo.toml b/bin/utils/subkey/Cargo.toml similarity index 53% rename from bin/subkey/Cargo.toml rename to bin/utils/subkey/Cargo.toml index 50cffad7de..a173c10130 100644 --- a/bin/subkey/Cargo.toml +++ b/bin/utils/subkey/Cargo.toml @@ -5,10 +5,10 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -primitives = { package = "sp-core", version = "*", path = "../../primitives/core" } -node-runtime = { version = "*", path = "../node/runtime" } -node-primitives = { version = "*", path = "../node/primitives" } -sp-runtime = { version = "*", path = "../../primitives/runtime" } +primitives = { package = "sp-core", version = "*", path = "../../../primitives/core" } +node-runtime = { version = "*", path = "../../node/runtime" } +node-primitives = { version = "*", path = "../../node/primitives" } +sp-runtime = { version = "*", path = "../../../primitives/runtime" } rand = "0.7.2" clap = "2.33.0" tiny-bip39 = "0.6.2" @@ -17,9 +17,9 @@ substrate-bip39 = "0.3.1" hex = "0.4.0" hex-literal = "0.2.1" codec = { package = "parity-scale-codec", version = "1.0.0" } -system = { package = "frame-system", path = "../../frame/system" } -balances = { package = "pallet-balances", path = "../../frame/balances" } -transaction-payment = { package = "pallet-transaction-payment", path = "../../frame/transaction-payment" } +system = { package = "frame-system", path = "../../../frame/system" } +balances = { package = "pallet-balances", path = "../../../frame/balances" } +transaction-payment = { package = "pallet-transaction-payment", path = "../../../frame/transaction-payment" } [features] bench = [] diff --git a/bin/subkey/README.adoc b/bin/utils/subkey/README.adoc similarity index 100% rename from bin/subkey/README.adoc rename to bin/utils/subkey/README.adoc diff --git a/bin/subkey/src/main.rs b/bin/utils/subkey/src/main.rs similarity index 100% rename from bin/subkey/src/main.rs rename to bin/utils/subkey/src/main.rs diff --git a/bin/subkey/src/vanity.rs b/bin/utils/subkey/src/vanity.rs similarity index 100% rename from bin/subkey/src/vanity.rs rename to bin/utils/subkey/src/vanity.rs diff --git a/client/api/Cargo.toml b/client/api/Cargo.toml index ccaad2b86d..f47294d571 100644 --- a/client/api/Cargo.toml +++ b/client/api/Cargo.toml @@ -28,7 +28,7 @@ sp-runtime = { path = "../../primitives/runtime", default-features = false } state-machine = { package = "sp-state-machine", path = "../../primitives/state-machine" } sc-telemetry = { path = "../telemetry" } trie = { package = "sp-trie", path = "../../primitives/trie" } -txpool-api = { package = "sp-transaction-pool-api", path = "../../primitives/transaction-pool" } +txpool-api = { package = "sp-transaction-pool", path = "../../primitives/transaction-pool" } [dev-dependencies] test-primitives = { package = "sp-test-primitives", path = "../../primitives/test-primitives" } \ No newline at end of file diff --git a/client/basic-authorship/Cargo.toml b/client/basic-authorship/Cargo.toml index 1132ec3c90..82eb5c3db9 100644 --- a/client/basic-authorship/Cargo.toml +++ b/client/basic-authorship/Cargo.toml @@ -16,7 +16,7 @@ client-api = { package = "sc-client-api", path = "../api" } consensus_common = { package = "sp-consensus", path = "../../primitives/consensus/common" } inherents = { package = "sp-inherents", path = "../../primitives/inherents" } sc-telemetry = { path = "../telemetry" } -txpool-api = { package = "sp-transaction-pool-api", path = "../../primitives/transaction-pool" } +txpool-api = { package = "sp-transaction-pool", path = "../../primitives/transaction-pool" } block-builder = { package = "sc-block-builder", path = "../block-builder" } tokio-executor = { version = "0.2.0-alpha.6", features = ["blocking"] } diff --git a/client/offchain/Cargo.toml b/client/offchain/Cargo.toml index 3d3046ff41..5bfffc80f5 100644 --- a/client/offchain/Cargo.toml +++ b/client/offchain/Cargo.toml @@ -36,7 +36,7 @@ env_logger = "0.7.0" test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client" } tokio = "0.1.22" txpool = { package = "sc-transaction-pool", path = "../../client/transaction-pool" } -txpool-api = { package = "sp-transaction-pool-api", path = "../../primitives/transaction-pool" } +txpool-api = { package = "sp-transaction-pool", path = "../../primitives/transaction-pool" } [features] default = [] diff --git a/client/rpc/Cargo.toml b/client/rpc/Cargo.toml index 4ecc413f58..ab93d48d2c 100644 --- a/client/rpc/Cargo.toml +++ b/client/rpc/Cargo.toml @@ -23,7 +23,7 @@ rpc-primitives = { package = "sp-rpc", path = "../../primitives/rpc" } state_machine = { package = "sp-state-machine", path = "../../primitives/state-machine" } sc-executor = { path = "../executor" } sc-keystore = { path = "../keystore" } -txpool-api = { package = "sp-transaction-pool-api", path = "../../primitives/transaction-pool" } +txpool-api = { package = "sp-transaction-pool", path = "../../primitives/transaction-pool" } sp-blockchain = { path = "../../primitives/blockchain" } hash-db = { version = "0.15.2", default-features = false } parking_lot = { version = "0.9.0" } diff --git a/client/rpc/api/Cargo.toml b/client/rpc/api/Cargo.toml index 6ec73965df..e5e6903215 100644 --- a/client/rpc/api/Cargo.toml +++ b/client/rpc/api/Cargo.toml @@ -18,5 +18,5 @@ primitives = { package = "sp-core", path = "../../../primitives/core" } runtime_version = { package = "sp-version", path = "../../../primitives/version" } serde = { version = "1.0.101", features = ["derive"] } serde_json = "1.0.41" -txpool-api = { package = "sp-transaction-pool-api", path = "../../../primitives/transaction-pool" } +txpool-api = { package = "sp-transaction-pool", path = "../../../primitives/transaction-pool" } rpc-primitives = { package = "sp-rpc", path = "../../../primitives/rpc" } diff --git a/client/service/Cargo.toml b/client/service/Cargo.toml index f09fad08de..0424aa28e7 100644 --- a/client/service/Cargo.toml +++ b/client/service/Cargo.toml @@ -45,7 +45,7 @@ client_db = { package = "sc-client-db", path = "../db" } codec = { package = "parity-scale-codec", version = "1.0.0" } sc-executor = { path = "../executor" } txpool = { package = "sc-transaction-pool", path = "../transaction-pool" } -sp-transaction-pool = { package = "sp-transaction-pool-api", path = "../../primitives/transaction-pool" } +sp-transaction-pool = { package = "sp-transaction-pool", path = "../../primitives/transaction-pool" } rpc-servers = { package = "sc-rpc-server", path = "../rpc-servers" } rpc = { package = "sc-rpc", path = "../rpc" } tel = { package = "sc-telemetry", path = "../telemetry" } diff --git a/client/service/test/Cargo.toml b/client/service/test/Cargo.toml index 87b4bfface..0a85fe0f6d 100644 --- a/client/service/test/Cargo.toml +++ b/client/service/test/Cargo.toml @@ -18,4 +18,4 @@ consensus = { package = "sp-consensus", path = "../../../primitives/consensus/co client = { package = "sc-client", path = "../../" } sp-runtime = { path = "../../../primitives/runtime" } primitives = { package = "sp-core", path = "../../../primitives/core" } -txpool-api = { package = "sp-transaction-pool-api", path = "../../../primitives/transaction-pool" } +txpool-api = { package = "sp-transaction-pool", path = "../../../primitives/transaction-pool" } diff --git a/client/transaction-pool/Cargo.toml b/client/transaction-pool/Cargo.toml index ff2a5e8f79..67cfe78373 100644 --- a/client/transaction-pool/Cargo.toml +++ b/client/transaction-pool/Cargo.toml @@ -14,7 +14,7 @@ primitives = { package = "sp-core", path = "../../primitives/core" } sp-api = { path = "../../primitives/api" } sp-runtime = { path = "../../primitives/runtime" } txpool = { package = "sc-transaction-graph", path = "./graph" } -txpool-api = { package = "sp-transaction-pool-api", path = "../../primitives/transaction-pool" } +txpool-api = { package = "sp-transaction-pool", path = "../../primitives/transaction-pool" } client-api = { package = "sc-client-api", path = "../api" } sp-blockchain = { path = "../../primitives/blockchain" } diff --git a/client/transaction-pool/graph/Cargo.toml b/client/transaction-pool/graph/Cargo.toml index 9e128557d2..a9f5e2e6b1 100644 --- a/client/transaction-pool/graph/Cargo.toml +++ b/client/transaction-pool/graph/Cargo.toml @@ -12,7 +12,7 @@ parking_lot = "0.9.0" serde = { version = "1.0.101", features = ["derive"] } primitives = { package = "sp-core", path = "../../../primitives/core" } sp-runtime = { path = "../../../primitives/runtime" } -txpool-api = { package = "sp-transaction-pool-api", path = "../../../primitives/transaction-pool" } +txpool-api = { package = "sp-transaction-pool", path = "../../../primitives/transaction-pool" } [dev-dependencies] assert_matches = "1.3.0" diff --git a/docs/Structure.adoc b/docs/Structure.adoc index cff2b48019..cb0e4b28cb 100644 --- a/docs/Structure.adoc +++ b/docs/Structure.adoc @@ -87,11 +87,14 @@ The default (testing) application pulling together our recommended setup of subs We also provide a template to get you started building your own node. -==== Subkey +==== Utils -* _found in_: `/bin/subkey` +* _found in_: `/bin/utils` -Subkey is a client library to generate keys and sign transactions to send to a substrate node. +- **subkey** + Subkey is a client library to generate keys and sign transactions to send to a substrate node. +- **chain-spec-builder** + The chain spec builder builds a chain specification that includes a Substrate runtime compiled as WASM. To ensure proper functioning of the included runtime compile (or run) the chain spec builder binary in `--release` mode. == Internal Dependency Tree diff --git a/primitives/arithmetic/Cargo.toml b/primitives/arithmetic/Cargo.toml index 7b6b8cc64c..bc7fd42019 100644 --- a/primitives/arithmetic/Cargo.toml +++ b/primitives/arithmetic/Cargo.toml @@ -10,7 +10,7 @@ integer-sqrt = "0.1.2" num-traits = { version = "0.2.8", default-features = false } sp-std = { path = "../std", default-features = false } serde = { version = "1.0.101", optional = true, features = ["derive"] } -sp-debug-derive = { path = "../../primitives/core/debug-derive", default-features = false } +sp-debug-derive = { path = "../../primitives/debug-derive", default-features = false } [dev-dependencies] primitive-types = "0.6.0" diff --git a/primitives/core/Cargo.toml b/primitives/core/Cargo.toml index d8e2513879..bde9d37ee0 100644 --- a/primitives/core/Cargo.toml +++ b/primitives/core/Cargo.toml @@ -25,9 +25,9 @@ num-traits = { version = "0.2.8", default-features = false } zeroize = { version = "1.0.0", default-features = false } lazy_static = { version = "1.4.0", default-features = false, optional = true } parking_lot = { version = "0.9.0", optional = true } -sp-debug-derive = { version = "2.0.0", path = "./debug-derive" } +sp-debug-derive = { version = "2.0.0", path = "../debug-derive" } externalities = { package = "sp-externalities", path = "../externalities", optional = true } -primitives-storage = { package = "sp-core-storage", path = "storage", default-features = false } +primitives-storage = { package = "sp-storage", path = "../storage", default-features = false } # full crypto ed25519-dalek = { version = "1.0.0-pre.3", default-features = false, features = ["u64_backend", "alloc"], optional = true } diff --git a/primitives/core/debug-derive/Cargo.toml b/primitives/debug-derive/Cargo.toml similarity index 100% rename from primitives/core/debug-derive/Cargo.toml rename to primitives/debug-derive/Cargo.toml diff --git a/primitives/core/debug-derive/src/impls.rs b/primitives/debug-derive/src/impls.rs similarity index 100% rename from primitives/core/debug-derive/src/impls.rs rename to primitives/debug-derive/src/impls.rs diff --git a/primitives/core/debug-derive/src/lib.rs b/primitives/debug-derive/src/lib.rs similarity index 100% rename from primitives/core/debug-derive/src/lib.rs rename to primitives/debug-derive/src/lib.rs diff --git a/primitives/core/debug-derive/tests/tests.rs b/primitives/debug-derive/tests/tests.rs similarity index 100% rename from primitives/core/debug-derive/tests/tests.rs rename to primitives/debug-derive/tests/tests.rs diff --git a/primitives/externalities/Cargo.toml b/primitives/externalities/Cargo.toml index 8a89a0be08..d64d104baa 100644 --- a/primitives/externalities/Cargo.toml +++ b/primitives/externalities/Cargo.toml @@ -6,6 +6,6 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -primitives-storage = { package = "sp-core-storage", path = "../core/storage" } +primitives-storage = { package = "sp-storage", path = "../storage" } sp-std = { path = "../std" } environmental = { version = "1.0.2" } diff --git a/primitives/core/storage/Cargo.toml b/primitives/storage/Cargo.toml similarity index 83% rename from primitives/core/storage/Cargo.toml rename to primitives/storage/Cargo.toml index d124dd47e1..d3fc7267bf 100644 --- a/primitives/core/storage/Cargo.toml +++ b/primitives/storage/Cargo.toml @@ -1,12 +1,12 @@ [package] -name = "sp-core-storage" +name = "sp-storage" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" description = "Storage related primitives" [dependencies] -sp-std = { path = "../../std", default-features = false } +sp-std = { path = "../std", default-features = false } serde = { version = "1.0.101", optional = true, features = ["derive"] } impl-serde = { version = "0.2.3", optional = true } sp-debug-derive = { version = "2.0.0", path = "../debug-derive" } diff --git a/primitives/core/storage/src/lib.rs b/primitives/storage/src/lib.rs similarity index 100% rename from primitives/core/storage/src/lib.rs rename to primitives/storage/src/lib.rs diff --git a/primitives/transaction-pool/Cargo.toml b/primitives/transaction-pool/Cargo.toml index e1a55d6b37..1bb0139dc0 100644 --- a/primitives/transaction-pool/Cargo.toml +++ b/primitives/transaction-pool/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "sp-transaction-pool-api" +name = "sp-transaction-pool" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" diff --git a/test/utils/runtime/Cargo.toml b/test/utils/runtime/Cargo.toml index 549cbd24e7..afde5a3d14 100644 --- a/test/utils/runtime/Cargo.toml +++ b/test/utils/runtime/Cargo.toml @@ -34,7 +34,7 @@ frame-system-rpc-runtime-api = { path = "../../../frame/system/rpc/runtime-api", pallet-timestamp = { path = "../../../frame/timestamp", default-features = false } sc-client = { path = "../../../client", optional = true } sp-trie = { path = "../../../primitives/trie", default-features = false } -sp-transaction-pool = { package = "sp-transaction-pool-api", path = "../../../primitives/transaction-pool", default-features = false } +sp-transaction-pool = { package = "sp-transaction-pool", path = "../../../primitives/transaction-pool", default-features = false } trie-db = { version = "0.16.0", default-features = false } [dev-dependencies] diff --git a/test/utils/transaction-factory/Cargo.toml b/test/utils/transaction-factory/Cargo.toml index 956e58b88a..76293b6e07 100644 --- a/test/utils/transaction-factory/Cargo.toml +++ b/test/utils/transaction-factory/Cargo.toml @@ -1,19 +1,19 @@ [package] -name = "transaction-factory" +name = "sc-transaction-factory" version = "0.0.1" authors = ["Parity Technologies "] edition = "2018" [dependencies] -block-builder-api = { package = "sp-block-builder", path = "../../../primitives/block-builder" } -cli = { package = "sc-cli", path = "../../../client/cli" } -client-api = { package = "sc-client-api", path = "../../../client/api" } -client = { package = "sc-client", path = "../../../client" } +block-builder-api = { package = "sp-block-builder", path = "../../primitives/block-builder" } +cli = { package = "sc-cli", path = "../cli" } +client-api = { package = "sc-client-api", path = "../api" } +client = { package = "sc-client", path = "../" } codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } -consensus_common = { package = "sp-consensus", path = "../../../primitives/consensus/common" } +consensus_common = { package = "sp-consensus", path = "../../primitives/consensus/common" } log = "0.4.8" -primitives = { package = "sp-core", path = "../../../primitives/core" } -sp-api = { path = "../../../primitives/api" } -sp-runtime = { path = "../../../primitives/runtime" } -sc-service = { path = "../../../client/service" } -sp-blockchain = { path = "../../../primitives/blockchain" } +primitives = { package = "sp-core", path = "../../primitives/core" } +sp-api = { path = "../../primitives/api" } +sp-runtime = { path = "../../primitives/runtime" } +sc-service = { path = "../service" } +sp-blockchain = { path = "../../primitives/blockchain" } diff --git a/utils/frame/rpc/support/Cargo.toml b/utils/frame/rpc/support/Cargo.toml index d2ca6c060e..1833322cd6 100644 --- a/utils/frame/rpc/support/Cargo.toml +++ b/utils/frame/rpc/support/Cargo.toml @@ -11,7 +11,7 @@ jsonrpc-core = "14" parity-scale-codec = "1" serde = "1" frame-support = { path = "../../../../frame/support" } -sp-core-storage = { path = "../../../../primitives/core/storage" } +sp-storage = { path = "../../../../primitives/storage" } sc-rpc-api = { path = "../../../../client/rpc/api" } [dev-dependencies] diff --git a/utils/frame/rpc/support/src/lib.rs b/utils/frame/rpc/support/src/lib.rs index c16e31f7e0..396c521501 100644 --- a/utils/frame/rpc/support/src/lib.rs +++ b/utils/frame/rpc/support/src/lib.rs @@ -27,7 +27,7 @@ use serde::{de::DeserializeOwned, Serialize}; use frame_support::storage::generator::{ StorageDoubleMap, StorageLinkedMap, StorageMap, StorageValue }; -use sp_core_storage::{StorageData, StorageKey}; +use sp_storage::{StorageData, StorageKey}; use sc_rpc_api::state::StateClient; /// A typed query on chain state usable from an RPC client. diff --git a/utils/frame/rpc/system/Cargo.toml b/utils/frame/rpc/system/Cargo.toml index d2273f941d..0697d15e63 100644 --- a/utils/frame/rpc/system/Cargo.toml +++ b/utils/frame/rpc/system/Cargo.toml @@ -17,7 +17,7 @@ sp-runtime = { path = "../../../../primitives/runtime" } frame-system-rpc-runtime-api = { path = "../../../../frame/system/rpc/runtime-api" } sp-core = { path = "../../../../primitives/core" } sp-blockchain = { path = "../../../../primitives/blockchain" } -txpool-api = { package = "sp-transaction-pool-api", path = "../../../../primitives/transaction-pool" } +txpool-api = { package = "sp-transaction-pool", path = "../../../../primitives/transaction-pool" } [dev-dependencies] test-client = { package = "substrate-test-runtime-client", path = "../../../../test/utils/runtime/client" } -- GitLab From 050424e28b8d984b7d24ce1620b16644e89660ec Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Thu, 12 Dec 2019 00:27:13 +0900 Subject: [PATCH 128/172] Allow referendums to begin out of order (#4345) * Allow referendums to begin out of order * Make `inject_referendum` infallible * Merge remote-tracking branch 'origin/gav-verified-id' into gav-verified-id # Conflicts: # frame/identity/src/lib.rs * Renames. --- frame/democracy/src/lib.rs | 104 +++++++++++++++++++++++++------------ 1 file changed, 70 insertions(+), 34 deletions(-) diff --git a/frame/democracy/src/lib.rs b/frame/democracy/src/lib.rs index 82aecc8557..de0ef3a5d7 100644 --- a/frame/democracy/src/lib.rs +++ b/frame/democracy/src/lib.rs @@ -276,8 +276,9 @@ decl_storage! { /// The next free referendum index, aka the number of referenda started so far. pub ReferendumCount get(fn referendum_count) build(|_| 0 as ReferendumIndex): ReferendumIndex; - /// The next referendum index that should be tallied. - pub NextTally get(fn next_tally) build(|_| 0 as ReferendumIndex): ReferendumIndex; + /// The lowest referendum index representing an unbaked referendum. Equal to + /// `ReferendumCount` if there isn't a unbaked referendum. + pub LowestUnbaked get(fn lowest_unbaked) build(|_| 0 as ReferendumIndex): ReferendumIndex; /// Information concerning any given referendum. pub ReferendumInfoOf get(fn referendum_info): map ReferendumIndex => Option<(ReferendumInfo)>; @@ -541,7 +542,7 @@ decl_module! { let now = >::block_number(); // We don't consider it an error if `vote_period` is too low, like `emergency_propose`. let period = voting_period.max(T::EmergencyVotingPeriod::get()); - Self::inject_referendum(now + period, proposal_hash, threshold, delay).map(|_| ())?; + Self::inject_referendum(now + period, proposal_hash, threshold, delay); } /// Veto and blacklist the external proposal hash. @@ -763,7 +764,7 @@ impl Module { pub fn active_referenda() -> Vec<(ReferendumIndex, ReferendumInfo)> { - let next = Self::next_tally(); + let next = Self::lowest_unbaked(); let last = Self::referendum_count(); (next..last).into_iter() .filter_map(|i| Self::referendum_info(i).map(|info| (i, info))) @@ -774,11 +775,11 @@ impl Module { pub fn maturing_referenda_at( n: T::BlockNumber ) -> Vec<(ReferendumIndex, ReferendumInfo)> { - let next = Self::next_tally(); + let next = Self::lowest_unbaked(); let last = Self::referendum_count(); (next..last).into_iter() .filter_map(|i| Self::referendum_info(i).map(|info| (i, info))) - .take_while(|&(_, ref info)| info.end == n) + .filter(|&(_, ref info)| info.end == n) .collect() } @@ -867,7 +868,7 @@ impl Module { proposal_hash: T::Hash, threshold: VoteThreshold, delay: T::BlockNumber - ) -> result::Result { + ) -> ReferendumIndex { >::inject_referendum( >::block_number() + T::VotingPeriod::get(), proposal_hash, @@ -900,26 +901,26 @@ impl Module { proposal_hash: T::Hash, threshold: VoteThreshold, delay: T::BlockNumber, - ) -> result::Result { + ) -> ReferendumIndex { let ref_index = Self::referendum_count(); - if ref_index.checked_sub(1) - .and_then(Self::referendum_info) - .map(|i| i.end > end) - .unwrap_or(false) - { - Err("Cannot inject a referendum that ends earlier than preceeding referendum")? - } - ReferendumCount::put(ref_index + 1); let item = ReferendumInfo { end, proposal_hash, threshold, delay }; >::insert(ref_index, item); Self::deposit_event(RawEvent::Started(ref_index, threshold)); - Ok(ref_index) + ref_index } /// Remove all info on a referendum. fn clear_referendum(ref_index: ReferendumIndex) { >::remove(ref_index); + + LowestUnbaked::mutate(|i| if *i == ref_index { + *i += 1; + let end = ReferendumCount::get(); + while !Self::is_active_referendum(*i) && *i < end { + *i += 1; + } + }); >::remove(ref_index); for v in Self::voters_for(ref_index) { >::remove((ref_index, v)); @@ -967,7 +968,7 @@ impl Module { proposal, threshold, T::EnactmentPeriod::get(), - )?; + ); Ok(()) } else { Err("No external proposal waiting") @@ -996,7 +997,7 @@ impl Module { proposal, VoteThreshold::SuperMajorityApprove, T::EnactmentPeriod::get(), - )?; + ); } Ok(()) } else { @@ -1037,6 +1038,7 @@ impl Module { } Self::clear_referendum(index); + if approved { Self::deposit_event(RawEvent::Passed(index)); if info.delay.is_zero() { @@ -1050,7 +1052,6 @@ impl Module { } else { Self::deposit_event(RawEvent::NotPassed(index)); } - NextTally::put(index + 1); Ok(()) } @@ -1277,7 +1278,7 @@ mod tests { set_balance_proposal_hash(2), VoteThreshold::SuperMajorityApprove, 0 - ).unwrap(); + ); assert_ok!(Democracy::vote(Origin::signed(1), r, AYE)); next_block(); @@ -1304,7 +1305,7 @@ mod tests { set_balance_proposal_hash_and_note(2), VoteThreshold::SuperMajorityApprove, 0 - ).unwrap(); + ); assert_ok!(Democracy::vote(Origin::signed(1), r, AYE)); assert_eq!(Balances::reserved_balance(6), 12); @@ -1329,7 +1330,7 @@ mod tests { set_balance_proposal_hash(2), VoteThreshold::SuperMajorityApprove, 1 - ).unwrap(); + ); assert_ok!(Democracy::vote(Origin::signed(1), r, AYE)); assert_noop!( @@ -1470,7 +1471,7 @@ mod tests { set_balance_proposal_hash_and_note(2), VoteThreshold::SuperMajorityApprove, 2 - ).unwrap(); + ); assert!(Democracy::referendum_info(r).is_some()); assert_noop!(Democracy::emergency_cancel(Origin::signed(3), r), "Invalid origin"); @@ -1484,7 +1485,7 @@ mod tests { set_balance_proposal_hash_and_note(2), VoteThreshold::SuperMajorityApprove, 2 - ).unwrap(); + ); assert!(Democracy::referendum_info(r).is_some()); assert_noop!(Democracy::emergency_cancel(Origin::signed(4), r), "cannot cancel the same proposal twice"); }); @@ -2013,6 +2014,41 @@ mod tests { }); } + #[test] + fn ooo_inject_referendums_should_work() { + new_test_ext().execute_with(|| { + System::set_block_number(1); + let r1 = Democracy::inject_referendum( + 3, + set_balance_proposal_hash_and_note(3), + VoteThreshold::SuperMajorityApprove, + 0 + ); + let r2 = Democracy::inject_referendum( + 2, + set_balance_proposal_hash_and_note(2), + VoteThreshold::SuperMajorityApprove, + 0 + ); + + assert_ok!(Democracy::vote(Origin::signed(1), r2, AYE)); + assert_eq!(Democracy::voters_for(r2), vec![1]); + assert_eq!(Democracy::vote_of((r2, 1)), AYE); + assert_eq!(Democracy::tally(r2), (1, 0, 1)); + + next_block(); + assert_eq!(Balances::free_balance(&42), 2); + + assert_ok!(Democracy::vote(Origin::signed(1), r1, AYE)); + assert_eq!(Democracy::voters_for(r1), vec![1]); + assert_eq!(Democracy::vote_of((r1, 1)), AYE); + assert_eq!(Democracy::tally(r1), (1, 0, 1)); + + next_block(); + assert_eq!(Balances::free_balance(&42), 3); + }); + } + #[test] fn simple_passing_should_work() { new_test_ext().execute_with(|| { @@ -2022,7 +2058,7 @@ mod tests { set_balance_proposal_hash_and_note(2), VoteThreshold::SuperMajorityApprove, 0 - ).unwrap(); + ); assert_ok!(Democracy::vote(Origin::signed(1), r, AYE)); assert_eq!(Democracy::voters_for(r), vec![1]); @@ -2045,7 +2081,7 @@ mod tests { set_balance_proposal_hash_and_note(2), VoteThreshold::SuperMajorityApprove, 0 - ).unwrap(); + ); assert_ok!(Democracy::vote(Origin::signed(1), r, AYE)); assert_ok!(Democracy::cancel_referendum(Origin::ROOT, r.into())); @@ -2065,7 +2101,7 @@ mod tests { set_balance_proposal_hash_and_note(2), VoteThreshold::SuperMajorityApprove, 0 - ).unwrap(); + ); assert_ok!(Democracy::vote(Origin::signed(1), r, NAY)); assert_eq!(Democracy::voters_for(r), vec![1]); @@ -2088,7 +2124,7 @@ mod tests { set_balance_proposal_hash_and_note(2), VoteThreshold::SuperMajorityApprove, 0 - ).unwrap(); + ); assert_ok!(Democracy::vote(Origin::signed(1), r, BIG_AYE)); assert_ok!(Democracy::vote(Origin::signed(2), r, BIG_NAY)); @@ -2115,7 +2151,7 @@ mod tests { set_balance_proposal_hash_and_note(2), VoteThreshold::SuperMajorityApprove, 1 - ).unwrap(); + ); assert_ok!(Democracy::vote(Origin::signed(1), r, AYE)); assert_ok!(Democracy::vote(Origin::signed(2), r, AYE)); assert_ok!(Democracy::vote(Origin::signed(3), r, AYE)); @@ -2143,7 +2179,7 @@ mod tests { set_balance_proposal_hash_and_note(2), VoteThreshold::SuperMajorityApprove, 0 - ).unwrap(); + ); assert_ok!(Democracy::vote(Origin::signed(5), r, BIG_NAY)); assert_ok!(Democracy::vote(Origin::signed(6), r, BIG_AYE)); @@ -2168,7 +2204,7 @@ mod tests { set_balance_proposal_hash_and_note(2), VoteThreshold::SuperMajorityApprove, 0 - ).unwrap(); + ); assert_ok!(Democracy::vote(Origin::signed(4), r, BIG_AYE)); assert_ok!(Democracy::vote(Origin::signed(5), r, BIG_NAY)); assert_ok!(Democracy::vote(Origin::signed(6), r, BIG_AYE)); @@ -2191,7 +2227,7 @@ mod tests { set_balance_proposal_hash_and_note(2), VoteThreshold::SuperMajorityApprove, 0 - ).unwrap(); + ); assert_ok!(Democracy::vote(Origin::signed(1), r, Vote { aye: false, conviction: Conviction::Locked5x @@ -2251,7 +2287,7 @@ mod tests { set_balance_proposal_hash_and_note(2), VoteThreshold::SuperMajorityApprove, 0 - ).unwrap(); + ); assert_ok!(Democracy::vote(Origin::signed(1), r, Vote { aye: false, conviction: Conviction::Locked5x -- GitLab From b5414b65c3d81999bec8fbd7a4c3dec12721a66b Mon Sep 17 00:00:00 2001 From: Benjamin Kampmann Date: Wed, 11 Dec 2019 16:41:38 +0100 Subject: [PATCH 129/172] Fix folder names in client and test (#4360) * client/rpc/api -> client/rpc-api * client/util/wasm-builder-runner -> utils/wasm-builder-runner * client/grafana-data-source -> utils/grafana-data-source * test/utils -> test-utils * fix moved path * Update Cargo.lock * Update Cargo.lock --- Cargo.lock | 20 ++--- Cargo.toml | 14 ++-- bin/node-template/runtime/Cargo.toml | 2 +- bin/node/executor/Cargo.toml | 2 +- bin/node/runtime/Cargo.toml | 2 +- bin/node/testing/Cargo.toml | 2 +- client/Cargo.toml | 2 +- client/basic-authorship/Cargo.toml | 2 +- client/consensus/aura/Cargo.toml | 2 +- client/consensus/babe/Cargo.toml | 2 +- client/consensus/slots/Cargo.toml | 2 +- client/db/Cargo.toml | 2 +- client/executor/Cargo.toml | 2 +- client/executor/runtime-test/Cargo.toml | 2 +- client/finality-grandpa/Cargo.toml | 2 +- client/network/Cargo.toml | 4 +- client/network/test/Cargo.toml | 4 +- client/offchain/Cargo.toml | 2 +- client/{rpc/api => rpc-api}/Cargo.toml | 8 +- .../{rpc/api => rpc-api}/src/author/error.rs | 0 .../{rpc/api => rpc-api}/src/author/hash.rs | 0 client/{rpc/api => rpc-api}/src/author/mod.rs | 0 .../{rpc/api => rpc-api}/src/chain/error.rs | 0 client/{rpc/api => rpc-api}/src/chain/mod.rs | 0 client/{rpc/api => rpc-api}/src/errors.rs | 0 client/{rpc/api => rpc-api}/src/helpers.rs | 0 client/{rpc/api => rpc-api}/src/lib.rs | 0 .../{rpc/api => rpc-api}/src/state/error.rs | 0 client/{rpc/api => rpc-api}/src/state/mod.rs | 0 .../{rpc/api => rpc-api}/src/subscriptions.rs | 0 .../{rpc/api => rpc-api}/src/system/error.rs | 0 .../api => rpc-api}/src/system/helpers.rs | 0 client/{rpc/api => rpc-api}/src/system/mod.rs | 0 client/rpc/Cargo.toml | 4 +- client/service/Cargo.toml | 4 +- client/tracing/Cargo.toml | 2 +- client/transaction-pool/Cargo.toml | 2 +- client/transaction-pool/graph/Cargo.toml | 2 +- frame/babe/Cargo.toml | 2 +- frame/elections-phragmen/Cargo.toml | 2 +- frame/staking/Cargo.toml | 2 +- primitives/api/test/Cargo.toml | 4 +- primitives/application-crypto/test/Cargo.toml | 2 +- primitives/phragmen/Cargo.toml | 2 +- .../runtime-interface/test-wasm/Cargo.toml | 2 +- {test/utils => test-utils}/Cargo.toml | 0 test-utils/client/Cargo.toml | 20 +++++ .../client/src/client_ext.rs | 0 {test/utils => test-utils}/client/src/lib.rs | 0 test-utils/runtime/Cargo.toml | 83 +++++++++++++++++++ {test/utils => test-utils}/runtime/build.rs | 2 +- .../runtime/client/Cargo.toml | 12 +-- .../runtime/client/src/block_builder_ext.rs | 0 .../runtime/client/src/lib.rs | 0 .../runtime/client/src/trait_tests.rs | 0 .../runtime/src/genesismap.rs | 0 {test/utils => test-utils}/runtime/src/lib.rs | 0 .../runtime/src/system.rs | 0 {test/utils => test-utils}/src/lib.rs | 0 test/utils/client/Cargo.toml | 20 ----- test/utils/runtime/Cargo.toml | 83 ------------------- test/utils/transaction-factory/Cargo.toml | 19 ----- utils/frame/rpc/support/Cargo.toml | 2 +- utils/frame/rpc/system/Cargo.toml | 2 +- .../grafana-data-source/Cargo.toml | 0 .../grafana-data-source/src/database.rs | 0 .../grafana-data-source/src/lib.rs | 0 .../grafana-data-source/src/networking.rs | 0 .../grafana-data-source/src/server.rs | 0 .../grafana-data-source/src/types.rs | 0 .../grafana-data-source/test/Cargo.toml | 0 .../grafana-data-source/test/src/main.rs | 0 .../wasm-builder-runner/Cargo.toml | 0 .../wasm-builder-runner/README.md | 0 .../wasm-builder-runner/src/lib.rs | 0 75 files changed, 166 insertions(+), 185 deletions(-) rename client/{rpc/api => rpc-api}/Cargo.toml (60%) rename client/{rpc/api => rpc-api}/src/author/error.rs (100%) rename client/{rpc/api => rpc-api}/src/author/hash.rs (100%) rename client/{rpc/api => rpc-api}/src/author/mod.rs (100%) rename client/{rpc/api => rpc-api}/src/chain/error.rs (100%) rename client/{rpc/api => rpc-api}/src/chain/mod.rs (100%) rename client/{rpc/api => rpc-api}/src/errors.rs (100%) rename client/{rpc/api => rpc-api}/src/helpers.rs (100%) rename client/{rpc/api => rpc-api}/src/lib.rs (100%) rename client/{rpc/api => rpc-api}/src/state/error.rs (100%) rename client/{rpc/api => rpc-api}/src/state/mod.rs (100%) rename client/{rpc/api => rpc-api}/src/subscriptions.rs (100%) rename client/{rpc/api => rpc-api}/src/system/error.rs (100%) rename client/{rpc/api => rpc-api}/src/system/helpers.rs (100%) rename client/{rpc/api => rpc-api}/src/system/mod.rs (100%) rename {test/utils => test-utils}/Cargo.toml (100%) create mode 100644 test-utils/client/Cargo.toml rename {test/utils => test-utils}/client/src/client_ext.rs (100%) rename {test/utils => test-utils}/client/src/lib.rs (100%) create mode 100644 test-utils/runtime/Cargo.toml rename {test/utils => test-utils}/runtime/build.rs (97%) rename {test/utils => test-utils}/runtime/client/Cargo.toml (55%) rename {test/utils => test-utils}/runtime/client/src/block_builder_ext.rs (100%) rename {test/utils => test-utils}/runtime/client/src/lib.rs (100%) rename {test/utils => test-utils}/runtime/client/src/trait_tests.rs (100%) rename {test/utils => test-utils}/runtime/src/genesismap.rs (100%) rename {test/utils => test-utils}/runtime/src/lib.rs (100%) rename {test/utils => test-utils}/runtime/src/system.rs (100%) rename {test/utils => test-utils}/src/lib.rs (100%) delete mode 100644 test/utils/client/Cargo.toml delete mode 100644 test/utils/runtime/Cargo.toml delete mode 100644 test/utils/transaction-factory/Cargo.toml rename {client => utils}/grafana-data-source/Cargo.toml (100%) rename {client => utils}/grafana-data-source/src/database.rs (100%) rename {client => utils}/grafana-data-source/src/lib.rs (100%) rename {client => utils}/grafana-data-source/src/networking.rs (100%) rename {client => utils}/grafana-data-source/src/server.rs (100%) rename {client => utils}/grafana-data-source/src/types.rs (100%) rename {client => utils}/grafana-data-source/test/Cargo.toml (100%) rename {client => utils}/grafana-data-source/test/src/main.rs (100%) rename {client/utils => utils}/wasm-builder-runner/Cargo.toml (100%) rename {client/utils => utils}/wasm-builder-runner/README.md (100%) rename {client/utils => utils}/wasm-builder-runner/src/lib.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index e301f48c07..cc63cf57f0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1207,7 +1207,7 @@ dependencies = [ [[package]] name = "finality-grandpa" -version = "0.10.1" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2368,7 +2368,7 @@ dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "libsecp256k1 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "multistream-select 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "multistream-select 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multiaddr 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-multihash 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2777,7 +2777,7 @@ dependencies = [ [[package]] name = "lru" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "hashbrown 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2932,7 +2932,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "multistream-select" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5298,7 +5298,7 @@ name = "sc-finality-grandpa" version = "2.0.0" dependencies = [ "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "finality-grandpa 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "finality-grandpa 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "fork-tree 2.0.0", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5365,7 +5365,7 @@ dependencies = [ "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "linked_hash_set 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "lru 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "lru 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "quickcheck 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -6106,7 +6106,7 @@ version = "2.0.0" dependencies = [ "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "lru 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "lru 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sp-block-builder 2.0.0", @@ -8188,7 +8188,7 @@ dependencies = [ "checksum fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" "checksum fdlimit 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b1ee15a7050e5580b3712877157068ea713b245b080ff302ae2ca973cfcd9baa" "checksum file-per-thread-logger 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8505b75b31ef7285168dd237c4a7db3c1f3e0927e7d314e670bc98e854272fe9" -"checksum finality-grandpa 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bd555755b04f83d6ed3041f5da26c0123a417ae2b96a826c1171b3f6fb804803" +"checksum finality-grandpa 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4106eb29c7e092f4a6ce6e7632abbbfdf85d94e63035d3790d2d16eeae83d3f4" "checksum fixed-hash 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "72fe7539e2c5692c6989f2f9c0457e42f1e5768f96b85c87d273574670ae459f" "checksum fixedbitset 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "86d4de0081402f5e88cdac65c8dcdcc73118c1a7a465e2a05f0da05843a8ea33" "checksum flate2 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6bd6d6f4752952feb71363cffc9ebac9411b75b87c6ab6058c40c8900cf43c0f" @@ -8317,7 +8317,7 @@ dependencies = [ "checksum lock_api 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e57b3997725d2b60dbec1297f6c2e2957cc383db1cebd6be812163f969c7d586" "checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" "checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" -"checksum lru 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "79aea63cd4aa0930b66807632cc61c74db9ea687358fc1f165bab053bcce4a7a" +"checksum lru 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0609345ddee5badacf857d4f547e0e5a2e987db77085c24cd887f73573a04237" "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" "checksum malloc_size_of_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e37c5d4cd9473c5f4c9c111f033f15d4df9bd378fdf615944e360a4f55a05f0b" "checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" @@ -8335,7 +8335,7 @@ dependencies = [ "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" "checksum more-asserts 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0debeb9fcf88823ea64d64e4a815ab1643f33127d995978e099942ce38f25238" "checksum multimap 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2eb04b9f127583ed176e163fb9ec6f3e793b87e21deedd5734a69386a18a0151" -"checksum multistream-select 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1242e4ecf2060b35fb58002988e4720fbb3a2cbd4c136d369c420fa028f69efe" +"checksum multistream-select 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fc3ef54aab1b2e37e911bcb99e376dbe4c1e0710afcdb8428608e4f993b39c47" "checksum names 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ef320dab323286b50fb5cdda23f61c796a72a89998ab565ca32525c5c556f2da" "checksum native-tls 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4b2df1a4c22fd44a62147fd8f13dd0f95c9d8ca7b2610299b2a2f9cf8964274e" "checksum net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" diff --git a/Cargo.toml b/Cargo.toml index b423ecbd38..84f4128515 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,16 +37,16 @@ members = [ "client/peerset", "client/rpc-servers", "client/rpc", - "client/rpc/api", + "client/rpc-api", "client/service", "client/service/test", "client/state-db", "client/telemetry", "client/transaction-pool", "client/transaction-pool/graph", - "client/utils/wasm-builder-runner", - "client/grafana-data-source", - "client/grafana-data-source/test", + "utils/wasm-builder-runner", + "utils/grafana-data-source", + "utils/grafana-data-source/test", "frame/assets", "frame/aura", "frame/authority-discovery", @@ -136,9 +136,9 @@ members = [ "primitives/transaction-pool", "primitives/trie", "primitives/wasm-interface", - "test/utils/client", - "test/utils/runtime", - "test/utils/runtime/client", + "test-utils/client", + "test-utils/runtime", + "test-utils/runtime/client", "utils/build-script-utils", "utils/fork-tree", "utils/frame/rpc/support", diff --git a/bin/node-template/runtime/Cargo.toml b/bin/node-template/runtime/Cargo.toml index bc4833e6e7..c1c30d3adc 100644 --- a/bin/node-template/runtime/Cargo.toml +++ b/bin/node-template/runtime/Cargo.toml @@ -33,7 +33,7 @@ sp-transaction-pool = { package = "sp-transaction-pool", path = "../../../primit version = { package = "sp-version", path = "../../../primitives/version", default-features = false } [build-dependencies] -wasm-builder-runner = { package = "substrate-wasm-builder-runner", path = "../../../client/utils/wasm-builder-runner", version = "1.0.4" } +wasm-builder-runner = { package = "substrate-wasm-builder-runner", path = "../../../utils/wasm-builder-runner", version = "1.0.4" } [features] default = ["std"] diff --git a/bin/node/executor/Cargo.toml b/bin/node/executor/Cargo.toml index a86ca7a391..7633c256e7 100644 --- a/bin/node/executor/Cargo.toml +++ b/bin/node/executor/Cargo.toml @@ -18,7 +18,7 @@ node-runtime = { path = "../runtime" } [dev-dependencies] node-testing = { path = "../testing" } -test-client = { package = "substrate-test-client", path = "../../../test/utils/client" } +test-client = { package = "substrate-test-client", path = "../../../test-utils/client" } sp-runtime = { path = "../../../primitives/runtime" } runtime_support = { package = "frame-support", path = "../../../frame/support" } balances = { package = "pallet-balances", path = "../../../frame/balances" } diff --git a/bin/node/runtime/Cargo.toml b/bin/node/runtime/Cargo.toml index 3c0a0f236c..1cc4fc831b 100644 --- a/bin/node/runtime/Cargo.toml +++ b/bin/node/runtime/Cargo.toml @@ -63,7 +63,7 @@ transaction-payment = { package = "pallet-transaction-payment", path = "../../.. transaction-payment-rpc-runtime-api = { package = "pallet-transaction-payment-rpc-runtime-api", path = "../../../frame/transaction-payment/rpc/runtime-api/", default-features = false } [build-dependencies] -wasm-builder-runner = { package = "substrate-wasm-builder-runner", path = "../../../client/utils/wasm-builder-runner", version = "1.0.4" } +wasm-builder-runner = { package = "substrate-wasm-builder-runner", path = "../../../utils/wasm-builder-runner", version = "1.0.4" } [dev-dependencies] sp-io = { path = "../../../primitives/io" } diff --git a/bin/node/testing/Cargo.toml b/bin/node/testing/Cargo.toml index 799ba86289..ce5aa78a5d 100644 --- a/bin/node/testing/Cargo.toml +++ b/bin/node/testing/Cargo.toml @@ -24,7 +24,7 @@ sp-runtime = { path = "../../../primitives/runtime" } staking = { package = "pallet-staking", path = "../../../frame/staking" } sc-executor = { path = "../../../client/executor" } system = { package = "frame-system", path = "../../../frame/system" } -test-client = { package = "substrate-test-client", path = "../../../test/utils/client" } +test-client = { package = "substrate-test-client", path = "../../../test-utils/client" } timestamp = { package = "pallet-timestamp", path = "../../../frame/timestamp" } transaction-payment = { package = "pallet-transaction-payment", path = "../../../frame/transaction-payment" } treasury = { package = "pallet-treasury", path = "../../../frame/treasury" } diff --git a/client/Cargo.toml b/client/Cargo.toml index 328a61d43a..c259c8db30 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -35,6 +35,6 @@ tracing = "0.1.10" [dev-dependencies] env_logger = "0.7.0" tempfile = "3.1.0" -test-client = { package = "substrate-test-runtime-client", path = "../test/utils/runtime/client" } +test-client = { package = "substrate-test-runtime-client", path = "../test-utils/runtime/client" } kvdb-memorydb = "0.1.2" panic-handler = { package = "sp-panic-handler", path = "../primitives/panic-handler" } diff --git a/client/basic-authorship/Cargo.toml b/client/basic-authorship/Cargo.toml index 82eb5c3db9..f361ebe477 100644 --- a/client/basic-authorship/Cargo.toml +++ b/client/basic-authorship/Cargo.toml @@ -22,5 +22,5 @@ tokio-executor = { version = "0.2.0-alpha.6", features = ["blocking"] } [dev-dependencies] txpool = { package = "sc-transaction-pool", path = "../../client/transaction-pool" } -test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client" } +test-client = { package = "substrate-test-runtime-client", path = "../../test-utils/runtime/client" } parking_lot = "0.9" diff --git a/client/consensus/aura/Cargo.toml b/client/consensus/aura/Cargo.toml index ad0e5621e2..c35d72bd67 100644 --- a/client/consensus/aura/Cargo.toml +++ b/client/consensus/aura/Cargo.toml @@ -37,7 +37,7 @@ sc-executor = { path = "../../executor" } sc-network = { path = "../../network" } sc-network-test = { path = "../../network/test" } service = { package = "sc-service", path = "../../service" } -test-client = { package = "substrate-test-runtime-client", path = "../../../test/utils/runtime/client" } +test-client = { package = "substrate-test-runtime-client", path = "../../../test-utils/runtime/client" } tokio = "0.1.22" env_logger = "0.7.0" tempfile = "3.1.0" diff --git a/client/consensus/babe/Cargo.toml b/client/consensus/babe/Cargo.toml index 5003a4bb0e..d03157415a 100644 --- a/client/consensus/babe/Cargo.toml +++ b/client/consensus/babe/Cargo.toml @@ -46,7 +46,7 @@ sc-executor = { path = "../../executor" } sc-network = { path = "../../network" } sc-network-test = { path = "../../network/test" } service = { package = "sc-service", path = "../../service" } -test-client = { package = "substrate-test-runtime-client", path = "../../../test/utils/runtime/client" } +test-client = { package = "substrate-test-runtime-client", path = "../../../test-utils/runtime/client" } block-builder = { package = "sc-block-builder", path = "../../block-builder" } tokio = "0.1.22" env_logger = "0.7.0" diff --git a/client/consensus/slots/Cargo.toml b/client/consensus/slots/Cargo.toml index 81629d2e32..18d9f97b19 100644 --- a/client/consensus/slots/Cargo.toml +++ b/client/consensus/slots/Cargo.toml @@ -21,4 +21,4 @@ parking_lot = "0.9.0" log = "0.4.8" [dev-dependencies] -test-client = { package = "substrate-test-runtime-client", path = "../../../test/utils/runtime/client" } +test-client = { package = "substrate-test-runtime-client", path = "../../../test-utils/runtime/client" } diff --git a/client/db/Cargo.toml b/client/db/Cargo.toml index 631d89ce48..c6c256b7eb 100644 --- a/client/db/Cargo.toml +++ b/client/db/Cargo.toml @@ -26,7 +26,7 @@ sp-blockchain = { path = "../../primitives/blockchain" } [dev-dependencies] sp-keyring = { path = "../../primitives/keyring" } -test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client" } +test-client = { package = "substrate-test-runtime-client", path = "../../test-utils/runtime/client" } env_logger = "0.7.0" quickcheck = "0.9" diff --git a/client/executor/Cargo.toml b/client/executor/Cargo.toml index 84ba2a9da0..6dc4b46017 100644 --- a/client/executor/Cargo.toml +++ b/client/executor/Cargo.toml @@ -37,7 +37,7 @@ assert_matches = "1.3.0" wabt = "0.9.2" hex-literal = "0.2.1" runtime-test = { package = "sc-runtime-test", path = "runtime-test" } -test-runtime = { package = "substrate-test-runtime", path = "../../test/utils/runtime" } +test-runtime = { package = "substrate-test-runtime", path = "../../test-utils/runtime" } runtime-interface = { package = "sp-runtime-interface", path = "../../primitives/runtime-interface" } state_machine = { package = "sp-state-machine", path = "../../primitives/state-machine" } test-case = "0.3.3" diff --git a/client/executor/runtime-test/Cargo.toml b/client/executor/runtime-test/Cargo.toml index 07b0dac21d..5d781a7249 100644 --- a/client/executor/runtime-test/Cargo.toml +++ b/client/executor/runtime-test/Cargo.toml @@ -13,7 +13,7 @@ primitives = { package = "sp-core", path = "../../../primitives/core", default- sp-runtime = { package = "sp-runtime", path = "../../../primitives/runtime", default-features = false } [build-dependencies] -wasm-builder-runner = { package = "substrate-wasm-builder-runner", path = "../../../client/utils/wasm-builder-runner", version = "1.0.4" } +wasm-builder-runner = { package = "substrate-wasm-builder-runner", path = "../../../utils/wasm-builder-runner", version = "1.0.4" } [features] default = [ "std" ] diff --git a/client/finality-grandpa/Cargo.toml b/client/finality-grandpa/Cargo.toml index 1ba0cfa766..fb6cb0827a 100644 --- a/client/finality-grandpa/Cargo.toml +++ b/client/finality-grandpa/Cargo.toml @@ -34,7 +34,7 @@ grandpa = { package = "finality-grandpa", version = "0.10.1", features = ["deriv network = { package = "sc-network", path = "../network" } sc-network-test = { path = "../network/test" } keyring = { package = "sp-keyring", path = "../../primitives/keyring" } -test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client"} +test-client = { package = "substrate-test-runtime-client", path = "../../test-utils/runtime/client"} babe_primitives = { package = "sp-consensus-babe", path = "../../primitives/consensus/babe" } state_machine = { package = "sp-state-machine", path = "../../primitives/state-machine" } env_logger = "0.7.0" diff --git a/client/network/Cargo.toml b/client/network/Cargo.toml index e2a8e688ad..d7ac7c3b6d 100644 --- a/client/network/Cargo.toml +++ b/client/network/Cargo.toml @@ -43,8 +43,8 @@ tokio-io = "0.1.12" tokio = { version = "0.1.22", optional = true } unsigned-varint = { version = "0.2.2", features = ["codec"] } keyring = { package = "sp-keyring", path = "../../primitives/keyring", optional = true } -test_client = { package = "substrate-test-client", path = "../../test/utils/client", optional = true } -test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client", optional = true } +test_client = { package = "substrate-test-client", path = "../../test-utils/client", optional = true } +test-client = { package = "substrate-test-runtime-client", path = "../../test-utils/runtime/client", optional = true } erased-serde = "0.3.9" void = "1.0.2" zeroize = "1.0.0" diff --git a/client/network/test/Cargo.toml b/client/network/test/Cargo.toml index 3ebb7ac6b4..e92ae0f7fc 100644 --- a/client/network/test/Cargo.toml +++ b/client/network/test/Cargo.toml @@ -24,7 +24,7 @@ primitives = { package = "sp-core", path = "../../../primitives/core" } block-builder = { package = "sc-block-builder", path = "../../block-builder" } babe-primitives = { package = "sp-consensus-babe", path = "../../../primitives/consensus/babe" } env_logger = "0.7.0" -test-client = { package = "substrate-test-runtime-client", path = "../../../test/utils/runtime/client" } -test_runtime = { package = "substrate-test-runtime", path = "../../../test/utils/runtime" } +test-client = { package = "substrate-test-runtime-client", path = "../../../test-utils/runtime/client" } +test_runtime = { package = "substrate-test-runtime", path = "../../../test-utils/runtime" } tempfile = "3.1.0" tokio = "0.1.22" diff --git a/client/offchain/Cargo.toml b/client/offchain/Cargo.toml index 5bfffc80f5..755453fa21 100644 --- a/client/offchain/Cargo.toml +++ b/client/offchain/Cargo.toml @@ -33,7 +33,7 @@ hyper-rustls = "0.17.1" [dev-dependencies] client-db = { package = "sc-client-db", path = "../db/", default-features = true } env_logger = "0.7.0" -test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client" } +test-client = { package = "substrate-test-runtime-client", path = "../../test-utils/runtime/client" } tokio = "0.1.22" txpool = { package = "sc-transaction-pool", path = "../../client/transaction-pool" } txpool-api = { package = "sp-transaction-pool", path = "../../primitives/transaction-pool" } diff --git a/client/rpc/api/Cargo.toml b/client/rpc-api/Cargo.toml similarity index 60% rename from client/rpc/api/Cargo.toml rename to client/rpc-api/Cargo.toml index e5e6903215..58fb3ca904 100644 --- a/client/rpc/api/Cargo.toml +++ b/client/rpc-api/Cargo.toml @@ -14,9 +14,9 @@ jsonrpc-derive = "14.0.3" jsonrpc-pubsub = "14.0.3" log = "0.4.8" parking_lot = "0.9.0" -primitives = { package = "sp-core", path = "../../../primitives/core" } -runtime_version = { package = "sp-version", path = "../../../primitives/version" } +primitives = { package = "sp-core", path = "../../primitives/core" } +runtime_version = { package = "sp-version", path = "../../primitives/version" } serde = { version = "1.0.101", features = ["derive"] } serde_json = "1.0.41" -txpool-api = { package = "sp-transaction-pool", path = "../../../primitives/transaction-pool" } -rpc-primitives = { package = "sp-rpc", path = "../../../primitives/rpc" } +txpool-api = { package = "sp-transaction-pool", path = "../../primitives/transaction-pool" } +rpc-primitives = { package = "sp-rpc", path = "../../primitives/rpc" } diff --git a/client/rpc/api/src/author/error.rs b/client/rpc-api/src/author/error.rs similarity index 100% rename from client/rpc/api/src/author/error.rs rename to client/rpc-api/src/author/error.rs diff --git a/client/rpc/api/src/author/hash.rs b/client/rpc-api/src/author/hash.rs similarity index 100% rename from client/rpc/api/src/author/hash.rs rename to client/rpc-api/src/author/hash.rs diff --git a/client/rpc/api/src/author/mod.rs b/client/rpc-api/src/author/mod.rs similarity index 100% rename from client/rpc/api/src/author/mod.rs rename to client/rpc-api/src/author/mod.rs diff --git a/client/rpc/api/src/chain/error.rs b/client/rpc-api/src/chain/error.rs similarity index 100% rename from client/rpc/api/src/chain/error.rs rename to client/rpc-api/src/chain/error.rs diff --git a/client/rpc/api/src/chain/mod.rs b/client/rpc-api/src/chain/mod.rs similarity index 100% rename from client/rpc/api/src/chain/mod.rs rename to client/rpc-api/src/chain/mod.rs diff --git a/client/rpc/api/src/errors.rs b/client/rpc-api/src/errors.rs similarity index 100% rename from client/rpc/api/src/errors.rs rename to client/rpc-api/src/errors.rs diff --git a/client/rpc/api/src/helpers.rs b/client/rpc-api/src/helpers.rs similarity index 100% rename from client/rpc/api/src/helpers.rs rename to client/rpc-api/src/helpers.rs diff --git a/client/rpc/api/src/lib.rs b/client/rpc-api/src/lib.rs similarity index 100% rename from client/rpc/api/src/lib.rs rename to client/rpc-api/src/lib.rs diff --git a/client/rpc/api/src/state/error.rs b/client/rpc-api/src/state/error.rs similarity index 100% rename from client/rpc/api/src/state/error.rs rename to client/rpc-api/src/state/error.rs diff --git a/client/rpc/api/src/state/mod.rs b/client/rpc-api/src/state/mod.rs similarity index 100% rename from client/rpc/api/src/state/mod.rs rename to client/rpc-api/src/state/mod.rs diff --git a/client/rpc/api/src/subscriptions.rs b/client/rpc-api/src/subscriptions.rs similarity index 100% rename from client/rpc/api/src/subscriptions.rs rename to client/rpc-api/src/subscriptions.rs diff --git a/client/rpc/api/src/system/error.rs b/client/rpc-api/src/system/error.rs similarity index 100% rename from client/rpc/api/src/system/error.rs rename to client/rpc-api/src/system/error.rs diff --git a/client/rpc/api/src/system/helpers.rs b/client/rpc-api/src/system/helpers.rs similarity index 100% rename from client/rpc/api/src/system/helpers.rs rename to client/rpc-api/src/system/helpers.rs diff --git a/client/rpc/api/src/system/mod.rs b/client/rpc-api/src/system/mod.rs similarity index 100% rename from client/rpc/api/src/system/mod.rs rename to client/rpc-api/src/system/mod.rs diff --git a/client/rpc/Cargo.toml b/client/rpc/Cargo.toml index ab93d48d2c..61ad753c84 100644 --- a/client/rpc/Cargo.toml +++ b/client/rpc/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -api = { package = "sc-rpc-api", path = "./api" } +api = { package = "sc-rpc-api", path = "../rpc-api" } client-api = { package = "sc-client-api", path = "../api" } client = { package = "sc-client", path = "../" } sp-api = { path = "../../primitives/api" } @@ -34,6 +34,6 @@ futures01 = { package = "futures", version = "0.1.29" } network = { package = "sc-network", path = "../network" } rustc-hex = "2.0.1" sp-io = { path = "../../primitives/io" } -test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client" } +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/client/service/Cargo.toml b/client/service/Cargo.toml index 0424aa28e7..fe01818d20 100644 --- a/client/service/Cargo.toml +++ b/client/service/Cargo.toml @@ -51,12 +51,12 @@ rpc = { package = "sc-rpc", path = "../rpc" } tel = { package = "sc-telemetry", path = "../telemetry" } offchain = { package = "sc-offchain", path = "../offchain" } parity-multiaddr = { package = "parity-multiaddr", version = "0.5.0" } -grafana-data-source = { path = "../grafana-data-source" } +grafana-data-source = { path = "../../utils/grafana-data-source" } sc-tracing = { package = "sc-tracing", path = "../tracing" } tracing = "0.1.10" [dev-dependencies] -substrate-test-runtime-client = { path = "../../test/utils/runtime/client" } +substrate-test-runtime-client = { path = "../../test-utils/runtime/client" } babe-primitives = { package = "sp-consensus-babe", path = "../../primitives/consensus/babe" } grandpa = { package = "sc-finality-grandpa", path = "../finality-grandpa" } grandpa-primitives = { package = "sp-finality-grandpa", path = "../../primitives/finality-grandpa" } diff --git a/client/tracing/Cargo.toml b/client/tracing/Cargo.toml index b94059edcd..6c9c04ead5 100644 --- a/client/tracing/Cargo.toml +++ b/client/tracing/Cargo.toml @@ -15,7 +15,7 @@ slog = { version = "2.5.2", features = ["nested-values"] } tracing-core = "0.1.7" sc-telemetry = { path = "../telemetry" } -grafana-data-source = { path = "../grafana-data-source" } +grafana-data-source = { path = "../../utils/grafana-data-source" } [dev-dependencies] tracing = "0.1.10" diff --git a/client/transaction-pool/Cargo.toml b/client/transaction-pool/Cargo.toml index 67cfe78373..f1ab17927d 100644 --- a/client/transaction-pool/Cargo.toml +++ b/client/transaction-pool/Cargo.toml @@ -20,4 +20,4 @@ sp-blockchain = { path = "../../primitives/blockchain" } [dev-dependencies] keyring = { package = "sp-keyring", path = "../../primitives/keyring" } -test-client = { package = "substrate-test-runtime-client", path = "../../test/utils/runtime/client" } +test-client = { package = "substrate-test-runtime-client", path = "../../test-utils/runtime/client" } diff --git a/client/transaction-pool/graph/Cargo.toml b/client/transaction-pool/graph/Cargo.toml index a9f5e2e6b1..cda2fb93e8 100644 --- a/client/transaction-pool/graph/Cargo.toml +++ b/client/transaction-pool/graph/Cargo.toml @@ -17,7 +17,7 @@ txpool-api = { package = "sp-transaction-pool", path = "../../../primitives/tran [dev-dependencies] assert_matches = "1.3.0" codec = { package = "parity-scale-codec", version = "1.0.0" } -test_runtime = { package = "substrate-test-runtime", path = "../../../test/utils/runtime" } +test_runtime = { package = "substrate-test-runtime", path = "../../../test-utils/runtime" } criterion = "0.3" [[bench]] diff --git a/frame/babe/Cargo.toml b/frame/babe/Cargo.toml index 4cc325c0e1..ebfc436f7a 100644 --- a/frame/babe/Cargo.toml +++ b/frame/babe/Cargo.toml @@ -25,7 +25,7 @@ lazy_static = "1.4.0" parking_lot = "0.9.0" sp-version = { path = "../../primitives/version", default-features = false } primitives = { package = "sp-core", path = "../../primitives/core" } -test-runtime = { package = "substrate-test-runtime", path = "../../test/utils/runtime" } +test-runtime = { package = "substrate-test-runtime", path = "../../test-utils/runtime" } [features] default = ["std"] diff --git a/frame/elections-phragmen/Cargo.toml b/frame/elections-phragmen/Cargo.toml index 7415107cd2..0778ef25fd 100644 --- a/frame/elections-phragmen/Cargo.toml +++ b/frame/elections-phragmen/Cargo.toml @@ -17,7 +17,7 @@ sp-io = { path = "../../primitives/io" } hex-literal = "0.2.1" balances = { package = "pallet-balances", path = "../balances" } primitives = { package = "sp-core", path = "../../primitives/core" } -substrate-test-utils = { path = "../../test/utils" } +substrate-test-utils = { path = "../../test-utils" } serde = { version = "1.0.101" } [features] diff --git a/frame/staking/Cargo.toml b/frame/staking/Cargo.toml index b125327f18..c82a0c13e2 100644 --- a/frame/staking/Cargo.toml +++ b/frame/staking/Cargo.toml @@ -24,7 +24,7 @@ primitives = { package = "sp-core", path = "../../primitives/core" } balances = { package = "pallet-balances", path = "../balances" } timestamp = { package = "pallet-timestamp", path = "../timestamp" } pallet-staking-reward-curve = { path = "../staking/reward-curve"} -substrate-test-utils = { path = "../../test/utils" } +substrate-test-utils = { path = "../../test-utils" } [features] equalize = [] diff --git a/primitives/api/test/Cargo.toml b/primitives/api/test/Cargo.toml index 9e0718a0d5..497790f2d6 100644 --- a/primitives/api/test/Cargo.toml +++ b/primitives/api/test/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" [dependencies] sp-api = { path = "../" } -test-client = { package = "substrate-test-runtime-client", path = "../../../test/utils/runtime/client" } +test-client = { package = "substrate-test-runtime-client", path = "../../../test-utils/runtime/client" } sp-version = { path = "../../version" } sp-runtime = { path = "../../runtime" } sp-blockchain = { path = "../../blockchain" } @@ -18,7 +18,7 @@ rustversion = "1.0.0" [dev-dependencies] criterion = "0.3.0" -test-client = { package = "substrate-test-runtime-client", path = "../../../test/utils/runtime/client" } +test-client = { package = "substrate-test-runtime-client", path = "../../../test-utils/runtime/client" } [[bench]] name = "bench" diff --git a/primitives/application-crypto/test/Cargo.toml b/primitives/application-crypto/test/Cargo.toml index e5eed8f5b3..2a599e9638 100644 --- a/primitives/application-crypto/test/Cargo.toml +++ b/primitives/application-crypto/test/Cargo.toml @@ -8,5 +8,5 @@ publish = false [dependencies] primitives = { package = "sp-core", path = "../../core", default-features = false } -test-client = { package = "substrate-test-runtime-client", path = "../../../test/utils/runtime/client" } +test-client = { package = "substrate-test-runtime-client", path = "../../../test-utils/runtime/client" } sp-runtime = { path = "../../runtime" } \ No newline at end of file diff --git a/primitives/phragmen/Cargo.toml b/primitives/phragmen/Cargo.toml index 8c546b7349..7637c25f2d 100644 --- a/primitives/phragmen/Cargo.toml +++ b/primitives/phragmen/Cargo.toml @@ -10,7 +10,7 @@ sp-std = { path = "../std", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } [dev-dependencies] -substrate-test-utils = { path = "../../test/utils" } +substrate-test-utils = { path = "../../test-utils" } sp-io ={ path = "../../primitives/io" } rand = "0.7.2" diff --git a/primitives/runtime-interface/test-wasm/Cargo.toml b/primitives/runtime-interface/test-wasm/Cargo.toml index 553693f248..9c3ac0a7f0 100644 --- a/primitives/runtime-interface/test-wasm/Cargo.toml +++ b/primitives/runtime-interface/test-wasm/Cargo.toml @@ -12,7 +12,7 @@ sp-io = { path = "../../io", default-features = false } primitives = { package = "sp-core", path = "../../core", default-features = false } [build-dependencies] -wasm-builder-runner = { package = "substrate-wasm-builder-runner", version = "1.0.3", path = "../../../client/utils/wasm-builder-runner" } +wasm-builder-runner = { package = "substrate-wasm-builder-runner", version = "1.0.3", path = "../../../utils/wasm-builder-runner" } [features] default = [ "std" ] diff --git a/test/utils/Cargo.toml b/test-utils/Cargo.toml similarity index 100% rename from test/utils/Cargo.toml rename to test-utils/Cargo.toml diff --git a/test-utils/client/Cargo.toml b/test-utils/client/Cargo.toml new file mode 100644 index 0000000000..d89a75d137 --- /dev/null +++ b/test-utils/client/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "substrate-test-client" +version = "2.0.0" +authors = ["Parity Technologies "] +edition = "2018" + +[dependencies] +client-api = { package = "sc-client-api", path = "../../client/api" } +client = { package = "sc-client", path = "../../client/" } +client-db = { package = "sc-client-db", path = "../../client//db", features = ["test-helpers"] } +consensus = { package = "sp-consensus", path = "../../primitives/consensus/common" } +executor = { package = "sc-executor", path = "../../client/executor" } +futures = "0.3.1" +hash-db = "0.15.2" +keyring = { package = "sp-keyring", path = "../../primitives/keyring" } +codec = { package = "parity-scale-codec", version = "1.0.0" } +primitives = { package = "sp-core", path = "../../primitives/core" } +sp-runtime = { path = "../../primitives/runtime" } +sp-blockchain = { path = "../../primitives/blockchain" } +state_machine = { package = "sp-state-machine", path = "../../primitives/state-machine" } diff --git a/test/utils/client/src/client_ext.rs b/test-utils/client/src/client_ext.rs similarity index 100% rename from test/utils/client/src/client_ext.rs rename to test-utils/client/src/client_ext.rs diff --git a/test/utils/client/src/lib.rs b/test-utils/client/src/lib.rs similarity index 100% rename from test/utils/client/src/lib.rs rename to test-utils/client/src/lib.rs diff --git a/test-utils/runtime/Cargo.toml b/test-utils/runtime/Cargo.toml new file mode 100644 index 0000000000..c669cd4141 --- /dev/null +++ b/test-utils/runtime/Cargo.toml @@ -0,0 +1,83 @@ +[package] +name = "substrate-test-runtime" +version = "2.0.0" +authors = ["Parity Technologies "] +edition = "2018" +build = "build.rs" + +[dependencies] +app-crypto = { package = "sp-application-crypto", path = "../../primitives/application-crypto", default-features = false } +aura-primitives = { package = "sp-consensus-aura", path = "../../primitives/consensus/aura", default-features = false } +babe-primitives = { package = "sp-consensus-babe", path = "../../primitives/consensus/babe", default-features = false } +block-builder-api = { package = "sp-block-builder", path = "../../primitives/block-builder", default-features = false } +cfg-if = "0.1.10" +codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } +executive = { package = "frame-executive", path = "../../frame/executive", default-features = false } +inherents = { package = "sp-inherents", path = "../../primitives/inherents", default-features = false } +keyring = { package = "sp-keyring", path = "../../primitives/keyring", optional = true } +log = { version = "0.4.8", optional = true } +memory-db = { version = "0.15.2", default-features = false } +offchain-primitives = { package = "sp-offchain", path = "../../primitives/offchain", default-features = false} +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} +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/version", default-features = false } +serde = { version = "1.0.101", optional = true, features = ["derive"] } +session = { package = "sp-session", path = "../../primitives/session", default-features = false } +sp-api = { path = "../../primitives/api", default-features = false } +sp-runtime = { path = "../../primitives/runtime", default-features = false } +pallet-babe = { path = "../../frame/babe", default-features = false } +frame-system = { path = "../../frame/system", default-features = false } +frame-system-rpc-runtime-api = { path = "../../frame/system/rpc/runtime-api", default-features = false } +pallet-timestamp = { path = "../../frame/timestamp", default-features = false } +sc-client = { path = "../../client", optional = true } +sp-trie = { path = "../../primitives/trie", default-features = false } +sp-transaction-pool = { package = "sp-transaction-pool", path = "../../primitives/transaction-pool", default-features = false } +trie-db = { version = "0.16.0", default-features = false } + +[dev-dependencies] +sc-executor = { path = "../../client/executor" } +substrate-test-runtime-client = { path = "./client" } +state_machine = { package = "sp-state-machine", path = "../../primitives/state-machine" } + +[build-dependencies] +wasm-builder-runner = { package = "substrate-wasm-builder-runner", path = "../../utils/wasm-builder-runner", version = "1.0.4" } + +[features] +default = [ + "std", +] +std = [ + "app-crypto/std", + "aura-primitives/std", + "babe-primitives/std", + "block-builder-api/std", + "codec/std", + "executive/std", + "inherents/std", + "keyring", + "log", + "memory-db/std", + "offchain-primitives/std", + "primitives/std", + "primitives/std", + "sp-std/std", + "runtime-interface/std", + "sp-io/std", + "runtime_support/std", + "runtime_version/std", + "serde", + "session/std", + "sp-api/std", + "sp-runtime/std", + "pallet-babe/std", + "frame-system-rpc-runtime-api/std", + "frame-system/std", + "pallet-timestamp/std", + "sc-client", + "sp-trie/std", + "sp-transaction-pool/std", + "trie-db/std", +] diff --git a/test/utils/runtime/build.rs b/test-utils/runtime/build.rs similarity index 97% rename from test/utils/runtime/build.rs rename to test-utils/runtime/build.rs index cd2c502e78..3197a406f2 100644 --- a/test/utils/runtime/build.rs +++ b/test-utils/runtime/build.rs @@ -20,7 +20,7 @@ fn main() { build_current_project_with_rustflags( "wasm_binary.rs", WasmBuilderSource::CratesOrPath { - path: "../../../utils/wasm-builder", + path: "../../utils/wasm-builder", version: "1.0.8", }, // Note that we set the stack-size to 1MB explicitly even though it is set diff --git a/test/utils/runtime/client/Cargo.toml b/test-utils/runtime/client/Cargo.toml similarity index 55% rename from test/utils/runtime/client/Cargo.toml rename to test-utils/runtime/client/Cargo.toml index 34b9a73fdc..85b9928234 100644 --- a/test/utils/runtime/client/Cargo.toml +++ b/test-utils/runtime/client/Cargo.toml @@ -5,13 +5,13 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -block-builder = { package = "sc-block-builder", path = "../../../../client/block-builder" } +block-builder = { package = "sc-block-builder", path = "../../../client/block-builder" } generic-test-client = { package = "substrate-test-client", path = "../../client" } -primitives = { package = "sp-core", path = "../../../../primitives/core" } +primitives = { package = "sp-core", path = "../../../primitives/core" } runtime = { package = "substrate-test-runtime", path = "../../runtime" } -sp-runtime = { path = "../../../../primitives/runtime" } -sp-blockchain = { path = "../../../../primitives/blockchain" } +sp-runtime = { path = "../../../primitives/runtime" } +sp-blockchain = { path = "../../../primitives/blockchain" } codec = { package = "parity-scale-codec", version = "1.0.0" } -client-api = { package = "sc-client-api", path = "../../../../client/api" } -client = { package = "sc-client", path = "../../../../client/" } +client-api = { package = "sc-client-api", path = "../../../client/api" } +client = { package = "sc-client", path = "../../../client/" } futures = "0.3.1" diff --git a/test/utils/runtime/client/src/block_builder_ext.rs b/test-utils/runtime/client/src/block_builder_ext.rs similarity index 100% rename from test/utils/runtime/client/src/block_builder_ext.rs rename to test-utils/runtime/client/src/block_builder_ext.rs diff --git a/test/utils/runtime/client/src/lib.rs b/test-utils/runtime/client/src/lib.rs similarity index 100% rename from test/utils/runtime/client/src/lib.rs rename to test-utils/runtime/client/src/lib.rs diff --git a/test/utils/runtime/client/src/trait_tests.rs b/test-utils/runtime/client/src/trait_tests.rs similarity index 100% rename from test/utils/runtime/client/src/trait_tests.rs rename to test-utils/runtime/client/src/trait_tests.rs diff --git a/test/utils/runtime/src/genesismap.rs b/test-utils/runtime/src/genesismap.rs similarity index 100% rename from test/utils/runtime/src/genesismap.rs rename to test-utils/runtime/src/genesismap.rs diff --git a/test/utils/runtime/src/lib.rs b/test-utils/runtime/src/lib.rs similarity index 100% rename from test/utils/runtime/src/lib.rs rename to test-utils/runtime/src/lib.rs diff --git a/test/utils/runtime/src/system.rs b/test-utils/runtime/src/system.rs similarity index 100% rename from test/utils/runtime/src/system.rs rename to test-utils/runtime/src/system.rs diff --git a/test/utils/src/lib.rs b/test-utils/src/lib.rs similarity index 100% rename from test/utils/src/lib.rs rename to test-utils/src/lib.rs diff --git a/test/utils/client/Cargo.toml b/test/utils/client/Cargo.toml deleted file mode 100644 index e3375099e3..0000000000 --- a/test/utils/client/Cargo.toml +++ /dev/null @@ -1,20 +0,0 @@ -[package] -name = "substrate-test-client" -version = "2.0.0" -authors = ["Parity Technologies "] -edition = "2018" - -[dependencies] -client-api = { package = "sc-client-api", path = "../../../client/api" } -client = { package = "sc-client", path = "../../../client/" } -client-db = { package = "sc-client-db", path = "../../../client//db", features = ["test-helpers"] } -consensus = { package = "sp-consensus", path = "../../../primitives/consensus/common" } -executor = { package = "sc-executor", path = "../../../client/executor" } -futures = "0.3.1" -hash-db = "0.15.2" -keyring = { package = "sp-keyring", path = "../../../primitives/keyring" } -codec = { package = "parity-scale-codec", version = "1.0.0" } -primitives = { package = "sp-core", path = "../../../primitives/core" } -sp-runtime = { path = "../../../primitives/runtime" } -sp-blockchain = { path = "../../../primitives/blockchain" } -state_machine = { package = "sp-state-machine", path = "../../../primitives/state-machine" } diff --git a/test/utils/runtime/Cargo.toml b/test/utils/runtime/Cargo.toml deleted file mode 100644 index afde5a3d14..0000000000 --- a/test/utils/runtime/Cargo.toml +++ /dev/null @@ -1,83 +0,0 @@ -[package] -name = "substrate-test-runtime" -version = "2.0.0" -authors = ["Parity Technologies "] -edition = "2018" -build = "build.rs" - -[dependencies] -app-crypto = { package = "sp-application-crypto", path = "../../../primitives/application-crypto", default-features = false } -aura-primitives = { package = "sp-consensus-aura", path = "../../../primitives/consensus/aura", default-features = false } -babe-primitives = { package = "sp-consensus-babe", path = "../../../primitives/consensus/babe", default-features = false } -block-builder-api = { package = "sp-block-builder", path = "../../../primitives/block-builder", default-features = false } -cfg-if = "0.1.10" -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -executive = { package = "frame-executive", path = "../../../frame/executive", default-features = false } -inherents = { package = "sp-inherents", path = "../../../primitives/inherents", default-features = false } -keyring = { package = "sp-keyring", path = "../../../primitives/keyring", optional = true } -log = { version = "0.4.8", optional = true } -memory-db = { version = "0.15.2", default-features = false } -offchain-primitives = { package = "sp-offchain", path = "../../../primitives/offchain", default-features = false} -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} -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/version", default-features = false } -serde = { version = "1.0.101", optional = true, features = ["derive"] } -session = { package = "sp-session", path = "../../../primitives/session", default-features = false } -sp-api = { path = "../../../primitives/api", default-features = false } -sp-runtime = { path = "../../../primitives/runtime", default-features = false } -pallet-babe = { path = "../../../frame/babe", default-features = false } -frame-system = { path = "../../../frame/system", default-features = false } -frame-system-rpc-runtime-api = { path = "../../../frame/system/rpc/runtime-api", default-features = false } -pallet-timestamp = { path = "../../../frame/timestamp", default-features = false } -sc-client = { path = "../../../client", optional = true } -sp-trie = { path = "../../../primitives/trie", default-features = false } -sp-transaction-pool = { package = "sp-transaction-pool", path = "../../../primitives/transaction-pool", default-features = false } -trie-db = { version = "0.16.0", default-features = false } - -[dev-dependencies] -sc-executor = { path = "../../../client/executor" } -substrate-test-runtime-client = { path = "./client" } -state_machine = { package = "sp-state-machine", path = "../../../primitives/state-machine" } - -[build-dependencies] -wasm-builder-runner = { package = "substrate-wasm-builder-runner", path = "../../../client/utils/wasm-builder-runner", version = "1.0.4" } - -[features] -default = [ - "std", -] -std = [ - "app-crypto/std", - "aura-primitives/std", - "babe-primitives/std", - "block-builder-api/std", - "codec/std", - "executive/std", - "inherents/std", - "keyring", - "log", - "memory-db/std", - "offchain-primitives/std", - "primitives/std", - "primitives/std", - "sp-std/std", - "runtime-interface/std", - "sp-io/std", - "runtime_support/std", - "runtime_version/std", - "serde", - "session/std", - "sp-api/std", - "sp-runtime/std", - "pallet-babe/std", - "frame-system-rpc-runtime-api/std", - "frame-system/std", - "pallet-timestamp/std", - "sc-client", - "sp-trie/std", - "sp-transaction-pool/std", - "trie-db/std", -] diff --git a/test/utils/transaction-factory/Cargo.toml b/test/utils/transaction-factory/Cargo.toml deleted file mode 100644 index 76293b6e07..0000000000 --- a/test/utils/transaction-factory/Cargo.toml +++ /dev/null @@ -1,19 +0,0 @@ -[package] -name = "sc-transaction-factory" -version = "0.0.1" -authors = ["Parity Technologies "] -edition = "2018" - -[dependencies] -block-builder-api = { package = "sp-block-builder", path = "../../primitives/block-builder" } -cli = { package = "sc-cli", path = "../cli" } -client-api = { package = "sc-client-api", path = "../api" } -client = { package = "sc-client", path = "../" } -codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } -consensus_common = { package = "sp-consensus", path = "../../primitives/consensus/common" } -log = "0.4.8" -primitives = { package = "sp-core", path = "../../primitives/core" } -sp-api = { path = "../../primitives/api" } -sp-runtime = { path = "../../primitives/runtime" } -sc-service = { path = "../service" } -sp-blockchain = { path = "../../primitives/blockchain" } diff --git a/utils/frame/rpc/support/Cargo.toml b/utils/frame/rpc/support/Cargo.toml index 1833322cd6..cc5a860470 100644 --- a/utils/frame/rpc/support/Cargo.toml +++ b/utils/frame/rpc/support/Cargo.toml @@ -12,7 +12,7 @@ parity-scale-codec = "1" serde = "1" frame-support = { path = "../../../../frame/support" } sp-storage = { path = "../../../../primitives/storage" } -sc-rpc-api = { path = "../../../../client/rpc/api" } +sc-rpc-api = { path = "../../../../client/rpc-api" } [dev-dependencies] frame-system = { path = "../../../../frame/system" } diff --git a/utils/frame/rpc/system/Cargo.toml b/utils/frame/rpc/system/Cargo.toml index 0697d15e63..a501891749 100644 --- a/utils/frame/rpc/system/Cargo.toml +++ b/utils/frame/rpc/system/Cargo.toml @@ -20,6 +20,6 @@ sp-blockchain = { path = "../../../../primitives/blockchain" } txpool-api = { package = "sp-transaction-pool", path = "../../../../primitives/transaction-pool" } [dev-dependencies] -test-client = { package = "substrate-test-runtime-client", path = "../../../../test/utils/runtime/client" } +test-client = { package = "substrate-test-runtime-client", path = "../../../../test-utils/runtime/client" } env_logger = "0.7.0" txpool = { package = "sc-transaction-pool", path = "../../../../client/transaction-pool" } diff --git a/client/grafana-data-source/Cargo.toml b/utils/grafana-data-source/Cargo.toml similarity index 100% rename from client/grafana-data-source/Cargo.toml rename to utils/grafana-data-source/Cargo.toml diff --git a/client/grafana-data-source/src/database.rs b/utils/grafana-data-source/src/database.rs similarity index 100% rename from client/grafana-data-source/src/database.rs rename to utils/grafana-data-source/src/database.rs diff --git a/client/grafana-data-source/src/lib.rs b/utils/grafana-data-source/src/lib.rs similarity index 100% rename from client/grafana-data-source/src/lib.rs rename to utils/grafana-data-source/src/lib.rs diff --git a/client/grafana-data-source/src/networking.rs b/utils/grafana-data-source/src/networking.rs similarity index 100% rename from client/grafana-data-source/src/networking.rs rename to utils/grafana-data-source/src/networking.rs diff --git a/client/grafana-data-source/src/server.rs b/utils/grafana-data-source/src/server.rs similarity index 100% rename from client/grafana-data-source/src/server.rs rename to utils/grafana-data-source/src/server.rs diff --git a/client/grafana-data-source/src/types.rs b/utils/grafana-data-source/src/types.rs similarity index 100% rename from client/grafana-data-source/src/types.rs rename to utils/grafana-data-source/src/types.rs diff --git a/client/grafana-data-source/test/Cargo.toml b/utils/grafana-data-source/test/Cargo.toml similarity index 100% rename from client/grafana-data-source/test/Cargo.toml rename to utils/grafana-data-source/test/Cargo.toml diff --git a/client/grafana-data-source/test/src/main.rs b/utils/grafana-data-source/test/src/main.rs similarity index 100% rename from client/grafana-data-source/test/src/main.rs rename to utils/grafana-data-source/test/src/main.rs diff --git a/client/utils/wasm-builder-runner/Cargo.toml b/utils/wasm-builder-runner/Cargo.toml similarity index 100% rename from client/utils/wasm-builder-runner/Cargo.toml rename to utils/wasm-builder-runner/Cargo.toml diff --git a/client/utils/wasm-builder-runner/README.md b/utils/wasm-builder-runner/README.md similarity index 100% rename from client/utils/wasm-builder-runner/README.md rename to utils/wasm-builder-runner/README.md diff --git a/client/utils/wasm-builder-runner/src/lib.rs b/utils/wasm-builder-runner/src/lib.rs similarity index 100% rename from client/utils/wasm-builder-runner/src/lib.rs rename to utils/wasm-builder-runner/src/lib.rs -- GitLab From 3d17cbd2fbcc337af49c861896ab4936b161bcee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Wed, 11 Dec 2019 20:48:55 +0100 Subject: [PATCH 130/172] `decl_error!` document that the error needs to be registered (#4366) --- frame/support/src/error.rs | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/frame/support/src/error.rs b/frame/support/src/error.rs index 937be730f9..d256f0d58b 100644 --- a/frame/support/src/error.rs +++ b/frame/support/src/error.rs @@ -28,10 +28,12 @@ pub use frame_metadata::{ModuleErrorMetadata, ErrorMetadata, DecodeDifferent}; /// error type implements `From<&'static str>` and `From` to make them usable with the /// try operator. /// +/// `decl_error!` supports only variants that do not hold any data. +/// /// # Usage /// /// ``` -/// # use frame_support::decl_error; +/// # use frame_support::{decl_error, decl_module}; /// decl_error! { /// /// Errors that can occur in my module. /// pub enum MyError { @@ -41,9 +43,23 @@ pub use frame_metadata::{ModuleErrorMetadata, ErrorMetadata, DecodeDifferent}; /// YouAreNotCoolEnough, /// } /// } -/// ``` /// -/// `decl_error!` supports only variants that do not hold any data. +/// # use frame_system::{self as system, Trait, ensure_signed}; +/// +/// // You need to register the error type in `decl_module!` as well. +/// +/// decl_module! { +/// pub struct Module for enum Call where origin: T::Origin { +/// type Error = MyError; +/// +/// fn do_something(origin) -> Result<(), MyError> { +/// Err(MyError::YouAreNotCoolEnough) +/// } +/// } +/// } +/// +/// # fn main() {} +/// ``` #[macro_export] macro_rules! decl_error { ( -- GitLab From d79e31ead96a225f2fc958a24f494e0259c6f40a Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Thu, 12 Dec 2019 19:24:36 +0900 Subject: [PATCH 131/172] Revamp reaping rules (#4371) * Allow owner of a preimage to reap it a little while before everyone else. * Revamp DispatchQueue to make reaping safer * Remove commented code * Update frame/democracy/src/lib.rs Co-Authored-By: Shawn Tabrizi * Update docs --- frame/democracy/src/lib.rs | 175 +++++++++++++++++++++++++------------ 1 file changed, 120 insertions(+), 55 deletions(-) diff --git a/frame/democracy/src/lib.rs b/frame/democracy/src/lib.rs index de0ef3a5d7..4b4c070cda 100644 --- a/frame/democracy/src/lib.rs +++ b/frame/democracy/src/lib.rs @@ -282,9 +282,8 @@ decl_storage! { /// Information concerning any given referendum. pub ReferendumInfoOf get(fn referendum_info): map ReferendumIndex => Option<(ReferendumInfo)>; - /// Queue of successful referenda to be dispatched. - pub DispatchQueue get(fn dispatch_queue): - map hasher(twox_64_concat) T::BlockNumber => Vec>; + /// Queue of successful referenda to be dispatched. Stored ordered by block number. + pub DispatchQueue get(fn dispatch_queue): Vec<(T::BlockNumber, T::Hash, ReferendumIndex)>; /// Get the voters for the current proposal. pub VotersFor get(fn voters_for): map ReferendumIndex => Vec; @@ -579,21 +578,13 @@ decl_module! { /// Cancel a proposal queued for enactment. #[weight = SimpleDispatchInfo::FixedOperational(10_000)] - fn cancel_queued( - origin, - #[compact] when: T::BlockNumber, - #[compact] which: u32, - #[compact] what: ReferendumIndex - ) { + fn cancel_queued(origin, which: ReferendumIndex) { ensure_root(origin)?; - let which = which as usize; - let mut items = >::get(when); - if items.get(which).and_then(Option::as_ref).map_or(false, |x| x.1 == what) { - items[which] = None; - >::insert(when, items); - } else { - Err("proposal not found")? - } + let mut items = >::get(); + let original_len = items.len(); + items.retain(|i| i.2 != which); + ensure!(items.len() < original_len, "proposal not found"); + >::put(items); } fn on_initialize(n: T::BlockNumber) { @@ -709,39 +700,41 @@ decl_module! { /// Register the preimage for an upcoming proposal. This requires the proposal to be /// in the dispatch queue. No deposit is needed. #[weight = SimpleDispatchInfo::FixedNormal(100_000)] - fn note_imminent_preimage(origin, - encoded_proposal: Vec, - when: T::BlockNumber, - which: u32 - ) { + fn note_imminent_preimage(origin, encoded_proposal: Vec) { let who = ensure_signed(origin)?; let proposal_hash = T::Hashing::hash(&encoded_proposal[..]); ensure!(!>::exists(&proposal_hash), "preimage already noted"); - let queue = >::get(when); - let item = queue.get(which as usize).and_then(|x| x.as_ref()) - .ok_or("dispatch queue entry not found")?; - ensure!(item.0 == proposal_hash, "dispatch queue entry invalid"); + let queue = >::get(); + ensure!(queue.iter().any(|item| &item.1 == &proposal_hash), "not imminent"); let now = >::block_number(); - >::insert(proposal_hash, (encoded_proposal, who.clone(), >::zero(), now)); + let free = >::zero(); + >::insert(proposal_hash, (encoded_proposal, who.clone(), free, now)); - Self::deposit_event(RawEvent::PreimageNoted(proposal_hash, who, Zero::zero())); + Self::deposit_event(RawEvent::PreimageNoted(proposal_hash, who, free)); } /// Remove an expired proposal preimage and collect the deposit. + /// + /// This will only work after `VotingPeriod` blocks from the time that the preimage was + /// noted, if it's the same account doing it. If it's a different account, then it'll only + /// work an additional `EnactmentPeriod` later. #[weight = SimpleDispatchInfo::FixedNormal(10_000)] fn reap_preimage(origin, proposal_hash: T::Hash) { let who = ensure_signed(origin)?; - if let Some((_, old, deposit, then)) = >::get(&proposal_hash) { - let now = >::block_number(); - if now >= then + T::EnactmentPeriod::get() + T::VotingPeriod::get() { - // allowed to claim the deposit. - let _ = T::Currency::repatriate_reserved(&old, &who, deposit); - >::remove(&proposal_hash); - Self::deposit_event(RawEvent::PreimageReaped(proposal_hash, old, deposit, who)); - } - } + let (_, old, deposit, then) = >::get(&proposal_hash).ok_or("not found")?; + let now = >::block_number(); + let (voting, enactment) = (T::VotingPeriod::get(), T::EnactmentPeriod::get()); + let additional = if who == old { Zero::zero() } else { enactment }; + ensure!(now >= then + voting + additional, "too early"); + + let queue = >::get(); + ensure!(!queue.iter().any(|item| &item.1 == &proposal_hash), "imminent"); + + let _ = T::Currency::repatriate_reserved(&old, &who, deposit); + >::remove(&proposal_hash); + Self::deposit_event(RawEvent::PreimageReaped(proposal_hash, old, deposit, who)); } } } @@ -1022,7 +1015,7 @@ impl Module { .map(|a| (a.clone(), Self::vote_of((index, a)))) // ^^^ defensive only: all items come from `voters`; for an item to be in `voters` // there must be a vote registered; qed - .filter(|&(_, vote)| vote.aye == approved) // Just the winning coins + .filter(|&(_, vote)| vote.aye == approved) // Just the winning coins { // now plus: the base lock period multiplied by the number of periods this voter // offered to lock should they win... @@ -1044,10 +1037,11 @@ impl Module { if info.delay.is_zero() { let _ = Self::enact_proposal(info.proposal_hash, index); } else { - >::append_or_insert( - now + info.delay, - &[Some((info.proposal_hash, index))][..] - ); + let item = (now + info.delay,info.proposal_hash, index); + >::mutate(|queue| { + let pos = queue.binary_search_by_key(&item.0, |x| x.0).unwrap_or_else(|e| e); + queue.insert(pos, item); + }); } } else { Self::deposit_event(RawEvent::NotPassed(index)); @@ -1070,8 +1064,15 @@ impl Module { Self::bake_referendum(now, index, info)?; } - for (proposal_hash, index) in >::take(now).into_iter().filter_map(|x| x) { - let _ = Self::enact_proposal(proposal_hash, index); + let queue = >::get(); + let mut used = 0; + // It's stored in order, so the earliest will always be at the start. + for &(_, proposal_hash, index) in queue.iter().take_while(|x| x.0 == now) { + let _ = Self::enact_proposal(proposal_hash.clone(), index); + used += 1; + } + if used != 0 { + >::put(&queue[used..]); } Ok(()) } @@ -1319,6 +1320,57 @@ mod tests { }); } + #[test] + fn preimage_deposit_should_be_reapable_earlier_by_owner() { + new_test_ext().execute_with(|| { + System::set_block_number(1); + PREIMAGE_BYTE_DEPOSIT.with(|v| *v.borrow_mut() = 1); + assert_ok!(Democracy::note_preimage(Origin::signed(6), set_balance_proposal(2))); + + assert_eq!(Balances::reserved_balance(6), 12); + + next_block(); + assert_noop!( + Democracy::reap_preimage(Origin::signed(6), set_balance_proposal_hash(2)), + "too early" + ); + next_block(); + assert_ok!(Democracy::reap_preimage(Origin::signed(6), set_balance_proposal_hash(2))); + + assert_eq!(Balances::reserved_balance(6), 0); + assert_eq!(Balances::free_balance(6), 60); + }); + } + + #[test] + fn preimage_deposit_should_be_reapable() { + new_test_ext().execute_with(|| { + System::set_block_number(1); + assert_noop!( + Democracy::reap_preimage(Origin::signed(5), set_balance_proposal_hash(2)), + "not found" + ); + + PREIMAGE_BYTE_DEPOSIT.with(|v| *v.borrow_mut() = 1); + assert_ok!(Democracy::note_preimage(Origin::signed(6), set_balance_proposal(2))); + assert_eq!(Balances::reserved_balance(6), 12); + + next_block(); + next_block(); + next_block(); + assert_noop!( + Democracy::reap_preimage(Origin::signed(5), set_balance_proposal_hash(2)), + "too early" + ); + + next_block(); + assert_ok!(Democracy::reap_preimage(Origin::signed(5), set_balance_proposal_hash(2))); + assert_eq!(Balances::reserved_balance(6), 0); + assert_eq!(Balances::free_balance(6), 48); + assert_eq!(Balances::free_balance(5), 62); + }); + } + #[test] fn noting_imminent_preimage_for_free_should_work() { new_test_ext().execute_with(|| { @@ -1334,14 +1386,14 @@ mod tests { assert_ok!(Democracy::vote(Origin::signed(1), r, AYE)); assert_noop!( - Democracy::note_imminent_preimage(Origin::signed(7), set_balance_proposal(2), 3, 0), - "dispatch queue entry not found" + Democracy::note_imminent_preimage(Origin::signed(7), set_balance_proposal(2)), + "not imminent" ); next_block(); // Now we're in the dispatch queue it's all good. - assert_ok!(Democracy::note_imminent_preimage(Origin::signed(7), set_balance_proposal(2), 3, 0)); + assert_ok!(Democracy::note_imminent_preimage(Origin::signed(7), set_balance_proposal(2))); next_block(); @@ -1349,6 +1401,20 @@ mod tests { }); } + #[test] + fn reaping_imminent_preimage_should_fail() { + new_test_ext().execute_with(|| { + System::set_block_number(1); + let h = set_balance_proposal_hash_and_note(2); + let r = Democracy::inject_referendum(3, h, VoteThreshold::SuperMajorityApprove, 1); + assert_ok!(Democracy::vote(Origin::signed(1), r, AYE)); + next_block(); + next_block(); + // now imminent. + assert_noop!(Democracy::reap_preimage(Origin::signed(6), h), "imminent"); + }); + } + #[test] fn external_and_public_interleaving_works() { new_test_ext().execute_with(|| { @@ -1719,8 +1785,8 @@ mod tests { fast_forward_to(4); assert!(Democracy::referendum_info(0).is_none()); - assert_eq!(Democracy::dispatch_queue(6), vec![ - Some((set_balance_proposal_hash_and_note(2), 0)) + assert_eq!(Democracy::dispatch_queue(), vec![ + (6, set_balance_proposal_hash_and_note(2), 0) ]); // referendum passes and wait another two blocks for enactment. @@ -1743,14 +1809,13 @@ mod tests { fast_forward_to(4); - assert_eq!(Democracy::dispatch_queue(6), vec![ - Some((set_balance_proposal_hash_and_note(2), 0)) + assert_eq!(Democracy::dispatch_queue(), vec![ + (6, set_balance_proposal_hash_and_note(2), 0) ]); - assert_noop!(Democracy::cancel_queued(Origin::ROOT, 5, 0, 0), "proposal not found"); - assert_noop!(Democracy::cancel_queued(Origin::ROOT, 6, 1, 0), "proposal not found"); - assert_ok!(Democracy::cancel_queued(Origin::ROOT, 6, 0, 0)); - assert_eq!(Democracy::dispatch_queue(6), vec![None]); + assert_noop!(Democracy::cancel_queued(Origin::ROOT, 1), "proposal not found"); + assert_ok!(Democracy::cancel_queued(Origin::ROOT, 0)); + assert_eq!(Democracy::dispatch_queue(), vec![]); }); } -- GitLab From c6fc2e6240edeb31233b07748c6bf968c7c15553 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Thu, 12 Dec 2019 11:24:50 +0100 Subject: [PATCH 132/172] Update rustdocs landing page (#4375) --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 496de058d1..7d1debb2fc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -329,7 +329,7 @@ build-rust-doc-release: - rm -f ./crate-docs/index.html # use it as an indicator if the job succeeds - BUILD_DUMMY_WASM_BINARY=1 RUSTDOCFLAGS="--html-in-header $(pwd)/.maintain/rustdoc-header.html" time cargo +nightly doc --release --all --verbose - cp -R ./target/doc ./crate-docs - - echo "" > ./crate-docs/index.html + - echo "" > ./crate-docs/index.html - sccache -s check_warnings: -- GitLab From 6e9be553703d0ad568ce161031e4c85219033e86 Mon Sep 17 00:00:00 2001 From: Weiliang Li Date: Sat, 14 Dec 2019 00:54:20 +0900 Subject: [PATCH 133/172] update comments in authority discovery (#4390) * update comments in authority discovery * Update lib.rs --- frame/authority-discovery/src/lib.rs | 2 +- primitives/authority-discovery/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frame/authority-discovery/src/lib.rs b/frame/authority-discovery/src/lib.rs index 467b494907..c63b5d5811 100644 --- a/frame/authority-discovery/src/lib.rs +++ b/frame/authority-discovery/src/lib.rs @@ -16,7 +16,7 @@ //! # Authority discovery module. //! -//! This module is used by the `core/authority-discovery` to retrieve the +//! This module is used by the `client/authority-discovery` to retrieve the //! current set of authorities. // Ensure we're `no_std` when compiling for Wasm. diff --git a/primitives/authority-discovery/src/lib.rs b/primitives/authority-discovery/src/lib.rs index 811bcc261b..b208727148 100644 --- a/primitives/authority-discovery/src/lib.rs +++ b/primitives/authority-discovery/src/lib.rs @@ -38,7 +38,7 @@ pub type AuthoritySignature = app::Signature; sp_api::decl_runtime_apis! { /// The authority discovery api. /// - /// This api is used by the `core/authority-discovery` module to retrieve identifiers + /// This api is used by the `client/authority-discovery` module to retrieve identifiers /// of the current authority set. pub trait AuthorityDiscoveryApi { /// Retrieve authority identifiers of the current authority set. -- GitLab From 723148f1d19f98d3cbd88dda8c15abaa6ad70a7a Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Fri, 13 Dec 2019 19:16:10 +0100 Subject: [PATCH 134/172] Extract consensus_gossip.rs and put it in its own crate (#4284) * Extract gossiping system from network * Finish porting GRANDPA tests * Try put correct engine ID * Fix messages encoding * Fix communication tests * Use a threads pool to spawn stuff * Fix compilation everywhere * Fix bad merge conflict * Remove dependency on async-std * Apply suggestions from code review Co-Authored-By: Robert Habermeier * More suggestions * Remove network startup GP future * Update to futures_timer * adjust wait_when_behind test * Pass correct Roles after handshake * Revert "adjust wait_when_behind test" This reverts commit 9e31024412c059335bd3c3b35ed4691cda4655db. * Crate root documentation * Remove MessageRecipient * Address concerns * Fix more concerns * Forgot Cargo.lock --- Cargo.lock | 34 +- Cargo.toml | 1 + bin/node-template/src/service.rs | 2 + bin/node/cli/src/service.rs | 2 + client/finality-grandpa/Cargo.toml | 4 +- .../src/communication/gossip.rs | 13 +- .../finality-grandpa/src/communication/mod.rs | 295 ++++------------- .../src/communication/periodic.rs | 13 +- .../src/communication/tests.rs | 146 ++++----- client/finality-grandpa/src/environment.rs | 38 +-- client/finality-grandpa/src/lib.rs | 62 ++-- client/finality-grandpa/src/observer.rs | 26 +- client/finality-grandpa/src/tests.rs | 70 +++- client/finality-grandpa/src/until_imported.rs | 22 +- client/network-gossip/Cargo.toml | 18 ++ client/network-gossip/src/bridge.rs | 301 ++++++++++++++++++ client/network-gossip/src/lib.rs | 140 ++++++++ .../src/state_machine.rs} | 53 +-- client/network/src/behaviour.rs | 48 ++- client/network/src/lib.rs | 2 +- client/network/src/protocol.rs | 182 +++++++---- client/network/src/protocol/event.rs | 35 ++ client/network/src/service.rs | 151 +++++---- client/service/src/lib.rs | 47 ++- 24 files changed, 1084 insertions(+), 621 deletions(-) create mode 100644 client/network-gossip/Cargo.toml create mode 100644 client/network-gossip/src/bridge.rs create mode 100644 client/network-gossip/src/lib.rs rename client/{network/src/protocol/consensus_gossip.rs => network-gossip/src/state_machine.rs} (91%) diff --git a/Cargo.lock b/Cargo.lock index cc63cf57f0..c921244587 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1780,6 +1780,11 @@ dependencies = [ "scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "hashbrown" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "hashbrown" version = "0.6.3" @@ -2775,6 +2780,14 @@ dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "lru" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "hashbrown 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "lru" version = "0.4.3" @@ -5302,6 +5315,7 @@ dependencies = [ "fork-tree 2.0.0", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-timer 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5310,6 +5324,7 @@ dependencies = [ "sc-client-api 2.0.0", "sc-keystore 2.0.0", "sc-network 2.0.0", + "sc-network-gossip 2.0.0", "sc-network-test 2.0.0", "sc-telemetry 2.0.0", "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5327,8 +5342,6 @@ dependencies = [ "substrate-test-runtime-client 2.0.0", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-timer 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -5398,6 +5411,21 @@ dependencies = [ "zeroize 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "sc-network-gossip" +version = "2.0.0" +dependencies = [ + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-timer 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libp2p 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "lru 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sc-network 2.0.0", + "sp-runtime 2.0.0", +] + [[package]] name = "sc-network-test" version = "2.0.0" @@ -8233,6 +8261,7 @@ dependencies = [ "checksum hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d23bd4e7b5eda0d0f3a307e8b381fdc8ba9000f26fbe912250c0a4cc3956364a" "checksum hash256-std-hasher 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)" = "92c171d55b98633f4ed3860808f004099b36c1cc29c42cfc53aa8591b21efcf2" "checksum hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3bae29b6653b3412c2e71e9d486db9f9df5d701941d86683005efb9f2d28e3da" +"checksum hashbrown 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e1de41fb8dba9714efd92241565cdff73f78508c95697dd56787d3cba27e2353" "checksum hashbrown 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8e6073d0ca812575946eb5f35ff68dbe519907b25c42530389ff946dc84c6ead" "checksum heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1679e6ea370dee694f91f1dc469bf94cf8f52051d147aec3e1f9497c6fc22461" "checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" @@ -8317,6 +8346,7 @@ dependencies = [ "checksum lock_api 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e57b3997725d2b60dbec1297f6c2e2957cc383db1cebd6be812163f969c7d586" "checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" "checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" +"checksum lru 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "5d8f669d42c72d18514dfca8115689c5f6370a17d980cb5bd777a67f404594c8" "checksum lru 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0609345ddee5badacf857d4f547e0e5a2e987db77085c24cd887f73573a04237" "checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1" "checksum malloc_size_of_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e37c5d4cd9473c5f4c9c111f033f15d4df9bd378fdf615944e360a4f55a05f0b" diff --git a/Cargo.toml b/Cargo.toml index 84f4128515..4aabe5916f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,6 +33,7 @@ members = [ "client/keystore", "client/network", "client/network/test", + "client/network-gossip", "client/offchain", "client/peerset", "client/rpc-servers", diff --git a/bin/node-template/src/service.rs b/bin/node-template/src/service.rs index 600ae2c5b2..9161e26732 100644 --- a/bin/node-template/src/service.rs +++ b/bin/node-template/src/service.rs @@ -158,6 +158,7 @@ pub fn new_full(config: Configuration { @@ -170,6 +171,7 @@ pub fn new_full(config: Configuration { @@ -243,6 +244,7 @@ macro_rules! new_full { on_exit: service.on_exit(), telemetry_on_connect: Some(service.telemetry_on_connect_stream()), voting_rule: grandpa::VotingRulesBuilder::default().build(), + executor: service.spawn_task_handle(), }; // the GRANDPA voter task is considered infallible, i.e. // if it fails we take down the service with it. diff --git a/client/finality-grandpa/Cargo.toml b/client/finality-grandpa/Cargo.toml index fb6cb0827a..3b1d57d213 100644 --- a/client/finality-grandpa/Cargo.toml +++ b/client/finality-grandpa/Cargo.toml @@ -8,10 +8,9 @@ edition = "2018" fork-tree = { path = "../../utils/fork-tree" } futures = "0.1.29" futures03 = { package = "futures", version = "0.3.1", features = ["compat"] } +futures-timer = "2.0.2" log = "0.4.8" parking_lot = "0.9.0" -tokio-executor = "0.1.8" -tokio-timer = "0.2.11" rand = "0.7.2" codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } sp-runtime = { path = "../../primitives/runtime" } @@ -25,6 +24,7 @@ client = { package = "sc-client", path = "../" } inherents = { package = "sp-inherents", path = "../../primitives/inherents" } sp-blockchain = { path = "../../primitives/blockchain" } network = { package = "sc-network", path = "../network" } +network-gossip = { package = "sc-network-gossip", path = "../network-gossip" } sp-finality-tracker = { path = "../../primitives/finality-tracker" } fg_primitives = { package = "sp-finality-grandpa", path = "../../primitives/finality-grandpa" } grandpa = { package = "finality-grandpa", version = "0.10.1", features = ["derive-codec"] } diff --git a/client/finality-grandpa/src/communication/gossip.rs b/client/finality-grandpa/src/communication/gossip.rs index 298d68d58f..6ed70b66ae 100644 --- a/client/finality-grandpa/src/communication/gossip.rs +++ b/client/finality-grandpa/src/communication/gossip.rs @@ -83,7 +83,7 @@ //! We only send polite messages to peers, use sp_runtime::traits::{NumberFor, Block as BlockT, Zero}; -use network::consensus_gossip::{self as network_gossip, MessageIntent, ValidatorContext}; +use network_gossip::{GossipEngine, MessageIntent, ValidatorContext}; use network::{config::Roles, PeerId, ReputationChange}; use codec::{Encode, Decode}; use fg_primitives::AuthorityId; @@ -1459,29 +1459,26 @@ pub(super) struct ReportStream { impl ReportStream { /// Consume the report stream, converting it into a future that /// handles all reports. - pub(super) fn consume(self, net: N) + pub(super) fn consume(self, net: GossipEngine) -> impl Future + Send + 'static where B: BlockT, - N: super::Network + Send + 'static, { ReportingTask { reports: self.reports, net, - _marker: Default::default(), } } } /// A future for reporting peers. #[must_use = "Futures do nothing unless polled"] -struct ReportingTask { +struct ReportingTask { reports: mpsc::UnboundedReceiver, - net: N, - _marker: std::marker::PhantomData, + net: GossipEngine, } -impl> Future for ReportingTask { +impl Future for ReportingTask { type Item = (); type Error = (); diff --git a/client/finality-grandpa/src/communication/mod.rs b/client/finality-grandpa/src/communication/mod.rs index d4a6363d1b..e535f85776 100644 --- a/client/finality-grandpa/src/communication/mod.rs +++ b/client/finality-grandpa/src/communication/mod.rs @@ -29,19 +29,17 @@ use std::sync::Arc; -use futures::prelude::*; -use futures::sync::{oneshot, mpsc}; -use futures03::stream::{StreamExt, TryStreamExt}; +use futures::{prelude::*, future::Executor as _, sync::mpsc}; +use futures03::{compat::Compat, stream::StreamExt, future::FutureExt as _, future::TryFutureExt as _}; use grandpa::Message::{Prevote, Precommit, PrimaryPropose}; use grandpa::{voter, voter_set::VoterSet}; use log::{debug, trace}; -use network::{consensus_gossip as network_gossip, NetworkService, ReputationChange}; -use network_gossip::ConsensusMessage; +use network::ReputationChange; +use network_gossip::{GossipEngine, Network}; use codec::{Encode, Decode}; use primitives::Pair; use sp_runtime::traits::{Block as BlockT, Hash as HashT, Header as HeaderT, NumberFor}; use sc_telemetry::{telemetry, CONSENSUS_DEBUG, CONSENSUS_INFO}; -use tokio_executor::Executor; use crate::{ CatchUp, Commit, CommunicationIn, CommunicationOut, CompactCommit, Error, @@ -97,50 +95,6 @@ mod benefit { pub(super) const PER_EQUIVOCATION: i32 = 10; } -/// A handle to the network. This is generally implemented by providing some -/// handle to a gossip service or similar. -/// -/// Intended to be a lightweight handle such as an `Arc`. -pub trait Network: Clone + Send + 'static { - /// A stream of input messages for a topic. - type In: Stream; - - /// Get a stream of messages for a specific gossip topic. - fn messages_for(&self, topic: Block::Hash) -> Self::In; - - /// Register a gossip validator. - fn register_validator(&self, validator: Arc>); - - /// Gossip a message out to all connected peers. - /// - /// Force causes it to be sent to all peers, even if they've seen it already. - /// Only should be used in case of consensus stall. - fn gossip_message(&self, topic: Block::Hash, data: Vec, force: bool); - - /// Register a message with the gossip service, it isn't broadcast right - /// away to any peers, but may be sent to new peers joining or when asked to - /// broadcast the topic. Useful to register previous messages on node - /// startup. - fn register_gossip_message(&self, topic: Block::Hash, data: Vec); - - /// Send a message to a bunch of specific peers, even if they've seen it already. - fn send_message(&self, who: Vec, data: Vec); - - /// Report a peer's cost or benefit after some action. - fn report(&self, who: network::PeerId, cost_benefit: ReputationChange); - - /// Inform peers that a block with given hash should be downloaded. - fn announce(&self, block: Block::Hash, associated_data: Vec); - - /// Notifies the sync service to try and sync the given block from the given - /// peers. - /// - /// If the given vector of peers is empty then the underlying implementation - /// should make a best effort to fetch the block from any peers it is - /// connected to (NOTE: this assumption will change in the future #3629). - fn set_sync_fork_request(&self, peers: Vec, hash: Block::Hash, number: NumberFor); -} - /// Create a unique topic for a round and set-id combo. pub(crate) fn round_topic(round: RoundNumber, set_id: SetIdNumber) -> B::Hash { <::Hashing as HashT>::hash(format!("{}-{}", set_id, round).as_bytes()) @@ -151,157 +105,32 @@ pub(crate) fn global_topic(set_id: SetIdNumber) -> B::Hash { <::Hashing as HashT>::hash(format!("{}-GLOBAL", set_id).as_bytes()) } -impl Network for Arc> where - B: BlockT, - S: network::specialization::NetworkSpecialization, - H: network::ExHashT, -{ - type In = NetworkStream< - Box + Send + 'static>, - >; - - fn messages_for(&self, topic: B::Hash) -> Self::In { - // Given that one can only communicate with the Substrate network via the `NetworkService` via message-passing, - // and given that methods on the network consensus gossip are not exposed but only reachable by passing a - // closure into `with_gossip` on the `NetworkService` this function needs to make use of the `NetworkStream` - // construction. - // - // We create a oneshot channel and pass the sender within a closure to the network. At some point in the future - // the network passes the message channel back through the oneshot channel. But the consumer of this function - // expects a stream, not a stream within a oneshot. This complexity is abstracted within `NetworkStream`, - // waiting for the oneshot to resolve and from there on acting like a normal message channel. - let (tx, rx) = oneshot::channel(); - self.with_gossip(move |gossip, _| { - let inner_rx: Box + Send> = Box::new(gossip - .messages_for(GRANDPA_ENGINE_ID, topic) - .map(|x| Ok(x)) - .compat() - ); - let _ = tx.send(inner_rx); - }); - NetworkStream::PollingOneshot(rx) - } - - fn register_validator(&self, validator: Arc>) { - self.with_gossip( - move |gossip, context| gossip.register_validator(context, GRANDPA_ENGINE_ID, validator) - ) - } - - fn gossip_message(&self, topic: B::Hash, data: Vec, force: bool) { - let msg = ConsensusMessage { - engine_id: GRANDPA_ENGINE_ID, - data, - }; - - self.with_gossip( - move |gossip, ctx| gossip.multicast(ctx, topic, msg, force) - ) - } - - fn register_gossip_message(&self, topic: B::Hash, data: Vec) { - let msg = ConsensusMessage { - engine_id: GRANDPA_ENGINE_ID, - data, - }; - - self.with_gossip(move |gossip, _| gossip.register_message(topic, msg)) - } - - fn send_message(&self, who: Vec, data: Vec) { - let msg = ConsensusMessage { - engine_id: GRANDPA_ENGINE_ID, - data, - }; - - self.with_gossip(move |gossip, ctx| for who in &who { - gossip.send_message(ctx, who, msg.clone()) - }) - } - - fn report(&self, who: network::PeerId, cost_benefit: ReputationChange) { - self.report_peer(who, cost_benefit) - } - - fn announce(&self, block: B::Hash, associated_data: Vec) { - self.announce_block(block, associated_data) - } - - fn set_sync_fork_request(&self, peers: Vec, hash: B::Hash, number: NumberFor) { - NetworkService::set_sync_fork_request(self, peers, hash, number) - } -} - -/// A stream used by NetworkBridge in its implementation of Network. Given a oneshot that eventually returns a channel -/// which eventually returns messages, instead of: -/// -/// 1. polling the oneshot until it returns a message channel -/// -/// 2. polling the message channel for messages -/// -/// `NetworkStream` combines the two steps into one, requiring a consumer to only poll `NetworkStream` to retrieve -/// messages directly. -pub enum NetworkStream { - PollingOneshot(oneshot::Receiver), - PollingTopicNotifications(R), -} - -impl Stream for NetworkStream -where - R: Stream, -{ - type Item = R::Item; - type Error = (); - - fn poll(&mut self) -> Poll, Self::Error> { - match self { - NetworkStream::PollingOneshot(oneshot) => { - match oneshot.poll() { - Ok(futures::Async::Ready(mut stream)) => { - let poll_result = stream.poll(); - *self = NetworkStream::PollingTopicNotifications(stream); - poll_result - }, - Ok(futures::Async::NotReady) => Ok(futures::Async::NotReady), - Err(_) => Err(()) - } - }, - NetworkStream::PollingTopicNotifications(stream) => { - stream.poll() - }, - } - } -} - /// Bridge between the underlying network service, gossiping consensus messages and Grandpa -pub(crate) struct NetworkBridge> { - service: N, +pub(crate) struct NetworkBridge { + gossip_engine: GossipEngine, validator: Arc>, neighbor_sender: periodic::NeighborPacketSender, } -impl> NetworkBridge { +impl NetworkBridge { /// Create a new NetworkBridge to the given NetworkService. Returns the service - /// handle and a future that must be polled to completion to finish startup. + /// handle. /// On creation it will register previous rounds' votes with the gossip /// service taken from the VoterSetState. - pub(crate) fn new( + pub(crate) fn new + Clone + Send + 'static>( service: N, config: crate::Config, set_state: crate::environment::SharedVoterSetState, + executor: &impl futures03::task::Spawn, on_exit: impl futures03::Future + Clone + Send + Unpin + 'static, - ) -> ( - Self, - impl Future + Send + 'static, - ) { - + ) -> Self { let (validator, report_stream) = GossipValidator::new( config, set_state.clone(), ); let validator = Arc::new(validator); - service.register_validator(validator.clone()); + let gossip_engine = GossipEngine::new(service, executor, GRANDPA_ENGINE_ID, validator.clone()); { // register all previous votes with the gossip service so that they're @@ -325,7 +154,7 @@ impl> NetworkBridge { } ); - service.register_gossip_message( + gossip_engine.register_gossip_message( topic, message.encode(), ); @@ -341,34 +170,18 @@ impl> NetworkBridge { } } - let (rebroadcast_job, neighbor_sender) = periodic::neighbor_packet_worker(service.clone()); - let reporting_job = report_stream.consume(service.clone()); - - let bridge = NetworkBridge { service, validator, neighbor_sender }; - - let startup_work = futures::future::lazy(move || { - // lazily spawn these jobs onto their own tasks. the lazy future has access - // to tokio globals, which aren't available outside. - let mut executor = tokio_executor::DefaultExecutor::current(); + let (rebroadcast_job, neighbor_sender) = periodic::neighbor_packet_worker(gossip_engine.clone()); + let reporting_job = report_stream.consume(gossip_engine.clone()); - use futures03::{FutureExt, TryFutureExt}; + let bridge = NetworkBridge { gossip_engine, validator, neighbor_sender }; - let rebroadcast_job = rebroadcast_job - .select(on_exit.clone().map(Ok).compat()) - .then(|_| Ok(())); - - let reporting_job = reporting_job - .select(on_exit.clone().map(Ok).compat()) - .then(|_| Ok(())); - - executor.spawn(Box::new(rebroadcast_job)) - .expect("failed to spawn grandpa rebroadcast job task"); - executor.spawn(Box::new(reporting_job)) - .expect("failed to spawn grandpa reporting job task"); - Ok(()) - }); + let executor = Compat::new(executor); + executor.execute(Box::new(rebroadcast_job.select(on_exit.clone().map(Ok).compat()).then(|_| Ok(())))) + .expect("failed to spawn grandpa rebroadcast job task"); + executor.execute(Box::new(reporting_job.select(on_exit.clone().map(Ok).compat()).then(|_| Ok(())))) + .expect("failed to spawn grandpa reporting job task"); - (bridge, startup_work) + bridge } /// Note the beginning of a new round to the `GossipValidator`. @@ -420,7 +233,8 @@ impl> NetworkBridge { }); let topic = round_topic::(round.0, set_id.0); - let incoming = self.service.messages_for(topic) + let incoming = Compat::new(self.gossip_engine.messages_for(topic) + .map(|item| Ok::<_, ()>(item))) .filter_map(|notification| { let decoded = GossipMessage::::decode(&mut ¬ification.message[..]); if let Err(ref e) = decoded { @@ -473,10 +287,10 @@ impl> NetworkBridge { .map_err(|()| Error::Network(format!("Failed to receive message on unbounded stream"))); let (tx, out_rx) = mpsc::unbounded(); - let outgoing = OutgoingMessages:: { + let outgoing = OutgoingMessages:: { round: round.0, set_id: set_id.0, - network: self.service.clone(), + network: self.gossip_engine.clone(), locals, sender: tx, has_voted, @@ -510,7 +324,7 @@ impl> NetworkBridge { |to, neighbor| self.neighbor_sender.send(to, neighbor), ); - let service = self.service.clone(); + let service = self.gossip_engine.clone(); let topic = global_topic::(set_id.0); let incoming = incoming_global( service, @@ -520,8 +334,8 @@ impl> NetworkBridge { self.neighbor_sender.clone(), ); - let outgoing = CommitsOut::::new( - self.service.clone(), + let outgoing = CommitsOut::::new( + self.gossip_engine.clone(), set_id.0, is_voter, self.validator.clone(), @@ -543,12 +357,12 @@ impl> NetworkBridge { /// should make a best effort to fetch the block from any peers it is /// connected to (NOTE: this assumption will change in the future #3629). pub(crate) fn set_sync_fork_request(&self, peers: Vec, hash: B::Hash, number: NumberFor) { - self.service.set_sync_fork_request(peers, hash, number) + self.gossip_engine.set_sync_fork_request(peers, hash, number) } } -fn incoming_global>( - mut service: N, +fn incoming_global( + mut gossip_engine: GossipEngine, topic: B::Hash, voters: Arc>, gossip_validator: Arc>, @@ -557,7 +371,7 @@ fn incoming_global>( let process_commit = move | msg: FullCommitMessage, mut notification: network_gossip::TopicNotification, - service: &mut N, + gossip_engine: &mut GossipEngine, gossip_validator: &Arc>, voters: &VoterSet, | { @@ -579,7 +393,7 @@ fn incoming_global>( msg.set_id, ) { if let Some(who) = notification.sender { - service.report(who, cost); + gossip_engine.report(who, cost); } return None; @@ -589,7 +403,7 @@ fn incoming_global>( let commit = msg.message; let finalized_number = commit.target_number; let gossip_validator = gossip_validator.clone(); - let service = service.clone(); + let gossip_engine = gossip_engine.clone(); let neighbor_sender = neighbor_sender.clone(); let cb = move |outcome| match outcome { voter::CommitProcessingOutcome::Good(_) => { @@ -601,12 +415,12 @@ fn incoming_global>( |to, neighbor| neighbor_sender.send(to, neighbor), ); - service.gossip_message(topic, notification.message.clone(), false); + gossip_engine.gossip_message(topic, notification.message.clone(), false); } voter::CommitProcessingOutcome::Bad(_) => { // report peer and do not gossip. if let Some(who) = notification.sender.take() { - service.report(who, cost::INVALID_COMMIT); + gossip_engine.report(who, cost::INVALID_COMMIT); } } }; @@ -619,12 +433,12 @@ fn incoming_global>( let process_catch_up = move | msg: FullCatchUpMessage, mut notification: network_gossip::TopicNotification, - service: &mut N, + gossip_engine: &mut GossipEngine, gossip_validator: &Arc>, voters: &VoterSet, | { let gossip_validator = gossip_validator.clone(); - let service = service.clone(); + let gossip_engine = gossip_engine.clone(); if let Err(cost) = check_catch_up::( &msg.message, @@ -632,7 +446,7 @@ fn incoming_global>( msg.set_id, ) { if let Some(who) = notification.sender { - service.report(who, cost); + gossip_engine.report(who, cost); } return None; @@ -642,7 +456,7 @@ fn incoming_global>( if let voter::CatchUpProcessingOutcome::Bad(_) = outcome { // report peer if let Some(who) = notification.sender.take() { - service.report(who, cost::INVALID_CATCH_UP); + gossip_engine.report(who, cost::INVALID_CATCH_UP); } } @@ -654,7 +468,8 @@ fn incoming_global>( Some(voter::CommunicationIn::CatchUp(msg.message, cb)) }; - service.messages_for(topic) + Compat::new(gossip_engine.messages_for(topic) + .map(|m| Ok::<_, ()>(m))) .filter_map(|notification| { // this could be optimized by decoding piecewise. let decoded = GossipMessage::::decode(&mut ¬ification.message[..]); @@ -666,9 +481,9 @@ fn incoming_global>( .filter_map(move |(notification, msg)| { match msg { GossipMessage::Commit(msg) => - process_commit(msg, notification, &mut service, &gossip_validator, &*voters), + process_commit(msg, notification, &mut gossip_engine, &gossip_validator, &*voters), GossipMessage::CatchUp(msg) => - process_catch_up(msg, notification, &mut service, &gossip_validator, &*voters), + process_catch_up(msg, notification, &mut gossip_engine, &gossip_validator, &*voters), _ => { debug!(target: "afg", "Skipping unknown message type"); return None; @@ -678,10 +493,10 @@ fn incoming_global>( .map_err(|()| Error::Network(format!("Failed to receive message on unbounded stream"))) } -impl> Clone for NetworkBridge { +impl Clone for NetworkBridge { fn clone(&self) -> Self { NetworkBridge { - service: self.service.clone(), + gossip_engine: self.gossip_engine.clone(), validator: Arc::clone(&self.validator), neighbor_sender: self.neighbor_sender.clone(), } @@ -725,16 +540,16 @@ pub(crate) fn check_message_sig( /// use the same raw message and key to sign. This is currently true for /// `ed25519` and `BLS` signatures (which we might use in the future), care must /// be taken when switching to different key types. -struct OutgoingMessages> { +struct OutgoingMessages { round: RoundNumber, set_id: SetIdNumber, locals: Option<(AuthorityPair, AuthorityId)>, sender: mpsc::UnboundedSender>, - network: N, + network: GossipEngine, has_voted: HasVoted, } -impl> Sink for OutgoingMessages +impl Sink for OutgoingMessages { type SinkItem = Message; type SinkError = Error; @@ -978,18 +793,18 @@ fn check_catch_up( } /// An output sink for commit messages. -struct CommitsOut> { - network: N, +struct CommitsOut { + network: GossipEngine, set_id: SetId, is_voter: bool, gossip_validator: Arc>, neighbor_sender: periodic::NeighborPacketSender, } -impl> CommitsOut { +impl CommitsOut { /// Create a new commit output stream. pub(crate) fn new( - network: N, + network: GossipEngine, set_id: SetIdNumber, is_voter: bool, gossip_validator: Arc>, @@ -1005,7 +820,7 @@ impl> CommitsOut { } } -impl> Sink for CommitsOut { +impl Sink for CommitsOut { type SinkItem = (RoundNumber, Commit); type SinkError = Error; diff --git a/client/finality-grandpa/src/communication/periodic.rs b/client/finality-grandpa/src/communication/periodic.rs index 7db5fb692e..3f9cc0dd8e 100644 --- a/client/finality-grandpa/src/communication/periodic.rs +++ b/client/finality-grandpa/src/communication/periodic.rs @@ -21,12 +21,14 @@ use std::time::{Instant, Duration}; use codec::Encode; use futures::prelude::*; use futures::sync::mpsc; +use futures_timer::Delay; +use futures03::future::{FutureExt as _, TryFutureExt as _}; use log::{debug, warn}; -use tokio_timer::Delay; use network::PeerId; +use network_gossip::GossipEngine; use sp_runtime::traits::{NumberFor, Block as BlockT}; -use super::{gossip::{NeighborPacket, GossipMessage}, Network}; +use super::gossip::{NeighborPacket, GossipMessage}; // how often to rebroadcast, if no other const REBROADCAST_AFTER: Duration = Duration::from_secs(2 * 60); @@ -58,16 +60,15 @@ impl NeighborPacketSender { /// /// It may rebroadcast the last neighbor packet periodically when no /// progress is made. -pub(super) fn neighbor_packet_worker(net: N) -> ( +pub(super) fn neighbor_packet_worker(net: GossipEngine) -> ( impl Future + Send + 'static, NeighborPacketSender, ) where B: BlockT, - N: Network, { let mut last = None; let (tx, mut rx) = mpsc::unbounded::<(Vec, NeighborPacket>)>(); - let mut delay = Delay::new(rebroadcast_instant()); + let mut delay = Delay::new(REBROADCAST_AFTER); let work = futures::future::poll_fn(move || { loop { @@ -88,7 +89,7 @@ pub(super) fn neighbor_packet_worker(net: N) -> ( // has to be done in a loop because it needs to be polled after // re-scheduling. loop { - match delay.poll() { + match (&mut delay).unit_error().compat().poll() { Err(e) => { warn!(target: "afg", "Could not rebroadcast neighbor packets: {:?}", e); delay.reset(rebroadcast_instant()); diff --git a/client/finality-grandpa/src/communication/tests.rs b/client/finality-grandpa/src/communication/tests.rs index 86bbdb8f64..6e80291c40 100644 --- a/client/finality-grandpa/src/communication/tests.rs +++ b/client/finality-grandpa/src/communication/tests.rs @@ -18,25 +18,23 @@ use futures::sync::mpsc; use futures::prelude::*; -use network::consensus_gossip as network_gossip; +use network::{Event as NetworkEvent, PeerId, config::Roles}; use sc_network_test::{Block, Hash}; use network_gossip::Validator; use tokio::runtime::current_thread; use std::sync::Arc; use keyring::Ed25519Keyring; use codec::Encode; -use sp_runtime::traits::NumberFor; +use sp_runtime::{ConsensusEngineId, traits::NumberFor}; use std::{pin::Pin, task::{Context, Poll}}; use crate::environment::SharedVoterSetState; -use fg_primitives::AuthorityList; +use fg_primitives::{AuthorityList, GRANDPA_ENGINE_ID}; use super::gossip::{self, GossipValidator}; use super::{AuthorityId, VoterSet, Round, SetId}; enum Event { - MessagesFor(Hash, mpsc::UnboundedSender), - RegisterValidator(Arc>), - GossipMessage(Hash, Vec, bool), - SendMessage(Vec, Vec), + EventStream(mpsc::UnboundedSender), + WriteNotification(network::PeerId, Vec), Report(network::PeerId, network::ReputationChange), Announce(Hash), } @@ -46,56 +44,36 @@ struct TestNetwork { sender: mpsc::UnboundedSender, } -impl super::Network for TestNetwork { - type In = mpsc::UnboundedReceiver; - - /// Get a stream of messages for a specific gossip topic. - fn messages_for(&self, topic: Hash) -> Self::In { +impl network_gossip::Network for TestNetwork { + fn event_stream(&self) + -> Box + Send> { let (tx, rx) = mpsc::unbounded(); - let _ = self.sender.unbounded_send(Event::MessagesFor(topic, tx)); - - rx + let _ = self.sender.unbounded_send(Event::EventStream(tx)); + Box::new(rx) } - /// Register a gossip validator. - fn register_validator(&self, validator: Arc>) { - let _ = self.sender.unbounded_send(Event::RegisterValidator(validator)); + fn report_peer(&self, who: network::PeerId, cost_benefit: network::ReputationChange) { + let _ = self.sender.unbounded_send(Event::Report(who, cost_benefit)); } - /// Gossip a message out to all connected peers. - /// - /// Force causes it to be sent to all peers, even if they've seen it already. - /// Only should be used in case of consensus stall. - fn gossip_message(&self, topic: Hash, data: Vec, force: bool) { - let _ = self.sender.unbounded_send(Event::GossipMessage(topic, data, force)); - } + fn disconnect_peer(&self, _: PeerId) {} - /// Send a message to a bunch of specific peers, even if they've seen it already. - fn send_message(&self, who: Vec, data: Vec) { - let _ = self.sender.unbounded_send(Event::SendMessage(who, data)); + fn write_notification(&self, who: PeerId, _: ConsensusEngineId, message: Vec) { + let _ = self.sender.unbounded_send(Event::WriteNotification(who, message)); } - /// Register a message with the gossip service, it isn't broadcast right - /// away to any peers, but may be sent to new peers joining or when asked to - /// broadcast the topic. Useful to register previous messages on node - /// startup. - fn register_gossip_message(&self, _topic: Hash, _data: Vec) { - // NOTE: only required to restore previous state on startup - // not required for tests currently - } + fn register_notifications_protocol(&self, _: ConsensusEngineId) {} - /// Report a peer's cost or benefit after some action. - fn report(&self, who: network::PeerId, cost_benefit: network::ReputationChange) { - let _ = self.sender.unbounded_send(Event::Report(who, cost_benefit)); - } - - /// Inform peers that a block with given hash should be downloaded. fn announce(&self, block: Hash, _associated_data: Vec) { let _ = self.sender.unbounded_send(Event::Announce(block)); } - /// Notify the sync service to try syncing the given chain. - fn set_sync_fork_request(&self, _peers: Vec, _hash: Hash, _number: NumberFor) {} + fn set_sync_fork_request( + &self, + _peers: Vec, + _hash: Hash, + _number: NumberFor, + ) {} } impl network_gossip::ValidatorContext for TestNetwork { @@ -104,14 +82,19 @@ impl network_gossip::ValidatorContext for TestNetwork { fn broadcast_message(&mut self, _: Hash, _: Vec, _: bool) { } fn send_message(&mut self, who: &network::PeerId, data: Vec) { - >::send_message(self, vec![who.clone()], data); + >::write_notification( + self, + who.clone(), + GRANDPA_ENGINE_ID, + data, + ); } fn send_topic(&mut self, _: &network::PeerId, _: Hash, _: bool) { } } struct Tester { - net_handle: super::NetworkBridge, + net_handle: super::NetworkBridge, gossip_validator: Arc>, events: mpsc::UnboundedReceiver, } @@ -165,7 +148,7 @@ fn voter_set_state() -> SharedVoterSetState { } // needs to run in a tokio runtime. -fn make_test_network() -> ( +fn make_test_network(executor: &impl futures03::task::Spawn) -> ( impl Future, TestNetwork, ) { @@ -183,15 +166,16 @@ fn make_test_network() -> ( } } - let (bridge, startup_work) = super::NetworkBridge::new( + let bridge = super::NetworkBridge::new( net.clone(), config(), voter_set_state(), + executor, Exit, ); ( - startup_work.map(move |()| Tester { + futures::future::ok(Tester { gossip_validator: bridge.validator.clone(), net_handle: bridge, events: rx, @@ -261,7 +245,8 @@ fn good_commit_leads_to_relay() { let id = network::PeerId::random(); let global_topic = super::global_topic::(set_id); - let test = make_test_network().0 + let threads_pool = futures03::executor::ThreadPool::new().unwrap(); + let test = make_test_network(&threads_pool).0 .and_then(move |tester| { // register a peer. tester.gossip_validator.new_peer(&mut NoopContext, &id, network::config::Roles::FULL); @@ -286,11 +271,15 @@ fn good_commit_leads_to_relay() { // send a message. let sender_id = id.clone(); let send_message = tester.filter_network_events(move |event| match event { - Event::MessagesFor(topic, sender) => { - if topic != global_topic { return false } - let _ = sender.unbounded_send(network_gossip::TopicNotification { - message: commit_to_send.clone(), - sender: Some(sender_id.clone()), + Event::EventStream(sender) => { + let _ = sender.unbounded_send(NetworkEvent::NotificationStreamOpened { + remote: sender_id.clone(), + engine_id: GRANDPA_ENGINE_ID, + roles: Roles::FULL, + }); + let _ = sender.unbounded_send(NetworkEvent::NotificationsReceived { + remote: sender_id.clone(), + messages: vec![(GRANDPA_ENGINE_ID, commit_to_send.clone().into())], }); true @@ -314,12 +303,8 @@ fn good_commit_leads_to_relay() { // a repropagation event coming from the network. send_message.join(handle_commit).and_then(move |(tester, ())| { tester.filter_network_events(move |event| match event { - Event::GossipMessage(topic, data, false) => { - if topic == global_topic && data == encoded_commit { - true - } else { - panic!("Trying to gossip something strange") - } + Event::WriteNotification(_, data) => { + data == encoded_commit } _ => false, }) @@ -328,11 +313,12 @@ fn good_commit_leads_to_relay() { .map(|_| ()) }); - current_thread::block_on_all(test).unwrap(); + current_thread::Runtime::new().unwrap().block_on(test).unwrap(); } #[test] fn bad_commit_leads_to_report() { + env_logger::init(); let private = [Ed25519Keyring::Alice, Ed25519Keyring::Bob, Ed25519Keyring::Charlie]; let public = make_ids(&private[..]); let voter_set = Arc::new(public.iter().cloned().collect::>()); @@ -376,7 +362,8 @@ fn bad_commit_leads_to_report() { let id = network::PeerId::random(); let global_topic = super::global_topic::(set_id); - let test = make_test_network().0 + let threads_pool = futures03::executor::ThreadPool::new().unwrap(); + let test = make_test_network(&threads_pool).0 .and_then(move |tester| { // register a peer. tester.gossip_validator.new_peer(&mut NoopContext, &id, network::config::Roles::FULL); @@ -401,11 +388,15 @@ fn bad_commit_leads_to_report() { // send a message. let sender_id = id.clone(); let send_message = tester.filter_network_events(move |event| match event { - Event::MessagesFor(topic, sender) => { - if topic != global_topic { return false } - let _ = sender.unbounded_send(network_gossip::TopicNotification { - message: commit_to_send.clone(), - sender: Some(sender_id.clone()), + Event::EventStream(sender) => { + let _ = sender.unbounded_send(NetworkEvent::NotificationStreamOpened { + remote: sender_id.clone(), + engine_id: GRANDPA_ENGINE_ID, + roles: Roles::FULL, + }); + let _ = sender.unbounded_send(NetworkEvent::NotificationsReceived { + remote: sender_id.clone(), + messages: vec![(GRANDPA_ENGINE_ID, commit_to_send.clone().into())], }); true @@ -430,11 +421,7 @@ fn bad_commit_leads_to_report() { send_message.join(handle_commit).and_then(move |(tester, ())| { tester.filter_network_events(move |event| match event { Event::Report(who, cost_benefit) => { - if who == id && cost_benefit == super::cost::INVALID_COMMIT { - true - } else { - panic!("reported unknown peer or unexpected cost"); - } + who == id && cost_benefit == super::cost::INVALID_COMMIT } _ => false, }) @@ -443,14 +430,15 @@ fn bad_commit_leads_to_report() { .map(|_| ()) }); - current_thread::block_on_all(test).unwrap(); + current_thread::Runtime::new().unwrap().block_on(test).unwrap(); } #[test] fn peer_with_higher_view_leads_to_catch_up_request() { let id = network::PeerId::random(); - let (tester, mut net) = make_test_network(); + let threads_pool = futures03::executor::ThreadPool::new().unwrap(); + let (tester, mut net) = make_test_network(&threads_pool); let test = tester .and_then(move |tester| { // register a peer with authority role. @@ -477,10 +465,10 @@ fn peer_with_higher_view_leads_to_catch_up_request() { // a catch up request should be sent to the peer for round - 1 tester.filter_network_events(move |event| match event { - Event::SendMessage(peers, message) => { + Event::WriteNotification(peer, message) => { assert_eq!( - peers, - vec![id.clone()], + peer, + id, ); assert_eq!( @@ -501,5 +489,5 @@ fn peer_with_higher_view_leads_to_catch_up_request() { .map(|_| ()) }); - current_thread::block_on_all(test).unwrap(); + current_thread::Runtime::new().unwrap().block_on(test).unwrap(); } diff --git a/client/finality-grandpa/src/environment.rs b/client/finality-grandpa/src/environment.rs index 52e1bea3e7..a252668481 100644 --- a/client/finality-grandpa/src/environment.rs +++ b/client/finality-grandpa/src/environment.rs @@ -17,12 +17,13 @@ use std::collections::BTreeMap; use std::iter::FromIterator; use std::sync::Arc; -use std::time::{Duration, Instant}; +use std::time::Duration; use log::{debug, warn, info}; use codec::{Decode, Encode}; use futures::prelude::*; -use tokio_timer::Delay; +use futures03::future::{FutureExt as _, TryFutureExt as _}; +use futures_timer::Delay; use parking_lot::RwLock; use sp_blockchain::{HeaderBackend, Error as ClientError}; @@ -48,7 +49,7 @@ use sp_runtime::traits::{ use sc_telemetry::{telemetry, CONSENSUS_INFO}; use crate::{ - CommandOrError, Commit, Config, Error, Network, Precommit, Prevote, + CommandOrError, Commit, Config, Error, Precommit, Prevote, PrimaryPropose, SignedMessage, NewAuthoritySet, VoterCommand, }; @@ -375,20 +376,20 @@ impl SharedVoterSetState { } /// The environment we run GRANDPA in. -pub(crate) struct Environment, RA, SC, VR> { +pub(crate) struct Environment { pub(crate) client: Arc>, pub(crate) select_chain: SC, pub(crate) voters: Arc>, pub(crate) config: Config, pub(crate) authority_set: SharedAuthoritySet>, pub(crate) consensus_changes: SharedConsensusChanges>, - pub(crate) network: crate::communication::NetworkBridge, + pub(crate) network: crate::communication::NetworkBridge, pub(crate) set_id: SetId, pub(crate) voter_set_state: SharedVoterSetState, pub(crate) voting_rule: VR, } -impl, RA, SC, VR> Environment { +impl Environment { /// Updates the voter set state using the given closure. The write lock is /// held during evaluation of the closure and the environment's voter set /// state is set to its result if successful. @@ -404,15 +405,13 @@ impl, RA, SC, VR> Environment, B, E, N, RA, SC, VR> +impl, B, E, RA, SC, VR> grandpa::Chain> -for Environment +for Environment where Block: 'static, B: Backend + 'static, E: CallExecutor + Send + Sync + 'static, - N: Network + 'static, - N::In: 'static, SC: SelectChain + 'static, VR: VotingRule>, RA: Send + Sync, @@ -555,15 +554,13 @@ pub(crate) fn ancestry, E, RA>( Ok(tree_route.retracted().iter().skip(1).map(|e| e.hash).collect()) } -impl, N, RA, SC, VR> +impl, RA, SC, VR> voter::Environment> -for Environment +for Environment where Block: 'static, B: Backend + 'static, E: CallExecutor + 'static + Send + Sync, - N: Network + 'static + Send, - N::In: 'static + Send, RA: 'static + Send + Sync, SC: SelectChain + 'static, VR: VotingRule>, @@ -589,9 +586,8 @@ where &self, round: RoundNumber, ) -> voter::RoundData { - let now = Instant::now(); - let prevote_timer = Delay::new(now + self.config.gossip_duration * 2); - let precommit_timer = Delay::new(now + self.config.gossip_duration * 4); + let prevote_timer = Delay::new(self.config.gossip_duration * 2); + let precommit_timer = Delay::new(self.config.gossip_duration * 4); let local_key = crate::is_voter(&self.voters, &self.config.keystore); @@ -629,8 +625,8 @@ where voter::RoundData { voter_id: local_key.map(|pair| pair.public()), - prevote_timer: Box::new(prevote_timer.map_err(|e| Error::Timer(e).into())), - precommit_timer: Box::new(precommit_timer.map_err(|e| Error::Timer(e).into())), + prevote_timer: Box::new(prevote_timer.map(Ok).compat()), + precommit_timer: Box::new(precommit_timer.map(Ok).compat()), incoming, outgoing, } @@ -904,9 +900,7 @@ where //random between 0-1 seconds. let delay: u64 = thread_rng().gen_range(0, 1000); - Box::new(Delay::new( - Instant::now() + Duration::from_millis(delay) - ).map_err(|e| Error::Timer(e).into())) + Box::new(Delay::new(Duration::from_millis(delay)).map(Ok).compat()) } fn prevote_equivocation( diff --git a/client/finality-grandpa/src/lib.rs b/client/finality-grandpa/src/lib.rs index 0890b6db0f..82c0400612 100644 --- a/client/finality-grandpa/src/lib.rs +++ b/client/finality-grandpa/src/lib.rs @@ -73,7 +73,7 @@ use sp_finality_tracker; use grandpa::Error as GrandpaError; use grandpa::{voter, BlockNumberOps, voter_set::VoterSet}; -use std::fmt; +use std::{fmt, io}; use std::sync::Arc; use std::time::Duration; @@ -90,7 +90,7 @@ mod observer; mod until_imported; mod voting_rule; -pub use communication::Network; +pub use network_gossip::Network; pub use finality_proof::FinalityProofProvider; pub use justification::GrandpaJustification; pub use light_import::light_block_import; @@ -230,7 +230,7 @@ pub enum Error { /// An invariant has been violated (e.g. not finalizing pending change blocks in-order) Safety(String), /// A timer failed to fire. - Timer(tokio_timer::Error), + Timer(io::Error), } impl From for Error { @@ -276,9 +276,8 @@ pub(crate) trait BlockSyncRequester { fn set_sync_fork_request(&self, peers: Vec, hash: Block::Hash, number: NumberFor); } -impl BlockSyncRequester for NetworkBridge where +impl BlockSyncRequester for NetworkBridge where Block: BlockT, - N: communication::Network, { fn set_sync_fork_request(&self, peers: Vec, hash: Block::Hash, number: NumberFor) { NetworkBridge::set_sync_fork_request(self, peers, hash, number) @@ -447,11 +446,11 @@ where )) } -fn global_communication, B, E, N, RA>( +fn global_communication, B, E, RA>( set_id: SetId, voters: &Arc>, client: &Arc>, - network: &NetworkBridge, + network: &NetworkBridge, keystore: &Option, ) -> ( impl Stream< @@ -465,7 +464,6 @@ fn global_communication, B, E, N, RA>( ) where B: Backend, E: CallExecutor + Send + Sync, - N: Network, RA: Send + Sync, NumberFor: BlockNumberOps, { @@ -523,7 +521,7 @@ fn register_finality_tracker_inherent_data_provider, N, RA, SC, VR, X> { +pub struct GrandpaParams, N, RA, SC, VR, X, Sp> { /// Configuration for the GRANDPA service. pub config: Config, /// A link to the block import worker. @@ -538,24 +536,26 @@ pub struct GrandpaParams, N, RA, SC, VR, X> { pub telemetry_on_connect: Option>, /// A voting rule used to potentially restrict target votes. pub voting_rule: VR, + /// How to spawn background tasks. + pub executor: Sp, } /// Run a GRANDPA voter as a task. Provide configuration and a link to a /// block import worker that has already been instantiated with `block_import`. -pub fn run_grandpa_voter, N, RA, SC, VR, X>( - grandpa_params: GrandpaParams, +pub fn run_grandpa_voter, N, RA, SC, VR, X, Sp>( + grandpa_params: GrandpaParams, ) -> sp_blockchain::Result + Send + 'static> where Block::Hash: Ord, B: Backend + 'static, E: CallExecutor + Send + Sync + 'static, - N: Network + Send + Sync + 'static, - N::In: Send + 'static, + N: Network + Send + Clone + 'static, SC: SelectChain + 'static, VR: VotingRule> + Clone + 'static, NumberFor: BlockNumberOps, DigestFor: Encode, RA: Send + Sync + 'static, X: futures03::Future + Clone + Send + Unpin + 'static, + Sp: futures03::task::Spawn + 'static, { let GrandpaParams { config, @@ -565,6 +565,7 @@ pub fn run_grandpa_voter, N, RA, SC, VR, X>( on_exit, telemetry_on_connect, voting_rule, + executor, } = grandpa_params; let LinkHalf { @@ -574,10 +575,11 @@ pub fn run_grandpa_voter, N, RA, SC, VR, X>( voter_commands_rx, } = link; - let (network, network_startup) = NetworkBridge::new( + let network = NetworkBridge::new( network, config.clone(), persistent_data.set_state.clone(), + &executor, on_exit.clone(), ); @@ -628,8 +630,6 @@ pub fn run_grandpa_voter, N, RA, SC, VR, X>( telemetry!(CONSENSUS_WARN; "afg.voter_failed"; "e" => ?e); }); - let voter_work = network_startup.and_then(move |()| voter_work); - // Make sure that `telemetry_task` doesn't accidentally finish and kill grandpa. let telemetry_task = telemetry_task .then(|_| futures::future::empty::<(), ()>()); @@ -641,17 +641,15 @@ pub fn run_grandpa_voter, N, RA, SC, VR, X>( /// Future that powers the voter. #[must_use] -struct VoterWork, RA, SC, VR> { +struct VoterWork { voter: Box>> + Send>, - env: Arc>, + env: Arc>, voter_commands_rx: mpsc::UnboundedReceiver>>, } -impl VoterWork +impl VoterWork where Block: BlockT, - N: Network + Sync, - N::In: Send + 'static, NumberFor: BlockNumberOps, RA: 'static + Send + Sync, E: CallExecutor + Send + Sync + 'static, @@ -662,7 +660,7 @@ where fn new( client: Arc>, config: Config, - network: NetworkBridge, + network: NetworkBridge, select_chain: SC, voting_rule: VR, persistent_data: PersistentData, @@ -823,11 +821,9 @@ where } } -impl Future for VoterWork +impl Future for VoterWork where Block: BlockT, - N: Network + Sync, - N::In: Send + 'static, NumberFor: BlockNumberOps, RA: 'static + Send + Sync, E: CallExecutor + Send + Sync + 'static, @@ -878,20 +874,20 @@ where } #[deprecated(since = "1.1.0", note = "Please switch to run_grandpa_voter.")] -pub fn run_grandpa, N, RA, SC, VR, X>( - grandpa_params: GrandpaParams, +pub fn run_grandpa, N, RA, SC, VR, X, Sp>( + grandpa_params: GrandpaParams, ) -> ::sp_blockchain::Result + Send + 'static> where Block::Hash: Ord, B: Backend + 'static, E: CallExecutor + Send + Sync + 'static, - N: Network + Send + Sync + 'static, - N::In: Send + 'static, + N: Network + Send + Clone + 'static, SC: SelectChain + 'static, NumberFor: BlockNumberOps, DigestFor: Encode, RA: Send + Sync + 'static, VR: VotingRule> + Clone + 'static, X: futures03::Future + Clone + Send + Unpin + 'static, + Sp: futures03::task::Spawn + 'static, { run_grandpa_voter(grandpa_params) } @@ -910,15 +906,17 @@ pub fn setup_disabled_grandpa, RA, N>( B: Backend + 'static, E: CallExecutor + Send + Sync + 'static, RA: Send + Sync + 'static, - N: Network + Send + Sync + 'static, - N::In: Send + 'static, + N: Network + Send + Clone + 'static, { register_finality_tracker_inherent_data_provider( client, inherent_data_providers, )?; - network.register_validator(Arc::new(network::consensus_gossip::DiscardAll)); + // We register the GRANDPA protocol so that we don't consider it an anomaly + // to receive GRANDPA messages on the network. We don't process the + // messages. + network.register_notifications_protocol(communication::GRANDPA_ENGINE_ID); Ok(()) } diff --git a/client/finality-grandpa/src/observer.rs b/client/finality-grandpa/src/observer.rs index cf09ae3b21..4681c12753 100644 --- a/client/finality-grandpa/src/observer.rs +++ b/client/finality-grandpa/src/observer.rs @@ -151,19 +151,20 @@ fn grandpa_observer, RA, S, F>( /// listening for and validating GRANDPA commits instead of following the full /// protocol. Provide configuration and a link to a block import worker that has /// already been instantiated with `block_import`. -pub fn run_grandpa_observer, N, RA, SC>( +pub fn run_grandpa_observer, N, RA, SC, Sp>( config: Config, link: LinkHalf, network: N, on_exit: impl futures03::Future + Clone + Send + Unpin + 'static, + executor: Sp, ) -> ::sp_blockchain::Result + Send + 'static> where B: Backend + 'static, E: CallExecutor + Send + Sync + 'static, - N: Network + Send + Sync + 'static, - N::In: Send + 'static, + N: Network + Send + Clone + 'static, SC: SelectChain + 'static, NumberFor: BlockNumberOps, RA: Send + Sync + 'static, + Sp: futures03::task::Spawn + 'static, { let LinkHalf { client, @@ -172,10 +173,11 @@ pub fn run_grandpa_observer, N, RA, SC>( voter_commands_rx, } = link; - let (network, network_startup) = NetworkBridge::new( + let network = NetworkBridge::new( network, config.clone(), persistent_data.set_state.clone(), + &executor, on_exit.clone(), ); @@ -193,8 +195,6 @@ pub fn run_grandpa_observer, N, RA, SC>( warn!("GRANDPA Observer failed: {:?}", e); }); - let observer_work = network_startup.and_then(move |()| observer_work); - use futures03::{FutureExt, TryFutureExt}; Ok(observer_work.select(on_exit.map(Ok).compat()).map(|_| ()).map_err(|_| ())) @@ -202,20 +202,18 @@ pub fn run_grandpa_observer, N, RA, SC>( /// Future that powers the observer. #[must_use] -struct ObserverWork, N: Network, E, Backend, RA> { +struct ObserverWork, E, Backend, RA> { observer: Box>> + Send>, client: Arc>, - network: NetworkBridge, + network: NetworkBridge, persistent_data: PersistentData, keystore: Option, voter_commands_rx: mpsc::UnboundedReceiver>>, } -impl ObserverWork +impl ObserverWork where B: BlockT, - N: Network, - N::In: Send + 'static, NumberFor: BlockNumberOps, RA: 'static + Send + Sync, E: CallExecutor + Send + Sync + 'static, @@ -223,7 +221,7 @@ where { fn new( client: Arc>, - network: NetworkBridge, + network: NetworkBridge, persistent_data: PersistentData, keystore: Option, voter_commands_rx: mpsc::UnboundedReceiver>>, @@ -327,11 +325,9 @@ where } } -impl Future for ObserverWork +impl Future for ObserverWork where B: BlockT, - N: Network, - N::In: Send + 'static, NumberFor: BlockNumberOps, RA: 'static + Send + Sync, E: CallExecutor + Send + Sync + 'static, diff --git a/client/finality-grandpa/src/tests.rs b/client/finality-grandpa/src/tests.rs index ece9bf167b..a63ce2a7f6 100644 --- a/client/finality-grandpa/src/tests.rs +++ b/client/finality-grandpa/src/tests.rs @@ -22,6 +22,7 @@ use sc_network_test::{Block, DummySpecialization, Hash, TestNetFactory, Peer, Pe use sc_network_test::{PassThroughVerifier}; use network::config::{ProtocolConfig, Roles, BoxFinalityProofRequestBuilder}; use parking_lot::Mutex; +use futures_timer::Delay; use futures03::{StreamExt as _, TryStreamExt as _}; use tokio::runtime::current_thread; use keyring::Ed25519Keyring; @@ -338,6 +339,7 @@ fn create_keystore(authority: Ed25519Keyring) -> (KeyStorePtr, tempfile::TempDir // the voters are spawned but before blocking on them. fn run_to_completion_with( runtime: &mut current_thread::Runtime, + threads_pool: &futures03::executor::ThreadPool, blocks: u64, net: Arc>, peers: &[Ed25519Keyring], @@ -405,6 +407,7 @@ fn run_to_completion_with( on_exit: Exit, telemetry_on_connect: None, voting_rule: (), + executor: threads_pool.clone(), }; let voter = run_grandpa_voter(grandpa_params).expect("all in order with client and network"); @@ -427,11 +430,12 @@ fn run_to_completion_with( fn run_to_completion( runtime: &mut current_thread::Runtime, + threads_pool: &futures03::executor::ThreadPool, blocks: u64, net: Arc>, peers: &[Ed25519Keyring] ) -> u64 { - run_to_completion_with(runtime, blocks, net, peers, |_| None) + run_to_completion_with(runtime, threads_pool, blocks, net, peers, |_| None) } fn add_scheduled_change(block: &mut Block, change: ScheduledChange) { @@ -456,6 +460,7 @@ fn add_forced_change( fn finalize_3_voters_no_observers() { let _ = env_logger::try_init(); let mut runtime = current_thread::Runtime::new().unwrap(); + let threads_pool = futures03::executor::ThreadPool::new().unwrap(); let peers = &[Ed25519Keyring::Alice, Ed25519Keyring::Bob, Ed25519Keyring::Charlie]; let voters = make_ids(peers); @@ -469,7 +474,7 @@ fn finalize_3_voters_no_observers() { } let net = Arc::new(Mutex::new(net)); - run_to_completion(&mut runtime, 20, net.clone(), peers); + run_to_completion(&mut runtime, &threads_pool, 20, net.clone(), peers); // normally there's no justification for finalized blocks assert!( @@ -481,6 +486,7 @@ fn finalize_3_voters_no_observers() { #[test] fn finalize_3_voters_1_full_observer() { let mut runtime = current_thread::Runtime::new().unwrap(); + let threads_pool = futures03::executor::ThreadPool::new().unwrap(); let peers = &[Ed25519Keyring::Alice, Ed25519Keyring::Bob, Ed25519Keyring::Charlie]; let voters = make_ids(peers); @@ -499,6 +505,8 @@ fn finalize_3_voters_1_full_observer() { let mut keystore_paths = Vec::new(); + let mut voters = Vec::new(); + for (peer_id, local_key) in all_peers.enumerate() { let (client, net_service, link) = { let net = net.lock(); @@ -539,9 +547,13 @@ fn finalize_3_voters_1_full_observer() { on_exit: Exit, telemetry_on_connect: None, voting_rule: (), + executor: threads_pool.clone(), }; - let voter = run_grandpa_voter(grandpa_params).expect("all in order with client and network"); + voters.push(run_grandpa_voter(grandpa_params).expect("all in order with client and network")); + } + + for voter in voters { runtime.spawn(voter); } @@ -583,6 +595,7 @@ fn transition_3_voters_twice_1_full_observer() { let net = Arc::new(Mutex::new(GrandpaTestNet::new(api, 8))); let mut runtime = current_thread::Runtime::new().unwrap(); + let threads_pool = futures03::executor::ThreadPool::new().unwrap(); net.lock().peer(0).push_blocks(1, false); net.lock().block_until_sync(&mut runtime); @@ -687,6 +700,7 @@ fn transition_3_voters_twice_1_full_observer() { assert_eq!(set.pending_changes().count(), 0); }) ); + let grandpa_params = GrandpaParams { config: Config { gossip_duration: TEST_GOSSIP_DURATION, @@ -702,6 +716,7 @@ fn transition_3_voters_twice_1_full_observer() { on_exit: Exit, telemetry_on_connect: None, voting_rule: (), + executor: threads_pool.clone(), }; let voter = run_grandpa_voter(grandpa_params).expect("all in order with client and network"); @@ -720,6 +735,7 @@ fn transition_3_voters_twice_1_full_observer() { #[test] fn justification_is_emitted_when_consensus_data_changes() { let mut runtime = current_thread::Runtime::new().unwrap(); + let threads_pool = futures03::executor::ThreadPool::new().unwrap(); let peers = &[Ed25519Keyring::Alice, Ed25519Keyring::Bob, Ed25519Keyring::Charlie]; let mut net = GrandpaTestNet::new(TestApi::new(make_ids(peers)), 3); @@ -728,7 +744,7 @@ fn justification_is_emitted_when_consensus_data_changes() { net.peer(0).push_authorities_change_block(new_authorities); net.block_until_sync(&mut runtime); let net = Arc::new(Mutex::new(net)); - run_to_completion(&mut runtime, 1, net.clone(), peers); + run_to_completion(&mut runtime, &threads_pool, 1, net.clone(), peers); // ... and check that there's justification for block#1 assert!(net.lock().peer(0).client().justification(&BlockId::Number(1)).unwrap().is_some(), @@ -738,6 +754,7 @@ fn justification_is_emitted_when_consensus_data_changes() { #[test] fn justification_is_generated_periodically() { let mut runtime = current_thread::Runtime::new().unwrap(); + let threads_pool = futures03::executor::ThreadPool::new().unwrap(); let peers = &[Ed25519Keyring::Alice, Ed25519Keyring::Bob, Ed25519Keyring::Charlie]; let voters = make_ids(peers); @@ -746,7 +763,7 @@ fn justification_is_generated_periodically() { net.block_until_sync(&mut runtime); let net = Arc::new(Mutex::new(net)); - run_to_completion(&mut runtime, 32, net.clone(), peers); + run_to_completion(&mut runtime, &threads_pool, 32, net.clone(), peers); // when block#32 (justification_period) is finalized, justification // is required => generated @@ -777,6 +794,7 @@ fn consensus_changes_works() { #[test] fn sync_justifications_on_change_blocks() { let mut runtime = current_thread::Runtime::new().unwrap(); + let threads_pool = futures03::executor::ThreadPool::new().unwrap(); let peers_a = &[Ed25519Keyring::Alice, Ed25519Keyring::Bob, Ed25519Keyring::Charlie]; let peers_b = &[Ed25519Keyring::Alice, Ed25519Keyring::Bob]; let voters = make_ids(peers_b); @@ -808,7 +826,7 @@ fn sync_justifications_on_change_blocks() { } let net = Arc::new(Mutex::new(net)); - run_to_completion(&mut runtime, 25, net.clone(), peers_a); + run_to_completion(&mut runtime, &threads_pool, 25, net.clone(), peers_a); // the first 3 peers are grandpa voters and therefore have already finalized // block 21 and stored a justification @@ -831,6 +849,7 @@ fn sync_justifications_on_change_blocks() { fn finalizes_multiple_pending_changes_in_order() { let _ = env_logger::try_init(); let mut runtime = current_thread::Runtime::new().unwrap(); + let threads_pool = futures03::executor::ThreadPool::new().unwrap(); let peers_a = &[Ed25519Keyring::Alice, Ed25519Keyring::Bob, Ed25519Keyring::Charlie]; let peers_b = &[Ed25519Keyring::Dave, Ed25519Keyring::Eve, Ed25519Keyring::Ferdie]; @@ -884,13 +903,14 @@ fn finalizes_multiple_pending_changes_in_order() { } let net = Arc::new(Mutex::new(net)); - run_to_completion(&mut runtime, 30, net.clone(), all_peers); + run_to_completion(&mut runtime, &threads_pool, 30, net.clone(), all_peers); } #[test] fn force_change_to_new_set() { let _ = env_logger::try_init(); let mut runtime = current_thread::Runtime::new().unwrap(); + let threads_pool = futures03::executor::ThreadPool::new().unwrap(); // two of these guys are offline. let genesis_authorities = &[ Ed25519Keyring::Alice, @@ -941,7 +961,7 @@ fn force_change_to_new_set() { // it will only finalize if the forced transition happens. // we add_blocks after the voters are spawned because otherwise // the link-halfs have the wrong AuthoritySet - run_to_completion(&mut runtime, 25, net, peers_a); + run_to_completion(&mut runtime, &threads_pool, 25, net, peers_a); } #[test] @@ -1059,6 +1079,7 @@ fn voter_persists_its_votes() { let _ = env_logger::try_init(); let mut runtime = current_thread::Runtime::new().unwrap(); + let threads_pool = futures03::executor::ThreadPool::new().unwrap(); // we have two authorities but we'll only be running the voter for alice // we are going to be listening for the prevotes it casts @@ -1097,6 +1118,7 @@ fn voter_persists_its_votes() { net: Arc>, client: PeersClient, keystore: KeyStorePtr, + threads_pool: futures03::executor::ThreadPool, } impl Future for ResettableVoter { @@ -1132,6 +1154,7 @@ fn voter_persists_its_votes() { on_exit: Exit, telemetry_on_connect: None, voting_rule: VotingRulesBuilder::default().build(), + executor: self.threads_pool.clone(), }; let voter = run_grandpa_voter(grandpa_params) @@ -1163,6 +1186,7 @@ fn voter_persists_its_votes() { net: net.clone(), client: client.clone(), keystore, + threads_pool: threads_pool.clone(), }); } @@ -1191,13 +1215,13 @@ fn voter_persists_its_votes() { set_state }; - let (network, routing_work) = communication::NetworkBridge::new( + let network = communication::NetworkBridge::new( net.lock().peers[1].network_service().clone(), config.clone(), set_state, + &threads_pool, Exit, ); - runtime.block_on(routing_work).unwrap(); let (round_rx, round_tx) = network.round_communication( communication::Round(1), @@ -1232,7 +1256,14 @@ fn voter_persists_its_votes() { let net = net.clone(); let voter_tx = voter_tx.clone(); let round_tx = round_tx.clone(); - future::Either::A(tokio_timer::Interval::new_interval(Duration::from_millis(200)) + + let interval = futures03::stream::unfold(Delay::new(Duration::from_millis(200)), |delay| + Box::pin(async move { + delay.await; + Some(((), Delay::new(Duration::from_millis(200)))) + })).map(Ok::<_, ()>).compat(); + + future::Either::A(interval .take_while(move |_| { Ok(net2.lock().peer(1).client().info().chain.best_number != 40) }) @@ -1302,6 +1333,7 @@ fn voter_persists_its_votes() { fn finalize_3_voters_1_light_observer() { let _ = env_logger::try_init(); let mut runtime = current_thread::Runtime::new().unwrap(); + let threads_pool = futures03::executor::ThreadPool::new().unwrap(); let authorities = &[Ed25519Keyring::Alice, Ed25519Keyring::Bob, Ed25519Keyring::Charlie]; let voters = make_ids(authorities); @@ -1322,7 +1354,7 @@ fn finalize_3_voters_1_light_observer() { .take_while(|n| Ok(n.header.number() < &20)) .collect(); - run_to_completion_with(&mut runtime, 20, net.clone(), authorities, |executor| { + run_to_completion_with(&mut runtime, &threads_pool, 20, net.clone(), authorities, |executor| { executor.spawn( run_grandpa_observer( Config { @@ -1336,6 +1368,7 @@ fn finalize_3_voters_1_light_observer() { link, net.lock().peers[3].network_service().clone(), Exit, + threads_pool.clone(), ).unwrap() ).unwrap(); @@ -1347,6 +1380,7 @@ fn finalize_3_voters_1_light_observer() { fn finality_proof_is_fetched_by_light_client_when_consensus_data_changes() { let _ = ::env_logger::try_init(); let mut runtime = current_thread::Runtime::new().unwrap(); + let threads_pool = futures03::executor::ThreadPool::new().unwrap(); let peers = &[Ed25519Keyring::Alice]; let mut net = GrandpaTestNet::new(TestApi::new(make_ids(peers)), 1); @@ -1356,7 +1390,7 @@ fn finality_proof_is_fetched_by_light_client_when_consensus_data_changes() { // && instead fetches finality proof for block #1 net.peer(0).push_authorities_change_block(vec![babe_primitives::AuthorityId::from_slice(&[42; 32])]); let net = Arc::new(Mutex::new(net)); - run_to_completion(&mut runtime, 1, net.clone(), peers); + run_to_completion(&mut runtime, &threads_pool, 1, net.clone(), peers); net.lock().block_until_sync(&mut runtime); // check that the block#1 is finalized on light client @@ -1377,6 +1411,7 @@ fn empty_finality_proof_is_returned_to_light_client_when_authority_set_is_differ let _ = ::env_logger::try_init(); let mut runtime = current_thread::Runtime::new().unwrap(); + let threads_pool = futures03::executor::ThreadPool::new().unwrap(); // two of these guys are offline. let genesis_authorities = if FORCE_CHANGE { @@ -1424,7 +1459,7 @@ fn empty_finality_proof_is_returned_to_light_client_when_authority_set_is_differ net.lock().block_until_sync(&mut runtime); // finalize block #11 on full clients - run_to_completion(&mut runtime, 11, net.clone(), peers_a); + run_to_completion(&mut runtime, &threads_pool, 11, net.clone(), peers_a); // request finalization by light client net.lock().add_light_peer(&GrandpaTestNet::default_config()); @@ -1441,6 +1476,7 @@ fn empty_finality_proof_is_returned_to_light_client_when_authority_set_is_differ fn voter_catches_up_to_latest_round_when_behind() { let _ = env_logger::try_init(); let mut runtime = current_thread::Runtime::new().unwrap(); + let threads_pool = futures03::executor::ThreadPool::new().unwrap(); let peers = &[Ed25519Keyring::Alice, Ed25519Keyring::Bob]; let voters = make_ids(peers); @@ -1468,6 +1504,7 @@ fn voter_catches_up_to_latest_round_when_behind() { on_exit: Exit, telemetry_on_connect: None, voting_rule: (), + executor: threads_pool.clone(), }; Box::new(run_grandpa_voter(grandpa_params).expect("all in order with client and network")) @@ -1555,6 +1592,8 @@ fn grandpa_environment_respects_voting_rules() { use grandpa::Chain; use sc_network_test::TestClient; + let threads_pool = futures03::executor::ThreadPool::new().unwrap(); + let peers = &[Ed25519Keyring::Alice]; let voters = make_ids(peers); @@ -1581,10 +1620,11 @@ fn grandpa_environment_respects_voting_rules() { observer_enabled: true, }; - let (network, _) = NetworkBridge::new( + let network = NetworkBridge::new( network_service.clone(), config.clone(), set_state.clone(), + &threads_pool, Exit, ); diff --git a/client/finality-grandpa/src/until_imported.rs b/client/finality-grandpa/src/until_imported.rs index 7e209e13b8..c843547a7b 100644 --- a/client/finality-grandpa/src/until_imported.rs +++ b/client/finality-grandpa/src/until_imported.rs @@ -32,11 +32,11 @@ use log::{debug, warn}; use client_api::{BlockImportNotification, ImportNotifications}; use futures::prelude::*; use futures::stream::Fuse; +use futures_timer::Delay; use futures03::{StreamExt as _, TryStreamExt as _}; use grandpa::voter; use parking_lot::Mutex; use sp_runtime::traits::{Block as BlockT, Header as HeaderT, NumberFor}; -use tokio_timer::Interval; use std::collections::{HashMap, VecDeque}; use std::sync::{atomic::{AtomicUsize, Ordering}, Arc}; @@ -76,7 +76,7 @@ pub(crate) struct UntilImported, ready: VecDeque, - check_pending: Interval, + check_pending: Box + Send>, /// Mapping block hashes to their block number, the point in time it was /// first encountered (Instant) and a list of GRANDPA messages referencing /// the block hash. @@ -104,9 +104,13 @@ impl UntilImported _>(|v| Ok::<_, ()>(v)).compat(); @@ -116,7 +120,7 @@ impl UntilImported panic!("neither should have had error"), Ok(Either::A(_)) => panic!("timeout should have fired first"), @@ -929,7 +933,7 @@ mod tests { // the `until_imported` stream doesn't request the blocks immediately, // but it should request them after a small timeout - let timeout = Delay::new(Instant::now() + Duration::from_secs(60)); + let timeout = Delay::new(Duration::from_secs(60)).unit_error().compat(); let test = assert.select2(timeout).map(|res| match res { Either::A(_) => {}, Either::B(_) => panic!("timed out waiting for block sync request"), diff --git a/client/network-gossip/Cargo.toml b/client/network-gossip/Cargo.toml new file mode 100644 index 0000000000..b0fcd1fe72 --- /dev/null +++ b/client/network-gossip/Cargo.toml @@ -0,0 +1,18 @@ +[package] +description = "Gossiping for the Substrate network protocol" +name = "sc-network-gossip" +version = "2.0.0" +license = "GPL-3.0" +authors = ["Parity Technologies "] +edition = "2018" + +[dependencies] +log = "0.4.8" +futures01 = { package = "futures", version = "0.1.29" } +futures = { version = "0.3.1", features = ["compat"] } +futures-timer = "0.4.0" +lru = "0.1.2" +libp2p = { version = "0.13.0", default-features = false, features = ["libp2p-websocket"] } +network = { package = "sc-network", path = "../network" } +parking_lot = "0.9.0" +sp-runtime = { path = "../../primitives/runtime" } diff --git a/client/network-gossip/src/bridge.rs b/client/network-gossip/src/bridge.rs new file mode 100644 index 0000000000..28f0e3f9b4 --- /dev/null +++ b/client/network-gossip/src/bridge.rs @@ -0,0 +1,301 @@ +// Copyright 2019 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Substrate is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Substrate. If not, see . + +use crate::Network; +use crate::state_machine::{ConsensusGossip, Validator, TopicNotification}; + +use network::Context; +use network::message::generic::ConsensusMessage; +use network::{Event, ReputationChange}; + +use futures::{prelude::*, channel::mpsc, compat::Compat01As03, task::SpawnExt as _}; +use libp2p::PeerId; +use parking_lot::Mutex; +use sp_runtime::{traits::{Block as BlockT, NumberFor}, ConsensusEngineId}; +use std::{sync::Arc, time::Duration}; + +/// Wraps around an implementation of the `Network` crate and provides gossiping capabilities on +/// top of it. +pub struct GossipEngine { + inner: Arc>>, + engine_id: ConsensusEngineId, +} + +struct GossipEngineInner { + state_machine: ConsensusGossip, + context: Box + Send>, + context_ext: Box + Send>, +} + +impl GossipEngine { + /// Create a new instance. + pub fn new + Send + Clone + 'static>( + network: N, + executor: &impl futures::task::Spawn, + engine_id: ConsensusEngineId, + validator: Arc>, + ) -> Self where B: 'static { + let mut state_machine = ConsensusGossip::new(); + let mut context = Box::new(ContextOverService { + network: network.clone(), + }); + let context_ext = Box::new(ContextOverService { + network: network.clone(), + }); + + // We grab the event stream before registering the notifications protocol, otherwise we + // might miss events. + let event_stream = network.event_stream(); + + network.register_notifications_protocol(engine_id); + state_machine.register_validator(&mut *context, engine_id, validator); + + let inner = Arc::new(Mutex::new(GossipEngineInner { + state_machine, + context, + context_ext, + })); + + let gossip_engine = GossipEngine { + inner: inner.clone(), + engine_id, + }; + + let res = executor.spawn({ + let inner = Arc::downgrade(&inner); + async move { + loop { + let _ = futures_timer::Delay::new(Duration::from_millis(1100)).await; + if let Some(inner) = inner.upgrade() { + let mut inner = inner.lock(); + let inner = &mut *inner; + inner.state_machine.tick(&mut *inner.context); + } else { + // We reach this branch if the `Arc` has no reference + // left. We can now let the task end. + break; + } + } + } + }); + + // Note: we consider the chances of an error to spawn a background task almost null. + if res.is_err() { + log::error!(target: "gossip", "Failed to spawn background task"); + } + + let res = executor.spawn(async move { + let mut stream = Compat01As03::new(event_stream); + while let Some(Ok(event)) = stream.next().await { + match event { + Event::NotificationStreamOpened { remote, engine_id: msg_engine_id, roles } => { + if msg_engine_id != engine_id { + continue; + } + let mut inner = inner.lock(); + let inner = &mut *inner; + inner.state_machine.new_peer(&mut *inner.context, remote, roles); + } + Event::NotificationsStreamClosed { remote, engine_id: msg_engine_id } => { + if msg_engine_id != engine_id { + continue; + } + let mut inner = inner.lock(); + let inner = &mut *inner; + inner.state_machine.peer_disconnected(&mut *inner.context, remote); + }, + Event::NotificationsReceived { remote, messages } => { + let mut inner = inner.lock(); + let inner = &mut *inner; + inner.state_machine.on_incoming( + &mut *inner.context, + remote, + messages.into_iter() + .filter_map(|(engine, data)| if engine == engine_id { + Some(ConsensusMessage { engine_id: engine, data: data.to_vec() }) + } else { None }) + .collect() + ); + }, + Event::Dht(_) => {} + } + } + }); + + // Note: we consider the chances of an error to spawn a background task almost null. + if res.is_err() { + log::error!(target: "gossip", "Failed to spawn background task"); + } + + gossip_engine + } + + /// Closes all notification streams. + pub fn abort(&self) { + self.inner.lock().state_machine.abort(); + } + + pub fn report(&self, who: PeerId, reputation: ReputationChange) { + self.inner.lock().context.report_peer(who, reputation); + } + + /// Registers a message without propagating it to any peers. The message + /// becomes available to new peers or when the service is asked to gossip + /// the message's topic. No validation is performed on the message, if the + /// message is already expired it should be dropped on the next garbage + /// collection. + pub fn register_gossip_message( + &self, + topic: B::Hash, + message: Vec, + ) { + let message = ConsensusMessage { + engine_id: self.engine_id, + data: message, + }; + + self.inner.lock().state_machine.register_message(topic, message); + } + + /// Broadcast all messages with given topic. + pub fn broadcast_topic(&self, topic: B::Hash, force: bool) { + let mut inner = self.inner.lock(); + let inner = &mut *inner; + inner.state_machine.broadcast_topic(&mut *inner.context, topic, force); + } + + /// Get data of valid, incoming messages for a topic (but might have expired meanwhile). + pub fn messages_for(&self, topic: B::Hash) + -> mpsc::UnboundedReceiver + { + self.inner.lock().state_machine.messages_for(self.engine_id, topic) + } + + /// Send all messages with given topic to a peer. + pub fn send_topic( + &self, + who: &PeerId, + topic: B::Hash, + force: bool + ) { + let mut inner = self.inner.lock(); + let inner = &mut *inner; + inner.state_machine.send_topic(&mut *inner.context, who, topic, self.engine_id, force) + } + + /// Multicast a message to all peers. + pub fn gossip_message( + &self, + topic: B::Hash, + message: Vec, + force: bool, + ) { + let message = ConsensusMessage { + engine_id: self.engine_id, + data: message, + }; + + let mut inner = self.inner.lock(); + let inner = &mut *inner; + inner.state_machine.multicast(&mut *inner.context, topic, message, force) + } + + /// Send addressed message to the given peers. The message is not kept or multicast + /// later on. + pub fn send_message(&self, who: Vec, data: Vec) { + let mut inner = self.inner.lock(); + let inner = &mut *inner; + + for who in &who { + inner.state_machine.send_message(&mut *inner.context, who, ConsensusMessage { + engine_id: self.engine_id, + data: data.clone(), + }); + } + } + + /// Notify everyone we're connected to that we have the given block. + /// + /// Note: this method isn't strictly related to gossiping and should eventually be moved + /// somewhere else. + pub fn announce(&self, block: B::Hash, associated_data: Vec) { + self.inner.lock().context_ext.announce(block, associated_data); + } + + /// Notifies the sync service to try and sync the given block from the given + /// peers. + /// + /// If the given vector of peers is empty then the underlying implementation + /// should make a best effort to fetch the block from any peers it is + /// connected to (NOTE: this assumption will change in the future #3629). + /// + /// Note: this method isn't strictly related to gossiping and should eventually be moved + /// somewhere else. + pub fn set_sync_fork_request(&self, peers: Vec, hash: B::Hash, number: NumberFor) { + self.inner.lock().context_ext.set_sync_fork_request(peers, hash, number); + } +} + +impl Clone for GossipEngine { + fn clone(&self) -> Self { + GossipEngine { + inner: self.inner.clone(), + engine_id: self.engine_id.clone(), + } + } +} + +struct ContextOverService { + network: N, +} + +impl> Context for ContextOverService { + fn report_peer(&mut self, who: PeerId, reputation: ReputationChange) { + self.network.report_peer(who, reputation); + } + + fn disconnect_peer(&mut self, who: PeerId) { + self.network.disconnect_peer(who) + } + + fn send_consensus(&mut self, who: PeerId, messages: Vec) { + for message in messages { + self.network.write_notification(who.clone(), message.engine_id, message.data); + } + } + + fn send_chain_specific(&mut self, _: PeerId, _: Vec) { + log::error!( + target: "sub-libp2p", + "send_chain_specific has been called in a context where it shouldn't" + ); + } +} + +trait ContextExt { + fn announce(&self, block: B::Hash, associated_data: Vec); + fn set_sync_fork_request(&self, peers: Vec, hash: B::Hash, number: NumberFor); +} + +impl> ContextExt for ContextOverService { + fn announce(&self, block: B::Hash, associated_data: Vec) { + Network::announce(&self.network, block, associated_data) + } + + fn set_sync_fork_request(&self, peers: Vec, hash: B::Hash, number: NumberFor) { + Network::set_sync_fork_request(&self.network, peers, hash, number) + } +} diff --git a/client/network-gossip/src/lib.rs b/client/network-gossip/src/lib.rs new file mode 100644 index 0000000000..6decda05c5 --- /dev/null +++ b/client/network-gossip/src/lib.rs @@ -0,0 +1,140 @@ +// Copyright 2019 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Substrate is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Substrate. If not, see . + +//! Polite gossiping. +//! +//! This crate provides gossiping capabilities on top of a network. +//! +//! Gossip messages are separated by two categories: "topics" and consensus engine ID. +//! The consensus engine ID is sent over the wire with the message, while the topic is not, +//! with the expectation that the topic can be derived implicitly from the content of the +//! message, assuming it is valid. +//! +//! Topics are a single 32-byte tag associated with a message, used to group those messages +//! in an opaque way. Consensus code can invoke `broadcast_topic` to attempt to send all messages +//! under a single topic to all peers who don't have them yet, and `send_topic` to +//! send all messages under a single topic to a specific peer. +//! +//! # Usage +//! +//! - Implement the `Network` trait, representing the low-level networking primitives. It is +//! already implemented on `sc_network::NetworkService`. +//! - Implement the `Validator` trait. See the section below. +//! - Decide on a `ConsensusEngineId`. Each gossiping protocol should have a different one. +//! - Build a `GossipEngine` using these three elements. +//! - Use the methods of the `GossipEngine` in order to send out messages and receive incoming +//! messages. +//! +//! # What is a validator? +//! +//! The primary role of a `Validator` is to process incoming messages from peers, and decide +//! whether to discard them or process them. It also decides whether to re-broadcast the message. +//! +//! The secondary role of the `Validator` is to check if a message is allowed to be sent to a given +//! peer. All messages, before being sent, will be checked against this filter. +//! This enables the validator to use information it's aware of about connected peers to decide +//! whether to send messages to them at any given moment in time - In particular, to wait until +//! peers can accept and process the message before sending it. +//! +//! Lastly, the fact that gossip validators can decide not to rebroadcast messages +//! opens the door for neighbor status packets to be baked into the gossip protocol. +//! These status packets will typically contain light pieces of information +//! used to inform peers of a current view of protocol state. + +pub use self::bridge::GossipEngine; +pub use self::state_machine::{TopicNotification, MessageIntent}; +pub use self::state_machine::{Validator, ValidatorContext, ValidationResult}; +pub use self::state_machine::DiscardAll; + +use network::{specialization::NetworkSpecialization, Event, ExHashT, NetworkService, PeerId, ReputationChange}; +use sp_runtime::{traits::{Block as BlockT, NumberFor}, ConsensusEngineId}; +use std::sync::Arc; + +mod bridge; +mod state_machine; + +/// Abstraction over a network. +pub trait Network { + /// Returns a stream of events representing what happens on the network. + fn event_stream(&self) -> Box + Send>; + + /// Adjust the reputation of a node. + fn report_peer(&self, peer_id: PeerId, reputation: ReputationChange); + + /// Force-disconnect a peer. + fn disconnect_peer(&self, who: PeerId); + + /// Send a notification to a peer. + fn write_notification(&self, who: PeerId, engine_id: ConsensusEngineId, message: Vec); + + /// Registers a notifications protocol. + /// + /// See the documentation of [`NetworkService:register_notifications_protocol`] for more information. + fn register_notifications_protocol( + &self, + engine_id: ConsensusEngineId + ); + + /// Notify everyone we're connected to that we have the given block. + /// + /// Note: this method isn't strictly related to gossiping and should eventually be moved + /// somewhere else. + fn announce(&self, block: B::Hash, associated_data: Vec); + + /// Notifies the sync service to try and sync the given block from the given + /// peers. + /// + /// If the given vector of peers is empty then the underlying implementation + /// should make a best effort to fetch the block from any peers it is + /// connected to (NOTE: this assumption will change in the future #3629). + /// + /// Note: this method isn't strictly related to gossiping and should eventually be moved + /// somewhere else. + fn set_sync_fork_request(&self, peers: Vec, hash: B::Hash, number: NumberFor); +} + +impl, H: ExHashT> Network for Arc> { + fn event_stream(&self) -> Box + Send> { + Box::new(NetworkService::event_stream(self)) + } + + fn report_peer(&self, peer_id: PeerId, reputation: ReputationChange) { + NetworkService::report_peer(self, peer_id, reputation); + } + + fn disconnect_peer(&self, who: PeerId) { + NetworkService::disconnect_peer(self, who) + } + + fn write_notification(&self, who: PeerId, engine_id: ConsensusEngineId, message: Vec) { + NetworkService::write_notification(self, who, engine_id, message) + } + + fn register_notifications_protocol( + &self, + engine_id: ConsensusEngineId, + ) { + NetworkService::register_notifications_protocol(self, engine_id) + } + + fn announce(&self, block: B::Hash, associated_data: Vec) { + NetworkService::announce_block(self, block, associated_data) + } + + fn set_sync_fork_request(&self, peers: Vec, hash: B::Hash, number: NumberFor) { + NetworkService::set_sync_fork_request(self, peers, hash, number) + } +} diff --git a/client/network/src/protocol/consensus_gossip.rs b/client/network-gossip/src/state_machine.rs similarity index 91% rename from client/network/src/protocol/consensus_gossip.rs rename to client/network-gossip/src/state_machine.rs index 24561debef..48854fc2a8 100644 --- a/client/network/src/protocol/consensus_gossip.rs +++ b/client/network-gossip/src/state_machine.rs @@ -14,48 +14,19 @@ // You should have received a copy of the GNU General Public License // along with Substrate. If not, see . -//! Utility for gossip of network messages between nodes. -//! Handles chain-specific and standard BFT messages. -//! -//! Gossip messages are separated by two categories: "topics" and consensus engine ID. -//! The consensus engine ID is sent over the wire with the message, while the topic is not, -//! with the expectation that the topic can be derived implicitly from the content of the -//! message, assuming it is valid. -//! -//! Topics are a single 32-byte tag associated with a message, used to group those messages -//! in an opaque way. Consensus code can invoke `broadcast_topic` to attempt to send all messages -//! under a single topic to all peers who don't have them yet, and `send_topic` to -//! send all messages under a single topic to a specific peer. -//! -//! Each consensus engine ID must have an associated, -//! registered `Validator` for all gossip messages. The primary role of this `Validator` is -//! to process incoming messages from peers, and decide whether to discard them or process -//! them. It also decides whether to re-broadcast the message. -//! -//! The secondary role of the `Validator` is to check if a message is allowed to be sent to a given -//! peer. All messages, before being sent, will be checked against this filter. -//! This enables the validator to use information it's aware of about connected peers to decide -//! whether to send messages to them at any given moment in time - In particular, to wait until -//! peers can accept and process the message before sending it. -//! -//! Lastly, the fact that gossip validators can decide not to rebroadcast messages -//! opens the door for neighbor status packets to be baked into the gossip protocol. -//! These status packets will typically contain light pieces of information -//! used to inform peers of a current view of protocol state. - use std::collections::{HashMap, HashSet, hash_map::Entry}; use std::sync::Arc; use std::iter; use std::time; use log::{trace, debug}; -use futures03::channel::mpsc; +use futures::channel::mpsc; use lru::LruCache; use libp2p::PeerId; use sp_runtime::traits::{Block as BlockT, Hash, HashFor}; use sp_runtime::ConsensusEngineId; -pub use crate::message::generic::{Message, ConsensusMessage}; -use crate::protocol::Context; -use crate::config::Roles; +pub use network::message::generic::{Message, ConsensusMessage}; +use network::Context; +use network::config::Roles; // FIXME: Add additional spam/DoS attack protection: https://github.com/paritytech/substrate/issues/1115 const KNOWN_MESSAGES_CACHE_SIZE: usize = 4096; @@ -63,7 +34,7 @@ const KNOWN_MESSAGES_CACHE_SIZE: usize = 4096; const REBROADCAST_INTERVAL: time::Duration = time::Duration::from_secs(30); mod rep { - use peerset::ReputationChange as Rep; + use network::ReputationChange as Rep; /// Reputation change when a peer sends us a gossip message that we didn't know about. pub const GOSSIP_SUCCESS: Rep = Rep::new(1 << 4, "Successfull gossip"); /// Reputation change when a peer sends us a gossip message that we already knew about. @@ -96,16 +67,6 @@ struct MessageEntry { sender: Option, } -/// Consensus message destination. -pub enum MessageRecipient { - /// Send to all peers. - BroadcastToAll, - /// Send to peers that don't have that message already. - BroadcastNew, - /// Send to specific peer. - Peer(PeerId), -} - /// The reason for sending out the message. #[derive(Eq, PartialEq, Copy, Clone)] #[cfg_attr(test, derive(Debug))] @@ -190,7 +151,7 @@ fn propagate<'a, B: BlockT, I>( validators: &HashMap>>, ) // (msg_hash, topic, message) - where I: Clone + IntoIterator, + where I: Clone + IntoIterator, { let mut check_fns = HashMap::new(); let mut message_allowed = move |who: &PeerId, intent: MessageIntent, topic: &B::Hash, message: &ConsensusMessage| { @@ -637,7 +598,7 @@ impl Validator for DiscardAll { mod tests { use std::sync::Arc; use sp_runtime::testing::{H256, Block as RawBlock, ExtrinsicWrapper}; - use futures03::executor::block_on_stream; + use futures::executor::block_on_stream; use super::*; diff --git a/client/network/src/behaviour.rs b/client/network/src/behaviour.rs index fb1f39726a..ae00c71757 100644 --- a/client/network/src/behaviour.rs +++ b/client/network/src/behaviour.rs @@ -16,10 +16,11 @@ use crate::{ debug_info, discovery::DiscoveryBehaviour, discovery::DiscoveryOut, DiscoveryNetBehaviour, - protocol::event::DhtEvent + Event, protocol::event::DhtEvent }; use crate::{ExHashT, specialization::NetworkSpecialization}; use crate::protocol::{CustomMessageOutcome, Protocol}; +use consensus::{BlockOrigin, import_queue::{IncomingBlock, Origin}}; use futures::prelude::*; use libp2p::NetworkBehaviour; use libp2p::core::{Multiaddr, PeerId, PublicKey}; @@ -27,7 +28,7 @@ use libp2p::kad::record; use libp2p::swarm::{NetworkBehaviourAction, NetworkBehaviourEventProcess}; use libp2p::core::{nodes::Substream, muxing::StreamMuxerBox}; use log::{debug, warn}; -use sp_runtime::traits::Block as BlockT; +use sp_runtime::{traits::{Block as BlockT, NumberFor}, Justification}; use std::iter; use void; @@ -50,8 +51,10 @@ pub struct Behaviour, H: ExHashT> { /// Event generated by `Behaviour`. pub enum BehaviourOut { - SubstrateAction(CustomMessageOutcome), - Dht(DhtEvent), + BlockImport(BlockOrigin, Vec>), + JustificationImport(Origin, B::Hash, NumberFor, Justification), + FinalityProofImport(Origin, B::Hash, NumberFor, Vec), + Event(Event), } impl, H: ExHashT> Behaviour { @@ -127,7 +130,34 @@ Behaviour { impl, H: ExHashT> NetworkBehaviourEventProcess> for Behaviour { fn inject_event(&mut self, event: CustomMessageOutcome) { - self.events.push(BehaviourOut::SubstrateAction(event)); + match event { + CustomMessageOutcome::BlockImport(origin, blocks) => + self.events.push(BehaviourOut::BlockImport(origin, blocks)), + CustomMessageOutcome::JustificationImport(origin, hash, nb, justification) => + self.events.push(BehaviourOut::JustificationImport(origin, hash, nb, justification)), + CustomMessageOutcome::FinalityProofImport(origin, hash, nb, proof) => + self.events.push(BehaviourOut::FinalityProofImport(origin, hash, nb, proof)), + CustomMessageOutcome::NotificationStreamOpened { remote, protocols, roles } => + for engine_id in protocols { + self.events.push(BehaviourOut::Event(Event::NotificationStreamOpened { + remote: remote.clone(), + engine_id, + roles, + })); + }, + CustomMessageOutcome::NotificationsStreamClosed { remote, protocols } => + for engine_id in protocols { + self.events.push(BehaviourOut::Event(Event::NotificationsStreamClosed { + remote: remote.clone(), + engine_id, + })); + }, + CustomMessageOutcome::NotificationsReceived { remote, messages } => { + let ev = Event::NotificationsReceived { remote, messages }; + self.events.push(BehaviourOut::Event(ev)); + }, + CustomMessageOutcome::None => {} + } } } @@ -166,16 +196,16 @@ impl, H: ExHashT> NetworkBehaviourEventPr self.substrate.add_discovered_nodes(iter::once(peer_id)); } DiscoveryOut::ValueFound(results) => { - self.events.push(BehaviourOut::Dht(DhtEvent::ValueFound(results))); + self.events.push(BehaviourOut::Event(Event::Dht(DhtEvent::ValueFound(results)))); } DiscoveryOut::ValueNotFound(key) => { - self.events.push(BehaviourOut::Dht(DhtEvent::ValueNotFound(key))); + self.events.push(BehaviourOut::Event(Event::Dht(DhtEvent::ValueNotFound(key)))); } DiscoveryOut::ValuePut(key) => { - self.events.push(BehaviourOut::Dht(DhtEvent::ValuePut(key))); + self.events.push(BehaviourOut::Event(Event::Dht(DhtEvent::ValuePut(key)))); } DiscoveryOut::ValuePutFailed(key) => { - self.events.push(BehaviourOut::Dht(DhtEvent::ValuePutFailed(key))); + self.events.push(BehaviourOut::Event(Event::Dht(DhtEvent::ValuePutFailed(key)))); } } } diff --git a/client/network/src/lib.rs b/client/network/src/lib.rs index 755ae803fe..ad98986276 100644 --- a/client/network/src/lib.rs +++ b/client/network/src/lib.rs @@ -186,7 +186,7 @@ pub use service::{ NetworkService, NetworkWorker, TransactionPool, ExHashT, ReportHandle, NetworkStateInfo, }; -pub use protocol::{PeerInfo, Context, ProtocolConfig, consensus_gossip, message, specialization}; +pub use protocol::{PeerInfo, Context, ProtocolConfig, message, specialization}; pub use protocol::event::{Event, DhtEvent}; pub use protocol::sync::SyncState; pub use libp2p::{Multiaddr, PeerId}; diff --git a/client/network/src/protocol.rs b/client/network/src/protocol.rs index 88bc1ede52..87dd1be4ec 100644 --- a/client/network/src/protocol.rs +++ b/client/network/src/protocol.rs @@ -17,7 +17,7 @@ use crate::{DiscoveryNetBehaviour, config::ProtocolId}; use legacy_proto::{LegacyProto, LegacyProtoOut}; use crate::utils::interval; -use bytes::BytesMut; +use bytes::{Bytes, BytesMut}; use futures::prelude::*; use futures03::{StreamExt as _, TryStreamExt as _}; use libp2p::{Multiaddr, PeerId}; @@ -38,7 +38,6 @@ use sp_runtime::traits::{ use sp_arithmetic::traits::SaturatedConversion; use message::{BlockAnnounce, BlockAttributes, Direction, FromBlock, Message, RequestId}; use message::generic::{Message as GenericMessage, ConsensusMessage}; -use consensus_gossip::{ConsensusGossip, MessageRecipient as GossipMessageRecipient}; use light_dispatch::{LightDispatch, LightDispatchNetwork, RequestData}; use specialization::NetworkSpecialization; use sync::{ChainSync, SyncState}; @@ -58,7 +57,6 @@ use util::LruHashSet; mod legacy_proto; mod util; -pub mod consensus_gossip; pub mod message; pub mod event; pub mod light_dispatch; @@ -135,7 +133,6 @@ pub struct Protocol, H: ExHashT> { genesis_hash: B::Hash, sync: ChainSync, specialization: S, - consensus_gossip: ConsensusGossip, context_data: ContextData, /// List of nodes for which we perform additional logging because they are important for the /// user. @@ -149,6 +146,8 @@ pub struct Protocol, H: ExHashT> { finality_proof_provider: Option>>, /// Handles opening the unique substream and sending and receiving raw messages. behaviour: LegacyProto>, + /// List of notification protocols that have been registered. + registered_notif_protocols: HashSet, } #[derive(Default)] @@ -473,13 +472,13 @@ impl, H: ExHashT> Protocol { genesis_hash: info.chain.genesis_hash, sync, specialization, - consensus_gossip: ConsensusGossip::new(), handshaking_peers: HashMap::new(), important_peers, transaction_pool, finality_proof_provider, peerset_handle: peerset_handle.clone(), behaviour, + registered_notif_protocols: HashSet::new(), }; Ok((protocol, peerset_handle)) @@ -614,7 +613,7 @@ impl, H: ExHashT> Protocol { stats.count_in += 1; match message { - GenericMessage::Status(s) => self.on_status_message(who, s), + GenericMessage::Status(s) => return self.on_status_message(who, s), GenericMessage::BlockRequest(r) => self.on_block_request(who, r), GenericMessage::BlockResponse(r) => { // Note, this is safe because only `ordinary bodies` and `remote bodies` are received in this matter. @@ -656,20 +655,38 @@ impl, H: ExHashT> Protocol { return self.on_finality_proof_response(who, response), GenericMessage::RemoteReadChildRequest(request) => self.on_remote_read_child_request(who, request), - GenericMessage::Consensus(msg) => { - self.consensus_gossip.on_incoming( - &mut ProtocolContext::new(&mut self.context_data, &mut self.behaviour, &self.peerset_handle), - who, - vec![msg], - ); - } + GenericMessage::Consensus(msg) => + return if self.registered_notif_protocols.contains(&msg.engine_id) { + CustomMessageOutcome::NotificationsReceived { + remote: who.clone(), + messages: vec![(msg.engine_id, From::from(msg.data))], + } + } else { + warn!(target: "sync", "Received message on non-registered protocol: {:?}", msg.engine_id); + CustomMessageOutcome::None + }, GenericMessage::ConsensusBatch(messages) => { - self.consensus_gossip.on_incoming( - &mut ProtocolContext::new(&mut self.context_data, &mut self.behaviour, &self.peerset_handle), - who, - messages, - ); - } + let messages = messages + .into_iter() + .filter_map(|msg| { + if self.registered_notif_protocols.contains(&msg.engine_id) { + Some((msg.engine_id, From::from(msg.data))) + } else { + warn!(target: "sync", "Received message on non-registered protocol: {:?}", msg.engine_id); + None + } + }) + .collect::>(); + + return if !messages.is_empty() { + CustomMessageOutcome::NotificationsReceived { + remote: who.clone(), + messages, + } + } else { + CustomMessageOutcome::None + }; + }, GenericMessage::ChainSpecific(msg) => self.specialization.on_message( &mut ProtocolContext::new(&mut self.context_data, &mut self.behaviour, &self.peerset_handle), who, @@ -699,14 +716,6 @@ impl, H: ExHashT> Protocol { ); } - /// Locks `self` and returns a context plus the `ConsensusGossip` struct. - pub fn consensus_gossip_lock<'a>( - &'a mut self, - ) -> (impl Context + 'a, &'a mut ConsensusGossip) { - let context = ProtocolContext::new(&mut self.context_data, &mut self.behaviour, &self.peerset_handle); - (context, &mut self.consensus_gossip) - } - /// Locks `self` and returns a context plus the network specialization. pub fn specialization_lock<'a>( &'a mut self, @@ -715,26 +724,6 @@ impl, H: ExHashT> Protocol { (context, &mut self.specialization) } - /// Gossip a consensus message to the network. - pub fn gossip_consensus_message( - &mut self, - topic: B::Hash, - engine_id: ConsensusEngineId, - message: Vec, - recipient: GossipMessageRecipient, - ) { - let mut context = ProtocolContext::new(&mut self.context_data, &mut self.behaviour, &self.peerset_handle); - let message = ConsensusMessage { data: message, engine_id }; - match recipient { - GossipMessageRecipient::BroadcastToAll => - self.consensus_gossip.multicast(&mut context, topic, message, true), - GossipMessageRecipient::BroadcastNew => - self.consensus_gossip.multicast(&mut context, topic, message, false), - GossipMessageRecipient::Peer(who) => - self.send_message(&who, GenericMessage::Consensus(message)), - } - } - /// Called when a new peer is connected pub fn on_peer_connected(&mut self, who: PeerId) { trace!(target: "sync", "Connecting {}", who); @@ -755,11 +744,8 @@ impl, H: ExHashT> Protocol { self.handshaking_peers.remove(&peer); self.context_data.peers.remove(&peer) }; - if let Some(peer_data) = removed { + if let Some(_peer_data) = removed { let mut context = ProtocolContext::new(&mut self.context_data, &mut self.behaviour, &self.peerset_handle); - if peer_data.info.protocol_version > 2 { - self.consensus_gossip.peer_disconnected(&mut context, peer.clone()); - } self.sync.peer_disconnected(peer.clone()); self.specialization.on_disconnect(&mut context, peer.clone()); self.light_dispatch.on_disconnect(LightDispatchIn { @@ -922,9 +908,6 @@ impl, H: ExHashT> Protocol { /// /// > **Note**: This method normally doesn't have to be called except for testing purposes. pub fn tick(&mut self) { - self.consensus_gossip.tick( - &mut ProtocolContext::new(&mut self.context_data, &mut self.behaviour, &self.peerset_handle) - ); self.maintain_peers(); self.light_dispatch.maintain_peers(LightDispatchIn { behaviour: &mut self.behaviour, @@ -975,9 +958,9 @@ impl, H: ExHashT> Protocol { } /// Called by peer to report status - fn on_status_message(&mut self, who: PeerId, status: message::Status) { + fn on_status_message(&mut self, who: PeerId, status: message::Status) -> CustomMessageOutcome { trace!(target: "sync", "New peer {} {:?}", who, status); - let protocol_version = { + let _protocol_version = { if self.context_data.peers.contains_key(&who) { log!( target: "sync", @@ -985,7 +968,7 @@ impl, H: ExHashT> Protocol { "Unexpected status packet from {}", who ); self.peerset_handle.report_peer(who, rep::UNEXPECTED_STATUS); - return; + return CustomMessageOutcome::None; } if status.genesis_hash != self.genesis_hash { log!( @@ -996,7 +979,7 @@ impl, H: ExHashT> Protocol { ); self.peerset_handle.report_peer(who.clone(), rep::GENESIS_MISMATCH); self.behaviour.disconnect_peer(&who); - return; + return CustomMessageOutcome::None; } if status.version < MIN_VERSION && CURRENT_VERSION < status.min_supported_version { log!( @@ -1006,7 +989,7 @@ impl, H: ExHashT> Protocol { ); self.peerset_handle.report_peer(who.clone(), rep::BAD_PROTOCOL); self.behaviour.disconnect_peer(&who); - return; + return CustomMessageOutcome::None; } if self.config.roles.is_light() { @@ -1015,7 +998,7 @@ impl, H: ExHashT> Protocol { debug!(target: "sync", "Peer {} is unable to serve light requests", who); self.peerset_handle.report_peer(who.clone(), rep::BAD_ROLE); self.behaviour.disconnect_peer(&who); - return; + return CustomMessageOutcome::None; } // we don't interested in peers that are far behind us @@ -1032,7 +1015,7 @@ impl, H: ExHashT> Protocol { debug!(target: "sync", "Peer {} is far behind us and will unable to serve light requests", who); self.peerset_handle.report_peer(who.clone(), rep::PEER_BEHIND_US_LIGHT); self.behaviour.disconnect_peer(&who); - return; + return CustomMessageOutcome::None; } } @@ -1047,7 +1030,7 @@ impl, H: ExHashT> Protocol { }, None => { error!(target: "sync", "Received status from previously unconnected node {}", who); - return; + return CustomMessageOutcome::None; }, }; @@ -1082,11 +1065,64 @@ impl, H: ExHashT> Protocol { } } } + let mut context = ProtocolContext::new(&mut self.context_data, &mut self.behaviour, &self.peerset_handle); - if protocol_version > 2 { - self.consensus_gossip.new_peer(&mut context, who.clone(), status.roles); + self.specialization.on_connect(&mut context, who.clone(), status); + + // Notify all the notification protocols as open. + CustomMessageOutcome::NotificationStreamOpened { + remote: who, + protocols: self.registered_notif_protocols.iter().cloned().collect(), + roles: info.roles, + } + } + + /// Send a notification to the given peer we're connected to. + /// + /// Doesn't do anything if we don't have a notifications substream for that protocol with that + /// peer. + pub fn write_notification( + &mut self, + target: PeerId, + engine_id: ConsensusEngineId, + message: impl Into> + ) { + if !self.registered_notif_protocols.contains(&engine_id) { + error!( + target: "sub-libp2p", + "Sending a notification with a protocol that wasn't registered: {:?}", + engine_id + ); + } + + self.send_message(&target, GenericMessage::Consensus(ConsensusMessage { + engine_id, + data: message.into(), + })); + } + + /// Registers a new notifications protocol. + /// + /// You are very strongly encouraged to call this method very early on. Any connection open + /// will retain the protocols that were registered then, and not any new one. + pub fn register_notifications_protocol( + &mut self, + engine_id: ConsensusEngineId, + ) -> Vec { + if !self.registered_notif_protocols.insert(engine_id) { + error!(target: "sub-libp2p", "Notifications protocol already registered: {:?}", engine_id); } - self.specialization.on_connect(&mut context, who, status); + + // Registering a protocol while we already have open connections isn't great, but for now + // we handle it by notifying that we opened channels with everyone. + self.context_data.peers.iter() + .map(|(peer_id, peer)| + event::Event::NotificationStreamOpened { + remote: peer_id.clone(), + engine_id, + roles: peer.info.roles, + }) + .collect() } /// Called when peer sends us new extrinsics @@ -1758,6 +1794,12 @@ pub enum CustomMessageOutcome { BlockImport(BlockOrigin, Vec>), JustificationImport(Origin, B::Hash, NumberFor, Justification), FinalityProofImport(Origin, B::Hash, NumberFor, Vec), + /// Notification protocols have been opened with a remote. + NotificationStreamOpened { remote: PeerId, protocols: Vec, roles: Roles }, + /// Notification protocols have been closed with a remote. + NotificationsStreamClosed { remote: PeerId, protocols: Vec }, + /// Messages have been received on one or more notifications protocols. + NotificationsReceived { remote: PeerId, messages: Vec<(ConsensusEngineId, Bytes)> }, None, } @@ -1887,12 +1929,16 @@ Protocol { version <= CURRENT_VERSION as u8 && version >= MIN_VERSION as u8 ); - self.on_peer_connected(peer_id); + self.on_peer_connected(peer_id.clone()); CustomMessageOutcome::None } LegacyProtoOut::CustomProtocolClosed { peer_id, .. } => { - self.on_peer_disconnected(peer_id); - CustomMessageOutcome::None + self.on_peer_disconnected(peer_id.clone()); + // Notify all the notification protocols as closed. + CustomMessageOutcome::NotificationsStreamClosed { + remote: peer_id, + protocols: self.registered_notif_protocols.iter().cloned().collect(), + } }, LegacyProtoOut::CustomMessage { peer_id, message } => self.on_custom_message(peer_id, message), diff --git a/client/network/src/protocol/event.rs b/client/network/src/protocol/event.rs index c8bee5588c..98aad8c76c 100644 --- a/client/network/src/protocol/event.rs +++ b/client/network/src/protocol/event.rs @@ -17,10 +17,15 @@ //! Network event types. These are are not the part of the protocol, but rather //! events that happen on the network like DHT get/put results received. +use crate::config::Roles; +use bytes::Bytes; +use libp2p::core::PeerId; use libp2p::kad::record::Key; +use sp_runtime::ConsensusEngineId; /// Events generated by DHT as a response to get_value and put_value requests. #[derive(Debug, Clone)] +#[must_use] pub enum DhtEvent { /// The value was found. ValueFound(Vec<(Key, Vec)>), @@ -37,7 +42,37 @@ pub enum DhtEvent { /// Type for events generated by networking layer. #[derive(Debug, Clone)] +#[must_use] pub enum Event { /// Event generated by a DHT. Dht(DhtEvent), + + /// Opened a substream with the given node with the given notifications protocol. + /// + /// The protocol is always one of the notification protocols that have been registered. + NotificationStreamOpened { + /// Node we opened the substream with. + remote: PeerId, + /// The concerned protocol. Each protocol uses a different substream. + engine_id: ConsensusEngineId, + /// Roles that the remote . + roles: Roles, + }, + + /// Closed a substream with the given node. Always matches a corresponding previous + /// `NotificationStreamOpened` message. + NotificationsStreamClosed { + /// Node we closed the substream with. + remote: PeerId, + /// The concerned protocol. Each protocol uses a different substream. + engine_id: ConsensusEngineId, + }, + + /// Received one or more messages from the given node using the given protocol. + NotificationsReceived { + /// Node we received the message from. + remote: PeerId, + /// Concerned protocol and associated message. + messages: Vec<(ConsensusEngineId, Bytes)>, + }, } diff --git a/client/network/src/service.rs b/client/network/src/service.rs index 85fd1c3ff5..c137932090 100644 --- a/client/network/src/service.rs +++ b/client/network/src/service.rs @@ -45,8 +45,7 @@ use crate::{NetworkState, NetworkStateNotConnectedPeer, NetworkStatePeer}; use crate::{transport, config::NonReservedPeerMode, ReputationChange}; use crate::config::{Params, TransportConfig}; use crate::error::Error; -use crate::protocol::{self, Protocol, Context, CustomMessageOutcome, PeerInfo}; -use crate::protocol::consensus_gossip::{ConsensusGossip, MessageRecipient as GossipMessageRecipient}; +use crate::protocol::{self, Protocol, Context, PeerInfo}; use crate::protocol::{event::Event, light_dispatch::{AlwaysBadChecker, RequestData}}; use crate::protocol::specialization::NetworkSpecialization; use crate::protocol::sync::SyncState; @@ -276,6 +275,7 @@ impl, H: ExHashT> NetworkWorker import_queue: params.import_queue, from_worker, light_client_rqs: params.on_demand.and_then(|od| od.extract_receiver()), + event_streams: Vec::new(), }) } @@ -416,6 +416,55 @@ impl, H: ExHashT> NetworkServic self.local_peer_id.clone() } + /// Writes a message on an open notifications channel. Has no effect if the notifications + /// channel with this protocol name is closed. + /// + /// > **Note**: The reason why this is a no-op in the situation where we have no channel is + /// > that we don't guarantee message delivery anyway. Networking issues can cause + /// > connections to drop at any time, and higher-level logic shouldn't differentiate + /// > between the remote voluntarily closing a substream or a network error + /// > preventing the message from being delivered. + /// + /// The protocol must have been registered with `register_notifications_protocol`. + /// + pub fn write_notification(&self, target: PeerId, engine_id: ConsensusEngineId, message: Vec) { + let _ = self.to_worker.unbounded_send(ServerToWorkerMsg::WriteNotification { + target, + engine_id, + message, + }); + } + + /// Returns a stream containing the events that happen on the network. + /// + /// If this method is called multiple times, the events are duplicated. + /// + /// The stream never ends (unless the `NetworkWorker` gets shut down). + pub fn event_stream(&self) -> impl Stream { + // Note: when transitioning to stable futures, remove the `Error` entirely + let (tx, rx) = mpsc::unbounded(); + let _ = self.to_worker.unbounded_send(ServerToWorkerMsg::EventStream(tx)); + rx + } + + /// Registers a new notifications protocol. + /// + /// After that, you can call `write_notifications`. + /// + /// Please call `event_stream` before registering a protocol, otherwise you may miss events + /// about the protocol that you have registered. + /// + /// You are very strongly encouraged to call this method very early on. Any connection open + /// will retain the protocols that were registered then, and not any new one. + pub fn register_notifications_protocol( + &self, + engine_id: ConsensusEngineId, + ) { + let _ = self.to_worker.unbounded_send(ServerToWorkerMsg::RegisterNotifProtocol { + engine_id, + }); + } + /// You must call this when new transactons are imported by the transaction pool. /// /// The latest transactions will be fetched from the `TransactionPool` that was passed at @@ -432,27 +481,19 @@ impl, H: ExHashT> NetworkServic let _ = self.to_worker.unbounded_send(ServerToWorkerMsg::AnnounceBlock(hash, data)); } - /// Send a consensus message through the gossip - pub fn gossip_consensus_message( - &self, - topic: B::Hash, - engine_id: ConsensusEngineId, - message: Vec, - recipient: GossipMessageRecipient, - ) { - let _ = self - .to_worker - .unbounded_send(ServerToWorkerMsg::GossipConsensusMessage( - topic, engine_id, message, recipient, - )); - } - /// Report a given peer as either beneficial (+) or costly (-) according to the /// given scalar. pub fn report_peer(&self, who: PeerId, cost_benefit: ReputationChange) { self.peerset.report_peer(who, cost_benefit); } + /// Disconnect from a node as soon as possible. + /// + /// This triggers the same effects as if the connection had closed itself spontaneously. + pub fn disconnect_peer(&self, who: PeerId) { + let _ = self.to_worker.unbounded_send(ServerToWorkerMsg::DisconnectPeer(who)); + } + /// Request a justification for the given block from the network. /// /// On success, the justification will be passed to the import queue that was part at @@ -472,15 +513,6 @@ impl, H: ExHashT> NetworkServic .unbounded_send(ServerToWorkerMsg::ExecuteWithSpec(Box::new(f))); } - /// Execute a closure with the consensus gossip. - pub fn with_gossip(&self, f: F) - where F: FnOnce(&mut ConsensusGossip, &mut dyn Context) + Send + 'static - { - let _ = self - .to_worker - .unbounded_send(ServerToWorkerMsg::ExecuteWithGossip(Box::new(f))); - } - /// Are we in the process of downloading the chain? pub fn is_major_syncing(&self) -> bool { self.is_major_syncing.load(Ordering::Relaxed) @@ -630,12 +662,20 @@ enum ServerToWorkerMsg> { RequestJustification(B::Hash, NumberFor), AnnounceBlock(B::Hash, Vec), ExecuteWithSpec(Box) + Send>), - ExecuteWithGossip(Box, &mut dyn Context) + Send>), - GossipConsensusMessage(B::Hash, ConsensusEngineId, Vec, GossipMessageRecipient), GetValue(record::Key), PutValue(record::Key, Vec), AddKnownAddress(PeerId, Multiaddr), SyncFork(Vec, B::Hash, NumberFor), + EventStream(mpsc::UnboundedSender), + WriteNotification { + message: Vec, + engine_id: ConsensusEngineId, + target: PeerId, + }, + RegisterNotifProtocol { + engine_id: ConsensusEngineId, + }, + DisconnectPeer(PeerId), } /// Main network worker. Must be polled in order for the network to advance. @@ -659,13 +699,15 @@ pub struct NetworkWorker, H: Ex from_worker: mpsc::UnboundedReceiver>, /// Receiver for queries from the light client that must be processed. light_client_rqs: Option>>, + /// Senders for events that happen on the network. + event_streams: Vec>, } -impl, H: ExHashT> Stream for NetworkWorker { - type Item = Event; +impl, H: ExHashT> Future for NetworkWorker { + type Item = (); type Error = io::Error; - fn poll(&mut self) -> Poll, Self::Error> { + fn poll(&mut self) -> Poll { // Poll the import queue for actions to perform. let _ = futures03::future::poll_fn(|cx| { self.import_queue.poll_actions(cx, &mut NetworkLink { @@ -685,7 +727,7 @@ impl, H: ExHashT> Stream for Ne // Process the next message coming from the `NetworkService`. let msg = match self.from_worker.poll() { Ok(Async::Ready(Some(msg))) => msg, - Ok(Async::Ready(None)) | Err(_) => return Ok(Async::Ready(None)), + Ok(Async::Ready(None)) | Err(_) => return Ok(Async::Ready(())), Ok(Async::NotReady) => break, }; @@ -695,13 +737,6 @@ impl, H: ExHashT> Stream for Ne let (mut context, spec) = protocol.specialization_lock(); task(spec, &mut context); }, - ServerToWorkerMsg::ExecuteWithGossip(task) => { - let protocol = self.network_service.user_protocol_mut(); - let (mut context, gossip) = protocol.consensus_gossip_lock(); - task(gossip, &mut context); - } - ServerToWorkerMsg::GossipConsensusMessage(topic, engine_id, message, recipient) => - self.network_service.user_protocol_mut().gossip_consensus_message(topic, engine_id, message, recipient), ServerToWorkerMsg::AnnounceBlock(hash, data) => self.network_service.user_protocol_mut().announce_block(hash, data), ServerToWorkerMsg::RequestJustification(hash, number) => @@ -716,6 +751,18 @@ impl, H: ExHashT> Stream for Ne self.network_service.add_known_address(peer_id, addr), ServerToWorkerMsg::SyncFork(peer_ids, hash, number) => self.network_service.user_protocol_mut().set_sync_fork_request(peer_ids, &hash, number), + ServerToWorkerMsg::EventStream(sender) => + self.event_streams.push(sender), + ServerToWorkerMsg::WriteNotification { message, engine_id, target } => + self.network_service.user_protocol_mut().write_notification(target, engine_id, message), + ServerToWorkerMsg::RegisterNotifProtocol { engine_id } => { + let events = self.network_service.user_protocol_mut().register_notifications_protocol(engine_id); + for event in events { + self.event_streams.retain(|sender| sender.unbounded_send(event.clone()).is_ok()); + } + }, + ServerToWorkerMsg::DisconnectPeer(who) => + self.network_service.user_protocol_mut().disconnect_peer(&who), } } @@ -723,27 +770,23 @@ impl, H: ExHashT> Stream for Ne // Process the next action coming from the network. let poll_value = self.network_service.poll(); - let outcome = match poll_value { + match poll_value { Ok(Async::NotReady) => break, - Ok(Async::Ready(Some(BehaviourOut::SubstrateAction(outcome)))) => outcome, - Ok(Async::Ready(Some(BehaviourOut::Dht(ev)))) => - return Ok(Async::Ready(Some(Event::Dht(ev)))), - Ok(Async::Ready(None)) => CustomMessageOutcome::None, + Ok(Async::Ready(Some(BehaviourOut::BlockImport(origin, blocks)))) => + self.import_queue.import_blocks(origin, blocks), + Ok(Async::Ready(Some(BehaviourOut::JustificationImport(origin, hash, nb, justification)))) => + self.import_queue.import_justification(origin, hash, nb, justification), + Ok(Async::Ready(Some(BehaviourOut::FinalityProofImport(origin, hash, nb, proof)))) => + self.import_queue.import_finality_proof(origin, hash, nb, proof), + Ok(Async::Ready(Some(BehaviourOut::Event(ev)))) => { + self.event_streams.retain(|sender| sender.unbounded_send(ev.clone()).is_ok()); + }, + Ok(Async::Ready(None)) => {}, Err(err) => { error!(target: "sync", "Error in the network: {:?}", err); return Err(err) } }; - - match outcome { - CustomMessageOutcome::BlockImport(origin, blocks) => - self.import_queue.import_blocks(origin, blocks), - CustomMessageOutcome::JustificationImport(origin, hash, nb, justification) => - self.import_queue.import_justification(origin, hash, nb, justification), - CustomMessageOutcome::FinalityProofImport(origin, hash, nb, proof) => - self.import_queue.import_finality_proof(origin, hash, nb, proof), - CustomMessageOutcome::None => {} - } } // Update the variables shared with the `NetworkService`. diff --git a/client/service/src/lib.rs b/client/service/src/lib.rs index 3ec785ff4a..de6077e12f 100644 --- a/client/service/src/lib.rs +++ b/client/service/src/lib.rs @@ -131,6 +131,14 @@ impl Executor + Send>> for SpawnTaskHandle } } +impl futures03::task::Spawn for SpawnTaskHandle { + fn spawn_obj(&self, future: futures03::task::FutureObj<'static, ()>) + -> Result<(), futures03::task::SpawnError> { + self.execute(Box::new(futures03::compat::Compat::new(future.unit_error()))) + .map_err(|_| futures03::task::SpawnError::shutdown()) + } +} + /// Abstraction over a Substrate service. pub trait AbstractService: 'static + Future + Executor + Send>> + Send { @@ -375,6 +383,9 @@ fn build_network_future< let mut finality_notification_stream = client.finality_notification_stream().fuse() .map(|v| Ok::<_, ()>(v)).compat(); + // Initializing a stream in order to obtain DHT events from the network. + let mut event_stream = network.service().event_stream(); + futures::future::poll_fn(move || { let before_polling = Instant::now(); @@ -451,22 +462,32 @@ fn build_network_future< (status, state) }); + // Processing DHT events. + while let Ok(Async::Ready(Some(event))) = event_stream.poll() { + match event { + Event::Dht(event) => { + // Given that client/authority-discovery is the only upper stack consumer of Dht events at the moment, all Dht + // events are being passed on to the authority-discovery module. In the future there might be multiple + // consumers of these events. In that case this would need to be refactored to properly dispatch the events, + // e.g. via a subscriber model. + if let Some(Err(e)) = dht_event_tx.as_ref().map(|c| c.clone().try_send(event)) { + if e.is_full() { + warn!(target: "service", "Dht event channel to authority discovery is full, dropping event."); + } else if e.is_disconnected() { + warn!(target: "service", "Dht event channel to authority discovery is disconnected, dropping event."); + } + } + } + _ => {} + } + } + // Main network polling. - while let Ok(Async::Ready(Some(Event::Dht(event)))) = network.poll().map_err(|err| { + if let Ok(Async::Ready(())) = network.poll().map_err(|err| { warn!(target: "service", "Error in network: {:?}", err); }) { - // Given that client/authority-discovery is the only upper stack consumer of Dht events at the moment, all Dht - // events are being passed on to the authority-discovery module. In the future there might be multiple - // consumers of these events. In that case this would need to be refactored to properly dispatch the events, - // e.g. via a subscriber model. - if let Some(Err(e)) = dht_event_tx.as_ref().map(|c| c.clone().try_send(event)) { - if e.is_full() { - warn!(target: "service", "Dht event channel to authority discovery is full, dropping event."); - } else if e.is_disconnected() { - warn!(target: "service", "Dht event channel to authority discovery is disconnected, dropping event."); - } - } - }; + return Ok(Async::Ready(())); + } // Now some diagnostic for performances. let polling_dur = before_polling.elapsed(); -- GitLab From 605f5c1b89616d14b0c401fb14eb899f5772d266 Mon Sep 17 00:00:00 2001 From: Benjamin Kampmann Date: Sat, 14 Dec 2019 02:59:37 +0100 Subject: [PATCH 135/172] Adding in-between variants of crate names to rename script (#4381) --- .maintain/rename-crates-for-2.0.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.maintain/rename-crates-for-2.0.sh b/.maintain/rename-crates-for-2.0.sh index 36d2076147..d2bd871f09 100644 --- a/.maintain/rename-crates-for-2.0.sh +++ b/.maintain/rename-crates-for-2.0.sh @@ -37,8 +37,12 @@ TO_RENAME=( # post initial rename fixes "sc-application-crypto sp-application-crypto" "sp-transaction-pool-api sp-transaction-pool" + "sp-transaction-pool-runtime-api sp-transaction-pool" "sp-core-storage sp-storage" "transaction-factory node-transaction-factory" + "sp-finality-granpda sp-finality-grandpa" + "sp-sesssion sp-session" + "sp-tracing-pool sp-transaction-pool" # PRIMITIVES "substrate-application-crypto sp-application-crypto" -- GitLab From 9f4c7b788b047661de28e9a3fc750af877efc155 Mon Sep 17 00:00:00 2001 From: cheme Date: Sat, 14 Dec 2019 03:11:19 +0100 Subject: [PATCH 136/172] Fix key collision for child trie (#4162) * In progress, runtime io must switch to future proof root + child_specific (unique id) + u32 type. * Switch interface, sr-io seems ok, rpc could use similar interface to sr-io, genesis json broken if there is child trie in existing encoding genesis. * test from previous implementation. * fix proving test. * Restore Keyspacedb from other branch, only apply to child trie. * Removing unneeded child_info from child root (child info are stored if things changed, otherwhise the root does not change). * Switch rpc to use same format as ext: more future proof. * use root from child info for trie backend essence. * Breaking long lines. * Update doc and clean pr a bit. * fix error type * Restore removed doc on merge and update sr-io doc. * Switch child storage api to use directly unique id, if managed id where to be put in place, the api will change at this time. * Clean deprecated host interface from child. * Removing assertion on child info (can fail depending on root memoization). * merging child info in the overlay when possible. * child iteration by prefix using child_info. * Using ChainInfo in frame support. ChainInfo gets redesign to avoid buffers allocation on every calls. * Add length of root to the data of child info. * comments * Encode compact. * Remove child info with root. * Fix try_update condition. * Comment Ext child root caching. * Replace tuples by struct with field * remove StorageTuple alias. * Fix doc tests, and remove StorageOverlay and ChildStorageOverlay aliases. --- bin/node/executor/src/lib.rs | 185 ++++++------ bin/node/testing/src/client.rs | 2 +- client/api/src/backend.rs | 4 +- client/api/src/light.rs | 7 +- client/chain-spec/src/chain_spec.rs | 83 ++++-- client/db/src/lib.rs | 97 +++++-- client/db/src/storage_cache.rs | 69 +++-- .../executor/src/deprecated_host_interface.rs | 133 --------- client/executor/src/integration_tests/mod.rs | 14 +- client/finality-grandpa/src/tests.rs | 2 +- client/network/src/chain.rs | 7 +- client/network/src/protocol.rs | 52 ++-- client/network/src/protocol/light_dispatch.rs | 11 +- client/network/src/protocol/message.rs | 5 + client/rpc-api/src/state/mod.rs | 8 + client/rpc/src/state/mod.rs | 32 ++- client/rpc/src/state/state_full.rs | 35 ++- client/rpc/src/state/state_light.rs | 10 +- client/rpc/src/state/tests.rs | 43 ++- client/src/cht.rs | 4 +- client/src/client.rs | 26 +- client/src/genesis.rs | 11 +- client/src/in_mem.rs | 20 +- client/src/lib.rs | 4 +- client/src/light/backend.rs | 67 +++-- client/src/light/fetcher.rs | 17 +- frame/contracts/src/account_db.rs | 16 +- frame/contracts/src/lib.rs | 39 ++- frame/contracts/src/rent.rs | 9 +- .../src/storage/genesis_config/mod.rs | 19 +- frame/support/src/storage/child.rs | 164 +++++++++-- frame/support/test/tests/instance.rs | 7 +- frame/system/src/lib.rs | 13 +- primitives/externalities/src/lib.rs | 74 ++++- primitives/io/src/lib.rs | 145 ++++++++-- primitives/runtime/src/lib.rs | 29 +- primitives/state-machine/src/backend.rs | 265 +++++++++++++----- primitives/state-machine/src/basic.rs | 194 +++++++------ .../state-machine/src/changes_trie/build.rs | 34 ++- primitives/state-machine/src/ext.rs | 235 +++++++++++----- primitives/state-machine/src/lib.rs | 55 +++- .../state-machine/src/overlayed_changes.rs | 102 +++++-- .../state-machine/src/proving_backend.rs | 90 ++++-- primitives/state-machine/src/testing.rs | 54 ++-- primitives/state-machine/src/trie_backend.rs | 65 ++++- .../state-machine/src/trie_backend_essence.rs | 92 ++++-- primitives/storage/src/lib.rs | 155 +++++++++- primitives/trie/src/lib.rs | 115 +++++++- test-utils/client/src/lib.rs | 28 +- test-utils/runtime/client/src/lib.rs | 29 +- test-utils/runtime/src/genesismap.rs | 36 +-- test-utils/runtime/src/lib.rs | 23 +- test-utils/runtime/src/system.rs | 8 +- 53 files changed, 2123 insertions(+), 920 deletions(-) diff --git a/bin/node/executor/src/lib.rs b/bin/node/executor/src/lib.rs index b2410ed15e..70a9853fc6 100644 --- a/bin/node/executor/src/lib.rs +++ b/bin/node/executor/src/lib.rs @@ -42,7 +42,7 @@ mod tests { use state_machine::TestExternalities as CoreTestExternalities; use primitives::{ Blake2Hasher, NeverNativeValue, NativeOrEncoded, map, - traits::{CodeExecutor, Externalities}, storage::well_known_keys, + traits::{CodeExecutor, Externalities}, storage::{well_known_keys, Storage}, }; use sp_runtime::{ Fixed64, traits::{Header as HeaderT, Hash as HashT, Convert}, ApplyExtrinsicResult, @@ -143,20 +143,23 @@ mod tests { #[test] fn panic_execution_with_foreign_code_gives_error() { - let mut t = TestExternalities::::new_with_code(BLOATY_CODE, (map![ - >::hashed_key_for(alice()) => { - 69_u128.encode() - }, - >::hashed_key().to_vec() => { - 69_u128.encode() - }, - >::hashed_key().to_vec() => { - 0_u128.encode() - }, - >::hashed_key_for(0) => { - vec![0u8; 32] - } - ], map![])); + let mut t = TestExternalities::::new_with_code(BLOATY_CODE, Storage { + top: map![ + >::hashed_key_for(alice()) => { + 69_u128.encode() + }, + >::hashed_key().to_vec() => { + 69_u128.encode() + }, + >::hashed_key().to_vec() => { + 0_u128.encode() + }, + >::hashed_key_for(0) => { + vec![0u8; 32] + } + ], + children: map![], + }); let r = executor_call:: _>( &mut t, @@ -179,20 +182,23 @@ mod tests { #[test] fn bad_extrinsic_with_native_equivalent_code_gives_error() { - let mut t = TestExternalities::::new_with_code(COMPACT_CODE, (map![ - >::hashed_key_for(alice()) => { - 69_u128.encode() - }, - >::hashed_key().to_vec() => { - 69_u128.encode() - }, - >::hashed_key().to_vec() => { - 0_u128.encode() - }, - >::hashed_key_for(0) => { - vec![0u8; 32] - } - ], map![])); + let mut t = TestExternalities::::new_with_code(COMPACT_CODE, Storage { + top: map![ + >::hashed_key_for(alice()) => { + 69_u128.encode() + }, + >::hashed_key().to_vec() => { + 69_u128.encode() + }, + >::hashed_key().to_vec() => { + 0_u128.encode() + }, + >::hashed_key_for(0) => { + vec![0u8; 32] + } + ], + children: map![], + }); let r = executor_call:: _>( &mut t, @@ -215,16 +221,19 @@ mod tests { #[test] fn successful_execution_with_native_equivalent_code_gives_ok() { - let mut t = TestExternalities::::new_with_code(COMPACT_CODE, (map![ - >::hashed_key_for(alice()) => { - (111 * DOLLARS).encode() - }, - >::hashed_key().to_vec() => { - (111 * DOLLARS).encode() - }, - >::hashed_key().to_vec() => vec![0u8; 16], - >::hashed_key_for(0) => vec![0u8; 32] - ], map![])); + let mut t = TestExternalities::::new_with_code(COMPACT_CODE, Storage { + top: map![ + >::hashed_key_for(alice()) => { + (111 * DOLLARS).encode() + }, + >::hashed_key().to_vec() => { + (111 * DOLLARS).encode() + }, + >::hashed_key().to_vec() => vec![0u8; 16], + >::hashed_key_for(0) => vec![0u8; 32] + ], + children: map![], + }); let r = executor_call:: _>( &mut t, @@ -254,16 +263,19 @@ mod tests { #[test] fn successful_execution_with_foreign_code_gives_ok() { - let mut t = TestExternalities::::new_with_code(BLOATY_CODE, (map![ - >::hashed_key_for(alice()) => { - (111 * DOLLARS).encode() - }, - >::hashed_key().to_vec() => { - (111 * DOLLARS).encode() - }, - >::hashed_key().to_vec() => vec![0u8; 16], - >::hashed_key_for(0) => vec![0u8; 32] - ], map![])); + let mut t = TestExternalities::::new_with_code(BLOATY_CODE, Storage { + top: map![ + >::hashed_key_for(alice()) => { + (111 * DOLLARS).encode() + }, + >::hashed_key().to_vec() => { + (111 * DOLLARS).encode() + }, + >::hashed_key().to_vec() => vec![0u8; 16], + >::hashed_key_for(0) => vec![0u8; 32] + ], + children: map![], + }); let r = executor_call:: _>( &mut t, @@ -828,16 +840,19 @@ mod tests { #[test] fn panic_execution_gives_error() { - let mut t = TestExternalities::::new_with_code(BLOATY_CODE, (map![ - >::hashed_key_for(alice()) => { - 0_u128.encode() - }, - >::hashed_key().to_vec() => { - 0_u128.encode() - }, - >::hashed_key().to_vec() => vec![0u8; 16], - >::hashed_key_for(0) => vec![0u8; 32] - ], map![])); + let mut t = TestExternalities::::new_with_code(BLOATY_CODE, Storage { + top: map![ + >::hashed_key_for(alice()) => { + 0_u128.encode() + }, + >::hashed_key().to_vec() => { + 0_u128.encode() + }, + >::hashed_key().to_vec() => vec![0u8; 16], + >::hashed_key_for(0) => vec![0u8; 32] + ], + children: map![], + }); let r = executor_call:: _>( &mut t, @@ -860,16 +875,19 @@ mod tests { #[test] fn successful_execution_gives_ok() { - let mut t = TestExternalities::::new_with_code(COMPACT_CODE, (map![ - >::hashed_key_for(alice()) => { - (111 * DOLLARS).encode() - }, - >::hashed_key().to_vec() => { - (111 * DOLLARS).encode() - }, - >::hashed_key().to_vec() => vec![0u8; 16], - >::hashed_key_for(0) => vec![0u8; 32] - ], map![])); + let mut t = TestExternalities::::new_with_code(COMPACT_CODE, Storage { + top: map![ + >::hashed_key_for(alice()) => { + (111 * DOLLARS).encode() + }, + >::hashed_key().to_vec() => { + (111 * DOLLARS).encode() + }, + >::hashed_key().to_vec() => vec![0u8; 16], + >::hashed_key_for(0) => vec![0u8; 32] + ], + children: map![], + }); let r = executor_call:: _>( &mut t, @@ -1037,19 +1055,22 @@ mod tests { // - 1 MILLICENTS in substrate node. // - 1 milli-dot based on current polkadot runtime. // (this baed on assigning 0.1 CENT to the cheapest tx with `weight = 100`) - let mut t = TestExternalities::::new_with_code(COMPACT_CODE, (map![ - >::hashed_key_for(alice()) => { - (100 * DOLLARS).encode() - }, - >::hashed_key_for(bob()) => { - (10 * DOLLARS).encode() - }, - >::hashed_key().to_vec() => { - (110 * DOLLARS).encode() - }, - >::hashed_key().to_vec() => vec![0u8; 16], - >::hashed_key_for(0) => vec![0u8; 32] - ], map![])); + let mut t = TestExternalities::::new_with_code(COMPACT_CODE, Storage { + top: map![ + >::hashed_key_for(alice()) => { + (100 * DOLLARS).encode() + }, + >::hashed_key_for(bob()) => { + (10 * DOLLARS).encode() + }, + >::hashed_key().to_vec() => { + (110 * DOLLARS).encode() + }, + >::hashed_key().to_vec() => vec![0u8; 16], + >::hashed_key_for(0) => vec![0u8; 32] + ], + children: map![], + }); let tip = 1_000_000; let xt = sign(CheckedExtrinsic { diff --git a/bin/node/testing/src/client.rs b/bin/node/testing/src/client.rs index b865a407fa..a6964b3915 100644 --- a/bin/node/testing/src/client.rs +++ b/bin/node/testing/src/client.rs @@ -42,7 +42,7 @@ pub struct GenesisParameters { } impl test_client::GenesisInit for GenesisParameters { - fn genesis_storage(&self) -> (StorageOverlay, ChildrenStorageOverlay) { + fn genesis_storage(&self) -> Storage { crate::genesis::config(self.support_changes_trie, None).build_storage().unwrap() } } diff --git a/client/api/src/backend.rs b/client/api/src/backend.rs index 488cab6bb0..a71ffff74b 100644 --- a/client/api/src/backend.rs +++ b/client/api/src/backend.rs @@ -20,7 +20,7 @@ use std::sync::Arc; use std::collections::HashMap; use primitives::ChangesTrieConfiguration; use primitives::offchain::OffchainStorage; -use sp_runtime::{generic::BlockId, Justification, StorageOverlay, ChildrenStorageOverlay}; +use sp_runtime::{generic::BlockId, Justification, Storage}; use sp_runtime::traits::{Block as BlockT, NumberFor}; use state_machine::backend::Backend as StateBackend; use state_machine::{ChangesTrieStorage as StateChangesTrieStorage, ChangesTrieTransaction}; @@ -134,7 +134,7 @@ pub trait BlockImportOperation where fn update_db_storage(&mut self, update: >::Transaction) -> sp_blockchain::Result<()>; /// Inject storage data into the database replacing any existing data. - fn reset_storage(&mut self, top: StorageOverlay, children: ChildrenStorageOverlay) -> sp_blockchain::Result; + fn reset_storage(&mut self, storage: Storage) -> sp_blockchain::Result; /// Set storage changes. fn update_storage( diff --git a/client/api/src/light.rs b/client/api/src/light.rs index c368fdd108..2c52aeca83 100644 --- a/client/api/src/light.rs +++ b/client/api/src/light.rs @@ -26,7 +26,7 @@ use sp_runtime::{ }, generic::BlockId }; -use primitives::{ChangesTrieConfiguration}; +use primitives::ChangesTrieConfiguration; use state_machine::StorageProof; use sp_blockchain::{ HeaderMetadata, well_known_cache_keys, HeaderBackend, Cache as BlockchainCache, @@ -81,6 +81,11 @@ pub struct RemoteReadChildRequest { pub header: Header, /// Storage key for child. pub storage_key: Vec, + /// Child trie source information. + pub child_info: Vec, + /// Child type, its required to resolve `child_info` + /// content and choose child implementation. + pub child_type: u32, /// Child storage key to read. pub keys: Vec>, /// Number of times to retry request. None means that default RETRY_COUNT is used. diff --git a/client/chain-spec/src/chain_spec.rs b/client/chain-spec/src/chain_spec.rs index 2ebd814c03..3c4cc7a54a 100644 --- a/client/chain-spec/src/chain_spec.rs +++ b/client/chain-spec/src/chain_spec.rs @@ -22,8 +22,8 @@ use std::fs::File; use std::path::PathBuf; use std::rc::Rc; use serde::{Serialize, Deserialize}; -use primitives::storage::{StorageKey, StorageData}; -use sp_runtime::{BuildStorage, StorageOverlay, ChildrenStorageOverlay}; +use primitives::storage::{StorageKey, StorageData, ChildInfo, Storage, StorageChild}; +use sp_runtime::BuildStorage; use serde_json as json; use crate::RuntimeGenesis; use network::Multiaddr; @@ -71,36 +71,62 @@ impl GenesisSource { } impl<'a, G: RuntimeGenesis, E> BuildStorage for &'a ChainSpec { - fn build_storage(&self) -> Result<(StorageOverlay, ChildrenStorageOverlay), String> { + fn build_storage(&self) -> Result { match self.genesis.resolve()? { Genesis::Runtime(gc) => gc.build_storage(), - Genesis::Raw(map, children_map) => Ok(( - map.into_iter().map(|(k, v)| (k.0, v.0)).collect(), - children_map.into_iter().map(|(sk, map)| ( - sk.0, - map.into_iter().map(|(k, v)| (k.0, v.0)).collect(), - )).collect(), - )), + Genesis::Raw(RawGenesis { top: map, children: children_map }) => Ok(Storage { + top: map.into_iter().map(|(k, v)| (k.0, v.0)).collect(), + children: children_map.into_iter().map(|(sk, child_content)| { + let child_info = ChildInfo::resolve_child_info( + child_content.child_type, + child_content.child_info.as_slice(), + ).expect("chainspec contains correct content").to_owned(); + ( + sk.0, + StorageChild { + data: child_content.data.into_iter().map(|(k, v)| (k.0, v.0)).collect(), + child_info, + }, + ) + }).collect(), + }), } } fn assimilate_storage( &self, - _: &mut (StorageOverlay, ChildrenStorageOverlay) + _: &mut Storage, ) -> Result<(), String> { Err("`assimilate_storage` not implemented for `ChainSpec`.".into()) } } +type GenesisStorage = HashMap; + +#[derive(Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +#[serde(deny_unknown_fields)] +struct ChildRawStorage { + data: GenesisStorage, + child_info: Vec, + child_type: u32, +} + +#[derive(Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +#[serde(deny_unknown_fields)] +/// Storage content for genesis block. +struct RawGenesis { + pub top: GenesisStorage, + pub children: HashMap, +} + #[derive(Serialize, Deserialize)] #[serde(rename_all = "camelCase")] #[serde(deny_unknown_fields)] enum Genesis { Runtime(G), - Raw( - HashMap, - HashMap>, - ), + Raw(RawGenesis), } #[derive(Serialize, Deserialize, Clone, Debug)] @@ -255,19 +281,26 @@ impl ChainSpec { let genesis = match (raw, self.genesis.resolve()?) { (true, Genesis::Runtime(g)) => { let storage = g.build_storage()?; - let top = storage.0.into_iter() + let top = storage.top.into_iter() .map(|(k, v)| (StorageKey(k), StorageData(v))) .collect(); - let children = storage.1.into_iter() - .map(|(sk, child)| ( + let children = storage.children.into_iter() + .map(|(sk, child)| { + let info = child.child_info.as_ref(); + let (info, ci_type) = info.info(); + ( StorageKey(sk), - child.into_iter() - .map(|(k, v)| (StorageKey(k), StorageData(v))) - .collect(), - )) + ChildRawStorage { + data: child.data.into_iter() + .map(|(k, v)| (StorageKey(k), StorageData(v))) + .collect(), + child_info: info.to_vec(), + child_type: ci_type, + }, + )}) .collect(); - Genesis::Raw(top, children) + Genesis::Raw(RawGenesis { top, children }) }, (_, genesis) => genesis, }; @@ -290,9 +323,9 @@ mod tests { impl BuildStorage for Genesis { fn assimilate_storage( &self, - storage: &mut (StorageOverlay, ChildrenStorageOverlay), + storage: &mut Storage, ) -> Result<(), String> { - storage.0.extend( + storage.top.extend( self.0.iter().map(|(a, b)| (a.clone().into_bytes(), b.clone().into_bytes())) ); Ok(()) diff --git a/client/db/src/lib.rs b/client/db/src/lib.rs index 9f1316253b..a7320ec1c3 100644 --- a/client/db/src/lib.rs +++ b/client/db/src/lib.rs @@ -52,9 +52,9 @@ use kvdb::{KeyValueDB, DBTransaction}; use trie::{MemoryDB, PrefixedMemoryDB, prefixed_key}; use parking_lot::{Mutex, RwLock}; use primitives::{H256, Blake2Hasher, ChangesTrieConfiguration, convert_hash, traits::CodeExecutor}; -use primitives::storage::well_known_keys; +use primitives::storage::{well_known_keys, ChildInfo}; use sp_runtime::{ - generic::{BlockId, DigestItem}, Justification, StorageOverlay, ChildrenStorageOverlay, + generic::{BlockId, DigestItem}, Justification, Storage, BuildStorage, }; use sp_runtime::traits::{ @@ -139,24 +139,39 @@ impl StateBackend for RefTrackingState { self.state.storage_hash(key) } - fn child_storage(&self, storage_key: &[u8], key: &[u8]) -> Result>, Self::Error> { - self.state.child_storage(storage_key, key) + fn child_storage( + &self, + storage_key: &[u8], + child_info: ChildInfo, + key: &[u8], + ) -> Result>, Self::Error> { + self.state.child_storage(storage_key, child_info, key) } fn exists_storage(&self, key: &[u8]) -> Result { self.state.exists_storage(key) } - fn exists_child_storage(&self, storage_key: &[u8], key: &[u8]) -> Result { - self.state.exists_child_storage(storage_key, key) + fn exists_child_storage( + &self, + storage_key: &[u8], + child_info: ChildInfo, + key: &[u8], + ) -> Result { + self.state.exists_child_storage(storage_key, child_info, key) } fn next_storage_key(&self, key: &[u8]) -> Result>, Self::Error> { self.state.next_storage_key(key) } - fn next_child_storage_key(&self, storage_key: &[u8], key: &[u8]) -> Result>, Self::Error> { - self.state.next_child_storage_key(storage_key, key) + fn next_child_storage_key( + &self, + storage_key: &[u8], + child_info: ChildInfo, + key: &[u8], + ) -> Result>, Self::Error> { + self.state.next_child_storage_key(storage_key, child_info, key) } fn for_keys_with_prefix(&self, prefix: &[u8], f: F) { @@ -167,12 +182,23 @@ impl StateBackend for RefTrackingState { self.state.for_key_values_with_prefix(prefix, f) } - fn for_keys_in_child_storage(&self, storage_key: &[u8], f: F) { - self.state.for_keys_in_child_storage(storage_key, f) + fn for_keys_in_child_storage( + &self, + storage_key: &[u8], + child_info: ChildInfo, + f: F, + ) { + self.state.for_keys_in_child_storage(storage_key, child_info, f) } - fn for_child_keys_with_prefix(&self, storage_key: &[u8], prefix: &[u8], f: F) { - self.state.for_child_keys_with_prefix(storage_key, prefix, f) + fn for_child_keys_with_prefix( + &self, + storage_key: &[u8], + child_info: ChildInfo, + prefix: &[u8], + f: F, + ) { + self.state.for_child_keys_with_prefix(storage_key, child_info, prefix, f) } fn storage_root(&self, delta: I) -> (H256, Self::Transaction) @@ -182,11 +208,16 @@ impl StateBackend for RefTrackingState { self.state.storage_root(delta) } - fn child_storage_root(&self, storage_key: &[u8], delta: I) -> (H256, bool, Self::Transaction) + fn child_storage_root( + &self, + storage_key: &[u8], + child_info: ChildInfo, + delta: I, + ) -> (H256, bool, Self::Transaction) where I: IntoIterator, Option>)>, { - self.state.child_storage_root(storage_key, delta) + self.state.child_storage_root(storage_key, child_info, delta) } fn pairs(&self) -> Vec<(Vec, Vec)> { @@ -197,8 +228,13 @@ impl StateBackend for RefTrackingState { self.state.keys(prefix) } - fn child_keys(&self, child_key: &[u8], prefix: &[u8]) -> Vec> { - self.state.child_keys(child_key, prefix) + fn child_keys( + &self, + storage_key: &[u8], + child_info: ChildInfo, + prefix: &[u8], + ) -> Vec> { + self.state.child_keys(storage_key, child_info, prefix) } fn as_trie_backend( @@ -523,26 +559,26 @@ impl client_api::backend::BlockImportOperation fn reset_storage( &mut self, - top: StorageOverlay, - children: ChildrenStorageOverlay + storage: Storage, ) -> ClientResult { - if top.iter().any(|(k, _)| well_known_keys::is_child_storage_key(k)) { + if storage.top.iter().any(|(k, _)| well_known_keys::is_child_storage_key(k)) { return Err(sp_blockchain::Error::GenesisInvalid.into()); } - for child_key in children.keys() { + for child_key in storage.children.keys() { if !well_known_keys::is_child_storage_key(&child_key) { return Err(sp_blockchain::Error::GenesisInvalid.into()); } } - let child_delta = children.into_iter() - .map(|(storage_key, child_overlay)| - (storage_key, child_overlay.into_iter().map(|(k, v)| (k, Some(v))))); + let child_delta = storage.children.into_iter().map(|(storage_key, child_content)| ( + storage_key, + child_content.data.into_iter().map(|(k, v)| (k, Some(v))), child_content.child_info), + ); let (root, transaction) = self.old_state.full_storage_root( - top.into_iter().map(|(k, v)| (k, Some(v))), + storage.top.into_iter().map(|(k, v)| (k, Some(v))), child_delta ); @@ -903,7 +939,8 @@ impl> Backend { }; let mut op = inmem.begin_operation().unwrap(); op.set_block_data(header, body, justification, new_block_state).unwrap(); - op.update_db_storage(state.into_iter().map(|(k, v)| (None, k, Some(v))).collect()).unwrap(); + op.update_db_storage(vec![(None, state.into_iter().map(|(k, v)| (k, Some(v))).collect())]) + .unwrap(); inmem.commit_operation(op).unwrap(); } @@ -1711,7 +1748,10 @@ mod tests { ).0.into(); let hash = header.hash(); - op.reset_storage(storage.iter().cloned().collect(), Default::default()).unwrap(); + op.reset_storage(Storage { + top: storage.iter().cloned().collect(), + children: Default::default(), + }).unwrap(); op.set_block_data( header.clone(), Some(vec![]), @@ -1793,7 +1833,10 @@ mod tests { ).0.into(); let hash = header.hash(); - op.reset_storage(storage.iter().cloned().collect(), Default::default()).unwrap(); + op.reset_storage(Storage { + top: storage.iter().cloned().collect(), + children: Default::default(), + }).unwrap(); key = op.db_updates.insert(EMPTY_PREFIX, b"hello"); op.set_block_data( diff --git a/client/db/src/storage_cache.rs b/client/db/src/storage_cache.rs index 2b8e356d9c..9053491b17 100644 --- a/client/db/src/storage_cache.rs +++ b/client/db/src/storage_cache.rs @@ -23,6 +23,7 @@ use linked_hash_map::{LinkedHashMap, Entry}; use hash_db::Hasher; use sp_runtime::traits::{Block as BlockT, Header}; use primitives::hexdisplay::HexDisplay; +use primitives::storage::ChildInfo; use state_machine::{backend::Backend as StateBackend, TrieBackend}; use log::trace; use client_api::backend::{StorageCollection, ChildStorageCollection}; @@ -516,7 +517,12 @@ impl, B: BlockT> StateBackend for CachingState< Ok(hash) } - fn child_storage(&self, storage_key: &[u8], key: &[u8]) -> Result>, Self::Error> { + fn child_storage( + &self, + storage_key: &[u8], + child_info: ChildInfo, + key: &[u8], + ) -> Result>, Self::Error> { let key = (storage_key.to_vec(), key.to_vec()); let local_cache = self.cache.local_cache.upgradable_read(); if let Some(entry) = local_cache.child_storage.get(&key).cloned() { @@ -531,7 +537,7 @@ impl, B: BlockT> StateBackend for CachingState< } } trace!("Cache miss: {:?}", key); - let value = self.state.child_storage(storage_key, &key.1[..])?; + let value = self.state.child_storage(storage_key, child_info, &key.1[..])?; RwLockUpgradableReadGuard::upgrade(local_cache).child_storage.insert(key, value.clone()); Ok(value) } @@ -540,20 +546,35 @@ impl, B: BlockT> StateBackend for CachingState< Ok(self.storage(key)?.is_some()) } - fn exists_child_storage(&self, storage_key: &[u8], key: &[u8]) -> Result { - self.state.exists_child_storage(storage_key, key) + fn exists_child_storage( + &self, + storage_key: &[u8], + child_info: ChildInfo, + key: &[u8], + ) -> Result { + self.state.exists_child_storage(storage_key, child_info, key) } - fn next_storage_key(&self, key: &[u8]) -> Result>, Self::Error> { - self.state.next_storage_key(key) + fn for_keys_in_child_storage( + &self, + storage_key: &[u8], + child_info: ChildInfo, + f: F, + ) { + self.state.for_keys_in_child_storage(storage_key, child_info, f) } - fn next_child_storage_key(&self, storage_key: &[u8], key: &[u8]) -> Result>, Self::Error> { - self.state.next_child_storage_key(storage_key, key) + fn next_storage_key(&self, key: &[u8]) -> Result>, Self::Error> { + self.state.next_storage_key(key) } - fn for_keys_in_child_storage(&self, storage_key: &[u8], f: F) { - self.state.for_keys_in_child_storage(storage_key, f) + fn next_child_storage_key( + &self, + storage_key: &[u8], + child_info: ChildInfo, + key: &[u8], + ) -> Result>, Self::Error> { + self.state.next_child_storage_key(storage_key, child_info, key) } fn for_keys_with_prefix(&self, prefix: &[u8], f: F) { @@ -564,8 +585,14 @@ impl, B: BlockT> StateBackend for CachingState< self.state.for_key_values_with_prefix(prefix, f) } - fn for_child_keys_with_prefix(&self, storage_key: &[u8], prefix: &[u8], f: F) { - self.state.for_child_keys_with_prefix(storage_key, prefix, f) + fn for_child_keys_with_prefix( + &self, + storage_key: &[u8], + child_info: ChildInfo, + prefix: &[u8], + f: F, + ) { + self.state.for_child_keys_with_prefix(storage_key, child_info, prefix, f) } fn storage_root(&self, delta: I) -> (H::Out, Self::Transaction) @@ -576,12 +603,17 @@ impl, B: BlockT> StateBackend for CachingState< self.state.storage_root(delta) } - fn child_storage_root(&self, storage_key: &[u8], delta: I) -> (H::Out, bool, Self::Transaction) + fn child_storage_root( + &self, + storage_key: &[u8], + child_info: ChildInfo, + delta: I, + ) -> (H::Out, bool, Self::Transaction) where I: IntoIterator, Option>)>, H::Out: Ord { - self.state.child_storage_root(storage_key, delta) + self.state.child_storage_root(storage_key, child_info, delta) } fn pairs(&self) -> Vec<(Vec, Vec)> { @@ -592,8 +624,13 @@ impl, B: BlockT> StateBackend for CachingState< self.state.keys(prefix) } - fn child_keys(&self, child_key: &[u8], prefix: &[u8]) -> Vec> { - self.state.child_keys(child_key, prefix) + fn child_keys( + &self, + storage_key: &[u8], + child_info: ChildInfo, + prefix: &[u8], + ) -> Vec> { + self.state.child_keys(storage_key, child_info, prefix) } fn as_trie_backend(&mut self) -> Option<&TrieBackend> { diff --git a/client/executor/src/deprecated_host_interface.rs b/client/executor/src/deprecated_host_interface.rs index 7ea3687bb9..f585659d9e 100644 --- a/client/executor/src/deprecated_host_interface.rs +++ b/client/executor/src/deprecated_host_interface.rs @@ -217,38 +217,6 @@ impl_wasm_host_interface! { Ok(sp_io::storage::set(&key, &value)) } - ext_set_child_storage( - storage_key_data: Pointer, - storage_key_len: WordSize, - key_data: Pointer, - key_len: WordSize, - value_data: Pointer, - value_len: WordSize, - ) { - let storage_key = context.read_memory(storage_key_data, storage_key_len) - .map_err(|_| "Invalid attempt to determine storage_key in ext_set_child_storage")?; - let key = context.read_memory(key_data, key_len) - .map_err(|_| "Invalid attempt to determine key in ext_set_child_storage")?; - let value = context.read_memory(value_data, value_len) - .map_err(|_| "Invalid attempt to determine value in ext_set_child_storage")?; - - Ok(sp_io::storage::child_set(&storage_key, &key, &value)) - } - - ext_clear_child_storage( - storage_key_data: Pointer, - storage_key_len: WordSize, - key_data: Pointer, - 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_clear_child_storage")?; - let key = context.read_memory(key_data, key_len) - .map_err(|_| "Invalid attempt to determine key in ext_clear_child_storage")?; - - 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")?; @@ -261,45 +229,12 @@ impl_wasm_host_interface! { Ok(if sp_io::storage::exists(&key) { 1 } else { 0 }) } - ext_exists_child_storage( - storage_key_data: Pointer, - storage_key_len: WordSize, - key_data: Pointer, - key_len: WordSize, - ) -> u32 { - let storage_key = context.read_memory(storage_key_data, storage_key_len) - .map_err(|_| "Invalid attempt to determine storage_key in ext_exists_child_storage")?; - let key = context.read_memory(key_data, key_len) - .map_err(|_| "Invalid attempt to determine key in ext_exists_child_storage")?; - - 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(sp_io::storage::clear_prefix(&prefix)) } - ext_clear_child_prefix( - storage_key_data: Pointer, - storage_key_len: WordSize, - prefix_data: Pointer, - prefix_len: WordSize, - ) { - let storage_key = context.read_memory(storage_key_data, storage_key_len) - .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(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(sp_io::storage::child_storage_kill(&storage_key)) - } - ext_get_allocated_storage( key_data: Pointer, key_len: WordSize, @@ -322,32 +257,6 @@ impl_wasm_host_interface! { } } - ext_get_allocated_child_storage( - storage_key_data: Pointer, - storage_key_len: WordSize, - key_data: Pointer, - key_len: WordSize, - written_out: Pointer, - ) -> Pointer { - let storage_key = context.read_memory(storage_key_data, storage_key_len) - .map_err(|_| "Invalid attempt to determine storage_key in ext_get_allocated_child_storage")?; - 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) = 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")?; - context.write_primitive(written_out, value.len() as u32) - .map_err(|_| "Invalid attempt to write written_out in ext_get_allocated_child_storage")?; - Ok(offset) - } else { - context.write_primitive(written_out, u32::max_value()) - .map_err(|_| "Invalid attempt to write failed written_out in ext_get_allocated_child_storage")?; - Ok(Pointer::null()) - } - } - ext_get_storage_into( key_data: Pointer, key_len: WordSize, @@ -369,53 +278,11 @@ impl_wasm_host_interface! { } } - ext_get_child_storage_into( - storage_key_data: Pointer, - storage_key_len: WordSize, - key_data: Pointer, - key_len: WordSize, - value_data: Pointer, - value_len: WordSize, - value_offset: WordSize, - ) -> WordSize { - let storage_key = context.read_memory(storage_key_data, storage_key_len) - .map_err(|_| "Invalid attempt to determine storage_key in ext_get_child_storage_into")?; - 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) = 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]) - .map_err(|_| "Invalid attempt to get value in ext_get_child_storage_into")?; - Ok(value.len() as u32) - } else { - Ok(u32::max_value()) - } - } - ext_storage_root(result: Pointer) { context.write_memory(result, sp_io::storage::root().as_ref()) .map_err(|_| "Invalid attempt to set memory in ext_storage_root".into()) } - ext_child_storage_root( - storage_key_data: Pointer, - storage_key_len: WordSize, - written_out: Pointer, - ) -> 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 = sp_io::storage::child_root(&storage_key); - - let offset = context.allocate_memory(value.len() as u32)?; - context.write_memory(offset, &value) - .map_err(|_| "Invalid attempt to set memory in ext_child_storage_root")?; - context.write_primitive(written_out, value.len() as u32) - .map_err(|_| "Invalid attempt to write written_out in ext_child_storage_root")?; - Ok(offset) - } - ext_storage_changes_root( parent_hash_data: Pointer, _len: WordSize, diff --git a/client/executor/src/integration_tests/mod.rs b/client/executor/src/integration_tests/mod.rs index 3cdb9fdafe..f02b532619 100644 --- a/client/executor/src/integration_tests/mod.rs +++ b/client/executor/src/integration_tests/mod.rs @@ -128,11 +128,14 @@ fn storage_should_work(wasm_method: WasmExecutionMethod) { assert_eq!(output, b"all ok!".to_vec().encode()); } - let expected = TestExternalities::new((map![ + let expected = TestExternalities::new(primitives::storage::Storage { + top: map![ b"input".to_vec() => b"Hello world".to_vec(), b"foo".to_vec() => b"bar".to_vec(), b"baz".to_vec() => b"bar".to_vec() - ], map![])); + ], + children: map![], + }); assert_eq!(ext, expected); } @@ -162,11 +165,14 @@ fn clear_prefix_should_work(wasm_method: WasmExecutionMethod) { assert_eq!(output, b"all ok!".to_vec().encode()); } - let expected = TestExternalities::new((map![ + let expected = TestExternalities::new(primitives::storage::Storage { + top: map![ b"aaa".to_vec() => b"1".to_vec(), b"aab".to_vec() => b"2".to_vec(), b"bbb".to_vec() => b"5".to_vec() - ], map![])); + ], + children: map![], + }); assert_eq!(expected, ext); } diff --git a/client/finality-grandpa/src/tests.rs b/client/finality-grandpa/src/tests.rs index a63ce2a7f6..68512a9853 100644 --- a/client/finality-grandpa/src/tests.rs +++ b/client/finality-grandpa/src/tests.rs @@ -291,7 +291,7 @@ impl AuthoritySetForFinalityProver for TestApi { fn prove_authorities(&self, block: &BlockId) -> Result { let authorities = self.authorities(block)?; let backend = >::from(vec![ - (None, b"authorities".to_vec(), Some(authorities.encode())) + (None, vec![(b"authorities".to_vec(), Some(authorities.encode()))]) ]); let proof = prove_read(backend, vec![b"authorities"]) .expect("failure proving read from in-memory storage backend"); diff --git a/client/network/src/chain.rs b/client/network/src/chain.rs index 671bdb27ca..59fd15bbf1 100644 --- a/client/network/src/chain.rs +++ b/client/network/src/chain.rs @@ -23,7 +23,8 @@ use consensus::{BlockImport, BlockStatus, Error as ConsensusError}; use sp_runtime::traits::{Block as BlockT, Header as HeaderT}; use sp_runtime::generic::{BlockId}; use sp_runtime::Justification; -use primitives::{H256, Blake2Hasher, storage::StorageKey}; +use primitives::{H256, Blake2Hasher}; +use primitives::storage::{StorageKey, ChildInfo}; /// Local client abstraction for the network. pub trait Client: Send + Sync { @@ -57,6 +58,7 @@ pub trait Client: Send + Sync { &self, block: &Block::Hash, storage_key: &[u8], + child_info: ChildInfo, keys: &[Vec], ) -> Result; @@ -135,10 +137,11 @@ impl Client for SubstrateClient where &self, block: &Block::Hash, storage_key: &[u8], + child_info: ChildInfo, keys: &[Vec], ) -> Result { (self as &SubstrateClient) - .read_child_proof(&BlockId::Hash(block.clone()), storage_key, keys) + .read_child_proof(&BlockId::Hash(block.clone()), storage_key, child_info, keys) } fn execution_proof(&self, block: &Block::Hash, method: &str, data: &[u8]) -> Result<(Vec, StorageProof), Error> { diff --git a/client/network/src/protocol.rs b/client/network/src/protocol.rs index 87dd1be4ec..d4283d588c 100644 --- a/client/network/src/protocol.rs +++ b/client/network/src/protocol.rs @@ -24,7 +24,7 @@ use libp2p::{Multiaddr, PeerId}; use libp2p::core::{ConnectedPoint, nodes::Substream, muxing::StreamMuxerBox}; use libp2p::swarm::{ProtocolsHandler, IntoProtocolsHandler}; use libp2p::swarm::{NetworkBehaviour, NetworkBehaviourAction, PollParameters}; -use primitives::storage::StorageKey; +use primitives::storage::{StorageKey, ChildInfo}; use consensus::{ BlockOrigin, block_validation::BlockAnnounceValidator, @@ -238,12 +238,16 @@ impl<'a, B: BlockT> LightDispatchNetwork for LightDispatchIn<'a> { id: RequestId, block: ::Hash, storage_key: Vec, + child_info: Vec, + child_type: u32, keys: Vec>, ) { let message: Message = message::generic::Message::RemoteReadChildRequest(message::RemoteReadChildRequest { id, block, storage_key, + child_info, + child_type, keys, }); @@ -1554,23 +1558,37 @@ impl, H: ExHashT> Protocol { trace!(target: "sync", "Remote read child request {} from {} ({} {} at {})", request.id, who, request.storage_key.to_hex::(), keys_str(), request.block); - let proof = match self.context_data.chain.read_child_proof( - &request.block, - &request.storage_key, - &request.keys, - ) { - Ok(proof) => proof, - Err(error) => { - trace!(target: "sync", "Remote read child request {} from {} ({} {} at {}) failed with: {}", - request.id, - who, - request.storage_key.to_hex::(), - keys_str(), - request.block, - error - ); - StorageProof::empty() + let proof = if let Some(child_info) = ChildInfo::resolve_child_info(request.child_type, &request.child_info[..]) { + match self.context_data.chain.read_child_proof( + &request.block, + &request.storage_key, + child_info, + &request.keys, + ) { + Ok(proof) => proof, + Err(error) => { + trace!(target: "sync", "Remote read child request {} from {} ({} {} at {}) failed with: {}", + request.id, + who, + request.storage_key.to_hex::(), + keys_str(), + request.block, + error + ); + StorageProof::empty() + } } + } else { + trace!(target: "sync", "Remote read child request {} from {} ({} {} at {}) failed with: {}", + request.id, + who, + request.storage_key.to_hex::(), + keys_str(), + request.block, + "invalid child info and type", + ); + + StorageProof::empty() }; self.send_message( &who, diff --git a/client/network/src/protocol/light_dispatch.rs b/client/network/src/protocol/light_dispatch.rs index 869fd703ca..047961250f 100644 --- a/client/network/src/protocol/light_dispatch.rs +++ b/client/network/src/protocol/light_dispatch.rs @@ -69,6 +69,8 @@ pub trait LightDispatchNetwork { id: RequestId, block: ::Hash, storage_key: Vec, + child_info: Vec, + child_type: u32, keys: Vec>, ); @@ -622,6 +624,8 @@ impl Request { self.id, data.block, data.storage_key.clone(), + data.child_info.clone(), + data.child_type, data.keys.clone(), ), RequestData::RemoteCall(ref data, _) => @@ -677,6 +681,7 @@ pub mod tests { use std::sync::Arc; use std::time::Instant; use futures::{Future, sync::oneshot}; + use primitives::storage::ChildInfo; use sp_runtime::traits::{Block as BlockT, NumberFor, Header as HeaderT}; use sp_blockchain::{Error as ClientError, Result as ClientResult}; use client_api::{FetchChecker, RemoteHeaderRequest, @@ -808,7 +813,7 @@ pub mod tests { fn send_header_request(&mut self, _: &PeerId, _: RequestId, _: <::Header as HeaderT>::Number) {} fn send_read_request(&mut self, _: &PeerId, _: RequestId, _: ::Hash, _: Vec>) {} fn send_read_child_request(&mut self, _: &PeerId, _: RequestId, _: ::Hash, _: Vec, - _: Vec>) {} + _: Vec, _: u32, _: Vec>) {} fn send_call_request(&mut self, _: &PeerId, _: RequestId, _: ::Hash, _: String, _: Vec) {} fn send_changes_request(&mut self, _: &PeerId, _: RequestId, _: ::Hash, _: ::Hash, _: ::Hash, _: ::Hash, _: Option>, _: Vec) {} @@ -1027,10 +1032,14 @@ pub mod tests { light_dispatch.on_connect(&mut network_interface, peer0.clone(), Roles::FULL, 1000); let (tx, response) = oneshot::channel(); + let child_info = ChildInfo::new_default(b"unique_id_1"); + let (child_info, child_type) = child_info.info(); light_dispatch.add_request(&mut network_interface, RequestData::RemoteReadChild(RemoteReadChildRequest { header: dummy_header(), block: Default::default(), storage_key: b":child_storage:sub".to_vec(), + child_info: child_info.to_vec(), + child_type, keys: vec![b":key".to_vec()], retry_count: None, }, tx)); diff --git a/client/network/src/protocol/message.rs b/client/network/src/protocol/message.rs index a05a254f16..b7267f376f 100644 --- a/client/network/src/protocol/message.rs +++ b/client/network/src/protocol/message.rs @@ -368,6 +368,11 @@ pub mod generic { pub block: H, /// Child Storage key. pub storage_key: Vec, + /// Child trie source information. + pub child_info: Vec, + /// Child type, its required to resolve `child_info` + /// content and choose child implementation. + pub child_type: u32, /// Storage key. pub keys: Vec>, } diff --git a/client/rpc-api/src/state/mod.rs b/client/rpc-api/src/state/mod.rs index 0d06092ca1..9a549b00c4 100644 --- a/client/rpc-api/src/state/mod.rs +++ b/client/rpc-api/src/state/mod.rs @@ -60,6 +60,8 @@ pub trait StateApi { fn child_storage_keys( &self, child_storage_key: StorageKey, + child_info: StorageKey, + child_type: u32, prefix: StorageKey, hash: Option ) -> FutureResult>; @@ -69,6 +71,8 @@ pub trait StateApi { fn child_storage( &self, child_storage_key: StorageKey, + child_info: StorageKey, + child_type: u32, key: StorageKey, hash: Option ) -> FutureResult>; @@ -78,6 +82,8 @@ pub trait StateApi { fn child_storage_hash( &self, child_storage_key: StorageKey, + child_info: StorageKey, + child_type: u32, key: StorageKey, hash: Option ) -> FutureResult>; @@ -87,6 +93,8 @@ pub trait StateApi { fn child_storage_size( &self, child_storage_key: StorageKey, + child_info: StorageKey, + child_type: u32, key: StorageKey, hash: Option ) -> FutureResult>; diff --git a/client/rpc/src/state/mod.rs b/client/rpc/src/state/mod.rs index df9a6709b9..53aabaf699 100644 --- a/client/rpc/src/state/mod.rs +++ b/client/rpc/src/state/mod.rs @@ -95,6 +95,8 @@ pub trait StateBackend: Send + Sync + 'static &self, block: Option, child_storage_key: StorageKey, + child_info: StorageKey, + child_type: u32, prefix: StorageKey, ) -> FutureResult>; @@ -103,6 +105,8 @@ pub trait StateBackend: Send + Sync + 'static &self, block: Option, child_storage_key: StorageKey, + child_info: StorageKey, + child_type: u32, key: StorageKey, ) -> FutureResult>; @@ -111,6 +115,8 @@ pub trait StateBackend: Send + Sync + 'static &self, block: Option, child_storage_key: StorageKey, + child_info: StorageKey, + child_type: u32, key: StorageKey, ) -> FutureResult>; @@ -119,9 +125,11 @@ pub trait StateBackend: Send + Sync + 'static &self, block: Option, child_storage_key: StorageKey, + child_info: StorageKey, + child_type: u32, key: StorageKey, ) -> FutureResult> { - Box::new(self.child_storage(block, child_storage_key, key) + Box::new(self.child_storage(block, child_storage_key, child_info, child_type, key) .map(|x| x.map(|x| x.0.len() as u64))) } @@ -256,37 +264,45 @@ impl StateApi for State fn child_storage( &self, child_storage_key: StorageKey, + child_info: StorageKey, + child_type: u32, key: StorageKey, block: Option ) -> FutureResult> { - self.backend.child_storage(block, child_storage_key, key) + self.backend.child_storage(block, child_storage_key, child_info, child_type, key) } fn child_storage_keys( &self, child_storage_key: StorageKey, + child_info: StorageKey, + child_type: u32, key_prefix: StorageKey, block: Option ) -> FutureResult> { - self.backend.child_storage_keys(block, child_storage_key, key_prefix) + self.backend.child_storage_keys(block, child_storage_key, child_info, child_type, key_prefix) } fn child_storage_hash( &self, child_storage_key: StorageKey, + child_info: StorageKey, + child_type: u32, key: StorageKey, block: Option ) -> FutureResult> { - self.backend.child_storage_hash(block, child_storage_key, key) + self.backend.child_storage_hash(block, child_storage_key, child_info, child_type, key) } fn child_storage_size( &self, child_storage_key: StorageKey, + child_info: StorageKey, + child_type: u32, key: StorageKey, block: Option ) -> FutureResult> { - self.backend.child_storage_size(block, child_storage_key, key) + self.backend.child_storage_size(block, child_storage_key, child_info, child_type, key) } fn metadata(&self, block: Option) -> FutureResult { @@ -335,3 +351,9 @@ impl StateApi for State fn client_err(err: sp_blockchain::Error) -> Error { Error::Client(Box::new(err)) } + +const CHILD_RESOLUTION_ERROR: &str = "Unexpected child info and type"; + +fn child_resolution_error() -> sp_blockchain::Error { + sp_blockchain::Error::Msg(CHILD_RESOLUTION_ERROR.to_string()) +} diff --git a/client/rpc/src/state/state_full.rs b/client/rpc/src/state/state_full.rs index 582d3a0e7e..d5de8d6441 100644 --- a/client/rpc/src/state/state_full.rs +++ b/client/rpc/src/state/state_full.rs @@ -36,7 +36,8 @@ use client::{ Client, CallExecutor, BlockchainEvents, }; use primitives::{ - H256, Blake2Hasher, Bytes, storage::{well_known_keys, StorageKey, StorageData, StorageChangeSet}, + H256, Blake2Hasher, Bytes, + storage::{well_known_keys, StorageKey, StorageData, StorageChangeSet, ChildInfo}, }; use runtime_version::RuntimeVersion; use state_machine::ExecutionStrategy; @@ -47,7 +48,7 @@ use sp_runtime::{ use sp_api::Metadata; -use super::{StateBackend, error::{FutureResult, Error, Result}, client_err}; +use super::{StateBackend, error::{FutureResult, Error, Result}, client_err, child_resolution_error}; /// Ranges to query in state_queryStorage. struct QueryStorageRange { @@ -287,11 +288,19 @@ impl StateBackend for FullState, child_storage_key: StorageKey, + child_info: StorageKey, + child_type: u32, prefix: StorageKey, ) -> FutureResult> { Box::new(result( self.block_or_best(block) - .and_then(|block| self.client.child_storage_keys(&BlockId::Hash(block), &child_storage_key, &prefix)) + .and_then(|block| self.client.child_storage_keys( + &BlockId::Hash(block), + &child_storage_key, + ChildInfo::resolve_child_info(child_type, &child_info.0[..]) + .ok_or_else(child_resolution_error)?, + &prefix, + )) .map_err(client_err))) } @@ -299,11 +308,19 @@ impl StateBackend for FullState, child_storage_key: StorageKey, + child_info: StorageKey, + child_type: u32, key: StorageKey, ) -> FutureResult> { Box::new(result( self.block_or_best(block) - .and_then(|block| self.client.child_storage(&BlockId::Hash(block), &child_storage_key, &key)) + .and_then(|block| self.client.child_storage( + &BlockId::Hash(block), + &child_storage_key, + ChildInfo::resolve_child_info(child_type, &child_info.0[..]) + .ok_or_else(child_resolution_error)?, + &key, + )) .map_err(client_err))) } @@ -311,11 +328,19 @@ impl StateBackend for FullState, child_storage_key: StorageKey, + child_info: StorageKey, + child_type: u32, key: StorageKey, ) -> FutureResult> { Box::new(result( self.block_or_best(block) - .and_then(|block| self.client.child_storage_hash(&BlockId::Hash(block), &child_storage_key, &key)) + .and_then(|block| self.client.child_storage_hash( + &BlockId::Hash(block), + &child_storage_key, + ChildInfo::resolve_child_info(child_type, &child_info.0[..]) + .ok_or_else(child_resolution_error)?, + &key, + )) .map_err(client_err))) } diff --git a/client/rpc/src/state/state_light.rs b/client/rpc/src/state/state_light.rs index 62d3404d8e..d90ef02c3d 100644 --- a/client/rpc/src/state/state_light.rs +++ b/client/rpc/src/state/state_light.rs @@ -236,6 +236,8 @@ impl StateBackend for LightState, _child_storage_key: StorageKey, + _child_info: StorageKey, + _child_type: u32, _prefix: StorageKey, ) -> FutureResult> { Box::new(result(Err(client_err(ClientError::NotAvailableOnLightClient)))) @@ -245,6 +247,8 @@ impl StateBackend for LightState, child_storage_key: StorageKey, + child_info: StorageKey, + child_type: u32, key: StorageKey, ) -> FutureResult> { let block = self.block_or_best(block); @@ -255,6 +259,8 @@ impl StateBackend for LightState StateBackend for LightState, child_storage_key: StorageKey, + child_info: StorageKey, + child_type: u32, key: StorageKey, ) -> FutureResult> { Box::new(self - .child_storage(block, child_storage_key, key) + .child_storage(block, child_storage_key, child_info, child_type, key) .and_then(|maybe_storage| result(Ok(maybe_storage.map(|storage| Blake2Hasher::hash(&storage.0)))) ) diff --git a/client/rpc/src/state/tests.rs b/client/rpc/src/state/tests.rs index 2ae22df1a0..c0f09fafeb 100644 --- a/client/rpc/src/state/tests.rs +++ b/client/rpc/src/state/tests.rs @@ -21,7 +21,7 @@ use self::error::Error; use std::sync::Arc; use assert_matches::assert_matches; use futures01::stream::Stream; -use primitives::storage::well_known_keys; +use primitives::storage::{well_known_keys, ChildInfo}; use primitives::hash::H256; use sp_io::hashing::blake2_256; use test_client::{ @@ -30,6 +30,8 @@ use test_client::{ runtime, }; +const CHILD_INFO: ChildInfo<'static> = ChildInfo::new_default(b"unique_id"); + #[test] fn should_return_storage() { const KEY: &[u8] = b":mock"; @@ -40,12 +42,14 @@ fn should_return_storage() { let mut core = tokio::runtime::Runtime::new().unwrap(); let client = TestClientBuilder::new() .add_extra_storage(KEY.to_vec(), VALUE.to_vec()) - .add_extra_child_storage(STORAGE_KEY.to_vec(), KEY.to_vec(), CHILD_VALUE.to_vec()) + .add_extra_child_storage(STORAGE_KEY.to_vec(), CHILD_INFO, KEY.to_vec(), CHILD_VALUE.to_vec()) .build(); let genesis_hash = client.genesis_hash(); let client = new_full(Arc::new(client), Subscriptions::new(Arc::new(core.executor()))); let key = StorageKey(KEY.to_vec()); let storage_key = StorageKey(STORAGE_KEY.to_vec()); + let (child_info, child_type) = CHILD_INFO.info(); + let child_info = StorageKey(child_info.to_vec()); assert_eq!( client.storage(key.clone(), Some(genesis_hash).into()).wait() @@ -63,7 +67,7 @@ fn should_return_storage() { ); assert_eq!( core.block_on( - client.child_storage(storage_key, key, Some(genesis_hash).into()) + client.child_storage(storage_key, child_info, child_type, key, Some(genesis_hash).into()) .map(|x| x.map(|x| x.0.len())) ).unwrap().unwrap() as usize, CHILD_VALUE.len(), @@ -73,27 +77,48 @@ fn should_return_storage() { #[test] fn should_return_child_storage() { + let (child_info, child_type) = CHILD_INFO.info(); + let child_info = StorageKey(child_info.to_vec()); let core = tokio::runtime::Runtime::new().unwrap(); let client = Arc::new(test_client::TestClientBuilder::new() - .add_child_storage("test", "key", vec![42_u8]) + .add_child_storage("test", "key", CHILD_INFO, vec![42_u8]) .build()); let genesis_hash = client.genesis_hash(); let client = new_full(client, Subscriptions::new(Arc::new(core.executor()))); - let child_key = StorageKey(well_known_keys::CHILD_STORAGE_KEY_PREFIX.iter().chain(b"test").cloned().collect()); + let child_key = StorageKey( + well_known_keys::CHILD_STORAGE_KEY_PREFIX.iter().chain(b"test").cloned().collect() + ); let key = StorageKey(b"key".to_vec()); assert_matches!( - client.child_storage(child_key.clone(), key.clone(), Some(genesis_hash).into()).wait(), + client.child_storage( + child_key.clone(), + child_info.clone(), + child_type, + key.clone(), + Some(genesis_hash).into(), + ).wait(), Ok(Some(StorageData(ref d))) if d[0] == 42 && d.len() == 1 ); assert_matches!( - client.child_storage_hash(child_key.clone(), key.clone(), Some(genesis_hash).into()) - .wait().map(|x| x.is_some()), + client.child_storage_hash( + child_key.clone(), + child_info.clone(), + child_type, + key.clone(), + Some(genesis_hash).into(), + ).wait().map(|x| x.is_some()), Ok(true) ); assert_matches!( - client.child_storage_size(child_key.clone(), key.clone(), None).wait(), + client.child_storage_size( + child_key.clone(), + child_info.clone(), + child_type, + key.clone(), + None, + ).wait(), Ok(Some(1)) ); } diff --git a/client/src/cht.rs b/client/src/cht.rs index 15a3b7718c..389560223a 100644 --- a/client/src/cht.rs +++ b/client/src/cht.rs @@ -98,9 +98,9 @@ pub fn build_proof( { let transaction = build_pairs::(cht_size, cht_num, hashes)? .into_iter() - .map(|(k, v)| (None, k, Some(v))) + .map(|(k, v)| (k, Some(v))) .collect::>(); - let mut storage = InMemoryState::::default().update(transaction); + let mut storage = InMemoryState::::default().update(vec![(None, transaction)]); let trie_storage = storage.as_trie_backend() .expect("InMemoryState::as_trie_backend always returns Some; qed"); prove_read_on_trie_backend( diff --git a/client/src/client.rs b/client/src/client.rs index 88ecfecd21..fe3dfbead3 100644 --- a/client/src/client.rs +++ b/client/src/client.rs @@ -28,7 +28,7 @@ use hash_db::{Hasher, Prefix}; use primitives::{ Blake2Hasher, H256, ChangesTrieConfiguration, convert_hash, NeverNativeValue, ExecutionContext, NativeOrEncoded, - storage::{StorageKey, StorageData, well_known_keys}, + storage::{StorageKey, StorageData, well_known_keys, ChildInfo}, traits::CodeExecutor, }; use sc_telemetry::{telemetry, SUBSTRATE_INFO}; @@ -199,10 +199,10 @@ impl Client where execution_extensions: ExecutionExtensions, ) -> sp_blockchain::Result { if backend.blockchain().header(BlockId::Number(Zero::zero()))?.is_none() { - let (genesis_storage, children_genesis_storage) = build_genesis_storage.build_storage()?; + let genesis_storage = build_genesis_storage.build_storage()?; let mut op = backend.begin_operation()?; backend.begin_state_operation(&mut op, BlockId::Hash(Default::default()))?; - let state_root = op.reset_storage(genesis_storage, children_genesis_storage)?; + let state_root = op.reset_storage(genesis_storage)?; let genesis_block = genesis::construct_genesis_block::(state_root.into()); info!("Initializing Genesis block/state (state: {}, header-hash: {})", genesis_block.header().state_root(), @@ -267,10 +267,11 @@ impl Client where &self, id: &BlockId, child_storage_key: &StorageKey, + child_info: ChildInfo, key_prefix: &StorageKey ) -> sp_blockchain::Result> { let keys = self.state_at(id)? - .child_keys(&child_storage_key.0, &key_prefix.0) + .child_keys(&child_storage_key.0, child_info, &key_prefix.0) .into_iter() .map(StorageKey) .collect(); @@ -281,11 +282,13 @@ impl Client where pub fn child_storage( &self, id: &BlockId, - child_storage_key: &StorageKey, + storage_key: &StorageKey, + child_info: ChildInfo, key: &StorageKey ) -> sp_blockchain::Result> { Ok(self.state_at(id)? - .child_storage(&child_storage_key.0, &key.0).map_err(|e| sp_blockchain::Error::from_state(Box::new(e)))? + .child_storage(&storage_key.0, child_info, &key.0) + .map_err(|e| sp_blockchain::Error::from_state(Box::new(e)))? .map(StorageData)) } @@ -293,11 +296,13 @@ impl Client where pub fn child_storage_hash( &self, id: &BlockId, - child_storage_key: &StorageKey, + storage_key: &StorageKey, + child_info: ChildInfo, key: &StorageKey ) -> sp_blockchain::Result> { Ok(self.state_at(id)? - .child_storage_hash(&child_storage_key.0, &key.0).map_err(|e| sp_blockchain::Error::from_state(Box::new(e)))? + .child_storage_hash(&storage_key.0, child_info, &key.0) + .map_err(|e| sp_blockchain::Error::from_state(Box::new(e)))? ) } @@ -334,13 +339,14 @@ impl Client where &self, id: &BlockId, storage_key: &[u8], + child_info: ChildInfo, keys: I, ) -> sp_blockchain::Result where I: IntoIterator, I::Item: AsRef<[u8]>, { self.state_at(id) - .and_then(|state| prove_child_read(state, storage_key, keys) + .and_then(|state| prove_child_read(state, storage_key, child_info, keys) .map_err(Into::into)) } @@ -1012,7 +1018,7 @@ impl Client where overlay.commit_prospective(); let (top, children) = overlay.into_committed(); - let children = children.map(|(sk, it)| (sk, it.collect())).collect(); + let children = children.map(|(sk, it)| (sk, it.0.collect())).collect(); if import_headers.post().state_root() != &storage_update.1 { return Err(sp_blockchain::Error::InvalidStateRoot); } diff --git a/client/src/genesis.rs b/client/src/genesis.rs index d274316742..a080a87cf4 100644 --- a/client/src/genesis.rs +++ b/client/src/genesis.rs @@ -53,7 +53,7 @@ mod tests { runtime::{Hash, Transfer, Block, BlockNumber, Header, Digest}, AccountKeyring, Sr25519Keyring, }; - use primitives::{Blake2Hasher, map}; + use primitives::Blake2Hasher; use hex_literal::*; native_executor_instance!( @@ -154,8 +154,7 @@ mod tests { vec![AccountKeyring::One.into(), AccountKeyring::Two.into()], 1000, None, - map![], - map![], + Default::default(), ).genesis_map(); let genesis_hash = insert_genesis_block(&mut storage); @@ -183,8 +182,7 @@ mod tests { vec![AccountKeyring::One.into(), AccountKeyring::Two.into()], 1000, None, - map![], - map![], + Default::default(), ).genesis_map(); let genesis_hash = insert_genesis_block(&mut storage); @@ -212,8 +210,7 @@ mod tests { vec![AccountKeyring::One.into(), AccountKeyring::Two.into()], 68, None, - map![], - map![], + Default::default(), ).genesis_map(); let genesis_hash = insert_genesis_block(&mut storage); diff --git a/client/src/in_mem.rs b/client/src/in_mem.rs index e5964669c9..85bdd954c8 100644 --- a/client/src/in_mem.rs +++ b/client/src/in_mem.rs @@ -25,7 +25,7 @@ use primitives::offchain::storage::{ }; use sp_runtime::generic::{BlockId, DigestItem}; use sp_runtime::traits::{Block as BlockT, Header as HeaderT, Zero, NumberFor}; -use sp_runtime::{Justification, StorageOverlay, ChildrenStorageOverlay}; +use sp_runtime::{Justification, Storage}; use state_machine::backend::{Backend as StateBackend, InMemory}; use state_machine::{self, InMemoryChangesTrieStorage, ChangesTrieAnchorBlockId, ChangesTrieTransaction}; use hash_db::{Hasher, Prefix}; @@ -505,15 +505,15 @@ where Ok(()) } - fn reset_storage(&mut self, top: StorageOverlay, children: ChildrenStorageOverlay) -> sp_blockchain::Result { - check_genesis_storage(&top, &children)?; + fn reset_storage(&mut self, storage: Storage) -> sp_blockchain::Result { + check_genesis_storage(&storage)?; - let child_delta = children.into_iter() - .map(|(storage_key, child_overlay)| - (storage_key, child_overlay.into_iter().map(|(k, v)| (k, Some(v))))); + let child_delta = storage.children.into_iter() + .map(|(storage_key, child_content)| + (storage_key, child_content.data.into_iter().map(|(k, v)| (k, Some(v))), child_content.child_info)); let (root, transaction) = self.old_state.full_storage_root( - top.into_iter().map(|(k, v)| (k, Some(v))), + storage.top.into_iter().map(|(k, v)| (k, Some(v))), child_delta ); @@ -796,12 +796,12 @@ impl state_machine::ChangesTrieStorage> for Change } /// Check that genesis storage is valid. -pub fn check_genesis_storage(top: &StorageOverlay, children: &ChildrenStorageOverlay) -> sp_blockchain::Result<()> { - if top.iter().any(|(k, _)| well_known_keys::is_child_storage_key(k)) { +pub fn check_genesis_storage(storage: &Storage) -> sp_blockchain::Result<()> { + if storage.top.iter().any(|(k, _)| well_known_keys::is_child_storage_key(k)) { return Err(sp_blockchain::Error::GenesisInvalid.into()); } - if children.keys().any(|child_key| !well_known_keys::is_child_storage_key(&child_key)) { + if storage.children.keys().any(|child_key| !well_known_keys::is_child_storage_key(&child_key)) { return Err(sp_blockchain::Error::GenesisInvalid.into()); } diff --git a/client/src/lib.rs b/client/src/lib.rs index 00a0d8c269..364733f1a4 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -48,7 +48,7 @@ //! use std::sync::Arc; //! use sc_client::{Client, in_mem::Backend, LocalCallExecutor}; //! use primitives::Blake2Hasher; -//! use sp_runtime::{StorageOverlay, ChildrenStorageOverlay}; +//! use sp_runtime::Storage; //! use executor::{NativeExecutor, WasmExecutionMethod}; //! //! // In this example, we're using the `Block` and `RuntimeApi` types from the @@ -65,7 +65,7 @@ //! NativeExecutor::::new(WasmExecutionMethod::Interpreted, None), //! ), //! // This parameter provides the storage for the chain genesis. -//! <(StorageOverlay, ChildrenStorageOverlay)>::default(), +//! ::default(), //! Default::default(), //! Default::default(), //! ); diff --git a/client/src/light/backend.rs b/client/src/light/backend.rs index 0d974411a9..5f770394fc 100644 --- a/client/src/light/backend.rs +++ b/client/src/light/backend.rs @@ -21,11 +21,12 @@ use std::collections::HashMap; use std::sync::Arc; use parking_lot::RwLock; +use primitives::storage::{ChildInfo, OwnedChildInfo}; use state_machine::{ Backend as StateBackend, TrieBackend, backend::InMemory as InMemoryState, ChangesTrieTransaction }; use primitives::offchain::storage::InMemOffchainStorage; -use sp_runtime::{generic::BlockId, Justification, StorageOverlay, ChildrenStorageOverlay}; +use sp_runtime::{generic::BlockId, Justification, Storage}; use sp_runtime::traits::{Block as BlockT, NumberFor, Zero, Header}; use crate::in_mem::{self, check_genesis_storage}; use sp_blockchain::{ Error as ClientError, Result as ClientResult }; @@ -280,22 +281,21 @@ where Ok(()) } - fn reset_storage(&mut self, top: StorageOverlay, children: ChildrenStorageOverlay) -> ClientResult { - check_genesis_storage(&top, &children)?; + fn reset_storage(&mut self, input: Storage) -> ClientResult { + check_genesis_storage(&input)?; // this is only called when genesis block is imported => shouldn't be performance bottleneck - let mut storage: HashMap>, StorageOverlay> = HashMap::new(); - storage.insert(None, top); + let mut storage: HashMap, OwnedChildInfo)>, _> = HashMap::new(); + storage.insert(None, input.top); // create a list of children keys to re-compute roots for - let child_delta = children.keys() - .cloned() - .map(|storage_key| (storage_key, None)) + let child_delta = input.children.iter() + .map(|(storage_key, storage_child)| (storage_key.clone(), None, storage_child.child_info.clone())) .collect::>(); // make sure to persist the child storage - for (child_key, child_storage) in children { - storage.insert(Some(child_key), child_storage); + for (child_key, storage_child) in input.children { + storage.insert(Some((child_key, storage_child.child_info)), storage_child.data); } let storage_update: InMemoryState = storage.into(); @@ -357,10 +357,15 @@ impl StateBackend for GenesisOrUnavailableState } } - fn child_storage(&self, storage_key: &[u8], key: &[u8]) -> ClientResult>> { + fn child_storage( + &self, + storage_key: &[u8], + child_info: ChildInfo, + key: &[u8], + ) -> ClientResult>> { match *self { GenesisOrUnavailableState::Genesis(ref state) => - Ok(state.child_storage(storage_key, key).expect(IN_MEMORY_EXPECT_PROOF)), + Ok(state.child_storage(storage_key, child_info, key).expect(IN_MEMORY_EXPECT_PROOF)), GenesisOrUnavailableState::Unavailable => Err(ClientError::NotAvailableOnLightClient), } } @@ -373,10 +378,17 @@ impl StateBackend for GenesisOrUnavailableState } } - fn next_child_storage_key(&self, storage_key: &[u8], key: &[u8]) -> Result>, Self::Error> { + fn next_child_storage_key( + &self, + storage_key: &[u8], + child_info: ChildInfo, + key: &[u8], + ) -> Result>, Self::Error> { match *self { - GenesisOrUnavailableState::Genesis(ref state) => - Ok(state.next_child_storage_key(storage_key, key).expect(IN_MEMORY_EXPECT_PROOF)), + GenesisOrUnavailableState::Genesis(ref state) => Ok( + state.next_child_storage_key(storage_key, child_info, key) + .expect(IN_MEMORY_EXPECT_PROOF) + ), GenesisOrUnavailableState::Unavailable => Err(ClientError::NotAvailableOnLightClient), } } @@ -395,10 +407,15 @@ impl StateBackend for GenesisOrUnavailableState } } - - fn for_keys_in_child_storage(&self, storage_key: &[u8], action: A) { + fn for_keys_in_child_storage( + &self, + storage_key: &[u8], + child_info: ChildInfo, + action: A, + ) { match *self { - GenesisOrUnavailableState::Genesis(ref state) => state.for_keys_in_child_storage(storage_key, action), + GenesisOrUnavailableState::Genesis(ref state) => + state.for_keys_in_child_storage(storage_key, child_info, action), GenesisOrUnavailableState::Unavailable => (), } } @@ -406,12 +423,13 @@ impl StateBackend for GenesisOrUnavailableState fn for_child_keys_with_prefix( &self, storage_key: &[u8], + child_info: ChildInfo, prefix: &[u8], action: A, ) { match *self { GenesisOrUnavailableState::Genesis(ref state) => - state.for_child_keys_with_prefix(storage_key, prefix, action), + state.for_child_keys_with_prefix(storage_key, child_info, prefix, action), GenesisOrUnavailableState::Unavailable => (), } } @@ -427,13 +445,18 @@ impl StateBackend for GenesisOrUnavailableState } } - fn child_storage_root(&self, key: &[u8], delta: I) -> (H::Out, bool, Self::Transaction) + fn child_storage_root( + &self, + storage_key: &[u8], + child_info: ChildInfo, + delta: I, + ) -> (H::Out, bool, Self::Transaction) where I: IntoIterator, Option>)> { match *self { GenesisOrUnavailableState::Genesis(ref state) => { - let (root, is_equal, _) = state.child_storage_root(key, delta); + let (root, is_equal, _) = state.child_storage_root(storage_key, child_info, delta); (root, is_equal, ()) }, GenesisOrUnavailableState::Unavailable => (H::Out::default(), true, ()), @@ -478,7 +501,7 @@ mod tests { let backend: Backend<_, Blake2Hasher> = Backend::new(Arc::new(DummyBlockchain::new(DummyStorage::new()))); let mut op = backend.begin_operation().unwrap(); op.set_block_data(header0, None, None, NewBlockState::Final).unwrap(); - op.reset_storage(Default::default(), Default::default()).unwrap(); + op.reset_storage(Default::default()).unwrap(); backend.commit_operation(op).unwrap(); match backend.state_at(BlockId::Number(0)).unwrap() { diff --git a/client/src/light/fetcher.rs b/client/src/light/fetcher.rs index 9b2c308668..babd83cfc9 100644 --- a/client/src/light/fetcher.rs +++ b/client/src/light/fetcher.rs @@ -339,11 +339,13 @@ pub mod tests { use crate::light::fetcher::{FetchChecker, LightDataChecker, RemoteHeaderRequest}; use crate::light::blockchain::tests::{DummyStorage, DummyBlockchain}; use primitives::{blake2_256, Blake2Hasher, H256}; - use primitives::storage::{well_known_keys, StorageKey}; + use primitives::storage::{well_known_keys, StorageKey, ChildInfo}; use sp_runtime::generic::BlockId; use state_machine::Backend; use super::*; + const CHILD_INFO_1: ChildInfo<'static> = ChildInfo::new_default(b"unique_id_1"); + type TestChecker = LightDataChecker< NativeExecutor, Blake2Hasher, @@ -394,8 +396,12 @@ pub mod tests { use test_client::TestClientBuilderExt; // prepare remote client let remote_client = test_client::TestClientBuilder::new() - .add_extra_child_storage(b":child_storage:default:child1".to_vec(), b"key1".to_vec(), b"value1".to_vec()) - .build(); + .add_extra_child_storage( + b":child_storage:default:child1".to_vec(), + CHILD_INFO_1, + b"key1".to_vec(), + b"value1".to_vec(), + ).build(); let remote_block_id = BlockId::Number(0); let remote_block_hash = remote_client.block_hash(0).unwrap().unwrap(); let mut remote_block_header = remote_client.header(&remote_block_id).unwrap().unwrap(); @@ -406,12 +412,14 @@ pub mod tests { let child_value = remote_client.child_storage( &remote_block_id, &StorageKey(b":child_storage:default:child1".to_vec()), + CHILD_INFO_1, &StorageKey(b"key1".to_vec()), ).unwrap().unwrap().0; assert_eq!(b"value1"[..], child_value[..]); let remote_read_proof = remote_client.read_child_proof( &remote_block_id, b":child_storage:default:child1", + CHILD_INFO_1, &[b"key1"], ).unwrap(); @@ -487,11 +495,14 @@ pub mod tests { remote_read_proof, result, ) = prepare_for_read_child_proof_check(); + let child_infos = CHILD_INFO_1.info(); assert_eq!((&local_checker as &dyn FetchChecker).check_read_child_proof( &RemoteReadChildRequest::

{ block: remote_block_header.hash(), header: remote_block_header, storage_key: b":child_storage:default:child1".to_vec(), + child_info: child_infos.0.to_vec(), + child_type: child_infos.1, keys: vec![b"key1".to_vec()], retry_count: None, }, diff --git a/frame/contracts/src/account_db.rs b/frame/contracts/src/account_db.rs index 2971f46f37..3f345f043f 100644 --- a/frame/contracts/src/account_db.rs +++ b/frame/contracts/src/account_db.rs @@ -128,7 +128,7 @@ impl AccountDb for DirectAccountDb { trie_id: Option<&TrieId>, location: &StorageKey ) -> Option> { - trie_id.and_then(|id| child::get_raw(id, &blake2_256(location))) + trie_id.and_then(|id| child::get_raw(id, crate::trie_unique_id(&id[..]), &blake2_256(location))) } fn get_code_hash(&self, account: &T::AccountId) -> Option> { >::get(account).and_then(|i| i.as_alive().map(|i| i.code_hash)) @@ -173,13 +173,13 @@ impl AccountDb for DirectAccountDb { (false, Some(info), _) => info, // Existing contract is being removed. (true, Some(info), None) => { - child::kill_storage(&info.trie_id); + child::kill_storage(&info.trie_id, info.child_trie_unique_id()); >::remove(&address); continue; } // Existing contract is being replaced by a new one. (true, Some(info), Some(code_hash)) => { - child::kill_storage(&info.trie_id); + child::kill_storage(&info.trie_id, info.child_trie_unique_id()); AliveContractInfo:: { code_hash, storage_size: T::StorageSizeOffset::get(), @@ -217,14 +217,18 @@ impl AccountDb for DirectAccountDb { } for (k, v) in changed.storage.into_iter() { - if let Some(value) = child::get_raw(&new_info.trie_id[..], &blake2_256(&k)) { + if let Some(value) = child::get_raw( + &new_info.trie_id[..], + new_info.child_trie_unique_id(), + &blake2_256(&k), + ) { new_info.storage_size -= value.len() as u32; } if let Some(value) = v { new_info.storage_size += value.len() as u32; - child::put_raw(&new_info.trie_id[..], &blake2_256(&k), &value[..]); + child::put_raw(&new_info.trie_id[..], new_info.child_trie_unique_id(), &blake2_256(&k), &value[..]); } else { - child::kill(&new_info.trie_id[..], &blake2_256(&k)); + child::kill(&new_info.trie_id[..], new_info.child_trie_unique_id(), &blake2_256(&k)); } } diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index f342a36a7a..0642049478 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -223,6 +223,19 @@ pub struct RawAliveContractInfo { pub last_write: Option, } +impl RawAliveContractInfo { + /// Associated child trie unique id is built from the hash part of the trie id. + pub fn child_trie_unique_id(&self) -> child::ChildInfo { + trie_unique_id(&self.trie_id[..]) + } +} + +/// Associated child trie unique id is built from the hash part of the trie id. +pub(crate) fn trie_unique_id(trie_id: &[u8]) -> child::ChildInfo { + let start = CHILD_STORAGE_KEY_PREFIX.len() + b"default:".len(); + child::ChildInfo::new_default(&trie_id[start ..]) +} + pub type TombstoneContractInfo = RawTombstoneContractInfo<::Hash, ::Hashing>; @@ -793,8 +806,17 @@ impl Module { let key_values_taken = delta.iter() .filter_map(|key| { - child::get_raw(&origin_contract.trie_id, &blake2_256(key)).map(|value| { - child::kill(&origin_contract.trie_id, &blake2_256(key)); + child::get_raw( + &origin_contract.trie_id, + origin_contract.child_trie_unique_id(), + &blake2_256(key), + ).map(|value| { + child::kill( + &origin_contract.trie_id, + origin_contract.child_trie_unique_id(), + &blake2_256(key), + ); + (key, value) }) }) @@ -803,13 +825,20 @@ 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. - &sp_io::storage::child_root(&origin_contract.trie_id)[..], + &child::child_root( + &origin_contract.trie_id, + )[..], code_hash, ); if tombstone != dest_tombstone { for (key, value) in key_values_taken { - child::put_raw(&origin_contract.trie_id, &blake2_256(key), &value); + child::put_raw( + &origin_contract.trie_id, + origin_contract.child_trie_unique_id(), + &blake2_256(key), + &value, + ); } return Err("Tombstones don't match"); @@ -887,7 +916,7 @@ decl_storage! { impl OnFreeBalanceZero for Module { fn on_free_balance_zero(who: &T::AccountId) { if let Some(ContractInfo::Alive(info)) = >::take(who) { - child::kill_storage(&info.trie_id); + child::kill_storage(&info.trie_id, info.child_trie_unique_id()); } } } diff --git a/frame/contracts/src/rent.rs b/frame/contracts/src/rent.rs index cf96ee2c1b..d4ca5ec7f7 100644 --- a/frame/contracts/src/rent.rs +++ b/frame/contracts/src/rent.rs @@ -19,6 +19,7 @@ use sp_runtime::traits::{Bounded, CheckedDiv, CheckedMul, Saturating, Zero, SaturatedConversion}; use support::traits::{Currency, ExistenceRequirement, Get, WithdrawReason, OnUnbalanced}; use support::StorageMap; +use support::storage::child; #[derive(PartialEq, Eq, Copy, Clone)] #[must_use] @@ -99,7 +100,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); - sp_io::storage::child_storage_kill(&contract.trie_id); + child::kill_storage(&contract.trie_id, contract.child_trie_unique_id()); return (RentOutcome::Evicted, None); } @@ -146,7 +147,9 @@ fn try_evict_or_and_pay_rent( // threshold, so it leaves a tombstone. // Note: this operation is heavy. - let child_storage_root = sp_io::storage::child_root(&contract.trie_id); + let child_storage_root = child::child_root( + &contract.trie_id, + ); let tombstone = >::new( &child_storage_root[..], @@ -155,7 +158,7 @@ fn try_evict_or_and_pay_rent( let tombstone_info = ContractInfo::Tombstone(tombstone); >::insert(account, &tombstone_info); - sp_io::storage::child_storage_kill(&contract.trie_id); + child::kill_storage(&contract.trie_id, contract.child_trie_unique_id()); return (RentOutcome::Evicted, Some(tombstone_info)); } diff --git a/frame/support/procedural/src/storage/genesis_config/mod.rs b/frame/support/procedural/src/storage/genesis_config/mod.rs index 4102513cce..4e91ccd1df 100644 --- a/frame/support/procedural/src/storage/genesis_config/mod.rs +++ b/frame/support/procedural/src/storage/genesis_config/mod.rs @@ -139,13 +139,10 @@ fn impl_build_storage( #[cfg(feature = "std")] impl#genesis_impl GenesisConfig#genesis_struct #genesis_where_clause { pub fn build_storage #fn_generic (&self) -> std::result::Result< - ( - #scrate::sp_runtime::StorageOverlay, - #scrate::sp_runtime::ChildrenStorageOverlay, - ), + #scrate::sp_runtime::Storage, String > #fn_where_clause { - let mut storage = (Default::default(), Default::default()); + let mut storage = Default::default(); self.assimilate_storage::<#fn_traitinstance>(&mut storage)?; Ok(storage) } @@ -153,12 +150,9 @@ fn impl_build_storage( /// Assimilate the storage for this module into pre-existing overlays. pub fn assimilate_storage #fn_generic ( &self, - tuple_storage: &mut ( - #scrate::sp_runtime::StorageOverlay, - #scrate::sp_runtime::ChildrenStorageOverlay, - ), + storage: &mut #scrate::sp_runtime::Storage, ) -> std::result::Result<(), String> #fn_where_clause { - #scrate::BasicExternalities::execute_with_storage(tuple_storage, || { + #scrate::BasicExternalities::execute_with_storage(storage, || { #( #builder_blocks )* Ok(()) }) @@ -171,10 +165,7 @@ fn impl_build_storage( { fn build_module_genesis_storage( &self, - storage: &mut ( - #scrate::sp_runtime::StorageOverlay, - #scrate::sp_runtime::ChildrenStorageOverlay, - ), + storage: &mut #scrate::sp_runtime::Storage, ) -> std::result::Result<(), String> { self.assimilate_storage::<#fn_traitinstance> (storage) } diff --git a/frame/support/src/storage/child.rs b/frame/support/src/storage/child.rs index 6fb8ce87b7..abd1a208c6 100644 --- a/frame/support/src/storage/child.rs +++ b/frame/support/src/storage/child.rs @@ -19,14 +19,29 @@ //! This module is a currently only a variant of unhashed with additional `storage_key`. //! Note that `storage_key` must be unique and strong (strong in the sense of being long enough to //! avoid collision from a resistant hash function (which unique implies)). +//! +//! A **key collision free** unique id is required as parameter to avoid key collision +//! between child tries. +//! This unique id management and generation responsability is delegated to pallet module. // NOTE: could replace unhashed by having only one kind of storage (root being null storage key (storage_key can become Option<&[u8]>). use crate::sp_std::prelude::*; use codec::{Codec, Encode, Decode}; +pub use primitives::storage::ChildInfo; /// 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 { - sp_io::storage::child_get(storage_key, key).and_then(|v| { +pub fn get( + storage_key: &[u8], + child_info: ChildInfo, + key: &[u8], +) -> Option { + let (data, child_type) = child_info.info(); + sp_io::storage::child_get( + storage_key, + data, + child_type, + 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); @@ -37,83 +52,178 @@ pub fn get(storage_key: &[u8], key: &[u8]) -> Option { /// Return the value of the item in storage under `key`, or the type's default if there is no /// explicit entry. -pub fn get_or_default(storage_key: &[u8], key: &[u8]) -> T { - get(storage_key, key).unwrap_or_else(Default::default) +pub fn get_or_default( + storage_key: &[u8], + child_info: ChildInfo, + key: &[u8], +) -> T { + get(storage_key, child_info, key).unwrap_or_else(Default::default) } /// Return the value of the item in storage under `key`, or `default_value` if there is no /// explicit entry. -pub fn get_or(storage_key: &[u8], key: &[u8], default_value: T) -> T { - get(storage_key, key).unwrap_or(default_value) +pub fn get_or( + storage_key: &[u8], + child_info: ChildInfo, + key: &[u8], + default_value: T, +) -> T { + get(storage_key, child_info, key).unwrap_or(default_value) } /// Return the value of the item in storage under `key`, or `default_value()` if there is no /// explicit entry. pub fn get_or_else T>( storage_key: &[u8], + child_info: ChildInfo, key: &[u8], default_value: F, ) -> T { - get(storage_key, key).unwrap_or_else(default_value) + get(storage_key, child_info, key).unwrap_or_else(default_value) } /// Put `value` in storage under `key`. -pub fn put(storage_key: &[u8], key: &[u8], value: &T) { - value.using_encoded(|slice| sp_io::storage::child_set(storage_key, key, slice)); +pub fn put( + storage_key: &[u8], + child_info: ChildInfo, + key: &[u8], + value: &T, +) { + let (data, child_type) = child_info.info(); + value.using_encoded(|slice| + sp_io::storage::child_set( + storage_key, + data, + child_type, + key, + slice, + ) + ); } /// Remove `key` from storage, returning its value if it had an explicit entry or `None` otherwise. -pub fn take(storage_key: &[u8], key: &[u8]) -> Option { - let r = get(storage_key, key); +pub fn take( + storage_key: &[u8], + child_info: ChildInfo, + key: &[u8], +) -> Option { + let r = get(storage_key, child_info, key); if r.is_some() { - kill(storage_key, key); + kill(storage_key, child_info, key); } r } /// Remove `key` from storage, returning its value, or, if there was no explicit entry in storage, /// the default for its type. -pub fn take_or_default(storage_key: &[u8], key: &[u8]) -> T { - take(storage_key, key).unwrap_or_else(Default::default) +pub fn take_or_default( + storage_key: &[u8], + child_info: ChildInfo, + key: &[u8], +) -> T { + take(storage_key, child_info, key).unwrap_or_else(Default::default) } /// Return the value of the item in storage under `key`, or `default_value` if there is no /// explicit entry. Ensure there is no explicit entry on return. -pub fn take_or(storage_key: &[u8],key: &[u8], default_value: T) -> T { - take(storage_key, key).unwrap_or(default_value) +pub fn take_or( + storage_key: &[u8], + child_info: ChildInfo, + key: &[u8], + default_value: T, +) -> T { + take(storage_key, child_info, key).unwrap_or(default_value) } /// Return the value of the item in storage under `key`, or `default_value()` if there is no /// explicit entry. Ensure there is no explicit entry on return. pub fn take_or_else T>( storage_key: &[u8], + child_info: ChildInfo, key: &[u8], default_value: F, ) -> T { - take(storage_key, key).unwrap_or_else(default_value) + take(storage_key, child_info, key).unwrap_or_else(default_value) } /// Check to see if `key` has an explicit entry in storage. -pub fn exists(storage_key: &[u8], key: &[u8]) -> bool { - sp_io::storage::child_read(storage_key, key, &mut [0;0][..], 0).is_some() +pub fn exists( + storage_key: &[u8], + child_info: ChildInfo, + key: &[u8], +) -> bool { + let (data, child_type) = child_info.info(); + sp_io::storage::child_read( + storage_key, data, child_type, + key, &mut [0;0][..], 0, + ).is_some() } /// Remove all `storage_key` key/values -pub fn kill_storage(storage_key: &[u8]) { - sp_io::storage::child_storage_kill(storage_key) +pub fn kill_storage( + storage_key: &[u8], + child_info: ChildInfo, +) { + let (data, child_type) = child_info.info(); + sp_io::storage::child_storage_kill( + storage_key, + data, + child_type, + ) } /// Ensure `key` has no explicit entry in storage. -pub fn kill(storage_key: &[u8], key: &[u8]) { - sp_io::storage::child_clear(storage_key, key); +pub fn kill( + storage_key: &[u8], + child_info: ChildInfo, + key: &[u8], +) { + let (data, child_type) = child_info.info(); + sp_io::storage::child_clear( + storage_key, + data, + child_type, + key, + ); } /// Get a Vec of bytes from storage. -pub fn get_raw(storage_key: &[u8], key: &[u8]) -> Option> { - sp_io::storage::child_get(storage_key, key) +pub fn get_raw( + storage_key: &[u8], + child_info: ChildInfo, + key: &[u8], +) -> Option> { + let (data, child_type) = child_info.info(); + sp_io::storage::child_get( + storage_key, + data, + child_type, + key, + ) } /// Put a raw byte slice into storage. -pub fn put_raw(storage_key: &[u8], key: &[u8], value: &[u8]) { - sp_io::storage::child_set(storage_key, key, value) +pub fn put_raw( + storage_key: &[u8], + child_info: ChildInfo, + key: &[u8], + value: &[u8], +) { + let (data, child_type) = child_info.info(); + sp_io::storage::child_set( + storage_key, + data, + child_type, + key, + value, + ) +} + +/// Calculate current child root value. +pub fn child_root( + storage_key: &[u8], +) -> Vec { + sp_io::storage::child_root( + storage_key, + ) } diff --git a/frame/support/test/tests/instance.rs b/frame/support/test/tests/instance.rs index c2ba694f7d..0525589afa 100644 --- a/frame/support/test/tests/instance.rs +++ b/frame/support/test/tests/instance.rs @@ -300,7 +300,10 @@ fn new_test_ext() -> sp_io::TestExternalities { #[test] fn storage_instance_independance() { - let mut storage = Default::default(); + let mut storage = primitives::storage::Storage { + top: std::collections::BTreeMap::new(), + children: std::collections::HashMap::new() + }; state_machine::BasicExternalities::execute_with_storage(&mut storage, || { module2::Value::::put(0); module2::Value::::put(0); @@ -320,7 +323,7 @@ fn storage_instance_independance() { module2::DoubleMap::::insert(&0, &0, &0); }); // 16 storage values + 4 linked_map head. - assert_eq!(storage.0.len(), 16 + 4); + assert_eq!(storage.top.len(), 16 + 4); } #[test] diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index d7485db096..b8786e59a5 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -703,11 +703,14 @@ impl Module { /// Get the basic externalities for this module, useful for tests. #[cfg(any(feature = "std", test))] pub fn externalities() -> TestExternalities { - TestExternalities::new((map![ - >::hashed_key_for(T::BlockNumber::zero()) => [69u8; 32].encode(), - >::hashed_key().to_vec() => T::BlockNumber::one().encode(), - >::hashed_key().to_vec() => [69u8; 32].encode() - ], map![])) + TestExternalities::new(primitives::storage::Storage { + top: map![ + >::hashed_key_for(T::BlockNumber::zero()) => [69u8; 32].encode(), + >::hashed_key().to_vec() => T::BlockNumber::one().encode(), + >::hashed_key().to_vec() => [69u8; 32].encode() + ], + children: map![], + }) } /// Set the block number to something in particular. Can be used as an alternative to diff --git a/primitives/externalities/src/lib.rs b/primitives/externalities/src/lib.rs index 05121f34d3..e79d6a2e3d 100644 --- a/primitives/externalities/src/lib.rs +++ b/primitives/externalities/src/lib.rs @@ -24,7 +24,7 @@ use std::any::{Any, TypeId}; -use primitives_storage::ChildStorageKey; +use primitives_storage::{ChildStorageKey, ChildInfo}; pub use scope_limited::{set_and_run_with_externalities, with_externalities}; pub use extensions::{Extension, Extensions, ExtensionStore}; @@ -45,7 +45,12 @@ pub trait Externalities: ExtensionStore { /// Get child storage value hash. This may be optimized for large values. /// /// Returns an `Option` that holds the SCALE encoded hash. - fn child_storage_hash(&self, storage_key: ChildStorageKey, key: &[u8]) -> Option>; + fn child_storage_hash( + &self, + storage_key: ChildStorageKey, + child_info: ChildInfo, + key: &[u8], + ) -> Option>; /// Read original runtime storage, ignoring any overlayed changes. fn original_storage(&self, key: &[u8]) -> Option>; @@ -53,7 +58,12 @@ pub trait Externalities: ExtensionStore { /// Read original runtime child storage, ignoring any overlayed changes. /// /// Returns an `Option` that holds the SCALE encoded hash. - fn original_child_storage(&self, storage_key: ChildStorageKey, key: &[u8]) -> Option>; + fn original_child_storage( + &self, + storage_key: ChildStorageKey, + child_info: ChildInfo, + key: &[u8], + ) -> Option>; /// Get original storage value hash, ignoring any overlayed changes. /// This may be optimized for large values. @@ -68,13 +78,19 @@ pub trait Externalities: ExtensionStore { fn original_child_storage_hash( &self, storage_key: ChildStorageKey, + child_info: ChildInfo, key: &[u8], ) -> Option>; /// Read child runtime storage. /// /// Returns an `Option` that holds the SCALE encoded hash. - fn child_storage(&self, storage_key: ChildStorageKey, key: &[u8]) -> Option>; + fn child_storage( + &self, + storage_key: ChildStorageKey, + child_info: ChildInfo, + key: &[u8], + ) -> Option>; /// Set storage entry `key` of current contract being called (effective immediately). fn set_storage(&mut self, key: Vec, value: Vec) { @@ -82,8 +98,14 @@ pub trait Externalities: ExtensionStore { } /// Set child storage entry `key` of current contract being called (effective immediately). - fn set_child_storage(&mut self, storage_key: ChildStorageKey, key: Vec, value: Vec) { - self.place_child_storage(storage_key, key, Some(value)) + fn set_child_storage( + &mut self, + storage_key: ChildStorageKey, + child_info: ChildInfo, + key: Vec, + value: Vec, + ) { + self.place_child_storage(storage_key, child_info, key, Some(value)) } /// Clear a storage entry (`key`) of current contract being called (effective immediately). @@ -92,8 +114,13 @@ pub trait Externalities: ExtensionStore { } /// Clear a child storage entry (`key`) of current contract being called (effective immediately). - fn clear_child_storage(&mut self, storage_key: ChildStorageKey, key: &[u8]) { - self.place_child_storage(storage_key, key.to_vec(), None) + fn clear_child_storage( + &mut self, + storage_key: ChildStorageKey, + child_info: ChildInfo, + key: &[u8], + ) { + self.place_child_storage(storage_key, child_info, key.to_vec(), None) } /// Whether a storage entry exists. @@ -102,24 +129,39 @@ pub trait Externalities: ExtensionStore { } /// Whether a child storage entry exists. - fn exists_child_storage(&self, storage_key: ChildStorageKey, key: &[u8]) -> bool { - self.child_storage(storage_key, key).is_some() + fn exists_child_storage( + &self, + storage_key: ChildStorageKey, + child_info: ChildInfo, + key: &[u8], + ) -> bool { + self.child_storage(storage_key, child_info, key).is_some() } /// Returns the key immediately following the given key, if it exists. fn next_storage_key(&self, key: &[u8]) -> Option>; /// Returns the key immediately following the given key, if it exists, in child storage. - fn next_child_storage_key(&self, storage_key: ChildStorageKey, key: &[u8]) -> Option>; + fn next_child_storage_key( + &self, + storage_key: ChildStorageKey, + child_info: ChildInfo, + key: &[u8], + ) -> Option>; /// Clear an entire child storage. - fn kill_child_storage(&mut self, storage_key: ChildStorageKey); + fn kill_child_storage(&mut self, storage_key: ChildStorageKey, child_info: ChildInfo); /// Clear storage entries which keys are start with the given prefix. fn clear_prefix(&mut self, prefix: &[u8]); /// Clear child storage entries which keys are start with the given prefix. - fn clear_child_prefix(&mut self, storage_key: ChildStorageKey, prefix: &[u8]); + fn clear_child_prefix( + &mut self, + storage_key: ChildStorageKey, + child_info: ChildInfo, + prefix: &[u8], + ); /// Set or clear a storage entry (`key`) of current contract being called (effective immediately). fn place_storage(&mut self, key: Vec, value: Option>); @@ -128,6 +170,7 @@ pub trait Externalities: ExtensionStore { fn place_child_storage( &mut self, storage_key: ChildStorageKey, + child_info: ChildInfo, key: Vec, value: Option>, ); @@ -147,7 +190,10 @@ pub trait Externalities: ExtensionStore { /// storage keys in the top-level storage map. /// If the storage root equals the default hash as defined by the trie, the key in the top-level /// storage map will be removed. - fn child_storage_root(&mut self, storage_key: ChildStorageKey) -> Vec; + fn child_storage_root( + &mut self, + storage_key: ChildStorageKey, + ) -> Vec; /// Get the change trie root of the current storage overlay at a block with given parent. /// `parent` is expects a SCALE endcoded hash. diff --git a/primitives/io/src/lib.rs b/primitives/io/src/lib.rs index ef4334808a..5941a8fff8 100644 --- a/primitives/io/src/lib.rs +++ b/primitives/io/src/lib.rs @@ -39,7 +39,7 @@ use primitives::{ traits::KeystoreExt, offchain::{OffchainExt, TransactionPoolExt}, hexdisplay::HexDisplay, - storage::ChildStorageKey, + storage::{ChildStorageKey, ChildInfo}, }; use primitives::{ @@ -91,10 +91,28 @@ pub trait Storage { self.storage(key).map(|s| s.to_vec()) } - /// Returns the data for `key` in the child storage or `None` if the key can not be found. - fn child_get(&self, child_storage_key: &[u8], key: &[u8]) -> Option> { + /// All Child api uses : + /// - A `child_storage_key` to define the anchor point for the child proof + /// (commonly the location where the child root is stored in its parent trie). + /// - A `child_storage_types` to identify the kind of the child type and how its + /// `child definition` parameter is encoded. + /// - A `child_definition_parameter` which is the additional information required + /// to use the child trie. For instance defaults child tries requires this to + /// contain a collision free unique id. + /// + /// This function specifically returns the data for `key` in the child storage or `None` + /// if the key can not be found. + fn child_get( + &self, + child_storage_key: &[u8], + child_definition: &[u8], + child_type: u32, + key: &[u8], + ) -> Option> { let storage_key = child_storage_key_or_panic(child_storage_key); - self.child_storage(storage_key, key).map(|s| s.to_vec()) + let child_info = ChildInfo::resolve_child_info(child_type, child_definition) + .expect("Invalid child definition"); + self.child_storage(storage_key, child_info, key).map(|s| s.to_vec()) } /// Get `key` from storage, placing the value into `value_out` and return the number of @@ -117,15 +135,21 @@ pub trait Storage { /// doesn't exist at all. /// If `value_out` length is smaller than the returned length, only `value_out` length bytes /// are copied into `value_out`. + /// + /// See `child_get` for common child api parameters. fn child_read( &self, child_storage_key: &[u8], + child_definition: &[u8], + child_type: u32, key: &[u8], value_out: &mut [u8], value_offset: u32, ) -> Option { let storage_key = child_storage_key_or_panic(child_storage_key); - self.child_storage(storage_key, key) + let child_info = ChildInfo::resolve_child_info(child_type, child_definition) + .expect("Invalid child definition"); + self.child_storage(storage_key, child_info, key) .map(|value| { let value_offset = value_offset as usize; let data = &value[value_offset.min(value.len())..]; @@ -141,9 +165,20 @@ pub trait Storage { } /// Set `key` to `value` in the child storage denoted by `child_storage_key`. - fn child_set(&mut self, child_storage_key: &[u8], key: &[u8], value: &[u8]) { + /// + /// See `child_get` for common child api parameters. + fn child_set( + &mut self, + child_storage_key: &[u8], + child_definition: &[u8], + child_type: u32, + key: &[u8], + value: &[u8], + ) { let storage_key = child_storage_key_or_panic(child_storage_key); - self.set_child_storage(storage_key, key.to_vec(), value.to_vec()); + let child_info = ChildInfo::resolve_child_info(child_type, child_definition) + .expect("Invalid child definition"); + self.set_child_storage(storage_key, child_info, key.to_vec(), value.to_vec()); } /// Clear the storage of the given `key` and its value. @@ -152,15 +187,34 @@ pub trait Storage { } /// Clear the given child storage of the given `key` and its value. - fn child_clear(&mut self, child_storage_key: &[u8], key: &[u8]) { + /// + /// See `child_get` for common child api parameters. + fn child_clear( + &mut self, + child_storage_key: &[u8], + child_definition: &[u8], + child_type: u32, + key: &[u8], + ) { let storage_key = child_storage_key_or_panic(child_storage_key); - self.clear_child_storage(storage_key, key); + let child_info = ChildInfo::resolve_child_info(child_type, child_definition) + .expect("Invalid child definition"); + self.clear_child_storage(storage_key, child_info, key); } /// Clear an entire child storage. - fn child_storage_kill(&mut self, child_storage_key: &[u8]) { + /// + /// See `child_get` for common child api parameters. + fn child_storage_kill( + &mut self, + child_storage_key: &[u8], + child_definition: &[u8], + child_type: u32, + ) { let storage_key = child_storage_key_or_panic(child_storage_key); - self.kill_child_storage(storage_key); + let child_info = ChildInfo::resolve_child_info(child_type, child_definition) + .expect("Invalid child definition"); + self.kill_child_storage(storage_key, child_info); } /// Check whether the given `key` exists in storage. @@ -169,9 +223,19 @@ pub trait Storage { } /// Check whether the given `key` exists in storage. - fn child_exists(&self, child_storage_key: &[u8], key: &[u8]) -> bool { + /// + /// See `child_get` for common child api parameters. + fn child_exists( + &self, + child_storage_key: &[u8], + child_definition: &[u8], + child_type: u32, + key: &[u8], + ) -> bool { let storage_key = child_storage_key_or_panic(child_storage_key); - self.exists_child_storage(storage_key, key) + let child_info = ChildInfo::resolve_child_info(child_type, child_definition) + .expect("Invalid child definition"); + self.exists_child_storage(storage_key, child_info, key) } /// Clear the storage of each key-value pair where the key starts with the given `prefix`. @@ -180,9 +244,19 @@ pub trait Storage { } /// Clear the child storage of each key-value pair where the key starts with the given `prefix`. - fn child_clear_prefix(&mut self, child_storage_key: &[u8], prefix: &[u8]) { + /// + /// See `child_get` for common child api parameters. + fn child_clear_prefix( + &mut self, + child_storage_key: &[u8], + child_definition: &[u8], + child_type: u32, + prefix: &[u8], + ) { let storage_key = child_storage_key_or_panic(child_storage_key); - self.clear_child_prefix(storage_key, prefix); + let child_info = ChildInfo::resolve_child_info(child_type, child_definition) + .expect("Invalid child definition"); + self.clear_child_prefix(storage_key, child_info, prefix); } /// "Commit" all existing operations and compute the resulting storage root. @@ -199,7 +273,12 @@ pub trait Storage { /// The hashing algorithm is defined by the `Block`. /// /// Returns the SCALE encoded hash. - fn child_root(&mut self, child_storage_key: &[u8]) -> Vec { + /// + /// See `child_get` for common child api parameters. + fn child_root( + &mut self, + child_storage_key: &[u8], + ) -> Vec { let storage_key = child_storage_key_or_panic(child_storage_key); self.child_storage_root(storage_key) } @@ -220,9 +299,17 @@ pub trait Storage { } /// Get the next key in storage after the given one in lexicographic order in child storage. - fn child_next_key(&mut self, child_storage_key: &[u8], key: &[u8]) -> Option> { + fn child_next_key( + &mut self, + child_storage_key: &[u8], + child_definition: &[u8], + child_type: u32, + key: &[u8], + ) -> Option> { let storage_key = child_storage_key_or_panic(child_storage_key); - self.next_child_storage_key(storage_key, key) + let child_info = ChildInfo::resolve_child_info(child_type, child_definition) + .expect("Invalid child definition"); + self.next_child_storage_key(storage_key, child_info, key) } } @@ -817,6 +904,7 @@ mod tests { use super::*; use primitives::map; use sp_state_machine::BasicExternalities; + use primitives::storage::Storage; #[test] fn storage_works() { @@ -829,7 +917,10 @@ mod tests { storage::set(b"foo", &[1, 2, 3][..]); }); - t = BasicExternalities::new(map![b"foo".to_vec() => b"bar".to_vec()], map![]); + t = BasicExternalities::new(Storage { + top: map![b"foo".to_vec() => b"bar".to_vec()], + children: map![], + }); t.execute_with(|| { assert_eq!(storage::get(b"hello"), None); @@ -839,10 +930,10 @@ mod tests { #[test] fn read_storage_works() { - let mut t = BasicExternalities::new( - map![b":test".to_vec() => b"\x0b\0\0\0Hello world".to_vec()], - map![], - ); + let mut t = BasicExternalities::new(Storage { + top: map![b":test".to_vec() => b"\x0b\0\0\0Hello world".to_vec()], + children: map![], + }); t.execute_with(|| { let mut v = [0u8; 4]; @@ -856,15 +947,15 @@ mod tests { #[test] fn clear_prefix_works() { - let mut t = BasicExternalities::new( - map![ + let mut t = BasicExternalities::new(Storage { + top: map![ b":a".to_vec() => b"\x0b\0\0\0Hello world".to_vec(), b":abcd".to_vec() => b"\x0b\0\0\0Hello world".to_vec(), b":abc".to_vec() => b"\x0b\0\0\0Hello world".to_vec(), b":abdd".to_vec() => b"\x0b\0\0\0Hello world".to_vec() ], - map![], - ); + children: map![], + }); t.execute_with(|| { storage::clear_prefix(b":abc"); diff --git a/primitives/runtime/src/lib.rs b/primitives/runtime/src/lib.rs index 426e29c407..8bfd4834c5 100644 --- a/primitives/runtime/src/lib.rs +++ b/primitives/runtime/src/lib.rs @@ -38,7 +38,7 @@ pub use paste; pub use app_crypto; #[cfg(feature = "std")] -pub use primitives::storage::{StorageOverlay, ChildrenStorageOverlay}; +pub use primitives::storage::{Storage, StorageChild}; use sp_std::prelude::*; use sp_std::convert::TryFrom; @@ -121,15 +121,15 @@ use crate::traits::IdentifyAccount; #[cfg(feature = "std")] pub trait BuildStorage: Sized { /// Build the storage out of this builder. - fn build_storage(&self) -> Result<(StorageOverlay, ChildrenStorageOverlay), String> { - let mut storage = (Default::default(), Default::default()); + fn build_storage(&self) -> Result { + let mut storage = Default::default(); self.assimilate_storage(&mut storage)?; Ok(storage) } /// Assimilate the storage for this module into pre-existing overlays. fn assimilate_storage( &self, - storage: &mut (StorageOverlay, ChildrenStorageOverlay), + storage: &mut primitives::storage::Storage, ) -> Result<(), String>; } @@ -139,23 +139,26 @@ pub trait BuildModuleGenesisStorage: Sized { /// Create the module genesis storage into the given `storage` and `child_storage`. fn build_module_genesis_storage( &self, - storage: &mut (StorageOverlay, ChildrenStorageOverlay), + storage: &mut primitives::storage::Storage, ) -> Result<(), String>; } #[cfg(feature = "std")] -impl BuildStorage for (StorageOverlay, ChildrenStorageOverlay) { +impl BuildStorage for primitives::storage::Storage { fn assimilate_storage( &self, - storage: &mut (StorageOverlay, ChildrenStorageOverlay), + storage: &mut primitives::storage::Storage, )-> Result<(), String> { - storage.0.extend(self.0.iter().map(|(k, v)| (k.clone(), v.clone()))); - for (k, other_map) in self.1.iter() { + storage.top.extend(self.top.iter().map(|(k, v)| (k.clone(), v.clone()))); + for (k, other_map) in self.children.iter() { let k = k.clone(); - if let Some(map) = storage.1.get_mut(&k) { - map.extend(other_map.iter().map(|(k, v)| (k.clone(), v.clone()))); + if let Some(map) = storage.children.get_mut(&k) { + map.data.extend(other_map.data.iter().map(|(k, v)| (k.clone(), v.clone()))); + if !map.child_info.try_update(other_map.child_info.as_ref()) { + return Err("Incompatible child info update".to_string()); + } } else { - storage.1.insert(k, other_map.clone()); + storage.children.insert(k, other_map.clone()); } } Ok(()) @@ -532,7 +535,7 @@ macro_rules! impl_outer_config { impl $crate::BuildStorage for $main { fn assimilate_storage( &self, - storage: &mut ($crate::StorageOverlay, $crate::ChildrenStorageOverlay), + storage: &mut $crate::Storage, ) -> std::result::Result<(), String> { $( if let Some(ref extra) = self.[< $snake $(_ $instance )? >] { diff --git a/primitives/state-machine/src/backend.rs b/primitives/state-machine/src/backend.rs index 78e08df6b9..8a6ba25731 100644 --- a/primitives/state-machine/src/backend.rs +++ b/primitives/state-machine/src/backend.rs @@ -26,6 +26,7 @@ use trie::{ trie_types::{TrieDBMut, Layout}, }; use codec::{Encode, Codec}; +use primitives::storage::{ChildInfo, OwnedChildInfo, Storage}; /// A state backend is used to read state data and can have changes committed /// to it. @@ -50,11 +51,21 @@ pub trait Backend: std::fmt::Debug { } /// Get keyed child storage or None if there is nothing associated. - fn child_storage(&self, storage_key: &[u8], key: &[u8]) -> Result>, Self::Error>; + fn child_storage( + &self, + storage_key: &[u8], + child_info: ChildInfo, + key: &[u8], + ) -> Result>, Self::Error>; /// Get child keyed storage value hash or None if there is nothing associated. - fn child_storage_hash(&self, storage_key: &[u8], key: &[u8]) -> Result, Self::Error> { - self.child_storage(storage_key, key).map(|v| v.map(|v| H::hash(&v))) + fn child_storage_hash( + &self, + storage_key: &[u8], + child_info: ChildInfo, + key: &[u8], + ) -> Result, Self::Error> { + self.child_storage(storage_key, child_info, key).map(|v| v.map(|v| H::hash(&v))) } /// true if a key exists in storage. @@ -63,8 +74,13 @@ pub trait Backend: std::fmt::Debug { } /// true if a key exists in child storage. - fn exists_child_storage(&self, storage_key: &[u8], key: &[u8]) -> Result { - Ok(self.child_storage(storage_key, key)?.is_some()) + fn exists_child_storage( + &self, + storage_key: &[u8], + child_info: ChildInfo, + key: &[u8], + ) -> Result { + Ok(self.child_storage(storage_key, child_info, key)?.is_some()) } /// Return the next key in storage in lexicographic order or `None` if there is no value. @@ -74,11 +90,17 @@ pub trait Backend: std::fmt::Debug { fn next_child_storage_key( &self, storage_key: &[u8], + child_info: ChildInfo, key: &[u8] ) -> Result>, Self::Error>; /// Retrieve all entries keys of child storage and call `f` for each of those keys. - fn for_keys_in_child_storage(&self, storage_key: &[u8], f: F); + fn for_keys_in_child_storage( + &self, + storage_key: &[u8], + child_info: ChildInfo, + f: F, + ); /// Retrieve all entries keys which start with the given prefix and /// call `f` for each of those keys. @@ -93,7 +115,13 @@ pub trait Backend: std::fmt::Debug { /// Retrieve all child entries keys which start with the given prefix and /// call `f` for each of those keys. - fn for_child_keys_with_prefix(&self, storage_key: &[u8], prefix: &[u8], f: F); + fn for_child_keys_with_prefix( + &self, + storage_key: &[u8], + child_info: ChildInfo, + prefix: &[u8], + f: F, + ); /// Calculate the storage root, with given delta over what is already stored in /// the backend, and produce a "transaction" that can be used to commit. @@ -106,7 +134,12 @@ pub trait Backend: std::fmt::Debug { /// Calculate the child storage root, with given delta over what is already stored in /// the backend, and produce a "transaction" that can be used to commit. The second argument /// is true if child storage root equals default storage root. - fn child_storage_root(&self, storage_key: &[u8], delta: I) -> (H::Out, bool, Self::Transaction) + fn child_storage_root( + &self, + storage_key: &[u8], + child_info: ChildInfo, + delta: I, + ) -> (H::Out, bool, Self::Transaction) where I: IntoIterator, Option>)>, H::Out: Ord; @@ -122,9 +155,14 @@ pub trait Backend: std::fmt::Debug { } /// Get all keys of child storage with given prefix - fn child_keys(&self, child_storage_key: &[u8], prefix: &[u8]) -> Vec> { + fn child_keys( + &self, + storage_key: &[u8], + child_info: ChildInfo, + prefix: &[u8], + ) -> Vec> { let mut all = Vec::new(); - self.for_child_keys_with_prefix(child_storage_key, prefix, |k| all.push(k.to_vec())); + self.for_child_keys_with_prefix(storage_key, child_info, prefix, |k| all.push(k.to_vec())); all } @@ -144,15 +182,15 @@ pub trait Backend: std::fmt::Debug { where I1: IntoIterator, Option>)>, I2i: IntoIterator, Option>)>, - I2: IntoIterator, I2i)>, + I2: IntoIterator, I2i, OwnedChildInfo)>, H::Out: Ord + Encode, { let mut txs: Self::Transaction = Default::default(); let mut child_roots: Vec<_> = Default::default(); // child first - for (storage_key, child_delta) in child_deltas { + for (storage_key, child_delta, child_info) in child_deltas { let (child_root, empty, child_txs) = - self.child_storage_root(&storage_key[..], child_delta); + self.child_storage_root(&storage_key[..], child_info.as_ref(), child_delta); txs.consolidate(child_txs); if empty { child_roots.push((storage_key, None)); @@ -177,28 +215,49 @@ impl<'a, T: Backend, H: Hasher> Backend for &'a T { (*self).storage(key) } - fn child_storage(&self, storage_key: &[u8], key: &[u8]) -> Result>, Self::Error> { - (*self).child_storage(storage_key, key) + fn child_storage( + &self, + storage_key: &[u8], + child_info: ChildInfo, + key: &[u8], + ) -> Result>, Self::Error> { + (*self).child_storage(storage_key, child_info, key) } - fn next_storage_key(&self, key: &[u8]) -> Result>, Self::Error> { - (*self).next_storage_key(key) + fn for_keys_in_child_storage( + &self, + storage_key: &[u8], + child_info: ChildInfo, + f: F, + ) { + (*self).for_keys_in_child_storage(storage_key, child_info, f) } - fn next_child_storage_key(&self, storage_key: &[u8], key: &[u8]) -> Result>, Self::Error> { - (*self).next_child_storage_key(storage_key, key) + fn next_storage_key(&self, key: &[u8]) -> Result>, Self::Error> { + (*self).next_storage_key(key) } - fn for_keys_in_child_storage(&self, storage_key: &[u8], f: F) { - (*self).for_keys_in_child_storage(storage_key, f) + fn next_child_storage_key( + &self, + storage_key: &[u8], + child_info: ChildInfo, + key: &[u8], + ) -> Result>, Self::Error> { + (*self).next_child_storage_key(storage_key, child_info, key) } fn for_keys_with_prefix(&self, prefix: &[u8], f: F) { (*self).for_keys_with_prefix(prefix, f) } - fn for_child_keys_with_prefix(&self, storage_key: &[u8], prefix: &[u8], f: F) { - (*self).for_child_keys_with_prefix(storage_key, prefix, f) + fn for_child_keys_with_prefix( + &self, + storage_key: &[u8], + child_info: ChildInfo, + prefix: &[u8], + f: F, + ) { + (*self).for_child_keys_with_prefix(storage_key, child_info, prefix, f) } fn storage_root(&self, delta: I) -> (H::Out, Self::Transaction) @@ -209,12 +268,17 @@ impl<'a, T: Backend, H: Hasher> Backend for &'a T { (*self).storage_root(delta) } - fn child_storage_root(&self, storage_key: &[u8], delta: I) -> (H::Out, bool, Self::Transaction) + fn child_storage_root( + &self, + storage_key: &[u8], + child_info: ChildInfo, + delta: I, + ) -> (H::Out, bool, Self::Transaction) where I: IntoIterator, Option>)>, H::Out: Ord, { - (*self).child_storage_root(storage_key, delta) + (*self).child_storage_root(storage_key, child_info, delta) } fn pairs(&self) -> Vec<(Vec, Vec)> { @@ -238,7 +302,10 @@ impl Consolidate for () { } } -impl Consolidate for Vec<(Option>, Vec, Option>)> { +impl Consolidate for Vec<( + Option<(Vec, OwnedChildInfo)>, + Vec<(Vec, Option>)>, + )> { fn consolidate(&mut self, mut other: Self) { self.append(&mut other); } @@ -268,7 +335,7 @@ impl error::Error for Void { /// In-memory backend. Fully recomputes tries each time `as_trie_backend` is called but useful for /// tests and proof checking. pub struct InMemory { - inner: HashMap>, BTreeMap, Vec>>, + inner: HashMap, OwnedChildInfo)>, BTreeMap, Vec>>, // This field is only needed for returning reference in `as_trie_backend`. trie: Option, H>>, _hasher: PhantomData, @@ -310,19 +377,21 @@ impl InMemory where H::Out: Codec { /// Copy the state, with applied updates pub fn update(&self, changes: >::Transaction) -> Self { let mut inner = self.inner.clone(); - for (storage_key, key, val) in changes { - match val { - Some(v) => { inner.entry(storage_key).or_default().insert(key, v); }, - None => { inner.entry(storage_key).or_default().remove(&key); }, + for (child_info, key_values) in changes { + let entry = inner.entry(child_info).or_default(); + for (key, val) in key_values { + match val { + Some(v) => { entry.insert(key, v); }, + None => { entry.remove(&key); }, + } } } - inner.into() } } -impl From>, BTreeMap, Vec>>> for InMemory { - fn from(inner: HashMap>, BTreeMap, Vec>>) -> Self { +impl From, OwnedChildInfo)>, BTreeMap, Vec>>> for InMemory { + fn from(inner: HashMap, OwnedChildInfo)>, BTreeMap, Vec>>) -> Self { InMemory { inner: inner, trie: None, @@ -331,17 +400,11 @@ impl From>, BTreeMap, Vec>>> for I } } -impl From<( - BTreeMap, Vec>, - HashMap, BTreeMap, Vec>>, -)> for InMemory { - fn from(inners: ( - BTreeMap, Vec>, - HashMap, BTreeMap, Vec>>, - )) -> Self { - let mut inner: HashMap>, BTreeMap, Vec>> - = inners.1.into_iter().map(|(k, v)| (Some(k), v)).collect(); - inner.insert(None, inners.0); +impl From for InMemory { + fn from(inners: Storage) -> Self { + let mut inner: HashMap, OwnedChildInfo)>, BTreeMap, Vec>> + = inners.children.into_iter().map(|(k, c)| (Some((k, c.child_info)), c.data)).collect(); + inner.insert(None, inners.top); InMemory { inner: inner, trie: None, @@ -362,12 +425,19 @@ impl From, Vec>> for InMemory { } } -impl From>, Vec, Option>)>> for InMemory { - fn from(inner: Vec<(Option>, Vec, Option>)>) -> Self { - let mut expanded: HashMap>, BTreeMap, Vec>> = HashMap::new(); - for (child_key, key, value) in inner { - if let Some(value) = value { - expanded.entry(child_key).or_default().insert(key, value); +impl From, OwnedChildInfo)>, Vec<(Vec, Option>)>)>> + for InMemory { + fn from( + inner: Vec<(Option<(Vec, OwnedChildInfo)>, Vec<(Vec, Option>)>)>, + ) -> Self { + let mut expanded: HashMap, OwnedChildInfo)>, BTreeMap, Vec>> + = HashMap::new(); + for (child_info, key_values) in inner { + let entry = expanded.entry(child_info).or_default(); + for (key, value) in key_values { + if let Some(value) = value { + entry.insert(key, value); + } } } expanded.into() @@ -376,22 +446,33 @@ impl From>, Vec, Option>)>> for InMem impl InMemory { /// child storage key iterator - pub fn child_storage_keys(&self) -> impl Iterator { - self.inner.iter().filter_map(|item| item.0.as_ref().map(|v|&v[..])) + pub fn child_storage_keys(&self) -> impl Iterator { + self.inner.iter().filter_map(|item| + item.0.as_ref().map(|v|(&v.0[..], v.1.as_ref())) + ) } } impl Backend for InMemory where H::Out: Codec { type Error = Void; - type Transaction = Vec<(Option>, Vec, Option>)>; + type Transaction = Vec<( + Option<(Vec, OwnedChildInfo)>, + Vec<(Vec, Option>)>, + )>; type TrieBackendStorage = MemoryDB; fn storage(&self, key: &[u8]) -> Result>, Self::Error> { Ok(self.inner.get(&None).and_then(|map| map.get(key).map(Clone::clone))) } - fn child_storage(&self, storage_key: &[u8], key: &[u8]) -> Result>, Self::Error> { - Ok(self.inner.get(&Some(storage_key.to_vec())).and_then(|map| map.get(key).map(Clone::clone))) + fn child_storage( + &self, + storage_key: &[u8], + child_info: ChildInfo, + key: &[u8], + ) -> Result>, Self::Error> { + Ok(self.inner.get(&Some((storage_key.to_vec(), child_info.to_owned()))) + .and_then(|map| map.get(key).map(Clone::clone))) } fn exists_storage(&self, key: &[u8]) -> Result { @@ -406,9 +487,14 @@ impl Backend for InMemory where H::Out: Codec { Ok(next_key) } - fn next_child_storage_key(&self, storage_key: &[u8], key: &[u8]) -> Result>, Self::Error> { + fn next_child_storage_key( + &self, + storage_key: &[u8], + child_info: ChildInfo, + key: &[u8], + ) -> Result>, Self::Error> { let range = (ops::Bound::Excluded(key), ops::Bound::Unbounded); - let next_key = self.inner.get(&Some(storage_key.to_vec())) + let next_key = self.inner.get(&Some((storage_key.to_vec(), child_info.to_owned()))) .and_then(|map| map.range::<[u8], _>(range).next().map(|(k, _)| k).cloned()); Ok(next_key) @@ -423,12 +509,24 @@ impl Backend for InMemory where H::Out: Codec { .for_each(|(k, v)| f(k, v))); } - fn for_keys_in_child_storage(&self, storage_key: &[u8], mut f: F) { - self.inner.get(&Some(storage_key.to_vec())).map(|map| map.keys().for_each(|k| f(&k))); + fn for_keys_in_child_storage( + &self, + storage_key: &[u8], + child_info: ChildInfo, + mut f: F, + ) { + self.inner.get(&Some((storage_key.to_vec(), child_info.to_owned()))) + .map(|map| map.keys().for_each(|k| f(&k))); } - fn for_child_keys_with_prefix(&self, storage_key: &[u8], prefix: &[u8], f: F) { - self.inner.get(&Some(storage_key.to_vec())) + fn for_child_keys_with_prefix( + &self, + storage_key: &[u8], + child_info: ChildInfo, + prefix: &[u8], + f: F, + ) { + self.inner.get(&Some((storage_key.to_vec(), child_info.to_owned()))) .map(|map| map.keys().filter(|key| key.starts_with(prefix)).map(|k| &**k).for_each(f)); } @@ -448,19 +546,26 @@ impl Backend for InMemory where H::Out: Codec { .filter_map(|(k, maybe_val)| maybe_val.map(|val| (k, val))) ); - let full_transaction = transaction.into_iter().map(|(k, v)| (None, k, v)).collect(); + let full_transaction = transaction.into_iter().collect(); - (root, full_transaction) + (root, vec![(None, full_transaction)]) } - fn child_storage_root(&self, storage_key: &[u8], delta: I) -> (H::Out, bool, Self::Transaction) + fn child_storage_root( + &self, + storage_key: &[u8], + child_info: ChildInfo, + delta: I, + ) -> (H::Out, bool, Self::Transaction) where I: IntoIterator, Option>)>, H::Out: Ord { let storage_key = storage_key.to_vec(); + let child_info = Some((storage_key.clone(), child_info.to_owned())); - let existing_pairs = self.inner.get(&Some(storage_key.clone())) + + let existing_pairs = self.inner.get(&child_info) .into_iter() .flat_map(|map| map.iter().map(|(k, v)| (k.clone(), Some(v.clone())))); @@ -473,11 +578,11 @@ impl Backend for InMemory where H::Out: Codec { .filter_map(|(k, maybe_val)| maybe_val.map(|val| (k, val))) ); - let full_transaction = transaction.into_iter().map(|(k, v)| (Some(storage_key.clone()), k, v)).collect(); + let full_transaction = transaction.into_iter().collect(); let is_default = root == default_child_trie_root::>(&storage_key); - (root, is_default, full_transaction) + (root, is_default, vec![(child_info, full_transaction)]) } fn pairs(&self) -> Vec<(Vec, Vec)> { @@ -494,8 +599,13 @@ impl Backend for InMemory where H::Out: Codec { .collect() } - fn child_keys(&self, storage_key: &[u8], prefix: &[u8]) -> Vec> { - self.inner.get(&Some(storage_key.to_vec())) + fn child_keys( + &self, + storage_key: &[u8], + child_info: ChildInfo, + prefix: &[u8], + ) -> Vec> { + self.inner.get(&Some((storage_key.to_vec(), child_info.to_owned()))) .into_iter() .flat_map(|map| map.keys().filter(|k| k.starts_with(prefix)).cloned()) .collect() @@ -505,8 +615,10 @@ impl Backend for InMemory where H::Out: Codec { let mut mdb = MemoryDB::default(); let mut new_child_roots = Vec::new(); let mut root_map = None; - for (storage_key, map) in &self.inner { - if let Some(storage_key) = storage_key.as_ref() { + for (child_info, map) in &self.inner { + if let Some((storage_key, _child_info)) = child_info.as_ref() { + // no need to use child_info at this point because we use a MemoryDB for + // proof (with PrefixedMemoryDB it would be needed). let ch = insert_into_memory_db::(&mut mdb, map.clone().into_iter())?; new_child_roots.push((storage_key.clone(), ch.as_ref().into())); } else { @@ -556,11 +668,16 @@ mod tests { #[test] fn in_memory_with_child_trie_only() { let storage = InMemory::::default(); + let child_info = OwnedChildInfo::new_default(b"unique_id_1".to_vec()); let mut storage = storage.update( - vec![(Some(b"1".to_vec()), b"2".to_vec(), Some(b"3".to_vec()))] + vec![( + Some((b"1".to_vec(), child_info.clone())), + vec![(b"2".to_vec(), Some(b"3".to_vec()))] + )] ); let trie_backend = storage.as_trie_backend().unwrap(); - assert_eq!(trie_backend.child_storage(b"1", b"2").unwrap(), Some(b"3".to_vec())); + assert_eq!(trie_backend.child_storage(b"1", child_info.as_ref(), b"2").unwrap(), + Some(b"3".to_vec())); assert!(trie_backend.storage(b"1").unwrap().is_some()); } } diff --git a/primitives/state-machine/src/basic.rs b/primitives/state-machine/src/basic.rs index deae7f2852..62503bdee1 100644 --- a/primitives/state-machine/src/basic.rs +++ b/primitives/state-machine/src/basic.rs @@ -17,7 +17,7 @@ //! Basic implementation for Externalities. use std::{ - collections::{HashMap, BTreeMap}, any::{TypeId, Any}, iter::FromIterator, mem, ops::Bound + collections::BTreeMap, any::{TypeId, Any}, iter::FromIterator, ops::Bound }; use crate::backend::{Backend, InMemory}; use hash_db::Hasher; @@ -25,54 +25,47 @@ use trie::{TrieConfiguration, default_child_trie_root}; use trie::trie_types::Layout; use primitives::{ storage::{ - well_known_keys::is_child_storage_key, ChildStorageKey, StorageOverlay, - ChildrenStorageOverlay + well_known_keys::is_child_storage_key, ChildStorageKey, Storage, + ChildInfo, StorageChild, }, traits::Externalities, Blake2Hasher, }; use log::warn; use codec::Encode; -/// Simple HashMap-based Externalities impl. +/// Simple Map-based Externalities impl. #[derive(Debug)] pub struct BasicExternalities { - top: StorageOverlay, - children: ChildrenStorageOverlay, + inner: Storage, } impl BasicExternalities { /// Create a new instance of `BasicExternalities` - pub fn new(top: StorageOverlay, children: ChildrenStorageOverlay) -> Self { - BasicExternalities { - top, - children, - } + pub fn new(inner: Storage) -> Self { + BasicExternalities { inner } } /// Insert key/value pub fn insert(&mut self, k: Vec, v: Vec) -> Option> { - self.top.insert(k, v) + self.inner.top.insert(k, v) } /// Consume self and returns inner storages - pub fn into_storages(self) -> ( - BTreeMap, Vec>, - HashMap, BTreeMap, Vec>>, - ) { - (self.top, self.children) + pub fn into_storages(self) -> Storage { + self.inner } /// Execute the given closure `f` with the externalities set and initialized with `storage`. /// /// Returns the result of the closure and updates `storage` with all changes. pub fn execute_with_storage( - storage: &mut (StorageOverlay, ChildrenStorageOverlay), + storage: &mut primitives::storage::Storage, f: impl FnOnce() -> R, ) -> R { - let mut ext = Self { - top: mem::replace(&mut storage.0, BTreeMap::default()), - children: mem::replace(&mut storage.1, HashMap::default()), - }; + let mut ext = Self { inner: Storage { + top: std::mem::replace(&mut storage.top, Default::default()), + children: std::mem::replace(&mut storage.children, Default::default()), + }}; let r = ext.execute_with(f); @@ -91,34 +84,35 @@ impl BasicExternalities { impl PartialEq for BasicExternalities { fn eq(&self, other: &BasicExternalities) -> bool { - self.top.eq(&other.top) && self.children.eq(&other.children) + self.inner.top.eq(&other.inner.top) + && self.inner.children.eq(&other.inner.children) } } impl FromIterator<(Vec, Vec)> for BasicExternalities { fn from_iter, Vec)>>(iter: I) -> Self { let mut t = Self::default(); - t.top.extend(iter); + t.inner.top.extend(iter); t } } impl Default for BasicExternalities { - fn default() -> Self { Self::new(Default::default(), Default::default()) } + fn default() -> Self { Self::new(Default::default()) } } impl From, Vec>> for BasicExternalities { fn from(hashmap: BTreeMap, Vec>) -> Self { - BasicExternalities { + BasicExternalities { inner: Storage { top: hashmap, children: Default::default(), - } + }} } } impl Externalities for BasicExternalities { fn storage(&self, key: &[u8]) -> Option> { - self.top.get(key).cloned() + self.inner.top.get(key).cloned() } fn storage_hash(&self, key: &[u8]) -> Option> { @@ -133,35 +127,56 @@ impl Externalities for BasicExternalities { self.storage_hash(key) } - fn child_storage(&self, storage_key: ChildStorageKey, key: &[u8]) -> Option> { - self.children.get(storage_key.as_ref()).and_then(|child| child.get(key)).cloned() + fn child_storage( + &self, + storage_key: ChildStorageKey, + _child_info: ChildInfo, + key: &[u8], + ) -> Option> { + self.inner.children.get(storage_key.as_ref()).and_then(|child| child.data.get(key)).cloned() } - fn child_storage_hash(&self, storage_key: ChildStorageKey, key: &[u8]) -> Option> { - self.child_storage(storage_key, key).map(|v| Blake2Hasher::hash(&v).encode()) + fn child_storage_hash( + &self, + storage_key: ChildStorageKey, + child_info: ChildInfo, + key: &[u8], + ) -> Option> { + self.child_storage(storage_key, child_info, key).map(|v| Blake2Hasher::hash(&v).encode()) } fn original_child_storage_hash( &self, storage_key: ChildStorageKey, + child_info: ChildInfo, key: &[u8], ) -> Option> { - self.child_storage_hash(storage_key, key) + self.child_storage_hash(storage_key, child_info, key) } - fn original_child_storage(&self, storage_key: ChildStorageKey, key: &[u8]) -> Option> { - Externalities::child_storage(self, storage_key, key) + fn original_child_storage( + &self, + storage_key: ChildStorageKey, + child_info: ChildInfo, + key: &[u8], + ) -> Option> { + Externalities::child_storage(self, storage_key, child_info, key) } fn next_storage_key(&self, key: &[u8]) -> Option> { let range = (Bound::Excluded(key), Bound::Unbounded); - self.top.range::<[u8], _>(range).next().map(|(k, _)| k).cloned() + self.inner.top.range::<[u8], _>(range).next().map(|(k, _)| k).cloned() } - fn next_child_storage_key(&self, storage_key: ChildStorageKey, key: &[u8]) -> Option> { + fn next_child_storage_key( + &self, + storage_key: ChildStorageKey, + _child_info: ChildInfo, + key: &[u8], + ) -> Option> { let range = (Bound::Excluded(key), Bound::Unbounded); - self.children.get(storage_key.as_ref()) - .and_then(|child| child.range::<[u8], _>(range).next().map(|(k, _)| k).cloned()) + self.inner.children.get(storage_key.as_ref()) + .and_then(|child| child.data.range::<[u8], _>(range).next().map(|(k, _)| k).cloned()) } fn place_storage(&mut self, key: Vec, maybe_value: Option>) { @@ -171,27 +186,36 @@ impl Externalities for BasicExternalities { } match maybe_value { - Some(value) => { self.top.insert(key, value); } - None => { self.top.remove(&key); } + Some(value) => { self.inner.top.insert(key, value); } + None => { self.inner.top.remove(&key); } } } fn place_child_storage( &mut self, storage_key: ChildStorageKey, + child_info: ChildInfo, key: Vec, value: Option>, ) { - let child_map = self.children.entry(storage_key.into_owned()).or_default(); + let child_map = self.inner.children.entry(storage_key.into_owned()) + .or_insert_with(|| StorageChild { + data: Default::default(), + child_info: child_info.to_owned(), + }); if let Some(value) = value { - child_map.insert(key, value); + child_map.data.insert(key, value); } else { - child_map.remove(&key); + child_map.data.remove(&key); } } - fn kill_child_storage(&mut self, storage_key: ChildStorageKey) { - self.children.remove(storage_key.as_ref()); + fn kill_child_storage( + &mut self, + storage_key: ChildStorageKey, + _child_info: ChildInfo, + ) { + self.inner.children.remove(storage_key.as_ref()); } fn clear_prefix(&mut self, prefix: &[u8]) { @@ -203,27 +227,32 @@ impl Externalities for BasicExternalities { return; } - let to_remove = self.top.range::<[u8], _>((Bound::Included(prefix), Bound::Unbounded)) + let to_remove = self.inner.top.range::<[u8], _>((Bound::Included(prefix), Bound::Unbounded)) .map(|(k, _)| k) .take_while(|k| k.starts_with(prefix)) .cloned() .collect::>(); for key in to_remove { - self.top.remove(&key); + self.inner.top.remove(&key); } } - fn clear_child_prefix(&mut self, storage_key: ChildStorageKey, prefix: &[u8]) { - if let Some(child) = self.children.get_mut(storage_key.as_ref()) { - let to_remove = child.range::<[u8], _>((Bound::Included(prefix), Bound::Unbounded)) + fn clear_child_prefix( + &mut self, + storage_key: ChildStorageKey, + _child_info: ChildInfo, + prefix: &[u8], + ) { + if let Some(child) = self.inner.children.get_mut(storage_key.as_ref()) { + let to_remove = child.data.range::<[u8], _>((Bound::Included(prefix), Bound::Unbounded)) .map(|(k, _)| k) .take_while(|k| k.starts_with(prefix)) .cloned() .collect::>(); for key in to_remove { - child.remove(&key); + child.data.remove(&key); } } } @@ -231,8 +260,8 @@ impl Externalities for BasicExternalities { fn chain_id(&self) -> u64 { 42 } fn storage_root(&mut self) -> Vec { - let mut top = self.top.clone(); - let keys: Vec<_> = self.children.keys().map(|k| k.to_vec()).collect(); + let mut top = self.inner.top.clone(); + let keys: Vec<_> = self.inner.children.keys().map(|k| k.to_vec()).collect(); // Single child trie implementation currently allows using the same child // empty root for all child trie. Using null storage key until multiple // type of child trie support. @@ -243,20 +272,24 @@ impl Externalities for BasicExternalities { .expect("Map only feed by valid keys; qed"), ); if &empty_hash[..] == &child_root[..] { - top.remove(&storage_key); + top.remove(storage_key.as_slice()); } else { top.insert(storage_key, child_root); } } - Layout::::trie_root(self.top.clone()).as_ref().into() + Layout::::trie_root(self.inner.top.clone()).as_ref().into() } - fn child_storage_root(&mut self, storage_key: ChildStorageKey) -> Vec { - if let Some(child) = self.children.get(storage_key.as_ref()) { - let delta = child.clone().into_iter().map(|(k, v)| (k, Some(v))); + fn child_storage_root( + &mut self, + storage_key: ChildStorageKey, + ) -> Vec { + if let Some(child) = self.inner.children.get(storage_key.as_ref()) { + let delta = child.data.clone().into_iter().map(|(k, v)| (k, Some(v))); - InMemory::::default().child_storage_root(storage_key.as_ref(), delta).0 + InMemory::::default() + .child_storage_root(storage_key.as_ref(), child.child_info.as_ref(), delta).0 } else { default_child_trie_root::>(storage_key.as_ref()) }.encode() @@ -278,9 +311,12 @@ impl externalities::ExtensionStore for BasicExternalities { mod tests { use super::*; use primitives::map; + use primitives::storage::{Storage, StorageChild}; use primitives::storage::well_known_keys::CODE; use hex_literal::hex; + const CHILD_INFO_1: ChildInfo<'static> = ChildInfo::new_default(b"unique_id_1"); + #[test] fn commit_should_work() { let mut ext = BasicExternalities::default(); @@ -306,37 +342,35 @@ mod tests { fn children_works() { let child_storage = b":child_storage:default:test".to_vec(); - let mut ext = BasicExternalities::new( - Default::default(), - map![ - child_storage.clone() => map![ - b"doe".to_vec() => b"reindeer".to_vec() - ] + let mut ext = BasicExternalities::new(Storage { + top: Default::default(), + children: map![ + child_storage.clone() => StorageChild { + data: map![ b"doe".to_vec() => b"reindeer".to_vec() ], + child_info: CHILD_INFO_1.to_owned(), + } ] - ); + }); let child = || ChildStorageKey::from_vec(child_storage.clone()).unwrap(); - assert_eq!(ext.child_storage(child(), b"doe"), Some(b"reindeer".to_vec())); + assert_eq!(ext.child_storage(child(), CHILD_INFO_1, b"doe"), Some(b"reindeer".to_vec())); - ext.set_child_storage(child(), b"dog".to_vec(), b"puppy".to_vec()); - assert_eq!(ext.child_storage(child(), b"dog"), Some(b"puppy".to_vec())); + ext.set_child_storage(child(), CHILD_INFO_1, b"dog".to_vec(), b"puppy".to_vec()); + assert_eq!(ext.child_storage(child(), CHILD_INFO_1, b"dog"), Some(b"puppy".to_vec())); - ext.clear_child_storage(child(), b"dog"); - assert_eq!(ext.child_storage(child(), b"dog"), None); + ext.clear_child_storage(child(), CHILD_INFO_1, b"dog"); + assert_eq!(ext.child_storage(child(), CHILD_INFO_1, b"dog"), None); - ext.kill_child_storage(child()); - assert_eq!(ext.child_storage(child(), b"doe"), None); + ext.kill_child_storage(child(), CHILD_INFO_1); + assert_eq!(ext.child_storage(child(), CHILD_INFO_1, b"doe"), None); } #[test] fn basic_externalities_is_empty() { // Make sure no values are set by default in `BasicExternalities`. - let (storage, child_storage) = BasicExternalities::new( - Default::default(), - Default::default(), - ).into_storages(); - assert!(storage.is_empty()); - assert!(child_storage.is_empty()); + let storage = BasicExternalities::new(Default::default()).into_storages(); + assert!(storage.top.is_empty()); + assert!(storage.children.is_empty()); } } diff --git a/primitives/state-machine/src/changes_trie/build.rs b/primitives/state-machine/src/changes_trie/build.rs index 7e082ad832..4bb7b6c0aa 100644 --- a/primitives/state-machine/src/changes_trie/build.rs +++ b/primitives/state-machine/src/changes_trie/build.rs @@ -133,10 +133,15 @@ fn prepare_extrinsics_input_inner<'a, B, H, Number>( H: Hasher, Number: BlockNumber, { - let (committed, prospective) = if let Some(sk) = storage_key.as_ref() { - (changes.committed.children.get(sk), changes.prospective.children.get(sk)) + let (committed, prospective, child_info) = if let Some(sk) = storage_key.as_ref() { + let child_info = changes.child_info(sk).cloned(); + ( + changes.committed.children.get(sk).map(|c| &c.0), + changes.prospective.children.get(sk).map(|c| &c.0), + child_info, + ) } else { - (Some(&changes.committed.top), Some(&changes.prospective.top)) + (Some(&changes.committed.top), Some(&changes.prospective.top), None) }; committed.iter().flat_map(|c| c.iter()) .chain(prospective.iter().flat_map(|c| c.iter())) @@ -148,8 +153,11 @@ fn prepare_extrinsics_input_inner<'a, B, H, Number>( // AND are not in storage at the beginning of operation if let Some(sk) = storage_key.as_ref() { if !changes.child_storage(sk, k).map(|v| v.is_some()).unwrap_or_default() { - if !backend.exists_child_storage(sk, k).map_err(|e| format!("{}", e))? { - return Ok(map); + if let Some(child_info) = child_info.as_ref() { + if !backend.exists_child_storage(sk, child_info.as_ref(), k) + .map_err(|e| format!("{}", e))? { + return Ok(map); + } } } } else { @@ -332,12 +340,16 @@ mod test { use codec::Encode; use primitives::Blake2Hasher; use primitives::storage::well_known_keys::{EXTRINSIC_INDEX}; + use primitives::storage::ChildInfo; use crate::backend::InMemory; use crate::changes_trie::{RootsStorage, Configuration, storage::InMemoryStorage}; use crate::changes_trie::build_cache::{IncompleteCacheAction, IncompleteCachedBuildData}; use crate::overlayed_changes::{OverlayedValue, OverlayedChangeSet}; use super::*; + const CHILD_INFO_1: ChildInfo<'static> = ChildInfo::new_default(b"unique_id_1"); + const CHILD_INFO_2: ChildInfo<'static> = ChildInfo::new_default(b"unique_id_2"); + fn prepare_for_build(zero: u64) -> ( InMemory, InMemoryStorage, @@ -416,18 +428,18 @@ mod test { }), ].into_iter().collect(), children: vec![ - (child_trie_key1.clone(), vec![ + (child_trie_key1.clone(), (vec![ (vec![100], OverlayedValue { value: Some(vec![200]), extrinsics: Some(vec![0, 2].into_iter().collect()) }) - ].into_iter().collect()), - (child_trie_key2, vec![ + ].into_iter().collect(), CHILD_INFO_1.to_owned())), + (child_trie_key2, (vec![ (vec![100], OverlayedValue { value: Some(vec![200]), extrinsics: Some(vec![0, 2].into_iter().collect()) }) - ].into_iter().collect()), + ].into_iter().collect(), CHILD_INFO_2.to_owned())), ].into_iter().collect() }, committed: OverlayedChangeSet { top: vec![ @@ -445,12 +457,12 @@ mod test { }), ].into_iter().collect(), children: vec![ - (child_trie_key1, vec![ + (child_trie_key1, (vec![ (vec![100], OverlayedValue { value: Some(vec![202]), extrinsics: Some(vec![3].into_iter().collect()) }) - ].into_iter().collect()), + ].into_iter().collect(), CHILD_INFO_1.to_owned())), ].into_iter().collect(), }, changes_trie_config: Some(config.clone()), diff --git a/primitives/state-machine/src/ext.rs b/primitives/state-machine/src/ext.rs index 3ac8c19048..9e7baea45e 100644 --- a/primitives/state-machine/src/ext.rs +++ b/primitives/state-machine/src/ext.rs @@ -25,7 +25,7 @@ use crate::{ use hash_db::Hasher; use primitives::{ - storage::{ChildStorageKey, well_known_keys::is_child_storage_key}, + storage::{ChildStorageKey, well_known_keys::is_child_storage_key, ChildInfo}, traits::Externalities, hexdisplay::HexDisplay, hash::H256, }; use trie::{trie_types::Layout, MemoryDB, default_child_trie_root}; @@ -229,13 +229,19 @@ where result.map(|r| r.encode()) } - fn child_storage(&self, storage_key: ChildStorageKey, key: &[u8]) -> Option> { + fn child_storage( + &self, + storage_key: ChildStorageKey, + child_info: ChildInfo, + key: &[u8], + ) -> Option> { let _guard = panic_handler::AbortGuard::force_abort(); let result = self.overlay .child_storage(storage_key.as_ref(), key) .map(|x| x.map(|x| x.to_vec())) .unwrap_or_else(|| - self.backend.child_storage(storage_key.as_ref(), key).expect(EXT_NOT_ALLOWED_TO_FAIL) + self.backend.child_storage(storage_key.as_ref(), child_info, key) + .expect(EXT_NOT_ALLOWED_TO_FAIL) ); trace!(target: "state-trace", "{:04x}: GetChild({}) {}={:?}", @@ -248,7 +254,12 @@ where result } - fn child_storage_hash(&self, storage_key: ChildStorageKey, key: &[u8]) -> Option> { + fn child_storage_hash( + &self, + storage_key: ChildStorageKey, + _child_info: ChildInfo, + key: &[u8], + ) -> Option> { let _guard = panic_handler::AbortGuard::force_abort(); let result = self.overlay .child_storage(storage_key.as_ref(), key) @@ -267,10 +278,15 @@ where result.map(|r| r.encode()) } - fn original_child_storage(&self, storage_key: ChildStorageKey, key: &[u8]) -> Option> { + fn original_child_storage( + &self, + storage_key: ChildStorageKey, + child_info: ChildInfo, + key: &[u8], + ) -> Option> { let _guard = panic_handler::AbortGuard::force_abort(); let result = self.backend - .child_storage(storage_key.as_ref(), key) + .child_storage(storage_key.as_ref(), child_info, key) .expect(EXT_NOT_ALLOWED_TO_FAIL); trace!(target: "state-trace", "{:04x}: ChildOriginal({}) {}={:?}", @@ -285,11 +301,12 @@ where fn original_child_storage_hash( &self, storage_key: ChildStorageKey, + child_info: ChildInfo, key: &[u8], ) -> Option> { let _guard = panic_handler::AbortGuard::force_abort(); let result = self.backend - .child_storage_hash(storage_key.as_ref(), key) + .child_storage_hash(storage_key.as_ref(), child_info, key) .expect(EXT_NOT_ALLOWED_TO_FAIL); trace!(target: "state-trace", "{}: ChildHashOriginal({}) {}={:?}", @@ -317,13 +334,18 @@ where } - fn exists_child_storage(&self, storage_key: ChildStorageKey, key: &[u8]) -> bool { + fn exists_child_storage( + &self, + storage_key: ChildStorageKey, + child_info: ChildInfo, + key: &[u8], + ) -> bool { let _guard = panic_handler::AbortGuard::force_abort(); let result = match self.overlay.child_storage(storage_key.as_ref(), key) { Some(x) => x.is_some(), _ => self.backend - .exists_child_storage(storage_key.as_ref(), key) + .exists_child_storage(storage_key.as_ref(), child_info, key) .expect(EXT_NOT_ALLOWED_TO_FAIL), }; @@ -351,8 +373,14 @@ where } } - fn next_child_storage_key(&self, storage_key: ChildStorageKey, key: &[u8]) -> Option> { - let next_backend_key = self.backend.next_child_storage_key(storage_key.as_ref(), key) + fn next_child_storage_key( + &self, + storage_key: ChildStorageKey, + child_info: ChildInfo, + key: &[u8], + ) -> Option> { + let next_backend_key = self.backend + .next_child_storage_key(storage_key.as_ref(), child_info, key) .expect(EXT_NOT_ALLOWED_TO_FAIL); let next_overlay_key_change = self.overlay.next_child_storage_key_change( storage_key.as_ref(), @@ -365,7 +393,11 @@ where (_, Some(overlay_key)) => if overlay_key.1.value.is_some() { Some(overlay_key.0.to_vec()) } else { - self.next_child_storage_key(storage_key, &overlay_key.0[..]) + self.next_child_storage_key( + storage_key, + child_info, + &overlay_key.0[..], + ) }, } } @@ -389,6 +421,7 @@ where fn place_child_storage( &mut self, storage_key: ChildStorageKey, + child_info: ChildInfo, key: Vec, value: Option>, ) { @@ -401,10 +434,14 @@ where let _guard = panic_handler::AbortGuard::force_abort(); self.mark_dirty(); - self.overlay.set_child_storage(storage_key.into_owned(), key, value); + self.overlay.set_child_storage(storage_key.into_owned(), child_info, key, value); } - fn kill_child_storage(&mut self, storage_key: ChildStorageKey) { + fn kill_child_storage( + &mut self, + storage_key: ChildStorageKey, + child_info: ChildInfo, + ) { trace!(target: "state-trace", "{:04x}: KillChild({})", self.id, HexDisplay::from(&storage_key.as_ref()), @@ -412,9 +449,9 @@ where let _guard = panic_handler::AbortGuard::force_abort(); self.mark_dirty(); - self.overlay.clear_child_storage(storage_key.as_ref()); - self.backend.for_keys_in_child_storage(storage_key.as_ref(), |key| { - self.overlay.set_child_storage(storage_key.as_ref().to_vec(), key.to_vec(), None); + self.overlay.clear_child_storage(storage_key.as_ref(), child_info); + self.backend.for_keys_in_child_storage(storage_key.as_ref(), child_info, |key| { + self.overlay.set_child_storage(storage_key.as_ref().to_vec(), child_info, key.to_vec(), None); }); } @@ -436,7 +473,12 @@ where }); } - fn clear_child_prefix(&mut self, storage_key: ChildStorageKey, prefix: &[u8]) { + fn clear_child_prefix( + &mut self, + storage_key: ChildStorageKey, + child_info: ChildInfo, + prefix: &[u8], + ) { trace!(target: "state-trace", "{:04x}: ClearChildPrefix({}) {}", self.id, HexDisplay::from(&storage_key.as_ref()), @@ -445,9 +487,9 @@ where let _guard = panic_handler::AbortGuard::force_abort(); self.mark_dirty(); - self.overlay.clear_child_prefix(storage_key.as_ref(), prefix); - self.backend.for_child_keys_with_prefix(storage_key.as_ref(), prefix, |key| { - self.overlay.set_child_storage(storage_key.as_ref().to_vec(), key.to_vec(), None); + self.overlay.clear_child_prefix(storage_key.as_ref(), child_info, prefix); + self.backend.for_child_keys_with_prefix(storage_key.as_ref(), child_info, prefix, |key| { + self.overlay.set_child_storage(storage_key.as_ref().to_vec(), child_info, key.to_vec(), None); }); } @@ -465,16 +507,23 @@ where return root.encode(); } - let child_storage_keys = - self.overlay.prospective.children.keys() + let child_storage_keys = self.overlay.prospective.children.keys() .chain(self.overlay.committed.children.keys()); let child_delta_iter = child_storage_keys.map(|storage_key| - (storage_key.clone(), self.overlay.committed.children.get(storage_key) - .into_iter() - .flat_map(|map| map.iter().map(|(k, v)| (k.clone(), v.value.clone()))) - .chain(self.overlay.prospective.children.get(storage_key) + ( + storage_key.clone(), + self.overlay.committed.children.get(storage_key) .into_iter() - .flat_map(|map| map.iter().map(|(k, v)| (k.clone(), v.value.clone())))))); + .flat_map(|(map, _)| map.iter().map(|(k, v)| (k.clone(), v.value.clone()))) + .chain( + self.overlay.prospective.children.get(storage_key) + .into_iter() + .flat_map(|(map, _)| map.iter().map(|(k, v)| (k.clone(), v.value.clone()))) + ), + self.overlay.child_info(storage_key).cloned() + .expect("child info initialized in either committed or prospective"), + ) + ); // compute and memoize @@ -490,7 +539,10 @@ where root.encode() } - fn child_storage_root(&mut self, storage_key: ChildStorageKey) -> Vec { + fn child_storage_root( + &mut self, + storage_key: ChildStorageKey, + ) -> Vec { let _guard = panic_handler::AbortGuard::force_abort(); if self.storage_transaction.is_some() { let root = self @@ -508,29 +560,53 @@ where } else { let storage_key = storage_key.as_ref(); - let (root, is_empty, _) = { - let delta = self.overlay.committed.children.get(storage_key) - .into_iter() - .flat_map(|map| map.clone().into_iter().map(|(k, v)| (k, v.value))) - .chain(self.overlay.prospective.children.get(storage_key) - .into_iter() - .flat_map(|map| map.clone().into_iter().map(|(k, v)| (k, v.value)))); - - self.backend.child_storage_root(storage_key, delta) - }; - - if is_empty { - self.overlay.set_storage(storage_key.into(), None); + if let Some(child_info) = self.overlay.child_info(storage_key).cloned() { + let (root, is_empty, _) = { + let delta = self.overlay.committed.children.get(storage_key) + .into_iter() + .flat_map(|(map, _)| map.clone().into_iter().map(|(k, v)| (k, v.value))) + .chain( + self.overlay.prospective.children.get(storage_key) + .into_iter() + .flat_map(|(map, _)| map.clone().into_iter().map(|(k, v)| (k, v.value))) + ); + + self.backend.child_storage_root(storage_key, child_info.as_ref(), delta) + }; + + let root = root.encode(); + // We store update in the overlay in order to be able to use 'self.storage_transaction' + // cache. This is brittle as it rely on Ext only querying the trie backend for + // storage root. + // A better design would be to manage 'child_storage_transaction' in a + // similar way as 'storage_transaction' but for each child trie. + if is_empty { + self.overlay.set_storage(storage_key.into(), None); + } else { + self.overlay.set_storage(storage_key.into(), Some(root.clone())); + } + + trace!(target: "state-trace", "{:04x}: ChildRoot({}) {}", + self.id, + HexDisplay::from(&storage_key.as_ref()), + HexDisplay::from(&root.as_ref()), + ); + root } else { - self.overlay.set_storage(storage_key.into(), Some(root.encode())); + // empty overlay + let root = self + .storage(storage_key.as_ref()) + .and_then(|k| Decode::decode(&mut &k[..]).ok()) + .unwrap_or( + default_child_trie_root::>(storage_key.as_ref()) + ); + trace!(target: "state-trace", "{:04x}: ChildRoot({}) (no change) {}", + self.id, + HexDisplay::from(&storage_key.as_ref()), + HexDisplay::from(&root.as_ref()), + ); + root.encode() } - - trace!(target: "state-trace", "{:04x}: ChildRoot({}) {}", - self.id, - HexDisplay::from(&storage_key.as_ref()), - HexDisplay::from(&root.as_ref()), - ); - root.encode() } } @@ -579,13 +655,14 @@ mod tests { use super::*; use hex_literal::hex; use codec::Encode; - use primitives::{Blake2Hasher, storage::well_known_keys::EXTRINSIC_INDEX}; + use primitives::{Blake2Hasher, storage::well_known_keys::EXTRINSIC_INDEX, map}; use crate::{ changes_trie::{ Configuration as ChangesTrieConfiguration, InMemoryStorage as InMemoryChangesTrieStorage, }, backend::InMemory, overlayed_changes::OverlayedValue, }; + use primitives::storage::{Storage, StorageChild}; type TestBackend = InMemory; type TestChangesTrieStorage = InMemoryChangesTrieStorage; @@ -659,11 +736,14 @@ mod tests { let mut overlay = OverlayedChanges::default(); overlay.set_storage(vec![20], None); overlay.set_storage(vec![30], Some(vec![31])); - let backend = vec![ - (None, vec![10], Some(vec![10])), - (None, vec![20], Some(vec![20])), - (None, vec![40], Some(vec![40])), - ].into(); + let backend = Storage { + top: map![ + vec![10] => vec![10], + vec![20] => vec![20], + vec![40] => vec![40] + ], + children: map![] + }.into(); let ext = TestExt::new(&mut overlay, &backend, None, None); @@ -689,35 +769,50 @@ mod tests { #[test] fn next_child_storage_key_works() { - let child = || ChildStorageKey::from_slice(b":child_storage:default:Child1").unwrap(); + const CHILD_KEY_1: &[u8] = b":child_storage:default:Child1"; + + const CHILD_UUID_1: &[u8] = b"unique_id_1"; + const CHILD_INFO_1: ChildInfo<'static> = ChildInfo::new_default(CHILD_UUID_1); + + + let child = || ChildStorageKey::from_slice(CHILD_KEY_1).unwrap(); let mut overlay = OverlayedChanges::default(); - overlay.set_child_storage(child().as_ref().to_vec(), vec![20], None); - overlay.set_child_storage(child().as_ref().to_vec(), vec![30], Some(vec![31])); - let backend = vec![ - (Some(child().as_ref().to_vec()), vec![10], Some(vec![10])), - (Some(child().as_ref().to_vec()), vec![20], Some(vec![20])), - (Some(child().as_ref().to_vec()), vec![40], Some(vec![40])), - ].into(); + overlay.set_child_storage(child().as_ref().to_vec(), CHILD_INFO_1, vec![20], None); + overlay.set_child_storage(child().as_ref().to_vec(), CHILD_INFO_1, vec![30], Some(vec![31])); + let backend = Storage { + top: map![], + children: map![ + child().as_ref().to_vec() => StorageChild { + data: map![ + vec![10] => vec![10], + vec![20] => vec![20], + vec![40] => vec![40] + ], + child_info: CHILD_INFO_1.to_owned(), + } + ], + }.into(); + let ext = TestExt::new(&mut overlay, &backend, None, None); // next_backend < next_overlay - assert_eq!(ext.next_child_storage_key(child(), &[5]), Some(vec![10])); + assert_eq!(ext.next_child_storage_key(child(), CHILD_INFO_1, &[5]), Some(vec![10])); // next_backend == next_overlay but next_overlay is a delete - assert_eq!(ext.next_child_storage_key(child(), &[10]), Some(vec![30])); + assert_eq!(ext.next_child_storage_key(child(), CHILD_INFO_1, &[10]), Some(vec![30])); // next_overlay < next_backend - assert_eq!(ext.next_child_storage_key(child(), &[20]), Some(vec![30])); + assert_eq!(ext.next_child_storage_key(child(), CHILD_INFO_1, &[20]), Some(vec![30])); // next_backend exist but next_overlay doesn't exist - assert_eq!(ext.next_child_storage_key(child(), &[30]), Some(vec![40])); + assert_eq!(ext.next_child_storage_key(child(), CHILD_INFO_1, &[30]), Some(vec![40])); drop(ext); - overlay.set_child_storage(child().as_ref().to_vec(), vec![50], Some(vec![50])); + overlay.set_child_storage(child().as_ref().to_vec(), CHILD_INFO_1, vec![50], Some(vec![50])); let ext = TestExt::new(&mut overlay, &backend, None, None); // next_overlay exist but next_backend doesn't exist - assert_eq!(ext.next_child_storage_key(child(), &[40]), Some(vec![50])); + assert_eq!(ext.next_child_storage_key(child(), CHILD_INFO_1, &[40]), Some(vec![50])); } } diff --git a/primitives/state-machine/src/lib.rs b/primitives/state-machine/src/lib.rs index 594e539b25..e8043829e7 100644 --- a/primitives/state-machine/src/lib.rs +++ b/primitives/state-machine/src/lib.rs @@ -23,7 +23,7 @@ use log::{warn, trace}; use hash_db::Hasher; use codec::{Decode, Encode, Codec}; use primitives::{ - storage::well_known_keys, NativeOrEncoded, NeverNativeValue, + storage::{well_known_keys, ChildInfo}, NativeOrEncoded, NeverNativeValue, traits::CodeExecutor, hexdisplay::HexDisplay, hash::H256, }; use overlayed_changes::OverlayedChangeSet; @@ -562,6 +562,7 @@ where pub fn prove_child_read( mut backend: B, storage_key: &[u8], + child_info: ChildInfo, keys: I, ) -> Result> where @@ -573,7 +574,7 @@ where { let trie_backend = backend.as_trie_backend() .ok_or_else(|| Box::new(ExecutionError::UnableToGenerateProof) as Box)?; - prove_child_read_on_trie_backend(trie_backend, storage_key, keys) + prove_child_read_on_trie_backend(trie_backend, storage_key, child_info, keys) } /// Generate storage read proof on pre-created trie backend. @@ -601,6 +602,7 @@ where pub fn prove_child_read_on_trie_backend( trie_backend: &TrieBackend, storage_key: &[u8], + child_info: ChildInfo, keys: I, ) -> Result> where @@ -613,7 +615,7 @@ where let proving_backend = proving_backend::ProvingBackend::<_, H>::new(trie_backend); for key in keys.into_iter() { proving_backend - .child_storage(storage_key, key.as_ref()) + .child_storage(storage_key, child_info.clone(), key.as_ref()) .map_err(|e| Box::new(e) as Box)?; } Ok(proving_backend.extract_proof()) @@ -688,7 +690,9 @@ where H: Hasher, H::Out: Ord + Codec, { - proving_backend.child_storage(storage_key, key).map_err(|e| Box::new(e) as Box) + // Not a prefixed memory db, using empty unique id and include root resolution. + proving_backend.child_storage(storage_key, ChildInfo::new_default(&[]), key) + .map_err(|e| Box::new(e) as Box) } /// Sets overlayed changes' changes trie configuration. Returns error if configuration @@ -750,6 +754,8 @@ mod tests { fallback_succeeds: bool, } + const CHILD_INFO_1: ChildInfo<'static> = ChildInfo::new_default(b"unique_id_1"); + impl CodeExecutor for DummyCodeExecutor { type Error = u8; @@ -982,22 +988,26 @@ mod tests { ext.set_child_storage( ChildStorageKey::from_slice(b":child_storage:default:testchild").unwrap(), + CHILD_INFO_1, b"abc".to_vec(), b"def".to_vec() ); assert_eq!( ext.child_storage( ChildStorageKey::from_slice(b":child_storage:default:testchild").unwrap(), + CHILD_INFO_1, b"abc" ), Some(b"def".to_vec()) ); ext.kill_child_storage( - ChildStorageKey::from_slice(b":child_storage:default:testchild").unwrap() + ChildStorageKey::from_slice(b":child_storage:default:testchild").unwrap(), + CHILD_INFO_1, ); assert_eq!( ext.child_storage( ChildStorageKey::from_slice(b":child_storage:default:testchild").unwrap(), + CHILD_INFO_1, b"abc" ), None @@ -1033,6 +1043,7 @@ mod tests { let remote_proof = prove_child_read( remote_backend, b":child_storage:default:sub1", + CHILD_INFO_1, &[b"value3"], ).unwrap(); let local_result1 = read_child_proof_check::( @@ -1081,6 +1092,40 @@ mod tests { assert!(state_machine.execute(ExecutionStrategy::NativeWhenPossible).is_err()); } + #[test] + fn child_storage_uuid() { + const CHILD_INFO_1: ChildInfo<'static> = ChildInfo::new_default(b"unique_id_1"); + const CHILD_INFO_2: ChildInfo<'static> = ChildInfo::new_default(b"unique_id_2"); + use crate::trie_backend::tests::test_trie; + let mut overlay = OverlayedChanges::default(); + + let subtrie1 = ChildStorageKey::from_slice(b":child_storage:default:sub_test1").unwrap(); + let subtrie2 = ChildStorageKey::from_slice(b":child_storage:default:sub_test2").unwrap(); + let mut transaction = { + let backend = test_trie(); + let changes_trie_storage = InMemoryChangesTrieStorage::::new(); + let mut ext = Ext::new( + &mut overlay, + &backend, + Some(&changes_trie_storage), + None, + ); + ext.set_child_storage(subtrie1, CHILD_INFO_1, b"abc".to_vec(), b"def".to_vec()); + ext.set_child_storage(subtrie2, CHILD_INFO_2, b"abc".to_vec(), b"def".to_vec()); + ext.storage_root(); + (ext.transaction().0).0 + }; + let mut duplicate = false; + for (k, (value, rc)) in transaction.drain().iter() { + // look for a key inserted twice: transaction rc is 2 + if *rc == 2 { + duplicate = true; + println!("test duplicate for {:?} {:?}", k, value); + } + } + assert!(!duplicate); + } + #[test] fn cannot_change_changes_trie_config_with_native_else_wasm() { let backend = trie_backend::tests::test_trie(); diff --git a/primitives/state-machine/src/overlayed_changes.rs b/primitives/state-machine/src/overlayed_changes.rs index d61d14961d..0714120ae3 100644 --- a/primitives/state-machine/src/overlayed_changes.rs +++ b/primitives/state-machine/src/overlayed_changes.rs @@ -21,7 +21,7 @@ use std::iter::FromIterator; use std::collections::{HashMap, BTreeMap, BTreeSet}; use codec::Decode; use crate::changes_trie::{NO_EXTRINSIC_INDEX, Configuration as ChangesTrieConfig}; -use primitives::storage::well_known_keys::EXTRINSIC_INDEX; +use primitives::storage::{well_known_keys::EXTRINSIC_INDEX, OwnedChildInfo, ChildInfo}; use std::{mem, ops}; /// The overlayed changes to state to be queried on top of the backend. @@ -57,7 +57,7 @@ pub struct OverlayedChangeSet { /// Top level storage changes. pub top: BTreeMap, OverlayedValue>, /// Child storage changes. - pub children: HashMap, BTreeMap, OverlayedValue>>, + pub children: HashMap, (BTreeMap, OverlayedValue>, OwnedChildInfo)>, } #[cfg(test)] @@ -119,13 +119,13 @@ impl OverlayedChanges { /// value has been set. pub fn child_storage(&self, storage_key: &[u8], key: &[u8]) -> Option> { if let Some(map) = self.prospective.children.get(storage_key) { - if let Some(val) = map.get(key) { + if let Some(val) = map.0.get(key) { return Some(val.value.as_ref().map(AsRef::as_ref)); } } if let Some(map) = self.committed.children.get(storage_key) { - if let Some(val) = map.get(key) { + if let Some(val) = map.0.get(key) { return Some(val.value.as_ref().map(AsRef::as_ref)); } } @@ -150,10 +150,20 @@ impl OverlayedChanges { /// Inserts the given key-value pair into the prospective child change set. /// /// `None` can be used to delete a value specified by the given key. - pub(crate) fn set_child_storage(&mut self, storage_key: Vec, key: Vec, val: Option>) { + pub(crate) fn set_child_storage( + &mut self, + storage_key: Vec, + child_info: ChildInfo, + key: Vec, + val: Option>, + ) { let extrinsic_index = self.extrinsic_index(); - let map_entry = self.prospective.children.entry(storage_key).or_default(); - let entry = map_entry.entry(key).or_default(); + let map_entry = self.prospective.children.entry(storage_key) + .or_insert_with(|| (Default::default(), child_info.to_owned())); + let updatable = map_entry.1.try_update(child_info); + debug_assert!(updatable); + + let entry = map_entry.0.entry(key).or_default(); entry.value = val; if let Some(extrinsic) = extrinsic_index { @@ -168,11 +178,18 @@ impl OverlayedChanges { /// change set, and still can be reverted by [`discard_prospective`]. /// /// [`discard_prospective`]: #method.discard_prospective - pub(crate) fn clear_child_storage(&mut self, storage_key: &[u8]) { + pub(crate) fn clear_child_storage( + &mut self, + storage_key: &[u8], + child_info: ChildInfo, + ) { let extrinsic_index = self.extrinsic_index(); - let map_entry = self.prospective.children.entry(storage_key.to_vec()).or_default(); + let map_entry = self.prospective.children.entry(storage_key.to_vec()) + .or_insert_with(|| (Default::default(), child_info.to_owned())); + let updatable = map_entry.1.try_update(child_info); + debug_assert!(updatable); - map_entry.values_mut().for_each(|e| { + map_entry.0.values_mut().for_each(|e| { if let Some(extrinsic) = extrinsic_index { e.extrinsics.get_or_insert_with(Default::default) .insert(extrinsic); @@ -181,10 +198,10 @@ impl OverlayedChanges { e.value = None; }); - if let Some(committed_map) = self.committed.children.get(storage_key) { + if let Some((committed_map, _child_info)) = self.committed.children.get(storage_key) { for (key, value) in committed_map.iter() { - if !map_entry.contains_key(key) { - map_entry.insert(key.clone(), OverlayedValue { + if !map_entry.0.contains_key(key) { + map_entry.0.insert(key.clone(), OverlayedValue { value: None, extrinsics: extrinsic_index.map(|i| { let mut e = value.extrinsics.clone() @@ -235,11 +252,19 @@ impl OverlayedChanges { } } - pub(crate) fn clear_child_prefix(&mut self, storage_key: &[u8], prefix: &[u8]) { + pub(crate) fn clear_child_prefix( + &mut self, + storage_key: &[u8], + child_info: ChildInfo, + prefix: &[u8], + ) { let extrinsic_index = self.extrinsic_index(); - let map_entry = self.prospective.children.entry(storage_key.to_vec()).or_default(); + let map_entry = self.prospective.children.entry(storage_key.to_vec()) + .or_insert_with(|| (Default::default(), child_info.to_owned())); + let updatable = map_entry.1.try_update(child_info); + debug_assert!(updatable); - for (key, entry) in map_entry.iter_mut() { + for (key, entry) in map_entry.0.iter_mut() { if key.starts_with(prefix) { entry.value = None; @@ -250,12 +275,12 @@ impl OverlayedChanges { } } - if let Some(child_committed) = self.committed.children.get(storage_key) { + if let Some((child_committed, _child_info)) = self.committed.children.get(storage_key) { // Then do the same with keys from commited changes. // NOTE that we are making changes in the prospective change set. for key in child_committed.keys() { if key.starts_with(prefix) { - let entry = map_entry.entry(key.clone()).or_default(); + let entry = map_entry.0.entry(key.clone()).or_default(); entry.value = None; if let Some(extrinsic) = extrinsic_index { @@ -287,10 +312,12 @@ impl OverlayedChanges { .extend(prospective_extrinsics); } } - for (storage_key, map) in self.prospective.children.drain() { - let map_dest = self.committed.children.entry(storage_key).or_default(); + for (storage_key, (map, child_info)) in self.prospective.children.drain() { + let child_content = self.committed.children.entry(storage_key) + .or_insert_with(|| (Default::default(), child_info)); + // No update to child info at this point (will be needed for deletion). for (key, val) in map.into_iter() { - let entry = map_dest.entry(key).or_default(); + let entry = child_content.0.entry(key).or_default(); entry.value = val.value; if let Some(prospective_extrinsics) = val.extrinsics { @@ -308,12 +335,12 @@ impl OverlayedChanges { /// Will panic if there are any uncommitted prospective changes. pub fn into_committed(self) -> ( impl Iterator, Option>)>, - impl Iterator, impl Iterator, Option>)>)>, + impl Iterator, (impl Iterator, Option>)>, OwnedChildInfo))>, ){ assert!(self.prospective.is_empty()); (self.committed.top.into_iter().map(|(k, v)| (k, v.value)), self.committed.children.into_iter() - .map(|(sk, v)| (sk, v.into_iter().map(|(k, v)| (k, v.value))))) + .map(|(sk, (v, ci))| (sk, (v.into_iter().map(|(k, v)| (k, v.value)), ci)))) } /// Inserts storage entry responsible for current extrinsic index. @@ -342,6 +369,18 @@ impl OverlayedChanges { } } + /// Get child info for a storage key. + /// Take the latest value so prospective first. + pub fn child_info(&self, storage_key: &[u8]) -> Option<&OwnedChildInfo> { + if let Some((_, ci)) = self.prospective.children.get(storage_key) { + return Some(&ci); + } + if let Some((_, ci)) = self.committed.children.get(storage_key) { + return Some(&ci); + } + None + } + /// Returns the next (in lexicographic order) storage key in the overlayed alongside its value. /// If no value is next then `None` is returned. pub fn next_storage_key_change(&self, key: &[u8]) -> Option<(&[u8], &OverlayedValue)> { @@ -377,10 +416,10 @@ impl OverlayedChanges { let range = (ops::Bound::Excluded(key), ops::Bound::Unbounded); let next_prospective_key = self.prospective.children.get(storage_key) - .and_then(|map| map.range::<[u8], _>(range).next().map(|(k, v)| (&k[..], v))); + .and_then(|(map, _)| map.range::<[u8], _>(range).next().map(|(k, v)| (&k[..], v))); let next_committed_key = self.committed.children.get(storage_key) - .and_then(|map| map.range::<[u8], _>(range).next().map(|(k, v)| (&k[..], v))); + .and_then(|(map, _)| map.range::<[u8], _>(range).next().map(|(k, v)| (&k[..], v))); match (next_committed_key, next_prospective_key) { // Committed is strictly less than prospective @@ -636,13 +675,14 @@ mod tests { #[test] fn next_child_storage_key_change_works() { let child = b"Child1".to_vec(); + let child_info = ChildInfo::new_default(b"uniqueid"); let mut overlay = OverlayedChanges::default(); - overlay.set_child_storage(child.clone(), vec![20], Some(vec![20])); - overlay.set_child_storage(child.clone(), vec![30], Some(vec![30])); - overlay.set_child_storage(child.clone(), vec![40], Some(vec![40])); + overlay.set_child_storage(child.clone(), child_info, vec![20], Some(vec![20])); + overlay.set_child_storage(child.clone(), child_info, vec![30], Some(vec![30])); + overlay.set_child_storage(child.clone(), child_info, vec![40], Some(vec![40])); overlay.commit_prospective(); - overlay.set_child_storage(child.clone(), vec![10], Some(vec![10])); - overlay.set_child_storage(child.clone(), vec![30], None); + overlay.set_child_storage(child.clone(), child_info, vec![10], Some(vec![10])); + overlay.set_child_storage(child.clone(), child_info, vec![30], None); // next_prospective < next_committed let next_to_5 = overlay.next_child_storage_key_change(&child, &[5]).unwrap(); @@ -664,7 +704,7 @@ mod tests { assert_eq!(next_to_30.0.to_vec(), vec![40]); assert_eq!(next_to_30.1.value, Some(vec![40])); - overlay.set_child_storage(child.clone(), vec![50], Some(vec![50])); + overlay.set_child_storage(child.clone(), child_info, vec![50], Some(vec![50])); // next_prospective, no next_committed let next_to_40 = overlay.next_child_storage_key_change(&child, &[40]).unwrap(); assert_eq!(next_to_40.0.to_vec(), vec![50]); diff --git a/primitives/state-machine/src/proving_backend.rs b/primitives/state-machine/src/proving_backend.rs index 2a9146dfce..3809ac8446 100644 --- a/primitives/state-machine/src/proving_backend.rs +++ b/primitives/state-machine/src/proving_backend.rs @@ -32,6 +32,7 @@ use crate::trie_backend_essence::{Ephemeral, TrieBackendEssence, TrieBackendStor use crate::{Error, ExecutionError, Backend}; use std::collections::{HashMap, HashSet}; use crate::DBValue; +use primitives::storage::ChildInfo; /// Patricia trie-based backend specialized in get value proofs. pub struct ProvingBackendRecorder<'a, S: 'a + TrieBackendStorage, H: 'a + Hasher> { @@ -143,6 +144,7 @@ impl<'a, S, H> ProvingBackendRecorder<'a, S, H> pub fn child_storage( &mut self, storage_key: &[u8], + child_info: ChildInfo, key: &[u8] ) -> Result>, String> { let root = self.storage(storage_key)? @@ -159,6 +161,7 @@ impl<'a, S, H> ProvingBackendRecorder<'a, S, H> read_child_trie_value_with::, _, _>( storage_key, + child_info.keyspace(), &eph, &root.as_ref(), key, @@ -268,20 +271,35 @@ impl<'a, S, H> Backend for ProvingBackend<'a, S, H> self.0.storage(key) } - fn child_storage(&self, storage_key: &[u8], key: &[u8]) -> Result>, Self::Error> { - self.0.child_storage(storage_key, key) + fn child_storage( + &self, + storage_key: &[u8], + child_info: ChildInfo, + key: &[u8], + ) -> Result>, Self::Error> { + self.0.child_storage(storage_key, child_info, key) } - fn next_storage_key(&self, key: &[u8]) -> Result>, Self::Error> { - self.0.next_storage_key(key) + fn for_keys_in_child_storage( + &self, + storage_key: &[u8], + child_info: ChildInfo, + f: F, + ) { + self.0.for_keys_in_child_storage(storage_key, child_info, f) } - fn next_child_storage_key(&self, storage_key: &[u8], key: &[u8]) -> Result>, Self::Error> { - self.0.next_child_storage_key(storage_key, key) + fn next_storage_key(&self, key: &[u8]) -> Result>, Self::Error> { + self.0.next_storage_key(key) } - fn for_keys_in_child_storage(&self, storage_key: &[u8], f: F) { - self.0.for_keys_in_child_storage(storage_key, f) + fn next_child_storage_key( + &self, + storage_key: &[u8], + child_info: ChildInfo, + key: &[u8], + ) -> Result>, Self::Error> { + self.0.next_child_storage_key(storage_key, child_info, key) } fn for_keys_with_prefix(&self, prefix: &[u8], f: F) { @@ -292,8 +310,14 @@ impl<'a, S, H> Backend for ProvingBackend<'a, S, H> self.0.for_key_values_with_prefix(prefix, f) } - fn for_child_keys_with_prefix(&self, storage_key: &[u8], prefix: &[u8], f: F) { - self.0.for_child_keys_with_prefix(storage_key, prefix, f) + fn for_child_keys_with_prefix( + &self, + storage_key: &[u8], + child_info: ChildInfo, + prefix: &[u8], + f: F, + ) { + self.0.for_child_keys_with_prefix(storage_key, child_info, prefix, f) } fn pairs(&self) -> Vec<(Vec, Vec)> { @@ -304,8 +328,13 @@ impl<'a, S, H> Backend for ProvingBackend<'a, S, H> self.0.keys(prefix) } - fn child_keys(&self, child_storage_key: &[u8], prefix: &[u8]) -> Vec> { - self.0.child_keys(child_storage_key, prefix) + fn child_keys( + &self, + storage_key: &[u8], + child_info: ChildInfo, + prefix: &[u8], + ) -> Vec> { + self.0.child_keys(storage_key, child_info, prefix) } fn storage_root(&self, delta: I) -> (H::Out, Self::Transaction) @@ -314,12 +343,17 @@ impl<'a, S, H> Backend for ProvingBackend<'a, S, H> self.0.storage_root(delta) } - fn child_storage_root(&self, storage_key: &[u8], delta: I) -> (H::Out, bool, Self::Transaction) + fn child_storage_root( + &self, + storage_key: &[u8], + child_info: ChildInfo, + delta: I, + ) -> (H::Out, bool, Self::Transaction) where I: IntoIterator, Option>)>, H::Out: Ord { - self.0.child_storage_root(storage_key, delta) + self.0.child_storage_root(storage_key, child_info, delta) } } @@ -363,6 +397,9 @@ mod tests { use primitives::{Blake2Hasher, storage::ChildStorageKey}; use crate::proving_backend::create_proof_check_backend; + const CHILD_INFO_1: ChildInfo<'static> = ChildInfo::new_default(b"unique_id_1"); + const CHILD_INFO_2: ChildInfo<'static> = ChildInfo::new_default(b"unique_id_2"); + fn test_proving<'a>( trie_backend: &'a TrieBackend,Blake2Hasher>, ) -> ProvingBackend<'a, PrefixedMemoryDB, Blake2Hasher> { @@ -408,9 +445,9 @@ mod tests { #[test] fn proof_recorded_and_checked() { - let contents = (0..64).map(|i| (None, vec![i], Some(vec![i]))).collect::>(); + let contents = (0..64).map(|i| (vec![i], Some(vec![i]))).collect::>(); let in_memory = InMemory::::default(); - let mut in_memory = in_memory.update(contents); + let mut in_memory = in_memory.update(vec![(None, contents)]); let in_memory_root = in_memory.storage_root(::std::iter::empty()).0; (0..64).for_each(|i| assert_eq!(in_memory.storage(&[i]).unwrap().unwrap(), vec![i])); @@ -434,26 +471,29 @@ mod tests { let subtrie2 = ChildStorageKey::from_slice(b":child_storage:default:sub2").unwrap(); let own1 = subtrie1.into_owned(); let own2 = subtrie2.into_owned(); - let contents = (0..64).map(|i| (None, vec![i], Some(vec![i]))) - .chain((28..65).map(|i| (Some(own1.clone()), vec![i], Some(vec![i])))) - .chain((10..15).map(|i| (Some(own2.clone()), vec![i], Some(vec![i])))) - .collect::>(); + let contents = vec![ + (None, (0..64).map(|i| (vec![i], Some(vec![i]))).collect()), + (Some((own1.clone(), CHILD_INFO_1.to_owned())), + (28..65).map(|i| (vec![i], Some(vec![i]))).collect()), + (Some((own2.clone(), CHILD_INFO_2.to_owned())), + (10..15).map(|i| (vec![i], Some(vec![i]))).collect()), + ]; let in_memory = InMemory::::default(); let mut in_memory = in_memory.update(contents); let in_memory_root = in_memory.full_storage_root::<_, Vec<_>, _>( ::std::iter::empty(), - in_memory.child_storage_keys().map(|k|(k.to_vec(), Vec::new())) + in_memory.child_storage_keys().map(|k|(k.0.to_vec(), Vec::new(), k.1.to_owned())) ).0; (0..64).for_each(|i| assert_eq!( in_memory.storage(&[i]).unwrap().unwrap(), vec![i] )); (28..65).for_each(|i| assert_eq!( - in_memory.child_storage(&own1[..], &[i]).unwrap().unwrap(), + in_memory.child_storage(&own1[..], CHILD_INFO_1, &[i]).unwrap().unwrap(), vec![i] )); (10..15).for_each(|i| assert_eq!( - in_memory.child_storage(&own2[..], &[i]).unwrap().unwrap(), + in_memory.child_storage(&own2[..], CHILD_INFO_2, &[i]).unwrap().unwrap(), vec![i] )); @@ -481,7 +521,7 @@ mod tests { assert_eq!(proof_check.storage(&[64]).unwrap(), None); let proving = ProvingBackend::new(trie); - assert_eq!(proving.child_storage(&own1[..], &[64]), Ok(Some(vec![64]))); + assert_eq!(proving.child_storage(&own1[..], CHILD_INFO_1, &[64]), Ok(Some(vec![64]))); let proof = proving.extract_proof(); let proof_check = create_proof_check_backend::( @@ -489,7 +529,7 @@ mod tests { proof ).unwrap(); assert_eq!( - proof_check.child_storage(&own1[..], &[64]).unwrap().unwrap(), + proof_check.child_storage(&own1[..], CHILD_INFO_1, &[64]).unwrap().unwrap(), vec![64] ); } diff --git a/primitives/state-machine/src/testing.rs b/primitives/state-machine/src/testing.rs index 85c9260fba..a37cd8caef 100644 --- a/primitives/state-machine/src/testing.rs +++ b/primitives/state-machine/src/testing.rs @@ -16,7 +16,7 @@ //! Test implementation for Externalities. -use std::{collections::{HashMap, BTreeMap}, any::{Any, TypeId}}; +use std::any::{Any, TypeId}; use hash_db::Hasher; use crate::{ backend::{InMemory, Backend}, OverlayedChanges, @@ -28,15 +28,14 @@ use crate::{ }; use primitives::{ storage::{ - well_known_keys::{CHANGES_TRIE_CONFIG, CODE, HEAP_PAGES, is_child_storage_key} + well_known_keys::{CHANGES_TRIE_CONFIG, CODE, HEAP_PAGES, is_child_storage_key}, + Storage, }, hash::H256, Blake2Hasher, }; use codec::Encode; use externalities::{Extensions, Extension}; -type StorageTuple = (BTreeMap, Vec>, HashMap, BTreeMap, Vec>>); - /// Simple HashMap-based Externalities impl. pub struct TestExternalities=Blake2Hasher, N: ChangesTrieBlockNumber=u64> { overlay: OverlayedChanges, @@ -57,42 +56,37 @@ impl, N: ChangesTrieBlockNumber> TestExternalities { } /// Create a new instance of `TestExternalities` with storage. - pub fn new(storage: StorageTuple) -> Self { + pub fn new(storage: Storage) -> Self { Self::new_with_code(&[], storage) } /// Create a new instance of `TestExternalities` with code and storage. - pub fn new_with_code(code: &[u8], mut storage: StorageTuple) -> Self { + pub fn new_with_code(code: &[u8], mut storage: Storage) -> Self { let mut overlay = OverlayedChanges::default(); - assert!(storage.0.keys().all(|key| !is_child_storage_key(key))); - assert!(storage.1.keys().all(|key| is_child_storage_key(key))); + assert!(storage.top.keys().all(|key| !is_child_storage_key(key))); + assert!(storage.children.keys().all(|key| is_child_storage_key(key))); super::set_changes_trie_config( &mut overlay, - storage.0.get(&CHANGES_TRIE_CONFIG.to_vec()).cloned(), + storage.top.get(&CHANGES_TRIE_CONFIG.to_vec()).cloned(), false, ).expect("changes trie configuration is correct in test env; qed"); - storage.0.insert(HEAP_PAGES.to_vec(), 8u64.encode()); - storage.0.insert(CODE.to_vec(), code.to_vec()); - - let backend: HashMap<_, _> = storage.1.into_iter() - .map(|(keyspace, map)| (Some(keyspace), map)) - .chain(Some((None, storage.0)).into_iter()) - .collect(); + storage.top.insert(HEAP_PAGES.to_vec(), 8u64.encode()); + storage.top.insert(CODE.to_vec(), code.to_vec()); TestExternalities { overlay, changes_trie_storage: ChangesTrieInMemoryStorage::new(), - backend: backend.into(), + backend: storage.into(), extensions: Default::default(), } } /// Insert key/value into backend pub fn insert(&mut self, k: Vec, v: Vec) { - self.backend = self.backend.update(vec![(None, k, Some(v))]); + self.backend = self.backend.update(vec![(None, vec![(k, Some(v))])]); } /// Registers the given extension for this instance. @@ -107,19 +101,23 @@ impl, N: ChangesTrieBlockNumber> TestExternalities { /// Return a new backend with all pending value. pub fn commit_all(&self) -> InMemory { - let top = self.overlay.committed.top.clone().into_iter() + let top: Vec<_> = self.overlay.committed.top.clone().into_iter() .chain(self.overlay.prospective.top.clone().into_iter()) - .map(|(k, v)| (None, k, v.value)); + .map(|(k, v)| (k, v.value)).collect(); + let mut transaction = vec![(None, top)]; - let children = self.overlay.committed.children.clone().into_iter() + self.overlay.committed.children.clone().into_iter() .chain(self.overlay.prospective.children.clone().into_iter()) - .flat_map(|(keyspace, map)| { - map.into_iter() - .map(|(k, v)| (Some(keyspace.clone()), k, v.value)) - .collect::>() + .for_each(|(keyspace, (map, child_info))| { + transaction.push(( + Some((keyspace, child_info)), + map.into_iter() + .map(|(k, v)| (k, v.value)) + .collect::>(), + )) }); - self.backend.update(top.chain(children).collect()) + self.backend.update(transaction) } /// Execute the given closure while `self` is set as externalities. @@ -149,8 +147,8 @@ impl, N: ChangesTrieBlockNumber> Default for TestExternaliti fn default() -> Self { Self::new(Default::default()) } } -impl, N: ChangesTrieBlockNumber> From for TestExternalities { - fn from(storage: StorageTuple) -> Self { +impl, N: ChangesTrieBlockNumber> From for TestExternalities { + fn from(storage: Storage) -> Self { Self::new(storage) } } diff --git a/primitives/state-machine/src/trie_backend.rs b/primitives/state-machine/src/trie_backend.rs index f24c47c891..5286f0e505 100644 --- a/primitives/state-machine/src/trie_backend.rs +++ b/primitives/state-machine/src/trie_backend.rs @@ -22,6 +22,7 @@ use trie::{Trie, delta_trie_root, default_child_trie_root, child_delta_trie_root use trie::trie_types::{TrieDB, TrieError, Layout}; use crate::trie_backend_essence::{TrieBackendEssence, TrieBackendStorage, Ephemeral}; use crate::Backend; +use primitives::storage::ChildInfo; use codec::{Codec, Decode}; /// Patricia trie-based backend. Transaction type is an overlay of changes to commit. @@ -75,16 +76,26 @@ impl, H: Hasher> Backend for TrieBackend where self.essence.storage(key) } - fn child_storage(&self, storage_key: &[u8], key: &[u8]) -> Result>, Self::Error> { - self.essence.child_storage(storage_key, key) + fn child_storage( + &self, + storage_key: &[u8], + child_info: ChildInfo, + key: &[u8], + ) -> Result>, Self::Error> { + self.essence.child_storage(storage_key, child_info, key) } fn next_storage_key(&self, key: &[u8]) -> Result>, Self::Error> { self.essence.next_storage_key(key) } - fn next_child_storage_key(&self, storage_key: &[u8], key: &[u8]) -> Result>, Self::Error> { - self.essence.next_child_storage_key(storage_key, key) + fn next_child_storage_key( + &self, + storage_key: &[u8], + child_info: ChildInfo, + key: &[u8], + ) -> Result>, Self::Error> { + self.essence.next_child_storage_key(storage_key, child_info, key) } fn for_keys_with_prefix(&self, prefix: &[u8], f: F) { @@ -95,12 +106,23 @@ impl, H: Hasher> Backend for TrieBackend where self.essence.for_key_values_with_prefix(prefix, f) } - fn for_keys_in_child_storage(&self, storage_key: &[u8], f: F) { - self.essence.for_keys_in_child_storage(storage_key, f) + fn for_keys_in_child_storage( + &self, + storage_key: &[u8], + child_info: ChildInfo, + f: F, + ) { + self.essence.for_keys_in_child_storage(storage_key, child_info, f) } - fn for_child_keys_with_prefix(&self, storage_key: &[u8], prefix: &[u8], f: F) { - self.essence.for_child_keys_with_prefix(storage_key, prefix, f) + fn for_child_keys_with_prefix( + &self, + storage_key: &[u8], + child_info: ChildInfo, + prefix: &[u8], + f: F, + ) { + self.essence.for_child_keys_with_prefix(storage_key, child_info, prefix, f) } fn pairs(&self) -> Vec<(Vec, Vec)> { @@ -168,7 +190,12 @@ impl, H: Hasher> Backend for TrieBackend where (root, write_overlay) } - fn child_storage_root(&self, storage_key: &[u8], delta: I) -> (H::Out, bool, Self::Transaction) + fn child_storage_root( + &self, + storage_key: &[u8], + child_info: ChildInfo, + delta: I, + ) -> (H::Out, bool, Self::Transaction) where I: IntoIterator, Option>)>, H::Out: Ord, @@ -193,6 +220,7 @@ impl, H: Hasher> Backend for TrieBackend where match child_delta_trie_root::, _, _, _, _, _>( storage_key, + child_info.keyspace(), &mut eph, root, delta @@ -217,13 +245,19 @@ pub mod tests { use std::collections::HashSet; use primitives::{Blake2Hasher, H256}; use codec::Encode; - use trie::{TrieMut, PrefixedMemoryDB, trie_types::TrieDBMut}; + use trie::{TrieMut, PrefixedMemoryDB, trie_types::TrieDBMut, KeySpacedDBMut}; use super::*; + const CHILD_KEY_1: &[u8] = b":child_storage:default:sub1"; + + const CHILD_UUID_1: &[u8] = b"unique_id_1"; + const CHILD_INFO_1: ChildInfo<'static> = ChildInfo::new_default(CHILD_UUID_1); + fn test_db() -> (PrefixedMemoryDB, H256) { let mut root = H256::default(); let mut mdb = PrefixedMemoryDB::::default(); { + let mut mdb = KeySpacedDBMut::new(&mut mdb, CHILD_UUID_1); let mut trie = TrieDBMut::new(&mut mdb, &mut root); trie.insert(b"value3", &[142]).expect("insert failed"); trie.insert(b"value4", &[124]).expect("insert failed"); @@ -233,7 +267,7 @@ pub mod tests { let mut sub_root = Vec::new(); root.encode_to(&mut sub_root); let mut trie = TrieDBMut::new(&mut mdb, &mut root); - trie.insert(b":child_storage:default:sub1", &sub_root).expect("insert failed"); + trie.insert(CHILD_KEY_1, &sub_root[..]).expect("insert failed"); trie.insert(b"key", b"value").expect("insert failed"); trie.insert(b"value1", &[42]).expect("insert failed"); trie.insert(b"value2", &[24]).expect("insert failed"); @@ -255,6 +289,15 @@ pub mod tests { assert_eq!(test_trie().storage(b"key").unwrap(), Some(b"value".to_vec())); } + #[test] + fn read_from_child_storage_returns_some() { + let test_trie = test_trie(); + assert_eq!( + test_trie.child_storage(CHILD_KEY_1, CHILD_INFO_1, b"value3").unwrap(), + Some(vec![142u8]), + ); + } + #[test] fn read_from_storage_returns_none() { assert_eq!(test_trie().storage(b"non-existing-key").unwrap(), None); diff --git a/primitives/state-machine/src/trie_backend_essence.rs b/primitives/state-machine/src/trie_backend_essence.rs index f071d19a94..cd8f686a92 100644 --- a/primitives/state-machine/src/trie_backend_essence.rs +++ b/primitives/state-machine/src/trie_backend_essence.rs @@ -23,9 +23,10 @@ use log::{debug, warn}; use hash_db::{self, Hasher, EMPTY_PREFIX, Prefix}; use trie::{Trie, MemoryDB, PrefixedMemoryDB, DBValue, default_child_trie_root, read_trie_value, read_child_trie_value, - for_keys_in_child_trie}; + for_keys_in_child_trie, KeySpacedDB}; use trie::trie_types::{TrieDB, TrieError, Layout}; use crate::backend::Consolidate; +use primitives::storage::ChildInfo; use codec::Encode; /// Patricia trie-based storage trait. @@ -67,7 +68,7 @@ impl, H: Hasher> TrieBackendEssence where H::Out: /// Return the next key in the trie i.e. the minimum key that is strictly superior to `key` in /// lexicographic order. pub fn next_storage_key(&self, key: &[u8]) -> Result>, String> { - self.next_storage_key_from_root(&self.root, key) + self.next_storage_key_from_root(&self.root, None, key) } /// Return the next key in the child trie i.e. the minimum key that is strictly superior to @@ -75,6 +76,7 @@ impl, H: Hasher> TrieBackendEssence where H::Out: pub fn next_child_storage_key( &self, storage_key: &[u8], + child_info: ChildInfo, key: &[u8], ) -> Result>, String> { let child_root = match self.storage(storage_key)? { @@ -90,13 +92,14 @@ impl, H: Hasher> TrieBackendEssence where H::Out: // note: child_root and hash must be same size, panics otherwise. hash.as_mut().copy_from_slice(&child_root[..]); - self.next_storage_key_from_root(&hash, key) + self.next_storage_key_from_root(&hash, Some(child_info), key) } /// Return next key from main trie or child trie by providing corresponding root. fn next_storage_key_from_root( &self, root: &H::Out, + child_info: Option, key: &[u8], ) -> Result>, String> { let mut read_overlay = S::Overlay::default(); @@ -104,8 +107,16 @@ impl, H: Hasher> TrieBackendEssence where H::Out: storage: &self.storage, overlay: &mut read_overlay, }; + let dyn_eph: &dyn hash_db::HashDBRef<_, _>; + let keyspace_eph; + if let Some(child_info) = child_info.as_ref() { + keyspace_eph = KeySpacedDB::new(&eph, child_info.keyspace()); + dyn_eph = &keyspace_eph; + } else { + dyn_eph = &eph; + } - let trie = TrieDB::::new(&eph, root) + let trie = TrieDB::::new(dyn_eph, root) .map_err(|e| format!("TrieDB creation error: {}", e))?; let mut iter = trie.iter() .map_err(|e| format!("TrieDB iteration error: {}", e))?; @@ -148,7 +159,12 @@ impl, H: Hasher> TrieBackendEssence where H::Out: } /// Get the value of child storage at given key. - pub fn child_storage(&self, storage_key: &[u8], key: &[u8]) -> Result>, String> { + pub fn child_storage( + &self, + storage_key: &[u8], + child_info: ChildInfo, + key: &[u8], + ) -> Result>, String> { let root = self.storage(storage_key)? .unwrap_or(default_child_trie_root::>(storage_key).encode()); @@ -160,11 +176,17 @@ impl, H: Hasher> TrieBackendEssence where H::Out: let map_e = |e| format!("Trie lookup error: {}", e); - read_child_trie_value::, _>(storage_key, &eph, &root, key).map_err(map_e) + read_child_trie_value::, _>(storage_key, child_info.keyspace(), &eph, &root, key) + .map_err(map_e) } /// Retrieve all entries keys of child storage and call `f` for each of those keys. - pub fn for_keys_in_child_storage(&self, storage_key: &[u8], f: F) { + pub fn for_keys_in_child_storage( + &self, + storage_key: &[u8], + child_info: ChildInfo, + f: F, + ) { let root = match self.storage(storage_key) { Ok(v) => v.unwrap_or(default_child_trie_root::>(storage_key).encode()), Err(e) => { @@ -181,6 +203,7 @@ impl, H: Hasher> TrieBackendEssence where H::Out: if let Err(e) = for_keys_in_child_trie::, _, Ephemeral>( storage_key, + child_info.keyspace(), &eph, &root, f, @@ -193,6 +216,7 @@ impl, H: Hasher> TrieBackendEssence where H::Out: pub fn for_child_keys_with_prefix( &self, storage_key: &[u8], + child_info: ChildInfo, prefix: &[u8], mut f: F, ) { @@ -205,13 +229,12 @@ impl, H: Hasher> TrieBackendEssence where H::Out: }; let mut root = H::Out::default(); root.as_mut().copy_from_slice(&root_vec); - - self.keys_values_with_prefix_inner(&root, prefix, |k, _v| f(k)) + self.keys_values_with_prefix_inner(&root, prefix, |k, _v| f(k), Some(child_info)) } /// Execute given closure for all keys starting with prefix. pub fn for_keys_with_prefix(&self, prefix: &[u8], mut f: F) { - self.keys_values_with_prefix_inner(&self.root, prefix, |k, _v| f(k)) + self.keys_values_with_prefix_inner(&self.root, prefix, |k, _v| f(k), None) } @@ -220,15 +243,16 @@ impl, H: Hasher> TrieBackendEssence where H::Out: root: &H::Out, prefix: &[u8], mut f: F, + child_info: Option, ) { let mut read_overlay = S::Overlay::default(); let eph = Ephemeral { storage: &self.storage, overlay: &mut read_overlay, }; - - let mut iter = move || -> Result<(), Box>> { - let trie = TrieDB::::new(&eph, root)?; + + let mut iter = move |db| -> Result<(), Box>> { + let trie = TrieDB::::new(db, root)?; let mut iter = trie.iter()?; iter.seek(prefix)?; @@ -246,14 +270,20 @@ impl, H: Hasher> TrieBackendEssence where H::Out: Ok(()) }; - if let Err(e) = iter() { + let result = if let Some(child_info) = child_info { + let db = KeySpacedDB::new(&eph, child_info.keyspace()); + iter(&db) + } else { + iter(&eph) + }; + if let Err(e) = result { debug!(target: "trie", "Error while iterating by prefix: {}", e); } } /// Execute given closure for all key and values starting with prefix. pub fn for_key_values_with_prefix(&self, prefix: &[u8], f: F) { - self.keys_values_with_prefix_inner(&self.root, prefix, f) + self.keys_values_with_prefix_inner(&self.root, prefix, f, None) } } @@ -419,11 +449,12 @@ impl TrieBackendStorage for MemoryDB { #[cfg(test)] mod test { use primitives::{Blake2Hasher, H256}; - use trie::{TrieMut, PrefixedMemoryDB, trie_types::TrieDBMut}; + use trie::{TrieMut, PrefixedMemoryDB, trie_types::TrieDBMut, KeySpacedDBMut}; use super::*; #[test] fn next_storage_key_and_next_child_storage_key_work() { + let child_info = ChildInfo::new_default(b"uniqueid"); // Contains values let mut root_1 = H256::default(); // Contains child trie @@ -436,6 +467,15 @@ mod test { trie.insert(b"4", &[1]).expect("insert failed"); trie.insert(b"6", &[1]).expect("insert failed"); } + { + let mut mdb = KeySpacedDBMut::new(&mut mdb, child_info.keyspace()); + // reuse of root_1 implicitly assert child trie root is same + // as top trie (contents must remain the same). + let mut trie = TrieDBMut::new(&mut mdb, &mut root_1); + trie.insert(b"3", &[1]).expect("insert failed"); + trie.insert(b"4", &[1]).expect("insert failed"); + trie.insert(b"6", &[1]).expect("insert failed"); + } { let mut trie = TrieDBMut::new(&mut mdb, &mut root_2); trie.insert(b"MyChild", root_1.as_ref()).expect("insert failed"); @@ -452,10 +492,20 @@ mod test { let mdb = essence_1.into_storage(); let essence_2 = TrieBackendEssence::new(mdb, root_2); - assert_eq!(essence_2.next_child_storage_key(b"MyChild", b"2"), Ok(Some(b"3".to_vec()))); - assert_eq!(essence_2.next_child_storage_key(b"MyChild", b"3"), Ok(Some(b"4".to_vec()))); - assert_eq!(essence_2.next_child_storage_key(b"MyChild", b"4"), Ok(Some(b"6".to_vec()))); - assert_eq!(essence_2.next_child_storage_key(b"MyChild", b"5"), Ok(Some(b"6".to_vec()))); - assert_eq!(essence_2.next_child_storage_key(b"MyChild", b"6"), Ok(None)); + assert_eq!( + essence_2.next_child_storage_key(b"MyChild", child_info, b"2"), Ok(Some(b"3".to_vec())) + ); + assert_eq!( + essence_2.next_child_storage_key(b"MyChild", child_info, b"3"), Ok(Some(b"4".to_vec())) + ); + assert_eq!( + essence_2.next_child_storage_key(b"MyChild", child_info, b"4"), Ok(Some(b"6".to_vec())) + ); + assert_eq!( + essence_2.next_child_storage_key(b"MyChild", child_info, b"5"), Ok(Some(b"6".to_vec())) + ); + assert_eq!( + essence_2.next_child_storage_key(b"MyChild", child_info, b"6"), Ok(None) + ); } } diff --git a/primitives/storage/src/lib.rs b/primitives/storage/src/lib.rs index 9d10d692e5..491a157ebe 100644 --- a/primitives/storage/src/lib.rs +++ b/primitives/storage/src/lib.rs @@ -40,13 +40,31 @@ pub struct StorageData( pub Vec, ); -/// A set of key value pairs for storage. +/// Map of data to use in a storage, it is a collection of +/// byte key and values. #[cfg(feature = "std")] -pub type StorageOverlay = std::collections::BTreeMap, Vec>; +pub type StorageMap = std::collections::BTreeMap, Vec>; -/// A set of key value pairs for children storage; #[cfg(feature = "std")] -pub type ChildrenStorageOverlay = std::collections::HashMap, StorageOverlay>; +#[derive(Debug, PartialEq, Eq, Clone)] +/// Child trie storage data. +pub struct StorageChild { + /// Child data for storage. + pub data: StorageMap, + /// Associated child info for a child + /// trie. + pub child_info: OwnedChildInfo, +} + +#[cfg(feature = "std")] +#[derive(Default, Debug, Clone)] +/// Struct containing data needed for a storage. +pub struct Storage { + /// Top trie storage data. + pub top: StorageMap, + /// Children trie storage data by storage key. + pub children: std::collections::HashMap, StorageChild>, +} /// Storage change set #[derive(RuntimeDebug)] @@ -156,3 +174,132 @@ impl<'a> ChildStorageKey<'a> { self.storage_key.into_owned() } } + +#[derive(Clone, Copy)] +/// Information related to a child state. +pub enum ChildInfo<'a> { + Default(ChildTrie<'a>), +} + +/// Owned version of `ChildInfo`. +/// To be use in persistence layers. +#[derive(Debug, Clone)] +#[cfg_attr(feature = "std", derive(PartialEq, Eq, Hash, PartialOrd, Ord))] +pub enum OwnedChildInfo { + Default(OwnedChildTrie), +} + +impl<'a> ChildInfo<'a> { + /// Instantiates information for a default child trie. + pub const fn new_default(unique_id: &'a[u8]) -> Self { + ChildInfo::Default(ChildTrie { + data: unique_id, + }) + } + + /// Instantiates a owned version of this child info. + pub fn to_owned(&self) -> OwnedChildInfo { + match self { + ChildInfo::Default(ChildTrie { data }) + => OwnedChildInfo::Default(OwnedChildTrie { + data: data.to_vec(), + }), + } + } + + /// Create child info from a linear byte packed value and a given type. + pub fn resolve_child_info(child_type: u32, data: &'a[u8]) -> Option { + match child_type { + x if x == ChildType::CryptoUniqueId as u32 => Some(ChildInfo::new_default(data)), + _ => None, + } + } + + /// Return a single byte vector containing packed child info content and its child info type. + /// This can be use as input for `resolve_child_info`. + pub fn info(&self) -> (&[u8], u32) { + match self { + ChildInfo::Default(ChildTrie { + data, + }) => (data, ChildType::CryptoUniqueId as u32), + } + } + + /// Return byte sequence (keyspace) that can be use by underlying db to isolate keys. + /// This is a unique id of the child trie. The collision resistance of this value + /// depends on the type of child info use. For `ChildInfo::Default` it is and need to be. + pub fn keyspace(&self) -> &[u8] { + match self { + ChildInfo::Default(ChildTrie { + data, + }) => &data[..], + } + } +} + +/// Type of child. +/// It does not strictly define different child type, it can also +/// be related to technical consideration or api variant. +#[repr(u32)] +pub enum ChildType { + /// Default, it uses a cryptographic strong unique id as input. + CryptoUniqueId = 1, +} + +impl OwnedChildInfo { + /// Instantiates info for a default child trie. + pub fn new_default(unique_id: Vec) -> Self { + OwnedChildInfo::Default(OwnedChildTrie { + data: unique_id, + }) + } + + /// Try to update with another instance, return false if both instance + /// are not compatible. + pub fn try_update(&mut self, other: ChildInfo) -> bool { + match self { + OwnedChildInfo::Default(owned_child_trie) => owned_child_trie.try_update(other), + } + } + + /// Get `ChildInfo` reference to this owned child info. + pub fn as_ref(&self) -> ChildInfo { + match self { + OwnedChildInfo::Default(OwnedChildTrie { data }) + => ChildInfo::Default(ChildTrie { + data: data.as_slice(), + }), + } + } +} + +/// A child trie of default type. +/// Default is the same implementation as the top trie. +/// It share its trie node storage with any kind of key, +/// and its unique id needs to be collision free (eg strong +/// crypto hash). +#[derive(Clone, Copy)] +pub struct ChildTrie<'a> { + /// Data containing unique id. + /// Unique id must but unique and free of any possible key collision + /// (depending on its storage behavior). + data: &'a[u8], +} + +/// Owned version of default child trie `ChildTrie`. +#[derive(Debug, Clone)] +#[cfg_attr(feature = "std", derive(PartialEq, Eq, Hash, PartialOrd, Ord))] +pub struct OwnedChildTrie { + /// See `ChildTrie` reference field documentation. + data: Vec, +} + +impl OwnedChildTrie { + /// Try to update with another instance, return false if both instance + /// are not compatible. + fn try_update(&mut self, other: ChildInfo) -> bool { + match other { + ChildInfo::Default(other) => self.data[..] == other.data[..], + } + } +} diff --git a/primitives/trie/src/lib.rs b/primitives/trie/src/lib.rs index 711ce302f0..244752f44b 100644 --- a/primitives/trie/src/lib.rs +++ b/primitives/trie/src/lib.rs @@ -24,8 +24,9 @@ mod node_codec; mod trie_stream; use sp_std::boxed::Box; +use sp_std::marker::PhantomData; use sp_std::vec::Vec; -use hash_db::Hasher; +use hash_db::{Hasher, Prefix}; /// Our `NodeCodec`-specific error. pub use error::Error; /// The Substrate format implementation of `TrieStream`. @@ -191,6 +192,7 @@ pub fn child_trie_root( /// but a generic implementation may ignore this type parameter and use other hashers. pub fn child_delta_trie_root( _storage_key: &[u8], + keyspace: &[u8], db: &mut DB, root_data: RD, delta: I, @@ -208,7 +210,8 @@ pub fn child_delta_trie_root( root.as_mut().copy_from_slice(root_data.as_ref()); { - let mut trie = TrieDBMut::::from_existing(&mut *db, &mut root)?; + let mut db = KeySpacedDBMut::new(&mut *db, keyspace); + let mut trie = TrieDBMut::::from_existing(&mut db, &mut root)?; for (key, change) in delta { match change { @@ -224,6 +227,7 @@ pub fn child_delta_trie_root( /// Call `f` for all keys in a child trie. pub fn for_keys_in_child_trie( _storage_key: &[u8], + keyspace: &[u8], db: &DB, root_slice: &[u8], mut f: F @@ -236,7 +240,8 @@ pub fn for_keys_in_child_trie( // root is fetched from DB, not writable by runtime, so it's always valid. root.as_mut().copy_from_slice(root_slice); - let trie = TrieDB::::new(&*db, &root)?; + let db = KeySpacedDB::new(&*db, keyspace); + let trie = TrieDB::::new(&db, &root)?; let iter = trie.iter()?; for x in iter { @@ -273,6 +278,7 @@ pub fn record_all_keys( /// Read a value from the child trie. pub fn read_child_trie_value( _storage_key: &[u8], + keyspace: &[u8], db: &DB, root_slice: &[u8], key: &[u8] @@ -285,12 +291,14 @@ pub fn read_child_trie_value( // root is fetched from DB, not writable by runtime, so it's always valid. root.as_mut().copy_from_slice(root_slice); - Ok(TrieDB::::new(&*db, &root)?.get(key).map(|x| x.map(|val| val.to_vec()))?) + let db = KeySpacedDB::new(&*db, keyspace); + Ok(TrieDB::::new(&db, &root)?.get(key).map(|x| x.map(|val| val.to_vec()))?) } /// Read a value from the child trie with given query. pub fn read_child_trie_value_with, DB>( _storage_key: &[u8], + keyspace: &[u8], db: &DB, root_slice: &[u8], key: &[u8], @@ -304,7 +312,104 @@ pub fn read_child_trie_value_with::new(&*db, &root)?.get_with(key, query).map(|x| x.map(|val| val.to_vec()))?) + let db = KeySpacedDB::new(&*db, keyspace); + Ok(TrieDB::::new(&db, &root)?.get_with(key, query).map(|x| x.map(|val| val.to_vec()))?) +} + +/// `HashDB` implementation that append a encoded prefix (unique id bytes) in addition to the +/// prefix of every key value. +pub struct KeySpacedDB<'a, DB, H>(&'a DB, &'a [u8], PhantomData); + +/// `HashDBMut` implementation that append a encoded prefix (unique id bytes) in addition to the +/// prefix of every key value. +/// +/// Mutable variant of `KeySpacedDB`, see [`KeySpacedDB`]. +pub struct KeySpacedDBMut<'a, DB, H>(&'a mut DB, &'a [u8], PhantomData); + +/// Utility function used to merge some byte data (keyspace) and `prefix` data +/// before calling key value database primitives. +fn keyspace_as_prefix_alloc(ks: &[u8], prefix: Prefix) -> (Vec, Option) { + let mut result = sp_std::vec![0; ks.len() + prefix.0.len()]; + result[..ks.len()].copy_from_slice(ks); + result[ks.len()..].copy_from_slice(prefix.0); + (result, prefix.1) +} + +impl<'a, DB, H> KeySpacedDB<'a, DB, H> where + H: Hasher, +{ + /// instantiate new keyspaced db + pub fn new(db: &'a DB, ks: &'a [u8]) -> Self { + KeySpacedDB(db, ks, PhantomData) + } +} + +impl<'a, DB, H> KeySpacedDBMut<'a, DB, H> where + H: Hasher, +{ + /// instantiate new keyspaced db + pub fn new(db: &'a mut DB, ks: &'a [u8]) -> Self { + KeySpacedDBMut(db, ks, PhantomData) + } +} + +impl<'a, DB, H, T> hash_db::HashDBRef for KeySpacedDB<'a, DB, H> where + DB: hash_db::HashDBRef, + H: Hasher, + T: From<&'static [u8]>, +{ + fn get(&self, key: &H::Out, prefix: Prefix) -> Option { + let derived_prefix = keyspace_as_prefix_alloc(self.1, prefix); + self.0.get(key, (&derived_prefix.0, derived_prefix.1)) + } + + fn contains(&self, key: &H::Out, prefix: Prefix) -> bool { + let derived_prefix = keyspace_as_prefix_alloc(self.1, prefix); + self.0.contains(key, (&derived_prefix.0, derived_prefix.1)) + } +} + +impl<'a, DB, H, T> hash_db::HashDB for KeySpacedDBMut<'a, DB, H> where + DB: hash_db::HashDB, + H: Hasher, + T: Default + PartialEq + for<'b> From<&'b [u8]> + Clone + Send + Sync, +{ + fn get(&self, key: &H::Out, prefix: Prefix) -> Option { + let derived_prefix = keyspace_as_prefix_alloc(self.1, prefix); + self.0.get(key, (&derived_prefix.0, derived_prefix.1)) + } + + fn contains(&self, key: &H::Out, prefix: Prefix) -> bool { + let derived_prefix = keyspace_as_prefix_alloc(self.1, prefix); + self.0.contains(key, (&derived_prefix.0, derived_prefix.1)) + } + + fn insert(&mut self, prefix: Prefix, value: &[u8]) -> H::Out { + let derived_prefix = keyspace_as_prefix_alloc(self.1, prefix); + self.0.insert((&derived_prefix.0, derived_prefix.1), value) + } + + fn emplace(&mut self, key: H::Out, prefix: Prefix, value: T) { + let derived_prefix = keyspace_as_prefix_alloc(self.1, prefix); + self.0.emplace(key, (&derived_prefix.0, derived_prefix.1), value) + } + + fn remove(&mut self, key: &H::Out, prefix: Prefix) { + let derived_prefix = keyspace_as_prefix_alloc(self.1, prefix); + self.0.remove(key, (&derived_prefix.0, derived_prefix.1)) + } +} + +impl<'a, DB, H, T> hash_db::AsHashDB for KeySpacedDBMut<'a, DB, H> where + DB: hash_db::HashDB, + H: Hasher, + T: Default + PartialEq + for<'b> From<&'b [u8]> + Clone + Send + Sync, +{ + fn as_hash_db(&self) -> &dyn hash_db::HashDB { &*self } + + fn as_hash_db_mut<'b>(&'b mut self) -> &'b mut (dyn hash_db::HashDB + 'b) { + &mut *self + } } /// Constants used into trie simplification codec. diff --git a/test-utils/client/src/lib.rs b/test-utils/client/src/lib.rs index 29370ba16c..c6067e5d7c 100644 --- a/test-utils/client/src/lib.rs +++ b/test-utils/client/src/lib.rs @@ -32,13 +32,13 @@ pub use keyring::{ sr25519::Keyring as Sr25519Keyring, }; pub use primitives::{Blake2Hasher, traits::BareCryptoStorePtr}; -pub use sp_runtime::{StorageOverlay, ChildrenStorageOverlay}; +pub use sp_runtime::{Storage, StorageChild}; pub use state_machine::ExecutionStrategy; use std::sync::Arc; use std::collections::HashMap; use hash_db::Hasher; -use primitives::storage::well_known_keys; +use primitives::storage::{well_known_keys, ChildInfo}; use sp_runtime::traits::Block as BlockT; use client::LocalCallExecutor; @@ -51,11 +51,11 @@ pub type LightBackend = client::light::backend::Backend< /// A genesis storage initialisation trait. pub trait GenesisInit: Default { /// Construct genesis storage. - fn genesis_storage(&self) -> (StorageOverlay, ChildrenStorageOverlay); + fn genesis_storage(&self) -> Storage; } impl GenesisInit for () { - fn genesis_storage(&self) -> (StorageOverlay, ChildrenStorageOverlay) { + fn genesis_storage(&self) -> Storage { Default::default() } } @@ -64,7 +64,7 @@ impl GenesisInit for () { pub struct TestClientBuilder { execution_strategies: ExecutionStrategies, genesis_init: G, - child_storage_extension: HashMap, Vec<(Vec, Vec)>>, + child_storage_extension: HashMap, StorageChild>, backend: Arc, _executor: std::marker::PhantomData, keystore: Option, @@ -136,10 +136,15 @@ impl TestClientBuilder mut self, key: impl AsRef<[u8]>, child_key: impl AsRef<[u8]>, + child_info: ChildInfo, value: impl AsRef<[u8]>, ) -> Self { - let entry = self.child_storage_extension.entry(key.as_ref().to_vec()).or_insert_with(Vec::new); - entry.push((child_key.as_ref().to_vec(), value.as_ref().to_vec())); + let entry = self.child_storage_extension.entry(key.as_ref().to_vec()) + .or_insert_with(|| StorageChild { + data: Default::default(), + child_info: child_info.to_owned(), + }); + entry.data.insert(child_key.as_ref().to_vec(), value.as_ref().to_vec()); self } @@ -180,10 +185,13 @@ impl TestClientBuilder let mut storage = self.genesis_init.genesis_storage(); // Add some child storage keys. - for (key, value) in self.child_storage_extension { - storage.1.insert( + for (key, child_content) in self.child_storage_extension { + storage.children.insert( well_known_keys::CHILD_STORAGE_KEY_PREFIX.iter().cloned().chain(key).collect(), - value.into_iter().collect(), + StorageChild { + data: child_content.data.into_iter().collect(), + child_info: child_content.child_info, + }, ); } diff --git a/test-utils/runtime/client/src/lib.rs b/test-utils/runtime/client/src/lib.rs index 8511750bc2..13d9b19553 100644 --- a/test-utils/runtime/client/src/lib.rs +++ b/test-utils/runtime/client/src/lib.rs @@ -23,12 +23,13 @@ pub mod trait_tests; mod block_builder_ext; use std::sync::Arc; -use std::collections::{HashMap, BTreeMap}; +use std::collections::HashMap; pub use block_builder_ext::BlockBuilderExt; pub use generic_test_client::*; pub use runtime; use primitives::sr25519; +use primitives::storage::{ChildInfo, Storage, StorageChild}; use runtime::genesismap::{GenesisConfig, additional_storage_with_genesis}; use sp_runtime::traits::{Block as BlockT, Header as HeaderT, Hash as HashT, NumberFor}; use client::{ @@ -97,8 +98,7 @@ pub type LightExecutor = client::light::call_executor::GenesisCallExecutor< pub struct GenesisParameters { support_changes_trie: bool, heap_pages_override: Option, - extra_storage: BTreeMap, Vec>, - child_extra_storage: HashMap, BTreeMap, Vec>>, + extra_storage: Storage, } impl GenesisParameters { @@ -118,27 +118,26 @@ impl GenesisParameters { 1000, self.heap_pages_override, self.extra_storage.clone(), - self.child_extra_storage.clone(), ) } } impl generic_test_client::GenesisInit for GenesisParameters { - fn genesis_storage(&self) -> (StorageOverlay, ChildrenStorageOverlay) { + fn genesis_storage(&self) -> Storage { use codec::Encode; let mut storage = self.genesis_config().genesis_map(); - let child_roots = storage.1.iter().map(|(sk, child_map)| { + let child_roots = storage.children.iter().map(|(sk, child_content)| { let state_root = <<::Header as HeaderT>::Hashing as HashT>::trie_root( - child_map.clone().into_iter().collect() + child_content.data.clone().into_iter().collect() ); (sk.clone(), state_root.encode()) }); let state_root = <<::Header as HeaderT>::Hashing as HashT>::trie_root( - storage.0.clone().into_iter().chain(child_roots).collect() + storage.top.clone().into_iter().chain(child_roots).collect() ); let block: runtime::Block = client::genesis::construct_genesis_block(state_root); - storage.0.extend(additional_storage_with_genesis(&block)); + storage.top.extend(additional_storage_with_genesis(&block)); storage } @@ -189,6 +188,7 @@ pub trait TestClientBuilderExt: Sized { fn add_extra_child_storage>, K: Into>, V: Into>>( self, storage_key: SK, + child_info: ChildInfo, key: K, value: V, ) -> Self; @@ -228,13 +228,14 @@ impl TestClientBuilderExt for TestClientBuilder< fn add_extra_storage>, V: Into>>(mut self, key: K, value: V) -> Self { let key = key.into(); assert!(!key.is_empty()); - self.genesis_init_mut().extra_storage.insert(key, value.into()); + self.genesis_init_mut().extra_storage.top.insert(key, value.into()); self } fn add_extra_child_storage>, K: Into>, V: Into>>( mut self, storage_key: SK, + child_info: ChildInfo, key: K, value: V, ) -> Self { @@ -242,10 +243,12 @@ impl TestClientBuilderExt for TestClientBuilder< let key = key.into(); assert!(!storage_key.is_empty()); assert!(!key.is_empty()); - self.genesis_init_mut().child_extra_storage + self.genesis_init_mut().extra_storage.children .entry(storage_key) - .or_insert_with(Default::default) - .insert(key, value.into()); + .or_insert_with(|| StorageChild { + data: Default::default(), + child_info: child_info.to_owned(), + }).data.insert(key, value.into()); self } diff --git a/test-utils/runtime/src/genesismap.rs b/test-utils/runtime/src/genesismap.rs index 5b65b54dce..85d513c2cf 100644 --- a/test-utils/runtime/src/genesismap.rs +++ b/test-utils/runtime/src/genesismap.rs @@ -16,11 +16,12 @@ //! Tool for creating the genesis block. -use std::collections::{BTreeMap, HashMap}; +use std::collections::BTreeMap; 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}; +use primitives::{ChangesTrieConfiguration, map}; +use primitives::storage::{well_known_keys, Storage}; use sp_runtime::traits::{Block as BlockT, Hash as HashT, Header as HeaderT}; /// Configuration of a general Substrate test genesis block. @@ -30,8 +31,7 @@ pub struct GenesisConfig { balances: Vec<(AccountId, u64)>, heap_pages_override: Option, /// Additional storage key pairs that will be added to the genesis map. - extra_storage: BTreeMap, Vec>, - child_extra_storage: HashMap, BTreeMap, Vec>>, + extra_storage: Storage, } impl GenesisConfig { @@ -41,8 +41,7 @@ impl GenesisConfig { endowed_accounts: Vec, balance: u64, heap_pages_override: Option, - extra_storage: BTreeMap, Vec>, - child_extra_storage: HashMap, BTreeMap, Vec>>, + extra_storage: Storage, ) -> Self { GenesisConfig { changes_trie_config: match support_changes_trie { @@ -53,14 +52,10 @@ impl GenesisConfig { balances: endowed_accounts.into_iter().map(|a| (a, balance)).collect(), heap_pages_override, extra_storage, - child_extra_storage, } } - pub fn genesis_map(&self) -> ( - BTreeMap, Vec>, - HashMap, BTreeMap, Vec>>, - ) { + pub fn genesis_map(&self) -> Storage { let wasm_runtime = WASM_BINARY.to_vec(); let mut map: BTreeMap, Vec> = self.balances.iter() .map(|&(ref account, balance)| (account.to_keyed_vec(b"balance:"), vec![].and(&balance))) @@ -78,10 +73,10 @@ impl GenesisConfig { } map.insert(twox_128(&b"sys:auth"[..])[..].to_vec(), self.authorities.encode()); // Add the extra storage entries. - map.extend(self.extra_storage.clone().into_iter()); + map.extend(self.extra_storage.top.clone().into_iter()); // Assimilate the system genesis config. - let mut storage = (map, self.child_extra_storage.clone()); + let mut storage = Storage { top: map, children: self.extra_storage.children.clone()}; let mut config = system::GenesisConfig::default(); config.authorities = self.authorities.clone(); config.assimilate_storage(&mut storage).expect("Adding `system::GensisConfig` to the genesis"); @@ -91,23 +86,22 @@ impl GenesisConfig { } pub fn insert_genesis_block( - storage: &mut ( - BTreeMap, Vec>, - HashMap, BTreeMap, Vec>>, - ) + storage: &mut Storage, ) -> primitives::hash::H256 { - let child_roots = storage.1.iter().map(|(sk, child_map)| { + let child_roots = storage.children.iter().map(|(sk, child_content)| { let state_root = <<::Header as HeaderT>::Hashing as HashT>::trie_root( - child_map.clone().into_iter().collect(), + child_content.data.clone().into_iter().collect(), ); (sk.clone(), state_root.encode()) }); + // add child roots to storage + storage.top.extend(child_roots); let state_root = <<::Header as HeaderT>::Hashing as HashT>::trie_root( - storage.0.clone().into_iter().chain(child_roots).collect() + storage.top.clone().into_iter().collect() ); let block: crate::Block = sc_client::genesis::construct_genesis_block(state_root); let genesis_hash = block.header.hash(); - storage.0.extend(additional_storage_with_genesis(&block)); + storage.top.extend(additional_storage_with_genesis(&block)); genesis_hash } diff --git a/test-utils/runtime/src/lib.rs b/test-utils/runtime/src/lib.rs index dcb76e27ef..785d8dec5b 100644 --- a/test-utils/runtime/src/lib.rs +++ b/test-utils/runtime/src/lib.rs @@ -50,6 +50,7 @@ use runtime_version::NativeVersion; use runtime_support::{impl_outer_origin, parameter_types, weights::Weight}; use inherents::{CheckInherentsResult, InherentData}; use cfg_if::cfg_if; +use primitives::storage::ChildType; // Ensure Babe and Aura use the same crypto to simplify things a bit. pub use babe_primitives::AuthorityId; @@ -910,21 +911,37 @@ fn test_read_storage() { fn test_read_child_storage() { const CHILD_KEY: &[u8] = b":child_storage:default:read_child_storage"; + const UNIQUE_ID: &[u8] = b":unique_id"; const KEY: &[u8] = b":read_child_storage"; - sp_io::storage::child_set(CHILD_KEY, KEY, b"test"); + sp_io::storage::child_set( + CHILD_KEY, + UNIQUE_ID, + ChildType::CryptoUniqueId as u32, + KEY, + b"test", + ); let mut v = [0u8; 4]; let r = sp_io::storage::child_read( CHILD_KEY, + UNIQUE_ID, + ChildType::CryptoUniqueId as u32, KEY, &mut v, - 0 + 0, ); assert_eq!(r, Some(4)); assert_eq!(&v, b"test"); let mut v = [0u8; 4]; - let r = sp_io::storage::child_read(CHILD_KEY, KEY, &mut v, 8); + let r = sp_io::storage::child_read( + CHILD_KEY, + UNIQUE_ID, + ChildType::CryptoUniqueId as u32, + KEY, + &mut v, + 8, + ); assert_eq!(r, Some(4)); assert_eq!(&v, &[0, 0, 0, 0]); } diff --git a/test-utils/runtime/src/system.rs b/test-utils/runtime/src/system.rs index d305220d5f..aec909f8da 100644 --- a/test-utils/runtime/src/system.rs +++ b/test-utils/runtime/src/system.rs @@ -361,16 +361,16 @@ mod tests { ]; TestExternalities::new_with_code( WASM_BINARY, - ( - map![ + primitives::storage::Storage { + top: map![ twox_128(b"latest").to_vec() => vec![69u8; 32], twox_128(b"sys:auth").to_vec() => authorities.encode(), blake2_256(&AccountKeyring::Alice.to_raw_public().to_keyed_vec(b"balance:")).to_vec() => { vec![111u8, 0, 0, 0, 0, 0, 0, 0] } ], - map![], - ) + children: map![], + }, ) } -- GitLab From 6050a8d50bba9cd5b35191978e5b7420c9ecbfd3 Mon Sep 17 00:00:00 2001 From: Robert Habermeier Date: Sun, 15 Dec 2019 17:24:49 +0100 Subject: [PATCH 137/172] babe: exponential backoff on missed blocks (#4397) * fix srml-support compilation * babe: exponential backoff on missed blocks. --- client/consensus/babe/src/lib.rs | 21 +++++++++++++++++---- frame/support/src/storage/mod.rs | 6 ++++-- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/client/consensus/babe/src/lib.rs b/client/consensus/babe/src/lib.rs index 9bdc08b883..84b018ac59 100644 --- a/client/consensus/babe/src/lib.rs +++ b/client/consensus/babe/src/lib.rs @@ -466,8 +466,11 @@ impl slots::SimpleSlotWorker for BabeWorker Option { - // never give more than 20 times more lenience. - const BACKOFF_CAP: u64 = 20; + // never give more than 2^this times the lenience. + const BACKOFF_CAP: u64 = 8; + + // how many slots it takes before we double the lenience. + const BACKOFF_STEP: u64 = 2; let slot_remaining = self.slot_remaining_duration(slot_info); let parent_slot = match find_pre_digest::(head) { @@ -478,12 +481,22 @@ impl slots::SimpleSlotWorker for BabeWorker= 1 { + debug!(target: "babe", "No block for {} slots. Applying 2^({}/{}) lenience", + slot_lenience, slot_lenience, BACKOFF_STEP); + } + + let slot_duration = slot_info.duration << (slot_lenience / BACKOFF_STEP); + + let slot_lenience = Duration::from_secs(slot_duration); Some(slot_lenience + slot_remaining) } } diff --git a/frame/support/src/storage/mod.rs b/frame/support/src/storage/mod.rs index 1d575d0794..4a392affbd 100644 --- a/frame/support/src/storage/mod.rs +++ b/frame/support/src/storage/mod.rs @@ -364,8 +364,10 @@ impl Iterator for PrefixIterator { type Item = Value; fn next(&mut self) -> Option { - match sp_io::storage::next_key(&self.previous_key) { - Some(next_key) if next_key.starts_with(&self.prefix[..]) => { + match sp_io::storage::next_key(&self.previous_key) + .filter(|n| n.starts_with(&self.prefix[..])) + { + Some(next_key) => { let value = unhashed::get(&next_key); if value.is_none() { -- GitLab From 11ee6a088d8d1c8902e1526de9f3f5758dcd120c Mon Sep 17 00:00:00 2001 From: Wei Tang Date: Sun, 15 Dec 2019 09:39:46 -0800 Subject: [PATCH 138/172] Simplify adding new Ss58AddressFormat variant and add KulupuAccountDirect (#4396) * Simplify adding new Ss58AddressFormat variant and add KulupuAccountDirect * Only enable std conversion in std --- bin/utils/subkey/src/main.rs | 2 +- primitives/core/src/crypto.rs | 127 ++++++++++++++++++---------------- 2 files changed, 69 insertions(+), 60 deletions(-) diff --git a/bin/utils/subkey/src/main.rs b/bin/utils/subkey/src/main.rs index d0babc5802..24ecbb0686 100644 --- a/bin/utils/subkey/src/main.rs +++ b/bin/utils/subkey/src/main.rs @@ -165,7 +165,7 @@ fn get_app<'a, 'b>() -> App<'a, 'b> { -k, --secp256k1 'Use SECP256k1/ECDSA/BIP39 cryptography' -s, --sr25519 'Use Schnorr/Ristretto x25519/BIP39 cryptography' [network] -n, --network 'Specify a network. One of substrate \ - (default), polkadot, kusama, or dothereum.' + (default), polkadot, kusama, dothereum, or kulupu' [password] -p, --password 'The password for the key' ") .subcommands(vec![ diff --git a/primitives/core/src/crypto.rs b/primitives/core/src/crypto.rs index 91fd19291f..2f7574bee3 100644 --- a/primitives/core/src/crypto.rs +++ b/primitives/core/src/crypto.rs @@ -355,76 +355,85 @@ lazy_static::lazy_static! { = Mutex::new(Ss58AddressFormat::SubstrateAccountDirect); } -/// A known address (sub)format/network ID for SS58. #[cfg(feature = "full_crypto")] -#[derive(Copy, Clone, PartialEq, Eq)] -pub enum Ss58AddressFormat { - /// Any Substrate network, direct checksum, standard account (*25519). - SubstrateAccountDirect, - /// Polkadot Relay-chain, direct checksum, standard account (*25519). - PolkadotAccountDirect, - /// Kusama Relay-chain, direct checksum, standard account (*25519). - KusamaAccountDirect, - /// Dothereum Para-chain, direct checksum, standard account (*25519). - DothereumAccountDirect, - /// Use a manually provided numeric value. - Custom(u8), -} +macro_rules! ss58_address_format { + ( $( $identifier:tt => ($number:expr, $name:expr, $desc:tt) )* ) => ( + /// A known address (sub)format/network ID for SS58. + #[derive(Copy, Clone, PartialEq, Eq)] + pub enum Ss58AddressFormat { + $(#[doc = $desc] $identifier),*, + /// Use a manually provided numeric value. + Custom(u8), + } -#[cfg(feature = "full_crypto")] -impl From for u8 { - fn from(x: Ss58AddressFormat) -> u8 { - match x { - Ss58AddressFormat::SubstrateAccountDirect => 42, - Ss58AddressFormat::PolkadotAccountDirect => 0, - Ss58AddressFormat::KusamaAccountDirect => 2, - Ss58AddressFormat::DothereumAccountDirect => 20, - Ss58AddressFormat::Custom(n) => n, + static ALL_SS58_ADDRESS_FORMATS: [Ss58AddressFormat; 0 $(+ { let _ = $number; 1})*] = [ + $(Ss58AddressFormat::$identifier),*, + ]; + + impl Ss58AddressFormat { + /// All known address formats. + pub fn all() -> &'static [Ss58AddressFormat] { + &ALL_SS58_ADDRESS_FORMATS + } } - } -} -#[cfg(feature = "full_crypto")] -impl TryFrom for Ss58AddressFormat { - type Error = (); - fn try_from(x: u8) -> Result { - match x { - 42 => Ok(Ss58AddressFormat::SubstrateAccountDirect), - 0 => Ok(Ss58AddressFormat::PolkadotAccountDirect), - 2 => Ok(Ss58AddressFormat::KusamaAccountDirect), - 20 => Ok(Ss58AddressFormat::DothereumAccountDirect), - _ => Err(()), + impl From for u8 { + fn from(x: Ss58AddressFormat) -> u8 { + match x { + $(Ss58AddressFormat::$identifier => $number),*, + Ss58AddressFormat::Custom(n) => n, + } + } } - } -} -#[cfg(feature = "full_crypto")] -impl<'a> TryFrom<&'a str> for Ss58AddressFormat { - type Error = (); - fn try_from(x: &'a str) -> Result { - match x { - "substrate" => Ok(Ss58AddressFormat::SubstrateAccountDirect), - "polkadot" => Ok(Ss58AddressFormat::PolkadotAccountDirect), - "kusama" => Ok(Ss58AddressFormat::KusamaAccountDirect), - "dothereum" => Ok(Ss58AddressFormat::DothereumAccountDirect), - a => a.parse::().map(Ss58AddressFormat::Custom).map_err(|_| ()), + impl TryFrom for Ss58AddressFormat { + type Error = (); + + fn try_from(x: u8) -> Result { + match x { + $($number => Ok(Ss58AddressFormat::$identifier)),*, + _ => Err(()), + } + } } - } -} -#[cfg(feature = "std")] -impl From for String { - fn from(x: Ss58AddressFormat) -> String { - match x { - Ss58AddressFormat::SubstrateAccountDirect => "substrate".into(), - Ss58AddressFormat::PolkadotAccountDirect => "polkadot".into(), - Ss58AddressFormat::KusamaAccountDirect => "kusama".into(), - Ss58AddressFormat::DothereumAccountDirect => "dothereum".into(), - Ss58AddressFormat::Custom(x) => x.to_string(), + impl<'a> TryFrom<&'a str> for Ss58AddressFormat { + type Error = (); + + fn try_from(x: &'a str) -> Result { + match x { + $($name => Ok(Ss58AddressFormat::$identifier)),*, + a => a.parse::().map(Ss58AddressFormat::Custom).map_err(|_| ()), + } + } } - } + + #[cfg(feature = "std")] + impl From for String { + fn from(x: Ss58AddressFormat) -> String { + match x { + $(Ss58AddressFormat::$identifier => $name.into()),*, + Ss58AddressFormat::Custom(x) => x.to_string(), + } + } + } + ) } +#[cfg(feature = "full_crypto")] +ss58_address_format!( + SubstrateAccountDirect => + (42, "substrate", "Any Substrate network, direct checksum, standard account (*25519).") + PolkadotAccountDirect => + (0, "polkadot", "Polkadot Relay-chain, direct checksum, standard account (*25519).") + KusamaAccountDirect => + (2, "kusama", "Kusama Relay-chain, direct checksum, standard account (*25519).") + DothereumAccountDirect => + (20, "dothereum", "Dothereum Para-chain, direct checksum, standard account (*25519).") + KulupuAccountDirect => + (16, "kulupu", "Kulupu mainnet, direct checksum, standard account (*25519).") +); + /// Set the default "version" (actually, this is a bit of a misnomer and the version byte is /// typically used not just to encode format/version but also network identity) that is used for /// encoding and decoding SS58 addresses. If an unknown version is provided then it fails. -- GitLab From 13b13087c9a2e43d118c3c4890c864601a990996 Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Mon, 16 Dec 2019 15:24:03 +0800 Subject: [PATCH 139/172] Remove proposal when it is refused (#4399) * Remove proposal when it is refused. * Fix build, add test --- frame/collective/src/lib.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/frame/collective/src/lib.rs b/frame/collective/src/lib.rs index 279c720e85..20f61e54ed 100644 --- a/frame/collective/src/lib.rs +++ b/frame/collective/src/lib.rs @@ -242,6 +242,7 @@ decl_module! { } } else { // disapproved + >::remove(&proposal); Self::deposit_event(RawEvent::Disapproved(proposal)); } @@ -648,6 +649,20 @@ mod tests { }); } + #[test] + fn motions_reproposing_disapproved_works() { + make_ext().execute_with(|| { + System::set_block_number(1); + let proposal = make_proposal(42); + let hash: H256 = proposal.blake2_256().into(); + assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()))); + assert_ok!(Collective::vote(Origin::signed(2), hash.clone(), 0, false)); + assert_eq!(Collective::proposals(), vec![]); + assert_ok!(Collective::propose(Origin::signed(1), 2, Box::new(proposal.clone()))); + assert_eq!(Collective::proposals(), vec![hash]); + }); + } + #[test] fn motions_disapproval_works() { make_ext().execute_with(|| { -- GitLab From 0176576278c024a891a1d4e1701e286c9d940942 Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Mon, 16 Dec 2019 20:36:08 +0800 Subject: [PATCH 140/172] Identity module enhancements (#4401) * Updates; not yet tested. * Fix and add tests * Add test * Update a few comments --- frame/identity/src/lib.rs | 136 +++++++++++++++++++++++++++++++++----- 1 file changed, 120 insertions(+), 16 deletions(-) diff --git a/frame/identity/src/lib.rs b/frame/identity/src/lib.rs index a4e6a46b6b..904ab8cf2e 100644 --- a/frame/identity/src/lib.rs +++ b/frame/identity/src/lib.rs @@ -93,10 +93,12 @@ pub trait Trait: system::Trait { /// The amount held on deposit per additional field for a registered identity. type FieldDeposit: Get>; - /// The amount held on deposit for a registered subaccount. + /// The amount held on deposit for a registered subaccount. This should account for the fact + /// that one storage item's value will increase by the size of an account ID, and there will be + /// another trie item whose value is the size of an account ID plus 32 bytes. type SubAccountDeposit: Get>; - /// The amount held on deposit for a registered subaccount. + /// The maximum number of sub-accounts allowed per identified account. type MaximumSubAccounts: Get; /// What to do with slashed funds. @@ -363,11 +365,14 @@ decl_storage! { /// Information that is pertinent to identify the entity behind an account. pub IdentityOf get(fn identity): map T::AccountId => Option>>; + /// The super-identity of an alternative "sub" identity together with its name, within that + /// context. If the account is not some other account's sub-identity, then just `None`. + pub SuperOf get(fn super_of): map T::AccountId => Option<(T::AccountId, Data)>; + /// Alternative "sub" identities of this account. /// - /// The first item is the deposit, the second is a vector of the accounts together with - /// their "local" name (i.e. in the context of the identity). - pub SubsOf get(fn subs): map T::AccountId => (BalanceOf, Vec<(T::AccountId, Data)>); + /// The first item is the deposit, the second is a vector of the accounts. + pub SubsOf get(fn subs): map T::AccountId => (BalanceOf, Vec); /// The set of registrars. Not expected to get very big as can only be added through a /// special origin (likely a council motion). @@ -488,14 +493,15 @@ decl_module! { /// # /// - `O(S)` where `S` subs-count (hard- and deposit-bounded). /// - At most two balance operations. - /// - One storage mutation (codec `O(S)`); one storage-exists. + /// - At most O(2 * S + 1) storage mutations; codec complexity `O(1 * S + S * 1)`); + /// one storage-exists. /// # fn set_subs(origin, subs: Vec<(T::AccountId, Data)>) { let sender = ensure_signed(origin)?; ensure!(>::exists(&sender), "not found"); ensure!(subs.len() <= T::MaximumSubAccounts::get() as usize, "too many subs"); - let old_deposit = >::get(&sender).0; + let (old_deposit, old_ids) = >::get(&sender); let new_deposit = T::SubAccountDeposit::get() * >::from(subs.len() as u32); if old_deposit < new_deposit { @@ -506,10 +512,18 @@ decl_module! { let _ = T::Currency::unreserve(&sender, old_deposit - new_deposit); } - if subs.is_empty() { + for s in old_ids.iter() { + >::remove(s); + } + let ids = subs.into_iter().map(|(id, name)| { + >::insert(&id, (sender.clone(), name)); + id + }).collect::>(); + + if ids.is_empty() { >::remove(&sender); } else { - >::insert(&sender, (new_deposit, subs)); + >::insert(&sender, (new_deposit, ids)); } } @@ -525,14 +539,18 @@ decl_module! { /// # /// - `O(R + S + X)`. /// - One balance-reserve operation. - /// - Two storage mutations. + /// - `S + 2` storage deletions. /// - One event. /// # fn clear_identity(origin) { let sender = ensure_signed(origin)?; + let (subs_deposit, sub_ids) = >::take(&sender); let deposit = >::take(&sender).ok_or("not named")?.total_deposit() - + >::take(&sender).0; + + subs_deposit; + for sub in sub_ids.iter() { + >::remove(sub); + } let _ = T::Currency::unreserve(&sender, deposit.clone()); @@ -654,6 +672,33 @@ decl_module! { ) } + /// Change the account associated with a registrar. + /// + /// The dispatch origin for this call must be _Signed_ and the sender must be the account + /// of the registrar whose index is `index`. + /// + /// - `index`: the index of the registrar whose fee is to be set. + /// - `new`: the new account ID. + /// + /// # + /// - `O(R)`. + /// - One storage mutation `O(R)`. + /// # + #[weight = SimpleDispatchInfo::FixedNormal(50_000)] + fn set_account_id(origin, + #[compact] index: RegistrarIndex, + new: T::AccountId, + ) -> Result { + let who = ensure_signed(origin)?; + + >::mutate(|rs| + rs.get_mut(index as usize) + .and_then(|x| x.as_mut()) + .and_then(|r| if r.account == who { r.account = new; Some(()) } else { None }) + .ok_or("invalid index") + ) + } + /// Set the field information for a registrar. /// /// The dispatch origin for this call must be _Signed_ and the sender must be the account @@ -746,7 +791,7 @@ decl_module! { /// # /// - `O(R + S + X)`. /// - One balance-reserve operation. - /// - Two storage mutations. + /// - `S + 2` storage mutations. /// - One event. /// # #[weight = SimpleDispatchInfo::FreeOperational] @@ -759,8 +804,12 @@ decl_module! { // Figure out who we're meant to be clearing. let target = T::Lookup::lookup(target)?; // Grab their deposit (and check that they have one). + let (subs_deposit, sub_ids) = >::take(&target); let deposit = >::take(&target).ok_or("not named")?.total_deposit() - + >::take(&target).0; + + subs_deposit; + for sub in sub_ids.iter() { + >::remove(sub); + } // Slash their deposit from them. T::Slashed::on_unbalanced(T::Currency::slash_reserved(&target, deposit).0); @@ -967,18 +1016,60 @@ mod tests { assert_ok!(Identity::set_identity(Origin::signed(10), ten())); assert_ok!(Identity::set_subs(Origin::signed(10), subs.clone())); assert_eq!(Balances::free_balance(10), 80); - assert_eq!(Identity::subs(10), (10, subs.clone())); + assert_eq!(Identity::subs(10), (10, vec![20])); + assert_eq!(Identity::super_of(20), Some((10, Data::Raw(vec![40; 1])))); + // push another item and re-set it. + subs.push((30, Data::Raw(vec![50; 1]))); + assert_ok!(Identity::set_subs(Origin::signed(10), subs.clone())); + assert_eq!(Balances::free_balance(10), 70); + assert_eq!(Identity::subs(10), (20, vec![20, 30])); + assert_eq!(Identity::super_of(20), Some((10, Data::Raw(vec![40; 1])))); + assert_eq!(Identity::super_of(30), Some((10, Data::Raw(vec![50; 1])))); + + // switch out one of the items and re-set. + subs[0] = (40, Data::Raw(vec![60; 1])); + assert_ok!(Identity::set_subs(Origin::signed(10), subs.clone())); + assert_eq!(Balances::free_balance(10), 70); // no change in the balance + assert_eq!(Identity::subs(10), (20, vec![40, 30])); + assert_eq!(Identity::super_of(20), None); + assert_eq!(Identity::super_of(30), Some((10, Data::Raw(vec![50; 1])))); + assert_eq!(Identity::super_of(40), Some((10, Data::Raw(vec![60; 1])))); + + // clear assert_ok!(Identity::set_subs(Origin::signed(10), vec![])); assert_eq!(Balances::free_balance(10), 90); assert_eq!(Identity::subs(10), (0, vec![])); + assert_eq!(Identity::super_of(30), None); + assert_eq!(Identity::super_of(40), None); - subs.push((30, Data::Raw(vec![41; 1]))); - subs.push((40, Data::Raw(vec![42; 1]))); + subs.push((20, Data::Raw(vec![40; 1]))); assert_noop!(Identity::set_subs(Origin::signed(10), subs.clone()), "too many subs"); }); } + #[test] + fn clearing_account_should_remove_subaccounts_and_refund() { + new_test_ext().execute_with(|| { + assert_ok!(Identity::set_identity(Origin::signed(10), ten())); + assert_ok!(Identity::set_subs(Origin::signed(10), vec![(20, Data::Raw(vec![40; 1]))])); + assert_ok!(Identity::clear_identity(Origin::signed(10))); + assert_eq!(Balances::free_balance(10), 100); + assert!(Identity::super_of(20).is_none()); + }); + } + + #[test] + fn killing_account_should_remove_subaccounts_and_not_refund() { + new_test_ext().execute_with(|| { + assert_ok!(Identity::set_identity(Origin::signed(10), ten())); + assert_ok!(Identity::set_subs(Origin::signed(10), vec![(20, Data::Raw(vec![40; 1]))])); + assert_ok!(Identity::kill_identity(Origin::ROOT, 10)); + assert_eq!(Balances::free_balance(10), 80); + assert!(Identity::super_of(20).is_none()); + }); + } + #[test] fn cancelling_requested_judgement_should_work() { new_test_ext().execute_with(|| { @@ -1040,4 +1131,17 @@ mod tests { assert_eq!(Balances::free_balance(10), 70); }); } + + #[test] + fn setting_account_id_should_work() { + new_test_ext().execute_with(|| { + assert_ok!(Identity::add_registrar(Origin::signed(1), 3)); + // account 4 cannot change the first registrar's identity since it's owned by 3. + assert_noop!(Identity::set_account_id(Origin::signed(4), 0, 3), "invalid index"); + // account 3 can, because that's the registrar's current account. + assert_ok!(Identity::set_account_id(Origin::signed(3), 0, 4)); + // account 4 can now, because that's their new ID. + assert_ok!(Identity::set_account_id(Origin::signed(4), 0, 3)); + }); + } } -- GitLab From 40a16efefc070faf5a25442bc3ae1d0ea2478eee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Mon, 16 Dec 2019 13:36:49 +0100 Subject: [PATCH 141/172] [big refactor] Remove crate aliasing. (#4395) * Rename: Phase 1. * Unify codec. * Fixing: Phase 2 * Fixing: Phase 3. * Fixing: Phase 4. * Fixing: Phase 5. * Fixing: Phase 6. * Fixing: Phase 7. * Fixing: Phase 8. Tests * Fixing: Phase 9. Tests!!! * Fixing: Phase 10. Moar tests! * Finally done! * More fixes. * Rename primitives:: to sp_core:: * Apply renames in finality-grandpa. * Fix benches. * Fix benches 2. * Revert node-template. * Fix frame-system in our modules. --- Cargo.lock | 1 + bin/node-template/Cargo.toml | 20 +- bin/node-template/runtime/Cargo.toml | 55 ++-- bin/node-template/runtime/src/lib.rs | 26 +- bin/node-template/runtime/src/template.rs | 6 +- bin/node-template/src/chain_spec.rs | 6 +- bin/node-template/src/cli.rs | 2 +- bin/node-template/src/service.rs | 52 ++-- bin/node/cli/Cargo.toml | 56 ++-- bin/node/cli/src/browser.rs | 2 +- bin/node/cli/src/chain_spec.rs | 48 ++-- bin/node/cli/src/factory_impl.rs | 22 +- bin/node/cli/src/service.rs | 114 ++++---- bin/node/executor/Cargo.toml | 28 +- bin/node/executor/benches/bench.rs | 16 +- bin/node/executor/src/lib.rs | 157 +++++----- bin/node/primitives/Cargo.toml | 4 +- bin/node/primitives/src/lib.rs | 2 +- bin/node/rpc/Cargo.toml | 4 +- bin/node/rpc/src/lib.rs | 8 +- bin/node/runtime/Cargo.toml | 146 +++++----- bin/node/runtime/src/impls.rs | 8 +- bin/node/runtime/src/lib.rs | 267 +++++++++--------- bin/node/testing/Cargo.toml | 30 +- bin/node/testing/src/client.rs | 14 +- bin/node/testing/src/genesis.rs | 40 +-- bin/node/testing/src/keyring.rs | 16 +- bin/node/transaction-factory/Cargo.toml | 12 +- .../transaction-factory/src/complex_mode.rs | 10 +- bin/node/transaction-factory/src/lib.rs | 30 +- .../transaction-factory/src/simple_modes.rs | 10 +- bin/utils/chain-spec-builder/Cargo.toml | 4 +- bin/utils/chain-spec-builder/src/main.rs | 12 +- bin/utils/subkey/Cargo.toml | 8 +- bin/utils/subkey/src/main.rs | 16 +- bin/utils/subkey/src/vanity.rs | 4 +- client/Cargo.toml | 26 +- client/api/Cargo.toml | 22 +- client/api/src/backend.rs | 10 +- client/api/src/call_executor.rs | 22 +- client/api/src/client.rs | 4 +- client/api/src/execution_extensions.rs | 12 +- client/api/src/lib.rs | 4 +- client/api/src/light.rs | 6 +- client/api/src/notifications.rs | 2 +- client/authority-discovery/Cargo.toml | 12 +- client/authority-discovery/src/lib.rs | 26 +- client/basic-authorship/Cargo.toml | 18 +- .../basic-authorship/src/basic_authorship.rs | 36 +-- client/basic-authorship/src/lib.rs | 8 +- client/block-builder/Cargo.toml | 6 +- client/block-builder/src/lib.rs | 6 +- client/chain-spec/Cargo.toml | 6 +- client/chain-spec/src/chain_spec.rs | 10 +- client/cli/Cargo.toml | 18 +- client/cli/src/error.rs | 2 +- client/cli/src/informant.rs | 4 +- client/cli/src/informant/display.rs | 6 +- client/cli/src/lib.rs | 60 ++-- client/cli/src/params.rs | 28 +- client/consensus/aura/Cargo.toml | 28 +- client/consensus/aura/src/digest.rs | 4 +- client/consensus/aura/src/lib.rs | 97 ++++--- client/consensus/babe/Cargo.toml | 32 +-- client/consensus/babe/src/authorship.rs | 14 +- client/consensus/babe/src/aux_schema.rs | 4 +- client/consensus/babe/src/epoch_changes.rs | 6 +- client/consensus/babe/src/lib.rs | 84 +++--- client/consensus/babe/src/tests.rs | 33 ++- client/consensus/babe/src/verification.rs | 8 +- client/consensus/pow/Cargo.toml | 12 +- client/consensus/pow/src/lib.rs | 32 +-- client/consensus/slots/Cargo.toml | 10 +- client/consensus/slots/src/aux_schema.rs | 10 +- client/consensus/slots/src/lib.rs | 24 +- client/consensus/slots/src/slots.rs | 6 +- client/consensus/uncles/Cargo.toml | 8 +- client/consensus/uncles/src/lib.rs | 10 +- client/db/Cargo.toml | 18 +- client/db/src/cache/list_cache.rs | 2 +- client/db/src/cache/mod.rs | 2 +- client/db/src/lib.rs | 170 ++++++----- client/db/src/light.rs | 14 +- client/db/src/offchain.rs | 4 +- client/db/src/storage_cache.rs | 16 +- client/db/src/utils.rs | 2 +- client/executor/Cargo.toml | 23 +- client/executor/runtime-test/Cargo.toml | 8 +- client/executor/runtime-test/src/lib.rs | 62 ++-- client/executor/src/allocator.rs | 2 +- .../executor/src/deprecated_host_interface.rs | 6 +- client/executor/src/error.rs | 4 +- client/executor/src/integration_tests/mod.rs | 14 +- .../executor/src/integration_tests/sandbox.rs | 2 +- client/executor/src/lib.rs | 10 +- client/executor/src/native_executor.rs | 26 +- client/executor/src/sandbox.rs | 4 +- client/executor/src/wasm_runtime.rs | 8 +- client/executor/src/wasm_utils.rs | 30 +- client/executor/src/wasmi_execution.rs | 8 +- .../src/wasmtime/function_executor.rs | 4 +- client/executor/src/wasmtime/runtime.rs | 4 +- client/executor/src/wasmtime/trampoline.rs | 2 +- client/executor/src/wasmtime/util.rs | 2 +- client/finality-grandpa/Cargo.toml | 34 +-- client/finality-grandpa/src/authorities.rs | 10 +- client/finality-grandpa/src/aux_schema.rs | 32 +-- .../src/communication/gossip.rs | 38 +-- .../finality-grandpa/src/communication/mod.rs | 38 +-- .../src/communication/periodic.rs | 8 +- .../src/communication/tests.rs | 76 ++--- .../finality-grandpa/src/consensus_changes.rs | 2 +- client/finality-grandpa/src/environment.rs | 28 +- client/finality-grandpa/src/finality_proof.rs | 22 +- client/finality-grandpa/src/import.rs | 20 +- client/finality-grandpa/src/justification.rs | 30 +- client/finality-grandpa/src/lib.rs | 64 ++--- client/finality-grandpa/src/light_import.rs | 46 +-- client/finality-grandpa/src/observer.rs | 26 +- client/finality-grandpa/src/tests.rs | 62 ++-- client/finality-grandpa/src/until_imported.rs | 36 +-- client/finality-grandpa/src/voting_rule.rs | 2 +- client/keystore/Cargo.toml | 4 +- client/keystore/src/lib.rs | 6 +- client/network-gossip/Cargo.toml | 2 +- client/network-gossip/src/bridge.rs | 14 +- client/network-gossip/src/lib.rs | 4 +- client/network-gossip/src/state_machine.rs | 8 +- client/network/Cargo.toml | 24 +- client/network/src/behaviour.rs | 2 +- client/network/src/chain.rs | 12 +- client/network/src/config.rs | 2 +- client/network/src/discovery.rs | 2 +- client/network/src/lib.rs | 2 +- client/network/src/on_demand_layer.rs | 2 +- client/network/src/protocol.rs | 30 +- .../src/protocol/legacy_proto/behaviour.rs | 24 +- .../src/protocol/legacy_proto/tests.rs | 2 +- client/network/src/protocol/light_dispatch.rs | 12 +- client/network/src/protocol/message.rs | 2 +- client/network/src/protocol/sync.rs | 8 +- client/network/src/protocol/sync/blocks.rs | 2 +- client/network/src/service.rs | 12 +- client/network/test/Cargo.toml | 16 +- client/network/test/src/block_import.rs | 16 +- client/network/test/src/lib.rs | 44 +-- client/network/test/src/sync.rs | 2 +- client/offchain/Cargo.toml | 18 +- client/offchain/src/api.rs | 14 +- client/offchain/src/api/http.rs | 4 +- client/offchain/src/api/http_dummy.rs | 2 +- client/offchain/src/api/timestamp.rs | 2 +- client/offchain/src/lib.rs | 22 +- client/rpc-api/Cargo.toml | 8 +- client/rpc-api/src/author/error.rs | 4 +- client/rpc-api/src/author/hash.rs | 2 +- client/rpc-api/src/author/mod.rs | 4 +- client/rpc-api/src/chain/mod.rs | 2 +- client/rpc-api/src/state/mod.rs | 6 +- client/rpc/Cargo.toml | 24 +- client/rpc/src/author/mod.rs | 16 +- client/rpc/src/author/tests.rs | 8 +- client/rpc/src/chain/chain_full.rs | 8 +- client/rpc/src/chain/chain_light.rs | 12 +- client/rpc/src/chain/mod.rs | 30 +- client/rpc/src/chain/tests.rs | 20 +- client/rpc/src/lib.rs | 2 +- client/rpc/src/state/mod.rs | 20 +- client/rpc/src/state/state_full.rs | 14 +- client/rpc/src/state/state_light.rs | 12 +- client/rpc/src/state/tests.rs | 24 +- client/rpc/src/system/mod.rs | 4 +- client/rpc/src/system/tests.rs | 12 +- client/service/Cargo.toml | 38 +-- client/service/src/builder.rs | 120 ++++---- client/service/src/chain_ops.rs | 16 +- client/service/src/config.rs | 14 +- client/service/src/error.rs | 12 +- client/service/src/lib.rs | 94 +++--- client/service/test/Cargo.toml | 12 +- client/service/test/src/lib.rs | 14 +- client/src/call_executor.rs | 30 +- client/src/cht.rs | 16 +- client/src/client.rs | 68 ++--- client/src/genesis.rs | 20 +- client/src/in_mem.rs | 36 +-- client/src/lib.rs | 10 +- client/src/light/backend.rs | 18 +- client/src/light/blockchain.rs | 6 +- client/src/light/call_executor.rs | 46 +-- client/src/light/fetcher.rs | 40 +-- client/src/light/mod.rs | 6 +- client/state-db/Cargo.toml | 2 +- client/state-db/src/lib.rs | 2 +- client/state-db/src/noncanonical.rs | 2 +- client/state-db/src/pruning.rs | 2 +- client/state-db/src/test.rs | 2 +- client/transaction-pool/Cargo.toml | 12 +- client/transaction-pool/graph/Cargo.toml | 6 +- .../transaction-pool/graph/benches/basics.rs | 8 +- .../transaction-pool/graph/src/base_pool.rs | 4 +- client/transaction-pool/graph/src/future.rs | 2 +- client/transaction-pool/graph/src/pool.rs | 6 +- client/transaction-pool/graph/src/ready.rs | 2 +- .../graph/src/validated_pool.rs | 2 +- client/transaction-pool/graph/src/watcher.rs | 2 +- client/transaction-pool/src/api.rs | 26 +- client/transaction-pool/src/error.rs | 4 +- client/transaction-pool/src/lib.rs | 22 +- client/transaction-pool/src/maintainer.rs | 42 +-- client/transaction-pool/src/tests.rs | 14 +- frame/assets/Cargo.toml | 10 +- frame/assets/src/lib.rs | 24 +- frame/aura/Cargo.toml | 26 +- frame/aura/src/lib.rs | 14 +- frame/aura/src/mock.rs | 10 +- frame/authority-discovery/Cargo.toml | 24 +- frame/authority-discovery/src/lib.rs | 38 +-- frame/authorship/Cargo.toml | 16 +- frame/authorship/src/lib.rs | 34 +-- frame/babe/Cargo.toml | 28 +- frame/babe/src/lib.rs | 33 ++- frame/babe/src/mock.rs | 22 +- frame/babe/src/tests.rs | 20 +- frame/balances/Cargo.toml | 12 +- frame/balances/src/lib.rs | 48 ++-- frame/balances/src/mock.rs | 19 +- frame/balances/src/tests.rs | 8 +- frame/collective/Cargo.toml | 14 +- frame/collective/src/lib.rs | 32 +-- frame/contracts/Cargo.toml | 22 +- frame/contracts/rpc/Cargo.toml | 4 +- frame/contracts/rpc/src/lib.rs | 4 +- frame/contracts/src/account_db.rs | 14 +- frame/contracts/src/exec.rs | 14 +- frame/contracts/src/gas.rs | 2 +- frame/contracts/src/lib.rs | 42 +-- frame/contracts/src/rent.rs | 8 +- frame/contracts/src/tests.rs | 85 +++--- frame/contracts/src/wasm/code_cache.rs | 2 +- frame/contracts/src/wasm/env_def/macros.rs | 30 +- frame/contracts/src/wasm/env_def/mod.rs | 6 +- frame/contracts/src/wasm/mod.rs | 12 +- frame/contracts/src/wasm/runtime.rs | 62 ++-- frame/democracy/Cargo.toml | 12 +- frame/democracy/src/lib.rs | 66 ++--- frame/elections-phragmen/Cargo.toml | 16 +- frame/elections-phragmen/src/lib.rs | 37 +-- frame/elections/Cargo.toml | 14 +- frame/elections/src/lib.rs | 20 +- frame/elections/src/mock.rs | 15 +- frame/elections/src/tests.rs | 2 +- frame/evm/Cargo.toml | 20 +- frame/evm/src/backend.rs | 10 +- frame/evm/src/lib.rs | 18 +- frame/example/Cargo.toml | 14 +- frame/example/src/lib.rs | 44 +-- frame/executive/Cargo.toml | 14 +- frame/executive/src/lib.rs | 130 ++++----- frame/finality-tracker/Cargo.toml | 10 +- frame/finality-tracker/src/lib.rs | 12 +- frame/generic-asset/Cargo.toml | 10 +- frame/generic-asset/src/lib.rs | 30 +- frame/generic-asset/src/mock.rs | 15 +- frame/generic-asset/src/tests.rs | 12 +- frame/grandpa/Cargo.toml | 20 +- frame/grandpa/src/lib.rs | 26 +- frame/grandpa/src/mock.rs | 13 +- frame/grandpa/src/tests.rs | 2 +- frame/identity/Cargo.toml | 12 +- frame/identity/src/lib.rs | 32 +-- frame/im-online/Cargo.toml | 26 +- frame/im-online/src/lib.rs | 54 ++-- frame/im-online/src/mock.rs | 30 +- frame/im-online/src/tests.rs | 14 +- frame/indices/Cargo.toml | 12 +- frame/indices/src/lib.rs | 14 +- frame/indices/src/mock.rs | 11 +- frame/membership/Cargo.toml | 10 +- frame/membership/src/lib.rs | 22 +- frame/metadata/Cargo.toml | 4 +- frame/metadata/src/lib.rs | 8 +- frame/nicks/Cargo.toml | 12 +- frame/nicks/src/lib.rs | 32 +-- frame/offences/Cargo.toml | 12 +- frame/offences/src/lib.rs | 9 +- frame/offences/src/mock.rs | 10 +- frame/offences/src/tests.rs | 2 +- frame/randomness-collective-flip/Cargo.toml | 10 +- frame/randomness-collective-flip/src/lib.rs | 24 +- frame/scored-pool/Cargo.toml | 12 +- frame/scored-pool/src/lib.rs | 18 +- frame/scored-pool/src/mock.rs | 18 +- frame/scored-pool/src/tests.rs | 6 +- frame/session/Cargo.toml | 14 +- frame/session/src/historical.rs | 14 +- frame/session/src/lib.rs | 18 +- frame/session/src/mock.rs | 12 +- frame/staking/Cargo.toml | 26 +- frame/staking/src/lib.rs | 86 +++--- frame/staking/src/migration.rs | 12 +- frame/staking/src/mock.rs | 50 ++-- frame/staking/src/slashing.rs | 2 +- frame/staking/src/tests.rs | 6 +- frame/sudo/Cargo.toml | 10 +- frame/sudo/src/lib.rs | 20 +- frame/support/Cargo.toml | 12 +- frame/support/procedural/Cargo.toml | 2 +- .../procedural/src/construct_runtime/mod.rs | 5 +- .../procedural/src/construct_runtime/parse.rs | 4 +- frame/support/procedural/tools/Cargo.toml | 2 +- frame/support/src/debug.rs | 6 +- frame/support/src/event.rs | 3 +- frame/support/src/inherent.rs | 2 +- frame/support/src/lib.rs | 2 +- frame/support/src/storage/child.rs | 2 +- frame/support/src/storage/mod.rs | 2 +- frame/support/src/traits.rs | 2 +- frame/support/test/Cargo.toml | 18 +- frame/support/test/src/lib.rs | 2 +- .../abundant_where_param.rs | 2 +- .../double_module_parts.rs | 2 +- .../double_module_parts_default.rs | 2 +- .../generics_in_invalid_module.rs | 2 +- .../invalid_module_details.rs | 2 +- .../invalid_module_details_keyword.rs | 2 +- .../invalid_token_after_module.rs | 2 +- .../invalid_token_after_name.rs | 2 +- .../invalid_where_param.rs | 2 +- ...g_event_generic_on_module_with_instance.rs | 2 +- .../missing_module_instance.rs | 2 +- ..._origin_generic_on_module_with_instance.rs | 2 +- .../missing_system_module.rs | 2 +- .../missing_where_block.rs | 2 +- .../missing_where_param.rs | 2 +- .../no_comma_after_where.rs | 2 +- .../params_in_invalid_module.rs | 2 +- frame/support/test/tests/decl_storage.rs | 18 +- .../tests/decl_storage_ui/config_duplicate.rs | 4 +- .../decl_storage_ui/config_get_duplicate.rs | 4 +- .../tests/decl_storage_ui/get_duplicate.rs | 4 +- frame/support/test/tests/final_keys.rs | 12 +- frame/support/test/tests/genesisconfig.rs | 4 +- frame/support/test/tests/instance.rs | 30 +- frame/support/test/tests/issue2219.rs | 14 +- .../tests/reserved_keyword/on_initialize.rs | 6 +- frame/support/test/tests/system.rs | 8 +- frame/system/Cargo.toml | 8 +- frame/system/benches/bench.rs | 6 +- frame/system/src/lib.rs | 16 +- frame/timestamp/Cargo.toml | 14 +- frame/timestamp/src/lib.rs | 30 +- frame/transaction-payment/Cargo.toml | 16 +- frame/transaction-payment/rpc/Cargo.toml | 4 +- .../rpc/runtime-api/Cargo.toml | 4 +- .../rpc/runtime-api/src/lib.rs | 2 +- frame/transaction-payment/rpc/src/lib.rs | 2 +- frame/transaction-payment/src/lib.rs | 43 +-- frame/treasury/Cargo.toml | 14 +- frame/treasury/src/lib.rs | 46 +-- frame/utility/Cargo.toml | 12 +- frame/utility/src/lib.rs | 36 +-- primitives/api/Cargo.toml | 8 +- primitives/api/src/lib.rs | 12 +- primitives/api/test/Cargo.toml | 8 +- primitives/api/test/benches/bench.rs | 12 +- primitives/api/test/tests/decl_and_impl.rs | 9 +- primitives/api/test/tests/runtime_calls.rs | 6 +- .../tests/ui/changed_in_unknown_version.rs | 2 +- .../tests/ui/empty_impl_runtime_apis_call.rs | 2 +- .../ui/impl_incorrect_method_signature.rs | 2 +- .../ui/impl_two_traits_with_same_name.rs | 2 +- .../ui/missing_block_generic_parameter.rs | 2 +- .../test/tests/ui/missing_path_for_trait.rs | 2 +- ...ype_reference_in_impl_runtime_apis_call.rs | 2 +- primitives/application-crypto/Cargo.toml | 6 +- primitives/application-crypto/src/ed25519.rs | 4 +- primitives/application-crypto/src/lib.rs | 6 +- primitives/application-crypto/src/sr25519.rs | 4 +- primitives/application-crypto/src/traits.rs | 4 +- primitives/application-crypto/test/Cargo.toml | 7 +- .../application-crypto/test/src/ed25519.rs | 9 +- .../application-crypto/test/src/sr25519.rs | 9 +- primitives/authority-discovery/Cargo.toml | 4 +- primitives/authority-discovery/src/lib.rs | 2 +- primitives/block-builder/Cargo.toml | 4 +- primitives/block-builder/src/lib.rs | 2 +- primitives/blockchain/Cargo.toml | 8 +- primitives/blockchain/src/error.rs | 4 +- primitives/consensus/aura/Cargo.toml | 8 +- primitives/consensus/aura/src/inherents.rs | 6 +- primitives/consensus/aura/src/lib.rs | 4 +- primitives/consensus/babe/Cargo.toml | 6 +- primitives/consensus/babe/src/lib.rs | 2 +- primitives/consensus/common/Cargo.toml | 6 +- primitives/consensus/common/src/error.rs | 6 +- primitives/consensus/common/src/lib.rs | 6 +- primitives/consensus/pow/Cargo.toml | 4 +- primitives/consensus/pow/src/lib.rs | 2 +- primitives/core/Cargo.toml | 14 +- primitives/core/benches/bench.rs | 11 +- primitives/core/src/crypto.rs | 2 +- primitives/core/src/ed25519.rs | 2 +- primitives/core/src/lib.rs | 4 +- primitives/core/src/offchain/mod.rs | 6 +- primitives/core/src/sr25519.rs | 2 +- primitives/core/src/traits.rs | 4 +- primitives/externalities/Cargo.toml | 2 +- primitives/externalities/src/lib.rs | 2 +- primitives/finality-tracker/Cargo.toml | 4 +- primitives/finality-tracker/src/lib.rs | 4 +- primitives/inherents/Cargo.toml | 4 +- primitives/inherents/src/lib.rs | 2 +- primitives/io/Cargo.toml | 16 +- primitives/io/src/lib.rs | 36 +-- primitives/keyring/Cargo.toml | 2 +- primitives/keyring/src/ed25519.rs | 6 +- primitives/keyring/src/sr25519.rs | 6 +- primitives/rpc/Cargo.toml | 2 +- primitives/rpc/src/number.rs | 2 +- primitives/runtime-interface/Cargo.toml | 14 +- .../bare_function_interface.rs | 4 +- .../host_function_interface.rs | 26 +- .../src/runtime_interface/trait_decl_impl.rs | 2 +- primitives/runtime-interface/src/host.rs | 2 +- primitives/runtime-interface/src/impls.rs | 8 +- primitives/runtime-interface/src/lib.rs | 14 +- primitives/runtime-interface/src/pass_by.rs | 2 +- .../runtime-interface/test-wasm/Cargo.toml | 6 +- .../runtime-interface/test-wasm/src/lib.rs | 4 +- primitives/runtime-interface/test/Cargo.toml | 8 +- primitives/runtime-interface/test/src/lib.rs | 12 +- primitives/runtime/Cargo.toml | 16 +- primitives/runtime/src/curve.rs | 2 +- primitives/runtime/src/generic/block.rs | 2 +- .../runtime/src/generic/checked_extrinsic.rs | 2 +- primitives/runtime/src/generic/digest.rs | 6 +- primitives/runtime/src/generic/era.rs | 2 +- primitives/runtime/src/generic/header.rs | 4 +- primitives/runtime/src/generic/tests.rs | 2 +- primitives/runtime/src/lib.rs | 38 +-- primitives/runtime/src/offchain/http.rs | 6 +- primitives/runtime/src/testing.rs | 6 +- primitives/runtime/src/traits.rs | 54 ++-- primitives/sandbox/Cargo.toml | 4 +- primitives/sandbox/src/lib.rs | 4 +- primitives/sandbox/without_std.rs | 6 +- primitives/state-machine/Cargo.toml | 8 +- primitives/state-machine/src/backend.rs | 12 +- primitives/state-machine/src/basic.rs | 18 +- .../state-machine/src/changes_trie/build.rs | 8 +- .../src/changes_trie/changes_iterator.rs | 4 +- .../state-machine/src/changes_trie/mod.rs | 10 +- .../state-machine/src/changes_trie/prune.rs | 6 +- .../state-machine/src/changes_trie/storage.rs | 4 +- primitives/state-machine/src/ext.rs | 48 ++-- primitives/state-machine/src/lib.rs | 10 +- .../state-machine/src/overlayed_changes.rs | 4 +- .../state-machine/src/proving_backend.rs | 12 +- primitives/state-machine/src/testing.rs | 10 +- primitives/state-machine/src/trie_backend.rs | 10 +- .../state-machine/src/trie_backend_essence.rs | 12 +- primitives/test-primitives/Cargo.toml | 6 +- primitives/test-primitives/src/lib.rs | 10 +- primitives/timestamp/Cargo.toml | 4 +- primitives/timestamp/src/lib.rs | 10 +- primitives/trie/Cargo.toml | 4 +- primitives/trie/benches/bench.rs | 4 +- primitives/trie/src/lib.rs | 2 +- primitives/trie/src/node_header.rs | 2 +- test-utils/client/Cargo.toml | 16 +- test-utils/client/src/client_ext.rs | 12 +- test-utils/client/src/lib.rs | 51 ++-- test-utils/runtime/Cargo.toml | 58 ++-- test-utils/runtime/client/Cargo.toml | 12 +- .../runtime/client/src/block_builder_ext.rs | 14 +- test-utils/runtime/client/src/lib.rs | 98 +++---- test-utils/runtime/client/src/trait_tests.rs | 16 +- test-utils/runtime/src/genesismap.rs | 8 +- test-utils/runtime/src/lib.rs | 65 +++-- test-utils/runtime/src/system.rs | 14 +- utils/frame/rpc/support/Cargo.toml | 2 +- utils/frame/rpc/support/src/lib.rs | 4 +- utils/frame/rpc/system/Cargo.toml | 8 +- utils/frame/rpc/system/src/lib.rs | 10 +- 485 files changed, 4022 insertions(+), 4004 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c921244587..679fa8d59a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6076,6 +6076,7 @@ dependencies = [ name = "sp-application-crypto-test" version = "2.0.0" dependencies = [ + "sp-application-crypto 2.0.0", "sp-core 2.0.0", "sp-runtime 2.0.0", "substrate-test-runtime-client 2.0.0", diff --git a/bin/node-template/Cargo.toml b/bin/node-template/Cargo.toml index 966c03549f..01a7840993 100644 --- a/bin/node-template/Cargo.toml +++ b/bin/node-template/Cargo.toml @@ -20,22 +20,22 @@ codec = { package = "parity-scale-codec", version = "1.0.0" } trie-root = "0.15.2" sp-io = { path = "../../primitives/io" } sc-cli = { path = "../../client/cli" } -primitives = { package = "sp-core", path = "../../primitives/core" } +sp-core = { path = "../../primitives/core" } sc-executor = { path = "../../client/executor" } sc-service = { path = "../../client/service" } -inherents = { package = "sp-inherents", path = "../../primitives/inherents" } -txpool = { package = "sc-transaction-pool", path = "../../client/transaction-pool" } -txpool-api = { package = "sp-transaction-pool", path = "../../primitives/transaction-pool" } -network = { package = "sc-network", path = "../../client/network" } -aura = { package = "sc-consensus-aura", path = "../../client/consensus/aura" } -aura-primitives = { package = "sp-consensus-aura", path = "../../primitives/consensus/aura" } -consensus-common = { package = "sp-consensus", path = "../../primitives/consensus/common" } +sp-inherents = { path = "../../primitives/inherents" } +sc-transaction-pool = { path = "../../client/transaction-pool" } +sp-transaction-pool = { path = "../../primitives/transaction-pool" } +sc-network = { path = "../../client/network" } +sc-consensus-aura = { path = "../../client/consensus/aura" } +sp-consensus-aura = { path = "../../primitives/consensus/aura" } +sp-consensus = { path = "../../primitives/consensus/common" } grandpa = { package = "sc-finality-grandpa", path = "../../client/finality-grandpa" } grandpa-primitives = { package = "sp-finality-grandpa", path = "../../primitives/finality-grandpa" } sc-client = { path = "../../client/" } -runtime = { package = "node-template-runtime", path = "runtime" } +node-template-runtime = { path = "runtime" } sp-runtime = { path = "../../primitives/runtime" } -basic-authorship = { package = "sc-basic-authority", path = "../../client/basic-authorship"} +sc-basic-authority = { path = "../../client/basic-authorship"} [build-dependencies] vergen = "3.0.4" diff --git a/bin/node-template/runtime/Cargo.toml b/bin/node-template/runtime/Cargo.toml index c1c30d3adc..398cf2ddb6 100644 --- a/bin/node-template/runtime/Cargo.toml +++ b/bin/node-template/runtime/Cargo.toml @@ -6,31 +6,32 @@ edition = "2018" [dependencies] aura = { package = "pallet-aura", path = "../../../frame/aura", default-features = false } -aura-primitives = { package = "sp-consensus-aura", path = "../../../primitives/consensus/aura", default-features = false } balances = { package = "pallet-balances", path = "../../../frame/balances", default-features = false } -block-builder-api = { package = "sp-block-builder", path = "../../../primitives/block-builder", default-features = false} -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -executive = { package = "frame-executive", path = "../../../frame/executive", default-features = false } +frame-support = { path = "../../../frame/support", default-features = false } grandpa = { package = "pallet-grandpa", path = "../../../frame/grandpa", default-features = false } indices = { package = "pallet-indices", path = "../../../frame/indices", default-features = false } -inherents = { package = "sp-inherents", path = "../../../primitives/inherents", default-features = false} -offchain-primitives = { package = "sp-offchain", path = "../../../primitives/offchain", default-features = false } -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 } -sp-io = { path = "../../../primitives/io", default-features = false } +sudo = { package = "pallet-sudo", path = "../../../frame/sudo", default-features = false } +system = { package = "frame-system", path = "../../../frame/system", default-features = false } +timestamp = { package = "pallet-timestamp", path = "../../../frame/timestamp", default-features = false } +transaction-payment = { package = "pallet-transaction-payment", path = "../../../frame/transaction-payment", default-features = false } + +codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } +frame-executive = { path = "../../../frame/executive", 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/api", default-features = false } +sp-block-builder = { path = "../../../primitives/block-builder", default-features = false} +sp-consensus-aura = { path = "../../../primitives/consensus/aura", default-features = false } +sp-core = { path = "../../../primitives/core", default-features = false } +sp-inherents = { path = "../../../primitives/inherents", default-features = false} +sp-io = { path = "../../../primitives/io", default-features = false } +sp-offchain = { path = "../../../primitives/offchain", default-features = false } sp-runtime = { path = "../../../primitives/runtime", default-features = false } sp-session = { path = "../../../primitives/session", default-features = false } -sudo = { package = "pallet-sudo", path = "../../../frame/sudo", default-features = false } -support = { package = "frame-support", path = "../../../frame/support", default-features = false } -system = { package = "frame-system", path = "../../../frame/system", default-features = false } -timestamp = { package = "pallet-timestamp", path = "../../../frame/timestamp", default-features = false } -transaction-payment = { package = "pallet-transaction-payment", path = "../../../frame/transaction-payment", default-features = false } -sp-transaction-pool = { package = "sp-transaction-pool", path = "../../../primitives/transaction-pool", default-features = false } -version = { package = "sp-version", path = "../../../primitives/version", default-features = false } +sp-std = { path = "../../../primitives/std", default-features = false } +sp-transaction-pool = { path = "../../../primitives/transaction-pool", default-features = false } +sp-version = { path = "../../../primitives/version", default-features = false } [build-dependencies] wasm-builder-runner = { package = "substrate-wasm-builder-runner", path = "../../../utils/wasm-builder-runner", version = "1.0.4" } @@ -38,30 +39,30 @@ wasm-builder-runner = { package = "substrate-wasm-builder-runner", path = "../.. [features] default = ["std"] std = [ - "aura-primitives/std", "aura/std", "balances/std", - "block-builder-api/std", "codec/std", - "executive/std", + "frame-executive/std", + "frame-support/std", "grandpa/std", "indices/std", - "inherents/std", - "offchain-primitives/std", - "primitives/std", "randomness-collective-flip/std", - "sp-std/std", - "sp-io/std", "safe-mix/std", "serde", "sp-api/std", + "sp-block-builder/std", + "sp-consensus-aura/std", + "sp-core/std", + "sp-inherents/std", + "sp-io/std", + "sp-offchain/std", "sp-runtime/std", "sp-session/std", + "sp-std/std", + "sp-transaction-pool/std", + "sp-version/std", "sudo/std", - "support/std", "system/std", "timestamp/std", "transaction-payment/std", - "sp-transaction-pool/std", - "version/std", ] diff --git a/bin/node-template/runtime/src/lib.rs b/bin/node-template/runtime/src/lib.rs index 7abe43c066..04f9d03363 100644 --- a/bin/node-template/runtime/src/lib.rs +++ b/bin/node-template/runtime/src/lib.rs @@ -9,7 +9,7 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); use sp_std::prelude::*; -use primitives::OpaqueMetadata; +use sp_core::OpaqueMetadata; use sp_runtime::{ ApplyExtrinsicResult, transaction_validity::TransactionValidity, generic, create_runtime_str, impl_opaque_keys, MultiSignature @@ -18,12 +18,12 @@ use sp_runtime::traits::{ NumberFor, BlakeTwo256, Block as BlockT, StaticLookup, Verify, ConvertInto, IdentifyAccount }; use sp_api::impl_runtime_apis; -use aura_primitives::sr25519::AuthorityId as AuraId; +use sp_consensus_aura::sr25519::AuthorityId as AuraId; use grandpa::AuthorityList as GrandpaAuthorityList; use grandpa::fg_primitives; -use version::RuntimeVersion; +use sp_version::RuntimeVersion; #[cfg(feature = "std")] -use version::NativeVersion; +use sp_version::NativeVersion; // A few exports that help ease life for downstream crates. #[cfg(any(feature = "std", test))] @@ -31,7 +31,7 @@ pub use sp_runtime::BuildStorage; pub use timestamp::Call as TimestampCall; pub use balances::Call as BalancesCall; pub use sp_runtime::{Permill, Perbill}; -pub use support::{ +pub use frame_support::{ StorageValue, construct_runtime, parameter_types, traits::Randomness, weights::Weight, @@ -58,7 +58,7 @@ pub type Balance = u128; pub type Index = u32; /// A hash of some data used by the chain. -pub type Hash = primitives::H256; +pub type Hash = sp_core::H256; /// Digest item type. pub type DigestItem = generic::DigestItem; @@ -280,7 +280,7 @@ pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; /// Executive: handles dispatch to the various modules. -pub type Executive = executive::Executive, Runtime, AllModules>; +pub type Executive = frame_executive::Executive, Runtime, AllModules>; impl_runtime_apis! { impl sp_api::Core for Runtime { @@ -303,7 +303,7 @@ impl_runtime_apis! { } } - impl block_builder_api::BlockBuilder for Runtime { + impl sp_block_builder::BlockBuilder for Runtime { fn apply_extrinsic(extrinsic: ::Extrinsic) -> ApplyExtrinsicResult { Executive::apply_extrinsic(extrinsic) } @@ -312,14 +312,14 @@ impl_runtime_apis! { Executive::finalize_block() } - fn inherent_extrinsics(data: inherents::InherentData) -> Vec<::Extrinsic> { + fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<::Extrinsic> { data.create_extrinsics() } fn check_inherents( block: Block, - data: inherents::InherentData, - ) -> inherents::CheckInherentsResult { + data: sp_inherents::InherentData, + ) -> sp_inherents::CheckInherentsResult { data.check_extrinsics(&block) } @@ -334,13 +334,13 @@ impl_runtime_apis! { } } - impl offchain_primitives::OffchainWorkerApi for Runtime { + impl sp_offchain::OffchainWorkerApi for Runtime { fn offchain_worker(number: NumberFor) { Executive::offchain_worker(number) } } - impl aura_primitives::AuraApi for Runtime { + impl sp_consensus_aura::AuraApi for Runtime { fn slot_duration() -> u64 { Aura::slot_duration() } diff --git a/bin/node-template/runtime/src/template.rs b/bin/node-template/runtime/src/template.rs index 231f9b9a2b..b800eae70c 100644 --- a/bin/node-template/runtime/src/template.rs +++ b/bin/node-template/runtime/src/template.rs @@ -8,7 +8,7 @@ /// For more guidance on Substrate modules, see the example module /// https://github.com/paritytech/substrate/blob/master/frame/example/src/lib.rs -use support::{decl_module, decl_storage, decl_event, dispatch}; +use frame_support::{decl_module, decl_storage, decl_event, dispatch}; use system::ensure_signed; /// The module's configuration trait. @@ -69,8 +69,8 @@ decl_event!( mod tests { use super::*; - use primitives::H256; - use support::{impl_outer_origin, assert_ok, parameter_types, weights::Weight}; + use sp_core::H256; + use frame_support::{impl_outer_origin, assert_ok, parameter_types, weights::Weight}; use sp_runtime::{ traits::{BlakeTwo256, IdentityLookup}, testing::Header, Perbill, }; diff --git a/bin/node-template/src/chain_spec.rs b/bin/node-template/src/chain_spec.rs index 6b979b16dd..fae9feaf51 100644 --- a/bin/node-template/src/chain_spec.rs +++ b/bin/node-template/src/chain_spec.rs @@ -1,9 +1,9 @@ -use primitives::{Pair, Public, sr25519}; -use runtime::{ +use sp_core::{Pair, Public, sr25519}; +use node_template_runtime::{ AccountId, AuraConfig, BalancesConfig, GenesisConfig, GrandpaConfig, SudoConfig, IndicesConfig, SystemConfig, WASM_BINARY, Signature }; -use aura_primitives::sr25519::{AuthorityId as AuraId}; +use sp_consensus_aura::sr25519::{AuthorityId as AuraId}; use grandpa_primitives::{AuthorityId as GrandpaId}; use sc_service; use sp_runtime::traits::{Verify, IdentifyAccount}; diff --git a/bin/node-template/src/cli.rs b/bin/node-template/src/cli.rs index 5d29cdf8df..16638c4af9 100644 --- a/bin/node-template/src/cli.rs +++ b/bin/node-template/src/cli.rs @@ -5,7 +5,7 @@ use tokio::runtime::Runtime; pub use sc_cli::{VersionInfo, IntoExit, error}; use sc_cli::{display_role, informant, parse_and_prepare, ParseAndPrepare, NoCustom}; use sc_service::{AbstractService, Roles as ServiceRoles, Configuration}; -use aura_primitives::sr25519::{AuthorityPair as AuraPair}; +use sp_consensus_aura::sr25519::{AuthorityPair as AuraPair}; use crate::chain_spec; use log::info; diff --git a/bin/node-template/src/service.rs b/bin/node-template/src/service.rs index 9161e26732..e1379d2200 100644 --- a/bin/node-template/src/service.rs +++ b/bin/node-template/src/service.rs @@ -3,21 +3,21 @@ use std::sync::Arc; use std::time::Duration; use sc_client::LongestChain; -use runtime::{self, GenesisConfig, opaque::Block, RuntimeApi}; +use node_template_runtime::{self, GenesisConfig, opaque::Block, RuntimeApi}; use sc_service::{error::{Error as ServiceError}, AbstractService, Configuration, ServiceBuilder}; -use inherents::InherentDataProviders; -use network::{construct_simple_protocol}; +use sp_inherents::InherentDataProviders; +use sc_network::{construct_simple_protocol}; use sc_executor::native_executor_instance; pub use sc_executor::NativeExecutor; -use aura_primitives::sr25519::{AuthorityPair as AuraPair}; +use sp_consensus_aura::sr25519::{AuthorityPair as AuraPair}; use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider}; -use basic_authorship; +use sc_basic_authority; // Our native executor instance. native_executor_instance!( pub Executor, - runtime::api::dispatch, - runtime::native_version, + node_template_runtime::api::dispatch, + node_template_runtime::native_version, ); construct_simple_protocol! { @@ -32,19 +32,19 @@ construct_simple_protocol! { macro_rules! new_full_start { ($config:expr) => {{ let mut import_setup = None; - let inherent_data_providers = inherents::InherentDataProviders::new(); + let inherent_data_providers = sp_inherents::InherentDataProviders::new(); let builder = sc_service::ServiceBuilder::new_full::< - runtime::opaque::Block, runtime::RuntimeApi, crate::service::Executor + node_template_runtime::opaque::Block, node_template_runtime::RuntimeApi, crate::service::Executor >($config)? .with_select_chain(|_config, backend| { Ok(sc_client::LongestChain::new(backend.clone())) })? .with_transaction_pool(|config, client, _fetcher| { - let pool_api = txpool::FullChainApi::new(client.clone()); - let pool = txpool::BasicPool::new(config, pool_api); - let maintainer = txpool::FullBasicPoolMaintainer::new(pool.pool().clone(), client); - let maintainable_pool = txpool_api::MaintainableTransactionPool::new(pool, maintainer); + let pool_api = sc_transaction_pool::FullChainApi::new(client.clone()); + let pool = sc_transaction_pool::BasicPool::new(config, pool_api); + let maintainer = sc_transaction_pool::FullBasicPoolMaintainer::new(pool.pool().clone(), client); + let maintainable_pool = sp_transaction_pool::MaintainableTransactionPool::new(pool, maintainer); Ok(maintainable_pool) })? .with_import_queue(|_config, client, mut select_chain, transaction_pool| { @@ -52,12 +52,12 @@ macro_rules! new_full_start { .ok_or_else(|| sc_service::Error::SelectChainRequired)?; let (grandpa_block_import, grandpa_link) = - grandpa::block_import::<_, _, _, runtime::RuntimeApi, _>( + grandpa::block_import::<_, _, _, node_template_runtime::RuntimeApi, _>( client.clone(), &*client, select_chain )?; - let import_queue = aura::import_queue::<_, _, AuraPair, _>( - aura::SlotDuration::get_or_compute(&*client)?, + let import_queue = sc_consensus_aura::import_queue::<_, _, AuraPair, _>( + sc_consensus_aura::SlotDuration::get_or_compute(&*client)?, Box::new(grandpa_block_import.clone()), Some(Box::new(grandpa_block_import.clone())), None, @@ -102,7 +102,7 @@ pub fn new_full(config: Configuration(config: Configuration( - aura::SlotDuration::get_or_compute(&*client)?, + let aura = sc_consensus_aura::start_aura::<_, _, _, _, _, AuraPair, _, _, _, _>( + sc_consensus_aura::SlotDuration::get_or_compute(&*client)?, client, select_chain, block_import, @@ -203,10 +203,10 @@ pub fn new_light(config: Configuration(config: Configuration( - aura::SlotDuration::get_or_compute(&*client)?, + let import_queue = sc_consensus_aura::import_queue::<_, _, AuraPair, ()>( + sc_consensus_aura::SlotDuration::get_or_compute(&*client)?, Box::new(grandpa_block_import), None, Some(Box::new(finality_proof_import)), diff --git a/bin/node/cli/Cargo.toml b/bin/node/cli/Cargo.toml index 3d356ce5e4..e87d590614 100644 --- a/bin/node/cli/Cargo.toml +++ b/bin/node/cli/Cargo.toml @@ -34,45 +34,45 @@ rand = "0.7.2" structopt = "0.3.3" # primitives -authority-discovery-primitives = { package = "sp-authority-discovery", path = "../../../primitives/authority-discovery"} -babe-primitives = { package = "sp-consensus-babe", path = "../../../primitives/consensus/babe" } +sp-authority-discovery = { path = "../../../primitives/authority-discovery"} +sp-consensus-babe = { path = "../../../primitives/consensus/babe" } grandpa-primitives = { package = "sp-finality-grandpa", path = "../../../primitives/finality-grandpa" } -primitives = { package = "sp-core", path = "../../../primitives/core" } +sp-core = { path = "../../../primitives/core" } sp-runtime = { path = "../../../primitives/runtime" } sp-timestamp = { path = "../../../primitives/timestamp", default-features = false } sp-finality-tracker = { path = "../../../primitives/finality-tracker", default-features = false } -inherents = { package = "sp-inherents", path = "../../../primitives/inherents" } -keyring = { package = "sp-keyring", path = "../../../primitives/keyring" } +sp-inherents = { path = "../../../primitives/inherents" } +sp-keyring = { path = "../../../primitives/keyring" } sp-io = { path = "../../../primitives/io" } -consensus-common = { package = "sp-consensus", path = "../../../primitives/consensus/common" } +sp-consensus = { path = "../../../primitives/consensus/common" } # client dependencies -client-api = { package = "sc-client-api", path = "../../../client/api" } -client = { package = "sc-client", path = "../../../client/" } -chain-spec = { package = "sc-chain-spec", path = "../../../client/chain-spec" } -txpool = { package = "sc-transaction-pool", path = "../../../client/transaction-pool" } -txpool-api = { package = "sp-transaction-pool", path = "../../../primitives/transaction-pool" } -network = { package = "sc-network", path = "../../../client/network" } -babe = { package = "sc-consensus-babe", path = "../../../client/consensus/babe" } +sc-client-api = { path = "../../../client/api" } +sc-client = { path = "../../../client/" } +sc-chain-spec = { path = "../../../client/chain-spec" } +sc-transaction-pool = { path = "../../../client/transaction-pool" } +sp-transaction-pool = { path = "../../../primitives/transaction-pool" } +sc-network = { path = "../../../client/network" } +sc-consensus-babe = { path = "../../../client/consensus/babe" } grandpa = { package = "sc-finality-grandpa", path = "../../../client/finality-grandpa" } -client-db = { package = "sc-client-db", path = "../../../client/db", default-features = false } -offchain = { package = "sc-offchain", path = "../../../client/offchain" } +sc-client-db = { path = "../../../client/db", default-features = false } +sc-offchain = { path = "../../../client/offchain" } sc-rpc = { path = "../../../client/rpc" } sc-basic-authority = { path = "../../../client/basic-authorship" } sc-service = { path = "../../../client/service", default-features = false } sc-telemetry = { path = "../../../client/telemetry" } -authority-discovery = { package = "sc-authority-discovery", path = "../../../client/authority-discovery"} +sc-authority-discovery = { path = "../../../client/authority-discovery"} # frame dependencies -indices = { package = "pallet-indices", path = "../../../frame/indices" } -timestamp = { package = "pallet-timestamp", path = "../../../frame/timestamp", default-features = false } -contracts = { package = "pallet-contracts", path = "../../../frame/contracts" } -system = { package = "frame-system", path = "../../../frame/system" } -balances = { package = "pallet-balances", path = "../../../frame/balances" } -transaction-payment = { package = "pallet-transaction-payment", path = "../../../frame/transaction-payment" } -support = { package = "frame-support", path = "../../../frame/support", default-features = false } -im_online = { package = "pallet-im-online", path = "../../../frame/im-online", default-features = false } -sr-authority-discovery = { package = "pallet-authority-discovery", path = "../../../frame/authority-discovery"} +pallet-indices = { path = "../../../frame/indices" } +pallet-timestamp = { path = "../../../frame/timestamp", default-features = false } +pallet-contracts = { path = "../../../frame/contracts" } +frame-system = { path = "../../../frame/system" } +pallet-balances = { path = "../../../frame/balances" } +pallet-transaction-payment = { path = "../../../frame/transaction-payment" } +frame-support = { path = "../../../frame/support", default-features = false } +pallet-im-online = { path = "../../../frame/im-online", default-features = false } +pallet-authority-discovery = { path = "../../../frame/authority-discovery"} # node-specific dependencies node-runtime = { path = "../runtime" } @@ -98,9 +98,9 @@ kvdb-memorydb = { version = "0.1.1", optional = true } rand6 = { package = "rand", version = "0.6", features = ["wasm-bindgen"], optional = true } # Imported just for the `wasm-bindgen` feature [dev-dependencies] -keystore = { package = "sc-keystore", path = "../../../client/keystore" } -babe = { package = "sc-consensus-babe", path = "../../../client/consensus/babe", features = ["test-helpers"] } -service-test = { package = "sc-service-test", path = "../../../client/service/test" } +sc-keystore = { path = "../../../client/keystore" } +sc-consensus-babe = { path = "../../../client/consensus/babe", features = ["test-helpers"] } +sc-service-test = { path = "../../../client/service/test" } futures = "0.3.1" tempfile = "3.1.0" diff --git a/bin/node/cli/src/browser.rs b/bin/node/cli/src/browser.rs index b09bb74026..cd1d453d8b 100644 --- a/bin/node/cli/src/browser.rs +++ b/bin/node/cli/src/browser.rs @@ -40,7 +40,7 @@ fn start_inner(wasm_ext: wasm_ext::ffi::Transport) -> Result::default_with_spec_and_base_path(chain_spec, None); - config.network.transport = network::config::TransportConfig::Normal { + config.network.transport = sc_network::config::TransportConfig::Normal { wasm_external_transport: Some(wasm_ext.clone()), allow_private_ipv4: true, enable_mdns: false, diff --git a/bin/node/cli/src/chain_spec.rs b/bin/node/cli/src/chain_spec.rs index fd65ec0624..8b86cb865b 100644 --- a/bin/node/cli/src/chain_spec.rs +++ b/bin/node/cli/src/chain_spec.rs @@ -16,8 +16,8 @@ //! Substrate chain configurations. -use chain_spec::ChainSpecExtension; -use primitives::{Pair, Public, crypto::UncheckedInto, sr25519}; +use sc_chain_spec::ChainSpecExtension; +use sp_core::{Pair, Public, crypto::UncheckedInto, sr25519}; use serde::{Serialize, Deserialize}; use node_runtime::{ AuthorityDiscoveryConfig, BabeConfig, BalancesConfig, ContractsConfig, CouncilConfig, DemocracyConfig, @@ -30,9 +30,9 @@ use sc_service; use hex_literal::hex; use sc_telemetry::TelemetryEndpoints; use grandpa_primitives::{AuthorityId as GrandpaId}; -use babe_primitives::{AuthorityId as BabeId}; -use im_online::sr25519::{AuthorityId as ImOnlineId}; -use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId; +use sp_consensus_babe::{AuthorityId as BabeId}; +use pallet_im_online::sr25519::{AuthorityId as ImOnlineId}; +use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; use sp_runtime::{Perbill, traits::{Verify, IdentifyAccount}}; pub use node_primitives::{AccountId, Balance, Signature}; @@ -49,7 +49,7 @@ const STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/"; #[derive(Default, Clone, Serialize, Deserialize, ChainSpecExtension)] pub struct Extensions { /// Block numbers with known hashes. - pub fork_blocks: client::ForkBlocks, + pub fork_blocks: sc_client::ForkBlocks, } /// Specialized `ChainSpec`. @@ -229,24 +229,24 @@ pub fn testnet_genesis( code: WASM_BINARY.to_vec(), changes_trie_config: Default::default(), }), - balances: Some(BalancesConfig { + pallet_balances: Some(BalancesConfig { balances: endowed_accounts.iter().cloned() .map(|k| (k, ENDOWMENT)) .chain(initial_authorities.iter().map(|x| (x.0.clone(), STASH))) .collect(), vesting: vec![], }), - indices: Some(IndicesConfig { + pallet_indices: Some(IndicesConfig { ids: endowed_accounts.iter().cloned() .chain(initial_authorities.iter().map(|x| x.0.clone())) .collect::>(), }), - session: Some(SessionConfig { + pallet_session: Some(SessionConfig { keys: initial_authorities.iter().map(|x| { (x.0.clone(), session_keys(x.2.clone(), x.3.clone(), x.4.clone(), x.5.clone())) }).collect::>(), }), - staking: Some(StakingConfig { + pallet_staking: Some(StakingConfig { current_era: 0, validator_count: initial_authorities.len() as u32 * 2, minimum_validator_count: initial_authorities.len() as u32, @@ -257,41 +257,41 @@ pub fn testnet_genesis( slash_reward_fraction: Perbill::from_percent(10), .. Default::default() }), - democracy: Some(DemocracyConfig::default()), - collective_Instance1: Some(CouncilConfig { + pallet_democracy: Some(DemocracyConfig::default()), + pallet_collective_Instance1: Some(CouncilConfig { members: endowed_accounts.iter().cloned() .collect::>()[..(num_endowed_accounts + 1) / 2].to_vec(), phantom: Default::default(), }), - collective_Instance2: Some(TechnicalCommitteeConfig { + pallet_collective_Instance2: Some(TechnicalCommitteeConfig { members: endowed_accounts.iter().cloned() .collect::>()[..(num_endowed_accounts + 1) / 2].to_vec(), phantom: Default::default(), }), - contracts: Some(ContractsConfig { - current_schedule: contracts::Schedule { + pallet_contracts: Some(ContractsConfig { + current_schedule: pallet_contracts::Schedule { enable_println, // this should only be enabled on development chains ..Default::default() }, gas_price: 1 * MILLICENTS, }), - sudo: Some(SudoConfig { + pallet_sudo: Some(SudoConfig { key: root_key, }), - babe: Some(BabeConfig { + pallet_babe: Some(BabeConfig { authorities: vec![], }), - im_online: Some(ImOnlineConfig { + pallet_im_online: Some(ImOnlineConfig { keys: vec![], }), - authority_discovery: Some(AuthorityDiscoveryConfig { + pallet_authority_discovery: Some(AuthorityDiscoveryConfig { keys: vec![], }), - grandpa: Some(GrandpaConfig { + pallet_grandpa: Some(GrandpaConfig { authorities: vec![], }), - membership_Instance1: Some(Default::default()), - treasury: Some(Default::default()), + pallet_membership_Instance1: Some(Default::default()), + pallet_treasury: Some(Default::default()), } } @@ -351,7 +351,7 @@ pub(crate) mod tests { use super::*; use crate::service::new_full; use sc_service::Roles; - use service_test; + use sc_service_test; fn local_testnet_genesis_instant_single() -> GenesisConfig { testnet_genesis( @@ -395,7 +395,7 @@ pub(crate) mod tests { #[test] #[ignore] fn test_connectivity() { - service_test::connectivity( + sc_service_test::connectivity( integration_test_config_with_two_authorities(), |config| new_full(config), |mut config| { diff --git a/bin/node/cli/src/factory_impl.rs b/bin/node/cli/src/factory_impl.rs index b586337a2b..2a77bb5caa 100644 --- a/bin/node/cli/src/factory_impl.rs +++ b/bin/node/cli/src/factory_impl.rs @@ -22,19 +22,19 @@ use rand::{Rng, SeedableRng}; use rand::rngs::StdRng; use codec::{Encode, Decode}; -use keyring::sr25519::Keyring; +use sp_keyring::sr25519::Keyring; use node_runtime::{ Call, CheckedExtrinsic, UncheckedExtrinsic, SignedExtra, BalancesCall, ExistentialDeposit, MinimumPeriod }; use node_primitives::Signature; -use primitives::{sr25519, crypto::Pair}; +use sp_core::{sr25519, crypto::Pair}; use sp_runtime::{ generic::Era, traits::{Block as BlockT, Header as HeaderT, SignedExtension, Verify, IdentifyAccount} }; use node_transaction_factory::RuntimeAdapter; use node_transaction_factory::modes::Mode; -use inherents::InherentData; +use sp_inherents::InherentData; use sp_timestamp; use sp_finality_tracker; @@ -56,12 +56,12 @@ type Number = <::Header as HeaderT>::Number; impl FactoryState { fn build_extra(index: node_primitives::Index, phase: u64) -> node_runtime::SignedExtra { ( - system::CheckVersion::new(), - system::CheckGenesis::new(), - system::CheckEra::from(Era::mortal(256, phase)), - system::CheckNonce::from(index), - system::CheckWeight::new(), - transaction_payment::ChargeTransactionPayment::from(0), + frame_system::CheckVersion::new(), + frame_system::CheckGenesis::new(), + frame_system::CheckEra::from(Era::mortal(256, phase)), + frame_system::CheckNonce::from(index), + frame_system::CheckWeight::new(), + pallet_transaction_payment::ChargeTransactionPayment::from(0), Default::default(), ) } @@ -149,7 +149,7 @@ impl RuntimeAdapter for FactoryState { signed: Some((sender.clone(), Self::build_extra(index, phase))), function: Call::Balances( BalancesCall::transfer( - indices::address::Address::Id(destination.clone().into()), + pallet_indices::address::Address::Id(destination.clone().into()), (*amount).into() ) ) @@ -253,7 +253,7 @@ fn sign( } }).into(); UncheckedExtrinsic { - signature: Some((indices::address::Address::Id(signed), signature, extra)), + signature: Some((pallet_indices::address::Address::Id(signed), signature, extra)), function: payload.0, } } diff --git a/bin/node/cli/src/service.rs b/bin/node/cli/src/service.rs index 025af2715c..7716f5a1c3 100644 --- a/bin/node/cli/src/service.rs +++ b/bin/node/cli/src/service.rs @@ -20,8 +20,8 @@ use std::sync::Arc; -use babe; -use client::{self, LongestChain}; +use sc_consensus_babe; +use sc_client::{self, LongestChain}; use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider}; use node_executor; use node_primitives::Block; @@ -29,17 +29,17 @@ use node_runtime::{GenesisConfig, RuntimeApi}; use sc_service::{ AbstractService, ServiceBuilder, config::Configuration, error::{Error as ServiceError}, }; -use inherents::InherentDataProviders; -use network::construct_simple_protocol; +use sp_inherents::InherentDataProviders; +use sc_network::construct_simple_protocol; use sc_service::{Service, NetworkStatus}; -use client::{Client, LocalCallExecutor}; -use client_db::Backend; +use sc_client::{Client, LocalCallExecutor}; +use sc_client_db::Backend; use sp_runtime::traits::Block as BlockT; use node_executor::NativeExecutor; -use network::NetworkService; -use offchain::OffchainWorkers; -use primitives::Blake2Hasher; +use sc_network::NetworkService; +use sc_offchain::OffchainWorkers; +use sp_core::Blake2Hasher; construct_simple_protocol! { /// Demo protocol attachment for substrate. @@ -54,19 +54,19 @@ macro_rules! new_full_start { ($config:expr) => {{ type RpcExtension = jsonrpc_core::IoHandler; let mut import_setup = None; - let inherent_data_providers = inherents::InherentDataProviders::new(); + let inherent_data_providers = sp_inherents::InherentDataProviders::new(); let builder = sc_service::ServiceBuilder::new_full::< node_primitives::Block, node_runtime::RuntimeApi, node_executor::Executor >($config)? .with_select_chain(|_config, backend| { - Ok(client::LongestChain::new(backend.clone())) + Ok(sc_client::LongestChain::new(backend.clone())) })? .with_transaction_pool(|config, client, _fetcher| { - let pool_api = txpool::FullChainApi::new(client.clone()); - let pool = txpool::BasicPool::new(config, pool_api); - let maintainer = txpool::FullBasicPoolMaintainer::new(pool.pool().clone(), client); - let maintainable_pool = txpool_api::MaintainableTransactionPool::new(pool, maintainer); + let pool_api = sc_transaction_pool::FullChainApi::new(client.clone()); + let pool = sc_transaction_pool::BasicPool::new(config, pool_api); + let maintainer = sc_transaction_pool::FullBasicPoolMaintainer::new(pool.pool().clone(), client); + let maintainable_pool = sp_transaction_pool::MaintainableTransactionPool::new(pool, maintainer); Ok(maintainable_pool) })? .with_import_queue(|_config, client, mut select_chain, _transaction_pool| { @@ -79,14 +79,14 @@ macro_rules! new_full_start { )?; let justification_import = grandpa_block_import.clone(); - let (block_import, babe_link) = babe::block_import( - babe::Config::get_or_compute(&*client)?, + let (block_import, babe_link) = sc_consensus_babe::block_import( + sc_consensus_babe::Config::get_or_compute(&*client)?, grandpa_block_import, client.clone(), client.clone(), )?; - let import_queue = babe::import_queue( + let import_queue = sc_consensus_babe::import_queue( babe_link.clone(), block_import.clone(), Some(Box::new(justification_import)), @@ -114,7 +114,7 @@ macro_rules! new_full_start { macro_rules! new_full { ($config:expr, $with_startup_data: expr) => {{ use futures01::sync::mpsc; - use network::DhtEvent; + use sc_network::DhtEvent; use futures::{ compat::Stream01CompatExt, stream::StreamExt, @@ -172,9 +172,9 @@ macro_rules! new_full { .ok_or(sc_service::Error::SelectChainRequired)?; let can_author_with = - consensus_common::CanAuthorWithNativeVersion::new(client.executor().clone()); + sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()); - let babe_config = babe::BabeParams { + let babe_config = sc_consensus_babe::BabeParams { keystore: service.keystore(), client, select_chain, @@ -187,13 +187,13 @@ macro_rules! new_full { can_author_with, }; - let babe = babe::start_babe(babe_config)?; + let babe = sc_consensus_babe::start_babe(babe_config)?; service.spawn_essential_task(babe); let future03_dht_event_rx = dht_event_rx.compat() .map(|x| x.expect(" never returns an error; qed")) .boxed(); - let authority_discovery = authority_discovery::AuthorityDiscovery::new( + let authority_discovery = sc_authority_discovery::AuthorityDiscovery::new( service.client(), service.network(), sentry_nodes, @@ -280,14 +280,14 @@ type ConcreteClient = #[allow(dead_code)] type ConcreteBackend = Backend; #[allow(dead_code)] -type ConcreteTransactionPool = txpool_api::MaintainableTransactionPool< - txpool::BasicPool< - txpool::FullChainApi, +type ConcreteTransactionPool = sp_transaction_pool::MaintainableTransactionPool< + sc_transaction_pool::BasicPool< + sc_transaction_pool::FullChainApi, ConcreteBlock >, - txpool::FullBasicPoolMaintainer< + sc_transaction_pool::FullBasicPoolMaintainer< ConcreteClient, - txpool::FullChainApi + sc_transaction_pool::FullChainApi > >; @@ -306,7 +306,7 @@ pub fn new_full(config: NodeConfiguration) ConcreteTransactionPool, OffchainWorkers< ConcreteClient, - >::OffchainStorage, + >::OffchainStorage, ConcreteBlock, > >, @@ -329,10 +329,10 @@ pub fn new_light(config: NodeConfiguration) .with_transaction_pool(|config, client, fetcher| { let fetcher = fetcher .ok_or_else(|| "Trying to start light transaction pool without active fetcher")?; - let pool_api = txpool::LightChainApi::new(client.clone(), fetcher.clone()); - let pool = txpool::BasicPool::new(config, pool_api); - let maintainer = txpool::LightBasicPoolMaintainer::with_defaults(pool.pool().clone(), client, fetcher); - let maintainable_pool = txpool_api::MaintainableTransactionPool::new(pool, maintainer); + let pool_api = sc_transaction_pool::LightChainApi::new(client.clone(), fetcher.clone()); + let pool = sc_transaction_pool::BasicPool::new(config, pool_api); + let maintainer = sc_transaction_pool::LightBasicPoolMaintainer::with_defaults(pool.pool().clone(), client, fetcher); + let maintainable_pool = sp_transaction_pool::MaintainableTransactionPool::new(pool, maintainer); Ok(maintainable_pool) })? .with_import_queue_and_fprb(|_config, client, backend, fetcher, _select_chain, _tx_pool| { @@ -350,14 +350,14 @@ pub fn new_light(config: NodeConfiguration) let finality_proof_request_builder = finality_proof_import.create_finality_proof_request_builder(); - let (babe_block_import, babe_link) = babe::block_import( - babe::Config::get_or_compute(&*client)?, + let (babe_block_import, babe_link) = sc_consensus_babe::block_import( + sc_consensus_babe::Config::get_or_compute(&*client)?, grandpa_block_import, client.clone(), client.clone(), )?; - let import_queue = babe::import_queue( + let import_queue = sc_consensus_babe::import_queue( babe_link, babe_block_import, None, @@ -390,15 +390,15 @@ pub fn new_light(config: NodeConfiguration) #[cfg(test)] mod tests { use std::sync::Arc; - use babe::CompatibleDigestItem; - use consensus_common::{ + use sc_consensus_babe::CompatibleDigestItem; + use sp_consensus::{ Environment, Proposer, BlockImportParams, BlockOrigin, ForkChoiceStrategy, BlockImport, }; use node_primitives::{Block, DigestItem, Signature}; use node_runtime::{BalancesCall, Call, UncheckedExtrinsic, Address}; use node_runtime::constants::{currency::CENTS, time::SLOT_DURATION}; use codec::{Encode, Decode}; - use primitives::{crypto::Pair as CryptoPair, H256}; + use sp_core::{crypto::Pair as CryptoPair, H256}; use sp_runtime::{ generic::{BlockId, Era, Digest, SignedPayload}, traits::Block as BlockT, @@ -407,7 +407,7 @@ mod tests { }; use sp_timestamp; use sp_finality_tracker; - use keyring::AccountKeyring; + use sp_keyring::AccountKeyring; use sc_service::{AbstractService, Roles}; use crate::service::new_full; use sp_runtime::traits::IdentifyAccount; @@ -416,10 +416,10 @@ mod tests { #[cfg(feature = "rhd")] fn test_sync() { - use primitives::ed25519::Pair; + use sp_core::ed25519::Pair; use {service_test, Factory}; - use client::{BlockImportParams, BlockOrigin}; + use sc_client::{BlockImportParams, BlockOrigin}; let alice: Arc = Arc::new(Keyring::Alice.into()); let bob: Arc = Arc::new(Keyring::Bob.into()); @@ -467,8 +467,8 @@ mod tests { let v: Vec = Decode::decode(&mut xt.as_slice()).unwrap(); OpaqueExtrinsic(v) }; - service_test::sync( - chain_spec::integration_test_config(), + sc_service_test::sync( + sc_chain_spec::integration_test_config(), |config| new_full(config), |mut config| { // light nodes are unsupported @@ -484,9 +484,9 @@ mod tests { #[ignore] fn test_sync() { let keystore_path = tempfile::tempdir().expect("Creates keystore path"); - let keystore = keystore::Store::open(keystore_path.path(), None) + let keystore = sc_keystore::Store::open(keystore_path.path(), None) .expect("Creates keystore"); - let alice = keystore.write().insert_ephemeral_from_seed::("//Alice") + let alice = keystore.write().insert_ephemeral_from_seed::("//Alice") .expect("Creates authority pair"); let chain_spec = crate::chain_spec::tests::integration_test_config_with_single_authority(); @@ -499,13 +499,13 @@ mod tests { let charlie = Arc::new(AccountKeyring::Charlie.pair()); let mut index = 0; - service_test::sync( + sc_service_test::sync( chain_spec, |config| { let mut setup_handles = None; new_full!(config, | - block_import: &babe::BabeBlockImport<_, _, Block, _, _, _>, - babe_link: &babe::BabeLink, + block_import: &sc_consensus_babe::BabeBlockImport<_, _, Block, _, _, _>, + babe_link: &sc_consensus_babe::BabeLink, | { setup_handles = Some((block_import.clone(), babe_link.clone())); }).map(move |(node, x)| (node, (x, setup_handles.unwrap()))) @@ -534,7 +534,7 @@ mod tests { // so we must keep trying the next slots until we can claim one. let babe_pre_digest = loop { inherent_data.replace_data(sp_timestamp::INHERENT_IDENTIFIER, &(slot_num * SLOT_DURATION)); - if let Some(babe_pre_digest) = babe::test_helpers::claim_slot( + if let Some(babe_pre_digest) = sc_consensus_babe::test_helpers::claim_slot( slot_num, &parent_header, &*service.client(), @@ -594,12 +594,12 @@ mod tests { let function = Call::Balances(BalancesCall::transfer(to.into(), amount)); - let check_version = system::CheckVersion::new(); - let check_genesis = system::CheckGenesis::new(); - let check_era = system::CheckEra::from(Era::Immortal); - let check_nonce = system::CheckNonce::from(index); - let check_weight = system::CheckWeight::new(); - let payment = transaction_payment::ChargeTransactionPayment::from(0); + let check_version = frame_system::CheckVersion::new(); + let check_genesis = frame_system::CheckGenesis::new(); + let check_era = frame_system::CheckEra::from(Era::Immortal); + let check_nonce = frame_system::CheckNonce::from(index); + let check_weight = frame_system::CheckWeight::new(); + let payment = pallet_transaction_payment::ChargeTransactionPayment::from(0); let extra = ( check_version, check_genesis, @@ -635,7 +635,7 @@ mod tests { #[test] #[ignore] fn test_consensus() { - service_test::consensus( + sc_service_test::consensus( crate::chain_spec::tests::integration_test_config_with_two_authorities(), |config| new_full(config), |mut config| { diff --git a/bin/node/executor/Cargo.toml b/bin/node/executor/Cargo.toml index 7633c256e7..68765ddff6 100644 --- a/bin/node/executor/Cargo.toml +++ b/bin/node/executor/Cargo.toml @@ -9,27 +9,27 @@ edition = "2018" trie-root = "0.15.2" codec = { package = "parity-scale-codec", version = "1.0.0" } sp-io = { path = "../../../primitives/io" } -state_machine = { package = "sp-state-machine", path = "../../../primitives/state-machine" } +sp-state-machine = { path = "../../../primitives/state-machine" } sc-executor = { path = "../../../client/executor" } -primitives = { package = "sp-core", path = "../../../primitives/core" } -trie = { package = "sp-trie", path = "../../../primitives/trie" } +sp-core = { path = "../../../primitives/core" } +sp-trie = { path = "../../../primitives/trie" } node-primitives = { path = "../primitives" } node-runtime = { path = "../runtime" } [dev-dependencies] node-testing = { path = "../testing" } -test-client = { package = "substrate-test-client", path = "../../../test-utils/client" } +substrate-test-client = { path = "../../../test-utils/client" } sp-runtime = { path = "../../../primitives/runtime" } -runtime_support = { package = "frame-support", path = "../../../frame/support" } -balances = { package = "pallet-balances", path = "../../../frame/balances" } -transaction-payment = { package = "pallet-transaction-payment", path = "../../../frame/transaction-payment" } -session = { package = "pallet-session", path = "../../../frame/session" } -system = { package = "frame-system", path = "../../../frame/system" } -timestamp = { package = "pallet-timestamp", path = "../../../frame/timestamp" } -treasury = { package = "pallet-treasury", path = "../../../frame/treasury" } -contracts = { package = "pallet-contracts", path = "../../../frame/contracts" } -grandpa = { package = "pallet-grandpa", path = "../../../frame/grandpa" } -indices = { package = "pallet-indices", path = "../../../frame/indices" } +frame-support = { path = "../../../frame/support" } +pallet-balances = { path = "../../../frame/balances" } +pallet-transaction-payment = { path = "../../../frame/transaction-payment" } +pallet-session = { path = "../../../frame/session" } +frame-system = { path = "../../../frame/system" } +pallet-timestamp = { path = "../../../frame/timestamp" } +pallet-treasury = { path = "../../../frame/treasury" } +pallet-contracts = { path = "../../../frame/contracts" } +pallet-grandpa = { path = "../../../frame/grandpa" } +pallet-indices = { path = "../../../frame/indices" } wabt = "0.9.2" criterion = "0.3.0" diff --git a/bin/node/executor/benches/bench.rs b/bin/node/executor/benches/bench.rs index 86a9c1c672..74999a404e 100644 --- a/bin/node/executor/benches/bench.rs +++ b/bin/node/executor/benches/bench.rs @@ -23,11 +23,11 @@ use node_runtime::{ }; use node_runtime::constants::currency::*; use node_testing::keyring::*; -use primitives::{Blake2Hasher, NativeOrEncoded, NeverNativeValue}; -use primitives::storage::well_known_keys; -use primitives::traits::CodeExecutor; -use runtime_support::Hashable; -use state_machine::TestExternalities as CoreTestExternalities; +use sp_core::{Blake2Hasher, NativeOrEncoded, NeverNativeValue}; +use sp_core::storage::well_known_keys; +use sp_core::traits::CodeExecutor; +use frame_support::Hashable; +use sp_state_machine::TestExternalities as CoreTestExternalities; use sc_executor::{NativeExecutor, RuntimeInfo, WasmExecutionMethod, Externalities}; criterion_group!(benches, bench_execute_block); @@ -70,7 +70,7 @@ fn construct_block( parent_hash: Hash, extrinsics: Vec, ) -> (Vec, Hash) { - use trie::{TrieConfiguration, trie_types::Layout}; + use sp_trie::{TrieConfiguration, trie_types::Layout}; // sign extrinsics. let extrinsics = extrinsics.into_iter().map(sign).collect::>(); @@ -131,13 +131,13 @@ fn test_blocks(genesis_config: &GenesisConfig, executor: &NativeExecutor::WeightToFee::convert(weight); + let weight_fee = ::WeightToFee::convert(weight); fee_multiplier.saturated_multiply_accumulate(length_fee + weight_fee) + TransferFee::get() } - fn default_transfer_call() -> balances::Call { - balances::Call::transfer::(bob().into(), 69 * DOLLARS) + fn default_transfer_call() -> pallet_balances::Call { + pallet_balances::Call::transfer::(bob().into(), 69 * DOLLARS) } fn xt() -> UncheckedExtrinsic { @@ -145,16 +144,16 @@ mod tests { fn panic_execution_with_foreign_code_gives_error() { let mut t = TestExternalities::::new_with_code(BLOATY_CODE, Storage { top: map![ - >::hashed_key_for(alice()) => { + >::hashed_key_for(alice()) => { 69_u128.encode() }, - >::hashed_key().to_vec() => { + >::hashed_key().to_vec() => { 69_u128.encode() }, - >::hashed_key().to_vec() => { + >::hashed_key().to_vec() => { 0_u128.encode() }, - >::hashed_key_for(0) => { + >::hashed_key_for(0) => { vec![0u8; 32] } ], @@ -184,16 +183,16 @@ mod tests { fn bad_extrinsic_with_native_equivalent_code_gives_error() { let mut t = TestExternalities::::new_with_code(COMPACT_CODE, Storage { top: map![ - >::hashed_key_for(alice()) => { + >::hashed_key_for(alice()) => { 69_u128.encode() }, - >::hashed_key().to_vec() => { + >::hashed_key().to_vec() => { 69_u128.encode() }, - >::hashed_key().to_vec() => { + >::hashed_key().to_vec() => { 0_u128.encode() }, - >::hashed_key_for(0) => { + >::hashed_key_for(0) => { vec![0u8; 32] } ], @@ -223,14 +222,14 @@ mod tests { fn successful_execution_with_native_equivalent_code_gives_ok() { let mut t = TestExternalities::::new_with_code(COMPACT_CODE, Storage { top: map![ - >::hashed_key_for(alice()) => { + >::hashed_key_for(alice()) => { (111 * DOLLARS).encode() }, - >::hashed_key().to_vec() => { + >::hashed_key().to_vec() => { (111 * DOLLARS).encode() }, - >::hashed_key().to_vec() => vec![0u8; 16], - >::hashed_key_for(0) => vec![0u8; 32] + >::hashed_key().to_vec() => vec![0u8; 16], + >::hashed_key_for(0) => vec![0u8; 32] ], children: map![], }); @@ -265,14 +264,14 @@ mod tests { fn successful_execution_with_foreign_code_gives_ok() { let mut t = TestExternalities::::new_with_code(BLOATY_CODE, Storage { top: map![ - >::hashed_key_for(alice()) => { + >::hashed_key_for(alice()) => { (111 * DOLLARS).encode() }, - >::hashed_key().to_vec() => { + >::hashed_key().to_vec() => { (111 * DOLLARS).encode() }, - >::hashed_key().to_vec() => vec![0u8; 16], - >::hashed_key_for(0) => vec![0u8; 32] + >::hashed_key().to_vec() => vec![0u8; 16], + >::hashed_key_for(0) => vec![0u8; 32] ], children: map![], }); @@ -318,7 +317,7 @@ mod tests { parent_hash: Hash, extrinsics: Vec, ) -> (Vec, Hash) { - use trie::{TrieConfiguration, trie_types::Layout}; + use sp_trie::{TrieConfiguration, trie_types::Layout}; // sign extrinsics. let extrinsics = extrinsics.into_iter().map(sign).collect::>(); @@ -379,11 +378,11 @@ mod tests { vec![ CheckedExtrinsic { signed: None, - function: Call::Timestamp(timestamp::Call::set(42 * 1000)), + function: Call::Timestamp(pallet_timestamp::Call::set(42 * 1000)), }, CheckedExtrinsic { signed: Some((alice(), signed_extra(0, 0))), - function: Call::Balances(balances::Call::transfer(bob().into(), 69 * DOLLARS)), + function: Call::Balances(pallet_balances::Call::transfer(bob().into(), 69 * DOLLARS)), }, ] ) @@ -401,11 +400,11 @@ mod tests { vec![ CheckedExtrinsic { signed: None, - function: Call::Timestamp(timestamp::Call::set(42 * 1000)), + function: Call::Timestamp(pallet_timestamp::Call::set(42 * 1000)), }, CheckedExtrinsic { signed: Some((alice(), signed_extra(0, 0))), - function: Call::Balances(balances::Call::transfer(bob().into(), 69 * DOLLARS)), + function: Call::Balances(pallet_balances::Call::transfer(bob().into(), 69 * DOLLARS)), }, ] ); @@ -416,15 +415,15 @@ mod tests { vec![ CheckedExtrinsic { signed: None, - function: Call::Timestamp(timestamp::Call::set(52 * 1000)), + function: Call::Timestamp(pallet_timestamp::Call::set(52 * 1000)), }, CheckedExtrinsic { signed: Some((bob(), signed_extra(0, 0))), - function: Call::Balances(balances::Call::transfer(alice().into(), 5 * DOLLARS)), + function: Call::Balances(pallet_balances::Call::transfer(alice().into(), 5 * DOLLARS)), }, CheckedExtrinsic { signed: Some((alice(), signed_extra(1, 0))), - function: Call::Balances(balances::Call::transfer(bob().into(), 15 * DOLLARS)), + function: Call::Balances(pallet_balances::Call::transfer(bob().into(), 15 * DOLLARS)), } ] ); @@ -444,11 +443,11 @@ mod tests { vec![ CheckedExtrinsic { signed: None, - function: Call::Timestamp(timestamp::Call::set(time * 1000)), + function: Call::Timestamp(pallet_timestamp::Call::set(time * 1000)), }, CheckedExtrinsic { signed: Some((alice(), signed_extra(nonce, 0))), - function: Call::System(system::Call::remark(vec![0; size])), + function: Call::System(frame_system::Call::remark(vec![0; size])), } ] ) @@ -478,19 +477,19 @@ mod tests { let events = vec![ EventRecord { phase: Phase::ApplyExtrinsic(0), - event: Event::system(system::Event::ExtrinsicSuccess( + event: Event::system(frame_system::Event::ExtrinsicSuccess( DispatchInfo { weight: 10000, class: DispatchClass::Operational, pays_fee: true } )), topics: vec![], }, EventRecord { phase: Phase::ApplyExtrinsic(1), - event: Event::treasury(treasury::RawEvent::Deposit(1984800000000)), + event: Event::pallet_treasury(pallet_treasury::RawEvent::Deposit(1984800000000)), topics: vec![], }, EventRecord { phase: Phase::ApplyExtrinsic(1), - event: Event::balances(balances::RawEvent::Transfer( + event: Event::pallet_balances(pallet_balances::RawEvent::Transfer( alice().into(), bob().into(), 69 * DOLLARS, @@ -500,7 +499,7 @@ mod tests { }, EventRecord { phase: Phase::ApplyExtrinsic(1), - event: Event::system(system::Event::ExtrinsicSuccess( + event: Event::system(frame_system::Event::ExtrinsicSuccess( DispatchInfo { weight: 1000000, class: DispatchClass::Normal, pays_fee: true } )), topics: vec![], @@ -531,20 +530,20 @@ mod tests { let events = vec![ EventRecord { phase: Phase::ApplyExtrinsic(0), - event: Event::system(system::Event::ExtrinsicSuccess( + event: Event::system(frame_system::Event::ExtrinsicSuccess( DispatchInfo { weight: 10000, class: DispatchClass::Operational, pays_fee: true } )), topics: vec![], }, EventRecord { phase: Phase::ApplyExtrinsic(1), - event: Event::treasury(treasury::RawEvent::Deposit(1984780231392)), + event: Event::pallet_treasury(pallet_treasury::RawEvent::Deposit(1984780231392)), topics: vec![], }, EventRecord { phase: Phase::ApplyExtrinsic(1), - event: Event::balances( - balances::RawEvent::Transfer( + event: Event::pallet_balances( + pallet_balances::RawEvent::Transfer( bob().into(), alice().into(), 5 * DOLLARS, @@ -555,20 +554,20 @@ mod tests { }, EventRecord { phase: Phase::ApplyExtrinsic(1), - event: Event::system(system::Event::ExtrinsicSuccess( + event: Event::system(frame_system::Event::ExtrinsicSuccess( DispatchInfo { weight: 1000000, class: DispatchClass::Normal, pays_fee: true } )), topics: vec![], }, EventRecord { phase: Phase::ApplyExtrinsic(2), - event: Event::treasury(treasury::RawEvent::Deposit(1984780231392)), + event: Event::pallet_treasury(pallet_treasury::RawEvent::Deposit(1984780231392)), topics: vec![], }, EventRecord { phase: Phase::ApplyExtrinsic(2), - event: Event::balances( - balances::RawEvent::Transfer( + event: Event::pallet_balances( + pallet_balances::RawEvent::Transfer( alice().into(), bob().into(), 15 * DOLLARS, @@ -579,7 +578,7 @@ mod tests { }, EventRecord { phase: Phase::ApplyExtrinsic(2), - event: Event::system(system::Event::ExtrinsicSuccess( + event: Event::system(frame_system::Event::ExtrinsicSuccess( DispatchInfo { weight: 1000000, class: DispatchClass::Normal, pays_fee: true } )), topics: vec![], @@ -729,9 +728,9 @@ mod tests { #[test] fn deploying_wasm_contract_should_work() { let transfer_code = wabt::wat2wasm(CODE_TRANSFER).unwrap(); - let transfer_ch = ::Hashing::hash(&transfer_code); + let transfer_ch = ::Hashing::hash(&transfer_code); - let addr = ::DetermineContractAddress::contract_address_for( + let addr = ::DetermineContractAddress::contract_address_for( &transfer_ch, &[], &charlie(), @@ -744,25 +743,25 @@ mod tests { vec![ CheckedExtrinsic { signed: None, - function: Call::Timestamp(timestamp::Call::set(42 * 1000)), + function: Call::Timestamp(pallet_timestamp::Call::set(42 * 1000)), }, CheckedExtrinsic { signed: Some((charlie(), signed_extra(0, 0))), function: Call::Contracts( - contracts::Call::put_code::(10_000, transfer_code) + pallet_contracts::Call::put_code::(10_000, transfer_code) ), }, CheckedExtrinsic { signed: Some((charlie(), signed_extra(1, 0))), function: Call::Contracts( - contracts::Call::instantiate::(1 * DOLLARS, 10_000, transfer_ch, Vec::new()) + pallet_contracts::Call::instantiate::(1 * DOLLARS, 10_000, transfer_ch, Vec::new()) ), }, CheckedExtrinsic { signed: Some((charlie(), signed_extra(2, 0))), function: Call::Contracts( - contracts::Call::call::( - indices::address::Address::Id(addr.clone()), + pallet_contracts::Call::call::( + pallet_indices::address::Address::Id(addr.clone()), 10, 10_000, vec![0x00, 0x01, 0x02, 0x03] @@ -785,7 +784,7 @@ mod tests { t.execute_with(|| { // Verify that the contract constructor worked well and code of TRANSFER contract is actually deployed. assert_eq!( - &contracts::ContractInfoOf::::get(addr) + &pallet_contracts::ContractInfoOf::::get(addr) .and_then(|c| c.get_alive()) .unwrap() .code_hash, @@ -842,14 +841,14 @@ mod tests { fn panic_execution_gives_error() { let mut t = TestExternalities::::new_with_code(BLOATY_CODE, Storage { top: map![ - >::hashed_key_for(alice()) => { + >::hashed_key_for(alice()) => { 0_u128.encode() }, - >::hashed_key().to_vec() => { + >::hashed_key().to_vec() => { 0_u128.encode() }, - >::hashed_key().to_vec() => vec![0u8; 16], - >::hashed_key_for(0) => vec![0u8; 32] + >::hashed_key().to_vec() => vec![0u8; 16], + >::hashed_key_for(0) => vec![0u8; 32] ], children: map![], }); @@ -877,14 +876,14 @@ mod tests { fn successful_execution_gives_ok() { let mut t = TestExternalities::::new_with_code(COMPACT_CODE, Storage { top: map![ - >::hashed_key_for(alice()) => { + >::hashed_key_for(alice()) => { (111 * DOLLARS).encode() }, - >::hashed_key().to_vec() => { + >::hashed_key().to_vec() => { (111 * DOLLARS).encode() }, - >::hashed_key().to_vec() => vec![0u8; 16], - >::hashed_key_for(0) => vec![0u8; 32] + >::hashed_key().to_vec() => vec![0u8; 16], + >::hashed_key_for(0) => vec![0u8; 32] ], children: map![], }); @@ -952,7 +951,9 @@ mod tests { #[test] fn should_import_block_with_test_client() { - use node_testing::client::{ClientExt, TestClientBuilderExt, TestClientBuilder, consensus::BlockOrigin}; + use node_testing::client::{ + ClientExt, TestClientBuilderExt, TestClientBuilder, sp_consensus::BlockOrigin + }; let client = TestClientBuilder::new().build(); let block1 = changes_trie_block(); @@ -984,11 +985,11 @@ mod tests { vec![ CheckedExtrinsic { signed: None, - function: Call::Timestamp(timestamp::Call::set(42 * 1000)), + function: Call::Timestamp(pallet_timestamp::Call::set(42 * 1000)), }, CheckedExtrinsic { signed: Some((charlie(), signed_extra(0, 0))), - function: Call::System(system::Call::fill_block()), + function: Call::System(frame_system::Call::fill_block()), } ] ); @@ -1001,11 +1002,11 @@ mod tests { vec![ CheckedExtrinsic { signed: None, - function: Call::Timestamp(timestamp::Call::set(52 * 1000)), + function: Call::Timestamp(pallet_timestamp::Call::set(52 * 1000)), }, CheckedExtrinsic { signed: Some((charlie(), signed_extra(1, 0))), - function: Call::System(system::Call::remark(vec![0; 1])), + function: Call::System(frame_system::Call::remark(vec![0; 1])), } ] ); @@ -1057,17 +1058,17 @@ mod tests { // (this baed on assigning 0.1 CENT to the cheapest tx with `weight = 100`) let mut t = TestExternalities::::new_with_code(COMPACT_CODE, Storage { top: map![ - >::hashed_key_for(alice()) => { + >::hashed_key_for(alice()) => { (100 * DOLLARS).encode() }, - >::hashed_key_for(bob()) => { + >::hashed_key_for(bob()) => { (10 * DOLLARS).encode() }, - >::hashed_key().to_vec() => { + >::hashed_key().to_vec() => { (110 * DOLLARS).encode() }, - >::hashed_key().to_vec() => vec![0u8; 16], - >::hashed_key_for(0) => vec![0u8; 32] + >::hashed_key().to_vec() => vec![0u8; 16], + >::hashed_key_for(0) => vec![0u8; 32] ], children: map![], }); @@ -1147,12 +1148,12 @@ mod tests { let num_transfers = block_number * factor; let mut xts = (0..num_transfers).map(|i| CheckedExtrinsic { signed: Some((charlie(), signed_extra(nonce + i as Index, 0))), - function: Call::Balances(balances::Call::transfer(bob().into(), 0)), + function: Call::Balances(pallet_balances::Call::transfer(bob().into(), 0)), }).collect::>(); xts.insert(0, CheckedExtrinsic { signed: None, - function: Call::Timestamp(timestamp::Call::set(time * 1000)), + function: Call::Timestamp(pallet_timestamp::Call::set(time * 1000)), }); // NOTE: this is super slow. Can probably be improved. @@ -1219,11 +1220,11 @@ mod tests { vec![ CheckedExtrinsic { signed: None, - function: Call::Timestamp(timestamp::Call::set(time * 1000)), + function: Call::Timestamp(pallet_timestamp::Call::set(time * 1000)), }, CheckedExtrinsic { signed: Some((charlie(), signed_extra(nonce, 0))), - function: Call::System(system::Call::remark(vec![0u8; (block_number * factor) as usize])), + function: Call::System(frame_system::Call::remark(vec![0u8; (block_number * factor) as usize])), }, ] ); diff --git a/bin/node/primitives/Cargo.toml b/bin/node/primitives/Cargo.toml index 7141dbbbca..956a346d2e 100644 --- a/bin/node/primitives/Cargo.toml +++ b/bin/node/primitives/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -primitives = { package = "sp-core", path = "../../../primitives/core", default-features = false } +sp-core = { path = "../../../primitives/core", default-features = false } sp-runtime = { path = "../../../primitives/runtime", default-features = false } [dev-dependencies] @@ -15,6 +15,6 @@ pretty_assertions = "0.6.1" [features] default = ["std"] std = [ - "primitives/std", + "sp-core/std", "sp-runtime/std", ] diff --git a/bin/node/primitives/src/lib.rs b/bin/node/primitives/src/lib.rs index eeb03a1b9b..9cd9c047c9 100644 --- a/bin/node/primitives/src/lib.rs +++ b/bin/node/primitives/src/lib.rs @@ -47,7 +47,7 @@ pub type Moment = u64; pub type Index = u32; /// A hash of some data used by the chain. -pub type Hash = primitives::H256; +pub type Hash = sp_core::H256; /// A timestamp: milliseconds since the unix epoch. /// `u64` is enough to represent a duration of half a billion years, when the diff --git a/bin/node/rpc/Cargo.toml b/bin/node/rpc/Cargo.toml index 2aead3b969..7b8f8a6cc3 100644 --- a/bin/node/rpc/Cargo.toml +++ b/bin/node/rpc/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -client = { package = "sc-client", path = "../../../client/" } +sc-client = { path = "../../../client/" } jsonrpc-core = "14.0.3" node-primitives = { path = "../primitives" } node-runtime = { path = "../runtime" } @@ -13,4 +13,4 @@ sp-runtime = { path = "../../../primitives/runtime" } pallet-contracts-rpc = { path = "../../../frame/contracts/rpc/" } pallet-transaction-payment-rpc = { path = "../../../frame/transaction-payment/rpc/" } substrate-frame-rpc-system = { path = "../../../utils/frame/rpc/system" } -txpool-api = { package = "sp-transaction-pool", path = "../../../primitives/transaction-pool" } +sp-transaction-pool = { path = "../../../primitives/transaction-pool" } diff --git a/bin/node/rpc/src/lib.rs b/bin/node/rpc/src/lib.rs index 718250d1d4..67a349598f 100644 --- a/bin/node/rpc/src/lib.rs +++ b/bin/node/rpc/src/lib.rs @@ -34,12 +34,12 @@ use std::sync::Arc; use node_primitives::{Block, AccountId, Index, Balance}; use node_runtime::UncheckedExtrinsic; use sp_runtime::traits::ProvideRuntimeApi; -use txpool_api::TransactionPool; +use sp_transaction_pool::TransactionPool; /// Light client extra dependencies. pub struct LightDeps { /// Remote access to the blockchain (async). - pub remote_blockchain: Arc>, + pub remote_blockchain: Arc>, /// Fetcher instance. pub fetcher: Arc, } @@ -63,12 +63,12 @@ pub fn create( light_deps: Option>, ) -> jsonrpc_core::IoHandler where C: ProvideRuntimeApi, - C: client::blockchain::HeaderBackend, + C: sc_client::blockchain::HeaderBackend, C: Send + Sync + 'static, C::Api: substrate_frame_rpc_system::AccountNonceApi, C::Api: pallet_contracts_rpc::ContractsRuntimeApi, C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi, - F: client::light::fetcher::Fetcher + 'static, + F: sc_client::light::fetcher::Fetcher + 'static, P: TransactionPool + 'static, M: jsonrpc_core::Metadata + Default, { diff --git a/bin/node/runtime/Cargo.toml b/bin/node/runtime/Cargo.toml index 1cc4fc831b..b8d669784d 100644 --- a/bin/node/runtime/Cargo.toml +++ b/bin/node/runtime/Cargo.toml @@ -14,53 +14,53 @@ rustc-hex = { version = "2.0", optional = true } serde = { version = "1.0.102", optional = true } # primitives -authority-discovery-primitives = { package = "sp-authority-discovery", path = "../../../primitives/authority-discovery", default-features = false } -babe-primitives = { package = "sp-consensus-babe", path = "../../../primitives/consensus/babe", default-features = false } -block-builder-api = { package = "sp-block-builder", path = "../../../primitives/block-builder", default-features = false} -inherents = { package = "sp-inherents", path = "../../../primitives/inherents", default-features = false } +sp-authority-discovery = { path = "../../../primitives/authority-discovery", default-features = false } +sp-consensus-babe = { path = "../../../primitives/consensus/babe", default-features = false } +sp-block-builder = { path = "../../../primitives/block-builder", default-features = false} +sp-inherents = { path = "../../../primitives/inherents", default-features = false } node-primitives = { path = "../primitives", default-features = false } -offchain-primitives = { package = "sp-offchain", path = "../../../primitives/offchain", default-features = false } -primitives = { package = "sp-core", path = "../../../primitives/core", default-features = false } +sp-offchain = { path = "../../../primitives/offchain", default-features = false } +sp-core = { path = "../../../primitives/core", default-features = false } sp-std = { path = "../../../primitives/std", default-features = false } sp-api = { path = "../../../primitives/api", default-features = false } sp-runtime = { path = "../../../primitives/runtime", default-features = false } sp-staking = { path = "../../../primitives/staking", default-features = false } sp-keyring = { path = "../../../primitives/keyring", optional = true } sp-session = { path = "../../../primitives/session", default-features = false } -sp-transaction-pool = { package = "sp-transaction-pool", path = "../../../primitives/transaction-pool", default-features = false } -version = { package = "sp-version", path = "../../../primitives/version", default-features = false } +sp-transaction-pool = { path = "../../../primitives/transaction-pool", default-features = false } +sp-version = { path = "../../../primitives/version", default-features = false } # frame dependencies -authority-discovery = { package = "pallet-authority-discovery", path = "../../../frame/authority-discovery", default-features = false } -authorship = { package = "pallet-authorship", path = "../../../frame/authorship", default-features = false } -babe = { package = "pallet-babe", path = "../../../frame/babe", default-features = false } -balances = { package = "pallet-balances", path = "../../../frame/balances", default-features = false } -collective = { package = "pallet-collective", path = "../../../frame/collective", default-features = false } -contracts = { package = "pallet-contracts", path = "../../../frame/contracts", default-features = false } -contracts-rpc-runtime-api = { package = "pallet-contracts-rpc-runtime-api", path = "../../../frame/contracts/rpc/runtime-api/", default-features = false } -democracy = { package = "pallet-democracy", path = "../../../frame/democracy", default-features = false } -elections-phragmen = { package = "pallet-elections-phragmen", path = "../../../frame/elections-phragmen", default-features = false } -executive = { package = "frame-executive", path = "../../../frame/executive", default-features = false } -finality-tracker = { package = "pallet-finality-tracker", path = "../../../frame/finality-tracker", default-features = false } -grandpa = { package = "pallet-grandpa", path = "../../../frame/grandpa", default-features = false } -im-online = { package = "pallet-im-online", path = "../../../frame/im-online", default-features = false } -indices = { package = "pallet-indices", path = "../../../frame/indices", default-features = false } -membership = { package = "pallet-membership", path = "../../../frame/membership", default-features = false } -nicks = { package = "pallet-nicks", path = "../../../frame/nicks", default-features = false } -offences = { package = "pallet-offences", path = "../../../frame/offences", default-features = false } -randomness-collective-flip = { package = "pallet-randomness-collective-flip", path = "../../../frame/randomness-collective-flip", default-features = false } -session = { package = "pallet-session", path = "../../../frame/session", default-features = false, features = ["historical"] } -staking = { package = "pallet-staking", path = "../../../frame/staking", default-features = false, features = ["migrate"] } +pallet-authority-discovery = { path = "../../../frame/authority-discovery", default-features = false } +pallet-authorship = { path = "../../../frame/authorship", default-features = false } +pallet-babe = { path = "../../../frame/babe", default-features = false } +pallet-balances = { path = "../../../frame/balances", default-features = false } +pallet-collective = { path = "../../../frame/collective", default-features = false } +pallet-contracts = { path = "../../../frame/contracts", default-features = false } +pallet-contracts-rpc-runtime-api = { path = "../../../frame/contracts/rpc/runtime-api/", default-features = false } +pallet-democracy = { path = "../../../frame/democracy", default-features = false } +pallet-elections-phragmen = { path = "../../../frame/elections-phragmen", default-features = false } +frame-executive = { path = "../../../frame/executive", default-features = false } +pallet-finality-tracker = { path = "../../../frame/finality-tracker", default-features = false } +pallet-grandpa = { path = "../../../frame/grandpa", default-features = false } +pallet-im-online = { path = "../../../frame/im-online", default-features = false } +pallet-indices = { path = "../../../frame/indices", default-features = false } +pallet-membership = { path = "../../../frame/membership", default-features = false } +pallet-nicks = { path = "../../../frame/nicks", default-features = false } +pallet-offences = { path = "../../../frame/offences", default-features = false } +pallet-randomness-collective-flip = { path = "../../../frame/randomness-collective-flip", default-features = false } +pallet-session = { path = "../../../frame/session", default-features = false, features = ["historical"] } +pallet-staking = { path = "../../../frame/staking", default-features = false, features = ["migrate"] } pallet-staking-reward-curve = { path = "../../../frame/staking/reward-curve"} -sudo = { package = "pallet-sudo", path = "../../../frame/sudo", default-features = false } -support = { package = "frame-support", path = "../../../frame/support", default-features = false } -system = { package = "frame-system", path = "../../../frame/system", default-features = false } -system-rpc-runtime-api = { package = "frame-system-rpc-runtime-api", path = "../../../frame/system/rpc/runtime-api/", default-features = false } -timestamp = { package = "pallet-timestamp", path = "../../../frame/timestamp", default-features = false } -treasury = { package = "pallet-treasury", path = "../../../frame/treasury", default-features = false } -utility = { package = "frame-utility", path = "../../../frame/utility", default-features = false } -transaction-payment = { package = "pallet-transaction-payment", path = "../../../frame/transaction-payment", default-features = false } -transaction-payment-rpc-runtime-api = { package = "pallet-transaction-payment-rpc-runtime-api", path = "../../../frame/transaction-payment/rpc/runtime-api/", default-features = false } +pallet-sudo = { path = "../../../frame/sudo", default-features = false } +frame-support = { path = "../../../frame/support", default-features = false } +frame-system = { path = "../../../frame/system", default-features = false } +frame-system-rpc-runtime-api = { path = "../../../frame/system/rpc/runtime-api/", default-features = false } +pallet-timestamp = { path = "../../../frame/timestamp", default-features = false } +pallet-treasury = { path = "../../../frame/treasury", default-features = false } +frame-utility = { path = "../../../frame/utility", default-features = false } +pallet-transaction-payment = { path = "../../../frame/transaction-payment", default-features = false } +pallet-transaction-payment-rpc-runtime-api = { path = "../../../frame/transaction-payment/rpc/runtime-api/", default-features = false } [build-dependencies] wasm-builder-runner = { package = "substrate-wasm-builder-runner", path = "../../../utils/wasm-builder-runner", version = "1.0.4" } @@ -71,52 +71,52 @@ sp-io = { path = "../../../primitives/io" } [features] default = ["std"] std = [ - "authority-discovery-primitives/std", - "authority-discovery/std", - "authorship/std", - "babe-primitives/std", - "babe/std", - "balances/std", - "block-builder-api/std", + "sp-authority-discovery/std", + "pallet-authority-discovery/std", + "pallet-authorship/std", + "sp-consensus-babe/std", + "pallet-babe/std", + "pallet-balances/std", + "sp-block-builder/std", "codec/std", - "collective/std", - "contracts-rpc-runtime-api/std", - "contracts/std", - "democracy/std", - "elections-phragmen/std", - "executive/std", - "finality-tracker/std", - "grandpa/std", - "im-online/std", - "indices/std", - "inherents/std", - "membership/std", - "nicks/std", + "pallet-collective/std", + "pallet-contracts-rpc-runtime-api/std", + "pallet-contracts/std", + "pallet-democracy/std", + "pallet-elections-phragmen/std", + "frame-executive/std", + "pallet-finality-tracker/std", + "pallet-grandpa/std", + "pallet-im-online/std", + "pallet-indices/std", + "sp-inherents/std", + "pallet-membership/std", + "pallet-nicks/std", "node-primitives/std", - "offchain-primitives/std", - "offences/std", - "primitives/std", - "randomness-collective-flip/std", + "sp-offchain/std", + "pallet-offences/std", + "sp-core/std", + "pallet-randomness-collective-flip/std", "sp-std/std", "rustc-hex", "safe-mix/std", "serde", - "session/std", + "pallet-session/std", "sp-api/std", "sp-runtime/std", "sp-staking/std", - "staking/std", + "pallet-staking/std", "sp-keyring", "sp-session/std", - "sudo/std", - "support/std", - "system-rpc-runtime-api/std", - "system/std", - "timestamp/std", - "transaction-payment-rpc-runtime-api/std", - "transaction-payment/std", - "treasury/std", + "pallet-sudo/std", + "frame-support/std", + "frame-system-rpc-runtime-api/std", + "frame-system/std", + "pallet-timestamp/std", + "pallet-transaction-payment-rpc-runtime-api/std", + "pallet-transaction-payment/std", + "pallet-treasury/std", "sp-transaction-pool/std", - "utility/std", - "version/std", + "frame-utility/std", + "sp-version/std", ] diff --git a/bin/node/runtime/src/impls.rs b/bin/node/runtime/src/impls.rs index 3d034a2fb1..75aba8b707 100644 --- a/bin/node/runtime/src/impls.rs +++ b/bin/node/runtime/src/impls.rs @@ -19,7 +19,7 @@ use node_primitives::Balance; use sp_runtime::traits::{Convert, Saturating}; use sp_runtime::{Fixed64, Perbill}; -use support::{traits::{OnUnbalanced, Currency, Get}, weights::Weight}; +use frame_support::{traits::{OnUnbalanced, Currency, Get}, weights::Weight}; use crate::{Balances, System, Authorship, MaximumBlockWeight, NegativeImbalance}; pub struct Author; @@ -118,7 +118,7 @@ mod tests { use sp_runtime::assert_eq_error_rate; use crate::{MaximumBlockWeight, AvailableBlockRatio, Runtime}; use crate::{constants::currency::*, TransactionPayment, TargetBlockFullness}; - use support::weights::Weight; + use frame_support::weights::Weight; fn max() -> Weight { MaximumBlockWeight::get() @@ -151,7 +151,7 @@ mod tests { fn run_with_system_weight(w: Weight, assertions: F) where F: Fn() -> () { let mut t: sp_io::TestExternalities = - system::GenesisConfig::default().build_storage::().unwrap().into(); + frame_system::GenesisConfig::default().build_storage::().unwrap().into(); t.execute_with(|| { System::set_block_limits(w, 0); assertions() @@ -227,7 +227,7 @@ mod tests { if fm == next { panic!("The fee should ever increase"); } fm = next; iterations += 1; - let fee = ::WeightToFee::convert(tx_weight); + let fee = ::WeightToFee::convert(tx_weight); let adjusted_fee = fm.saturated_multiply_accumulate(fee); println!( "iteration {}, new fm = {:?}. Fee at this point is: {} units / {} millicents, \ diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index e78e873142..fbf765fee5 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -21,12 +21,12 @@ #![recursion_limit="256"] use sp_std::prelude::*; -use support::{ +use frame_support::{ construct_runtime, parameter_types, weights::Weight, traits::{SplitTwoWays, Currency, Randomness}, }; -use primitives::u32_trait::{_1, _2, _3, _4}; +use sp_core::u32_trait::{_1, _2, _3, _4}; use node_primitives::{AccountId, AccountIndex, Balance, BlockNumber, Hash, Index, Moment, Signature}; use sp_api::impl_runtime_apis; use sp_runtime::{Permill, Perbill, ApplyExtrinsicResult, impl_opaque_keys, generic, create_runtime_str}; @@ -36,26 +36,26 @@ use sp_runtime::traits::{ self, BlakeTwo256, Block as BlockT, NumberFor, StaticLookup, SaturatedConversion, OpaqueKeys, }; -use version::RuntimeVersion; +use sp_version::RuntimeVersion; #[cfg(any(feature = "std", test))] -use version::NativeVersion; -use primitives::OpaqueMetadata; -use grandpa::AuthorityList as GrandpaAuthorityList; -use grandpa::fg_primitives; -use im_online::sr25519::{AuthorityId as ImOnlineId}; -use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId; -use transaction_payment_rpc_runtime_api::RuntimeDispatchInfo; -use contracts_rpc_runtime_api::ContractExecResult; -use system::offchain::TransactionSubmitter; -use inherents::{InherentData, CheckInherentsResult}; +use sp_version::NativeVersion; +use sp_core::OpaqueMetadata; +use pallet_grandpa::AuthorityList as GrandpaAuthorityList; +use pallet_grandpa::fg_primitives; +use pallet_im_online::sr25519::{AuthorityId as ImOnlineId}; +use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; +use pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo; +use pallet_contracts_rpc_runtime_api::ContractExecResult; +use frame_system::offchain::TransactionSubmitter; +use sp_inherents::{InherentData, CheckInherentsResult}; #[cfg(any(feature = "std", test))] pub use sp_runtime::BuildStorage; -pub use timestamp::Call as TimestampCall; -pub use balances::Call as BalancesCall; -pub use contracts::Gas; -pub use support::StorageValue; -pub use staking::StakerStatus; +pub use pallet_timestamp::Call as TimestampCall; +pub use pallet_balances::Call as BalancesCall; +pub use pallet_contracts::Gas; +pub use frame_support::StorageValue; +pub use pallet_staking::StakerStatus; /// Implementations of some helper traits passed into runtime modules as associated types. pub mod impls; @@ -109,7 +109,7 @@ parameter_types! { pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75); } -impl system::Trait for Runtime { +impl frame_system::Trait for Runtime { type Origin = Origin; type Call = Call; type Index = Index; @@ -127,7 +127,7 @@ impl system::Trait for Runtime { type Version = Version; } -impl utility::Trait for Runtime { +impl frame_utility::Trait for Runtime { type Event = Event; type Call = Call; } @@ -137,16 +137,16 @@ parameter_types! { pub const ExpectedBlockTime: Moment = MILLISECS_PER_BLOCK; } -impl babe::Trait for Runtime { +impl pallet_babe::Trait for Runtime { type EpochDuration = EpochDuration; type ExpectedBlockTime = ExpectedBlockTime; - type EpochChangeTrigger = babe::ExternalTrigger; + type EpochChangeTrigger = pallet_babe::ExternalTrigger; } -impl indices::Trait for Runtime { +impl pallet_indices::Trait for Runtime { type AccountIndex = AccountIndex; type IsDeadAccount = Balances; - type ResolveHint = indices::SimpleResolveHint; + type ResolveHint = pallet_indices::SimpleResolveHint; type Event = Event; } @@ -156,7 +156,7 @@ parameter_types! { pub const CreationFee: Balance = 1 * CENTS; } -impl balances::Trait for Runtime { +impl pallet_balances::Trait for Runtime { type Balance = Balance; type OnFreeBalanceZero = ((Staking, Contracts), Session); type OnNewAccount = Indices; @@ -177,7 +177,7 @@ parameter_types! { pub const TargetBlockFullness: Perbill = Perbill::from_percent(25); } -impl transaction_payment::Trait for Runtime { +impl pallet_transaction_payment::Trait for Runtime { type Currency = Balances; type OnTransactionPayment = DealWithFees; type TransactionBaseFee = TransactionBaseFee; @@ -189,7 +189,7 @@ impl transaction_payment::Trait for Runtime { parameter_types! { pub const MinimumPeriod: Moment = SLOT_DURATION / 2; } -impl timestamp::Trait for Runtime { +impl pallet_timestamp::Trait for Runtime { type Moment = Moment; type OnTimestampSet = Babe; type MinimumPeriod = MinimumPeriod; @@ -199,8 +199,8 @@ parameter_types! { pub const UncleGenerations: BlockNumber = 5; } -impl authorship::Trait for Runtime { - type FindAuthor = session::FindAccountFromAuthorIndex; +impl pallet_authorship::Trait for Runtime { + type FindAuthor = pallet_session::FindAccountFromAuthorIndex; type UncleGenerations = UncleGenerations; type FilterUncle = (); type EventHandler = (Staking, ImOnline); @@ -219,21 +219,21 @@ parameter_types! { pub const DisabledValidatorsThreshold: Perbill = Perbill::from_percent(17); } -impl session::Trait for Runtime { +impl pallet_session::Trait for Runtime { type OnSessionEnding = Staking; type SessionHandler = ::KeyTypeIdProviders; type ShouldEndSession = Babe; type Event = Event; type Keys = SessionKeys; - type ValidatorId = ::AccountId; - type ValidatorIdOf = staking::StashOf; + type ValidatorId = ::AccountId; + type ValidatorIdOf = pallet_staking::StashOf; type SelectInitialValidators = Staking; type DisabledValidatorsThreshold = DisabledValidatorsThreshold; } -impl session::historical::Trait for Runtime { - type FullIdentification = staking::Exposure; - type FullIdentificationOf = staking::ExposureOf; +impl pallet_session::historical::Trait for Runtime { + type FullIdentification = pallet_staking::Exposure; + type FullIdentificationOf = pallet_staking::ExposureOf; } pallet_staking_reward_curve::build! { @@ -249,12 +249,12 @@ pallet_staking_reward_curve::build! { parameter_types! { pub const SessionsPerEra: sp_staking::SessionIndex = 6; - pub const BondingDuration: staking::EraIndex = 24 * 28; - pub const SlashDeferDuration: staking::EraIndex = 24 * 7; // 1/4 the bonding duration. + pub const BondingDuration: pallet_staking::EraIndex = 24 * 28; + pub const SlashDeferDuration: pallet_staking::EraIndex = 24 * 7; // 1/4 the bonding duration. pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE; } -impl staking::Trait for Runtime { +impl pallet_staking::Trait for Runtime { type Currency = Balances; type Time = Timestamp; type CurrencyToVote = CurrencyToVoteHandler; @@ -266,7 +266,7 @@ impl staking::Trait for Runtime { type BondingDuration = BondingDuration; type SlashDeferDuration = SlashDeferDuration; /// A super-majority of the council can cancel the slash. - type SlashCancelOrigin = collective::EnsureProportionAtLeast<_3, _4, AccountId, CouncilCollective>; + type SlashCancelOrigin = pallet_collective::EnsureProportionAtLeast<_3, _4, AccountId, CouncilCollective>; type SessionInterface = Self; type RewardCurve = RewardCurve; } @@ -282,7 +282,7 @@ parameter_types! { pub const PreimageByteDeposit: Balance = 1 * CENTS; } -impl democracy::Trait for Runtime { +impl pallet_democracy::Trait for Runtime { type Proposal = Call; type Event = Event; type Currency = Balances; @@ -292,27 +292,27 @@ impl democracy::Trait for Runtime { type EmergencyVotingPeriod = EmergencyVotingPeriod; type MinimumDeposit = MinimumDeposit; /// A straight majority of the council can decide what their next motion is. - type ExternalOrigin = collective::EnsureProportionAtLeast<_1, _2, AccountId, CouncilCollective>; + type ExternalOrigin = pallet_collective::EnsureProportionAtLeast<_1, _2, AccountId, CouncilCollective>; /// A super-majority can have the next scheduled referendum be a straight majority-carries vote. - type ExternalMajorityOrigin = collective::EnsureProportionAtLeast<_3, _4, AccountId, CouncilCollective>; + type ExternalMajorityOrigin = pallet_collective::EnsureProportionAtLeast<_3, _4, AccountId, CouncilCollective>; /// A unanimous council can have the next scheduled referendum be a straight default-carries /// (NTB) vote. - type ExternalDefaultOrigin = collective::EnsureProportionAtLeast<_1, _1, AccountId, CouncilCollective>; + type ExternalDefaultOrigin = pallet_collective::EnsureProportionAtLeast<_1, _1, AccountId, CouncilCollective>; /// Two thirds of the technical committee can have an ExternalMajority/ExternalDefault vote /// be tabled immediately and with a shorter voting/enactment period. - type FastTrackOrigin = collective::EnsureProportionAtLeast<_2, _3, AccountId, TechnicalCollective>; + type FastTrackOrigin = pallet_collective::EnsureProportionAtLeast<_2, _3, AccountId, TechnicalCollective>; // To cancel a proposal which has been passed, 2/3 of the council must agree to it. - type CancellationOrigin = collective::EnsureProportionAtLeast<_2, _3, AccountId, CouncilCollective>; + type CancellationOrigin = pallet_collective::EnsureProportionAtLeast<_2, _3, AccountId, CouncilCollective>; // Any single technical committee member may veto a coming council proposal, however they can // only do it once and it lasts only for the cooloff period. - type VetoOrigin = collective::EnsureMember; + type VetoOrigin = pallet_collective::EnsureMember; type CooloffPeriod = CooloffPeriod; type PreimageByteDeposit = PreimageByteDeposit; type Slash = Treasury; } -type CouncilCollective = collective::Instance1; -impl collective::Trait for Runtime { +type CouncilCollective = pallet_collective::Instance1; +impl pallet_collective::Trait for Runtime { type Origin = Origin; type Proposal = Call; type Event = Event; @@ -326,7 +326,7 @@ parameter_types! { pub const DesiredRunnersUp: u32 = 7; } -impl elections_phragmen::Trait for Runtime { +impl pallet_elections_phragmen::Trait for Runtime { type Event = Event; type Currency = Balances; type CurrencyToVote = CurrencyToVoteHandler; @@ -341,19 +341,19 @@ impl elections_phragmen::Trait for Runtime { type ChangeMembers = Council; } -type TechnicalCollective = collective::Instance2; -impl collective::Trait for Runtime { +type TechnicalCollective = pallet_collective::Instance2; +impl pallet_collective::Trait for Runtime { type Origin = Origin; type Proposal = Call; type Event = Event; } -impl membership::Trait for Runtime { +impl pallet_membership::Trait for Runtime { type Event = Event; - type AddOrigin = collective::EnsureProportionMoreThan<_1, _2, AccountId, CouncilCollective>; - type RemoveOrigin = collective::EnsureProportionMoreThan<_1, _2, AccountId, CouncilCollective>; - type SwapOrigin = collective::EnsureProportionMoreThan<_1, _2, AccountId, CouncilCollective>; - type ResetOrigin = collective::EnsureProportionMoreThan<_1, _2, AccountId, CouncilCollective>; + type AddOrigin = pallet_collective::EnsureProportionMoreThan<_1, _2, AccountId, CouncilCollective>; + type RemoveOrigin = pallet_collective::EnsureProportionMoreThan<_1, _2, AccountId, CouncilCollective>; + type SwapOrigin = pallet_collective::EnsureProportionMoreThan<_1, _2, AccountId, CouncilCollective>; + type ResetOrigin = pallet_collective::EnsureProportionMoreThan<_1, _2, AccountId, CouncilCollective>; type MembershipInitialized = TechnicalCommittee; type MembershipChanged = TechnicalCommittee; } @@ -365,10 +365,10 @@ parameter_types! { pub const Burn: Permill = Permill::from_percent(50); } -impl treasury::Trait for Runtime { +impl pallet_treasury::Trait for Runtime { type Currency = Balances; - type ApproveOrigin = collective::EnsureMembers<_4, AccountId, CouncilCollective>; - type RejectOrigin = collective::EnsureMembers<_2, AccountId, CouncilCollective>; + type ApproveOrigin = pallet_collective::EnsureMembers<_4, AccountId, CouncilCollective>; + type RejectOrigin = pallet_collective::EnsureMembers<_2, AccountId, CouncilCollective>; type Event = Event; type ProposalRejection = (); type ProposalBond = ProposalBond; @@ -389,20 +389,20 @@ parameter_types! { pub const SurchargeReward: Balance = 150 * DOLLARS; } -impl contracts::Trait for Runtime { +impl pallet_contracts::Trait for Runtime { type Currency = Balances; type Time = Timestamp; type Randomness = RandomnessCollectiveFlip; type Call = Call; type Event = Event; - type DetermineContractAddress = contracts::SimpleAddressDeterminator; - type ComputeDispatchFee = contracts::DefaultDispatchFeeComputor; - type TrieIdGenerator = contracts::TrieIdFromParentCounter; + type DetermineContractAddress = pallet_contracts::SimpleAddressDeterminator; + type ComputeDispatchFee = pallet_contracts::DefaultDispatchFeeComputor; + type TrieIdGenerator = pallet_contracts::TrieIdFromParentCounter; type GasPayment = (); type RentPayment = (); - type SignedClaimHandicap = contracts::DefaultSignedClaimHandicap; + type SignedClaimHandicap = pallet_contracts::DefaultSignedClaimHandicap; type TombstoneDeposit = TombstoneDeposit; - type StorageSizeOffset = contracts::DefaultStorageSizeOffset; + type StorageSizeOffset = pallet_contracts::DefaultStorageSizeOffset; type RentByteFee = RentByteFee; type RentDepositOffset = RentDepositOffset; type SurchargeReward = SurchargeReward; @@ -411,14 +411,14 @@ impl contracts::Trait for Runtime { type TransactionBaseFee = ContractTransactionBaseFee; type TransactionByteFee = ContractTransactionByteFee; type ContractFee = ContractFee; - type CallBaseFee = contracts::DefaultCallBaseFee; - type InstantiateBaseFee = contracts::DefaultInstantiateBaseFee; - type MaxDepth = contracts::DefaultMaxDepth; - type MaxValueSize = contracts::DefaultMaxValueSize; - type BlockGasLimit = contracts::DefaultBlockGasLimit; + type CallBaseFee = pallet_contracts::DefaultCallBaseFee; + type InstantiateBaseFee = pallet_contracts::DefaultInstantiateBaseFee; + type MaxDepth = pallet_contracts::DefaultMaxDepth; + type MaxValueSize = pallet_contracts::DefaultMaxValueSize; + type BlockGasLimit = pallet_contracts::DefaultBlockGasLimit; } -impl sudo::Trait for Runtime { +impl pallet_sudo::Trait for Runtime { type Event = Event; type Proposal = Call; } @@ -429,7 +429,7 @@ parameter_types! { pub const SessionDuration: BlockNumber = EPOCH_DURATION_IN_SLOTS as _; } -impl im_online::Trait for Runtime { +impl pallet_im_online::Trait for Runtime { type AuthorityId = ImOnlineId; type Call = Call; type Event = Event; @@ -438,15 +438,15 @@ impl im_online::Trait for Runtime { type SessionDuration = SessionDuration; } -impl offences::Trait for Runtime { +impl pallet_offences::Trait for Runtime { type Event = Event; - type IdentificationTuple = session::historical::IdentificationTuple; + type IdentificationTuple = pallet_session::historical::IdentificationTuple; type OnOffenceHandler = Staking; } -impl authority_discovery::Trait for Runtime {} +impl pallet_authority_discovery::Trait for Runtime {} -impl grandpa::Trait for Runtime { +impl pallet_grandpa::Trait for Runtime { type Event = Event; } @@ -455,7 +455,7 @@ parameter_types! { pub const ReportLatency: BlockNumber = 1000; } -impl finality_tracker::Trait for Runtime { +impl pallet_finality_tracker::Trait for Runtime { type OnFinalizationStalled = Grandpa; type WindowSize = WindowSize; type ReportLatency = ReportLatency; @@ -467,21 +467,21 @@ parameter_types! { pub const MaxLength: usize = 16; } -impl nicks::Trait for Runtime { +impl pallet_nicks::Trait for Runtime { type Event = Event; type Currency = Balances; type ReservationFee = ReservationFee; type Slashed = Treasury; - type ForceOrigin = collective::EnsureMember; + type ForceOrigin = pallet_collective::EnsureMember; type MinLength = MinLength; type MaxLength = MaxLength; } -impl system::offchain::CreateTransaction for Runtime { +impl frame_system::offchain::CreateTransaction for Runtime { type Public = ::Signer; type Signature = Signature; - fn create_transaction>( + fn create_transaction>( call: Call, public: Self::Public, account: AccountId, @@ -491,12 +491,12 @@ impl system::offchain::CreateTransaction for Runtim let current_block = System::block_number().saturated_into::(); let tip = 0; let extra: SignedExtra = ( - system::CheckVersion::::new(), - system::CheckGenesis::::new(), - system::CheckEra::::from(generic::Era::mortal(period, current_block)), - system::CheckNonce::::from(index), - system::CheckWeight::::new(), - transaction_payment::ChargeTransactionPayment::::from(tip), + frame_system::CheckVersion::::new(), + frame_system::CheckGenesis::::new(), + frame_system::CheckEra::::from(generic::Era::mortal(period, current_block)), + frame_system::CheckNonce::::from(index), + frame_system::CheckWeight::::new(), + pallet_transaction_payment::ChargeTransactionPayment::::from(tip), Default::default(), ); let raw_payload = SignedPayload::new(call, extra).ok()?; @@ -507,6 +507,7 @@ impl system::offchain::CreateTransaction for Runtim } } +use frame_system as system; construct_runtime!( pub enum Runtime where Block = Block, @@ -514,30 +515,30 @@ construct_runtime!( UncheckedExtrinsic = UncheckedExtrinsic { System: system::{Module, Call, Storage, Config, Event}, - Utility: utility::{Module, Call, Event}, - Babe: babe::{Module, Call, Storage, Config, Inherent(Timestamp)}, - Timestamp: timestamp::{Module, Call, Storage, Inherent}, - Authorship: authorship::{Module, Call, Storage, Inherent}, - Indices: indices, - Balances: balances::{default, Error}, - TransactionPayment: transaction_payment::{Module, Storage}, - Staking: staking::{default, OfflineWorker}, - Session: session::{Module, Call, Storage, Event, Config}, - Democracy: democracy::{Module, Call, Storage, Config, Event}, - Council: collective::::{Module, Call, Storage, Origin, Event, Config}, - TechnicalCommittee: collective::::{Module, Call, Storage, Origin, Event, Config}, - Elections: elections_phragmen::{Module, Call, Storage, Event}, - TechnicalMembership: membership::::{Module, Call, Storage, Event, Config}, - FinalityTracker: finality_tracker::{Module, Call, Inherent}, - Grandpa: grandpa::{Module, Call, Storage, Config, Event}, - Treasury: treasury::{Module, Call, Storage, Config, Event}, - Contracts: contracts, - Sudo: sudo, - ImOnline: im_online::{Module, Call, Storage, Event, ValidateUnsigned, Config}, - AuthorityDiscovery: authority_discovery::{Module, Call, Config}, - Offences: offences::{Module, Call, Storage, Event}, - RandomnessCollectiveFlip: randomness_collective_flip::{Module, Call, Storage}, - Nicks: nicks::{Module, Call, Storage, Event}, + Utility: frame_utility::{Module, Call, Event}, + Babe: pallet_babe::{Module, Call, Storage, Config, Inherent(Timestamp)}, + Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent}, + Authorship: pallet_authorship::{Module, Call, Storage, Inherent}, + Indices: pallet_indices, + Balances: pallet_balances::{default, Error}, + TransactionPayment: pallet_transaction_payment::{Module, Storage}, + Staking: pallet_staking::{default, OfflineWorker}, + Session: pallet_session::{Module, Call, Storage, Event, Config}, + Democracy: pallet_democracy::{Module, Call, Storage, Config, Event}, + Council: pallet_collective::::{Module, Call, Storage, Origin, Event, Config}, + TechnicalCommittee: pallet_collective::::{Module, Call, Storage, Origin, Event, Config}, + Elections: pallet_elections_phragmen::{Module, Call, Storage, Event}, + TechnicalMembership: pallet_membership::::{Module, Call, Storage, Event, Config}, + FinalityTracker: pallet_finality_tracker::{Module, Call, Inherent}, + Grandpa: pallet_grandpa::{Module, Call, Storage, Config, Event}, + Treasury: pallet_treasury::{Module, Call, Storage, Config, Event}, + Contracts: pallet_contracts, + Sudo: pallet_sudo, + ImOnline: pallet_im_online::{Module, Call, Storage, Event, ValidateUnsigned, Config}, + AuthorityDiscovery: pallet_authority_discovery::{Module, Call, Config}, + Offences: pallet_offences::{Module, Call, Storage, Event}, + RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage}, + Nicks: pallet_nicks::{Module, Call, Storage, Event}, } ); @@ -553,13 +554,13 @@ pub type SignedBlock = generic::SignedBlock; pub type BlockId = generic::BlockId; /// The SignedExtension to the basic transaction logic. pub type SignedExtra = ( - system::CheckVersion, - system::CheckGenesis, - system::CheckEra, - system::CheckNonce, - system::CheckWeight, - transaction_payment::ChargeTransactionPayment, - contracts::CheckBlockGasLimit, + frame_system::CheckVersion, + frame_system::CheckGenesis, + frame_system::CheckEra, + frame_system::CheckNonce, + frame_system::CheckWeight, + pallet_transaction_payment::ChargeTransactionPayment, + pallet_contracts::CheckBlockGasLimit, ); /// Unchecked extrinsic type as expected by this runtime. pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; @@ -568,7 +569,7 @@ pub type SignedPayload = generic::SignedPayload; /// Extrinsic type that has already been checked. pub type CheckedExtrinsic = generic::CheckedExtrinsic; /// Executive: handles dispatch to the various modules. -pub type Executive = executive::Executive, Runtime, AllModules>; +pub type Executive = frame_executive::Executive, Runtime, AllModules>; impl_runtime_apis! { impl sp_api::Core for Runtime { @@ -591,7 +592,7 @@ impl_runtime_apis! { } } - impl block_builder_api::BlockBuilder for Runtime { + impl sp_block_builder::BlockBuilder for Runtime { fn apply_extrinsic(extrinsic: ::Extrinsic) -> ApplyExtrinsicResult { Executive::apply_extrinsic(extrinsic) } @@ -619,7 +620,7 @@ impl_runtime_apis! { } } - impl offchain_primitives::OffchainWorkerApi for Runtime { + impl sp_offchain::OffchainWorkerApi for Runtime { fn offchain_worker(number: NumberFor) { Executive::offchain_worker(number) } @@ -631,14 +632,14 @@ impl_runtime_apis! { } } - impl babe_primitives::BabeApi for Runtime { - fn configuration() -> babe_primitives::BabeConfiguration { + impl sp_consensus_babe::BabeApi for Runtime { + fn configuration() -> sp_consensus_babe::BabeConfiguration { // The choice of `c` parameter (where `1 - c` represents the // probability of a slot being empty), is done in accordance to the // slot duration and expected target block time, for safely // resisting network delays of maximum two seconds. // - babe_primitives::BabeConfiguration { + sp_consensus_babe::BabeConfiguration { slot_duration: Babe::slot_duration(), epoch_length: EpochDuration::get(), c: PRIMARY_PROBABILITY, @@ -649,19 +650,19 @@ impl_runtime_apis! { } } - impl authority_discovery_primitives::AuthorityDiscoveryApi for Runtime { + impl sp_authority_discovery::AuthorityDiscoveryApi for Runtime { fn authorities() -> Vec { AuthorityDiscovery::authorities() } } - impl system_rpc_runtime_api::AccountNonceApi for Runtime { + impl frame_system_rpc_runtime_api::AccountNonceApi for Runtime { fn account_nonce(account: AccountId) -> Index { System::account_nonce(account) } } - impl contracts_rpc_runtime_api::ContractsApi for Runtime { + impl pallet_contracts_rpc_runtime_api::ContractsApi for Runtime { fn call( origin: AccountId, dest: AccountId, @@ -688,10 +689,10 @@ impl_runtime_apis! { fn get_storage( address: AccountId, key: [u8; 32], - ) -> contracts_rpc_runtime_api::GetStorageResult { + ) -> pallet_contracts_rpc_runtime_api::GetStorageResult { Contracts::get_storage(address, key).map_err(|rpc_err| { - use contracts::GetStorageError; - use contracts_rpc_runtime_api::{GetStorageError as RpcGetStorageError}; + use pallet_contracts::GetStorageError; + use pallet_contracts_rpc_runtime_api::{GetStorageError as RpcGetStorageError}; /// Map the contract error into the RPC layer error. match rpc_err { GetStorageError::ContractDoesntExist => RpcGetStorageError::ContractDoesntExist, @@ -701,7 +702,7 @@ impl_runtime_apis! { } } - impl transaction_payment_rpc_runtime_api::TransactionPaymentApi< + impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi< Block, Balance, UncheckedExtrinsic, @@ -721,7 +722,7 @@ impl_runtime_apis! { #[cfg(test)] mod tests { use super::*; - use system::offchain::SubmitSignedTransaction; + use frame_system::offchain::SubmitSignedTransaction; fn is_submit_signed_transaction(_arg: T) where T: SubmitSignedTransaction< @@ -741,7 +742,7 @@ mod tests { #[test] fn block_hooks_weight_should_not_exceed_limits() { - use support::weights::WeighBlock; + use frame_support::weights::WeighBlock; let check_for_block = |b| { let block_hooks_weight = >::on_initialize(b) + diff --git a/bin/node/testing/Cargo.toml b/bin/node/testing/Cargo.toml index ce5aa78a5d..e23901d7f7 100644 --- a/bin/node/testing/Cargo.toml +++ b/bin/node/testing/Cargo.toml @@ -6,26 +6,26 @@ description = "Test utilities for Substrate node." edition = "2018" [dependencies] -balances = { package = "pallet-balances", path = "../../../frame/balances" } -client = { package = "sc-client", path = "../../../client/" } +pallet-balances = { path = "../../../frame/balances" } +sc-client = { path = "../../../client/" } codec = { package = "parity-scale-codec", version = "1.0.0" } -contracts = { package = "pallet-contracts", path = "../../../frame/contracts" } -grandpa = { package = "pallet-grandpa", path = "../../../frame/grandpa" } -indices = { package = "pallet-indices", path = "../../../frame/indices" } -keyring = { package = "sp-keyring", path = "../../../primitives/keyring" } +pallet-contracts = { path = "../../../frame/contracts" } +pallet-grandpa = { path = "../../../frame/grandpa" } +pallet-indices = { path = "../../../frame/indices" } +sp-keyring = { path = "../../../primitives/keyring" } node-executor = { path = "../executor" } node-primitives = { path = "../primitives" } node-runtime = { path = "../runtime" } -primitives = { package = "sp-core", path = "../../../primitives/core" } +sp-core = { path = "../../../primitives/core" } sp-io = { path = "../../../primitives/io" } -runtime_support = { package = "frame-support", path = "../../../frame/support" } -session = { package = "pallet-session", path = "../../../frame/session" } +frame-support = { path = "../../../frame/support" } +pallet-session = { path = "../../../frame/session" } sp-runtime = { path = "../../../primitives/runtime" } -staking = { package = "pallet-staking", path = "../../../frame/staking" } +pallet-staking = { path = "../../../frame/staking" } sc-executor = { path = "../../../client/executor" } -system = { package = "frame-system", path = "../../../frame/system" } -test-client = { package = "substrate-test-client", path = "../../../test-utils/client" } -timestamp = { package = "pallet-timestamp", path = "../../../frame/timestamp" } -transaction-payment = { package = "pallet-transaction-payment", path = "../../../frame/transaction-payment" } -treasury = { package = "pallet-treasury", path = "../../../frame/treasury" } +frame-system = { path = "../../../frame/system" } +substrate-test-client = { path = "../../../test-utils/client" } +pallet-timestamp = { path = "../../../frame/timestamp" } +pallet-transaction-payment = { path = "../../../frame/transaction-payment" } +pallet-treasury = { path = "../../../frame/treasury" } wabt = "0.9.2" diff --git a/bin/node/testing/src/client.rs b/bin/node/testing/src/client.rs index a6964b3915..4cd193a69e 100644 --- a/bin/node/testing/src/client.rs +++ b/bin/node/testing/src/client.rs @@ -19,18 +19,18 @@ use sp_runtime::BuildStorage; /// Re-export test-client utilities. -pub use test_client::*; +pub use substrate_test_client::*; /// Call executor for `node-runtime` `TestClient`. pub type Executor = sc_executor::NativeExecutor; /// Default backend type. -pub type Backend = client_db::Backend; +pub type Backend = sc_client_db::Backend; /// Test client type. -pub type Client = client::Client< +pub type Client = sc_client::Client< Backend, - client::LocalCallExecutor, + sc_client::LocalCallExecutor, node_primitives::Block, node_runtime::RuntimeApi, >; @@ -41,7 +41,7 @@ pub struct GenesisParameters { support_changes_trie: bool, } -impl test_client::GenesisInit for GenesisParameters { +impl substrate_test_client::GenesisInit for GenesisParameters { fn genesis_storage(&self) -> Storage { crate::genesis::config(self.support_changes_trie, None).build_storage().unwrap() } @@ -56,8 +56,8 @@ pub trait TestClientBuilderExt: Sized { fn build(self) -> Client; } -impl TestClientBuilderExt for test_client::TestClientBuilder< - client::LocalCallExecutor, +impl TestClientBuilderExt for substrate_test_client::TestClientBuilder< + sc_client::LocalCallExecutor, Backend, GenesisParameters, > { diff --git a/bin/node/testing/src/genesis.rs b/bin/node/testing/src/genesis.rs index dae5c2c4a4..feb9ed526f 100644 --- a/bin/node/testing/src/genesis.rs +++ b/bin/node/testing/src/genesis.rs @@ -17,13 +17,13 @@ //! Genesis Configuration. use crate::keyring::*; -use keyring::{Ed25519Keyring, Sr25519Keyring}; +use sp_keyring::{Ed25519Keyring, Sr25519Keyring}; use node_runtime::{ GenesisConfig, BalancesConfig, SessionConfig, StakingConfig, SystemConfig, GrandpaConfig, IndicesConfig, ContractsConfig, WASM_BINARY, }; use node_runtime::constants::currency::*; -use primitives::ChangesTrieConfiguration; +use sp_core::ChangesTrieConfiguration; use sp_runtime::Perbill; @@ -37,10 +37,10 @@ pub fn config(support_changes_trie: bool, code: Option<&[u8]>) -> GenesisConfig }) } else { None }, code: code.map(|x| x.to_vec()).unwrap_or_else(|| WASM_BINARY.to_vec()), }), - indices: Some(IndicesConfig { + pallet_indices: Some(IndicesConfig { ids: vec![alice(), bob(), charlie(), dave(), eve(), ferdie()], }), - balances: Some(BalancesConfig { + pallet_balances: Some(BalancesConfig { balances: vec![ (alice(), 111 * DOLLARS), (bob(), 100 * DOLLARS), @@ -51,7 +51,7 @@ pub fn config(support_changes_trie: bool, code: Option<&[u8]>) -> GenesisConfig ], vesting: vec![], }), - session: Some(SessionConfig { + pallet_session: Some(SessionConfig { keys: vec![ (alice(), to_session_keys( &Ed25519Keyring::Alice, @@ -67,12 +67,12 @@ pub fn config(support_changes_trie: bool, code: Option<&[u8]>) -> GenesisConfig )), ] }), - staking: Some(StakingConfig { + pallet_staking: Some(StakingConfig { current_era: 0, stakers: vec![ - (dave(), alice(), 111 * DOLLARS, staking::StakerStatus::Validator), - (eve(), bob(), 100 * DOLLARS, staking::StakerStatus::Validator), - (ferdie(), charlie(), 100 * DOLLARS, staking::StakerStatus::Validator) + (dave(), alice(), 111 * DOLLARS, pallet_staking::StakerStatus::Validator), + (eve(), bob(), 100 * DOLLARS, pallet_staking::StakerStatus::Validator), + (ferdie(), charlie(), 100 * DOLLARS, pallet_staking::StakerStatus::Validator) ], validator_count: 3, minimum_validator_count: 0, @@ -80,21 +80,21 @@ pub fn config(support_changes_trie: bool, code: Option<&[u8]>) -> GenesisConfig invulnerables: vec![alice(), bob(), charlie()], .. Default::default() }), - contracts: Some(ContractsConfig { + pallet_contracts: Some(ContractsConfig { current_schedule: Default::default(), gas_price: 1 * MILLICENTS, }), - babe: Some(Default::default()), - grandpa: Some(GrandpaConfig { + pallet_babe: Some(Default::default()), + pallet_grandpa: Some(GrandpaConfig { authorities: vec![], }), - im_online: Some(Default::default()), - authority_discovery: Some(Default::default()), - democracy: Some(Default::default()), - collective_Instance1: Some(Default::default()), - collective_Instance2: Some(Default::default()), - membership_Instance1: Some(Default::default()), - sudo: Some(Default::default()), - treasury: Some(Default::default()), + pallet_im_online: Some(Default::default()), + pallet_authority_discovery: Some(Default::default()), + pallet_democracy: Some(Default::default()), + pallet_collective_Instance1: Some(Default::default()), + pallet_collective_Instance2: Some(Default::default()), + pallet_membership_Instance1: Some(Default::default()), + pallet_sudo: Some(Default::default()), + pallet_treasury: Some(Default::default()), } } diff --git a/bin/node/testing/src/keyring.rs b/bin/node/testing/src/keyring.rs index 53dac68096..b3dd18b539 100644 --- a/bin/node/testing/src/keyring.rs +++ b/bin/node/testing/src/keyring.rs @@ -16,7 +16,7 @@ //! Test accounts. -use keyring::{AccountKeyring, Sr25519Keyring, Ed25519Keyring}; +use sp_keyring::{AccountKeyring, Sr25519Keyring, Ed25519Keyring}; use node_primitives::{AccountId, Balance, Index}; use node_runtime::{CheckedExtrinsic, UncheckedExtrinsic, SessionKeys, SignedExtra}; use sp_runtime::generic::Era; @@ -66,12 +66,12 @@ pub fn to_session_keys( /// Returns transaction extra. pub fn signed_extra(nonce: Index, extra_fee: Balance) -> SignedExtra { ( - system::CheckVersion::new(), - system::CheckGenesis::new(), - system::CheckEra::from(Era::mortal(256, 0)), - system::CheckNonce::from(nonce), - system::CheckWeight::new(), - transaction_payment::ChargeTransactionPayment::from(extra_fee), + frame_system::CheckVersion::new(), + frame_system::CheckGenesis::new(), + frame_system::CheckEra::from(Era::mortal(256, 0)), + frame_system::CheckNonce::from(nonce), + frame_system::CheckWeight::new(), + pallet_transaction_payment::ChargeTransactionPayment::from(extra_fee), Default::default(), ) } @@ -90,7 +90,7 @@ pub fn sign(xt: CheckedExtrinsic, version: u32, genesis_hash: [u8; 32]) -> Unche } }).into(); UncheckedExtrinsic { - signature: Some((indices::address::Address::Id(signed), signature, extra)), + signature: Some((pallet_indices::address::Address::Id(signed), signature, extra)), function: payload.0, } } diff --git a/bin/node/transaction-factory/Cargo.toml b/bin/node/transaction-factory/Cargo.toml index ab17c52b0d..c873877ac3 100644 --- a/bin/node/transaction-factory/Cargo.toml +++ b/bin/node/transaction-factory/Cargo.toml @@ -5,14 +5,14 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -block-builder-api = { package = "sp-block-builder", path = "../../../primitives/block-builder" } -cli = { package = "sc-cli", path = "../../../client/cli" } -client-api = { package = "sc-client-api", path = "../../../client/api" } -client = { package = "sc-client", path = "../../../client" } +sp-block-builder = { path = "../../../primitives/block-builder" } +sc-cli = { path = "../../../client/cli" } +sc-client-api = { path = "../../../client/api" } +sc-client = { path = "../../../client" } codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } -consensus_common = { package = "sp-consensus", path = "../../../primitives/consensus/common" } +sp-consensus = { path = "../../../primitives/consensus/common" } log = "0.4.8" -primitives = { package = "sp-core", path = "../../../primitives/core" } +sp-core = { path = "../../../primitives/core" } sp-api = { path = "../../../primitives/api" } sp-runtime = { path = "../../../primitives/runtime" } sc-service = { path = "../../../client/service" } diff --git a/bin/node/transaction-factory/src/complex_mode.rs b/bin/node/transaction-factory/src/complex_mode.rs index 2c82be3b4c..61be2ab987 100644 --- a/bin/node/transaction-factory/src/complex_mode.rs +++ b/bin/node/transaction-factory/src/complex_mode.rs @@ -41,10 +41,10 @@ use std::sync::Arc; use log::info; -use client::Client; -use block_builder_api::BlockBuilder; +use sc_client::Client; +use sp_block_builder::BlockBuilder; use sp_api::ConstructRuntimeApi; -use primitives::{Blake2Hasher, Hasher}; +use sp_core::{Blake2Hasher, Hasher}; use sp_runtime::generic::BlockId; use sp_runtime::traits::{Block as BlockT, ProvideRuntimeApi, One, Zero}; @@ -60,8 +60,8 @@ pub fn next( ) -> Option where Block: BlockT::Out>, - Exec: client::CallExecutor + Send + Sync + Clone, - Backend: client_api::backend::Backend + Send, + Exec: sc_client::CallExecutor + Send + Sync + Clone, + Backend: sc_client_api::backend::Backend + Send, Client: ProvideRuntimeApi, as ProvideRuntimeApi>::Api: BlockBuilder, diff --git a/bin/node/transaction-factory/src/lib.rs b/bin/node/transaction-factory/src/lib.rs index e9526e6259..effb9c6d80 100644 --- a/bin/node/transaction-factory/src/lib.rs +++ b/bin/node/transaction-factory/src/lib.rs @@ -26,16 +26,16 @@ use std::fmt::Display; use log::info; -use client::Client; -use block_builder_api::BlockBuilder; +use sc_client::Client; +use sp_block_builder::BlockBuilder; use sp_api::ConstructRuntimeApi; -use consensus_common::{ +use sp_consensus::{ BlockOrigin, BlockImportParams, InherentData, ForkChoiceStrategy, SelectChain }; -use consensus_common::block_import::BlockImport; +use sp_consensus::block_import::BlockImport; use codec::{Decode, Encode}; -use primitives::{Blake2Hasher, Hasher}; +use sp_core::{Blake2Hasher, Hasher}; use sp_runtime::generic::BlockId; use sp_runtime::traits::{ Block as BlockT, Header as HeaderT, ProvideRuntimeApi, SimpleArithmetic, @@ -98,25 +98,25 @@ pub fn factory( mut factory_state: RA, client: &Arc>, select_chain: &Sc, -) -> cli::error::Result<()> +) -> sc_cli::error::Result<()> where Block: BlockT::Out>, - Exec: client::CallExecutor + Send + Sync + Clone, - Backend: client_api::backend::Backend + Send, + Exec: sc_client::CallExecutor + Send + Sync + Clone, + Backend: sc_client_api::backend::Backend + Send, Client: ProvideRuntimeApi, as ProvideRuntimeApi>::Api: BlockBuilder, RtApi: ConstructRuntimeApi> + Send + Sync, Sc: SelectChain, RA: RuntimeAdapter, - <::Block as BlockT>::Hash: From, + <::Block as BlockT>::Hash: From, { if *factory_state.mode() != Mode::MasterToNToM && factory_state.rounds() > RA::Number::one() { let msg = "The factory can only be used with rounds set to 1 in this mode.".into(); - return Err(cli::error::Error::Input(msg)); + return Err(sc_cli::error::Error::Input(msg)); } - let best_header: Result<::Header, cli::error::Error> = + let best_header: Result<::Header, sc_cli::error::Error> = select_chain.best_chain().map_err(|e| format!("{:?}", e).into()); let mut best_hash = best_header?.hash(); let mut best_block_id = BlockId::::hash(best_hash); @@ -160,8 +160,8 @@ pub fn create_block( ) -> Block where Block: BlockT::Out>, - Exec: client::CallExecutor + Send + Sync + Clone, - Backend: client_api::backend::Backend + Send, + Exec: sc_client::CallExecutor + Send + Sync + Clone, + Backend: sc_client_api::backend::Backend + Send, Client: ProvideRuntimeApi, RtApi: ConstructRuntimeApi> + Send + Sync, as ProvideRuntimeApi>::Api: @@ -186,8 +186,8 @@ fn import_block( block: Block ) -> () where Block: BlockT::Out>, - Exec: client::CallExecutor + Send + Sync + Clone, - Backend: client_api::backend::Backend + Send, + Exec: sc_client::CallExecutor + Send + Sync + Clone, + Backend: sc_client_api::backend::Backend + Send, { let import = BlockImportParams { origin: BlockOrigin::File, diff --git a/bin/node/transaction-factory/src/simple_modes.rs b/bin/node/transaction-factory/src/simple_modes.rs index 756708b17f..c8ea77f5fe 100644 --- a/bin/node/transaction-factory/src/simple_modes.rs +++ b/bin/node/transaction-factory/src/simple_modes.rs @@ -36,10 +36,10 @@ use std::sync::Arc; use log::info; -use client::Client; -use block_builder_api::BlockBuilder; +use sc_client::Client; +use sp_block_builder::BlockBuilder; use sp_api::ConstructRuntimeApi; -use primitives::{Blake2Hasher, Hasher}; +use sp_core::{Blake2Hasher, Hasher}; use sp_runtime::traits::{Block as BlockT, ProvideRuntimeApi, One}; use sp_runtime::generic::BlockId; @@ -55,8 +55,8 @@ pub fn next( ) -> Option where Block: BlockT::Out>, - Exec: client::CallExecutor + Send + Sync + Clone, - Backend: client_api::backend::Backend + Send, + Exec: sc_client::CallExecutor + Send + Sync + Clone, + Backend: sc_client_api::backend::Backend + Send, Client: ProvideRuntimeApi, as ProvideRuntimeApi>::Api: BlockBuilder, diff --git a/bin/utils/chain-spec-builder/Cargo.toml b/bin/utils/chain-spec-builder/Cargo.toml index 4d317d3a54..1e2bd0bc36 100644 --- a/bin/utils/chain-spec-builder/Cargo.toml +++ b/bin/utils/chain-spec-builder/Cargo.toml @@ -7,8 +7,8 @@ build = "build.rs" [dependencies] ansi_term = "0.12.1" -keystore = { package = "sc-keystore", path = "../../../client/keystore" } +sc-keystore = { path = "../../../client/keystore" } node-cli = { path = "../../node/cli" } -primitives = { package = "sp-core", path = "../../../primitives/core" } +sp-core = { path = "../../../primitives/core" } rand = "0.7.2" structopt = "0.3.3" diff --git a/bin/utils/chain-spec-builder/src/main.rs b/bin/utils/chain-spec-builder/src/main.rs index b277987e1e..c370469d64 100644 --- a/bin/utils/chain-spec-builder/src/main.rs +++ b/bin/utils/chain-spec-builder/src/main.rs @@ -20,9 +20,9 @@ use ansi_term::Style; use rand::{Rng, distributions::Alphanumeric, rngs::OsRng}; use structopt::StructOpt; -use keystore::{Store as Keystore}; +use sc_keystore::{Store as Keystore}; use node_cli::chain_spec::{self, AccountId}; -use primitives::{sr25519, crypto::{Public, Ss58Codec}, traits::BareCryptoStore}; +use sp_core::{sr25519, crypto::{Public, Ss58Codec}, traits::BareCryptoStore}; /// A utility to easily create a testnet chain spec definition with a given set /// of authorities and endowed accounts and/or generate random accounts. @@ -153,22 +153,22 @@ fn generate_authority_keys_and_store( }; insert_key( - primitives::crypto::key_types::BABE, + sp_core::crypto::key_types::BABE, babe.as_slice(), )?; insert_key( - primitives::crypto::key_types::GRANDPA, + sp_core::crypto::key_types::GRANDPA, grandpa.as_slice(), )?; insert_key( - primitives::crypto::key_types::IM_ONLINE, + sp_core::crypto::key_types::IM_ONLINE, im_online.as_slice(), )?; insert_key( - primitives::crypto::key_types::AUTHORITY_DISCOVERY, + sp_core::crypto::key_types::AUTHORITY_DISCOVERY, authority_discovery.as_slice(), )?; } diff --git a/bin/utils/subkey/Cargo.toml b/bin/utils/subkey/Cargo.toml index a173c10130..3c998c9c9c 100644 --- a/bin/utils/subkey/Cargo.toml +++ b/bin/utils/subkey/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -primitives = { package = "sp-core", version = "*", path = "../../../primitives/core" } +sp-core = { version = "*", path = "../../../primitives/core" } node-runtime = { version = "*", path = "../../node/runtime" } node-primitives = { version = "*", path = "../../node/primitives" } sp-runtime = { version = "*", path = "../../../primitives/runtime" } @@ -17,9 +17,9 @@ substrate-bip39 = "0.3.1" hex = "0.4.0" hex-literal = "0.2.1" codec = { package = "parity-scale-codec", version = "1.0.0" } -system = { package = "frame-system", path = "../../../frame/system" } -balances = { package = "pallet-balances", path = "../../../frame/balances" } -transaction-payment = { package = "pallet-transaction-payment", path = "../../../frame/transaction-payment" } +frame-system = { path = "../../../frame/system" } +pallet-balances = { path = "../../../frame/balances" } +pallet-transaction-payment = { path = "../../../frame/transaction-payment" } [features] bench = [] diff --git a/bin/utils/subkey/src/main.rs b/bin/utils/subkey/src/main.rs index 24ecbb0686..05d22cd57b 100644 --- a/bin/utils/subkey/src/main.rs +++ b/bin/utils/subkey/src/main.rs @@ -24,7 +24,7 @@ use codec::{Decode, Encode}; use hex_literal::hex; use node_primitives::{Balance, Hash, Index, AccountId, Signature}; use node_runtime::{BalancesCall, Call, Runtime, SignedPayload, UncheckedExtrinsic, VERSION}; -use primitives::{ +use sp_core::{ crypto::{set_default_ss58_version, Ss58AddressFormat, Ss58Codec}, ed25519, sr25519, ecdsa, Pair, Public, H256, hexdisplay::HexDisplay, }; @@ -197,7 +197,7 @@ fn get_app<'a, 'b>() -> App<'a, 'b> { -s, --suri 'The secret key URI.' "), SubCommand::with_name("transfer") - .about("Author and sign a Node balances::Transfer transaction with a given (secret) key") + .about("Author and sign a Node pallet_balances::Transfer transaction with a given (secret) key") .args_from_usage(" -g, --genesis 'The genesis hash or a recognised \ chain identifier (dev, elm, alex).' @@ -484,12 +484,12 @@ fn create_extrinsic( { let extra = |i: Index, f: Balance| { ( - system::CheckVersion::::new(), - system::CheckGenesis::::new(), - system::CheckEra::::from(Era::Immortal), - system::CheckNonce::::from(i), - system::CheckWeight::::new(), - transaction_payment::ChargeTransactionPayment::::from(f), + frame_system::CheckVersion::::new(), + frame_system::CheckGenesis::::new(), + frame_system::CheckEra::::from(Era::Immortal), + frame_system::CheckNonce::::from(i), + frame_system::CheckWeight::::new(), + pallet_transaction_payment::ChargeTransactionPayment::::from(f), Default::default(), ) }; diff --git a/bin/utils/subkey/src/vanity.rs b/bin/utils/subkey/src/vanity.rs index 835001a0aa..33e8559b1f 100644 --- a/bin/utils/subkey/src/vanity.rs +++ b/bin/utils/subkey/src/vanity.rs @@ -15,7 +15,7 @@ // along with Substrate. If not, see . use super::{PublicOf, PublicT, Crypto}; -use primitives::Pair; +use sp_core::Pair; use rand::{rngs::OsRng, RngCore}; fn good_waypoint(done: u64) -> u64 { @@ -110,7 +110,7 @@ pub(super) fn generate_key(desired: &str) -> Result, &str> mod tests { use super::super::Ed25519; use super::*; - use primitives::{crypto::Ss58Codec, Pair}; + use sp_core::{crypto::Ss58Codec, Pair}; #[cfg(feature = "bench")] use test::Bencher; diff --git a/client/Cargo.toml b/client/Cargo.toml index c259c8db30..a30dfc00ff 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -5,36 +5,36 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -block-builder = { package = "sc-block-builder", path = "block-builder" } -client-api = { package = "sc-client-api", path = "api" } +sc-block-builder = { path = "block-builder" } +sc-client-api = { path = "api" } codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } -consensus = { package = "sp-consensus", path = "../primitives/consensus/common" } +sp-consensus = { path = "../primitives/consensus/common" } derive_more = { version = "0.99.2" } -executor = { package = "sc-executor", path = "executor" } -externalities = { package = "sp-externalities", path = "../primitives/externalities" } +sc-executor = { path = "executor" } +sp-externalities = { path = "../primitives/externalities" } fnv = { version = "1.0.6" } futures = { version = "0.3.1", features = ["compat"] } hash-db = { version = "0.15.2" } hex-literal = { version = "0.2.1" } -inherents = { package = "sp-inherents", path = "../primitives/inherents" } -keyring = { package = "sp-keyring", path = "../primitives/keyring" } +sp-inherents = { path = "../primitives/inherents" } +sp-keyring = { path = "../primitives/keyring" } kvdb = "0.1.1" log = { version = "0.4.8" } parking_lot = { version = "0.9.0" } -primitives = { package = "sp-core", path = "../primitives/core" } +sp-core = { path = "../primitives/core" } sp-std = { path = "../primitives/std" } -runtime-version = { package = "sp-version", path = "../primitives/version" } +sp-version = { path = "../primitives/version" } sp-api = { path = "../primitives/api" } sp-runtime = { path = "../primitives/runtime" } sp-blockchain = { path = "../primitives/blockchain" } -state-machine = { package = "sp-state-machine", path = "../primitives/state-machine" } +sp-state-machine = { path = "../primitives/state-machine" } sc-telemetry = { path = "telemetry" } -trie = { package = "sp-trie", path = "../primitives/trie" } +sp-trie = { path = "../primitives/trie" } tracing = "0.1.10" [dev-dependencies] env_logger = "0.7.0" tempfile = "3.1.0" -test-client = { package = "substrate-test-runtime-client", path = "../test-utils/runtime/client" } +substrate-test-runtime-client = { path = "../test-utils/runtime/client" } kvdb-memorydb = "0.1.2" -panic-handler = { package = "sp-panic-handler", path = "../primitives/panic-handler" } +sp-panic-handler = { path = "../primitives/panic-handler" } diff --git a/client/api/Cargo.toml b/client/api/Cargo.toml index f47294d571..12a6901c0e 100644 --- a/client/api/Cargo.toml +++ b/client/api/Cargo.toml @@ -6,29 +6,29 @@ edition = "2018" [dependencies] codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -consensus = { package = "sp-consensus", path = "../../primitives/consensus/common" } +sp-consensus = { path = "../../primitives/consensus/common" } derive_more = { version = "0.99.2" } -executor = { package = "sc-executor", path = "../executor" } -externalities = { package = "sp-externalities", path = "../../primitives/externalities" } +sc-executor = { path = "../executor" } +sp-externalities = { path = "../../primitives/externalities" } fnv = { version = "1.0.6" } futures = { version = "0.3.1" } hash-db = { version = "0.15.2", default-features = false } sp-blockchain = { path = "../../primitives/blockchain" } hex-literal = { version = "0.2.1" } -inherents = { package = "sp-inherents", path = "../../primitives/inherents", default-features = false } -keyring = { package = "sp-keyring", path = "../../primitives/keyring" } +sp-inherents = { path = "../../primitives/inherents", default-features = false } +sp-keyring = { path = "../../primitives/keyring" } kvdb = "0.1.1" log = { version = "0.4.8" } parking_lot = { version = "0.9.0" } -primitives = { package = "sp-core", path = "../../primitives/core", default-features = false } +sp-core = { path = "../../primitives/core", default-features = false } sp-std = { path = "../../primitives/std", default-features = false } -runtime-version = { package = "sp-version", path = "../../primitives/version", default-features = false } +sp-version = { path = "../../primitives/version", default-features = false } sp-api = { path = "../../primitives/api" } sp-runtime = { path = "../../primitives/runtime", default-features = false } -state-machine = { package = "sp-state-machine", path = "../../primitives/state-machine" } +sp-state-machine = { path = "../../primitives/state-machine" } sc-telemetry = { path = "../telemetry" } -trie = { package = "sp-trie", path = "../../primitives/trie" } -txpool-api = { package = "sp-transaction-pool", path = "../../primitives/transaction-pool" } +sp-trie = { path = "../../primitives/trie" } +sp-transaction-pool = { path = "../../primitives/transaction-pool" } [dev-dependencies] -test-primitives = { package = "sp-test-primitives", path = "../../primitives/test-primitives" } \ No newline at end of file +sp-test-primitives = { path = "../../primitives/test-primitives" } \ No newline at end of file diff --git a/client/api/src/backend.rs b/client/api/src/backend.rs index a71ffff74b..963bb6083b 100644 --- a/client/api/src/backend.rs +++ b/client/api/src/backend.rs @@ -18,12 +18,12 @@ use std::sync::Arc; use std::collections::HashMap; -use primitives::ChangesTrieConfiguration; -use primitives::offchain::OffchainStorage; +use sp_core::ChangesTrieConfiguration; +use sp_core::offchain::OffchainStorage; use sp_runtime::{generic::BlockId, Justification, Storage}; use sp_runtime::traits::{Block as BlockT, NumberFor}; -use state_machine::backend::Backend as StateBackend; -use state_machine::{ChangesTrieStorage as StateChangesTrieStorage, ChangesTrieTransaction}; +use sp_state_machine::backend::Backend as StateBackend; +use sp_state_machine::{ChangesTrieStorage as StateChangesTrieStorage, ChangesTrieTransaction}; use crate::{ blockchain::{ Backend as BlockchainBackend, well_known_cache_keys @@ -31,7 +31,7 @@ use crate::{ light::RemoteBlockchain, }; use sp_blockchain; -use consensus::BlockOrigin; +use sp_consensus::BlockOrigin; use hash_db::Hasher; use parking_lot::RwLock; diff --git a/client/api/src/call_executor.rs b/client/api/src/call_executor.rs index 8bd4bb9015..b54f6f5205 100644 --- a/client/api/src/call_executor.rs +++ b/client/api/src/call_executor.rs @@ -21,14 +21,14 @@ use codec::{Encode, Decode}; use sp_runtime::{ generic::BlockId, traits::Block as BlockT, traits::NumberFor, }; -use state_machine::{ +use sp_state_machine::{ self, OverlayedChanges, ExecutionManager, ExecutionStrategy, ChangesTrieTransaction, StorageProof, }; -use executor::{RuntimeVersion, NativeVersion}; -use externalities::Extensions; +use sc_executor::{RuntimeVersion, NativeVersion}; +use sp_externalities::Extensions; use hash_db::Hasher; -use primitives::{Blake2Hasher, NativeOrEncoded}; +use sp_core::{Blake2Hasher, NativeOrEncoded}; use sp_api::{ProofRecorder, InitializeBlock}; use sp_blockchain; @@ -41,7 +41,7 @@ where H::Out: Ord, { /// Externalities error type. - type Error: state_machine::Error; + type Error: sp_state_machine::Error; /// Execute a call to a contract on top of state in a block of given hash. /// @@ -92,7 +92,7 @@ where /// /// No changes are made. fn call_at_state< - S: state_machine::Backend, + S: sp_state_machine::Backend, F: FnOnce( Result, Self::Error>, Result, Self::Error>, @@ -119,7 +119,7 @@ where /// Execute a call to a contract on top of given state, gathering execution proof. /// /// No changes are made. - fn prove_at_state>( + fn prove_at_state>( &self, mut state: S, overlay: &mut OverlayedChanges, @@ -128,8 +128,8 @@ where ) -> Result<(Vec, StorageProof), sp_blockchain::Error> { let trie_state = state.as_trie_backend() .ok_or_else(|| - Box::new(state_machine::ExecutionError::UnableToGenerateProof) - as Box + Box::new(sp_state_machine::ExecutionError::UnableToGenerateProof) + as Box )?; self.prove_at_trie_state(trie_state, overlay, method, call_data) } @@ -137,9 +137,9 @@ where /// Execute a call to a contract on top of given trie state, gathering execution proof. /// /// No changes are made. - fn prove_at_trie_state>( + fn prove_at_trie_state>( &self, - trie_state: &state_machine::TrieBackend, + trie_state: &sp_state_machine::TrieBackend, overlay: &mut OverlayedChanges, method: &str, call_data: &[u8] diff --git a/client/api/src/client.rs b/client/api/src/client.rs index d053e11732..17da85b5de 100644 --- a/client/api/src/client.rs +++ b/client/api/src/client.rs @@ -18,12 +18,12 @@ use std::collections::HashMap; use futures::channel::mpsc; -use primitives::storage::StorageKey; +use sp_core::storage::StorageKey; use sp_runtime::{ traits::{Block as BlockT, NumberFor}, generic::BlockId }; -use consensus::BlockOrigin; +use sp_consensus::BlockOrigin; use crate::blockchain::Info; use crate::notifications::StorageEventStream; diff --git a/client/api/src/execution_extensions.rs b/client/api/src/execution_extensions.rs index 3e0cf44b84..e1be4d8ec0 100644 --- a/client/api/src/execution_extensions.rs +++ b/client/api/src/execution_extensions.rs @@ -22,7 +22,7 @@ use std::sync::{Weak, Arc}; use codec::Decode; -use primitives::{ +use sp_core::{ ExecutionContext, offchain::{self, OffchainExt, TransactionPoolExt}, traits::{BareCryptoStorePtr, KeystoreExt}, @@ -31,8 +31,8 @@ use sp_runtime::{ generic::BlockId, traits, }; -use state_machine::{ExecutionStrategy, ExecutionManager, DefaultHandler}; -use externalities::Extensions; +use sp_state_machine::{ExecutionStrategy, ExecutionManager, DefaultHandler}; +use sp_externalities::Extensions; use parking_lot::RwLock; /// Execution strategies settings. @@ -70,7 +70,7 @@ impl Default for ExecutionStrategies { pub struct ExecutionExtensions { strategies: ExecutionStrategies, keystore: Option, - transaction_pool: RwLock>>>, + transaction_pool: RwLock>>>, } impl Default for ExecutionExtensions { @@ -104,7 +104,7 @@ impl ExecutionExtensions { /// extension to be a `Weak` reference. /// That's also the reason why it's being registered lazily instead of /// during initialisation. - pub fn register_transaction_pool(&self, pool: Weak>) { + pub fn register_transaction_pool(&self, pool: Weak>) { *self.transaction_pool.write() = Some(pool); } @@ -165,7 +165,7 @@ impl ExecutionExtensions { /// A wrapper type to pass `BlockId` to the actual transaction pool. struct TransactionPoolAdapter { at: BlockId, - pool: Arc>, + pool: Arc>, } impl offchain::TransactionPool for TransactionPoolAdapter { diff --git a/client/api/src/lib.rs b/client/api/src/lib.rs index ab2f521df2..d51157d245 100644 --- a/client/api/src/lib.rs +++ b/client/api/src/lib.rs @@ -32,13 +32,13 @@ pub use client::*; pub use light::*; pub use notifications::*; -pub use state_machine::{StorageProof, ExecutionStrategy}; +pub use sp_state_machine::{StorageProof, ExecutionStrategy}; /// Utility methods for the client. pub mod utils { use sp_blockchain::{HeaderBackend, HeaderMetadata, Error}; - use primitives::H256; + use sp_core::H256; use sp_runtime::traits::{Block as BlockT}; use std::borrow::Borrow; diff --git a/client/api/src/light.rs b/client/api/src/light.rs index 2c52aeca83..073e62e687 100644 --- a/client/api/src/light.rs +++ b/client/api/src/light.rs @@ -26,8 +26,8 @@ use sp_runtime::{ }, generic::BlockId }; -use primitives::ChangesTrieConfiguration; -use state_machine::StorageProof; +use sp_core::ChangesTrieConfiguration; +use sp_state_machine::StorageProof; use sp_blockchain::{ HeaderMetadata, well_known_cache_keys, HeaderBackend, Cache as BlockchainCache, Error as ClientError, Result as ClientResult, @@ -304,7 +304,7 @@ pub mod tests { use futures::future::Ready; use parking_lot::Mutex; use sp_blockchain::Error as ClientError; - use test_primitives::{Block, Header, Extrinsic}; + use sp_test_primitives::{Block, Header, Extrinsic}; use super::*; pub type OkCallFetcher = Mutex>; diff --git a/client/api/src/notifications.rs b/client/api/src/notifications.rs index 1706f07b96..88b0b2d307 100644 --- a/client/api/src/notifications.rs +++ b/client/api/src/notifications.rs @@ -23,7 +23,7 @@ use std::{ use fnv::{FnvHashSet, FnvHashMap}; use futures::channel::mpsc; -use primitives::storage::{StorageKey, StorageData}; +use sp_core::storage::{StorageKey, StorageData}; use sp_runtime::traits::Block as BlockT; /// Storage change set diff --git a/client/authority-discovery/Cargo.toml b/client/authority-discovery/Cargo.toml index 72e4345166..8dcd29a2a7 100644 --- a/client/authority-discovery/Cargo.toml +++ b/client/authority-discovery/Cargo.toml @@ -9,18 +9,18 @@ build = "build.rs" prost-build = "0.5.0" [dependencies] -authority-discovery-primitives = { package = "sp-authority-discovery", path = "../../primitives/authority-discovery" } +sp-authority-discovery = { path = "../../primitives/authority-discovery" } bytes = "0.4.12" -client-api = { package = "sc-client-api", path = "../api" } +sc-client-api = { path = "../api" } codec = { package = "parity-scale-codec", default-features = false, version = "1.0.3" } derive_more = "0.99.2" futures = "0.3.1" futures-timer = "2.0" -keystore = { package = "sc-keystore", path = "../keystore" } +sc-keystore = { path = "../keystore" } libp2p = { version = "0.13.0", default-features = false, features = ["secp256k1", "libp2p-websocket"] } log = "0.4.8" -network = { package = "sc-network", path = "../network" } -primitives = { package = "sp-core", path = "../../primitives/core" } +sc-network = { path = "../network" } +sp-core = { path = "../../primitives/core" } sp-blockchain = { path = "../../primitives/blockchain" } prost = "0.5.0" serde_json = "1.0.41" @@ -29,6 +29,6 @@ sp-runtime = { path = "../../primitives/runtime" } [dev-dependencies] env_logger = "0.7.0" parking_lot = "0.9.0" -peerset = { package = "sc-peerset", path = "../peerset" } +sc-peerset = { path = "../peerset" } sp-test-primitives = { path = "../../primitives/test-primitives" } sp-api = { path = "../../primitives/api" } diff --git a/client/authority-discovery/src/lib.rs b/client/authority-discovery/src/lib.rs index a70683f682..6ab2d899a5 100644 --- a/client/authority-discovery/src/lib.rs +++ b/client/authority-discovery/src/lib.rs @@ -55,18 +55,18 @@ use futures::task::{Context, Poll}; use futures::{Future, FutureExt, Stream, StreamExt}; use futures_timer::Delay; -use authority_discovery_primitives::{ +use sp_authority_discovery::{ AuthorityDiscoveryApi, AuthorityId, AuthoritySignature, AuthorityPair }; -use client_api::blockchain::HeaderBackend; +use sc_client_api::blockchain::HeaderBackend; use codec::{Decode, Encode}; use error::{Error, Result}; use log::{debug, error, log_enabled, warn}; use libp2p::Multiaddr; -use network::specialization::NetworkSpecialization; -use network::{DhtEvent, ExHashT}; -use primitives::crypto::{key_types, Pair}; -use primitives::traits::BareCryptoStorePtr; +use sc_network::specialization::NetworkSpecialization; +use sc_network::{DhtEvent, ExHashT}; +use sp_core::crypto::{key_types, Pair}; +use sp_core::traits::BareCryptoStorePtr; use prost::Message; use sp_runtime::generic::BlockId; use sp_runtime::traits::{Block as BlockT, ProvideRuntimeApi}; @@ -501,7 +501,7 @@ pub trait NetworkProvider { fn get_value(&self, key: &libp2p::kad::record::Key); } -impl NetworkProvider for network::NetworkService +impl NetworkProvider for sc_network::NetworkService where B: BlockT + 'static, S: NetworkSpecialization, @@ -551,7 +551,7 @@ mod tests { use futures::channel::mpsc::channel; use futures::executor::block_on; use futures::future::poll_fn; - use primitives::{ExecutionContext, NativeOrEncoded, testing::KeyStore}; + use sp_core::{ExecutionContext, NativeOrEncoded, testing::KeyStore}; use sp_runtime::traits::Zero; use sp_runtime::traits::{ApiRef, Block as BlockT, NumberFor, ProvideRuntimeApi}; use std::sync::{Arc, Mutex}; @@ -642,8 +642,8 @@ mod tests { Ok(None) } - fn info(&self) -> client_api::blockchain::Info { - client_api::blockchain::Info { + fn info(&self) -> sc_client_api::blockchain::Info { + sc_client_api::blockchain::Info { best_hash: Default::default(), best_number: Zero::zero(), finalized_hash: Default::default(), @@ -655,8 +655,8 @@ mod tests { fn status( &self, _id: BlockId, - ) -> std::result::Result { - Ok(client_api::blockchain::BlockStatus::Unknown) + ) -> std::result::Result { + Ok(sc_client_api::blockchain::BlockStatus::Unknown) } fn number( @@ -865,7 +865,7 @@ mod tests { .encode(&mut signed_addresses) .unwrap(); - let dht_event = network::DhtEvent::ValueFound(vec![(authority_id_1, signed_addresses)]); + let dht_event = sc_network::DhtEvent::ValueFound(vec![(authority_id_1, signed_addresses)]); dht_event_tx.try_send(dht_event).unwrap(); // Make authority discovery handle the event. diff --git a/client/basic-authorship/Cargo.toml b/client/basic-authorship/Cargo.toml index f361ebe477..3b0aa79b97 100644 --- a/client/basic-authorship/Cargo.toml +++ b/client/basic-authorship/Cargo.toml @@ -9,18 +9,18 @@ log = "0.4.8" futures = "0.3.1" codec = { package = "parity-scale-codec", version = "1.0.0" } sp-runtime = { path = "../../primitives/runtime" } -primitives = { package = "sp-core", path = "../../primitives/core" } +sp-core = { path = "../../primitives/core" } sp-blockchain = { path = "../../primitives/blockchain" } -client = { package = "sc-client", path = "../" } -client-api = { package = "sc-client-api", path = "../api" } -consensus_common = { package = "sp-consensus", path = "../../primitives/consensus/common" } -inherents = { package = "sp-inherents", path = "../../primitives/inherents" } +sc-client = { path = "../" } +sc-client-api = { path = "../api" } +sp-consensus = { path = "../../primitives/consensus/common" } +sp-inherents = { path = "../../primitives/inherents" } sc-telemetry = { path = "../telemetry" } -txpool-api = { package = "sp-transaction-pool", path = "../../primitives/transaction-pool" } -block-builder = { package = "sc-block-builder", path = "../block-builder" } +sp-transaction-pool = { path = "../../primitives/transaction-pool" } +sc-block-builder = { path = "../block-builder" } tokio-executor = { version = "0.2.0-alpha.6", features = ["blocking"] } [dev-dependencies] -txpool = { package = "sc-transaction-pool", path = "../../client/transaction-pool" } -test-client = { package = "substrate-test-runtime-client", path = "../../test-utils/runtime/client" } +sc-transaction-pool = { path = "../../client/transaction-pool" } +substrate-test-runtime-client = { path = "../../test-utils/runtime/client" } parking_lot = "0.9" diff --git a/client/basic-authorship/src/basic_authorship.rs b/client/basic-authorship/src/basic_authorship.rs index 131a4e9f2d..55f358cdd7 100644 --- a/client/basic-authorship/src/basic_authorship.rs +++ b/client/basic-authorship/src/basic_authorship.rs @@ -19,23 +19,23 @@ // FIXME #1021 move this into sp-consensus use std::{time, sync::Arc}; -use client_api::CallExecutor; +use sc_client_api::CallExecutor; use sp_blockchain; -use client::Client as SubstrateClient; +use sc_client::Client as SubstrateClient; use codec::Decode; -use consensus_common::{evaluation}; -use inherents::InherentData; +use sp_consensus::{evaluation}; +use sp_inherents::InherentData; use log::{error, info, debug, trace}; -use primitives::{H256, Blake2Hasher, ExecutionContext}; +use sp_core::{H256, Blake2Hasher, ExecutionContext}; use sp_runtime::{ traits::{ Block as BlockT, Hash as HashT, Header as HeaderT, ProvideRuntimeApi, DigestFor, BlakeTwo256 }, generic::BlockId, }; -use txpool_api::{TransactionPool, InPoolTransaction}; +use sp_transaction_pool::{TransactionPool, InPoolTransaction}; use sc_telemetry::{telemetry, CONSENSUS_INFO}; -use block_builder::BlockBuilderApi; +use sc_block_builder::BlockBuilderApi; /// Proposer factory. pub struct ProposerFactory where A: TransactionPool { @@ -48,7 +48,7 @@ pub struct ProposerFactory where A: TransactionPool { impl ProposerFactory, A> where A: TransactionPool + 'static, - B: client_api::backend::Backend + Send + Sync + 'static, + B: sc_client_api::backend::Backend + Send + Sync + 'static, E: CallExecutor + Send + Sync + Clone + 'static, Block: BlockT, RA: Send + Sync + 'static, @@ -82,11 +82,11 @@ where } } -impl consensus_common::Environment for +impl sp_consensus::Environment for ProposerFactory, A> where A: TransactionPool + 'static, - B: client_api::backend::Backend + Send + Sync + 'static, + B: sc_client_api::backend::Backend + Send + Sync + 'static, E: CallExecutor + Send + Sync + Clone + 'static, Block: BlockT, RA: Send + Sync + 'static, @@ -120,11 +120,11 @@ struct ProposerInner { now: Box time::Instant + Send + Sync>, } -impl consensus_common::Proposer for +impl sp_consensus::Proposer for Proposer, A> where A: TransactionPool + 'static, - B: client_api::backend::Backend + Send + Sync + 'static, + B: sc_client_api::backend::Backend + Send + Sync + 'static, E: CallExecutor + Send + Sync + Clone + 'static, Block: BlockT, RA: Send + Sync + 'static, @@ -152,7 +152,7 @@ where impl ProposerInner, A> where A: TransactionPool + 'static, - B: client_api::backend::Backend + Send + Sync + 'static, + B: sc_client_api::backend::Backend + Send + Sync + 'static, E: CallExecutor + Send + Sync + Clone + 'static, Block: BlockT, RA: Send + Sync + 'static, @@ -201,7 +201,7 @@ impl ProposerInner, let pending_tx_data = pending_tx.data().clone(); let pending_tx_hash = pending_tx.hash().clone(); trace!("[{:?}] Pushing to the block.", pending_tx_hash); - match block_builder::BlockBuilder::push(&mut block_builder, pending_tx_data) { + match sc_block_builder::BlockBuilder::push(&mut block_builder, pending_tx_data) { Ok(()) => { debug!("[{:?}] Pushed to the block.", pending_tx_hash); } @@ -266,9 +266,9 @@ mod tests { use super::*; use parking_lot::Mutex; - use consensus_common::Proposer; - use test_client::{self, runtime::{Extrinsic, Transfer}, AccountKeyring}; - use txpool::{BasicPool, FullChainApi}; + use sp_consensus::Proposer; + use substrate_test_runtime_client::{self, runtime::{Extrinsic, Transfer}, AccountKeyring}; + use sc_transaction_pool::{BasicPool, FullChainApi}; fn extrinsic(nonce: u64) -> Extrinsic { Transfer { @@ -282,7 +282,7 @@ mod tests { #[test] fn should_cease_building_block_when_deadline_is_reached() { // given - let client = Arc::new(test_client::new()); + let client = Arc::new(substrate_test_runtime_client::new()); let txpool = Arc::new(BasicPool::new(Default::default(), FullChainApi::new(client.clone()))); futures::executor::block_on( diff --git a/client/basic-authorship/src/lib.rs b/client/basic-authorship/src/lib.rs index f27ce9cb52..65ac39f9ff 100644 --- a/client/basic-authorship/src/lib.rs +++ b/client/basic-authorship/src/lib.rs @@ -20,12 +20,12 @@ //! //! ``` //! # use sc_basic_authority::ProposerFactory; -//! # use consensus_common::{Environment, Proposer}; +//! # use sp_consensus::{Environment, Proposer}; //! # use sp_runtime::generic::BlockId; //! # use std::{sync::Arc, time::Duration}; -//! # use test_client::{self, runtime::{Extrinsic, Transfer}, AccountKeyring}; -//! # use txpool::{BasicPool, FullChainApi}; -//! # let client = Arc::new(test_client::new()); +//! # use substrate_test_runtime_client::{self, runtime::{Extrinsic, Transfer}, AccountKeyring}; +//! # use sc_transaction_pool::{BasicPool, FullChainApi}; +//! # let client = Arc::new(substrate_test_runtime_client::new()); //! # let txpool = Arc::new(BasicPool::new(Default::default(), FullChainApi::new(client.clone()))); //! // The first step is to create a `ProposerFactory`. //! let mut proposer_factory = ProposerFactory { diff --git a/client/block-builder/Cargo.toml b/client/block-builder/Cargo.toml index 3ed6d56ba8..421419c122 100644 --- a/client/block-builder/Cargo.toml +++ b/client/block-builder/Cargo.toml @@ -5,10 +5,10 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -state-machine = { package = "sp-state-machine", path = "../../primitives/state-machine" } +sp-state-machine = { path = "../../primitives/state-machine" } sp-runtime = { path = "../../primitives/runtime" } sp-blockchain = { path = "../../primitives/blockchain" } -primitives = { package = "sp-core", path = "../../primitives/core" } +sp-core = { path = "../../primitives/core" } codec = { package = "parity-scale-codec", version = "1.0.6", features = ["derive"] } -runtime_api = { package = "sp-block-builder", path = "../../primitives/block-builder" } +sp-block-builder = { path = "../../primitives/block-builder" } sp-api = { path = "../../primitives/api" } diff --git a/client/block-builder/src/lib.rs b/client/block-builder/src/lib.rs index c378bede38..ba5c5694c1 100644 --- a/client/block-builder/src/lib.rs +++ b/client/block-builder/src/lib.rs @@ -34,11 +34,11 @@ use sp_runtime::{ } }; use sp_blockchain::{ApplyExtrinsicFailed, Error}; -use primitives::ExecutionContext; -use state_machine::StorageProof; +use sp_core::ExecutionContext; +use sp_state_machine::StorageProof; use sp_api::{Core, ApiExt, ApiErrorFor}; -pub use runtime_api::BlockBuilder as BlockBuilderApi; +pub use sp_block_builder::BlockBuilder as BlockBuilderApi; /// Utility for building new (valid) blocks from a stream of extrinsics. diff --git a/client/chain-spec/Cargo.toml b/client/chain-spec/Cargo.toml index f1035e8d56..91dd4a2814 100644 --- a/client/chain-spec/Cargo.toml +++ b/client/chain-spec/Cargo.toml @@ -7,9 +7,9 @@ edition = "2018" [dependencies] sc-chain-spec-derive = { path = "./derive" } impl-trait-for-tuples = "0.1.3" -network = { package = "sc-network", path = "../network" } -primitives = { package = "sp-core", path = "../../primitives/core" } +sc-network = { path = "../network" } +sp-core = { path = "../../primitives/core" } serde = { version = "1.0.101", features = ["derive"] } serde_json = "1.0.41" sp-runtime = { path = "../../primitives/runtime" } -tel = { package = "sc-telemetry", path = "../telemetry" } +sc-telemetry = { path = "../telemetry" } diff --git a/client/chain-spec/src/chain_spec.rs b/client/chain-spec/src/chain_spec.rs index 3c4cc7a54a..c5d0fcf402 100644 --- a/client/chain-spec/src/chain_spec.rs +++ b/client/chain-spec/src/chain_spec.rs @@ -22,12 +22,12 @@ use std::fs::File; use std::path::PathBuf; use std::rc::Rc; use serde::{Serialize, Deserialize}; -use primitives::storage::{StorageKey, StorageData, ChildInfo, Storage, StorageChild}; +use sp_core::storage::{StorageKey, StorageData, ChildInfo, Storage, StorageChild}; use sp_runtime::BuildStorage; use serde_json as json; use crate::RuntimeGenesis; -use network::Multiaddr; -use tel::TelemetryEndpoints; +use sc_network::Multiaddr; +use sc_telemetry::TelemetryEndpoints; enum GenesisSource { File(PathBuf), @@ -77,7 +77,7 @@ impl<'a, G: RuntimeGenesis, E> BuildStorage for &'a ChainSpec { Genesis::Raw(RawGenesis { top: map, children: children_map }) => Ok(Storage { top: map.into_iter().map(|(k, v)| (k.0, v.0)).collect(), children: children_map.into_iter().map(|(sk, child_content)| { - let child_info = ChildInfo::resolve_child_info( + let child_info = ChildInfo::resolve_child_info( child_content.child_type, child_content.child_info.as_slice(), ).expect("chainspec contains correct content").to_owned(); @@ -292,7 +292,7 @@ impl ChainSpec { StorageKey(sk), ChildRawStorage { data: child.data.into_iter() - .map(|(k, v)| (StorageKey(k), StorageData(v))) + .map(|(k, v)| (StorageKey(k), StorageData(v))) .collect(), child_info: info.to_vec(), child_type: ci_type, diff --git a/client/cli/Cargo.toml b/client/cli/Cargo.toml index 7e65e59faa..3f76ff0b72 100644 --- a/client/cli/Cargo.toml +++ b/client/cli/Cargo.toml @@ -20,19 +20,19 @@ tokio = "0.2.1" futures = { version = "0.3.1", features = ["compat"] } fdlimit = "0.1.1" serde_json = "1.0.41" -panic-handler = { package = "sp-panic-handler", path = "../../primitives/panic-handler" } -client-api = { package = "sc-client-api", path = "../api" } +sp-panic-handler = { path = "../../primitives/panic-handler" } +sc-client-api = { path = "../api" } sp-blockchain = { path = "../../primitives/blockchain" } -network = { package = "sc-network", path = "../network" } +sc-network = { path = "../network" } sp-runtime = { path = "../../primitives/runtime" } -primitives = { package = "sp-core", path = "../../primitives/core" } -service = { package = "sc-service", path = "../service", default-features = false } -state-machine = { package = "sp-state-machine", path = "../../primitives/state-machine" } +sp-core = { path = "../../primitives/core" } +sc-service = { path = "../service", default-features = false } +sp-state-machine = { path = "../../primitives/state-machine" } sc-telemetry = { path = "../telemetry" } -keyring = { package = "sp-keyring", path = "../../primitives/keyring" } +sp-keyring = { path = "../../primitives/keyring" } names = "0.11.0" structopt = "0.3.3" -sc-tracing = { package = "sc-tracing", path = "../tracing" } +sc-tracing = { path = "../tracing" } [target.'cfg(not(target_os = "unknown"))'.dependencies] rpassword = "4.0.1" @@ -42,5 +42,5 @@ tempfile = "3.1.0" [features] wasmtime = [ - "service/wasmtime", + "sc-service/wasmtime", ] diff --git a/client/cli/src/error.rs b/client/cli/src/error.rs index bec3aa1ec7..80fbdd553b 100644 --- a/client/cli/src/error.rs +++ b/client/cli/src/error.rs @@ -27,7 +27,7 @@ pub enum Error { /// Cli error Cli(clap::Error), /// Service error - Service(service::Error), + Service(sc_service::Error), /// Client error Client(sp_blockchain::Error), /// Input error diff --git a/client/cli/src/informant.rs b/client/cli/src/informant.rs index 169fb2a660..be896e180d 100644 --- a/client/cli/src/informant.rs +++ b/client/cli/src/informant.rs @@ -16,11 +16,11 @@ //! Console informant. Prints sync progress and block events. Runs on the calling thread. -use client_api::BlockchainEvents; +use sc_client_api::BlockchainEvents; use futures::{StreamExt, TryStreamExt, FutureExt, future, compat::Stream01CompatExt}; use log::{info, warn}; use sp_runtime::traits::Header; -use service::AbstractService; +use sc_service::AbstractService; use std::time::Duration; mod display; diff --git a/client/cli/src/informant/display.rs b/client/cli/src/informant/display.rs index e91b41b227..1742becb86 100644 --- a/client/cli/src/informant/display.rs +++ b/client/cli/src/informant/display.rs @@ -15,11 +15,11 @@ // along with Substrate. If not, see . use ansi_term::Colour; -use client_api::ClientInfo; +use sc_client_api::ClientInfo; use log::info; -use network::SyncState; +use sc_network::SyncState; use sp_runtime::traits::{Block as BlockT, CheckedDiv, NumberFor, Zero, Saturating}; -use service::NetworkStatus; +use sc_service::NetworkStatus; use std::{convert::{TryFrom, TryInto}, fmt, time}; /// State of the informant display system. diff --git a/client/cli/src/lib.rs b/client/cli/src/lib.rs index 70beedc427..d4387c984f 100644 --- a/client/cli/src/lib.rs +++ b/client/cli/src/lib.rs @@ -26,20 +26,20 @@ mod execution_strategy; pub mod error; pub mod informant; -use client_api::execution_extensions::ExecutionStrategies; -use service::{ +use sc_client_api::execution_extensions::ExecutionStrategies; +use sc_service::{ config::{Configuration, DatabaseConfig}, ServiceBuilderCommand, RuntimeGenesis, ChainSpecExtension, PruningMode, ChainSpec, }; -use network::{ +use sc_network::{ self, multiaddr::Protocol, config::{ NetworkConfiguration, TransportConfig, NonReservedPeerMode, NodeKeyConfig, build_multiaddr }, }; -use primitives::H256; +use sp_core::H256; use std::{ io::{Write, Read, Seek, Cursor, stdin, stdout, ErrorKind}, iter, fs::{self, File}, @@ -200,12 +200,12 @@ where I: IntoIterator, ::Item: Into + Clone, { - let full_version = service::config::full_version_from_strs( + let full_version = sc_service::config::full_version_from_strs( version.version, version.commit ); - panic_handler::set(version.support_url, &full_version); + sp_panic_handler::set(version.support_url, &full_version); let matches = CoreParams::::clap() .name(version.executable_name) .author(version.author) @@ -333,7 +333,7 @@ impl<'a> ParseAndPrepareBuildSpec<'a> { if spec.boot_nodes().is_empty() && !self.params.disable_default_bootnode { let base_path = base_path(&self.params.shared_params, self.version); - let cfg = service::Configuration::::default_with_spec_and_base_path(spec.clone(), Some(base_path)); + let cfg = sc_service::Configuration::::default_with_spec_and_base_path(spec.clone(), Some(base_path)); let node_key = node_key_config( self.params.node_key_params, &Some(cfg.in_chain_config_dir(DEFAULT_NETWORK_CONFIG_PATH).expect("We provided a base_path")) @@ -348,7 +348,7 @@ impl<'a> ParseAndPrepareBuildSpec<'a> { spec.add_boot_node(addr) } - let json = service::chain_ops::build_spec(spec, raw_output)?; + let json = sc_service::chain_ops::build_spec(spec, raw_output)?; print!("{}", json); @@ -440,7 +440,7 @@ impl<'a> ParseAndPrepareImport<'a> { Exit: IntoExit { let mut config = create_config_with_db_path(spec_factory, &self.params.shared_params, self.version)?; - fill_import_params(&mut config, &self.params.import_params, service::Roles::FULL)?; + fill_import_params(&mut config, &self.params.import_params, sc_service::Roles::FULL)?; let file: Box = match self.params.input { Some(filename) => Box::new(File::open(filename)?), @@ -500,7 +500,7 @@ impl<'a> CheckBlock<'a> { Exit: IntoExit { let mut config = create_config_with_db_path(spec_factory, &self.params.shared_params, self.version)?; - fill_import_params(&mut config, &self.params.import_params, service::Roles::FULL)?; + fill_import_params(&mut config, &self.params.import_params, sc_service::Roles::FULL)?; let input = if self.params.input.starts_with("0x") { &self.params.input[2..] } else { &self.params.input[..] }; let block_id = match FromStr::from_str(input) { @@ -621,8 +621,8 @@ where params.node_key.as_ref().map(parse_ed25519_secret).unwrap_or_else(|| Ok(params.node_key_file .or_else(|| net_config_file(net_config_dir, NODE_KEY_ED25519_FILE)) - .map(network::config::Secret::File) - .unwrap_or(network::config::Secret::New))) + .map(sc_network::config::Secret::File) + .unwrap_or(sc_network::config::Secret::New))) .map(NodeKeyConfig::Ed25519) } } @@ -639,11 +639,11 @@ fn invalid_node_key(e: impl std::fmt::Display) -> error::Error { error::Error::Input(format!("Invalid node key: {}", e)) } -/// Parse a Ed25519 secret key from a hex string into a `network::Secret`. -fn parse_ed25519_secret(hex: &String) -> error::Result { +/// Parse a Ed25519 secret key from a hex string into a `sc_network::Secret`. +fn parse_ed25519_secret(hex: &String) -> error::Result { H256::from_str(&hex).map_err(invalid_node_key).and_then(|bytes| - network::config::identity::ed25519::SecretKey::from_bytes(bytes) - .map(network::config::Secret::Input) + sc_network::config::identity::ed25519::SecretKey::from_bytes(bytes) + .map(sc_network::config::Secret::Input) .map_err(invalid_node_key)) } @@ -728,7 +728,7 @@ fn input_keystore_password() -> Result { /// Fill the password field of the given config instance. fn fill_config_keystore_password( - config: &mut service::Configuration, + config: &mut sc_service::Configuration, cli: &RunCmd, ) -> Result<(), String> { config.keystore_password = if cli.password_interactive { @@ -753,7 +753,7 @@ fn fill_config_keystore_password( pub fn fill_import_params( config: &mut Configuration, cli: &ImportParams, - role: service::Roles, + role: sc_service::Roles, ) -> error::Result<()> where C: Default, @@ -774,10 +774,10 @@ pub fn fill_import_params( // unless `unsafe_pruning` is set. config.pruning = match &cli.pruning { Some(ref s) if s == "archive" => PruningMode::ArchiveAll, - None if role == service::Roles::AUTHORITY => PruningMode::ArchiveAll, + None if role == sc_service::Roles::AUTHORITY => PruningMode::ArchiveAll, None => PruningMode::default(), Some(s) => { - if role == service::Roles::AUTHORITY && !cli.unsafe_pruning { + if role == sc_service::Roles::AUTHORITY && !cli.unsafe_pruning { return Err(error::Error::Input( "Validators should run with state pruning disabled (i.e. archive). \ You can ignore this check with `--unsafe-pruning`.".to_string() @@ -821,11 +821,11 @@ where let is_authority = cli.validator || cli.sentry || is_dev || cli.keyring.account.is_some(); let role = if cli.light { - service::Roles::LIGHT + sc_service::Roles::LIGHT } else if is_authority { - service::Roles::AUTHORITY + sc_service::Roles::AUTHORITY } else { - service::Roles::FULL + sc_service::Roles::FULL }; fill_import_params(&mut config, &cli.import_params, role)?; @@ -856,7 +856,7 @@ where config.sentry_mode = cli.sentry; config.offchain_worker = match (cli.offchain_worker, role) { - (params::OffchainWorkerEnabled::WhenValidating, service::Roles::AUTHORITY) => true, + (params::OffchainWorkerEnabled::WhenValidating, sc_service::Roles::AUTHORITY) => true, (params::OffchainWorkerEnabled::Always, _) => true, (params::OffchainWorkerEnabled::Never, _) => false, (params::OffchainWorkerEnabled::WhenValidating, _) => false, @@ -939,7 +939,7 @@ where let spec = load_spec(cli, spec_factory)?; let base_path = base_path(cli, version); - let mut config = service::Configuration::default_with_spec_and_base_path( + let mut config = sc_service::Configuration::default_with_spec_and_base_path( spec.clone(), Some(base_path), ); @@ -1043,7 +1043,7 @@ fn kill_color(s: &str) -> String { #[cfg(test)] mod tests { use super::*; - use network::config::identity::ed25519; + use sc_network::config::identity::ed25519; #[test] fn tests_node_name_good() { @@ -1074,7 +1074,7 @@ mod tests { node_key_file: None }; node_key_config(params, &net_config_dir).and_then(|c| match c { - NodeKeyConfig::Ed25519(network::config::Secret::Input(ref ski)) + NodeKeyConfig::Ed25519(sc_network::config::Secret::Input(ref ski)) if node_key_type == NodeKeyType::Ed25519 && &sk[..] == ski.as_ref() => Ok(()), _ => Err(error::Error::Input("Unexpected node key config".into())) @@ -1099,7 +1099,7 @@ mod tests { node_key_file: Some(file.clone()) }; node_key_config(params, &net_config_dir).and_then(|c| match c { - NodeKeyConfig::Ed25519(network::config::Secret::File(ref f)) + NodeKeyConfig::Ed25519(sc_network::config::Secret::File(ref f)) if node_key_type == NodeKeyType::Ed25519 && f == &file => Ok(()), _ => Err(error::Error::Input("Unexpected node key config".into())) }) @@ -1131,7 +1131,7 @@ mod tests { let typ = params.node_key_type; node_key_config::(params, &None) .and_then(|c| match c { - NodeKeyConfig::Ed25519(network::config::Secret::New) + NodeKeyConfig::Ed25519(sc_network::config::Secret::New) if typ == NodeKeyType::Ed25519 => Ok(()), _ => Err(error::Error::Input("Unexpected node key config".into())) }) @@ -1144,7 +1144,7 @@ mod tests { let typ = params.node_key_type; node_key_config(params, &Some(net_config_dir.clone())) .and_then(move |c| match c { - NodeKeyConfig::Ed25519(network::config::Secret::File(ref f)) + NodeKeyConfig::Ed25519(sc_network::config::Secret::File(ref f)) if typ == NodeKeyType::Ed25519 && f == &dir.join(NODE_KEY_ED25519_FILE) => Ok(()), _ => Err(error::Error::Input("Unexpected node key config".into())) diff --git a/client/cli/src/params.rs b/client/cli/src/params.rs index d81abaa724..7121c53858 100644 --- a/client/cli/src/params.rs +++ b/client/cli/src/params.rs @@ -32,13 +32,13 @@ macro_rules! impl_get_log_filter { } } -impl Into for ExecutionStrategy { - fn into(self) -> client_api::ExecutionStrategy { +impl Into for ExecutionStrategy { + fn into(self) -> sc_client_api::ExecutionStrategy { match self { - ExecutionStrategy::Native => client_api::ExecutionStrategy::NativeWhenPossible, - ExecutionStrategy::Wasm => client_api::ExecutionStrategy::AlwaysWasm, - ExecutionStrategy::Both => client_api::ExecutionStrategy::Both, - ExecutionStrategy::NativeElseWasm => client_api::ExecutionStrategy::NativeElseWasm, + ExecutionStrategy::Native => sc_client_api::ExecutionStrategy::NativeWhenPossible, + ExecutionStrategy::Wasm => sc_client_api::ExecutionStrategy::AlwaysWasm, + ExecutionStrategy::Both => sc_client_api::ExecutionStrategy::Both, + ExecutionStrategy::NativeElseWasm => sc_client_api::ExecutionStrategy::NativeElseWasm, } } } @@ -66,12 +66,12 @@ impl WasmExecutionMethod { } } -impl Into for WasmExecutionMethod { - fn into(self) -> service::config::WasmExecutionMethod { +impl Into for WasmExecutionMethod { + fn into(self) -> sc_service::config::WasmExecutionMethod { match self { - WasmExecutionMethod::Interpreted => service::config::WasmExecutionMethod::Interpreted, + WasmExecutionMethod::Interpreted => sc_service::config::WasmExecutionMethod::Interpreted, #[cfg(feature = "wasmtime")] - WasmExecutionMethod::Compiled => service::config::WasmExecutionMethod::Compiled, + WasmExecutionMethod::Compiled => sc_service::config::WasmExecutionMethod::Compiled, #[cfg(not(feature = "wasmtime"))] WasmExecutionMethod::Compiled => panic!( "Substrate must be compiled with \"wasmtime\" feature for compiled Wasm execution" @@ -584,19 +584,19 @@ struct KeyringTestAccountCliValues { help: String, conflicts_with: Vec, name: String, - variant: keyring::Sr25519Keyring, + variant: sp_keyring::Sr25519Keyring, } lazy_static::lazy_static! { /// The Cli values for all test accounts. static ref TEST_ACCOUNTS_CLI_VALUES: Vec = { - keyring::Sr25519Keyring::iter().map(|a| { + sp_keyring::Sr25519Keyring::iter().map(|a| { let help = format!( "Shortcut for `--name {} --validator` with session keys for `{}` added to keystore.", a, a, ); - let conflicts_with = keyring::Sr25519Keyring::iter() + let conflicts_with = sp_keyring::Sr25519Keyring::iter() .filter(|b| a != *b) .map(|b| b.to_string().to_lowercase()) .chain(std::iter::once("name".to_string())) @@ -616,7 +616,7 @@ lazy_static::lazy_static! { /// Wrapper for exposing the keyring test accounts into the Cli. #[derive(Debug, Clone)] pub struct Keyring { - pub account: Option, + pub account: Option, } impl StructOpt for Keyring { diff --git a/client/consensus/aura/Cargo.toml b/client/consensus/aura/Cargo.toml index c35d72bd67..cf237b9f82 100644 --- a/client/consensus/aura/Cargo.toml +++ b/client/consensus/aura/Cargo.toml @@ -6,38 +6,38 @@ description = "Aura consensus algorithm for substrate" edition = "2018" [dependencies] -app-crypto = { package = "sp-application-crypto", path = "../../../primitives/application-crypto" } -aura_primitives = { package = "sp-consensus-aura", path = "../../../primitives/consensus/aura" } -block-builder-api = { package = "sp-block-builder", path = "../../../primitives/block-builder" } -client = { package = "sc-client", path = "../../" } -client-api = { package = "sc-client-api", path = "../../api" } +sp-application-crypto = { path = "../../../primitives/application-crypto" } +sp-consensus-aura = { path = "../../../primitives/consensus/aura" } +sp-block-builder = { path = "../../../primitives/block-builder" } +sc-client = { path = "../../" } +sc-client-api = { path = "../../api" } codec = { package = "parity-scale-codec", version = "1.0.0" } -consensus_common = { package = "sp-consensus", path = "../../../primitives/consensus/common" } +sp-consensus = { path = "../../../primitives/consensus/common" } derive_more = "0.99.2" futures = { version = "0.3.1", features = ["compat"] } futures01 = { package = "futures", version = "0.1" } futures-timer = "0.4.0" -inherents = { package = "sp-inherents", path = "../../../primitives/inherents" } -keystore = { package = "sc-keystore", path = "../../keystore" } +sp-inherents = { path = "../../../primitives/inherents" } +sc-keystore = { path = "../../keystore" } log = "0.4.8" parking_lot = "0.9.0" -primitives = { package = "sp-core", path = "../../../primitives/core" } +sp-core = { path = "../../../primitives/core" } sp-blockchain = { path = "../../../primitives/blockchain" } sp-io = { path = "../../../primitives/io" } -runtime_version = { package = "sp-version", path = "../../../primitives/version" } -slots = { package = "sc-consensus-slots", path = "../slots" } +sp-version = { path = "../../../primitives/version" } +sc-consensus-slots = { path = "../slots" } sp-api = { path = "../../../primitives/api" } sp-runtime = { path = "../../../primitives/runtime" } sp-timestamp = { path = "../../../primitives/timestamp" } sc-telemetry = { path = "../../telemetry" } [dev-dependencies] -keyring = { package = "sp-keyring", path = "../../../primitives/keyring" } +sp-keyring = { path = "../../../primitives/keyring" } sc-executor = { path = "../../executor" } sc-network = { path = "../../network" } sc-network-test = { path = "../../network/test" } -service = { package = "sc-service", path = "../../service" } -test-client = { package = "substrate-test-runtime-client", path = "../../../test-utils/runtime/client" } +sc-service = { path = "../../service" } +substrate-test-runtime-client = { path = "../../../test-utils/runtime/client" } tokio = "0.1.22" env_logger = "0.7.0" tempfile = "3.1.0" diff --git a/client/consensus/aura/src/digest.rs b/client/consensus/aura/src/digest.rs index e788586616..b1633fbfc8 100644 --- a/client/consensus/aura/src/digest.rs +++ b/client/consensus/aura/src/digest.rs @@ -19,8 +19,8 @@ //! This implements the digests for AuRa, to allow the private //! `CompatibleDigestItem` trait to appear in public interfaces. -use primitives::Pair; -use aura_primitives::AURA_ENGINE_ID; +use sp_core::Pair; +use sp_consensus_aura::AURA_ENGINE_ID; use sp_runtime::generic::{DigestItem, OpaqueDigestItemId}; use codec::{Encode, Codec}; use std::fmt::Debug; diff --git a/client/consensus/aura/src/lib.rs b/client/consensus/aura/src/lib.rs index c9be311b11..82ea2e764c 100644 --- a/client/consensus/aura/src/lib.rs +++ b/client/consensus/aura/src/lib.rs @@ -31,28 +31,28 @@ use std::{sync::Arc, time::Duration, thread, marker::PhantomData, hash::Hash, fmt::Debug, pin::Pin}; use codec::{Encode, Decode, Codec}; -use consensus_common::{ +use sp_consensus::{ self, BlockImport, Environment, Proposer, CanAuthorWith, ForkChoiceStrategy, BlockImportParams, BlockOrigin, Error as ConsensusError, SelectChain, SlotData, }; -use consensus_common::import_queue::{ +use sp_consensus::import_queue::{ Verifier, BasicQueue, BoxBlockImport, BoxJustificationImport, BoxFinalityProofImport, }; -use client_api::backend::AuxStore; -use client::{ +use sc_client_api::backend::AuxStore; +use sc_client::{ blockchain::ProvideCache, BlockOf }; use sp_blockchain::{ Result as CResult, well_known_cache_keys::{self, Id as CacheKeyId}, }; -use block_builder_api::BlockBuilder as BlockBuilderApi; +use sp_block_builder::BlockBuilder as BlockBuilderApi; use sp_runtime::{generic::{BlockId, OpaqueDigestItemId}, Justification}; use sp_runtime::traits::{Block as BlockT, Header, DigestItemFor, ProvideRuntimeApi, Zero, Member}; -use primitives::crypto::Pair; -use inherents::{InherentDataProviders, InherentData}; +use sp_core::crypto::Pair; +use sp_inherents::{InherentDataProviders, InherentData}; use futures::prelude::*; use parking_lot::Mutex; @@ -65,21 +65,21 @@ use sp_timestamp::{ use sc_telemetry::{telemetry, CONSENSUS_TRACE, CONSENSUS_DEBUG, CONSENSUS_INFO}; -use slots::{CheckedHeader, SlotWorker, SlotInfo, SlotCompatible}; -use slots::check_equivocation; +use sc_consensus_slots::{CheckedHeader, SlotWorker, SlotInfo, SlotCompatible}; +use sc_consensus_slots::check_equivocation; -use keystore::KeyStorePtr; +use sc_keystore::KeyStorePtr; use sp_api::ApiExt; -pub use aura_primitives::{ +pub use sp_consensus_aura::{ ConsensusLog, AuraApi, AURA_ENGINE_ID, inherents::{ InherentType as AuraInherent, AuraInherentData, INHERENT_IDENTIFIER, InherentDataProvider, }, }; -pub use consensus_common::SyncOracle; +pub use sp_consensus::SyncOracle; pub use digest::CompatibleDigestItem; mod digest; @@ -88,7 +88,7 @@ type AuthorityId

=

::Public; /// A slot duration. Create with `get_or_compute`. #[derive(Clone, Copy, Debug, Encode, Decode, Hash, PartialOrd, Ord, PartialEq, Eq)] -pub struct SlotDuration(slots::SlotDuration); +pub struct SlotDuration(sc_consensus_slots::SlotDuration); impl SlotDuration { /// Either fetch the slot duration from disk or compute it from the genesis @@ -100,7 +100,7 @@ impl SlotDuration { C: AuxStore + ProvideRuntimeApi, C::Api: AuraApi, { - slots::SlotDuration::get_or_compute(client, |a, b| a.slot_duration(b)).map(Self) + sc_consensus_slots::SlotDuration::get_or_compute(client, |a, b| a.slot_duration(b)).map(Self) } /// Get the slot duration in milliseconds. @@ -133,11 +133,11 @@ impl SlotCompatible for AuraSlotCompatible { fn extract_timestamp_and_slot( &self, data: &InherentData - ) -> Result<(TimestampInherent, AuraInherent, std::time::Duration), consensus_common::Error> { + ) -> Result<(TimestampInherent, AuraInherent, std::time::Duration), sp_consensus::Error> { data.timestamp_inherent_data() .and_then(|t| data.aura_inherent_data().map(|a| (t, a))) .map_err(Into::into) - .map_err(consensus_common::Error::InherentData) + .map_err(sp_consensus::Error::InherentData) .map(|(x, y)| (x, y, Default::default())) } } @@ -154,7 +154,7 @@ pub fn start_aura( force_authoring: bool, keystore: KeyStorePtr, can_author_with: CAW, -) -> Result, consensus_common::Error> where +) -> Result, sp_consensus::Error> where B: BlockT, C: ProvideRuntimeApi + BlockOf + ProvideCache + AuxStore + Send + Sync, C::Api: AuraApi>, @@ -167,7 +167,7 @@ pub fn start_aura( P::Signature: Hash + Member + Encode + Decode, H: Header, I: BlockImport + Send + Sync + 'static, - Error: ::std::error::Error + Send + From<::consensus_common::Error> + From + 'static, + Error: ::std::error::Error + Send + From<::sp_consensus::Error> + From + 'static, SO: SyncOracle + Send + Sync + Clone, CAW: CanAuthorWith + Send, { @@ -184,7 +184,7 @@ pub fn start_aura( &inherent_data_providers, slot_duration.0.slot_duration() )?; - Ok(slots::start_slot_worker::<_, _, _, _, _, AuraSlotCompatible, _>( + Ok(sc_consensus_slots::start_slot_worker::<_, _, _, _, _, AuraSlotCompatible, _>( slot_duration.0, select_chain, worker, @@ -205,7 +205,7 @@ struct AuraWorker { _key_type: PhantomData

, } -impl slots::SimpleSlotWorker for AuraWorker where +impl sc_consensus_slots::SimpleSlotWorker for AuraWorker where B: BlockT, C: ProvideRuntimeApi + BlockOf + ProvideCache + Sync, C::Api: AuraApi>, @@ -218,7 +218,7 @@ impl slots::SimpleSlotWorker for AuraWorker + From + 'static, + Error: ::std::error::Error + Send + From<::sp_consensus::Error> + From + 'static, { type EpochData = Vec>; type Claim = P; @@ -234,7 +234,7 @@ impl slots::SimpleSlotWorker for AuraWorker Result { + fn epoch_data(&self, header: &B::Header, _slot_number: u64) -> Result { authorities(self.client.as_ref(), &BlockId::Hash(header.hash())) } @@ -252,7 +252,7 @@ impl slots::SimpleSlotWorker for AuraWorker(&p, app_crypto::key_types::AURA).ok() + .key_pair_by_type::

(&p, sp_application_crypto::key_types::AURA).ok() }) } @@ -267,7 +267,7 @@ impl slots::SimpleSlotWorker for AuraWorker, Self::Claim, - ) -> consensus_common::BlockImportParams + Send> { + ) -> sp_consensus::BlockImportParams + Send> { Box::new(|header, header_hash, body, pair| { // sign the pre-sealed hash of the block and then // add it to a digest item. @@ -297,9 +297,9 @@ impl slots::SimpleSlotWorker for AuraWorker Result { + fn proposer(&mut self, block: &B::Header) -> Result { self.env.init(block).map_err(|e| { - consensus_common::Error::ClientImport(format!("{:?}", e)).into() + sp_consensus::Error::ClientImport(format!("{:?}", e)).into() }) } @@ -343,12 +343,12 @@ impl SlotWorker for AuraWorker + From + 'static, + Error: ::std::error::Error + Send + From<::sp_consensus::Error> + From + 'static, { - type OnSlot = Pin> + Send>>; + type OnSlot = Pin> + Send>>; fn on_slot(&mut self, chain_head: B::Header, slot_info: SlotInfo) -> Self::OnSlot { - >::on_slot(self, chain_head, slot_info) + >::on_slot(self, chain_head, slot_info) } } @@ -416,7 +416,7 @@ fn check_header( ) -> Result)>, Error> where DigestItemFor: CompatibleDigestItem

, P::Signature: Decode, - C: client_api::backend::AuxStore, + C: sc_client_api::backend::AuxStore, P::Public: Encode + Decode + PartialEq + Clone, T: Send + Sync + 'static, { @@ -471,7 +471,7 @@ fn check_header( pub struct AuraVerifier { client: Arc, phantom: PhantomData

, - inherent_data_providers: inherents::InherentDataProviders, + inherent_data_providers: sp_inherents::InherentDataProviders, transaction_pool: Option>, } @@ -531,7 +531,7 @@ impl AuraVerifier #[forbid(deprecated)] impl Verifier for AuraVerifier where - C: ProvideRuntimeApi + Send + Sync + client_api::backend::AuxStore + ProvideCache + BlockOf, + C: ProvideRuntimeApi + Send + Sync + sc_client_api::backend::AuxStore + ProvideCache + BlockOf, C::Api: BlockBuilderApi + AuraApi> + ApiExt, DigestItemFor: CompatibleDigestItem

; diff --git a/client/finality-grandpa/src/import.rs b/client/finality-grandpa/src/import.rs index e7cfa46d4a..2132d6f36d 100644 --- a/client/finality-grandpa/src/import.rs +++ b/client/finality-grandpa/src/import.rs @@ -17,25 +17,25 @@ use std::{sync::Arc, collections::HashMap}; use log::{debug, trace, info}; -use codec::Encode; +use parity_scale_codec::Encode; use futures::sync::mpsc; use parking_lot::RwLockWriteGuard; use sp_blockchain::{HeaderBackend, BlockStatus, well_known_cache_keys}; -use client_api::{backend::Backend, CallExecutor, utils::is_descendent_of}; -use client::Client; -use consensus_common::{ +use sc_client_api::{backend::Backend, CallExecutor, utils::is_descendent_of}; +use sc_client::Client; +use sp_consensus::{ BlockImport, Error as ConsensusError, BlockCheckParams, BlockImportParams, ImportResult, JustificationImport, SelectChain, }; -use fg_primitives::{GRANDPA_ENGINE_ID, ScheduledChange, ConsensusLog}; +use sp_finality_grandpa::{GRANDPA_ENGINE_ID, ScheduledChange, ConsensusLog}; use sp_runtime::Justification; use sp_runtime::generic::{BlockId, OpaqueDigestItemId}; use sp_runtime::traits::{ Block as BlockT, DigestFor, Header as HeaderT, NumberFor, Zero, }; -use primitives::{H256, Blake2Hasher}; +use sp_core::{H256, Blake2Hasher}; use crate::{Error, CommandOrError, NewAuthoritySet, VoterCommand}; use crate::authorities::{AuthoritySet, SharedAuthoritySet, DelayKind, PendingChange}; @@ -76,7 +76,7 @@ impl, RA, SC: Clone> Clone for impl, RA, SC> JustificationImport for GrandpaBlockImport where - NumberFor: grandpa::BlockNumberOps, + NumberFor: finality_grandpa::BlockNumberOps, B: Backend + 'static, E: CallExecutor + 'static + Clone + Send + Sync, DigestFor: Encode, @@ -204,7 +204,7 @@ fn find_forced_change(header: &B::Header) impl, RA, SC> GrandpaBlockImport where - NumberFor: grandpa::BlockNumberOps, + NumberFor: finality_grandpa::BlockNumberOps, B: Backend + 'static, E: CallExecutor + 'static + Clone + Send + Sync, DigestFor: Encode, @@ -381,7 +381,7 @@ where impl, RA, SC> BlockImport for GrandpaBlockImport where - NumberFor: grandpa::BlockNumberOps, + NumberFor: finality_grandpa::BlockNumberOps, B: Backend + 'static, E: CallExecutor + 'static + Clone + Send + Sync, DigestFor: Encode, @@ -532,7 +532,7 @@ impl, RA, SC> impl, RA, SC> GrandpaBlockImport where - NumberFor: grandpa::BlockNumberOps, + NumberFor: finality_grandpa::BlockNumberOps, B: Backend + 'static, E: CallExecutor + 'static + Clone + Send + Sync, RA: Send + Sync, diff --git a/client/finality-grandpa/src/justification.rs b/client/finality-grandpa/src/justification.rs index 2851fa2132..d7650a39f8 100644 --- a/client/finality-grandpa/src/justification.rs +++ b/client/finality-grandpa/src/justification.rs @@ -16,16 +16,16 @@ use std::collections::{HashMap, HashSet}; -use client::Client; -use client_api::{CallExecutor, backend::Backend}; +use sc_client::Client; +use sc_client_api::{CallExecutor, backend::Backend}; use sp_blockchain::Error as ClientError; -use codec::{Encode, Decode}; -use grandpa::voter_set::VoterSet; -use grandpa::{Error as GrandpaError}; +use parity_scale_codec::{Encode, Decode}; +use finality_grandpa::voter_set::VoterSet; +use finality_grandpa::{Error as GrandpaError}; use sp_runtime::generic::BlockId; use sp_runtime::traits::{NumberFor, Block as BlockT, Header as HeaderT}; -use primitives::{H256, Blake2Hasher}; -use fg_primitives::AuthorityId; +use sp_core::{H256, Blake2Hasher}; +use sp_finality_grandpa::AuthorityId; use crate::{Commit, Error}; use crate::communication; @@ -98,7 +98,7 @@ impl> GrandpaJustification { set_id: u64, voters: &VoterSet, ) -> Result, ClientError> where - NumberFor: grandpa::BlockNumberOps, + NumberFor: finality_grandpa::BlockNumberOps, { let justification = GrandpaJustification::::decode(&mut &*encoded) @@ -115,13 +115,13 @@ impl> GrandpaJustification { /// Validate the commit and the votes' ancestry proofs. pub(crate) fn verify(&self, set_id: u64, voters: &VoterSet) -> Result<(), ClientError> where - NumberFor: grandpa::BlockNumberOps, + NumberFor: finality_grandpa::BlockNumberOps, { - use grandpa::Chain; + use finality_grandpa::Chain; let ancestry_chain = AncestryChain::::new(&self.votes_ancestries); - match grandpa::validate_commit( + match finality_grandpa::validate_commit( &self.commit, voters, &ancestry_chain, @@ -136,7 +136,7 @@ impl> GrandpaJustification { let mut visited_hashes = HashSet::new(); for signed in self.commit.precommits.iter() { if let Err(_) = communication::check_message_sig::( - &grandpa::Message::Precommit(signed.precommit.clone()), + &finality_grandpa::Message::Precommit(signed.precommit.clone()), &signed.id, &signed.signature, self.round, @@ -179,7 +179,7 @@ impl> GrandpaJustification { } } -/// A utility trait implementing `grandpa::Chain` using a given set of headers. +/// A utility trait implementing `finality_grandpa::Chain` using a given set of headers. /// This is useful when validating commits, using the given set of headers to /// verify a valid ancestry route to the target commit block. struct AncestryChain { @@ -198,8 +198,8 @@ impl AncestryChain { } } -impl grandpa::Chain> for AncestryChain where - NumberFor: grandpa::BlockNumberOps +impl finality_grandpa::Chain> for AncestryChain where + NumberFor: finality_grandpa::BlockNumberOps { fn ancestry(&self, base: Block::Hash, block: Block::Hash) -> Result, GrandpaError> { let mut route = Vec::new(); diff --git a/client/finality-grandpa/src/lib.rs b/client/finality-grandpa/src/lib.rs index 82c0400612..7d3b26a632 100644 --- a/client/finality-grandpa/src/lib.rs +++ b/client/finality-grandpa/src/lib.rs @@ -55,23 +55,23 @@ use futures::prelude::*; use log::{debug, error, info}; use futures::sync::mpsc; -use client_api::{BlockchainEvents, CallExecutor, backend::Backend, ExecutionStrategy}; +use sc_client_api::{BlockchainEvents, CallExecutor, backend::Backend, ExecutionStrategy}; use sp_blockchain::{HeaderBackend, Error as ClientError}; -use client::Client; -use codec::{Decode, Encode}; +use sc_client::Client; +use parity_scale_codec::{Decode, Encode}; use sp_runtime::generic::BlockId; use sp_runtime::traits::{NumberFor, Block as BlockT, DigestFor, Zero}; -use keystore::KeyStorePtr; -use inherents::InherentDataProviders; -use consensus_common::SelectChain; -use primitives::{H256, Blake2Hasher, Pair}; +use sc_keystore::KeyStorePtr; +use sp_inherents::InherentDataProviders; +use sp_consensus::SelectChain; +use sp_core::{H256, Blake2Hasher, Pair}; use sc_telemetry::{telemetry, CONSENSUS_INFO, CONSENSUS_DEBUG, CONSENSUS_WARN}; use serde_json; use sp_finality_tracker; -use grandpa::Error as GrandpaError; -use grandpa::{voter, BlockNumberOps, voter_set::VoterSet}; +use finality_grandpa::Error as GrandpaError; +use finality_grandpa::{voter, BlockNumberOps, voter_set::VoterSet}; use std::{fmt, io}; use std::sync::Arc; @@ -90,7 +90,7 @@ mod observer; mod until_imported; mod voting_rule; -pub use network_gossip::Network; +pub use sc_network_gossip::Network; pub use finality_proof::FinalityProofProvider; pub use justification::GrandpaJustification; pub use light_import::light_block_import; @@ -104,18 +104,18 @@ use environment::{Environment, VoterSetState}; use import::GrandpaBlockImport; use until_imported::UntilGlobalMessageBlocksImported; use communication::NetworkBridge; -use fg_primitives::{AuthorityList, AuthorityPair, AuthoritySignature, SetId}; +use sp_finality_grandpa::{AuthorityList, AuthorityPair, AuthoritySignature, SetId}; // Re-export these two because it's just so damn convenient. -pub use fg_primitives::{AuthorityId, ScheduledChange}; +pub use sp_finality_grandpa::{AuthorityId, ScheduledChange}; #[cfg(test)] mod tests; /// A GRANDPA message for a substrate chain. -pub type Message = grandpa::Message<::Hash, NumberFor>; +pub type Message = finality_grandpa::Message<::Hash, NumberFor>; /// A signed message. -pub type SignedMessage = grandpa::SignedMessage< +pub type SignedMessage = finality_grandpa::SignedMessage< ::Hash, NumberFor, AuthoritySignature, @@ -123,27 +123,27 @@ pub type SignedMessage = grandpa::SignedMessage< >; /// A primary propose message for this chain's block type. -pub type PrimaryPropose = grandpa::PrimaryPropose<::Hash, NumberFor>; +pub type PrimaryPropose = finality_grandpa::PrimaryPropose<::Hash, NumberFor>; /// A prevote message for this chain's block type. -pub type Prevote = grandpa::Prevote<::Hash, NumberFor>; +pub type Prevote = finality_grandpa::Prevote<::Hash, NumberFor>; /// A precommit message for this chain's block type. -pub type Precommit = grandpa::Precommit<::Hash, NumberFor>; +pub type Precommit = finality_grandpa::Precommit<::Hash, NumberFor>; /// A catch up message for this chain's block type. -pub type CatchUp = grandpa::CatchUp< +pub type CatchUp = finality_grandpa::CatchUp< ::Hash, NumberFor, AuthoritySignature, AuthorityId, >; /// A commit message for this chain's block type. -pub type Commit = grandpa::Commit< +pub type Commit = finality_grandpa::Commit< ::Hash, NumberFor, AuthoritySignature, AuthorityId, >; /// A compact commit message for this chain's block type. -pub type CompactCommit = grandpa::CompactCommit< +pub type CompactCommit = finality_grandpa::CompactCommit< ::Hash, NumberFor, AuthoritySignature, @@ -152,7 +152,7 @@ pub type CompactCommit = grandpa::CompactCommit< /// A global communication input stream for commits and catch up messages. Not /// exposed publicly, used internally to simplify types in the communication /// layer. -type CommunicationIn = grandpa::voter::CommunicationIn< +type CommunicationIn = finality_grandpa::voter::CommunicationIn< ::Hash, NumberFor, AuthoritySignature, @@ -162,7 +162,7 @@ type CommunicationIn = grandpa::voter::CommunicationIn< /// Global communication input stream for commits and catch up messages, with /// the hash type not being derived from the block, useful for forcing the hash /// to some type (e.g. `H256`) when the compiler can't do the inference. -type CommunicationInH = grandpa::voter::CommunicationIn< +type CommunicationInH = finality_grandpa::voter::CommunicationIn< H, NumberFor, AuthoritySignature, @@ -171,7 +171,7 @@ type CommunicationInH = grandpa::voter::CommunicationIn< /// A global communication sink for commits. Not exposed publicly, used /// internally to simplify types in the communication layer. -type CommunicationOut = grandpa::voter::CommunicationOut< +type CommunicationOut = finality_grandpa::voter::CommunicationOut< ::Hash, NumberFor, AuthoritySignature, @@ -181,7 +181,7 @@ type CommunicationOut = grandpa::voter::CommunicationOut< /// Global communication sink for commits with the hash type not being derived /// from the block, useful for forcing the hash to some type (e.g. `H256`) when /// the compiler can't do the inference. -type CommunicationOutH = grandpa::voter::CommunicationOut< +type CommunicationOutH = finality_grandpa::voter::CommunicationOut< H, NumberFor, AuthoritySignature, @@ -207,7 +207,7 @@ pub struct Config { /// Some local identifier of the voter. pub name: Option, /// The keystore that manages the keys of this node. - pub keystore: Option, + pub keystore: Option, } impl Config { @@ -273,13 +273,13 @@ pub(crate) trait BlockSyncRequester { /// If the given vector of peers is empty then the underlying implementation /// should make a best effort to fetch the block from any peers it is /// connected to (NOTE: this assumption will change in the future #3629). - fn set_sync_fork_request(&self, peers: Vec, hash: Block::Hash, number: NumberFor); + fn set_sync_fork_request(&self, peers: Vec, hash: Block::Hash, number: NumberFor); } impl BlockSyncRequester for NetworkBridge where Block: BlockT, { - fn set_sync_fork_request(&self, peers: Vec, hash: Block::Hash, number: NumberFor) { + fn set_sync_fork_request(&self, peers: Vec, hash: Block::Hash, number: NumberFor) { NetworkBridge::set_sync_fork_request(self, peers, hash, number) } } @@ -332,8 +332,8 @@ impl From for CommandOrError { } } -impl From for CommandOrError { - fn from(e: grandpa::Error) -> Self { +impl From for CommandOrError { + fn from(e: finality_grandpa::Error) -> Self { CommandOrError::Error(Error::from(e)) } } @@ -496,7 +496,7 @@ fn global_communication, B, E, RA>( fn register_finality_tracker_inherent_data_provider, RA>( client: Arc>, inherent_data_providers: &InherentDataProviders, -) -> Result<(), consensus_common::Error> where +) -> Result<(), sp_consensus::Error> where B: Backend + 'static, E: CallExecutor + Send + Sync + 'static, RA: Send + Sync + 'static, @@ -514,7 +514,7 @@ fn register_finality_tracker_inherent_data_provider, RA, N>( client: Arc>, inherent_data_providers: &InherentDataProviders, network: N, -) -> Result<(), consensus_common::Error> where +) -> Result<(), sp_consensus::Error> where B: Backend + 'static, E: CallExecutor + Send + Sync + 'static, RA: Send + Sync + 'static, diff --git a/client/finality-grandpa/src/light_import.rs b/client/finality-grandpa/src/light_import.rs index 344c6110cc..8907ac8226 100644 --- a/client/finality-grandpa/src/light_import.rs +++ b/client/finality-grandpa/src/light_import.rs @@ -18,21 +18,21 @@ use std::collections::HashMap; use std::sync::Arc; use log::{info, trace, warn}; use parking_lot::RwLock; -use client::Client; -use client_api::{CallExecutor, backend::{AuxStore, Backend, Finalizer}}; +use sc_client::Client; +use sc_client_api::{CallExecutor, backend::{AuxStore, Backend, Finalizer}}; use sp_blockchain::{HeaderBackend, Error as ClientError, well_known_cache_keys}; -use codec::{Encode, Decode}; -use consensus_common::{ +use parity_scale_codec::{Encode, Decode}; +use sp_consensus::{ import_queue::Verifier, BlockOrigin, BlockImport, FinalityProofImport, BlockImportParams, ImportResult, ImportedAux, BlockCheckParams, Error as ConsensusError, }; -use network::config::{BoxFinalityProofRequestBuilder, FinalityProofRequestBuilder}; +use sc_network::config::{BoxFinalityProofRequestBuilder, FinalityProofRequestBuilder}; use sp_runtime::Justification; use sp_runtime::traits::{NumberFor, Block as BlockT, Header as HeaderT, DigestFor}; -use fg_primitives::{self, AuthorityList}; +use sp_finality_grandpa::{self, AuthorityList}; use sp_runtime::generic::BlockId; -use primitives::{H256, Blake2Hasher}; +use sp_core::{H256, Blake2Hasher}; use crate::GenesisAuthoritySetProvider; use crate::aux_schema::load_decode; @@ -120,7 +120,7 @@ impl, RA> GrandpaLightBlockImport, RA> BlockImport for GrandpaLightBlockImport where - NumberFor: grandpa::BlockNumberOps, + NumberFor: finality_grandpa::BlockNumberOps, B: Backend + 'static, E: CallExecutor + 'static + Clone + Send + Sync, DigestFor: Encode, @@ -148,7 +148,7 @@ impl, RA> BlockImport impl, RA> FinalityProofImport for GrandpaLightBlockImport where - NumberFor: grandpa::BlockNumberOps, + NumberFor: finality_grandpa::BlockNumberOps, B: Backend + 'static, E: CallExecutor + 'static + Clone + Send + Sync, DigestFor: Encode, @@ -194,7 +194,7 @@ impl LightAuthoritySet { /// Get a genesis set with given authorities. pub fn genesis(initial: AuthorityList) -> Self { LightAuthoritySet { - set_id: fg_primitives::SetId::default(), + set_id: sp_finality_grandpa::SetId::default(), authorities: initial, } } @@ -242,7 +242,7 @@ fn do_import_block, J>( + BlockImport + Clone, B: Backend + 'static, - NumberFor: grandpa::BlockNumberOps, + NumberFor: finality_grandpa::BlockNumberOps, DigestFor: Encode, J: ProvableJustification, { @@ -306,7 +306,7 @@ fn do_import_finality_proof, J>( + Clone, B: Backend + 'static, DigestFor: Encode, - NumberFor: grandpa::BlockNumberOps, + NumberFor: finality_grandpa::BlockNumberOps, J: ProvableJustification, { let authority_set_id = data.authority_set.set_id(); @@ -369,7 +369,7 @@ fn do_import_justification, J>( + Finalizer + Clone, B: Backend + 'static, - NumberFor: grandpa::BlockNumberOps, + NumberFor: finality_grandpa::BlockNumberOps, J: ProvableJustification, { // with justification, we have two cases @@ -440,7 +440,7 @@ fn do_finalize_block>( + Finalizer + Clone, B: Backend + 'static, - NumberFor: grandpa::BlockNumberOps, + NumberFor: finality_grandpa::BlockNumberOps, { // finalize the block client.finalize_block(BlockId::Hash(hash), Some(justification), true).map_err(|e| { @@ -540,11 +540,11 @@ fn on_post_finalization_error(error: ClientError, value_type: &str) -> Consensus #[cfg(test)] pub mod tests { use super::*; - use consensus_common::ForkChoiceStrategy; - use fg_primitives::AuthorityId; - use primitives::{H256, crypto::Public}; - use test_client::client::in_mem::Blockchain as InMemoryAuxStore; - use test_client::runtime::{Block, Header}; + use sp_consensus::ForkChoiceStrategy; + use sp_finality_grandpa::AuthorityId; + use sp_core::{H256, crypto::Public}; + use substrate_test_runtime_client::sc_client::in_mem::Blockchain as InMemoryAuxStore; + use substrate_test_runtime_client::runtime::{Block, Header}; use crate::tests::TestApi; use crate::finality_proof::tests::TestJustification; @@ -554,7 +554,7 @@ pub mod tests { impl, RA> Clone for NoJustificationsImport where - NumberFor: grandpa::BlockNumberOps, + NumberFor: finality_grandpa::BlockNumberOps, B: Backend + 'static, E: CallExecutor + 'static + Clone + Send + Sync, DigestFor: Encode, @@ -567,7 +567,7 @@ pub mod tests { impl, RA> BlockImport for NoJustificationsImport where - NumberFor: grandpa::BlockNumberOps, + NumberFor: finality_grandpa::BlockNumberOps, B: Backend + 'static, E: CallExecutor + 'static + Clone + Send + Sync, DigestFor: Encode, @@ -594,7 +594,7 @@ pub mod tests { impl, RA> FinalityProofImport for NoJustificationsImport where - NumberFor: grandpa::BlockNumberOps, + NumberFor: finality_grandpa::BlockNumberOps, B: Backend + 'static, E: CallExecutor + 'static + Clone + Send + Sync, DigestFor: Encode, @@ -637,7 +637,7 @@ pub mod tests { new_cache: HashMap>, justification: Option, ) -> ImportResult { - let (client, _backend) = test_client::new_light(); + let (client, _backend) = substrate_test_runtime_client::new_light(); let mut import_data = LightImportData { last_finalized: Default::default(), authority_set: LightAuthoritySet::genesis(vec![(AuthorityId::from_slice(&[1; 32]), 1)]), diff --git a/client/finality-grandpa/src/observer.rs b/client/finality-grandpa/src/observer.rs index 4681c12753..350d9d31c0 100644 --- a/client/finality-grandpa/src/observer.rs +++ b/client/finality-grandpa/src/observer.rs @@ -19,16 +19,16 @@ use std::sync::Arc; use futures::prelude::*; use futures::{future, sync::mpsc}; -use grandpa::{ +use finality_grandpa::{ BlockNumberOps, Error as GrandpaError, voter, voter_set::VoterSet }; use log::{debug, info, warn}; -use consensus_common::SelectChain; -use client_api::{CallExecutor, backend::Backend}; -use client::Client; +use sp_consensus::SelectChain; +use sc_client_api::{CallExecutor, backend::Backend}; +use sc_client::Client; use sp_runtime::traits::{NumberFor, Block as BlockT}; -use primitives::{H256, Blake2Hasher}; +use sp_core::{H256, Blake2Hasher}; use crate::{ global_communication, CommandOrError, CommunicationIn, Config, environment, @@ -37,11 +37,11 @@ use crate::{ use crate::authorities::SharedAuthoritySet; use crate::communication::NetworkBridge; use crate::consensus_changes::SharedConsensusChanges; -use fg_primitives::AuthorityId; +use sp_finality_grandpa::AuthorityId; struct ObserverChain<'a, Block: BlockT, B, E, RA>(&'a Client); -impl<'a, Block: BlockT, B, E, RA> grandpa::Chain> +impl<'a, Block: BlockT, B, E, RA> finality_grandpa::Chain> for ObserverChain<'a, Block, B, E, RA> where B: Backend, E: CallExecutor, @@ -84,7 +84,7 @@ fn grandpa_observer, RA, S, F>( let observer = commits.fold(last_finalized_number, move |last_finalized_number, global| { let (round, commit, callback) = match global { voter::CommunicationIn::Commit(round, commit, callback) => { - let commit = grandpa::Commit::from(commit); + let commit = finality_grandpa::Commit::from(commit); (round, commit, callback) }, voter::CommunicationIn::CatchUp(..) => { @@ -99,7 +99,7 @@ fn grandpa_observer, RA, S, F>( return future::ok(last_finalized_number); } - let validation_result = match grandpa::validate_commit( + let validation_result = match finality_grandpa::validate_commit( &commit, &voters, &ObserverChain(&*client), @@ -130,14 +130,14 @@ fn grandpa_observer, RA, S, F>( // and that implies that the next round has started. note_round(round + 1); - grandpa::process_commit_validation_result(validation_result, callback); + finality_grandpa::process_commit_validation_result(validation_result, callback); // proceed processing with new finalized block number future::ok(finalized_number) } else { debug!(target: "afg", "Received invalid commit: ({:?}, {:?})", round, commit); - grandpa::process_commit_validation_result(validation_result, callback); + finality_grandpa::process_commit_validation_result(validation_result, callback); // commit is invalid, continue processing commits with the current state future::ok(last_finalized_number) @@ -207,7 +207,7 @@ struct ObserverWork, E, Backend, RA> { client: Arc>, network: NetworkBridge, persistent_data: PersistentData, - keystore: Option, + keystore: Option, voter_commands_rx: mpsc::UnboundedReceiver>>, } @@ -223,7 +223,7 @@ where client: Arc>, network: NetworkBridge, persistent_data: PersistentData, - keystore: Option, + keystore: Option, voter_commands_rx: mpsc::UnboundedReceiver>>, ) -> Self { diff --git a/client/finality-grandpa/src/tests.rs b/client/finality-grandpa/src/tests.rs index 68512a9853..7b52aad6e3 100644 --- a/client/finality-grandpa/src/tests.rs +++ b/client/finality-grandpa/src/tests.rs @@ -20,26 +20,26 @@ use super::*; use environment::HasVoted; use sc_network_test::{Block, DummySpecialization, Hash, TestNetFactory, Peer, PeersClient}; use sc_network_test::{PassThroughVerifier}; -use network::config::{ProtocolConfig, Roles, BoxFinalityProofRequestBuilder}; +use sc_network::config::{ProtocolConfig, Roles, BoxFinalityProofRequestBuilder}; use parking_lot::Mutex; use futures_timer::Delay; use futures03::{StreamExt as _, TryStreamExt as _}; use tokio::runtime::current_thread; -use keyring::Ed25519Keyring; -use client::LongestChain; +use sp_keyring::Ed25519Keyring; +use sc_client::LongestChain; use sp_blockchain::Result; use sp_api::{Core, RuntimeVersion, ApiExt, StorageProof}; -use test_client::{self, runtime::BlockNumber}; -use consensus_common::{BlockOrigin, ForkChoiceStrategy, ImportedAux, BlockImportParams, ImportResult}; -use consensus_common::import_queue::{BoxBlockImport, BoxJustificationImport, BoxFinalityProofImport}; +use substrate_test_runtime_client::{self, runtime::BlockNumber}; +use sp_consensus::{BlockOrigin, ForkChoiceStrategy, ImportedAux, BlockImportParams, ImportResult}; +use sp_consensus::import_queue::{BoxBlockImport, BoxJustificationImport, BoxFinalityProofImport}; use std::collections::{HashMap, HashSet}; use std::result; -use codec::Decode; +use parity_scale_codec::Decode; use sp_runtime::traits::{ApiRef, ProvideRuntimeApi, Header as HeaderT}; use sp_runtime::generic::{BlockId, DigestItem}; -use primitives::{NativeOrEncoded, ExecutionContext, crypto::Public}; -use fg_primitives::{GRANDPA_ENGINE_ID, AuthorityList, GrandpaApi}; -use state_machine::{backend::InMemory, prove_read, read_proof_check}; +use sp_core::{NativeOrEncoded, ExecutionContext, crypto::Public}; +use sp_finality_grandpa::{GRANDPA_ENGINE_ID, AuthorityList, GrandpaApi}; +use sp_state_machine::{backend::InMemory, prove_read, read_proof_check}; use std::{pin::Pin, task}; use authorities::AuthoritySet; @@ -50,11 +50,11 @@ type PeerData = Mutex< Option< LinkHalf< - test_client::Backend, - test_client::Executor, + substrate_test_runtime_client::Backend, + substrate_test_runtime_client::Executor, Block, - test_client::runtime::RuntimeApi, - LongestChain + substrate_test_runtime_client::runtime::RuntimeApi, + LongestChain > > >; @@ -151,7 +151,7 @@ impl TestNetFactory for GrandpaTestNet { fn make_finality_proof_provider( &self, client: PeersClient - ) -> Option>> { + ) -> Option>> { match client { PeersClient::Full(_, ref backend) => { let authorities_provider = Arc::new(self.test_config.clone()); @@ -328,7 +328,7 @@ fn make_ids(keys: &[Ed25519Keyring]) -> AuthorityList { fn create_keystore(authority: Ed25519Keyring) -> (KeyStorePtr, tempfile::TempDir) { let keystore_path = tempfile::tempdir().expect("Creates keystore path"); - let keystore = keystore::Store::open(keystore_path.path(), None).expect("Creates keystore"); + let keystore = sc_keystore::Store::open(keystore_path.path(), None).expect("Creates keystore"); keystore.write().insert_ephemeral_from_seed::(&authority.to_seed()) .expect("Creates authority key"); @@ -441,7 +441,7 @@ fn run_to_completion( fn add_scheduled_change(block: &mut Block, change: ScheduledChange) { block.header.digest_mut().push(DigestItem::Consensus( GRANDPA_ENGINE_ID, - fg_primitives::ConsensusLog::ScheduledChange(change).encode(), + sp_finality_grandpa::ConsensusLog::ScheduledChange(change).encode(), )); } @@ -452,7 +452,7 @@ fn add_forced_change( ) { block.header.digest_mut().push(DigestItem::Consensus( GRANDPA_ENGINE_ID, - fg_primitives::ConsensusLog::ForcedChange(median_last_finalized, change).encode(), + sp_finality_grandpa::ConsensusLog::ForcedChange(median_last_finalized, change).encode(), )); } @@ -740,7 +740,7 @@ fn justification_is_emitted_when_consensus_data_changes() { let mut net = GrandpaTestNet::new(TestApi::new(make_ids(peers)), 3); // import block#1 WITH consensus data change - let new_authorities = vec![babe_primitives::AuthorityId::from_slice(&[42; 32])]; + let new_authorities = vec![sp_consensus_babe::AuthorityId::from_slice(&[42; 32])]; net.peer(0).push_authorities_change_block(new_authorities); net.block_until_sync(&mut runtime); let net = Arc::new(Mutex::new(net)); @@ -1241,7 +1241,7 @@ fn voter_persists_its_votes() { if state.compare_and_swap(0, 1, Ordering::SeqCst) == 0 { // the first message we receive should be a prevote from alice. let prevote = match signed.message { - grandpa::Message::Prevote(prevote) => prevote, + finality_grandpa::Message::Prevote(prevote) => prevote, _ => panic!("voter should prevote."), }; @@ -1276,19 +1276,19 @@ fn voter_persists_its_votes() { voter_tx.unbounded_send(()).unwrap(); // and we push our own prevote for block 30 - let prevote = grandpa::Prevote { + let prevote = finality_grandpa::Prevote { target_number: 30, target_hash: block_30_hash, }; - round_tx.lock().start_send(grandpa::Message::Prevote(prevote)).unwrap(); + round_tx.lock().start_send(finality_grandpa::Message::Prevote(prevote)).unwrap(); Ok(()) }).map_err(|_| panic!())) } else if state.compare_and_swap(1, 2, Ordering::SeqCst) == 1 { // the next message we receive should be our own prevote let prevote = match signed.message { - grandpa::Message::Prevote(prevote) => prevote, + finality_grandpa::Message::Prevote(prevote) => prevote, _ => panic!("We should receive our own prevote."), }; @@ -1305,7 +1305,7 @@ fn voter_persists_its_votes() { // we then receive a precommit from alice for block 15 // even though we casted a prevote for block 30 let precommit = match signed.message { - grandpa::Message::Precommit(precommit) => precommit, + finality_grandpa::Message::Precommit(precommit) => precommit, _ => panic!("voter should precommit."), }; @@ -1388,7 +1388,7 @@ fn finality_proof_is_fetched_by_light_client_when_consensus_data_changes() { // import block#1 WITH consensus data change. Light client ignores justification // && instead fetches finality proof for block #1 - net.peer(0).push_authorities_change_block(vec![babe_primitives::AuthorityId::from_slice(&[42; 32])]); + net.peer(0).push_authorities_change_block(vec![sp_consensus_babe::AuthorityId::from_slice(&[42; 32])]); let net = Arc::new(Mutex::new(net)); run_to_completion(&mut runtime, &threads_pool, 1, net.clone(), peers); net.lock().block_until_sync(&mut runtime); @@ -1453,7 +1453,7 @@ fn empty_finality_proof_is_returned_to_light_client_when_authority_set_is_differ // normally it will reach light client, but because of the forced change, it will not net.lock().peer(0).push_blocks(8, false); // best is #9 net.lock().peer(0).push_authorities_change_block( - vec![babe_primitives::AuthorityId::from_slice(&[42; 32])] + vec![sp_consensus_babe::AuthorityId::from_slice(&[42; 32])] ); // #10 net.lock().peer(0).push_blocks(1, false); // best is #11 net.lock().block_until_sync(&mut runtime); @@ -1589,7 +1589,7 @@ fn voter_catches_up_to_latest_round_when_behind() { #[test] fn grandpa_environment_respects_voting_rules() { - use grandpa::Chain; + use finality_grandpa::Chain; use sc_network_test::TestClient; let threads_pool = futures03::executor::ThreadPool::new().unwrap(); @@ -1741,22 +1741,22 @@ fn imports_justification_for_regular_blocks_on_import() { let round = 1; let set_id = 0; - let precommit = grandpa::Precommit { + let precommit = finality_grandpa::Precommit { target_hash: block_hash, target_number: *block.header.number(), }; - let msg = grandpa::Message::Precommit(precommit.clone()); + let msg = finality_grandpa::Message::Precommit(precommit.clone()); let encoded = communication::localized_payload(round, set_id, &msg); let signature = peers[0].sign(&encoded[..]).into(); - let precommit = grandpa::SignedPrecommit { + let precommit = finality_grandpa::SignedPrecommit { precommit, signature, id: peers[0].public().into(), }; - let commit = grandpa::Commit { + let commit = finality_grandpa::Commit { target_hash: block_hash, target_number: *block.header.number(), precommits: vec![precommit], diff --git a/client/finality-grandpa/src/until_imported.rs b/client/finality-grandpa/src/until_imported.rs index c843547a7b..23ab5c5daa 100644 --- a/client/finality-grandpa/src/until_imported.rs +++ b/client/finality-grandpa/src/until_imported.rs @@ -29,19 +29,19 @@ use super::{ }; use log::{debug, warn}; -use client_api::{BlockImportNotification, ImportNotifications}; +use sc_client_api::{BlockImportNotification, ImportNotifications}; use futures::prelude::*; use futures::stream::Fuse; use futures_timer::Delay; use futures03::{StreamExt as _, TryStreamExt as _}; -use grandpa::voter; +use finality_grandpa::voter; use parking_lot::Mutex; use sp_runtime::traits::{Block as BlockT, Header as HeaderT, NumberFor}; use std::collections::{HashMap, VecDeque}; use std::sync::{atomic::{AtomicUsize, Ordering}, Arc}; use std::time::{Duration, Instant}; -use fg_primitives::AuthorityId; +use sp_finality_grandpa::AuthorityId; const LOG_PENDING_INTERVAL: Duration = Duration::from_secs(15); @@ -475,13 +475,13 @@ mod tests { use super::*; use crate::{CatchUp, CompactCommit}; use tokio::runtime::current_thread::Runtime; - use test_client::runtime::{Block, Hash, Header}; - use consensus_common::BlockOrigin; - use client_api::BlockImportNotification; + use substrate_test_runtime_client::runtime::{Block, Hash, Header}; + use sp_consensus::BlockOrigin; + use sc_client_api::BlockImportNotification; use futures::future::Either; use futures_timer::Delay; use futures03::{channel::mpsc, future::FutureExt as _, future::TryFutureExt as _}; - use grandpa::Precommit; + use finality_grandpa::Precommit; #[derive(Clone)] struct TestChainState { @@ -543,7 +543,7 @@ mod tests { } impl BlockSyncRequesterT for TestBlockSyncRequester { - fn set_sync_fork_request(&self, _peers: Vec, hash: Hash, number: NumberFor) { + fn set_sync_fork_request(&self, _peers: Vec, hash: Hash, number: NumberFor) { self.requests.lock().push((hash, number)); } } @@ -741,10 +741,10 @@ mod tests { let h3 = make_header(7); let signed_prevote = |header: &Header| { - grandpa::SignedPrevote { + finality_grandpa::SignedPrevote { id: Default::default(), signature: Default::default(), - prevote: grandpa::Prevote { + prevote: finality_grandpa::Prevote { target_hash: header.hash(), target_number: *header.number(), }, @@ -752,10 +752,10 @@ mod tests { }; let signed_precommit = |header: &Header| { - grandpa::SignedPrecommit { + finality_grandpa::SignedPrecommit { id: Default::default(), signature: Default::default(), - precommit: grandpa::Precommit { + precommit: finality_grandpa::Precommit { target_hash: header.hash(), target_number: *header.number(), }, @@ -772,7 +772,7 @@ mod tests { signed_precommit(&h2), ]; - let unknown_catch_up = grandpa::CatchUp { + let unknown_catch_up = finality_grandpa::CatchUp { round_number: 1, prevotes, precommits, @@ -807,10 +807,10 @@ mod tests { let h3 = make_header(7); let signed_prevote = |header: &Header| { - grandpa::SignedPrevote { + finality_grandpa::SignedPrevote { id: Default::default(), signature: Default::default(), - prevote: grandpa::Prevote { + prevote: finality_grandpa::Prevote { target_hash: header.hash(), target_number: *header.number(), }, @@ -818,10 +818,10 @@ mod tests { }; let signed_precommit = |header: &Header| { - grandpa::SignedPrecommit { + finality_grandpa::SignedPrecommit { id: Default::default(), signature: Default::default(), - precommit: grandpa::Precommit { + precommit: finality_grandpa::Precommit { target_hash: header.hash(), target_number: *header.number(), }, @@ -838,7 +838,7 @@ mod tests { signed_precommit(&h2), ]; - let unknown_catch_up = grandpa::CatchUp { + let unknown_catch_up = finality_grandpa::CatchUp { round_number: 1, prevotes, precommits, diff --git a/client/finality-grandpa/src/voting_rule.rs b/client/finality-grandpa/src/voting_rule.rs index cfa28d03fe..424677433f 100644 --- a/client/finality-grandpa/src/voting_rule.rs +++ b/client/finality-grandpa/src/voting_rule.rs @@ -22,7 +22,7 @@ use std::sync::Arc; -use client_api::blockchain::HeaderBackend; +use sc_client_api::blockchain::HeaderBackend; use sp_runtime::generic::BlockId; use sp_runtime::traits::{Block as BlockT, Header, NumberFor, One, Zero}; diff --git a/client/keystore/Cargo.toml b/client/keystore/Cargo.toml index 32bd3d460b..93629956fe 100644 --- a/client/keystore/Cargo.toml +++ b/client/keystore/Cargo.toml @@ -6,8 +6,8 @@ edition = "2018" [dependencies] derive_more = "0.99.2" -primitives = { package = "sp-core", path = "../../primitives/core" } -app-crypto = { package = "sp-application-crypto", path = "../../primitives/application-crypto" } +sp-core = { path = "../../primitives/core" } +sp-application-crypto = { path = "../../primitives/application-crypto" } hex = "0.4.0" rand = "0.7.2" serde_json = "1.0.41" diff --git a/client/keystore/src/lib.rs b/client/keystore/src/lib.rs index 36cbcb5786..b51ab5a0a0 100644 --- a/client/keystore/src/lib.rs +++ b/client/keystore/src/lib.rs @@ -20,11 +20,11 @@ use std::{collections::HashMap, path::PathBuf, fs::{self, File}, io::{self, Write}, sync::Arc}; -use primitives::{ +use sp_core::{ crypto::{KeyTypeId, Pair as PairT, Public, IsWrappedBy, Protected}, traits::BareCryptoStore, }; -use app_crypto::{AppKey, AppPublic, AppPair, ed25519, sr25519}; +use sp_application_crypto::{AppKey, AppPublic, AppPair, ed25519, sr25519}; use parking_lot::RwLock; @@ -318,7 +318,7 @@ impl BareCryptoStore for Store { mod tests { use super::*; use tempfile::TempDir; - use primitives::{testing::{SR25519}, crypto::{Ss58Codec}}; + use sp_core::{testing::{SR25519}, crypto::{Ss58Codec}}; #[test] fn basic_store() { diff --git a/client/network-gossip/Cargo.toml b/client/network-gossip/Cargo.toml index b0fcd1fe72..cc521e65f1 100644 --- a/client/network-gossip/Cargo.toml +++ b/client/network-gossip/Cargo.toml @@ -13,6 +13,6 @@ futures = { version = "0.3.1", features = ["compat"] } futures-timer = "0.4.0" lru = "0.1.2" libp2p = { version = "0.13.0", default-features = false, features = ["libp2p-websocket"] } -network = { package = "sc-network", path = "../network" } +sc-network = { path = "../network" } parking_lot = "0.9.0" sp-runtime = { path = "../../primitives/runtime" } diff --git a/client/network-gossip/src/bridge.rs b/client/network-gossip/src/bridge.rs index 28f0e3f9b4..34d2fa6180 100644 --- a/client/network-gossip/src/bridge.rs +++ b/client/network-gossip/src/bridge.rs @@ -17,9 +17,9 @@ use crate::Network; use crate::state_machine::{ConsensusGossip, Validator, TopicNotification}; -use network::Context; -use network::message::generic::ConsensusMessage; -use network::{Event, ReputationChange}; +use sc_network::Context; +use sc_network::message::generic::ConsensusMessage; +use sc_network::{Event, ReputationChange}; use futures::{prelude::*, channel::mpsc, compat::Compat01As03, task::SpawnExt as _}; use libp2p::PeerId; @@ -215,7 +215,7 @@ impl GossipEngine { /// Send addressed message to the given peers. The message is not kept or multicast /// later on. - pub fn send_message(&self, who: Vec, data: Vec) { + pub fn send_message(&self, who: Vec, data: Vec) { let mut inner = self.inner.lock(); let inner = &mut *inner; @@ -244,7 +244,7 @@ impl GossipEngine { /// /// Note: this method isn't strictly related to gossiping and should eventually be moved /// somewhere else. - pub fn set_sync_fork_request(&self, peers: Vec, hash: B::Hash, number: NumberFor) { + pub fn set_sync_fork_request(&self, peers: Vec, hash: B::Hash, number: NumberFor) { self.inner.lock().context_ext.set_sync_fork_request(peers, hash, number); } } @@ -287,7 +287,7 @@ impl> Context for ContextOverService { trait ContextExt { fn announce(&self, block: B::Hash, associated_data: Vec); - fn set_sync_fork_request(&self, peers: Vec, hash: B::Hash, number: NumberFor); + fn set_sync_fork_request(&self, peers: Vec, hash: B::Hash, number: NumberFor); } impl> ContextExt for ContextOverService { @@ -295,7 +295,7 @@ impl> ContextExt for ContextOverService { Network::announce(&self.network, block, associated_data) } - fn set_sync_fork_request(&self, peers: Vec, hash: B::Hash, number: NumberFor) { + fn set_sync_fork_request(&self, peers: Vec, hash: B::Hash, number: NumberFor) { Network::set_sync_fork_request(&self.network, peers, hash, number) } } diff --git a/client/network-gossip/src/lib.rs b/client/network-gossip/src/lib.rs index 6decda05c5..5459123c41 100644 --- a/client/network-gossip/src/lib.rs +++ b/client/network-gossip/src/lib.rs @@ -59,7 +59,7 @@ pub use self::state_machine::{TopicNotification, MessageIntent}; pub use self::state_machine::{Validator, ValidatorContext, ValidationResult}; pub use self::state_machine::DiscardAll; -use network::{specialization::NetworkSpecialization, Event, ExHashT, NetworkService, PeerId, ReputationChange}; +use sc_network::{specialization::NetworkSpecialization, Event, ExHashT, NetworkService, PeerId, ReputationChange}; use sp_runtime::{traits::{Block as BlockT, NumberFor}, ConsensusEngineId}; use std::sync::Arc; @@ -134,7 +134,7 @@ impl, H: ExHashT> Network for Arc, hash: B::Hash, number: NumberFor) { + fn set_sync_fork_request(&self, peers: Vec, hash: B::Hash, number: NumberFor) { NetworkService::set_sync_fork_request(self, peers, hash, number) } } diff --git a/client/network-gossip/src/state_machine.rs b/client/network-gossip/src/state_machine.rs index 48854fc2a8..e2d1ebc8eb 100644 --- a/client/network-gossip/src/state_machine.rs +++ b/client/network-gossip/src/state_machine.rs @@ -24,9 +24,9 @@ use lru::LruCache; use libp2p::PeerId; use sp_runtime::traits::{Block as BlockT, Hash, HashFor}; use sp_runtime::ConsensusEngineId; -pub use network::message::generic::{Message, ConsensusMessage}; -use network::Context; -use network::config::Roles; +pub use sc_network::message::generic::{Message, ConsensusMessage}; +use sc_network::Context; +use sc_network::config::Roles; // FIXME: Add additional spam/DoS attack protection: https://github.com/paritytech/substrate/issues/1115 const KNOWN_MESSAGES_CACHE_SIZE: usize = 4096; @@ -34,7 +34,7 @@ const KNOWN_MESSAGES_CACHE_SIZE: usize = 4096; const REBROADCAST_INTERVAL: time::Duration = time::Duration::from_secs(30); mod rep { - use network::ReputationChange as Rep; + use sc_network::ReputationChange as Rep; /// Reputation change when a peer sends us a gossip message that we didn't know about. pub const GOSSIP_SUCCESS: Rep = Rep::new(1 << 4, "Successfull gossip"); /// Reputation change when a peer sends us a gossip message that we already knew about. diff --git a/client/network/Cargo.toml b/client/network/Cargo.toml index d7ac7c3b6d..ba20f06e5f 100644 --- a/client/network/Cargo.toml +++ b/client/network/Cargo.toml @@ -24,16 +24,16 @@ rustc-hex = "2.0.1" rand = "0.7.2" libp2p = { version = "0.13.0", default-features = false, features = ["libp2p-websocket"] } fork-tree = { path = "../../utils/fork-tree" } -consensus = { package = "sp-consensus", path = "../../primitives/consensus/common" } -client = { package = "sc-client", path = "../" } -client-api = { package = "sc-client-api", path = "../api" } +sp-consensus = { path = "../../primitives/consensus/common" } +sc-client = { path = "../" } +sc-client-api = { path = "../api" } sp-blockchain = { path = "../../primitives/blockchain" } sp-runtime = { path = "../../primitives/runtime" } sp-arithmetic = { path = "../../primitives/arithmetic" } -primitives = { package = "sp-core", path = "../../primitives/core" } -block-builder = { package = "sc-block-builder", path = "../block-builder" } +sp-core = { path = "../../primitives/core" } +sc-block-builder = { path = "../block-builder" } codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } -peerset = { package = "sc-peerset", path = "../peerset" } +sc-peerset = { path = "../peerset" } serde = { version = "1.0.101", features = ["derive"] } serde_json = "1.0.41" slog = { version = "2.5.2", features = ["nested-values"] } @@ -42,18 +42,18 @@ smallvec = "0.6.10" tokio-io = "0.1.12" tokio = { version = "0.1.22", optional = true } unsigned-varint = { version = "0.2.2", features = ["codec"] } -keyring = { package = "sp-keyring", path = "../../primitives/keyring", optional = true } -test_client = { package = "substrate-test-client", path = "../../test-utils/client", optional = true } -test-client = { package = "substrate-test-runtime-client", path = "../../test-utils/runtime/client", optional = true } +sp-keyring = { path = "../../primitives/keyring", optional = true } +substrate-test-client = { path = "../../test-utils/client", optional = true } +substrate-test-runtime-client = { path = "../../test-utils/runtime/client", optional = true } erased-serde = "0.3.9" void = "1.0.2" zeroize = "1.0.0" -babe-primitives = { package = "sp-consensus-babe", path = "../../primitives/consensus/babe" } +sp-consensus-babe = { path = "../../primitives/consensus/babe" } [dev-dependencies] sp-test-primitives = { path = "../../primitives/test-primitives" } env_logger = "0.7.0" -keyring = { package = "sp-keyring", path = "../../primitives/keyring" } +sp-keyring = { path = "../../primitives/keyring" } quickcheck = "0.9.0" rand = "0.7.2" tempfile = "3.1.0" @@ -61,4 +61,4 @@ tokio = "0.1.22" [features] default = [] -test-helpers = ["keyring", "test-client", "tokio"] +test-helpers = ["sp-keyring", "substrate-test-runtime-client", "tokio"] diff --git a/client/network/src/behaviour.rs b/client/network/src/behaviour.rs index ae00c71757..705fa2a27a 100644 --- a/client/network/src/behaviour.rs +++ b/client/network/src/behaviour.rs @@ -20,7 +20,6 @@ use crate::{ }; use crate::{ExHashT, specialization::NetworkSpecialization}; use crate::protocol::{CustomMessageOutcome, Protocol}; -use consensus::{BlockOrigin, import_queue::{IncomingBlock, Origin}}; use futures::prelude::*; use libp2p::NetworkBehaviour; use libp2p::core::{Multiaddr, PeerId, PublicKey}; @@ -28,6 +27,7 @@ use libp2p::kad::record; use libp2p::swarm::{NetworkBehaviourAction, NetworkBehaviourEventProcess}; use libp2p::core::{nodes::Substream, muxing::StreamMuxerBox}; use log::{debug, warn}; +use sp_consensus::{BlockOrigin, import_queue::{IncomingBlock, Origin}}; use sp_runtime::{traits::{Block as BlockT, NumberFor}, Justification}; use std::iter; use void; diff --git a/client/network/src/chain.rs b/client/network/src/chain.rs index 59fd15bbf1..8231f3bb53 100644 --- a/client/network/src/chain.rs +++ b/client/network/src/chain.rs @@ -16,15 +16,15 @@ //! Blockchain access trait -use client::Client as SubstrateClient; +use sc_client::Client as SubstrateClient; use sp_blockchain::Error; -use client_api::{ChangesProof, StorageProof, ClientInfo, CallExecutor}; -use consensus::{BlockImport, BlockStatus, Error as ConsensusError}; +use sc_client_api::{ChangesProof, StorageProof, ClientInfo, CallExecutor}; +use sp_consensus::{BlockImport, BlockStatus, Error as ConsensusError}; use sp_runtime::traits::{Block as BlockT, Header as HeaderT}; use sp_runtime::generic::{BlockId}; use sp_runtime::Justification; -use primitives::{H256, Blake2Hasher}; -use primitives::storage::{StorageKey, ChildInfo}; +use sp_core::{H256, Blake2Hasher}; +use sp_core::storage::{StorageKey, ChildInfo}; /// Local client abstraction for the network. pub trait Client: Send + Sync { @@ -93,7 +93,7 @@ impl FinalityProofProvider for () { } impl Client for SubstrateClient where - B: client_api::backend::Backend + Send + Sync + 'static, + B: sc_client_api::backend::Backend + Send + Sync + 'static, E: CallExecutor + Send + Sync + 'static, Self: BlockImport, Block: BlockT, diff --git a/client/network/src/config.rs b/client/network/src/config.rs index 9a55be7fe9..199b4abd9d 100644 --- a/client/network/src/config.rs +++ b/client/network/src/config.rs @@ -26,7 +26,7 @@ use crate::chain::{Client, FinalityProofProvider}; use crate::on_demand_layer::OnDemand; use crate::service::{ExHashT, TransactionPool}; use bitflags::bitflags; -use consensus::{block_validation::BlockAnnounceValidator, import_queue::ImportQueue}; +use sp_consensus::{block_validation::BlockAnnounceValidator, import_queue::ImportQueue}; use sp_runtime::traits::{Block as BlockT}; use libp2p::identity::{Keypair, ed25519}; use libp2p::wasm_ext; diff --git a/client/network/src/discovery.rs b/client/network/src/discovery.rs index 2e0a6fe244..0e05ff8b03 100644 --- a/client/network/src/discovery.rs +++ b/client/network/src/discovery.rs @@ -63,7 +63,7 @@ use libp2p::multiaddr::Protocol; use log::{debug, info, trace, warn}; use std::{cmp, collections::VecDeque, time::Duration}; use tokio_io::{AsyncRead, AsyncWrite}; -use primitives::hexdisplay::HexDisplay; +use sp_core::hexdisplay::HexDisplay; /// Implementation of `NetworkBehaviour` that discovers the nodes on the network. pub struct DiscoveryBehaviour { diff --git a/client/network/src/lib.rs b/client/network/src/lib.rs index ad98986276..a60087751f 100644 --- a/client/network/src/lib.rs +++ b/client/network/src/lib.rs @@ -195,7 +195,7 @@ pub use libp2p::multiaddr; pub use message::{generic as generic_message, RequestId, Status as StatusMessage}; pub use on_demand_layer::{OnDemand, RemoteResponse}; -pub use peerset::ReputationChange; +pub use sc_peerset::ReputationChange; // Used by the `construct_simple_protocol!` macro. #[doc(hidden)] diff --git a/client/network/src/on_demand_layer.rs b/client/network/src/on_demand_layer.rs index 91c8464b78..db75de5e34 100644 --- a/client/network/src/on_demand_layer.rs +++ b/client/network/src/on_demand_layer.rs @@ -23,7 +23,7 @@ use futures::{prelude::*, sync::mpsc, sync::oneshot}; use futures03::compat::{Compat01As03, Future01CompatExt as _}; use parking_lot::Mutex; use sp_blockchain::Error as ClientError; -use client_api::{Fetcher, FetchChecker, RemoteHeaderRequest, +use sc_client_api::{Fetcher, FetchChecker, RemoteHeaderRequest, RemoteCallRequest, RemoteReadRequest, RemoteChangesRequest, RemoteReadChildRequest, RemoteBodyRequest}; use sp_runtime::traits::{Block as BlockT, Header as HeaderT, NumberFor}; diff --git a/client/network/src/protocol.rs b/client/network/src/protocol.rs index d4283d588c..165cef0c68 100644 --- a/client/network/src/protocol.rs +++ b/client/network/src/protocol.rs @@ -24,8 +24,8 @@ use libp2p::{Multiaddr, PeerId}; use libp2p::core::{ConnectedPoint, nodes::Substream, muxing::StreamMuxerBox}; use libp2p::swarm::{ProtocolsHandler, IntoProtocolsHandler}; use libp2p::swarm::{NetworkBehaviour, NetworkBehaviourAction, PollParameters}; -use primitives::storage::{StorageKey, ChildInfo}; -use consensus::{ +use sp_core::storage::{StorageKey, ChildInfo}; +use sp_consensus::{ BlockOrigin, block_validation::BlockAnnounceValidator, import_queue::{BlockImportResult, BlockImportError, IncomingBlock, Origin} @@ -50,7 +50,7 @@ use std::fmt::Write; use std::{cmp, num::NonZeroUsize, time}; use log::{log, Level, trace, debug, warn, error}; use crate::chain::{Client, FinalityProofProvider}; -use client_api::{FetchChecker, ChangesProof, StorageProof}; +use sc_client_api::{FetchChecker, ChangesProof, StorageProof}; use crate::error; use util::LruHashSet; @@ -89,7 +89,7 @@ const MAX_CONSENSUS_MESSAGES: usize = 256; const LIGHT_MAXIMAL_BLOCKS_DIFFERENCE: u64 = 8192; mod rep { - use peerset::ReputationChange as Rep; + use sc_peerset::ReputationChange as Rep; /// Reputation change when a peer is "clogged", meaning that it's not fast enough to process our /// messages. pub const CLOGGED_PEER: Rep = Rep::new(-(1 << 12), "Clogged message queue"); @@ -140,7 +140,7 @@ pub struct Protocol, H: ExHashT> { // Connected peers pending Status message. handshaking_peers: HashMap, /// Used to report reputation changes. - peerset_handle: peerset::PeersetHandle, + peerset_handle: sc_peerset::PeersetHandle, transaction_pool: Arc>, /// When asked for a proof of finality, we use this struct to build one. finality_proof_provider: Option>>, @@ -195,11 +195,11 @@ pub struct PeerInfo { struct LightDispatchIn<'a> { behaviour: &'a mut LegacyProto>, - peerset: peerset::PeersetHandle, + peerset: sc_peerset::PeersetHandle, } impl<'a, B: BlockT> LightDispatchNetwork for LightDispatchIn<'a> { - fn report_peer(&mut self, who: &PeerId, reputation: peerset::ReputationChange) { + fn report_peer(&mut self, who: &PeerId, reputation: sc_peerset::ReputationChange) { self.peerset.report_peer(who.clone(), reputation) } @@ -323,7 +323,7 @@ impl<'a, B: BlockT> LightDispatchNetwork for LightDispatchIn<'a> { pub trait Context { /// Adjusts the reputation of the peer. Use this to point out that a peer has been malign or /// irresponsible or appeared lazy. - fn report_peer(&mut self, who: PeerId, reputation: peerset::ReputationChange); + fn report_peer(&mut self, who: PeerId, reputation: sc_peerset::ReputationChange); /// Force disconnecting from a peer. Use this when a peer misbehaved. fn disconnect_peer(&mut self, who: PeerId); @@ -339,21 +339,21 @@ pub trait Context { struct ProtocolContext<'a, B: 'a + BlockT, H: 'a + ExHashT> { behaviour: &'a mut LegacyProto>, context_data: &'a mut ContextData, - peerset_handle: &'a peerset::PeersetHandle, + peerset_handle: &'a sc_peerset::PeersetHandle, } impl<'a, B: BlockT + 'a, H: 'a + ExHashT> ProtocolContext<'a, B, H> { fn new( context_data: &'a mut ContextData, behaviour: &'a mut LegacyProto>, - peerset_handle: &'a peerset::PeersetHandle, + peerset_handle: &'a sc_peerset::PeersetHandle, ) -> Self { ProtocolContext { context_data, peerset_handle, behaviour } } } impl<'a, B: BlockT + 'a, H: ExHashT + 'a> Context for ProtocolContext<'a, B, H> { - fn report_peer(&mut self, who: PeerId, reputation: peerset::ReputationChange) { + fn report_peer(&mut self, who: PeerId, reputation: sc_peerset::ReputationChange) { self.peerset_handle.report_peer(who, reputation) } @@ -437,9 +437,9 @@ impl, H: ExHashT> Protocol { finality_proof_provider: Option>>, finality_proof_request_builder: Option>, protocol_id: ProtocolId, - peerset_config: peerset::PeersetConfig, + peerset_config: sc_peerset::PeersetConfig, block_announce_validator: Box + Send> - ) -> error::Result<(Protocol, peerset::PeersetHandle)> { + ) -> error::Result<(Protocol, sc_peerset::PeersetHandle)> { let info = chain.info(); let sync = ChainSync::new( config.roles, @@ -459,7 +459,7 @@ impl, H: ExHashT> Protocol { imp_p }; - let (peerset, peerset_handle) = peerset::Peerset::from_config(peerset_config); + let (peerset, peerset_handle) = sc_peerset::Peerset::from_config(peerset_config); let versions = &((MIN_VERSION as u8)..=(CURRENT_VERSION as u8)).collect::>(); let behaviour = LegacyProto::new(protocol_id, versions, peerset); @@ -853,7 +853,7 @@ impl, H: ExHashT> Protocol { } /// Adjusts the reputation of a node. - pub fn report_peer(&self, who: PeerId, reputation: peerset::ReputationChange) { + pub fn report_peer(&self, who: PeerId, reputation: sc_peerset::ReputationChange) { self.peerset_handle.report_peer(who, reputation) } diff --git a/client/network/src/protocol/legacy_proto/behaviour.rs b/client/network/src/protocol/legacy_proto/behaviour.rs index ed3ea8af4d..31e162a589 100644 --- a/client/network/src/protocol/legacy_proto/behaviour.rs +++ b/client/network/src/protocol/legacy_proto/behaviour.rs @@ -65,7 +65,7 @@ pub struct LegacyProto< TSubstream> { protocol: RegisteredProtocol, /// Receiver for instructions about who to connect to or disconnect from. - peerset: peerset::Peerset, + peerset: sc_peerset::Peerset, /// List of peers in our state. peers: FnvHashMap, @@ -76,7 +76,7 @@ pub struct LegacyProto< TSubstream> { /// We generate indices to identify incoming connections. This is the next value for the index /// to use when a connection is incoming. - next_incoming_index: peerset::IncomingIndex, + next_incoming_index: sc_peerset::IncomingIndex, /// Events to produce from `poll()`. events: SmallVec<[NetworkBehaviourAction; 4]>, @@ -183,7 +183,7 @@ struct IncomingPeer { /// connection corresponding to it has been closed or replaced already. alive: bool, /// Id that the we sent to the peerset. - incoming_id: peerset::IncomingIndex, + incoming_id: sc_peerset::IncomingIndex, } /// Event that can be emitted by the `LegacyProto`. @@ -230,7 +230,7 @@ impl LegacyProto { pub fn new( protocol: impl Into, versions: &[u8], - peerset: peerset::Peerset, + peerset: sc_peerset::Peerset, ) -> Self { let protocol = RegisteredProtocol::new(protocol, versions); @@ -239,7 +239,7 @@ impl LegacyProto { peerset, peers: FnvHashMap::default(), incoming: SmallVec::new(), - next_incoming_index: peerset::IncomingIndex(0), + next_incoming_index: sc_peerset::IncomingIndex(0), events: SmallVec::new(), marker: PhantomData, } @@ -520,7 +520,7 @@ impl LegacyProto { } /// Function that is called when the peerset wants us to accept an incoming node. - fn peerset_report_accept(&mut self, index: peerset::IncomingIndex) { + fn peerset_report_accept(&mut self, index: sc_peerset::IncomingIndex) { let incoming = if let Some(pos) = self.incoming.iter().position(|i| i.incoming_id == index) { self.incoming.remove(pos) } else { @@ -564,7 +564,7 @@ impl LegacyProto { } /// Function that is called when the peerset wants us to reject an incoming node. - fn peerset_report_reject(&mut self, index: peerset::IncomingIndex) { + fn peerset_report_reject(&mut self, index: sc_peerset::IncomingIndex) { let incoming = if let Some(pos) = self.incoming.iter().position(|i| i.incoming_id == index) { self.incoming.remove(pos) } else { @@ -942,7 +942,7 @@ where // again in the short term. self.peerset.report_peer( source.clone(), - peerset::ReputationChange::new(i32::min_value(), "Protocol error") + sc_peerset::ReputationChange::new(i32::min_value(), "Protocol error") ); self.disconnect_peer_inner(&source, Some(Duration::from_secs(5))); } @@ -965,16 +965,16 @@ where futures03::Stream::poll_next(Pin::new(&mut self.peerset), cx) ).map(|v| Ok::<_, ()>(v)).compat(); match peerset01.poll() { - Ok(Async::Ready(Some(peerset::Message::Accept(index)))) => { + Ok(Async::Ready(Some(sc_peerset::Message::Accept(index)))) => { self.peerset_report_accept(index); } - Ok(Async::Ready(Some(peerset::Message::Reject(index)))) => { + Ok(Async::Ready(Some(sc_peerset::Message::Reject(index)))) => { self.peerset_report_reject(index); } - Ok(Async::Ready(Some(peerset::Message::Connect(id)))) => { + Ok(Async::Ready(Some(sc_peerset::Message::Connect(id)))) => { self.peerset_report_connect(id); } - Ok(Async::Ready(Some(peerset::Message::Drop(id)))) => { + Ok(Async::Ready(Some(sc_peerset::Message::Drop(id)))) => { self.peerset_report_disconnect(id); } Ok(Async::Ready(None)) => { diff --git a/client/network/src/protocol/legacy_proto/tests.rs b/client/network/src/protocol/legacy_proto/tests.rs index 32af2198b7..eaf25e5119 100644 --- a/client/network/src/protocol/legacy_proto/tests.rs +++ b/client/network/src/protocol/legacy_proto/tests.rs @@ -68,7 +68,7 @@ fn build_nodes() .map_err(|err| io::Error::new(io::ErrorKind::Other, err)) .boxed(); - let (peerset, _) = peerset::Peerset::from_config(peerset::PeersetConfig { + let (peerset, _) = sc_peerset::Peerset::from_config(sc_peerset::PeersetConfig { in_peers: 25, out_peers: 25, bootnodes: if index == 0 { diff --git a/client/network/src/protocol/light_dispatch.rs b/client/network/src/protocol/light_dispatch.rs index 047961250f..83e0331325 100644 --- a/client/network/src/protocol/light_dispatch.rs +++ b/client/network/src/protocol/light_dispatch.rs @@ -26,14 +26,14 @@ use log::{trace, info}; use futures::sync::oneshot::{Sender as OneShotSender}; use linked_hash_map::{Entry, LinkedHashMap}; use sp_blockchain::Error as ClientError; -use client_api::{FetchChecker, RemoteHeaderRequest, +use sc_client_api::{FetchChecker, RemoteHeaderRequest, RemoteCallRequest, RemoteReadRequest, RemoteChangesRequest, ChangesProof, RemoteReadChildRequest, RemoteBodyRequest, StorageProof}; use crate::message::{self, BlockAttributes, Direction, FromBlock, RequestId}; use libp2p::PeerId; use crate::config::Roles; use sp_runtime::traits::{Block as BlockT, Header as HeaderT, NumberFor}; -use peerset::ReputationChange; +use sc_peerset::ReputationChange; /// Remote request timeout. const REQUEST_TIMEOUT: Duration = Duration::from_secs(15); @@ -681,10 +681,10 @@ pub mod tests { use std::sync::Arc; use std::time::Instant; use futures::{Future, sync::oneshot}; - use primitives::storage::ChildInfo; + use sp_core::storage::ChildInfo; use sp_runtime::traits::{Block as BlockT, NumberFor, Header as HeaderT}; use sp_blockchain::{Error as ClientError, Result as ClientResult}; - use client_api::{FetchChecker, RemoteHeaderRequest, + use sc_client_api::{FetchChecker, RemoteHeaderRequest, ChangesProof, RemoteCallRequest, RemoteReadRequest, RemoteReadChildRequest, RemoteChangesRequest, RemoteBodyRequest}; use crate::config::Roles; @@ -1233,7 +1233,7 @@ pub mod tests { assert_eq!(light_dispatch.active_peers.len(), 1); let block = message::BlockData:: { - hash: primitives::H256::random(), + hash: sp_core::H256::random(), header: None, body: Some(Vec::new()), message_queue: None, @@ -1271,7 +1271,7 @@ pub mod tests { let response = { let blocks: Vec<_> = (0..3).map(|_| message::BlockData:: { - hash: primitives::H256::random(), + hash: sp_core::H256::random(), header: None, body: Some(Vec::new()), message_queue: None, diff --git a/client/network/src/protocol/message.rs b/client/network/src/protocol/message.rs index b7267f376f..0bb9d8c64f 100644 --- a/client/network/src/protocol/message.rs +++ b/client/network/src/protocol/message.rs @@ -26,7 +26,7 @@ pub use self::generic::{ FinalityProofRequest, FinalityProofResponse, FromBlock, RemoteReadChildRequest, }; -use client_api::StorageProof; +use sc_client_api::StorageProof; /// A unique ID of a request. pub type RequestId = u64; diff --git a/client/network/src/protocol/sync.rs b/client/network/src/protocol/sync.rs index ca332d46f1..4e248b7fe4 100644 --- a/client/network/src/protocol/sync.rs +++ b/client/network/src/protocol/sync.rs @@ -28,9 +28,9 @@ //! use blocks::BlockCollection; -use client_api::ClientInfo; +use sc_client_api::ClientInfo; use sp_blockchain::Error as ClientError; -use consensus::{BlockOrigin, BlockStatus, +use sp_consensus::{BlockOrigin, BlockStatus, block_validation::{BlockAnnounceValidator, Validation}, import_queue::{IncomingBlock, BlockImportResult, BlockImportError} }; @@ -73,7 +73,7 @@ const MAJOR_SYNC_BLOCKS: u8 = 5; const ANNOUNCE_HISTORY_SIZE: usize = 64; mod rep { - use peerset::ReputationChange as Rep; + use sc_peerset::ReputationChange as Rep; /// Reputation change when a peer sent us a message that led to a /// database read error. pub const BLOCKCHAIN_READ_ERROR: Rep = Rep::new(-(1 << 16), "DB Error"); @@ -230,7 +230,7 @@ pub struct Status { /// A peer did not behave as expected and should be reported. #[derive(Debug, Clone, PartialEq, Eq)] -pub struct BadPeer(pub PeerId, pub peerset::ReputationChange); +pub struct BadPeer(pub PeerId, pub sc_peerset::ReputationChange); impl fmt::Display for BadPeer { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { diff --git a/client/network/src/protocol/sync/blocks.rs b/client/network/src/protocol/sync/blocks.rs index f89772a8e7..ef08d7320d 100644 --- a/client/network/src/protocol/sync/blocks.rs +++ b/client/network/src/protocol/sync/blocks.rs @@ -216,7 +216,7 @@ mod test { use super::{BlockCollection, BlockData, BlockRangeState}; use crate::{message, PeerId}; use sp_runtime::testing::{Block as RawBlock, ExtrinsicWrapper}; - use primitives::H256; + use sp_core::H256; type Block = RawBlock>; diff --git a/client/network/src/service.rs b/client/network/src/service.rs index c137932090..3b3a64b41a 100644 --- a/client/network/src/service.rs +++ b/client/network/src/service.rs @@ -28,8 +28,8 @@ use std::{collections::{HashMap, HashSet}, fs, marker::PhantomData, io, path::Path}; use std::sync::{Arc, atomic::{AtomicBool, AtomicUsize, Ordering}}; -use consensus::import_queue::{ImportQueue, Link}; -use consensus::import_queue::{BlockImportResult, BlockImportError}; +use sp_consensus::import_queue::{ImportQueue, Link}; +use sp_consensus::import_queue::{BlockImportResult, BlockImportError}; use futures::{prelude::*, sync::mpsc}; use futures03::TryFutureExt as _; use log::{warn, error, info}; @@ -37,7 +37,7 @@ use libp2p::{PeerId, Multiaddr, kad::record}; use libp2p::core::{transport::boxed::Boxed, muxing::StreamMuxerBox}; use libp2p::swarm::NetworkBehaviour; use parking_lot::Mutex; -use peerset::PeersetHandle; +use sc_peerset::PeersetHandle; use sp_runtime::{traits::{Block as BlockT, NumberFor}, ConsensusEngineId}; use crate::{behaviour::{Behaviour, BehaviourOut}, config::{parse_str_addr, parse_addr}}; @@ -176,7 +176,7 @@ impl, H: ExHashT> NetworkWorker } } - let peerset_config = peerset::PeersetConfig { + let peerset_config = sc_peerset::PeersetConfig { in_peers: params.network_config.in_peers, out_peers: params.network_config.out_peers, bootnodes, @@ -604,7 +604,7 @@ impl, H: ExHashT> NetworkServic } } -impl, H: ExHashT> consensus::SyncOracle +impl, H: ExHashT> sp_consensus::SyncOracle for NetworkService { fn is_major_syncing(&mut self) -> bool { @@ -616,7 +616,7 @@ impl, H: ExHashT> consensus::Sy } } -impl<'a, B: BlockT + 'static, S: NetworkSpecialization, H: ExHashT> consensus::SyncOracle +impl<'a, B: BlockT + 'static, S: NetworkSpecialization, H: ExHashT> sp_consensus::SyncOracle for &'a NetworkService { fn is_major_syncing(&mut self) -> bool { diff --git a/client/network/test/Cargo.toml b/client/network/test/Cargo.toml index e92ae0f7fc..c3f95894f8 100644 --- a/client/network/test/Cargo.toml +++ b/client/network/test/Cargo.toml @@ -15,16 +15,16 @@ futures03 = { package = "futures", version = "0.3.1", features = ["compat"] } futures-timer = "0.4.0" rand = "0.7.2" libp2p = { version = "0.13.0", default-features = false, features = ["libp2p-websocket"] } -consensus = { package = "sp-consensus", path = "../../../primitives/consensus/common" } -client = { package = "sc-client", path = "../../" } -client-api = { package = "sc-client-api", path = "../../api" } +sp-consensus = { path = "../../../primitives/consensus/common" } +sc-client = { path = "../../" } +sc-client-api = { path = "../../api" } sp-blockchain = { path = "../../../primitives/blockchain" } sp-runtime = { path = "../../../primitives/runtime" } -primitives = { package = "sp-core", path = "../../../primitives/core" } -block-builder = { package = "sc-block-builder", path = "../../block-builder" } -babe-primitives = { package = "sp-consensus-babe", path = "../../../primitives/consensus/babe" } +sp-core = { path = "../../../primitives/core" } +sc-block-builder = { path = "../../block-builder" } +sp-consensus-babe = { path = "../../../primitives/consensus/babe" } env_logger = "0.7.0" -test-client = { package = "substrate-test-runtime-client", path = "../../../test-utils/runtime/client" } -test_runtime = { package = "substrate-test-runtime", path = "../../../test-utils/runtime" } +substrate-test-runtime-client = { path = "../../../test-utils/runtime/client" } +substrate-test-runtime = { path = "../../../test-utils/runtime" } tempfile = "3.1.0" tokio = "0.1.22" diff --git a/client/network/test/src/block_import.rs b/client/network/test/src/block_import.rs index 5cb7b6b606..7ea317c2b4 100644 --- a/client/network/test/src/block_import.rs +++ b/client/network/test/src/block_import.rs @@ -16,17 +16,17 @@ //! Testing block import logic. -use consensus::ImportedAux; -use consensus::import_queue::{ +use sp_consensus::ImportedAux; +use sp_consensus::import_queue::{ import_single_block, BasicQueue, BlockImportError, BlockImportResult, IncomingBlock, }; -use test_client::{self, prelude::*}; -use test_client::runtime::{Block, Hash}; +use substrate_test_runtime_client::{self, prelude::*}; +use substrate_test_runtime_client::runtime::{Block, Hash}; use sp_runtime::generic::BlockId; use super::*; fn prepare_good_block() -> (TestClient, Hash, u64, PeerId, IncomingBlock) { - let client = test_client::new(); + let client = substrate_test_runtime_client::new(); let block = client.new_block(Default::default()).unwrap().bake().unwrap(); client.import(BlockOrigin::File, block).unwrap(); @@ -52,7 +52,7 @@ fn import_single_good_block_works() { let mut expected_aux = ImportedAux::default(); expected_aux.is_new_best = true; - match import_single_block(&mut test_client::new(), BlockOrigin::File, block, &mut PassThroughVerifier(true)) { + match import_single_block(&mut substrate_test_runtime_client::new(), BlockOrigin::File, block, &mut PassThroughVerifier(true)) { Ok(BlockImportResult::ImportedUnknown(ref num, ref aux, ref org)) if *num == number && *aux == expected_aux && *org == Some(peer_id) => {} r @ _ => panic!("{:?}", r) @@ -72,7 +72,7 @@ fn import_single_good_known_block_is_ignored() { fn import_single_good_block_without_header_fails() { let (_, _, _, peer_id, mut block) = prepare_good_block(); block.header = None; - match import_single_block(&mut test_client::new(), BlockOrigin::File, block, &mut PassThroughVerifier(true)) { + match import_single_block(&mut substrate_test_runtime_client::new(), BlockOrigin::File, block, &mut PassThroughVerifier(true)) { Err(BlockImportError::IncompleteHeader(ref org)) if *org == Some(peer_id) => {} _ => panic!() } @@ -83,7 +83,7 @@ fn async_import_queue_drops() { // Perform this test multiple times since it exhibits non-deterministic behavior. for _ in 0..100 { let verifier = PassThroughVerifier(true); - let queue = BasicQueue::new(verifier, Box::new(test_client::new()), None, None); + let queue = BasicQueue::new(verifier, Box::new(substrate_test_runtime_client::new()), None, None); drop(queue); } } diff --git a/client/network/test/src/lib.rs b/client/network/test/src/lib.rs index cc81789e24..8e598c95a3 100644 --- a/client/network/test/src/lib.rs +++ b/client/network/test/src/lib.rs @@ -30,42 +30,42 @@ use sc_network::FinalityProofProvider; use sp_blockchain::{ Result as ClientResult, well_known_cache_keys::{self, Id as CacheKeyId}, }; -use client_api::{ +use sc_client_api::{ ClientInfo, BlockchainEvents, BlockImportNotification, FinalityNotifications, ImportNotifications, FinalityNotification, backend::{AuxStore, Backend, Finalizer} }; -use block_builder::BlockBuilder; -use client::LongestChain; +use sc_block_builder::BlockBuilder; +use sc_client::LongestChain; use sc_network::config::Roles; -use consensus::block_validation::DefaultBlockAnnounceValidator; -use consensus::import_queue::BasicQueue; -use consensus::import_queue::{ +use sp_consensus::block_validation::DefaultBlockAnnounceValidator; +use sp_consensus::import_queue::BasicQueue; +use sp_consensus::import_queue::{ BoxBlockImport, BoxJustificationImport, Verifier, BoxFinalityProofImport, }; -use consensus::block_import::{BlockImport, ImportResult}; -use consensus::Error as ConsensusError; -use consensus::{BlockOrigin, ForkChoiceStrategy, BlockImportParams, BlockCheckParams, JustificationImport}; +use sp_consensus::block_import::{BlockImport, ImportResult}; +use sp_consensus::Error as ConsensusError; +use sp_consensus::{BlockOrigin, ForkChoiceStrategy, BlockImportParams, BlockCheckParams, JustificationImport}; use futures::prelude::*; use futures03::{StreamExt as _, TryStreamExt as _}; use sc_network::{NetworkWorker, NetworkService, ReportHandle, config::ProtocolId}; use sc_network::config::{NetworkConfiguration, TransportConfig, BoxFinalityProofRequestBuilder}; use libp2p::PeerId; use parking_lot::Mutex; -use primitives::H256; +use sp_core::H256; use sc_network::{Context, ProtocolConfig}; use sp_runtime::generic::{BlockId, OpaqueDigestItemId}; use sp_runtime::traits::{Block as BlockT, Header, NumberFor}; use sp_runtime::Justification; use sc_network::TransactionPool; use sc_network::specialization::NetworkSpecialization; -use test_client::{self, AccountKeyring}; +use substrate_test_runtime_client::{self, AccountKeyring}; -pub use test_client::runtime::{Block, Extrinsic, Hash, Transfer}; -pub use test_client::{TestClient, TestClientBuilder, TestClientBuilderExt}; +pub use substrate_test_runtime_client::runtime::{Block, Extrinsic, Hash, Transfer}; +pub use substrate_test_runtime_client::{TestClient, TestClientBuilder, TestClientBuilderExt}; -type AuthorityId = babe_primitives::AuthorityId; +type AuthorityId = sp_consensus_babe::AuthorityId; /// A Verifier that accepts all blocks and passes them on with the configured /// finality to be imported. @@ -129,14 +129,14 @@ impl NetworkSpecialization for DummySpecialization { } pub type PeersFullClient = - client::Client; + sc_client::Client; pub type PeersLightClient = - client::Client; + sc_client::Client; #[derive(Clone)] pub enum PeersClient { - Full(Arc, Arc), - Light(Arc, Arc), + Full(Arc, Arc), + Light(Arc, Arc), } impl PeersClient { @@ -218,8 +218,8 @@ pub struct Peer> { /// We keep a copy of the block_import so that we can invoke it for locally-generated blocks, /// instead of going through the import queue. block_import: Box>, - select_chain: Option>, - backend: Option>, + select_chain: Option>, + backend: Option>, network: NetworkWorker::Hash>, imported_blocks_stream: Box, Error = ()> + Send>, finality_notification_stream: Box, Error = ()> + Send>, @@ -237,7 +237,7 @@ impl> Peer { } // Returns a clone of the local SelectChain, only available on full nodes - pub fn select_chain(&self) -> Option> { + pub fn select_chain(&self) -> Option> { self.select_chain.clone() } @@ -608,7 +608,7 @@ pub trait TestNetFactory: Sized { let mut config = config.clone(); config.roles = Roles::LIGHT; - let (c, backend) = test_client::new_light(); + let (c, backend) = substrate_test_runtime_client::new_light(); let client = Arc::new(c); let ( block_import, diff --git a/client/network/test/src/sync.rs b/client/network/test/src/sync.rs index b4e166be67..0160c081e3 100644 --- a/client/network/test/src/sync.rs +++ b/client/network/test/src/sync.rs @@ -15,7 +15,7 @@ // along with Substrate. If not, see . use sc_network::config::Roles; -use consensus::BlockOrigin; +use sp_consensus::BlockOrigin; use futures03::TryFutureExt as _; use std::time::Duration; use tokio::runtime::current_thread; diff --git a/client/offchain/Cargo.toml b/client/offchain/Cargo.toml index 755453fa21..2e1255eab2 100644 --- a/client/offchain/Cargo.toml +++ b/client/offchain/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" [dependencies] bytes = "0.4.12" -client-api = { package = "sc-client-api", path = "../api" } +sc-client-api = { path = "../api" } sp-api = { path = "../../primitives/api" } fnv = "1.0.6" futures01 = { package = "futures", version = "0.1" } @@ -17,26 +17,26 @@ futures-timer = "2.0" log = "0.4.8" threadpool = "1.7" num_cpus = "1.10" -offchain-primitives = { package = "sp-offchain", path = "../../primitives/offchain" } +sp-offchain = { path = "../../primitives/offchain" } codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } parking_lot = "0.9.0" -primitives = { package = "sp-core", path = "../../primitives/core" } +sp-core = { path = "../../primitives/core" } rand = "0.7.2" sp-runtime = { path = "../../primitives/runtime" } -network = { package = "sc-network", path = "../network" } -keystore = { package = "sc-keystore", path = "../keystore" } +sc-network = { path = "../network" } +sc-keystore = { path = "../keystore" } [target.'cfg(not(target_os = "unknown"))'.dependencies] hyper = "0.12.35" hyper-rustls = "0.17.1" [dev-dependencies] -client-db = { package = "sc-client-db", path = "../db/", default-features = true } +sc-client-db = { path = "../db/", default-features = true } env_logger = "0.7.0" -test-client = { package = "substrate-test-runtime-client", path = "../../test-utils/runtime/client" } +substrate-test-runtime-client = { path = "../../test-utils/runtime/client" } tokio = "0.1.22" -txpool = { package = "sc-transaction-pool", path = "../../client/transaction-pool" } -txpool-api = { package = "sp-transaction-pool", path = "../../primitives/transaction-pool" } +sc-transaction-pool = { path = "../../client/transaction-pool" } +sp-transaction-pool = { path = "../../primitives/transaction-pool" } [features] default = [] diff --git a/client/offchain/src/api.rs b/client/offchain/src/api.rs index ff2a5a433a..4db08c145d 100644 --- a/client/offchain/src/api.rs +++ b/client/offchain/src/api.rs @@ -21,16 +21,16 @@ use std::{ thread::sleep, }; -use primitives::offchain::OffchainStorage; +use sp_core::offchain::OffchainStorage; use futures::Future; use log::error; -use network::{PeerId, Multiaddr, NetworkStateInfo}; +use sc_network::{PeerId, Multiaddr, NetworkStateInfo}; use codec::{Encode, Decode}; -use primitives::offchain::{ +use sp_core::offchain::{ Externalities as OffchainExt, HttpRequestId, Timestamp, HttpRequestStatus, HttpError, OpaqueNetworkState, OpaquePeerId, OpaqueMultiaddr, StorageKind, }; -pub use offchain_primitives::STORAGE_PREFIX; +pub use sp_offchain::STORAGE_PREFIX; #[cfg(not(target_os = "unknown"))] mod http; @@ -282,8 +282,8 @@ impl AsyncApi { mod tests { use super::*; use std::{convert::{TryFrom, TryInto}, time::SystemTime}; - use client_db::offchain::LocalStorage; - use network::PeerId; + use sc_client_db::offchain::LocalStorage; + use sc_network::PeerId; struct MockNetworkStateInfo(); @@ -331,7 +331,7 @@ mod tests { // Arrange. let now = api.timestamp(); - let delta = primitives::offchain::Duration::from_millis(100); + let delta = sp_core::offchain::Duration::from_millis(100); let deadline = now.add(delta); // Act. diff --git a/client/offchain/src/api/http.rs b/client/offchain/src/api/http.rs index 30cadf0918..6744e1b90f 100644 --- a/client/offchain/src/api/http.rs +++ b/client/offchain/src/api/http.rs @@ -30,7 +30,7 @@ use bytes::Buf as _; use fnv::FnvHashMap; use futures::{prelude::*, channel::mpsc, compat::Compat01As03}; use log::error; -use primitives::offchain::{HttpRequestId, Timestamp, HttpRequestStatus, HttpError}; +use sp_core::offchain::{HttpRequestId, Timestamp, HttpRequestStatus, HttpError}; use std::{fmt, io::Read as _, mem, pin::Pin, task::Context, task::Poll}; /// Creates a pair of [`HttpApi`] and [`HttpWorker`]. @@ -696,7 +696,7 @@ mod tests { use super::http; use futures::prelude::*; use futures01::Future as _; - use primitives::offchain::{HttpError, HttpRequestId, HttpRequestStatus, Duration}; + use sp_core::offchain::{HttpError, HttpRequestId, HttpRequestStatus, Duration}; // Returns an `HttpApi` whose worker is ran in the background, and a `SocketAddr` to an HTTP // server that runs in the background as well. diff --git a/client/offchain/src/api/http_dummy.rs b/client/offchain/src/api/http_dummy.rs index e3cb272a0d..83c3b3c80c 100644 --- a/client/offchain/src/api/http_dummy.rs +++ b/client/offchain/src/api/http_dummy.rs @@ -16,7 +16,7 @@ //! Contains the same API as the `http` module, except that everything returns an error. -use primitives::offchain::{HttpRequestId, Timestamp, HttpRequestStatus, HttpError}; +use sp_core::offchain::{HttpRequestId, Timestamp, HttpRequestStatus, HttpError}; use std::{future::Future, pin::Pin, task::Context, task::Poll}; /// Creates a pair of [`HttpApi`] and [`HttpWorker`]. diff --git a/client/offchain/src/api/timestamp.rs b/client/offchain/src/api/timestamp.rs index 445c7f3878..8c45fce0cd 100644 --- a/client/offchain/src/api/timestamp.rs +++ b/client/offchain/src/api/timestamp.rs @@ -16,7 +16,7 @@ //! Helper methods dedicated to timestamps. -use primitives::offchain::Timestamp; +use sp_core::offchain::Timestamp; use std::convert::TryInto; use std::time::{SystemTime, Duration}; diff --git a/client/offchain/src/lib.rs b/client/offchain/src/lib.rs index 174aee89d9..208cfdfb0f 100644 --- a/client/offchain/src/lib.rs +++ b/client/offchain/src/lib.rs @@ -40,13 +40,13 @@ use threadpool::ThreadPool; use sp_api::ApiExt; use futures::future::Future; use log::{debug, warn}; -use network::NetworkStateInfo; -use primitives::{offchain::{self, OffchainStorage}, ExecutionContext}; +use sc_network::NetworkStateInfo; +use sp_core::{offchain::{self, OffchainStorage}, ExecutionContext}; use sp_runtime::{generic::BlockId, traits::{self, ProvideRuntimeApi}}; mod api; -pub use offchain_primitives::{OffchainWorkerApi, STORAGE_PREFIX}; +pub use sp_offchain::{OffchainWorkerApi, STORAGE_PREFIX}; /// An offchain workers manager. pub struct OffchainWorkers { @@ -146,10 +146,10 @@ impl OffchainWorkers< mod tests { use super::*; use std::sync::Arc; - use network::{Multiaddr, PeerId}; - use test_client::runtime::Block; - use txpool::{BasicPool, FullChainApi}; - use txpool_api::{TransactionPool, InPoolTransaction}; + use sc_network::{Multiaddr, PeerId}; + use substrate_test_runtime_client::runtime::Block; + use sc_transaction_pool::{BasicPool, FullChainApi}; + use sp_transaction_pool::{TransactionPool, InPoolTransaction}; struct MockNetworkStateInfo(); @@ -163,9 +163,9 @@ mod tests { } } - struct TestPool(BasicPool, Block>); + struct TestPool(BasicPool, Block>); - impl txpool_api::OffchainSubmitTransaction for TestPool { + impl sp_transaction_pool::OffchainSubmitTransaction for TestPool { fn submit_at( &self, at: &BlockId, @@ -181,11 +181,11 @@ mod tests { fn should_call_into_runtime_and_produce_extrinsic() { // given let _ = env_logger::try_init(); - let client = Arc::new(test_client::new()); + let client = Arc::new(substrate_test_runtime_client::new()); let pool = Arc::new(TestPool(BasicPool::new(Default::default(), FullChainApi::new(client.clone())))); client.execution_extensions() .register_transaction_pool(Arc::downgrade(&pool.clone()) as _); - let db = client_db::offchain::LocalStorage::new_test(); + let db = sc_client_db::offchain::LocalStorage::new_test(); let network_state = Arc::new(MockNetworkStateInfo()); // when diff --git a/client/rpc-api/Cargo.toml b/client/rpc-api/Cargo.toml index 58fb3ca904..7b1f68c512 100644 --- a/client/rpc-api/Cargo.toml +++ b/client/rpc-api/Cargo.toml @@ -14,9 +14,9 @@ jsonrpc-derive = "14.0.3" jsonrpc-pubsub = "14.0.3" log = "0.4.8" parking_lot = "0.9.0" -primitives = { package = "sp-core", path = "../../primitives/core" } -runtime_version = { package = "sp-version", path = "../../primitives/version" } +sp-core = { path = "../../primitives/core" } +sp-version = { path = "../../primitives/version" } serde = { version = "1.0.101", features = ["derive"] } serde_json = "1.0.41" -txpool-api = { package = "sp-transaction-pool", path = "../../primitives/transaction-pool" } -rpc-primitives = { package = "sp-rpc", path = "../../primitives/rpc" } +sp-transaction-pool = { path = "../../primitives/transaction-pool" } +sp-rpc = { path = "../../primitives/rpc" } diff --git a/client/rpc-api/src/author/error.rs b/client/rpc-api/src/author/error.rs index eb98fbda51..b1dfcc140a 100644 --- a/client/rpc-api/src/author/error.rs +++ b/client/rpc-api/src/author/error.rs @@ -34,7 +34,7 @@ pub enum Error { Client(Box), /// Transaction pool error, #[display(fmt="Transaction pool error: {}", _0)] - Pool(txpool_api::error::Error), + Pool(sp_transaction_pool::error::Error), /// Verification error #[display(fmt="Extrinsic verification error: {}", _0)] #[from(ignore)] @@ -93,7 +93,7 @@ const UNSUPPORTED_KEY_TYPE: i64 = POOL_INVALID_TX + 7; impl From for rpc::Error { fn from(e: Error) -> Self { - use txpool_api::error::{Error as PoolError}; + use sp_transaction_pool::error::{Error as PoolError}; match e { Error::BadFormat(e) => rpc::Error { diff --git a/client/rpc-api/src/author/hash.rs b/client/rpc-api/src/author/hash.rs index a01e26de3c..9d2f658ae6 100644 --- a/client/rpc-api/src/author/hash.rs +++ b/client/rpc-api/src/author/hash.rs @@ -16,7 +16,7 @@ //! Extrinsic helpers for author RPC module. -use primitives::Bytes; +use sp_core::Bytes; use serde::{Serialize, Deserialize}; /// RPC Extrinsic or hash diff --git a/client/rpc-api/src/author/mod.rs b/client/rpc-api/src/author/mod.rs index 927bb530ea..c2fbe229c1 100644 --- a/client/rpc-api/src/author/mod.rs +++ b/client/rpc-api/src/author/mod.rs @@ -21,8 +21,8 @@ pub mod hash; use jsonrpc_derive::rpc; use jsonrpc_pubsub::{typed::Subscriber, SubscriptionId}; -use primitives::Bytes; -use txpool_api::TransactionStatus; +use sp_core::Bytes; +use sp_transaction_pool::TransactionStatus; use self::error::{FutureResult, Result}; pub use self::gen_client::Client as AuthorClient; diff --git a/client/rpc-api/src/chain/mod.rs b/client/rpc-api/src/chain/mod.rs index fd7576f988..f3c51d3871 100644 --- a/client/rpc-api/src/chain/mod.rs +++ b/client/rpc-api/src/chain/mod.rs @@ -22,7 +22,7 @@ use jsonrpc_core::Result as RpcResult; use jsonrpc_core::futures::Future; use jsonrpc_derive::rpc; use jsonrpc_pubsub::{typed::Subscriber, SubscriptionId}; -use rpc_primitives::{number::NumberOrHex, list::ListOrValue}; +use sp_rpc::{number::NumberOrHex, list::ListOrValue}; use self::error::{FutureResult, Result}; pub use self::gen_client::Client as ChainClient; diff --git a/client/rpc-api/src/state/mod.rs b/client/rpc-api/src/state/mod.rs index 9a549b00c4..ecc31581c6 100644 --- a/client/rpc-api/src/state/mod.rs +++ b/client/rpc-api/src/state/mod.rs @@ -22,9 +22,9 @@ use jsonrpc_core::Result as RpcResult; use jsonrpc_core::futures::Future; use jsonrpc_derive::rpc; use jsonrpc_pubsub::{typed::Subscriber, SubscriptionId}; -use primitives::Bytes; -use primitives::storage::{StorageKey, StorageData, StorageChangeSet}; -use runtime_version::RuntimeVersion; +use sp_core::Bytes; +use sp_core::storage::{StorageKey, StorageData, StorageChangeSet}; +use sp_version::RuntimeVersion; use self::error::FutureResult; pub use self::gen_client::Client as StateClient; diff --git a/client/rpc/Cargo.toml b/client/rpc/Cargo.toml index 61ad753c84..91274ed34b 100644 --- a/client/rpc/Cargo.toml +++ b/client/rpc/Cargo.toml @@ -5,25 +5,25 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -api = { package = "sc-rpc-api", path = "../rpc-api" } -client-api = { package = "sc-client-api", path = "../api" } -client = { package = "sc-client", path = "../" } +sc-rpc-api = { path = "../rpc-api" } +sc-client-api = { path = "../api" } +sc-client = { path = "../" } sp-api = { path = "../../primitives/api" } codec = { package = "parity-scale-codec", version = "1.0.0" } futures = { version = "0.3.1", features = ["compat"] } jsonrpc-pubsub = "14.0.3" log = "0.4.8" -primitives = { package = "sp-core", path = "../../primitives/core" } +sp-core = { path = "../../primitives/core" } rpc = { package = "jsonrpc-core", version = "14.0.3" } -runtime_version = { package = "sp-version", path = "../../primitives/version" } +sp-version = { path = "../../primitives/version" } serde_json = "1.0.41" -session = { package = "sp-session", path = "../../primitives/session" } +sp-session = { path = "../../primitives/session" } sp-runtime = { path = "../../primitives/runtime" } -rpc-primitives = { package = "sp-rpc", path = "../../primitives/rpc" } -state_machine = { package = "sp-state-machine", path = "../../primitives/state-machine" } +sp-rpc = { path = "../../primitives/rpc" } +sp-state-machine = { path = "../../primitives/state-machine" } sc-executor = { path = "../executor" } sc-keystore = { path = "../keystore" } -txpool-api = { package = "sp-transaction-pool", path = "../../primitives/transaction-pool" } +sp-transaction-pool = { path = "../../primitives/transaction-pool" } sp-blockchain = { path = "../../primitives/blockchain" } hash-db = { version = "0.15.2", default-features = false } parking_lot = { version = "0.9.0" } @@ -31,9 +31,9 @@ parking_lot = { version = "0.9.0" } [dev-dependencies] assert_matches = "1.3.0" futures01 = { package = "futures", version = "0.1.29" } -network = { package = "sc-network", path = "../network" } +sc-network = { path = "../network" } rustc-hex = "2.0.1" sp-io = { path = "../../primitives/io" } -test-client = { package = "substrate-test-runtime-client", path = "../../test-utils/runtime/client" } +substrate-test-runtime-client = { path = "../../test-utils/runtime/client" } tokio = "0.1.22" -txpool = { package = "sc-transaction-pool", path = "../transaction-pool" } +sc-transaction-pool = { path = "../transaction-pool" } diff --git a/client/rpc/src/author/mod.rs b/client/rpc/src/author/mod.rs index c710016003..1cdbda5904 100644 --- a/client/rpc/src/author/mod.rs +++ b/client/rpc/src/author/mod.rs @@ -22,7 +22,7 @@ mod tests; use std::{sync::Arc, convert::TryInto}; use log::warn; -use client::Client; +use sc_client::Client; use sp_blockchain::Error as ClientError; use rpc::futures::{ @@ -31,20 +31,20 @@ use rpc::futures::{ }; use futures::{StreamExt as _, compat::Compat}; use futures::future::{ready, FutureExt, TryFutureExt}; -use api::Subscriptions; +use sc_rpc_api::Subscriptions; use jsonrpc_pubsub::{typed::Subscriber, SubscriptionId}; use codec::{Encode, Decode}; -use primitives::{Bytes, Blake2Hasher, H256, traits::BareCryptoStorePtr}; +use sp_core::{Bytes, Blake2Hasher, H256, traits::BareCryptoStorePtr}; use sp_api::ConstructRuntimeApi; use sp_runtime::{generic, traits::{self, ProvideRuntimeApi}}; -use txpool_api::{ +use sp_transaction_pool::{ TransactionPool, InPoolTransaction, TransactionStatus, BlockHash, TxHash, TransactionFor, error::IntoPoolError, }; -use session::SessionKeys; +use sp_session::SessionKeys; /// Re-export the API for backward compatibility. -pub use api::author::*; +pub use sc_rpc_api::author::*; use self::error::{Error, FutureResult, Result}; /// Authoring API @@ -78,8 +78,8 @@ impl Author { impl AuthorApi for Author where Block: traits::Block, - B: client_api::backend::Backend + Send + Sync + 'static, - E: client_api::CallExecutor + Clone + Send + Sync + 'static, + B: sc_client_api::backend::Backend + Send + Sync + 'static, + E: sc_client_api::CallExecutor + Clone + Send + Sync + 'static, P: TransactionPool + Sync + Send + 'static, RA: ConstructRuntimeApi> + Send + Sync + 'static, Client: ProvideRuntimeApi, diff --git a/client/rpc/src/author/tests.rs b/client/rpc/src/author/tests.rs index 14aa03a643..f672e38fa5 100644 --- a/client/rpc/src/author/tests.rs +++ b/client/rpc/src/author/tests.rs @@ -19,16 +19,16 @@ use super::*; use std::sync::Arc; use assert_matches::assert_matches; use codec::Encode; -use primitives::{ +use sp_core::{ H256, blake2_256, hexdisplay::HexDisplay, testing::{ED25519, SR25519, KeyStore}, traits::BareCryptoStorePtr, ed25519, crypto::Pair, }; use rpc::futures::Stream as _; -use test_client::{ +use substrate_test_runtime_client::{ self, AccountKeyring, runtime::{Extrinsic, Transfer, SessionKeys, RuntimeApi, Block}, DefaultTestClientBuilderExt, TestClientBuilderExt, Backend, Client, Executor, }; -use txpool::{BasicPool, FullChainApi}; +use sc_transaction_pool::{BasicPool, FullChainApi}; use tokio::runtime; fn uxt(sender: AccountKeyring, nonce: u64) -> Extrinsic { @@ -56,7 +56,7 @@ struct TestSetup { impl Default for TestSetup { fn default() -> Self { let keystore = KeyStore::new(); - let client = Arc::new(test_client::TestClientBuilder::new().set_keystore(keystore.clone()).build()); + let client = Arc::new(substrate_test_runtime_client::TestClientBuilder::new().set_keystore(keystore.clone()).build()); let pool = Arc::new(BasicPool::new(Default::default(), FullChainApi::new(client.clone()))); TestSetup { runtime: runtime::Runtime::new().expect("Failed to create runtime in test setup"), diff --git a/client/rpc/src/chain/chain_full.rs b/client/rpc/src/chain/chain_full.rs index aa11481a3e..f0a0b180c3 100644 --- a/client/rpc/src/chain/chain_full.rs +++ b/client/rpc/src/chain/chain_full.rs @@ -19,10 +19,10 @@ use std::sync::Arc; use rpc::futures::future::result; -use api::Subscriptions; -use client_api::{CallExecutor, backend::Backend}; -use client::Client; -use primitives::{H256, Blake2Hasher}; +use sc_rpc_api::Subscriptions; +use sc_client_api::{CallExecutor, backend::Backend}; +use sc_client::Client; +use sp_core::{H256, Blake2Hasher}; use sp_runtime::{ generic::{BlockId, SignedBlock}, traits::{Block as BlockT}, diff --git a/client/rpc/src/chain/chain_light.rs b/client/rpc/src/chain/chain_light.rs index 63cb067619..0c850153f7 100644 --- a/client/rpc/src/chain/chain_light.rs +++ b/client/rpc/src/chain/chain_light.rs @@ -20,15 +20,15 @@ use std::sync::Arc; use futures::{future::ready, FutureExt, TryFutureExt}; use rpc::futures::future::{result, Future, Either}; -use api::Subscriptions; -use client::{ +use sc_rpc_api::Subscriptions; +use sc_client::{ self, Client, light::{ fetcher::{Fetcher, RemoteBodyRequest}, blockchain::RemoteBlockchain, }, }; -use primitives::{H256, Blake2Hasher}; +use sp_core::{H256, Blake2Hasher}; use sp_runtime::{ generic::{BlockId, SignedBlock}, traits::{Block as BlockT}, @@ -68,8 +68,8 @@ impl> LightChain impl ChainBackend for LightChain where Block: BlockT + 'static, - B: client_api::backend::Backend + Send + Sync + 'static, - E: client::CallExecutor + Send + Sync + 'static, + B: sc_client_api::backend::Backend + Send + Sync + 'static, + E: sc_client::CallExecutor + Send + Sync + 'static, RA: Send + Sync + 'static, F: Fetcher + Send + Sync + 'static, { @@ -85,7 +85,7 @@ impl ChainBackend for LightChain: Send + Sync + 'static where Block: BlockT + 'static, - B: client_api::backend::Backend + Send + Sync + 'static, - E: client::CallExecutor + Send + Sync + 'static, + B: sc_client_api::backend::Backend + Send + Sync + 'static, + E: sc_client::CallExecutor + Send + Sync + 'static, { /// Get client reference. fn client(&self) -> &Arc>; @@ -156,8 +156,8 @@ pub fn new_full( ) -> Chain where Block: BlockT + 'static, - B: client_api::backend::Backend + Send + Sync + 'static, - E: client::CallExecutor + Send + Sync + 'static + Clone, + B: sc_client_api::backend::Backend + Send + Sync + 'static, + E: sc_client::CallExecutor + Send + Sync + 'static + Clone, RA: Send + Sync + 'static, { Chain { @@ -174,8 +174,8 @@ pub fn new_light>( ) -> Chain where Block: BlockT + 'static, - B: client_api::backend::Backend + Send + Sync + 'static, - E: client::CallExecutor + Send + Sync + 'static + Clone, + B: sc_client_api::backend::Backend + Send + Sync + 'static, + E: sc_client::CallExecutor + Send + Sync + 'static + Clone, RA: Send + Sync + 'static, F: Send + Sync + 'static, { @@ -196,8 +196,8 @@ pub struct Chain { impl ChainApi, Block::Hash, Block::Header, SignedBlock> for Chain where Block: BlockT + 'static, - B: client_api::backend::Backend + Send + Sync + 'static, - E: client::CallExecutor + Send + Sync + 'static, + B: sc_client_api::backend::Backend + Send + Sync + 'static, + E: sc_client::CallExecutor + Send + Sync + 'static, RA: Send + Sync + 'static { type Metadata = crate::metadata::Metadata; @@ -256,8 +256,8 @@ fn subscribe_headers( stream: F, ) where Block: BlockT + 'static, - B: client_api::backend::Backend + Send + Sync + 'static, - E: client::CallExecutor + Send + Sync + 'static, + B: sc_client_api::backend::Backend + Send + Sync + 'static, + E: sc_client::CallExecutor + Send + Sync + 'static, F: FnOnce() -> S, G: FnOnce() -> Block::Hash, ERR: ::std::fmt::Debug, diff --git a/client/rpc/src/chain/tests.rs b/client/rpc/src/chain/tests.rs index 4f7c1f65cf..c07ea2044c 100644 --- a/client/rpc/src/chain/tests.rs +++ b/client/rpc/src/chain/tests.rs @@ -16,19 +16,19 @@ use super::*; use assert_matches::assert_matches; -use test_client::{ +use substrate_test_runtime_client::{ prelude::*, - consensus::BlockOrigin, + sp_consensus::BlockOrigin, runtime::{H256, Block, Header}, }; -use rpc_primitives::list::ListOrValue; +use sp_rpc::list::ListOrValue; #[test] fn should_return_header() { let core = ::tokio::runtime::Runtime::new().unwrap(); let remote = core.executor(); - let client = Arc::new(test_client::new()); + let client = Arc::new(substrate_test_runtime_client::new()); let api = new_full(client.clone(), Subscriptions::new(Arc::new(remote))); assert_matches!( @@ -64,7 +64,7 @@ fn should_return_a_block() { let core = ::tokio::runtime::Runtime::new().unwrap(); let remote = core.executor(); - let client = Arc::new(test_client::new()); + let client = Arc::new(substrate_test_runtime_client::new()); let api = new_full(client.clone(), Subscriptions::new(Arc::new(remote))); let block = client.new_block(Default::default()).unwrap().bake().unwrap(); @@ -116,7 +116,7 @@ fn should_return_block_hash() { let core = ::tokio::runtime::Runtime::new().unwrap(); let remote = core.executor(); - let client = Arc::new(test_client::new()); + let client = Arc::new(substrate_test_runtime_client::new()); let api = new_full(client.clone(), Subscriptions::new(Arc::new(remote))); assert_matches!( @@ -147,7 +147,7 @@ fn should_return_block_hash() { Ok(ListOrValue::Value(Some(ref x))) if x == &block.hash() ); assert_matches!( - api.block_hash(Some(ListOrValue::Value(primitives::U256::from(1u64).into())).into()), + api.block_hash(Some(ListOrValue::Value(sp_core::U256::from(1u64).into())).into()), Ok(ListOrValue::Value(Some(ref x))) if x == &block.hash() ); @@ -163,7 +163,7 @@ fn should_return_finalized_hash() { let core = ::tokio::runtime::Runtime::new().unwrap(); let remote = core.executor(); - let client = Arc::new(test_client::new()); + let client = Arc::new(substrate_test_runtime_client::new()); let api = new_full(client.clone(), Subscriptions::new(Arc::new(remote))); assert_matches!( @@ -195,7 +195,7 @@ fn should_notify_about_latest_block() { let (subscriber, id, transport) = Subscriber::new_test("test"); { - let client = Arc::new(test_client::new()); + let client = Arc::new(substrate_test_runtime_client::new()); let api = new_full(client.clone(), Subscriptions::new(Arc::new(remote))); api.subscribe_new_heads(Default::default(), subscriber); @@ -224,7 +224,7 @@ fn should_notify_about_finalized_block() { let (subscriber, id, transport) = Subscriber::new_test("test"); { - let client = Arc::new(test_client::new()); + let client = Arc::new(substrate_test_runtime_client::new()); let api = new_full(client.clone(), Subscriptions::new(Arc::new(remote))); api.subscribe_finalized_heads(Default::default(), subscriber); diff --git a/client/rpc/src/lib.rs b/client/rpc/src/lib.rs index 1341acb63d..748a78f131 100644 --- a/client/rpc/src/lib.rs +++ b/client/rpc/src/lib.rs @@ -22,7 +22,7 @@ mod metadata; -pub use api::Subscriptions; +pub use sc_rpc_api::Subscriptions; pub use self::metadata::Metadata; pub use rpc::IoHandlerExtension as RpcExtension; diff --git a/client/rpc/src/state/mod.rs b/client/rpc/src/state/mod.rs index 53aabaf699..f0dce85932 100644 --- a/client/rpc/src/state/mod.rs +++ b/client/rpc/src/state/mod.rs @@ -26,13 +26,13 @@ use std::sync::Arc; use jsonrpc_pubsub::{typed::Subscriber, SubscriptionId}; use rpc::{Result as RpcResult, futures::Future}; -use api::Subscriptions; -use client::{Client, CallExecutor, light::{blockchain::RemoteBlockchain, fetcher::Fetcher}}; -use primitives::{ +use sc_rpc_api::Subscriptions; +use sc_client::{Client, CallExecutor, light::{blockchain::RemoteBlockchain, fetcher::Fetcher}}; +use sp_core::{ Blake2Hasher, Bytes, H256, storage::{StorageKey, StorageData, StorageChangeSet}, }; -use runtime_version::RuntimeVersion; +use sp_version::RuntimeVersion; use sp_runtime::{ traits::{Block as BlockT, ProvideRuntimeApi}, }; @@ -41,14 +41,14 @@ use sp_api::Metadata; use self::error::{Error, FutureResult}; -pub use api::state::*; +pub use sc_rpc_api::state::*; /// State backend API. pub trait StateBackend: Send + Sync + 'static where Block: BlockT + 'static, - B: client_api::backend::Backend + Send + Sync + 'static, - E: client::CallExecutor + Send + Sync + 'static, + B: sc_client_api::backend::Backend + Send + Sync + 'static, + E: sc_client::CallExecutor + Send + Sync + 'static, RA: Send + Sync + 'static, { /// Call runtime method at given block. @@ -187,7 +187,7 @@ pub fn new_full( ) -> State where Block: BlockT + 'static, - B: client_api::backend::Backend + Send + Sync + 'static, + B: sc_client_api::backend::Backend + Send + Sync + 'static, E: CallExecutor + Send + Sync + 'static + Clone, RA: Send + Sync + 'static, Client: ProvideRuntimeApi, @@ -208,7 +208,7 @@ pub fn new_light>( ) -> State where Block: BlockT + 'static, - B: client_api::backend::Backend + Send + Sync + 'static, + B: sc_client_api::backend::Backend + Send + Sync + 'static, E: CallExecutor + Send + Sync + 'static + Clone, RA: Send + Sync + 'static, F: Send + Sync + 'static, @@ -231,7 +231,7 @@ pub struct State { impl StateApi for State where Block: BlockT + 'static, - B: client_api::backend::Backend + Send + Sync + 'static, + B: sc_client_api::backend::Backend + Send + Sync + 'static, E: CallExecutor + Send + Sync + 'static + Clone, RA: Send + Sync + 'static, { diff --git a/client/rpc/src/state/state_full.rs b/client/rpc/src/state/state_full.rs index d5de8d6441..05bb64c36f 100644 --- a/client/rpc/src/state/state_full.rs +++ b/client/rpc/src/state/state_full.rs @@ -27,20 +27,20 @@ use rpc::{ futures::{stream, Future, Sink, Stream, future::result}, }; -use api::Subscriptions; -use client_api::backend::Backend; +use sc_rpc_api::Subscriptions; +use sc_client_api::backend::Backend; use sp_blockchain::{ Result as ClientResult, Error as ClientError, HeaderMetadata, CachedHeaderMetadata }; -use client::{ - Client, CallExecutor, BlockchainEvents, +use sc_client::{ + Client, CallExecutor, BlockchainEvents, }; -use primitives::{ +use sp_core::{ H256, Blake2Hasher, Bytes, storage::{well_known_keys, StorageKey, StorageData, StorageChangeSet, ChildInfo}, }; -use runtime_version::RuntimeVersion; -use state_machine::ExecutionStrategy; +use sp_version::RuntimeVersion; +use sp_state_machine::ExecutionStrategy; use sp_runtime::{ generic::BlockId, traits::{Block as BlockT, NumberFor, ProvideRuntimeApi, SaturatedConversion}, diff --git a/client/rpc/src/state/state_light.rs b/client/rpc/src/state/state_light.rs index d90ef02c3d..a00ce72945 100644 --- a/client/rpc/src/state/state_light.rs +++ b/client/rpc/src/state/state_light.rs @@ -38,21 +38,21 @@ use rpc::{ futures::stream::Stream, }; -use api::Subscriptions; -use client_api::backend::Backend; +use sc_rpc_api::Subscriptions; +use sc_client_api::backend::Backend; use sp_blockchain::Error as ClientError; -use client::{ +use sc_client::{ BlockchainEvents, Client, CallExecutor, light::{ blockchain::{future_header, RemoteBlockchain}, fetcher::{Fetcher, RemoteCallRequest, RemoteReadRequest, RemoteReadChildRequest}, }, }; -use primitives::{ +use sp_core::{ H256, Blake2Hasher, Bytes, OpaqueMetadata, storage::{StorageKey, StorageData, StorageChangeSet}, }; -use runtime_version::RuntimeVersion; +use sp_version::RuntimeVersion; use sp_runtime::{ generic::BlockId, traits::Block as BlockT, @@ -711,7 +711,7 @@ fn ignore_error(future: F) -> impl std::future::Future>>(sync: T) -> System { let _ = sender.send(peers); } Request::NetworkState(sender) => { - let _ = sender.send(serde_json::to_value(&network::NetworkState { + let _ = sender.send(serde_json::to_value(&sc_network::NetworkState { peer_id: String::new(), listened_addresses: Default::default(), external_addresses: Default::default(), @@ -211,8 +211,8 @@ fn system_peers() { fn system_network_state() { let res = wait_receiver(api(None).system_network_state()); assert_eq!( - serde_json::from_value::(res).unwrap(), - network::NetworkState { + serde_json::from_value::(res).unwrap(), + sc_network::NetworkState { peer_id: String::new(), listened_addresses: Default::default(), external_addresses: Default::default(), diff --git a/client/service/Cargo.toml b/client/service/Cargo.toml index fe01818d20..39b2fb2676 100644 --- a/client/service/Cargo.toml +++ b/client/service/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" default = ["rocksdb"] # The RocksDB feature activates the RocksDB database backend. If it is not activated, and you pass # a path to a database, an error will be produced at runtime. -rocksdb = ["client_db/kvdb-rocksdb"] +rocksdb = ["sc-client-db/kvdb-rocksdb"] wasmtime = [ "sc-executor/wasmtime", ] @@ -28,36 +28,36 @@ serde = "1.0.101" serde_json = "1.0.41" sysinfo = "0.9.5" target_info = "0.1.0" -keystore = { package = "sc-keystore", path = "../keystore" } +sc-keystore = { path = "../keystore" } sp-io = { path = "../../primitives/io" } sp-runtime = { path = "../../primitives/runtime" } sp-blockchain = { path = "../../primitives/blockchain" } -primitives = { package = "sp-core", path = "../../primitives/core" } -session = { package = "sp-session", path = "../../primitives/session" } -app-crypto = { package = "sp-application-crypto", path = "../../primitives/application-crypto" } -consensus_common = { package = "sp-consensus", path = "../../primitives/consensus/common" } -network = { package = "sc-network", path = "../network" } -chain-spec = { package = "sc-chain-spec", path = "../chain-spec" } -client-api = { package = "sc-client-api", path = "../api" } -client = { package = "sc-client", path = "../" } +sp-core = { path = "../../primitives/core" } +sp-session = { path = "../../primitives/session" } +sp-application-crypto = { path = "../../primitives/application-crypto" } +sp-consensus = { path = "../../primitives/consensus/common" } +sc-network = { path = "../network" } +sc-chain-spec = { path = "../chain-spec" } +sc-client-api = { path = "../api" } +sc-client = { path = "../" } sp-api = { path = "../../primitives/api" } -client_db = { package = "sc-client-db", path = "../db" } +sc-client-db = { path = "../db" } codec = { package = "parity-scale-codec", version = "1.0.0" } sc-executor = { path = "../executor" } -txpool = { package = "sc-transaction-pool", path = "../transaction-pool" } -sp-transaction-pool = { package = "sp-transaction-pool", path = "../../primitives/transaction-pool" } -rpc-servers = { package = "sc-rpc-server", path = "../rpc-servers" } -rpc = { package = "sc-rpc", path = "../rpc" } -tel = { package = "sc-telemetry", path = "../telemetry" } -offchain = { package = "sc-offchain", path = "../offchain" } +sc-transaction-pool = { path = "../transaction-pool" } +sp-transaction-pool = { path = "../../primitives/transaction-pool" } +sc-rpc-server = { path = "../rpc-servers" } +sc-rpc = { path = "../rpc" } +sc-telemetry = { path = "../telemetry" } +sc-offchain = { path = "../offchain" } parity-multiaddr = { package = "parity-multiaddr", version = "0.5.0" } grafana-data-source = { path = "../../utils/grafana-data-source" } -sc-tracing = { package = "sc-tracing", path = "../tracing" } +sc-tracing = { path = "../tracing" } tracing = "0.1.10" [dev-dependencies] substrate-test-runtime-client = { path = "../../test-utils/runtime/client" } -babe-primitives = { package = "sp-consensus-babe", path = "../../primitives/consensus/babe" } +sp-consensus-babe = { path = "../../primitives/consensus/babe" } grandpa = { package = "sc-finality-grandpa", path = "../finality-grandpa" } grandpa-primitives = { package = "sp-finality-grandpa", path = "../../primitives/finality-grandpa" } tokio = "0.1" diff --git a/client/service/src/builder.rs b/client/service/src/builder.rs index 526983974a..713b873ff9 100644 --- a/client/service/src/builder.rs +++ b/client/service/src/builder.rs @@ -18,14 +18,14 @@ use crate::{Service, NetworkStatus, NetworkState, error::Error, DEFAULT_PROTOCOL use crate::{SpawnTaskHandle, start_rpc_servers, build_network_future, TransactionPoolAdapter}; use crate::status_sinks; use crate::config::{Configuration, DatabaseConfig}; -use client_api::{ +use sc_client_api::{ self, BlockchainEvents, backend::RemoteBackend, light::RemoteBlockchain, }; -use client::Client; -use chain_spec::{RuntimeGenesis, Extension}; -use consensus_common::import_queue::ImportQueue; +use sc_client::Client; +use sc_chain_spec::{RuntimeGenesis, Extension}; +use sp_consensus::import_queue::ImportQueue; use futures::{prelude::*, sync::mpsc}; use futures03::{ compat::Compat, @@ -33,13 +33,13 @@ use futures03::{ StreamExt as _, TryStreamExt as _, future::{select, Either} }; -use keystore::{Store as Keystore}; +use sc_keystore::{Store as Keystore}; use log::{info, warn, error}; -use network::{FinalityProofProvider, OnDemand, NetworkService, NetworkStateInfo, DhtEvent}; -use network::{config::BoxFinalityProofRequestBuilder, specialization::NetworkSpecialization}; +use sc_network::{FinalityProofProvider, OnDemand, NetworkService, NetworkStateInfo, DhtEvent}; +use sc_network::{config::BoxFinalityProofRequestBuilder, specialization::NetworkSpecialization}; use parking_lot::{Mutex, RwLock}; -use primitives::{Blake2Hasher, H256, Hasher}; -use rpc; +use sp_core::{Blake2Hasher, H256, Hasher}; +use sc_rpc; use sp_api::ConstructRuntimeApi; use sp_runtime::generic::BlockId; use sp_runtime::traits::{ @@ -51,7 +51,7 @@ use std::{ marker::PhantomData, sync::Arc, time::SystemTime }; use sysinfo::{get_current_pid, ProcessExt, System, SystemExt}; -use tel::{telemetry, SUBSTRATE_INFO}; +use sc_telemetry::{telemetry, SUBSTRATE_INFO}; use sp_transaction_pool::{TransactionPool, TransactionPoolMaintainer}; use sp_blockchain; use grafana_data_source::{self, record_metrics}; @@ -103,11 +103,11 @@ type TFullClient = Client< >; /// Full client backend type. -type TFullBackend = client_db::Backend; +type TFullBackend = sc_client_db::Backend; /// Full client call executor type. -type TFullCallExecutor = client::LocalCallExecutor< - client_db::Backend, +type TFullCallExecutor = sc_client::LocalCallExecutor< + sc_client_db::Backend, NativeExecutor, >; @@ -120,20 +120,20 @@ type TLightClient = Client< >; /// Light client backend type. -type TLightBackend = client::light::backend::Backend< - client_db::light::LightStorage, +type TLightBackend = sc_client::light::backend::Backend< + sc_client_db::light::LightStorage, Blake2Hasher, >; /// Light call executor type. -type TLightCallExecutor = client::light::call_executor::GenesisCallExecutor< - client::light::backend::Backend< - client_db::light::LightStorage, +type TLightCallExecutor = sc_client::light::call_executor::GenesisCallExecutor< + sc_client::light::backend::Backend< + sc_client_db::light::LightStorage, Blake2Hasher >, - client::LocalCallExecutor< - client::light::backend::Backend< - client_db::light::LightStorage, + sc_client::LocalCallExecutor< + sc_client::light::backend::Backend< + sc_client_db::light::LightStorage, Blake2Hasher >, NativeExecutor @@ -174,33 +174,33 @@ where TGen: RuntimeGenesis, TCSExt: Extension { let fork_blocks = config.chain_spec .extensions() - .get::>() + .get::>() .cloned() .unwrap_or_default(); let (client, backend) = { - let db_config = client_db::DatabaseSettings { + let db_config = sc_client_db::DatabaseSettings { state_cache_size: config.state_cache_size, state_cache_child_ratio: config.state_cache_child_ratio.map(|v| (v, 100)), pruning: config.pruning.clone(), source: match &config.database { DatabaseConfig::Path { path, cache_size } => - client_db::DatabaseSettingsSrc::Path { + sc_client_db::DatabaseSettingsSrc::Path { path: path.clone(), cache_size: cache_size.clone().map(|u| u as usize), }, DatabaseConfig::Custom(db) => - client_db::DatabaseSettingsSrc::Custom(db.clone()), + sc_client_db::DatabaseSettingsSrc::Custom(db.clone()), }, }; - let extensions = client_api::execution_extensions::ExecutionExtensions::new( + let extensions = sc_client_api::execution_extensions::ExecutionExtensions::new( config.execution_strategies.clone(), Some(keystore.clone()), ); - client_db::new_client( + sc_client_db::new_client( db_config, executor, &config.chain_spec, @@ -261,29 +261,29 @@ where TGen: RuntimeGenesis, TCSExt: Extension { ); let db_storage = { - let db_settings = client_db::DatabaseSettings { + let db_settings = sc_client_db::DatabaseSettings { state_cache_size: config.state_cache_size, state_cache_child_ratio: config.state_cache_child_ratio.map(|v| (v, 100)), pruning: config.pruning.clone(), source: match &config.database { DatabaseConfig::Path { path, cache_size } => - client_db::DatabaseSettingsSrc::Path { + sc_client_db::DatabaseSettingsSrc::Path { path: path.clone(), cache_size: cache_size.clone().map(|u| u as usize), }, DatabaseConfig::Custom(db) => - client_db::DatabaseSettingsSrc::Custom(db.clone()), + sc_client_db::DatabaseSettingsSrc::Custom(db.clone()), }, }; - client_db::light::LightStorage::new(db_settings)? + sc_client_db::light::LightStorage::new(db_settings)? }; - let light_blockchain = client::light::new_light_blockchain(db_storage); - let fetch_checker = Arc::new(client::light::new_fetch_checker(light_blockchain.clone(), executor.clone())); - let fetcher = Arc::new(network::OnDemand::new(fetch_checker)); - let backend = client::light::new_light_backend(light_blockchain); + let light_blockchain = sc_client::light::new_light_blockchain(db_storage); + let fetch_checker = Arc::new(sc_client::light::new_fetch_checker(light_blockchain.clone(), executor.clone())); + let fetcher = Arc::new(sc_network::OnDemand::new(fetch_checker)); + let backend = sc_client::light::new_light_backend(light_blockchain); let remote_blockchain = backend.remote_blockchain(); - let client = Arc::new(client::light::new_light( + let client = Arc::new(sc_client::light::new_light( backend.clone(), &config.chain_spec, executor, @@ -559,7 +559,7 @@ impl( self, transaction_pool_builder: impl FnOnce( - txpool::txpool::Options, + sc_transaction_pool::txpool::Options, Arc, Option, ) -> Result @@ -713,24 +713,24 @@ ServiceBuilder< Client: ProvideRuntimeApi, as ProvideRuntimeApi>::Api: sp_api::Metadata + - offchain::OffchainWorkerApi + + sc_offchain::OffchainWorkerApi + sp_transaction_pool::runtime_api::TaggedTransactionQueue + - session::SessionKeys + + sp_session::SessionKeys + sp_api::ApiExt, TBl: BlockT::Out>, TRtApi: ConstructRuntimeApi> + 'static + Send + Sync, TCfg: Default, TGen: RuntimeGenesis, TCSExt: Extension, - TBackend: 'static + client_api::backend::Backend + Send, - TExec: 'static + client::CallExecutor + Send + Sync + Clone, + TBackend: 'static + sc_client_api::backend::Backend + Send, + TExec: 'static + sc_client::CallExecutor + Send + Sync + Clone, TSc: Clone, TImpQu: 'static + ImportQueue, TNetP: NetworkSpecialization, TExPool: 'static + TransactionPool::Hash> + TransactionPoolMaintainer::Hash>, - TRpc: rpc::RpcExtension + Clone, + TRpc: sc_rpc::RpcExtension + Clone, { /// Builds the service. pub fn build(self) -> Result, NetworkService::Hash>, TExPool, - offchain::OffchainWorkers< + sc_offchain::OffchainWorkers< Client, TBackend::OffchainStorage, TBl @@ -764,7 +764,7 @@ ServiceBuilder< dht_event_tx, } = self; - session::generate_initial_session_keys( + sp_session::generate_initial_session_keys( client.clone(), &BlockId::Hash(client.info().chain.best_hash), config.dev_key_seed.clone().map(|s| vec![s]).unwrap_or_default(), @@ -812,13 +812,13 @@ ServiceBuilder< DEFAULT_PROTOCOL_ID } }.as_bytes(); - network::config::ProtocolId::from(protocol_id_full) + sc_network::config::ProtocolId::from(protocol_id_full) }; let block_announce_validator = - Box::new(consensus_common::block_validation::DefaultBlockAnnounceValidator::new(client.clone())); + Box::new(sp_consensus::block_validation::DefaultBlockAnnounceValidator::new(client.clone())); - let network_params = network::config::Params { + let network_params = sc_network::config::Params { roles: config.roles, network_config: config.network.clone(), chain: client.clone(), @@ -833,14 +833,14 @@ ServiceBuilder< }; let has_bootnodes = !network_params.network_config.boot_nodes.is_empty(); - let network_mut = network::NetworkWorker::new(network_params)?; + let network_mut = sc_network::NetworkWorker::new(network_params)?; let network = network_mut.service().clone(); let network_status_sinks = Arc::new(Mutex::new(status_sinks::StatusSinks::new())); let offchain_storage = backend.offchain_storage(); let offchain_workers = match (config.offchain_worker, offchain_storage) { (true, Some(db)) => { - Some(Arc::new(offchain::OffchainWorkers::new(client.clone(), db))) + Some(Arc::new(sc_offchain::OffchainWorkers::new(client.clone(), db))) }, (true, None) => { log::warn!("Offchain workers disabled, due to lack of offchain storage support in backend."); @@ -986,16 +986,16 @@ ServiceBuilder< // RPC let (system_rpc_tx, system_rpc_rx) = futures03::channel::mpsc::unbounded(); let gen_handler = || { - use rpc::{chain, state, author, system}; + use sc_rpc::{chain, state, author, system}; - let system_info = rpc::system::SystemInfo { + let system_info = sc_rpc::system::SystemInfo { chain_name: config.chain_spec.name().into(), impl_name: config.impl_name.into(), impl_version: config.impl_version.into(), properties: config.chain_spec.properties().clone(), }; - let subscriptions = rpc::Subscriptions::new(Arc::new(SpawnTaskHandle { + let subscriptions = sc_rpc::Subscriptions::new(Arc::new(SpawnTaskHandle { sender: to_spawn_tx.clone(), on_exit: exit.clone() })); @@ -1003,13 +1003,13 @@ ServiceBuilder< let (chain, state) = if let (Some(remote_backend), Some(on_demand)) = (remote_backend.as_ref(), on_demand.as_ref()) { // Light clients - let chain = rpc::chain::new_light( + let chain = sc_rpc::chain::new_light( client.clone(), subscriptions.clone(), remote_backend.clone(), on_demand.clone() ); - let state = rpc::state::new_light( + let state = sc_rpc::state::new_light( client.clone(), subscriptions.clone(), remote_backend.clone(), @@ -1019,12 +1019,12 @@ ServiceBuilder< } else { // Full nodes - let chain = rpc::chain::new_full(client.clone(), subscriptions.clone()); - let state = rpc::state::new_full(client.clone(), subscriptions.clone()); + let chain = sc_rpc::chain::new_full(client.clone(), subscriptions.clone()); + let state = sc_rpc::state::new_full(client.clone(), subscriptions.clone()); (chain, state) }; - let author = rpc::author::Author::new( + let author = sc_rpc::author::Author::new( client.clone(), transaction_pool.clone(), subscriptions, @@ -1032,7 +1032,7 @@ ServiceBuilder< ); let system = system::System::new(system_info, system_rpc_tx.clone()); - rpc_servers::rpc_handler(( + sc_rpc_server::rpc_handler(( state::StateApi::to_delegate(state), chain::ChainApi::to_delegate(chain), author::AuthorApi::to_delegate(author), @@ -1068,7 +1068,7 @@ ServiceBuilder< let version = version.clone(); let chain_name = config.chain_spec.name().to_owned(); let telemetry_connection_sinks_ = telemetry_connection_sinks.clone(); - let telemetry = tel::init_telemetry(tel::TelemetryConfig { + let telemetry = sc_telemetry::init_telemetry(sc_telemetry::TelemetryConfig { endpoints, wasm_external_transport: config.telemetry_external_transport.take(), }); @@ -1080,7 +1080,7 @@ ServiceBuilder< .compat() .for_each(move |event| { // Safe-guard in case we add more events in the future. - let tel::TelemetryEvent::Connected = event; + let sc_telemetry::TelemetryEvent::Connected = event; telemetry!(SUBSTRATE_INFO; "system.connected"; "name" => name.clone(), diff --git a/client/service/src/chain_ops.rs b/client/service/src/chain_ops.rs index 742167069a..fb62cd3399 100644 --- a/client/service/src/chain_ops.rs +++ b/client/service/src/chain_ops.rs @@ -19,27 +19,27 @@ use crate::error; use crate::builder::{ServiceBuilderCommand, ServiceBuilder}; use crate::error::Error; -use chain_spec::{ChainSpec, RuntimeGenesis, Extension}; +use sc_chain_spec::{ChainSpec, RuntimeGenesis, Extension}; use log::{warn, info}; use futures::{future, prelude::*}; use futures03::{ TryFutureExt as _, }; -use primitives::{Blake2Hasher, Hasher}; +use sp_core::{Blake2Hasher, Hasher}; use sp_runtime::traits::{ Block as BlockT, NumberFor, One, Zero, Header, SaturatedConversion }; use sp_runtime::generic::{BlockId, SignedBlock}; use codec::{Decode, Encode, IoReader}; -use client::Client; -use consensus_common::import_queue::{IncomingBlock, Link, BlockImportError, BlockImportResult, ImportQueue}; -use consensus_common::BlockOrigin; +use sc_client::Client; +use sp_consensus::import_queue::{IncomingBlock, Link, BlockImportError, BlockImportResult, ImportQueue}; +use sp_consensus::BlockOrigin; use std::{ io::{Read, Write, Seek}, }; -use network::message; +use sc_network::message; /// Build a chain spec json pub fn build_spec(spec: ChainSpec, raw: bool) -> error::Result where @@ -58,8 +58,8 @@ impl< TFchr, TSc, TImpQu, TFprb, TFpp, TNetP, TExPool, TRpc, Backend > where TBl: BlockT::Out>, - TBackend: 'static + client_api::backend::Backend + Send, - TExec: 'static + client::CallExecutor + Send + Sync + Clone, + TBackend: 'static + sc_client_api::backend::Backend + Send, + TExec: 'static + sc_client::CallExecutor + Send + Sync + Clone, TImpQu: 'static + ImportQueue, TRtApi: 'static + Send + Sync, { diff --git a/client/service/src/config.rs b/client/service/src/config.rs index 310d185b4d..0b5152e248 100644 --- a/client/service/src/config.rs +++ b/client/service/src/config.rs @@ -16,17 +16,17 @@ //! Service configuration. -pub use client::ExecutionStrategies; -pub use client_db::{kvdb::KeyValueDB, PruningMode}; -pub use network::config::{ExtTransport, NetworkConfiguration, Roles}; +pub use sc_client::ExecutionStrategies; +pub use sc_client_db::{kvdb::KeyValueDB, PruningMode}; +pub use sc_network::config::{ExtTransport, NetworkConfiguration, Roles}; pub use sc_executor::WasmExecutionMethod; use std::{path::PathBuf, net::SocketAddr, sync::Arc}; -pub use txpool::txpool::Options as TransactionPoolOptions; -use chain_spec::{ChainSpec, RuntimeGenesis, Extension, NoExtension}; -use primitives::crypto::Protected; +pub use sc_transaction_pool::txpool::Options as TransactionPoolOptions; +use sc_chain_spec::{ChainSpec, RuntimeGenesis, Extension, NoExtension}; +use sp_core::crypto::Protected; use target_info::Target; -use tel::TelemetryEndpoints; +use sc_telemetry::TelemetryEndpoints; /// Service configuration. #[derive(Clone)] diff --git a/client/service/src/error.rs b/client/service/src/error.rs index cd2fce6bde..d1dc827a38 100644 --- a/client/service/src/error.rs +++ b/client/service/src/error.rs @@ -16,9 +16,9 @@ //! Errors that can occur during the service operation. -use network; -use keystore; -use consensus_common; +use sc_network; +use sc_keystore; +use sp_consensus; use sp_blockchain; /// Service Result typedef. @@ -32,11 +32,11 @@ pub enum Error { /// IO error. Io(std::io::Error), /// Consensus error. - Consensus(consensus_common::Error), + Consensus(sp_consensus::Error), /// Network error. - Network(network::error::Error), + Network(sc_network::error::Error), /// Keystore error. - Keystore(keystore::Error), + Keystore(sc_keystore::Error), /// Best chain selection strategy is missing. #[display(fmt="Best chain selection strategy (SelectChain) is not provided.")] SelectChainRequired, diff --git a/client/service/src/lib.rs b/client/service/src/lib.rs index de6077e12f..d23e2a988c 100644 --- a/client/service/src/lib.rs +++ b/client/service/src/lib.rs @@ -35,35 +35,35 @@ use std::time::{Duration, Instant}; use futures::sync::mpsc; use parking_lot::Mutex; -use client::Client; +use sc_client::Client; use exit_future::Signal; use futures::prelude::*; use futures03::{ future::{ready, FutureExt as _, TryFutureExt as _}, stream::{StreamExt as _, TryStreamExt as _}, }; -use network::{ +use sc_network::{ NetworkService, NetworkState, specialization::NetworkSpecialization, Event, DhtEvent, PeerId, ReportHandle, }; use log::{log, warn, debug, error, Level}; use codec::{Encode, Decode}; -use primitives::{Blake2Hasher, H256}; +use sp_core::{Blake2Hasher, H256}; use sp_runtime::generic::BlockId; use sp_runtime::traits::{NumberFor, Block as BlockT}; pub use self::error::Error; pub use self::builder::{ServiceBuilder, ServiceBuilderCommand}; pub use config::{Configuration, Roles, PruningMode}; -pub use chain_spec::{ChainSpec, Properties, RuntimeGenesis, Extension as ChainSpecExtension}; +pub use sc_chain_spec::{ChainSpec, Properties, RuntimeGenesis, Extension as ChainSpecExtension}; pub use sp_transaction_pool::{TransactionPool, TransactionPoolMaintainer, InPoolTransaction, error::IntoPoolError}; -pub use txpool::txpool::Options as TransactionPoolOptions; -pub use client::FinalityNotifications; -pub use rpc::Metadata as RpcMetadata; +pub use sc_transaction_pool::txpool::Options as TransactionPoolOptions; +pub use sc_client::FinalityNotifications; +pub use sc_rpc::Metadata as RpcMetadata; #[doc(hidden)] pub use std::{ops::Deref, result::Result, sync::Arc}; #[doc(hidden)] -pub use network::{FinalityProofProvider, OnDemand, config::BoxFinalityProofRequestBuilder}; +pub use sc_network::{FinalityProofProvider, OnDemand, config::BoxFinalityProofRequestBuilder}; #[doc(hidden)] pub use futures::future::Executor; @@ -96,12 +96,12 @@ pub struct Service { /// If spawning a background task is not possible, we instead push the task into this `Vec`. /// The elements must then be polled manually. to_poll: Vec + Send>>, - rpc_handlers: rpc_servers::RpcHandler, + rpc_handlers: sc_rpc_server::RpcHandler, _rpc: Box, - _telemetry: Option, + _telemetry: Option, _telemetry_on_connect_sinks: Arc>>>, _offchain_workers: Option>, - keystore: keystore::KeyStorePtr, + keystore: sc_keystore::KeyStorePtr, marker: PhantomData, } @@ -145,13 +145,13 @@ pub trait AbstractService: 'static + Future + /// Type of block of this chain. type Block: BlockT; /// Backend storage for the client. - type Backend: 'static + client_api::backend::Backend; + type Backend: 'static + sc_client_api::backend::Backend; /// How to execute calls towards the runtime. - type CallExecutor: 'static + client::CallExecutor + Send + Sync + Clone; + type CallExecutor: 'static + sc_client::CallExecutor + Send + Sync + Clone; /// API that the runtime provides. type RuntimeApi: Send + Sync; /// Chain selection algorithm. - type SelectChain: consensus_common::SelectChain; + type SelectChain: sp_consensus::SelectChain; /// Transaction pool. type TransactionPool: TransactionPool + TransactionPoolMaintainer; @@ -162,7 +162,7 @@ pub trait AbstractService: 'static + Future + fn telemetry_on_connect_stream(&self) -> mpsc::UnboundedReceiver<()>; /// return a shared instance of Telemetry (if enabled) - fn telemetry(&self) -> Option; + fn telemetry(&self) -> Option; /// Spawns a task in the background that runs the future passed as parameter. fn spawn_task(&self, task: impl Future + Send + 'static); @@ -176,7 +176,7 @@ pub trait AbstractService: 'static + Future + fn spawn_task_handle(&self) -> SpawnTaskHandle; /// Returns the keystore that stores keys. - fn keystore(&self) -> keystore::KeyStorePtr; + fn keystore(&self) -> sc_keystore::KeyStorePtr; /// Starts an RPC query. /// @@ -190,7 +190,7 @@ pub trait AbstractService: 'static + Future + fn rpc_query(&self, mem: &RpcSession, request: &str) -> Box, Error = ()> + Send>; /// Get shared client instance. - fn client(&self) -> Arc>; + fn client(&self) -> Arc>; /// Get clone of select chain. fn select_chain(&self) -> Option; @@ -213,10 +213,10 @@ impl AbstractService NetworkService, TExPool, TOc> where TBl: BlockT, - TBackend: 'static + client_api::backend::Backend, - TExec: 'static + client::CallExecutor + Send + Sync + Clone, + TBackend: 'static + sc_client_api::backend::Backend, + TExec: 'static + sc_client::CallExecutor + Send + Sync + Clone, TRtApi: 'static + Send + Sync, - TSc: consensus_common::SelectChain + 'static + Clone + Send, + TSc: sp_consensus::SelectChain + 'static + Clone + Send, TExPool: 'static + TransactionPool + TransactionPoolMaintainer, TOc: 'static + Send + Sync, @@ -236,11 +236,11 @@ where stream } - fn telemetry(&self) -> Option { + fn telemetry(&self) -> Option { self._telemetry.as_ref().map(|t| t.clone()) } - fn keystore(&self) -> keystore::KeyStorePtr { + fn keystore(&self) -> sc_keystore::KeyStorePtr { self.keystore.clone() } @@ -276,7 +276,7 @@ where Box::new(self.rpc_handlers.handle_request(request, mem.metadata.clone())) } - fn client(&self) -> Arc> { + fn client(&self) -> Arc> { self.client.clone() } @@ -362,15 +362,15 @@ impl Executor, - S: network::specialization::NetworkSpecialization, - H: network::ExHashT + C: sc_client::BlockchainEvents, + S: sc_network::specialization::NetworkSpecialization, + H: sc_network::ExHashT > ( roles: Roles, - mut network: network::NetworkWorker, + mut network: sc_network::NetworkWorker, client: Arc, status_sinks: Arc, NetworkState)>>>, - rpc_rx: futures03::channel::mpsc::UnboundedReceiver>, + rpc_rx: futures03::channel::mpsc::UnboundedReceiver>, should_have_peers: bool, dht_event_tx: Option>, ) -> impl Future { @@ -406,16 +406,16 @@ fn build_network_future< // Poll the RPC requests and answer them. while let Ok(Async::Ready(Some(request))) = rpc_rx.poll() { match request { - rpc::system::Request::Health(sender) => { - let _ = sender.send(rpc::system::Health { + sc_rpc::system::Request::Health(sender) => { + let _ = sender.send(sc_rpc::system::Health { peers: network.peers_debug_info().len(), is_syncing: network.service().is_major_syncing(), should_have_peers, }); }, - rpc::system::Request::Peers(sender) => { + sc_rpc::system::Request::Peers(sender) => { let _ = sender.send(network.peers_debug_info().into_iter().map(|(peer_id, p)| - rpc::system::PeerInfo { + sc_rpc::system::PeerInfo { peer_id: peer_id.to_base58(), roles: format!("{:?}", p.roles), protocol_version: p.protocol_version, @@ -424,13 +424,13 @@ fn build_network_future< } ).collect()); } - rpc::system::Request::NetworkState(sender) => { + sc_rpc::system::Request::NetworkState(sender) => { if let Some(network_state) = serde_json::to_value(&network.network_state()).ok() { let _ = sender.send(network_state); } } - rpc::system::Request::NodeRoles(sender) => { - use rpc::system::NodeRole; + sc_rpc::system::Request::NodeRoles(sender) => { + use sc_rpc::system::NodeRole; let node_roles = (0 .. 8) .filter(|&bit_number| (roles.bits() >> bit_number) & 1 == 1) @@ -506,7 +506,7 @@ fn build_network_future< #[derive(Clone)] pub struct NetworkStatus { /// Current global sync state. - pub sync_state: network::SyncState, + pub sync_state: sc_network::SyncState, /// Target sync block number. pub best_seen_block: Option>, /// Number of peers participating in syncing. @@ -534,7 +534,7 @@ impl Drop for /// Starts RPC servers that run in their own thread, and returns an opaque object that keeps them alive. #[cfg(not(target_os = "unknown"))] -fn start_rpc_servers rpc_servers::RpcHandler>( +fn start_rpc_servers sc_rpc_server::RpcHandler>( config: &Configuration, mut gen_handler: H ) -> Result, error::Error> { @@ -559,11 +559,11 @@ fn start_rpc_servers rpc_servers::RpcHandler rpc_servers::RpcHandler rpc_servers::RpcHandler>( +fn start_rpc_servers sc_rpc_server::RpcHandler>( _: &Configuration, _: H ) -> Result, error::Error> { @@ -586,7 +586,7 @@ fn start_rpc_servers rpc_servers::RpcHandler network::TransactionPool for +impl sc_network::TransactionPool for TransactionPoolAdapter where - C: network::ClientHandle + Send + Sync, + C: sc_network::ClientHandle + Send + Sync, Pool: 'static + TransactionPool, B: BlockT, H: std::hash::Hash + Eq + sp_runtime::traits::Member + sp_runtime::traits::MaybeSerialize, @@ -653,8 +653,8 @@ where &self, report_handle: ReportHandle, who: PeerId, - reputation_change_good: network::ReputationChange, - reputation_change_bad: network::ReputationChange, + reputation_change_good: sc_network::ReputationChange, + reputation_change_bad: sc_network::ReputationChange, transaction: B::Extrinsic ) { if !self.imports_external_transactions { @@ -701,10 +701,10 @@ where mod tests { use super::*; use futures03::executor::block_on; - use consensus_common::SelectChain; + use sp_consensus::SelectChain; use sp_runtime::traits::BlindCheckable; use substrate_test_runtime_client::{prelude::*, runtime::{Extrinsic, Transfer}}; - use txpool::{BasicPool, FullChainApi}; + use sc_transaction_pool::{BasicPool, FullChainApi}; #[test] fn should_not_propagate_transactions_that_are_marked_as_such() { diff --git a/client/service/test/Cargo.toml b/client/service/test/Cargo.toml index 0a85fe0f6d..aa0d4b5414 100644 --- a/client/service/test/Cargo.toml +++ b/client/service/test/Cargo.toml @@ -12,10 +12,10 @@ log = "0.4.8" env_logger = "0.7.0" fdlimit = "0.1.1" futures03 = { package = "futures", version = "0.3.1", features = ["compat"] } -service = { package = "sc-service", path = "../../service", default-features = false } -network = { package = "sc-network", path = "../../network" } -consensus = { package = "sp-consensus", path = "../../../primitives/consensus/common" } -client = { package = "sc-client", path = "../../" } +sc-service = { path = "../../service", default-features = false } +sc-network = { path = "../../network" } +sp-consensus = { path = "../../../primitives/consensus/common" } +sc-client = { path = "../../" } sp-runtime = { path = "../../../primitives/runtime" } -primitives = { package = "sp-core", path = "../../../primitives/core" } -txpool-api = { package = "sp-transaction-pool", path = "../../../primitives/transaction-pool" } +sp-core = { path = "../../../primitives/core" } +sp-transaction-pool = { path = "../../../primitives/transaction-pool" } diff --git a/client/service/test/src/lib.rs b/client/service/test/src/lib.rs index e3b46c7720..e1eb919a6f 100644 --- a/client/service/test/src/lib.rs +++ b/client/service/test/src/lib.rs @@ -25,7 +25,7 @@ use futures::{Future, Stream, Poll}; use tempfile::TempDir; use tokio::{runtime::Runtime, prelude::FutureExt}; use tokio::timer::Interval; -use service::{ +use sc_service::{ AbstractService, ChainSpec, Configuration, @@ -33,10 +33,10 @@ use service::{ Roles, Error, }; -use network::{multiaddr, Multiaddr}; -use network::config::{NetworkConfiguration, TransportConfig, NodeKeyConfig, Secret, NonReservedPeerMode}; +use sc_network::{multiaddr, Multiaddr}; +use sc_network::config::{NetworkConfiguration, TransportConfig, NodeKeyConfig, Secret, NonReservedPeerMode}; use sp_runtime::{generic::BlockId, traits::Block as BlockT}; -use txpool_api::TransactionPool; +use sp_transaction_pool::TransactionPool; /// Maximum duration of single wait call. const MAX_WAIT_TIME: Duration = Duration::from_secs(60 * 3); @@ -72,9 +72,9 @@ impl From for SyncService { } } -impl> Future for SyncService { +impl> Future for SyncService { type Item = (); - type Error = service::Error; + type Error = sc_service::Error; fn poll(&mut self) -> Poll { self.0.lock().unwrap().poll() @@ -186,7 +186,7 @@ fn node_config ( chain_spec: (*spec).clone(), custom: Default::default(), name: format!("Node {}", index), - wasm_method: service::config::WasmExecutionMethod::Interpreted, + wasm_method: sc_service::config::WasmExecutionMethod::Interpreted, execution_strategies: Default::default(), rpc_http: None, rpc_ws: None, diff --git a/client/src/call_executor.rs b/client/src/call_executor.rs index e069885047..3115c78103 100644 --- a/client/src/call_executor.rs +++ b/client/src/call_executor.rs @@ -19,19 +19,19 @@ use codec::{Encode, Decode}; use sp_runtime::{ generic::BlockId, traits::Block as BlockT, traits::NumberFor, }; -use state_machine::{ +use sp_state_machine::{ self, OverlayedChanges, Ext, ExecutionManager, StateMachine, ExecutionStrategy, backend::Backend as _, ChangesTrieTransaction, StorageProof, }; -use executor::{RuntimeVersion, RuntimeInfo, NativeVersion}; -use externalities::Extensions; +use sc_executor::{RuntimeVersion, RuntimeInfo, NativeVersion}; +use sp_externalities::Extensions; use hash_db::Hasher; -use primitives::{ +use sp_core::{ H256, Blake2Hasher, NativeOrEncoded, NeverNativeValue, traits::CodeExecutor, }; use sp_api::{ProofRecorder, InitializeBlock}; -use client_api::{backend, call_executor::CallExecutor}; +use sc_client_api::{backend, call_executor::CallExecutor}; /// Call executor that executes methods locally, querying all required /// data from local backend. @@ -138,11 +138,11 @@ impl CallExecutor for LocalCallExecutor Some(recorder) => { let trie_state = state.as_trie_backend() .ok_or_else(|| - Box::new(state_machine::ExecutionError::UnableToGenerateProof) - as Box + Box::new(sp_state_machine::ExecutionError::UnableToGenerateProof) + as Box )?; - let backend = state_machine::ProvingBackend::new_with_recorder( + let backend = sp_state_machine::ProvingBackend::new_with_recorder( trie_state, recorder.clone() ); @@ -206,7 +206,7 @@ impl CallExecutor for LocalCallExecutor } fn call_at_state< - S: state_machine::Backend, + S: sp_state_machine::Backend, F: FnOnce( Result, Self::Error>, Result, Self::Error>, @@ -247,14 +247,14 @@ impl CallExecutor for LocalCallExecutor .map_err(Into::into) } - fn prove_at_trie_state>( + fn prove_at_trie_state>( &self, - trie_state: &state_machine::TrieBackend, + trie_state: &sp_state_machine::TrieBackend, overlay: &mut OverlayedChanges, method: &str, call_data: &[u8] ) -> Result<(Vec, StorageProof), sp_blockchain::Error> { - state_machine::prove_execution_on_trie_backend( + sp_state_machine::prove_execution_on_trie_backend( trie_state, overlay, &self.executor, @@ -269,20 +269,20 @@ impl CallExecutor for LocalCallExecutor } } -impl runtime_version::GetRuntimeVersion for LocalCallExecutor +impl sp_version::GetRuntimeVersion for LocalCallExecutor where B: backend::Backend, E: CodeExecutor + RuntimeInfo, Block: BlockT, { - fn native_version(&self) -> &runtime_version::NativeVersion { + fn native_version(&self) -> &sp_version::NativeVersion { self.executor.native_version() } fn runtime_version( &self, at: &BlockId, - ) -> Result { + ) -> Result { CallExecutor::runtime_version(self, at).map_err(|e| format!("{:?}", e)) } } diff --git a/client/src/cht.rs b/client/src/cht.rs index 389560223a..7eeea10bb3 100644 --- a/client/src/cht.rs +++ b/client/src/cht.rs @@ -25,12 +25,12 @@ use hash_db; use codec::Encode; -use trie; +use sp_trie; -use primitives::{H256, convert_hash}; +use sp_core::{H256, convert_hash}; use sp_runtime::traits::{Header as HeaderT, SimpleArithmetic, Zero, One}; -use state_machine::backend::InMemory as InMemoryState; -use state_machine::{MemoryDB, TrieBackend, Backend as StateBackend, StorageProof, +use sp_state_machine::backend::InMemory as InMemoryState; +use sp_state_machine::{MemoryDB, TrieBackend, Backend as StateBackend, StorageProof, prove_read_on_trie_backend, read_proof_check, read_proof_check_on_proving_backend}; use sp_blockchain::{Error as ClientError, Result as ClientResult}; @@ -76,8 +76,8 @@ pub fn compute_root( Hasher::Out: Ord, I: IntoIterator>>, { - use trie::TrieConfiguration; - Ok(trie::trie_types::Layout::::trie_root( + use sp_trie::TrieConfiguration; + Ok(sp_trie::trie_types::Layout::::trie_root( build_pairs::(cht_size, cht_num, hashes)? )) } @@ -317,8 +317,8 @@ pub fn decode_cht_value(value: &[u8]) -> Option { #[cfg(test)] mod tests { - use primitives::{Blake2Hasher}; - use test_client::runtime::Header; + use sp_core::{Blake2Hasher}; + use substrate_test_runtime_client::runtime::Header; use super::*; #[test] diff --git a/client/src/client.rs b/client/src/client.rs index fe3dfbead3..a0fc940d24 100644 --- a/client/src/client.rs +++ b/client/src/client.rs @@ -25,7 +25,7 @@ use futures::channel::mpsc; use parking_lot::{Mutex, RwLock}; use codec::{Encode, Decode}; use hash_db::{Hasher, Prefix}; -use primitives::{ +use sp_core::{ Blake2Hasher, H256, ChangesTrieConfiguration, convert_hash, NeverNativeValue, ExecutionContext, NativeOrEncoded, storage::{StorageKey, StorageData, well_known_keys, ChildInfo}, @@ -40,14 +40,14 @@ use sp_runtime::{ ApiRef, ProvideRuntimeApi, SaturatedConversion, One, DigestFor, }, }; -use state_machine::{ +use sp_state_machine::{ DBValue, Backend as StateBackend, ChangesTrieAnchorBlockId, ExecutionStrategy, ExecutionManager, prove_read, prove_child_read, ChangesTrieRootsStorage, ChangesTrieStorage, ChangesTrieTransaction, ChangesTrieConfigurationRange, key_changes, key_changes_proof, OverlayedChanges, BackendTrustLevel, StorageProof, merge_storage_proofs, }; -use executor::{RuntimeVersion, RuntimeInfo}; -use consensus::{ +use sc_executor::{RuntimeVersion, RuntimeInfo}; +use sp_consensus::{ Error as ConsensusError, BlockStatus, BlockImportParams, BlockCheckParams, ImportResult, BlockOrigin, ForkChoiceStrategy, SelectChain, self, @@ -60,9 +60,9 @@ use sp_blockchain::{self as blockchain, }; use sp_api::{CallRuntimeAt, ConstructRuntimeApi, Core as CoreApi, ProofRecorder, InitializeBlock}; -use block_builder::BlockBuilderApi; +use sc_block_builder::BlockBuilderApi; -pub use client_api::{ +pub use sc_client_api::{ backend::{ self, BlockImportOperation, PrunableStateChangesTrieStorage, ClientImportOperation, Finalizer, ImportSummary, NewBlockState, @@ -88,7 +88,7 @@ type StorageUpdate = < < >::BlockImportOperation as BlockImportOperation - >::State as state_machine::Backend>::Transaction; + >::State as sp_state_machine::Backend>::Transaction; type ChangesUpdate = ChangesTrieTransaction>; /// Substrate Client @@ -144,7 +144,7 @@ impl PrePostHeader { pub fn new_in_mem( executor: E, genesis_storage: S, - keystore: Option, + keystore: Option, ) -> sp_blockchain::Result, LocalCallExecutor, E>, @@ -164,7 +164,7 @@ pub fn new_with_backend( backend: Arc, executor: E, build_genesis_storage: S, - keystore: Option, + keystore: Option, ) -> sp_blockchain::Result, Block, RA>> where E: CodeExecutor + RuntimeInfo, @@ -525,7 +525,7 @@ impl Client where } impl<'a, Block: BlockT> ChangesTrieStorage> for AccessedRootsRecorder<'a, Block> { - fn as_roots_storage(&self) -> &dyn state_machine::ChangesTrieRootsStorage> { + fn as_roots_storage(&self) -> &dyn sp_state_machine::ChangesTrieRootsStorage> { self } @@ -649,14 +649,14 @@ impl Client where pub fn new_block( &self, inherent_digests: DigestFor, - ) -> sp_blockchain::Result> where + ) -> sp_blockchain::Result> where E: Clone + Send + Sync, RA: Send + Sync, Self: ProvideRuntimeApi, ::Api: BlockBuilderApi { let info = self.info(); - block_builder::BlockBuilder::new( + sc_block_builder::BlockBuilder::new( self, info.chain.best_hash, info.chain.best_number, @@ -670,13 +670,13 @@ impl Client where &self, parent: &BlockId, inherent_digests: DigestFor, - ) -> sp_blockchain::Result> where + ) -> sp_blockchain::Result> where E: Clone + Send + Sync, RA: Send + Sync, Self: ProvideRuntimeApi, ::Api: BlockBuilderApi { - block_builder::BlockBuilder::new( + sc_block_builder::BlockBuilder::new( self, self.expect_block_hash_from_id(parent)?, self.expect_block_number_from_id(parent)?, @@ -694,13 +694,13 @@ impl Client where &self, parent: &BlockId, inherent_digests: DigestFor, - ) -> sp_blockchain::Result> where + ) -> sp_blockchain::Result> where E: Clone + Send + Sync, RA: Send + Sync, Self: ProvideRuntimeApi, ::Api: BlockBuilderApi { - block_builder::BlockBuilder::new( + sc_block_builder::BlockBuilder::new( self, self.expect_block_hash_from_id(parent)?, self.expect_block_number_from_id(parent)?, @@ -1432,7 +1432,7 @@ impl CallRuntimeAt for Client where /// NOTE: only use this implementation when you are sure there are NO consensus-level BlockImport /// objects. Otherwise, importing blocks directly into the client would be bypassing /// important verification work. -impl<'a, B, E, Block, RA> consensus::BlockImport for &'a Client where +impl<'a, B, E, Block, RA> sp_consensus::BlockImport for &'a Client where B: backend::Backend, E: CallExecutor + Clone + Send + Sync, Block: BlockT, @@ -1507,7 +1507,7 @@ impl<'a, B, E, Block, RA> consensus::BlockImport for &'a Client consensus::BlockImport for Client where +impl sp_consensus::BlockImport for Client where B: backend::Backend, E: CallExecutor + Clone + Send + Sync, Block: BlockT, @@ -1758,7 +1758,7 @@ where ) } -impl consensus::block_validation::Chain for Client +impl sp_consensus::block_validation::Chain for Client where BE: backend::Backend, E: CallExecutor, @@ -1773,13 +1773,13 @@ impl consensus::block_validation::Chain for Client ( - test_client::client::Client, + substrate_test_runtime_client::sc_client::Client, Vec, Vec<(u64, u64, Vec, Vec<(u64, u32)>)>, ) { @@ -1858,7 +1858,7 @@ pub(crate) mod tests { #[test] fn client_initializes_from_genesis_ok() { - let client = test_client::new(); + let client = substrate_test_runtime_client::new(); assert_eq!( client.runtime_api().balance_of( @@ -1878,7 +1878,7 @@ pub(crate) mod tests { #[test] fn block_builder_works_with_no_transactions() { - let client = test_client::new(); + let client = substrate_test_runtime_client::new(); let builder = client.new_block(Default::default()).unwrap(); @@ -1889,7 +1889,7 @@ pub(crate) mod tests { #[test] fn block_builder_works_with_transactions() { - let client = test_client::new(); + let client = substrate_test_runtime_client::new(); let mut builder = client.new_block(Default::default()).unwrap(); @@ -1925,7 +1925,7 @@ pub(crate) mod tests { #[test] fn block_builder_does_not_include_invalid() { - let client = test_client::new(); + let client = substrate_test_runtime_client::new(); let mut builder = client.new_block(Default::default()).unwrap(); @@ -1987,7 +1987,7 @@ pub(crate) mod tests { fn uncles_with_only_ancestors() { // block tree: // G -> A1 -> A2 - let client = test_client::new(); + let client = substrate_test_runtime_client::new(); // G -> A1 let a1 = client.new_block(Default::default()).unwrap().bake().unwrap(); @@ -2007,7 +2007,7 @@ pub(crate) mod tests { // A1 -> B2 -> B3 -> B4 // B2 -> C3 // A1 -> D2 - let client = test_client::new(); + let client = substrate_test_runtime_client::new(); // G -> A1 let a1 = client.new_block(Default::default()).unwrap().bake().unwrap(); @@ -2444,7 +2444,7 @@ pub(crate) mod tests { #[test] fn import_with_justification() { - let client = test_client::new(); + let client = substrate_test_runtime_client::new(); // G -> A1 let a1 = client.new_block(Default::default()).unwrap().bake().unwrap(); @@ -2483,7 +2483,7 @@ pub(crate) mod tests { #[test] fn importing_diverged_finalized_block_should_trigger_reorg() { - let client = test_client::new(); + let client = substrate_test_runtime_client::new(); // G -> A1 -> A2 // \ @@ -2599,7 +2599,7 @@ pub(crate) mod tests { #[test] fn get_header_by_block_number_doesnt_panic() { - let client = test_client::new(); + let client = substrate_test_runtime_client::new(); // backend uses u32 for block numbers, make sure we don't panic when // trying to convert @@ -2610,7 +2610,7 @@ pub(crate) mod tests { #[test] fn state_reverted_on_reorg() { let _ = env_logger::try_init(); - let client = test_client::new(); + let client = substrate_test_runtime_client::new(); let current_balance = || client.runtime_api().balance_of( diff --git a/client/src/genesis.rs b/client/src/genesis.rs index a080a87cf4..506771217d 100644 --- a/client/src/genesis.rs +++ b/client/src/genesis.rs @@ -43,27 +43,27 @@ pub fn construct_genesis_block< #[cfg(test)] mod tests { use codec::{Encode, Decode, Joiner}; - use executor::native_executor_instance; - use state_machine::{ + use sc_executor::native_executor_instance; + use sp_state_machine::{ StateMachine, OverlayedChanges, ExecutionStrategy, InMemoryChangesTrieStorage, }; - use state_machine::backend::InMemory; - use test_client::{ + use sp_state_machine::backend::InMemory; + use substrate_test_runtime_client::{ runtime::genesismap::{GenesisConfig, insert_genesis_block}, runtime::{Hash, Transfer, Block, BlockNumber, Header, Digest}, AccountKeyring, Sr25519Keyring, }; - use primitives::Blake2Hasher; + use sp_core::Blake2Hasher; use hex_literal::*; native_executor_instance!( Executor, - test_client::runtime::api::dispatch, - test_client::runtime::native_version + substrate_test_runtime_client::runtime::api::dispatch, + substrate_test_runtime_client::runtime::native_version ); - fn executor() -> executor::NativeExecutor { - executor::NativeExecutor::new(executor::WasmExecutionMethod::Interpreted, None) + fn executor() -> sc_executor::NativeExecutor { + sc_executor::NativeExecutor::new(sc_executor::WasmExecutionMethod::Interpreted, None) } fn construct_block( @@ -73,7 +73,7 @@ mod tests { state_root: Hash, txs: Vec ) -> (Vec, Hash) { - use trie::{TrieConfiguration, trie_types::Layout}; + use sp_trie::{TrieConfiguration, trie_types::Layout}; let transactions = txs.into_iter().map(|tx| tx.into_signed_tx()).collect::>(); diff --git a/client/src/in_mem.rs b/client/src/in_mem.rs index 85bdd954c8..58e88934f3 100644 --- a/client/src/in_mem.rs +++ b/client/src/in_mem.rs @@ -19,20 +19,20 @@ use std::collections::{HashMap, HashSet}; use std::sync::Arc; use parking_lot::RwLock; -use primitives::{ChangesTrieConfiguration, storage::well_known_keys}; -use primitives::offchain::storage::{ +use sp_core::{ChangesTrieConfiguration, storage::well_known_keys}; +use sp_core::offchain::storage::{ InMemOffchainStorage as OffchainStorage }; use sp_runtime::generic::{BlockId, DigestItem}; use sp_runtime::traits::{Block as BlockT, Header as HeaderT, Zero, NumberFor}; use sp_runtime::{Justification, Storage}; -use state_machine::backend::{Backend as StateBackend, InMemory}; -use state_machine::{self, InMemoryChangesTrieStorage, ChangesTrieAnchorBlockId, ChangesTrieTransaction}; +use sp_state_machine::backend::{Backend as StateBackend, InMemory}; +use sp_state_machine::{self, InMemoryChangesTrieStorage, ChangesTrieAnchorBlockId, ChangesTrieTransaction}; use hash_db::{Hasher, Prefix}; -use trie::MemoryDB; +use sp_trie::MemoryDB; use sp_blockchain::{CachedHeaderMetadata, HeaderMetadata}; -use client_api::{ +use sc_client_api::{ backend::{self, NewBlockState, StorageCollection, ChildStorageCollection}, blockchain::{ self, BlockStatus, HeaderBackend, well_known_cache_keys::Id as CacheKeyId @@ -398,7 +398,7 @@ impl backend::AuxStore for Blockchain { } } -impl client_api::light::Storage for Blockchain +impl sc_client_api::light::Storage for Blockchain where Block::Hash: From<[u8; 32]>, { @@ -752,7 +752,7 @@ impl backend::PrunableStateChangesTrieStorage state_machine::ChangesTrieRootsStorage> for ChangesTrieStorage +impl sp_state_machine::ChangesTrieRootsStorage> for ChangesTrieStorage where Block: BlockT, H: Hasher, @@ -760,7 +760,7 @@ impl state_machine::ChangesTrieRootsStorage> for C fn build_anchor( &self, _hash: H::Out, - ) -> Result>, String> { + ) -> Result>, String> { Err("Dummy implementation".into()) } @@ -773,12 +773,12 @@ impl state_machine::ChangesTrieRootsStorage> for C } } -impl state_machine::ChangesTrieStorage> for ChangesTrieStorage +impl sp_state_machine::ChangesTrieStorage> for ChangesTrieStorage where Block: BlockT, H: Hasher, { - fn as_roots_storage(&self) -> &dyn state_machine::ChangesTrieRootsStorage> { + fn as_roots_storage(&self) -> &dyn sp_state_machine::ChangesTrieRootsStorage> { self } @@ -790,7 +790,7 @@ impl state_machine::ChangesTrieStorage> for Change false } - fn get(&self, key: &H::Out, prefix: Prefix) -> Result, String> { + fn get(&self, key: &H::Out, prefix: Prefix) -> Result, String> { self.0.get(key, prefix) } } @@ -810,25 +810,25 @@ pub fn check_genesis_storage(storage: &Storage) -> sp_blockchain::Result<()> { #[cfg(test)] mod tests { - use primitives::offchain::{OffchainStorage, storage::InMemOffchainStorage}; + use sp_core::offchain::{OffchainStorage, storage::InMemOffchainStorage}; use std::sync::Arc; - use test_client; - use primitives::Blake2Hasher; + use substrate_test_runtime_client; + use sp_core::Blake2Hasher; - type TestBackend = test_client::client::in_mem::Backend; + type TestBackend = substrate_test_runtime_client::sc_client::in_mem::Backend; #[test] fn test_leaves_with_complex_block_tree() { let backend = Arc::new(TestBackend::new()); - test_client::trait_tests::test_leaves_for_backend(backend); + substrate_test_runtime_client::trait_tests::test_leaves_for_backend(backend); } #[test] fn test_blockchain_query_by_number_gets_canonical() { let backend = Arc::new(TestBackend::new()); - test_client::trait_tests::test_blockchain_query_by_number_gets_canonical(backend); + substrate_test_runtime_client::trait_tests::test_blockchain_query_by_number_gets_canonical(backend); } #[test] diff --git a/client/src/lib.rs b/client/src/lib.rs index 364733f1a4..70d1f28659 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -47,15 +47,15 @@ //! ``` //! use std::sync::Arc; //! use sc_client::{Client, in_mem::Backend, LocalCallExecutor}; -//! use primitives::Blake2Hasher; +//! use sp_core::Blake2Hasher; //! use sp_runtime::Storage; -//! use executor::{NativeExecutor, WasmExecutionMethod}; +//! use sc_executor::{NativeExecutor, WasmExecutionMethod}; //! //! // In this example, we're using the `Block` and `RuntimeApi` types from the //! // `substrate-test-runtime-client` crate. These types are automatically generated when //! // compiling a runtime. In a typical use-case, these types would have been to be generated //! // from your runtime. -//! use test_client::{LocalExecutor, runtime::Block, runtime::RuntimeApi}; +//! use substrate_test_runtime_client::{LocalExecutor, runtime::Block, runtime::RuntimeApi}; //! //! let backend = Arc::new(Backend::::new()); //! let client = Client::<_, _, _, RuntimeApi>::new( @@ -83,7 +83,7 @@ pub mod leaves; mod call_executor; mod client; -pub use client_api::{ +pub use sc_client_api::{ blockchain, blockchain::well_known_cache_keys, blockchain::Info as ChainInfo, @@ -102,4 +102,4 @@ pub use crate::{ }, leaves::LeafSet, }; -pub use state_machine::{ExecutionStrategy, StorageProof}; +pub use sp_state_machine::{ExecutionStrategy, StorageProof}; diff --git a/client/src/light/backend.rs b/client/src/light/backend.rs index 5f770394fc..f946d91b3c 100644 --- a/client/src/light/backend.rs +++ b/client/src/light/backend.rs @@ -21,16 +21,16 @@ use std::collections::HashMap; use std::sync::Arc; use parking_lot::RwLock; -use primitives::storage::{ChildInfo, OwnedChildInfo}; -use state_machine::{ +use sp_core::storage::{ChildInfo, OwnedChildInfo}; +use sp_core::offchain::storage::InMemOffchainStorage; +use sp_state_machine::{ Backend as StateBackend, TrieBackend, backend::InMemory as InMemoryState, ChangesTrieTransaction }; -use primitives::offchain::storage::InMemOffchainStorage; use sp_runtime::{generic::BlockId, Justification, Storage}; use sp_runtime::traits::{Block as BlockT, NumberFor, Zero, Header}; use crate::in_mem::{self, check_genesis_storage}; use sp_blockchain::{ Error as ClientError, Result as ClientResult }; -use client_api::{ +use sc_client_api::{ backend::{ AuxStore, Backend as ClientBackend, BlockImportOperation, RemoteBackend, NewBlockState, StorageCollection, ChildStorageCollection, @@ -42,7 +42,7 @@ use client_api::{ }; use crate::light::blockchain::Blockchain; use hash_db::Hasher; -use trie::MemoryDB; +use sp_trie::MemoryDB; const IN_MEMORY_EXPECT_PROOF: &str = "InMemory state backend has Void error type and always succeeds; qed"; @@ -487,16 +487,16 @@ impl StateBackend for GenesisOrUnavailableState #[cfg(test)] mod tests { - use primitives::Blake2Hasher; - use test_client::{self, runtime::Block}; - use client_api::backend::NewBlockState; + use sp_core::Blake2Hasher; + use substrate_test_runtime_client::{self, runtime::Block}; + use sc_client_api::backend::NewBlockState; use crate::light::blockchain::tests::{DummyBlockchain, DummyStorage}; use super::*; #[test] fn local_state_is_created_when_genesis_state_is_available() { let def = Default::default(); - let header0 = test_client::runtime::Header::new(0, def, def, def, Default::default()); + let header0 = substrate_test_runtime_client::runtime::Header::new(0, def, def, def, Default::default()); let backend: Backend<_, Blake2Hasher> = Backend::new(Arc::new(DummyBlockchain::new(DummyStorage::new()))); let mut op = backend.begin_operation().unwrap(); diff --git a/client/src/light/blockchain.rs b/client/src/light/blockchain.rs index 03ee035031..54cb8d9b09 100644 --- a/client/src/light/blockchain.rs +++ b/client/src/light/blockchain.rs @@ -27,7 +27,7 @@ use sp_blockchain::{ HeaderMetadata, CachedHeaderMetadata, Error as ClientError, Result as ClientResult, }; -pub use client_api::{ +pub use sc_client_api::{ backend::{ AuxStore, NewBlockState }, @@ -195,8 +195,8 @@ pub fn future_header>( pub mod tests { use std::collections::HashMap; use parking_lot::Mutex; - use test_client::runtime::{Hash, Block, Header}; - use client_api::blockchain::Info; + use substrate_test_runtime_client::runtime::{Hash, Block, Header}; + use sc_client_api::blockchain::Info; use super::*; pub type DummyBlockchain = Blockchain; diff --git a/client/src/light/call_executor.rs b/client/src/light/call_executor.rs index 8571c331b2..656271b932 100644 --- a/client/src/light/call_executor.rs +++ b/client/src/light/call_executor.rs @@ -21,15 +21,15 @@ use std::{ }; use codec::{Encode, Decode}; -use primitives::{ +use sp_core::{ H256, Blake2Hasher, convert_hash, NativeOrEncoded, traits::CodeExecutor, }; use sp_runtime::{ generic::BlockId, traits::{One, Block as BlockT, Header as HeaderT, NumberFor}, }; -use externalities::Extensions; -use state_machine::{ +use sp_externalities::Extensions; +use sp_state_machine::{ self, Backend as StateBackend, OverlayedChanges, ExecutionStrategy, create_proof_check_backend, execution_proof_check_on_trie_backend, ExecutionManager, ChangesTrieTransaction, StorageProof, merge_storage_proofs, @@ -40,12 +40,12 @@ use sp_api::{ProofRecorder, InitializeBlock}; use sp_blockchain::{Error as ClientError, Result as ClientResult}; -use client_api::{ +use sc_client_api::{ backend::RemoteBackend, light::RemoteCallRequest, call_executor::CallExecutor }; -use executor::{RuntimeVersion, NativeVersion}; +use sc_executor::{RuntimeVersion, NativeVersion}; /// Call executor that is able to execute calls only on genesis state. /// @@ -176,9 +176,9 @@ impl CallExecutor for Err(ClientError::NotAvailableOnLightClient) } - fn prove_at_trie_state>( + fn prove_at_trie_state>( &self, - _state: &state_machine::TrieBackend, + _state: &sp_state_machine::TrieBackend, _changes: &mut OverlayedChanges, _method: &str, _call_data: &[u8] @@ -208,7 +208,7 @@ pub fn prove_execution( E: CallExecutor, { let trie_state = state.as_trie_backend() - .ok_or_else(|| Box::new(state_machine::ExecutionError::UnableToGenerateProof) as Box)?; + .ok_or_else(|| Box::new(sp_state_machine::ExecutionError::UnableToGenerateProof) as Box)?; // prepare execution environment + record preparation proof let mut changes = Default::default(); @@ -293,11 +293,11 @@ fn check_execution_proof_with_make_header, + S: sp_state_machine::Backend, F: FnOnce( Result, Self::Error>, Result, Self::Error> @@ -372,9 +372,9 @@ mod tests { unreachable!() } - fn prove_at_trie_state>( + fn prove_at_trie_state>( &self, - _trie_state: &state_machine::TrieBackend, + _trie_state: &sp_state_machine::TrieBackend, _overlay: &mut OverlayedChanges, _method: &str, _call_data: &[u8] @@ -387,7 +387,7 @@ mod tests { } } - fn local_executor() -> NativeExecutor { + fn local_executor() -> NativeExecutor { NativeExecutor::new(WasmExecutionMethod::Interpreted, None) } @@ -408,7 +408,7 @@ mod tests { let local_result = check_execution_proof::<_, _, Blake2Hasher>( &local_executor(), &RemoteCallRequest { - block: test_client::runtime::Hash::default(), + block: substrate_test_runtime_client::runtime::Hash::default(), header: remote_header, method: method.into(), call_data: vec![], @@ -435,7 +435,7 @@ mod tests { let execution_result = check_execution_proof_with_make_header::<_, _, Blake2Hasher, _>( &local_executor(), &RemoteCallRequest { - block: test_client::runtime::Hash::default(), + block: substrate_test_runtime_client::runtime::Hash::default(), header: remote_header, method: method.into(), call_data: vec![], @@ -457,7 +457,7 @@ mod tests { } // prepare remote client - let remote_client = test_client::new(); + let remote_client = substrate_test_runtime_client::new(); for i in 1u32..3u32 { let mut digest = Digest::default(); digest.push(sp_runtime::generic::DigestItem::Other::(i.to_le_bytes().to_vec())); @@ -488,7 +488,7 @@ mod tests { execute_with_proof_failure(&remote_client, 2, "Core_version"); // check that proof check doesn't panic even if proof is incorrect AND panic handler is set - panic_handler::set("TEST", "1.2.3"); + sp_panic_handler::set("TEST", "1.2.3"); execute_with_proof_failure(&remote_client, 2, "Core_version"); } @@ -496,9 +496,9 @@ mod tests { fn code_is_executed_at_genesis_only() { let backend = Arc::new(InMemBackend::::new()); let def = H256::default(); - let header0 = test_client::runtime::Header::new(0, def, def, def, Default::default()); + let header0 = substrate_test_runtime_client::runtime::Header::new(0, def, def, def, Default::default()); let hash0 = header0.hash(); - let header1 = test_client::runtime::Header::new(1, def, def, hash0, Default::default()); + let header1 = substrate_test_runtime_client::runtime::Header::new(1, def, def, hash0, Default::default()); let hash1 = header1.hash(); backend.blockchain().insert(hash0, header0, None, None, NewBlockState::Final).unwrap(); backend.blockchain().insert(hash1, header1, None, None, NewBlockState::Final).unwrap(); diff --git a/client/src/light/fetcher.rs b/client/src/light/fetcher.rs index babd83cfc9..c081f6bb9e 100644 --- a/client/src/light/fetcher.rs +++ b/client/src/light/fetcher.rs @@ -22,21 +22,21 @@ use std::marker::PhantomData; use hash_db::{HashDB, Hasher, EMPTY_PREFIX}; use codec::{Decode, Encode}; -use primitives::{convert_hash, traits::CodeExecutor, H256}; +use sp_core::{convert_hash, traits::CodeExecutor, H256}; use sp_runtime::traits::{ Block as BlockT, Header as HeaderT, Hash, HashFor, NumberFor, SimpleArithmetic, CheckedConversion, Zero, }; -use state_machine::{ +use sp_state_machine::{ ChangesTrieRootsStorage, ChangesTrieAnchorBlockId, ChangesTrieConfigurationRange, TrieBackend, read_proof_check, key_changes_proof_check, create_proof_check_backend_storage, read_child_proof_check, }; -pub use state_machine::StorageProof; +pub use sp_state_machine::StorageProof; use sp_blockchain::{Error as ClientError, Result as ClientResult}; use crate::cht; -pub use client_api::{ +pub use sc_client_api::{ light::{ RemoteCallRequest, RemoteHeaderRequest, RemoteReadRequest, RemoteReadChildRequest, RemoteChangesRequest, ChangesProof, RemoteBodyRequest, Fetcher, FetchChecker, @@ -294,7 +294,7 @@ impl<'a, H, Number, Hash> ChangesTrieRootsStorage for RootsStorage<'a fn build_anchor( &self, _hash: H::Out, - ) -> Result, String> { + ) -> Result, String> { Err("build_anchor is only called when building block".into()) } @@ -326,40 +326,40 @@ impl<'a, H, Number, Hash> ChangesTrieRootsStorage for RootsStorage<'a pub mod tests { use codec::Decode; use crate::client::tests::prepare_client_with_key_changes; - use executor::{NativeExecutor, WasmExecutionMethod}; + use sc_executor::{NativeExecutor, WasmExecutionMethod}; use sp_blockchain::Error as ClientError; - use client_api::backend::NewBlockState; - use test_client::{ + use sc_client_api::backend::NewBlockState; + use substrate_test_runtime_client::{ self, ClientExt, blockchain::HeaderBackend, AccountKeyring, runtime::{self, Hash, Block, Header, Extrinsic} }; - use consensus::BlockOrigin; + use sp_consensus::BlockOrigin; use crate::in_mem::{Blockchain as InMemoryBlockchain}; use crate::light::fetcher::{FetchChecker, LightDataChecker, RemoteHeaderRequest}; use crate::light::blockchain::tests::{DummyStorage, DummyBlockchain}; - use primitives::{blake2_256, Blake2Hasher, H256}; - use primitives::storage::{well_known_keys, StorageKey, ChildInfo}; + use sp_core::{blake2_256, Blake2Hasher, H256}; + use sp_core::storage::{well_known_keys, StorageKey, ChildInfo}; use sp_runtime::generic::BlockId; - use state_machine::Backend; + use sp_state_machine::Backend; use super::*; const CHILD_INFO_1: ChildInfo<'static> = ChildInfo::new_default(b"unique_id_1"); type TestChecker = LightDataChecker< - NativeExecutor, + NativeExecutor, Blake2Hasher, Block, DummyStorage, >; - fn local_executor() -> NativeExecutor { + fn local_executor() -> NativeExecutor { NativeExecutor::new(WasmExecutionMethod::Interpreted, None) } fn prepare_for_read_proof_check() -> (TestChecker, Header, StorageProof, u32) { // prepare remote client - let remote_client = test_client::new(); + let remote_client = substrate_test_runtime_client::new(); let remote_block_id = BlockId::Number(0); let remote_block_hash = remote_client.block_hash(0).unwrap().unwrap(); let mut remote_block_header = remote_client.header(&remote_block_id).unwrap().unwrap(); @@ -392,10 +392,10 @@ pub mod tests { } fn prepare_for_read_child_proof_check() -> (TestChecker, Header, StorageProof, Vec) { - use test_client::DefaultTestClientBuilderExt; - use test_client::TestClientBuilderExt; + use substrate_test_runtime_client::DefaultTestClientBuilderExt; + use substrate_test_runtime_client::TestClientBuilderExt; // prepare remote client - let remote_client = test_client::TestClientBuilder::new() + let remote_client = substrate_test_runtime_client::TestClientBuilder::new() .add_extra_child_storage( b":child_storage:default:child1".to_vec(), CHILD_INFO_1, @@ -441,7 +441,7 @@ pub mod tests { fn prepare_for_header_proof_check(insert_cht: bool) -> (TestChecker, Hash, Header, StorageProof) { // prepare remote client - let remote_client = test_client::new(); + let remote_client = substrate_test_runtime_client::new(); let mut local_headers_hashes = Vec::new(); for i in 0..4 { let builder = remote_client.new_block(Default::default()).unwrap(); @@ -468,7 +468,7 @@ pub mod tests { } fn header_with_computed_extrinsics_root(extrinsics: Vec) -> Header { - use trie::{TrieConfiguration, trie_types::Layout}; + use sp_trie::{TrieConfiguration, trie_types::Layout}; let iter = extrinsics.iter().map(Encode::encode); let extrinsics_root = Layout::::ordered_trie_root(iter); diff --git a/client/src/light/mod.rs b/client/src/light/mod.rs index bd8040d22b..cc27bc698b 100644 --- a/client/src/light/mod.rs +++ b/client/src/light/mod.rs @@ -23,15 +23,15 @@ pub mod fetcher; use std::sync::Arc; -use executor::RuntimeInfo; -use primitives::{H256, Blake2Hasher, traits::CodeExecutor}; +use sc_executor::RuntimeInfo; +use sp_core::{H256, Blake2Hasher, traits::CodeExecutor}; use sp_runtime::BuildStorage; use sp_runtime::traits::Block as BlockT; use sp_blockchain::Result as ClientResult; use crate::call_executor::LocalCallExecutor; use crate::client::Client; -use client_api::{ +use sc_client_api::{ light::Storage as BlockchainStorage, }; use crate::light::backend::Backend; diff --git a/client/state-db/Cargo.toml b/client/state-db/Cargo.toml index 175b38f7f0..97079c8f18 100644 --- a/client/state-db/Cargo.toml +++ b/client/state-db/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] parking_lot = "0.9.0" log = "0.4.8" -primitives = { package = "sp-core", path = "../../primitives/core" } +sp-core = { path = "../../primitives/core" } codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } [dev-dependencies] diff --git a/client/state-db/src/lib.rs b/client/state-db/src/lib.rs index e561d9ce96..331da7d575 100644 --- a/client/state-db/src/lib.rs +++ b/client/state-db/src/lib.rs @@ -471,7 +471,7 @@ impl StateDb { #[cfg(test)] mod tests { use std::io; - use primitives::H256; + use sp_core::H256; use crate::{StateDb, PruningMode, Constraints}; use crate::test::{make_db, make_changeset, TestDb}; diff --git a/client/state-db/src/noncanonical.rs b/client/state-db/src/noncanonical.rs index 58715715cc..6e4cd079ae 100644 --- a/client/state-db/src/noncanonical.rs +++ b/client/state-db/src/noncanonical.rs @@ -436,7 +436,7 @@ impl NonCanonicalOverlay { #[cfg(test)] mod tests { use std::io; - use primitives::H256; + use sp_core::H256; use super::{NonCanonicalOverlay, to_journal_key}; use crate::{ChangeSet, CommitSet}; use crate::test::{make_db, make_changeset}; diff --git a/client/state-db/src/pruning.rs b/client/state-db/src/pruning.rs index 21f472fe69..4cb130eff8 100644 --- a/client/state-db/src/pruning.rs +++ b/client/state-db/src/pruning.rs @@ -201,7 +201,7 @@ impl RefWindow { #[cfg(test)] mod tests { use super::RefWindow; - use primitives::H256; + use sp_core::H256; use crate::CommitSet; use crate::test::{make_db, make_commit, TestDb}; diff --git a/client/state-db/src/test.rs b/client/state-db/src/test.rs index d90c369906..dfbb08998b 100644 --- a/client/state-db/src/test.rs +++ b/client/state-db/src/test.rs @@ -17,7 +17,7 @@ //! Test utils use std::collections::HashMap; -use primitives::H256; +use sp_core::H256; use crate::{DBValue, ChangeSet, CommitSet, MetaDb, NodeDb}; #[derive(Default, Debug, Clone, PartialEq, Eq)] diff --git a/client/transaction-pool/Cargo.toml b/client/transaction-pool/Cargo.toml index f1ab17927d..b9d7bf59ab 100644 --- a/client/transaction-pool/Cargo.toml +++ b/client/transaction-pool/Cargo.toml @@ -10,14 +10,14 @@ derive_more = "0.99.2" futures = { version = "0.3.1", features = ["compat"] } log = "0.4.8" parking_lot = "0.9.0" -primitives = { package = "sp-core", path = "../../primitives/core" } +sp-core = { path = "../../primitives/core" } sp-api = { path = "../../primitives/api" } sp-runtime = { path = "../../primitives/runtime" } -txpool = { package = "sc-transaction-graph", path = "./graph" } -txpool-api = { package = "sp-transaction-pool", path = "../../primitives/transaction-pool" } -client-api = { package = "sc-client-api", path = "../api" } +sc-transaction-graph = { path = "./graph" } +sp-transaction-pool = { path = "../../primitives/transaction-pool" } +sc-client-api = { path = "../api" } sp-blockchain = { path = "../../primitives/blockchain" } [dev-dependencies] -keyring = { package = "sp-keyring", path = "../../primitives/keyring" } -test-client = { package = "substrate-test-runtime-client", path = "../../test-utils/runtime/client" } +sp-keyring = { path = "../../primitives/keyring" } +substrate-test-runtime-client = { path = "../../test-utils/runtime/client" } diff --git a/client/transaction-pool/graph/Cargo.toml b/client/transaction-pool/graph/Cargo.toml index cda2fb93e8..8da67ef9c6 100644 --- a/client/transaction-pool/graph/Cargo.toml +++ b/client/transaction-pool/graph/Cargo.toml @@ -10,14 +10,14 @@ futures = "0.3.1" log = "0.4.8" parking_lot = "0.9.0" serde = { version = "1.0.101", features = ["derive"] } -primitives = { package = "sp-core", path = "../../../primitives/core" } +sp-core = { path = "../../../primitives/core" } sp-runtime = { path = "../../../primitives/runtime" } -txpool-api = { package = "sp-transaction-pool", path = "../../../primitives/transaction-pool" } +sp-transaction-pool = { path = "../../../primitives/transaction-pool" } [dev-dependencies] assert_matches = "1.3.0" codec = { package = "parity-scale-codec", version = "1.0.0" } -test_runtime = { package = "substrate-test-runtime", path = "../../../test-utils/runtime" } +substrate-test-runtime = { path = "../../../test-utils/runtime" } criterion = "0.3" [[bench]] diff --git a/client/transaction-pool/graph/benches/basics.rs b/client/transaction-pool/graph/benches/basics.rs index 884cffea74..bd65efe448 100644 --- a/client/transaction-pool/graph/benches/basics.rs +++ b/client/transaction-pool/graph/benches/basics.rs @@ -20,12 +20,12 @@ use futures::executor::block_on; use sc_transaction_graph::*; use sp_runtime::transaction_validity::{ValidTransaction, InvalidTransaction}; use codec::Encode; -use test_runtime::{Block, Extrinsic, Transfer, H256, AccountId}; +use substrate_test_runtime::{Block, Extrinsic, Transfer, H256, AccountId}; use sp_runtime::{ generic::BlockId, transaction_validity::{TransactionValidity, TransactionTag as Tag}, }; -use primitives::blake2_256; +use sp_core::blake2_256; #[derive(Clone, Debug, Default)] struct TestApi { @@ -48,8 +48,8 @@ fn to_tag(nonce: u64, from: AccountId) -> Tag { impl ChainApi for TestApi { type Block = Block; type Hash = H256; - type Error = txpool_api::error::Error; - type ValidationFuture = futures::future::Ready>; + type Error = sp_transaction_pool::error::Error; + type ValidationFuture = futures::future::Ready>; fn validate_transaction( &self, diff --git a/client/transaction-pool/graph/src/base_pool.rs b/client/transaction-pool/graph/src/base_pool.rs index 77ba175963..8878e9e6dd 100644 --- a/client/transaction-pool/graph/src/base_pool.rs +++ b/client/transaction-pool/graph/src/base_pool.rs @@ -27,14 +27,14 @@ use std::{ use log::{trace, debug, warn}; use serde::Serialize; -use primitives::hexdisplay::HexDisplay; +use sp_core::hexdisplay::HexDisplay; use sp_runtime::traits::Member; use sp_runtime::transaction_validity::{ TransactionTag as Tag, TransactionLongevity as Longevity, TransactionPriority as Priority, }; -use txpool_api::{error, PoolStatus, InPoolTransaction}; +use sp_transaction_pool::{error, PoolStatus, InPoolTransaction}; use crate::future::{FutureTransactions, WaitingTransaction}; use crate::ready::ReadyTransactions; diff --git a/client/transaction-pool/graph/src/future.rs b/client/transaction-pool/graph/src/future.rs index 1c653cc6e6..2902f03b26 100644 --- a/client/transaction-pool/graph/src/future.rs +++ b/client/transaction-pool/graph/src/future.rs @@ -22,7 +22,7 @@ use std::{ time, }; -use primitives::hexdisplay::HexDisplay; +use sp_core::hexdisplay::HexDisplay; use sp_runtime::transaction_validity::{ TransactionTag as Tag, }; diff --git a/client/transaction-pool/graph/src/pool.rs b/client/transaction-pool/graph/src/pool.rs index d29a513d97..bb5f59ef87 100644 --- a/client/transaction-pool/graph/src/pool.rs +++ b/client/transaction-pool/graph/src/pool.rs @@ -34,7 +34,7 @@ use sp_runtime::{ traits::{self, SaturatedConversion}, transaction_validity::{TransactionValidity, TransactionTag as Tag, TransactionValidityError}, }; -use txpool_api::{error, PoolStatus}; +use sp_transaction_pool::{error, PoolStatus}; use crate::validated_pool::{ValidatedPool, ValidatedTransaction}; @@ -466,10 +466,10 @@ mod tests { use parking_lot::Mutex; use futures::executor::block_on; use super::*; - use txpool_api::TransactionStatus; + use sp_transaction_pool::TransactionStatus; use sp_runtime::transaction_validity::{ValidTransaction, InvalidTransaction}; use codec::Encode; - use test_runtime::{Block, Extrinsic, Transfer, H256, AccountId}; + use substrate_test_runtime::{Block, Extrinsic, Transfer, H256, AccountId}; use assert_matches::assert_matches; use crate::base_pool::Limit; diff --git a/client/transaction-pool/graph/src/ready.rs b/client/transaction-pool/graph/src/ready.rs index a358047dd7..9fd11ab959 100644 --- a/client/transaction-pool/graph/src/ready.rs +++ b/client/transaction-pool/graph/src/ready.rs @@ -28,7 +28,7 @@ use sp_runtime::traits::Member; use sp_runtime::transaction_validity::{ TransactionTag as Tag, }; -use txpool_api::error; +use sp_transaction_pool::error; use crate::future::WaitingTransaction; use crate::base_pool::Transaction; diff --git a/client/transaction-pool/graph/src/validated_pool.rs b/client/transaction-pool/graph/src/validated_pool.rs index 7f9e407727..49b86bbca0 100644 --- a/client/transaction-pool/graph/src/validated_pool.rs +++ b/client/transaction-pool/graph/src/validated_pool.rs @@ -36,7 +36,7 @@ use sp_runtime::{ traits::{self, SaturatedConversion}, transaction_validity::TransactionTag as Tag, }; -use txpool_api::{error, PoolStatus}; +use sp_transaction_pool::{error, PoolStatus}; use crate::base_pool::PruneStatus; use crate::pool::{EventStream, Options, ChainApi, BlockHash, ExHash, ExtrinsicFor, TransactionFor}; diff --git a/client/transaction-pool/graph/src/watcher.rs b/client/transaction-pool/graph/src/watcher.rs index fa93386c8c..f222c8b621 100644 --- a/client/transaction-pool/graph/src/watcher.rs +++ b/client/transaction-pool/graph/src/watcher.rs @@ -20,7 +20,7 @@ use futures::{ Stream, channel::mpsc, }; -use txpool_api::TransactionStatus; +use sp_transaction_pool::TransactionStatus; /// Extrinsic watcher. /// diff --git a/client/transaction-pool/src/api.rs b/client/transaction-pool/src/api.rs index 8d2fdd9702..6f4899995f 100644 --- a/client/transaction-pool/src/api.rs +++ b/client/transaction-pool/src/api.rs @@ -20,13 +20,13 @@ use std::{marker::PhantomData, pin::Pin, sync::Arc}; use codec::{Decode, Encode}; use futures::{channel::oneshot, executor::{ThreadPool, ThreadPoolBuilder}, future::{Future, FutureExt, ready}}; -use client_api::{ +use sc_client_api::{ blockchain::HeaderBackend, light::{Fetcher, RemoteCallRequest} }; -use primitives::{H256, Blake2Hasher, Hasher}; +use sp_core::{H256, Blake2Hasher, Hasher}; use sp_runtime::{generic::BlockId, traits::{self, Block as BlockT}, transaction_validity::TransactionValidity}; -use txpool_api::runtime_api::TaggedTransactionQueue; +use sp_transaction_pool::runtime_api::TaggedTransactionQueue; use crate::error::{self, Error}; @@ -54,7 +54,7 @@ impl FullChainApi where } } -impl txpool::ChainApi for FullChainApi where +impl sc_transaction_graph::ChainApi for FullChainApi where Block: BlockT, T: traits::ProvideRuntimeApi + traits::BlockIdTo + 'static + Send + Sync, T::Api: TaggedTransactionQueue, @@ -68,7 +68,7 @@ impl txpool::ChainApi for FullChainApi where fn validate_transaction( &self, at: &BlockId, - uxt: txpool::ExtrinsicFor, + uxt: sc_transaction_graph::ExtrinsicFor, ) -> Self::ValidationFuture { let (tx, rx) = oneshot::channel(); let client = self.client.clone(); @@ -93,18 +93,18 @@ impl txpool::ChainApi for FullChainApi where fn block_id_to_number( &self, at: &BlockId, - ) -> error::Result>> { + ) -> error::Result>> { self.client.to_number(at).map_err(|e| Error::BlockIdConversion(format!("{:?}", e))) } fn block_id_to_hash( &self, at: &BlockId, - ) -> error::Result>> { + ) -> error::Result>> { self.client.to_hash(at).map_err(|e| Error::BlockIdConversion(format!("{:?}", e))) } - fn hash_and_length(&self, ex: &txpool::ExtrinsicFor) -> (Self::Hash, usize) { + fn hash_and_length(&self, ex: &sc_transaction_graph::ExtrinsicFor) -> (Self::Hash, usize) { ex.using_encoded(|x| { (Blake2Hasher::hash(x), x.len()) }) @@ -133,7 +133,7 @@ impl LightChainApi where } } -impl txpool::ChainApi for LightChainApi where +impl sc_transaction_graph::ChainApi for LightChainApi where Block: BlockT, T: HeaderBackend + 'static, F: Fetcher + 'static, @@ -146,7 +146,7 @@ impl txpool::ChainApi for LightChainApi where fn validate_transaction( &self, at: &BlockId, - uxt: txpool::ExtrinsicFor, + uxt: sc_transaction_graph::ExtrinsicFor, ) -> Self::ValidationFuture { let header_hash = self.client.expect_block_hash_from_id(at); let header_and_hash = header_hash @@ -177,15 +177,15 @@ impl txpool::ChainApi for LightChainApi where Box::new(remote_validation_request) } - fn block_id_to_number(&self, at: &BlockId) -> error::Result>> { + fn block_id_to_number(&self, at: &BlockId) -> error::Result>> { Ok(self.client.block_number_from_id(at)?) } - fn block_id_to_hash(&self, at: &BlockId) -> error::Result>> { + fn block_id_to_hash(&self, at: &BlockId) -> error::Result>> { Ok(self.client.block_hash_from_id(at)?) } - fn hash_and_length(&self, ex: &txpool::ExtrinsicFor) -> (Self::Hash, usize) { + fn hash_and_length(&self, ex: &sc_transaction_graph::ExtrinsicFor) -> (Self::Hash, usize) { ex.using_encoded(|x| { (Blake2Hasher::hash(x), x.len()) }) diff --git a/client/transaction-pool/src/error.rs b/client/transaction-pool/src/error.rs index 6ba1d8e825..5394393c46 100644 --- a/client/transaction-pool/src/error.rs +++ b/client/transaction-pool/src/error.rs @@ -16,7 +16,7 @@ //! Transaction pool error. -use txpool_api::error::Error as TxPoolError; +use sp_transaction_pool::error::Error as TxPoolError; /// Transaction pool result. pub type Result = std::result::Result; @@ -47,7 +47,7 @@ impl std::error::Error for Error { } } -impl txpool_api::error::IntoPoolError for Error { +impl sp_transaction_pool::error::IntoPoolError for Error { fn into_pool_error(self) -> std::result::Result { match self { Error::Pool(e) => Ok(e), diff --git a/client/transaction-pool/src/lib.rs b/client/transaction-pool/src/lib.rs index 62e88af74e..9ca4cc0a1e 100644 --- a/client/transaction-pool/src/lib.rs +++ b/client/transaction-pool/src/lib.rs @@ -26,7 +26,7 @@ pub mod error; #[cfg(test)] mod tests; -pub use txpool; +pub use sc_transaction_graph as txpool; pub use crate::api::{FullChainApi, LightChainApi}; pub use crate::maintainer::{FullBasicPoolMaintainer, LightBasicPoolMaintainer}; @@ -37,7 +37,7 @@ use sp_runtime::{ generic::BlockId, traits::Block as BlockT, }; -use txpool_api::{ +use sp_transaction_pool::{ TransactionPool, PoolStatus, ImportNotificationStream, TxHash, TransactionFor, TransactionStatusStreamFor, }; @@ -46,25 +46,25 @@ use txpool_api::{ pub struct BasicPool where Block: BlockT, - PoolApi: txpool::ChainApi, + PoolApi: sc_transaction_graph::ChainApi, { - pool: Arc>, + pool: Arc>, } impl BasicPool where Block: BlockT, - PoolApi: txpool::ChainApi, + PoolApi: sc_transaction_graph::ChainApi, { /// Create new basic transaction pool with provided api. - pub fn new(options: txpool::Options, pool_api: PoolApi) -> Self { + pub fn new(options: sc_transaction_graph::Options, pool_api: PoolApi) -> Self { BasicPool { - pool: Arc::new(txpool::Pool::new(options, pool_api)), + pool: Arc::new(sc_transaction_graph::Pool::new(options, pool_api)), } } /// Gets shared reference to the underlying pool. - pub fn pool(&self) -> &Arc> { + pub fn pool(&self) -> &Arc> { &self.pool } } @@ -72,11 +72,11 @@ impl BasicPool impl TransactionPool for BasicPool where Block: BlockT, - PoolApi: 'static + txpool::ChainApi, + PoolApi: 'static + sc_transaction_graph::ChainApi, { type Block = PoolApi::Block; - type Hash = txpool::ExHash; - type InPoolTransaction = txpool::base_pool::Transaction, TransactionFor>; + type Hash = sc_transaction_graph::ExHash; + type InPoolTransaction = sc_transaction_graph::base_pool::Transaction, TransactionFor>; type Error = error::Error; fn submit_at( diff --git a/client/transaction-pool/src/maintainer.rs b/client/transaction-pool/src/maintainer.rs index 5867192dce..799aa8bd12 100644 --- a/client/transaction-pool/src/maintainer.rs +++ b/client/transaction-pool/src/maintainer.rs @@ -26,31 +26,31 @@ use futures::{ use log::{warn, debug, trace}; use parking_lot::Mutex; -use client_api::{ +use sc_client_api::{ client::BlockBody, light::{Fetcher, RemoteBodyRequest}, }; -use primitives::{Blake2Hasher, H256}; +use sp_core::{Blake2Hasher, H256}; use sp_runtime::{ generic::BlockId, traits::{Block as BlockT, Extrinsic, Header, NumberFor, ProvideRuntimeApi, SimpleArithmetic}, }; use sp_blockchain::HeaderBackend; -use txpool_api::TransactionPoolMaintainer; -use txpool_api::runtime_api::TaggedTransactionQueue; +use sp_transaction_pool::TransactionPoolMaintainer; +use sp_transaction_pool::runtime_api::TaggedTransactionQueue; -use txpool::{self, ChainApi}; +use sc_transaction_graph::{self, ChainApi}; /// Basic transaction pool maintainer for full clients. pub struct FullBasicPoolMaintainer { - pool: Arc>, + pool: Arc>, client: Arc, } impl FullBasicPoolMaintainer { /// Create new basic full pool maintainer. pub fn new( - pool: Arc>, + pool: Arc>, client: Arc, ) -> Self { FullBasicPoolMaintainer { pool, client } @@ -61,7 +61,7 @@ impl TransactionPoolMaintainer for FullBasicPoolMaintainer where - Block: BlockT::Out>, + Block: BlockT::Out>, Client: ProvideRuntimeApi + HeaderBackend + BlockBody + 'static, Client::Api: TaggedTransactionQueue, PoolApi: ChainApi + 'static, @@ -143,7 +143,7 @@ where /// Basic transaction pool maintainer for light clients. pub struct LightBasicPoolMaintainer { - pool: Arc>, + pool: Arc>, client: Arc, fetcher: Arc, revalidate_time_period: Option, @@ -154,7 +154,7 @@ pub struct LightBasicPoolMaintainer impl LightBasicPoolMaintainer where - Block: BlockT::Out>, + Block: BlockT::Out>, Client: ProvideRuntimeApi + HeaderBackend + BlockBody + 'static, Client::Api: TaggedTransactionQueue, PoolApi: ChainApi + 'static, @@ -165,7 +165,7 @@ impl LightBasicPoolMaintainer>, + pool: Arc>, client: Arc, fetcher: Arc, ) -> Self { @@ -180,7 +180,7 @@ impl LightBasicPoolMaintainer>, + pool: Arc>, client: Arc, fetcher: Arc, revalidate_time_period: Option, @@ -261,7 +261,7 @@ impl TransactionPoolMaintainer for LightBasicPoolMaintainer where - Block: BlockT::Out>, + Block: BlockT::Out>, Client: ProvideRuntimeApi + HeaderBackend + BlockBody + 'static, Client::Api: TaggedTransactionQueue, PoolApi: ChainApi + 'static, @@ -355,15 +355,15 @@ mod tests { use super::*; use futures::executor::block_on; use codec::Encode; - use test_client::{prelude::*, runtime::{Block, Transfer}, consensus::{BlockOrigin, SelectChain}}; - use txpool_api::PoolStatus; + use substrate_test_runtime_client::{prelude::*, runtime::{Block, Transfer}, sp_consensus::{BlockOrigin, SelectChain}}; + use sp_transaction_pool::PoolStatus; use crate::api::{FullChainApi, LightChainApi}; #[test] fn should_remove_transactions_from_the_full_pool() { let (client, longest_chain) = TestClientBuilder::new().build_with_longest_chain(); let client = Arc::new(client); - let pool = txpool::Pool::new(Default::default(), FullChainApi::new(client.clone())); + let pool = sc_transaction_graph::Pool::new(Default::default(), FullChainApi::new(client.clone())); let pool = Arc::new(pool); let transaction = Transfer { amount: 5, @@ -401,7 +401,7 @@ mod tests { to: Default::default(), }.into_signed_tx(); let fetcher_transaction = transaction.clone(); - let fetcher = Arc::new(test_client::new_light_fetcher() + let fetcher = Arc::new(substrate_test_runtime_client::new_light_fetcher() .with_remote_body(Some(Box::new(move |_| Ok(vec![fetcher_transaction.clone()])))) .with_remote_call(Some(Box::new(move |_| { let validity: sp_runtime::transaction_validity::TransactionValidity = @@ -417,7 +417,7 @@ mod tests { let (client, longest_chain) = TestClientBuilder::new().build_with_longest_chain(); let client = Arc::new(client); - let pool = txpool::Pool::new(Default::default(), LightChainApi::new( + let pool = sc_transaction_graph::Pool::new(Default::default(), LightChainApi::new( client.clone(), fetcher.clone(), )); @@ -473,7 +473,7 @@ mod tests { let build_fetcher = || { let validated = Arc::new(atomic::AtomicBool::new(false)); - Arc::new(test_client::new_light_fetcher() + Arc::new(substrate_test_runtime_client::new_light_fetcher() .with_remote_body(Some(Box::new(move |_| Ok(vec![])))) .with_remote_call(Some(Box::new(move |_| { let is_inserted = validated.swap(true, atomic::Ordering::SeqCst); @@ -504,7 +504,7 @@ mod tests { let client = Arc::new(client); // now let's prepare pool - let pool = txpool::Pool::new(Default::default(), LightChainApi::new( + let pool = sc_transaction_graph::Pool::new(Default::default(), LightChainApi::new( client.clone(), fetcher.clone(), )); @@ -563,7 +563,7 @@ mod tests { fn should_add_reverted_transactions_to_the_pool() { let (client, longest_chain) = TestClientBuilder::new().build_with_longest_chain(); let client = Arc::new(client); - let pool = txpool::Pool::new(Default::default(), FullChainApi::new(client.clone())); + let pool = sc_transaction_graph::Pool::new(Default::default(), FullChainApi::new(client.clone())); let pool = Arc::new(pool); let transaction = Transfer { amount: 5, diff --git a/client/transaction-pool/src/tests.rs b/client/transaction-pool/src/tests.rs index 65ca06c2c3..e6bdffa945 100644 --- a/client/transaction-pool/src/tests.rs +++ b/client/transaction-pool/src/tests.rs @@ -19,8 +19,8 @@ use super::*; use codec::Encode; use futures::executor::block_on; -use txpool::{self, Pool}; -use test_client::{runtime::{AccountId, Block, Hash, Index, Extrinsic, Transfer}, AccountKeyring::{self, *}}; +use sc_transaction_graph::{self, Pool}; +use substrate_test_runtime_client::{runtime::{AccountId, Block, Hash, Index, Extrinsic, Transfer}, AccountKeyring::{self, *}}; use sp_runtime::{ generic::{self, BlockId}, traits::{Hash as HashT, BlakeTwo256}, @@ -39,7 +39,7 @@ impl TestApi { } } -impl txpool::ChainApi for TestApi { +impl sc_transaction_graph::ChainApi for TestApi { type Block = Block; type Hash = Hash; type Error = error::Error; @@ -48,7 +48,7 @@ impl txpool::ChainApi for TestApi { fn validate_transaction( &self, at: &BlockId, - uxt: txpool::ExtrinsicFor, + uxt: sc_transaction_graph::ExtrinsicFor, ) -> Self::ValidationFuture { let expected = index(at); let requires = if expected == uxt.transfer().nonce { @@ -73,18 +73,18 @@ impl txpool::ChainApi for TestApi { )) } - fn block_id_to_number(&self, at: &BlockId) -> error::Result>> { + fn block_id_to_number(&self, at: &BlockId) -> error::Result>> { Ok(Some(number_of(at))) } - fn block_id_to_hash(&self, at: &BlockId) -> error::Result>> { + fn block_id_to_hash(&self, at: &BlockId) -> error::Result>> { Ok(match at { generic::BlockId::Hash(x) => Some(x.clone()), _ => Some(Default::default()), }) } - fn hash_and_length(&self, ex: &txpool::ExtrinsicFor) -> (Self::Hash, usize) { + fn hash_and_length(&self, ex: &sc_transaction_graph::ExtrinsicFor) -> (Self::Hash, usize) { let encoded = ex.encode(); (BlakeTwo256::hash(&encoded), encoded.len()) } diff --git a/frame/assets/Cargo.toml b/frame/assets/Cargo.toml index 4618c2a831..72de7d2b8b 100644 --- a/frame/assets/Cargo.toml +++ b/frame/assets/Cargo.toml @@ -10,12 +10,12 @@ codec = { package = "parity-scale-codec", version = "1.0.0", default-features = # Needed for various traits. In our case, `OnFinalize`. sp-runtime = { path = "../../primitives/runtime", default-features = false } # Needed for type-safe access to storage DB. -support = { package = "frame-support", path = "../support", default-features = false } +frame-support = { path = "../support", default-features = false } # `system` module provides us with all sorts of useful stuff and macros depend on it being around. -system = { package = "frame-system", path = "../system", default-features = false } +frame-system = { path = "../system", default-features = false } [dev-dependencies] -primitives = { package = "sp-core", path = "../../primitives/core" } +sp-core = { path = "../../primitives/core" } sp-std = { path = "../../primitives/std" } sp-io = { path = "../../primitives/io" } @@ -25,6 +25,6 @@ std = [ "serde", "codec/std", "sp-runtime/std", - "support/std", - "system/std", + "frame-support/std", + "frame-system/std", ] diff --git a/frame/assets/src/lib.rs b/frame/assets/src/lib.rs index af2baae62b..87e74c0c6c 100644 --- a/frame/assets/src/lib.rs +++ b/frame/assets/src/lib.rs @@ -84,8 +84,8 @@ //! ### Simple Code Snippet //! //! ```rust,ignore -//! use support::{decl_module, dispatch}; -//! use system::ensure_signed; +//! use frame_support::{decl_module, dispatch}; +//! use frame_system::{self as system, ensure_signed}; //! //! pub trait Trait: assets::Trait { } //! @@ -130,15 +130,15 @@ // Ensure we're `no_std` when compiling for Wasm. #![cfg_attr(not(feature = "std"), no_std)] -use support::{Parameter, decl_module, decl_event, decl_storage, ensure}; +use frame_support::{Parameter, decl_module, decl_event, decl_storage, ensure}; use sp_runtime::traits::{Member, SimpleArithmetic, Zero, StaticLookup}; -use system::ensure_signed; +use frame_system::{self as system, ensure_signed}; use sp_runtime::traits::One; /// The module configuration trait. -pub trait Trait: system::Trait { +pub trait Trait: frame_system::Trait { /// The overarching event type. - type Event: From> + Into<::Event>; + type Event: From> + Into<::Event>; /// The units in which we record balances. type Balance: Member + Parameter + SimpleArithmetic + Default + Copy; @@ -197,7 +197,7 @@ decl_module! { decl_event!( pub enum Event where - ::AccountId, + ::AccountId, ::Balance, ::AssetId, { @@ -240,14 +240,14 @@ impl Module { mod tests { use super::*; - use support::{impl_outer_origin, assert_ok, assert_noop, parameter_types, weights::Weight}; - use primitives::H256; + use frame_support::{impl_outer_origin, assert_ok, assert_noop, parameter_types, weights::Weight}; + use sp_core::H256; // The testing primitives are very useful for avoiding having to work with signatures // or public keys. `u64` is used as the `AccountId` and no `Signature`s are required. use sp_runtime::{Perbill, traits::{BlakeTwo256, IdentityLookup}, testing::Header}; impl_outer_origin! { - pub enum Origin for Test {} + pub enum Origin for Test where system = frame_system {} } // For testing the module, we construct most of a mock runtime. This means @@ -261,7 +261,7 @@ mod tests { pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); } - impl system::Trait for Test { + impl frame_system::Trait for Test { type Origin = Origin; type Index = u64; type Call = (); @@ -288,7 +288,7 @@ mod tests { // This function basically just builds a genesis storage key/value store according to // our desired mockup. fn new_test_ext() -> sp_io::TestExternalities { - system::GenesisConfig::default().build_storage::().unwrap().into() + frame_system::GenesisConfig::default().build_storage::().unwrap().into() } #[test] diff --git a/frame/aura/Cargo.toml b/frame/aura/Cargo.toml index 68083e075f..767056aaf6 100644 --- a/frame/aura/Cargo.toml +++ b/frame/aura/Cargo.toml @@ -5,20 +5,20 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -app-crypto = { package = "sp-application-crypto", path = "../../primitives/application-crypto", default-features = false } +sp-application-crypto = { path = "../../primitives/application-crypto", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -inherents = { package = "sp-inherents", path = "../../primitives/inherents", default-features = false } -primitives = { package = "sp-core", path = "../../primitives/core", default-features = false } +sp-inherents = { path = "../../primitives/inherents", default-features = false } +sp-core = { path = "../../primitives/core", default-features = false } sp-std = { path = "../../primitives/std", default-features = false } serde = { version = "1.0.101", optional = true } -session = { package = "pallet-session", path = "../session", default-features = false } +pallet-session = { path = "../session", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } sp-io ={ path = "../../primitives/io", default-features = false } -support = { package = "frame-support", path = "../support", default-features = false } +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 } -sp-timestamp = { package = "sp-timestamp", path = "../../primitives/timestamp", default-features = false } -pallet-timestamp = { package = "pallet-timestamp", path = "../timestamp", default-features = false } +frame-system = { path = "../system", default-features = false } +sp-timestamp = { path = "../../primitives/timestamp", default-features = false } +pallet-timestamp = { path = "../timestamp", default-features = false } [dev-dependencies] @@ -28,17 +28,17 @@ parking_lot = "0.9.0" [features] default = ["std"] std = [ - "app-crypto/std", + "sp-application-crypto/std", "codec/std", - "inherents/std", + "sp-inherents/std", "sp-io/std", - "primitives/std", + "sp-core/std", "sp-std/std", "serde", "sp-runtime/std", - "support/std", + "frame-support/std", "sp-consensus-aura/std", - "system/std", + "frame-system/std", "sp-timestamp/std", "pallet-timestamp/std", ] diff --git a/frame/aura/src/lib.rs b/frame/aura/src/lib.rs index 3e691e14cb..462c30b648 100644 --- a/frame/aura/src/lib.rs +++ b/frame/aura/src/lib.rs @@ -49,7 +49,7 @@ use pallet_timestamp; use sp_std::{result, prelude::*}; use codec::{Encode, Decode}; -use support::{ +use frame_support::{ decl_storage, decl_module, Parameter, traits::{Get, FindAuthor}, ConsensusEngineId, }; @@ -58,7 +58,7 @@ use sp_runtime::{ traits::{SaturatedConversion, Saturating, Zero, Member, IsMember}, generic::DigestItem, }; use sp_timestamp::OnTimestampSet; -use inherents::{InherentIdentifier, InherentData, ProvideInherent, MakeFatalError}; +use sp_inherents::{InherentIdentifier, InherentData, ProvideInherent, MakeFatalError}; use sp_consensus_aura::{ AURA_ENGINE_ID, ConsensusLog, AuthorityIndex, inherents::{INHERENT_IDENTIFIER, AuraInherentData}, @@ -98,7 +98,7 @@ impl Module { AURA_ENGINE_ID, ConsensusLog::AuthoritiesChange(new).encode() ); - >::deposit_log(log.into()); + >::deposit_log(log.into()); } fn initialize_authorities(authorities: &[T::AuthorityId]) { @@ -113,7 +113,7 @@ impl sp_runtime::BoundToRuntimeAppPublic for Module { type Public = T::AuthorityId; } -impl session::OneSessionHandler for Module { +impl pallet_session::OneSessionHandler for Module { type Key = T::AuthorityId; fn on_genesis_session<'a, I: 'a>(validators: I) @@ -142,7 +142,7 @@ impl session::OneSessionHandler for Module { ConsensusLog::::OnDisabled(i as AuthorityIndex).encode(), ); - >::deposit_log(log.into()); + >::deposit_log(log.into()); } } @@ -206,7 +206,7 @@ impl OnTimestampSet for Module { impl ProvideInherent for Module { type Call = pallet_timestamp::Call; - type Error = MakeFatalError; + type Error = MakeFatalError; const INHERENT_IDENTIFIER: InherentIdentifier = INHERENT_IDENTIFIER; fn create_inherent(_: &InherentData) -> Option { @@ -227,7 +227,7 @@ impl ProvideInherent for Module { if timestamp_based_slot == seal_slot { Ok(()) } else { - Err(inherents::Error::from("timestamp set in block doesn't match slot in seal").into()) + Err(sp_inherents::Error::from("timestamp set in block doesn't match slot in seal").into()) } } } diff --git a/frame/aura/src/mock.rs b/frame/aura/src/mock.rs index 241f904617..758bb72597 100644 --- a/frame/aura/src/mock.rs +++ b/frame/aura/src/mock.rs @@ -24,12 +24,12 @@ use sp_runtime::{ traits::IdentityLookup, Perbill, testing::{Header, UintAuthorityId}, }; -use support::{impl_outer_origin, parameter_types, weights::Weight}; +use frame_support::{impl_outer_origin, parameter_types, weights::Weight}; use sp_io; -use primitives::H256; +use sp_core::H256; impl_outer_origin!{ - pub enum Origin for Test {} + pub enum Origin for Test where system = frame_system {} } // Workaround for https://github.com/rust-lang/rust/issues/26925 . Remove when sorted. @@ -44,7 +44,7 @@ parameter_types! { pub const MinimumPeriod: u64 = 1; } -impl system::Trait for Test { +impl frame_system::Trait for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; @@ -73,7 +73,7 @@ impl Trait for Test { } pub fn new_test_ext(authorities: Vec) -> sp_io::TestExternalities { - let mut t = system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); GenesisConfig::{ authorities: authorities.into_iter().map(|a| UintAuthorityId(a).to_public_key()).collect(), }.assimilate_storage(&mut t).unwrap(); diff --git a/frame/authority-discovery/Cargo.toml b/frame/authority-discovery/Cargo.toml index a6c5d65659..4d7b43417a 100644 --- a/frame/authority-discovery/Cargo.toml +++ b/frame/authority-discovery/Cargo.toml @@ -5,17 +5,17 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -authority-discovery-primitives = { package = "sp-authority-discovery", path = "../../primitives/authority-discovery", default-features = false } -app-crypto = { package = "sp-application-crypto", path = "../../primitives/application-crypto", default-features = false } +sp-authority-discovery = { path = "../../primitives/authority-discovery", default-features = false } +sp-application-crypto = { path = "../../primitives/application-crypto", 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-core = { path = "../../primitives/core", default-features = false } sp-std = { path = "../../primitives/std", default-features = false } serde = { version = "1.0.101", optional = true } sp-io = { path = "../../primitives/io", default-features = false } -session = { package = "pallet-session", path = "../session", default-features = false, features = ["historical" ] } +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 } -system = { package = "frame-system", path = "../system", default-features = false } +frame-support = { path = "../support", default-features = false } +frame-system = { path = "../system", default-features = false } [dev-dependencies] sp-staking = { path = "../../primitives/staking", default-features = false } @@ -23,15 +23,15 @@ sp-staking = { path = "../../primitives/staking", default-features = false } [features] default = ["std"] std = [ - "app-crypto/std", - "authority-discovery-primitives/std", + "sp-application-crypto/std", + "sp-authority-discovery/std", "codec/std", - "primitives/std", + "sp-core/std", "sp-io/std", "sp-std/std", "serde", - "session/std", + "pallet-session/std", "sp-runtime/std", - "support/std", - "system/std", + "frame-support/std", + "frame-system/std", ] diff --git a/frame/authority-discovery/src/lib.rs b/frame/authority-discovery/src/lib.rs index c63b5d5811..b4abae88dd 100644 --- a/frame/authority-discovery/src/lib.rs +++ b/frame/authority-discovery/src/lib.rs @@ -23,11 +23,11 @@ #![cfg_attr(not(feature = "std"), no_std)] use sp_std::prelude::*; -use support::{decl_module, decl_storage}; -use authority_discovery_primitives::AuthorityId; +use frame_support::{decl_module, decl_storage}; +use sp_authority_discovery::AuthorityId; /// The module's config trait. -pub trait Trait: system::Trait + session::Trait {} +pub trait Trait: frame_system::Trait + pallet_session::Trait {} decl_storage! { trait Store for Module as AuthorityDiscovery { @@ -63,7 +63,7 @@ impl sp_runtime::BoundToRuntimeAppPublic for Module { type Public = AuthorityId; } -impl session::OneSessionHandler for Module { +impl pallet_session::OneSessionHandler for Module { type Key = AuthorityId; fn on_genesis_session<'a, I: 'a>(authorities: I) @@ -92,15 +92,15 @@ impl session::OneSessionHandler for Module { #[cfg(test)] mod tests { use super::*; - use authority_discovery_primitives::{AuthorityPair}; - use app_crypto::Pair; - use primitives::{crypto::key_types, H256}; + use sp_authority_discovery::{AuthorityPair}; + use sp_application_crypto::Pair; + use sp_core::{crypto::key_types, H256}; use sp_io::TestExternalities; use sp_runtime::{ testing::{Header, UintAuthorityId}, traits::{ConvertInto, IdentityLookup, OpaqueKeys}, Perbill, KeyTypeId, }; - use support::{impl_outer_origin, parameter_types, weights::Weight}; + use frame_support::{impl_outer_origin, parameter_types, weights::Weight}; type AuthorityDiscovery = Module; type SessionIndex = u32; @@ -110,7 +110,7 @@ mod tests { impl Trait for Test {} pub struct TestOnSessionEnding; - impl session::OnSessionEnding for TestOnSessionEnding { + impl pallet_session::OnSessionEnding for TestOnSessionEnding { fn on_session_ending(_: SessionIndex, _: SessionIndex) -> Option> { None } @@ -120,10 +120,10 @@ mod tests { pub const DisabledValidatorsThreshold: Perbill = Perbill::from_percent(33); } - impl session::Trait for Test { + impl pallet_session::Trait for Test { type OnSessionEnding = TestOnSessionEnding; type Keys = UintAuthorityId; - type ShouldEndSession = session::PeriodicSessions; + type ShouldEndSession = pallet_session::PeriodicSessions; type SessionHandler = TestSessionHandler; type Event = (); type ValidatorId = AuthorityId; @@ -132,7 +132,7 @@ mod tests { type DisabledValidatorsThreshold = DisabledValidatorsThreshold; } - impl session::historical::Trait for Test { + impl pallet_session::historical::Trait for Test { type FullIdentification = (); type FullIdentificationOf = (); } @@ -149,7 +149,7 @@ mod tests { pub const AvailableBlockRatio: Perbill = Perbill::one(); } - impl system::Trait for Test { + impl frame_system::Trait for Test { type Origin = Origin; type Index = u64; type BlockNumber = BlockNumber; @@ -168,11 +168,11 @@ mod tests { } impl_outer_origin! { - pub enum Origin for Test {} + pub enum Origin for Test where system = frame_system {} } pub struct TestSessionHandler; - impl session::SessionHandler for TestSessionHandler { + impl pallet_session::SessionHandler for TestSessionHandler { const KEY_TYPE_IDS: &'static [KeyTypeId] = &[key_types::DUMMY]; fn on_new_session( @@ -190,7 +190,7 @@ mod tests { #[test] fn authorities_returns_current_authority_set() { // The whole authority discovery module ignores account ids, but we still need it for - // `session::OneSessionHandler::on_new_session`, thus its safe to use the same value everywhere. + // `pallet_session::OneSessionHandler::on_new_session`, thus its safe to use the same value everywhere. let account_id = AuthorityPair::from_seed_slice(vec![10; 32].as_ref()).unwrap().public(); let first_authorities: Vec = vec![0, 1].into_iter() @@ -203,14 +203,14 @@ mod tests { .map(AuthorityId::from) .collect(); - // Needed for `session::OneSessionHandler::on_new_session`. + // Needed for `pallet_session::OneSessionHandler::on_new_session`. let second_authorities_and_account_ids: Vec<(&AuthorityId, AuthorityId)> = second_authorities.clone() .into_iter() .map(|id| (&account_id, id)) .collect(); // Build genesis. - let mut t = system::GenesisConfig::default() + let mut t = frame_system::GenesisConfig::default() .build_storage::() .unwrap(); @@ -224,7 +224,7 @@ mod tests { let mut externalities = TestExternalities::new(t); externalities.execute_with(|| { - use session::OneSessionHandler; + use pallet_session::OneSessionHandler; AuthorityDiscovery::on_genesis_session( first_authorities.iter().map(|id| (id, id.clone())) diff --git a/frame/authorship/Cargo.toml b/frame/authorship/Cargo.toml index 40a045998c..c21ed24be1 100644 --- a/frame/authorship/Cargo.toml +++ b/frame/authorship/Cargo.toml @@ -6,14 +6,14 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -primitives = { package = "sp-core", path = "../../primitives/core", default-features = false } +sp-core = { path = "../../primitives/core", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -inherents = { package = "sp-inherents", path = "../../primitives/inherents", default-features = false } +sp-inherents = { path = "../../primitives/inherents", default-features = false } sp-authorship = { path = "../../primitives/authorship", default-features = false } 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 } +frame-support = { path = "../support", default-features = false } +frame-system = { path = "../system", default-features = false } sp-io ={ path = "../../primitives/io", default-features = false } impl-trait-for-tuples = "0.1.3" @@ -21,12 +21,12 @@ impl-trait-for-tuples = "0.1.3" default = ["std"] std = [ "codec/std", - "primitives/std", - "inherents/std", + "sp-core/std", + "sp-inherents/std", "sp-runtime/std", "sp-std/std", - "support/std", - "system/std", + "frame-support/std", + "frame-system/std", "sp-io/std", "sp-authorship/std", ] diff --git a/frame/authorship/src/lib.rs b/frame/authorship/src/lib.rs index 4aa188cf71..882e8161da 100644 --- a/frame/authorship/src/lib.rs +++ b/frame/authorship/src/lib.rs @@ -22,18 +22,18 @@ use sp_std::{result, prelude::*}; use sp_std::collections::btree_set::BTreeSet; -use support::{decl_module, decl_storage, dispatch, ensure}; -use support::traits::{FindAuthor, VerifySeal, Get}; +use frame_support::{decl_module, decl_storage, dispatch, ensure}; +use frame_support::traits::{FindAuthor, VerifySeal, Get}; use codec::{Encode, Decode}; -use system::ensure_none; +use frame_system::ensure_none; use sp_runtime::traits::{Header as HeaderT, One, Zero}; -use support::weights::SimpleDispatchInfo; -use inherents::{InherentIdentifier, ProvideInherent, InherentData}; +use frame_support::weights::SimpleDispatchInfo; +use sp_inherents::{InherentIdentifier, ProvideInherent, InherentData}; use sp_authorship::{INHERENT_IDENTIFIER, UnclesInherentData, InherentError}; const MAX_UNCLES: usize = 10; -pub trait Trait: system::Trait { +pub trait Trait: frame_system::Trait { /// Find the author of a block. type FindAuthor: FindAuthor; /// The number of blocks back we should accept uncles. @@ -209,7 +209,7 @@ impl Module { return author; } - let digest = >::digest(); + let digest = >::digest(); let pre_runtime_digests = digest.logs.iter().filter_map(|d| d.as_pre_runtime()); if let Some(author) = T::FindAuthor::find_author(pre_runtime_digests) { ::Author::put(&author); @@ -220,7 +220,7 @@ impl Module { } fn verify_and_import_uncles(new_uncles: Vec) -> dispatch::Result { - let now = >::block_number(); + let now = >::block_number(); let mut uncles = ::Uncles::get(); uncles.push(UncleEntryItem::InclusionHeight(now)); @@ -253,7 +253,7 @@ impl Module { accumulator: &mut >::Accumulator, ) -> Result, &'static str> { - let now = >::block_number(); + let now = >::block_number(); let (minimum_height, maximum_height) = { let uncle_generations = T::UncleGenerations::get(); @@ -278,7 +278,7 @@ impl Module { { let parent_number = uncle.number().clone() - One::one(); - let parent_hash = >::block_hash(&parent_number); + let parent_hash = >::block_hash(&parent_number); if &parent_hash != uncle.parent_hash() { return Err("uncle parent not in chain"); } @@ -289,7 +289,7 @@ impl Module { } let duplicate = existing_uncles.into_iter().find(|h| **h == hash).is_some(); - let in_chain = >::block_hash(uncle.number()) == hash; + let in_chain = >::block_hash(uncle.number()) == hash; if duplicate || in_chain { return Err("uncle already included") @@ -372,14 +372,14 @@ impl ProvideInherent for Module { #[cfg(test)] mod tests { use super::*; - use primitives::H256; + use sp_core::H256; use sp_runtime::{ traits::{BlakeTwo256, IdentityLookup}, testing::Header, generic::DigestItem, Perbill, }; - use support::{parameter_types, impl_outer_origin, ConsensusEngineId, weights::Weight}; + use frame_support::{parameter_types, impl_outer_origin, ConsensusEngineId, weights::Weight}; impl_outer_origin!{ - pub enum Origin for Test {} + pub enum Origin for Test where system = frame_system {} } #[derive(Clone, Eq, PartialEq)] @@ -392,7 +392,7 @@ mod tests { pub const AvailableBlockRatio: Perbill = Perbill::one(); } - impl system::Trait for Test { + impl frame_system::Trait for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; @@ -421,7 +421,7 @@ mod tests { type EventHandler = (); } - type System = system::Module; + type System = frame_system::Module; type Authorship = Module; const TEST_ID: ConsensusEngineId = [1, 2, 3, 4]; @@ -493,7 +493,7 @@ mod tests { } fn new_test_ext() -> sp_io::TestExternalities { - let t = system::GenesisConfig::default().build_storage::().unwrap(); + let t = frame_system::GenesisConfig::default().build_storage::().unwrap(); t.into() } diff --git a/frame/babe/Cargo.toml b/frame/babe/Cargo.toml index ebfc436f7a..d9f9dec339 100644 --- a/frame/babe/Cargo.toml +++ b/frame/babe/Cargo.toml @@ -8,24 +8,24 @@ edition = "2018" hex-literal = "0.2.1" codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } serde = { version = "1.0.101", optional = true } -inherents = { package = "sp-inherents", path = "../../primitives/inherents", default-features = false } +sp-inherents = { path = "../../primitives/inherents", default-features = false } sp-std = { path = "../../primitives/std", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } sp-staking = { path = "../../primitives/staking", default-features = false } -support = { package = "frame-support", path = "../support", default-features = false } -system = { package = "frame-system", path = "../system", default-features = false } -timestamp = { package = "pallet-timestamp", path = "../timestamp", default-features = false } +frame-support = { path = "../support", default-features = false } +frame-system = { path = "../system", default-features = false } +pallet-timestamp = { path = "../timestamp", default-features = false } 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 } +pallet-session = { path = "../session", default-features = false } +sp-consensus-babe = { path = "../../primitives/consensus/babe", default-features = false } sp-io ={ path = "../../primitives/io", default-features = false } [dev-dependencies] lazy_static = "1.4.0" parking_lot = "0.9.0" sp-version = { path = "../../primitives/version", default-features = false } -primitives = { package = "sp-core", path = "../../primitives/core" } -test-runtime = { package = "substrate-test-runtime", path = "../../test-utils/runtime" } +sp-core = { path = "../../primitives/core" } +substrate-test-runtime = { path = "../../test-utils/runtime" } [features] default = ["std"] @@ -33,14 +33,14 @@ std = [ "serde", "codec/std", "sp-std/std", - "support/std", + "frame-support/std", "sp-runtime/std", "sp-staking/std", - "system/std", - "timestamp/std", + "frame-system/std", + "pallet-timestamp/std", "sp-timestamp/std", - "inherents/std", - "babe-primitives/std", - "session/std", + "sp-inherents/std", + "sp-consensus-babe/std", + "pallet-session/std", "sp-io/std", ] diff --git a/frame/babe/src/lib.rs b/frame/babe/src/lib.rs index 663f29ee0c..cdc29e203c 100644 --- a/frame/babe/src/lib.rs +++ b/frame/babe/src/lib.rs @@ -20,11 +20,10 @@ #![cfg_attr(not(feature = "std"), no_std)] #![forbid(unused_must_use, unsafe_code, unused_variables, unused_must_use)] #![deny(unused_imports)] -pub use timestamp; -use sp_timestamp; +pub use pallet_timestamp; use sp_std::{result, prelude::*}; -use support::{decl_storage, decl_module, traits::FindAuthor, traits::Get}; +use frame_support::{decl_storage, decl_module, traits::FindAuthor, traits::Get}; use sp_timestamp::OnTimestampSet; use sp_runtime::{generic::DigestItem, ConsensusEngineId, Perbill}; use sp_runtime::traits::{IsMember, SaturatedConversion, Saturating, RandomnessBeacon}; @@ -34,12 +33,12 @@ use sp_staking::{ }; use codec::{Encode, Decode}; -use inherents::{InherentIdentifier, InherentData, ProvideInherent, MakeFatalError}; -use babe_primitives::{ +use sp_inherents::{InherentIdentifier, InherentData, ProvideInherent, MakeFatalError}; +use sp_consensus_babe::{ BABE_ENGINE_ID, ConsensusLog, BabeAuthorityWeight, NextEpochDescriptor, RawBabePreDigest, SlotNumber, inherents::{INHERENT_IDENTIFIER, BabeInherentData} }; -pub use babe_primitives::{AuthorityId, VRF_OUTPUT_LENGTH, PUBLIC_KEY_LENGTH}; +pub use sp_consensus_babe::{AuthorityId, VRF_OUTPUT_LENGTH, PUBLIC_KEY_LENGTH}; #[cfg(all(feature = "std", test))] mod tests; @@ -47,7 +46,7 @@ mod tests; #[cfg(all(feature = "std", test))] mod mock; -pub trait Trait: timestamp::Trait { +pub trait Trait: pallet_timestamp::Trait { /// The amount of time, in slots, that each epoch should last. type EpochDuration: Get; @@ -228,11 +227,11 @@ impl IsMember for Module { } } -impl session::ShouldEndSession for Module { +impl pallet_session::ShouldEndSession for Module { fn should_end_session(now: T::BlockNumber) -> bool { // it might be (and it is in current implementation) that session module is calling // should_end_session() from it's own on_initialize() handler - // => because session on_initialize() is called earlier than ours, let's ensure + // => because pallet_session on_initialize() is called earlier than ours, let's ensure // that we have synced with digest before checking if session should be ended. Self::do_initialize(now); @@ -292,7 +291,7 @@ impl Module { pub fn slot_duration() -> T::Moment { // we double the minimum block-period so each author can always propose within // the majority of their slot. - ::MinimumPeriod::get().saturating_mul(2.into()) + ::MinimumPeriod::get().saturating_mul(2.into()) } /// Determine whether an epoch change should take place at this block. @@ -367,7 +366,7 @@ impl Module { fn deposit_consensus(new: U) { let log: DigestItem = DigestItem::Consensus(BABE_ENGINE_ID, new.encode()); - >::deposit_log(log.into()) + >::deposit_log(log.into()) } fn deposit_vrf_output(vrf_output: &[u8; VRF_OUTPUT_LENGTH]) { @@ -393,7 +392,7 @@ impl Module { return; } - let maybe_pre_digest = >::digest() + let maybe_pre_digest = >::digest() .logs .iter() .filter_map(|s| s.as_pre_runtime()) @@ -476,7 +475,7 @@ impl sp_runtime::BoundToRuntimeAppPublic for Module { type Public = AuthorityId; } -impl session::OneSessionHandler for Module { +impl pallet_session::OneSessionHandler for Module { type Key = AuthorityId; fn on_genesis_session<'a, I: 'a>(validators: I) @@ -527,8 +526,8 @@ fn compute_randomness( } impl ProvideInherent for Module { - type Call = timestamp::Call; - type Error = MakeFatalError; + type Call = pallet_timestamp::Call; + type Error = MakeFatalError; const INHERENT_IDENTIFIER: InherentIdentifier = INHERENT_IDENTIFIER; fn create_inherent(_: &InherentData) -> Option { @@ -537,7 +536,7 @@ impl ProvideInherent for Module { fn check_inherent(call: &Self::Call, data: &InherentData) -> result::Result<(), Self::Error> { let timestamp = match call { - timestamp::Call::set(ref timestamp) => timestamp.clone(), + pallet_timestamp::Call::set(ref timestamp) => timestamp.clone(), _ => return Ok(()), }; @@ -547,7 +546,7 @@ impl ProvideInherent for Module { if timestamp_based_slot == seal_slot { Ok(()) } else { - Err(inherents::Error::from("timestamp set in block doesn't match slot in seal").into()) + Err(sp_inherents::Error::from("timestamp set in block doesn't match slot in seal").into()) } } } diff --git a/frame/babe/src/mock.rs b/frame/babe/src/mock.rs index 35a423e2ad..a8acfee291 100644 --- a/frame/babe/src/mock.rs +++ b/frame/babe/src/mock.rs @@ -18,17 +18,17 @@ #![allow(dead_code, unused_imports)] use super::{Trait, Module, GenesisConfig}; -use babe_primitives::AuthorityId; +use sp_consensus_babe::AuthorityId; use sp_runtime::{ traits::IdentityLookup, Perbill, testing::{Header, UintAuthorityId}, impl_opaque_keys, }; use sp_version::RuntimeVersion; -use support::{impl_outer_origin, parameter_types, weights::Weight}; +use frame_support::{impl_outer_origin, parameter_types, weights::Weight}; use sp_io; -use primitives::{H256, Blake2Hasher}; +use sp_core::{H256, Blake2Hasher}; impl_outer_origin!{ - pub enum Origin for Test {} + pub enum Origin for Test where system = frame_system {} } type DummyValidatorId = u64; @@ -45,11 +45,11 @@ parameter_types! { pub const MinimumPeriod: u64 = 1; pub const EpochDuration: u64 = 3; pub const ExpectedBlockTime: u64 = 1; - pub const Version: RuntimeVersion = test_runtime::VERSION; + pub const Version: RuntimeVersion = substrate_test_runtime::VERSION; pub const DisabledValidatorsThreshold: Perbill = Perbill::from_percent(16); } -impl system::Trait for Test { +impl frame_system::Trait for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; @@ -73,9 +73,9 @@ impl_opaque_keys! { } } -impl session::Trait for Test { +impl pallet_session::Trait for Test { type Event = (); - type ValidatorId = ::AccountId; + type ValidatorId = ::AccountId; type ShouldEndSession = Babe; type SessionHandler = (Babe,Babe,); type OnSessionEnding = (); @@ -85,7 +85,7 @@ impl session::Trait for Test { type DisabledValidatorsThreshold = DisabledValidatorsThreshold; } -impl timestamp::Trait for Test { +impl pallet_timestamp::Trait for Test { type Moment = u64; type OnTimestampSet = Babe; type MinimumPeriod = MinimumPeriod; @@ -98,12 +98,12 @@ impl Trait for Test { } pub fn new_test_ext(authorities: Vec) -> sp_io::TestExternalities { - let mut t = system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); GenesisConfig { authorities: authorities.into_iter().map(|a| (UintAuthorityId(a).to_public_key(), 1)).collect(), }.assimilate_storage::(&mut t).unwrap(); t.into() } -pub type System = system::Module; +pub type System = frame_system::Module; pub type Babe = Module; diff --git a/frame/babe/src/tests.rs b/frame/babe/src/tests.rs index 7ce256b43b..1ae57a6d6e 100644 --- a/frame/babe/src/tests.rs +++ b/frame/babe/src/tests.rs @@ -19,7 +19,7 @@ use super::*; use mock::{new_test_ext, Babe, Test}; use sp_runtime::{traits::OnFinalize, testing::{Digest, DigestItem}}; -use session::ShouldEndSession; +use pallet_session::ShouldEndSession; const EMPTY_RANDOMNESS: [u8; 32] = [ 74, 25, 49, 128, 53, 97, 244, 49, @@ -29,18 +29,18 @@ const EMPTY_RANDOMNESS: [u8; 32] = [ ]; fn make_pre_digest( - authority_index: babe_primitives::AuthorityIndex, - slot_number: babe_primitives::SlotNumber, - vrf_output: [u8; babe_primitives::VRF_OUTPUT_LENGTH], - vrf_proof: [u8; babe_primitives::VRF_PROOF_LENGTH], + authority_index: sp_consensus_babe::AuthorityIndex, + slot_number: sp_consensus_babe::SlotNumber, + vrf_output: [u8; sp_consensus_babe::VRF_OUTPUT_LENGTH], + vrf_proof: [u8; sp_consensus_babe::VRF_PROOF_LENGTH], ) -> Digest { - let digest_data = babe_primitives::RawBabePreDigest::Primary { + let digest_data = sp_consensus_babe::RawBabePreDigest::Primary { authority_index, slot_number, vrf_output, vrf_proof, }; - let log = DigestItem::PreRuntime(babe_primitives::BABE_ENGINE_ID, digest_data.encode()); + let log = DigestItem::PreRuntime(sp_consensus_babe::BABE_ENGINE_ID, digest_data.encode()); Digest { logs: vec![log] } } @@ -66,7 +66,7 @@ fn check_module() { }) } -type System = system::Module; +type System = frame_system::Module; #[test] fn first_block_epoch_zero_start() { @@ -103,8 +103,8 @@ fn first_block_epoch_zero_start() { assert_eq!(header.digest.logs[0], pre_digest.logs[0]); let authorities = Babe::authorities(); - let consensus_log = babe_primitives::ConsensusLog::NextEpochData( - babe_primitives::NextEpochDescriptor { + let consensus_log = sp_consensus_babe::ConsensusLog::NextEpochData( + sp_consensus_babe::NextEpochDescriptor { authorities, randomness: Babe::randomness(), } diff --git a/frame/balances/Cargo.toml b/frame/balances/Cargo.toml index 9c71401b36..cc29e3c502 100644 --- a/frame/balances/Cargo.toml +++ b/frame/balances/Cargo.toml @@ -10,13 +10,13 @@ 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 } 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 } +frame-support = { path = "../support", default-features = false } +frame-system = { path = "../system", default-features = false } [dev-dependencies] sp-io = { path = "../../primitives/io" } -primitives = { package = "sp-core", path = "../../primitives/core" } -transaction-payment = { package = "pallet-transaction-payment", path = "../transaction-payment" } +sp-core = { path = "../../primitives/core" } +pallet-transaction-payment = { path = "../transaction-payment" } [features] default = ["std"] @@ -25,7 +25,7 @@ std = [ "safe-mix/std", "codec/std", "sp-std/std", - "support/std", + "frame-support/std", "sp-runtime/std", - "system/std", + "frame-system/std", ] diff --git a/frame/balances/src/lib.rs b/frame/balances/src/lib.rs index 96737c64db..8829964238 100644 --- a/frame/balances/src/lib.rs +++ b/frame/balances/src/lib.rs @@ -107,13 +107,13 @@ //! The Contract module uses the `Currency` trait to handle gas payment, and its types inherit from `Currency`: //! //! ``` -//! use support::traits::Currency; -//! # pub trait Trait: system::Trait { +//! use frame_support::traits::Currency; +//! # pub trait Trait: frame_system::Trait { //! # type Currency: Currency; //! # } //! -//! pub type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; -//! pub type NegativeImbalanceOf = <::Currency as Currency<::AccountId>>::NegativeImbalance; +//! pub type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; +//! pub type NegativeImbalanceOf = <::Currency as Currency<::AccountId>>::NegativeImbalance; //! //! # fn main() {} //! ``` @@ -121,14 +121,14 @@ //! The Staking module uses the `LockableCurrency` trait to lock a stash account's funds: //! //! ``` -//! use support::traits::{WithdrawReasons, LockableCurrency}; +//! use frame_support::traits::{WithdrawReasons, LockableCurrency}; //! use sp_runtime::traits::Bounded; -//! pub trait Trait: system::Trait { +//! pub trait Trait: frame_system::Trait { //! type Currency: LockableCurrency; //! } //! # struct StakingLedger { -//! # stash: ::AccountId, -//! # total: <::Currency as support::traits::Currency<::AccountId>>::Balance, +//! # stash: ::AccountId, +//! # total: <::Currency as frame_support::traits::Currency<::AccountId>>::Balance, //! # phantom: std::marker::PhantomData, //! # } //! # const STAKING_ID: [u8; 8] = *b"staking "; @@ -162,7 +162,7 @@ use sp_std::prelude::*; use sp_std::{cmp, result, mem, fmt::Debug}; use codec::{Codec, Encode, Decode}; -use support::{ +use frame_support::{ StorageValue, Parameter, decl_event, decl_storage, decl_module, traits::{ UpdateBalanceOutcome, Currency, OnFreeBalanceZero, OnUnbalanced, TryDrop, @@ -179,7 +179,7 @@ use sp_runtime::{ Saturating, Bounded, }, }; -use system::{IsDeadAccount, OnNewAccount, ensure_signed, ensure_root}; +use frame_system::{self as system, IsDeadAccount, OnNewAccount, ensure_signed, ensure_root}; #[cfg(test)] mod mock; @@ -188,7 +188,7 @@ mod tests; pub use self::imbalances::{PositiveImbalance, NegativeImbalance}; -pub trait Subtrait: system::Trait { +pub trait Subtrait: frame_system::Trait { /// The balance of an account. type Balance: Parameter + Member + SimpleArithmetic + Codec + Default + Copy + MaybeSerializeDeserialize + Debug + From; @@ -212,7 +212,7 @@ pub trait Subtrait: system::Trait { type CreationFee: Get; } -pub trait Trait: system::Trait { +pub trait Trait: frame_system::Trait { /// The balance of an account. type Balance: Parameter + Member + SimpleArithmetic + Codec + Default + Copy + MaybeSerializeDeserialize + Debug + From; @@ -234,7 +234,7 @@ pub trait Trait: system::Trait { type DustRemoval: OnUnbalanced>; /// The overarching event type. - type Event: From> + Into<::Event>; + type Event: From> + Into<::Event>; /// The minimum amount required to keep an account open. type ExistentialDeposit: Get; @@ -257,7 +257,7 @@ impl, I: Instance> Subtrait for T { decl_event!( pub enum Event where - ::AccountId, + ::AccountId, >::Balance { /// A new account was created. @@ -348,7 +348,7 @@ decl_storage! { /// is invoked, giving a chance to external modules to clean up data associated with /// the deleted account. /// - /// `system::AccountNonce` is also deleted if `ReservedBalance` is also zero (it also gets + /// `frame_system::AccountNonce` is also deleted if `ReservedBalance` is also zero (it also gets /// collapsed to zero if it ever becomes less than `ExistentialDeposit`. pub FreeBalance get(fn free_balance) build(|config: &GenesisConfig| config.balances.clone()): @@ -363,7 +363,7 @@ decl_storage! { /// When this balance falls below the value of `ExistentialDeposit`, then this 'reserve account' /// is deleted: specifically, `ReservedBalance`. /// - /// `system::AccountNonce` is also deleted if `FreeBalance` is also zero (it also gets + /// `frame_system::AccountNonce` is also deleted if `FreeBalance` is also zero (it also gets /// collapsed to zero if it ever becomes less than `ExistentialDeposit`.) pub ReservedBalance get(fn reserved_balance): map T::AccountId => T::Balance; @@ -439,7 +439,7 @@ decl_module! { /// This will alter `FreeBalance` and `ReservedBalance` in storage. it will /// also decrease the total issuance of the system (`TotalIssuance`). /// If the new free or reserved balance is below the existential deposit, - /// it will reset the account nonce (`system::AccountNonce`). + /// it will reset the account nonce (`frame_system::AccountNonce`). /// /// The dispatch origin for this call is `root`. /// @@ -565,7 +565,7 @@ impl, I: Instance> Module { /// /// This just removes the nonce and leaves an event. fn reap_account(who: &T::AccountId) { - >::remove(who); + >::remove(who); Self::deposit_event(RawEvent::ReapedAccount(who.clone())); } @@ -781,7 +781,7 @@ impl, I: Instance> PartialEq for ElevatedTrait { fn eq(&self, _: &Self) -> bool { unimplemented!() } } impl, I: Instance> Eq for ElevatedTrait {} -impl, I: Instance> system::Trait for ElevatedTrait { +impl, I: Instance> frame_system::Trait for ElevatedTrait { type Origin = T::Origin; type Call = T::Call; type Index = T::Index; @@ -878,7 +878,7 @@ where return Ok(()) } - let now = >::block_number(); + let now = >::block_number(); if locks.into_iter() .all(|l| now >= l.until @@ -1140,7 +1140,7 @@ where until: T::BlockNumber, reasons: WithdrawReasons, ) { - let now = >::block_number(); + let now = >::block_number(); let mut new_lock = Some(BalanceLock { id, amount, until, reasons }); let mut locks = Self::locks(who).into_iter().filter_map(|l| if l.id == id { @@ -1163,7 +1163,7 @@ where until: T::BlockNumber, reasons: WithdrawReasons, ) { - let now = >::block_number(); + let now = >::block_number(); let mut new_lock = Some(BalanceLock { id, amount, until, reasons }); let mut locks = Self::locks(who).into_iter().filter_map(|l| if l.id == id { @@ -1190,7 +1190,7 @@ where id: LockIdentifier, who: &T::AccountId, ) { - let now = >::block_number(); + let now = >::block_number(); let locks = Self::locks(who).into_iter().filter_map(|l| if l.until > now && l.id != id { Some(l) @@ -1211,7 +1211,7 @@ where fn vesting_balance(who: &T::AccountId) -> T::Balance { if let Some(v) = Self::vesting(who) { Self::free_balance(who) - .min(v.locked_at(>::block_number())) + .min(v.locked_at(>::block_number())) } else { Zero::zero() } diff --git a/frame/balances/src/mock.rs b/frame/balances/src/mock.rs index 944aab1493..2ae15d977a 100644 --- a/frame/balances/src/mock.rs +++ b/frame/balances/src/mock.rs @@ -17,14 +17,15 @@ //! Test utilities use sp_runtime::{Perbill, traits::{ConvertInto, IdentityLookup}, testing::Header}; -use primitives::H256; +use sp_core::H256; use sp_io; -use support::{impl_outer_origin, parameter_types}; -use support::traits::Get; -use support::weights::{Weight, DispatchInfo}; +use frame_support::{impl_outer_origin, parameter_types}; +use frame_support::traits::Get; +use frame_support::weights::{Weight, DispatchInfo}; use std::cell::RefCell; use crate::{GenesisConfig, Module, Trait}; +use frame_system as system; impl_outer_origin!{ pub enum Origin for Runtime {} } @@ -59,7 +60,7 @@ parameter_types! { pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); } -impl system::Trait for Runtime { +impl frame_system::Trait for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = u64; @@ -80,7 +81,7 @@ parameter_types! { pub const TransactionBaseFee: u64 = 0; pub const TransactionByteFee: u64 = 1; } -impl transaction_payment::Trait for Runtime { +impl pallet_transaction_payment::Trait for Runtime { type Currency = Module; type OnTransactionPayment = (); type TransactionBaseFee = TransactionBaseFee; @@ -150,7 +151,7 @@ impl ExtBuilder { } pub fn build(self) -> sp_io::TestExternalities { self.set_associated_consts(); - let mut t = system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); GenesisConfig:: { balances: if self.monied { vec![ @@ -177,10 +178,10 @@ impl ExtBuilder { } } -pub type System = system::Module; +pub type System = frame_system::Module; pub type Balances = Module; -pub const CALL: &::Call = &(); +pub const CALL: &::Call = &(); /// create a transaction info struct from weight. Handy to avoid building the whole struct. pub fn info_from_weight(w: Weight) -> DispatchInfo { diff --git a/frame/balances/src/tests.rs b/frame/balances/src/tests.rs index b26ac5c691..bf0fa392fc 100644 --- a/frame/balances/src/tests.rs +++ b/frame/balances/src/tests.rs @@ -19,13 +19,13 @@ use super::*; use mock::{Balances, ExtBuilder, Runtime, System, info_from_weight, CALL}; use sp_runtime::traits::SignedExtension; -use support::{ +use frame_support::{ assert_noop, assert_ok, assert_err, traits::{LockableCurrency, LockIdentifier, WithdrawReason, WithdrawReasons, Currency, ReservableCurrency, ExistenceRequirement::AllowDeath} }; -use transaction_payment::ChargeTransactionPayment; -use system::RawOrigin; +use pallet_transaction_payment::ChargeTransactionPayment; +use frame_system::RawOrigin; const ID_1: LockIdentifier = *b"1 "; const ID_2: LockIdentifier = *b"2 "; @@ -763,7 +763,7 @@ fn transfer_keep_alive_works() { #[should_panic="the balance of any account should always be more than existential deposit."] fn cannot_set_genesis_value_below_ed() { mock::EXISTENTIAL_DEPOSIT.with(|v| *v.borrow_mut() = 11); - let mut t = system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); let _ = GenesisConfig:: { balances: vec![(1, 10)], vesting: vec![], diff --git a/frame/collective/Cargo.toml b/frame/collective/Cargo.toml index 5e24e72228..7c298dd887 100644 --- a/frame/collective/Cargo.toml +++ b/frame/collective/Cargo.toml @@ -8,27 +8,27 @@ edition = "2018" serde = { version = "1.0.101", optional = true } 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-core = { path = "../../primitives/core", default-features = false } sp-std = { path = "../../primitives/std", 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 } +frame-support = { path = "../support", default-features = false } +frame-system = { path = "../system", default-features = false } [dev-dependencies] hex-literal = "0.2.1" -balances = { package = "pallet-balances", path = "../balances" } +pallet-balances = { path = "../balances" } [features] default = ["std"] std = [ "safe-mix/std", "codec/std", - "primitives/std", + "sp-core/std", "sp-std/std", "serde", "sp-io/std", - "support/std", + "frame-support/std", "sp-runtime/std", - "system/std", + "frame-system/std", ] diff --git a/frame/collective/src/lib.rs b/frame/collective/src/lib.rs index 20f61e54ed..1fd718bc01 100644 --- a/frame/collective/src/lib.rs +++ b/frame/collective/src/lib.rs @@ -24,16 +24,16 @@ #![recursion_limit="128"] use sp_std::{prelude::*, result}; -use primitives::u32_trait::Value as U32; +use sp_core::u32_trait::Value as U32; use sp_runtime::RuntimeDebug; use sp_runtime::traits::{Hash, EnsureOrigin}; -use support::weights::SimpleDispatchInfo; -use support::{ +use frame_support::weights::SimpleDispatchInfo; +use frame_support::{ dispatch::{Dispatchable, Parameter}, codec::{Encode, Decode}, traits::{ChangeMembers, InitializeMembers}, decl_module, decl_event, decl_storage, ensure, }; -use system::{self, ensure_signed, ensure_root}; +use frame_system::{self as system, ensure_signed, ensure_root}; /// Simple index type for proposal counting. pub type ProposalIndex = u32; @@ -44,7 +44,7 @@ pub type ProposalIndex = u32; /// vote exactly once, therefore also the number of votes for any given motion. pub type MemberCount = u32; -pub trait Trait: system::Trait { +pub trait Trait: frame_system::Trait { /// The outer origin type. type Origin: From>; @@ -52,7 +52,7 @@ pub trait Trait: system::Trait { type Proposal: Parameter + Dispatchable>::Origin>; /// The outer event type. - type Event: From> + Into<::Event>; + type Event: From> + Into<::Event>; } /// Origin for the collective module. @@ -67,7 +67,7 @@ pub enum RawOrigin { } /// Origin for the collective module. -pub type Origin = RawOrigin<::AccountId, I>; +pub type Origin = RawOrigin<::AccountId, I>; #[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug)] /// Info for keeping track of a motion being voted on. @@ -104,8 +104,8 @@ decl_storage! { decl_event!( pub enum Event where - ::Hash, - ::AccountId, + ::Hash, + ::AccountId, { /// A motion (given hash) has been proposed (by given account) with a threshold (given /// `MemberCount`). @@ -128,7 +128,7 @@ decl_event!( // executed logic with other democracy function. Note that councillor operations are assigned to the // operational class. decl_module! { - pub struct Module, I: Instance=DefaultInstance> for enum Call where origin: ::Origin { + pub struct Module, I: Instance=DefaultInstance> for enum Call where origin: ::Origin { fn deposit_event() = default; /// Set the collective's membership manually to `new_members`. Be nice to the chain and @@ -379,10 +379,10 @@ impl< #[cfg(test)] mod tests { use super::*; - use support::{Hashable, assert_ok, assert_noop, parameter_types, weights::Weight}; - use system::{EventRecord, Phase}; + use frame_support::{Hashable, assert_ok, assert_noop, parameter_types, weights::Weight}; + use frame_system::{self as system, EventRecord, Phase}; use hex_literal::hex; - use primitives::H256; + use sp_core::H256; use sp_runtime::{ Perbill, traits::{BlakeTwo256, IdentityLookup, Block as BlockT}, testing::Header, BuildStorage, @@ -395,7 +395,7 @@ mod tests { pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); } - impl system::Trait for Test { + impl frame_system::Trait for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; @@ -426,7 +426,7 @@ mod tests { pub type Block = sp_runtime::generic::Block; pub type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic; - support::construct_runtime!( + frame_support::construct_runtime!( pub enum Test where Block = Block, NodeBlock = Block, @@ -458,7 +458,7 @@ mod tests { } fn make_proposal(value: u64) -> Call { - Call::System(system::Call::remark(value.encode())) + Call::System(frame_system::Call::remark(value.encode())) } #[test] diff --git a/frame/contracts/Cargo.toml b/frame/contracts/Cargo.toml index b5bd460dee..a55c6671b9 100644 --- a/frame/contracts/Cargo.toml +++ b/frame/contracts/Cargo.toml @@ -10,34 +10,34 @@ pwasm-utils = { version = "0.12.0", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } 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-core = { path = "../../primitives/core", default-features = false } sp-runtime = { path = "../../primitives/runtime", 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/sandbox", default-features = false } -support = { package = "frame-support", path = "../support", default-features = false } -system = { package = "frame-system", path = "../system", default-features = false } +sp-sandbox = { path = "../../primitives/sandbox", default-features = false } +frame-support = { path = "../support", default-features = false } +frame-system = { path = "../system", default-features = false } [dev-dependencies] wabt = "0.9.2" assert_matches = "1.3.0" hex-literal = "0.2.1" -balances = { package = "pallet-balances", path = "../balances" } -timestamp = { package = "pallet-timestamp", path = "../timestamp" } -randomness-collective-flip = { package = "pallet-randomness-collective-flip", path = "../randomness-collective-flip" } +pallet-balances = { path = "../balances" } +pallet-timestamp = { path = "../timestamp" } +pallet-randomness-collective-flip = { path = "../randomness-collective-flip" } [features] default = ["std"] std = [ "serde", "codec/std", - "primitives/std", + "sp-core/std", "sp-runtime/std", "sp-io/std", "sp-std/std", - "sandbox/std", - "support/std", - "system/std", + "sp-sandbox/std", + "frame-support/std", + "frame-system/std", "parity-wasm/std", "pwasm-utils/std", "wasmi-validation/std", diff --git a/frame/contracts/rpc/Cargo.toml b/frame/contracts/rpc/Cargo.toml index 8e69b4fb8e..bb2bbd5844 100644 --- a/frame/contracts/rpc/Cargo.toml +++ b/frame/contracts/rpc/Cargo.toml @@ -10,8 +10,8 @@ jsonrpc-core = "14.0.3" jsonrpc-core-client = "14.0.3" jsonrpc-derive = "14.0.3" sp-blockchain = { path = "../../../primitives/blockchain" } -primitives = { package = "sp-core", path = "../../../primitives/core" } -rpc-primitives = { package = "sp-rpc", path = "../../../primitives/rpc" } +sp-core = { path = "../../../primitives/core" } +sp-rpc = { path = "../../../primitives/rpc" } serde = { version = "1.0.101", features = ["derive"] } sp-runtime = { path = "../../../primitives/runtime" } pallet-contracts-rpc-runtime-api = { path = "./runtime-api" } diff --git a/frame/contracts/rpc/src/lib.rs b/frame/contracts/rpc/src/lib.rs index ab0f89bd56..01d346c66a 100644 --- a/frame/contracts/rpc/src/lib.rs +++ b/frame/contracts/rpc/src/lib.rs @@ -22,8 +22,8 @@ use sp_blockchain::HeaderBackend; use codec::Codec; use jsonrpc_core::{Error, ErrorCode, Result}; use jsonrpc_derive::rpc; -use primitives::{H256, Bytes}; -use rpc_primitives::number; +use sp_core::{H256, Bytes}; +use sp_rpc::number; use serde::{Deserialize, Serialize}; use sp_runtime::{ generic::BlockId, diff --git a/frame/contracts/src/account_db.rs b/frame/contracts/src/account_db.rs index 3f345f043f..866733cefa 100644 --- a/frame/contracts/src/account_db.rs +++ b/frame/contracts/src/account_db.rs @@ -26,9 +26,9 @@ use sp_std::collections::btree_map::{BTreeMap, Entry}; use sp_std::prelude::*; 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}; -use system; +use frame_support::traits::{Currency, Get, Imbalance, SignedImbalance, UpdateBalanceOutcome}; +use frame_support::{storage::child, StorageMap}; +use frame_system; // Note: we don't provide Option because we can't create // the trie_id in the overlay, thus we provide an overlay on the fields @@ -100,7 +100,7 @@ impl Default for ChangeEntry { } } -pub type ChangeSet = BTreeMap<::AccountId, ChangeEntry>; +pub type ChangeSet = BTreeMap<::AccountId, ChangeEntry>; pub trait AccountDb { /// Account is used when overlayed otherwise trie_id must be provided. @@ -184,7 +184,7 @@ impl AccountDb for DirectAccountDb { code_hash, storage_size: T::StorageSizeOffset::get(), trie_id: ::TrieIdGenerator::trie_id(&address), - deduct_block: >::block_number(), + deduct_block: >::block_number(), rent_allowance: >::max_value(), last_write: None, } @@ -195,7 +195,7 @@ impl AccountDb for DirectAccountDb { code_hash, storage_size: T::StorageSizeOffset::get(), trie_id: ::TrieIdGenerator::trie_id(&address), - deduct_block: >::block_number(), + deduct_block: >::block_number(), rent_allowance: >::max_value(), last_write: None, } @@ -213,7 +213,7 @@ impl AccountDb for DirectAccountDb { } if !changed.storage.is_empty() { - new_info.last_write = Some(>::block_number()); + new_info.last_write = Some(>::block_number()); } for (k, v) in changed.storage.into_iter() { diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index 9243d9f8c1..c2a20ec4a1 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -22,20 +22,20 @@ use crate::rent; use sp_std::prelude::*; use sp_runtime::traits::{Bounded, CheckedAdd, CheckedSub, Zero}; -use support::{ +use frame_support::{ storage::unhashed, traits::{WithdrawReason, Currency, Time, Randomness}, }; -pub type AccountIdOf = ::AccountId; +pub type AccountIdOf = ::AccountId; pub type CallOf = ::Call; pub type MomentOf = <::Time as Time>::Moment; -pub type SeedOf = ::Hash; -pub type BlockNumberOf = ::BlockNumber; +pub type SeedOf = ::Hash; +pub type BlockNumberOf = ::BlockNumber; pub type StorageKey = [u8; 32]; /// A type that represents a topic of an event. At the moment a hash is used. -pub type TopicOf = ::Hash; +pub type TopicOf = ::Hash; /// A status code return to the source of a contract call or instantiation indicating success or /// failure. A code of 0 indicates success and that changes are applied. All other codes indicate @@ -304,7 +304,7 @@ where vm: &vm, loader: &loader, timestamp: T::Time::now(), - block_number: >::block_number(), + block_number: >::block_number(), } } @@ -871,7 +871,7 @@ mod tests { fn insert(&mut self, f: impl Fn(MockCtx) -> ExecResult + 'a) -> CodeHash { // Generate code hashes as monotonically increasing values. - let code_hash = ::Hash::from_low_u64_be(self.counter); + let code_hash = ::Hash::from_low_u64_be(self.counter); self.counter += 1; self.map.insert(code_hash, MockExecutable::new(f)); diff --git a/frame/contracts/src/gas.rs b/frame/contracts/src/gas.rs index b9faaf298f..f914aaad1b 100644 --- a/frame/contracts/src/gas.rs +++ b/frame/contracts/src/gas.rs @@ -19,7 +19,7 @@ use sp_std::convert::TryFrom; use sp_runtime::traits::{ CheckedMul, Zero, SaturatedConversion, SimpleArithmetic, UniqueSaturatedInto, }; -use support::{ +use frame_support::{ traits::{Currency, ExistenceRequirement, Imbalance, OnUnbalanced, WithdrawReason}, StorageValue, }; diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index 0642049478..83f11b1d9f 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -108,7 +108,7 @@ pub use crate::exec::{ExecResult, ExecReturnValue, ExecError, StatusCode}; #[cfg(feature = "std")] use serde::{Serialize, Deserialize}; -use primitives::crypto::UncheckedFrom; +use sp_core::crypto::UncheckedFrom; use sp_std::{prelude::*, marker::PhantomData, fmt::Debug}; use codec::{Codec, Encode, Decode}; use sp_io::hashing::blake2_256; @@ -119,17 +119,17 @@ use sp_runtime::{ }, RuntimeDebug, }; -use support::dispatch::{Result, Dispatchable}; -use support::{ +use frame_support::dispatch::{Result, Dispatchable}; +use frame_support::{ Parameter, decl_module, decl_event, decl_storage, storage::child, parameter_types, IsSubType, weights::DispatchInfo, }; -use support::traits::{OnFreeBalanceZero, OnUnbalanced, Currency, Get, Time, Randomness}; -use system::{ensure_signed, RawOrigin, ensure_root}; -use primitives::storage::well_known_keys::CHILD_STORAGE_KEY_PREFIX; +use frame_support::traits::{OnFreeBalanceZero, OnUnbalanced, Currency, Get, Time, Randomness}; +use frame_system::{self as system, ensure_signed, RawOrigin, ensure_root}; +use sp_core::storage::well_known_keys::CHILD_STORAGE_KEY_PREFIX; -pub type CodeHash = ::Hash; +pub type CodeHash = ::Hash; pub type TrieId = Vec; /// A function that generates an `AccountId` for a contract upon instantiation. @@ -203,7 +203,7 @@ impl ContractInfo { } pub type AliveContractInfo = - RawAliveContractInfo, BalanceOf, ::BlockNumber>; + RawAliveContractInfo, BalanceOf, ::BlockNumber>; /// Information for managing an account and its sub trie abstraction. /// This is the required info to cache for an account. @@ -237,7 +237,7 @@ pub(crate) fn trie_unique_id(trie_id: &[u8]) -> child::ChildInfo { } pub type TombstoneContractInfo = - RawTombstoneContractInfo<::Hash, ::Hashing>; + RawTombstoneContractInfo<::Hash, ::Hashing>; #[derive(Encode, Decode, PartialEq, Eq, RuntimeDebug)] pub struct RawTombstoneContractInfo(H, PhantomData); @@ -303,9 +303,9 @@ where } } -pub type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; +pub type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; pub type NegativeImbalanceOf = - <::Currency as Currency<::AccountId>>::NegativeImbalance; + <::Currency as Currency<::AccountId>>::NegativeImbalance; parameter_types! { /// A reasonable default value for [`Trait::SignedClaimedHandicap`]. @@ -342,16 +342,16 @@ parameter_types! { pub const DefaultBlockGasLimit: u32 = 10_000_000; } -pub trait Trait: system::Trait { +pub trait Trait: frame_system::Trait { type Currency: Currency; type Time: Time; type Randomness: Randomness; /// The outer call dispatch type. - type Call: Parameter + Dispatchable::Origin> + IsSubType, Self>; + type Call: Parameter + Dispatchable::Origin> + IsSubType, Self>; /// The overarching event type. - type Event: From> + Into<::Event>; + type Event: From> + Into<::Event>; /// A function type to get the contract address given the instantiator. type DetermineContractAddress: ContractAddressFor, Self::AccountId>; @@ -469,7 +469,7 @@ impl ComputeDispatchFee<::Call, BalanceOf> for DefaultD decl_module! { /// Contracts module. - pub struct Module for enum Call where origin: ::Origin { + pub struct Module for enum Call where origin: ::Origin { /// Number of block delay an extrinsic claim surcharge has. /// /// When claim surcharge is called by an extrinsic the rent is checked @@ -630,10 +630,10 @@ decl_module! { fn claim_surcharge(origin, dest: T::AccountId, aux_sender: Option) { let origin = origin.into(); let (signed, rewarded) = match (origin, aux_sender) { - (Ok(system::RawOrigin::Signed(account)), None) => { + (Ok(frame_system::RawOrigin::Signed(account)), None) => { (true, account) }, - (Ok(system::RawOrigin::None), Some(aux_sender)) => { + (Ok(frame_system::RawOrigin::None), Some(aux_sender)) => { (false, aux_sender) }, _ => return Err( @@ -751,7 +751,7 @@ impl Module { DepositEvent { topics, event, - } => >::deposit_event_indexed( + } => >::deposit_event_indexed( &*topics, ::Event::from(event).into(), ), @@ -788,7 +788,7 @@ impl Module { .and_then(|c| c.get_alive()) .ok_or("Cannot restore from inexisting or tombstone contract")?; - let current_block = >::block_number(); + let current_block = >::block_number(); if origin_contract.last_write == Some(current_block) { return Err("Origin TrieId written in the current block"); @@ -870,8 +870,8 @@ decl_event! { pub enum Event where Balance = BalanceOf, - ::AccountId, - ::Hash + ::AccountId, + ::Hash { /// Transfer happened `from` to `to` with given `value` as part of a `call` or `instantiate`. Transfer(AccountId, AccountId, Balance), diff --git a/frame/contracts/src/rent.rs b/frame/contracts/src/rent.rs index d4ca5ec7f7..c75dd97ff3 100644 --- a/frame/contracts/src/rent.rs +++ b/frame/contracts/src/rent.rs @@ -17,9 +17,9 @@ use crate::{BalanceOf, ContractInfo, ContractInfoOf, TombstoneContractInfo, Trait, AliveContractInfo}; use sp_runtime::traits::{Bounded, CheckedDiv, CheckedMul, Saturating, Zero, SaturatedConversion}; -use support::traits::{Currency, ExistenceRequirement, Get, WithdrawReason, OnUnbalanced}; -use support::StorageMap; -use support::storage::child; +use frame_support::traits::{Currency, ExistenceRequirement, Get, WithdrawReason, OnUnbalanced}; +use frame_support::StorageMap; +use frame_support::storage::child; #[derive(PartialEq, Eq, Copy, Clone)] #[must_use] @@ -58,7 +58,7 @@ fn try_evict_or_and_pay_rent( Some(ContractInfo::Alive(contract)) => contract, }; - let current_block_number = >::block_number(); + let current_block_number = >::block_number(); // How much block has passed since the last deduction for the contract. let blocks_passed = { diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 153a70d54b..160b1d74dc 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -32,29 +32,32 @@ use sp_runtime::{ traits::{BlakeTwo256, Hash, IdentityLookup, SignedExtension}, testing::{Digest, DigestItem, Header, UintAuthorityId, H256}, }; -use support::{ +use frame_support::{ assert_ok, assert_err, impl_outer_dispatch, impl_outer_event, impl_outer_origin, parameter_types, storage::child, StorageMap, StorageValue, traits::{Currency, Get}, weights::{DispatchInfo, DispatchClass, Weight}, }; use std::{cell::RefCell, sync::atomic::{AtomicUsize, Ordering}}; -use primitives::storage::well_known_keys; -use system::{self, EventRecord, Phase}; +use sp_core::storage::well_known_keys; +use frame_system::{self as system, EventRecord, Phase}; mod contract { // Re-export contents of the root. This basically // needs to give a name for the current crate. // This hack is required for `impl_outer_event!`. pub use super::super::*; - use support::impl_outer_event; + use frame_support::impl_outer_event; } + +use pallet_balances as balances; + impl_outer_event! { pub enum MetaEvent for Test { balances, contract, } } impl_outer_origin! { - pub enum Origin for Test { } + pub enum Origin for Test where system = frame_system { } } impl_outer_dispatch! { pub enum Call for Test where origin: Origin { @@ -98,7 +101,7 @@ parameter_types! { pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); } -impl system::Trait for Test { +impl frame_system::Trait for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; @@ -115,7 +118,7 @@ impl system::Trait for Test { type MaximumBlockLength = MaximumBlockLength; type Version = (); } -impl balances::Trait for Test { +impl pallet_balances::Trait for Test { type Balance = u64; type OnFreeBalanceZero = Contract; type OnNewAccount = (); @@ -129,7 +132,7 @@ impl balances::Trait for Test { parameter_types! { pub const MinimumPeriod: u64 = 1; } -impl timestamp::Trait for Test { +impl pallet_timestamp::Trait for Test { type Moment = u64; type OnTimestampSet = (); type MinimumPeriod = MinimumPeriod; @@ -178,11 +181,11 @@ impl Trait for Test { type BlockGasLimit = BlockGasLimit; } -type Balances = balances::Module; -type Timestamp = timestamp::Module; +type Balances = pallet_balances::Module; +type Timestamp = pallet_timestamp::Module; type Contract = Module; -type System = system::Module; -type Randomness = randomness_collective_flip::Module; +type System = frame_system::Module; +type Randomness = pallet_randomness_collective_flip::Module; pub struct DummyContractAddressFor; impl ContractAddressFor for DummyContractAddressFor { @@ -194,7 +197,7 @@ impl ContractAddressFor for DummyContractAddressFor { pub struct DummyTrieIdGenerator; impl TrieIdGenerator for DummyTrieIdGenerator { fn trie_id(account_id: &u64) -> TrieId { - use primitives::storage::well_known_keys; + use sp_core::storage::well_known_keys; let new_seed = super::AccountCounter::mutate(|v| { *v = v.wrapping_add(1); @@ -270,8 +273,8 @@ impl ExtBuilder { } pub fn build(self) -> sp_io::TestExternalities { self.set_associated_consts(); - let mut t = system::GenesisConfig::default().build_storage::().unwrap(); - balances::GenesisConfig:: { + let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + pallet_balances::GenesisConfig:: { balances: vec![], vesting: vec![], }.assimilate_storage(&mut t).unwrap(); @@ -289,7 +292,7 @@ impl ExtBuilder { /// Generate Wasm binary and code hash from wabt source. fn compile_module(wabt_module: &str) -> Result<(Vec, ::Output), wabt::Error> - where T: system::Trait + where T: frame_system::Trait { let wasm = wabt::wat2wasm(wabt_module)?; let code_hash = T::Hashing::hash(&wasm); @@ -426,7 +429,7 @@ fn instantiate_and_call_and_deposit_event() { assert_eq!(System::events(), vec![ EventRecord { phase: Phase::ApplyExtrinsic(0), - event: MetaEvent::balances(balances::RawEvent::NewAccount(1, 1_000_000)), + event: MetaEvent::balances(pallet_balances::RawEvent::NewAccount(1, 1_000_000)), topics: vec![], }, EventRecord { @@ -437,7 +440,7 @@ fn instantiate_and_call_and_deposit_event() { EventRecord { phase: Phase::ApplyExtrinsic(0), event: MetaEvent::balances( - balances::RawEvent::NewAccount(BOB, 100) + pallet_balances::RawEvent::NewAccount(BOB, 100) ), topics: vec![], }, @@ -484,7 +487,7 @@ const CODE_DISPATCH_CALL: &str = r#" fn dispatch_call() { // This test can fail due to the encoding changes. In case it becomes too annoying // let's rewrite so as we use this module controlled call or we serialize it in runtime. - let encoded = Encode::encode(&Call::Balances(balances::Call::transfer(CHARLIE, 50))); + let encoded = Encode::encode(&Call::Balances(pallet_balances::Call::transfer(CHARLIE, 50))); assert_eq!(&encoded[..], &hex!("00000300000000000000C8")[..]); let (wasm, code_hash) = compile_module::(CODE_DISPATCH_CALL).unwrap(); @@ -499,7 +502,7 @@ fn dispatch_call() { assert_eq!(System::events(), vec![ EventRecord { phase: Phase::ApplyExtrinsic(0), - event: MetaEvent::balances(balances::RawEvent::NewAccount(1, 1_000_000)), + event: MetaEvent::balances(pallet_balances::RawEvent::NewAccount(1, 1_000_000)), topics: vec![], }, EventRecord { @@ -528,7 +531,7 @@ fn dispatch_call() { assert_eq!(System::events(), vec![ EventRecord { phase: Phase::ApplyExtrinsic(0), - event: MetaEvent::balances(balances::RawEvent::NewAccount(1, 1_000_000)), + event: MetaEvent::balances(pallet_balances::RawEvent::NewAccount(1, 1_000_000)), topics: vec![], }, EventRecord { @@ -539,7 +542,7 @@ fn dispatch_call() { EventRecord { phase: Phase::ApplyExtrinsic(0), event: MetaEvent::balances( - balances::RawEvent::NewAccount(BOB, 100) + pallet_balances::RawEvent::NewAccount(BOB, 100) ), topics: vec![], }, @@ -558,14 +561,14 @@ fn dispatch_call() { EventRecord { phase: Phase::ApplyExtrinsic(0), event: MetaEvent::balances( - balances::RawEvent::NewAccount(CHARLIE, 50) + pallet_balances::RawEvent::NewAccount(CHARLIE, 50) ), topics: vec![], }, EventRecord { phase: Phase::ApplyExtrinsic(0), event: MetaEvent::balances( - balances::RawEvent::Transfer(BOB, CHARLIE, 50, 0) + pallet_balances::RawEvent::Transfer(BOB, CHARLIE, 50, 0) ), topics: vec![], }, @@ -602,7 +605,7 @@ const CODE_DISPATCH_CALL_THEN_TRAP: &str = r#" fn dispatch_call_not_dispatched_after_top_level_transaction_failure() { // This test can fail due to the encoding changes. In case it becomes too annoying // let's rewrite so as we use this module controlled call or we serialize it in runtime. - let encoded = Encode::encode(&Call::Balances(balances::Call::transfer(CHARLIE, 50))); + let encoded = Encode::encode(&Call::Balances(pallet_balances::Call::transfer(CHARLIE, 50))); assert_eq!(&encoded[..], &hex!("00000300000000000000C8")[..]); let (wasm, code_hash) = compile_module::(CODE_DISPATCH_CALL_THEN_TRAP).unwrap(); @@ -617,7 +620,7 @@ fn dispatch_call_not_dispatched_after_top_level_transaction_failure() { assert_eq!(System::events(), vec![ EventRecord { phase: Phase::ApplyExtrinsic(0), - event: MetaEvent::balances(balances::RawEvent::NewAccount(1, 1_000_000)), + event: MetaEvent::balances(pallet_balances::RawEvent::NewAccount(1, 1_000_000)), topics: vec![], }, EventRecord { @@ -650,7 +653,7 @@ fn dispatch_call_not_dispatched_after_top_level_transaction_failure() { assert_eq!(System::events(), vec![ EventRecord { phase: Phase::ApplyExtrinsic(0), - event: MetaEvent::balances(balances::RawEvent::NewAccount(1, 1_000_000)), + event: MetaEvent::balances(pallet_balances::RawEvent::NewAccount(1, 1_000_000)), topics: vec![], }, EventRecord { @@ -661,7 +664,7 @@ fn dispatch_call_not_dispatched_after_top_level_transaction_failure() { EventRecord { phase: Phase::ApplyExtrinsic(0), event: MetaEvent::balances( - balances::RawEvent::NewAccount(BOB, 100) + pallet_balances::RawEvent::NewAccount(BOB, 100) ), topics: vec![], }, @@ -802,7 +805,7 @@ mod call { fn test_set_rent_code_and_hash() { // This test can fail due to the encoding changes. In case it becomes too annoying // let's rewrite so as we use this module controlled call or we serialize it in runtime. - let encoded = Encode::encode(&Call::Balances(balances::Call::transfer(CHARLIE, 50))); + let encoded = Encode::encode(&Call::Balances(pallet_balances::Call::transfer(CHARLIE, 50))); assert_eq!(&encoded[..], &hex!("00000300000000000000C8")[..]); let (wasm, code_hash) = compile_module::(CODE_SET_RENT).unwrap(); @@ -816,7 +819,7 @@ fn test_set_rent_code_and_hash() { assert_eq!(System::events(), vec![ EventRecord { phase: Phase::ApplyExtrinsic(0), - event: MetaEvent::balances(balances::RawEvent::NewAccount(1, 1_000_000)), + event: MetaEvent::balances(pallet_balances::RawEvent::NewAccount(1, 1_000_000)), topics: vec![], }, EventRecord { @@ -841,7 +844,7 @@ fn storage_size() { Origin::signed(ALICE), 30_000, 100_000, code_hash.into(), - ::Balance::from(1_000u32).encode() // rent allowance + ::Balance::from(1_000u32).encode() // rent allowance )); let bob_contract = ContractInfoOf::::get(BOB).unwrap().get_alive().unwrap(); assert_eq!(bob_contract.storage_size, ::StorageSizeOffset::get() + 4); @@ -868,7 +871,7 @@ fn deduct_blocks() { Origin::signed(ALICE), 30_000, 100_000, code_hash.into(), - ::Balance::from(1_000u32).encode() // rent allowance + ::Balance::from(1_000u32).encode() // rent allowance )); // Check creation @@ -962,7 +965,7 @@ fn claim_surcharge(blocks: u64, trigger_call: impl Fn() -> bool, removes: bool) Origin::signed(ALICE), 100, 100_000, code_hash.into(), - ::Balance::from(1_000u32).encode() // rent allowance + ::Balance::from(1_000u32).encode() // rent allowance )); // Advance blocks @@ -995,7 +998,7 @@ fn removals(trigger_call: impl Fn() -> bool) { Origin::signed(ALICE), 100, 100_000, code_hash.into(), - ::Balance::from(1_000u32).encode() // rent allowance + ::Balance::from(1_000u32).encode() // rent allowance )); let subsistence_threshold = 50 /*existential_deposit*/ + 16 /*tombstone_deposit*/; @@ -1031,7 +1034,7 @@ fn removals(trigger_call: impl Fn() -> bool) { Origin::signed(ALICE), 1_000, 100_000, code_hash.into(), - ::Balance::from(100u32).encode() // rent allowance + ::Balance::from(100u32).encode() // rent allowance )); // Trigger rent must have no effect @@ -1066,7 +1069,7 @@ fn removals(trigger_call: impl Fn() -> bool) { Origin::signed(ALICE), 50+Balances::minimum_balance(), 100_000, code_hash.into(), - ::Balance::from(1_000u32).encode() // rent allowance + ::Balance::from(1_000u32).encode() // rent allowance )); // Trigger rent must have no effect @@ -1110,7 +1113,7 @@ fn call_removed_contract() { Origin::signed(ALICE), 100, 100_000, code_hash.into(), - ::Balance::from(1_000u32).encode() // rent allowance + ::Balance::from(1_000u32).encode() // rent allowance )); // Calling contract should succeed. @@ -1311,7 +1314,7 @@ fn restoration(test_different_storage: bool, test_restore_to_with_dirty_storage: assert_eq!(System::events(), vec![ EventRecord { phase: Phase::ApplyExtrinsic(0), - event: MetaEvent::balances(balances::RawEvent::NewAccount(1, 1_000_000)), + event: MetaEvent::balances(pallet_balances::RawEvent::NewAccount(1, 1_000_000)), topics: vec![], }, EventRecord { @@ -1333,7 +1336,7 @@ fn restoration(test_different_storage: bool, test_restore_to_with_dirty_storage: 30_000, 100_000, set_rent_code_hash.into(), - ::Balance::from(0u32).encode() + ::Balance::from(0u32).encode() )); // Check if `BOB` was created successfully and that the rent allowance is @@ -1370,7 +1373,7 @@ fn restoration(test_different_storage: bool, test_restore_to_with_dirty_storage: 30_000, 100_000, restoration_code_hash.into(), - ::Balance::from(0u32).encode() + ::Balance::from(0u32).encode() )); // Before performing a call to `DJANGO` save its original trie id. @@ -2425,7 +2428,7 @@ fn get_runtime_storage() { ExtBuilder::default().existential_deposit(50).build().execute_with(|| { Balances::deposit_creating(&ALICE, 1_000_000); - support::storage::unhashed::put_raw( + frame_support::storage::unhashed::put_raw( &[1, 2, 3, 4], 0x14144020u32.to_le_bytes().to_vec().as_ref() ); diff --git a/frame/contracts/src/wasm/code_cache.rs b/frame/contracts/src/wasm/code_cache.rs index 7264122397..ada28ffc15 100644 --- a/frame/contracts/src/wasm/code_cache.rs +++ b/frame/contracts/src/wasm/code_cache.rs @@ -31,7 +31,7 @@ use crate::wasm::{prepare, runtime::Env, PrefabWasmModule}; use crate::{CodeHash, CodeStorage, PristineCode, Schedule, Trait}; use sp_std::prelude::*; use sp_runtime::traits::{Hash, Bounded}; -use support::StorageMap; +use frame_support::StorageMap; /// Gas metering token that used for charging storing code into the code storage. /// diff --git a/frame/contracts/src/wasm/env_def/macros.rs b/frame/contracts/src/wasm/env_def/macros.rs index 0f36095048..e02be90b8e 100644 --- a/frame/contracts/src/wasm/env_def/macros.rs +++ b/frame/contracts/src/wasm/env_def/macros.rs @@ -96,7 +96,7 @@ macro_rules! unmarshall_then_body { #[inline(always)] pub fn constrain_closure(f: F) -> F where - F: FnOnce() -> Result, + F: FnOnce() -> Result, { f } @@ -110,14 +110,14 @@ macro_rules! unmarshall_then_body_then_marshall { unmarshall_then_body!($body, $ctx, $args_iter, $( $names : $params ),*) }); let r = body()?; - return Ok(sandbox::ReturnValue::Value({ use $crate::wasm::env_def::ConvertibleToWasm; r.to_typed_value() })) + return Ok(sp_sandbox::ReturnValue::Value({ use $crate::wasm::env_def::ConvertibleToWasm; r.to_typed_value() })) }); ( $args_iter:ident, $ctx:ident, ( $( $names:ident : $params:ty ),* ) => $body:tt ) => ({ let body = $crate::wasm::env_def::macros::constrain_closure::<(), _>(|| { unmarshall_then_body!($body, $ctx, $args_iter, $( $names : $params ),*) }); body()?; - return Ok(sandbox::ReturnValue::Unit) + return Ok(sp_sandbox::ReturnValue::Unit) }) } @@ -126,8 +126,8 @@ macro_rules! define_func { ( < E: $ext_ty:tt > $name:ident ( $ctx: ident $(, $names:ident : $params:ty)*) $(-> $returns:ty)* => $body:tt ) => { fn $name< E: $ext_ty >( $ctx: &mut $crate::wasm::Runtime, - args: &[sandbox::TypedValue], - ) -> Result { + args: &[sp_sandbox::TypedValue], + ) -> Result { #[allow(unused)] let mut args = args.iter(); @@ -196,7 +196,7 @@ mod tests { use parity_wasm::elements::FunctionType; use parity_wasm::elements::ValueType; use sp_runtime::traits::Zero; - use sandbox::{self, ReturnValue, TypedValue}; + use sp_sandbox::{self, ReturnValue, TypedValue}; use crate::wasm::tests::MockExt; use crate::wasm::Runtime; use crate::exec::Ext; @@ -206,15 +206,15 @@ mod tests { fn macro_unmarshall_then_body_then_marshall_value_or_trap() { fn test_value( _ctx: &mut u32, - args: &[sandbox::TypedValue], - ) -> Result { + args: &[sp_sandbox::TypedValue], + ) -> Result { let mut args = args.iter(); unmarshall_then_body_then_marshall!( args, _ctx, (a: u32, b: u32) -> u32 => { if b == 0 { - Err(sandbox::HostError) + Err(sp_sandbox::HostError) } else { Ok(a / b) } @@ -234,8 +234,8 @@ mod tests { fn macro_unmarshall_then_body_then_marshall_unit() { fn test_unit( ctx: &mut u32, - args: &[sandbox::TypedValue], - ) -> Result { + args: &[sp_sandbox::TypedValue], + ) -> Result { let mut args = args.iter(); unmarshall_then_body_then_marshall!( args, @@ -260,11 +260,11 @@ mod tests { if !amount.is_zero() { Ok(()) } else { - Err(sandbox::HostError) + Err(sp_sandbox::HostError) } }); - let _f: fn(&mut Runtime, &[sandbox::TypedValue]) - -> Result = ext_gas::; + let _f: fn(&mut Runtime, &[sp_sandbox::TypedValue]) + -> Result = ext_gas::; } #[test] @@ -312,7 +312,7 @@ mod tests { if !amount.is_zero() { Ok(()) } else { - Err(sandbox::HostError) + Err(sp_sandbox::HostError) } }, ); diff --git a/frame/contracts/src/wasm/env_def/mod.rs b/frame/contracts/src/wasm/env_def/mod.rs index d51a157910..30c1b5455d 100644 --- a/frame/contracts/src/wasm/env_def/mod.rs +++ b/frame/contracts/src/wasm/env_def/mod.rs @@ -17,7 +17,7 @@ use super::Runtime; use crate::exec::Ext; -use sandbox::{self, TypedValue}; +use sp_sandbox::{self, TypedValue}; use parity_wasm::elements::{FunctionType, ValueType}; #[macro_use] @@ -69,8 +69,8 @@ impl ConvertibleToWasm for u64 { pub(crate) type HostFunc = fn( &mut Runtime, - &[sandbox::TypedValue] - ) -> Result; + &[sp_sandbox::TypedValue] + ) -> Result; pub(crate) trait FunctionImplProvider { fn impls)>(f: &mut F); diff --git a/frame/contracts/src/wasm/mod.rs b/frame/contracts/src/wasm/mod.rs index 273b7fb037..472951efb5 100644 --- a/frame/contracts/src/wasm/mod.rs +++ b/frame/contracts/src/wasm/mod.rs @@ -24,7 +24,7 @@ use crate::gas::GasMeter; use sp_std::prelude::*; use codec::{Encode, Decode}; -use sandbox; +use sp_sandbox; #[macro_use] mod env_def; @@ -114,7 +114,7 @@ impl<'a, T: Trait> crate::exec::Vm for WasmVm<'a> { gas_meter: &mut GasMeter, ) -> ExecResult { let memory = - sandbox::Memory::new(exec.prefab_module.initial, Some(exec.prefab_module.maximum)) + sp_sandbox::Memory::new(exec.prefab_module.initial, Some(exec.prefab_module.maximum)) .unwrap_or_else(|_| { // unlike `.expect`, explicit panic preserves the source location. // Needed as we can't use `RUST_BACKTRACE` in here. @@ -125,7 +125,7 @@ impl<'a, T: Trait> crate::exec::Vm for WasmVm<'a> { ) }); - let mut imports = sandbox::EnvironmentDefinitionBuilder::new(); + let mut imports = sp_sandbox::EnvironmentDefinitionBuilder::new(); imports.add_memory("env", "memory", memory.clone()); runtime::Env::impls(&mut |name, func_ptr| { imports.add_host_func("env", name, func_ptr); @@ -141,7 +141,7 @@ impl<'a, T: Trait> crate::exec::Vm for WasmVm<'a> { // Instantiate the instance from the instrumented module code and invoke the contract // entrypoint. - let result = sandbox::Instance::new(&exec.prefab_module.code, &imports, &mut runtime) + let result = sp_sandbox::Instance::new(&exec.prefab_module.code, &imports, &mut runtime) .and_then(|mut instance| instance.invoke(exec.entrypoint_name, &[], &mut runtime)); to_execution_result(runtime, result) } @@ -152,7 +152,7 @@ mod tests { use super::*; use std::collections::HashMap; use std::cell::RefCell; - use primitives::H256; + use sp_core::H256; use crate::exec::{Ext, StorageKey, ExecError, ExecReturnValue, STATUS_SUCCESS}; use crate::gas::{Gas, GasMeter}; use crate::tests::{Test, Call}; @@ -1111,7 +1111,7 @@ mod tests { assert_eq!( &mock_ext.dispatches, &[DispatchEntry( - Call::Balances(balances::Call::set_balance(42, 1337, 0)), + Call::Balances(pallet_balances::Call::set_balance(42, 1337, 0)), )] ); } diff --git a/frame/contracts/src/wasm/runtime.rs b/frame/contracts/src/wasm/runtime.rs index 0204d4eba0..98675aa0e4 100644 --- a/frame/contracts/src/wasm/runtime.rs +++ b/frame/contracts/src/wasm/runtime.rs @@ -21,8 +21,8 @@ use crate::exec::{ Ext, ExecResult, ExecError, ExecReturnValue, StorageKey, TopicOf, STATUS_SUCCESS, }; use crate::gas::{Gas, GasMeter, Token, GasMeterResult, approx_gas_for_balance}; -use sandbox; -use system; +use sp_sandbox; +use frame_system; use sp_std::prelude::*; use sp_std::convert::TryInto; use sp_std::mem; @@ -48,7 +48,7 @@ pub(crate) struct Runtime<'a, E: Ext + 'a> { ext: &'a mut E, scratch_buf: Vec, schedule: &'a Schedule, - memory: sandbox::Memory, + memory: sp_sandbox::Memory, gas_meter: &'a mut GasMeter, special_trap: Option, } @@ -57,7 +57,7 @@ impl<'a, E: Ext + 'a> Runtime<'a, E> { ext: &'a mut E, input_data: Vec, schedule: &'a Schedule, - memory: sandbox::Memory, + memory: sp_sandbox::Memory, gas_meter: &'a mut GasMeter, ) -> Self { Runtime { @@ -74,7 +74,7 @@ impl<'a, E: Ext + 'a> Runtime<'a, E> { pub(crate) fn to_execution_result( runtime: Runtime, - sandbox_result: Result, + sandbox_result: Result, ) -> ExecResult { // Special case. The trap was the result of the execution `return` host function. if let Some(SpecialTrap::Return(data)) = runtime.special_trap { @@ -84,12 +84,12 @@ pub(crate) fn to_execution_result( // Check the exact type of the error. match sandbox_result { // No traps were generated. Proceed normally. - Ok(sandbox::ReturnValue::Unit) => { + Ok(sp_sandbox::ReturnValue::Unit) => { let mut buffer = runtime.scratch_buf; buffer.clear(); Ok(ExecReturnValue { status: STATUS_SUCCESS, data: buffer }) } - Ok(sandbox::ReturnValue::Value(sandbox::TypedValue::I32(exit_code))) => { + Ok(sp_sandbox::ReturnValue::Value(sp_sandbox::TypedValue::I32(exit_code))) => { let status = (exit_code & 0xFF).try_into() .expect("exit_code is masked into the range of a u8; qed"); Ok(ExecReturnValue { status, data: runtime.scratch_buf }) @@ -105,10 +105,10 @@ pub(crate) fn to_execution_result( // // Because panics are really undesirable in the runtime code, we treat this as // a trap for now. Eventually, we might want to revisit this. - Err(sandbox::Error::Module) => + Err(sp_sandbox::Error::Module) => Err(ExecError { reason: "validation error", buffer: runtime.scratch_buf }), // Any other kind of a trap should result in a failure. - Err(sandbox::Error::Execution) | Err(sandbox::Error::OutOfBounds) => + Err(sp_sandbox::Error::Execution) | Err(sp_sandbox::Error::OutOfBounds) => Err(ExecError { reason: "during execution", buffer: runtime.scratch_buf }), } } @@ -182,10 +182,10 @@ fn charge_gas>( gas_meter: &mut GasMeter, metadata: &Tok::Metadata, token: Tok, -) -> Result<(), sandbox::HostError> { +) -> Result<(), sp_sandbox::HostError> { match gas_meter.charge(metadata, token) { GasMeterResult::Proceed => Ok(()), - GasMeterResult::OutOfGas => Err(sandbox::HostError), + GasMeterResult::OutOfGas => Err(sp_sandbox::HostError), } } @@ -201,11 +201,11 @@ fn read_sandbox_memory( ctx: &mut Runtime, ptr: u32, len: u32, -) -> Result, sandbox::HostError> { +) -> Result, sp_sandbox::HostError> { charge_gas(ctx.gas_meter, ctx.schedule, RuntimeToken::ReadMemory(len))?; let mut buf = vec![0u8; len as usize]; - ctx.memory.get(ptr, buf.as_mut_slice()).map_err(|_| sandbox::HostError)?; + ctx.memory.get(ptr, buf.as_mut_slice()).map_err(|_| sp_sandbox::HostError)?; Ok(buf) } @@ -221,11 +221,11 @@ fn read_sandbox_memory_into_scratch( ctx: &mut Runtime, ptr: u32, len: u32, -) -> Result<(), sandbox::HostError> { +) -> Result<(), sp_sandbox::HostError> { charge_gas(ctx.gas_meter, ctx.schedule, RuntimeToken::ReadMemory(len))?; ctx.scratch_buf.resize(len as usize, 0); - ctx.memory.get(ptr, ctx.scratch_buf.as_mut_slice()).map_err(|_| sandbox::HostError)?; + ctx.memory.get(ptr, ctx.scratch_buf.as_mut_slice()).map_err(|_| sp_sandbox::HostError)?; Ok(()) } @@ -241,7 +241,7 @@ fn read_sandbox_memory_into_buf( ctx: &mut Runtime, ptr: u32, buf: &mut [u8], -) -> Result<(), sandbox::HostError> { +) -> Result<(), sp_sandbox::HostError> { charge_gas(ctx.gas_meter, ctx.schedule, RuntimeToken::ReadMemory(buf.len() as u32))?; ctx.memory.get(ptr, buf).map_err(Into::into) @@ -260,9 +260,9 @@ fn read_sandbox_memory_as( ctx: &mut Runtime, ptr: u32, len: u32, -) -> Result { +) -> Result { let buf = read_sandbox_memory(ctx, ptr, len)?; - D::decode(&mut &buf[..]).map_err(|_| sandbox::HostError) + D::decode(&mut &buf[..]).map_err(|_| sp_sandbox::HostError) } /// Write the given buffer to the designated location in the sandbox memory, consuming @@ -276,10 +276,10 @@ fn read_sandbox_memory_as( fn write_sandbox_memory( schedule: &Schedule, gas_meter: &mut GasMeter, - memory: &sandbox::Memory, + memory: &sp_sandbox::Memory, ptr: u32, buf: &[u8], -) -> Result<(), sandbox::HostError> { +) -> Result<(), sp_sandbox::HostError> { charge_gas(gas_meter, schedule, RuntimeToken::WriteMemory(buf.len() as u32))?; memory.set(ptr, buf)?; @@ -318,7 +318,7 @@ define_env!(Env, , // - value_len: the length of the value. If `value_non_null` is set to 0, then this parameter is ignored. ext_set_storage(ctx, key_ptr: u32, value_non_null: u32, value_ptr: u32, value_len: u32) => { if value_non_null != 0 && ctx.ext.max_value_size() < value_len { - return Err(sandbox::HostError); + return Err(sp_sandbox::HostError); } let mut key: StorageKey = [0; 32]; read_sandbox_memory_into_buf(ctx, key_ptr, &mut key)?; @@ -328,7 +328,7 @@ define_env!(Env, , } else { None }; - ctx.ext.set_storage(key, value).map_err(|_| sandbox::HostError)?; + ctx.ext.set_storage(key, value).map_err(|_| sp_sandbox::HostError)?; Ok(()) }, @@ -382,7 +382,7 @@ define_env!(Env, , input_data_ptr: u32, input_data_len: u32 ) -> u32 => { - let callee: <::T as system::Trait>::AccountId = + let callee: <::T as frame_system::Trait>::AccountId = read_sandbox_memory_as(ctx, callee_ptr, callee_len)?; let value: BalanceOf<::T> = read_sandbox_memory_as(ctx, value_ptr, value_len)?; @@ -532,7 +532,7 @@ define_env!(Env, , // The trap mechanism is used to immediately terminate the execution. // This trap should be handled appropriately before returning the result // to the user of this crate. - Err(sandbox::HostError) + Err(sp_sandbox::HostError) }, // Stores the address of the caller into the scratch buffer. @@ -597,7 +597,7 @@ define_env!(Env, , ext_random(ctx, subject_ptr: u32, subject_len: u32) => { // The length of a subject can't exceed `max_subject_len`. if subject_len > ctx.schedule.max_subject_len { - return Err(sandbox::HostError); + return Err(sp_sandbox::HostError); } let subject_buf = read_sandbox_memory(ctx, subject_ptr, subject_len)?; @@ -675,7 +675,7 @@ define_env!(Env, , delta_ptr: u32, delta_count: u32 ) => { - let dest: <::T as system::Trait>::AccountId = + let dest: <::T as frame_system::Trait>::AccountId = read_sandbox_memory_as(ctx, dest_ptr, dest_len)?; let code_hash: CodeHash<::T> = read_sandbox_memory_as(ctx, code_hash_ptr, code_hash_len)?; @@ -696,7 +696,7 @@ define_env!(Env, , delta.push(delta_key); // Offset key_ptr to the next element. - key_ptr = key_ptr.checked_add(KEY_SIZE as u32).ok_or_else(|| sandbox::HostError)?; + key_ptr = key_ptr.checked_add(KEY_SIZE as u32).ok_or_else(|| sp_sandbox::HostError)?; } delta @@ -729,13 +729,13 @@ define_env!(Env, , let offset = offset as usize; if offset > ctx.scratch_buf.len() { // Offset can't be larger than scratch buffer length. - return Err(sandbox::HostError); + return Err(sp_sandbox::HostError); } // This can't panic since `offset <= ctx.scratch_buf.len()`. let src = &ctx.scratch_buf[offset..]; if src.len() != len as usize { - return Err(sandbox::HostError); + return Err(sp_sandbox::HostError); } // Finally, perform the write. @@ -775,12 +775,12 @@ define_env!(Env, , // If there are more than `max_event_topics`, then trap. if topics.len() > ctx.schedule.max_event_topics as usize { - return Err(sandbox::HostError); + return Err(sp_sandbox::HostError); } // Check for duplicate topics. If there are any, then trap. if has_duplicates(&mut topics) { - return Err(sandbox::HostError); + return Err(sp_sandbox::HostError); } let event_data = read_sandbox_memory(ctx, data_ptr, data_len)?; diff --git a/frame/democracy/Cargo.toml b/frame/democracy/Cargo.toml index 5772f11af1..7e0a9ad53d 100644 --- a/frame/democracy/Cargo.toml +++ b/frame/democracy/Cargo.toml @@ -11,12 +11,12 @@ codec = { package = "parity-scale-codec", version = "1.0.0", default-features = sp-std = { path = "../../primitives/std", 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 } +frame-support = { path = "../support", default-features = false } +frame-system = { path = "../system", default-features = false } [dev-dependencies] -primitives = { package = "sp-core", path = "../../primitives/core" } -balances = { package = "pallet-balances", path = "../balances" } +sp-core = { path = "../../primitives/core" } +pallet-balances = { path = "../balances" } [features] default = ["std"] @@ -26,7 +26,7 @@ std = [ "codec/std", "sp-std/std", "sp-io/std", - "support/std", + "frame-support/std", "sp-runtime/std", - "system/std", + "frame-system/std", ] diff --git a/frame/democracy/src/lib.rs b/frame/democracy/src/lib.rs index 4b4c070cda..ea51c4e1d9 100644 --- a/frame/democracy/src/lib.rs +++ b/frame/democracy/src/lib.rs @@ -25,7 +25,7 @@ use sp_runtime::{ traits::{Zero, Bounded, CheckedMul, CheckedDiv, EnsureOrigin, Hash, Dispatchable, Saturating}, }; use codec::{Ref, Encode, Decode, Input, Output, Error}; -use support::{ +use frame_support::{ decl_module, decl_storage, decl_event, ensure, dispatch, Parameter, @@ -35,7 +35,7 @@ use support::{ OnFreeBalanceZero, OnUnbalanced } }; -use system::{ensure_signed, ensure_root}; +use frame_system::{self as system, ensure_signed, ensure_root}; mod vote_threshold; pub use vote_threshold::{Approved, VoteThreshold}; @@ -173,13 +173,13 @@ impl Decode for Vote { } } -type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; +type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; type NegativeImbalanceOf = -<::Currency as Currency<::AccountId>>::NegativeImbalance; +<::Currency as Currency<::AccountId>>::NegativeImbalance; -pub trait Trait: system::Trait + Sized { +pub trait Trait: frame_system::Trait + Sized { type Proposal: Parameter + Dispatchable; - type Event: From> + Into<::Event>; + type Event: From> + Into<::Event>; /// Currency type for this module. type Currency: ReservableCurrency @@ -281,7 +281,7 @@ decl_storage! { pub LowestUnbaked get(fn lowest_unbaked) build(|_| 0 as ReferendumIndex): ReferendumIndex; /// Information concerning any given referendum. pub ReferendumInfoOf get(fn referendum_info): - map ReferendumIndex => Option<(ReferendumInfo)>; + map ReferendumIndex => Option>; /// Queue of successful referenda to be dispatched. Stored ordered by block number. pub DispatchQueue get(fn dispatch_queue): Vec<(T::BlockNumber, T::Hash, ReferendumIndex)>; @@ -323,9 +323,9 @@ decl_storage! { decl_event!( pub enum Event where Balance = BalanceOf, - ::AccountId, - ::Hash, - ::BlockNumber, + ::AccountId, + ::Hash, + ::BlockNumber, { /// A motion has been proposed by a public account. Proposed(PropIndex, Balance), @@ -487,7 +487,7 @@ decl_module! { T::ExternalOrigin::ensure_origin(origin)?; ensure!(!>::exists(), "proposal already made"); if let Some((until, _)) = >::get(proposal_hash) { - ensure!(>::block_number() >= until, "proposal still blacklisted"); + ensure!(>::block_number() >= until, "proposal still blacklisted"); } >::put((proposal_hash, VoteThreshold::SuperMajorityApprove)); } @@ -538,7 +538,7 @@ decl_module! { ensure!(proposal_hash == e_proposal_hash, "invalid hash"); >::kill(); - let now = >::block_number(); + let now = >::block_number(); // We don't consider it an error if `vote_period` is too low, like `emergency_propose`. let period = voting_period.max(T::EmergencyVotingPeriod::get()); Self::inject_referendum(now + period, proposal_hash, threshold, delay); @@ -562,7 +562,7 @@ decl_module! { .err().ok_or("identity may not veto a proposal twice")?; existing_vetoers.insert(insert_position, who.clone()); - let until = >::block_number() + T::CooloffPeriod::get(); + let until = >::block_number() + T::CooloffPeriod::get(); >::insert(&proposal_hash, (until, existing_vetoers)); Self::deposit_event(RawEvent::Vetoed(who, proposal_hash, until)); @@ -659,7 +659,7 @@ decl_module! { ensure!(>::exists(&who), "not delegated"); let (_, conviction) = >::take(&who); // Indefinite lock is reduced to the maximum voting lock that could be possible. - let now = >::block_number(); + let now = >::block_number(); let locked_until = now + T::EnactmentPeriod::get() * conviction.lock_periods().into(); T::Currency::set_lock( DEMOCRACY_ID, @@ -691,7 +691,7 @@ decl_module! { .saturating_mul(T::PreimageByteDeposit::get()); T::Currency::reserve(&who, deposit)?; - let now = >::block_number(); + let now = >::block_number(); >::insert(proposal_hash, (encoded_proposal, who.clone(), deposit, now)); Self::deposit_event(RawEvent::PreimageNoted(proposal_hash, who, deposit)); @@ -707,7 +707,7 @@ decl_module! { let queue = >::get(); ensure!(queue.iter().any(|item| &item.1 == &proposal_hash), "not imminent"); - let now = >::block_number(); + let now = >::block_number(); let free = >::zero(); >::insert(proposal_hash, (encoded_proposal, who.clone(), free, now)); @@ -724,7 +724,7 @@ decl_module! { let who = ensure_signed(origin)?; let (_, old, deposit, then) = >::get(&proposal_hash).ok_or("not found")?; - let now = >::block_number(); + let now = >::block_number(); let (voting, enactment) = (T::VotingPeriod::get(), T::EnactmentPeriod::get()); let additional = if who == old { Zero::zero() } else { enactment }; ensure!(now >= then + voting + additional, "too early"); @@ -863,7 +863,7 @@ impl Module { delay: T::BlockNumber ) -> ReferendumIndex { >::inject_referendum( - >::block_number() + T::VotingPeriod::get(), + >::block_number() + T::VotingPeriod::get(), proposal_hash, threshold, delay @@ -927,7 +927,7 @@ impl Module { let _ = T::Currency::unreserve(&who, amount); Self::deposit_event(RawEvent::PreimageUsed(proposal_hash, who, amount)); - let ok = proposal.dispatch(system::RawOrigin::Root.into()).is_ok(); + let ok = proposal.dispatch(frame_system::RawOrigin::Root.into()).is_ok(); Self::deposit_event(RawEvent::Executed(index, ok)); Ok(()) @@ -1088,15 +1088,15 @@ impl OnFreeBalanceZero for Module { mod tests { use super::*; use std::cell::RefCell; - use support::{ + use frame_support::{ impl_outer_origin, impl_outer_dispatch, assert_noop, assert_ok, parameter_types, traits::Contains, weights::Weight, }; - use primitives::H256; + use sp_core::H256; use sp_runtime::{traits::{BlakeTwo256, IdentityLookup, Bounded}, testing::Header, Perbill}; - use balances::BalanceLock; - use system::EnsureSignedBy; + use pallet_balances::BalanceLock; + use frame_system::EnsureSignedBy; const AYE: Vote = Vote{ aye: true, conviction: Conviction::None }; const NAY: Vote = Vote{ aye: false, conviction: Conviction::None }; @@ -1104,12 +1104,12 @@ mod tests { const BIG_NAY: Vote = Vote{ aye: false, conviction: Conviction::Locked1x }; impl_outer_origin! { - pub enum Origin for Test {} + pub enum Origin for Test where system = frame_system {} } impl_outer_dispatch! { pub enum Call for Test where origin: Origin { - balances::Balances, + pallet_balances::Balances, democracy::Democracy, } } @@ -1123,7 +1123,7 @@ mod tests { pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); } - impl system::Trait for Test { + impl frame_system::Trait for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; @@ -1145,7 +1145,7 @@ mod tests { pub const TransferFee: u64 = 0; pub const CreationFee: u64 = 0; } - impl balances::Trait for Test { + impl pallet_balances::Trait for Test { type Balance = u64; type OnFreeBalanceZero = (); type OnNewAccount = (); @@ -1185,7 +1185,7 @@ mod tests { impl super::Trait for Test { type Proposal = Call; type Event = (); - type Currency = balances::Module; + type Currency = pallet_balances::Module; type EnactmentPeriod = EnactmentPeriod; type LaunchPeriod = LaunchPeriod; type VotingPeriod = VotingPeriod; @@ -1203,8 +1203,8 @@ mod tests { } fn new_test_ext() -> sp_io::TestExternalities { - let mut t = system::GenesisConfig::default().build_storage::().unwrap(); - balances::GenesisConfig::{ + let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + pallet_balances::GenesisConfig::{ balances: vec![(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60)], vesting: vec![], }.assimilate_storage(&mut t).unwrap(); @@ -1212,8 +1212,8 @@ mod tests { sp_io::TestExternalities::new(t) } - type System = system::Module; - type Balances = balances::Module; + type System = frame_system::Module; + type Balances = pallet_balances::Module; type Democracy = Module; #[test] @@ -1226,7 +1226,7 @@ mod tests { } fn set_balance_proposal(value: u64) -> Vec { - Call::Balances(balances::Call::set_balance(42, value, 0)).encode() + Call::Balances(pallet_balances::Call::set_balance(42, value, 0)).encode() } fn set_balance_proposal_hash(value: u64) -> H256 { diff --git a/frame/elections-phragmen/Cargo.toml b/frame/elections-phragmen/Cargo.toml index 0778ef25fd..df253e0f02 100644 --- a/frame/elections-phragmen/Cargo.toml +++ b/frame/elections-phragmen/Cargo.toml @@ -7,16 +7,16 @@ edition = "2018" [dependencies] codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } sp-runtime = { path = "../../primitives/runtime", default-features = false } -phragmen = { package = "sp-phragmen", path = "../../primitives/phragmen", default-features = false } -support = { package = "frame-support", path = "../support", default-features = false } -system = { package = "frame-system", path = "../system", default-features = false } +sp-phragmen = { path = "../../primitives/phragmen", default-features = false } +frame-support = { path = "../support", default-features = false } +frame-system = { path = "../system", default-features = false } sp-std = { path = "../../primitives/std", default-features = false } [dev-dependencies] sp-io = { path = "../../primitives/io" } hex-literal = "0.2.1" -balances = { package = "pallet-balances", path = "../balances" } -primitives = { package = "sp-core", path = "../../primitives/core" } +pallet-balances = { path = "../balances" } +sp-core = { path = "../../primitives/core" } substrate-test-utils = { path = "../../test-utils" } serde = { version = "1.0.101" } @@ -24,9 +24,9 @@ serde = { version = "1.0.101" } default = ["std"] std = [ "codec/std", - "support/std", + "frame-support/std", "sp-runtime/std", - "phragmen/std", - "system/std", + "sp-phragmen/std", + "frame-system/std", "sp-std/std", ] diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index 0fa0515751..59856692b5 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -76,7 +76,7 @@ //! //! ### Module Information //! -//! - [`election_phragmen::Trait`](./trait.Trait.html) +//! - [`election_sp_phragmen::Trait`](./trait.Trait.html) //! - [`Call`](./enum.Call.html) //! - [`Module`](./struct.Module.html) @@ -84,28 +84,28 @@ use sp_std::prelude::*; use sp_runtime::{print, traits::{Zero, StaticLookup, Bounded, Convert}}; -use support::{ +use frame_support::{ decl_storage, decl_event, ensure, decl_module, dispatch, weights::SimpleDispatchInfo, traits::{ Currency, Get, LockableCurrency, LockIdentifier, ReservableCurrency, WithdrawReasons, ChangeMembers, OnUnbalanced, WithdrawReason } }; -use phragmen::ExtendedBalance; -use system::{self, ensure_signed, ensure_root}; +use sp_phragmen::ExtendedBalance; +use frame_system::{self as system, ensure_signed, ensure_root}; const MODULE_ID: LockIdentifier = *b"phrelect"; /// The maximum votes allowed per voter. pub const MAXIMUM_VOTE: usize = 16; -type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; +type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; type NegativeImbalanceOf = - <::Currency as Currency<::AccountId>>::NegativeImbalance; + <::Currency as Currency<::AccountId>>::NegativeImbalance; -pub trait Trait: system::Trait { +pub trait Trait: frame_system::Trait { /// The overarching event type.c - type Event: From> + Into<::Event>; + type Event: From> + Into<::Event>; /// The currency that people are electing with. type Currency: @@ -418,7 +418,7 @@ decl_module! { decl_event!( pub enum Event where Balance = BalanceOf, - ::AccountId, + ::AccountId, { /// A new term with new members. This indicates that enough candidates existed, not that /// enough have has been elected. The inner value must be examined for this purpose. @@ -602,7 +602,7 @@ impl Module { let voters_and_votes = >::enumerate() .map(|(v, i)| (v, i)) .collect::)>>(); - let maybe_phragmen_result = phragmen::elect::<_, _, _, T::CurrencyToVote>( + let maybe_phragmen_result = sp_phragmen::elect::<_, _, _, T::CurrencyToVote>( num_to_elect, 0, candidates, @@ -629,7 +629,7 @@ impl Module { .filter_map(|(m, a)| if a.is_zero() { None } else { Some(m) } ) .collect::>(); - let support_map = phragmen::build_support_map::<_, _, _, T::CurrencyToVote>( + let support_map = sp_phragmen::build_support_map::<_, _, _, T::CurrencyToVote>( &new_set, &phragmen_result.assignments, Self::locked_stake_of, @@ -735,14 +735,15 @@ impl Module { mod tests { use super::*; use std::cell::RefCell; - use support::{assert_ok, assert_noop, parameter_types, weights::Weight}; + use frame_support::{assert_ok, assert_noop, parameter_types, weights::Weight}; use substrate_test_utils::assert_eq_uvec; - use primitives::H256; + use sp_core::H256; use sp_runtime::{ Perbill, testing::Header, BuildStorage, traits::{BlakeTwo256, IdentityLookup, Block as BlockT}, }; use crate as elections; + use frame_system as system; parameter_types! { pub const BlockHashCount: u64 = 250; @@ -751,7 +752,7 @@ mod tests { pub const AvailableBlockRatio: Perbill = Perbill::one(); } - impl system::Trait for Test { + impl frame_system::Trait for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; @@ -775,7 +776,7 @@ mod tests { pub const CreationFee: u64 = 0; } - impl balances::Trait for Test { + impl pallet_balances::Trait for Test { type Balance = u64; type OnNewAccount = (); type OnFreeBalanceZero = (); @@ -886,14 +887,14 @@ mod tests { pub type Block = sp_runtime::generic::Block; pub type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic; - support::construct_runtime!( + frame_support::construct_runtime!( pub enum Test where Block = Block, NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic { System: system::{Module, Call, Event}, - Balances: balances::{Module, Call, Event, Config}, + Balances: pallet_balances::{Module, Call, Event, Config}, Elections: elections::{Module, Call, Event}, } ); @@ -934,7 +935,7 @@ mod tests { TERM_DURATION.with(|v| *v.borrow_mut() = self.term_duration); DESIRED_RUNNERS_UP.with(|v| *v.borrow_mut() = self.desired_runners_up); GenesisConfig { - balances: Some(balances::GenesisConfig::{ + pallet_balances: Some(pallet_balances::GenesisConfig::{ balances: vec![ (1, 10 * self.balance_factor), (2, 20 * self.balance_factor), diff --git a/frame/elections/Cargo.toml b/frame/elections/Cargo.toml index 9a1216f38c..c1b845bd5a 100644 --- a/frame/elections/Cargo.toml +++ b/frame/elections/Cargo.toml @@ -8,27 +8,27 @@ edition = "2018" serde = { version = "1.0.101", optional = true } 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-core = { path = "../../primitives/core", default-features = false } sp-std = { path = "../../primitives/std", 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 } +frame-support = { path = "../support", default-features = false } +frame-system = { path = "../system", default-features = false } [dev-dependencies] hex-literal = "0.2.1" -balances = { package = "pallet-balances", path = "../balances" } +pallet-balances = { path = "../balances" } [features] default = ["std"] std = [ "safe-mix/std", "codec/std", - "primitives/std", + "sp-core/std", "sp-std/std", "serde", "sp-io/std", - "support/std", + "frame-support/std", "sp-runtime/std", - "system/std", + "frame-system/std", ] diff --git a/frame/elections/src/lib.rs b/frame/elections/src/lib.rs index 530ffad963..5b2bee253c 100644 --- a/frame/elections/src/lib.rs +++ b/frame/elections/src/lib.rs @@ -29,7 +29,7 @@ use sp_runtime::{ print, traits::{Zero, One, StaticLookup, Bounded, Saturating}, }; -use support::{ +use frame_support::{ dispatch::Result, decl_storage, decl_event, ensure, decl_module, weights::SimpleDispatchInfo, traits::{ @@ -38,7 +38,7 @@ use support::{ } }; use codec::{Encode, Decode}; -use system::{self, ensure_signed, ensure_root}; +use frame_system::{self as system, ensure_signed, ensure_root}; mod mock; mod tests; @@ -134,9 +134,9 @@ pub const VOTER_SET_SIZE: usize = 64; /// NUmber of approvals grouped in one chunk. pub const APPROVAL_SET_SIZE: usize = 8; -type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; +type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; type NegativeImbalanceOf = - <::Currency as Currency<::AccountId>>::NegativeImbalance; + <::Currency as Currency<::AccountId>>::NegativeImbalance; /// Index used to access chunks. type SetIndex = u32; @@ -147,8 +147,8 @@ type ApprovalFlag = u32; /// Number of approval flags that can fit into [`ApprovalFlag`] type. const APPROVAL_FLAG_LEN: usize = 32; -pub trait Trait: system::Trait { - type Event: From> + Into<::Event>; +pub trait Trait: frame_system::Trait { + type Event: From> + Into<::Event>; /// The currency that people are electing with. type Currency: @@ -643,7 +643,7 @@ decl_module! { } decl_event!( - pub enum Event where ::AccountId { + pub enum Event where ::AccountId { /// reaped voter, reaper VoterReaped(AccountId, AccountId), /// slashed reaper @@ -695,7 +695,7 @@ impl Module { // if there's a tally in progress, then next tally can begin immediately afterwards (tally_end, c.len() - leavers.len() + comers as usize, comers) } else { - (>::block_number(), c.len(), 0) + (>::block_number(), c.len(), 0) }; if count < desired_seats as usize { Some(next_possible) @@ -851,7 +851,7 @@ impl Module { fn start_tally() { let members = Self::members(); let desired_seats = Self::desired_seats() as usize; - let number = >::block_number(); + let number = >::block_number(); let expiring = members.iter().take_while(|i| i.1 <= number).map(|i| i.0.clone()).collect::>(); let retaining_seats = members.len() - expiring.len(); @@ -879,7 +879,7 @@ impl Module { .ok_or("finalize can only be called after a tally is started.")?; let leaderboard: Vec<(BalanceOf, T::AccountId)> = >::take() .unwrap_or_default(); - let new_expiry = >::block_number() + Self::term_duration(); + let new_expiry = >::block_number() + Self::term_duration(); // return bond to winners. let candidacy_bond = T::CandidacyBond::get(); diff --git a/frame/elections/src/mock.rs b/frame/elections/src/mock.rs index 7e3c762427..de4f263f0e 100644 --- a/frame/elections/src/mock.rs +++ b/frame/elections/src/mock.rs @@ -19,12 +19,12 @@ #![cfg(test)] use std::cell::RefCell; -use support::{ +use frame_support::{ StorageValue, StorageMap, parameter_types, assert_ok, traits::{Get, ChangeMembers, Currency}, weights::Weight, }; -use primitives::H256; +use sp_core::H256; use sp_runtime::{ Perbill, BuildStorage, testing::Header, traits::{BlakeTwo256, IdentityLookup, Block as BlockT}, }; @@ -37,7 +37,7 @@ parameter_types! { pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); } -impl system::Trait for Test { +impl frame_system::Trait for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; @@ -60,7 +60,7 @@ parameter_types! { pub const TransferFee: u64 = 0; pub const CreationFee: u64 = 0; } -impl balances::Trait for Test { +impl pallet_balances::Trait for Test { type Balance = u64; type OnNewAccount = (); type OnFreeBalanceZero = (); @@ -145,14 +145,15 @@ impl elections::Trait for Test { pub type Block = sp_runtime::generic::Block; pub type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic; -support::construct_runtime!( +use frame_system as system; +frame_support::construct_runtime!( pub enum Test where Block = Block, NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic { System: system::{Module, Call, Event}, - Balances: balances::{Module, Call, Event, Config, Error}, + Balances: pallet_balances::{Module, Call, Event, Config, Error}, Elections: elections::{Module, Call, Event, Config}, } ); @@ -210,7 +211,7 @@ impl ExtBuilder { PRESENT_SLASH_PER_VOTER.with(|v| *v.borrow_mut() = self.bad_presentation_punishment); DECAY_RATIO.with(|v| *v.borrow_mut() = self.decay_ratio); GenesisConfig { - balances: Some(balances::GenesisConfig::{ + pallet_balances: Some(pallet_balances::GenesisConfig::{ balances: vec![ (1, 10 * self.balance_factor), (2, 20 * self.balance_factor), diff --git a/frame/elections/src/tests.rs b/frame/elections/src/tests.rs index c9bb054ab2..b502c52f8f 100644 --- a/frame/elections/src/tests.rs +++ b/frame/elections/src/tests.rs @@ -21,7 +21,7 @@ use crate::mock::*; use crate::*; -use support::{assert_ok, assert_err, assert_noop}; +use frame_support::{assert_ok, assert_err, assert_noop}; #[test] fn params_should_work() { diff --git a/frame/evm/Cargo.toml b/frame/evm/Cargo.toml index c6a8083a2f..d26c6672d1 100644 --- a/frame/evm/Cargo.toml +++ b/frame/evm/Cargo.toml @@ -7,11 +7,11 @@ edition = "2018" [dependencies] serde = { version = "1.0.101", optional = true, features = ["derive"] } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } -support = { package = "frame-support", path = "../support", default-features = false } -system = { package = "frame-system", path = "../system", default-features = false } -timestamp = { package = "pallet-timestamp", path = "../timestamp", default-features = false } -balances = { package = "pallet-balances", path = "../balances", default-features = false } -primitives = { package = "sp-core", path = "../../primitives/core", default-features = false } +frame-support = { path = "../support", default-features = false } +frame-system = { path = "../system", default-features = false } +pallet-timestamp = { path = "../timestamp", default-features = false } +pallet-balances = { path = "../balances", default-features = false } +sp-core = { path = "../../primitives/core", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } sp-std = { path = "../../primitives/std", default-features = false } sp-io = { path = "../../primitives/io", default-features = false } @@ -25,16 +25,16 @@ default = ["std"] std = [ "serde", "codec/std", - "primitives/std", + "sp-core/std", "sp-runtime/std", - "support/std", - "system/std", - "balances/std", + "frame-support/std", + "frame-system/std", + "pallet-balances/std", "sp-io/std", "sp-std/std", "sha3/std", "rlp/std", "primitive-types/std", "evm/std", - "timestamp/std", + "pallet-timestamp/std", ] diff --git a/frame/evm/src/backend.rs b/frame/evm/src/backend.rs index aec3371f0b..b6c3078a33 100644 --- a/frame/evm/src/backend.rs +++ b/frame/evm/src/backend.rs @@ -3,9 +3,9 @@ use sp_std::vec::Vec; #[cfg(feature = "std")] use serde::{Serialize, Deserialize}; use codec::{Encode, Decode}; -use primitives::{U256, H256, H160}; +use sp_core::{U256, H256, H160}; use sp_runtime::traits::UniqueSaturatedInto; -use support::storage::{StorageMap, StorageDoubleMap}; +use frame_support::storage::{StorageMap, StorageDoubleMap}; use sha3::{Keccak256, Digest}; use evm::Config; use evm::backend::{Backend as BackendT, ApplyBackend, Apply}; @@ -69,12 +69,12 @@ impl<'vicinity, T: Trait> BackendT for Backend<'vicinity, T> { H256::default() } else { let number = T::BlockNumber::from(number.as_u32()); - H256::from_slice(system::Module::::block_hash(number).as_ref()) + H256::from_slice(frame_system::Module::::block_hash(number).as_ref()) } } fn block_number(&self) -> U256 { - let number: u128 = system::Module::::block_number().unique_saturated_into(); + let number: u128 = frame_system::Module::::block_number().unique_saturated_into(); U256::from(number) } @@ -83,7 +83,7 @@ impl<'vicinity, T: Trait> BackendT for Backend<'vicinity, T> { } fn block_timestamp(&self) -> U256 { - let now: u128 = timestamp::Module::::get().unique_saturated_into(); + let now: u128 = pallet_timestamp::Module::::get().unique_saturated_into(); U256::from(now) } diff --git a/frame/evm/src/lib.rs b/frame/evm/src/lib.rs index 4a62dae9ad..6215dfaab2 100644 --- a/frame/evm/src/lib.rs +++ b/frame/evm/src/lib.rs @@ -24,14 +24,14 @@ mod backend; pub use crate::backend::{Account, Log, Vicinity, Backend}; use sp_std::{vec::Vec, marker::PhantomData}; -use support::{dispatch, decl_module, decl_storage, decl_event}; -use support::weights::{Weight, WeighData, ClassifyDispatch, DispatchClass, PaysFee}; -use support::traits::{Currency, WithdrawReason, ExistenceRequirement}; -use system::ensure_signed; +use frame_support::{dispatch, decl_module, decl_storage, decl_event}; +use frame_support::weights::{Weight, WeighData, ClassifyDispatch, DispatchClass, PaysFee}; +use frame_support::traits::{Currency, WithdrawReason, ExistenceRequirement}; +use frame_system::{self as system, ensure_signed}; use sp_runtime::ModuleId; -use support::weights::SimpleDispatchInfo; +use frame_support::weights::SimpleDispatchInfo; use sp_runtime::traits::{UniqueSaturatedInto, AccountIdConversion, SaturatedConversion}; -use primitives::{U256, H256, H160}; +use sp_core::{U256, H256, H160}; use evm::{ExitReason, ExitSucceed, ExitError}; use evm::executor::StackExecutor; use evm::backend::ApplyBackend; @@ -39,7 +39,7 @@ use evm::backend::ApplyBackend; const MODULE_ID: ModuleId = ModuleId(*b"py/ethvm"); /// Type alias for currency balance. -pub type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; +pub type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; /// Trait that outputs the current transaction gas price. pub trait FeeCalculator { @@ -116,7 +116,7 @@ impl PaysFee for WeightForCallCreate { } /// EVM module trait -pub trait Trait: system::Trait + timestamp::Trait { +pub trait Trait: frame_system::Trait + pallet_timestamp::Trait { /// Calculator for current gas price. type FeeCalculator: FeeCalculator; /// Convert account ID to H160; @@ -124,7 +124,7 @@ pub trait Trait: system::Trait + timestamp::Trait { /// Currency type for deposit and withdraw. type Currency: Currency; /// The overarching event type. - type Event: From + Into<::Event>; + type Event: From + Into<::Event>; /// Precompiles associated with this EVM engine. type Precompiles: Precompiles; } diff --git a/frame/example/Cargo.toml b/frame/example/Cargo.toml index 496d4e64a5..2515604b3e 100644 --- a/frame/example/Cargo.toml +++ b/frame/example/Cargo.toml @@ -7,15 +7,15 @@ edition = "2018" [dependencies] serde = { version = "1.0.101", optional = true } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } -support = { package = "frame-support", path = "../support", default-features = false } -system = { package = "frame-system", path = "../system", default-features = false } -balances = { package = "pallet-balances", path = "../balances", default-features = false } +frame-support = { path = "../support", default-features = false } +frame-system = { path = "../system", default-features = false } +pallet-balances = { path = "../balances", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } sp-std = { path = "../../primitives/std", default-features = false } sp-io = { path = "../../primitives/io", default-features = false } [dev-dependencies] -primitives = { package = "sp-core", path = "../../primitives/core" } +sp-core = { path = "../../primitives/core" } [features] default = ["std"] @@ -23,9 +23,9 @@ std = [ "serde", "codec/std", "sp-runtime/std", - "support/std", - "system/std", - "balances/std", + "frame-support/std", + "frame-system/std", + "pallet-balances/std", "sp-io/std", "sp-std/std" ] diff --git a/frame/example/src/lib.rs b/frame/example/src/lib.rs index 10f075ec6d..d77998c85f 100644 --- a/frame/example/src/lib.rs +++ b/frame/example/src/lib.rs @@ -254,11 +254,11 @@ #![cfg_attr(not(feature = "std"), no_std)] use sp_std::marker::PhantomData; -use support::{ +use frame_support::{ dispatch::Result, decl_module, decl_storage, decl_event, weights::{SimpleDispatchInfo, DispatchInfo, DispatchClass, ClassifyDispatch, WeighData, Weight, PaysFee}, }; -use system::{ensure_signed, ensure_root}; +use frame_system::{self as system, ensure_signed, ensure_root}; use codec::{Encode, Decode}; use sp_runtime::{ traits::{SignedExtension, Bounded, SaturatedConversion}, @@ -281,9 +281,9 @@ use sp_runtime::{ // - The final weight of each dispatch is calculated as the argument of the call multiplied by the // parameter given to the `WeightForSetDummy`'s constructor. // - assigns a dispatch class `operational` if the argument of the call is more than 1000. -struct WeightForSetDummy(BalanceOf); +struct WeightForSetDummy(BalanceOf); -impl WeighData<(&BalanceOf,)> for WeightForSetDummy +impl WeighData<(&BalanceOf,)> for WeightForSetDummy { fn weigh_data(&self, target: (&BalanceOf,)) -> Weight { let multiplier = self.0; @@ -291,7 +291,7 @@ impl WeighData<(&BalanceOf,)> for WeightForSetDummy } } -impl ClassifyDispatch<(&BalanceOf,)> for WeightForSetDummy { +impl ClassifyDispatch<(&BalanceOf,)> for WeightForSetDummy { fn classify_dispatch(&self, target: (&BalanceOf,)) -> DispatchClass { if *target.0 > >::from(1000u32) { DispatchClass::Operational @@ -301,23 +301,23 @@ impl ClassifyDispatch<(&BalanceOf,)> for WeightForSetDumm } } -impl PaysFee for WeightForSetDummy { +impl PaysFee for WeightForSetDummy { fn pays_fee(&self) -> bool { true } } /// A type alias for the balance type from this module's point of view. -type BalanceOf = ::Balance; +type BalanceOf = ::Balance; /// Our module's configuration trait. All our types and constants go in here. If the /// module is dependent on specific other modules, then their configuration traits /// should be added to our implied traits list. /// -/// `system::Trait` should always be included in our implied traits. -pub trait Trait: balances::Trait { +/// `frame_system::Trait` should always be included in our implied traits. +pub trait Trait: pallet_balances::Trait { /// The overarching event type. - type Event: From> + Into<::Event>; + type Event: From> + Into<::Event>; } decl_storage! { @@ -342,8 +342,8 @@ decl_storage! { // e.g. pub Bar get(fn bar): map T::AccountId => Vec<(T::Balance, u64)>; // // For basic value items, you'll get a type which implements - // `support::StorageValue`. For map items, you'll get a type which - // implements `support::StorageMap`. + // `frame_support::StorageValue`. For map items, you'll get a type which + // implements `frame_support::StorageMap`. // // If they have a getter (`get(getter_name)`), then your module will come // equipped with `fn getter_name() -> Type` for basic value items or @@ -362,7 +362,7 @@ decl_event!( /// Events are a simple means of reporting specific conditions and /// circumstances that have happened that users, Dapps and/or chain explorers would find /// interesting and otherwise difficult to detect. - pub enum Event where B = ::Balance { + pub enum Event where B = ::Balance { // Just a normal `enum`, here's a dummy event to ensure it compiles. /// Dummy event, just here so there's a generic type that's used. Dummy(B), @@ -398,7 +398,7 @@ decl_event!( // // `fn foo(origin: T::Origin, bar: Bar, baz: Baz) { ... }` // -// There are three entries in the `system::Origin` enum that correspond +// There are three entries in the `frame_system::Origin` enum that correspond // to the above bullets: `::Signed(AccountId)`, `::Root` and `::None`. You should always match // against them as the first thing you do in your function. There are three convenience calls // in system that do the matching for you and return a convenient result: `ensure_signed`, @@ -605,7 +605,7 @@ impl sp_std::fmt::Debug for WatchDummy { impl SignedExtension for WatchDummy { type AccountId = T::AccountId; // Note that this could also be assigned to the top-level call enum. It is passed into the - // balances module directly and since `Trait: balances::Trait`, you could also use `T::Call`. + // balances module directly and since `Trait: pallet_balances::Trait`, you could also use `T::Call`. // In that case, you would have had access to all call variants and could match on variants from // other modules. type Call = Call; @@ -645,8 +645,8 @@ impl SignedExtension for WatchDummy { mod tests { use super::*; - use support::{assert_ok, impl_outer_origin, parameter_types, weights::GetDispatchInfo}; - use primitives::H256; + use frame_support::{assert_ok, impl_outer_origin, parameter_types, weights::GetDispatchInfo}; + use sp_core::H256; // The testing primitives are very useful for avoiding having to work with signatures // or public keys. `u64` is used as the `AccountId` and no `Signature`s are required. use sp_runtime::{ @@ -655,7 +655,7 @@ mod tests { }; impl_outer_origin! { - pub enum Origin for Test {} + pub enum Origin for Test where system = frame_system {} } // For testing the module, we construct most of a mock runtime. This means @@ -669,7 +669,7 @@ mod tests { pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); } - impl system::Trait for Test { + impl frame_system::Trait for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; @@ -691,7 +691,7 @@ mod tests { pub const TransferFee: u64 = 0; pub const CreationFee: u64 = 0; } - impl balances::Trait for Test { + impl pallet_balances::Trait for Test { type Balance = u64; type OnFreeBalanceZero = (); type OnNewAccount = (); @@ -710,9 +710,9 @@ mod tests { // This function basically just builds a genesis storage key/value store according to // our desired mockup. fn new_test_ext() -> sp_io::TestExternalities { - let mut t = system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_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(); + pallet_balances::GenesisConfig::::default().assimilate_storage(&mut t).unwrap(); GenesisConfig::{ dummy: 42, // we configure the map with (key, value) pairs. diff --git a/frame/executive/Cargo.toml b/frame/executive/Cargo.toml index 3220e2ba49..de9a82643e 100644 --- a/frame/executive/Cargo.toml +++ b/frame/executive/Cargo.toml @@ -10,24 +10,24 @@ codec = { package = "parity-scale-codec", version = "1.0.0", default-features = sp-std = { path = "../../primitives/std", 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 } +frame-support = { path = "../support", default-features = false } +frame-system = { path = "../system", default-features = false } [dev-dependencies] hex-literal = "0.2.1" -primitives = { package = "sp-core", path = "../../primitives/core" } +sp-core = { path = "../../primitives/core" } pallet-indices = { path = "../indices" } -balances = { package = "pallet-balances", path = "../balances" } -transaction-payment = { package = "pallet-transaction-payment", path = "../transaction-payment" } +pallet-balances = { path = "../balances" } +pallet-transaction-payment = { path = "../transaction-payment" } [features] default = ["std"] std = [ "sp-std/std", - "support/std", + "frame-support/std", "serde", "codec/std", "sp-runtime/std", "sp-io/std", - "system/std", + "frame-system/std", ] diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index efe963a6d3..4dfa72f9c6 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -54,7 +54,7 @@ //! # use frame_executive as executive; //! # pub struct UncheckedExtrinsic {}; //! # pub struct Header {}; -//! # type Context = system::ChainContext; +//! # type Context = frame_system::ChainContext; //! # pub type Block = generic::Block; //! # pub type Balances = u64; //! # pub type AllModules = u64; @@ -77,7 +77,7 @@ #![cfg_attr(not(feature = "std"), no_std)] use sp_std::{prelude::*, marker::PhantomData}; -use support::weights::{GetDispatchInfo, WeighBlock, DispatchInfo}; +use frame_support::weights::{GetDispatchInfo, WeighBlock, DispatchInfo}; use sp_runtime::{ generic::Digest, ApplyExtrinsicResult, traits::{ @@ -89,7 +89,7 @@ use sp_runtime::{ #[allow(deprecated)] use sp_runtime::traits::ValidateUnsigned; use codec::{Codec, Encode}; -use system::{extrinsics_root, DigestOf}; +use frame_system::{extrinsics_root, DigestOf}; /// Trait that can be used to execute a block. pub trait ExecuteBlock { @@ -107,7 +107,7 @@ pub struct Executive( #[allow(deprecated)] // Allow ValidateUnsigned, remove the attribute when the trait is removed. impl< - System: system::Trait, + System: frame_system::Trait, Block: traits::Block, Context: Default, UnsignedValidator, @@ -133,7 +133,7 @@ where #[allow(deprecated)] // Allow ValidateUnsigned, remove the attribute when the trait is removed. impl< - System: system::Trait, + System: frame_system::Trait, Block: traits::Block, Context: Default, UnsignedValidator, @@ -165,12 +165,12 @@ where extrinsics_root: &System::Hash, digest: &Digest, ) { - >::initialize(block_number, parent_hash, extrinsics_root, digest); + >::initialize(block_number, parent_hash, extrinsics_root, digest); >::on_initialize(*block_number); - >::register_extra_weight_unchecked( + >::register_extra_weight_unchecked( >::on_initialize(*block_number) ); - >::register_extra_weight_unchecked( + >::register_extra_weight_unchecked( >::on_finalize(*block_number) ); } @@ -182,7 +182,7 @@ where let n = header.number().clone(); assert!( n > System::BlockNumber::zero() - && >::block_hash(n - System::BlockNumber::one()) == *header.parent_hash(), + && >::block_hash(n - System::BlockNumber::one()) == *header.parent_hash(), "Parent hash should be valid." ); @@ -213,19 +213,19 @@ where extrinsics.into_iter().for_each(Self::apply_extrinsic_no_note); // post-extrinsics book-keeping - >::note_finished_extrinsics(); + >::note_finished_extrinsics(); >::on_finalize(block_number); } /// Finalize the block - it is up the caller to ensure that all header fields are valid /// except state-root. pub fn finalize_block() -> System::Header { - >::note_finished_extrinsics(); - >::on_finalize(>::block_number()); + >::note_finished_extrinsics(); + >::on_finalize(>::block_number()); // set up extrinsics - >::derive_extrinsics(); - >::finalize() + >::derive_extrinsics(); + >::finalize() } /// Apply extrinsic outside of the block execution function. @@ -261,7 +261,7 @@ where // executed to prevent it from leaking in storage since at this point, it will either // execute or panic (and revert storage changes). if let Some(encoded) = to_note { - >::note_extrinsic(encoded); + >::note_extrinsic(encoded); } // AUDIT: Under no circumstances may this function panic from here onwards. @@ -270,14 +270,14 @@ where let dispatch_info = xt.get_dispatch_info(); let r = Applyable::apply::(xt, dispatch_info, encoded_len)?; - >::note_applied_extrinsic(&r, encoded_len as u32, dispatch_info); + >::note_applied_extrinsic(&r, encoded_len as u32, dispatch_info); Ok(r) } fn final_checks(header: &System::Header) { // remove temporaries - let new_header = >::finalize(); + let new_header = >::finalize(); // check digest assert_eq!( @@ -319,40 +319,40 @@ where #[cfg(test)] mod tests { use super::*; - use primitives::H256; + use sp_core::H256; use sp_runtime::{ generic::Era, Perbill, DispatchError, testing::{Digest, Header, Block}, traits::{Bounded, Header as HeaderT, BlakeTwo256, IdentityLookup, ConvertInto}, transaction_validity::{InvalidTransaction, UnknownTransaction, TransactionValidityError}, }; - use support::{ + use frame_support::{ impl_outer_event, impl_outer_origin, parameter_types, impl_outer_dispatch, weights::Weight, traits::{Currency, LockIdentifier, LockableCurrency, WithdrawReasons, WithdrawReason}, }; - use system::{Call as SystemCall, ChainContext}; - use balances::Call as BalancesCall; + use frame_system::{self as system, Call as SystemCall, ChainContext}; + use pallet_balances::Call as BalancesCall; use hex_literal::hex; mod custom { - use support::weights::SimpleDispatchInfo; + use frame_support::weights::SimpleDispatchInfo; - pub trait Trait: system::Trait {} + pub trait Trait: frame_system::Trait {} - support::decl_module! { + frame_support::decl_module! { pub struct Module for enum Call where origin: T::Origin { #[weight = SimpleDispatchInfo::FixedNormal(100)] fn some_function(origin) { // NOTE: does not make any different. - let _ = system::ensure_signed(origin); + let _ = frame_system::ensure_signed(origin); } #[weight = SimpleDispatchInfo::FixedOperational(200)] fn some_root_operation(origin) { - let _ = system::ensure_root(origin); + let _ = frame_system::ensure_root(origin); } #[weight = SimpleDispatchInfo::FreeNormal] fn some_unsigned_message(origin) { - let _ = system::ensure_none(origin); + let _ = frame_system::ensure_none(origin); } // module hooks. @@ -369,10 +369,12 @@ mod tests { } } - type System = system::Module; - type Balances = balances::Module; + type System = frame_system::Module; + type Balances = pallet_balances::Module; type Custom = custom::Module; + use pallet_balances as balances; + impl_outer_origin! { pub enum Origin for Runtime { } } @@ -384,8 +386,8 @@ mod tests { } impl_outer_dispatch! { pub enum Call for Runtime where origin: Origin { - system::System, - balances::Balances, + frame_system::System, + pallet_balances::Balances, } } @@ -397,12 +399,12 @@ mod tests { pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); } - impl system::Trait for Runtime { + impl frame_system::Trait for Runtime { type Origin = Origin; type Index = u64; type Call = Call; type BlockNumber = u64; - type Hash = primitives::H256; + type Hash = sp_core::H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; @@ -419,7 +421,7 @@ mod tests { pub const TransferFee: u64 = 0; pub const CreationFee: u64 = 0; } - impl balances::Trait for Runtime { + impl pallet_balances::Trait for Runtime { type Balance = u64; type OnFreeBalanceZero = (); type OnNewAccount = (); @@ -435,7 +437,7 @@ mod tests { pub const TransactionBaseFee: u64 = 10; pub const TransactionByteFee: u64 = 0; } - impl transaction_payment::Trait for Runtime { + impl pallet_transaction_payment::Trait for Runtime { type Currency = Balances; type OnTransactionPayment = (); type TransactionBaseFee = TransactionBaseFee; @@ -462,10 +464,10 @@ mod tests { } type SignedExtra = ( - system::CheckEra, - system::CheckNonce, - system::CheckWeight, - transaction_payment::ChargeTransactionPayment + frame_system::CheckEra, + frame_system::CheckNonce, + frame_system::CheckWeight, + pallet_transaction_payment::ChargeTransactionPayment ); type AllModules = (System, Balances, Custom); type TestXt = sp_runtime::testing::TestXt; @@ -473,10 +475,10 @@ mod tests { fn extra(nonce: u64, fee: u64) -> SignedExtra { ( - system::CheckEra::from(Era::Immortal), - system::CheckNonce::from(nonce), - system::CheckWeight::new(), - transaction_payment::ChargeTransactionPayment::from(fee) + frame_system::CheckEra::from(Era::Immortal), + frame_system::CheckNonce::from(nonce), + frame_system::CheckWeight::new(), + pallet_transaction_payment::ChargeTransactionPayment::from(fee) ) } @@ -486,8 +488,8 @@ mod tests { #[test] fn balance_transfer_dispatch_works() { - let mut t = system::GenesisConfig::default().build_storage::().unwrap(); - balances::GenesisConfig:: { + let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + pallet_balances::GenesisConfig:: { balances: vec![(1, 211)], vesting: vec![], }.assimilate_storage(&mut t).unwrap(); @@ -504,14 +506,14 @@ mod tests { )); let r = Executive::apply_extrinsic(xt); assert!(r.is_ok()); - assert_eq!(>::total_balance(&1), 142 - 10 - weight); - assert_eq!(>::total_balance(&2), 69); + assert_eq!(>::total_balance(&1), 142 - 10 - weight); + assert_eq!(>::total_balance(&2), 69); }); } fn new_test_ext(balance_factor: u64) -> sp_io::TestExternalities { - let mut t = system::GenesisConfig::default().build_storage::().unwrap(); - balances::GenesisConfig:: { + let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + pallet_balances::GenesisConfig:: { balances: vec![(1, 111 * balance_factor)], vesting: vec![], }.assimilate_storage(&mut t).unwrap(); @@ -582,7 +584,7 @@ mod tests { Digest::default(), )); assert!(Executive::apply_extrinsic(xt).is_err()); - assert_eq!(>::extrinsic_index(), Some(0)); + assert_eq!(>::extrinsic_index(), Some(0)); }); } @@ -604,7 +606,7 @@ mod tests { Digest::default(), )); // Initial block weight form the custom module. - assert_eq!(>::all_extrinsics_weight(), 175); + assert_eq!(>::all_extrinsics_weight(), 175); for nonce in 0..=num_to_exhaust_block { let xt = sp_runtime::testing::TestXt( @@ -614,10 +616,10 @@ mod tests { if nonce != num_to_exhaust_block { assert!(res.is_ok()); assert_eq!( - >::all_extrinsics_weight(), + >::all_extrinsics_weight(), encoded_len * (nonce + 1) + 175, ); - assert_eq!(>::extrinsic_index(), Some(nonce as u32 + 1)); + assert_eq!(>::extrinsic_index(), Some(nonce as u32 + 1)); } else { assert_eq!(res, Err(InvalidTransaction::ExhaustsResources.into())); } @@ -633,21 +635,21 @@ mod tests { let len = xt.clone().encode().len() as u32; let mut t = new_test_ext(1); t.execute_with(|| { - assert_eq!(>::all_extrinsics_weight(), 0); - assert_eq!(>::all_extrinsics_weight(), 0); + assert_eq!(>::all_extrinsics_weight(), 0); + assert_eq!(>::all_extrinsics_weight(), 0); assert!(Executive::apply_extrinsic(xt.clone()).unwrap().is_ok()); assert!(Executive::apply_extrinsic(x1.clone()).unwrap().is_ok()); assert!(Executive::apply_extrinsic(x2.clone()).unwrap().is_ok()); // default weight for `TestXt` == encoded length. - assert_eq!(>::all_extrinsics_weight(), (3 * len) as Weight); - assert_eq!(>::all_extrinsics_len(), 3 * len); + assert_eq!(>::all_extrinsics_weight(), (3 * len) as Weight); + assert_eq!(>::all_extrinsics_len(), 3 * len); - let _ = >::finalize(); + let _ = >::finalize(); - assert_eq!(>::all_extrinsics_weight(), 0); - assert_eq!(>::all_extrinsics_weight(), 0); + assert_eq!(>::all_extrinsics_weight(), 0); + assert_eq!(>::all_extrinsics_weight(), 0); }); } @@ -675,7 +677,7 @@ mod tests { let execute_with_lock = |lock: WithdrawReasons| { let mut t = new_test_ext(1); t.execute_with(|| { - as LockableCurrency>::set_lock( + as LockableCurrency>::set_lock( id, &1, 110, @@ -698,13 +700,13 @@ mod tests { if lock == WithdrawReasons::except(WithdrawReason::TransactionPayment) { assert!(Executive::apply_extrinsic(xt).unwrap().is_ok()); // tx fee has been deducted. - assert_eq!(>::total_balance(&1), 111 - 10 - weight); + assert_eq!(>::total_balance(&1), 111 - 10 - weight); } else { assert_eq!( Executive::apply_extrinsic(xt), Err(InvalidTransaction::Payment.into()), ); - assert_eq!(>::total_balance(&1), 111); + assert_eq!(>::total_balance(&1), 111); } }); }; @@ -720,7 +722,7 @@ mod tests { Executive::initialize_block(&Header::new_from_number(1)); // NOTE: might need updates over time if system and balance introduce new weights. For // now only accounts for the custom module. - assert_eq!(>::all_extrinsics_weight(), 150 + 25); + assert_eq!(>::all_extrinsics_weight(), 150 + 25); }) } } diff --git a/frame/finality-tracker/Cargo.toml b/frame/finality-tracker/Cargo.toml index 6169ba8c03..96aef70792 100644 --- a/frame/finality-tracker/Cargo.toml +++ b/frame/finality-tracker/Cargo.toml @@ -7,16 +7,16 @@ 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 } -inherents = { package = "sp-inherents", path = "../../primitives/inherents", default-features = false } +sp-inherents = { path = "../../primitives/inherents", default-features = false } sp-std = { path = "../../primitives/std", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } sp-finality-tracker = { path = "../../primitives/finality-tracker", default-features = false } -support = { package = "frame-support", path = "../support", default-features = false } +frame-support = { path = "../support", default-features = false } frame-system = { path = "../system", default-features = false } impl-trait-for-tuples = "0.1.3" [dev-dependencies] -primitives = { package = "sp-core", path = "../../primitives/core", default-features = false } +sp-core = { path = "../../primitives/core", default-features = false } sp-io = { path = "../../primitives/io", default-features = false } [features] @@ -25,9 +25,9 @@ std = [ "serde/std", "codec/std", "sp-std/std", - "support/std", + "frame-support/std", "sp-runtime/std", "frame-system/std", "sp-finality-tracker/std", - "inherents/std", + "sp-inherents/std", ] diff --git a/frame/finality-tracker/src/lib.rs b/frame/finality-tracker/src/lib.rs index 14aba50834..4837a9cf78 100644 --- a/frame/finality-tracker/src/lib.rs +++ b/frame/finality-tracker/src/lib.rs @@ -18,11 +18,11 @@ #![cfg_attr(not(feature = "std"), no_std)] -use inherents::{InherentIdentifier, ProvideInherent, InherentData, MakeFatalError}; +use sp_inherents::{InherentIdentifier, ProvideInherent, InherentData, MakeFatalError}; use sp_runtime::traits::{One, Zero, SaturatedConversion}; use sp_std::{prelude::*, result, cmp, vec}; -use support::{decl_module, decl_storage}; -use support::traits::Get; +use frame_support::{decl_module, decl_storage}; +use frame_support::traits::Get; use frame_system::{ensure_none, Trait as SystemTrait}; use sp_finality_tracker::{INHERENT_IDENTIFIER, FinalizedInherentData}; @@ -194,12 +194,12 @@ mod tests { use super::*; use sp_io::TestExternalities; - use primitives::H256; + use sp_core::H256; use sp_runtime::{ testing::Header, Perbill, traits::{BlakeTwo256, IdentityLookup, OnFinalize, Header as HeaderT}, }; - use support::{assert_ok, impl_outer_origin, parameter_types, weights::Weight}; + use frame_support::{assert_ok, impl_outer_origin, parameter_types, weights::Weight}; use frame_system as system; use std::cell::RefCell; @@ -213,7 +213,7 @@ mod tests { pub struct Test; impl_outer_origin! { - pub enum Origin for Test {} + pub enum Origin for Test where system = frame_system {} } thread_local! { diff --git a/frame/generic-asset/Cargo.toml b/frame/generic-asset/Cargo.toml index 2b4b5e3ac0..fa05425d11 100644 --- a/frame/generic-asset/Cargo.toml +++ b/frame/generic-asset/Cargo.toml @@ -9,12 +9,12 @@ 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 } 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 } +frame-support = { path = "../support", default-features = false } +frame-system = { path = "../system", default-features = false } [dev-dependencies] sp-io ={ path = "../../primitives/io" } -primitives = { package = "sp-core", path = "../../primitives/core" } +sp-core = { path = "../../primitives/core" } [features] default = ["std"] @@ -23,6 +23,6 @@ std =[ "codec/std", "sp-std/std", "sp-runtime/std", - "support/std", - "system/std", + "frame-support/std", + "frame-system/std", ] diff --git a/frame/generic-asset/src/lib.rs b/frame/generic-asset/src/lib.rs index 9315b36674..4ad61af4a7 100644 --- a/frame/generic-asset/src/lib.rs +++ b/frame/generic-asset/src/lib.rs @@ -114,14 +114,14 @@ //! The Fees module uses the `Currency` trait to handle fee charge/refund, and its types inherit from `Currency`: //! //! ``` -//! use support::{ +//! use frame_support::{ //! dispatch, //! traits::{Currency, ExistenceRequirement, WithdrawReason}, //! }; -//! # pub trait Trait: system::Trait { +//! # pub trait Trait: frame_system::Trait { //! # type Currency: Currency; //! # } -//! type AssetOf = <::Currency as Currency<::AccountId>>::Balance; +//! type AssetOf = <::Currency as Currency<::AccountId>>::Balance; //! //! fn charge_fee(transactor: &T::AccountId, amount: AssetOf) -> dispatch::Result { //! // ... @@ -161,7 +161,7 @@ use sp_runtime::traits::{ use sp_std::prelude::*; use sp_std::{cmp, result, fmt::Debug}; -use support::{ +use frame_support::{ decl_event, decl_module, decl_storage, ensure, dispatch, traits::{ Currency, ExistenceRequirement, Imbalance, LockIdentifier, LockableCurrency, ReservableCurrency, @@ -169,14 +169,14 @@ use support::{ }, Parameter, StorageMap, }; -use system::{ensure_signed, ensure_root}; +use frame_system::{self as system, ensure_signed, ensure_root}; mod mock; mod tests; pub use self::imbalances::{NegativeImbalance, PositiveImbalance}; -pub trait Trait: system::Trait { +pub trait Trait: frame_system::Trait { type Balance: Parameter + Member + SimpleArithmetic @@ -185,10 +185,10 @@ pub trait Trait: system::Trait { + MaybeSerializeDeserialize + Debug; type AssetId: Parameter + Member + SimpleArithmetic + Default + Copy; - type Event: From> + Into<::Event>; + type Event: From> + Into<::Event>; } -pub trait Subtrait: system::Trait { +pub trait Subtrait: frame_system::Trait { type Balance: Parameter + Member + SimpleArithmetic @@ -495,10 +495,10 @@ decl_storage! { decl_event!( pub enum Event where - ::AccountId, + ::AccountId, ::Balance, ::AssetId, - AssetOptions = AssetOptions<::Balance, ::AccountId> + AssetOptions = AssetOptions<::Balance, ::AccountId> { /// Asset created (asset_id, creator, asset_options). Created(AssetId, AccountId, AssetOptions), @@ -760,7 +760,7 @@ impl Module { if locks.is_empty() { return Ok(()); } - let now = >::block_number(); + let now = >::block_number(); if Self::locks(who) .into_iter() .all(|l| now >= l.until || new_balance >= l.amount || !l.reasons.intersects(reasons)) @@ -792,7 +792,7 @@ impl Module { until: T::BlockNumber, reasons: WithdrawReasons, ) { - let now = >::block_number(); + let now = >::block_number(); let mut new_lock = Some(BalanceLock { id, amount, @@ -824,7 +824,7 @@ impl Module { until: T::BlockNumber, reasons: WithdrawReasons, ) { - let now = >::block_number(); + let now = >::block_number(); let mut new_lock = Some(BalanceLock { id, amount, @@ -855,7 +855,7 @@ impl Module { } fn remove_lock(id: LockIdentifier, who: &T::AccountId) { - let now = >::block_number(); + let now = >::block_number(); let locks = >::locks(who) .into_iter() .filter_map(|l| if l.until > now && l.id != id { Some(l) } else { None }) @@ -1076,7 +1076,7 @@ impl PartialEq for ElevatedTrait { } } impl Eq for ElevatedTrait {} -impl system::Trait for ElevatedTrait { +impl frame_system::Trait for ElevatedTrait { type Origin = T::Origin; type Call = T::Call; type Index = T::Index; diff --git a/frame/generic-asset/src/mock.rs b/frame/generic-asset/src/mock.rs index 461fb0aeca..90426516c1 100644 --- a/frame/generic-asset/src/mock.rs +++ b/frame/generic-asset/src/mock.rs @@ -25,13 +25,13 @@ use sp_runtime::{ testing::Header, traits::{BlakeTwo256, IdentityLookup}, }; -use primitives::H256; -use support::{parameter_types, impl_outer_event, impl_outer_origin, weights::Weight}; +use sp_core::H256; +use frame_support::{parameter_types, impl_outer_event, impl_outer_origin, weights::Weight}; use super::*; impl_outer_origin! { - pub enum Origin for Test {} + pub enum Origin for Test where system = frame_system {} } // For testing the module, we construct most of a mock runtime. This means @@ -45,7 +45,7 @@ parameter_types! { pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); } -impl system::Trait for Test { +impl frame_system::Trait for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; @@ -73,6 +73,7 @@ mod generic_asset { pub use crate::Event; } +use frame_system as system; impl_outer_event! { pub enum TestEvent for Test { generic_asset, @@ -81,7 +82,7 @@ impl_outer_event! { pub type GenericAsset = Module; -pub type System = system::Module; +pub type System = frame_system::Module; pub struct ExtBuilder { asset_id: u32, @@ -118,7 +119,7 @@ impl ExtBuilder { // builds genesis config pub fn build(self) -> sp_io::TestExternalities { - let mut t = system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); GenesisConfig:: { assets: vec![self.asset_id], @@ -137,7 +138,7 @@ impl ExtBuilder { // This function basically just builds a genesis storage key/value store according to // our desired mockup. pub fn new_test_ext() -> sp_io::TestExternalities { - system::GenesisConfig::default() + frame_system::GenesisConfig::default() .build_storage::() .unwrap() .into() diff --git a/frame/generic-asset/src/tests.rs b/frame/generic-asset/src/tests.rs index 165936d021..1f9f458b2c 100644 --- a/frame/generic-asset/src/tests.rs +++ b/frame/generic-asset/src/tests.rs @@ -22,7 +22,7 @@ use super::*; use crate::mock::{new_test_ext, ExtBuilder, GenericAsset, Origin, System, Test, TestEvent}; -use support::{assert_noop, assert_ok}; +use frame_support::{assert_noop, assert_ok}; #[test] fn issuing_asset_units_to_issuer_should_work() { @@ -906,7 +906,7 @@ fn update_permission_should_throw_error_when_lack_of_permissions() { fn create_asset_works_with_given_asset_id_and_from_account() { ExtBuilder::default().next_asset_id(10).build().execute_with(|| { let origin = 1; - let from_account: Option<::AccountId> = Some(1); + let from_account: Option<::AccountId> = Some(1); let default_permission = PermissionLatest { update: Owner::Address(origin), @@ -943,7 +943,7 @@ fn create_asset_works_with_given_asset_id_and_from_account() { fn create_asset_with_non_reserved_asset_id_should_not_work() { ExtBuilder::default().next_asset_id(10).build().execute_with(|| { let origin = 1; - let from_account: Option<::AccountId> = Some(1); + let from_account: Option<::AccountId> = Some(1); let default_permission = PermissionLatest { update: Owner::Address(origin), @@ -977,7 +977,7 @@ fn create_asset_with_non_reserved_asset_id_should_not_work() { fn create_asset_with_a_taken_asset_id_should_not_work() { ExtBuilder::default().next_asset_id(10).build().execute_with(|| { let origin = 1; - let from_account: Option<::AccountId> = Some(1); + let from_account: Option<::AccountId> = Some(1); let default_permission = PermissionLatest { update: Owner::Address(origin), @@ -1022,7 +1022,7 @@ fn create_asset_with_a_taken_asset_id_should_not_work() { fn create_asset_should_create_a_reserved_asset_when_from_account_is_none() { ExtBuilder::default().next_asset_id(10).build().execute_with(|| { let origin = 1; - let from_account: Option<::AccountId> = None; + let from_account: Option<::AccountId> = None; let default_permission = PermissionLatest { update: Owner::Address(origin), @@ -1065,7 +1065,7 @@ fn create_asset_should_create_a_reserved_asset_when_from_account_is_none() { fn create_asset_should_create_a_user_asset() { ExtBuilder::default().next_asset_id(10).build().execute_with(|| { let origin = 1; - let from_account: Option<::AccountId> = None; + let from_account: Option<::AccountId> = None; let default_permission = PermissionLatest { update: Owner::Address(origin), diff --git a/frame/grandpa/Cargo.toml b/frame/grandpa/Cargo.toml index 49cb393315..bfb330fcee 100644 --- a/frame/grandpa/Cargo.toml +++ b/frame/grandpa/Cargo.toml @@ -7,15 +7,15 @@ edition = "2018" [dependencies] serde = { version = "1.0.101", optional = true, features = ["derive"] } 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-core = { path = "../../primitives/core", default-features = false } sp-finality-grandpa = { path = "../../primitives/finality-grandpa", default-features = false } sp-std = { path = "../../primitives/std", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } sp-staking = { path = "../../primitives/staking", default-features = false } -support = { package = "frame-support", path = "../support", default-features = false } -system = { package = "frame-system", path = "../system", default-features = false } -session = { package = "pallet-session", path = "../session", default-features = false } -finality-tracker = { package = "pallet-finality-tracker", path = "../finality-tracker", default-features = false } +frame-support = { path = "../support", default-features = false } +frame-system = { path = "../system", default-features = false } +pallet-session = { path = "../session", default-features = false } +pallet-finality-tracker = { path = "../finality-tracker", default-features = false } [dev-dependencies] sp-io ={ path = "../../primitives/io" } @@ -25,14 +25,14 @@ default = ["std"] std = [ "serde", "codec/std", - "primitives/std", + "sp-core/std", "sp-finality-grandpa/std", "sp-std/std", - "support/std", + "frame-support/std", "sp-runtime/std", "sp-staking/std", - "system/std", - "session/std", - "finality-tracker/std", + "frame-system/std", + "pallet-session/std", + "pallet-finality-tracker/std", ] migrate-authorities = [] diff --git a/frame/grandpa/src/lib.rs b/frame/grandpa/src/lib.rs index 301a09d107..8c017acc91 100644 --- a/frame/grandpa/src/lib.rs +++ b/frame/grandpa/src/lib.rs @@ -32,7 +32,7 @@ pub use sp_finality_grandpa as fg_primitives; use sp_std::prelude::*; use codec::{self as codec, Encode, Decode, Error}; -use support::{decl_event, decl_storage, decl_module, dispatch, storage}; +use frame_support::{decl_event, decl_storage, decl_module, dispatch, storage}; use sp_runtime::{ generic::{DigestItem, OpaqueDigestItemId}, traits::Zero, Perbill, }; @@ -44,14 +44,14 @@ use fg_primitives::{ GRANDPA_AUTHORITIES_KEY, GRANDPA_ENGINE_ID, ScheduledChange, ConsensusLog, SetId, RoundNumber, }; pub use fg_primitives::{AuthorityId, AuthorityList, AuthorityWeight, VersionedAuthorityList}; -use system::{ensure_signed, DigestOf}; +use frame_system::{self as system, ensure_signed, DigestOf}; mod mock; mod tests; -pub trait Trait: system::Trait { +pub trait Trait: frame_system::Trait { /// The event type of this module. - type Event: From + Into<::Event>; + type Event: From + Into<::Event>; } /// A stored pending change, old format. @@ -266,7 +266,7 @@ impl Module { /// Cannot be done when already paused. pub fn schedule_pause(in_blocks: T::BlockNumber) -> dispatch::Result { if let StoredState::Live = >::get() { - let scheduled_at = >::block_number(); + let scheduled_at = >::block_number(); >::put(StoredState::PendingPause { delay: in_blocks, scheduled_at, @@ -282,7 +282,7 @@ impl Module { /// Schedule a resume of GRANDPA after pausing. pub fn schedule_resume(in_blocks: T::BlockNumber) -> dispatch::Result { if let StoredState::Paused = >::get() { - let scheduled_at = >::block_number(); + let scheduled_at = >::block_number(); >::put(StoredState::PendingResume { delay: in_blocks, scheduled_at, @@ -315,7 +315,7 @@ impl Module { forced: Option, ) -> dispatch::Result { if !>::exists() { - let scheduled_at = >::block_number(); + let scheduled_at = >::block_number(); if let Some(_) = forced { if Self::next_forced().map_or(false, |next| next > scheduled_at) { @@ -343,7 +343,7 @@ impl Module { /// Deposit one of this module's logs. fn deposit_log(log: ConsensusLog) { let log: DigestItem = DigestItem::Consensus(GRANDPA_ENGINE_ID, log.encode()); - >::deposit_log(log.into()); + >::deposit_log(log.into()); } fn initialize_authorities(authorities: &AuthorityList) { @@ -404,8 +404,8 @@ impl sp_runtime::BoundToRuntimeAppPublic for Module { type Public = AuthorityId; } -impl session::OneSessionHandler for Module - where T: session::Trait +impl pallet_session::OneSessionHandler for Module + where T: pallet_session::Trait { type Key = AuthorityId; @@ -438,7 +438,7 @@ impl session::OneSessionHandler for Module // if we didn't issue a change, we update the mapping to note that the current // set corresponds to the latest equivalent session (i.e. now). - let session_index = >::current_index(); + let session_index = >::current_index(); SetIdSession::insert(current_set_id, &session_index); } @@ -447,9 +447,9 @@ impl session::OneSessionHandler for Module } } -impl finality_tracker::OnFinalizationStalled for Module { +impl pallet_finality_tracker::OnFinalizationStalled for Module { fn on_stalled(further_wait: T::BlockNumber, median: T::BlockNumber) { - // when we record old authority sets, we can use `finality_tracker::median` + // when we record old authority sets, we can use `pallet_finality_tracker::median` // to figure out _who_ failed. until then, we can't meaningfully guard // against `next == last` the way that normal session changes do. >::put((further_wait, median)); diff --git a/frame/grandpa/src/mock.rs b/frame/grandpa/src/mock.rs index 8826414cfc..20701b11aa 100644 --- a/frame/grandpa/src/mock.rs +++ b/frame/grandpa/src/mock.rs @@ -20,14 +20,15 @@ use sp_runtime::{Perbill, DigestItem, traits::IdentityLookup, testing::{Header, UintAuthorityId}}; use sp_io; -use support::{impl_outer_origin, impl_outer_event, parameter_types, weights::Weight}; -use primitives::H256; +use frame_support::{impl_outer_origin, impl_outer_event, parameter_types, weights::Weight}; +use sp_core::H256; use codec::{Encode, Decode}; use crate::{AuthorityId, AuthorityList, GenesisConfig, Trait, Module, ConsensusLog}; use sp_finality_grandpa::GRANDPA_ENGINE_ID; +use frame_system as system; impl_outer_origin!{ - pub enum Origin for Test {} + pub enum Origin for Test where system = frame_system {} } pub fn grandpa_log(log: ConsensusLog) -> DigestItem { @@ -47,7 +48,7 @@ parameter_types! { pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); } -impl system::Trait for Test { +impl frame_system::Trait for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; @@ -82,12 +83,12 @@ pub fn to_authorities(vec: Vec<(u64, u64)>) -> AuthorityList { } pub fn new_test_ext(authorities: Vec<(u64, u64)>) -> sp_io::TestExternalities { - let mut t = system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); GenesisConfig { authorities: to_authorities(authorities), }.assimilate_storage::(&mut t).unwrap(); t.into() } -pub type System = system::Module; +pub type System = frame_system::Module; pub type Grandpa = Module; diff --git a/frame/grandpa/src/tests.rs b/frame/grandpa/src/tests.rs index 9ca00fd169..5ad26d22f4 100644 --- a/frame/grandpa/src/tests.rs +++ b/frame/grandpa/src/tests.rs @@ -20,7 +20,7 @@ use sp_runtime::{testing::Digest, traits::{Header, OnFinalize}}; use crate::mock::*; -use system::{EventRecord, Phase}; +use frame_system::{EventRecord, Phase}; use codec::{Decode, Encode}; use fg_primitives::ScheduledChange; use super::*; diff --git a/frame/identity/Cargo.toml b/frame/identity/Cargo.toml index c1518bfcfc..74979dec5d 100644 --- a/frame/identity/Cargo.toml +++ b/frame/identity/Cargo.toml @@ -11,12 +11,12 @@ enumflags2 = { version = "0.6.2" } sp-std = { path = "../../primitives/std", 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 } +frame-support = { path = "../support", default-features = false } +frame-system = { path = "../system", default-features = false } [dev-dependencies] -primitives = { package = "sp-core", path = "../../primitives/core" } -balances = { package = "pallet-balances", path = "../balances" } +sp-core = { path = "../../primitives/core" } +pallet-balances = { path = "../balances" } [features] default = ["std"] @@ -26,6 +26,6 @@ std = [ "sp-std/std", "sp-io/std", "sp-runtime/std", - "support/std", - "system/std", + "frame-support/std", + "frame-system/std", ] diff --git a/frame/identity/src/lib.rs b/frame/identity/src/lib.rs index 904ab8cf2e..2813d6c83b 100644 --- a/frame/identity/src/lib.rs +++ b/frame/identity/src/lib.rs @@ -70,19 +70,19 @@ use sp_std::{fmt::Debug, ops::Add, iter::once}; use enumflags2::BitFlags; use codec::{Encode, Decode}; use sp_runtime::{traits::{StaticLookup, EnsureOrigin, Zero}, RuntimeDebug}; -use support::{ +use frame_support::{ decl_module, decl_event, decl_storage, ensure, dispatch::Result, traits::{Currency, ReservableCurrency, OnUnbalanced, Get}, weights::SimpleDispatchInfo, }; -use system::{ensure_signed, ensure_root}; +use frame_system::{self as system, ensure_signed, ensure_root}; -type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; -type NegativeImbalanceOf = <::Currency as Currency<::AccountId>>::NegativeImbalance; +type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; +type NegativeImbalanceOf = <::Currency as Currency<::AccountId>>::NegativeImbalance; -pub trait Trait: system::Trait { +pub trait Trait: frame_system::Trait { /// The overarching event type. - type Event: From> + Into<::Event>; + type Event: From> + Into<::Event>; /// The currency trait. type Currency: ReservableCurrency; @@ -383,7 +383,7 @@ decl_storage! { } decl_event!( - pub enum Event where AccountId = ::AccountId, Balance = BalanceOf { + pub enum Event where AccountId = ::AccountId, Balance = BalanceOf { /// A name was set or reset (which will remove all judgements). IdentitySet(AccountId), /// A name was cleared, and the given balance returned. @@ -822,9 +822,9 @@ decl_module! { mod tests { use super::*; - use support::{assert_ok, assert_noop, impl_outer_origin, parameter_types, weights::Weight}; - use primitives::H256; - use system::EnsureSignedBy; + use frame_support::{assert_ok, assert_noop, impl_outer_origin, parameter_types, weights::Weight}; + use sp_core::H256; + use frame_system::EnsureSignedBy; // The testing primitives are very useful for avoiding having to work with signatures // or public keys. `u64` is used as the `AccountId` and no `Signature`s are required. use sp_runtime::{ @@ -832,7 +832,7 @@ mod tests { }; impl_outer_origin! { - pub enum Origin for Test {} + pub enum Origin for Test where system = frame_system {} } // For testing the module, we construct most of a mock runtime. This means @@ -846,7 +846,7 @@ mod tests { pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); } - impl system::Trait for Test { + impl frame_system::Trait for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; @@ -868,7 +868,7 @@ mod tests { pub const TransferFee: u64 = 0; pub const CreationFee: u64 = 0; } - impl balances::Trait for Test { + impl pallet_balances::Trait for Test { type Balance = u64; type OnFreeBalanceZero = (); type OnNewAccount = (); @@ -898,15 +898,15 @@ mod tests { type RegistrarOrigin = EnsureSignedBy; type ForceOrigin = EnsureSignedBy; } - type Balances = balances::Module; + type Balances = pallet_balances::Module; type Identity = Module; // This function basically just builds a genesis storage key/value store according to // our desired mockup. fn new_test_ext() -> sp_io::TestExternalities { - let mut t = system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); // We use default for brevity, but you can configure as desired if needed. - balances::GenesisConfig:: { + pallet_balances::GenesisConfig:: { balances: vec![ (1, 10), (2, 10), diff --git a/frame/im-online/Cargo.toml b/frame/im-online/Cargo.toml index e71a2f41c4..2b498c2ae9 100644 --- a/frame/im-online/Cargo.toml +++ b/frame/im-online/Cargo.toml @@ -5,32 +5,32 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -app-crypto = { package = "sp-application-crypto", path = "../../primitives/application-crypto", default-features = false } -authorship = { package = "pallet-authorship", path = "../authorship", default-features = false } +sp-application-crypto = { path = "../../primitives/application-crypto", default-features = false } +pallet-authorship = { path = "../authorship", 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-core = { path = "../../primitives/core", default-features = false } sp-std = { path = "../../primitives/std", default-features = false } serde = { version = "1.0.101", optional = true } -session = { package = "pallet-session", path = "../session", default-features = false } +pallet-session = { path = "../session", default-features = false } sp-io = { path = "../../primitives/io", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } sp-staking = { path = "../../primitives/staking", default-features = false } -support = { package = "frame-support", path = "../support", default-features = false } -system = { package = "frame-system", path = "../system", default-features = false } +frame-support = { path = "../support", default-features = false } +frame-system = { path = "../system", default-features = false } [features] -default = ["std", "session/historical"] +default = ["std", "pallet-session/historical"] std = [ - "app-crypto/std", - "authorship/std", + "sp-application-crypto/std", + "pallet-authorship/std", "codec/std", - "primitives/std", + "sp-core/std", "sp-std/std", "serde", - "session/std", + "pallet-session/std", "sp-io/std", "sp-runtime/std", "sp-staking/std", - "support/std", - "system/std", + "frame-support/std", + "frame-system/std", ] diff --git a/frame/im-online/src/lib.rs b/frame/im-online/src/lib.rs index c9991cf690..64d23dbb5d 100644 --- a/frame/im-online/src/lib.rs +++ b/frame/im-online/src/lib.rs @@ -42,8 +42,8 @@ //! ## Usage //! //! ``` -//! use support::{decl_module, dispatch}; -//! use system::ensure_signed; +//! use frame_support::{decl_module, dispatch}; +//! use frame_system::{self as system, ensure_signed}; //! use pallet_im_online::{self as im_online}; //! //! pub trait Trait: im_online::Trait {} @@ -70,12 +70,12 @@ mod mock; mod tests; -use app_crypto::RuntimeAppPublic; +use sp_application_crypto::RuntimeAppPublic; use codec::{Encode, Decode}; -use primitives::offchain::{OpaqueNetworkState, StorageKind}; +use sp_core::offchain::{OpaqueNetworkState, StorageKind}; use sp_std::prelude::*; use sp_std::convert::TryInto; -use session::historical::IdentificationTuple; +use pallet_session::historical::IdentificationTuple; use sp_runtime::{ RuntimeDebug, traits::{Convert, Member, Printable, Saturating}, Perbill, @@ -88,16 +88,16 @@ use sp_staking::{ SessionIndex, offence::{ReportOffence, Offence, Kind}, }; -use support::{ +use frame_support::{ decl_module, decl_event, decl_storage, print, Parameter, debug, traits::Get, }; -use system::ensure_none; -use system::offchain::SubmitUnsignedTransaction; +use frame_system::{self as system, ensure_none}; +use frame_system::offchain::SubmitUnsignedTransaction; pub mod sr25519 { mod app_sr25519 { - use app_crypto::{app_crypto, key_types::IM_ONLINE, sr25519}; + use sp_application_crypto::{app_crypto, key_types::IM_ONLINE, sr25519}; app_crypto!(sr25519, IM_ONLINE); } @@ -114,7 +114,7 @@ pub mod sr25519 { pub mod ed25519 { mod app_ed25519 { - use app_crypto::{app_crypto, key_types::IM_ONLINE, ed25519}; + use sp_application_crypto::{app_crypto, key_types::IM_ONLINE, ed25519}; app_crypto!(ed25519, IM_ONLINE); } @@ -177,12 +177,12 @@ pub struct Heartbeat authority_index: AuthIndex, } -pub trait Trait: system::Trait + session::historical::Trait { +pub trait Trait: frame_system::Trait + pallet_session::historical::Trait { /// The identifier type for an authority. type AuthorityId: Member + Parameter + RuntimeAppPublic + Default + Ord; /// The overarching event type. - type Event: From> + Into<::Event>; + type Event: From> + Into<::Event>; /// A dispatchable call type. type Call: From>; @@ -257,7 +257,7 @@ decl_module! { ) { ensure_none(origin)?; - let current_session = >::current_index(); + let current_session = >::current_index(); let exists = ::exists( ¤t_session, &heartbeat.authority_index @@ -294,7 +294,7 @@ decl_module! { /// Keep track of number of authored blocks per authority, uncles are counted as /// well since they're a valid proof of onlineness. -impl authorship::EventHandler for Module { +impl pallet_authorship::EventHandler for Module { fn note_author(author: T::ValidatorId) { Self::note_authorship(author); } @@ -310,7 +310,7 @@ impl Module { /// authored at least one block, during the current session. Otherwise /// `false`. pub fn is_online(authority_index: AuthIndex) -> bool { - let current_validators = >::validators(); + let current_validators = >::validators(); if authority_index >= current_validators.len() as u32 { return false; @@ -322,7 +322,7 @@ impl Module { } fn is_online_aux(authority_index: AuthIndex, authority: &T::ValidatorId) -> bool { - let current_session = >::current_index(); + let current_session = >::current_index(); ::exists(¤t_session, &authority_index) || >::get( @@ -334,13 +334,13 @@ impl Module { /// Returns `true` if a heartbeat has been received for the authority at `authority_index` in /// the authorities series, during the current session. Otherwise `false`. pub fn received_heartbeat_in_current_session(authority_index: AuthIndex) -> bool { - let current_session = >::current_index(); + let current_session = >::current_index(); ::exists(¤t_session, &authority_index) } /// Note that the given authority has authored a block in the current session. fn note_authorship(author: T::ValidatorId) { - let current_session = >::current_index(); + let current_session = >::current_index(); >::mutate( ¤t_session, @@ -413,7 +413,7 @@ impl Module { let heartbeat_data = Heartbeat { block_number, network_state, - session_index: >::current_index(), + session_index: >::current_index(), authority_index, }; @@ -513,7 +513,7 @@ impl sp_runtime::BoundToRuntimeAppPublic for Module { type Public = T::AuthorityId; } -impl session::OneSessionHandler for Module { +impl pallet_session::OneSessionHandler for Module { type Key = T::AuthorityId; fn on_genesis_session<'a, I: 'a>(validators: I) @@ -529,7 +529,7 @@ impl session::OneSessionHandler for Module { // Tell the offchain worker to start making the next session's heartbeats. // Since we consider producing blocks as being online, // the hearbeat is defered a bit to prevent spaming. - let block_number = >::block_number(); + let block_number = >::block_number(); let half_session = T::SessionDuration::get() / 2.into(); >::put(block_number + half_session); @@ -538,9 +538,9 @@ impl session::OneSessionHandler for Module { } fn on_before_session_ending() { - let session_index = >::current_index(); + let session_index = >::current_index(); let keys = Keys::::get(); - let current_validators = >::validators(); + let current_validators = >::validators(); let offenders = current_validators.into_iter().enumerate() .filter(|(index, id)| @@ -552,8 +552,8 @@ impl session::OneSessionHandler for Module { // Remove all received heartbeats and number of authored blocks from the // current session, they have already been processed and won't be needed // anymore. - ::remove_prefix(&>::current_index()); - >::remove_prefix(&>::current_index()); + ::remove_prefix(&>::current_index()); + >::remove_prefix(&>::current_index()); if offenders.is_empty() { Self::deposit_event(RawEvent::AllGood); @@ -572,7 +572,7 @@ impl session::OneSessionHandler for Module { } #[allow(deprecated)] -impl support::unsigned::ValidateUnsigned for Module { +impl frame_support::unsigned::ValidateUnsigned for Module { type Call = Call; fn validate_unsigned(call: &Self::Call) -> TransactionValidity { @@ -583,7 +583,7 @@ impl support::unsigned::ValidateUnsigned for Module { } // check if session index from heartbeat is recent - let current_session = >::current_index(); + let current_session = >::current_index(); if heartbeat.session_index != current_session { return InvalidTransaction::Stale.into(); } diff --git a/frame/im-online/src/mock.rs b/frame/im-online/src/mock.rs index 48af849195..94f91ddc2e 100644 --- a/frame/im-online/src/mock.rs +++ b/frame/im-online/src/mock.rs @@ -25,10 +25,10 @@ use sp_runtime::Perbill; use sp_staking::{SessionIndex, offence::ReportOffence}; 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 {sp_io, system}; +use sp_core::H256; +use frame_support::{impl_outer_origin, impl_outer_dispatch, parameter_types, weights::Weight}; +use frame_system as system; impl_outer_origin!{ pub enum Origin for Runtime {} } @@ -44,7 +44,7 @@ thread_local! { } pub struct TestOnSessionEnding; -impl session::OnSessionEnding for TestOnSessionEnding { +impl pallet_session::OnSessionEnding for TestOnSessionEnding { fn on_session_ending(_ending_index: SessionIndex, _will_apply_at: SessionIndex) -> Option> { @@ -52,7 +52,7 @@ impl session::OnSessionEnding for TestOnSessionEnding { } } -impl session::historical::OnSessionEnding for TestOnSessionEnding { +impl pallet_session::historical::OnSessionEnding for TestOnSessionEnding { fn on_session_ending(_ending_index: SessionIndex, _will_apply_at: SessionIndex) -> Option<(Vec, Vec<(u64, u64)>)> { @@ -69,7 +69,7 @@ impl session::historical::OnSessionEnding for TestOnSessionEnding { /// An extrinsic type used for tests. pub type Extrinsic = TestXt; -type SubmitTransaction = system::offchain::TransactionSubmitter<(), Call, Extrinsic>; +type SubmitTransaction = frame_system::offchain::TransactionSubmitter<(), Call, Extrinsic>; type IdentificationTuple = (u64, u64); type Offence = crate::UnresponsivenessOffence; @@ -86,7 +86,7 @@ impl ReportOffence for OffenceHandler { } pub fn new_test_ext() -> sp_io::TestExternalities { - let t = system::GenesisConfig::default().build_storage::().unwrap(); + let t = frame_system::GenesisConfig::default().build_storage::().unwrap(); t.into() } @@ -101,7 +101,7 @@ parameter_types! { pub const AvailableBlockRatio: Perbill = Perbill::one(); } -impl system::Trait for Runtime { +impl frame_system::Trait for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = u64; @@ -128,9 +128,9 @@ parameter_types! { pub const DisabledValidatorsThreshold: Perbill = Perbill::from_percent(33); } -impl session::Trait for Runtime { - type ShouldEndSession = session::PeriodicSessions; - type OnSessionEnding = session::historical::NoteHistoricalRoot; +impl pallet_session::Trait for Runtime { + type ShouldEndSession = pallet_session::PeriodicSessions; + type OnSessionEnding = pallet_session::historical::NoteHistoricalRoot; type SessionHandler = (ImOnline, ); type ValidatorId = u64; type ValidatorIdOf = ConvertInto; @@ -140,7 +140,7 @@ impl session::Trait for Runtime { type DisabledValidatorsThreshold = DisabledValidatorsThreshold; } -impl session::historical::Trait for Runtime { +impl pallet_session::historical::Trait for Runtime { type FullIdentification = u64; type FullIdentificationOf = ConvertInto; } @@ -149,7 +149,7 @@ parameter_types! { pub const UncleGenerations: u32 = 5; } -impl authorship::Trait for Runtime { +impl pallet_authorship::Trait for Runtime { type FindAuthor = (); type UncleGenerations = UncleGenerations; type FilterUncle = (); @@ -167,8 +167,8 @@ impl Trait for Runtime { /// Im Online module. pub type ImOnline = Module; -pub type System = system::Module; -pub type Session = session::Module; +pub type System = frame_system::Module; +pub type Session = pallet_session::Module; pub fn advance_session() { let now = System::block_number(); diff --git a/frame/im-online/src/tests.rs b/frame/im-online/src/tests.rs index db91a215de..3fbd424421 100644 --- a/frame/im-online/src/tests.rs +++ b/frame/im-online/src/tests.rs @@ -20,13 +20,13 @@ use super::*; use crate::mock::*; -use primitives::offchain::{ +use sp_core::offchain::{ OpaquePeerId, OffchainExt, TransactionPoolExt, testing::{TestOffchainExt, TestTransactionPoolExt}, }; -use support::{dispatch, assert_noop}; +use frame_support::{dispatch, assert_noop}; use sp_runtime::testing::UintAuthorityId; #[test] @@ -113,7 +113,7 @@ fn heartbeat( id: UintAuthorityId, ) -> dispatch::Result { #[allow(deprecated)] - use support::unsigned::ValidateUnsigned; + use frame_support::unsigned::ValidateUnsigned; let heartbeat = Heartbeat { block_number, @@ -129,7 +129,7 @@ fn heartbeat( #[allow(deprecated)] // Allow ValidateUnsigned ImOnline::pre_dispatch(&crate::Call::heartbeat(heartbeat.clone(), signature.clone()))?; ImOnline::heartbeat( - Origin::system(system::RawOrigin::None), + Origin::system(frame_system::RawOrigin::None), heartbeat, signature ) @@ -262,7 +262,7 @@ fn should_cleanup_received_heartbeats_on_session_end() { #[test] fn should_mark_online_validator_when_block_is_authored() { - use authorship::EventHandler; + use pallet_authorship::EventHandler; new_test_ext().execute_with(|| { advance_session(); @@ -292,7 +292,7 @@ fn should_mark_online_validator_when_block_is_authored() { #[test] fn should_not_send_a_report_if_already_online() { - use authorship::EventHandler; + use pallet_authorship::EventHandler; let mut ext = new_test_ext(); let (offchain, _state) = TestOffchainExt::new(); @@ -313,7 +313,7 @@ fn should_not_send_a_report_if_already_online() { ImOnline::note_uncle(3, 0); // when - UintAuthorityId::set_all_keys(vec![0]); // all authorities use session key 0 + UintAuthorityId::set_all_keys(vec![0]); // all authorities use pallet_session key 0 ImOnline::offchain(4); // then diff --git a/frame/indices/Cargo.toml b/frame/indices/Cargo.toml index 2503d0ea60..24609622f3 100644 --- a/frame/indices/Cargo.toml +++ b/frame/indices/Cargo.toml @@ -12,9 +12,9 @@ sp-keyring = { path = "../../primitives/keyring", optional = true } sp-std = { path = "../../primitives/std", 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 } -system = { package = "frame-system", path = "../system", default-features = false } +sp-core = { path = "../../primitives/core", default-features = false } +frame-support = { path = "../support", default-features = false } +frame-system = { path = "../system", default-features = false } [dev-dependencies] ref_thread_local = "0.0.0" @@ -26,10 +26,10 @@ std = [ "safe-mix/std", "sp-keyring", "codec/std", - "primitives/std", + "sp-core/std", "sp-std/std", "sp-io/std", - "support/std", + "frame-support/std", "sp-runtime/std", - "system/std", + "frame-system/std", ] diff --git a/frame/indices/src/lib.rs b/frame/indices/src/lib.rs index f74991e4ac..af30d5297e 100644 --- a/frame/indices/src/lib.rs +++ b/frame/indices/src/lib.rs @@ -21,9 +21,9 @@ use sp_std::{prelude::*, marker::PhantomData, convert::TryInto}; use codec::{Encode, Codec}; -use support::{Parameter, decl_module, decl_event, decl_storage}; +use frame_support::{Parameter, decl_module, decl_event, decl_storage}; use sp_runtime::traits::{One, SimpleArithmetic, StaticLookup, Member, LookupError}; -use system::{IsDeadAccount, OnNewAccount}; +use frame_system::{IsDeadAccount, OnNewAccount}; use self::address::Address as RawAddress; @@ -35,7 +35,7 @@ mod tests; /// Number of account IDs stored per enum set. const ENUM_SET_SIZE: u32 = 64; -pub type Address = RawAddress<::AccountId, ::AccountIndex>; +pub type Address = RawAddress<::AccountId, ::AccountIndex>; /// Turn an Id into an Index, or None for the purpose of getting /// a hint at a possibly desired index. @@ -56,7 +56,7 @@ impl> } /// The module's config trait. -pub trait Trait: system::Trait { +pub trait Trait: frame_system::Trait { /// Type used for storing an account's index; implies the maximum number of accounts the system /// can hold. type AccountIndex: Parameter + Member + Codec + Default + SimpleArithmetic + Copy; @@ -68,18 +68,18 @@ pub trait Trait: system::Trait { type ResolveHint: ResolveHint; /// The overarching event type. - type Event: From> + Into<::Event>; + type Event: From> + Into<::Event>; } decl_module! { - pub struct Module for enum Call where origin: T::Origin { + pub struct Module for enum Call where origin: T::Origin, system = frame_system { fn deposit_event() = default; } } decl_event!( pub enum Event where - ::AccountId, + ::AccountId, ::AccountIndex { /// A new account index was assigned. diff --git a/frame/indices/src/mock.rs b/frame/indices/src/mock.rs index ea24f46e13..e4ff3d2d77 100644 --- a/frame/indices/src/mock.rs +++ b/frame/indices/src/mock.rs @@ -22,13 +22,12 @@ use std::collections::HashSet; use ref_thread_local::{ref_thread_local, RefThreadLocal}; use sp_runtime::testing::Header; use sp_runtime::Perbill; -use primitives::H256; -use support::{impl_outer_origin, parameter_types, weights::Weight}; -use {sp_io, system}; +use sp_core::H256; +use frame_support::{impl_outer_origin, parameter_types, weights::Weight}; use crate::{GenesisConfig, Module, Trait, IsDeadAccount, OnNewAccount, ResolveHint}; impl_outer_origin!{ - pub enum Origin for Runtime {} + pub enum Origin for Runtime where system = frame_system {} } ref_thread_local! { @@ -71,7 +70,7 @@ parameter_types! { pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); } -impl system::Trait for Runtime { +impl frame_system::Trait for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = u64; @@ -102,7 +101,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { for i in 1..5 { h.insert(i); } } - let mut t = system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); GenesisConfig:: { ids: vec![1, 2, 3, 4] }.assimilate_storage(&mut t).unwrap(); diff --git a/frame/membership/Cargo.toml b/frame/membership/Cargo.toml index 13c6fba9f9..c5ffc8ce81 100644 --- a/frame/membership/Cargo.toml +++ b/frame/membership/Cargo.toml @@ -9,12 +9,12 @@ 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 } 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 } +frame-support = { path = "../support", default-features = false } +frame-system = { path = "../system", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } [dev-dependencies] -primitives = { package = "sp-core", path = "../../primitives/core" } +sp-core = { path = "../../primitives/core" } [features] default = ["std"] @@ -24,6 +24,6 @@ std = [ "sp-runtime/std", "sp-std/std", "sp-io/std", - "support/std", - "system/std", + "frame-support/std", + "frame-system/std", ] diff --git a/frame/membership/src/lib.rs b/frame/membership/src/lib.rs index 2c441f2d72..93fcb479c7 100644 --- a/frame/membership/src/lib.rs +++ b/frame/membership/src/lib.rs @@ -23,17 +23,17 @@ #![cfg_attr(not(feature = "std"), no_std)] use sp_std::prelude::*; -use support::{ +use frame_support::{ decl_module, decl_storage, decl_event, traits::{ChangeMembers, InitializeMembers}, weights::SimpleDispatchInfo, }; -use system::{ensure_root, ensure_signed}; +use frame_system::{self as system, ensure_root, ensure_signed}; use sp_runtime::traits::EnsureOrigin; -pub trait Trait: system::Trait { +pub trait Trait: frame_system::Trait { /// The overarching event type. - type Event: From> + Into<::Event>; + type Event: From> + Into<::Event>; /// Required origin for adding a member (though can always be Root). type AddOrigin: EnsureOrigin; @@ -75,7 +75,7 @@ decl_storage! { decl_event!( pub enum Event where - ::AccountId, + ::AccountId, >::Event, { /// The given member was added; see the transaction for who. @@ -221,15 +221,15 @@ mod tests { use super::*; use std::cell::RefCell; - use support::{assert_ok, assert_noop, impl_outer_origin, parameter_types, weights::Weight}; - use primitives::H256; + use frame_support::{assert_ok, assert_noop, impl_outer_origin, parameter_types, weights::Weight}; + use sp_core::H256; // The testing primitives are very useful for avoiding having to work with signatures // or public keys. `u64` is used as the `AccountId` and no `Signature`s are requried. use sp_runtime::{Perbill, traits::{BlakeTwo256, IdentityLookup}, testing::Header}; - use system::EnsureSignedBy; + use frame_system::EnsureSignedBy; impl_outer_origin! { - pub enum Origin for Test {} + pub enum Origin for Test where system = frame_system {} } // For testing the module, we construct most of a mock runtime. This means @@ -243,7 +243,7 @@ mod tests { pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); } - impl system::Trait for Test { + impl frame_system::Trait for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; @@ -307,7 +307,7 @@ mod tests { // This function basically just builds a genesis storage key/value store according to // our desired mockup. fn new_test_ext() -> sp_io::TestExternalities { - let mut t = system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); // We use default for brevity, but you can configure as desired if needed. GenesisConfig::{ members: vec![10, 20, 30], diff --git a/frame/metadata/Cargo.toml b/frame/metadata/Cargo.toml index 0feeb14d59..b29193ec20 100644 --- a/frame/metadata/Cargo.toml +++ b/frame/metadata/Cargo.toml @@ -8,13 +8,13 @@ edition = "2018" 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 = "../../primitives/std", default-features = false } -primitives = { package = "sp-core", path = "../../primitives/core", default-features = false } +sp-core = { path = "../../primitives/core", default-features = false } [features] default = ["std"] std = [ "codec/std", "sp-std/std", - "primitives/std", + "sp-core/std", "serde", ] diff --git a/frame/metadata/src/lib.rs b/frame/metadata/src/lib.rs index e37733fc9d..d47e0c75cf 100644 --- a/frame/metadata/src/lib.rs +++ b/frame/metadata/src/lib.rs @@ -28,7 +28,7 @@ use serde::Serialize; use codec::{Decode, Input, Error}; use codec::{Encode, Output}; use sp_std::vec::Vec; -use primitives::RuntimeDebug; +use sp_core::RuntimeDebug; #[cfg(feature = "std")] type StringBuf = String; @@ -391,9 +391,9 @@ pub struct ModuleMetadata { type ODFnA = Option>; type DFnA = DecodeDifferent, Vec>; -impl Into for RuntimeMetadataPrefixed { - fn into(self) -> primitives::OpaqueMetadata { - primitives::OpaqueMetadata::new(self.encode()) +impl Into for RuntimeMetadataPrefixed { + fn into(self) -> sp_core::OpaqueMetadata { + sp_core::OpaqueMetadata::new(self.encode()) } } diff --git a/frame/nicks/Cargo.toml b/frame/nicks/Cargo.toml index 924d706d51..55c1afe1b9 100644 --- a/frame/nicks/Cargo.toml +++ b/frame/nicks/Cargo.toml @@ -10,12 +10,12 @@ codec = { package = "parity-scale-codec", version = "1.0.0", default-features = sp-std = { path = "../../primitives/std", 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 } +frame-support = { path = "../support", default-features = false } +frame-system = { path = "../system", default-features = false } [dev-dependencies] -primitives = { package = "sp-core", path = "../../primitives/core" } -balances = { package = "pallet-balances", path = "../balances" } +sp-core = { path = "../../primitives/core" } +pallet-balances = { path = "../balances" } [features] default = ["std"] @@ -25,6 +25,6 @@ std = [ "sp-std/std", "sp-io/std", "sp-runtime/std", - "support/std", - "system/std", + "frame-support/std", + "frame-system/std", ] diff --git a/frame/nicks/src/lib.rs b/frame/nicks/src/lib.rs index 95fd6f5b82..1c28146edb 100644 --- a/frame/nicks/src/lib.rs +++ b/frame/nicks/src/lib.rs @@ -42,19 +42,19 @@ use sp_std::prelude::*; use sp_runtime::{ traits::{StaticLookup, EnsureOrigin, Zero} }; -use support::{ +use frame_support::{ decl_module, decl_event, decl_storage, ensure, traits::{Currency, ReservableCurrency, OnUnbalanced, Get}, weights::SimpleDispatchInfo, }; -use system::{ensure_signed, ensure_root}; +use frame_system::{self as system, ensure_signed, ensure_root}; -type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; -type NegativeImbalanceOf = <::Currency as Currency<::AccountId>>::NegativeImbalance; +type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; +type NegativeImbalanceOf = <::Currency as Currency<::AccountId>>::NegativeImbalance; -pub trait Trait: system::Trait { +pub trait Trait: frame_system::Trait { /// The overarching event type. - type Event: From> + Into<::Event>; + type Event: From> + Into<::Event>; /// The currency trait. type Currency: ReservableCurrency; @@ -83,7 +83,7 @@ decl_storage! { } decl_event!( - pub enum Event where AccountId = ::AccountId, Balance = BalanceOf { + pub enum Event where AccountId = ::AccountId, Balance = BalanceOf { /// A name was set. NameSet(AccountId), /// A name was forcibly set. @@ -229,9 +229,9 @@ decl_module! { mod tests { use super::*; - use support::{assert_ok, assert_noop, impl_outer_origin, parameter_types, weights::Weight}; - use primitives::H256; - use system::EnsureSignedBy; + use frame_support::{assert_ok, assert_noop, impl_outer_origin, parameter_types, weights::Weight}; + use sp_core::H256; + use frame_system::EnsureSignedBy; // The testing primitives are very useful for avoiding having to work with signatures // or public keys. `u64` is used as the `AccountId` and no `Signature`s are required. use sp_runtime::{ @@ -239,7 +239,7 @@ mod tests { }; impl_outer_origin! { - pub enum Origin for Test {} + pub enum Origin for Test where system = frame_system {} } // For testing the module, we construct most of a mock runtime. This means @@ -253,7 +253,7 @@ mod tests { pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); } - impl system::Trait for Test { + impl frame_system::Trait for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; @@ -275,7 +275,7 @@ mod tests { pub const TransferFee: u64 = 0; pub const CreationFee: u64 = 0; } - impl balances::Trait for Test { + impl pallet_balances::Trait for Test { type Balance = u64; type OnFreeBalanceZero = (); type OnNewAccount = (); @@ -301,15 +301,15 @@ mod tests { type MinLength = MinLength; type MaxLength = MaxLength; } - type Balances = balances::Module; + type Balances = pallet_balances::Module; type Nicks = Module; // This function basically just builds a genesis storage key/value store according to // our desired mockup. fn new_test_ext() -> sp_io::TestExternalities { - let mut t = system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); // We use default for brevity, but you can configure as desired if needed. - balances::GenesisConfig:: { + pallet_balances::GenesisConfig:: { balances: vec![ (1, 10), (2, 10), diff --git a/frame/offences/Cargo.toml b/frame/offences/Cargo.toml index db60c463a0..72e1f15c56 100644 --- a/frame/offences/Cargo.toml +++ b/frame/offences/Cargo.toml @@ -5,14 +5,14 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -balances = { package = "pallet-balances", path = "../balances", default-features = false } +pallet-balances = { path = "../balances", 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 } serde = { version = "1.0.101", optional = true } sp-runtime = { path = "../../primitives/runtime", default-features = false } sp-staking = { path = "../../primitives/staking", default-features = false } -support = { package = "frame-support", path = "../support", default-features = false } -system = { package = "frame-system", path = "../system", default-features = false } +frame-support = { path = "../support", default-features = false } +frame-system = { path = "../system", default-features = false } [dev-dependencies] sp-io = { path = "../../primitives/io" } @@ -21,12 +21,12 @@ sp-core = { path = "../../primitives/core" } [features] default = ["std"] std = [ - "balances/std", + "pallet-balances/std", "codec/std", "sp-std/std", "serde", "sp-runtime/std", "sp-staking/std", - "support/std", - "system/std", + "frame-support/std", + "frame-system/std", ] diff --git a/frame/offences/src/lib.rs b/frame/offences/src/lib.rs index 6d83de3652..0dc66c72d4 100644 --- a/frame/offences/src/lib.rs +++ b/frame/offences/src/lib.rs @@ -25,7 +25,7 @@ mod mock; mod tests; use sp_std::vec::Vec; -use support::{ +use frame_support::{ decl_module, decl_event, decl_storage, Parameter, }; use sp_runtime::traits::Hash; @@ -33,17 +33,18 @@ use sp_staking::{ offence::{Offence, ReportOffence, Kind, OnOffenceHandler, OffenceDetails}, }; use codec::{Encode, Decode}; +use frame_system as system; /// A binary blob which represents a SCALE codec-encoded `O::TimeSlot`. type OpaqueTimeSlot = Vec; /// A type alias for a report identifier. -type ReportIdOf = ::Hash; +type ReportIdOf = ::Hash; /// Offences trait -pub trait Trait: system::Trait { +pub trait Trait: frame_system::Trait { /// The overarching event type. - type Event: From + Into<::Event>; + type Event: From + Into<::Event>; /// Full identification of the validator. type IdentificationTuple: Parameter + Ord; /// A handler called for every offence report. diff --git a/frame/offences/src/mock.rs b/frame/offences/src/mock.rs index abe84fe5f5..1175ebaeee 100644 --- a/frame/offences/src/mock.rs +++ b/frame/offences/src/mock.rs @@ -29,11 +29,11 @@ use sp_staking::{ use sp_runtime::testing::Header; use sp_runtime::traits::{IdentityLookup, BlakeTwo256}; use sp_core::H256; -use support::{ +use frame_support::{ impl_outer_origin, impl_outer_event, parameter_types, StorageMap, StorageDoubleMap, weights::Weight, }; -use {sp_io, system}; +use frame_system as system; impl_outer_origin!{ pub enum Origin for Runtime {} @@ -72,7 +72,7 @@ parameter_types! { pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); } -impl system::Trait for Runtime { +impl frame_system::Trait for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = u64; @@ -107,13 +107,13 @@ impl_outer_event! { } pub fn new_test_ext() -> sp_io::TestExternalities { - let t = system::GenesisConfig::default().build_storage::().unwrap(); + let t = frame_system::GenesisConfig::default().build_storage::().unwrap(); t.into() } /// Offences module. pub type Offences = Module; -pub type System = system::Module; +pub type System = frame_system::Module; pub const KIND: [u8; 16] = *b"test_report_1234"; diff --git a/frame/offences/src/tests.rs b/frame/offences/src/tests.rs index 134c7a3cb0..2cbadf96b5 100644 --- a/frame/offences/src/tests.rs +++ b/frame/offences/src/tests.rs @@ -24,7 +24,7 @@ use crate::mock::{ offence_reports, }; use sp_runtime::Perbill; -use system::{EventRecord, Phase}; +use frame_system::{EventRecord, Phase}; #[test] fn should_report_an_authority_and_trigger_on_offence() { diff --git a/frame/randomness-collective-flip/Cargo.toml b/frame/randomness-collective-flip/Cargo.toml index 1840e795f5..131b20c28b 100644 --- a/frame/randomness-collective-flip/Cargo.toml +++ b/frame/randomness-collective-flip/Cargo.toml @@ -8,21 +8,21 @@ edition = "2018" safe-mix = { version = "1.0", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } 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 } +frame-support = { path = "../support", default-features = false } +frame-system = { path = "../system", default-features = false } sp-std = { path = "../../primitives/std", default-features = false } [dev-dependencies] -primitives = { package = "sp-core", path = "../../primitives/core" } +sp-core = { path = "../../primitives/core" } sp-io = { path = "../../primitives/io" } [features] default = ["std"] std = [ "safe-mix/std", - "system/std", + "frame-system/std", "codec/std", - "support/std", + "frame-support/std", "sp-runtime/std", "sp-std/std", ] diff --git a/frame/randomness-collective-flip/src/lib.rs b/frame/randomness-collective-flip/src/lib.rs index 17b681d2e0..ff75d6b9b8 100644 --- a/frame/randomness-collective-flip/src/lib.rs +++ b/frame/randomness-collective-flip/src/lib.rs @@ -35,9 +35,9 @@ //! ### Example - Get random seed for the current block //! //! ``` -//! use support::{decl_module, dispatch, traits::Randomness}; +//! use frame_support::{decl_module, dispatch, traits::Randomness}; //! -//! pub trait Trait: system::Trait {} +//! pub trait Trait: frame_system::Trait {} //! //! decl_module! { //! pub struct Module for enum Call where origin: T::Origin { @@ -54,10 +54,10 @@ use sp_std::{prelude::*, convert::TryInto}; use sp_runtime::traits::Hash; -use support::{decl_module, decl_storage, traits::Randomness}; +use frame_support::{decl_module, decl_storage, traits::Randomness}; use safe_mix::TripletMix; use codec::Encode; -use system::Trait; +use frame_system::Trait; const RANDOM_MATERIAL_LEN: u32 = 81; @@ -70,7 +70,7 @@ fn block_number_to_index(block_number: T::BlockNumber) -> usize { decl_module! { pub struct Module for enum Call where origin: T::Origin { fn on_initialize(block_number: T::BlockNumber) { - let parent_hash = >::parent_hash(); + let parent_hash = >::parent_hash(); >::mutate(|ref mut values| if values.len() < RANDOM_MATERIAL_LEN as usize { values.push(parent_hash) @@ -130,7 +130,7 @@ impl Randomness for Module { /// and mean that all bits of the resulting value are entirely manipulatable by the author of /// the parent block, who can determine the value of `parent_hash`. fn random(subject: &[u8]) -> T::Hash { - let block_number = >::block_number(); + let block_number = >::block_number(); let index = block_number_to_index::(block_number); let hash_series = >::get(); @@ -152,17 +152,17 @@ impl Randomness for Module { #[cfg(test)] mod tests { use super::*; - use primitives::H256; + use sp_core::H256; use sp_runtime::{ Perbill, traits::{BlakeTwo256, OnInitialize, Header as _, IdentityLookup}, testing::Header, }; - use support::{impl_outer_origin, parameter_types, weights::Weight, traits::Randomness}; + use frame_support::{impl_outer_origin, parameter_types, weights::Weight, traits::Randomness}; #[derive(Clone, PartialEq, Eq)] pub struct Test; impl_outer_origin! { - pub enum Origin for Test {} + pub enum Origin for Test where system = frame_system {} } parameter_types! { @@ -172,7 +172,7 @@ mod tests { pub const AvailableBlockRatio: Perbill = Perbill::one(); } - impl system::Trait for Test { + impl frame_system::Trait for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; @@ -190,11 +190,11 @@ mod tests { type Version = (); } - type System = system::Module; + type System = frame_system::Module; type CollectiveFlip = Module; fn new_test_ext() -> sp_io::TestExternalities { - let t = system::GenesisConfig::default().build_storage::().unwrap(); + let t = frame_system::GenesisConfig::default().build_storage::().unwrap(); t.into() } diff --git a/frame/scored-pool/Cargo.toml b/frame/scored-pool/Cargo.toml index 5ac049d1e2..ebc5417659 100644 --- a/frame/scored-pool/Cargo.toml +++ b/frame/scored-pool/Cargo.toml @@ -10,12 +10,12 @@ serde = { version = "1.0.101", optional = true } 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 } -system = { package = "frame-system", path = "../system", default-features = false } +frame-support = { path = "../support", default-features = false } +frame-system = { path = "../system", default-features = false } [dev-dependencies] -balances = { package = "pallet-balances", path = "../balances" } -primitives = { package = "sp-core", path = "../../primitives/core" } +pallet-balances = { path = "../balances" } +sp-core = { path = "../../primitives/core" } [features] default = ["std"] @@ -25,6 +25,6 @@ std = [ "sp-io/std", "sp-runtime/std", "sp-std/std", - "support/std", - "system/std", + "frame-support/std", + "frame-system/std", ] diff --git a/frame/scored-pool/src/lib.rs b/frame/scored-pool/src/lib.rs index 30dfbbbccf..9703d041d7 100644 --- a/frame/scored-pool/src/lib.rs +++ b/frame/scored-pool/src/lib.rs @@ -53,8 +53,8 @@ //! ## Usage //! //! ``` -//! use support::{decl_module, dispatch}; -//! use system::ensure_signed; +//! use frame_support::{decl_module, dispatch}; +//! use frame_system::{self as system, ensure_signed}; //! use pallet_scored_pool::{self as scored_pool}; //! //! pub trait Trait: scored_pool::Trait {} @@ -93,17 +93,17 @@ use sp_std::{ fmt::Debug, prelude::*, }; -use support::{ +use frame_support::{ decl_module, decl_storage, decl_event, ensure, traits::{ChangeMembers, InitializeMembers, Currency, Get, ReservableCurrency}, }; -use system::{self, ensure_root, ensure_signed}; +use frame_system::{self as system, ensure_root, ensure_signed}; use sp_runtime::{ traits::{EnsureOrigin, SimpleArithmetic, MaybeSerializeDeserialize, Zero, StaticLookup}, }; -type BalanceOf = <>::Currency as Currency<::AccountId>>::Balance; -type PoolT = Vec<(::AccountId, Option<>::Score>)>; +type BalanceOf = <>::Currency as Currency<::AccountId>>::Balance; +type PoolT = Vec<(::AccountId, Option<>::Score>)>; /// The enum is supplied when refreshing the members set. /// Depending on the enum variant the corresponding associated @@ -115,7 +115,7 @@ enum ChangeReceiver { MembershipChanged, } -pub trait Trait: system::Trait { +pub trait Trait: frame_system::Trait { /// The currency used for deposits. type Currency: Currency + ReservableCurrency; @@ -124,7 +124,7 @@ pub trait Trait: system::Trait { SimpleArithmetic + Clone + Copy + Default + FullCodec + MaybeSerializeDeserialize + Debug; /// The overarching event type. - type Event: From> + Into<::Event>; + type Event: From> + Into<::Event>; // The deposit which is reserved from candidates if they want to // start a candidacy. The deposit gets returned when the candidacy is @@ -203,7 +203,7 @@ decl_storage! { decl_event!( pub enum Event where - ::AccountId, + ::AccountId, { /// The given member was removed. See the transaction for who. MemberRemoved, diff --git a/frame/scored-pool/src/mock.rs b/frame/scored-pool/src/mock.rs index 06e11e62eb..097d7bc33f 100644 --- a/frame/scored-pool/src/mock.rs +++ b/frame/scored-pool/src/mock.rs @@ -19,17 +19,17 @@ use super::*; use std::cell::RefCell; -use support::{impl_outer_origin, parameter_types, weights::Weight}; -use primitives::H256; +use frame_support::{impl_outer_origin, parameter_types, weights::Weight}; +use sp_core::H256; // The testing primitives are very useful for avoiding having to work with signatures // or public keys. `u64` is used as the `AccountId` and no `Signature`s are requried. use sp_runtime::{ Perbill, traits::{BlakeTwo256, IdentityLookup}, testing::Header, }; -use system::EnsureSignedBy; +use frame_system::EnsureSignedBy; impl_outer_origin! { - pub enum Origin for Test {} + pub enum Origin for Test where system = frame_system {} } // For testing the module, we construct most of a mock runtime. This means @@ -54,7 +54,7 @@ parameter_types! { pub const CreationFee: u64 = 0; } -impl system::Trait for Test { +impl frame_system::Trait for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; @@ -72,7 +72,7 @@ impl system::Trait for Test { type Version = (); } -impl balances::Trait for Test { +impl pallet_balances::Trait for Test { type Balance = u64; type OnFreeBalanceZero = (); type OnNewAccount = (); @@ -116,7 +116,7 @@ impl Trait for Test { type KickOrigin = EnsureSignedBy; type MembershipInitialized = TestChangeMembers; type MembershipChanged = TestChangeMembers; - type Currency = balances::Module; + type Currency = pallet_balances::Module; type CandidateDeposit = CandidateDeposit; type Period = Period; type Score = u64; @@ -126,9 +126,9 @@ 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() -> sp_io::TestExternalities { - let mut t = system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); // We use default for brevity, but you can configure as desired if needed. - balances::GenesisConfig:: { + pallet_balances::GenesisConfig:: { balances: vec![ (5, 500_000), (10, 500_000), diff --git a/frame/scored-pool/src/tests.rs b/frame/scored-pool/src/tests.rs index 20aff6618a..0b3ede9ee0 100644 --- a/frame/scored-pool/src/tests.rs +++ b/frame/scored-pool/src/tests.rs @@ -19,12 +19,12 @@ use super::*; use mock::*; -use support::{assert_ok, assert_noop}; +use frame_support::{assert_ok, assert_noop}; use sp_runtime::traits::OnInitialize; type ScoredPool = Module; -type System = system::Module; -type Balances = balances::Module; +type System = frame_system::Module; +type Balances = pallet_balances::Module; const OOB_ERR: &str = "index out of bounds"; const INDEX_ERR: &str = "index does not match requested account"; diff --git a/frame/session/Cargo.toml b/frame/session/Cargo.toml index 98f5221cf1..d82b8ef144 100644 --- a/frame/session/Cargo.toml +++ b/frame/session/Cargo.toml @@ -11,16 +11,16 @@ codec = { package = "parity-scale-codec", version = "1.0.0", default-features = sp-std = { path = "../../primitives/std", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } sp-staking = { path = "../../primitives/staking", default-features = false } -support = { package = "frame-support", path = "../support", default-features = false } -system = { package = "frame-system", path = "../system", default-features = false } -timestamp = { package = "pallet-timestamp", path = "../timestamp", default-features = false } +frame-support = { path = "../support", default-features = false } +frame-system = { path = "../system", default-features = false } +pallet-timestamp = { path = "../timestamp", default-features = false } sp-trie = { path = "../../primitives/trie", default-features = false, optional = true } sp-io ={ path = "../../primitives/io", default-features = false } impl-trait-for-tuples = "0.1.3" [dev-dependencies] -primitives = { package = "sp-core", path = "../../primitives/core" } -app-crypto = { package = "sp-application-crypto", path = "../../primitives/application-crypto" } +sp-core = { path = "../../primitives/core" } +sp-application-crypto = { path = "../../primitives/application-crypto" } lazy_static = "1.4.0" [features] @@ -31,10 +31,10 @@ std = [ "safe-mix/std", "codec/std", "sp-std/std", - "support/std", + "frame-support/std", "sp-runtime/std", "sp-staking/std", - "timestamp/std", + "pallet-timestamp/std", "sp-trie/std", "sp-io/std", ] diff --git a/frame/session/src/historical.rs b/frame/session/src/historical.rs index e116e6ac34..1298111e93 100644 --- a/frame/session/src/historical.rs +++ b/frame/session/src/historical.rs @@ -29,8 +29,8 @@ use sp_std::prelude::*; use codec::{Encode, Decode}; use sp_runtime::KeyTypeId; use sp_runtime::traits::{Convert, OpaqueKeys, Hash as HashT}; -use support::{decl_module, decl_storage}; -use support::{Parameter, print}; +use frame_support::{decl_module, decl_storage}; +use frame_support::{Parameter, print}; use sp_trie::{MemoryDB, Trie, TrieMut, Recorder, EMPTY_PREFIX}; use sp_trie::trie_types::{TrieDBMut, TrieDB}; use super::{SessionIndex, Module as SessionModule}; @@ -146,7 +146,7 @@ impl crate::OnSessionEnding for NoteHistoricalRoot< } } -type HasherOf = <::Hashing as HashT>::Hasher; +type HasherOf = <::Hashing as HashT>::Hasher; /// A tuple of the validator's ID and their full identification. pub type IdentificationTuple = (::ValidatorId, ::FullIdentification); @@ -273,7 +273,7 @@ pub struct Proof { trie_nodes: Vec>, } -impl> support::traits::KeyOwnerProofSystem<(KeyTypeId, D)> +impl> frame_support::traits::KeyOwnerProofSystem<(KeyTypeId, D)> for Module { type Proof = Proof; @@ -310,18 +310,18 @@ impl> support::traits::KeyOwnerProofSystem<(KeyTypeId, #[cfg(test)] mod tests { use super::*; - use primitives::crypto::key_types::DUMMY; + use sp_core::crypto::key_types::DUMMY; use sp_runtime::{traits::OnInitialize, testing::UintAuthorityId}; use crate::mock::{ NEXT_VALIDATORS, force_new_session, set_next_validators, Test, System, Session, }; - use support::traits::KeyOwnerProofSystem; + use frame_support::traits::KeyOwnerProofSystem; type Historical = Module; fn new_test_ext() -> sp_io::TestExternalities { - let mut t = system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); crate::GenesisConfig:: { keys: NEXT_VALIDATORS.with(|l| l.borrow().iter().cloned().map(|i| (i, UintAuthorityId(i).into())).collect() diff --git a/frame/session/src/lib.rs b/frame/session/src/lib.rs index 2fb08540c0..aee01dc37f 100644 --- a/frame/session/src/lib.rs +++ b/frame/session/src/lib.rs @@ -122,12 +122,12 @@ use sp_std::{prelude::*, marker::PhantomData, ops::{Sub, Rem}}; use codec::Decode; use sp_runtime::{KeyTypeId, Perbill, RuntimeAppPublic, BoundToRuntimeAppPublic}; -use support::weights::SimpleDispatchInfo; +use frame_support::weights::SimpleDispatchInfo; use sp_runtime::traits::{Convert, Zero, Member, OpaqueKeys}; use sp_staking::SessionIndex; -use support::{dispatch, ConsensusEngineId, decl_module, decl_event, decl_storage}; -use support::{ensure, traits::{OnFreeBalanceZero, Get, FindAuthor, ValidatorRegistration}, Parameter}; -use system::{self, ensure_signed}; +use frame_support::{dispatch, ConsensusEngineId, decl_module, decl_event, decl_storage}; +use frame_support::{ensure, traits::{OnFreeBalanceZero, Get, FindAuthor, ValidatorRegistration}, Parameter}; +use frame_system::{self as system, ensure_signed}; #[cfg(test)] mod mock; @@ -339,9 +339,9 @@ impl ValidatorRegistration for Module { } } -pub trait Trait: system::Trait { +pub trait Trait: frame_system::Trait { /// The overarching event type. - type Event: From + Into<::Event>; + type Event: From + Into<::Event>; /// A stable ID for a validator. type ValidatorId: Member + Parameter; @@ -720,8 +720,8 @@ impl> FindAuthor #[cfg(test)] mod tests { use super::*; - use support::assert_ok; - use primitives::crypto::key_types::DUMMY; + use frame_support::assert_ok; + use sp_core::crypto::key_types::DUMMY; use sp_runtime::{traits::OnInitialize, testing::UintAuthorityId}; use mock::{ NEXT_VALIDATORS, SESSION_CHANGED, TEST_SESSION_CHANGED, authorities, force_new_session, @@ -730,7 +730,7 @@ mod tests { }; fn new_test_ext() -> sp_io::TestExternalities { - let mut t = system::GenesisConfig::default().build_storage::().unwrap(); + let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); GenesisConfig:: { keys: NEXT_VALIDATORS.with(|l| l.borrow().iter().cloned().map(|i| (i, UintAuthorityId(i).into())).collect() diff --git a/frame/session/src/mock.rs b/frame/session/src/mock.rs index 9ee95d208b..14fbc46c82 100644 --- a/frame/session/src/mock.rs +++ b/frame/session/src/mock.rs @@ -18,8 +18,8 @@ use super::*; use std::cell::RefCell; -use support::{impl_outer_origin, parameter_types, weights::Weight}; -use primitives::{crypto::key_types::DUMMY, H256}; +use frame_support::{impl_outer_origin, parameter_types, weights::Weight}; +use sp_core::{crypto::key_types::DUMMY, H256}; use sp_runtime::{ Perbill, impl_opaque_keys, traits::{BlakeTwo256, IdentityLookup, ConvertInto}, testing::{Header, UintAuthorityId} @@ -39,7 +39,7 @@ impl From for MockSessionKeys { } impl_outer_origin! { - pub enum Origin for Test {} + pub enum Origin for Test where system = frame_system {} } thread_local! { @@ -158,7 +158,7 @@ parameter_types! { pub const AvailableBlockRatio: Perbill = Perbill::one(); } -impl system::Trait for Test { +impl frame_system::Trait for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; @@ -176,7 +176,7 @@ impl system::Trait for Test { type Version = (); } -impl timestamp::Trait for Test { +impl pallet_timestamp::Trait for Test { type Moment = u64; type OnTimestampSet = (); type MinimumPeriod = MinimumPeriod; @@ -207,5 +207,5 @@ impl crate::historical::Trait for Test { type FullIdentificationOf = sp_runtime::traits::ConvertInto; } -pub type System = system::Module; +pub type System = frame_system::Module; pub type Session = Module; diff --git a/frame/staking/Cargo.toml b/frame/staking/Cargo.toml index c82a0c13e2..878acdbce6 100644 --- a/frame/staking/Cargo.toml +++ b/frame/staking/Cargo.toml @@ -10,19 +10,19 @@ 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 } -phragmen = { package = "sp-phragmen", path = "../../primitives/phragmen", default-features = false } +sp-phragmen = { path = "../../primitives/phragmen", default-features = false } sp-io ={ path = "../../primitives/io", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } sp-staking = { path = "../../primitives/staking", default-features = false } -support = { package = "frame-support", path = "../support", default-features = false } -system = { package = "frame-system", path = "../system", default-features = false } -session = { package = "pallet-session", path = "../session", default-features = false, features = ["historical"] } -authorship = { package = "pallet-authorship", path = "../authorship", default-features = false } +frame-support = { path = "../support", default-features = false } +frame-system = { path = "../system", default-features = false } +pallet-session = { path = "../session", default-features = false, features = ["historical"] } +pallet-authorship = { path = "../authorship", default-features = false } [dev-dependencies] -primitives = { package = "sp-core", path = "../../primitives/core" } -balances = { package = "pallet-balances", path = "../balances" } -timestamp = { package = "pallet-timestamp", path = "../timestamp" } +sp-core = { path = "../../primitives/core" } +pallet-balances = { path = "../balances" } +pallet-timestamp = { path = "../timestamp" } pallet-staking-reward-curve = { path = "../staking/reward-curve"} substrate-test-utils = { path = "../../test-utils" } @@ -36,12 +36,12 @@ std = [ "sp-keyring", "codec/std", "sp-std/std", - "phragmen/std", + "sp-phragmen/std", "sp-io/std", - "support/std", + "frame-support/std", "sp-runtime/std", "sp-staking/std", - "session/std", - "system/std", - "authorship/std", + "pallet-session/std", + "frame-system/std", + "pallet-authorship/std", ] diff --git a/frame/staking/src/lib.rs b/frame/staking/src/lib.rs index d2a6ec7c13..3d641e24a5 100644 --- a/frame/staking/src/lib.rs +++ b/frame/staking/src/lib.rs @@ -138,8 +138,8 @@ //! ### Example: Rewarding a validator by id. //! //! ``` -//! use support::{decl_module, dispatch}; -//! use system::ensure_signed; +//! use frame_support::{decl_module, dispatch}; +//! use frame_system::{self as system, ensure_signed}; //! use pallet_staking::{self as staking}; //! //! pub trait Trait: staking::Trait {} @@ -181,7 +181,7 @@ //! [`reward_by_indices`](./enum.Call.html#variant.reward_by_indices). //! //! [`Module`](./struct.Module.html) implements -//! [`authorship::EventHandler`](../pallet_authorship/trait.EventHandler.html) to add reward points +//! [`pallet_authorship::EventHandler`](../pallet_authorship/trait.EventHandler.html) to add reward points //! to block producer and block producer of referenced uncles. //! //! The validator and its nominator split their reward as following: @@ -257,7 +257,7 @@ pub mod inflation; use sp_std::{prelude::*, result}; use codec::{HasCompact, Encode, Decode}; -use support::{ +use frame_support::{ decl_module, decl_event, decl_storage, ensure, weights::SimpleDispatchInfo, traits::{ @@ -265,7 +265,7 @@ use support::{ WithdrawReasons, OnUnbalanced, Imbalance, Get, Time } }; -use session::{historical::OnSessionEnding, SelectInitialValidators}; +use pallet_session::{historical::OnSessionEnding, SelectInitialValidators}; use sp_runtime::{ Perbill, RuntimeDebug, @@ -281,9 +281,9 @@ use sp_staking::{ }; #[cfg(feature = "std")] use sp_runtime::{Serialize, Deserialize}; -use system::{ensure_signed, ensure_root}; +use frame_system::{self as system, ensure_signed, ensure_root}; -use phragmen::{ExtendedBalance, PhragmenStakedAssignment}; +use sp_phragmen::{ExtendedBalance, PhragmenStakedAssignment}; const DEFAULT_MINIMUM_VALIDATOR_COUNT: u32 = 4; const MAX_NOMINATIONS: usize = 16; @@ -521,17 +521,17 @@ pub struct UnappliedSlash { } pub type BalanceOf = - <::Currency as Currency<::AccountId>>::Balance; + <::Currency as Currency<::AccountId>>::Balance; type PositiveImbalanceOf = - <::Currency as Currency<::AccountId>>::PositiveImbalance; + <::Currency as Currency<::AccountId>>::PositiveImbalance; type NegativeImbalanceOf = - <::Currency as Currency<::AccountId>>::NegativeImbalance; + <::Currency as Currency<::AccountId>>::NegativeImbalance; type MomentOf = <::Time as Time>::Moment; /// Means for interacting with a specialized version of the `session` trait. /// -/// This is needed because `Staking` sets the `ValidatorIdOf` of the `session::Trait` -pub trait SessionInterface: system::Trait { +/// This is needed because `Staking` sets the `ValidatorIdOf` of the `pallet_session::Trait` +pub trait SessionInterface: frame_system::Trait { /// Disable a given validator by stash ID. /// /// Returns `true` if new era should be forced at the end of this session. @@ -544,31 +544,31 @@ pub trait SessionInterface: system::Trait { fn prune_historical_up_to(up_to: SessionIndex); } -impl SessionInterface<::AccountId> for T where - T: session::Trait::AccountId>, - T: session::historical::Trait< - FullIdentification = Exposure<::AccountId, BalanceOf>, +impl SessionInterface<::AccountId> for T where + T: pallet_session::Trait::AccountId>, + T: pallet_session::historical::Trait< + FullIdentification = Exposure<::AccountId, BalanceOf>, FullIdentificationOf = ExposureOf, >, - T::SessionHandler: session::SessionHandler<::AccountId>, - T::OnSessionEnding: session::OnSessionEnding<::AccountId>, - T::SelectInitialValidators: session::SelectInitialValidators<::AccountId>, - T::ValidatorIdOf: Convert<::AccountId, Option<::AccountId>> + T::SessionHandler: pallet_session::SessionHandler<::AccountId>, + T::OnSessionEnding: pallet_session::OnSessionEnding<::AccountId>, + T::SelectInitialValidators: pallet_session::SelectInitialValidators<::AccountId>, + T::ValidatorIdOf: Convert<::AccountId, Option<::AccountId>> { - fn disable_validator(validator: &::AccountId) -> Result { - >::disable(validator) + fn disable_validator(validator: &::AccountId) -> Result { + >::disable(validator) } - fn validators() -> Vec<::AccountId> { - >::validators() + fn validators() -> Vec<::AccountId> { + >::validators() } fn prune_historical_up_to(up_to: SessionIndex) { - >::prune_up_to(up_to); + >::prune_up_to(up_to); } } -pub trait Trait: system::Trait { +pub trait Trait: frame_system::Trait { /// The staking balance. type Currency: LockableCurrency; @@ -586,7 +586,7 @@ pub trait Trait: system::Trait { type RewardRemainder: OnUnbalanced>; /// The overarching event type. - type Event: From> + Into<::Event>; + type Event: From> + Into<::Event>; /// Handler for the unbalanced reduction when slashing a staker. type Slash: OnUnbalanced>; @@ -771,7 +771,7 @@ decl_storage! { } decl_event!( - pub enum Event where Balance = BalanceOf, ::AccountId { + pub enum Event where Balance = BalanceOf, ::AccountId { /// All validators have been rewarded by the first balance; the second is the remainder /// from the maximum amount of reward. Reward(Balance, Balance), @@ -1423,7 +1423,7 @@ impl Module { }); all_nominators.extend(nominator_votes); - let maybe_phragmen_result = phragmen::elect::<_, _, _, T::CurrencyToVote>( + let maybe_phragmen_result = sp_phragmen::elect::<_, _, _, T::CurrencyToVote>( Self::validator_count() as usize, Self::minimum_validator_count().max(1) as usize, all_validators, @@ -1442,7 +1442,7 @@ impl Module { let to_balance = |e: ExtendedBalance| >>::convert(e); - let mut supports = phragmen::build_support_map::<_, _, _, T::CurrencyToVote>( + let mut supports = sp_phragmen::build_support_map::<_, _, _, T::CurrencyToVote>( &elected_stashes, &assignments, Self::slashable_balance_of, @@ -1473,7 +1473,7 @@ impl Module { let tolerance = 0_u128; let iterations = 2_usize; - phragmen::equalize::<_, _, T::CurrencyToVote, _>( + sp_phragmen::equalize::<_, _, T::CurrencyToVote, _>( staked_assignments, &mut supports, tolerance, @@ -1600,7 +1600,7 @@ impl Module { } } -impl session::OnSessionEnding for Module { +impl pallet_session::OnSessionEnding for Module { fn on_session_ending(_ending: SessionIndex, start_session: SessionIndex) -> Option> { Self::ensure_storage_upgraded(); Self::new_session(start_session - 1).map(|(new, _old)| new) @@ -1627,13 +1627,13 @@ impl OnFreeBalanceZero for Module { /// * 20 points to the block producer for producing a (non-uncle) block in the relay chain, /// * 2 points to the block producer for each reference to a previously unreferenced uncle, and /// * 1 point to the producer of each referenced uncle block. -impl authorship::EventHandler for Module { +impl pallet_authorship::EventHandler for Module { fn note_author(author: T::AccountId) { Self::reward_by_ids(vec![(author, 20)]); } fn note_uncle(author: T::AccountId, _age: T::BlockNumber) { Self::reward_by_ids(vec![ - (>::author(), 2), + (>::author(), 2), (author, 1) ]) } @@ -1668,19 +1668,19 @@ impl SelectInitialValidators for Module { } /// This is intended to be used with `FilterHistoricalOffences`. -impl OnOffenceHandler> for Module where - T: session::Trait::AccountId>, - T: session::historical::Trait< - FullIdentification = Exposure<::AccountId, BalanceOf>, +impl OnOffenceHandler> for Module where + T: pallet_session::Trait::AccountId>, + T: pallet_session::historical::Trait< + FullIdentification = Exposure<::AccountId, BalanceOf>, FullIdentificationOf = ExposureOf, >, - T::SessionHandler: session::SessionHandler<::AccountId>, - T::OnSessionEnding: session::OnSessionEnding<::AccountId>, - T::SelectInitialValidators: session::SelectInitialValidators<::AccountId>, - T::ValidatorIdOf: Convert<::AccountId, Option<::AccountId>> + T::SessionHandler: pallet_session::SessionHandler<::AccountId>, + T::OnSessionEnding: pallet_session::OnSessionEnding<::AccountId>, + T::SelectInitialValidators: pallet_session::SelectInitialValidators<::AccountId>, + T::ValidatorIdOf: Convert<::AccountId, Option<::AccountId>> { fn on_offence( - offenders: &[OffenceDetails>], + offenders: &[OffenceDetails>], slash_fraction: &[Perbill], slash_session: SessionIndex, ) { diff --git a/frame/staking/src/migration.rs b/frame/staking/src/migration.rs index 4c4306253e..0ee52dc337 100644 --- a/frame/staking/src/migration.rs +++ b/frame/staking/src/migration.rs @@ -25,7 +25,7 @@ pub const CURRENT_VERSION: VersionNumber = 1; #[cfg(any(test, feature = "migrate"))] mod inner { use crate::{Store, Module, Trait}; - use support::{StorageLinkedMap, StorageValue}; + use frame_support::{StorageLinkedMap, StorageValue}; use sp_std::vec::Vec; use super::{CURRENT_VERSION, VersionNumber}; @@ -51,21 +51,21 @@ mod inner { ); if let Err(e) = res { - support::print("Encountered error in migration of Staking::Nominators map."); + frame_support::print("Encountered error in migration of Staking::Nominators map."); if e.is_none() { - support::print("Staking::Nominators map reinitialized"); + frame_support::print("Staking::Nominators map reinitialized"); } } - support::print("Finished migrating Staking storage to v1."); + frame_support::print("Finished migrating Staking storage to v1."); } pub(super) fn perform_migrations() { as Store>::StorageVersion::mutate(|version| { if *version < MIN_SUPPORTED_VERSION { - support::print("Cannot migrate staking storage because version is less than\ + frame_support::print("Cannot migrate staking storage because version is less than\ minimum."); - support::print(*version); + frame_support::print(*version); return } diff --git a/frame/staking/src/mock.rs b/frame/staking/src/mock.rs index 91c6b3c2a1..16c587f9be 100644 --- a/frame/staking/src/mock.rs +++ b/frame/staking/src/mock.rs @@ -22,9 +22,9 @@ use sp_runtime::curve::PiecewiseLinear; use sp_runtime::traits::{IdentityLookup, Convert, OpaqueKeys, OnInitialize, SaturatedConversion}; use sp_runtime::testing::{Header, UintAuthorityId}; use sp_staking::{SessionIndex, offence::{OffenceDetails, OnOffenceHandler}}; -use primitives::{H256, crypto::key_types}; +use sp_core::{H256, crypto::key_types}; use sp_io; -use support::{ +use frame_support::{ assert_ok, impl_outer_origin, parameter_types, StorageLinkedMap, StorageValue, traits::{Currency, Get, FindAuthor}, weights::Weight, @@ -55,7 +55,7 @@ thread_local! { } pub struct TestSessionHandler; -impl session::SessionHandler for TestSessionHandler { +impl pallet_session::SessionHandler for TestSessionHandler { const KEY_TYPE_IDS: &'static [KeyTypeId] = &[key_types::DUMMY]; fn on_genesis_session(_validators: &[(AccountId, Ks)]) {} @@ -99,14 +99,14 @@ impl Get for SlashDeferDuration { } impl_outer_origin!{ - pub enum Origin for Test {} + pub enum Origin for Test where system = frame_system {} } /// Author of block is always 11 pub struct Author11; impl FindAuthor for Author11 { fn find_author<'a, I>(_digests: I) -> Option - where I: 'a + IntoIterator + where I: 'a + IntoIterator { Some(11) } @@ -121,7 +121,7 @@ parameter_types! { pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); } -impl system::Trait for Test { +impl frame_system::Trait for Test { type Origin = Origin; type Index = u64; type BlockNumber = BlockNumber; @@ -142,7 +142,7 @@ parameter_types! { pub const TransferFee: Balance = 0; pub const CreationFee: Balance = 0; } -impl balances::Trait for Test { +impl pallet_balances::Trait for Test { type Balance = Balance; type OnFreeBalanceZero = Staking; type OnNewAccount = (); @@ -159,10 +159,10 @@ parameter_types! { pub const UncleGenerations: u64 = 0; pub const DisabledValidatorsThreshold: Perbill = Perbill::from_percent(25); } -impl session::Trait for Test { - type OnSessionEnding = session::historical::NoteHistoricalRoot; +impl pallet_session::Trait for Test { + type OnSessionEnding = pallet_session::historical::NoteHistoricalRoot; type Keys = UintAuthorityId; - type ShouldEndSession = session::PeriodicSessions; + type ShouldEndSession = pallet_session::PeriodicSessions; type SessionHandler = TestSessionHandler; type Event = (); type ValidatorId = AccountId; @@ -171,11 +171,11 @@ impl session::Trait for Test { type DisabledValidatorsThreshold = DisabledValidatorsThreshold; } -impl session::historical::Trait for Test { +impl pallet_session::historical::Trait for Test { type FullIdentification = crate::Exposure; type FullIdentificationOf = crate::ExposureOf; } -impl authorship::Trait for Test { +impl pallet_authorship::Trait for Test { type FindAuthor = Author11; type UncleGenerations = UncleGenerations; type FilterUncle = (); @@ -184,7 +184,7 @@ impl authorship::Trait for Test { parameter_types! { pub const MinimumPeriod: u64 = 5; } -impl timestamp::Trait for Test { +impl pallet_timestamp::Trait for Test { type Moment = u64; type OnTimestampSet = (); type MinimumPeriod = MinimumPeriod; @@ -205,8 +205,8 @@ parameter_types! { pub const RewardCurve: &'static PiecewiseLinear<'static> = &I_NPOS; } impl Trait for Test { - type Currency = balances::Module; - type Time = timestamp::Module; + type Currency = pallet_balances::Module; + type Time = pallet_timestamp::Module; type CurrencyToVote = CurrencyToVoteHandler; type RewardRemainder = (); type Event = (); @@ -214,7 +214,7 @@ impl Trait for Test { type Reward = (); type SessionsPerEra = SessionsPerEra; type SlashDeferDuration = SlashDeferDuration; - type SlashCancelOrigin = system::EnsureRoot; + type SlashCancelOrigin = frame_system::EnsureRoot; type BondingDuration = BondingDuration; type SessionInterface = Self; type RewardCurve = RewardCurve; @@ -291,7 +291,7 @@ impl ExtBuilder { } pub fn build(self) -> sp_io::TestExternalities { self.set_associated_consts(); - let mut storage = system::GenesisConfig::default().build_storage::().unwrap(); + let mut storage = frame_system::GenesisConfig::default().build_storage::().unwrap(); let balance_factor = if self.existential_deposit > 0 { 256 } else { @@ -303,7 +303,7 @@ impl ExtBuilder { .map(|x| ((x + 1) * 10 + 1) as u64) .collect::>(); - let _ = balances::GenesisConfig::{ + let _ = pallet_balances::GenesisConfig::{ balances: vec![ (1, 10 * balance_factor), (2, 20 * balance_factor), @@ -351,7 +351,7 @@ impl ExtBuilder { ..Default::default() }.assimilate_storage(&mut storage); - let _ = session::GenesisConfig:: { + let _ = pallet_session::GenesisConfig:: { keys: validators.iter().map(|x| (*x, UintAuthorityId(*x))).collect(), }.assimilate_storage(&mut storage); @@ -366,10 +366,10 @@ impl ExtBuilder { } } -pub type System = system::Module; -pub type Balances = balances::Module; -pub type Session = session::Module; -pub type Timestamp = timestamp::Module; +pub type System = frame_system::Module; +pub type Balances = pallet_balances::Module; +pub type Session = pallet_session::Module; +pub type Timestamp = pallet_timestamp::Module; pub type Staking = Module; pub fn check_exposure_all() { @@ -481,7 +481,7 @@ pub fn validator_controllers() -> Vec { } pub fn on_offence_in_era( - offenders: &[OffenceDetails>], + offenders: &[OffenceDetails>], slash_fraction: &[Perbill], era: EraIndex, ) { @@ -503,7 +503,7 @@ pub fn on_offence_in_era( } pub fn on_offence_now( - offenders: &[OffenceDetails>], + offenders: &[OffenceDetails>], slash_fraction: &[Perbill], ) { let now = Staking::current_era(); diff --git a/frame/staking/src/slashing.rs b/frame/staking/src/slashing.rs index 54b14a0cf8..b4ef364cb3 100644 --- a/frame/staking/src/slashing.rs +++ b/frame/staking/src/slashing.rs @@ -53,7 +53,7 @@ use super::{ NegativeImbalanceOf, UnappliedSlash, }; use sp_runtime::traits::{Zero, Saturating}; -use support::{ +use frame_support::{ StorageMap, StorageDoubleMap, traits::{Currency, OnUnbalanced, Imbalance}, }; diff --git a/frame/staking/src/tests.rs b/frame/staking/src/tests.rs index 0f0dbb4eba..c31cdf7611 100644 --- a/frame/staking/src/tests.rs +++ b/frame/staking/src/tests.rs @@ -20,7 +20,7 @@ use super::*; use mock::*; use sp_runtime::{assert_eq_error_rate, traits::OnInitialize}; use sp_staking::offence::OffenceDetails; -use support::{assert_ok, assert_noop, traits::{Currency, ReservableCurrency}}; +use frame_support::{assert_ok, assert_noop, traits::{Currency, ReservableCurrency}}; use substrate_test_utils::assert_eq_uvec; #[test] @@ -1688,9 +1688,9 @@ fn reward_validator_slashing_validator_doesnt_overflow() { #[test] fn reward_from_authorship_event_handler_works() { ExtBuilder::default().build().execute_with(|| { - use authorship::EventHandler; + use pallet_authorship::EventHandler; - assert_eq!(>::author(), 11); + assert_eq!(>::author(), 11); >::note_author(11); >::note_uncle(21, 1); diff --git a/frame/sudo/Cargo.toml b/frame/sudo/Cargo.toml index 1487df43b5..733e9a7084 100644 --- a/frame/sudo/Cargo.toml +++ b/frame/sudo/Cargo.toml @@ -10,11 +10,11 @@ codec = { package = "parity-scale-codec", version = "1.0.0", default-features = sp-std = { path = "../../primitives/std", 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 } +frame-support = { path = "../support", default-features = false } +frame-system = { path = "../system", default-features = false } [dev-dependencies] -primitives = { package = "sp-core", path = "../../primitives/core" } +sp-core = { path = "../../primitives/core" } [features] default = ["std"] @@ -24,6 +24,6 @@ std = [ "sp-std/std", "sp-io/std", "sp-runtime/std", - "support/std", - "system/std", + "frame-support/std", + "frame-system/std", ] diff --git a/frame/sudo/src/lib.rs b/frame/sudo/src/lib.rs index 95ff953904..3a80c2e946 100644 --- a/frame/sudo/src/lib.rs +++ b/frame/sudo/src/lib.rs @@ -51,10 +51,10 @@ //! This is an example of a module that exposes a privileged function: //! //! ``` -//! use support::{decl_module, dispatch}; -//! use system::ensure_root; +//! use frame_support::{decl_module, dispatch}; +//! use frame_system::{self as system, ensure_root}; //! -//! pub trait Trait: system::Trait {} +//! pub trait Trait: frame_system::Trait {} //! //! decl_module! { //! pub struct Module for enum Call where origin: T::Origin { @@ -90,15 +90,15 @@ use sp_std::prelude::*; use sp_runtime::{ traits::{StaticLookup, Dispatchable}, DispatchError, }; -use support::{ +use frame_support::{ Parameter, decl_module, decl_event, decl_storage, ensure, weights::SimpleDispatchInfo, }; -use system::ensure_signed; +use frame_system::{self as system, ensure_signed}; -pub trait Trait: system::Trait { +pub trait Trait: frame_system::Trait { /// The overarching event type. - type Event: From> + Into<::Event>; + type Event: From> + Into<::Event>; /// A sudo-able call. type Proposal: Parameter + Dispatchable; @@ -125,7 +125,7 @@ decl_module! { let sender = ensure_signed(origin)?; ensure!(sender == Self::key(), "only the current sudo key can sudo"); - let res = match proposal.dispatch(system::RawOrigin::Root.into()) { + let res = match proposal.dispatch(frame_system::RawOrigin::Root.into()) { Ok(_) => true, Err(e) => { let e: DispatchError = e.into(); @@ -175,7 +175,7 @@ decl_module! { let who = T::Lookup::lookup(who)?; - let res = match proposal.dispatch(system::RawOrigin::Signed(who).into()) { + let res = match proposal.dispatch(frame_system::RawOrigin::Signed(who).into()) { Ok(_) => true, Err(e) => { let e: DispatchError = e.into(); @@ -190,7 +190,7 @@ decl_module! { } decl_event!( - pub enum Event where AccountId = ::AccountId { + pub enum Event where AccountId = ::AccountId { /// A sudo just took place. Sudid(bool), /// The sudoer just switched identity; the old key is supplied. diff --git a/frame/support/Cargo.toml b/frame/support/Cargo.toml index 4312cbceeb..ad04964b12 100644 --- a/frame/support/Cargo.toml +++ b/frame/support/Cargo.toml @@ -12,13 +12,13 @@ frame-metadata = { path = "../metadata", default-features = false } sp-std = { path = "../../primitives/std", 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-core = { path = "../../primitives/core", default-features = false } sp-arithmetic = { path = "../../primitives/arithmetic", default-features = false } -inherents = { package = "sp-inherents", path = "../../primitives/inherents", default-features = false } -frame-support-procedural = { package = "frame-support-procedural", path = "./procedural" } +sp-inherents = { path = "../../primitives/inherents", default-features = false } +frame-support-procedural = { path = "./procedural" } paste = "0.1.6" once_cell = { version = "0.2.4", default-features = false, optional = true } -state-machine = { package = "sp-state-machine", path = "../../primitives/state-machine", optional = true } +sp-state-machine = { path = "../../primitives/state-machine", optional = true } bitmask = { version = "0.5.0", default-features = false } impl-trait-for-tuples = "0.1.3" tracing = { version = "0.1.10", optional = true } @@ -40,8 +40,8 @@ std = [ "sp-runtime/std", "sp-arithmetic/std", "frame-metadata/std", - "inherents/std", - "state-machine", + "sp-inherents/std", + "sp-state-machine", ] nightly = [] strict = [] diff --git a/frame/support/procedural/Cargo.toml b/frame/support/procedural/Cargo.toml index 2231cf67db..220aea5028 100644 --- a/frame/support/procedural/Cargo.toml +++ b/frame/support/procedural/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" proc-macro = true [dependencies] -frame-support-procedural-tools = { package = "frame-support-procedural-tools", path = "./tools" } +frame-support-procedural-tools = { path = "./tools" } proc-macro2 = "1.0.6" quote = "1.0.2" diff --git a/frame/support/procedural/src/construct_runtime/mod.rs b/frame/support/procedural/src/construct_runtime/mod.rs index 184cb4d49d..07b7f2cefe 100644 --- a/frame/support/procedural/src/construct_runtime/mod.rs +++ b/frame/support/procedural/src/construct_runtime/mod.rs @@ -79,7 +79,7 @@ fn construct_runtime_parsed(definition: RuntimeDefinition) -> Result( fn decl_all_modules<'a>( runtime: &'a Ident, + system_name: &'a Ident, module_declarations: impl Iterator, ) -> TokenStream2 { let mut types = TokenStream2::new(); @@ -335,7 +336,7 @@ fn decl_all_modules<'a>( ); quote!( - pub type System = system::Module<#runtime>; + pub type System = #system_name::Module<#runtime>; #types type AllModules = ( #all_modules ); ) diff --git a/frame/support/procedural/src/construct_runtime/parse.rs b/frame/support/procedural/src/construct_runtime/parse.rs index a5338bb8af..84ac6573c6 100644 --- a/frame/support/procedural/src/construct_runtime/parse.rs +++ b/frame/support/procedural/src/construct_runtime/parse.rs @@ -243,7 +243,7 @@ impl ModuleDeclaration { .collect(); res.extend( ["Event", "Config"] - .into_iter() + .iter() .map(|name| ModulePart::with_generics(name, span)), ); res @@ -345,7 +345,7 @@ impl ModulePart { pub fn is_included_in_default(&self) -> bool { ["Module", "Call", "Storage", "Event", "Config"] - .into_iter() + .iter() .any(|name| self.name == name) } diff --git a/frame/support/procedural/tools/Cargo.toml b/frame/support/procedural/tools/Cargo.toml index 8a9f87116b..00ac787c57 100644 --- a/frame/support/procedural/tools/Cargo.toml +++ b/frame/support/procedural/tools/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -frame-support-procedural-tools-derive = { package = "frame-support-procedural-tools-derive", path = "./derive" } +frame-support-procedural-tools-derive = { path = "./derive" } proc-macro2 = "1.0.6" quote = "1.0.2" syn = { version = "1.0.7", features = ["full", "visit"] } diff --git a/frame/support/src/debug.rs b/frame/support/src/debug.rs index 0609148092..2e64b67c1b 100644 --- a/frame/support/src/debug.rs +++ b/frame/support/src/debug.rs @@ -25,7 +25,7 @@ //! this that are described below. //! //! First component to utilize debug-printing and loggin is actually -//! located in `primitives` crate: `primitives::RuntimeDebug`. +//! located in `primitives` crate: `sp_core::RuntimeDebug`. //! This custom-derive generates `core::fmt::Debug` implementation, //! just like regular `derive(Debug)`, however it does not generate //! any code when the code is compiled to WASM. This means that @@ -37,7 +37,7 @@ //! ```rust,no_run //! use frame_support::debug; //! -//! #[derive(primitives::RuntimeDebug)] +//! #[derive(sp_core::RuntimeDebug)] //! struct MyStruct { //! a: u64, //! } @@ -68,7 +68,7 @@ //! ```rust,no_run //! use frame_support::debug::native; //! -//! #[derive(primitives::RuntimeDebug)] +//! #[derive(sp_core::RuntimeDebug)] //! struct MyStruct { //! a: u64, //! } diff --git a/frame/support/src/event.rs b/frame/support/src/event.rs index 5b8ce1830e..3453adf796 100644 --- a/frame/support/src/event.rs +++ b/frame/support/src/event.rs @@ -530,7 +530,7 @@ macro_rules! __impl_outer_event_json_metadata { $crate::event::OuterEventMetadata { name: $crate::event::DecodeDifferent::Encode(stringify!($event_name)), events: $crate::event::DecodeDifferent::Encode(&[ - ("system", $crate::event::FnEncode(system::Event::metadata)) + ("system", $crate::event::FnEncode($system::Event::metadata)) $( , ( stringify!($module_name), @@ -542,6 +542,7 @@ macro_rules! __impl_outer_event_json_metadata { ]) } } + #[allow(dead_code)] pub fn __module_events_system() -> &'static [$crate::event::EventMetadata] { system::Event::metadata() diff --git a/frame/support/src/inherent.rs b/frame/support/src/inherent.rs index 5dfb1bade8..fc11cd0a2e 100644 --- a/frame/support/src/inherent.rs +++ b/frame/support/src/inherent.rs @@ -19,7 +19,7 @@ pub use crate::sp_std::vec::Vec; #[doc(hidden)] pub use crate::sp_runtime::traits::{Block as BlockT, Extrinsic}; #[doc(hidden)] -pub use inherents::{InherentData, ProvideInherent, CheckInherentsResult, IsFatalError}; +pub use sp_inherents::{InherentData, ProvideInherent, CheckInherentsResult, IsFatalError}; /// Implement the outer inherent. diff --git a/frame/support/src/lib.rs b/frame/support/src/lib.rs index 1ddc6db65c..cf6b2472f0 100644 --- a/frame/support/src/lib.rs +++ b/frame/support/src/lib.rs @@ -39,7 +39,7 @@ pub use once_cell; pub use paste; #[cfg(feature = "std")] #[doc(hidden)] -pub use state_machine::BasicExternalities; +pub use sp_state_machine::BasicExternalities; #[doc(hidden)] pub use sp_io::storage::root as storage_root; #[doc(hidden)] diff --git a/frame/support/src/storage/child.rs b/frame/support/src/storage/child.rs index abd1a208c6..5aca2d3125 100644 --- a/frame/support/src/storage/child.rs +++ b/frame/support/src/storage/child.rs @@ -27,7 +27,7 @@ use crate::sp_std::prelude::*; use codec::{Codec, Encode, Decode}; -pub use primitives::storage::ChildInfo; +pub use sp_core::storage::ChildInfo; /// Return the value of the item in storage under `key`, or `None` if there is no explicit entry. pub fn get( diff --git a/frame/support/src/storage/mod.rs b/frame/support/src/storage/mod.rs index 4a392affbd..7c0ee4c8e4 100644 --- a/frame/support/src/storage/mod.rs +++ b/frame/support/src/storage/mod.rs @@ -423,7 +423,7 @@ pub trait StoragePrefixedMap { #[cfg(test)] mod test { - use primitives::hashing::twox_128; + use sp_core::hashing::twox_128; use sp_io::TestExternalities; use crate::storage::{unhashed, StoragePrefixedMap}; diff --git a/frame/support/src/traits.rs b/frame/support/src/traits.rs index ae1695b3d3..afc4a4e4f4 100644 --- a/frame/support/src/traits.rs +++ b/frame/support/src/traits.rs @@ -20,7 +20,7 @@ use sp_std::{prelude::*, result, marker::PhantomData, ops::Div, fmt::Debug}; use codec::{FullCodec, Codec, Encode, Decode}; -use primitives::u32_trait::Value as U32; +use sp_core::u32_trait::Value as U32; use sp_runtime::{ ConsensusEngineId, traits::{MaybeSerializeDeserialize, SimpleArithmetic, Saturating}, diff --git a/frame/support/test/Cargo.toml b/frame/support/test/Cargo.toml index abd44f7a95..8637a582bf 100644 --- a/frame/support/test/Cargo.toml +++ b/frame/support/test/Cargo.toml @@ -8,11 +8,11 @@ edition = "2018" serde = { version = "1.0.101", default-features = false, features = ["derive"] } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } 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 } -sp-runtime = { package = "sp-runtime", path = "../../../primitives/runtime", default-features = false } -primitives = { package = "sp-core", path = "../../../primitives/core", default-features = false } +sp-state-machine = { path = "../../../primitives/state-machine", optional = true } +frame-support = { version = "2", path = "../", default-features = false } +sp-inherents = { path = "../../../primitives/inherents", default-features = false } +sp-runtime = { path = "../../../primitives/runtime", default-features = false } +sp-core = { path = "../../../primitives/core", default-features = false } trybuild = "1.0.17" pretty_assertions = "0.6.1" @@ -22,9 +22,9 @@ std = [ "serde/std", "codec/std", "sp-io/std", - "support/std", - "inherents/std", - "primitives/std", + "frame-support/std", + "sp-inherents/std", + "sp-core/std", "sp-runtime/std", - "state-machine", + "sp-state-machine", ] diff --git a/frame/support/test/src/lib.rs b/frame/support/test/src/lib.rs index 95fa5c6e95..c6a93e1b77 100644 --- a/frame/support/test/src/lib.rs +++ b/frame/support/test/src/lib.rs @@ -14,5 +14,5 @@ // You should have received a copy of the GNU General Public License // along with Substrate. If not, see . -//! Test crate for frame_support. Allow to make use of `support::decl_storage`. +//! Test crate for frame_support. Allow to make use of `frame_support::decl_storage`. //! See tests directory. diff --git a/frame/support/test/tests/construct_runtime_ui/abundant_where_param.rs b/frame/support/test/tests/construct_runtime_ui/abundant_where_param.rs index 4d5b40d7c9..d5e9f22521 100644 --- a/frame/support/test/tests/construct_runtime_ui/abundant_where_param.rs +++ b/frame/support/test/tests/construct_runtime_ui/abundant_where_param.rs @@ -1,4 +1,4 @@ -use support::construct_runtime; +use frame_support::construct_runtime; construct_runtime! { pub enum Runtime where diff --git a/frame/support/test/tests/construct_runtime_ui/double_module_parts.rs b/frame/support/test/tests/construct_runtime_ui/double_module_parts.rs index b741b316e1..0907f0bfb3 100644 --- a/frame/support/test/tests/construct_runtime_ui/double_module_parts.rs +++ b/frame/support/test/tests/construct_runtime_ui/double_module_parts.rs @@ -1,4 +1,4 @@ -use support::construct_runtime; +use frame_support::construct_runtime; construct_runtime! { pub enum Runtime where diff --git a/frame/support/test/tests/construct_runtime_ui/double_module_parts_default.rs b/frame/support/test/tests/construct_runtime_ui/double_module_parts_default.rs index d259389460..3d61abebe8 100644 --- a/frame/support/test/tests/construct_runtime_ui/double_module_parts_default.rs +++ b/frame/support/test/tests/construct_runtime_ui/double_module_parts_default.rs @@ -1,4 +1,4 @@ -use support::construct_runtime; +use frame_support::construct_runtime; construct_runtime! { pub enum Runtime where diff --git a/frame/support/test/tests/construct_runtime_ui/generics_in_invalid_module.rs b/frame/support/test/tests/construct_runtime_ui/generics_in_invalid_module.rs index 16e3696195..5a9a4612ed 100644 --- a/frame/support/test/tests/construct_runtime_ui/generics_in_invalid_module.rs +++ b/frame/support/test/tests/construct_runtime_ui/generics_in_invalid_module.rs @@ -1,4 +1,4 @@ -use support::construct_runtime; +use frame_support::construct_runtime; construct_runtime! { pub enum Runtime where diff --git a/frame/support/test/tests/construct_runtime_ui/invalid_module_details.rs b/frame/support/test/tests/construct_runtime_ui/invalid_module_details.rs index bfaeca6a42..336e27e915 100644 --- a/frame/support/test/tests/construct_runtime_ui/invalid_module_details.rs +++ b/frame/support/test/tests/construct_runtime_ui/invalid_module_details.rs @@ -1,4 +1,4 @@ -use support::construct_runtime; +use frame_support::construct_runtime; construct_runtime! { pub enum Runtime where diff --git a/frame/support/test/tests/construct_runtime_ui/invalid_module_details_keyword.rs b/frame/support/test/tests/construct_runtime_ui/invalid_module_details_keyword.rs index 87e802f4bc..0891483c92 100644 --- a/frame/support/test/tests/construct_runtime_ui/invalid_module_details_keyword.rs +++ b/frame/support/test/tests/construct_runtime_ui/invalid_module_details_keyword.rs @@ -1,4 +1,4 @@ -use support::construct_runtime; +use frame_support::construct_runtime; construct_runtime! { pub enum Runtime where diff --git a/frame/support/test/tests/construct_runtime_ui/invalid_token_after_module.rs b/frame/support/test/tests/construct_runtime_ui/invalid_token_after_module.rs index d7307c2548..448ae913f3 100644 --- a/frame/support/test/tests/construct_runtime_ui/invalid_token_after_module.rs +++ b/frame/support/test/tests/construct_runtime_ui/invalid_token_after_module.rs @@ -1,4 +1,4 @@ -use support::construct_runtime; +use frame_support::construct_runtime; construct_runtime! { pub enum Runtime where diff --git a/frame/support/test/tests/construct_runtime_ui/invalid_token_after_name.rs b/frame/support/test/tests/construct_runtime_ui/invalid_token_after_name.rs index f0fb296c73..43538789f1 100644 --- a/frame/support/test/tests/construct_runtime_ui/invalid_token_after_name.rs +++ b/frame/support/test/tests/construct_runtime_ui/invalid_token_after_name.rs @@ -1,4 +1,4 @@ -use support::construct_runtime; +use frame_support::construct_runtime; construct_runtime! { pub enum Runtime where diff --git a/frame/support/test/tests/construct_runtime_ui/invalid_where_param.rs b/frame/support/test/tests/construct_runtime_ui/invalid_where_param.rs index 000af42715..13536338e0 100644 --- a/frame/support/test/tests/construct_runtime_ui/invalid_where_param.rs +++ b/frame/support/test/tests/construct_runtime_ui/invalid_where_param.rs @@ -1,4 +1,4 @@ -use support::construct_runtime; +use frame_support::construct_runtime; construct_runtime! { pub enum Runtime where diff --git a/frame/support/test/tests/construct_runtime_ui/missing_event_generic_on_module_with_instance.rs b/frame/support/test/tests/construct_runtime_ui/missing_event_generic_on_module_with_instance.rs index 224ec65ee3..928871fab2 100644 --- a/frame/support/test/tests/construct_runtime_ui/missing_event_generic_on_module_with_instance.rs +++ b/frame/support/test/tests/construct_runtime_ui/missing_event_generic_on_module_with_instance.rs @@ -1,4 +1,4 @@ -use support::construct_runtime; +use frame_support::construct_runtime; construct_runtime! { pub enum Runtime where diff --git a/frame/support/test/tests/construct_runtime_ui/missing_module_instance.rs b/frame/support/test/tests/construct_runtime_ui/missing_module_instance.rs index 9171827d16..fbc4b60db8 100644 --- a/frame/support/test/tests/construct_runtime_ui/missing_module_instance.rs +++ b/frame/support/test/tests/construct_runtime_ui/missing_module_instance.rs @@ -1,4 +1,4 @@ -use support::construct_runtime; +use frame_support::construct_runtime; construct_runtime! { pub enum Runtime where diff --git a/frame/support/test/tests/construct_runtime_ui/missing_origin_generic_on_module_with_instance.rs b/frame/support/test/tests/construct_runtime_ui/missing_origin_generic_on_module_with_instance.rs index 6eadbbf3e0..35a5c8201b 100644 --- a/frame/support/test/tests/construct_runtime_ui/missing_origin_generic_on_module_with_instance.rs +++ b/frame/support/test/tests/construct_runtime_ui/missing_origin_generic_on_module_with_instance.rs @@ -1,4 +1,4 @@ -use support::construct_runtime; +use frame_support::construct_runtime; construct_runtime! { pub enum Runtime where diff --git a/frame/support/test/tests/construct_runtime_ui/missing_system_module.rs b/frame/support/test/tests/construct_runtime_ui/missing_system_module.rs index 409ee2b8ba..71dabf91c1 100644 --- a/frame/support/test/tests/construct_runtime_ui/missing_system_module.rs +++ b/frame/support/test/tests/construct_runtime_ui/missing_system_module.rs @@ -1,4 +1,4 @@ -use support::construct_runtime; +use frame_support::construct_runtime; construct_runtime! { pub enum Runtime where diff --git a/frame/support/test/tests/construct_runtime_ui/missing_where_block.rs b/frame/support/test/tests/construct_runtime_ui/missing_where_block.rs index 8d43c58140..5148330ae5 100644 --- a/frame/support/test/tests/construct_runtime_ui/missing_where_block.rs +++ b/frame/support/test/tests/construct_runtime_ui/missing_where_block.rs @@ -1,4 +1,4 @@ -use support::construct_runtime; +use frame_support::construct_runtime; construct_runtime! { pub enum Runtime {} diff --git a/frame/support/test/tests/construct_runtime_ui/missing_where_param.rs b/frame/support/test/tests/construct_runtime_ui/missing_where_param.rs index 7ec6409124..2e311c5ea0 100644 --- a/frame/support/test/tests/construct_runtime_ui/missing_where_param.rs +++ b/frame/support/test/tests/construct_runtime_ui/missing_where_param.rs @@ -1,4 +1,4 @@ -use support::construct_runtime; +use frame_support::construct_runtime; construct_runtime! { pub enum Runtime where diff --git a/frame/support/test/tests/construct_runtime_ui/no_comma_after_where.rs b/frame/support/test/tests/construct_runtime_ui/no_comma_after_where.rs index 096d5fd376..954fadefa1 100644 --- a/frame/support/test/tests/construct_runtime_ui/no_comma_after_where.rs +++ b/frame/support/test/tests/construct_runtime_ui/no_comma_after_where.rs @@ -1,4 +1,4 @@ -use support::construct_runtime; +use frame_support::construct_runtime; construct_runtime! { pub enum Runtime where diff --git a/frame/support/test/tests/construct_runtime_ui/params_in_invalid_module.rs b/frame/support/test/tests/construct_runtime_ui/params_in_invalid_module.rs index f493371bb3..a739277d62 100644 --- a/frame/support/test/tests/construct_runtime_ui/params_in_invalid_module.rs +++ b/frame/support/test/tests/construct_runtime_ui/params_in_invalid_module.rs @@ -1,4 +1,4 @@ -use support::construct_runtime; +use frame_support::construct_runtime; construct_runtime! { pub enum Runtime where diff --git a/frame/support/test/tests/decl_storage.rs b/frame/support/test/tests/decl_storage.rs index 1c7ff1ce0a..e12799f479 100644 --- a/frame/support/test/tests/decl_storage.rs +++ b/frame/support/test/tests/decl_storage.rs @@ -18,12 +18,12 @@ // Do not complain about unused `dispatch` and `dispatch_aux`. #[allow(dead_code)] mod tests { - use support::metadata::*; + use frame_support::metadata::*; use sp_io::TestExternalities; use std::marker::PhantomData; use codec::{Encode, Decode, EncodeLike}; - support::decl_module! { + frame_support::decl_module! { pub struct Module for enum Call where origin: T::Origin {} } @@ -32,7 +32,7 @@ mod tests { type BlockNumber; } - support::decl_storage! { + frame_support::decl_storage! { trait Store for Module as TestStorage { // non-getters: pub / $default @@ -478,13 +478,13 @@ mod test2 { type BlockNumber; } - support::decl_module! { + frame_support::decl_module! { pub struct Module for enum Call where origin: T::Origin {} } type PairOf = (T, T); - support::decl_storage! { + frame_support::decl_storage! { trait Store for Module as TestStorage { SingleDef : u32; PairDef : PairOf; @@ -513,10 +513,10 @@ mod test3 { type Origin; type BlockNumber; } - support::decl_module! { + frame_support::decl_module! { pub struct Module for enum Call where origin: T::Origin {} } - support::decl_storage! { + frame_support::decl_storage! { trait Store for Module as Test { Foo get(fn foo) config(initial_foo): u32; } @@ -543,14 +543,14 @@ mod test_append_and_len { type BlockNumber; } - support::decl_module! { + frame_support::decl_module! { pub struct Module for enum Call where origin: T::Origin {} } #[derive(PartialEq, Eq, Clone, Encode, Decode)] struct NoDef(u32); - support::decl_storage! { + frame_support::decl_storage! { trait Store for Module as Test { NoDefault: Option; diff --git a/frame/support/test/tests/decl_storage_ui/config_duplicate.rs b/frame/support/test/tests/decl_storage_ui/config_duplicate.rs index bdd7da7449..e00f9a8f4c 100644 --- a/frame/support/test/tests/decl_storage_ui/config_duplicate.rs +++ b/frame/support/test/tests/decl_storage_ui/config_duplicate.rs @@ -19,11 +19,11 @@ pub trait Trait { type BlockNumber: codec::Codec + codec::EncodeLike + Default + Clone; } -support::decl_module! { +frame_support::decl_module! { pub struct Module for enum Call where origin: T::Origin {} } -support::decl_storage!{ +frame_support::decl_storage!{ trait Store for Module as FinalKeysNone { pub Value config(value): u32; pub Value2 config(value): u32; diff --git a/frame/support/test/tests/decl_storage_ui/config_get_duplicate.rs b/frame/support/test/tests/decl_storage_ui/config_get_duplicate.rs index 2bf8df4532..6ce8194b57 100644 --- a/frame/support/test/tests/decl_storage_ui/config_get_duplicate.rs +++ b/frame/support/test/tests/decl_storage_ui/config_get_duplicate.rs @@ -19,11 +19,11 @@ pub trait Trait { type BlockNumber: codec::Codec + codec::EncodeLike + Default + Clone; } -support::decl_module! { +frame_support::decl_module! { pub struct Module for enum Call where origin: T::Origin {} } -support::decl_storage!{ +frame_support::decl_storage!{ trait Store for Module as FinalKeysNone { pub Value get(fn value) config(): u32; pub Value2 config(value): u32; diff --git a/frame/support/test/tests/decl_storage_ui/get_duplicate.rs b/frame/support/test/tests/decl_storage_ui/get_duplicate.rs index 41ca708352..d593ddc477 100644 --- a/frame/support/test/tests/decl_storage_ui/get_duplicate.rs +++ b/frame/support/test/tests/decl_storage_ui/get_duplicate.rs @@ -19,11 +19,11 @@ pub trait Trait { type BlockNumber: codec::Codec + codec::EncodeLike + Default + Clone; } -support::decl_module! { +frame_support::decl_module! { pub struct Module for enum Call where origin: T::Origin {} } -support::decl_storage!{ +frame_support::decl_storage!{ trait Store for Module as FinalKeysNone { pub Value get(fn value) config(): u32; pub Value2 get(fn value) config(): u32; diff --git a/frame/support/test/tests/final_keys.rs b/frame/support/test/tests/final_keys.rs index 21f91e4f78..3d4c3f5060 100644 --- a/frame/support/test/tests/final_keys.rs +++ b/frame/support/test/tests/final_keys.rs @@ -14,9 +14,9 @@ // You should have received a copy of the GNU General Public License // along with Substrate. If not, see . -use support::storage::unhashed; +use frame_support::storage::unhashed; use codec::Encode; -use support::{StorageDoubleMap, StorageLinkedMap, StorageMap, StorageValue, StoragePrefixedMap}; +use frame_support::{StorageDoubleMap, StorageLinkedMap, StorageMap, StorageValue, StoragePrefixedMap}; use sp_io::{TestExternalities, hashing::{twox_128, blake2_128, blake2_256}}; mod no_instance { @@ -27,11 +27,11 @@ mod no_instance { type BlockNumber: Encode + Decode + EncodeLike + Default + Clone; } - support::decl_module! { + frame_support::decl_module! { pub struct Module for enum Call where origin: T::Origin {} } - support::decl_storage!{ + frame_support::decl_storage!{ trait Store for Module as FinalKeysNone { pub Value config(value): u32; @@ -54,12 +54,12 @@ mod no_instance { mod instance { pub trait Trait: super::no_instance::Trait {} - support::decl_module! { + frame_support::decl_module! { pub struct Module, I: Instantiable = DefaultInstance> for enum Call where origin: T::Origin {} } - support::decl_storage!{ + frame_support::decl_storage!{ trait Store for Module, I: Instantiable = DefaultInstance> as FinalKeysSome { diff --git a/frame/support/test/tests/genesisconfig.rs b/frame/support/test/tests/genesisconfig.rs index e945c774c0..1b5a935983 100644 --- a/frame/support/test/tests/genesisconfig.rs +++ b/frame/support/test/tests/genesisconfig.rs @@ -19,11 +19,11 @@ pub trait Trait { type Origin; } -support::decl_module! { +frame_support::decl_module! { pub struct Module for enum Call where origin: T::Origin {} } -support::decl_storage! { +frame_support::decl_storage! { trait Store for Module as Example { pub AppendableDM config(t): double_map u32, blake2_256(T::BlockNumber) => Vec; } diff --git a/frame/support/test/tests/instance.rs b/frame/support/test/tests/instance.rs index 0525589afa..835c082a66 100644 --- a/frame/support/test/tests/instance.rs +++ b/frame/support/test/tests/instance.rs @@ -17,7 +17,7 @@ #![recursion_limit="128"] use sp_runtime::{generic, BuildStorage, traits::{BlakeTwo256, Block as _, Verify}}; -use support::{ +use frame_support::{ Parameter, traits::Get, parameter_types, metadata::{ DecodeDifferent, StorageMetadata, StorageEntryModifier, StorageEntryType, DefaultByteGetter, @@ -25,8 +25,8 @@ use support::{ }, StorageValue, StorageMap, StorageLinkedMap, StorageDoubleMap, }; -use inherents::{ProvideInherent, InherentData, InherentIdentifier, MakeFatalError}; -use primitives::{H256, sr25519}; +use sp_inherents::{ProvideInherent, InherentData, InherentIdentifier, MakeFatalError}; +use sp_core::{H256, sr25519}; mod system; @@ -46,7 +46,7 @@ mod module1 { type GenericType: Default + Clone + codec::Codec + codec::EncodeLike; } - support::decl_module! { + frame_support::decl_module! { pub struct Module, I: InstantiableThing> for enum Call where origin: ::Origin, T::BlockNumber: From @@ -62,7 +62,7 @@ mod module1 { } } - support::decl_storage! { + frame_support::decl_storage! { trait Store for Module, I: InstantiableThing> as Module1 where T::BlockNumber: From + std::fmt::Display { @@ -79,7 +79,7 @@ mod module1 { } } - support::decl_event! { + frame_support::decl_event! { pub enum Event where Phantom = std::marker::PhantomData { _Phantom(Phantom), AnotherVariant(u32), @@ -98,7 +98,7 @@ mod module1 { T::BlockNumber: From { type Call = Call; - type Error = MakeFatalError; + type Error = MakeFatalError; const INHERENT_IDENTIFIER: InherentIdentifier = INHERENT_IDENTIFIER; fn create_inherent(_data: &InherentData) -> Option { @@ -125,7 +125,7 @@ mod module2 { impl, I: Instance> Currency for Module {} - support::decl_module! { + frame_support::decl_module! { pub struct Module, I: Instance=DefaultInstance> for enum Call where origin: ::Origin { @@ -133,7 +133,7 @@ mod module2 { } } - support::decl_storage! { + frame_support::decl_storage! { trait Store for Module, I: Instance=DefaultInstance> as Module2 { pub Value config(value): T::Amount; pub Map config(map): map u64 => u64; @@ -142,7 +142,7 @@ mod module2 { } } - support::decl_event! { + frame_support::decl_event! { pub enum Event where Amount = >::Amount { Variant(Amount), } @@ -158,7 +158,7 @@ mod module2 { impl, I: Instance> ProvideInherent for Module { type Call = Call; - type Error = MakeFatalError; + type Error = MakeFatalError; const INHERENT_IDENTIFIER: InherentIdentifier = INHERENT_IDENTIFIER; fn create_inherent(_data: &InherentData) -> Option { @@ -181,7 +181,7 @@ mod module3 { type Currency2: Currency; } - support::decl_module! { + frame_support::decl_module! { pub struct Module for enum Call where origin: ::Origin {} } } @@ -240,7 +240,7 @@ impl system::Trait for Runtime { type Event = Event; } -support::construct_runtime!( +frame_support::construct_runtime!( pub enum Runtime where Block = Block, NodeBlock = Block, @@ -300,11 +300,11 @@ fn new_test_ext() -> sp_io::TestExternalities { #[test] fn storage_instance_independance() { - let mut storage = primitives::storage::Storage { + let mut storage = sp_core::storage::Storage { top: std::collections::BTreeMap::new(), children: std::collections::HashMap::new() }; - state_machine::BasicExternalities::execute_with_storage(&mut storage, || { + sp_state_machine::BasicExternalities::execute_with_storage(&mut storage, || { module2::Value::::put(0); module2::Value::::put(0); module2::Value::::put(0); diff --git a/frame/support/test/tests/issue2219.rs b/frame/support/test/tests/issue2219.rs index c5c7f77935..4c9731b498 100644 --- a/frame/support/test/tests/issue2219.rs +++ b/frame/support/test/tests/issue2219.rs @@ -14,10 +14,10 @@ // You should have received a copy of the GNU General Public License // along with Substrate. If not, see . -use support::sp_runtime::generic; -use support::sp_runtime::traits::{BlakeTwo256, Block as _, Verify}; -use support::codec::{Encode, Decode}; -use primitives::{H256, sr25519}; +use frame_support::sp_runtime::generic; +use frame_support::sp_runtime::traits::{BlakeTwo256, Block as _, Verify}; +use frame_support::codec::{Encode, Decode}; +use sp_core::{H256, sr25519}; use serde::{Serialize, Deserialize}; mod system; @@ -82,7 +82,7 @@ mod module { pub trait Trait: system::Trait {} - support::decl_module! { + frame_support::decl_module! { pub struct Module for enum Call where origin: T::Origin {} } @@ -99,7 +99,7 @@ mod module { } } - support::decl_storage! { + frame_support::decl_storage! { trait Store for Module as Actors { /// requirements to enter and maintain status in roles pub Parameters get(fn parameters) build(|config: &GenesisConfig| { @@ -164,7 +164,7 @@ impl system::Trait for Runtime { impl module::Trait for Runtime {} -support::construct_runtime!( +frame_support::construct_runtime!( pub enum Runtime where Block = Block, NodeBlock = Block, diff --git a/frame/support/test/tests/reserved_keyword/on_initialize.rs b/frame/support/test/tests/reserved_keyword/on_initialize.rs index 80ee52a982..9a7ffcf067 100644 --- a/frame/support/test/tests/reserved_keyword/on_initialize.rs +++ b/frame/support/test/tests/reserved_keyword/on_initialize.rs @@ -2,7 +2,7 @@ macro_rules! reserved { ($($reserved:ident)*) => { $( mod $reserved { - pub use support::dispatch; + pub use frame_support::dispatch; pub trait Trait { type Origin; @@ -10,14 +10,14 @@ macro_rules! reserved { } pub mod system { - use support::dispatch; + use frame_support::dispatch; pub fn ensure_root(_: R) -> dispatch::Result { Ok(()) } } - support::decl_module! { + frame_support::decl_module! { pub struct Module for enum Call where origin: T::Origin { fn $reserved(_origin) -> dispatch::Result { unreachable!() } } diff --git a/frame/support/test/tests/system.rs b/frame/support/test/tests/system.rs index fe977392dd..e7da24bbab 100644 --- a/frame/support/test/tests/system.rs +++ b/frame/support/test/tests/system.rs @@ -1,4 +1,4 @@ -use support::codec::{Encode, Decode, EncodeLike}; +use frame_support::codec::{Encode, Decode, EncodeLike}; pub trait Trait: 'static + Eq + Clone { type Origin: Into, Self::Origin>> @@ -10,7 +10,7 @@ pub trait Trait: 'static + Eq + Clone { type Event: From; } -support::decl_module! { +frame_support::decl_module! { pub struct Module for enum Call where origin: T::Origin { } } @@ -20,14 +20,14 @@ impl Module { } } -support::decl_event!( +frame_support::decl_event!( pub enum Event { ExtrinsicSuccess, ExtrinsicFailed, } ); -support::decl_error! { +frame_support::decl_error! { pub enum Error { /// Test error documentation TestError, diff --git a/frame/system/Cargo.toml b/frame/system/Cargo.toml index 78c8884e42..1bd0f60d51 100644 --- a/frame/system/Cargo.toml +++ b/frame/system/Cargo.toml @@ -8,12 +8,12 @@ edition = "2018" 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"] } -primitives = { package = "sp-core", path = "../../primitives/core", default-features = false } +sp-core = { path = "../../primitives/core", default-features = false } sp-std = { path = "../../primitives/std", default-features = false } sp-io ={ path = "../../primitives/io", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } sp-version = { path = "../../primitives/version", default-features = false } -support = { package = "frame-support", path = "../support", default-features = false } +frame-support = { path = "../support", default-features = false } impl-trait-for-tuples = "0.1.3" [dev-dependencies] @@ -25,10 +25,10 @@ std = [ "serde", "safe-mix/std", "codec/std", - "primitives/std", + "sp-core/std", "sp-std/std", "sp-io/std", - "support/std", + "frame-support/std", "sp-runtime/std", "sp-version/std", ] diff --git a/frame/system/benches/bench.rs b/frame/system/benches/bench.rs index 731cadb579..5102c56adf 100644 --- a/frame/system/benches/bench.rs +++ b/frame/system/benches/bench.rs @@ -16,8 +16,8 @@ use criterion::{Criterion, criterion_group, criterion_main, black_box}; use frame_system as system; -use support::{decl_module, decl_event, impl_outer_origin, impl_outer_event, weights::Weight}; -use primitives::H256; +use frame_support::{decl_module, decl_event, impl_outer_origin, impl_outer_event, weights::Weight}; +use sp_core::H256; use sp_runtime::{Perbill, traits::{BlakeTwo256, IdentityLookup}, testing::Header}; mod module { @@ -50,7 +50,7 @@ impl_outer_event! { } } -support::parameter_types! { +frame_support::parameter_types! { pub const BlockHashCount: u64 = 250; pub const MaximumBlockWeight: Weight = 4 * 1024 * 1024; pub const MaximumBlockLength: u32 = 4 * 1024 * 1024; diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index b8786e59a5..cf008101ed 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -68,7 +68,7 @@ //! ### Example - Get extrinsic count and parent hash for the current block //! //! ``` -//! use support::{decl_module, dispatch}; +//! use frame_support::{decl_module, dispatch}; //! use frame_system::{self as system, ensure_signed}; //! //! pub trait Trait: system::Trait {} @@ -110,8 +110,8 @@ use sp_runtime::{ }, }; -use primitives::storage::well_known_keys; -use support::{ +use sp_core::storage::well_known_keys; +use frame_support::{ decl_module, decl_event, decl_storage, decl_error, storage, Parameter, traits::{Contains, Get}, weights::{Weight, DispatchInfo, DispatchClass, SimpleDispatchInfo}, @@ -122,7 +122,7 @@ use codec::{Encode, Decode}; use sp_io::TestExternalities; #[cfg(any(feature = "std", test))] -use primitives::ChangesTrieConfiguration; +use sp_core::ChangesTrieConfiguration; pub mod offchain; @@ -416,7 +416,7 @@ decl_storage! { } add_extra_genesis { config(changes_trie_config): Option; - #[serde(with = "primitives::bytes")] + #[serde(with = "sp_core::bytes")] config(code): Vec; build(|config: &GenesisConfig| { @@ -703,7 +703,7 @@ impl Module { /// Get the basic externalities for this module, useful for tests. #[cfg(any(feature = "std", test))] pub fn externalities() -> TestExternalities { - TestExternalities::new(primitives::storage::Storage { + TestExternalities::new(sp_core::storage::Storage { top: map![ >::hashed_key_for(T::BlockNumber::zero()) => [69u8; 32].encode(), >::hashed_key().to_vec() => T::BlockNumber::one().encode(), @@ -1141,9 +1141,9 @@ impl Lookup for ChainContext { #[cfg(test)] mod tests { use super::*; - use primitives::H256; + use sp_core::H256; use sp_runtime::{traits::{BlakeTwo256, IdentityLookup}, testing::Header, DispatchError}; - use support::{impl_outer_origin, parameter_types}; + use frame_support::{impl_outer_origin, parameter_types}; impl_outer_origin! { pub enum Origin for Test where system = super {} diff --git a/frame/timestamp/Cargo.toml b/frame/timestamp/Cargo.toml index ab2e40d021..675efe37b0 100644 --- a/frame/timestamp/Cargo.toml +++ b/frame/timestamp/Cargo.toml @@ -9,25 +9,25 @@ 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 } sp-runtime = { path = "../../primitives/runtime", default-features = false } -inherents = { package = "sp-inherents", path = "../../primitives/inherents", default-features = false } -support = { package = "frame-support", path = "../support", default-features = false } -system = { package = "frame-system", path = "../system", default-features = false } +sp-inherents = { path = "../../primitives/inherents", default-features = false } +frame-support = { path = "../support", default-features = false } +frame-system = { path = "../system", default-features = false } sp-timestamp = { path = "../../primitives/timestamp", default-features = false } impl-trait-for-tuples = "0.1.3" [dev-dependencies] sp-io ={ path = "../../primitives/io" } -primitives = { package = "sp-core", path = "../../primitives/core" } +sp-core = { path = "../../primitives/core" } [features] default = ["std"] std = [ - "inherents/std", + "sp-inherents/std", "codec/std", "sp-std/std", "sp-runtime/std", - "support/std", + "frame-support/std", "serde", - "system/std", + "frame-system/std", "sp-timestamp/std" ] diff --git a/frame/timestamp/src/lib.rs b/frame/timestamp/src/lib.rs index 90c9f9ef6c..f15c0ed627 100644 --- a/frame/timestamp/src/lib.rs +++ b/frame/timestamp/src/lib.rs @@ -61,9 +61,9 @@ //! ### Get current timestamp //! //! ``` -//! use support::{decl_module, dispatch}; +//! use frame_support::{decl_module, dispatch}; //! # use pallet_timestamp as timestamp; -//! use system::ensure_signed; +//! use frame_system::{self as system, ensure_signed}; //! //! pub trait Trait: timestamp::Trait {} //! @@ -91,24 +91,24 @@ #![cfg_attr(not(feature = "std"), no_std)] use sp_std::{result, cmp}; -use inherents::{ProvideInherent, InherentData, InherentIdentifier}; -use support::{Parameter, decl_storage, decl_module}; -use support::traits::{Time, Get}; +use sp_inherents::{ProvideInherent, InherentData, InherentIdentifier}; +use frame_support::{Parameter, decl_storage, decl_module}; +use frame_support::traits::{Time, Get}; use sp_runtime::{ RuntimeString, traits::{ SimpleArithmetic, Zero, SaturatedConversion, Scale } }; -use support::weights::SimpleDispatchInfo; -use system::ensure_none; +use frame_support::weights::SimpleDispatchInfo; +use frame_system::ensure_none; use sp_timestamp::{ InherentError, INHERENT_IDENTIFIER, InherentType, OnTimestampSet, }; /// The module configuration trait -pub trait Trait: system::Trait { +pub trait Trait: frame_system::Trait { /// Type used for expressing timestamp. type Moment: Parameter + Default + SimpleArithmetic + Scale + Copy; @@ -240,13 +240,13 @@ impl Time for Module { mod tests { use super::*; - use support::{impl_outer_origin, assert_ok, parameter_types, weights::Weight}; + use frame_support::{impl_outer_origin, assert_ok, parameter_types, weights::Weight}; use sp_io::TestExternalities; - use primitives::H256; + use sp_core::H256; use sp_runtime::{Perbill, traits::{BlakeTwo256, IdentityLookup}, testing::Header}; impl_outer_origin! { - pub enum Origin for Test {} + pub enum Origin for Test where system = frame_system {} } #[derive(Clone, Eq, PartialEq)] @@ -257,7 +257,7 @@ mod tests { pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); } - impl system::Trait for Test { + impl frame_system::Trait for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; @@ -286,7 +286,7 @@ mod tests { #[test] fn timestamp_works() { - let t = system::GenesisConfig::default().build_storage::().unwrap(); + let t = frame_system::GenesisConfig::default().build_storage::().unwrap(); TestExternalities::new(t).execute_with(|| { Timestamp::set_timestamp(42); assert_ok!(Timestamp::dispatch(Call::set(69), Origin::NONE)); @@ -297,7 +297,7 @@ mod tests { #[test] #[should_panic(expected = "Timestamp must be updated only once in the block")] fn double_timestamp_should_fail() { - let t = system::GenesisConfig::default().build_storage::().unwrap(); + let t = frame_system::GenesisConfig::default().build_storage::().unwrap(); TestExternalities::new(t).execute_with(|| { Timestamp::set_timestamp(42); assert_ok!(Timestamp::dispatch(Call::set(69), Origin::NONE)); @@ -308,7 +308,7 @@ mod tests { #[test] #[should_panic(expected = "Timestamp must increment by at least between sequential blocks")] fn block_period_minimum_enforced() { - let t = system::GenesisConfig::default().build_storage::().unwrap(); + let t = frame_system::GenesisConfig::default().build_storage::().unwrap(); TestExternalities::new(t).execute_with(|| { Timestamp::set_timestamp(42); let _ = Timestamp::dispatch(Call::set(46), Origin::NONE); diff --git a/frame/transaction-payment/Cargo.toml b/frame/transaction-payment/Cargo.toml index e8c163fb34..379dfc8d65 100644 --- a/frame/transaction-payment/Cargo.toml +++ b/frame/transaction-payment/Cargo.toml @@ -8,14 +8,14 @@ edition = "2018" codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } 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 } -transaction-payment-rpc-runtime-api = { package = "pallet-transaction-payment-rpc-runtime-api", path = "./rpc/runtime-api", default-features = false } +frame-support = { path = "../support", default-features = false } +frame-system = { path = "../system", default-features = false } +pallet-transaction-payment-rpc-runtime-api = { path = "./rpc/runtime-api", default-features = false } [dev-dependencies] sp-io = { path = "../../primitives/io" } -primitives = { package = "sp-core", path = "../../primitives/core" } -balances = { package = "pallet-balances", path = "../balances" } +sp-core = { path = "../../primitives/core" } +pallet-balances = { path = "../balances" } [features] default = ["std"] @@ -23,7 +23,7 @@ std = [ "codec/std", "sp-std/std", "sp-runtime/std", - "support/std", - "system/std", - "transaction-payment-rpc-runtime-api/std" + "frame-support/std", + "frame-system/std", + "pallet-transaction-payment-rpc-runtime-api/std" ] diff --git a/frame/transaction-payment/rpc/Cargo.toml b/frame/transaction-payment/rpc/Cargo.toml index 71817ab05e..087333e80e 100644 --- a/frame/transaction-payment/rpc/Cargo.toml +++ b/frame/transaction-payment/rpc/Cargo.toml @@ -9,8 +9,8 @@ codec = { package = "parity-scale-codec", version = "1.0.0" } jsonrpc-core = "14.0.3" jsonrpc-core-client = "14.0.3" jsonrpc-derive = "14.0.3" -primitives = { package = "sp-core", path = "../../../primitives/core" } -rpc-primitives = { package = "sp-rpc", path = "../../../primitives/rpc" } +sp-core = { path = "../../../primitives/core" } +sp-rpc = { path = "../../../primitives/rpc" } serde = { version = "1.0.101", features = ["derive"] } sp-runtime = { path = "../../../primitives/runtime" } sp-blockchain = { path = "../../../primitives/blockchain" } diff --git a/frame/transaction-payment/rpc/runtime-api/Cargo.toml b/frame/transaction-payment/rpc/runtime-api/Cargo.toml index 076bd2afc7..b5f8c8e876 100644 --- a/frame/transaction-payment/rpc/runtime-api/Cargo.toml +++ b/frame/transaction-payment/rpc/runtime-api/Cargo.toml @@ -10,7 +10,7 @@ sp-api = { path = "../../../../primitives/api", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.6", default-features = false, features = ["derive"] } 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 } +frame-support = { path = "../../../support", default-features = false } [dev-dependencies] serde_json = "1.0.41" @@ -23,5 +23,5 @@ std = [ "codec/std", "sp-std/std", "sp-runtime/std", - "support/std", + "frame-support/std", ] diff --git a/frame/transaction-payment/rpc/runtime-api/src/lib.rs b/frame/transaction-payment/rpc/runtime-api/src/lib.rs index 8de2e847ac..ea2b7c2677 100644 --- a/frame/transaction-payment/rpc/runtime-api/src/lib.rs +++ b/frame/transaction-payment/rpc/runtime-api/src/lib.rs @@ -19,7 +19,7 @@ #![cfg_attr(not(feature = "std"), no_std)] use sp_std::prelude::*; -use support::weights::{Weight, DispatchClass}; +use frame_support::weights::{Weight, DispatchClass}; use codec::{Encode, Codec, Decode}; #[cfg(feature = "std")] use serde::{Serialize, Deserialize}; diff --git a/frame/transaction-payment/rpc/src/lib.rs b/frame/transaction-payment/rpc/src/lib.rs index 63a6b1827b..e7f4638113 100644 --- a/frame/transaction-payment/rpc/src/lib.rs +++ b/frame/transaction-payment/rpc/src/lib.rs @@ -25,7 +25,7 @@ use sp_runtime::{ generic::BlockId, traits::{Block as BlockT, ProvideRuntimeApi, UniqueSaturatedInto}, }; -use primitives::Bytes; +use sp_core::Bytes; use pallet_transaction_payment_rpc_runtime_api::CappedDispatchInfo; pub use pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi as TransactionPaymentRuntimeApi; pub use self::gen_client::Client as TransactionPaymentClient; diff --git a/frame/transaction-payment/src/lib.rs b/frame/transaction-payment/src/lib.rs index 6f35f79f14..562e7fe21f 100644 --- a/frame/transaction-payment/src/lib.rs +++ b/frame/transaction-payment/src/lib.rs @@ -33,7 +33,7 @@ use sp_std::prelude::*; use codec::{Encode, Decode}; -use support::{ +use frame_support::{ decl_storage, decl_module, traits::{Currency, Get, OnUnbalanced, ExistenceRequirement, WithdrawReason}, weights::{Weight, DispatchInfo, GetDispatchInfo}, @@ -46,15 +46,15 @@ use sp_runtime::{ }, traits::{Zero, Saturating, SignedExtension, SaturatedConversion, Convert}, }; -use transaction_payment_rpc_runtime_api::RuntimeDispatchInfo; +use pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo; type Multiplier = Fixed64; type BalanceOf = - <::Currency as Currency<::AccountId>>::Balance; + <::Currency as Currency<::AccountId>>::Balance; type NegativeImbalanceOf = - <::Currency as Currency<::AccountId>>::NegativeImbalance; + <::Currency as Currency<::AccountId>>::NegativeImbalance; -pub trait Trait: system::Trait { +pub trait Trait: frame_system::Trait { /// The currency type in which fees will be paid. type Currency: Currency + Send + Sync; @@ -163,7 +163,7 @@ impl ChargeTransactionPayment { let weight_fee = { // cap the weight to the maximum defined in runtime, otherwise it will be the `Bounded` // maximum of its data type, which is not desired. - let capped_weight = info.weight.min(::MaximumBlockWeight::get()); + let capped_weight = info.weight.min(::MaximumBlockWeight::get()); T::WeightToFee::convert(capped_weight) }; @@ -237,32 +237,33 @@ impl SignedExtension for ChargeTransactionPayment mod tests { use super::*; use codec::Encode; - use support::{ + use frame_support::{ parameter_types, impl_outer_origin, impl_outer_dispatch, weights::{DispatchClass, DispatchInfo, GetDispatchInfo, Weight}, }; - use primitives::H256; + use sp_core::H256; use sp_runtime::{ Perbill, testing::{Header, TestXt}, traits::{BlakeTwo256, IdentityLookup, Extrinsic}, }; - use balances::Call as BalancesCall; + use pallet_balances::Call as BalancesCall; use sp_std::cell::RefCell; - use transaction_payment_rpc_runtime_api::RuntimeDispatchInfo; + use pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo; - const CALL: &::Call = &Call::Balances(BalancesCall::transfer(2, 69)); + const CALL: &::Call = &Call::Balances(BalancesCall::transfer(2, 69)); impl_outer_dispatch! { pub enum Call for Runtime where origin: Origin { - balances::Balances, - system::System, + pallet_balances::Balances, + frame_system::System, } } #[derive(Clone, PartialEq, Eq, Debug)] pub struct Runtime; + use frame_system as system; impl_outer_origin!{ pub enum Origin for Runtime {} } @@ -274,7 +275,7 @@ mod tests { pub const AvailableBlockRatio: Perbill = Perbill::one(); } - impl system::Trait for Runtime { + impl frame_system::Trait for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = u64; @@ -298,7 +299,7 @@ mod tests { pub const ExistentialDeposit: u64 = 0; } - impl balances::Trait for Runtime { + impl pallet_balances::Trait for Runtime { type Balance = u64; type OnFreeBalanceZero = (); type OnNewAccount = (); @@ -334,7 +335,7 @@ mod tests { } impl Trait for Runtime { - type Currency = balances::Module; + type Currency = pallet_balances::Module; type OnTransactionPayment = (); type TransactionBaseFee = TransactionBaseFee; type TransactionByteFee = TransactionByteFee; @@ -342,8 +343,8 @@ mod tests { type FeeMultiplierUpdate = (); } - type Balances = balances::Module; - type System = system::Module; + type Balances = pallet_balances::Module; + type System = frame_system::Module; type TransactionPayment = Module; pub struct ExtBuilder { @@ -382,8 +383,8 @@ mod tests { } pub fn build(self) -> sp_io::TestExternalities { self.set_constants(); - let mut t = system::GenesisConfig::default().build_storage::().unwrap(); - balances::GenesisConfig:: { + let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + pallet_balances::GenesisConfig:: { balances: vec![ (1, 10 * self.balance_factor), (2, 20 * self.balance_factor), @@ -445,7 +446,7 @@ mod tests { // fee will be proportional to what is the actual maximum weight in the runtime. assert_eq!( Balances::free_balance(&1), - (10000 - ::MaximumBlockWeight::get()) as u64 + (10000 - ::MaximumBlockWeight::get()) as u64 ); }); } diff --git a/frame/treasury/Cargo.toml b/frame/treasury/Cargo.toml index 0f588e910e..bd79b4d038 100644 --- a/frame/treasury/Cargo.toml +++ b/frame/treasury/Cargo.toml @@ -9,13 +9,13 @@ serde = { version = "1.0.101", optional = true, features = ["derive"] } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } 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 } -balances = { package = "pallet-balances", path = "../balances", default-features = false } +frame-support = { path = "../support", default-features = false } +frame-system = { path = "../system", default-features = false } +pallet-balances = { path = "../balances", default-features = false } [dev-dependencies] sp-io ={ path = "../../primitives/io" } -primitives = { package = "sp-core", path = "../../primitives/core" } +sp-core = { path = "../../primitives/core" } [features] default = ["std"] @@ -24,7 +24,7 @@ std = [ "codec/std", "sp-std/std", "sp-runtime/std", - "support/std", - "system/std", - "balances/std", + "frame-support/std", + "frame-system/std", + "pallet-balances/std", ] diff --git a/frame/treasury/src/lib.rs b/frame/treasury/src/lib.rs index 92749d5eee..210761d87e 100644 --- a/frame/treasury/src/lib.rs +++ b/frame/treasury/src/lib.rs @@ -60,8 +60,8 @@ #[cfg(feature = "std")] use serde::{Serialize, Deserialize}; use sp_std::prelude::*; -use support::{decl_module, decl_storage, decl_event, ensure, print}; -use support::traits::{ +use frame_support::{decl_module, decl_storage, decl_event, ensure, print}; +use frame_support::traits::{ Currency, ExistenceRequirement, Get, Imbalance, OnUnbalanced, ReservableCurrency, WithdrawReason }; @@ -69,17 +69,17 @@ use sp_runtime::{Permill, ModuleId}; use sp_runtime::traits::{ Zero, EnsureOrigin, StaticLookup, AccountIdConversion, Saturating }; -use support::weights::SimpleDispatchInfo; +use frame_support::weights::SimpleDispatchInfo; use codec::{Encode, Decode}; -use system::ensure_signed; +use frame_system::{self as system, ensure_signed}; -type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; -type PositiveImbalanceOf = <::Currency as Currency<::AccountId>>::PositiveImbalance; -type NegativeImbalanceOf = <::Currency as Currency<::AccountId>>::NegativeImbalance; +type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; +type PositiveImbalanceOf = <::Currency as Currency<::AccountId>>::PositiveImbalance; +type NegativeImbalanceOf = <::Currency as Currency<::AccountId>>::NegativeImbalance; const MODULE_ID: ModuleId = ModuleId(*b"py/trsry"); -pub trait Trait: system::Trait { +pub trait Trait: frame_system::Trait { /// The staking balance. type Currency: Currency + ReservableCurrency; @@ -90,7 +90,7 @@ pub trait Trait: system::Trait { type RejectOrigin: EnsureOrigin; /// The overarching event type. - type Event: From> + Into<::Event>; + type Event: From> + Into<::Event>; /// Handler for the unbalanced decrease when slashing for a rejected proposal. type ProposalRejection: OnUnbalanced>; @@ -235,7 +235,7 @@ decl_event!( pub enum Event where Balance = BalanceOf, - ::AccountId + ::AccountId { /// New proposal. Proposed(ProposalIndex), @@ -351,14 +351,14 @@ impl OnUnbalanced> for Module { mod tests { use super::*; - use support::{assert_noop, assert_ok, impl_outer_origin, parameter_types, weights::Weight}; - use primitives::H256; + use frame_support::{assert_noop, assert_ok, impl_outer_origin, parameter_types, weights::Weight}; + use sp_core::H256; use sp_runtime::{ traits::{BlakeTwo256, OnFinalize, IdentityLookup}, testing::Header, Perbill }; impl_outer_origin! { - pub enum Origin for Test {} + pub enum Origin for Test where system = frame_system {} } #[derive(Clone, Eq, PartialEq)] @@ -369,7 +369,7 @@ mod tests { pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); } - impl system::Trait for Test { + impl frame_system::Trait for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; @@ -391,7 +391,7 @@ mod tests { pub const TransferFee: u64 = 0; pub const CreationFee: u64 = 0; } - impl balances::Trait for Test { + impl pallet_balances::Trait for Test { type Balance = u64; type OnNewAccount = (); type OnFreeBalanceZero = (); @@ -409,9 +409,9 @@ mod tests { pub const Burn: Permill = Permill::from_percent(50); } impl Trait for Test { - type Currency = balances::Module; - type ApproveOrigin = system::EnsureRoot; - type RejectOrigin = system::EnsureRoot; + type Currency = pallet_balances::Module; + type ApproveOrigin = frame_system::EnsureRoot; + type RejectOrigin = frame_system::EnsureRoot; type Event = (); type ProposalRejection = (); type ProposalBond = ProposalBond; @@ -419,12 +419,12 @@ mod tests { type SpendPeriod = SpendPeriod; type Burn = Burn; } - type Balances = balances::Module; + type Balances = pallet_balances::Module; type Treasury = Module; fn new_test_ext() -> sp_io::TestExternalities { - let mut t = system::GenesisConfig::default().build_storage::().unwrap(); - balances::GenesisConfig::{ + let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + pallet_balances::GenesisConfig::{ // Total issuance will be 200 with treasury account initialized at ED. balances: vec![(0, 100), (1, 98), (2, 1)], vesting: vec![], @@ -614,8 +614,8 @@ mod tests { // This is usefull for chain that will just update runtime. #[test] fn inexisting_account_works() { - let mut t = system::GenesisConfig::default().build_storage::().unwrap(); - balances::GenesisConfig::{ + let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + pallet_balances::GenesisConfig::{ balances: vec![(0, 100), (1, 99), (2, 1)], vesting: vec![], }.assimilate_storage(&mut t).unwrap(); diff --git a/frame/utility/Cargo.toml b/frame/utility/Cargo.toml index 3341fd50ec..e4bcd1f84b 100644 --- a/frame/utility/Cargo.toml +++ b/frame/utility/Cargo.toml @@ -7,15 +7,15 @@ edition = "2018" [dependencies] serde = { version = "1.0.101", optional = true } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } -support = { package = "frame-support", path = "../support", default-features = false } -system = { package = "frame-system", path = "../system", default-features = false } +frame-support = { path = "../support", default-features = false } +frame-system = { path = "../system", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } sp-std = { path = "../../primitives/std", default-features = false } sp-io = { path = "../../primitives/io", default-features = false } [dev-dependencies] -primitives = { package = "sp-core", path = "../../primitives/core" } -balances = { package = "pallet-balances", path = "../balances" } +sp-core = { path = "../../primitives/core" } +pallet-balances = { path = "../balances" } [features] default = ["std"] @@ -23,8 +23,8 @@ std = [ "serde", "codec/std", "sp-runtime/std", - "support/std", - "system/std", + "frame-support/std", + "frame-system/std", "sp-io/std", "sp-std/std" ] diff --git a/frame/utility/src/lib.rs b/frame/utility/src/lib.rs index 7639d0c77a..c5400b891e 100644 --- a/frame/utility/src/lib.rs +++ b/frame/utility/src/lib.rs @@ -21,14 +21,14 @@ #![cfg_attr(not(feature = "std"), no_std)] use sp_std::prelude::*; -use support::{decl_module, decl_event, Parameter, weights::SimpleDispatchInfo}; -use system::ensure_root; +use frame_support::{decl_module, decl_event, Parameter, weights::SimpleDispatchInfo}; +use frame_system::{self as system, ensure_root}; use sp_runtime::{traits::Dispatchable, DispatchError}; /// Configuration trait. -pub trait Trait: system::Trait { +pub trait Trait: frame_system::Trait { /// The overarching event type. - type Event: From + Into<::Event>; + type Event: From + Into<::Event>; /// The overarching call type. type Call: Parameter + Dispatchable; @@ -51,7 +51,7 @@ decl_module! { fn batch(origin, calls: Vec<::Call>) { ensure_root(origin)?; let results = calls.into_iter() - .map(|call| call.dispatch(system::RawOrigin::Root.into())) + .map(|call| call.dispatch(frame_system::RawOrigin::Root.into())) .map(|res| res.map_err(Into::into)) .collect::>(); Self::deposit_event(Event::BatchExecuted(results)); @@ -63,20 +63,20 @@ decl_module! { mod tests { use super::*; - use support::{ + use frame_support::{ assert_ok, assert_noop, impl_outer_origin, parameter_types, impl_outer_dispatch, weights::Weight }; - use primitives::H256; + use sp_core::H256; use sp_runtime::{Perbill, traits::{BlakeTwo256, IdentityLookup}, testing::Header}; impl_outer_origin! { - pub enum Origin for Test {} + pub enum Origin for Test where system = frame_system {} } impl_outer_dispatch! { pub enum Call for Test where origin: Origin { - balances::Balances, + pallet_balances::Balances, utility::Utility, } } @@ -92,7 +92,7 @@ mod tests { pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); } - impl system::Trait for Test { + impl frame_system::Trait for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; @@ -114,7 +114,7 @@ mod tests { pub const TransferFee: u64 = 0; pub const CreationFee: u64 = 0; } - impl balances::Trait for Test { + impl pallet_balances::Trait for Test { type Balance = u64; type OnFreeBalanceZero = (); type OnNewAccount = (); @@ -129,12 +129,12 @@ mod tests { type Event = (); type Call = Call; } - type Balances = balances::Module; + type Balances = pallet_balances::Module; type Utility = Module; fn new_test_ext() -> sp_io::TestExternalities { - let mut t = system::GenesisConfig::default().build_storage::().unwrap(); - balances::GenesisConfig:: { + let mut t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + pallet_balances::GenesisConfig:: { balances: vec![(1, 10), (2, 0)], vesting: vec![], }.assimilate_storage(&mut t).unwrap(); @@ -147,12 +147,12 @@ mod tests { assert_eq!(Balances::free_balance(1), 10); assert_eq!(Balances::free_balance(2), 0); assert_noop!(Utility::batch(Origin::signed(1), vec![ - Call::Balances(balances::Call::force_transfer(1, 2, 5)), - Call::Balances(balances::Call::force_transfer(1, 2, 5)) + Call::Balances(pallet_balances::Call::force_transfer(1, 2, 5)), + Call::Balances(pallet_balances::Call::force_transfer(1, 2, 5)) ]), "RequireRootOrigin"); assert_ok!(Utility::batch(Origin::ROOT, vec![ - Call::Balances(balances::Call::force_transfer(1, 2, 5)), - Call::Balances(balances::Call::force_transfer(1, 2, 5)) + Call::Balances(pallet_balances::Call::force_transfer(1, 2, 5)), + Call::Balances(pallet_balances::Call::force_transfer(1, 2, 5)) ])); assert_eq!(Balances::free_balance(1), 0); assert_eq!(Balances::free_balance(2), 10); diff --git a/primitives/api/Cargo.toml b/primitives/api/Cargo.toml index ef36a7b47a..0b3a1f2cf9 100644 --- a/primitives/api/Cargo.toml +++ b/primitives/api/Cargo.toml @@ -7,11 +7,11 @@ edition = "2018" [dependencies] codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } sp-api-proc-macro = { path = "proc-macro" } -primitives = { package = "sp-core", path = "../core", default-features = false } +sp-core = { path = "../core", default-features = false } sp-std = { path = "../std", default-features = false } sp-runtime = { path = "../runtime", default-features = false } sp-version = { path = "../version", default-features = false } -state-machine = { package = "sp-state-machine", path = "../../primitives/state-machine", optional = true } +sp-state-machine = { path = "../../primitives/state-machine", optional = true } [dev-dependencies] sp-test-primitives = { path = "../test-primitives" } @@ -20,9 +20,9 @@ sp-test-primitives = { path = "../test-primitives" } default = [ "std" ] std = [ "codec/std", - "primitives/std", + "sp-core/std", "sp-std/std", "sp-runtime/std", - "state-machine", + "sp-state-machine", "sp-version/std", ] diff --git a/primitives/api/src/lib.rs b/primitives/api/src/lib.rs index 7d1f91e339..b655cf0939 100644 --- a/primitives/api/src/lib.rs +++ b/primitives/api/src/lib.rs @@ -35,13 +35,13 @@ extern crate self as sp_api; #[doc(hidden)] #[cfg(feature = "std")] -pub use state_machine::{OverlayedChanges, StorageProof}; +pub use sp_state_machine::{OverlayedChanges, StorageProof}; #[doc(hidden)] #[cfg(feature = "std")] -pub use primitives::NativeOrEncoded; +pub use sp_core::NativeOrEncoded; #[doc(hidden)] #[cfg(not(feature = "std"))] -pub use primitives::to_substrate_wasm_fn_return_value; +pub use sp_core::to_substrate_wasm_fn_return_value; #[doc(hidden)] pub use sp_runtime::{ traits::{ @@ -51,7 +51,7 @@ pub use sp_runtime::{ generic::BlockId, transaction_validity::TransactionValidity, }; #[doc(hidden)] -pub use primitives::{offchain, ExecutionContext}; +pub use sp_core::{offchain, ExecutionContext}; #[doc(hidden)] pub use sp_version::{ApiId, RuntimeVersion, ApisVec, create_apis_vec}; #[doc(hidden)] @@ -60,7 +60,7 @@ pub use sp_std::{slice, mem}; use sp_std::result; #[doc(hidden)] pub use codec::{Encode, Decode}; -use primitives::OpaqueMetadata; +use sp_core::OpaqueMetadata; #[cfg(feature = "std")] use std::{panic::UnwindSafe, cell::RefCell}; @@ -223,7 +223,7 @@ pub use sp_api_proc_macro::impl_runtime_apis; #[cfg(feature = "std")] /// A type that records all accessed trie nodes and generates a proof out of it. -pub type ProofRecorder = state_machine::ProofRecorder< +pub type ProofRecorder = sp_state_machine::ProofRecorder< <<::Header as HeaderT>::Hashing as HashT>::Hasher >; diff --git a/primitives/api/test/Cargo.toml b/primitives/api/test/Cargo.toml index 497790f2d6..8fdfcc98f1 100644 --- a/primitives/api/test/Cargo.toml +++ b/primitives/api/test/Cargo.toml @@ -6,19 +6,19 @@ edition = "2018" [dependencies] sp-api = { path = "../" } -test-client = { package = "substrate-test-runtime-client", path = "../../../test-utils/runtime/client" } +substrate-test-runtime-client = { path = "../../../test-utils/runtime/client" } sp-version = { path = "../../version" } sp-runtime = { path = "../../runtime" } sp-blockchain = { path = "../../blockchain" } -consensus_common = { package = "sp-consensus", path = "../../../primitives/consensus/common" } +sp-consensus = { path = "../../../primitives/consensus/common" } codec = { package = "parity-scale-codec", version = "1.0.0" } -state-machine = { package = "sp-state-machine", path = "../../../primitives/state-machine" } +sp-state-machine = { path = "../../../primitives/state-machine" } trybuild = "1.0.17" rustversion = "1.0.0" [dev-dependencies] criterion = "0.3.0" -test-client = { package = "substrate-test-runtime-client", path = "../../../test-utils/runtime/client" } +substrate-test-runtime-client = { path = "../../../test-utils/runtime/client" } [[bench]] name = "bench" diff --git a/primitives/api/test/benches/bench.rs b/primitives/api/test/benches/bench.rs index 59bac57f13..9b41834097 100644 --- a/primitives/api/test/benches/bench.rs +++ b/primitives/api/test/benches/bench.rs @@ -15,16 +15,16 @@ // along with Substrate. If not, see . use criterion::{Criterion, criterion_group, criterion_main}; -use test_client::{ +use substrate_test_runtime_client::{ DefaultTestClientBuilderExt, TestClientBuilder, TestClientBuilderExt, runtime::TestAPI, }; use sp_runtime::{generic::BlockId, traits::ProvideRuntimeApi}; -use state_machine::ExecutionStrategy; +use sp_state_machine::ExecutionStrategy; fn sp_api_benchmark(c: &mut Criterion) { c.bench_function("add one with same runtime api", |b| { - let client = test_client::new(); + let client = substrate_test_runtime_client::new(); let runtime_api = client.runtime_api(); let block_id = BlockId::Number(client.info().chain.best_number); @@ -32,14 +32,14 @@ fn sp_api_benchmark(c: &mut Criterion) { }); c.bench_function("add one with recreating runtime api", |b| { - let client = test_client::new(); + let client = substrate_test_runtime_client::new(); let block_id = BlockId::Number(client.info().chain.best_number); b.iter(|| client.runtime_api().benchmark_add_one(&block_id, &1)) }); c.bench_function("vector add one with same runtime api", |b| { - let client = test_client::new(); + let client = substrate_test_runtime_client::new(); let runtime_api = client.runtime_api(); let block_id = BlockId::Number(client.info().chain.best_number); let data = vec![0; 1000]; @@ -48,7 +48,7 @@ fn sp_api_benchmark(c: &mut Criterion) { }); c.bench_function("vector add one with recreating runtime api", |b| { - let client = test_client::new(); + let client = substrate_test_runtime_client::new(); let block_id = BlockId::Number(client.info().chain.best_number); let data = vec![0; 1000]; diff --git a/primitives/api/test/tests/decl_and_impl.rs b/primitives/api/test/tests/decl_and_impl.rs index d52b5b4070..b25c8c2710 100644 --- a/primitives/api/test/tests/decl_and_impl.rs +++ b/primitives/api/test/tests/decl_and_impl.rs @@ -18,7 +18,7 @@ use sp_api::{RuntimeApiInfo, decl_runtime_apis, impl_runtime_apis}; use sp_runtime::{traits::{GetNodeBlockType, Block as BlockT}, generic::BlockId}; -use test_client::runtime::Block; +use substrate_test_runtime_client::runtime::Block; use sp_blockchain::Result; /// The declaration of the `Runtime` type and the implementation of the `GetNodeBlockType` @@ -81,8 +81,11 @@ impl_runtime_apis! { } } -type TestClient = test_client::client::Client< - test_client::Backend, test_client::Executor, Block, RuntimeApi +type TestClient = substrate_test_runtime_client::sc_client::Client< + substrate_test_runtime_client::Backend, + substrate_test_runtime_client::Executor, + Block, + RuntimeApi, >; #[test] diff --git a/primitives/api/test/tests/runtime_calls.rs b/primitives/api/test/tests/runtime_calls.rs index 3b09d67a2c..34184c936a 100644 --- a/primitives/api/test/tests/runtime_calls.rs +++ b/primitives/api/test/tests/runtime_calls.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Substrate. If not, see . -use test_client::{ +use substrate_test_runtime_client::{ prelude::*, DefaultTestClientBuilderExt, TestClientBuilder, runtime::{TestAPI, DecodeFails, Transfer, Header}, @@ -23,12 +23,12 @@ use sp_runtime::{ generic::BlockId, traits::{ProvideRuntimeApi, Header as HeaderT, Hash as HashT}, }; -use state_machine::{ +use sp_state_machine::{ ExecutionStrategy, create_proof_check_backend, execution_proof_check_on_trie_backend, }; -use consensus_common::SelectChain; +use sp_consensus::SelectChain; use codec::Encode; fn calling_function_with_strat(strat: ExecutionStrategy) { diff --git a/primitives/api/test/tests/ui/changed_in_unknown_version.rs b/primitives/api/test/tests/ui/changed_in_unknown_version.rs index 818b504860..151f3e5f4d 100644 --- a/primitives/api/test/tests/ui/changed_in_unknown_version.rs +++ b/primitives/api/test/tests/ui/changed_in_unknown_version.rs @@ -1,5 +1,5 @@ use sp_runtime::traits::GetNodeBlockType; -use test_client::runtime::Block; +use substrate_test_runtime_client::runtime::Block; /// The declaration of the `Runtime` type and the implementation of the `GetNodeBlockType` /// trait are done by the `construct_runtime!` macro in a real runtime. diff --git a/primitives/api/test/tests/ui/empty_impl_runtime_apis_call.rs b/primitives/api/test/tests/ui/empty_impl_runtime_apis_call.rs index 6275979de2..93343fb72a 100644 --- a/primitives/api/test/tests/ui/empty_impl_runtime_apis_call.rs +++ b/primitives/api/test/tests/ui/empty_impl_runtime_apis_call.rs @@ -1,5 +1,5 @@ use sp_runtime::traits::GetNodeBlockType; -use test_client::runtime::Block; +use substrate_test_runtime_client::runtime::Block; /// The declaration of the `Runtime` type and the implementation of the `GetNodeBlockType` /// trait are done by the `construct_runtime!` macro in a real runtime. diff --git a/primitives/api/test/tests/ui/impl_incorrect_method_signature.rs b/primitives/api/test/tests/ui/impl_incorrect_method_signature.rs index cdc1dacb6a..e4eba99d9e 100644 --- a/primitives/api/test/tests/ui/impl_incorrect_method_signature.rs +++ b/primitives/api/test/tests/ui/impl_incorrect_method_signature.rs @@ -1,5 +1,5 @@ use sp_runtime::traits::{GetNodeBlockType, Block as BlockT}; -use test_client::runtime::Block; +use substrate_test_runtime_client::runtime::Block; /// The declaration of the `Runtime` type and the implementation of the `GetNodeBlockType` /// trait are done by the `construct_runtime!` macro in a real runtime. diff --git a/primitives/api/test/tests/ui/impl_two_traits_with_same_name.rs b/primitives/api/test/tests/ui/impl_two_traits_with_same_name.rs index 4c3ee6b27d..9c01dc0e92 100644 --- a/primitives/api/test/tests/ui/impl_two_traits_with_same_name.rs +++ b/primitives/api/test/tests/ui/impl_two_traits_with_same_name.rs @@ -1,5 +1,5 @@ use sp_runtime::traits::GetNodeBlockType; -use test_client::runtime::Block; +use substrate_test_runtime_client::runtime::Block; /// The declaration of the `Runtime` type and the implementation of the `GetNodeBlockType` /// trait are done by the `construct_runtime!` macro in a real runtime. diff --git a/primitives/api/test/tests/ui/missing_block_generic_parameter.rs b/primitives/api/test/tests/ui/missing_block_generic_parameter.rs index 4639ae328c..e194fdbf4a 100644 --- a/primitives/api/test/tests/ui/missing_block_generic_parameter.rs +++ b/primitives/api/test/tests/ui/missing_block_generic_parameter.rs @@ -1,5 +1,5 @@ use sp_runtime::traits::GetNodeBlockType; -use test_client::runtime::Block; +use substrate_test_runtime_client::runtime::Block; /// The declaration of the `Runtime` type and the implementation of the `GetNodeBlockType` /// trait are done by the `construct_runtime!` macro in a real runtime. diff --git a/primitives/api/test/tests/ui/missing_path_for_trait.rs b/primitives/api/test/tests/ui/missing_path_for_trait.rs index d90756ce1b..d7540ce88a 100644 --- a/primitives/api/test/tests/ui/missing_path_for_trait.rs +++ b/primitives/api/test/tests/ui/missing_path_for_trait.rs @@ -1,5 +1,5 @@ use sp_runtime::traits::GetNodeBlockType; -use test_client::runtime::Block; +use substrate_test_runtime_client::runtime::Block; /// The declaration of the `Runtime` type and the implementation of the `GetNodeBlockType` /// trait are done by the `construct_runtime!` macro in a real runtime. diff --git a/primitives/api/test/tests/ui/type_reference_in_impl_runtime_apis_call.rs b/primitives/api/test/tests/ui/type_reference_in_impl_runtime_apis_call.rs index 809444cb30..f45f0844c6 100644 --- a/primitives/api/test/tests/ui/type_reference_in_impl_runtime_apis_call.rs +++ b/primitives/api/test/tests/ui/type_reference_in_impl_runtime_apis_call.rs @@ -1,5 +1,5 @@ use sp_runtime::traits::{GetNodeBlockType, Block as BlockT}; -use test_client::runtime::Block; +use substrate_test_runtime_client::runtime::Block; /// The declaration of the `Runtime` type and the implementation of the `GetNodeBlockType` /// trait are done by the `construct_runtime!` macro in a real runtime. diff --git a/primitives/application-crypto/Cargo.toml b/primitives/application-crypto/Cargo.toml index 79b3f35f6b..549c0a5891 100644 --- a/primitives/application-crypto/Cargo.toml +++ b/primitives/application-crypto/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" description = "Provides facilities for generating application specific crypto wrapper types." [dependencies] -primitives = { package = "sp-core", path = "../core", default-features = false } +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 } @@ -14,11 +14,11 @@ sp-io = { path = "../../primitives/io", default-features = false } [features] default = [ "std" ] -std = [ "full_crypto", "primitives/std", "codec/std", "serde", "sp-std/std", "sp-io/std" ] +std = [ "full_crypto", "sp-core/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. # For the regular wasm runtime builds this should not be used. full_crypto = [ - "primitives/full_crypto" + "sp-core/full_crypto" ] diff --git a/primitives/application-crypto/src/ed25519.rs b/primitives/application-crypto/src/ed25519.rs index 2ac94ac423..14796a4b55 100644 --- a/primitives/application-crypto/src/ed25519.rs +++ b/primitives/application-crypto/src/ed25519.rs @@ -20,10 +20,10 @@ use crate::{RuntimePublic, KeyTypeId}; use sp_std::vec::Vec; -pub use primitives::ed25519::*; +pub use sp_core::ed25519::*; mod app { - use primitives::testing::ED25519; + use sp_core::testing::ED25519; crate::app_crypto!(super, ED25519); impl crate::traits::BoundToRuntimeAppPublic for Public { diff --git a/primitives/application-crypto/src/lib.rs b/primitives/application-crypto/src/lib.rs index 12972b4707..0d8df56535 100644 --- a/primitives/application-crypto/src/lib.rs +++ b/primitives/application-crypto/src/lib.rs @@ -21,11 +21,11 @@ #![cfg_attr(not(feature = "std"), no_std)] #[doc(hidden)] -pub use primitives::{self, crypto::{CryptoType, Public, Derive, IsWrappedBy, Wraps}, RuntimeDebug}; +pub use sp_core::{self, crypto::{CryptoType, Public, Derive, IsWrappedBy, Wraps}, RuntimeDebug}; #[doc(hidden)] #[cfg(feature = "full_crypto")] -pub use primitives::crypto::{SecretStringError, DeriveJunction, Ss58Codec, Pair}; -pub use primitives::{crypto::{KeyTypeId, key_types}}; +pub use sp_core::crypto::{SecretStringError, DeriveJunction, Ss58Codec, Pair}; +pub use sp_core::{crypto::{KeyTypeId, key_types}}; #[doc(hidden)] pub use codec; diff --git a/primitives/application-crypto/src/sr25519.rs b/primitives/application-crypto/src/sr25519.rs index d49fc46cc2..f3d2a84843 100644 --- a/primitives/application-crypto/src/sr25519.rs +++ b/primitives/application-crypto/src/sr25519.rs @@ -20,10 +20,10 @@ use crate::{RuntimePublic, KeyTypeId}; use sp_std::vec::Vec; -pub use primitives::sr25519::*; +pub use sp_core::sr25519::*; mod app { - use primitives::testing::SR25519; + use sp_core::testing::SR25519; crate::app_crypto!(super, SR25519); impl crate::traits::BoundToRuntimeAppPublic for Public { diff --git a/primitives/application-crypto/src/traits.rs b/primitives/application-crypto/src/traits.rs index 741bbc48c9..917ec3b0e9 100644 --- a/primitives/application-crypto/src/traits.rs +++ b/primitives/application-crypto/src/traits.rs @@ -15,10 +15,10 @@ // along with Substrate. If not, see . #[cfg(feature = "full_crypto")] -use primitives::crypto::Pair; +use sp_core::crypto::Pair; use codec::Codec; -use primitives::crypto::{KeyTypeId, CryptoType, IsWrappedBy, Public}; +use sp_core::crypto::{KeyTypeId, CryptoType, IsWrappedBy, Public}; use sp_std::{fmt::Debug, vec::Vec}; /// An application-specific key. diff --git a/primitives/application-crypto/test/Cargo.toml b/primitives/application-crypto/test/Cargo.toml index 2a599e9638..85cb5d1163 100644 --- a/primitives/application-crypto/test/Cargo.toml +++ b/primitives/application-crypto/test/Cargo.toml @@ -7,6 +7,7 @@ description = "Integration tests for application-crypto" publish = false [dependencies] -primitives = { package = "sp-core", path = "../../core", default-features = false } -test-client = { package = "substrate-test-runtime-client", path = "../../../test-utils/runtime/client" } -sp-runtime = { path = "../../runtime" } \ No newline at end of file +sp-core = { path = "../../core", default-features = false } +substrate-test-runtime-client = { path = "../../../test-utils/runtime/client" } +sp-runtime = { path = "../../runtime" } +sp-application-crypto = { path = "../" } diff --git a/primitives/application-crypto/test/src/ed25519.rs b/primitives/application-crypto/test/src/ed25519.rs index 0e66e5b3ff..40f318509e 100644 --- a/primitives/application-crypto/test/src/ed25519.rs +++ b/primitives/application-crypto/test/src/ed25519.rs @@ -17,11 +17,12 @@ //! Integration tests for ed25519 use sp_runtime::{generic::BlockId, traits::ProvideRuntimeApi}; -use primitives::{testing::{KeyStore, ED25519}, crypto::Pair}; -use test_client::{ +use sp_core::{testing::{KeyStore, ED25519}, crypto::Pair}; +use substrate_test_runtime_client::{ TestClientBuilder, DefaultTestClientBuilderExt, TestClientBuilderExt, - runtime::{TestAPI, app_crypto::ed25519::{AppPair, AppPublic}}, + runtime::TestAPI, }; +use sp_application_crypto::ed25519::{AppPair, AppPublic}; #[test] fn ed25519_works_in_runtime() { @@ -35,4 +36,4 @@ fn ed25519_works_in_runtime() { .expect("There should be at a `ed25519` key in the keystore for the given public key."); assert!(AppPair::verify(&signature, "ed25519", &AppPublic::from(key_pair.public()))); -} \ No newline at end of file +} diff --git a/primitives/application-crypto/test/src/sr25519.rs b/primitives/application-crypto/test/src/sr25519.rs index 50981f4677..f0bc3e09b2 100644 --- a/primitives/application-crypto/test/src/sr25519.rs +++ b/primitives/application-crypto/test/src/sr25519.rs @@ -18,11 +18,12 @@ use sp_runtime::{generic::BlockId, traits::ProvideRuntimeApi}; -use primitives::{testing::{KeyStore, SR25519}, crypto::Pair}; -use test_client::{ +use sp_core::{testing::{KeyStore, SR25519}, crypto::Pair}; +use substrate_test_runtime_client::{ TestClientBuilder, DefaultTestClientBuilderExt, TestClientBuilderExt, - runtime::{TestAPI, app_crypto::sr25519::{AppPair, AppPublic}}, + runtime::TestAPI, }; +use sp_application_crypto::sr25519::{AppPair, AppPublic}; #[test] fn sr25519_works_in_runtime() { @@ -36,4 +37,4 @@ fn sr25519_works_in_runtime() { .expect("There should be at a `sr25519` key in the keystore for the given public key."); assert!(AppPair::verify(&signature, "sr25519", &AppPublic::from(key_pair.public()))); -} \ No newline at end of file +} diff --git a/primitives/authority-discovery/Cargo.toml b/primitives/authority-discovery/Cargo.toml index aa8fa926ca..241891a48b 100644 --- a/primitives/authority-discovery/Cargo.toml +++ b/primitives/authority-discovery/Cargo.toml @@ -6,7 +6,7 @@ description = "Authority discovery primitives" edition = "2018" [dependencies] -app-crypto = { package = "sp-application-crypto", path = "../application-crypto", default-features = false } +sp-application-crypto = { path = "../application-crypto", default-features = false } codec = { package = "parity-scale-codec", default-features = false, version = "1.0.3" } sp-std = { path = "../std", default-features = false } sp-api = { path = "../api", default-features = false } @@ -15,7 +15,7 @@ sp-runtime = { path = "../runtime", default-features = false } [features] default = ["std"] std = [ - "app-crypto/std", + "sp-application-crypto/std", "codec/std", "sp-std/std", "sp-api/std", diff --git a/primitives/authority-discovery/src/lib.rs b/primitives/authority-discovery/src/lib.rs index b208727148..41ad384f91 100644 --- a/primitives/authority-discovery/src/lib.rs +++ b/primitives/authority-discovery/src/lib.rs @@ -21,7 +21,7 @@ use sp_std::vec::Vec; mod app { - use app_crypto::{app_crypto, key_types::AUTHORITY_DISCOVERY, sr25519}; + use sp_application_crypto::{app_crypto, key_types::AUTHORITY_DISCOVERY, sr25519}; app_crypto!(sr25519, AUTHORITY_DISCOVERY); } diff --git a/primitives/block-builder/Cargo.toml b/primitives/block-builder/Cargo.toml index c454a1516d..41bedb2fa5 100644 --- a/primitives/block-builder/Cargo.toml +++ b/primitives/block-builder/Cargo.toml @@ -9,14 +9,14 @@ sp-runtime = { path = "../runtime", default-features = false } sp-api = { path = "../api", default-features = false } sp-std = { path = "../std", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.6", default-features = false } -inherents = { package = "sp-inherents", path = "../inherents", default-features = false } +sp-inherents = { path = "../inherents", default-features = false } [features] default = [ "std" ] std = [ "sp-runtime/std", "codec/std", - "inherents/std", + "sp-inherents/std", "sp-api/std", "sp-std/std", ] diff --git a/primitives/block-builder/src/lib.rs b/primitives/block-builder/src/lib.rs index 3b0a615ae5..95f187da9a 100644 --- a/primitives/block-builder/src/lib.rs +++ b/primitives/block-builder/src/lib.rs @@ -20,7 +20,7 @@ use sp_runtime::{traits::Block as BlockT, ApplyExtrinsicResult}; -use inherents::{InherentData, CheckInherentsResult}; +use sp_inherents::{InherentData, CheckInherentsResult}; /// Definitions for supporting the older version of API: v3 /// diff --git a/primitives/blockchain/Cargo.toml b/primitives/blockchain/Cargo.toml index 598af8153e..9326ad6e0b 100644 --- a/primitives/blockchain/Cargo.toml +++ b/primitives/blockchain/Cargo.toml @@ -9,8 +9,8 @@ log = "0.4.8" lru = "0.4.0" parking_lot = "0.9.0" derive_more = "0.99.2" -parity-scale-codec = { version = "1.0.0", default-features = false, features = ["derive"] } -sp_consensus = { package = "sp-consensus", path = "../consensus/common" } +codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } +sp-consensus = { path = "../consensus/common" } sp-runtime = { path = "../runtime" } -sp-block-builder-runtime-api = { package = "sp-block-builder", path = "../block-builder" } -sp-state-machine = { package = "sp-state-machine", path = "../state-machine" } +sp-block-builder = { path = "../block-builder" } +sp-state-machine = { path = "../state-machine" } diff --git a/primitives/blockchain/src/error.rs b/primitives/blockchain/src/error.rs index 68a916b7d8..ec60533a50 100644 --- a/primitives/blockchain/src/error.rs +++ b/primitives/blockchain/src/error.rs @@ -20,10 +20,10 @@ use std::{self, error, result}; use sp_state_machine; use sp_runtime::transaction_validity::TransactionValidityError; #[allow(deprecated)] -use sp_block_builder_runtime_api::compatability_v3; +use sp_block_builder::compatability_v3; use sp_consensus; use derive_more::{Display, From}; -use parity_scale_codec::Error as CodecError; +use codec::Error as CodecError; /// Client Result type alias pub type Result = result::Result; diff --git a/primitives/consensus/aura/Cargo.toml b/primitives/consensus/aura/Cargo.toml index 2a46cf015c..c84a943779 100644 --- a/primitives/consensus/aura/Cargo.toml +++ b/primitives/consensus/aura/Cargo.toml @@ -6,22 +6,22 @@ description = "Primitives for Aura consensus" edition = "2018" [dependencies] -app-crypto = { package = "sp-application-crypto", path = "../../application-crypto", default-features = false } +sp-application-crypto = { path = "../../application-crypto", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } sp-std = { path = "../../std", default-features = false } sp-api = { path = "../../api", default-features = false } sp-runtime = { path = "../../runtime", default-features = false } -inherents = { package = "sp-inherents", path = "../../inherents", default-features = false } +sp-inherents = { path = "../../inherents", default-features = false } sp-timestamp = { path = "../../timestamp", default-features = false } [features] default = ["std"] std = [ - "app-crypto/std", + "sp-application-crypto/std", "codec/std", "sp-std/std", "sp-api/std", "sp-runtime/std", - "inherents/std", + "sp-inherents/std", "sp-timestamp/std", ] diff --git a/primitives/consensus/aura/src/inherents.rs b/primitives/consensus/aura/src/inherents.rs index 9a7c7c0c5b..566ed6ccc4 100644 --- a/primitives/consensus/aura/src/inherents.rs +++ b/primitives/consensus/aura/src/inherents.rs @@ -16,10 +16,10 @@ /// Contains the inherents for the AURA module -use inherents::{InherentIdentifier, InherentData, Error}; +use sp_inherents::{InherentIdentifier, InherentData, Error}; #[cfg(feature = "std")] -use inherents::{InherentDataProviders, ProvideInherentData}; +use sp_inherents::{InherentDataProviders, ProvideInherentData}; /// The Aura inherent identifier. pub const INHERENT_IDENTIFIER: InherentIdentifier = *b"auraslot"; @@ -93,6 +93,6 @@ impl ProvideInherentData for InherentDataProvider { fn error_to_string(&self, error: &[u8]) -> Option { use codec::Decode; - inherents::Error::decode(&mut &error[..]).map(|e| e.into_string()).ok() + sp_inherents::Error::decode(&mut &error[..]).map(|e| e.into_string()).ok() } } diff --git a/primitives/consensus/aura/src/lib.rs b/primitives/consensus/aura/src/lib.rs index 1ed1da96ec..770ed47319 100644 --- a/primitives/consensus/aura/src/lib.rs +++ b/primitives/consensus/aura/src/lib.rs @@ -26,7 +26,7 @@ pub mod inherents; pub mod sr25519 { mod app_sr25519 { - use app_crypto::{app_crypto, key_types::AURA, sr25519}; + use sp_application_crypto::{app_crypto, key_types::AURA, sr25519}; app_crypto!(sr25519, AURA); } @@ -43,7 +43,7 @@ pub mod sr25519 { pub mod ed25519 { mod app_ed25519 { - use app_crypto::{app_crypto, key_types::AURA, ed25519}; + use sp_application_crypto::{app_crypto, key_types::AURA, ed25519}; app_crypto!(ed25519, AURA); } diff --git a/primitives/consensus/babe/Cargo.toml b/primitives/consensus/babe/Cargo.toml index 0889f6f639..f994c69671 100644 --- a/primitives/consensus/babe/Cargo.toml +++ b/primitives/consensus/babe/Cargo.toml @@ -6,20 +6,20 @@ description = "Primitives for BABE consensus" edition = "2018" [dependencies] -app-crypto = { package = "sp-application-crypto", path = "../../application-crypto", default-features = false } +sp-application-crypto = { path = "../../application-crypto", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } sp-std = { path = "../../std", default-features = false } schnorrkel = { version = "0.8.5", features = ["preaudit_deprecated"], optional = true } sp-api = { path = "../../api", default-features = false } sp-consensus = { path = "../common", optional = true } -sp-inherents = { package = "sp-inherents", path = "../../inherents", default-features = false } +sp-inherents = { path = "../../inherents", default-features = false } sp-runtime = { path = "../../runtime", default-features = false } sp-timestamp = { path = "../../timestamp", default-features = false } [features] default = ["std"] std = [ - "app-crypto/std", + "sp-application-crypto/std", "codec/std", "sp-std/std", "schnorrkel", diff --git a/primitives/consensus/babe/src/lib.rs b/primitives/consensus/babe/src/lib.rs index 90e8855b57..196f1be1a6 100644 --- a/primitives/consensus/babe/src/lib.rs +++ b/primitives/consensus/babe/src/lib.rs @@ -31,7 +31,7 @@ pub use digest::{BabePreDigest, CompatibleDigestItem}; pub use digest::{BABE_VRF_PREFIX, RawBabePreDigest, NextEpochDescriptor}; mod app { - use app_crypto::{app_crypto, key_types::BABE, sr25519}; + use sp_application_crypto::{app_crypto, key_types::BABE, sr25519}; app_crypto!(sr25519, BABE); } diff --git a/primitives/consensus/common/Cargo.toml b/primitives/consensus/common/Cargo.toml index 17aec7bca2..9fde4e3df9 100644 --- a/primitives/consensus/common/Cargo.toml +++ b/primitives/consensus/common/Cargo.toml @@ -9,12 +9,12 @@ edition = "2018" derive_more = "0.99.2" libp2p = { version = "0.13.0", default-features = false } log = "0.4.8" -primitives = { package = "sp-core", path= "../../core" } -inherents = { package = "sp-inherents", path = "../../inherents" } +sp-core = { path= "../../core" } +sp-inherents = { path = "../../inherents" } futures = { version = "0.3.1", features = ["thread-pool"] } futures-timer = "0.4.0" sp-std = { path = "../../std" } -runtime_version = { package = "sp-version", path = "../../version" } +sp-version = { path = "../../version" } sp-runtime = { path = "../../runtime" } codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } parking_lot = "0.9.0" diff --git a/primitives/consensus/common/src/error.rs b/primitives/consensus/common/src/error.rs index 0455a553cc..29e9a3ee92 100644 --- a/primitives/consensus/common/src/error.rs +++ b/primitives/consensus/common/src/error.rs @@ -15,8 +15,8 @@ // along with Substrate. If not, see . //! Error types in Consensus -use runtime_version::RuntimeVersion; -use primitives::ed25519::{Public, Signature}; +use sp_version::RuntimeVersion; +use sp_core::ed25519::{Public, Signature}; use std::error; /// Result type alias. @@ -36,7 +36,7 @@ pub enum Error { FaultyTimer(std::io::Error), /// Error while working with inherent data. #[display(fmt="InherentData error: {}", _0)] - InherentData(inherents::Error), + InherentData(sp_inherents::Error), /// Unable to propose a block. #[display(fmt="Unable to create block proposal.")] CannotPropose, diff --git a/primitives/consensus/common/src/lib.rs b/primitives/consensus/common/src/lib.rs index cc5d0105ad..413f541340 100644 --- a/primitives/consensus/common/src/lib.rs +++ b/primitives/consensus/common/src/lib.rs @@ -33,7 +33,7 @@ use std::time::Duration; use sp_runtime::{traits::{Block as BlockT, DigestFor}, generic::BlockId}; use futures::prelude::*; -pub use inherents::InherentData; +pub use sp_inherents::InherentData; pub mod block_validation; pub mod offline_tracker; @@ -146,7 +146,7 @@ pub trait CanAuthorWith { } /// Checks if the node can author blocks by using -/// [`NativeVersion::can_author_with`](runtime_version::NativeVersion::can_author_with). +/// [`NativeVersion::can_author_with`](sp_version::NativeVersion::can_author_with). pub struct CanAuthorWithNativeVersion(T); impl CanAuthorWithNativeVersion { @@ -156,7 +156,7 @@ impl CanAuthorWithNativeVersion { } } -impl, Block: BlockT> CanAuthorWith +impl, Block: BlockT> CanAuthorWith for CanAuthorWithNativeVersion { fn can_author_with(&self, at: &BlockId) -> Result<(), String> { diff --git a/primitives/consensus/pow/Cargo.toml b/primitives/consensus/pow/Cargo.toml index 0baff76a9b..73efe40ec5 100644 --- a/primitives/consensus/pow/Cargo.toml +++ b/primitives/consensus/pow/Cargo.toml @@ -9,7 +9,7 @@ edition = "2018" sp-api = { path = "../../api", default-features = false } sp-std = { path = "../../std", default-features = false } sp-runtime = { path = "../../runtime", default-features = false } -primitives = { package = "sp-core", path = "../../core", default-features = false } +sp-core = { path = "../../core", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } [features] @@ -18,6 +18,6 @@ std = [ "sp-std/std", "sp-api/std", "sp-runtime/std", - "primitives/std", + "sp-core/std", "codec/std", ] diff --git a/primitives/consensus/pow/src/lib.rs b/primitives/consensus/pow/src/lib.rs index 005e2f5325..6a1c1179ed 100644 --- a/primitives/consensus/pow/src/lib.rs +++ b/primitives/consensus/pow/src/lib.rs @@ -33,7 +33,7 @@ pub trait TotalDifficulty { fn increment(&mut self, other: Self); } -impl TotalDifficulty for primitives::U256 { +impl TotalDifficulty for sp_core::U256 { fn increment(&mut self, other: Self) { let ret = self.saturating_add(other); *self = ret; diff --git a/primitives/core/Cargo.toml b/primitives/core/Cargo.toml index bde9d37ee0..d9e4619fa1 100644 --- a/primitives/core/Cargo.toml +++ b/primitives/core/Cargo.toml @@ -26,8 +26,8 @@ zeroize = { version = "1.0.0", default-features = false } lazy_static = { version = "1.4.0", default-features = false, optional = true } parking_lot = { version = "0.9.0", optional = true } sp-debug-derive = { version = "2.0.0", path = "../debug-derive" } -externalities = { package = "sp-externalities", path = "../externalities", optional = true } -primitives-storage = { package = "sp-storage", path = "../storage", default-features = false } +sp-externalities = { path = "../externalities", optional = true } +sp-storage = { path = "../storage", default-features = false } # full crypto ed25519-dalek = { version = "1.0.0-pre.3", default-features = false, features = ["u64_backend", "alloc"], optional = true } @@ -39,7 +39,7 @@ sha2 = { version = "0.8.0", default-features = false, optional = true } hex = { version = "0.4", default-features = false, optional = true } twox-hash = { version = "1.5.0", default-features = false, optional = true } -runtime-interface = { package = "sp-runtime-interface", path = "../runtime-interface", default-features = false } +sp-runtime-interface = { path = "../runtime-interface", default-features = false } [dev-dependencies] sp-serializer = { path = "../serializer" } @@ -93,9 +93,9 @@ std = [ "libsecp256k1", "tiny-keccak", "sp-debug-derive/std", - "externalities", - "primitives-storage/std", - "runtime-interface/std", + "sp-externalities", + "sp-storage/std", + "sp-runtime-interface/std", "zeroize/alloc" ] @@ -111,5 +111,5 @@ full_crypto = [ "hex", "sha2", "twox-hash", - "runtime-interface/disable_target_static_assertions", + "sp-runtime-interface/disable_target_static_assertions", ] diff --git a/primitives/core/benches/bench.rs b/primitives/core/benches/bench.rs index bac7eb41ca..d03407de5f 100644 --- a/primitives/core/benches/bench.rs +++ b/primitives/core/benches/bench.rs @@ -16,11 +16,10 @@ #[macro_use] extern crate criterion; -use sp_core as primitives; use criterion::{Criterion, black_box, Bencher, Fun}; use std::time::Duration; -use primitives::crypto::Pair as _; -use primitives::hashing::{twox_128, blake2_128}; +use sp_core::crypto::Pair as _; +use sp_core::hashing::{twox_128, blake2_128}; const MAX_KEY_SIZE: u32 = 32; @@ -72,7 +71,7 @@ fn bench_ed25519(c: &mut Criterion) { let msg = (0..msg_size) .map(|_| rand::random::()) .collect::>(); - let key = primitives::ed25519::Pair::generate().0; + let key = sp_core::ed25519::Pair::generate().0; b.iter(|| key.sign(&msg)) }, vec![32, 1024, 1024 * 1024]); @@ -80,10 +79,10 @@ fn bench_ed25519(c: &mut Criterion) { let msg = (0..msg_size) .map(|_| rand::random::()) .collect::>(); - let key = primitives::ed25519::Pair::generate().0; + let key = sp_core::ed25519::Pair::generate().0; let sig = key.sign(&msg); let public = key.public(); - b.iter(|| primitives::ed25519::Pair::verify(&sig, &msg, &public)) + b.iter(|| sp_core::ed25519::Pair::verify(&sig, &msg, &public)) }, vec![32, 1024, 1024 * 1024]); } diff --git a/primitives/core/src/crypto.rs b/primitives/core/src/crypto.rs index 2f7574bee3..5119203a08 100644 --- a/primitives/core/src/crypto.rs +++ b/primitives/core/src/crypto.rs @@ -37,7 +37,7 @@ use base58::{FromBase58, ToBase58}; use zeroize::Zeroize; #[doc(hidden)] pub use sp_std::ops::Deref; -use runtime_interface::pass_by::PassByInner; +use sp_runtime_interface::pass_by::PassByInner; /// The root phrase for our publicly known keys. pub const DEV_PHRASE: &str = "bottom drive obey lake curtain smoke basket hold race lonely fit walk"; diff --git a/primitives/core/src/ed25519.rs b/primitives/core/src/ed25519.rs index 0b40ea8bb6..180e3b0ccb 100644 --- a/primitives/core/src/ed25519.rs +++ b/primitives/core/src/ed25519.rs @@ -39,7 +39,7 @@ use crate::crypto::Ss58Codec; #[cfg(feature = "std")] use serde::{de, Serializer, Serialize, Deserializer, Deserialize}; use crate::{crypto::{Public as TraitPublic, UncheckedFrom, CryptoType, Derive}}; -use runtime_interface::pass_by::PassByInner; +use sp_runtime_interface::pass_by::PassByInner; use sp_std::ops::Deref; /// A secret seed. It's not called a "secret key" because ring doesn't expose the secret keys diff --git a/primitives/core/src/lib.rs b/primitives/core/src/lib.rs index 3241f9b4ff..00343c0e7f 100644 --- a/primitives/core/src/lib.rs +++ b/primitives/core/src/lib.rs @@ -84,7 +84,7 @@ pub use hash_db::Hasher; // pub use self::hasher::blake::BlakeHasher; pub use self::hasher::blake2::Blake2Hasher; -pub use primitives_storage as storage; +pub use sp_storage as storage; #[doc(hidden)] pub use sp_std; @@ -236,7 +236,7 @@ pub trait TypeId { /// A log level matching the one from `log` crate. /// /// Used internally by `sp_io::log` method. -#[derive(Encode, Decode, runtime_interface::pass_by::PassByEnum, Copy, Clone)] +#[derive(Encode, Decode, sp_runtime_interface::pass_by::PassByEnum, Copy, Clone)] pub enum LogLevel { /// `Error` log level. Error = 1, diff --git a/primitives/core/src/offchain/mod.rs b/primitives/core/src/offchain/mod.rs index 4b7423c253..9c33abb7c1 100644 --- a/primitives/core/src/offchain/mod.rs +++ b/primitives/core/src/offchain/mod.rs @@ -19,7 +19,7 @@ use codec::{Encode, Decode}; use sp_std::{prelude::{Vec, Box}, convert::TryFrom}; use crate::RuntimeDebug; -use runtime_interface::pass_by::{PassByCodec, PassByInner, PassByEnum}; +use sp_runtime_interface::pass_by::{PassByCodec, PassByInner, PassByEnum}; pub use crate::crypto::KeyTypeId; @@ -669,7 +669,7 @@ impl Externalities for LimitedExternalities { } #[cfg(feature = "std")] -externalities::decl_extension! { +sp_externalities::decl_extension! { /// The offchain extension that will be registered at the Substrate externalities. pub struct OffchainExt(Box); } @@ -696,7 +696,7 @@ pub trait TransactionPool { } #[cfg(feature = "std")] -externalities::decl_extension! { +sp_externalities::decl_extension! { /// An externalities extension to submit transactions to the pool. pub struct TransactionPoolExt(Box); } diff --git a/primitives/core/src/sr25519.rs b/primitives/core/src/sr25519.rs index 05b128d288..c0f71ea83b 100644 --- a/primitives/core/src/sr25519.rs +++ b/primitives/core/src/sr25519.rs @@ -48,7 +48,7 @@ use sp_std::ops::Deref; use serde::{de, Deserialize, Deserializer, Serialize, Serializer}; #[cfg(feature = "full_crypto")] use schnorrkel::keys::{MINI_SECRET_KEY_LENGTH, SECRET_KEY_LENGTH}; -use runtime_interface::pass_by::PassByInner; +use sp_runtime_interface::pass_by::PassByInner; // signing context #[cfg(feature = "full_crypto")] diff --git a/primitives/core/src/traits.rs b/primitives/core/src/traits.rs index f1b13408d1..2f78c8a708 100644 --- a/primitives/core/src/traits.rs +++ b/primitives/core/src/traits.rs @@ -24,7 +24,7 @@ use std::{ sync::Arc, }; -pub use externalities::{Externalities, ExternalitiesExt}; +pub use sp_externalities::{Externalities, ExternalitiesExt}; /// Something that generates, stores and provides access to keys. pub trait BareCryptoStore: Send + Sync { @@ -74,7 +74,7 @@ pub trait BareCryptoStore: Send + Sync { /// A pointer to the key store. pub type BareCryptoStorePtr = Arc>; -externalities::decl_extension! { +sp_externalities::decl_extension! { /// The keystore extension to register/retrieve from the externalities. pub struct KeystoreExt(BareCryptoStorePtr); } diff --git a/primitives/externalities/Cargo.toml b/primitives/externalities/Cargo.toml index d64d104baa..e9c826a8fe 100644 --- a/primitives/externalities/Cargo.toml +++ b/primitives/externalities/Cargo.toml @@ -6,6 +6,6 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -primitives-storage = { package = "sp-storage", path = "../storage" } +sp-storage = { path = "../storage" } sp-std = { path = "../std" } environmental = { version = "1.0.2" } diff --git a/primitives/externalities/src/lib.rs b/primitives/externalities/src/lib.rs index e79d6a2e3d..52be547e25 100644 --- a/primitives/externalities/src/lib.rs +++ b/primitives/externalities/src/lib.rs @@ -24,7 +24,7 @@ use std::any::{Any, TypeId}; -use primitives_storage::{ChildStorageKey, ChildInfo}; +use sp_storage::{ChildStorageKey, ChildInfo}; pub use scope_limited::{set_and_run_with_externalities, with_externalities}; pub use extensions::{Extension, Extensions, ExtensionStore}; diff --git a/primitives/finality-tracker/Cargo.toml b/primitives/finality-tracker/Cargo.toml index 919fc0bab4..24681bbd1e 100644 --- a/primitives/finality-tracker/Cargo.toml +++ b/primitives/finality-tracker/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" [dependencies] codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } -inherents = { package = "sp-inherents", path = "../../primitives/inherents", default-features = false } +sp-inherents = { path = "../../primitives/inherents", default-features = false } sp-std = { path = "../../primitives/std", default-features = false } [features] @@ -14,5 +14,5 @@ default = ["std"] std = [ "codec/std", "sp-std/std", - "inherents/std", + "sp-inherents/std", ] diff --git a/primitives/finality-tracker/src/lib.rs b/primitives/finality-tracker/src/lib.rs index 7b81a300c4..677be24ef5 100644 --- a/primitives/finality-tracker/src/lib.rs +++ b/primitives/finality-tracker/src/lib.rs @@ -18,7 +18,7 @@ #![cfg_attr(not(feature = "std"), no_std)] -use inherents::{InherentIdentifier, InherentData, Error}; +use sp_inherents::{InherentIdentifier, InherentData, Error}; use codec::Decode; #[cfg(feature = "std")] @@ -55,7 +55,7 @@ impl InherentDataProvider { } #[cfg(feature = "std")] -impl inherents::ProvideInherentData for InherentDataProvider +impl sp_inherents::ProvideInherentData for InherentDataProvider where F: Fn() -> Result { fn inherent_identifier(&self) -> &'static InherentIdentifier { diff --git a/primitives/inherents/Cargo.toml b/primitives/inherents/Cargo.toml index d8f67031f9..f40cf8c7f5 100644 --- a/primitives/inherents/Cargo.toml +++ b/primitives/inherents/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] parking_lot = { version = "0.9.0", optional = true } sp-std = { path = "../std", default-features = false } -primitives = { package = "sp-core", path = "../core", default-features = false } +sp-core = { path = "../core", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.6", default-features = false, features = ["derive"] } derive_more = { version = "0.99.2", optional = true } @@ -17,6 +17,6 @@ std = [ "parking_lot", "sp-std/std", "codec/std", - "primitives/std", + "sp-core/std", "derive_more", ] diff --git a/primitives/inherents/src/lib.rs b/primitives/inherents/src/lib.rs index 8f26a50822..b777b64e5e 100644 --- a/primitives/inherents/src/lib.rs +++ b/primitives/inherents/src/lib.rs @@ -64,7 +64,7 @@ impl Error { } /// An error that can occur within the inherent data system. -#[derive(Encode, primitives::RuntimeDebug)] +#[derive(Encode, sp_core::RuntimeDebug)] #[cfg(not(feature = "std"))] pub struct Error(&'static str); diff --git a/primitives/io/Cargo.toml b/primitives/io/Cargo.toml index b124ef7843..b72a6adb8c 100644 --- a/primitives/io/Cargo.toml +++ b/primitives/io/Cargo.toml @@ -7,27 +7,27 @@ edition = "2018" [dependencies] codec = { package = "parity-scale-codec", version = "1.0.6", default-features = false } hash-db = { version = "0.15.2", default-features = false } -primitives = { package = "sp-core", path = "../core", default-features = false } +sp-core = { path = "../core", default-features = false } sp-std = { path = "../std", default-features = false } libsecp256k1 = { version = "0.3.0", optional = true } sp-state-machine = { path = "../../primitives/state-machine", optional = true } -runtime-interface = { package = "sp-runtime-interface", path = "../runtime-interface", default-features = false } -trie = { package = "sp-trie", path = "../../primitives/trie", optional = true } -externalities = { package = "sp-externalities", path = "../externalities", optional = true } +sp-runtime-interface = { path = "../runtime-interface", default-features = false } +sp-trie = { path = "../../primitives/trie", optional = true } +sp-externalities = { path = "../externalities", optional = true } log = { version = "0.4.8", optional = true } [features] default = ["std"] std = [ - "primitives/std", + "sp-core/std", "codec/std", "sp-std/std", "hash-db/std", - "trie", + "sp-trie", "sp-state-machine", "libsecp256k1", - "runtime-interface/std", - "externalities", + "sp-runtime-interface/std", + "sp-externalities", "log", ] diff --git a/primitives/io/src/lib.rs b/primitives/io/src/lib.rs index 5941a8fff8..be88907cde 100644 --- a/primitives/io/src/lib.rs +++ b/primitives/io/src/lib.rs @@ -34,7 +34,7 @@ use sp_std::vec::Vec; use sp_std::ops::Deref; #[cfg(feature = "std")] -use primitives::{ +use sp_core::{ crypto::Pair, traits::KeystoreExt, offchain::{OffchainExt, TransactionPoolExt}, @@ -42,7 +42,7 @@ use primitives::{ storage::{ChildStorageKey, ChildInfo}, }; -use primitives::{ +use sp_core::{ crypto::KeyTypeId, ed25519, sr25519, H256, LogLevel, offchain::{ Timestamp, HttpRequestId, HttpRequestStatus, HttpError, StorageKind, OpaqueNetworkState, @@ -50,14 +50,14 @@ use primitives::{ }; #[cfg(feature = "std")] -use ::trie::{TrieConfiguration, trie_types::Layout}; +use ::sp_trie::{TrieConfiguration, trie_types::Layout}; -use runtime_interface::{runtime_interface, Pointer}; +use sp_runtime_interface::{runtime_interface, Pointer}; use codec::{Encode, Decode}; #[cfg(feature = "std")] -use externalities::{ExternalitiesExt, Externalities}; +use sp_externalities::{ExternalitiesExt, Externalities}; /// Error verifying ECDSA signature #[derive(Encode, Decode)] @@ -318,12 +318,12 @@ pub trait Storage { pub trait Trie { /// A trie root formed from the iterated items. fn blake2_256_root(input: Vec<(Vec, Vec)>) -> H256 { - Layout::::trie_root(input) + Layout::::trie_root(input) } /// A trie root formed from the enumerated items. fn blake2_256_ordered_root(input: Vec>) -> H256 { - Layout::::ordered_trie_root(input) + Layout::::ordered_trie_root(input) } } @@ -332,7 +332,7 @@ pub trait Trie { pub trait Misc { /// The current relay chain identifier. fn chain_id(&self) -> u64 { - externalities::Externalities::chain_id(*self) + sp_externalities::Externalities::chain_id(*self) } /// Print a number. @@ -496,37 +496,37 @@ pub trait Crypto { pub trait Hashing { /// Conduct a 256-bit Keccak hash. fn keccak_256(data: &[u8]) -> [u8; 32] { - primitives::hashing::keccak_256(data) + sp_core::hashing::keccak_256(data) } /// Conduct a 256-bit Sha2 hash. fn sha2_256(data: &[u8]) -> [u8; 32] { - primitives::hashing::sha2_256(data) + sp_core::hashing::sha2_256(data) } /// Conduct a 128-bit Blake2 hash. fn blake2_128(data: &[u8]) -> [u8; 16] { - primitives::hashing::blake2_128(data) + sp_core::hashing::blake2_128(data) } /// Conduct a 256-bit Blake2 hash. fn blake2_256(data: &[u8]) -> [u8; 32] { - primitives::hashing::blake2_256(data) + sp_core::hashing::blake2_256(data) } /// Conduct four XX hashes to give a 256-bit result. fn twox_256(data: &[u8]) -> [u8; 32] { - primitives::hashing::twox_256(data) + sp_core::hashing::twox_256(data) } /// Conduct two XX hashes to give a 128-bit result. fn twox_128(data: &[u8]) -> [u8; 16] { - primitives::hashing::twox_128(data) + sp_core::hashing::twox_128(data) } /// Conduct two XX hashes to give a 64-bit result. fn twox_64(data: &[u8]) -> [u8; 8] { - primitives::hashing::twox_64(data) + sp_core::hashing::twox_64(data) } } @@ -881,7 +881,7 @@ pub fn oom(_: core::alloc::Layout) -> ! { /// Type alias for Externalities implementation used in tests. #[cfg(feature = "std")] -pub type TestExternalities = sp_state_machine::TestExternalities; +pub type TestExternalities = sp_state_machine::TestExternalities; /// The host functions Substrate provides for the Wasm runtime environment. /// @@ -902,9 +902,9 @@ pub type SubstrateHostFunctions = ( #[cfg(test)] mod tests { use super::*; - use primitives::map; + use sp_core::map; use sp_state_machine::BasicExternalities; - use primitives::storage::Storage; + use sp_core::storage::Storage; #[test] fn storage_works() { diff --git a/primitives/keyring/Cargo.toml b/primitives/keyring/Cargo.toml index 9053266184..7db87f3391 100644 --- a/primitives/keyring/Cargo.toml +++ b/primitives/keyring/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -primitives = { package = "sp-core", path = "../core" } +sp-core = { path = "../core" } sp-runtime = { path = "../runtime" } lazy_static = "1.4.0" strum = { version = "0.16.0", features = ["derive"] } diff --git a/primitives/keyring/src/ed25519.rs b/primitives/keyring/src/ed25519.rs index 7174d1cc43..3b882bfea8 100644 --- a/primitives/keyring/src/ed25519.rs +++ b/primitives/keyring/src/ed25519.rs @@ -18,8 +18,8 @@ use std::{collections::HashMap, ops::Deref}; use lazy_static::lazy_static; -use primitives::{ed25519::{Pair, Public, Signature}, Pair as PairT, Public as PublicT, H256}; -pub use primitives::ed25519; +use sp_core::{ed25519::{Pair, Public, Signature}, Pair as PairT, Public as PublicT, H256}; +pub use sp_core::ed25519; use sp_runtime::AccountId32; /// Set of test accounts. @@ -180,7 +180,7 @@ impl Deref for Keyring { #[cfg(test)] mod tests { use super::*; - use primitives::{ed25519::Pair, Pair as PairT}; + use sp_core::{ed25519::Pair, Pair as PairT}; #[test] fn should_work() { diff --git a/primitives/keyring/src/sr25519.rs b/primitives/keyring/src/sr25519.rs index a14566bbab..533a21f55a 100644 --- a/primitives/keyring/src/sr25519.rs +++ b/primitives/keyring/src/sr25519.rs @@ -19,8 +19,8 @@ use std::collections::HashMap; use std::ops::Deref; use lazy_static::lazy_static; -use primitives::{sr25519::{Pair, Public, Signature}, Pair as PairT, Public as PublicT, H256}; -pub use primitives::sr25519; +use sp_core::{sr25519::{Pair, Public, Signature}, Pair as PairT, Public as PublicT, H256}; +pub use sp_core::sr25519; use sp_runtime::AccountId32; /// Set of test accounts. @@ -181,7 +181,7 @@ impl Deref for Keyring { #[cfg(test)] mod tests { use super::*; - use primitives::{sr25519::Pair, Pair as PairT}; + use sp_core::{sr25519::Pair, Pair as PairT}; #[test] fn should_work() { diff --git a/primitives/rpc/Cargo.toml b/primitives/rpc/Cargo.toml index 9e44f407d0..09ce69e0c5 100644 --- a/primitives/rpc/Cargo.toml +++ b/primitives/rpc/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" [dependencies] serde = { version = "1.0.101", features = ["derive"] } -primitives = { package = "sp-core", path = "../core" } +sp-core = { path = "../core" } [dev-dependencies] serde_json = "1.0.41" diff --git a/primitives/rpc/src/number.rs b/primitives/rpc/src/number.rs index 9c3312e6cc..220b221b66 100644 --- a/primitives/rpc/src/number.rs +++ b/primitives/rpc/src/number.rs @@ -18,7 +18,7 @@ use serde::{Serialize, Deserialize}; use std::{convert::TryFrom, fmt::Debug}; -use primitives::U256; +use sp_core::U256; /// RPC Block number type /// diff --git a/primitives/runtime-interface/Cargo.toml b/primitives/runtime-interface/Cargo.toml index c451407681..5874e66237 100644 --- a/primitives/runtime-interface/Cargo.toml +++ b/primitives/runtime-interface/Cargo.toml @@ -5,19 +5,19 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -wasm-interface = { package = "sp-wasm-interface", path = "../wasm-interface", optional = true } +sp-wasm-interface = { path = "../wasm-interface", optional = true } sp-std = { path = "../std", default-features = false } sp-runtime-interface-proc-macro = { path = "proc-macro" } -externalities = { package = "sp-externalities", path = "../externalities", optional = true } +sp-externalities = { path = "../externalities", optional = true } codec = { package = "parity-scale-codec", version = "1.0.6", default-features = false } environmental = { version = "1.0.2", optional = true } static_assertions = "1.0.0" primitive-types = { version = "0.6.1", default-features = false } [dev-dependencies] -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" } +sp-runtime-interface-test-wasm = { path = "test-wasm" } +sp-state-machine = { path = "../../primitives/state-machine" } +sp-core = { path = "../core" } sp-io = { path = "../io" } rustversion = "1.0.0" trybuild = "1.0.17" @@ -25,10 +25,10 @@ trybuild = "1.0.17" [features] default = [ "std" ] std = [ - "wasm-interface", + "sp-wasm-interface", "sp-std/std", "codec/std", - "externalities", + "sp-externalities", "environmental", "primitive-types/std", ] diff --git a/primitives/runtime-interface/proc-macro/src/runtime_interface/bare_function_interface.rs b/primitives/runtime-interface/proc-macro/src/runtime_interface/bare_function_interface.rs index dbedba000e..1c662f8802 100644 --- a/primitives/runtime-interface/proc-macro/src/runtime_interface/bare_function_interface.rs +++ b/primitives/runtime-interface/proc-macro/src/runtime_interface/bare_function_interface.rs @@ -106,7 +106,7 @@ fn function_std_impl( if is_wasm_only { Some( parse_quote!( - mut __function_context__: &mut dyn #crate_::wasm_interface::FunctionContext + mut __function_context__: &mut dyn #crate_::sp_wasm_interface::FunctionContext ) ) } else { @@ -164,7 +164,7 @@ fn generate_call_to_trait( } else { // The name of the trait the interface trait is implemented for let impl_trait_name = if is_wasm_only { - quote!( #crate_::wasm_interface::FunctionContext ) + quote!( #crate_::sp_wasm_interface::FunctionContext ) } else { quote!( #crate_::Externalities ) }; diff --git a/primitives/runtime-interface/proc-macro/src/runtime_interface/host_function_interface.rs b/primitives/runtime-interface/proc-macro/src/runtime_interface/host_function_interface.rs index f710e9b60c..63cb75f667 100644 --- a/primitives/runtime-interface/proc-macro/src/runtime_interface/host_function_interface.rs +++ b/primitives/runtime-interface/proc-macro/src/runtime_interface/host_function_interface.rs @@ -174,8 +174,8 @@ fn generate_host_functions_struct(trait_def: &ItemTrait, is_wasm_only: bool) -> pub struct HostFunctions; #[cfg(feature = "std")] - impl #crate_::wasm_interface::HostFunctions for HostFunctions { - fn host_functions() -> Vec<&'static dyn #crate_::wasm_interface::Function> { + impl #crate_::sp_wasm_interface::HostFunctions for HostFunctions { + fn host_functions() -> Vec<&'static dyn #crate_::sp_wasm_interface::Function> { vec![ #( #host_functions ),* ] } } @@ -212,20 +212,20 @@ fn generate_host_function_implementation( struct #struct_name; #[allow(unused)] - impl #crate_::wasm_interface::Function for #struct_name { + impl #crate_::sp_wasm_interface::Function for #struct_name { fn name(&self) -> &str { #name } - fn signature(&self) -> #crate_::wasm_interface::Signature { + fn signature(&self) -> #crate_::sp_wasm_interface::Signature { #signature } fn execute( &self, - __function_context__: &mut dyn #crate_::wasm_interface::FunctionContext, - args: &mut dyn Iterator, - ) -> std::result::Result, String> { + __function_context__: &mut dyn #crate_::sp_wasm_interface::FunctionContext, + args: &mut dyn Iterator, + ) -> std::result::Result, String> { #( #wasm_to_ffi_values )* #( #ffi_to_host_values )* #host_function_call @@ -234,7 +234,7 @@ fn generate_host_function_implementation( } } - &#struct_name as &dyn #crate_::wasm_interface::Function + &#struct_name as &dyn #crate_::sp_wasm_interface::Function } } ) @@ -246,18 +246,18 @@ fn generate_wasm_interface_signature_for_host_function(sig: &Signature) -> Resul let return_value = match &sig.output { ReturnType::Type(_, ty) => quote! { - Some( <<#ty as #crate_::RIType>::FFIType as #crate_::wasm_interface::IntoValue>::VALUE_TYPE ) + Some( <<#ty as #crate_::RIType>::FFIType as #crate_::sp_wasm_interface::IntoValue>::VALUE_TYPE ) }, ReturnType::Default => quote!( None ), }; let arg_types = get_function_argument_types_without_ref(sig) .map(|ty| quote! { - <<#ty as #crate_::RIType>::FFIType as #crate_::wasm_interface::IntoValue>::VALUE_TYPE + <<#ty as #crate_::RIType>::FFIType as #crate_::sp_wasm_interface::IntoValue>::VALUE_TYPE }); Ok( quote! { - #crate_::wasm_interface::Signature { + #crate_::sp_wasm_interface::Signature { args: std::borrow::Cow::Borrowed(&[ #( #arg_types ),* ][..]), return_value: #return_value, } @@ -292,7 +292,7 @@ fn generate_wasm_to_ffi_values<'a>( Ok(quote! { let val = args.next().ok_or_else(|| #error_message)?; let #var_name = < - <#ty as #crate_::RIType>::FFIType as #crate_::wasm_interface::TryFromValue + <#ty as #crate_::RIType>::FFIType as #crate_::sp_wasm_interface::TryFromValue >::try_from_value(val).ok_or_else(|| #try_from_error)?; }) }) @@ -408,7 +408,7 @@ fn generate_return_value_into_wasm_value(sig: &Signature) -> TokenStream { <#ty as #crate_::host::IntoFFIValue>::into_ffi_value( #result_var_name, __function_context__, - ).map(#crate_::wasm_interface::IntoValue::into_value).map(Some) + ).map(#crate_::sp_wasm_interface::IntoValue::into_value).map(Some) } } } diff --git a/primitives/runtime-interface/proc-macro/src/runtime_interface/trait_decl_impl.rs b/primitives/runtime-interface/proc-macro/src/runtime_interface/trait_decl_impl.rs index 0e5ae906ab..e76daf71bd 100644 --- a/primitives/runtime-interface/proc-macro/src/runtime_interface/trait_decl_impl.rs +++ b/primitives/runtime-interface/proc-macro/src/runtime_interface/trait_decl_impl.rs @@ -130,7 +130,7 @@ fn impl_trait_for_externalities(trait_def: &ItemTrait, is_wasm_only: bool) -> Re }); let impl_type = if is_wasm_only { - quote!( &mut dyn #crate_::wasm_interface::FunctionContext ) + quote!( &mut dyn #crate_::sp_wasm_interface::FunctionContext ) } else { quote!( &mut dyn #crate_::Externalities ) }; diff --git a/primitives/runtime-interface/src/host.rs b/primitives/runtime-interface/src/host.rs index 313aba3d85..10ebd1beec 100644 --- a/primitives/runtime-interface/src/host.rs +++ b/primitives/runtime-interface/src/host.rs @@ -18,7 +18,7 @@ use crate::RIType; -use wasm_interface::{FunctionContext, Result}; +use sp_wasm_interface::{FunctionContext, Result}; /// Something that can be converted into a ffi value. pub trait IntoFFIValue: RIType { diff --git a/primitives/runtime-interface/src/impls.rs b/primitives/runtime-interface/src/impls.rs index 0410d15321..97dfcb769a 100644 --- a/primitives/runtime-interface/src/impls.rs +++ b/primitives/runtime-interface/src/impls.rs @@ -26,7 +26,7 @@ use crate::wasm::*; use static_assertions::assert_eq_size; #[cfg(feature = "std")] -use wasm_interface::{FunctionContext, Result}; +use sp_wasm_interface::{FunctionContext, Result}; use codec::{Encode, Decode}; @@ -448,7 +448,7 @@ impl IntoFFIValue for str { } #[cfg(feature = "std")] -impl RIType for Pointer { +impl RIType for Pointer { type FFIType = u32; } @@ -475,7 +475,7 @@ impl FromFFIValue for Pointer { } #[cfg(feature = "std")] -impl FromFFIValue for Pointer { +impl FromFFIValue for Pointer { type SelfInstance = Self; fn from_ffi_value(_: &mut dyn FunctionContext, arg: u32) -> Result { @@ -484,7 +484,7 @@ impl FromFFIValue for Pointer { } #[cfg(feature = "std")] -impl IntoFFIValue for Pointer { +impl IntoFFIValue for Pointer { fn into_ffi_value(self, _: &mut dyn FunctionContext) -> Result { Ok(self.into()) } diff --git a/primitives/runtime-interface/src/lib.rs b/primitives/runtime-interface/src/lib.rs index 9baf47df27..b02ccc6ab2 100644 --- a/primitives/runtime-interface/src/lib.rs +++ b/primitives/runtime-interface/src/lib.rs @@ -76,7 +76,7 @@ extern crate self as sp_runtime_interface; #[doc(hidden)] #[cfg(feature = "std")] -pub use wasm_interface; +pub use sp_wasm_interface; #[doc(hidden)] pub use sp_std; @@ -130,7 +130,7 @@ pub use sp_std; /// fn set_or_clear(&mut self, optional: Option>); /// } /// -/// impl Interface for &mut dyn externalities::Externalities { +/// impl Interface for &mut dyn sp_externalities::Externalities { /// fn call_some_complex_code(data: &[u8]) -> Vec { Vec::new() } /// fn set_or_clear(&mut self, optional: Option>) { /// match optional { @@ -141,11 +141,11 @@ pub use sp_std; /// } /// /// pub fn call_some_complex_code(data: &[u8]) -> Vec { -/// <&mut dyn externalities::Externalities as Interface>::call_some_complex_code(data) +/// <&mut dyn sp_externalities::Externalities as Interface>::call_some_complex_code(data) /// } /// /// pub fn set_or_clear(optional: Option>) { -/// externalities::with_externalities(|mut ext| Interface::set_or_clear(&mut ext, optional)) +/// sp_externalities::with_externalities(|mut ext| Interface::set_or_clear(&mut ext, optional)) /// .expect("`set_or_clear` called outside of an Externalities-provided environment.") /// } /// @@ -227,7 +227,7 @@ pub use sp_runtime_interface_proc_macro::runtime_interface; #[doc(hidden)] #[cfg(feature = "std")] -pub use externalities::{ +pub use sp_externalities::{ set_and_run_with_externalities, with_externalities, Externalities, ExternalitiesExt, ExtensionStore, }; @@ -249,7 +249,7 @@ pub mod pass_by; pub trait RIType { /// The ffi type that is used to represent `Self`. #[cfg(feature = "std")] - type FFIType: wasm_interface::IntoValue + wasm_interface::TryFromValue; + type FFIType: sp_wasm_interface::IntoValue + sp_wasm_interface::TryFromValue; #[cfg(not(feature = "std"))] type FFIType; } @@ -260,4 +260,4 @@ pub type Pointer = *mut T; /// A pointer that can be used in a runtime interface function signature. #[cfg(feature = "std")] -pub type Pointer = wasm_interface::Pointer; \ No newline at end of file +pub type Pointer = sp_wasm_interface::Pointer; \ No newline at end of file diff --git a/primitives/runtime-interface/src/pass_by.rs b/primitives/runtime-interface/src/pass_by.rs index 5d5b98244e..dd38a4f80f 100644 --- a/primitives/runtime-interface/src/pass_by.rs +++ b/primitives/runtime-interface/src/pass_by.rs @@ -28,7 +28,7 @@ use crate::host::*; use crate::wasm::*; #[cfg(feature = "std")] -use wasm_interface::{FunctionContext, Pointer, Result}; +use sp_wasm_interface::{FunctionContext, Pointer, Result}; use sp_std::{marker::PhantomData, convert::TryFrom}; diff --git a/primitives/runtime-interface/test-wasm/Cargo.toml b/primitives/runtime-interface/test-wasm/Cargo.toml index 9c3ac0a7f0..d8ed272aa8 100644 --- a/primitives/runtime-interface/test-wasm/Cargo.toml +++ b/primitives/runtime-interface/test-wasm/Cargo.toml @@ -6,14 +6,14 @@ edition = "2018" build = "build.rs" [dependencies] -runtime-interface = { package = "sp-runtime-interface", path = "../", default-features = false } +sp-runtime-interface = { path = "../", default-features = false } sp-std = { path = "../../std", default-features = false } sp-io = { path = "../../io", default-features = false } -primitives = { package = "sp-core", path = "../../core", default-features = false } +sp-core = { path = "../../core", default-features = false } [build-dependencies] wasm-builder-runner = { package = "substrate-wasm-builder-runner", version = "1.0.3", path = "../../../utils/wasm-builder-runner" } [features] default = [ "std" ] -std = [ "runtime-interface/std", "sp-std/std", "primitives/std", "sp-io/std" ] +std = [ "sp-runtime-interface/std", "sp-std/std", "sp-core/std", "sp-io/std" ] diff --git a/primitives/runtime-interface/test-wasm/src/lib.rs b/primitives/runtime-interface/test-wasm/src/lib.rs index dd75a9cb8a..f353518019 100644 --- a/primitives/runtime-interface/test-wasm/src/lib.rs +++ b/primitives/runtime-interface/test-wasm/src/lib.rs @@ -18,12 +18,12 @@ #![cfg_attr(not(feature = "std"), no_std)] -use runtime_interface::runtime_interface; +use sp_runtime_interface::runtime_interface; #[cfg(not(feature = "std"))] use sp_std::{vec, vec::Vec, mem, convert::TryFrom}; -use primitives::{sr25519::Public, wasm_export_functions}; +use sp_core::{sr25519::Public, wasm_export_functions}; // Inlucde the WASM binary #[cfg(feature = "std")] diff --git a/primitives/runtime-interface/test/Cargo.toml b/primitives/runtime-interface/test/Cargo.toml index 269e8bc4aa..1e9aea910e 100644 --- a/primitives/runtime-interface/test/Cargo.toml +++ b/primitives/runtime-interface/test/Cargo.toml @@ -7,8 +7,8 @@ publish = false [dependencies] sp-runtime-interface = { path = "../" } -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" } +sc-executor = { path = "../../../client/executor" } +sp-runtime-interface-test-wasm = { path = "../test-wasm" } +sp-state-machine = { path = "../../../primitives/state-machine" } +sp-core = { path = "../../core" } sp-io = { path = "../../io" } diff --git a/primitives/runtime-interface/test/src/lib.rs b/primitives/runtime-interface/test/src/lib.rs index 3de5e1ddc1..a791442fc4 100644 --- a/primitives/runtime-interface/test/src/lib.rs +++ b/primitives/runtime-interface/test/src/lib.rs @@ -17,26 +17,26 @@ //! Integration tests for runtime interface primitives use sp_runtime_interface::*; -use test_wasm::{WASM_BINARY, test_api::HostFunctions}; -use wasm_interface::HostFunctions as HostFunctionsT; +use sp_runtime_interface_test_wasm::{WASM_BINARY, test_api::HostFunctions}; +use sp_wasm_interface::HostFunctions as HostFunctionsT; -type TestExternalities = state_machine::TestExternalities; +type TestExternalities = sp_state_machine::TestExternalities; fn call_wasm_method(method: &str) -> TestExternalities { let mut ext = TestExternalities::default(); let mut ext_ext = ext.ext(); - executor::call_in_wasm::< + sc_executor::call_in_wasm::< _, ( HF, sp_io::SubstrateHostFunctions, - executor::deprecated_host_interface::SubstrateExternals + sc_executor::deprecated_host_interface::SubstrateExternals ) >( method, &[], - executor::WasmExecutionMethod::Interpreted, + sc_executor::WasmExecutionMethod::Interpreted, &mut ext_ext, &WASM_BINARY[..], 8, diff --git a/primitives/runtime/Cargo.toml b/primitives/runtime/Cargo.toml index 3c8377666a..78cbcad6dc 100644 --- a/primitives/runtime/Cargo.toml +++ b/primitives/runtime/Cargo.toml @@ -7,16 +7,16 @@ edition = "2018" [dependencies] serde = { version = "1.0.101", optional = true, features = ["derive"] } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -primitives = { package = "sp-core", path = "../core", default-features = false } -app-crypto = { package = "sp-application-crypto", path = "../application-crypto", default-features = false } -arithmetic = { package = "sp-arithmetic", path = "../arithmetic", default-features = false } +sp-core = { path = "../core", default-features = false } +sp-application-crypto = { path = "../application-crypto", default-features = false } +sp-arithmetic = { path = "../arithmetic", default-features = false } sp-std = { path = "../std", 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 } impl-trait-for-tuples = "0.1.3" -inherents = { package = "sp-inherents", path = "../inherents", default-features = false } +sp-inherents = { path = "../inherents", default-features = false } [dev-dependencies] serde_json = "1.0.41" @@ -26,14 +26,14 @@ rand = "0.7.2" bench = [] default = ["std"] std = [ - "app-crypto/std", - "arithmetic/std", + "sp-application-crypto/std", + "sp-arithmetic/std", "codec/std", "log", - "primitives/std", + "sp-core/std", "rand", "sp-std/std", "sp-io/std", "serde", - "inherents/std", + "sp-inherents/std", ] diff --git a/primitives/runtime/src/curve.rs b/primitives/runtime/src/curve.rs index 52a6ddd33b..f2e1a8b7d5 100644 --- a/primitives/runtime/src/curve.rs +++ b/primitives/runtime/src/curve.rs @@ -20,7 +20,7 @@ use crate::{Perbill, traits::{SimpleArithmetic, SaturatedConversion}}; use core::ops::Sub; /// Piecewise Linear function in [0, 1] -> [0, 1]. -#[derive(PartialEq, Eq, primitives::RuntimeDebug)] +#[derive(PartialEq, Eq, sp_core::RuntimeDebug)] pub struct PiecewiseLinear<'a> { /// Array of points. Must be in order from the lowest abscissas to the highest. pub points: &'a [(Perbill, Perbill)], diff --git a/primitives/runtime/src/generic/block.rs b/primitives/runtime/src/generic/block.rs index 12b2f82eac..cad166e80c 100644 --- a/primitives/runtime/src/generic/block.rs +++ b/primitives/runtime/src/generic/block.rs @@ -23,7 +23,7 @@ use std::fmt; use serde::{Deserialize, Serialize}; use sp_std::prelude::*; -use primitives::RuntimeDebug; +use sp_core::RuntimeDebug; use crate::codec::{Codec, Encode, Decode}; use crate::traits::{self, Member, Block as BlockT, Header as HeaderT, MaybeSerialize}; use crate::Justification; diff --git a/primitives/runtime/src/generic/checked_extrinsic.rs b/primitives/runtime/src/generic/checked_extrinsic.rs index 929d702661..3940943a59 100644 --- a/primitives/runtime/src/generic/checked_extrinsic.rs +++ b/primitives/runtime/src/generic/checked_extrinsic.rs @@ -27,7 +27,7 @@ use crate::transaction_validity::TransactionValidity; /// Definition of something that the external world might want to say; its /// existence implies that it has been checked and is good, particularly with /// regards to the signature. -#[derive(PartialEq, Eq, Clone, primitives::RuntimeDebug)] +#[derive(PartialEq, Eq, Clone, sp_core::RuntimeDebug)] pub struct CheckedExtrinsic { /// Who this purports to be from and the number of extrinsics have come before /// from the same signer, if anyone (note this is not a signature). diff --git a/primitives/runtime/src/generic/digest.rs b/primitives/runtime/src/generic/digest.rs index c74d09076b..9e241d9a48 100644 --- a/primitives/runtime/src/generic/digest.rs +++ b/primitives/runtime/src/generic/digest.rs @@ -23,7 +23,7 @@ use sp_std::prelude::*; use crate::ConsensusEngineId; use crate::codec::{Decode, Encode, Input, Error}; -use primitives::RuntimeDebug; +use sp_core::RuntimeDebug; /// Generic header digest. #[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug)] @@ -105,7 +105,7 @@ pub enum DigestItem { impl serde::Serialize for DigestItem { fn serialize(&self, seq: S) -> Result where S: serde::Serializer { self.using_encoded(|bytes| { - primitives::bytes::serialize(bytes, seq) + sp_core::bytes::serialize(bytes, seq) }) } } @@ -115,7 +115,7 @@ impl<'a, Hash: Decode> serde::Deserialize<'a> for DigestItem { fn deserialize(de: D) -> Result where D: serde::Deserializer<'a>, { - let r = primitives::bytes::deserialize(de)?; + let r = sp_core::bytes::deserialize(de)?; Decode::decode(&mut &r[..]) .map_err(|e| serde::de::Error::custom(format!("Decode error: {}", e))) } diff --git a/primitives/runtime/src/generic/era.rs b/primitives/runtime/src/generic/era.rs index 305951b1ee..c72e8f8b0f 100644 --- a/primitives/runtime/src/generic/era.rs +++ b/primitives/runtime/src/generic/era.rs @@ -28,7 +28,7 @@ pub type Period = u64; pub type Phase = u64; /// An era to describe the longevity of a transaction. -#[derive(PartialEq, Eq, Clone, Copy, primitives::RuntimeDebug)] +#[derive(PartialEq, Eq, Clone, Copy, sp_core::RuntimeDebug)] #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] pub enum Era { /// The transaction is valid forever. The genesis hash must be present in the signed content. diff --git a/primitives/runtime/src/generic/header.rs b/primitives/runtime/src/generic/header.rs index aa47966956..c095490bc9 100644 --- a/primitives/runtime/src/generic/header.rs +++ b/primitives/runtime/src/generic/header.rs @@ -24,14 +24,14 @@ use crate::traits::{ MaybeSerializeDeserialize, MaybeSerialize, MaybeDisplay, }; use crate::generic::Digest; -use primitives::U256; +use sp_core::U256; use sp_std::{ convert::TryFrom, fmt::Debug, }; /// Abstraction over a block header for a substrate chain. -#[derive(PartialEq, Eq, Clone, primitives::RuntimeDebug)] +#[derive(PartialEq, Eq, Clone, sp_core::RuntimeDebug)] #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] #[cfg_attr(feature = "std", serde(rename_all = "camelCase"))] #[cfg_attr(feature = "std", serde(deny_unknown_fields))] diff --git a/primitives/runtime/src/generic/tests.rs b/primitives/runtime/src/generic/tests.rs index 67e85da374..fed9f6ec60 100644 --- a/primitives/runtime/src/generic/tests.rs +++ b/primitives/runtime/src/generic/tests.rs @@ -17,7 +17,7 @@ //! Tests for the generic implementations of Extrinsic/Header/Block. use crate::codec::{Decode, Encode}; -use primitives::H256; +use sp_core::H256; use super::DigestItem; #[test] diff --git a/primitives/runtime/src/lib.rs b/primitives/runtime/src/lib.rs index 8bfd4834c5..db039d5b75 100644 --- a/primitives/runtime/src/lib.rs +++ b/primitives/runtime/src/lib.rs @@ -35,14 +35,14 @@ pub use sp_std; pub use paste; #[doc(hidden)] -pub use app_crypto; +pub use sp_application_crypto as app_crypto; #[cfg(feature = "std")] -pub use primitives::storage::{Storage, StorageChild}; +pub use sp_core::storage::{Storage, StorageChild}; use sp_std::prelude::*; use sp_std::convert::TryFrom; -use primitives::{crypto, ed25519, sr25519, ecdsa, hash::{H256, H512}}; +use sp_core::{crypto, ed25519, sr25519, ecdsa, hash::{H256, H512}}; use codec::{Encode, Decode}; pub mod curve; @@ -58,18 +58,18 @@ pub mod random_number_generator; pub use generic::{DigestItem, Digest}; /// Re-export this since it's part of the API of this crate. -pub use primitives::{TypeId, crypto::{key_types, KeyTypeId, CryptoType, AccountId32}}; -pub use app_crypto::{RuntimeAppPublic, BoundToRuntimeAppPublic}; +pub use sp_core::{TypeId, crypto::{key_types, KeyTypeId, CryptoType, AccountId32}}; +pub use sp_application_crypto::{RuntimeAppPublic, BoundToRuntimeAppPublic}; /// Re-export `RuntimeDebug`, to avoid dependency clutter. -pub use primitives::RuntimeDebug; +pub use sp_core::RuntimeDebug; /// Re-export top-level arithmetic stuff. -pub use arithmetic::{Perquintill, Perbill, Permill, Percent, Rational128, Fixed64}; +pub use sp_arithmetic::{Perquintill, Perbill, Permill, Percent, Rational128, Fixed64}; /// Re-export 128 bit helpers. -pub use arithmetic::helpers_128bit; +pub use sp_arithmetic::helpers_128bit; /// Re-export big_uint stuff. -pub use arithmetic::biguint; +pub use sp_arithmetic::biguint; pub use random_number_generator::RandomNumberGenerator; @@ -121,7 +121,7 @@ use crate::traits::IdentifyAccount; #[cfg(feature = "std")] pub trait BuildStorage: Sized { /// Build the storage out of this builder. - fn build_storage(&self) -> Result { + fn build_storage(&self) -> Result { let mut storage = Default::default(); self.assimilate_storage(&mut storage)?; Ok(storage) @@ -129,7 +129,7 @@ pub trait BuildStorage: Sized { /// Assimilate the storage for this module into pre-existing overlays. fn assimilate_storage( &self, - storage: &mut primitives::storage::Storage, + storage: &mut sp_core::storage::Storage, ) -> Result<(), String>; } @@ -139,15 +139,15 @@ pub trait BuildModuleGenesisStorage: Sized { /// Create the module genesis storage into the given `storage` and `child_storage`. fn build_module_genesis_storage( &self, - storage: &mut primitives::storage::Storage, + storage: &mut sp_core::storage::Storage, ) -> Result<(), String>; } #[cfg(feature = "std")] -impl BuildStorage for primitives::storage::Storage { +impl BuildStorage for sp_core::storage::Storage { fn assimilate_storage( &self, - storage: &mut primitives::storage::Storage, + storage: &mut sp_core::storage::Storage, )-> Result<(), String> { storage.top.extend(self.top.iter().map(|(k, v)| (k.clone(), v.clone()))); for (k, other_map) in self.children.iter() { @@ -304,7 +304,7 @@ impl std::fmt::Display for MultiSigner { impl Verify for MultiSignature { type Signer = MultiSigner; fn verify>(&self, mut msg: L, signer: &AccountId32) -> bool { - use primitives::crypto::Public; + use sp_core::crypto::Public; match (self, signer) { (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())), @@ -329,7 +329,7 @@ pub struct AnySignature(H512); impl Verify for AnySignature { type Signer = sr25519::Public; fn verify>(&self, mut msg: L, signer: &sr25519::Public) -> bool { - use primitives::crypto::Public; + use sp_core::crypto::Public; let msg = msg.get(); sr25519::Signature::try_from(self.0.as_fixed_bytes().as_ref()) .map(|s| s.verify(msg, signer)) @@ -619,7 +619,7 @@ pub struct OpaqueExtrinsic(pub Vec); impl sp_std::fmt::Debug for OpaqueExtrinsic { #[cfg(feature = "std")] fn fmt(&self, fmt: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { - write!(fmt, "{}", primitives::hexdisplay::HexDisplay::from(&self.0)) + write!(fmt, "{}", sp_core::hexdisplay::HexDisplay::from(&self.0)) } #[cfg(not(feature = "std"))] @@ -632,14 +632,14 @@ impl sp_std::fmt::Debug for OpaqueExtrinsic { #[cfg(feature = "std")] impl ::serde::Serialize for OpaqueExtrinsic { fn serialize(&self, seq: S) -> Result where S: ::serde::Serializer { - codec::Encode::using_encoded(&self.0, |bytes| ::primitives::bytes::serialize(bytes, seq)) + codec::Encode::using_encoded(&self.0, |bytes| ::sp_core::bytes::serialize(bytes, seq)) } } #[cfg(feature = "std")] impl<'a> ::serde::Deserialize<'a> for OpaqueExtrinsic { fn deserialize(de: D) -> Result where D: ::serde::Deserializer<'a> { - let r = ::primitives::bytes::deserialize(de)?; + let r = ::sp_core::bytes::deserialize(de)?; Decode::decode(&mut &r[..]) .map_err(|e| ::serde::de::Error::custom(format!("Decode error: {}", e))) } diff --git a/primitives/runtime/src/offchain/http.rs b/primitives/runtime/src/offchain/http.rs index 5110aede13..968d50daee 100644 --- a/primitives/runtime/src/offchain/http.rs +++ b/primitives/runtime/src/offchain/http.rs @@ -51,8 +51,8 @@ use sp_std::str; use sp_std::prelude::Vec; #[cfg(not(feature = "std"))] use sp_std::prelude::vec; -use primitives::RuntimeDebug; -use primitives::offchain::{ +use sp_core::RuntimeDebug; +use sp_core::offchain::{ Timestamp, HttpRequestId as RequestId, HttpRequestStatus as RequestStatus, @@ -516,7 +516,7 @@ impl<'a> HeadersIterator<'a> { mod tests { use super::*; use sp_io::TestExternalities; - use primitives::offchain::{ + use sp_core::offchain::{ OffchainExt, testing, }; diff --git a/primitives/runtime/src/testing.rs b/primitives/runtime/src/testing.rs index e77b7c23b4..4fb7ccade7 100644 --- a/primitives/runtime/src/testing.rs +++ b/primitives/runtime/src/testing.rs @@ -26,8 +26,8 @@ use crate::traits::{ #[allow(deprecated)] use crate::traits::ValidateUnsigned; use crate::{generic, KeyTypeId, ApplyExtrinsicResult}; -pub use primitives::{H256, sr25519}; -use primitives::{crypto::{CryptoType, Dummy, key_types, Public}, U256}; +pub use sp_core::{H256, sr25519}; +use sp_core::{crypto::{CryptoType, Dummy, key_types, Public}, U256}; use crate::transaction_validity::{TransactionValidity, TransactionValidityError}; /// Authority Id @@ -80,7 +80,7 @@ impl UintAuthorityId { } } -impl app_crypto::RuntimeAppPublic for UintAuthorityId { +impl sp_application_crypto::RuntimeAppPublic for UintAuthorityId { const ID: KeyTypeId = key_types::DUMMY; type Signature = u64; diff --git a/primitives/runtime/src/traits.rs b/primitives/runtime/src/traits.rs index de74c949db..0001690b38 100644 --- a/primitives/runtime/src/traits.rs +++ b/primitives/runtime/src/traits.rs @@ -23,18 +23,18 @@ use sp_io; use std::fmt::Display; #[cfg(feature = "std")] use serde::{Serialize, Deserialize, de::DeserializeOwned}; -use primitives::{self, Hasher, Blake2Hasher, TypeId}; +use sp_core::{self, Hasher, Blake2Hasher, TypeId}; use crate::codec::{Codec, Encode, Decode}; use crate::transaction_validity::{ ValidTransaction, TransactionValidity, TransactionValidityError, UnknownTransaction, }; use crate::generic::{Digest, DigestItem}; -pub use arithmetic::traits::{ +pub use sp_arithmetic::traits::{ SimpleArithmetic, UniqueSaturatedInto, UniqueSaturatedFrom, Saturating, SaturatedConversion, Zero, One, Bounded, CheckedAdd, CheckedSub, CheckedMul, CheckedDiv, CheckedShl, CheckedShr, IntegerSquareRoot }; -use app_crypto::AppKey; +use sp_application_crypto::AppKey; use impl_trait_for_tuples::impl_for_tuples; /// A lazy value. @@ -58,17 +58,17 @@ pub trait IdentifyAccount { fn into_account(self) -> Self::AccountId; } -impl IdentifyAccount for primitives::ed25519::Public { +impl IdentifyAccount for sp_core::ed25519::Public { type AccountId = Self; fn into_account(self) -> Self { self } } -impl IdentifyAccount for primitives::sr25519::Public { +impl IdentifyAccount for sp_core::sr25519::Public { type AccountId = Self; fn into_account(self) -> Self { self } } -impl IdentifyAccount for primitives::ecdsa::Public { +impl IdentifyAccount for sp_core::ecdsa::Public { type AccountId = Self; fn into_account(self) -> Self { self } } @@ -81,23 +81,23 @@ pub trait Verify { fn verify>(&self, msg: L, signer: &::AccountId) -> bool; } -impl Verify for primitives::ed25519::Signature { - type Signer = primitives::ed25519::Public; - fn verify>(&self, mut msg: L, signer: &primitives::ed25519::Public) -> bool { +impl Verify for sp_core::ed25519::Signature { + type Signer = sp_core::ed25519::Public; + fn verify>(&self, mut msg: L, signer: &sp_core::ed25519::Public) -> bool { 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 { +impl Verify for sp_core::sr25519::Signature { + type Signer = sp_core::sr25519::Public; + fn verify>(&self, mut msg: L, signer: &sp_core::sr25519::Public) -> bool { 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 { +impl Verify for sp_core::ecdsa::Signature { + type Signer = sp_core::ecdsa::Public; + fn verify>(&self, mut msg: L, signer: &sp_core::ecdsa::Public) -> bool { match sp_io::crypto::secp256k1_ecdsa_recover_compressed( self.as_ref(), &sp_io::hashing::blake2_256(msg.get()), @@ -117,19 +117,19 @@ pub trait AppVerify { } impl< - S: Verify::Public as app_crypto::AppPublic>::Generic> + From, - T: app_crypto::Wraps + app_crypto::AppKey + app_crypto::AppSignature + + S: Verify::Public as sp_application_crypto::AppPublic>::Generic> + From, + T: sp_application_crypto::Wraps + sp_application_crypto::AppKey + sp_application_crypto::AppSignature + AsRef + AsMut + From, > AppVerify for T where ::Signer: IdentifyAccount::Signer>, - <::Public as app_crypto::AppPublic>::Generic: - IdentifyAccount::Public as app_crypto::AppPublic>::Generic>, + <::Public as sp_application_crypto::AppPublic>::Generic: + IdentifyAccount::Public as sp_application_crypto::AppPublic>::Generic>, { type AccountId = ::Public; fn verify>(&self, msg: L, signer: &::Public) -> bool { - use app_crypto::IsWrappedBy; + use sp_application_crypto::IsWrappedBy; let inner: &S = self.as_ref(); - let inner_pubkey = <::Public as app_crypto::AppPublic>::Generic::from_ref(&signer); + let inner_pubkey = <::Public as sp_application_crypto::AppPublic>::Generic::from_ref(&signer); Verify::verify(inner, msg, inner_pubkey) } } @@ -391,12 +391,12 @@ pub trait Hash: 'static + MaybeSerializeDeserialize + Debug + Clone + Eq + Parti } /// Blake2-256 Hash implementation. -#[derive(PartialEq, Eq, Clone, primitives::RuntimeDebug)] +#[derive(PartialEq, Eq, Clone, sp_core::RuntimeDebug)] #[cfg_attr(feature = "std", derive(Serialize, Deserialize))] pub struct BlakeTwo256; impl Hash for BlakeTwo256 { - type Output = primitives::H256; + type Output = sp_core::H256; type Hasher = Blake2Hasher; fn hash(s: &[u8]) -> Self::Output { sp_io::hashing::blake2_256(s).into() @@ -417,10 +417,10 @@ pub trait CheckEqual { fn check_equal(&self, other: &Self); } -impl CheckEqual for primitives::H256 { +impl CheckEqual for sp_core::H256 { #[cfg(feature = "std")] fn check_equal(&self, other: &Self) { - use primitives::hexdisplay::HexDisplay; + use sp_core::hexdisplay::HexDisplay; if self != other { println!( "Hash: given={}, expected={}", @@ -1281,8 +1281,8 @@ mod tests { use crate::codec::{Encode, Decode, Input}; mod t { - use primitives::crypto::KeyTypeId; - use app_crypto::{app_crypto, sr25519}; + use sp_core::crypto::KeyTypeId; + use sp_application_crypto::{app_crypto, sr25519}; app_crypto!(sr25519, KeyTypeId(*b"test")); } diff --git a/primitives/sandbox/Cargo.toml b/primitives/sandbox/Cargo.toml index 6f8d518c49..d02c115501 100755 --- a/primitives/sandbox/Cargo.toml +++ b/primitives/sandbox/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" [dependencies] wasmi = { version = "0.6.2", optional = true } -primitives = { package = "sp-core", path = "../core", default-features = false } +sp-core = { path = "../core", default-features = false } sp-std = { path = "../std", default-features = false } sp-io = { path = "../io", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } @@ -19,7 +19,7 @@ assert_matches = "1.3.0" default = ["std"] std = [ "wasmi", - "primitives/std", + "sp-core/std", "sp-std/std", "codec/std", "sp-io/std", diff --git a/primitives/sandbox/src/lib.rs b/primitives/sandbox/src/lib.rs index a006655c78..448cadfe80 100755 --- a/primitives/sandbox/src/lib.rs +++ b/primitives/sandbox/src/lib.rs @@ -40,7 +40,7 @@ use sp_std::prelude::*; -pub use primitives::sandbox::{TypedValue, ReturnValue, HostError}; +pub use sp_core::sandbox::{TypedValue, ReturnValue, HostError}; mod imp { #[cfg(feature = "std")] @@ -51,7 +51,7 @@ mod imp { } /// Error that can occur while using this crate. -#[derive(primitives::RuntimeDebug)] +#[derive(sp_core::RuntimeDebug)] pub enum Error { /// Module is not valid, couldn't be instantiated. Module, diff --git a/primitives/sandbox/without_std.rs b/primitives/sandbox/without_std.rs index 68956db8bf..e76bbe7285 100755 --- a/primitives/sandbox/without_std.rs +++ b/primitives/sandbox/without_std.rs @@ -14,11 +14,11 @@ // You should have received a copy of the GNU General Public License // along with Substrate. If not, see . -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 sp_core::sandbox as sandbox_primitives; use sp_io::sandbox; +use sp_std::{prelude::*, slice, marker, mem, vec, rc::Rc}; +use super::{Error, TypedValue, ReturnValue, HostFuncType}; mod ffi { use sp_std::mem; diff --git a/primitives/state-machine/Cargo.toml b/primitives/state-machine/Cargo.toml index cd721c17fd..73e943011c 100644 --- a/primitives/state-machine/Cargo.toml +++ b/primitives/state-machine/Cargo.toml @@ -11,13 +11,13 @@ parking_lot = "0.9.0" hash-db = "0.15.2" trie-db = "0.16.0" trie-root = "0.15.2" -trie = { package = "sp-trie", path = "../trie" } -primitives = { package = "sp-core", path = "../core" } -panic-handler = { package = "sp-panic-handler", path = "../panic-handler" } +sp-trie = { path = "../trie" } +sp-core = { path = "../core" } +sp-panic-handler = { path = "../panic-handler" } codec = { package = "parity-scale-codec", version = "1.0.0" } num-traits = "0.2.8" rand = "0.7.2" -externalities = { package = "sp-externalities", path = "../externalities" } +sp-externalities = { path = "../externalities" } [dev-dependencies] hex-literal = "0.2.1" diff --git a/primitives/state-machine/src/backend.rs b/primitives/state-machine/src/backend.rs index 8a6ba25731..7a5357c398 100644 --- a/primitives/state-machine/src/backend.rs +++ b/primitives/state-machine/src/backend.rs @@ -21,12 +21,12 @@ use log::warn; use hash_db::Hasher; use crate::trie_backend::TrieBackend; use crate::trie_backend_essence::TrieBackendStorage; -use trie::{ +use sp_trie::{ TrieMut, MemoryDB, child_trie_root, default_child_trie_root, TrieConfiguration, trie_types::{TrieDBMut, Layout}, }; use codec::{Encode, Codec}; -use primitives::storage::{ChildInfo, OwnedChildInfo, Storage}; +use sp_core::storage::{ChildInfo, OwnedChildInfo, Storage}; /// A state backend is used to read state data and can have changes committed /// to it. @@ -311,9 +311,9 @@ impl Consolidate for Vec<( } } -impl> Consolidate for trie::GenericMemoryDB { +impl> Consolidate for sp_trie::GenericMemoryDB { fn consolidate(&mut self, other: Self) { - trie::GenericMemoryDB::consolidate(self, other) + sp_trie::GenericMemoryDB::consolidate(self, other) } } @@ -564,7 +564,7 @@ impl Backend for InMemory where H::Out: Codec { let storage_key = storage_key.to_vec(); let child_info = Some((storage_key.clone(), child_info.to_owned())); - + let existing_pairs = self.inner.get(&child_info) .into_iter() .flat_map(|map| map.iter().map(|(k, v)| (k.clone(), Some(v.clone())))); @@ -667,7 +667,7 @@ mod tests { /// Assert in memory backend with only child trie keys works as trie backend. #[test] fn in_memory_with_child_trie_only() { - let storage = InMemory::::default(); + let storage = InMemory::::default(); let child_info = OwnedChildInfo::new_default(b"unique_id_1".to_vec()); let mut storage = storage.update( vec![( diff --git a/primitives/state-machine/src/basic.rs b/primitives/state-machine/src/basic.rs index 62503bdee1..641d3b531c 100644 --- a/primitives/state-machine/src/basic.rs +++ b/primitives/state-machine/src/basic.rs @@ -21,9 +21,9 @@ use std::{ }; use crate::backend::{Backend, InMemory}; use hash_db::Hasher; -use trie::{TrieConfiguration, default_child_trie_root}; -use trie::trie_types::Layout; -use primitives::{ +use sp_trie::{TrieConfiguration, default_child_trie_root}; +use sp_trie::trie_types::Layout; +use sp_core::{ storage::{ well_known_keys::is_child_storage_key, ChildStorageKey, Storage, ChildInfo, StorageChild, @@ -59,7 +59,7 @@ impl BasicExternalities { /// /// Returns the result of the closure and updates `storage` with all changes. pub fn execute_with_storage( - storage: &mut primitives::storage::Storage, + storage: &mut sp_core::storage::Storage, f: impl FnOnce() -> R, ) -> R { let mut ext = Self { inner: Storage { @@ -78,7 +78,7 @@ impl BasicExternalities { /// /// Returns the result of the given closure. pub fn execute_with(&mut self, f: impl FnOnce() -> R) -> R { - externalities::set_and_run_with_externalities(self, f) + sp_externalities::set_and_run_with_externalities(self, f) } } @@ -300,7 +300,7 @@ impl Externalities for BasicExternalities { } } -impl externalities::ExtensionStore for BasicExternalities { +impl sp_externalities::ExtensionStore for BasicExternalities { fn extension_by_type_id(&mut self, _: TypeId) -> Option<&mut dyn Any> { warn!("Extensions are not supported by `BasicExternalities`."); None @@ -310,9 +310,9 @@ impl externalities::ExtensionStore for BasicExternalities { #[cfg(test)] mod tests { use super::*; - use primitives::map; - use primitives::storage::{Storage, StorageChild}; - use primitives::storage::well_known_keys::CODE; + use sp_core::map; + use sp_core::storage::{Storage, StorageChild}; + use sp_core::storage::well_known_keys::CODE; use hex_literal::hex; const CHILD_INFO_1: ChildInfo<'static> = ChildInfo::new_default(b"unique_id_1"); diff --git a/primitives/state-machine/src/changes_trie/build.rs b/primitives/state-machine/src/changes_trie/build.rs index 4bb7b6c0aa..356c8614e2 100644 --- a/primitives/state-machine/src/changes_trie/build.rs +++ b/primitives/state-machine/src/changes_trie/build.rs @@ -153,7 +153,7 @@ fn prepare_extrinsics_input_inner<'a, B, H, Number>( // AND are not in storage at the beginning of operation if let Some(sk) = storage_key.as_ref() { if !changes.child_storage(sk, k).map(|v| v.is_some()).unwrap_or_default() { - if let Some(child_info) = child_info.as_ref() { + if let Some(child_info) = child_info.as_ref() { if !backend.exists_child_storage(sk, child_info.as_ref(), k) .map_err(|e| format!("{}", e))? { return Ok(map); @@ -338,9 +338,9 @@ fn prepare_digest_input<'a, H, Number>( #[cfg(test)] mod test { use codec::Encode; - use primitives::Blake2Hasher; - use primitives::storage::well_known_keys::{EXTRINSIC_INDEX}; - use primitives::storage::ChildInfo; + use sp_core::Blake2Hasher; + use sp_core::storage::well_known_keys::{EXTRINSIC_INDEX}; + use sp_core::storage::ChildInfo; use crate::backend::InMemory; use crate::changes_trie::{RootsStorage, Configuration, storage::InMemoryStorage}; use crate::changes_trie::build_cache::{IncompleteCacheAction, IncompleteCachedBuildData}; diff --git a/primitives/state-machine/src/changes_trie/changes_iterator.rs b/primitives/state-machine/src/changes_trie/changes_iterator.rs index 017eb33d52..f62575f451 100644 --- a/primitives/state-machine/src/changes_trie/changes_iterator.rs +++ b/primitives/state-machine/src/changes_trie/changes_iterator.rs @@ -22,7 +22,7 @@ use std::collections::VecDeque; use codec::{Decode, Encode, Codec}; use hash_db::Hasher; use num_traits::Zero; -use trie::Recorder; +use sp_trie::Recorder; use crate::changes_trie::{AnchorBlockId, ConfigurationRange, RootsStorage, Storage, BlockNumber}; use crate::changes_trie::input::{DigestIndex, ExtrinsicIndex, DigestIndexValue, ExtrinsicIndexValue}; use crate::changes_trie::storage::{TrieBackendAdapter, InMemoryStorage}; @@ -376,7 +376,7 @@ impl<'a, H, Number> Iterator for ProvingDrilldownIterator<'a, H, Number> #[cfg(test)] mod tests { use std::iter::FromIterator; - use primitives::Blake2Hasher; + use sp_core::Blake2Hasher; use crate::changes_trie::Configuration; use crate::changes_trie::input::InputPair; use crate::changes_trie::storage::InMemoryStorage; diff --git a/primitives/state-machine/src/changes_trie/mod.rs b/primitives/state-machine/src/changes_trie/mod.rs index 0542ec6268..54eaa967c7 100644 --- a/primitives/state-machine/src/changes_trie/mod.rs +++ b/primitives/state-machine/src/changes_trie/mod.rs @@ -71,12 +71,12 @@ use hash_db::{Hasher, Prefix}; use crate::backend::Backend; use num_traits::{One, Zero}; use codec::{Decode, Encode}; -use primitives; +use sp_core; use crate::changes_trie::build::prepare_input; use crate::changes_trie::build_cache::{IncompleteCachedBuildData, IncompleteCacheAction}; use crate::overlayed_changes::OverlayedChanges; -use trie::{MemoryDB, DBValue, TrieMut}; -use trie::trie_types::TrieDBMut; +use sp_trie::{MemoryDB, DBValue, TrieMut}; +use sp_trie::trie_types::TrieDBMut; /// Changes that are made outside of extrinsics are marked with this index; pub const NO_EXTRINSIC_INDEX: u32 = 0xffffffff; @@ -149,7 +149,7 @@ pub trait Storage: RootsStorage { pub struct TrieBackendStorageAdapter<'a, H: Hasher, Number: BlockNumber>(pub &'a dyn Storage); impl<'a, H: Hasher, N: BlockNumber> crate::TrieBackendStorage for TrieBackendStorageAdapter<'a, H, N> { - type Overlay = trie::MemoryDB; + type Overlay = sp_trie::MemoryDB; fn get(&self, key: &H::Out, prefix: Prefix) -> Result, String> { self.0.get(key, prefix) @@ -157,7 +157,7 @@ impl<'a, H: Hasher, N: BlockNumber> crate::TrieBackendStorage for TrieBackend } /// Changes trie configuration. -pub type Configuration = primitives::ChangesTrieConfiguration; +pub type Configuration = sp_core::ChangesTrieConfiguration; /// Blocks range where configuration has been constant. #[derive(Clone)] diff --git a/primitives/state-machine/src/changes_trie/prune.rs b/primitives/state-machine/src/changes_trie/prune.rs index 2f39f9162c..c6d305ddf9 100644 --- a/primitives/state-machine/src/changes_trie/prune.rs +++ b/primitives/state-machine/src/changes_trie/prune.rs @@ -17,7 +17,7 @@ //! Changes trie pruning-related functions. use hash_db::Hasher; -use trie::Recorder; +use sp_trie::Recorder; use log::warn; use num_traits::{One, Zero}; use crate::proving_backend::ProvingBackendRecorder; @@ -202,8 +202,8 @@ fn max_digest_intervals_to_keep( #[cfg(test)] mod tests { use std::collections::HashSet; - use trie::MemoryDB; - use primitives::Blake2Hasher; + use sp_trie::MemoryDB; + use sp_core::Blake2Hasher; use crate::backend::insert_into_memory_db; use crate::changes_trie::storage::InMemoryStorage; use codec::Encode; diff --git a/primitives/state-machine/src/changes_trie/storage.rs b/primitives/state-machine/src/changes_trie/storage.rs index a82477bdc3..f9a03b6c2e 100644 --- a/primitives/state-machine/src/changes_trie/storage.rs +++ b/primitives/state-machine/src/changes_trie/storage.rs @@ -18,8 +18,8 @@ use std::collections::{BTreeMap, HashSet, HashMap}; use hash_db::{Hasher, Prefix, EMPTY_PREFIX}; -use trie::DBValue; -use trie::MemoryDB; +use sp_trie::DBValue; +use sp_trie::MemoryDB; use parking_lot::RwLock; use crate::changes_trie::{BuildCache, RootsStorage, Storage, AnchorBlockId, BlockNumber}; use crate::trie_backend_essence::TrieBackendStorage; diff --git a/primitives/state-machine/src/ext.rs b/primitives/state-machine/src/ext.rs index 9e7baea45e..32dcba634e 100644 --- a/primitives/state-machine/src/ext.rs +++ b/primitives/state-machine/src/ext.rs @@ -24,12 +24,12 @@ use crate::{ }; use hash_db::Hasher; -use primitives::{ +use sp_core::{ storage::{ChildStorageKey, well_known_keys::is_child_storage_key, ChildInfo}, traits::Externalities, hexdisplay::HexDisplay, hash::H256, }; -use trie::{trie_types::Layout, MemoryDB, default_child_trie_root}; -use externalities::Extensions; +use sp_trie::{trie_types::Layout, MemoryDB, default_child_trie_root}; +use sp_externalities::Extensions; use codec::{Decode, Encode}; use std::{error, fmt, any::{Any, TypeId}}; @@ -179,7 +179,7 @@ where N: crate::changes_trie::BlockNumber, { fn storage(&self, key: &[u8]) -> Option> { - let _guard = panic_handler::AbortGuard::force_abort(); + let _guard = sp_panic_handler::AbortGuard::force_abort(); let result = self.overlay.storage(key).map(|x| x.map(|x| x.to_vec())).unwrap_or_else(|| self.backend.storage(key).expect(EXT_NOT_ALLOWED_TO_FAIL)); trace!(target: "state-trace", "{:04x}: Get {}={:?}", @@ -191,7 +191,7 @@ where } fn storage_hash(&self, key: &[u8]) -> Option> { - let _guard = panic_handler::AbortGuard::force_abort(); + let _guard = sp_panic_handler::AbortGuard::force_abort(); let result = self.overlay .storage(key) .map(|x| x.map(|x| H::hash(x))) @@ -206,7 +206,7 @@ where } fn original_storage(&self, key: &[u8]) -> Option> { - let _guard = panic_handler::AbortGuard::force_abort(); + let _guard = sp_panic_handler::AbortGuard::force_abort(); let result = self.backend.storage(key).expect(EXT_NOT_ALLOWED_TO_FAIL); trace!(target: "state-trace", "{:04x}: GetOriginal {}={:?}", @@ -218,7 +218,7 @@ where } fn original_storage_hash(&self, key: &[u8]) -> Option> { - let _guard = panic_handler::AbortGuard::force_abort(); + let _guard = sp_panic_handler::AbortGuard::force_abort(); let result = self.backend.storage_hash(key).expect(EXT_NOT_ALLOWED_TO_FAIL); trace!(target: "state-trace", "{:04x}: GetOriginalHash {}={:?}", @@ -235,7 +235,7 @@ where child_info: ChildInfo, key: &[u8], ) -> Option> { - let _guard = panic_handler::AbortGuard::force_abort(); + let _guard = sp_panic_handler::AbortGuard::force_abort(); let result = self.overlay .child_storage(storage_key.as_ref(), key) .map(|x| x.map(|x| x.to_vec())) @@ -260,7 +260,7 @@ where _child_info: ChildInfo, key: &[u8], ) -> Option> { - let _guard = panic_handler::AbortGuard::force_abort(); + let _guard = sp_panic_handler::AbortGuard::force_abort(); let result = self.overlay .child_storage(storage_key.as_ref(), key) .map(|x| x.map(|x| H::hash(x))) @@ -284,7 +284,7 @@ where child_info: ChildInfo, key: &[u8], ) -> Option> { - let _guard = panic_handler::AbortGuard::force_abort(); + let _guard = sp_panic_handler::AbortGuard::force_abort(); let result = self.backend .child_storage(storage_key.as_ref(), child_info, key) .expect(EXT_NOT_ALLOWED_TO_FAIL); @@ -304,7 +304,7 @@ where child_info: ChildInfo, key: &[u8], ) -> Option> { - let _guard = panic_handler::AbortGuard::force_abort(); + let _guard = sp_panic_handler::AbortGuard::force_abort(); let result = self.backend .child_storage_hash(storage_key.as_ref(), child_info, key) .expect(EXT_NOT_ALLOWED_TO_FAIL); @@ -319,7 +319,7 @@ where } fn exists_storage(&self, key: &[u8]) -> bool { - let _guard = panic_handler::AbortGuard::force_abort(); + let _guard = sp_panic_handler::AbortGuard::force_abort(); let result = match self.overlay.storage(key) { Some(x) => x.is_some(), _ => self.backend.exists_storage(key).expect(EXT_NOT_ALLOWED_TO_FAIL), @@ -340,7 +340,7 @@ where child_info: ChildInfo, key: &[u8], ) -> bool { - let _guard = panic_handler::AbortGuard::force_abort(); + let _guard = sp_panic_handler::AbortGuard::force_abort(); let result = match self.overlay.child_storage(storage_key.as_ref(), key) { Some(x) => x.is_some(), @@ -408,7 +408,7 @@ where HexDisplay::from(&key), value.as_ref().map(HexDisplay::from) ); - let _guard = panic_handler::AbortGuard::force_abort(); + let _guard = sp_panic_handler::AbortGuard::force_abort(); if is_child_storage_key(&key) { warn!(target: "trie", "Refuse to directly set child storage key"); return; @@ -431,7 +431,7 @@ where HexDisplay::from(&key), value.as_ref().map(HexDisplay::from) ); - let _guard = panic_handler::AbortGuard::force_abort(); + let _guard = sp_panic_handler::AbortGuard::force_abort(); self.mark_dirty(); self.overlay.set_child_storage(storage_key.into_owned(), child_info, key, value); @@ -446,7 +446,7 @@ where self.id, HexDisplay::from(&storage_key.as_ref()), ); - let _guard = panic_handler::AbortGuard::force_abort(); + let _guard = sp_panic_handler::AbortGuard::force_abort(); self.mark_dirty(); self.overlay.clear_child_storage(storage_key.as_ref(), child_info); @@ -460,7 +460,7 @@ where self.id, HexDisplay::from(&prefix), ); - let _guard = panic_handler::AbortGuard::force_abort(); + let _guard = sp_panic_handler::AbortGuard::force_abort(); if is_child_storage_key(prefix) { warn!(target: "trie", "Refuse to directly clear prefix that is part of child storage key"); return; @@ -484,7 +484,7 @@ where HexDisplay::from(&storage_key.as_ref()), HexDisplay::from(&prefix), ); - let _guard = panic_handler::AbortGuard::force_abort(); + let _guard = sp_panic_handler::AbortGuard::force_abort(); self.mark_dirty(); self.overlay.clear_child_prefix(storage_key.as_ref(), child_info, prefix); @@ -498,7 +498,7 @@ where } fn storage_root(&mut self) -> Vec { - let _guard = panic_handler::AbortGuard::force_abort(); + let _guard = sp_panic_handler::AbortGuard::force_abort(); if let Some((_, ref root)) = self.storage_transaction { trace!(target: "state-trace", "{:04x}: Root (cached) {}", self.id, @@ -543,7 +543,7 @@ where &mut self, storage_key: ChildStorageKey, ) -> Vec { - let _guard = panic_handler::AbortGuard::force_abort(); + let _guard = sp_panic_handler::AbortGuard::force_abort(); if self.storage_transaction.is_some() { let root = self .storage(storage_key.as_ref()) @@ -611,7 +611,7 @@ where } fn storage_changes_root(&mut self, parent_hash: &[u8]) -> Result>, ()> { - let _guard = panic_handler::AbortGuard::force_abort(); + let _guard = sp_panic_handler::AbortGuard::force_abort(); self.changes_trie_transaction = build_changes_trie::<_, T, H, N>( self.backend, @@ -638,7 +638,7 @@ where } } -impl<'a, H, B, T, N> externalities::ExtensionStore for Ext<'a, H, N, B, T> +impl<'a, H, B, T, N> sp_externalities::ExtensionStore for Ext<'a, H, N, B, T> where H: Hasher, B: 'a + Backend, @@ -655,14 +655,14 @@ mod tests { use super::*; use hex_literal::hex; use codec::Encode; - use primitives::{Blake2Hasher, storage::well_known_keys::EXTRINSIC_INDEX, map}; + use sp_core::{Blake2Hasher, storage::well_known_keys::EXTRINSIC_INDEX, map}; use crate::{ changes_trie::{ Configuration as ChangesTrieConfiguration, InMemoryStorage as InMemoryChangesTrieStorage, }, backend::InMemory, overlayed_changes::OverlayedValue, }; - use primitives::storage::{Storage, StorageChild}; + use sp_core::storage::{Storage, StorageChild}; type TestBackend = InMemory; type TestChangesTrieStorage = InMemoryChangesTrieStorage; diff --git a/primitives/state-machine/src/lib.rs b/primitives/state-machine/src/lib.rs index e8043829e7..86cae2dfbb 100644 --- a/primitives/state-machine/src/lib.rs +++ b/primitives/state-machine/src/lib.rs @@ -22,12 +22,12 @@ use std::{fmt, result, collections::HashMap, panic::UnwindSafe, marker::PhantomD use log::{warn, trace}; use hash_db::Hasher; use codec::{Decode, Encode, Codec}; -use primitives::{ +use sp_core::{ storage::{well_known_keys, ChildInfo}, NativeOrEncoded, NeverNativeValue, traits::CodeExecutor, hexdisplay::HexDisplay, hash::H256, }; use overlayed_changes::OverlayedChangeSet; -use externalities::Extensions; +use sp_externalities::Extensions; pub mod backend; mod changes_trie; @@ -40,7 +40,7 @@ mod proving_backend; mod trie_backend; mod trie_backend_essence; -pub use trie::{trie_types::{Layout, TrieDBMut}, TrieMut, DBValue, MemoryDB}; +pub use sp_trie::{trie_types::{Layout, TrieDBMut}, TrieMut, DBValue, MemoryDB}; pub use testing::TestExternalities; pub use basic::BasicExternalities; pub use ext::Ext; @@ -424,7 +424,7 @@ impl<'a, B, H, N, T, Exec> StateMachine<'a, B, H, N, T, Exec> where ExecutionManager::AlwaysWasm(trust_level) => { let _abort_guard = match trust_level { BackendTrustLevel::Trusted => None, - BackendTrustLevel::Untrusted => Some(panic_handler::AbortGuard::never_abort()), + BackendTrustLevel::Untrusted => Some(sp_panic_handler::AbortGuard::never_abort()), }; let res = self.execute_aux(compute_tx, false, native_call); (res.0, res.2, res.3) @@ -745,7 +745,7 @@ mod tests { InMemoryStorage as InMemoryChangesTrieStorage, Configuration as ChangesTrieConfig, }; - use primitives::{Blake2Hasher, map, traits::Externalities, storage::ChildStorageKey}; + use sp_core::{Blake2Hasher, map, traits::Externalities, storage::ChildStorageKey}; struct DummyCodeExecutor { change_changes_trie_config: bool, diff --git a/primitives/state-machine/src/overlayed_changes.rs b/primitives/state-machine/src/overlayed_changes.rs index 0714120ae3..f4e0de5045 100644 --- a/primitives/state-machine/src/overlayed_changes.rs +++ b/primitives/state-machine/src/overlayed_changes.rs @@ -21,7 +21,7 @@ use std::iter::FromIterator; use std::collections::{HashMap, BTreeMap, BTreeSet}; use codec::Decode; use crate::changes_trie::{NO_EXTRINSIC_INDEX, Configuration as ChangesTrieConfig}; -use primitives::storage::{well_known_keys::EXTRINSIC_INDEX, OwnedChildInfo, ChildInfo}; +use sp_core::storage::{well_known_keys::EXTRINSIC_INDEX, OwnedChildInfo, ChildInfo}; use std::{mem, ops}; /// The overlayed changes to state to be queried on top of the backend. @@ -442,7 +442,7 @@ impl From>> for OverlayedValue { #[cfg(test)] mod tests { use hex_literal::hex; - use primitives::{ + use sp_core::{ Blake2Hasher, traits::Externalities, storage::well_known_keys::EXTRINSIC_INDEX, }; use crate::backend::InMemory; diff --git a/primitives/state-machine/src/proving_backend.rs b/primitives/state-machine/src/proving_backend.rs index 3809ac8446..92ad2047a5 100644 --- a/primitives/state-machine/src/proving_backend.rs +++ b/primitives/state-machine/src/proving_backend.rs @@ -21,18 +21,18 @@ use parking_lot::RwLock; use codec::{Decode, Encode, Codec}; use log::debug; use hash_db::{Hasher, HashDB, EMPTY_PREFIX, Prefix}; -use trie::{ +use sp_trie::{ MemoryDB, PrefixedMemoryDB, default_child_trie_root, read_trie_value_with, read_child_trie_value_with, record_all_keys }; -pub use trie::Recorder; -pub use trie::trie_types::{Layout, TrieError}; +pub use sp_trie::Recorder; +pub use sp_trie::trie_types::{Layout, TrieError}; use crate::trie_backend::TrieBackend; use crate::trie_backend_essence::{Ephemeral, TrieBackendEssence, TrieBackendStorage}; use crate::{Error, ExecutionError, Backend}; use std::collections::{HashMap, HashSet}; use crate::DBValue; -use primitives::storage::ChildInfo; +use sp_core::storage::ChildInfo; /// Patricia trie-based backend specialized in get value proofs. pub struct ProvingBackendRecorder<'a, S: 'a + TrieBackendStorage, H: 'a + Hasher> { @@ -394,7 +394,7 @@ mod tests { use crate::backend::{InMemory}; use crate::trie_backend::tests::test_trie; use super::*; - use primitives::{Blake2Hasher, storage::ChildStorageKey}; + use sp_core::{Blake2Hasher, storage::ChildStorageKey}; use crate::proving_backend::create_proof_check_backend; const CHILD_INFO_1: ChildInfo<'static> = ChildInfo::new_default(b"unique_id_1"); @@ -422,7 +422,7 @@ mod tests { #[test] fn proof_is_invalid_when_does_not_contains_root() { - use primitives::H256; + use sp_core::H256; let result = create_proof_check_backend::( H256::from_low_u64_be(1), StorageProof::empty() diff --git a/primitives/state-machine/src/testing.rs b/primitives/state-machine/src/testing.rs index a37cd8caef..7bb7e7320b 100644 --- a/primitives/state-machine/src/testing.rs +++ b/primitives/state-machine/src/testing.rs @@ -26,7 +26,7 @@ use crate::{ }, ext::Ext, }; -use primitives::{ +use sp_core::{ storage::{ well_known_keys::{CHANGES_TRIE_CONFIG, CODE, HEAP_PAGES, is_child_storage_key}, Storage, @@ -34,7 +34,7 @@ use primitives::{ hash::H256, Blake2Hasher, }; use codec::Encode; -use externalities::{Extensions, Extension}; +use sp_externalities::{Extensions, Extension}; /// Simple HashMap-based Externalities impl. pub struct TestExternalities=Blake2Hasher, N: ChangesTrieBlockNumber=u64> { @@ -125,7 +125,7 @@ impl, N: ChangesTrieBlockNumber> TestExternalities { /// Returns the result of the given closure. pub fn execute_with(&mut self, execute: impl FnOnce() -> R) -> R { let mut ext = self.ext(); - externalities::set_and_run_with_externalities(&mut ext, execute) + sp_externalities::set_and_run_with_externalities(&mut ext, execute) } } @@ -153,7 +153,7 @@ impl, N: ChangesTrieBlockNumber> From for TestExter } } -impl externalities::ExtensionStore for TestExternalities where +impl sp_externalities::ExtensionStore for TestExternalities where H: Hasher, N: ChangesTrieBlockNumber, { @@ -165,7 +165,7 @@ impl externalities::ExtensionStore for TestExternalities where #[cfg(test)] mod tests { use super::*; - use primitives::traits::Externalities; + use sp_core::traits::Externalities; use hex_literal::hex; #[test] diff --git a/primitives/state-machine/src/trie_backend.rs b/primitives/state-machine/src/trie_backend.rs index 5286f0e505..4b48bec31b 100644 --- a/primitives/state-machine/src/trie_backend.rs +++ b/primitives/state-machine/src/trie_backend.rs @@ -18,11 +18,11 @@ use log::{warn, debug}; use hash_db::Hasher; -use trie::{Trie, delta_trie_root, default_child_trie_root, child_delta_trie_root}; -use trie::trie_types::{TrieDB, TrieError, Layout}; +use sp_trie::{Trie, delta_trie_root, default_child_trie_root, child_delta_trie_root}; +use sp_trie::trie_types::{TrieDB, TrieError, Layout}; use crate::trie_backend_essence::{TrieBackendEssence, TrieBackendStorage, Ephemeral}; use crate::Backend; -use primitives::storage::ChildInfo; +use sp_core::storage::ChildInfo; use codec::{Codec, Decode}; /// Patricia trie-based backend. Transaction type is an overlay of changes to commit. @@ -243,9 +243,9 @@ impl, H: Hasher> Backend for TrieBackend where #[cfg(test)] pub mod tests { use std::collections::HashSet; - use primitives::{Blake2Hasher, H256}; + use sp_core::{Blake2Hasher, H256}; use codec::Encode; - use trie::{TrieMut, PrefixedMemoryDB, trie_types::TrieDBMut, KeySpacedDBMut}; + use sp_trie::{TrieMut, PrefixedMemoryDB, trie_types::TrieDBMut, KeySpacedDBMut}; use super::*; const CHILD_KEY_1: &[u8] = b":child_storage:default:sub1"; diff --git a/primitives/state-machine/src/trie_backend_essence.rs b/primitives/state-machine/src/trie_backend_essence.rs index cd8f686a92..75601373ed 100644 --- a/primitives/state-machine/src/trie_backend_essence.rs +++ b/primitives/state-machine/src/trie_backend_essence.rs @@ -21,12 +21,12 @@ use std::ops::Deref; use std::sync::Arc; use log::{debug, warn}; use hash_db::{self, Hasher, EMPTY_PREFIX, Prefix}; -use trie::{Trie, MemoryDB, PrefixedMemoryDB, DBValue, +use sp_trie::{Trie, MemoryDB, PrefixedMemoryDB, DBValue, default_child_trie_root, read_trie_value, read_child_trie_value, for_keys_in_child_trie, KeySpacedDB}; -use trie::trie_types::{TrieDB, TrieError, Layout}; +use sp_trie::trie_types::{TrieDB, TrieError, Layout}; use crate::backend::Consolidate; -use primitives::storage::ChildInfo; +use sp_core::storage::ChildInfo; use codec::Encode; /// Patricia trie-based storage trait. @@ -250,7 +250,7 @@ impl, H: Hasher> TrieBackendEssence where H::Out: storage: &self.storage, overlay: &mut read_overlay, }; - + let mut iter = move |db| -> Result<(), Box>> { let trie = TrieDB::::new(db, root)?; let mut iter = trie.iter()?; @@ -448,8 +448,8 @@ impl TrieBackendStorage for MemoryDB { #[cfg(test)] mod test { - use primitives::{Blake2Hasher, H256}; - use trie::{TrieMut, PrefixedMemoryDB, trie_types::TrieDBMut, KeySpacedDBMut}; + use sp_core::{Blake2Hasher, H256}; + use sp_trie::{TrieMut, PrefixedMemoryDB, trie_types::TrieDBMut, KeySpacedDBMut}; use super::*; #[test] diff --git a/primitives/test-primitives/Cargo.toml b/primitives/test-primitives/Cargo.toml index d8d66e91c4..1301887241 100644 --- a/primitives/test-primitives/Cargo.toml +++ b/primitives/test-primitives/Cargo.toml @@ -5,9 +5,9 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -app-crypto = { package = "sp-application-crypto", path = "../application-crypto", default-features = false } +sp-application-crypto = { path = "../application-crypto", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -primitives = { package = "sp-core", path = "../core", default-features = false } +sp-core = { path = "../core", default-features = false } serde = { version = "1.0.101", optional = true, features = ["derive"] } sp-runtime = { path = "../runtime", default-features = false } @@ -16,6 +16,6 @@ default = [ "std", ] std = [ - "app-crypto/std", + "sp-application-crypto/std", "serde", ] diff --git a/primitives/test-primitives/src/lib.rs b/primitives/test-primitives/src/lib.rs index 4acf10bbdf..d95b9cb3e2 100644 --- a/primitives/test-primitives/src/lib.rs +++ b/primitives/test-primitives/src/lib.rs @@ -20,10 +20,10 @@ use codec::{Encode, Decode}; -use app_crypto::sr25519; -pub use app_crypto; +use sp_application_crypto::sr25519; +pub use sp_application_crypto; -pub use primitives::{hash::H256, RuntimeDebug}; +pub use sp_core::{hash::H256, RuntimeDebug}; use sp_runtime::traits::{BlakeTwo256, Verify, Extrinsic as ExtrinsicT,}; /// Extrinsic for test-runtime. @@ -79,8 +79,8 @@ pub type Header = sp_runtime::generic::Header; /// Changes trie configuration (optionally) used in tests. -pub fn changes_trie_config() -> primitives::ChangesTrieConfiguration { - primitives::ChangesTrieConfiguration { +pub fn changes_trie_config() -> sp_core::ChangesTrieConfiguration { + sp_core::ChangesTrieConfiguration { digest_interval: 4, digest_levels: 2, } diff --git a/primitives/timestamp/Cargo.toml b/primitives/timestamp/Cargo.toml index 8661a44a44..a11e4bce40 100644 --- a/primitives/timestamp/Cargo.toml +++ b/primitives/timestamp/Cargo.toml @@ -9,7 +9,7 @@ sp-api = { path = "../api", default-features = false } sp-std = { path = "../std", default-features = false } sp-runtime = { path = "../runtime", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -inherents = { package = "sp-inherents", path = "../inherents", default-features = false } +sp-inherents = { path = "../inherents", default-features = false } impl-trait-for-tuples = "0.1.3" [features] @@ -19,5 +19,5 @@ std = [ "sp-std/std", "sp-runtime/std", "codec/std", - "inherents/std", + "sp-inherents/std", ] diff --git a/primitives/timestamp/src/lib.rs b/primitives/timestamp/src/lib.rs index 6b20e11ef4..9306e14ca8 100644 --- a/primitives/timestamp/src/lib.rs +++ b/primitives/timestamp/src/lib.rs @@ -22,8 +22,8 @@ use codec::Encode; #[cfg(feature = "std")] use codec::Decode; #[cfg(feature = "std")] -use inherents::ProvideInherentData; -use inherents::{InherentIdentifier, IsFatalError, InherentData}; +use sp_inherents::ProvideInherentData; +use sp_inherents::{InherentIdentifier, IsFatalError, InherentData}; use sp_runtime::RuntimeString; @@ -67,11 +67,11 @@ impl InherentError { /// Auxiliary trait to extract timestamp inherent data. pub trait TimestampInherentData { /// Get timestamp inherent data. - fn timestamp_inherent_data(&self) -> Result; + fn timestamp_inherent_data(&self) -> Result; } impl TimestampInherentData for InherentData { - fn timestamp_inherent_data(&self) -> Result { + fn timestamp_inherent_data(&self) -> Result { self.get_data(&INHERENT_IDENTIFIER) .and_then(|r| r.ok_or_else(|| "Timestamp inherent data not found".into())) } @@ -89,7 +89,7 @@ impl ProvideInherentData for InherentDataProvider { fn provide_inherent_data( &self, inherent_data: &mut InherentData, - ) -> Result<(), inherents::Error> { + ) -> Result<(), sp_inherents::Error> { use std::time::SystemTime; let now = SystemTime::now(); diff --git a/primitives/trie/Cargo.toml b/primitives/trie/Cargo.toml index e77d5665b4..974246b0e4 100644 --- a/primitives/trie/Cargo.toml +++ b/primitives/trie/Cargo.toml @@ -18,7 +18,7 @@ hash-db = { version = "0.15.2", default-features = false } trie-db = { version = "0.16.0", default-features = false } trie-root = { version = "0.15.2", default-features = false } memory-db = { version = "0.15.2", default-features = false } -primitives = { package = "sp-core", path = "../core", default-features = false } +sp-core = { path = "../core", default-features = false } [dev-dependencies] trie-bench = "0.17.0" @@ -35,5 +35,5 @@ std = [ "memory-db/std", "trie-db/std", "trie-root/std", - "primitives/std", + "sp-core/std", ] diff --git a/primitives/trie/benches/bench.rs b/primitives/trie/benches/bench.rs index 347426d0c5..353644ee1e 100644 --- a/primitives/trie/benches/bench.rs +++ b/primitives/trie/benches/bench.rs @@ -20,11 +20,11 @@ criterion_main!(benches); fn benchmark(c: &mut Criterion) { trie_bench::standard_benchmark::< - sp_trie::Layout, + sp_trie::Layout, sp_trie::TrieStream, >(c, "substrate-blake2"); trie_bench::standard_benchmark::< - sp_trie::Layout, + sp_trie::Layout, sp_trie::TrieStream, >(c, "substrate-keccak"); } diff --git a/primitives/trie/src/lib.rs b/primitives/trie/src/lib.rs index 244752f44b..08f26e0063 100644 --- a/primitives/trie/src/lib.rs +++ b/primitives/trie/src/lib.rs @@ -425,7 +425,7 @@ mod trie_constants { mod tests { use super::*; use codec::{Encode, Compact}; - use primitives::Blake2Hasher; + use sp_core::Blake2Hasher; use hash_db::{HashDB, Hasher}; use trie_db::{DBValue, TrieMut, Trie, NodeCodec as NodeCodecT}; use trie_standardmap::{Alphabet, ValueMode, StandardMap}; diff --git a/primitives/trie/src/node_header.rs b/primitives/trie/src/node_header.rs index 34586d8b52..43d71e33b3 100644 --- a/primitives/trie/src/node_header.rs +++ b/primitives/trie/src/node_header.rs @@ -22,7 +22,7 @@ use sp_std::iter::once; /// A node header #[derive(Copy, Clone, PartialEq, Eq)] -#[derive(primitives::RuntimeDebug)] +#[derive(sp_core::RuntimeDebug)] pub(crate) enum NodeHeader { Null, Branch(bool, usize), diff --git a/test-utils/client/Cargo.toml b/test-utils/client/Cargo.toml index d89a75d137..df0bb1738a 100644 --- a/test-utils/client/Cargo.toml +++ b/test-utils/client/Cargo.toml @@ -5,16 +5,16 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -client-api = { package = "sc-client-api", path = "../../client/api" } -client = { package = "sc-client", path = "../../client/" } -client-db = { package = "sc-client-db", path = "../../client//db", features = ["test-helpers"] } -consensus = { package = "sp-consensus", path = "../../primitives/consensus/common" } -executor = { package = "sc-executor", path = "../../client/executor" } +sc-client-api = { path = "../../client/api" } +sc-client = { path = "../../client/" } +sc-client-db = { path = "../../client/db", features = ["test-helpers"] } +sp-consensus = { path = "../../primitives/consensus/common" } +sc-executor = { path = "../../client/executor" } futures = "0.3.1" hash-db = "0.15.2" -keyring = { package = "sp-keyring", path = "../../primitives/keyring" } +sp-keyring = { path = "../../primitives/keyring" } codec = { package = "parity-scale-codec", version = "1.0.0" } -primitives = { package = "sp-core", path = "../../primitives/core" } +sp-core = { path = "../../primitives/core" } sp-runtime = { path = "../../primitives/runtime" } sp-blockchain = { path = "../../primitives/blockchain" } -state_machine = { package = "sp-state-machine", path = "../../primitives/state-machine" } +sp-state-machine = { path = "../../primitives/state-machine" } diff --git a/test-utils/client/src/client_ext.rs b/test-utils/client/src/client_ext.rs index 961d8570d8..f560d0f97b 100644 --- a/test-utils/client/src/client_ext.rs +++ b/test-utils/client/src/client_ext.rs @@ -16,9 +16,9 @@ //! Client extension for tests. -use client::{self, Client}; -use client_api::backend::Finalizer; -use consensus::{ +use sc_client::{self, Client}; +use sc_client_api::backend::Finalizer; +use sp_consensus::{ BlockImportParams, BlockImport, BlockOrigin, Error as ConsensusError, ForkChoiceStrategy, }; @@ -26,7 +26,7 @@ use hash_db::Hasher; use sp_runtime::Justification; use sp_runtime::traits::{Block as BlockT}; use sp_runtime::generic::BlockId; -use primitives::Blake2Hasher; +use sp_core::Blake2Hasher; use codec::alloc::collections::hash_map::HashMap; /// Extension trait for a test client. @@ -64,8 +64,8 @@ pub trait ClientExt: Sized { impl ClientExt for Client where - B: client_api::backend::Backend, - E: client::CallExecutor, + B: sc_client_api::backend::Backend, + E: sc_client::CallExecutor, for<'r> &'r Self: BlockImport, Block: BlockT::Out>, { diff --git a/test-utils/client/src/lib.rs b/test-utils/client/src/lib.rs index c6067e5d7c..2496409f87 100644 --- a/test-utils/client/src/lib.rs +++ b/test-utils/client/src/lib.rs @@ -20,31 +20,32 @@ pub mod client_ext; -pub use client::{blockchain, self}; -pub use client_api::execution_extensions::{ExecutionStrategies, ExecutionExtensions}; -pub use client_db::{Backend, self}; -pub use client_ext::ClientExt; -pub use consensus; -pub use executor::{NativeExecutor, WasmExecutionMethod, self}; -pub use keyring::{ +pub use sc_client::{blockchain, self}; +pub use sc_client_api::execution_extensions::{ExecutionStrategies, ExecutionExtensions}; +pub use sc_client_db::{Backend, self}; +pub use sp_consensus; +pub use sc_executor::{NativeExecutor, WasmExecutionMethod, self}; +pub use sp_keyring::{ AccountKeyring, ed25519::Keyring as Ed25519Keyring, sr25519::Keyring as Sr25519Keyring, }; -pub use primitives::{Blake2Hasher, traits::BareCryptoStorePtr}; +pub use sp_core::{Blake2Hasher, traits::BareCryptoStorePtr}; pub use sp_runtime::{Storage, StorageChild}; -pub use state_machine::ExecutionStrategy; +pub use sp_state_machine::ExecutionStrategy; + +pub use self::client_ext::ClientExt; use std::sync::Arc; use std::collections::HashMap; use hash_db::Hasher; -use primitives::storage::{well_known_keys, ChildInfo}; +use sp_core::storage::{well_known_keys, ChildInfo}; use sp_runtime::traits::Block as BlockT; -use client::LocalCallExecutor; +use sc_client::LocalCallExecutor; /// Test client light database backend. -pub type LightBackend = client::light::backend::Backend< - client_db::light::LightStorage, +pub type LightBackend = sc_client::light::backend::Backend< + sc_client_db::light::LightStorage, Blake2Hasher, >; @@ -168,16 +169,16 @@ impl TestClientBuilder self, executor: Executor, ) -> ( - client::Client< + sc_client::Client< Backend, Executor, Block, RuntimeApi, >, - client::LongestChain, + sc_client::LongestChain, ) where - Executor: client::CallExecutor, - Backend: client_api::backend::Backend, + Executor: sc_client::CallExecutor, + Backend: sc_client_api::backend::Backend, Block: BlockT::Out>, { @@ -198,7 +199,7 @@ impl TestClientBuilder storage }; - let client = client::Client::new( + let client = sc_client::Client::new( self.backend.clone(), executor, storage, @@ -209,14 +210,14 @@ impl TestClientBuilder ) ).expect("Creates new client"); - let longest_chain = client::LongestChain::new(self.backend); + let longest_chain = sc_client::LongestChain::new(self.backend); (client, longest_chain) } } impl TestClientBuilder< - client::LocalCallExecutor>, + sc_client::LocalCallExecutor>, Backend, G, > { @@ -225,17 +226,17 @@ impl TestClientBuilder< self, executor: I, ) -> ( - client::Client< + sc_client::Client< Backend, - client::LocalCallExecutor>, + sc_client::LocalCallExecutor>, Block, RuntimeApi >, - client::LongestChain, + sc_client::LongestChain, ) where I: Into>>, - E: executor::NativeExecutionDispatch, - Backend: client_api::backend::Backend, + E: sc_executor::NativeExecutionDispatch, + Backend: sc_client_api::backend::Backend, Block: BlockT::Out>, { let executor = executor.into().unwrap_or_else(|| diff --git a/test-utils/runtime/Cargo.toml b/test-utils/runtime/Cargo.toml index c669cd4141..66b97ac78e 100644 --- a/test-utils/runtime/Cargo.toml +++ b/test-utils/runtime/Cargo.toml @@ -6,26 +6,26 @@ edition = "2018" build = "build.rs" [dependencies] -app-crypto = { package = "sp-application-crypto", path = "../../primitives/application-crypto", default-features = false } -aura-primitives = { package = "sp-consensus-aura", path = "../../primitives/consensus/aura", default-features = false } -babe-primitives = { package = "sp-consensus-babe", path = "../../primitives/consensus/babe", default-features = false } -block-builder-api = { package = "sp-block-builder", path = "../../primitives/block-builder", default-features = false } +sp-application-crypto = { path = "../../primitives/application-crypto", default-features = false } +sp-consensus-aura = { path = "../../primitives/consensus/aura", default-features = false } +sp-consensus-babe = { path = "../../primitives/consensus/babe", default-features = false } +sp-block-builder = { path = "../../primitives/block-builder", default-features = false } cfg-if = "0.1.10" codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -executive = { package = "frame-executive", path = "../../frame/executive", default-features = false } -inherents = { package = "sp-inherents", path = "../../primitives/inherents", default-features = false } -keyring = { package = "sp-keyring", path = "../../primitives/keyring", optional = true } +frame-executive = { path = "../../frame/executive", default-features = false } +sp-inherents = { path = "../../primitives/inherents", default-features = false } +sp-keyring = { path = "../../primitives/keyring", optional = true } log = { version = "0.4.8", optional = true } memory-db = { version = "0.15.2", default-features = false } -offchain-primitives = { package = "sp-offchain", path = "../../primitives/offchain", default-features = false} -primitives = { package = "sp-core", path = "../../primitives/core", default-features = false } +sp-offchain = { path = "../../primitives/offchain", default-features = false} +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} +sp-runtime-interface = { path = "../../primitives/runtime-interface", 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/version", default-features = false } +frame-support = { path = "../../frame/support", default-features = false } +sp-version = { path = "../../primitives/version", default-features = false } serde = { version = "1.0.101", optional = true, features = ["derive"] } -session = { package = "sp-session", path = "../../primitives/session", default-features = false } +sp-session = { path = "../../primitives/session", default-features = false } sp-api = { path = "../../primitives/api", default-features = false } sp-runtime = { path = "../../primitives/runtime", default-features = false } pallet-babe = { path = "../../frame/babe", default-features = false } @@ -34,13 +34,13 @@ frame-system-rpc-runtime-api = { path = "../../frame/system/rpc/runtime-api", de pallet-timestamp = { path = "../../frame/timestamp", default-features = false } sc-client = { path = "../../client", optional = true } sp-trie = { path = "../../primitives/trie", default-features = false } -sp-transaction-pool = { package = "sp-transaction-pool", path = "../../primitives/transaction-pool", default-features = false } +sp-transaction-pool = { path = "../../primitives/transaction-pool", default-features = false } trie-db = { version = "0.16.0", default-features = false } [dev-dependencies] sc-executor = { path = "../../client/executor" } substrate-test-runtime-client = { path = "./client" } -state_machine = { package = "sp-state-machine", path = "../../primitives/state-machine" } +sp-state-machine = { path = "../../primitives/state-machine" } [build-dependencies] wasm-builder-runner = { package = "substrate-wasm-builder-runner", path = "../../utils/wasm-builder-runner", version = "1.0.4" } @@ -50,26 +50,26 @@ default = [ "std", ] std = [ - "app-crypto/std", - "aura-primitives/std", - "babe-primitives/std", - "block-builder-api/std", + "sp-application-crypto/std", + "sp-consensus-aura/std", + "sp-consensus-babe/std", + "sp-block-builder/std", "codec/std", - "executive/std", - "inherents/std", - "keyring", + "frame-executive/std", + "sp-inherents/std", + "sp-keyring", "log", "memory-db/std", - "offchain-primitives/std", - "primitives/std", - "primitives/std", + "sp-offchain/std", + "sp-core/std", + "sp-core/std", "sp-std/std", - "runtime-interface/std", + "sp-runtime-interface/std", "sp-io/std", - "runtime_support/std", - "runtime_version/std", + "frame-support/std", + "sp-version/std", "serde", - "session/std", + "sp-session/std", "sp-api/std", "sp-runtime/std", "pallet-babe/std", diff --git a/test-utils/runtime/client/Cargo.toml b/test-utils/runtime/client/Cargo.toml index 85b9928234..2ba3fab8d1 100644 --- a/test-utils/runtime/client/Cargo.toml +++ b/test-utils/runtime/client/Cargo.toml @@ -5,13 +5,13 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -block-builder = { package = "sc-block-builder", path = "../../../client/block-builder" } -generic-test-client = { package = "substrate-test-client", path = "../../client" } -primitives = { package = "sp-core", path = "../../../primitives/core" } -runtime = { package = "substrate-test-runtime", path = "../../runtime" } +sc-block-builder = { path = "../../../client/block-builder" } +substrate-test-client = { path = "../../client" } +sp-core = { path = "../../../primitives/core" } +substrate-test-runtime = { path = "../../runtime" } sp-runtime = { path = "../../../primitives/runtime" } sp-blockchain = { path = "../../../primitives/blockchain" } codec = { package = "parity-scale-codec", version = "1.0.0" } -client-api = { package = "sc-client-api", path = "../../../client/api" } -client = { package = "sc-client", path = "../../../client/" } +sc-client-api = { path = "../../../client/api" } +sc-client = { path = "../../../client/" } futures = "0.3.1" diff --git a/test-utils/runtime/client/src/block_builder_ext.rs b/test-utils/runtime/client/src/block_builder_ext.rs index a1065c82a0..5b98b1deb3 100644 --- a/test-utils/runtime/client/src/block_builder_ext.rs +++ b/test-utils/runtime/client/src/block_builder_ext.rs @@ -16,15 +16,15 @@ //! Block Builder extensions for tests. -use runtime; +use substrate_test_runtime; use sp_runtime::traits::ProvideRuntimeApi; -use block_builder::BlockBuilderApi; +use sc_block_builder::BlockBuilderApi; /// Extension trait for test block builder. pub trait BlockBuilderExt { /// Add transfer extrinsic to the block. - fn push_transfer(&mut self, transfer: runtime::Transfer) -> Result<(), sp_blockchain::Error>; + fn push_transfer(&mut self, transfer: substrate_test_runtime::Transfer) -> Result<(), sp_blockchain::Error>; /// Add storage change extrinsic to the block. fn push_storage_change( &mut self, @@ -33,11 +33,11 @@ pub trait BlockBuilderExt { ) -> Result<(), sp_blockchain::Error>; } -impl<'a, A> BlockBuilderExt for block_builder::BlockBuilder<'a, runtime::Block, A> where +impl<'a, A> BlockBuilderExt for sc_block_builder::BlockBuilder<'a, substrate_test_runtime::Block, A> where A: ProvideRuntimeApi + 'a, - A::Api: BlockBuilderApi, + A::Api: BlockBuilderApi, { - fn push_transfer(&mut self, transfer: runtime::Transfer) -> Result<(), sp_blockchain::Error> { + fn push_transfer(&mut self, transfer: substrate_test_runtime::Transfer) -> Result<(), sp_blockchain::Error> { self.push(transfer.into_signed_tx()) } @@ -46,6 +46,6 @@ impl<'a, A> BlockBuilderExt for block_builder::BlockBuilder<'a, runtime::Block, key: Vec, value: Option>, ) -> Result<(), sp_blockchain::Error> { - self.push(runtime::Extrinsic::StorageChange(key, value)) + self.push(substrate_test_runtime::Extrinsic::StorageChange(key, value)) } } diff --git a/test-utils/runtime/client/src/lib.rs b/test-utils/runtime/client/src/lib.rs index 13d9b19553..988fa56678 100644 --- a/test-utils/runtime/client/src/lib.rs +++ b/test-utils/runtime/client/src/lib.rs @@ -24,15 +24,16 @@ mod block_builder_ext; use std::sync::Arc; use std::collections::HashMap; -pub use block_builder_ext::BlockBuilderExt; -pub use generic_test_client::*; -pub use runtime; +pub use substrate_test_client::*; +pub use substrate_test_runtime as runtime; -use primitives::sr25519; -use primitives::storage::{ChildInfo, Storage, StorageChild}; -use runtime::genesismap::{GenesisConfig, additional_storage_with_genesis}; +pub use self::block_builder_ext::BlockBuilderExt; + +use sp_core::sr25519; +use sp_core::storage::{ChildInfo, Storage, StorageChild}; +use substrate_test_runtime::genesismap::{GenesisConfig, additional_storage_with_genesis}; use sp_runtime::traits::{Block as BlockT, Header as HeaderT, Hash as HashT, NumberFor}; -use client::{ +use sc_client::{ light::fetcher::{ Fetcher, RemoteHeaderRequest, RemoteReadRequest, RemoteReadChildRequest, @@ -56,37 +57,37 @@ pub mod prelude { mod local_executor { #![allow(missing_docs)] - use runtime; - use crate::executor::native_executor_instance; + use substrate_test_runtime; + use crate::sc_executor::native_executor_instance; // FIXME #1576 change the macro and pass in the `BlakeHasher` that dispatch needs from here instead native_executor_instance!( pub LocalExecutor, - runtime::api::dispatch, - runtime::native_version + substrate_test_runtime::api::dispatch, + substrate_test_runtime::native_version ); } /// Native executor used for tests. -pub use local_executor::LocalExecutor; +pub use self::local_executor::LocalExecutor; /// Test client database backend. -pub type Backend = generic_test_client::Backend; +pub type Backend = substrate_test_client::Backend; /// Test client executor. -pub type Executor = client::LocalCallExecutor< +pub type Executor = sc_client::LocalCallExecutor< Backend, NativeExecutor, >; /// Test client light database backend. -pub type LightBackend = generic_test_client::LightBackend; +pub type LightBackend = substrate_test_client::LightBackend; /// Test client light executor. -pub type LightExecutor = client::light::call_executor::GenesisCallExecutor< +pub type LightExecutor = sc_client::light::call_executor::GenesisCallExecutor< LightBackend, - client::LocalCallExecutor< - client::light::backend::Backend< - client_db::light::LightStorage, + sc_client::LocalCallExecutor< + sc_client::light::backend::Backend< + sc_client_db::light::LightStorage, Blake2Hasher, >, NativeExecutor @@ -122,9 +123,10 @@ impl GenesisParameters { } } -impl generic_test_client::GenesisInit for GenesisParameters { +impl substrate_test_client::GenesisInit for GenesisParameters { fn genesis_storage(&self) -> Storage { use codec::Encode; + let mut storage = self.genesis_config().genesis_map(); let child_roots = storage.children.iter().map(|(sk, child_content)| { @@ -136,7 +138,7 @@ impl generic_test_client::GenesisInit for GenesisParameters { let state_root = <<::Header as HeaderT>::Hashing as HashT>::trie_root( storage.top.clone().into_iter().chain(child_roots).collect() ); - let block: runtime::Block = client::genesis::construct_genesis_block(state_root); + let block: runtime::Block = sc_client::genesis::construct_genesis_block(state_root); storage.top.extend(additional_storage_with_genesis(&block)); storage @@ -144,14 +146,14 @@ impl generic_test_client::GenesisInit for GenesisParameters { } /// A `TestClient` with `test-runtime` builder. -pub type TestClientBuilder = generic_test_client::TestClientBuilder; +pub type TestClientBuilder = substrate_test_client::TestClientBuilder; /// Test client type with `LocalExecutor` and generic Backend. -pub type Client = client::Client< +pub type Client = sc_client::Client< B, - client::LocalCallExecutor>, - runtime::Block, - runtime::RuntimeApi, + sc_client::LocalCallExecutor>, + substrate_test_runtime::Block, + substrate_test_runtime::RuntimeApi, >; /// A test client with default backend. @@ -206,14 +208,14 @@ pub trait TestClientBuilderExt: Sized { } /// Build the test client and longest chain selector. - fn build_with_longest_chain(self) -> (Client, client::LongestChain); + fn build_with_longest_chain(self) -> (Client, sc_client::LongestChain); } impl TestClientBuilderExt for TestClientBuilder< - client::LocalCallExecutor>, + sc_client::LocalCallExecutor>, B > where - B: client_api::backend::Backend, + B: sc_client_api::backend::Backend, { fn set_heap_pages(mut self, heap_pages: u64) -> Self { self.genesis_init_mut().heap_pages_override = Some(heap_pages); @@ -253,7 +255,7 @@ impl TestClientBuilderExt for TestClientBuilder< } - fn build_with_longest_chain(self) -> (Client, client::LongestChain) { + fn build_with_longest_chain(self) -> (Client, sc_client::LongestChain) { self.build_with_native_executor(None) } } @@ -267,15 +269,15 @@ type FetcherFutureResult = futures::future::Ready, Vec>, - body: MaybeFetcherCallback, Vec>, + call: MaybeFetcherCallback, Vec>, + body: MaybeFetcherCallback, Vec>, } impl LightFetcher { /// Sets remote call callback. pub fn with_remote_call( self, - call: MaybeFetcherCallback, Vec>, + call: MaybeFetcherCallback, Vec>, ) -> Self { LightFetcher { call, @@ -286,7 +288,7 @@ impl LightFetcher { /// Sets remote body callback. pub fn with_remote_body( self, - body: MaybeFetcherCallback, Vec>, + body: MaybeFetcherCallback, Vec>, ) -> Self { LightFetcher { call: self.call, @@ -295,37 +297,37 @@ impl LightFetcher { } } -impl Fetcher for LightFetcher { - type RemoteHeaderResult = FetcherFutureResult; +impl Fetcher for LightFetcher { + type RemoteHeaderResult = FetcherFutureResult; type RemoteReadResult = FetcherFutureResult, Option>>>; type RemoteCallResult = FetcherFutureResult>; - type RemoteChangesResult = FetcherFutureResult, u32)>>; - type RemoteBodyResult = FetcherFutureResult>; + type RemoteChangesResult = FetcherFutureResult, u32)>>; + type RemoteBodyResult = FetcherFutureResult>; - fn remote_header(&self, _: RemoteHeaderRequest) -> Self::RemoteHeaderResult { + fn remote_header(&self, _: RemoteHeaderRequest) -> Self::RemoteHeaderResult { unimplemented!() } - fn remote_read(&self, _: RemoteReadRequest) -> Self::RemoteReadResult { + fn remote_read(&self, _: RemoteReadRequest) -> Self::RemoteReadResult { unimplemented!() } - fn remote_read_child(&self, _: RemoteReadChildRequest) -> Self::RemoteReadResult { + fn remote_read_child(&self, _: RemoteReadChildRequest) -> Self::RemoteReadResult { unimplemented!() } - fn remote_call(&self, req: RemoteCallRequest) -> Self::RemoteCallResult { + fn remote_call(&self, req: RemoteCallRequest) -> Self::RemoteCallResult { match self.call { Some(ref call) => futures::future::ready(call(req)), None => unimplemented!(), } } - fn remote_changes(&self, _: RemoteChangesRequest) -> Self::RemoteChangesResult { + fn remote_changes(&self, _: RemoteChangesRequest) -> Self::RemoteChangesResult { unimplemented!() } - fn remote_body(&self, req: RemoteBodyRequest) -> Self::RemoteBodyResult { + fn remote_body(&self, req: RemoteBodyRequest) -> Self::RemoteBodyResult { match self.body { Some(ref body) => futures::future::ready(body(req)), None => unimplemented!(), @@ -340,15 +342,15 @@ pub fn new() -> Client { /// Creates new light client instance used for tests. pub fn new_light() -> ( - client::Client, + sc_client::Client, Arc, ) { - let storage = client_db::light::LightStorage::new_test(); - let blockchain = Arc::new(client::light::blockchain::Blockchain::new(storage)); + let storage = sc_client_db::light::LightStorage::new_test(); + let blockchain = Arc::new(sc_client::light::blockchain::Blockchain::new(storage)); let backend = Arc::new(LightBackend::new(blockchain.clone())); let executor = NativeExecutor::new(WasmExecutionMethod::Interpreted, None); - let local_call_executor = client::LocalCallExecutor::new(backend.clone(), executor); + let local_call_executor = sc_client::LocalCallExecutor::new(backend.clone(), executor); let call_executor = LightExecutor::new( backend.clone(), local_call_executor, diff --git a/test-utils/runtime/client/src/trait_tests.rs b/test-utils/runtime/client/src/trait_tests.rs index 108924c4dd..9217cff801 100644 --- a/test-utils/runtime/client/src/trait_tests.rs +++ b/test-utils/runtime/client/src/trait_tests.rs @@ -21,19 +21,19 @@ use std::sync::Arc; -use client_api::backend::LocalBackend; +use sc_client_api::backend::LocalBackend; use crate::block_builder_ext::BlockBuilderExt; -use client_api::blockchain::{Backend as BlockChainBackendT, HeaderBackend}; +use sc_client_api::blockchain::{Backend as BlockChainBackendT, HeaderBackend}; use crate::{AccountKeyring, ClientExt, TestClientBuilder, TestClientBuilderExt}; -use generic_test_client::consensus::BlockOrigin; -use primitives::Blake2Hasher; -use runtime::{self, Transfer}; +use substrate_test_client::sp_consensus::BlockOrigin; +use sp_core::Blake2Hasher; +use substrate_test_runtime::{self, Transfer}; use sp_runtime::generic::BlockId; use sp_runtime::traits::Block as BlockT; /// helper to test the `leaves` implementation for various backends pub fn test_leaves_for_backend(backend: Arc) where - B: LocalBackend, + B: LocalBackend, { // block tree: // G -> A1 -> A2 -> A3 -> A4 -> A5 @@ -149,7 +149,7 @@ pub fn test_leaves_for_backend(backend: Arc) where /// helper to test the `children` implementation for various backends pub fn test_children_for_backend(backend: Arc) where - B: LocalBackend, + B: LocalBackend, { // block tree: // G -> A1 -> A2 -> A3 -> A4 -> A5 @@ -240,7 +240,7 @@ pub fn test_children_for_backend(backend: Arc) where } pub fn test_blockchain_query_by_number_gets_canonical(backend: Arc) where - B: LocalBackend, + B: LocalBackend, { // block tree: // G -> A1 -> A2 -> A3 -> A4 -> A5 diff --git a/test-utils/runtime/src/genesismap.rs b/test-utils/runtime/src/genesismap.rs index 85d513c2cf..62d9b160b9 100644 --- a/test-utils/runtime/src/genesismap.rs +++ b/test-utils/runtime/src/genesismap.rs @@ -20,8 +20,8 @@ use std::collections::BTreeMap; use sp_io::hashing::{blake2_256, twox_128}; use super::{AuthorityId, AccountId, WASM_BINARY, system}; use codec::{Encode, KeyedVec, Joiner}; -use primitives::{ChangesTrieConfiguration, map}; -use primitives::storage::{well_known_keys, Storage}; +use sp_core::{ChangesTrieConfiguration, map}; +use sp_core::storage::{well_known_keys, Storage}; use sp_runtime::traits::{Block as BlockT, Hash as HashT, Header as HeaderT}; /// Configuration of a general Substrate test genesis block. @@ -41,7 +41,7 @@ impl GenesisConfig { endowed_accounts: Vec, balance: u64, heap_pages_override: Option, - extra_storage: Storage, + extra_storage: Storage, ) -> Self { GenesisConfig { changes_trie_config: match support_changes_trie { @@ -87,7 +87,7 @@ impl GenesisConfig { pub fn insert_genesis_block( storage: &mut Storage, -) -> primitives::hash::H256 { +) -> sp_core::hash::H256 { let child_roots = storage.children.iter().map(|(sk, child_content)| { let state_root = <<::Header as HeaderT>::Hashing as HashT>::trie_root( child_content.data.clone().into_iter().collect(), diff --git a/test-utils/runtime/src/lib.rs b/test-utils/runtime/src/lib.rs index 785d8dec5b..2a0cfe454f 100644 --- a/test-utils/runtime/src/lib.rs +++ b/test-utils/runtime/src/lib.rs @@ -25,9 +25,8 @@ pub mod system; use sp_std::{prelude::*, marker::PhantomData}; use codec::{Encode, Decode, Input, Error}; -use primitives::{Blake2Hasher, OpaqueMetadata, RuntimeDebug}; -use app_crypto::{ed25519, sr25519, RuntimeAppPublic}; -pub use app_crypto; +use sp_core::{Blake2Hasher, OpaqueMetadata, RuntimeDebug}; +use sp_application_crypto::{ed25519, sr25519, RuntimeAppPublic}; use trie_db::{TrieMut, Trie}; use sp_trie::PrefixedMemoryDB; use sp_trie::trie_types::{TrieDB, TrieDBMut}; @@ -43,18 +42,18 @@ use sp_runtime::{ GetNodeBlockType, GetRuntimeBlockType, Verify, IdentityLookup, }, }; -use runtime_version::RuntimeVersion; -pub use primitives::{hash::H256}; +use sp_version::RuntimeVersion; +pub use sp_core::{hash::H256}; #[cfg(any(feature = "std", test))] -use runtime_version::NativeVersion; -use runtime_support::{impl_outer_origin, parameter_types, weights::Weight}; -use inherents::{CheckInherentsResult, InherentData}; +use sp_version::NativeVersion; +use frame_support::{impl_outer_origin, parameter_types, weights::Weight}; +use sp_inherents::{CheckInherentsResult, InherentData}; use cfg_if::cfg_if; -use primitives::storage::ChildType; +use sp_core::storage::ChildType; // Ensure Babe and Aura use the same crypto to simplify things a bit. -pub use babe_primitives::AuthorityId; -pub type AuraId = aura_primitives::sr25519::AuthorityId; +pub use sp_consensus_babe::AuthorityId; +pub type AuraId = sp_consensus_aura::sr25519::AuthorityId; // Inlucde the WASM binary #[cfg(feature = "std")] @@ -96,7 +95,7 @@ impl Transfer { /// Convert into a signed extrinsic. #[cfg(feature = "std")] pub fn into_signed_tx(self) -> Extrinsic { - let signature = keyring::AccountKeyring::from_public(&self.from) + let signature = sp_keyring::AccountKeyring::from_public(&self.from) .expect("Creates keyring from public key.").sign(&self.encode()).into(); Extrinsic::Transfer(self, signature) } @@ -195,8 +194,8 @@ pub fn run_tests(mut input: &[u8]) -> Vec { } /// Changes trie configuration (optionally) used in tests. -pub fn changes_trie_config() -> primitives::ChangesTrieConfiguration { - primitives::ChangesTrieConfiguration { +pub fn changes_trie_config() -> sp_core::ChangesTrieConfiguration { + sp_core::ChangesTrieConfiguration { digest_interval: 4, digest_levels: 2, } @@ -406,8 +405,8 @@ fn benchmark_add_one(i: u64) -> u64 { /// The `benchmark_add_one` function as function pointer. #[cfg(not(feature = "std"))] -static BENCHMARK_ADD_ONE: runtime_interface::wasm::ExchangeableFunction u64> = - runtime_interface::wasm::ExchangeableFunction::new(benchmark_add_one); +static BENCHMARK_ADD_ONE: sp_runtime_interface::wasm::ExchangeableFunction u64> = + sp_runtime_interface::wasm::ExchangeableFunction::new(benchmark_add_one); fn code_using_trie() -> u64 { let pairs = [ @@ -494,7 +493,7 @@ cfg_if! { } } - impl block_builder_api::BlockBuilder for Runtime { + impl sp_block_builder::BlockBuilder for Runtime { fn apply_extrinsic(extrinsic: ::Extrinsic) -> ApplyExtrinsicResult { system::execute_transaction(extrinsic) } @@ -598,7 +597,7 @@ cfg_if! { } } - impl aura_primitives::AuraApi for Runtime { + impl sp_consensus_aura::AuraApi for Runtime { fn slot_duration() -> u64 { 1000 } fn authorities() -> Vec { system::authorities().into_iter().map(|a| { @@ -608,9 +607,9 @@ cfg_if! { } } - impl babe_primitives::BabeApi for Runtime { - fn configuration() -> babe_primitives::BabeConfiguration { - babe_primitives::BabeConfiguration { + impl sp_consensus_babe::BabeApi for Runtime { + fn configuration() -> sp_consensus_babe::BabeConfiguration { + sp_consensus_babe::BabeConfiguration { slot_duration: 1000, epoch_length: EpochDuration::get(), c: (3, 10), @@ -622,14 +621,14 @@ cfg_if! { } } - impl offchain_primitives::OffchainWorkerApi for Runtime { + impl sp_offchain::OffchainWorkerApi for Runtime { fn offchain_worker(block: u64) { let ex = Extrinsic::IncludeData(block.encode()); sp_io::offchain::submit_transaction(ex.encode()).unwrap(); } } - impl session::SessionKeys for Runtime { + impl sp_session::SessionKeys for Runtime { fn generate_session_keys(_: Option>) -> Vec { SessionKeys::generate(None) } @@ -679,7 +678,7 @@ cfg_if! { } } - impl block_builder_api::BlockBuilder for Runtime { + impl sp_block_builder::BlockBuilder for Runtime { fn apply_extrinsic(extrinsic: ::Extrinsic) -> ApplyExtrinsicResult { system::execute_transaction(extrinsic) } @@ -814,7 +813,7 @@ cfg_if! { } } - impl aura_primitives::AuraApi for Runtime { + impl sp_consensus_aura::AuraApi for Runtime { fn slot_duration() -> u64 { 1000 } fn authorities() -> Vec { system::authorities().into_iter().map(|a| { @@ -824,9 +823,9 @@ cfg_if! { } } - impl babe_primitives::BabeApi for Runtime { - fn configuration() -> babe_primitives::BabeConfiguration { - babe_primitives::BabeConfiguration { + impl sp_consensus_babe::BabeApi for Runtime { + fn configuration() -> sp_consensus_babe::BabeConfiguration { + sp_consensus_babe::BabeConfiguration { slot_duration: 1000, epoch_length: EpochDuration::get(), c: (3, 10), @@ -838,14 +837,14 @@ cfg_if! { } } - impl offchain_primitives::OffchainWorkerApi for Runtime { + impl sp_offchain::OffchainWorkerApi for Runtime { fn offchain_worker(block: u64) { let ex = Extrinsic::IncludeData(block.encode()); sp_io::offchain::submit_transaction(ex.encode()).unwrap() } } - impl session::SessionKeys for Runtime { + impl sp_session::SessionKeys for Runtime { fn generate_session_keys(_: Option>) -> Vec { SessionKeys::generate(None) } @@ -950,7 +949,7 @@ fn test_read_child_storage() { mod tests { use substrate_test_runtime_client::{ prelude::*, - consensus::BlockOrigin, + sp_consensus::BlockOrigin, DefaultTestClientBuilderExt, TestClientBuilder, runtime::TestAPI, }; @@ -958,8 +957,8 @@ mod tests { generic::BlockId, traits::ProvideRuntimeApi, }; - use primitives::storage::well_known_keys::HEAP_PAGES; - use state_machine::ExecutionStrategy; + use sp_core::storage::well_known_keys::HEAP_PAGES; + use sp_state_machine::ExecutionStrategy; use codec::Encode; #[test] diff --git a/test-utils/runtime/src/system.rs b/test-utils/runtime/src/system.rs index aec909f8da..162f9a8ad6 100644 --- a/test-utils/runtime/src/system.rs +++ b/test-utils/runtime/src/system.rs @@ -22,8 +22,8 @@ use sp_io::{ storage::root as storage_root, storage::changes_root as storage_changes_root, hashing::blake2_256, }; -use runtime_support::storage; -use runtime_support::{decl_storage, decl_module}; +use frame_support::storage; +use frame_support::{decl_storage, decl_module}; use sp_runtime::{ traits::{Hash as HashT, BlakeTwo256, Header as _}, generic, ApplyExtrinsicResult, transaction_validity::{ @@ -35,7 +35,7 @@ use frame_system::Trait; use crate::{ AccountId, BlockNumber, Extrinsic, Transfer, H256 as Hash, Block, Header, Digest, AuthorityId }; -use primitives::storage::well_known_keys; +use sp_core::storage::well_known_keys; const NONCE_OF: &[u8] = b"nonce:"; const BALANCE_OF: &[u8] = b"balance:"; @@ -169,7 +169,7 @@ fn execute_block_with_state_root_handler( /// The block executor. pub struct BlockExecutor; -impl executive::ExecuteBlock for BlockExecutor { +impl frame_executive::ExecuteBlock for BlockExecutor { fn execute_block(block: Block) { execute_block(block); } @@ -312,7 +312,7 @@ fn execute_storage_change(key: &[u8], value: Option<&[u8]>) -> ApplyExtrinsicRes #[cfg(feature = "std")] fn info_expect_equal_hash(given: &Hash, expected: &Hash) { - use primitives::hexdisplay::HexDisplay; + use sp_core::hexdisplay::HexDisplay; if given != expected { println!( "Hash: given={}, expected={}", @@ -338,7 +338,7 @@ mod tests { use sp_io::TestExternalities; use substrate_test_runtime_client::{AccountKeyring, Sr25519Keyring}; use crate::{Header, Transfer, WASM_BINARY}; - use primitives::{NeverNativeValue, map, traits::CodeExecutor}; + use sp_core::{NeverNativeValue, map, traits::CodeExecutor}; use sc_executor::{NativeExecutor, WasmExecutionMethod, native_executor_instance}; use sp_io::hashing::twox_128; @@ -361,7 +361,7 @@ mod tests { ]; TestExternalities::new_with_code( WASM_BINARY, - primitives::storage::Storage { + sp_core::storage::Storage { top: map![ twox_128(b"latest").to_vec() => vec![69u8; 32], twox_128(b"sys:auth").to_vec() => authorities.encode(), diff --git a/utils/frame/rpc/support/Cargo.toml b/utils/frame/rpc/support/Cargo.toml index cc5a860470..272fdb5642 100644 --- a/utils/frame/rpc/support/Cargo.toml +++ b/utils/frame/rpc/support/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" futures = { version = "0.3.0", features = ["compat"] } jsonrpc-client-transports = "14" jsonrpc-core = "14" -parity-scale-codec = "1" +codec = { package = "parity-scale-codec", version = "1" } serde = "1" frame-support = { path = "../../../../frame/support" } sp-storage = { path = "../../../../primitives/storage" } diff --git a/utils/frame/rpc/support/src/lib.rs b/utils/frame/rpc/support/src/lib.rs index 396c521501..80c0658086 100644 --- a/utils/frame/rpc/support/src/lib.rs +++ b/utils/frame/rpc/support/src/lib.rs @@ -22,7 +22,7 @@ use core::marker::PhantomData; use futures::compat::Future01CompatExt; use jsonrpc_client_transports::RpcError; -use parity_scale_codec::{DecodeAll, FullCodec, FullEncode}; +use codec::{DecodeAll, FullCodec, FullEncode}; use serde::{de::DeserializeOwned, Serialize}; use frame_support::storage::generator::{ StorageDoubleMap, StorageLinkedMap, StorageMap, StorageValue @@ -38,7 +38,7 @@ use sc_rpc_api::state::StateClient; /// # use futures::future::FutureExt; /// # use jsonrpc_client_transports::RpcError; /// # use jsonrpc_client_transports::transports::http; -/// # use parity_scale_codec::Encode; +/// # use codec::Encode; /// # use frame_support::{decl_storage, decl_module}; /// # use substrate_frame_rpc_support::StorageQuery; /// # use frame_system::Trait; diff --git a/utils/frame/rpc/system/Cargo.toml b/utils/frame/rpc/system/Cargo.toml index a501891749..c904bceae0 100644 --- a/utils/frame/rpc/system/Cargo.toml +++ b/utils/frame/rpc/system/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -client = { package = "sc-client", path = "../../../../client/" } +sc-client = { path = "../../../../client/" } codec = { package = "parity-scale-codec", version = "1.0.0" } futures = "0.3.1" jsonrpc-core = "14.0.3" @@ -17,9 +17,9 @@ sp-runtime = { path = "../../../../primitives/runtime" } frame-system-rpc-runtime-api = { path = "../../../../frame/system/rpc/runtime-api" } sp-core = { path = "../../../../primitives/core" } sp-blockchain = { path = "../../../../primitives/blockchain" } -txpool-api = { package = "sp-transaction-pool", path = "../../../../primitives/transaction-pool" } +sp-transaction-pool = { path = "../../../../primitives/transaction-pool" } [dev-dependencies] -test-client = { package = "substrate-test-runtime-client", path = "../../../../test-utils/runtime/client" } +substrate-test-runtime-client = { path = "../../../../test-utils/runtime/client" } env_logger = "0.7.0" -txpool = { package = "sc-transaction-pool", path = "../../../../client/transaction-pool" } +sc-transaction-pool = { path = "../../../../client/transaction-pool" } diff --git a/utils/frame/rpc/system/src/lib.rs b/utils/frame/rpc/system/src/lib.rs index 675965729d..c1d9b1f4f6 100644 --- a/utils/frame/rpc/system/src/lib.rs +++ b/utils/frame/rpc/system/src/lib.rs @@ -19,7 +19,7 @@ use std::sync::Arc; use codec::{self, Codec, Decode, Encode}; -use client::{ +use sc_client::{ light::blockchain::{future_header, RemoteBlockchain}, light::fetcher::{Fetcher, RemoteCallRequest}, }; @@ -38,7 +38,7 @@ use sp_runtime::{ traits, }; use sp_core::hexdisplay::HexDisplay; -use txpool_api::{TransactionPool, InPoolTransaction}; +use sp_transaction_pool::{TransactionPool, InPoolTransaction}; pub use frame_system_rpc_runtime_api::AccountNonceApi; pub use self::gen_client::Client as SystemClient; @@ -224,17 +224,17 @@ mod tests { use super::*; use futures::executor::block_on; - use test_client::{ + use substrate_test_runtime_client::{ runtime::Transfer, AccountKeyring, }; - use txpool::{BasicPool, FullChainApi}; + use sc_transaction_pool::{BasicPool, FullChainApi}; #[test] fn should_return_next_nonce_for_some_account() { // given let _ = env_logger::try_init(); - let client = Arc::new(test_client::new()); + let client = Arc::new(substrate_test_runtime_client::new()); let pool = Arc::new(BasicPool::new(Default::default(), FullChainApi::new(client.clone()))); let new_transaction = |nonce: u64| { -- GitLab From 0d02284040adf9dcf2ca37886715d591b8a7bc29 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Tue, 17 Dec 2019 00:32:40 +0100 Subject: [PATCH 142/172] Make sudo use `decl_error!` (#4369) * Make sudo use `decl_error` * copy pasta error * Update to use `as_str` * Add doc * Add back `decl_error` --- frame/sudo/src/lib.rs | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/frame/sudo/src/lib.rs b/frame/sudo/src/lib.rs index 3a80c2e946..b7486edf31 100644 --- a/frame/sudo/src/lib.rs +++ b/frame/sudo/src/lib.rs @@ -88,10 +88,11 @@ use sp_std::prelude::*; use sp_runtime::{ - traits::{StaticLookup, Dispatchable}, DispatchError, + traits::{StaticLookup, Dispatchable, ModuleDispatchError}, DispatchError, }; + use frame_support::{ - Parameter, decl_module, decl_event, decl_storage, ensure, + Parameter, decl_module, decl_event, decl_storage, decl_error, ensure, weights::SimpleDispatchInfo, }; use frame_system::{self as system, ensure_signed}; @@ -107,6 +108,8 @@ pub trait Trait: frame_system::Trait { decl_module! { // Simple declaration of the `Module` type. Lets the macro know what it's working on. pub struct Module for enum Call where origin: T::Origin { + type Error = Error; + fn deposit_event() = default; /// Authenticates the sudo key and dispatches a function call with `Root` origin. @@ -122,8 +125,8 @@ decl_module! { #[weight = SimpleDispatchInfo::FreeOperational] fn sudo(origin, proposal: Box) { // This is a public call, so we ensure that the origin is some signed account. - let sender = ensure_signed(origin)?; - ensure!(sender == Self::key(), "only the current sudo key can sudo"); + let sender = ensure_signed(origin).map_err(|e| e.as_str())?; + ensure!(sender == Self::key(), Error::RequireSudo); let res = match proposal.dispatch(frame_system::RawOrigin::Root.into()) { Ok(_) => true, @@ -148,8 +151,8 @@ decl_module! { /// # fn set_key(origin, new: ::Source) { // This is a public call, so we ensure that the origin is some signed account. - let sender = ensure_signed(origin)?; - ensure!(sender == Self::key(), "only the current sudo key can change the sudo key"); + let sender = ensure_signed(origin).map_err(|e| e.as_str())?; + ensure!(sender == Self::key(), Error::RequireSudo); let new = T::Lookup::lookup(new)?; Self::deposit_event(RawEvent::KeyChanged(Self::key())); @@ -170,8 +173,8 @@ decl_module! { #[weight = SimpleDispatchInfo::FixedOperational(0)] fn sudo_as(origin, who: ::Source, proposal: Box) { // This is a public call, so we ensure that the origin is some signed account. - let sender = ensure_signed(origin)?; - ensure!(sender == Self::key(), "only the current sudo key can sudo"); + let sender = ensure_signed(origin).map_err(|e| e.as_str())?; + ensure!(sender == Self::key(), Error::RequireSudo); let who = T::Lookup::lookup(who)?; @@ -206,3 +209,11 @@ decl_storage! { Key get(fn key) config(): T::AccountId; } } + +decl_error! { + /// Error for the Sudo module + pub enum Error { + /// Sender must be the Sudo account + RequireSudo, + } +} -- GitLab From 48f2d8b6612b6cc59d143a7102e245b3f20a61df Mon Sep 17 00:00:00 2001 From: thiolliere Date: Tue, 17 Dec 2019 06:41:25 +0100 Subject: [PATCH 143/172] impl iter_prefix on doublemap (#4388) --- .../src/storage/generator/double_map.rs | 42 +++++++++++++++++++ frame/support/src/storage/mod.rs | 3 ++ 2 files changed, 45 insertions(+) diff --git a/frame/support/src/storage/generator/double_map.rs b/frame/support/src/storage/generator/double_map.rs index 5edd8ee90f..036b1f506e 100644 --- a/frame/support/src/storage/generator/double_map.rs +++ b/frame/support/src/storage/generator/double_map.rs @@ -181,6 +181,17 @@ where unhashed::kill_prefix(Self::storage_double_map_final_key1(k1).as_ref()) } + fn iter_prefix(k1: KArg1) -> storage::PrefixIterator + where KArg1: ?Sized + EncodeLike + { + let prefix = Self::storage_double_map_final_key1(k1); + storage::PrefixIterator:: { + prefix: prefix.clone(), + previous_key: prefix, + phantom_data: Default::default(), + } + } + fn mutate(k1: KArg1, k2: KArg2, f: F) -> R where KArg1: EncodeLike, @@ -266,3 +277,34 @@ where } } } + +#[cfg(test)] +mod test { + use sp_io::TestExternalities; + use crate::storage::{self, StorageDoubleMap}; + use crate::hash::Twox128; + + #[test] + fn iter_prefix_works() { + TestExternalities::default().execute_with(|| { + struct MyStorage; + impl storage::generator::StorageDoubleMap for MyStorage { + type Query = Option; + fn module_prefix() -> &'static [u8] { b"MyModule" } + fn storage_prefix() -> &'static [u8] { b"MyStorage" } + type Hasher1 = Twox128; + type Hasher2 = Twox128; + fn from_optional_value_to_query(v: Option) -> Self::Query { v } + fn from_query_to_optional_value(v: Self::Query) -> Option { v } + } + + MyStorage::insert(1, 3, 7); + MyStorage::insert(1, 4, 8); + MyStorage::insert(2, 5, 9); + MyStorage::insert(2, 6, 10); + + assert_eq!(MyStorage::iter_prefix(1).collect::>(), vec![7, 8]); + assert_eq!(MyStorage::iter_prefix(2).collect::>(), vec![10, 9]); + }); + } +} diff --git a/frame/support/src/storage/mod.rs b/frame/support/src/storage/mod.rs index 7c0ee4c8e4..43be8699f4 100644 --- a/frame/support/src/storage/mod.rs +++ b/frame/support/src/storage/mod.rs @@ -305,6 +305,9 @@ pub trait StorageDoubleMap { fn remove_prefix(k1: KArg1) where KArg1: ?Sized + EncodeLike; + fn iter_prefix(k1: KArg1) -> PrefixIterator + where KArg1: ?Sized + EncodeLike; + fn mutate(k1: KArg1, k2: KArg2, f: F) -> R where KArg1: EncodeLike, -- GitLab From 93cdb6243aacde5d0f386011dfb7da88d805f601 Mon Sep 17 00:00:00 2001 From: Stanislav Tkach Date: Tue, 17 Dec 2019 07:03:08 +0100 Subject: [PATCH 144/172] Use decl_error in the treasure module (#4370) --- client/transaction-pool/graph/src/error.rs | 2 +- frame/treasury/src/lib.rs | 39 ++++++++++++++-------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/client/transaction-pool/graph/src/error.rs b/client/transaction-pool/graph/src/error.rs index 76a276bb49..4da1a58624 100644 --- a/client/transaction-pool/graph/src/error.rs +++ b/client/transaction-pool/graph/src/error.rs @@ -52,7 +52,7 @@ pub enum Error { /// Transaction entering the pool. new: Priority }, - /// Deps cycle etected and we couldn't import transaction. + /// Deps cycle detected and we couldn't import transaction. #[display(fmt="Cycle Detected")] CycleDetected, /// Transaction was dropped immediately after it got inserted. diff --git a/frame/treasury/src/lib.rs b/frame/treasury/src/lib.rs index 210761d87e..5574c69d7a 100644 --- a/frame/treasury/src/lib.rs +++ b/frame/treasury/src/lib.rs @@ -60,14 +60,14 @@ #[cfg(feature = "std")] use serde::{Serialize, Deserialize}; use sp_std::prelude::*; -use frame_support::{decl_module, decl_storage, decl_event, ensure, print}; +use frame_support::{decl_module, decl_storage, decl_event, ensure, print, decl_error}; use frame_support::traits::{ Currency, ExistenceRequirement, Get, Imbalance, OnUnbalanced, ReservableCurrency, WithdrawReason }; use sp_runtime::{Permill, ModuleId}; use sp_runtime::traits::{ - Zero, EnsureOrigin, StaticLookup, AccountIdConversion, Saturating + Zero, EnsureOrigin, StaticLookup, AccountIdConversion, Saturating, ModuleDispatchError, }; use frame_support::weights::SimpleDispatchInfo; use codec::{Encode, Decode}; @@ -126,7 +126,10 @@ decl_module! { /// Percentage of spare funds (if any) that are burnt per spend period. const Burn: Permill = T::Burn::get(); + type Error = Error; + fn deposit_event() = default; + /// Put forward a suggestion for spending. A deposit proportional to the value /// is reserved and slashed if the proposal is rejected. It is returned once the /// proposal is awarded. @@ -142,12 +145,12 @@ decl_module! { #[compact] value: BalanceOf, beneficiary: ::Source ) { - let proposer = ensure_signed(origin)?; + let proposer = ensure_signed(origin).map_err(|e| e.as_str())?; let beneficiary = T::Lookup::lookup(beneficiary)?; let bond = Self::calculate_bond(value); T::Currency::reserve(&proposer, bond) - .map_err(|_| "Proposer's balance too low")?; + .map_err(|_| Error::InsufficientProposersBalance)?; let c = Self::proposal_count(); ProposalCount::put(c + 1); @@ -165,8 +168,8 @@ decl_module! { /// # #[weight = SimpleDispatchInfo::FixedOperational(100_000)] fn reject_proposal(origin, #[compact] proposal_id: ProposalIndex) { - T::RejectOrigin::ensure_origin(origin)?; - let proposal = >::take(proposal_id).ok_or("No proposal at that index")?; + T::RejectOrigin::ensure_origin(origin).map_err(|e| Into::<&str>::into(e))?; + let proposal = >::take(proposal_id).ok_or(Error::InvalidProposalIndex)?; let value = proposal.bond; let imbalance = T::Currency::slash_reserved(&proposal.proposer, value).0; @@ -183,9 +186,9 @@ decl_module! { /// # #[weight = SimpleDispatchInfo::FixedOperational(100_000)] fn approve_proposal(origin, #[compact] proposal_id: ProposalIndex) { - T::ApproveOrigin::ensure_origin(origin)?; + T::ApproveOrigin::ensure_origin(origin).map_err(|e| Into::<&str>::into(e))?; - ensure!(>::exists(proposal_id), "No proposal at that index"); + ensure!(>::exists(proposal_id), Error::InvalidProposalIndex); Approvals::mutate(|v| v.push(proposal_id)); } @@ -252,6 +255,16 @@ decl_event!( } ); +decl_error! { + /// Error for the treasury module. + pub enum Error { + /// Proposer's balance is too low. + InsufficientProposersBalance, + /// No proposal at that index. + InvalidProposalIndex, + } +} + impl Module { // Add public immutables and private mutables. @@ -471,7 +484,7 @@ mod tests { #[test] fn spend_proposal_fails_when_proposer_poor() { new_test_ext().execute_with(|| { - assert_noop!(Treasury::propose_spend(Origin::signed(2), 100, 3), "Proposer's balance too low"); + assert_noop!(Treasury::propose_spend(Origin::signed(2), 100, 3), Error::InsufficientProposersBalance); }); } @@ -523,21 +536,21 @@ mod tests { assert_ok!(Treasury::propose_spend(Origin::signed(0), 100, 3)); assert_ok!(Treasury::reject_proposal(Origin::ROOT, 0)); - assert_noop!(Treasury::reject_proposal(Origin::ROOT, 0), "No proposal at that index"); + assert_noop!(Treasury::reject_proposal(Origin::ROOT, 0), Error::InvalidProposalIndex); }); } #[test] fn reject_non_existant_spend_proposal_fails() { new_test_ext().execute_with(|| { - assert_noop!(Treasury::reject_proposal(Origin::ROOT, 0), "No proposal at that index"); + assert_noop!(Treasury::reject_proposal(Origin::ROOT, 0), Error::InvalidProposalIndex); }); } #[test] fn accept_non_existant_spend_proposal_fails() { new_test_ext().execute_with(|| { - assert_noop!(Treasury::approve_proposal(Origin::ROOT, 0), "No proposal at that index"); + assert_noop!(Treasury::approve_proposal(Origin::ROOT, 0), Error::InvalidProposalIndex); }); } @@ -548,7 +561,7 @@ mod tests { assert_ok!(Treasury::propose_spend(Origin::signed(0), 100, 3)); assert_ok!(Treasury::reject_proposal(Origin::ROOT, 0)); - assert_noop!(Treasury::approve_proposal(Origin::ROOT, 0), "No proposal at that index"); + assert_noop!(Treasury::approve_proposal(Origin::ROOT, 0), Error::InvalidProposalIndex); }); } -- GitLab From 86f174592c3534fa59c484575bfe80753f448e0e Mon Sep 17 00:00:00 2001 From: Stanislav Tkach Date: Tue, 17 Dec 2019 07:03:24 +0100 Subject: [PATCH 145/172] Use decl_error in stacking module (#4387) --- frame/staking/src/lib.rs | 98 ++++++++++++++++++++++++-------------- frame/staking/src/tests.rs | 16 +++---- 2 files changed, 71 insertions(+), 43 deletions(-) diff --git a/frame/staking/src/lib.rs b/frame/staking/src/lib.rs index 3d641e24a5..bc43b54e91 100644 --- a/frame/staking/src/lib.rs +++ b/frame/staking/src/lib.rs @@ -258,7 +258,7 @@ pub mod inflation; use sp_std::{prelude::*, result}; use codec::{HasCompact, Encode, Decode}; use frame_support::{ - decl_module, decl_event, decl_storage, ensure, + decl_module, decl_event, decl_storage, ensure, decl_error, weights::SimpleDispatchInfo, traits::{ Currency, OnFreeBalanceZero, LockIdentifier, LockableCurrency, @@ -272,7 +272,7 @@ use sp_runtime::{ curve::PiecewiseLinear, traits::{ Convert, Zero, One, StaticLookup, CheckedSub, Saturating, Bounded, SaturatedConversion, - SimpleArithmetic, EnsureOrigin, + SimpleArithmetic, EnsureOrigin, ModuleDispatchError, } }; use sp_staking::{ @@ -783,6 +783,32 @@ decl_event!( } ); +decl_error! { + /// Error for the stacking module. + pub enum Error { + /// Not a controller account. + NotController, + /// Not a stash account. + NotStash, + /// Stash is already bonded. + AlreadyBonded, + /// Controller is already paired. + AlreadyPaired, + /// Should be the root origin or the `T::SlashCancelOrigin`. + BadOrigin, + /// Targets cannot be empty. + EmptyTargets, + /// Duplicate index. + DuplicateIndex, + /// Slash record index out of bounds. + InvalidSlashIndex, + /// Can not bond with value less than minimum balance. + InsufficientValue, + /// Can not schedule more unlock chunks. + NoMoreChunks, + } +} + decl_module! { pub struct Module for enum Call where origin: T::Origin { /// Number of sessions per era. @@ -791,6 +817,8 @@ decl_module! { /// Number of eras that staked funds must remain bonded for. const BondingDuration: EraIndex = T::BondingDuration::get(); + type Error = Error; + fn deposit_event() = default; fn on_initialize() { @@ -825,21 +853,21 @@ decl_module! { #[compact] value: BalanceOf, payee: RewardDestination ) { - let stash = ensure_signed(origin)?; + let stash = ensure_signed(origin).map_err(|e| e.as_str())?; if >::exists(&stash) { - return Err("stash already bonded") + return Err(Error::AlreadyBonded) } let controller = T::Lookup::lookup(controller)?; if >::exists(&controller) { - return Err("controller already paired") + return Err(Error::AlreadyPaired) } // reject a bond which is considered to be _dust_. if value < T::Currency::minimum_balance() { - return Err("can not bond with value less than minimum balance") + return Err(Error::InsufficientValue) } // You're auto-bonded forever, here. We might improve this by only bonding when @@ -869,10 +897,10 @@ decl_module! { /// # #[weight = SimpleDispatchInfo::FixedNormal(500_000)] fn bond_extra(origin, #[compact] max_additional: BalanceOf) { - let stash = ensure_signed(origin)?; + let stash = ensure_signed(origin).map_err(|e| e.as_str())?; - let controller = Self::bonded(&stash).ok_or("not a stash")?; - let mut ledger = Self::ledger(&controller).ok_or("not a controller")?; + let controller = Self::bonded(&stash).ok_or(Error::NotStash)?; + let mut ledger = Self::ledger(&controller).ok_or(Error::NotController)?; let stash_balance = T::Currency::free_balance(&stash); @@ -909,11 +937,11 @@ decl_module! { /// #[weight = SimpleDispatchInfo::FixedNormal(400_000)] fn unbond(origin, #[compact] value: BalanceOf) { - let controller = ensure_signed(origin)?; - let mut ledger = Self::ledger(&controller).ok_or("not a controller")?; + let controller = ensure_signed(origin).map_err(|e| e.as_str())?; + let mut ledger = Self::ledger(&controller).ok_or(Error::NotController)?; ensure!( ledger.unlocking.len() < MAX_UNLOCKING_CHUNKS, - "can not schedule more unlock chunks" + Error::NoMoreChunks ); let mut value = value.min(ledger.active); @@ -951,8 +979,8 @@ decl_module! { /// # #[weight = SimpleDispatchInfo::FixedNormal(400_000)] fn withdraw_unbonded(origin) { - let controller = ensure_signed(origin)?; - let ledger = Self::ledger(&controller).ok_or("not a controller")?; + let controller = ensure_signed(origin).map_err(|e| e.as_str())?; + let ledger = Self::ledger(&controller).ok_or(Error::NotController)?; let ledger = ledger.consolidate_unlocked(Self::current_era()); if ledger.unlocking.is_empty() && ledger.active.is_zero() { @@ -985,8 +1013,8 @@ decl_module! { fn validate(origin, prefs: ValidatorPrefs) { Self::ensure_storage_upgraded(); - let controller = ensure_signed(origin)?; - let ledger = Self::ledger(&controller).ok_or("not a controller")?; + let controller = ensure_signed(origin).map_err(|e| e.as_str())?; + let ledger = Self::ledger(&controller).ok_or(Error::NotController)?; let stash = &ledger.stash; >::remove(stash); >::insert(stash, prefs); @@ -1007,10 +1035,10 @@ decl_module! { fn nominate(origin, targets: Vec<::Source>) { Self::ensure_storage_upgraded(); - let controller = ensure_signed(origin)?; - let ledger = Self::ledger(&controller).ok_or("not a controller")?; + let controller = ensure_signed(origin).map_err(|e| e.as_str())?; + let ledger = Self::ledger(&controller).ok_or(Error::NotController)?; let stash = &ledger.stash; - ensure!(!targets.is_empty(), "targets cannot be empty"); + ensure!(!targets.is_empty(), Error::EmptyTargets); let targets = targets.into_iter() .take(MAX_NOMINATIONS) .map(|t| T::Lookup::lookup(t)) @@ -1039,8 +1067,8 @@ decl_module! { /// # #[weight = SimpleDispatchInfo::FixedNormal(500_000)] fn chill(origin) { - let controller = ensure_signed(origin)?; - let ledger = Self::ledger(&controller).ok_or("not a controller")?; + let controller = ensure_signed(origin).map_err(|e| e.as_str())?; + let ledger = Self::ledger(&controller).ok_or(Error::NotController)?; Self::chill_stash(&ledger.stash); } @@ -1057,8 +1085,8 @@ decl_module! { /// # #[weight = SimpleDispatchInfo::FixedNormal(500_000)] fn set_payee(origin, payee: RewardDestination) { - let controller = ensure_signed(origin)?; - let ledger = Self::ledger(&controller).ok_or("not a controller")?; + let controller = ensure_signed(origin).map_err(|e| e.as_str())?; + let ledger = Self::ledger(&controller).ok_or(Error::NotController)?; let stash = &ledger.stash; >::insert(stash, payee); } @@ -1076,11 +1104,11 @@ decl_module! { /// # #[weight = SimpleDispatchInfo::FixedNormal(750_000)] fn set_controller(origin, controller: ::Source) { - let stash = ensure_signed(origin)?; - let old_controller = Self::bonded(&stash).ok_or("not a stash")?; + let stash = ensure_signed(origin).map_err(|e| e.as_str())?; + let old_controller = Self::bonded(&stash).ok_or(Error::NotStash)?; let controller = T::Lookup::lookup(controller)?; if >::exists(&controller) { - return Err("controller already paired") + return Err(Error::AlreadyPaired) } if controller != old_controller { >::insert(&stash, &controller); @@ -1093,7 +1121,7 @@ decl_module! { /// The ideal number of validators. #[weight = SimpleDispatchInfo::FreeOperational] fn set_validator_count(origin, #[compact] new: u32) { - ensure_root(origin)?; + ensure_root(origin).map_err(|e| e.as_str())?; ValidatorCount::put(new); } @@ -1106,7 +1134,7 @@ decl_module! { /// # #[weight = SimpleDispatchInfo::FreeOperational] fn force_no_eras(origin) { - ensure_root(origin)?; + ensure_root(origin).map_err(|e| e.as_str())?; ForceEra::put(Forcing::ForceNone); } @@ -1118,21 +1146,21 @@ decl_module! { /// # #[weight = SimpleDispatchInfo::FreeOperational] fn force_new_era(origin) { - ensure_root(origin)?; + ensure_root(origin).map_err(|e| e.as_str())?; ForceEra::put(Forcing::ForceNew); } /// Set the validators who cannot be slashed (if any). #[weight = SimpleDispatchInfo::FreeOperational] fn set_invulnerables(origin, validators: Vec) { - ensure_root(origin)?; + ensure_root(origin).map_err(|e| e.as_str())?; >::put(validators); } /// Force a current staker to become completely unstaked, immediately. #[weight = SimpleDispatchInfo::FreeOperational] fn force_unstake(origin, stash: T::AccountId) { - ensure_root(origin)?; + ensure_root(origin).map_err(|e| e.as_str())?; // remove the lock. T::Currency::remove_lock(STAKING_ID, &stash); @@ -1147,7 +1175,7 @@ decl_module! { /// # #[weight = SimpleDispatchInfo::FreeOperational] fn force_new_era_always(origin) { - ensure_root(origin)?; + ensure_root(origin).map_err(|e| e.as_str())?; ForceEra::put(Forcing::ForceAlways); } @@ -1163,7 +1191,7 @@ decl_module! { T::SlashCancelOrigin::try_origin(origin) .map(|_| ()) .or_else(ensure_root) - .map_err(|_| "bad origin")?; + .map_err(|_| Error::BadOrigin)?; let mut slash_indices = slash_indices; slash_indices.sort_unstable(); @@ -1173,12 +1201,12 @@ decl_module! { let index = index as usize; // if `index` is not duplicate, `removed` must be <= index. - ensure!(removed <= index, "duplicate index"); + ensure!(removed <= index, Error::DuplicateIndex); // all prior removals were from before this index, since the // list is sorted. let index = index - removed; - ensure!(index < unapplied.len(), "slash record index out of bounds"); + ensure!(index < unapplied.len(), Error::InvalidSlashIndex); unapplied.remove(index); } diff --git a/frame/staking/src/tests.rs b/frame/staking/src/tests.rs index c31cdf7611..33bf860b2c 100644 --- a/frame/staking/src/tests.rs +++ b/frame/staking/src/tests.rs @@ -35,7 +35,7 @@ fn force_unstake_works() { "account liquidity restrictions prevent withdrawal" ); // Force unstake requires root. - assert_noop!(Staking::force_unstake(Origin::signed(11), 11), "RequireRootOrigin"); + assert_noop!(Staking::force_unstake(Origin::signed(11), 11), "RequireRootOrigin".into()); // We now force them to unstake assert_ok!(Staking::force_unstake(Origin::ROOT, 11)); // No longer bonded. @@ -142,7 +142,7 @@ fn change_controller_works() { assert_noop!( Staking::validate(Origin::signed(10), ValidatorPrefs::default()), - "not a controller" + Error::NotController, ); assert_ok!(Staking::validate(Origin::signed(5), ValidatorPrefs::default())); }) @@ -680,10 +680,10 @@ fn double_staking_should_fail() { // 4 = not used so far, 1 stashed => not allowed. assert_noop!( Staking::bond(Origin::signed(1), 4, arbitrary_value, - RewardDestination::default()), "stash already bonded" + RewardDestination::default()), Error::AlreadyBonded, ); // 1 = stashed => attempting to nominate should fail. - assert_noop!(Staking::nominate(Origin::signed(1), vec![1]), "not a controller"); + assert_noop!(Staking::nominate(Origin::signed(1), vec![1]), Error::NotController); // 2 = controller => nominating should work. assert_ok!(Staking::nominate(Origin::signed(2), vec![1])); }); @@ -705,7 +705,7 @@ fn double_controlling_should_fail() { // 2 = controller, 3 stashed (Note that 2 is reused.) => no-op assert_noop!( Staking::bond(Origin::signed(3), 2, arbitrary_value, RewardDestination::default()), - "controller already paired", + Error::AlreadyPaired, ); }); } @@ -1152,11 +1152,11 @@ fn too_many_unbond_calls_should_not_work() { // locked at era 1 until 4 assert_ok!(Staking::unbond(Origin::signed(10), 1)); // can't do more. - assert_noop!(Staking::unbond(Origin::signed(10), 1), "can not schedule more unlock chunks"); + assert_noop!(Staking::unbond(Origin::signed(10), 1), Error::NoMoreChunks); start_era(3); - assert_noop!(Staking::unbond(Origin::signed(10), 1), "can not schedule more unlock chunks"); + assert_noop!(Staking::unbond(Origin::signed(10), 1), Error::NoMoreChunks); // free up. assert_ok!(Staking::withdraw_unbonded(Origin::signed(10))); @@ -1422,7 +1422,7 @@ fn bond_with_no_staked_value() { // Can't bond with 1 assert_noop!( Staking::bond(Origin::signed(1), 2, 1, RewardDestination::Controller), - "can not bond with value less than minimum balance", + Error::InsufficientValue, ); // bonded with absolute minimum value possible. assert_ok!(Staking::bond(Origin::signed(1), 2, 5, RewardDestination::Controller)); -- GitLab From 40b1e530870cd5c1803fdd39b6386dcaa6a770fb Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Tue, 17 Dec 2019 14:25:52 +0800 Subject: [PATCH 146/172] Fix naming of utility crate (it's a legit pallet) (#4408) * Fix naming of utility crate (it's a legit pallet) * Additional bits --- Cargo.lock | 32 ++++++++++++++++---------------- bin/node/runtime/Cargo.toml | 4 ++-- bin/node/runtime/src/lib.rs | 4 ++-- frame/utility/Cargo.toml | 2 +- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 679fa8d59a..7bb1f65567 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1397,21 +1397,6 @@ dependencies = [ "sp-api 2.0.0", ] -[[package]] -name = "frame-utility" -version = "2.0.0" -dependencies = [ - "frame-support 2.0.0", - "frame-system 2.0.0", - "pallet-balances 2.0.0", - "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-core 2.0.0", - "sp-io 2.0.0", - "sp-runtime 2.0.0", - "sp-std 2.0.0", -] - [[package]] name = "fs-swap" version = "0.2.4" @@ -3151,7 +3136,6 @@ dependencies = [ "frame-support 2.0.0", "frame-system 2.0.0", "frame-system-rpc-runtime-api 2.0.0", - "frame-utility 2.0.0", "integer-sqrt 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "node-primitives 2.0.0", "pallet-authority-discovery 0.1.0", @@ -3179,6 +3163,7 @@ dependencies = [ "pallet-transaction-payment 2.0.0", "pallet-transaction-payment-rpc-runtime-api 2.0.0", "pallet-treasury 2.0.0", + "pallet-utility 2.0.0", "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4044,6 +4029,21 @@ dependencies = [ "sp-std 2.0.0", ] +[[package]] +name = "pallet-utility" +version = "2.0.0" +dependencies = [ + "frame-support 2.0.0", + "frame-system 2.0.0", + "pallet-balances 2.0.0", + "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "sp-core 2.0.0", + "sp-io 2.0.0", + "sp-runtime 2.0.0", + "sp-std 2.0.0", +] + [[package]] name = "parity-bytes" version = "0.1.1" diff --git a/bin/node/runtime/Cargo.toml b/bin/node/runtime/Cargo.toml index b8d669784d..c3d79373ec 100644 --- a/bin/node/runtime/Cargo.toml +++ b/bin/node/runtime/Cargo.toml @@ -58,7 +58,7 @@ frame-system = { path = "../../../frame/system", default-features = false } frame-system-rpc-runtime-api = { path = "../../../frame/system/rpc/runtime-api/", default-features = false } pallet-timestamp = { path = "../../../frame/timestamp", default-features = false } pallet-treasury = { path = "../../../frame/treasury", default-features = false } -frame-utility = { path = "../../../frame/utility", default-features = false } +pallet-utility = { path = "../../../frame/utility", default-features = false } pallet-transaction-payment = { path = "../../../frame/transaction-payment", default-features = false } pallet-transaction-payment-rpc-runtime-api = { path = "../../../frame/transaction-payment/rpc/runtime-api/", default-features = false } @@ -117,6 +117,6 @@ std = [ "pallet-transaction-payment/std", "pallet-treasury/std", "sp-transaction-pool/std", - "frame-utility/std", + "pallet-utility/std", "sp-version/std", ] diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index fbf765fee5..fc8a7e4eae 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -127,7 +127,7 @@ impl frame_system::Trait for Runtime { type Version = Version; } -impl frame_utility::Trait for Runtime { +impl pallet_utility::Trait for Runtime { type Event = Event; type Call = Call; } @@ -515,7 +515,7 @@ construct_runtime!( UncheckedExtrinsic = UncheckedExtrinsic { System: system::{Module, Call, Storage, Config, Event}, - Utility: frame_utility::{Module, Call, Event}, + Utility: pallet_utility::{Module, Call, Event}, Babe: pallet_babe::{Module, Call, Storage, Config, Inherent(Timestamp)}, Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent}, Authorship: pallet_authorship::{Module, Call, Storage, Inherent}, diff --git a/frame/utility/Cargo.toml b/frame/utility/Cargo.toml index e4bcd1f84b..e35927bc62 100644 --- a/frame/utility/Cargo.toml +++ b/frame/utility/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "frame-utility" +name = "pallet-utility" version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" -- GitLab From 010234864b6e199d7a8167a1ad775833a4557e5c Mon Sep 17 00:00:00 2001 From: Svyatoslav Nikolsky Date: Tue, 17 Dec 2019 10:45:04 +0300 Subject: [PATCH 147/172] recover light client integration tests (#4377) --- bin/node/cli/src/chain_spec.rs | 10 ++-------- bin/node/cli/src/service.rs | 22 +++++----------------- client/service/test/src/lib.rs | 8 +------- 3 files changed, 8 insertions(+), 32 deletions(-) diff --git a/bin/node/cli/src/chain_spec.rs b/bin/node/cli/src/chain_spec.rs index 8b86cb865b..cf47d25bc6 100644 --- a/bin/node/cli/src/chain_spec.rs +++ b/bin/node/cli/src/chain_spec.rs @@ -349,8 +349,7 @@ pub fn local_testnet_config() -> ChainSpec { #[cfg(test)] pub(crate) mod tests { use super::*; - use crate::service::new_full; - use sc_service::Roles; + use crate::service::{new_full, new_light}; use sc_service_test; fn local_testnet_genesis_instant_single() -> GenesisConfig { @@ -398,12 +397,7 @@ pub(crate) mod tests { sc_service_test::connectivity( integration_test_config_with_two_authorities(), |config| new_full(config), - |mut config| { - // light nodes are unsupported - config.roles = Roles::FULL; - new_full(config) - }, - true, + |config| new_light(config), ); } } diff --git a/bin/node/cli/src/service.rs b/bin/node/cli/src/service.rs index 7716f5a1c3..1403393866 100644 --- a/bin/node/cli/src/service.rs +++ b/bin/node/cli/src/service.rs @@ -408,8 +408,8 @@ mod tests { use sp_timestamp; use sp_finality_tracker; use sp_keyring::AccountKeyring; - use sc_service::{AbstractService, Roles}; - use crate::service::new_full; + use sc_service::AbstractService; + use crate::service::{new_full, new_light}; use sp_runtime::traits::IdentifyAccount; type AccountPublic = ::Signer; @@ -470,11 +470,7 @@ mod tests { sc_service_test::sync( sc_chain_spec::integration_test_config(), |config| new_full(config), - |mut config| { - // light nodes are unsupported - config.roles = Roles::FULL; - new_full(config) - }, + |mut config| new_light(config), block_factory, extrinsic_factory, ); @@ -510,11 +506,7 @@ mod tests { setup_handles = Some((block_import.clone(), babe_link.clone())); }).map(move |(node, x)| (node, (x, setup_handles.unwrap()))) }, - |mut config| { - // light nodes are unsupported - config.roles = Roles::FULL; - new_full(config) - }, + |config| new_light(config), |service, &mut (ref inherent_data_providers, (ref mut block_import, ref babe_link))| { let mut inherent_data = inherent_data_providers .create_inherent_data() @@ -638,11 +630,7 @@ mod tests { sc_service_test::consensus( crate::chain_spec::tests::integration_test_config_with_two_authorities(), |config| new_full(config), - |mut config| { - // light nodes are unsupported - config.roles = Roles::FULL; - new_full(config) - }, + |config| new_light(config), vec![ "//Alice".into(), "//Bob".into(), diff --git a/client/service/test/src/lib.rs b/client/service/test/src/lib.rs index e1eb919a6f..dae0f5604f 100644 --- a/client/service/test/src/lib.rs +++ b/client/service/test/src/lib.rs @@ -299,8 +299,6 @@ pub fn connectivity( spec: ChainSpec, full_builder: Fb, light_builder: Lb, - light_node_interconnectivity: bool, // should normally be false, unless the light nodes - // aren't actually light. ) where E: Clone, Fb: Fn(Configuration<(), G, E>) -> Result, @@ -312,11 +310,7 @@ pub fn connectivity( const NUM_LIGHT_NODES: usize = 5; let expected_full_connections = NUM_FULL_NODES - 1 + NUM_LIGHT_NODES; - let expected_light_connections = if light_node_interconnectivity { - expected_full_connections - } else { - NUM_FULL_NODES - }; + let expected_light_connections = NUM_FULL_NODES; { let temp = tempdir_with_prefix("substrate-connectivity-test"); -- GitLab From ff75a19ce49640adda13581f418528a076f24d4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Tue, 17 Dec 2019 10:54:50 +0100 Subject: [PATCH 148/172] Fix frame_system renaming in contruct_runtime (#4412) * Fix contruct_runtime * Update lib.rs * Update event.rs * Update event.rs * Update event.rs * Update event.rs * Update event.rs * Update event.rs * Update event.rs Back to where we started * Update chain_spec.rs * Update genesis.rs * Fix it properly --- bin/node/cli/src/chain_spec.rs | 2 +- bin/node/runtime/src/lib.rs | 3 +-- bin/node/testing/src/genesis.rs | 2 +- frame/support/src/event.rs | 33 ++++++++++++++++++++------------- 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/bin/node/cli/src/chain_spec.rs b/bin/node/cli/src/chain_spec.rs index cf47d25bc6..bfab71b553 100644 --- a/bin/node/cli/src/chain_spec.rs +++ b/bin/node/cli/src/chain_spec.rs @@ -225,7 +225,7 @@ pub fn testnet_genesis( const STASH: Balance = 100 * DOLLARS; GenesisConfig { - system: Some(SystemConfig { + frame_system: Some(SystemConfig { code: WASM_BINARY.to_vec(), changes_trie_config: Default::default(), }), diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index fc8a7e4eae..e3f3101b37 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -507,14 +507,13 @@ impl frame_system::offchain::CreateTransaction for } } -use frame_system as system; construct_runtime!( pub enum Runtime where Block = Block, NodeBlock = node_primitives::Block, UncheckedExtrinsic = UncheckedExtrinsic { - System: system::{Module, Call, Storage, Config, Event}, + System: frame_system::{Module, Call, Storage, Config, Event}, Utility: pallet_utility::{Module, Call, Event}, Babe: pallet_babe::{Module, Call, Storage, Config, Inherent(Timestamp)}, Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent}, diff --git a/bin/node/testing/src/genesis.rs b/bin/node/testing/src/genesis.rs index feb9ed526f..3a7e597ed5 100644 --- a/bin/node/testing/src/genesis.rs +++ b/bin/node/testing/src/genesis.rs @@ -30,7 +30,7 @@ use sp_runtime::Perbill; /// Create genesis runtime configuration for tests. pub fn config(support_changes_trie: bool, code: Option<&[u8]>) -> GenesisConfig { GenesisConfig { - system: Some(SystemConfig { + frame_system: Some(SystemConfig { changes_trie_config: if support_changes_trie { Some(ChangesTrieConfiguration { digest_interval: 2, digest_levels: 2, diff --git a/frame/support/src/event.rs b/frame/support/src/event.rs index 3453adf796..1c9a0b66fe 100644 --- a/frame/support/src/event.rs +++ b/frame/support/src/event.rs @@ -543,21 +543,28 @@ macro_rules! __impl_outer_event_json_metadata { } } - #[allow(dead_code)] - pub fn __module_events_system() -> &'static [$crate::event::EventMetadata] { - system::Event::metadata() + $crate::__impl_outer_event_json_metadata! { + @DECL_MODULE_EVENT_FNS + $system <> ; + $( $module_name < $( $generic_params ),* > $( $instance )? ; )* } + } + }; - $crate::paste::item! { - $( - #[allow(dead_code)] - pub fn [< __module_events_ $module_name $( _ $instance )? >] () -> - &'static [$crate::event::EventMetadata] - { - $module_name::Event ::< $( $generic_params ),* > ::metadata() - } - )* - } + (@DECL_MODULE_EVENT_FNS + $( + $module_name:ident < $( $generic_params:path ),* > $( $instance:ident )? ; + )* + ) => { + $crate::paste::item! { + $( + #[allow(dead_code)] + pub fn [< __module_events_ $module_name $( _ $instance )? >] () -> + &'static [$crate::event::EventMetadata] + { + $module_name::Event ::< $( $generic_params ),* > ::metadata() + } + )* } } } -- GitLab From f548309478da3935f72567c2abc2eceec3978e9f Mon Sep 17 00:00:00 2001 From: Niklas Adolfsson Date: Tue, 17 Dec 2019 11:45:20 +0100 Subject: [PATCH 149/172] [client cli] generic blocknumber (#4376) * rewrite me * [cli]: make `BlockNumber` generic * cleanup --- client/cli/src/lib.rs | 19 +++++++---- client/cli/src/params.rs | 43 +++++++++++++++++++++--- frame/system/src/lib.rs | 2 +- primitives/runtime/src/generic/header.rs | 2 +- primitives/runtime/src/traits.rs | 2 +- 5 files changed, 54 insertions(+), 14 deletions(-) diff --git a/client/cli/src/lib.rs b/client/cli/src/lib.rs index d4387c984f..c2e11b56ca 100644 --- a/client/cli/src/lib.rs +++ b/client/cli/src/lib.rs @@ -42,7 +42,7 @@ use sc_network::{ use sp_core::H256; use std::{ - io::{Write, Read, Seek, Cursor, stdin, stdout, ErrorKind}, iter, fs::{self, File}, + io::{Write, Read, Seek, Cursor, stdin, stdout, ErrorKind}, iter, fmt::Debug, fs::{self, File}, net::{Ipv4Addr, SocketAddr}, path::{Path, PathBuf}, str::FromStr, pin::Pin, task::Poll }; @@ -64,7 +64,7 @@ use lazy_static::lazy_static; use futures::{Future, compat::Future01CompatExt, executor::block_on}; use sc_telemetry::TelemetryEndpoints; use sp_runtime::generic::BlockId; -use sp_runtime::traits::Block as BlockT; +use sp_runtime::traits::{Block as BlockT, Header as HeaderT}; /// default sub directory to store network config const DEFAULT_NETWORK_CONFIG_PATH : &'static str = "network"; @@ -373,6 +373,8 @@ impl<'a> ParseAndPrepareExport<'a> { where S: FnOnce(&str) -> Result>, String>, F: FnOnce(Configuration) -> Result, B: ServiceBuilderCommand, + <<<::Block as BlockT>::Header as HeaderT> + ::Number as FromStr>::Err: Debug, C: Default, G: RuntimeGenesis, E: ChainSpecExtension, @@ -383,8 +385,9 @@ impl<'a> ParseAndPrepareExport<'a> { if let DatabaseConfig::Path { ref path, .. } = &config.database { info!("DB path: {}", path.display()); } - let from = self.params.from.unwrap_or(1); - let to = self.params.to; + let from = self.params.from.and_then(|f| f.parse().ok()).unwrap_or(1); + let to = self.params.to.and_then(|t| t.parse().ok()); + let json = self.params.json; let file: Box = match self.params.output { @@ -402,7 +405,7 @@ impl<'a> ParseAndPrepareExport<'a> { }); let mut export_fut = builder(config)? - .export_blocks(file, from.into(), to.map(Into::into), json) + .export_blocks(file, from.into(), to, json) .compat(); let fut = futures::future::poll_fn(|cx| { if exit_recv.try_recv().is_ok() { @@ -596,6 +599,8 @@ impl<'a> ParseAndPrepareRevert<'a> { S: FnOnce(&str) -> Result>, String>, F: FnOnce(Configuration) -> Result, B: ServiceBuilderCommand, + <<<::Block as BlockT>::Header as HeaderT> + ::Number as FromStr>::Err: Debug, C: Default, G: RuntimeGenesis, E: ChainSpecExtension, @@ -603,8 +608,8 @@ impl<'a> ParseAndPrepareRevert<'a> { let config = create_config_with_db_path( spec_factory, &self.params.shared_params, self.version )?; - let blocks = self.params.num; - builder(config)?.revert_chain(blocks.into())?; + let blocks = self.params.num.parse()?; + builder(config)?.revert_chain(blocks)?; Ok(()) } } diff --git a/client/cli/src/params.rs b/client/cli/src/params.rs index 7121c53858..10be3f0c1b 100644 --- a/client/cli/src/params.rs +++ b/client/cli/src/params.rs @@ -16,7 +16,7 @@ use crate::traits::{AugmentClap, GetLogFilter}; -use std::path::PathBuf; +use std::{str::FromStr, path::PathBuf}; use structopt::{StructOpt, clap::{arg_enum, App, AppSettings, SubCommand, Arg}}; pub use crate::execution_strategy::ExecutionStrategy; @@ -734,6 +734,41 @@ pub struct BuildSpecCmd { impl_get_log_filter!(BuildSpecCmd); +/// Wrapper type of `String` which holds an arbitary sized unsigned integer formatted as decimal. +#[derive(Debug, Clone)] +pub struct BlockNumber(String); + +impl FromStr for BlockNumber { + type Err = String; + + fn from_str(block_number: &str) -> Result { + if block_number.chars().any(|d| !d.is_digit(10)) { + Err(format!( + "Invalid block number: {}, expected decimal formatted unsigned integer", + block_number + )) + } else { + Ok(Self(block_number.to_owned())) + } + } +} + +impl BlockNumber { + /// Wrapper on top of `std::str::parse` but with `Error` as a `String` + /// + /// See `https://doc.rust-lang.org/std/primitive.str.html#method.parse` for more elaborate + /// documentation. + pub fn parse(&self) -> Result + where + N: FromStr, + N::Err: std::fmt::Debug, + { + self.0 + .parse() + .map_err(|e| format!("BlockNumber: {} parsing failed because of {:?}", self.0, e)) + } +} + /// The `export-blocks` command used to export blocks. #[derive(Debug, StructOpt, Clone)] pub struct ExportBlocksCmd { @@ -745,13 +780,13 @@ pub struct ExportBlocksCmd { /// /// Default is 1. #[structopt(long = "from", value_name = "BLOCK")] - pub from: Option, + pub from: Option, /// Specify last block number. /// /// Default is best block. #[structopt(long = "to", value_name = "BLOCK")] - pub to: Option, + pub to: Option, /// Use JSON output rather than binary. #[structopt(long = "json")] @@ -817,7 +852,7 @@ impl_get_log_filter!(CheckBlockCmd); pub struct RevertCmd { /// Number of blocks to revert. #[structopt(default_value = "256")] - pub num: u32, + pub num: BlockNumber, #[allow(missing_docs)] #[structopt(flatten)] diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index cf008101ed..1acdc30570 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -172,7 +172,7 @@ pub trait Trait: 'static + Eq + Clone { /// The block number type used by the runtime. type BlockNumber: Parameter + Member + MaybeSerializeDeserialize + Debug + MaybeDisplay + SimpleArithmetic - + Default + Bounded + Copy + sp_std::hash::Hash; + + Default + Bounded + Copy + sp_std::hash::Hash + sp_std::str::FromStr; /// The output of the `Hashing` function. type Hash: diff --git a/primitives/runtime/src/generic/header.rs b/primitives/runtime/src/generic/header.rs index c095490bc9..35f2e91afc 100644 --- a/primitives/runtime/src/generic/header.rs +++ b/primitives/runtime/src/generic/header.rs @@ -105,7 +105,7 @@ impl codec::EncodeLike for Header where impl traits::Header for Header where Number: Member + MaybeSerializeDeserialize + Debug + sp_std::hash::Hash + MaybeDisplay + - SimpleArithmetic + Codec + Copy + Into + TryFrom, + SimpleArithmetic + Codec + Copy + Into + TryFrom + sp_std::str::FromStr, Hash: HashT, Hash::Output: Default + sp_std::hash::Hash + Copy + Member + MaybeSerialize + Debug + MaybeDisplay + SimpleBitOps + Codec, diff --git a/primitives/runtime/src/traits.rs b/primitives/runtime/src/traits.rs index 0001690b38..97ff85c986 100644 --- a/primitives/runtime/src/traits.rs +++ b/primitives/runtime/src/traits.rs @@ -524,7 +524,7 @@ pub trait IsMember { pub trait Header: Clone + Send + Sync + Codec + Eq + MaybeSerialize + Debug + 'static { /// Header number. type Number: Member + MaybeSerializeDeserialize + Debug + sp_std::hash::Hash - + Copy + MaybeDisplay + SimpleArithmetic + Codec; + + Copy + MaybeDisplay + SimpleArithmetic + Codec + sp_std::str::FromStr; /// Header hash type type Hash: Member + MaybeSerializeDeserialize + Debug + sp_std::hash::Hash + Copy + MaybeDisplay + Default + SimpleBitOps + Codec + AsRef<[u8]> + AsMut<[u8]>; -- GitLab From 2f1f3bd4af2c2521e32d884fbcd7ff991e5cac3c Mon Sep 17 00:00:00 2001 From: Wei Tang Date: Tue, 17 Dec 2019 05:04:57 -0800 Subject: [PATCH 150/172] docs: fix link to babe (#4418) --- client/consensus/babe/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/consensus/babe/src/lib.rs b/client/consensus/babe/src/lib.rs index d46486b1d8..de06f63848 100644 --- a/client/consensus/babe/src/lib.rs +++ b/client/consensus/babe/src/lib.rs @@ -54,7 +54,7 @@ //! blocks) and will go with the longest one in case of a tie. //! //! An in-depth description and analysis of the protocol can be found here: -//! +//! #![forbid(unsafe_code)] #![warn(missing_docs)] -- GitLab From 8db5194960dd9f97b693e9d0402e682dbd3dd36f Mon Sep 17 00:00:00 2001 From: Benjamin Kampmann Date: Tue, 17 Dec 2019 15:05:50 +0100 Subject: [PATCH 151/172] Setting versions locally towards 2.0 release (#4404) * clean up cargo.toml syntax * bumping versions to 2.0 * bump networking to 0.8 * move consensus down to 0.8 * bump consensus pallets to 0.8.0, too * Upping babe and aura pallets * add remaining, missing version definitions * missed some --- Cargo.lock | 160 +++++++++--------- bin/node-template/Cargo.toml | 38 ++--- bin/node-template/runtime/Cargo.toml | 44 ++--- bin/node/cli/Cargo.toml | 92 +++++----- bin/node/executor/Cargo.toml | 40 ++--- bin/node/primitives/Cargo.toml | 6 +- bin/node/rpc-client/Cargo.toml | 4 +- bin/node/rpc/Cargo.toml | 16 +- bin/node/runtime/Cargo.toml | 92 +++++----- bin/node/testing/Cargo.toml | 42 ++--- bin/node/transaction-factory/Cargo.toml | 22 +-- bin/utils/chain-spec-builder/Cargo.toml | 6 +- bin/utils/subkey/Cargo.toml | 6 +- client/Cargo.toml | 36 ++-- client/api/Cargo.toml | 32 ++-- client/authority-discovery/Cargo.toml | 20 +-- client/basic-authorship/Cargo.toml | 24 +-- client/block-builder/Cargo.toml | 12 +- client/chain-spec/Cargo.toml | 10 +- client/cli/Cargo.toml | 22 +-- client/consensus/aura/Cargo.toml | 48 +++--- client/consensus/babe/Cargo.toml | 54 +++--- client/consensus/pow/Cargo.toml | 20 +-- client/consensus/slots/Cargo.toml | 18 +- client/consensus/uncles/Cargo.toml | 14 +- client/db/Cargo.toml | 24 +-- client/executor/Cargo.toml | 24 +-- client/executor/runtime-test/Cargo.toml | 12 +- client/finality-grandpa/Cargo.toml | 42 ++--- client/keystore/Cargo.toml | 4 +- client/network-gossip/Cargo.toml | 4 +- client/network/Cargo.toml | 34 ++-- client/network/test/Cargo.toml | 22 +-- client/offchain/Cargo.toml | 22 +-- client/rpc-api/Cargo.toml | 8 +- client/rpc-servers/Cargo.toml | 2 +- client/rpc/Cargo.toml | 36 ++-- client/service/Cargo.toml | 54 +++--- client/service/test/Cargo.toml | 14 +- client/state-db/Cargo.toml | 2 +- client/tracing/Cargo.toml | 4 +- client/transaction-pool/Cargo.toml | 18 +- client/transaction-pool/graph/Cargo.toml | 8 +- frame/assets/Cargo.toml | 12 +- frame/aura/Cargo.toml | 20 +-- frame/authority-discovery/Cargo.toml | 22 +-- frame/authorship/Cargo.toml | 16 +- frame/babe/Cargo.toml | 26 +-- frame/balances/Cargo.toml | 14 +- frame/collective/Cargo.toml | 14 +- frame/contracts/Cargo.toml | 20 +-- frame/contracts/rpc/Cargo.toml | 10 +- frame/contracts/rpc/runtime-api/Cargo.toml | 6 +- frame/democracy/Cargo.toml | 14 +- frame/elections-phragmen/Cargo.toml | 18 +- frame/elections/Cargo.toml | 14 +- frame/evm/Cargo.toml | 16 +- frame/example/Cargo.toml | 14 +- frame/executive/Cargo.toml | 16 +- frame/finality-tracker/Cargo.toml | 16 +- frame/generic-asset/Cargo.toml | 12 +- frame/grandpa/Cargo.toml | 20 +-- frame/identity/Cargo.toml | 14 +- frame/im-online/Cargo.toml | 22 +-- frame/indices/Cargo.toml | 14 +- frame/membership/Cargo.toml | 12 +- frame/metadata/Cargo.toml | 4 +- frame/nicks/Cargo.toml | 14 +- frame/offences/Cargo.toml | 18 +- frame/randomness-collective-flip/Cargo.toml | 12 +- frame/scored-pool/Cargo.toml | 16 +- frame/session/Cargo.toml | 18 +- frame/staking/Cargo.toml | 28 +-- frame/staking/reward-curve/Cargo.toml | 2 +- frame/sudo/Cargo.toml | 12 +- frame/support/Cargo.toml | 18 +- frame/support/procedural/Cargo.toml | 2 +- frame/support/procedural/tools/Cargo.toml | 2 +- frame/support/test/Cargo.toml | 10 +- frame/system/Cargo.toml | 10 +- frame/system/rpc/runtime-api/Cargo.toml | 4 +- frame/timestamp/Cargo.toml | 16 +- frame/transaction-payment/Cargo.toml | 16 +- frame/transaction-payment/rpc/Cargo.toml | 10 +- .../rpc/runtime-api/Cargo.toml | 8 +- frame/treasury/Cargo.toml | 14 +- frame/utility/Cargo.toml | 14 +- primitives/api/Cargo.toml | 14 +- primitives/api/test/Cargo.toml | 16 +- primitives/application-crypto/Cargo.toml | 6 +- primitives/application-crypto/test/Cargo.toml | 8 +- primitives/arithmetic/Cargo.toml | 4 +- primitives/arithmetic/fuzzer/Cargo.toml | 2 +- primitives/authority-discovery/Cargo.toml | 8 +- primitives/authorship/Cargo.toml | 6 +- primitives/block-builder/Cargo.toml | 8 +- primitives/blockchain/Cargo.toml | 8 +- primitives/consensus/aura/Cargo.toml | 14 +- primitives/consensus/babe/Cargo.toml | 16 +- primitives/consensus/common/Cargo.toml | 12 +- primitives/consensus/pow/Cargo.toml | 10 +- primitives/core/Cargo.toml | 10 +- primitives/externalities/Cargo.toml | 4 +- primitives/finality-grandpa/Cargo.toml | 8 +- primitives/finality-tracker/Cargo.toml | 4 +- primitives/inherents/Cargo.toml | 4 +- primitives/io/Cargo.toml | 12 +- primitives/keyring/Cargo.toml | 4 +- primitives/offchain/Cargo.toml | 4 +- primitives/phragmen/Cargo.toml | 8 +- primitives/rpc/Cargo.toml | 2 +- primitives/runtime-interface/Cargo.toml | 16 +- .../runtime-interface/test-wasm/Cargo.toml | 10 +- primitives/runtime-interface/test/Cargo.toml | 12 +- primitives/runtime/Cargo.toml | 12 +- primitives/sandbox/Cargo.toml | 6 +- primitives/session/Cargo.toml | 6 +- primitives/staking/Cargo.toml | 4 +- primitives/state-machine/Cargo.toml | 8 +- primitives/storage/Cargo.toml | 2 +- primitives/test-primitives/Cargo.toml | 6 +- primitives/timestamp/Cargo.toml | 8 +- primitives/transaction-pool/Cargo.toml | 4 +- primitives/trie/Cargo.toml | 4 +- primitives/version/Cargo.toml | 4 +- test-utils/client/Cargo.toml | 20 +-- test-utils/runtime/Cargo.toml | 52 +++--- test-utils/runtime/client/Cargo.toml | 16 +- utils/frame/rpc/support/Cargo.toml | 8 +- utils/frame/rpc/system/Cargo.toml | 16 +- utils/grafana-data-source/test/Cargo.toml | 2 +- 131 files changed, 1115 insertions(+), 1115 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7bb1f65567..f8afee75dc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3010,11 +3010,11 @@ dependencies = [ "node-primitives 2.0.0", "node-rpc 2.0.0", "node-runtime 2.0.0", - "node-transaction-factory 0.0.1", - "pallet-authority-discovery 0.1.0", + "node-transaction-factory 2.0.0", + "pallet-authority-discovery 2.0.0", "pallet-balances 2.0.0", "pallet-contracts 2.0.0", - "pallet-im-online 0.1.0", + "pallet-im-online 2.0.0", "pallet-indices 2.0.0", "pallet-timestamp 2.0.0", "pallet-transaction-payment 2.0.0", @@ -3028,10 +3028,10 @@ dependencies = [ "sc-client 2.0.0", "sc-client-api 2.0.0", "sc-client-db 2.0.0", - "sc-consensus-babe 2.0.0", + "sc-consensus-babe 0.8.0", "sc-finality-grandpa 2.0.0", "sc-keystore 2.0.0", - "sc-network 2.0.0", + "sc-network 0.8.0", "sc-offchain 2.0.0", "sc-rpc 2.0.0", "sc-service 2.0.0", @@ -3040,8 +3040,8 @@ dependencies = [ "sc-transaction-pool 2.0.0", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-authority-discovery 2.0.0", - "sp-consensus 2.0.0", - "sp-consensus-babe 2.0.0", + "sp-consensus 0.8.0", + "sp-consensus-babe 0.8.0", "sp-core 2.0.0", "sp-finality-grandpa 2.0.0", "sp-finality-tracker 2.0.0", @@ -3138,8 +3138,8 @@ dependencies = [ "frame-system-rpc-runtime-api 2.0.0", "integer-sqrt 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "node-primitives 2.0.0", - "pallet-authority-discovery 0.1.0", - "pallet-authorship 0.1.0", + "pallet-authority-discovery 2.0.0", + "pallet-authorship 2.0.0", "pallet-babe 2.0.0", "pallet-balances 2.0.0", "pallet-collective 2.0.0", @@ -3149,11 +3149,11 @@ dependencies = [ "pallet-elections-phragmen 2.0.0", "pallet-finality-tracker 2.0.0", "pallet-grandpa 2.0.0", - "pallet-im-online 0.1.0", + "pallet-im-online 2.0.0", "pallet-indices 2.0.0", "pallet-membership 2.0.0", "pallet-nicks 2.0.0", - "pallet-offences 1.0.0", + "pallet-offences 2.0.0", "pallet-randomness-collective-flip 2.0.0", "pallet-session 2.0.0", "pallet-staking 2.0.0", @@ -3171,7 +3171,7 @@ dependencies = [ "sp-api 2.0.0", "sp-authority-discovery 2.0.0", "sp-block-builder 2.0.0", - "sp-consensus-babe 2.0.0", + "sp-consensus-babe 0.8.0", "sp-core 2.0.0", "sp-inherents 2.0.0", "sp-io 2.0.0", @@ -3200,14 +3200,14 @@ dependencies = [ "sc-basic-authority 2.0.0", "sc-cli 2.0.0", "sc-client 2.0.0", - "sc-consensus-aura 2.0.0", + "sc-consensus-aura 0.8.0", "sc-executor 2.0.0", "sc-finality-grandpa 2.0.0", - "sc-network 2.0.0", + "sc-network 0.8.0", "sc-service 2.0.0", "sc-transaction-pool 2.0.0", - "sp-consensus 2.0.0", - "sp-consensus-aura 2.0.0", + "sp-consensus 0.8.0", + "sp-consensus-aura 0.8.0", "sp-core 2.0.0", "sp-finality-grandpa 2.0.0", "sp-inherents 2.0.0", @@ -3240,7 +3240,7 @@ dependencies = [ "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-api 2.0.0", "sp-block-builder 2.0.0", - "sp-consensus-aura 2.0.0", + "sp-consensus-aura 0.8.0", "sp-core 2.0.0", "sp-inherents 2.0.0", "sp-io 2.0.0", @@ -3284,7 +3284,7 @@ dependencies = [ [[package]] name = "node-transaction-factory" -version = "0.0.1" +version = "2.0.0" dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3295,7 +3295,7 @@ dependencies = [ "sp-api 2.0.0", "sp-block-builder 2.0.0", "sp-blockchain 2.0.0", - "sp-consensus 2.0.0", + "sp-consensus 0.8.0", "sp-core 2.0.0", "sp-runtime 2.0.0", ] @@ -3471,7 +3471,7 @@ dependencies = [ "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "sp-application-crypto 2.0.0", - "sp-consensus-aura 2.0.0", + "sp-consensus-aura 0.8.0", "sp-core 2.0.0", "sp-inherents 2.0.0", "sp-io 2.0.0", @@ -3482,7 +3482,7 @@ dependencies = [ [[package]] name = "pallet-authority-discovery" -version = "0.1.0" +version = "2.0.0" dependencies = [ "frame-support 2.0.0", "frame-system 2.0.0", @@ -3500,7 +3500,7 @@ dependencies = [ [[package]] name = "pallet-authorship" -version = "0.1.0" +version = "2.0.0" dependencies = [ "frame-support 2.0.0", "frame-system 2.0.0", @@ -3527,7 +3527,7 @@ dependencies = [ "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", - "sp-consensus-babe 2.0.0", + "sp-consensus-babe 0.8.0", "sp-core 2.0.0", "sp-inherents 2.0.0", "sp-io 2.0.0", @@ -3776,11 +3776,11 @@ dependencies = [ [[package]] name = "pallet-im-online" -version = "0.1.0" +version = "2.0.0" dependencies = [ "frame-support 2.0.0", "frame-system 2.0.0", - "pallet-authorship 0.1.0", + "pallet-authorship 2.0.0", "pallet-session 2.0.0", "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3840,7 +3840,7 @@ dependencies = [ [[package]] name = "pallet-offences" -version = "1.0.0" +version = "2.0.0" dependencies = [ "frame-support 2.0.0", "frame-system 2.0.0", @@ -3870,7 +3870,7 @@ dependencies = [ [[package]] name = "pallet-scored-pool" -version = "1.0.0" +version = "2.0.0" dependencies = [ "frame-support 2.0.0", "frame-system 2.0.0", @@ -3910,7 +3910,7 @@ version = "2.0.0" dependencies = [ "frame-support 2.0.0", "frame-system 2.0.0", - "pallet-authorship 0.1.0", + "pallet-authorship 2.0.0", "pallet-balances 2.0.0", "pallet-session 2.0.0", "pallet-staking-reward-curve 2.0.0", @@ -4927,7 +4927,7 @@ dependencies = [ "prost-build 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "sc-client-api 2.0.0", "sc-keystore 2.0.0", - "sc-network 2.0.0", + "sc-network 0.8.0", "sc-peerset 2.0.0", "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", "sp-api 2.0.0", @@ -4952,7 +4952,7 @@ dependencies = [ "sc-telemetry 2.0.0", "sc-transaction-pool 2.0.0", "sp-blockchain 2.0.0", - "sp-consensus 2.0.0", + "sp-consensus 0.8.0", "sp-core 2.0.0", "sp-inherents 2.0.0", "sp-runtime 2.0.0", @@ -4980,7 +4980,7 @@ version = "2.0.0" dependencies = [ "impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "sc-chain-spec-derive 2.0.0", - "sc-network 2.0.0", + "sc-network 0.8.0", "sc-telemetry 2.0.0", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5016,7 +5016,7 @@ dependencies = [ "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "rpassword 4.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "sc-client-api 2.0.0", - "sc-network 2.0.0", + "sc-network 0.8.0", "sc-service 2.0.0", "sc-telemetry 2.0.0", "sc-tracing 2.0.0", @@ -5054,7 +5054,7 @@ dependencies = [ "sc-telemetry 2.0.0", "sp-api 2.0.0", "sp-blockchain 2.0.0", - "sp-consensus 2.0.0", + "sp-consensus 0.8.0", "sp-core 2.0.0", "sp-externalities 2.0.0", "sp-inherents 2.0.0", @@ -5087,7 +5087,7 @@ dependencies = [ "sc-telemetry 2.0.0", "sp-api 2.0.0", "sp-blockchain 2.0.0", - "sp-consensus 2.0.0", + "sp-consensus 0.8.0", "sp-core 2.0.0", "sp-externalities 2.0.0", "sp-inherents 2.0.0", @@ -5120,7 +5120,7 @@ dependencies = [ "sc-executor 2.0.0", "sc-state-db 2.0.0", "sp-blockchain 2.0.0", - "sp-consensus 2.0.0", + "sp-consensus 0.8.0", "sp-core 2.0.0", "sp-keyring 2.0.0", "sp-runtime 2.0.0", @@ -5131,7 +5131,7 @@ dependencies = [ [[package]] name = "sc-consensus-aura" -version = "2.0.0" +version = "0.8.0" dependencies = [ "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5143,10 +5143,10 @@ dependencies = [ "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sc-client 2.0.0", "sc-client-api 2.0.0", - "sc-consensus-slots 2.0.0", + "sc-consensus-slots 0.8.0", "sc-executor 2.0.0", "sc-keystore 2.0.0", - "sc-network 2.0.0", + "sc-network 0.8.0", "sc-network-test 2.0.0", "sc-service 2.0.0", "sc-telemetry 2.0.0", @@ -5154,8 +5154,8 @@ dependencies = [ "sp-application-crypto 2.0.0", "sp-block-builder 2.0.0", "sp-blockchain 2.0.0", - "sp-consensus 2.0.0", - "sp-consensus-aura 2.0.0", + "sp-consensus 0.8.0", + "sp-consensus-aura 0.8.0", "sp-core 2.0.0", "sp-inherents 2.0.0", "sp-io 2.0.0", @@ -5170,7 +5170,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe" -version = "2.0.0" +version = "0.8.0" dependencies = [ "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5190,11 +5190,11 @@ dependencies = [ "sc-block-builder 2.0.0", "sc-client 2.0.0", "sc-client-api 2.0.0", - "sc-consensus-slots 2.0.0", - "sc-consensus-uncles 2.0.0", + "sc-consensus-slots 0.8.0", + "sc-consensus-uncles 0.8.0", "sc-executor 2.0.0", "sc-keystore 2.0.0", - "sc-network 2.0.0", + "sc-network 0.8.0", "sc-network-test 2.0.0", "sc-service 2.0.0", "sc-telemetry 2.0.0", @@ -5203,8 +5203,8 @@ dependencies = [ "sp-application-crypto 2.0.0", "sp-block-builder 2.0.0", "sp-blockchain 2.0.0", - "sp-consensus 2.0.0", - "sp-consensus-babe 2.0.0", + "sp-consensus 0.8.0", + "sp-consensus-babe 0.8.0", "sp-core 2.0.0", "sp-inherents 2.0.0", "sp-io 2.0.0", @@ -5219,7 +5219,7 @@ dependencies = [ [[package]] name = "sc-consensus-pow" -version = "2.0.0" +version = "0.8.0" dependencies = [ "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5228,8 +5228,8 @@ dependencies = [ "sc-client-api 2.0.0", "sp-block-builder 2.0.0", "sp-blockchain 2.0.0", - "sp-consensus 2.0.0", - "sp-consensus-pow 2.0.0", + "sp-consensus 0.8.0", + "sp-consensus-pow 0.8.0", "sp-core 2.0.0", "sp-inherents 2.0.0", "sp-runtime 2.0.0", @@ -5238,7 +5238,7 @@ dependencies = [ [[package]] name = "sc-consensus-slots" -version = "2.0.0" +version = "0.8.0" dependencies = [ "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "futures-timer 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5248,7 +5248,7 @@ dependencies = [ "sc-client-api 2.0.0", "sc-telemetry 2.0.0", "sp-blockchain 2.0.0", - "sp-consensus 2.0.0", + "sp-consensus 0.8.0", "sp-core 2.0.0", "sp-inherents 2.0.0", "sp-runtime 2.0.0", @@ -5257,12 +5257,12 @@ dependencies = [ [[package]] name = "sc-consensus-uncles" -version = "2.0.0" +version = "0.8.0" dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "sc-client-api 2.0.0", "sp-authorship 2.0.0", - "sp-consensus 2.0.0", + "sp-consensus 0.8.0", "sp-core 2.0.0", "sp-inherents 2.0.0", "sp-runtime 2.0.0", @@ -5323,15 +5323,15 @@ dependencies = [ "sc-client 2.0.0", "sc-client-api 2.0.0", "sc-keystore 2.0.0", - "sc-network 2.0.0", + "sc-network 0.8.0", "sc-network-gossip 2.0.0", "sc-network-test 2.0.0", "sc-telemetry 2.0.0", "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", "sp-api 2.0.0", "sp-blockchain 2.0.0", - "sp-consensus 2.0.0", - "sp-consensus-babe 2.0.0", + "sp-consensus 0.8.0", + "sp-consensus-babe 0.8.0", "sp-core 2.0.0", "sp-finality-grandpa 2.0.0", "sp-finality-tracker 2.0.0", @@ -5361,7 +5361,7 @@ dependencies = [ [[package]] name = "sc-network" -version = "2.0.0" +version = "0.8.0" dependencies = [ "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5395,8 +5395,8 @@ dependencies = [ "smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", "sp-arithmetic 2.0.0", "sp-blockchain 2.0.0", - "sp-consensus 2.0.0", - "sp-consensus-babe 2.0.0", + "sp-consensus 0.8.0", + "sp-consensus-babe 0.8.0", "sp-core 2.0.0", "sp-keyring 2.0.0", "sp-runtime 2.0.0", @@ -5422,7 +5422,7 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "lru 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sc-network 2.0.0", + "sc-network 0.8.0", "sp-runtime 2.0.0", ] @@ -5441,10 +5441,10 @@ dependencies = [ "sc-block-builder 2.0.0", "sc-client 2.0.0", "sc-client-api 2.0.0", - "sc-network 2.0.0", + "sc-network 0.8.0", "sp-blockchain 2.0.0", - "sp-consensus 2.0.0", - "sp-consensus-babe 2.0.0", + "sp-consensus 0.8.0", + "sp-consensus-babe 0.8.0", "sp-core 2.0.0", "sp-runtime 2.0.0", "substrate-test-runtime 2.0.0", @@ -5473,7 +5473,7 @@ dependencies = [ "sc-client-api 2.0.0", "sc-client-db 2.0.0", "sc-keystore 2.0.0", - "sc-network 2.0.0", + "sc-network 0.8.0", "sc-transaction-pool 2.0.0", "sp-api 2.0.0", "sp-core 2.0.0", @@ -5514,7 +5514,7 @@ dependencies = [ "sc-client-api 2.0.0", "sc-executor 2.0.0", "sc-keystore 2.0.0", - "sc-network 2.0.0", + "sc-network 0.8.0", "sc-rpc-api 2.0.0", "sc-transaction-pool 2.0.0", "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5600,7 +5600,7 @@ dependencies = [ "sc-executor 2.0.0", "sc-finality-grandpa 2.0.0", "sc-keystore 2.0.0", - "sc-network 2.0.0", + "sc-network 0.8.0", "sc-offchain 2.0.0", "sc-rpc 2.0.0", "sc-rpc-server 2.0.0", @@ -5613,8 +5613,8 @@ dependencies = [ "sp-api 2.0.0", "sp-application-crypto 2.0.0", "sp-blockchain 2.0.0", - "sp-consensus 2.0.0", - "sp-consensus-babe 2.0.0", + "sp-consensus 0.8.0", + "sp-consensus-babe 0.8.0", "sp-core 2.0.0", "sp-finality-grandpa 2.0.0", "sp-io 2.0.0", @@ -5640,9 +5640,9 @@ dependencies = [ "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "sc-client 2.0.0", - "sc-network 2.0.0", + "sc-network 0.8.0", "sc-service 2.0.0", - "sp-consensus 2.0.0", + "sp-consensus 0.8.0", "sp-core 2.0.0", "sp-runtime 2.0.0", "sp-transaction-pool 2.0.0", @@ -6053,7 +6053,7 @@ dependencies = [ "rustversion 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "sp-api 2.0.0", "sp-blockchain 2.0.0", - "sp-consensus 2.0.0", + "sp-consensus 0.8.0", "sp-runtime 2.0.0", "sp-state-machine 2.0.0", "sp-version 2.0.0", @@ -6139,14 +6139,14 @@ dependencies = [ "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "sp-block-builder 2.0.0", - "sp-consensus 2.0.0", + "sp-consensus 0.8.0", "sp-runtime 2.0.0", "sp-state-machine 2.0.0", ] [[package]] name = "sp-consensus" -version = "2.0.0" +version = "0.8.0" dependencies = [ "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -6165,7 +6165,7 @@ dependencies = [ [[package]] name = "sp-consensus-aura" -version = "2.0.0" +version = "0.8.0" dependencies = [ "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "sp-api 2.0.0", @@ -6178,13 +6178,13 @@ dependencies = [ [[package]] name = "sp-consensus-babe" -version = "2.0.0" +version = "0.8.0" dependencies = [ "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "schnorrkel 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)", "sp-api 2.0.0", "sp-application-crypto 2.0.0", - "sp-consensus 2.0.0", + "sp-consensus 0.8.0", "sp-inherents 2.0.0", "sp-runtime 2.0.0", "sp-std 2.0.0", @@ -6193,7 +6193,7 @@ dependencies = [ [[package]] name = "sp-consensus-pow" -version = "2.0.0" +version = "0.8.0" dependencies = [ "parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "sp-api 2.0.0", @@ -6745,7 +6745,7 @@ dependencies = [ "sc-client-db 2.0.0", "sc-executor 2.0.0", "sp-blockchain 2.0.0", - "sp-consensus 2.0.0", + "sp-consensus 0.8.0", "sp-core 2.0.0", "sp-keyring 2.0.0", "sp-runtime 2.0.0", @@ -6772,8 +6772,8 @@ dependencies = [ "sp-api 2.0.0", "sp-application-crypto 2.0.0", "sp-block-builder 2.0.0", - "sp-consensus-aura 2.0.0", - "sp-consensus-babe 2.0.0", + "sp-consensus-aura 0.8.0", + "sp-consensus-babe 0.8.0", "sp-core 2.0.0", "sp-inherents 2.0.0", "sp-io 2.0.0", diff --git a/bin/node-template/Cargo.toml b/bin/node-template/Cargo.toml index 01a7840993..aaaae647cf 100644 --- a/bin/node-template/Cargo.toml +++ b/bin/node-template/Cargo.toml @@ -18,25 +18,25 @@ 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/io" } -sc-cli = { path = "../../client/cli" } -sp-core = { path = "../../primitives/core" } -sc-executor = { path = "../../client/executor" } -sc-service = { path = "../../client/service" } -sp-inherents = { path = "../../primitives/inherents" } -sc-transaction-pool = { path = "../../client/transaction-pool" } -sp-transaction-pool = { path = "../../primitives/transaction-pool" } -sc-network = { path = "../../client/network" } -sc-consensus-aura = { path = "../../client/consensus/aura" } -sp-consensus-aura = { path = "../../primitives/consensus/aura" } -sp-consensus = { path = "../../primitives/consensus/common" } -grandpa = { package = "sc-finality-grandpa", path = "../../client/finality-grandpa" } -grandpa-primitives = { package = "sp-finality-grandpa", path = "../../primitives/finality-grandpa" } -sc-client = { path = "../../client/" } -node-template-runtime = { path = "runtime" } -sp-runtime = { path = "../../primitives/runtime" } -sc-basic-authority = { path = "../../client/basic-authorship"} +sp-io = { version = "2.0.0", path = "../../primitives/io" } +sc-cli = { version = "2.0.0", path = "../../client/cli" } +sp-core = { version = "2.0.0", path = "../../primitives/core" } +sc-executor = { version = "2.0.0", path = "../../client/executor" } +sc-service = { version = "2.0.0", path = "../../client/service" } +sp-inherents = { version = "2.0.0", path = "../../primitives/inherents" } +sc-transaction-pool = { version = "2.0.0", path = "../../client/transaction-pool" } +sp-transaction-pool = { version = "2.0.0", path = "../../primitives/transaction-pool" } +sc-network = { version = "0.8", path = "../../client/network" } +sc-consensus-aura = { version = "0.8", path = "../../client/consensus/aura" } +sp-consensus-aura = { version = "0.8", path = "../../primitives/consensus/aura" } +sp-consensus = { version = "0.8", path = "../../primitives/consensus/common" } +grandpa = { version = "2.0.0", package = "sc-finality-grandpa", path = "../../client/finality-grandpa" } +grandpa-primitives = { version = "2.0.0", package = "sp-finality-grandpa", path = "../../primitives/finality-grandpa" } +sc-client = { version = "2.0.0", path = "../../client/" } +node-template-runtime = { version = "2.0.0", path = "runtime" } +sp-runtime = { version = "2.0.0", path = "../../primitives/runtime" } +sc-basic-authority = { path = "../../client/basic-authorship" } [build-dependencies] vergen = "3.0.4" -build-script-utils = { package = "substrate-build-script-utils", path = "../../utils/build-script-utils" } +build-script-utils = { version = "2.0.0", package = "substrate-build-script-utils", path = "../../utils/build-script-utils" } diff --git a/bin/node-template/runtime/Cargo.toml b/bin/node-template/runtime/Cargo.toml index 398cf2ddb6..b61ad25f46 100644 --- a/bin/node-template/runtime/Cargo.toml +++ b/bin/node-template/runtime/Cargo.toml @@ -5,36 +5,36 @@ authors = ["Anonymous"] edition = "2018" [dependencies] -aura = { package = "pallet-aura", path = "../../../frame/aura", default-features = false } -balances = { package = "pallet-balances", path = "../../../frame/balances", default-features = false } -frame-support = { path = "../../../frame/support", default-features = false } -grandpa = { package = "pallet-grandpa", path = "../../../frame/grandpa", default-features = false } -indices = { package = "pallet-indices", path = "../../../frame/indices", default-features = false } -randomness-collective-flip = { package = "pallet-randomness-collective-flip", path = "../../../frame/randomness-collective-flip", default-features = false } -sudo = { package = "pallet-sudo", path = "../../../frame/sudo", default-features = false } -system = { package = "frame-system", path = "../../../frame/system", default-features = false } -timestamp = { package = "pallet-timestamp", path = "../../../frame/timestamp", default-features = false } -transaction-payment = { package = "pallet-transaction-payment", path = "../../../frame/transaction-payment", default-features = false } +aura = { version = "2.0.0", default-features = false, package = "pallet-aura", path = "../../../frame/aura" } +balances = { version = "2.0.0", default-features = false, package = "pallet-balances", path = "../../../frame/balances" } +frame-support = { version = "2.0.0", default-features = false, path = "../../../frame/support" } +grandpa = { version = "2.0.0", default-features = false, package = "pallet-grandpa", path = "../../../frame/grandpa" } +indices = { version = "2.0.0", default-features = false, package = "pallet-indices", path = "../../../frame/indices" } +randomness-collective-flip = { version = "2.0.0", default-features = false, package = "pallet-randomness-collective-flip", path = "../../../frame/randomness-collective-flip" } +sudo = { version = "2.0.0", default-features = false, package = "pallet-sudo", path = "../../../frame/sudo" } +system = { version = "2.0.0", default-features = false, package = "frame-system", path = "../../../frame/system" } +timestamp = { version = "2.0.0", default-features = false, package = "pallet-timestamp", path = "../../../frame/timestamp" } +transaction-payment = { version = "2.0.0", default-features = false, package = "pallet-transaction-payment", path = "../../../frame/transaction-payment" } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -frame-executive = { path = "../../../frame/executive", default-features = false } +frame-executive = { version = "2.0.0", default-features = false, path = "../../../frame/executive" } safe-mix = { version = "1.0.0", default-features = false } serde = { version = "1.0.101", optional = true, features = ["derive"] } -sp-api = { path = "../../../primitives/api", default-features = false } +sp-api = { version = "2.0.0", default-features = false, path = "../../../primitives/api" } sp-block-builder = { path = "../../../primitives/block-builder", default-features = false} -sp-consensus-aura = { path = "../../../primitives/consensus/aura", default-features = false } -sp-core = { path = "../../../primitives/core", default-features = false } +sp-consensus-aura = { version = "0.8", default-features = false, path = "../../../primitives/consensus/aura" } +sp-core = { version = "2.0.0", default-features = false, path = "../../../primitives/core" } sp-inherents = { path = "../../../primitives/inherents", default-features = false} -sp-io = { path = "../../../primitives/io", default-features = false } -sp-offchain = { path = "../../../primitives/offchain", default-features = false } -sp-runtime = { path = "../../../primitives/runtime", default-features = false } -sp-session = { path = "../../../primitives/session", default-features = false } -sp-std = { path = "../../../primitives/std", default-features = false } -sp-transaction-pool = { path = "../../../primitives/transaction-pool", default-features = false } -sp-version = { path = "../../../primitives/version", default-features = false } +sp-io = { version = "2.0.0", default-features = false, path = "../../../primitives/io" } +sp-offchain = { version = "2.0.0", default-features = false, path = "../../../primitives/offchain" } +sp-runtime = { version = "2.0.0", default-features = false, path = "../../../primitives/runtime" } +sp-session = { version = "2.0.0", default-features = false, path = "../../../primitives/session" } +sp-std = { version = "2.0.0", default-features = false, path = "../../../primitives/std" } +sp-transaction-pool = { version = "2.0.0", default-features = false, path = "../../../primitives/transaction-pool" } +sp-version = { version = "2.0.0", default-features = false, path = "../../../primitives/version" } [build-dependencies] -wasm-builder-runner = { package = "substrate-wasm-builder-runner", path = "../../../utils/wasm-builder-runner", version = "1.0.4" } +wasm-builder-runner = { version = "1.0.4", package = "substrate-wasm-builder-runner", path = "../../../utils/wasm-builder-runner" } [features] default = ["std"] diff --git a/bin/node/cli/Cargo.toml b/bin/node/cli/Cargo.toml index e87d590614..0ce5115831 100644 --- a/bin/node/cli/Cargo.toml +++ b/bin/node/cli/Cargo.toml @@ -34,57 +34,57 @@ rand = "0.7.2" structopt = "0.3.3" # primitives -sp-authority-discovery = { path = "../../../primitives/authority-discovery"} -sp-consensus-babe = { path = "../../../primitives/consensus/babe" } -grandpa-primitives = { package = "sp-finality-grandpa", path = "../../../primitives/finality-grandpa" } -sp-core = { path = "../../../primitives/core" } -sp-runtime = { path = "../../../primitives/runtime" } -sp-timestamp = { path = "../../../primitives/timestamp", default-features = false } -sp-finality-tracker = { path = "../../../primitives/finality-tracker", default-features = false } -sp-inherents = { path = "../../../primitives/inherents" } -sp-keyring = { path = "../../../primitives/keyring" } -sp-io = { path = "../../../primitives/io" } -sp-consensus = { path = "../../../primitives/consensus/common" } +sp-authority-discovery = { version = "2.0.0", path = "../../../primitives/authority-discovery" } +sp-consensus-babe = { version = "0.8", path = "../../../primitives/consensus/babe" } +grandpa-primitives = { version = "2.0.0", package = "sp-finality-grandpa", path = "../../../primitives/finality-grandpa" } +sp-core = { version = "2.0.0", path = "../../../primitives/core" } +sp-runtime = { version = "2.0.0", path = "../../../primitives/runtime" } +sp-timestamp = { version = "2.0.0", default-features = false, path = "../../../primitives/timestamp" } +sp-finality-tracker = { version = "2.0.0", default-features = false, path = "../../../primitives/finality-tracker" } +sp-inherents = { version = "2.0.0", path = "../../../primitives/inherents" } +sp-keyring = { version = "2.0.0", path = "../../../primitives/keyring" } +sp-io = { version = "2.0.0", path = "../../../primitives/io" } +sp-consensus = { version = "0.8", path = "../../../primitives/consensus/common" } # client dependencies -sc-client-api = { path = "../../../client/api" } -sc-client = { path = "../../../client/" } -sc-chain-spec = { path = "../../../client/chain-spec" } -sc-transaction-pool = { path = "../../../client/transaction-pool" } -sp-transaction-pool = { path = "../../../primitives/transaction-pool" } -sc-network = { path = "../../../client/network" } -sc-consensus-babe = { path = "../../../client/consensus/babe" } -grandpa = { package = "sc-finality-grandpa", path = "../../../client/finality-grandpa" } -sc-client-db = { path = "../../../client/db", default-features = false } -sc-offchain = { path = "../../../client/offchain" } -sc-rpc = { path = "../../../client/rpc" } -sc-basic-authority = { path = "../../../client/basic-authorship" } -sc-service = { path = "../../../client/service", default-features = false } -sc-telemetry = { path = "../../../client/telemetry" } -sc-authority-discovery = { path = "../../../client/authority-discovery"} +sc-client-api = { version = "2.0.0", path = "../../../client/api" } +sc-client = { version = "2.0.0", path = "../../../client/" } +sc-chain-spec = { version = "2.0.0", path = "../../../client/chain-spec" } +sc-transaction-pool = { version = "2.0.0", path = "../../../client/transaction-pool" } +sp-transaction-pool = { version = "2.0.0", path = "../../../primitives/transaction-pool" } +sc-network = { version = "0.8", path = "../../../client/network" } +sc-consensus-babe = { version = "0.8", path = "../../../client/consensus/babe" } +grandpa = { version = "2.0.0", package = "sc-finality-grandpa", path = "../../../client/finality-grandpa" } +sc-client-db = { version = "2.0.0", default-features = false, path = "../../../client/db" } +sc-offchain = { version = "2.0.0", path = "../../../client/offchain" } +sc-rpc = { version = "2.0.0", path = "../../../client/rpc" } +sc-basic-authority = { version = "2.0.0", path = "../../../client/basic-authorship" } +sc-service = { version = "2.0.0", default-features = false, path = "../../../client/service" } +sc-telemetry = { version = "2.0.0", path = "../../../client/telemetry" } +sc-authority-discovery = { version = "2.0.0", path = "../../../client/authority-discovery" } # frame dependencies -pallet-indices = { path = "../../../frame/indices" } -pallet-timestamp = { path = "../../../frame/timestamp", default-features = false } -pallet-contracts = { path = "../../../frame/contracts" } -frame-system = { path = "../../../frame/system" } -pallet-balances = { path = "../../../frame/balances" } -pallet-transaction-payment = { path = "../../../frame/transaction-payment" } -frame-support = { path = "../../../frame/support", default-features = false } -pallet-im-online = { path = "../../../frame/im-online", default-features = false } -pallet-authority-discovery = { path = "../../../frame/authority-discovery"} +pallet-indices = { version = "2.0.0", path = "../../../frame/indices" } +pallet-timestamp = { version = "2.0.0", default-features = false, path = "../../../frame/timestamp" } +pallet-contracts = { version = "2.0.0", path = "../../../frame/contracts" } +frame-system = { version = "2.0.0", path = "../../../frame/system" } +pallet-balances = { version = "2.0.0", path = "../../../frame/balances" } +pallet-transaction-payment = { version = "2.0.0", path = "../../../frame/transaction-payment" } +frame-support = { version = "2.0.0", default-features = false, path = "../../../frame/support" } +pallet-im-online = { version = "2.0.0", default-features = false, path = "../../../frame/im-online" } +pallet-authority-discovery = { version = "2.0.0", path = "../../../frame/authority-discovery" } # node-specific dependencies -node-runtime = { path = "../runtime" } -node-rpc = { path = "../rpc" } -node-primitives = { path = "../primitives" } -node-executor = { path = "../executor" } +node-runtime = { version = "2.0.0", path = "../runtime" } +node-rpc = { version = "2.0.0", path = "../rpc" } +node-primitives = { version = "2.0.0", path = "../primitives" } +node-executor = { version = "2.0.0", path = "../executor" } # CLI-specific dependencies tokio = { version = "0.1.22", optional = true } -sc-cli = { path = "../../../client/cli", optional = true } +sc-cli = { version = "2.0.0", optional = true, path = "../../../client/cli" } ctrlc = { version = "3.1.3", features = ["termination"], optional = true } -node-transaction-factory = { path = "../transaction-factory", optional = true } +node-transaction-factory = { version = "2.0.0", optional = true, path = "../transaction-factory" } # WASM-specific dependencies libp2p = { version = "0.13.0", default-features = false, optional = true } @@ -98,15 +98,15 @@ kvdb-memorydb = { version = "0.1.1", optional = true } rand6 = { package = "rand", version = "0.6", features = ["wasm-bindgen"], optional = true } # Imported just for the `wasm-bindgen` feature [dev-dependencies] -sc-keystore = { path = "../../../client/keystore" } -sc-consensus-babe = { path = "../../../client/consensus/babe", features = ["test-helpers"] } -sc-service-test = { path = "../../../client/service/test" } +sc-keystore = { version = "2.0.0", path = "../../../client/keystore" } +sc-consensus-babe = { version = "0.8", features = ["test-helpers"], path = "../../../client/consensus/babe" } +sc-service-test = { version = "2.0.0", path = "../../../client/service/test" } futures = "0.3.1" tempfile = "3.1.0" [build-dependencies] -sc-cli = { package = "sc-cli", path = "../../../client/cli" } -build-script-utils = { package = "substrate-build-script-utils", path = "../../../utils/build-script-utils" } +sc-cli = { version = "2.0.0", package = "sc-cli", path = "../../../client/cli" } +build-script-utils = { version = "2.0.0", package = "substrate-build-script-utils", path = "../../../utils/build-script-utils" } structopt = "0.3.3" vergen = "3.0.4" diff --git a/bin/node/executor/Cargo.toml b/bin/node/executor/Cargo.toml index 68765ddff6..24f593d1ce 100644 --- a/bin/node/executor/Cargo.toml +++ b/bin/node/executor/Cargo.toml @@ -8,28 +8,28 @@ edition = "2018" [dependencies] trie-root = "0.15.2" codec = { package = "parity-scale-codec", version = "1.0.0" } -sp-io = { path = "../../../primitives/io" } -sp-state-machine = { path = "../../../primitives/state-machine" } -sc-executor = { path = "../../../client/executor" } -sp-core = { path = "../../../primitives/core" } -sp-trie = { path = "../../../primitives/trie" } -node-primitives = { path = "../primitives" } -node-runtime = { path = "../runtime" } +sp-io = { version = "2.0.0", path = "../../../primitives/io" } +sp-state-machine = { version = "2.0.0", path = "../../../primitives/state-machine" } +sc-executor = { version = "2.0.0", path = "../../../client/executor" } +sp-core = { version = "2.0.0", path = "../../../primitives/core" } +sp-trie = { version = "2.0.0", path = "../../../primitives/trie" } +node-primitives = { version = "2.0.0", path = "../primitives" } +node-runtime = { version = "2.0.0", path = "../runtime" } [dev-dependencies] -node-testing = { path = "../testing" } -substrate-test-client = { path = "../../../test-utils/client" } -sp-runtime = { path = "../../../primitives/runtime" } -frame-support = { path = "../../../frame/support" } -pallet-balances = { path = "../../../frame/balances" } -pallet-transaction-payment = { path = "../../../frame/transaction-payment" } -pallet-session = { path = "../../../frame/session" } -frame-system = { path = "../../../frame/system" } -pallet-timestamp = { path = "../../../frame/timestamp" } -pallet-treasury = { path = "../../../frame/treasury" } -pallet-contracts = { path = "../../../frame/contracts" } -pallet-grandpa = { path = "../../../frame/grandpa" } -pallet-indices = { path = "../../../frame/indices" } +node-testing = { version = "2.0.0", path = "../testing" } +substrate-test-client = { version = "2.0.0", path = "../../../test-utils/client" } +sp-runtime = { version = "2.0.0", path = "../../../primitives/runtime" } +frame-support = { version = "2.0.0", path = "../../../frame/support" } +pallet-balances = { version = "2.0.0", path = "../../../frame/balances" } +pallet-transaction-payment = { version = "2.0.0", path = "../../../frame/transaction-payment" } +pallet-session = { version = "2.0.0", path = "../../../frame/session" } +frame-system = { version = "2.0.0", path = "../../../frame/system" } +pallet-timestamp = { version = "2.0.0", path = "../../../frame/timestamp" } +pallet-treasury = { version = "2.0.0", path = "../../../frame/treasury" } +pallet-contracts = { version = "2.0.0", path = "../../../frame/contracts" } +pallet-grandpa = { version = "2.0.0", path = "../../../frame/grandpa" } +pallet-indices = { version = "2.0.0", path = "../../../frame/indices" } wabt = "0.9.2" criterion = "0.3.0" diff --git a/bin/node/primitives/Cargo.toml b/bin/node/primitives/Cargo.toml index 956a346d2e..1ecfd76792 100644 --- a/bin/node/primitives/Cargo.toml +++ b/bin/node/primitives/Cargo.toml @@ -5,11 +5,11 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -sp-core = { path = "../../../primitives/core", default-features = false } -sp-runtime = { path = "../../../primitives/runtime", default-features = false } +sp-core = { version = "2.0.0", default-features = false, path = "../../../primitives/core" } +sp-runtime = { version = "2.0.0", default-features = false, path = "../../../primitives/runtime" } [dev-dependencies] -sp-serializer = { path = "../../../primitives/serializer" } +sp-serializer = { version = "2.0.0", path = "../../../primitives/serializer" } pretty_assertions = "0.6.1" [features] diff --git a/bin/node/rpc-client/Cargo.toml b/bin/node/rpc-client/Cargo.toml index 5ef06beb65..5ef9d1e99d 100644 --- a/bin/node/rpc-client/Cargo.toml +++ b/bin/node/rpc-client/Cargo.toml @@ -10,5 +10,5 @@ futures = "0.1.29" hyper = "0.12.35" jsonrpc-core-client = { version = "14.0.3", features = ["http", "ws"] } log = "0.4.8" -node-primitives = { path = "../primitives" } -sc-rpc = { path = "../../../client/rpc", version = "2.0.0" } +node-primitives = { version = "2.0.0", path = "../primitives" } +sc-rpc = { version = "2.0.0", path = "../../../client/rpc" } diff --git a/bin/node/rpc/Cargo.toml b/bin/node/rpc/Cargo.toml index 7b8f8a6cc3..634a946bb7 100644 --- a/bin/node/rpc/Cargo.toml +++ b/bin/node/rpc/Cargo.toml @@ -5,12 +5,12 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -sc-client = { path = "../../../client/" } +sc-client = { version = "2.0.0", path = "../../../client/" } jsonrpc-core = "14.0.3" -node-primitives = { path = "../primitives" } -node-runtime = { path = "../runtime" } -sp-runtime = { path = "../../../primitives/runtime" } -pallet-contracts-rpc = { path = "../../../frame/contracts/rpc/" } -pallet-transaction-payment-rpc = { path = "../../../frame/transaction-payment/rpc/" } -substrate-frame-rpc-system = { path = "../../../utils/frame/rpc/system" } -sp-transaction-pool = { path = "../../../primitives/transaction-pool" } +node-primitives = { version = "2.0.0", path = "../primitives" } +node-runtime = { version = "2.0.0", path = "../runtime" } +sp-runtime = { version = "2.0.0", path = "../../../primitives/runtime" } +pallet-contracts-rpc = { version = "2.0.0", path = "../../../frame/contracts/rpc/" } +pallet-transaction-payment-rpc = { version = "2.0.0", path = "../../../frame/transaction-payment/rpc/" } +substrate-frame-rpc-system = { version = "2.0.0", path = "../../../utils/frame/rpc/system" } +sp-transaction-pool = { version = "2.0.0", path = "../../../primitives/transaction-pool" } diff --git a/bin/node/runtime/Cargo.toml b/bin/node/runtime/Cargo.toml index c3d79373ec..33cb7b61db 100644 --- a/bin/node/runtime/Cargo.toml +++ b/bin/node/runtime/Cargo.toml @@ -14,59 +14,59 @@ rustc-hex = { version = "2.0", optional = true } serde = { version = "1.0.102", optional = true } # primitives -sp-authority-discovery = { path = "../../../primitives/authority-discovery", default-features = false } -sp-consensus-babe = { path = "../../../primitives/consensus/babe", default-features = false } +sp-authority-discovery = { version = "2.0.0", default-features = false, path = "../../../primitives/authority-discovery" } +sp-consensus-babe = { version = "0.8", default-features = false, path = "../../../primitives/consensus/babe" } sp-block-builder = { path = "../../../primitives/block-builder", default-features = false} -sp-inherents = { path = "../../../primitives/inherents", default-features = false } -node-primitives = { path = "../primitives", default-features = false } -sp-offchain = { path = "../../../primitives/offchain", default-features = false } -sp-core = { path = "../../../primitives/core", default-features = false } -sp-std = { path = "../../../primitives/std", default-features = false } -sp-api = { path = "../../../primitives/api", default-features = false } -sp-runtime = { path = "../../../primitives/runtime", default-features = false } -sp-staking = { path = "../../../primitives/staking", default-features = false } -sp-keyring = { path = "../../../primitives/keyring", optional = true } -sp-session = { path = "../../../primitives/session", default-features = false } -sp-transaction-pool = { path = "../../../primitives/transaction-pool", default-features = false } -sp-version = { path = "../../../primitives/version", default-features = false } +sp-inherents = { version = "2.0.0", default-features = false, path = "../../../primitives/inherents" } +node-primitives = { version = "2.0.0", default-features = false, path = "../primitives" } +sp-offchain = { version = "2.0.0", default-features = false, path = "../../../primitives/offchain" } +sp-core = { version = "2.0.0", default-features = false, path = "../../../primitives/core" } +sp-std = { version = "2.0.0", default-features = false, path = "../../../primitives/std" } +sp-api = { version = "2.0.0", default-features = false, path = "../../../primitives/api" } +sp-runtime = { version = "2.0.0", default-features = false, path = "../../../primitives/runtime" } +sp-staking = { version = "2.0.0", default-features = false, path = "../../../primitives/staking" } +sp-keyring = { version = "2.0.0", optional = true, path = "../../../primitives/keyring" } +sp-session = { version = "2.0.0", default-features = false, path = "../../../primitives/session" } +sp-transaction-pool = { version = "2.0.0", default-features = false, path = "../../../primitives/transaction-pool" } +sp-version = { version = "2.0.0", default-features = false, path = "../../../primitives/version" } # frame dependencies -pallet-authority-discovery = { path = "../../../frame/authority-discovery", default-features = false } -pallet-authorship = { path = "../../../frame/authorship", default-features = false } -pallet-babe = { path = "../../../frame/babe", default-features = false } -pallet-balances = { path = "../../../frame/balances", default-features = false } -pallet-collective = { path = "../../../frame/collective", default-features = false } -pallet-contracts = { path = "../../../frame/contracts", default-features = false } -pallet-contracts-rpc-runtime-api = { path = "../../../frame/contracts/rpc/runtime-api/", default-features = false } -pallet-democracy = { path = "../../../frame/democracy", default-features = false } -pallet-elections-phragmen = { path = "../../../frame/elections-phragmen", default-features = false } -frame-executive = { path = "../../../frame/executive", default-features = false } -pallet-finality-tracker = { path = "../../../frame/finality-tracker", default-features = false } -pallet-grandpa = { path = "../../../frame/grandpa", default-features = false } -pallet-im-online = { path = "../../../frame/im-online", default-features = false } -pallet-indices = { path = "../../../frame/indices", default-features = false } -pallet-membership = { path = "../../../frame/membership", default-features = false } -pallet-nicks = { path = "../../../frame/nicks", default-features = false } -pallet-offences = { path = "../../../frame/offences", default-features = false } -pallet-randomness-collective-flip = { path = "../../../frame/randomness-collective-flip", default-features = false } -pallet-session = { path = "../../../frame/session", default-features = false, features = ["historical"] } -pallet-staking = { path = "../../../frame/staking", default-features = false, features = ["migrate"] } -pallet-staking-reward-curve = { path = "../../../frame/staking/reward-curve"} -pallet-sudo = { path = "../../../frame/sudo", default-features = false } -frame-support = { path = "../../../frame/support", default-features = false } -frame-system = { path = "../../../frame/system", default-features = false } -frame-system-rpc-runtime-api = { path = "../../../frame/system/rpc/runtime-api/", default-features = false } -pallet-timestamp = { path = "../../../frame/timestamp", default-features = false } -pallet-treasury = { path = "../../../frame/treasury", default-features = false } -pallet-utility = { path = "../../../frame/utility", default-features = false } -pallet-transaction-payment = { path = "../../../frame/transaction-payment", default-features = false } -pallet-transaction-payment-rpc-runtime-api = { path = "../../../frame/transaction-payment/rpc/runtime-api/", default-features = false } +pallet-authority-discovery = { version = "2.0.0", default-features = false, path = "../../../frame/authority-discovery" } +pallet-authorship = { version = "2.0.0", default-features = false, path = "../../../frame/authorship" } +pallet-babe = { version = "2.0.0", default-features = false, path = "../../../frame/babe" } +pallet-balances = { version = "2.0.0", default-features = false, path = "../../../frame/balances" } +pallet-collective = { version = "2.0.0", default-features = false, path = "../../../frame/collective" } +pallet-contracts = { version = "2.0.0", default-features = false, path = "../../../frame/contracts" } +pallet-contracts-rpc-runtime-api = { version = "2.0.0", default-features = false, path = "../../../frame/contracts/rpc/runtime-api/" } +pallet-democracy = { version = "2.0.0", default-features = false, path = "../../../frame/democracy" } +pallet-elections-phragmen = { version = "2.0.0", default-features = false, path = "../../../frame/elections-phragmen" } +frame-executive = { version = "2.0.0", default-features = false, path = "../../../frame/executive" } +pallet-finality-tracker = { version = "2.0.0", default-features = false, path = "../../../frame/finality-tracker" } +pallet-grandpa = { version = "2.0.0", default-features = false, path = "../../../frame/grandpa" } +pallet-im-online = { version = "2.0.0", default-features = false, path = "../../../frame/im-online" } +pallet-indices = { version = "2.0.0", default-features = false, path = "../../../frame/indices" } +pallet-membership = { version = "2.0.0", default-features = false, path = "../../../frame/membership" } +pallet-nicks = { version = "2.0.0", default-features = false, path = "../../../frame/nicks" } +pallet-offences = { version = "2.0.0", default-features = false, path = "../../../frame/offences" } +pallet-randomness-collective-flip = { version = "2.0.0", default-features = false, path = "../../../frame/randomness-collective-flip" } +pallet-session = { version = "2.0.0", features = ["historical"], path = "../../../frame/session", default-features = false } +pallet-staking = { version = "2.0.0", features = ["migrate"], path = "../../../frame/staking", default-features = false } +pallet-staking-reward-curve = { version = "2.0.0", path = "../../../frame/staking/reward-curve" } +pallet-sudo = { version = "2.0.0", default-features = false, path = "../../../frame/sudo" } +frame-support = { version = "2.0.0", default-features = false, path = "../../../frame/support" } +frame-system = { version = "2.0.0", default-features = false, path = "../../../frame/system" } +frame-system-rpc-runtime-api = { version = "2.0.0", default-features = false, path = "../../../frame/system/rpc/runtime-api/" } +pallet-timestamp = { version = "2.0.0", default-features = false, path = "../../../frame/timestamp" } +pallet-treasury = { version = "2.0.0", default-features = false, path = "../../../frame/treasury" } +pallet-utility = { version = "2.0.0", default-features = false, path = "../../../frame/utility" } +pallet-transaction-payment = { version = "2.0.0", default-features = false, path = "../../../frame/transaction-payment" } +pallet-transaction-payment-rpc-runtime-api = { version = "2.0.0", default-features = false, path = "../../../frame/transaction-payment/rpc/runtime-api/" } [build-dependencies] -wasm-builder-runner = { package = "substrate-wasm-builder-runner", path = "../../../utils/wasm-builder-runner", version = "1.0.4" } +wasm-builder-runner = { version = "1.0.4", package = "substrate-wasm-builder-runner", path = "../../../utils/wasm-builder-runner" } [dev-dependencies] -sp-io = { path = "../../../primitives/io" } +sp-io = { version = "2.0.0", path = "../../../primitives/io" } [features] default = ["std"] diff --git a/bin/node/testing/Cargo.toml b/bin/node/testing/Cargo.toml index e23901d7f7..4449c7bd22 100644 --- a/bin/node/testing/Cargo.toml +++ b/bin/node/testing/Cargo.toml @@ -6,26 +6,26 @@ description = "Test utilities for Substrate node." edition = "2018" [dependencies] -pallet-balances = { path = "../../../frame/balances" } -sc-client = { path = "../../../client/" } +pallet-balances = { version = "2.0.0", path = "../../../frame/balances" } +sc-client = { version = "2.0.0", path = "../../../client/" } codec = { package = "parity-scale-codec", version = "1.0.0" } -pallet-contracts = { path = "../../../frame/contracts" } -pallet-grandpa = { path = "../../../frame/grandpa" } -pallet-indices = { path = "../../../frame/indices" } -sp-keyring = { path = "../../../primitives/keyring" } -node-executor = { path = "../executor" } -node-primitives = { path = "../primitives" } -node-runtime = { path = "../runtime" } -sp-core = { path = "../../../primitives/core" } -sp-io = { path = "../../../primitives/io" } -frame-support = { path = "../../../frame/support" } -pallet-session = { path = "../../../frame/session" } -sp-runtime = { path = "../../../primitives/runtime" } -pallet-staking = { path = "../../../frame/staking" } -sc-executor = { path = "../../../client/executor" } -frame-system = { path = "../../../frame/system" } -substrate-test-client = { path = "../../../test-utils/client" } -pallet-timestamp = { path = "../../../frame/timestamp" } -pallet-transaction-payment = { path = "../../../frame/transaction-payment" } -pallet-treasury = { path = "../../../frame/treasury" } +pallet-contracts = { version = "2.0.0", path = "../../../frame/contracts" } +pallet-grandpa = { version = "2.0.0", path = "../../../frame/grandpa" } +pallet-indices = { version = "2.0.0", path = "../../../frame/indices" } +sp-keyring = { version = "2.0.0", path = "../../../primitives/keyring" } +node-executor = { version = "2.0.0", path = "../executor" } +node-primitives = { version = "2.0.0", path = "../primitives" } +node-runtime = { version = "2.0.0", path = "../runtime" } +sp-core = { version = "2.0.0", path = "../../../primitives/core" } +sp-io = { version = "2.0.0", path = "../../../primitives/io" } +frame-support = { version = "2.0.0", path = "../../../frame/support" } +pallet-session = { version = "2.0.0", path = "../../../frame/session" } +sp-runtime = { version = "2.0.0", path = "../../../primitives/runtime" } +pallet-staking = { version = "2.0.0", path = "../../../frame/staking" } +sc-executor = { version = "2.0.0", path = "../../../client/executor" } +frame-system = { version = "2.0.0", path = "../../../frame/system" } +substrate-test-client = { version = "2.0.0", path = "../../../test-utils/client" } +pallet-timestamp = { version = "2.0.0", path = "../../../frame/timestamp" } +pallet-transaction-payment = { version = "2.0.0", path = "../../../frame/transaction-payment" } +pallet-treasury = { version = "2.0.0", path = "../../../frame/treasury" } wabt = "0.9.2" diff --git a/bin/node/transaction-factory/Cargo.toml b/bin/node/transaction-factory/Cargo.toml index c873877ac3..8b10e10f41 100644 --- a/bin/node/transaction-factory/Cargo.toml +++ b/bin/node/transaction-factory/Cargo.toml @@ -1,19 +1,19 @@ [package] name = "node-transaction-factory" -version = "0.0.1" +version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" [dependencies] -sp-block-builder = { path = "../../../primitives/block-builder" } -sc-cli = { path = "../../../client/cli" } -sc-client-api = { path = "../../../client/api" } -sc-client = { path = "../../../client" } +sp-block-builder = { version = "2.0.0", path = "../../../primitives/block-builder" } +sc-cli = { version = "2.0.0", path = "../../../client/cli" } +sc-client-api = { version = "2.0.0", path = "../../../client/api" } +sc-client = { version = "2.0.0", path = "../../../client" } codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } -sp-consensus = { path = "../../../primitives/consensus/common" } +sp-consensus = { version = "0.8", path = "../../../primitives/consensus/common" } log = "0.4.8" -sp-core = { path = "../../../primitives/core" } -sp-api = { path = "../../../primitives/api" } -sp-runtime = { path = "../../../primitives/runtime" } -sc-service = { path = "../../../client/service" } -sp-blockchain = { path = "../../../primitives/blockchain" } +sp-core = { version = "2.0.0", path = "../../../primitives/core" } +sp-api = { version = "2.0.0", path = "../../../primitives/api" } +sp-runtime = { version = "2.0.0", path = "../../../primitives/runtime" } +sc-service = { version = "2.0.0", path = "../../../client/service" } +sp-blockchain = { version = "2.0.0", path = "../../../primitives/blockchain" } diff --git a/bin/utils/chain-spec-builder/Cargo.toml b/bin/utils/chain-spec-builder/Cargo.toml index 1e2bd0bc36..e31419d3b9 100644 --- a/bin/utils/chain-spec-builder/Cargo.toml +++ b/bin/utils/chain-spec-builder/Cargo.toml @@ -7,8 +7,8 @@ build = "build.rs" [dependencies] ansi_term = "0.12.1" -sc-keystore = { path = "../../../client/keystore" } -node-cli = { path = "../../node/cli" } -sp-core = { path = "../../../primitives/core" } +sc-keystore = { version = "2.0.0", path = "../../../client/keystore" } +node-cli = { version = "2.0.0", path = "../../node/cli" } +sp-core = { version = "2.0.0", path = "../../../primitives/core" } rand = "0.7.2" structopt = "0.3.3" diff --git a/bin/utils/subkey/Cargo.toml b/bin/utils/subkey/Cargo.toml index 3c998c9c9c..ca3519ae27 100644 --- a/bin/utils/subkey/Cargo.toml +++ b/bin/utils/subkey/Cargo.toml @@ -17,9 +17,9 @@ substrate-bip39 = "0.3.1" hex = "0.4.0" hex-literal = "0.2.1" codec = { package = "parity-scale-codec", version = "1.0.0" } -frame-system = { path = "../../../frame/system" } -pallet-balances = { path = "../../../frame/balances" } -pallet-transaction-payment = { path = "../../../frame/transaction-payment" } +frame-system = { version = "2.0.0", path = "../../../frame/system" } +pallet-balances = { version = "2.0.0", path = "../../../frame/balances" } +pallet-transaction-payment = { version = "2.0.0", path = "../../../frame/transaction-payment" } [features] bench = [] diff --git a/client/Cargo.toml b/client/Cargo.toml index a30dfc00ff..da4f5e3cc2 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -5,36 +5,36 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -sc-block-builder = { path = "block-builder" } -sc-client-api = { path = "api" } +sc-block-builder = { version = "2.0.0", path = "block-builder" } +sc-client-api = { version = "2.0.0", path = "api" } codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } -sp-consensus = { path = "../primitives/consensus/common" } +sp-consensus = { version = "0.8", path = "../primitives/consensus/common" } derive_more = { version = "0.99.2" } -sc-executor = { path = "executor" } -sp-externalities = { path = "../primitives/externalities" } +sc-executor = { version = "2.0.0", path = "executor" } +sp-externalities = { version = "2.0.0", path = "../primitives/externalities" } fnv = { version = "1.0.6" } futures = { version = "0.3.1", features = ["compat"] } hash-db = { version = "0.15.2" } hex-literal = { version = "0.2.1" } -sp-inherents = { path = "../primitives/inherents" } -sp-keyring = { path = "../primitives/keyring" } +sp-inherents = { version = "2.0.0", path = "../primitives/inherents" } +sp-keyring = { version = "2.0.0", path = "../primitives/keyring" } kvdb = "0.1.1" log = { version = "0.4.8" } parking_lot = { version = "0.9.0" } -sp-core = { path = "../primitives/core" } -sp-std = { path = "../primitives/std" } -sp-version = { path = "../primitives/version" } -sp-api = { path = "../primitives/api" } -sp-runtime = { path = "../primitives/runtime" } -sp-blockchain = { path = "../primitives/blockchain" } -sp-state-machine = { path = "../primitives/state-machine" } -sc-telemetry = { path = "telemetry" } -sp-trie = { path = "../primitives/trie" } +sp-core = { version = "2.0.0", path = "../primitives/core" } +sp-std = { version = "2.0.0", path = "../primitives/std" } +sp-version = { version = "2.0.0", path = "../primitives/version" } +sp-api = { version = "2.0.0", path = "../primitives/api" } +sp-runtime = { version = "2.0.0", path = "../primitives/runtime" } +sp-blockchain = { version = "2.0.0", path = "../primitives/blockchain" } +sp-state-machine = { version = "2.0.0", path = "../primitives/state-machine" } +sc-telemetry = { version = "2.0.0", path = "telemetry" } +sp-trie = { version = "2.0.0", path = "../primitives/trie" } tracing = "0.1.10" [dev-dependencies] env_logger = "0.7.0" tempfile = "3.1.0" -substrate-test-runtime-client = { path = "../test-utils/runtime/client" } +substrate-test-runtime-client = { version = "2.0.0", path = "../test-utils/runtime/client" } kvdb-memorydb = "0.1.2" -sp-panic-handler = { path = "../primitives/panic-handler" } +sp-panic-handler = { version = "2.0.0", path = "../primitives/panic-handler" } diff --git a/client/api/Cargo.toml b/client/api/Cargo.toml index 12a6901c0e..e445e9bc4c 100644 --- a/client/api/Cargo.toml +++ b/client/api/Cargo.toml @@ -6,29 +6,29 @@ edition = "2018" [dependencies] codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-consensus = { path = "../../primitives/consensus/common" } +sp-consensus = { version = "0.8", path = "../../primitives/consensus/common" } derive_more = { version = "0.99.2" } -sc-executor = { path = "../executor" } -sp-externalities = { path = "../../primitives/externalities" } +sc-executor = { version = "2.0.0", path = "../executor" } +sp-externalities = { version = "2.0.0", path = "../../primitives/externalities" } fnv = { version = "1.0.6" } futures = { version = "0.3.1" } hash-db = { version = "0.15.2", default-features = false } -sp-blockchain = { path = "../../primitives/blockchain" } +sp-blockchain = { version = "2.0.0", path = "../../primitives/blockchain" } hex-literal = { version = "0.2.1" } -sp-inherents = { path = "../../primitives/inherents", default-features = false } -sp-keyring = { path = "../../primitives/keyring" } +sp-inherents = { version = "2.0.0", default-features = false, path = "../../primitives/inherents" } +sp-keyring = { version = "2.0.0", path = "../../primitives/keyring" } kvdb = "0.1.1" log = { version = "0.4.8" } parking_lot = { version = "0.9.0" } -sp-core = { path = "../../primitives/core", default-features = false } -sp-std = { path = "../../primitives/std", default-features = false } -sp-version = { path = "../../primitives/version", default-features = false } -sp-api = { path = "../../primitives/api" } -sp-runtime = { path = "../../primitives/runtime", default-features = false } -sp-state-machine = { path = "../../primitives/state-machine" } -sc-telemetry = { path = "../telemetry" } -sp-trie = { path = "../../primitives/trie" } -sp-transaction-pool = { path = "../../primitives/transaction-pool" } +sp-core = { version = "2.0.0", default-features = false, path = "../../primitives/core" } +sp-std = { version = "2.0.0", default-features = false, path = "../../primitives/std" } +sp-version = { version = "2.0.0", default-features = false, path = "../../primitives/version" } +sp-api = { version = "2.0.0", path = "../../primitives/api" } +sp-runtime = { version = "2.0.0", default-features = false, path = "../../primitives/runtime" } +sp-state-machine = { version = "2.0.0", path = "../../primitives/state-machine" } +sc-telemetry = { version = "2.0.0", path = "../telemetry" } +sp-trie = { version = "2.0.0", path = "../../primitives/trie" } +sp-transaction-pool = { version = "2.0.0", path = "../../primitives/transaction-pool" } [dev-dependencies] -sp-test-primitives = { path = "../../primitives/test-primitives" } \ No newline at end of file +sp-test-primitives = { version = "2.0.0", path = "../../primitives/test-primitives" } \ No newline at end of file diff --git a/client/authority-discovery/Cargo.toml b/client/authority-discovery/Cargo.toml index 8dcd29a2a7..3564ad477d 100644 --- a/client/authority-discovery/Cargo.toml +++ b/client/authority-discovery/Cargo.toml @@ -9,26 +9,26 @@ build = "build.rs" prost-build = "0.5.0" [dependencies] -sp-authority-discovery = { path = "../../primitives/authority-discovery" } +sp-authority-discovery = { version = "2.0.0", path = "../../primitives/authority-discovery" } bytes = "0.4.12" -sc-client-api = { path = "../api" } +sc-client-api = { version = "2.0.0", path = "../api" } codec = { package = "parity-scale-codec", default-features = false, version = "1.0.3" } derive_more = "0.99.2" futures = "0.3.1" futures-timer = "2.0" -sc-keystore = { path = "../keystore" } +sc-keystore = { version = "2.0.0", path = "../keystore" } libp2p = { version = "0.13.0", default-features = false, features = ["secp256k1", "libp2p-websocket"] } log = "0.4.8" -sc-network = { path = "../network" } -sp-core = { path = "../../primitives/core" } -sp-blockchain = { path = "../../primitives/blockchain" } +sc-network = { version = "0.8", path = "../network" } +sp-core = { version = "2.0.0", path = "../../primitives/core" } +sp-blockchain = { version = "2.0.0", path = "../../primitives/blockchain" } prost = "0.5.0" serde_json = "1.0.41" -sp-runtime = { path = "../../primitives/runtime" } +sp-runtime = { version = "2.0.0", path = "../../primitives/runtime" } [dev-dependencies] env_logger = "0.7.0" parking_lot = "0.9.0" -sc-peerset = { path = "../peerset" } -sp-test-primitives = { path = "../../primitives/test-primitives" } -sp-api = { path = "../../primitives/api" } +sc-peerset = { version = "2.0.0", path = "../peerset" } +sp-test-primitives = { version = "2.0.0", path = "../../primitives/test-primitives" } +sp-api = { version = "2.0.0", path = "../../primitives/api" } diff --git a/client/basic-authorship/Cargo.toml b/client/basic-authorship/Cargo.toml index 3b0aa79b97..a93ca94282 100644 --- a/client/basic-authorship/Cargo.toml +++ b/client/basic-authorship/Cargo.toml @@ -8,19 +8,19 @@ edition = "2018" log = "0.4.8" futures = "0.3.1" codec = { package = "parity-scale-codec", version = "1.0.0" } -sp-runtime = { path = "../../primitives/runtime" } -sp-core = { path = "../../primitives/core" } -sp-blockchain = { path = "../../primitives/blockchain" } -sc-client = { path = "../" } -sc-client-api = { path = "../api" } -sp-consensus = { path = "../../primitives/consensus/common" } -sp-inherents = { path = "../../primitives/inherents" } -sc-telemetry = { path = "../telemetry" } -sp-transaction-pool = { path = "../../primitives/transaction-pool" } -sc-block-builder = { path = "../block-builder" } +sp-runtime = { version = "2.0.0", path = "../../primitives/runtime" } +sp-core = { version = "2.0.0", path = "../../primitives/core" } +sp-blockchain = { version = "2.0.0", path = "../../primitives/blockchain" } +sc-client = { version = "2.0.0", path = "../" } +sc-client-api = { version = "2.0.0", path = "../api" } +sp-consensus = { version = "0.8", path = "../../primitives/consensus/common" } +sp-inherents = { version = "2.0.0", path = "../../primitives/inherents" } +sc-telemetry = { version = "2.0.0", path = "../telemetry" } +sp-transaction-pool = { version = "2.0.0", path = "../../primitives/transaction-pool" } +sc-block-builder = { version = "2.0.0", path = "../block-builder" } tokio-executor = { version = "0.2.0-alpha.6", features = ["blocking"] } [dev-dependencies] -sc-transaction-pool = { path = "../../client/transaction-pool" } -substrate-test-runtime-client = { path = "../../test-utils/runtime/client" } +sc-transaction-pool = { version = "2.0.0", path = "../../client/transaction-pool" } +substrate-test-runtime-client = { version = "2.0.0", path = "../../test-utils/runtime/client" } parking_lot = "0.9" diff --git a/client/block-builder/Cargo.toml b/client/block-builder/Cargo.toml index 421419c122..157fa54960 100644 --- a/client/block-builder/Cargo.toml +++ b/client/block-builder/Cargo.toml @@ -5,10 +5,10 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -sp-state-machine = { path = "../../primitives/state-machine" } -sp-runtime = { path = "../../primitives/runtime" } -sp-blockchain = { path = "../../primitives/blockchain" } -sp-core = { path = "../../primitives/core" } +sp-state-machine = { version = "2.0.0", path = "../../primitives/state-machine" } +sp-runtime = { version = "2.0.0", path = "../../primitives/runtime" } +sp-blockchain = { version = "2.0.0", path = "../../primitives/blockchain" } +sp-core = { version = "2.0.0", path = "../../primitives/core" } codec = { package = "parity-scale-codec", version = "1.0.6", features = ["derive"] } -sp-block-builder = { path = "../../primitives/block-builder" } -sp-api = { path = "../../primitives/api" } +sp-block-builder = { version = "2.0.0", path = "../../primitives/block-builder" } +sp-api = { version = "2.0.0", path = "../../primitives/api" } diff --git a/client/chain-spec/Cargo.toml b/client/chain-spec/Cargo.toml index 91dd4a2814..fee166df32 100644 --- a/client/chain-spec/Cargo.toml +++ b/client/chain-spec/Cargo.toml @@ -5,11 +5,11 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -sc-chain-spec-derive = { path = "./derive" } +sc-chain-spec-derive = { version = "2.0.0", path = "./derive" } impl-trait-for-tuples = "0.1.3" -sc-network = { path = "../network" } -sp-core = { path = "../../primitives/core" } +sc-network = { version = "0.8", path = "../network" } +sp-core = { version = "2.0.0", path = "../../primitives/core" } serde = { version = "1.0.101", features = ["derive"] } serde_json = "1.0.41" -sp-runtime = { path = "../../primitives/runtime" } -sc-telemetry = { path = "../telemetry" } +sp-runtime = { version = "2.0.0", path = "../../primitives/runtime" } +sc-telemetry = { version = "2.0.0", path = "../telemetry" } diff --git a/client/cli/Cargo.toml b/client/cli/Cargo.toml index 3f76ff0b72..937135a8c3 100644 --- a/client/cli/Cargo.toml +++ b/client/cli/Cargo.toml @@ -20,19 +20,19 @@ tokio = "0.2.1" futures = { version = "0.3.1", features = ["compat"] } fdlimit = "0.1.1" serde_json = "1.0.41" -sp-panic-handler = { path = "../../primitives/panic-handler" } -sc-client-api = { path = "../api" } -sp-blockchain = { path = "../../primitives/blockchain" } -sc-network = { path = "../network" } -sp-runtime = { path = "../../primitives/runtime" } -sp-core = { path = "../../primitives/core" } -sc-service = { path = "../service", default-features = false } -sp-state-machine = { path = "../../primitives/state-machine" } -sc-telemetry = { path = "../telemetry" } -sp-keyring = { path = "../../primitives/keyring" } +sp-panic-handler = { version = "2.0.0", path = "../../primitives/panic-handler" } +sc-client-api = { version = "2.0.0", path = "../api" } +sp-blockchain = { version = "2.0.0", path = "../../primitives/blockchain" } +sc-network = { version = "0.8", path = "../network" } +sp-runtime = { version = "2.0.0", path = "../../primitives/runtime" } +sp-core = { version = "2.0.0", path = "../../primitives/core" } +sc-service = { version = "2.0.0", default-features = false, path = "../service" } +sp-state-machine = { version = "2.0.0", path = "../../primitives/state-machine" } +sc-telemetry = { version = "2.0.0", path = "../telemetry" } +sp-keyring = { version = "2.0.0", path = "../../primitives/keyring" } names = "0.11.0" structopt = "0.3.3" -sc-tracing = { path = "../tracing" } +sc-tracing = { version = "2.0.0", path = "../tracing" } [target.'cfg(not(target_os = "unknown"))'.dependencies] rpassword = "4.0.1" diff --git a/client/consensus/aura/Cargo.toml b/client/consensus/aura/Cargo.toml index cf237b9f82..ddae989b41 100644 --- a/client/consensus/aura/Cargo.toml +++ b/client/consensus/aura/Cargo.toml @@ -1,43 +1,43 @@ [package] name = "sc-consensus-aura" -version = "2.0.0" +version = "0.8.0" authors = ["Parity Technologies "] description = "Aura consensus algorithm for substrate" edition = "2018" [dependencies] -sp-application-crypto = { path = "../../../primitives/application-crypto" } -sp-consensus-aura = { path = "../../../primitives/consensus/aura" } -sp-block-builder = { path = "../../../primitives/block-builder" } -sc-client = { path = "../../" } -sc-client-api = { path = "../../api" } +sp-application-crypto = { version = "2.0.0", path = "../../../primitives/application-crypto" } +sp-consensus-aura = { version = "0.8", path = "../../../primitives/consensus/aura" } +sp-block-builder = { version = "2.0.0", path = "../../../primitives/block-builder" } +sc-client = { version = "2.0.0", path = "../../" } +sc-client-api = { version = "2.0.0", path = "../../api" } codec = { package = "parity-scale-codec", version = "1.0.0" } -sp-consensus = { path = "../../../primitives/consensus/common" } +sp-consensus = { version = "0.8", path = "../../../primitives/consensus/common" } derive_more = "0.99.2" futures = { version = "0.3.1", features = ["compat"] } futures01 = { package = "futures", version = "0.1" } futures-timer = "0.4.0" -sp-inherents = { path = "../../../primitives/inherents" } -sc-keystore = { path = "../../keystore" } +sp-inherents = { version = "2.0.0", path = "../../../primitives/inherents" } +sc-keystore = { version = "2.0.0", path = "../../keystore" } log = "0.4.8" parking_lot = "0.9.0" -sp-core = { path = "../../../primitives/core" } -sp-blockchain = { path = "../../../primitives/blockchain" } -sp-io = { path = "../../../primitives/io" } -sp-version = { path = "../../../primitives/version" } -sc-consensus-slots = { path = "../slots" } -sp-api = { path = "../../../primitives/api" } -sp-runtime = { path = "../../../primitives/runtime" } -sp-timestamp = { path = "../../../primitives/timestamp" } -sc-telemetry = { path = "../../telemetry" } +sp-core = { version = "2.0.0", path = "../../../primitives/core" } +sp-blockchain = { version = "2.0.0", path = "../../../primitives/blockchain" } +sp-io = { version = "2.0.0", path = "../../../primitives/io" } +sp-version = { version = "2.0.0", path = "../../../primitives/version" } +sc-consensus-slots = { version = "0.8", path = "../slots" } +sp-api = { version = "2.0.0", path = "../../../primitives/api" } +sp-runtime = { version = "2.0.0", path = "../../../primitives/runtime" } +sp-timestamp = { version = "2.0.0", path = "../../../primitives/timestamp" } +sc-telemetry = { version = "2.0.0", path = "../../telemetry" } [dev-dependencies] -sp-keyring = { path = "../../../primitives/keyring" } -sc-executor = { path = "../../executor" } -sc-network = { path = "../../network" } -sc-network-test = { path = "../../network/test" } -sc-service = { path = "../../service" } -substrate-test-runtime-client = { path = "../../../test-utils/runtime/client" } +sp-keyring = { version = "2.0.0", path = "../../../primitives/keyring" } +sc-executor = { version = "2.0.0", path = "../../executor" } +sc-network = { version = "0.8", path = "../../network" } +sc-network-test = { version = "2.0.0", path = "../../network/test" } +sc-service = { version = "2.0.0", path = "../../service" } +substrate-test-runtime-client = { version = "2.0.0", path = "../../../test-utils/runtime/client" } tokio = "0.1.22" env_logger = "0.7.0" tempfile = "3.1.0" diff --git a/client/consensus/babe/Cargo.toml b/client/consensus/babe/Cargo.toml index d9f3eaabb0..eb2875b3d3 100644 --- a/client/consensus/babe/Cargo.toml +++ b/client/consensus/babe/Cargo.toml @@ -1,34 +1,34 @@ [package] name = "sc-consensus-babe" -version = "2.0.0" +version = "0.8.0" authors = ["Parity Technologies "] description = "BABE consensus algorithm for substrate" edition = "2018" [dependencies] codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } -sp-consensus-babe = { path = "../../../primitives/consensus/babe" } -sp-core = { path = "../../../primitives/core" } -sp-application-crypto = { path = "../../../primitives/application-crypto" } +sp-consensus-babe = { version = "0.8", path = "../../../primitives/consensus/babe" } +sp-core = { version = "2.0.0", path = "../../../primitives/core" } +sp-application-crypto = { version = "2.0.0", path = "../../../primitives/application-crypto" } num-bigint = "0.2.3" num-rational = "0.2.2" num-traits = "0.2.8" -sp-version = { path = "../../../primitives/version" } -sp-io = { path = "../../../primitives/io" } -sp-inherents = { path = "../../../primitives/inherents" } -sp-timestamp = { path = "../../../primitives/timestamp" } -sc-telemetry = { path = "../../telemetry" } -sc-keystore = { path = "../../keystore" } -sc-client-api = { path = "../../api" } -sc-client = { path = "../../" } -sp-api = { path = "../../../primitives/api" } -sp-block-builder = { path = "../../../primitives/block-builder" } -sp-blockchain = { path = "../../../primitives/blockchain" } -sp-consensus = { path = "../../../primitives/consensus/common" } -sc-consensus-uncles = { path = "../uncles" } -sc-consensus-slots = { path = "../slots" } -sp-runtime = { path = "../../../primitives/runtime" } -fork-tree = { path = "../../../utils/fork-tree" } +sp-version = { version = "2.0.0", path = "../../../primitives/version" } +sp-io = { version = "2.0.0", path = "../../../primitives/io" } +sp-inherents = { version = "2.0.0", path = "../../../primitives/inherents" } +sp-timestamp = { version = "2.0.0", path = "../../../primitives/timestamp" } +sc-telemetry = { version = "2.0.0", path = "../../telemetry" } +sc-keystore = { version = "2.0.0", path = "../../keystore" } +sc-client-api = { version = "2.0.0", path = "../../api" } +sc-client = { version = "2.0.0", path = "../../" } +sp-api = { version = "2.0.0", path = "../../../primitives/api" } +sp-block-builder = { version = "2.0.0", path = "../../../primitives/block-builder" } +sp-blockchain = { version = "2.0.0", path = "../../../primitives/blockchain" } +sp-consensus = { version = "0.8", path = "../../../primitives/consensus/common" } +sc-consensus-uncles = { version = "0.8", path = "../uncles" } +sc-consensus-slots = { version = "0.8", path = "../slots" } +sp-runtime = { version = "2.0.0", path = "../../../primitives/runtime" } +fork-tree = { version = "2.0.0", path = "../../../utils/fork-tree" } futures = { version = "0.3.1", features = ["compat"] } futures01 = { package = "futures", version = "0.1" } futures-timer = "0.4.0" @@ -41,13 +41,13 @@ pdqselect = "0.1.0" derive_more = "0.99.2" [dev-dependencies] -sp-keyring = { path = "../../../primitives/keyring" } -sc-executor = { path = "../../executor" } -sc-network = { path = "../../network" } -sc-network-test = { path = "../../network/test" } -sc-service = { path = "../../service" } -substrate-test-runtime-client = { path = "../../../test-utils/runtime/client" } -sc-block-builder = { path = "../../block-builder" } +sp-keyring = { version = "2.0.0", path = "../../../primitives/keyring" } +sc-executor = { version = "2.0.0", path = "../../executor" } +sc-network = { version = "0.8", path = "../../network" } +sc-network-test = { version = "2.0.0", path = "../../network/test" } +sc-service = { version = "2.0.0", path = "../../service" } +substrate-test-runtime-client = { version = "2.0.0", path = "../../../test-utils/runtime/client" } +sc-block-builder = { version = "2.0.0", path = "../../block-builder" } tokio = "0.1.22" env_logger = "0.7.0" tempfile = "3.1.0" diff --git a/client/consensus/pow/Cargo.toml b/client/consensus/pow/Cargo.toml index eeea954f77..c7c4eeb6ff 100644 --- a/client/consensus/pow/Cargo.toml +++ b/client/consensus/pow/Cargo.toml @@ -1,21 +1,21 @@ [package] name = "sc-consensus-pow" -version = "2.0.0" +version = "0.8.0" authors = ["Parity Technologies "] description = "PoW consensus algorithm for substrate" edition = "2018" [dependencies] codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } -sp-core = { path = "../../../primitives/core" } -sp-blockchain = { path = "../../../primitives/blockchain" } -sp-runtime = { path = "../../../primitives/runtime" } -sc-client-api = { path = "../../api" } -sp-block-builder = { path = "../../../primitives/block-builder" } -sp-inherents = { path = "../../../primitives/inherents" } -sp-consensus-pow = { path = "../../../primitives/consensus/pow" } -sp-consensus = { path = "../../../primitives/consensus/common" } +sp-core = { version = "2.0.0", path = "../../../primitives/core" } +sp-blockchain = { version = "2.0.0", path = "../../../primitives/blockchain" } +sp-runtime = { version = "2.0.0", path = "../../../primitives/runtime" } +sc-client-api = { version = "2.0.0", path = "../../api" } +sp-block-builder = { version = "2.0.0", path = "../../../primitives/block-builder" } +sp-inherents = { version = "2.0.0", path = "../../../primitives/inherents" } +sp-consensus-pow = { version = "0.8", path = "../../../primitives/consensus/pow" } +sp-consensus = { version = "0.8", path = "../../../primitives/consensus/common" } log = "0.4.8" futures = { version = "0.3.1", features = ["compat"] } -sp-timestamp = { path = "../../../primitives/timestamp" } +sp-timestamp = { version = "2.0.0", path = "../../../primitives/timestamp" } derive_more = "0.99.2" diff --git a/client/consensus/slots/Cargo.toml b/client/consensus/slots/Cargo.toml index 01f6bf5251..510ea72abc 100644 --- a/client/consensus/slots/Cargo.toml +++ b/client/consensus/slots/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sc-consensus-slots" -version = "2.0.0" +version = "0.8.0" authors = ["Parity Technologies "] description = "Generic slots-based utilities for consensus" edition = "2018" @@ -8,17 +8,17 @@ build = "build.rs" [dependencies] codec = { package = "parity-scale-codec", version = "1.0.0" } -sc-client-api = { path = "../../api" } -sp-core = { path = "../../../primitives/core" } -sp-blockchain = { path = "../../../primitives/blockchain" } -sp-runtime = { path = "../../../primitives/runtime" } -sc-telemetry = { path = "../../telemetry" } -sp-consensus = { path = "../../../primitives/consensus/common" } -sp-inherents = { path = "../../../primitives/inherents" } +sc-client-api = { version = "2.0.0", path = "../../api" } +sp-core = { version = "2.0.0", path = "../../../primitives/core" } +sp-blockchain = { version = "2.0.0", path = "../../../primitives/blockchain" } +sp-runtime = { version = "2.0.0", path = "../../../primitives/runtime" } +sc-telemetry = { version = "2.0.0", path = "../../telemetry" } +sp-consensus = { version = "0.8", path = "../../../primitives/consensus/common" } +sp-inherents = { version = "2.0.0", path = "../../../primitives/inherents" } futures = "0.3.1" futures-timer = "2.0" parking_lot = "0.9.0" log = "0.4.8" [dev-dependencies] -substrate-test-runtime-client = { path = "../../../test-utils/runtime/client" } +substrate-test-runtime-client = { version = "2.0.0", path = "../../../test-utils/runtime/client" } diff --git a/client/consensus/uncles/Cargo.toml b/client/consensus/uncles/Cargo.toml index c017358ca4..54789c5794 100644 --- a/client/consensus/uncles/Cargo.toml +++ b/client/consensus/uncles/Cargo.toml @@ -1,15 +1,15 @@ [package] name = "sc-consensus-uncles" -version = "2.0.0" +version = "0.8.0" authors = ["Parity Technologies "] description = "Generic uncle inclusion utilities for consensus" edition = "2018" [dependencies] -sc-client-api = { path = "../../api" } -sp-core = { path = "../../../primitives/core" } -sp-runtime = { path = "../../../primitives/runtime" } -sp-authorship = { path = "../../../primitives/authorship" } -sp-consensus = { path = "../../../primitives/consensus/common" } -sp-inherents = { path = "../../../primitives/inherents" } +sc-client-api = { version = "2.0.0", path = "../../api" } +sp-core = { version = "2.0.0", path = "../../../primitives/core" } +sp-runtime = { version = "2.0.0", path = "../../../primitives/runtime" } +sp-authorship = { version = "2.0.0", path = "../../../primitives/authorship" } +sp-consensus = { version = "0.8", path = "../../../primitives/consensus/common" } +sp-inherents = { version = "2.0.0", path = "../../../primitives/inherents" } log = "0.4.8" diff --git a/client/db/Cargo.toml b/client/db/Cargo.toml index 20eba6fc13..955f6f8e0d 100644 --- a/client/db/Cargo.toml +++ b/client/db/Cargo.toml @@ -12,21 +12,21 @@ kvdb-rocksdb = { version = "0.2", optional = true } kvdb-memorydb = "0.1.2" linked-hash-map = "0.5.2" hash-db = "0.15.2" -sc-client-api = { path = "../api" } -sp-core = { path = "../../primitives/core" } -sp-runtime = { path = "../../primitives/runtime" } -sc-client = { path = "../" } -sp-state-machine = { path = "../../primitives/state-machine" } +sc-client-api = { version = "2.0.0", path = "../api" } +sp-core = { version = "2.0.0", path = "../../primitives/core" } +sp-runtime = { version = "2.0.0", path = "../../primitives/runtime" } +sc-client = { version = "2.0.0", path = "../" } +sp-state-machine = { version = "2.0.0", path = "../../primitives/state-machine" } codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } -sc-executor = { path = "../executor" } -sc-state-db = { path = "../state-db" } -sp-trie = { path = "../../primitives/trie" } -sp-consensus = { path = "../../primitives/consensus/common" } -sp-blockchain = { path = "../../primitives/blockchain" } +sc-executor = { version = "2.0.0", path = "../executor" } +sc-state-db = { version = "2.0.0", path = "../state-db" } +sp-trie = { version = "2.0.0", path = "../../primitives/trie" } +sp-consensus = { version = "0.8", path = "../../primitives/consensus/common" } +sp-blockchain = { version = "2.0.0", path = "../../primitives/blockchain" } [dev-dependencies] -sp-keyring = { path = "../../primitives/keyring" } -substrate-test-runtime-client = { path = "../../test-utils/runtime/client" } +sp-keyring = { version = "2.0.0", path = "../../primitives/keyring" } +substrate-test-runtime-client = { version = "2.0.0", path = "../../test-utils/runtime/client" } env_logger = "0.7.0" quickcheck = "0.9" diff --git a/client/executor/Cargo.toml b/client/executor/Cargo.toml index ec5f7c2a2c..b21a8165c5 100644 --- a/client/executor/Cargo.toml +++ b/client/executor/Cargo.toml @@ -7,18 +7,18 @@ edition = "2018" [dependencies] derive_more = "0.99.2" codec = { package = "parity-scale-codec", version = "1.0.0" } -sp-io = { path = "../../primitives/io" } -sp-core = { path = "../../primitives/core" } -sp-trie = { path = "../../primitives/trie" } -sp-serializer = { path = "../../primitives/serializer" } -sp-version = { path = "../../primitives/version" } -sp-panic-handler = { path = "../../primitives/panic-handler" } +sp-io = { version = "2.0.0", path = "../../primitives/io" } +sp-core = { version = "2.0.0", path = "../../primitives/core" } +sp-trie = { version = "2.0.0", path = "../../primitives/trie" } +sp-serializer = { version = "2.0.0", path = "../../primitives/serializer" } +sp-version = { version = "2.0.0", path = "../../primitives/version" } +sp-panic-handler = { version = "2.0.0", path = "../../primitives/panic-handler" } wasmi = "0.6.2" parity-wasm = "0.41.0" lazy_static = "1.4.0" -sp-wasm-interface = { path = "../../primitives/wasm-interface" } -sp-runtime-interface = { path = "../../primitives/runtime-interface" } -sp-externalities = { path = "../../primitives/externalities" } +sp-wasm-interface = { version = "2.0.0", path = "../../primitives/wasm-interface" } +sp-runtime-interface = { version = "2.0.0", path = "../../primitives/runtime-interface" } +sp-externalities = { version = "2.0.0", path = "../../primitives/externalities" } parking_lot = "0.9.0" log = "0.4.8" libsecp256k1 = "0.3.2" @@ -36,9 +36,9 @@ wasmtime-runtime = { version = "0.8", optional = true } assert_matches = "1.3.0" wabt = "0.9.2" hex-literal = "0.2.1" -sc-runtime-test = { path = "runtime-test" } -substrate-test-runtime = { path = "../../test-utils/runtime" } -sp-state-machine = { path = "../../primitives/state-machine" } +sc-runtime-test = { version = "2.0.0", path = "runtime-test" } +substrate-test-runtime = { version = "2.0.0", path = "../../test-utils/runtime" } +sp-state-machine = { version = "2.0.0", path = "../../primitives/state-machine" } test-case = "0.3.3" [features] diff --git a/client/executor/runtime-test/Cargo.toml b/client/executor/runtime-test/Cargo.toml index 00e53199a2..ba88550a92 100644 --- a/client/executor/runtime-test/Cargo.toml +++ b/client/executor/runtime-test/Cargo.toml @@ -6,14 +6,14 @@ edition = "2018" build = "build.rs" [dependencies] -sp-std = { path = "../../../primitives/std", default-features = false } -sp-io = { path = "../../../primitives/io", default-features = false } -sp-sandbox = { path = "../../../primitives/sandbox", default-features = false } -sp-core = { path = "../../../primitives/core", default-features = false } -sp-runtime = { path = "../../../primitives/runtime", default-features = false } +sp-std = { version = "2.0.0", default-features = false, path = "../../../primitives/std" } +sp-io = { version = "2.0.0", default-features = false, path = "../../../primitives/io" } +sp-sandbox = { version = "2.0.0", default-features = false, path = "../../../primitives/sandbox" } +sp-core = { version = "2.0.0", default-features = false, path = "../../../primitives/core" } +sp-runtime = { version = "2.0.0", default-features = false, path = "../../../primitives/runtime" } [build-dependencies] -wasm-builder-runner = { package = "substrate-wasm-builder-runner", path = "../../../utils/wasm-builder-runner", version = "1.0.4" } +wasm-builder-runner = { version = "1.0.4", package = "substrate-wasm-builder-runner", path = "../../../utils/wasm-builder-runner" } [features] default = [ "std" ] diff --git a/client/finality-grandpa/Cargo.toml b/client/finality-grandpa/Cargo.toml index 8f4cb2298d..9f90834e0d 100644 --- a/client/finality-grandpa/Cargo.toml +++ b/client/finality-grandpa/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -fork-tree = { path = "../../utils/fork-tree" } +fork-tree = { version = "2.0.0", path = "../../utils/fork-tree" } futures = "0.1.29" futures03 = { package = "futures", version = "0.3.1", features = ["compat"] } futures-timer = "2.0.2" @@ -13,31 +13,31 @@ log = "0.4.8" parking_lot = "0.9.0" rand = "0.7.2" parity-scale-codec = { version = "1.0.0", features = ["derive"] } -sp-runtime = { path = "../../primitives/runtime" } -sp-consensus = { path = "../../primitives/consensus/common" } -sp-core = { path = "../../primitives/core" } -sc-telemetry = { path = "../telemetry" } -sc-keystore = { path = "../keystore" } +sp-runtime = { version = "2.0.0", path = "../../primitives/runtime" } +sp-consensus = { version = "0.8", path = "../../primitives/consensus/common" } +sp-core = { version = "2.0.0", path = "../../primitives/core" } +sc-telemetry = { version = "2.0.0", path = "../telemetry" } +sc-keystore = { version = "2.0.0", path = "../keystore" } serde_json = "1.0.41" -sc-client-api = { path = "../api" } -sc-client = { path = "../" } -sp-inherents = { path = "../../primitives/inherents" } -sp-blockchain = { path = "../../primitives/blockchain" } -sc-network = { path = "../network" } -sc-network-gossip = { path = "../network-gossip" } -sp-finality-tracker = { path = "../../primitives/finality-tracker" } -sp-finality-grandpa = { path = "../../primitives/finality-grandpa" } +sc-client-api = { version = "2.0.0", path = "../api" } +sc-client = { version = "2.0.0", path = "../" } +sp-inherents = { version = "2.0.0", path = "../../primitives/inherents" } +sp-blockchain = { version = "2.0.0", path = "../../primitives/blockchain" } +sc-network = { version = "0.8", path = "../network" } +sc-network-gossip = { version = "2.0.0", path = "../network-gossip" } +sp-finality-tracker = { version = "2.0.0", path = "../../primitives/finality-tracker" } +sp-finality-grandpa = { version = "2.0.0", path = "../../primitives/finality-grandpa" } finality-grandpa = { version = "0.10.1", features = ["derive-codec"] } [dev-dependencies] finality-grandpa = { version = "0.10.1", features = ["derive-codec", "test-helpers"] } -sc-network = { path = "../network" } -sc-network-test = { path = "../network/test" } -sp-keyring = { path = "../../primitives/keyring" } -substrate-test-runtime-client = { path = "../../test-utils/runtime/client"} -sp-consensus-babe = { path = "../../primitives/consensus/babe" } -sp-state-machine = { path = "../../primitives/state-machine" } +sc-network = { version = "0.8", path = "../network" } +sc-network-test = { version = "2.0.0", path = "../network/test" } +sp-keyring = { version = "2.0.0", path = "../../primitives/keyring" } +substrate-test-runtime-client = { version = "2.0.0", path = "../../test-utils/runtime/client" } +sp-consensus-babe = { version = "0.8", path = "../../primitives/consensus/babe" } +sp-state-machine = { version = "2.0.0", path = "../../primitives/state-machine" } env_logger = "0.7.0" tokio = "0.1.22" tempfile = "3.1.0" -sp-api = { path = "../../primitives/api" } +sp-api = { version = "2.0.0", path = "../../primitives/api" } diff --git a/client/keystore/Cargo.toml b/client/keystore/Cargo.toml index 93629956fe..cdc69349fb 100644 --- a/client/keystore/Cargo.toml +++ b/client/keystore/Cargo.toml @@ -6,8 +6,8 @@ edition = "2018" [dependencies] derive_more = "0.99.2" -sp-core = { path = "../../primitives/core" } -sp-application-crypto = { path = "../../primitives/application-crypto" } +sp-core = { version = "2.0.0", path = "../../primitives/core" } +sp-application-crypto = { version = "2.0.0", path = "../../primitives/application-crypto" } hex = "0.4.0" rand = "0.7.2" serde_json = "1.0.41" diff --git a/client/network-gossip/Cargo.toml b/client/network-gossip/Cargo.toml index cc521e65f1..79246151c3 100644 --- a/client/network-gossip/Cargo.toml +++ b/client/network-gossip/Cargo.toml @@ -13,6 +13,6 @@ futures = { version = "0.3.1", features = ["compat"] } futures-timer = "0.4.0" lru = "0.1.2" libp2p = { version = "0.13.0", default-features = false, features = ["libp2p-websocket"] } -sc-network = { path = "../network" } +sc-network = { version = "0.8", path = "../network" } parking_lot = "0.9.0" -sp-runtime = { path = "../../primitives/runtime" } +sp-runtime = { version = "2.0.0", path = "../../primitives/runtime" } diff --git a/client/network/Cargo.toml b/client/network/Cargo.toml index ba20f06e5f..73b180b780 100644 --- a/client/network/Cargo.toml +++ b/client/network/Cargo.toml @@ -1,7 +1,7 @@ [package] description = "Substrate network protocol" name = "sc-network" -version = "2.0.0" +version = "0.8.0" license = "GPL-3.0" authors = ["Parity Technologies "] edition = "2018" @@ -23,17 +23,17 @@ lru = "0.4.0" rustc-hex = "2.0.1" rand = "0.7.2" libp2p = { version = "0.13.0", default-features = false, features = ["libp2p-websocket"] } -fork-tree = { path = "../../utils/fork-tree" } -sp-consensus = { path = "../../primitives/consensus/common" } -sc-client = { path = "../" } -sc-client-api = { path = "../api" } -sp-blockchain = { path = "../../primitives/blockchain" } -sp-runtime = { path = "../../primitives/runtime" } -sp-arithmetic = { path = "../../primitives/arithmetic" } -sp-core = { path = "../../primitives/core" } -sc-block-builder = { path = "../block-builder" } +fork-tree = { version = "2.0.0", path = "../../utils/fork-tree" } +sp-consensus = { version = "0.8", path = "../../primitives/consensus/common" } +sc-client = { version = "2.0.0", path = "../" } +sc-client-api = { version = "2.0.0", path = "../api" } +sp-blockchain = { version = "2.0.0", path = "../../primitives/blockchain" } +sp-runtime = { version = "2.0.0", path = "../../primitives/runtime" } +sp-arithmetic = { version = "2.0.0", path = "../../primitives/arithmetic" } +sp-core = { version = "2.0.0", path = "../../primitives/core" } +sc-block-builder = { version = "2.0.0", path = "../block-builder" } codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } -sc-peerset = { path = "../peerset" } +sc-peerset = { version = "2.0.0", path = "../peerset" } serde = { version = "1.0.101", features = ["derive"] } serde_json = "1.0.41" slog = { version = "2.5.2", features = ["nested-values"] } @@ -42,18 +42,18 @@ smallvec = "0.6.10" tokio-io = "0.1.12" tokio = { version = "0.1.22", optional = true } unsigned-varint = { version = "0.2.2", features = ["codec"] } -sp-keyring = { path = "../../primitives/keyring", optional = true } -substrate-test-client = { path = "../../test-utils/client", optional = true } -substrate-test-runtime-client = { path = "../../test-utils/runtime/client", optional = true } +sp-keyring = { version = "2.0.0", optional = true, path = "../../primitives/keyring" } +substrate-test-client = { version = "2.0.0", optional = true, path = "../../test-utils/client" } +substrate-test-runtime-client = { version = "2.0.0", optional = true, path = "../../test-utils/runtime/client" } erased-serde = "0.3.9" void = "1.0.2" zeroize = "1.0.0" -sp-consensus-babe = { path = "../../primitives/consensus/babe" } +sp-consensus-babe = { version = "0.8", path = "../../primitives/consensus/babe" } [dev-dependencies] -sp-test-primitives = { path = "../../primitives/test-primitives" } +sp-test-primitives = { version = "2.0.0", path = "../../primitives/test-primitives" } env_logger = "0.7.0" -sp-keyring = { path = "../../primitives/keyring" } +sp-keyring = { version = "2.0.0", path = "../../primitives/keyring" } quickcheck = "0.9.0" rand = "0.7.2" tempfile = "3.1.0" diff --git a/client/network/test/Cargo.toml b/client/network/test/Cargo.toml index c3f95894f8..c935843d77 100644 --- a/client/network/test/Cargo.toml +++ b/client/network/test/Cargo.toml @@ -7,7 +7,7 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -sc-network = { path = "../" } +sc-network = { version = "0.8", path = "../" } log = "0.4.8" parking_lot = "0.9.0" futures = "0.1.29" @@ -15,16 +15,16 @@ futures03 = { package = "futures", version = "0.3.1", features = ["compat"] } futures-timer = "0.4.0" rand = "0.7.2" libp2p = { version = "0.13.0", default-features = false, features = ["libp2p-websocket"] } -sp-consensus = { path = "../../../primitives/consensus/common" } -sc-client = { path = "../../" } -sc-client-api = { path = "../../api" } -sp-blockchain = { path = "../../../primitives/blockchain" } -sp-runtime = { path = "../../../primitives/runtime" } -sp-core = { path = "../../../primitives/core" } -sc-block-builder = { path = "../../block-builder" } -sp-consensus-babe = { path = "../../../primitives/consensus/babe" } +sp-consensus = { version = "0.8", path = "../../../primitives/consensus/common" } +sc-client = { version = "2.0.0", path = "../../" } +sc-client-api = { version = "2.0.0", path = "../../api" } +sp-blockchain = { version = "2.0.0", path = "../../../primitives/blockchain" } +sp-runtime = { version = "2.0.0", path = "../../../primitives/runtime" } +sp-core = { version = "2.0.0", path = "../../../primitives/core" } +sc-block-builder = { version = "2.0.0", path = "../../block-builder" } +sp-consensus-babe = { version = "0.8", path = "../../../primitives/consensus/babe" } env_logger = "0.7.0" -substrate-test-runtime-client = { path = "../../../test-utils/runtime/client" } -substrate-test-runtime = { path = "../../../test-utils/runtime" } +substrate-test-runtime-client = { version = "2.0.0", path = "../../../test-utils/runtime/client" } +substrate-test-runtime = { version = "2.0.0", path = "../../../test-utils/runtime" } tempfile = "3.1.0" tokio = "0.1.22" diff --git a/client/offchain/Cargo.toml b/client/offchain/Cargo.toml index 2e1255eab2..8048d10dc3 100644 --- a/client/offchain/Cargo.toml +++ b/client/offchain/Cargo.toml @@ -8,8 +8,8 @@ edition = "2018" [dependencies] bytes = "0.4.12" -sc-client-api = { path = "../api" } -sp-api = { path = "../../primitives/api" } +sc-client-api = { version = "2.0.0", path = "../api" } +sp-api = { version = "2.0.0", path = "../../primitives/api" } fnv = "1.0.6" futures01 = { package = "futures", version = "0.1" } futures = "0.3.1" @@ -17,26 +17,26 @@ futures-timer = "2.0" log = "0.4.8" threadpool = "1.7" num_cpus = "1.10" -sp-offchain = { path = "../../primitives/offchain" } +sp-offchain = { version = "2.0.0", path = "../../primitives/offchain" } codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } parking_lot = "0.9.0" -sp-core = { path = "../../primitives/core" } +sp-core = { version = "2.0.0", path = "../../primitives/core" } rand = "0.7.2" -sp-runtime = { path = "../../primitives/runtime" } -sc-network = { path = "../network" } -sc-keystore = { path = "../keystore" } +sp-runtime = { version = "2.0.0", path = "../../primitives/runtime" } +sc-network = { version = "0.8", path = "../network" } +sc-keystore = { version = "2.0.0", path = "../keystore" } [target.'cfg(not(target_os = "unknown"))'.dependencies] hyper = "0.12.35" hyper-rustls = "0.17.1" [dev-dependencies] -sc-client-db = { path = "../db/", default-features = true } +sc-client-db = { version = "2.0.0", default-features = true, path = "../db/" } env_logger = "0.7.0" -substrate-test-runtime-client = { path = "../../test-utils/runtime/client" } +substrate-test-runtime-client = { version = "2.0.0", path = "../../test-utils/runtime/client" } tokio = "0.1.22" -sc-transaction-pool = { path = "../../client/transaction-pool" } -sp-transaction-pool = { path = "../../primitives/transaction-pool" } +sc-transaction-pool = { version = "2.0.0", path = "../../client/transaction-pool" } +sp-transaction-pool = { version = "2.0.0", path = "../../primitives/transaction-pool" } [features] default = [] diff --git a/client/rpc-api/Cargo.toml b/client/rpc-api/Cargo.toml index 7b1f68c512..2c7a2ee071 100644 --- a/client/rpc-api/Cargo.toml +++ b/client/rpc-api/Cargo.toml @@ -14,9 +14,9 @@ jsonrpc-derive = "14.0.3" jsonrpc-pubsub = "14.0.3" log = "0.4.8" parking_lot = "0.9.0" -sp-core = { path = "../../primitives/core" } -sp-version = { path = "../../primitives/version" } +sp-core = { version = "2.0.0", path = "../../primitives/core" } +sp-version = { version = "2.0.0", path = "../../primitives/version" } serde = { version = "1.0.101", features = ["derive"] } serde_json = "1.0.41" -sp-transaction-pool = { path = "../../primitives/transaction-pool" } -sp-rpc = { path = "../../primitives/rpc" } +sp-transaction-pool = { version = "2.0.0", path = "../../primitives/transaction-pool" } +sp-rpc = { version = "2.0.0", path = "../../primitives/rpc" } diff --git a/client/rpc-servers/Cargo.toml b/client/rpc-servers/Cargo.toml index eb63193ace..e540274e25 100644 --- a/client/rpc-servers/Cargo.toml +++ b/client/rpc-servers/Cargo.toml @@ -10,7 +10,7 @@ pubsub = { package = "jsonrpc-pubsub", version = "14.0.3" } log = "0.4.8" serde = "1.0.101" serde_json = "1.0.41" -sp-runtime = { path = "../../primitives/runtime" } +sp-runtime = { version = "2.0.0", path = "../../primitives/runtime" } [target.'cfg(not(target_os = "unknown"))'.dependencies] http = { package = "jsonrpc-http-server", version = "14.0.3" } diff --git a/client/rpc/Cargo.toml b/client/rpc/Cargo.toml index 91274ed34b..f4a42d169a 100644 --- a/client/rpc/Cargo.toml +++ b/client/rpc/Cargo.toml @@ -5,35 +5,35 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -sc-rpc-api = { path = "../rpc-api" } -sc-client-api = { path = "../api" } -sc-client = { path = "../" } -sp-api = { path = "../../primitives/api" } +sc-rpc-api = { version = "2.0.0", path = "../rpc-api" } +sc-client-api = { version = "2.0.0", path = "../api" } +sc-client = { version = "2.0.0", path = "../" } +sp-api = { version = "2.0.0", path = "../../primitives/api" } codec = { package = "parity-scale-codec", version = "1.0.0" } futures = { version = "0.3.1", features = ["compat"] } jsonrpc-pubsub = "14.0.3" log = "0.4.8" -sp-core = { path = "../../primitives/core" } +sp-core = { version = "2.0.0", path = "../../primitives/core" } rpc = { package = "jsonrpc-core", version = "14.0.3" } -sp-version = { path = "../../primitives/version" } +sp-version = { version = "2.0.0", path = "../../primitives/version" } serde_json = "1.0.41" -sp-session = { path = "../../primitives/session" } -sp-runtime = { path = "../../primitives/runtime" } -sp-rpc = { path = "../../primitives/rpc" } -sp-state-machine = { path = "../../primitives/state-machine" } -sc-executor = { path = "../executor" } -sc-keystore = { path = "../keystore" } -sp-transaction-pool = { path = "../../primitives/transaction-pool" } -sp-blockchain = { path = "../../primitives/blockchain" } +sp-session = { version = "2.0.0", path = "../../primitives/session" } +sp-runtime = { version = "2.0.0", path = "../../primitives/runtime" } +sp-rpc = { version = "2.0.0", path = "../../primitives/rpc" } +sp-state-machine = { version = "2.0.0", path = "../../primitives/state-machine" } +sc-executor = { version = "2.0.0", path = "../executor" } +sc-keystore = { version = "2.0.0", path = "../keystore" } +sp-transaction-pool = { version = "2.0.0", path = "../../primitives/transaction-pool" } +sp-blockchain = { version = "2.0.0", path = "../../primitives/blockchain" } hash-db = { version = "0.15.2", default-features = false } parking_lot = { version = "0.9.0" } [dev-dependencies] assert_matches = "1.3.0" futures01 = { package = "futures", version = "0.1.29" } -sc-network = { path = "../network" } +sc-network = { version = "0.8", path = "../network" } rustc-hex = "2.0.1" -sp-io = { path = "../../primitives/io" } -substrate-test-runtime-client = { path = "../../test-utils/runtime/client" } +sp-io = { version = "2.0.0", path = "../../primitives/io" } +substrate-test-runtime-client = { version = "2.0.0", path = "../../test-utils/runtime/client" } tokio = "0.1.22" -sc-transaction-pool = { path = "../transaction-pool" } +sc-transaction-pool = { version = "2.0.0", path = "../transaction-pool" } diff --git a/client/service/Cargo.toml b/client/service/Cargo.toml index 39b2fb2676..ce27b0995c 100644 --- a/client/service/Cargo.toml +++ b/client/service/Cargo.toml @@ -28,36 +28,36 @@ serde = "1.0.101" serde_json = "1.0.41" sysinfo = "0.9.5" target_info = "0.1.0" -sc-keystore = { path = "../keystore" } -sp-io = { path = "../../primitives/io" } -sp-runtime = { path = "../../primitives/runtime" } -sp-blockchain = { path = "../../primitives/blockchain" } -sp-core = { path = "../../primitives/core" } -sp-session = { path = "../../primitives/session" } -sp-application-crypto = { path = "../../primitives/application-crypto" } -sp-consensus = { path = "../../primitives/consensus/common" } -sc-network = { path = "../network" } -sc-chain-spec = { path = "../chain-spec" } -sc-client-api = { path = "../api" } -sc-client = { path = "../" } -sp-api = { path = "../../primitives/api" } -sc-client-db = { path = "../db" } +sc-keystore = { version = "2.0.0", path = "../keystore" } +sp-io = { version = "2.0.0", path = "../../primitives/io" } +sp-runtime = { version = "2.0.0", path = "../../primitives/runtime" } +sp-blockchain = { version = "2.0.0", path = "../../primitives/blockchain" } +sp-core = { version = "2.0.0", path = "../../primitives/core" } +sp-session = { version = "2.0.0", path = "../../primitives/session" } +sp-application-crypto = { version = "2.0.0", path = "../../primitives/application-crypto" } +sp-consensus = { version = "0.8", path = "../../primitives/consensus/common" } +sc-network = { version = "0.8", path = "../network" } +sc-chain-spec = { version = "2.0.0", path = "../chain-spec" } +sc-client-api = { version = "2.0.0", path = "../api" } +sc-client = { version = "2.0.0", path = "../" } +sp-api = { version = "2.0.0", path = "../../primitives/api" } +sc-client-db = { version = "2.0.0", path = "../db" } codec = { package = "parity-scale-codec", version = "1.0.0" } -sc-executor = { path = "../executor" } -sc-transaction-pool = { path = "../transaction-pool" } -sp-transaction-pool = { path = "../../primitives/transaction-pool" } -sc-rpc-server = { path = "../rpc-servers" } -sc-rpc = { path = "../rpc" } -sc-telemetry = { path = "../telemetry" } -sc-offchain = { path = "../offchain" } +sc-executor = { version = "2.0.0", path = "../executor" } +sc-transaction-pool = { version = "2.0.0", path = "../transaction-pool" } +sp-transaction-pool = { version = "2.0.0", path = "../../primitives/transaction-pool" } +sc-rpc-server = { version = "2.0.0", path = "../rpc-servers" } +sc-rpc = { version = "2.0.0", path = "../rpc" } +sc-telemetry = { version = "2.0.0", path = "../telemetry" } +sc-offchain = { version = "2.0.0", path = "../offchain" } parity-multiaddr = { package = "parity-multiaddr", version = "0.5.0" } -grafana-data-source = { path = "../../utils/grafana-data-source" } -sc-tracing = { path = "../tracing" } +grafana-data-source = { version = "2.0.0", path = "../../utils/grafana-data-source" } +sc-tracing = { version = "2.0.0", path = "../tracing" } tracing = "0.1.10" [dev-dependencies] -substrate-test-runtime-client = { path = "../../test-utils/runtime/client" } -sp-consensus-babe = { path = "../../primitives/consensus/babe" } -grandpa = { package = "sc-finality-grandpa", path = "../finality-grandpa" } -grandpa-primitives = { package = "sp-finality-grandpa", path = "../../primitives/finality-grandpa" } +substrate-test-runtime-client = { version = "2.0.0", path = "../../test-utils/runtime/client" } +sp-consensus-babe = { version = "0.8", path = "../../primitives/consensus/babe" } +grandpa = { version = "2.0.0", package = "sc-finality-grandpa", path = "../finality-grandpa" } +grandpa-primitives = { version = "2.0.0", package = "sp-finality-grandpa", path = "../../primitives/finality-grandpa" } tokio = "0.1" diff --git a/client/service/test/Cargo.toml b/client/service/test/Cargo.toml index aa0d4b5414..2789bfda0f 100644 --- a/client/service/test/Cargo.toml +++ b/client/service/test/Cargo.toml @@ -12,10 +12,10 @@ log = "0.4.8" env_logger = "0.7.0" fdlimit = "0.1.1" futures03 = { package = "futures", version = "0.3.1", features = ["compat"] } -sc-service = { path = "../../service", default-features = false } -sc-network = { path = "../../network" } -sp-consensus = { path = "../../../primitives/consensus/common" } -sc-client = { path = "../../" } -sp-runtime = { path = "../../../primitives/runtime" } -sp-core = { path = "../../../primitives/core" } -sp-transaction-pool = { path = "../../../primitives/transaction-pool" } +sc-service = { version = "2.0.0", default-features = false, path = "../../service" } +sc-network = { version = "0.8", path = "../../network" } +sp-consensus = { version = "0.8", path = "../../../primitives/consensus/common" } +sc-client = { version = "2.0.0", path = "../../" } +sp-runtime = { version = "2.0.0", path = "../../../primitives/runtime" } +sp-core = { version = "2.0.0", path = "../../../primitives/core" } +sp-transaction-pool = { version = "2.0.0", path = "../../../primitives/transaction-pool" } diff --git a/client/state-db/Cargo.toml b/client/state-db/Cargo.toml index 97079c8f18..31335d752e 100644 --- a/client/state-db/Cargo.toml +++ b/client/state-db/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] parking_lot = "0.9.0" log = "0.4.8" -sp-core = { path = "../../primitives/core" } +sp-core = { version = "2.0.0", path = "../../primitives/core" } codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } [dev-dependencies] diff --git a/client/tracing/Cargo.toml b/client/tracing/Cargo.toml index 6c9c04ead5..2ceee93f6a 100644 --- a/client/tracing/Cargo.toml +++ b/client/tracing/Cargo.toml @@ -14,8 +14,8 @@ serde_json = "1.0.41" slog = { version = "2.5.2", features = ["nested-values"] } tracing-core = "0.1.7" -sc-telemetry = { path = "../telemetry" } -grafana-data-source = { path = "../../utils/grafana-data-source" } +sc-telemetry = { version = "2.0.0", path = "../telemetry" } +grafana-data-source = { version = "2.0.0", path = "../../utils/grafana-data-source" } [dev-dependencies] tracing = "0.1.10" diff --git a/client/transaction-pool/Cargo.toml b/client/transaction-pool/Cargo.toml index b9d7bf59ab..7018263071 100644 --- a/client/transaction-pool/Cargo.toml +++ b/client/transaction-pool/Cargo.toml @@ -10,14 +10,14 @@ derive_more = "0.99.2" futures = { version = "0.3.1", features = ["compat"] } log = "0.4.8" parking_lot = "0.9.0" -sp-core = { path = "../../primitives/core" } -sp-api = { path = "../../primitives/api" } -sp-runtime = { path = "../../primitives/runtime" } -sc-transaction-graph = { path = "./graph" } -sp-transaction-pool = { path = "../../primitives/transaction-pool" } -sc-client-api = { path = "../api" } -sp-blockchain = { path = "../../primitives/blockchain" } +sp-core = { version = "2.0.0", path = "../../primitives/core" } +sp-api = { version = "2.0.0", path = "../../primitives/api" } +sp-runtime = { version = "2.0.0", path = "../../primitives/runtime" } +sc-transaction-graph = { version = "2.0.0", path = "./graph" } +sp-transaction-pool = { version = "2.0.0", path = "../../primitives/transaction-pool" } +sc-client-api = { version = "2.0.0", path = "../api" } +sp-blockchain = { version = "2.0.0", path = "../../primitives/blockchain" } [dev-dependencies] -sp-keyring = { path = "../../primitives/keyring" } -substrate-test-runtime-client = { path = "../../test-utils/runtime/client" } +sp-keyring = { version = "2.0.0", path = "../../primitives/keyring" } +substrate-test-runtime-client = { version = "2.0.0", path = "../../test-utils/runtime/client" } diff --git a/client/transaction-pool/graph/Cargo.toml b/client/transaction-pool/graph/Cargo.toml index 8da67ef9c6..c5897e84fe 100644 --- a/client/transaction-pool/graph/Cargo.toml +++ b/client/transaction-pool/graph/Cargo.toml @@ -10,14 +10,14 @@ futures = "0.3.1" log = "0.4.8" parking_lot = "0.9.0" serde = { version = "1.0.101", features = ["derive"] } -sp-core = { path = "../../../primitives/core" } -sp-runtime = { path = "../../../primitives/runtime" } -sp-transaction-pool = { path = "../../../primitives/transaction-pool" } +sp-core = { version = "2.0.0", path = "../../../primitives/core" } +sp-runtime = { version = "2.0.0", path = "../../../primitives/runtime" } +sp-transaction-pool = { version = "2.0.0", path = "../../../primitives/transaction-pool" } [dev-dependencies] assert_matches = "1.3.0" codec = { package = "parity-scale-codec", version = "1.0.0" } -substrate-test-runtime = { path = "../../../test-utils/runtime" } +substrate-test-runtime = { version = "2.0.0", path = "../../../test-utils/runtime" } criterion = "0.3" [[bench]] diff --git a/frame/assets/Cargo.toml b/frame/assets/Cargo.toml index 72de7d2b8b..f371f21e1a 100644 --- a/frame/assets/Cargo.toml +++ b/frame/assets/Cargo.toml @@ -8,16 +8,16 @@ edition = "2018" serde = { version = "1.0.101", optional = true } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } # Needed for various traits. In our case, `OnFinalize`. -sp-runtime = { path = "../../primitives/runtime", default-features = false } +sp-runtime = { version = "2.0.0", default-features = false, path = "../../primitives/runtime" } # Needed for type-safe access to storage DB. -frame-support = { path = "../support", default-features = false } +frame-support = { version = "2.0.0", default-features = false, path = "../support" } # `system` module provides us with all sorts of useful stuff and macros depend on it being around. -frame-system = { path = "../system", default-features = false } +frame-system = { version = "2.0.0", default-features = false, path = "../system" } [dev-dependencies] -sp-core = { path = "../../primitives/core" } -sp-std = { path = "../../primitives/std" } -sp-io = { path = "../../primitives/io" } +sp-core = { version = "2.0.0", path = "../../primitives/core" } +sp-std = { version = "2.0.0", path = "../../primitives/std" } +sp-io = { version = "2.0.0", path = "../../primitives/io" } [features] default = ["std"] diff --git a/frame/aura/Cargo.toml b/frame/aura/Cargo.toml index 767056aaf6..2675445832 100644 --- a/frame/aura/Cargo.toml +++ b/frame/aura/Cargo.toml @@ -5,20 +5,20 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -sp-application-crypto = { path = "../../primitives/application-crypto", default-features = false } +sp-application-crypto = { version = "2.0.0", default-features = false, path = "../../primitives/application-crypto" } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-inherents = { path = "../../primitives/inherents", default-features = false } -sp-core = { path = "../../primitives/core", default-features = false } -sp-std = { path = "../../primitives/std", default-features = false } +sp-inherents = { version = "2.0.0", default-features = false, path = "../../primitives/inherents" } +sp-core = { version = "2.0.0", default-features = false, path = "../../primitives/core" } +sp-std = { version = "2.0.0", default-features = false, path = "../../primitives/std" } serde = { version = "1.0.101", optional = true } -pallet-session = { path = "../session", default-features = false } -sp-runtime = { path = "../../primitives/runtime", default-features = false } +pallet-session = { version = "2.0.0", default-features = false, path = "../session" } +sp-runtime = { version = "2.0.0", default-features = false, path = "../../primitives/runtime" } sp-io ={ path = "../../primitives/io", default-features = false } -frame-support = { path = "../support", default-features = false } +frame-support = { version = "2.0.0", default-features = false, path = "../support" } sp-consensus-aura = { path = "../../primitives/consensus/aura", default-features = false} -frame-system = { path = "../system", default-features = false } -sp-timestamp = { path = "../../primitives/timestamp", default-features = false } -pallet-timestamp = { path = "../timestamp", default-features = false } +frame-system = { version = "2.0.0", default-features = false, path = "../system" } +sp-timestamp = { version = "2.0.0", default-features = false, path = "../../primitives/timestamp" } +pallet-timestamp = { version = "2.0.0", default-features = false, path = "../timestamp" } [dev-dependencies] diff --git a/frame/authority-discovery/Cargo.toml b/frame/authority-discovery/Cargo.toml index 4d7b43417a..3760d863d7 100644 --- a/frame/authority-discovery/Cargo.toml +++ b/frame/authority-discovery/Cargo.toml @@ -1,24 +1,24 @@ [package] name = "pallet-authority-discovery" -version = "0.1.0" +version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" [dependencies] -sp-authority-discovery = { path = "../../primitives/authority-discovery", default-features = false } -sp-application-crypto = { path = "../../primitives/application-crypto", default-features = false } +sp-authority-discovery = { version = "2.0.0", default-features = false, path = "../../primitives/authority-discovery" } +sp-application-crypto = { version = "2.0.0", default-features = false, path = "../../primitives/application-crypto" } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-core = { path = "../../primitives/core", default-features = false } -sp-std = { path = "../../primitives/std", default-features = false } +sp-core = { version = "2.0.0", default-features = false, path = "../../primitives/core" } +sp-std = { version = "2.0.0", default-features = false, path = "../../primitives/std" } serde = { version = "1.0.101", optional = true } -sp-io = { path = "../../primitives/io", default-features = false } -pallet-session = { path = "../session", default-features = false, features = ["historical" ] } -sp-runtime = { path = "../../primitives/runtime", default-features = false } -frame-support = { path = "../support", default-features = false } -frame-system = { path = "../system", default-features = false } +sp-io = { version = "2.0.0", default-features = false, path = "../../primitives/io" } +pallet-session = { version = "2.0.0", features = ["historical" ], path = "../session", default-features = false } +sp-runtime = { version = "2.0.0", default-features = false, path = "../../primitives/runtime" } +frame-support = { version = "2.0.0", default-features = false, path = "../support" } +frame-system = { version = "2.0.0", default-features = false, path = "../system" } [dev-dependencies] -sp-staking = { path = "../../primitives/staking", default-features = false } +sp-staking = { version = "2.0.0", default-features = false, path = "../../primitives/staking" } [features] default = ["std"] diff --git a/frame/authorship/Cargo.toml b/frame/authorship/Cargo.toml index c21ed24be1..298da65a2b 100644 --- a/frame/authorship/Cargo.toml +++ b/frame/authorship/Cargo.toml @@ -1,19 +1,19 @@ [package] name = "pallet-authorship" -version = "0.1.0" +version = "2.0.0" description = "Block and Uncle Author tracking for the SRML" authors = ["Parity Technologies "] edition = "2018" [dependencies] -sp-core = { path = "../../primitives/core", default-features = false } +sp-core = { version = "2.0.0", default-features = false, path = "../../primitives/core" } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-inherents = { path = "../../primitives/inherents", default-features = false } -sp-authorship = { path = "../../primitives/authorship", default-features = false } -sp-std = { path = "../../primitives/std", default-features = false } -sp-runtime = { path = "../../primitives/runtime", default-features = false } -frame-support = { path = "../support", default-features = false } -frame-system = { path = "../system", default-features = false } +sp-inherents = { version = "2.0.0", default-features = false, path = "../../primitives/inherents" } +sp-authorship = { version = "2.0.0", default-features = false, path = "../../primitives/authorship" } +sp-std = { version = "2.0.0", default-features = false, path = "../../primitives/std" } +sp-runtime = { version = "2.0.0", default-features = false, path = "../../primitives/runtime" } +frame-support = { version = "2.0.0", default-features = false, path = "../support" } +frame-system = { version = "2.0.0", default-features = false, path = "../system" } sp-io ={ path = "../../primitives/io", default-features = false } impl-trait-for-tuples = "0.1.3" diff --git a/frame/babe/Cargo.toml b/frame/babe/Cargo.toml index d9f9dec339..30dbda4e53 100644 --- a/frame/babe/Cargo.toml +++ b/frame/babe/Cargo.toml @@ -8,24 +8,24 @@ edition = "2018" hex-literal = "0.2.1" codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } serde = { version = "1.0.101", optional = true } -sp-inherents = { path = "../../primitives/inherents", default-features = false } -sp-std = { path = "../../primitives/std", default-features = false } -sp-runtime = { path = "../../primitives/runtime", default-features = false } -sp-staking = { path = "../../primitives/staking", default-features = false } -frame-support = { path = "../support", default-features = false } -frame-system = { path = "../system", default-features = false } -pallet-timestamp = { path = "../timestamp", default-features = false } -sp-timestamp = { path = "../../primitives/timestamp", default-features = false } -pallet-session = { path = "../session", default-features = false } -sp-consensus-babe = { path = "../../primitives/consensus/babe", default-features = false } +sp-inherents = { version = "2.0.0", default-features = false, path = "../../primitives/inherents" } +sp-std = { version = "2.0.0", default-features = false, path = "../../primitives/std" } +sp-runtime = { version = "2.0.0", default-features = false, path = "../../primitives/runtime" } +sp-staking = { version = "2.0.0", default-features = false, path = "../../primitives/staking" } +frame-support = { version = "2.0.0", default-features = false, path = "../support" } +frame-system = { version = "2.0.0", default-features = false, path = "../system" } +pallet-timestamp = { version = "2.0.0", default-features = false, path = "../timestamp" } +sp-timestamp = { version = "2.0.0", default-features = false, path = "../../primitives/timestamp" } +pallet-session = { version = "2.0.0", default-features = false, path = "../session" } +sp-consensus-babe = { version = "0.8", default-features = false, path = "../../primitives/consensus/babe" } sp-io ={ path = "../../primitives/io", default-features = false } [dev-dependencies] lazy_static = "1.4.0" parking_lot = "0.9.0" -sp-version = { path = "../../primitives/version", default-features = false } -sp-core = { path = "../../primitives/core" } -substrate-test-runtime = { path = "../../test-utils/runtime" } +sp-version = { version = "2.0.0", default-features = false, path = "../../primitives/version" } +sp-core = { version = "2.0.0", path = "../../primitives/core" } +substrate-test-runtime = { version = "2.0.0", path = "../../test-utils/runtime" } [features] default = ["std"] diff --git a/frame/balances/Cargo.toml b/frame/balances/Cargo.toml index cc29e3c502..e5a3c4f2d7 100644 --- a/frame/balances/Cargo.toml +++ b/frame/balances/Cargo.toml @@ -8,15 +8,15 @@ edition = "2018" serde = { version = "1.0.101", optional = true } 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 } -sp-runtime = { path = "../../primitives/runtime", default-features = false } -frame-support = { path = "../support", default-features = false } -frame-system = { path = "../system", default-features = false } +sp-std = { version = "2.0.0", default-features = false, path = "../../primitives/std" } +sp-runtime = { version = "2.0.0", default-features = false, path = "../../primitives/runtime" } +frame-support = { version = "2.0.0", default-features = false, path = "../support" } +frame-system = { version = "2.0.0", default-features = false, path = "../system" } [dev-dependencies] -sp-io = { path = "../../primitives/io" } -sp-core = { path = "../../primitives/core" } -pallet-transaction-payment = { path = "../transaction-payment" } +sp-io = { version = "2.0.0", path = "../../primitives/io" } +sp-core = { version = "2.0.0", path = "../../primitives/core" } +pallet-transaction-payment = { version = "2.0.0", path = "../transaction-payment" } [features] default = ["std"] diff --git a/frame/collective/Cargo.toml b/frame/collective/Cargo.toml index 7c298dd887..6bf3c1b9b5 100644 --- a/frame/collective/Cargo.toml +++ b/frame/collective/Cargo.toml @@ -8,16 +8,16 @@ edition = "2018" serde = { version = "1.0.101", optional = true } safe-mix = { version = "1.0.0", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-core = { path = "../../primitives/core", default-features = false } -sp-std = { path = "../../primitives/std", default-features = false } -sp-io = { path = "../../primitives/io", default-features = false } -sp-runtime = { path = "../../primitives/runtime", default-features = false } -frame-support = { path = "../support", default-features = false } -frame-system = { path = "../system", default-features = false } +sp-core = { version = "2.0.0", default-features = false, path = "../../primitives/core" } +sp-std = { version = "2.0.0", default-features = false, path = "../../primitives/std" } +sp-io = { version = "2.0.0", default-features = false, path = "../../primitives/io" } +sp-runtime = { version = "2.0.0", default-features = false, path = "../../primitives/runtime" } +frame-support = { version = "2.0.0", default-features = false, path = "../support" } +frame-system = { version = "2.0.0", default-features = false, path = "../system" } [dev-dependencies] hex-literal = "0.2.1" -pallet-balances = { path = "../balances" } +pallet-balances = { version = "2.0.0", path = "../balances" } [features] default = ["std"] diff --git a/frame/contracts/Cargo.toml b/frame/contracts/Cargo.toml index a55c6671b9..c6102d23ea 100644 --- a/frame/contracts/Cargo.toml +++ b/frame/contracts/Cargo.toml @@ -10,21 +10,21 @@ pwasm-utils = { version = "0.12.0", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } parity-wasm = { version = "0.41.0", default-features = false } wasmi-validation = { version = "0.3.0", default-features = false } -sp-core = { path = "../../primitives/core", default-features = false } -sp-runtime = { path = "../../primitives/runtime", default-features = false } -sp-io = { path = "../../primitives/io", default-features = false } -sp-std = { path = "../../primitives/std", default-features = false } -sp-sandbox = { path = "../../primitives/sandbox", default-features = false } -frame-support = { path = "../support", default-features = false } -frame-system = { path = "../system", default-features = false } +sp-core = { version = "2.0.0", default-features = false, path = "../../primitives/core" } +sp-runtime = { version = "2.0.0", default-features = false, path = "../../primitives/runtime" } +sp-io = { version = "2.0.0", default-features = false, path = "../../primitives/io" } +sp-std = { version = "2.0.0", default-features = false, path = "../../primitives/std" } +sp-sandbox = { version = "2.0.0", default-features = false, path = "../../primitives/sandbox" } +frame-support = { version = "2.0.0", default-features = false, path = "../support" } +frame-system = { version = "2.0.0", default-features = false, path = "../system" } [dev-dependencies] wabt = "0.9.2" assert_matches = "1.3.0" hex-literal = "0.2.1" -pallet-balances = { path = "../balances" } -pallet-timestamp = { path = "../timestamp" } -pallet-randomness-collective-flip = { path = "../randomness-collective-flip" } +pallet-balances = { version = "2.0.0", path = "../balances" } +pallet-timestamp = { version = "2.0.0", path = "../timestamp" } +pallet-randomness-collective-flip = { version = "2.0.0", path = "../randomness-collective-flip" } [features] default = ["std"] diff --git a/frame/contracts/rpc/Cargo.toml b/frame/contracts/rpc/Cargo.toml index bb2bbd5844..3b5b495b0c 100644 --- a/frame/contracts/rpc/Cargo.toml +++ b/frame/contracts/rpc/Cargo.toml @@ -9,12 +9,12 @@ codec = { package = "parity-scale-codec", version = "1.0.0" } jsonrpc-core = "14.0.3" jsonrpc-core-client = "14.0.3" jsonrpc-derive = "14.0.3" -sp-blockchain = { path = "../../../primitives/blockchain" } -sp-core = { path = "../../../primitives/core" } -sp-rpc = { path = "../../../primitives/rpc" } +sp-blockchain = { version = "2.0.0", path = "../../../primitives/blockchain" } +sp-core = { version = "2.0.0", path = "../../../primitives/core" } +sp-rpc = { version = "2.0.0", path = "../../../primitives/rpc" } serde = { version = "1.0.101", features = ["derive"] } -sp-runtime = { path = "../../../primitives/runtime" } -pallet-contracts-rpc-runtime-api = { path = "./runtime-api" } +sp-runtime = { version = "2.0.0", path = "../../../primitives/runtime" } +pallet-contracts-rpc-runtime-api = { version = "2.0.0", path = "./runtime-api" } [dev-dependencies] serde_json = "1.0.41" diff --git a/frame/contracts/rpc/runtime-api/Cargo.toml b/frame/contracts/rpc/runtime-api/Cargo.toml index 05fb0d5609..c8e183237c 100644 --- a/frame/contracts/rpc/runtime-api/Cargo.toml +++ b/frame/contracts/rpc/runtime-api/Cargo.toml @@ -5,10 +5,10 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -sp-api = { path = "../../../../primitives/api", default-features = false } +sp-api = { version = "2.0.0", default-features = false, path = "../../../../primitives/api" } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-std = { path = "../../../../primitives/std", default-features = false } -sp-runtime = { path = "../../../../primitives/runtime", default-features = false } +sp-std = { version = "2.0.0", default-features = false, path = "../../../../primitives/std" } +sp-runtime = { version = "2.0.0", default-features = false, path = "../../../../primitives/runtime" } [features] default = ["std"] diff --git a/frame/democracy/Cargo.toml b/frame/democracy/Cargo.toml index 7e0a9ad53d..8e1aa13fc6 100644 --- a/frame/democracy/Cargo.toml +++ b/frame/democracy/Cargo.toml @@ -8,15 +8,15 @@ edition = "2018" 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 } -sp-io = { path = "../../primitives/io", default-features = false } -sp-runtime = { path = "../../primitives/runtime", default-features = false } -frame-support = { path = "../support", default-features = false } -frame-system = { path = "../system", default-features = false } +sp-std = { version = "2.0.0", default-features = false, path = "../../primitives/std" } +sp-io = { version = "2.0.0", default-features = false, path = "../../primitives/io" } +sp-runtime = { version = "2.0.0", default-features = false, path = "../../primitives/runtime" } +frame-support = { version = "2.0.0", default-features = false, path = "../support" } +frame-system = { version = "2.0.0", default-features = false, path = "../system" } [dev-dependencies] -sp-core = { path = "../../primitives/core" } -pallet-balances = { path = "../balances" } +sp-core = { version = "2.0.0", path = "../../primitives/core" } +pallet-balances = { version = "2.0.0", path = "../balances" } [features] default = ["std"] diff --git a/frame/elections-phragmen/Cargo.toml b/frame/elections-phragmen/Cargo.toml index df253e0f02..9d0c3ed61c 100644 --- a/frame/elections-phragmen/Cargo.toml +++ b/frame/elections-phragmen/Cargo.toml @@ -6,18 +6,18 @@ edition = "2018" [dependencies] codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-runtime = { path = "../../primitives/runtime", default-features = false } -sp-phragmen = { path = "../../primitives/phragmen", default-features = false } -frame-support = { path = "../support", default-features = false } -frame-system = { path = "../system", default-features = false } -sp-std = { path = "../../primitives/std", default-features = false } +sp-runtime = { version = "2.0.0", default-features = false, path = "../../primitives/runtime" } +sp-phragmen = { version = "2.0.0", default-features = false, path = "../../primitives/phragmen" } +frame-support = { version = "2.0.0", default-features = false, path = "../support" } +frame-system = { version = "2.0.0", default-features = false, path = "../system" } +sp-std = { version = "2.0.0", default-features = false, path = "../../primitives/std" } [dev-dependencies] -sp-io = { path = "../../primitives/io" } +sp-io = { version = "2.0.0", path = "../../primitives/io" } hex-literal = "0.2.1" -pallet-balances = { path = "../balances" } -sp-core = { path = "../../primitives/core" } -substrate-test-utils = { path = "../../test-utils" } +pallet-balances = { version = "2.0.0", path = "../balances" } +sp-core = { version = "2.0.0", path = "../../primitives/core" } +substrate-test-utils = { version = "2.0.0", path = "../../test-utils" } serde = { version = "1.0.101" } [features] diff --git a/frame/elections/Cargo.toml b/frame/elections/Cargo.toml index c1b845bd5a..44d624b986 100644 --- a/frame/elections/Cargo.toml +++ b/frame/elections/Cargo.toml @@ -8,16 +8,16 @@ edition = "2018" serde = { version = "1.0.101", optional = true } safe-mix = { version = "1.0.0", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-core = { path = "../../primitives/core", default-features = false } -sp-std = { path = "../../primitives/std", default-features = false } -sp-io = { path = "../../primitives/io", default-features = false } -sp-runtime = { path = "../../primitives/runtime", default-features = false } -frame-support = { path = "../support", default-features = false } -frame-system = { path = "../system", default-features = false } +sp-core = { version = "2.0.0", default-features = false, path = "../../primitives/core" } +sp-std = { version = "2.0.0", default-features = false, path = "../../primitives/std" } +sp-io = { version = "2.0.0", default-features = false, path = "../../primitives/io" } +sp-runtime = { version = "2.0.0", default-features = false, path = "../../primitives/runtime" } +frame-support = { version = "2.0.0", default-features = false, path = "../support" } +frame-system = { version = "2.0.0", default-features = false, path = "../system" } [dev-dependencies] hex-literal = "0.2.1" -pallet-balances = { path = "../balances" } +pallet-balances = { version = "2.0.0", path = "../balances" } [features] default = ["std"] diff --git a/frame/evm/Cargo.toml b/frame/evm/Cargo.toml index d26c6672d1..933b450ee4 100644 --- a/frame/evm/Cargo.toml +++ b/frame/evm/Cargo.toml @@ -7,14 +7,14 @@ edition = "2018" [dependencies] serde = { version = "1.0.101", optional = true, features = ["derive"] } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } -frame-support = { path = "../support", default-features = false } -frame-system = { path = "../system", default-features = false } -pallet-timestamp = { path = "../timestamp", default-features = false } -pallet-balances = { path = "../balances", default-features = false } -sp-core = { path = "../../primitives/core", default-features = false } -sp-runtime = { path = "../../primitives/runtime", default-features = false } -sp-std = { path = "../../primitives/std", default-features = false } -sp-io = { path = "../../primitives/io", default-features = false } +frame-support = { version = "2.0.0", default-features = false, path = "../support" } +frame-system = { version = "2.0.0", default-features = false, path = "../system" } +pallet-timestamp = { version = "2.0.0", default-features = false, path = "../timestamp" } +pallet-balances = { version = "2.0.0", default-features = false, path = "../balances" } +sp-core = { version = "2.0.0", default-features = false, path = "../../primitives/core" } +sp-runtime = { version = "2.0.0", default-features = false, path = "../../primitives/runtime" } +sp-std = { version = "2.0.0", default-features = false, path = "../../primitives/std" } +sp-io = { version = "2.0.0", default-features = false, path = "../../primitives/io" } primitive-types = { version = "0.6", default-features = false, features = ["rlp"] } rlp = { version = "0.4", default-features = false } evm = { version = "0.14", default-features = false } diff --git a/frame/example/Cargo.toml b/frame/example/Cargo.toml index 2515604b3e..fd80d8b8df 100644 --- a/frame/example/Cargo.toml +++ b/frame/example/Cargo.toml @@ -7,15 +7,15 @@ edition = "2018" [dependencies] serde = { version = "1.0.101", optional = true } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } -frame-support = { path = "../support", default-features = false } -frame-system = { path = "../system", default-features = false } -pallet-balances = { path = "../balances", default-features = false } -sp-runtime = { path = "../../primitives/runtime", default-features = false } -sp-std = { path = "../../primitives/std", default-features = false } -sp-io = { path = "../../primitives/io", default-features = false } +frame-support = { version = "2.0.0", default-features = false, path = "../support" } +frame-system = { version = "2.0.0", default-features = false, path = "../system" } +pallet-balances = { version = "2.0.0", default-features = false, path = "../balances" } +sp-runtime = { version = "2.0.0", default-features = false, path = "../../primitives/runtime" } +sp-std = { version = "2.0.0", default-features = false, path = "../../primitives/std" } +sp-io = { version = "2.0.0", default-features = false, path = "../../primitives/io" } [dev-dependencies] -sp-core = { path = "../../primitives/core" } +sp-core = { version = "2.0.0", path = "../../primitives/core" } [features] default = ["std"] diff --git a/frame/executive/Cargo.toml b/frame/executive/Cargo.toml index de9a82643e..b58d4a6790 100644 --- a/frame/executive/Cargo.toml +++ b/frame/executive/Cargo.toml @@ -7,18 +7,18 @@ edition = "2018" [dependencies] 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 } +sp-std = { version = "2.0.0", default-features = false, path = "../../primitives/std" } sp-io ={ path = "../../primitives/io", default-features = false } -sp-runtime = { path = "../../primitives/runtime", default-features = false } -frame-support = { path = "../support", default-features = false } -frame-system = { path = "../system", default-features = false } +sp-runtime = { version = "2.0.0", default-features = false, path = "../../primitives/runtime" } +frame-support = { version = "2.0.0", default-features = false, path = "../support" } +frame-system = { version = "2.0.0", default-features = false, path = "../system" } [dev-dependencies] hex-literal = "0.2.1" -sp-core = { path = "../../primitives/core" } -pallet-indices = { path = "../indices" } -pallet-balances = { path = "../balances" } -pallet-transaction-payment = { path = "../transaction-payment" } +sp-core = { version = "2.0.0", path = "../../primitives/core" } +pallet-indices = { version = "2.0.0", path = "../indices" } +pallet-balances = { version = "2.0.0", path = "../balances" } +pallet-transaction-payment = { version = "2.0.0", path = "../transaction-payment" } [features] default = ["std"] diff --git a/frame/finality-tracker/Cargo.toml b/frame/finality-tracker/Cargo.toml index 96aef70792..22e1380e65 100644 --- a/frame/finality-tracker/Cargo.toml +++ b/frame/finality-tracker/Cargo.toml @@ -7,17 +7,17 @@ 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 } -sp-inherents = { path = "../../primitives/inherents", default-features = false } -sp-std = { path = "../../primitives/std", default-features = false } -sp-runtime = { path = "../../primitives/runtime", default-features = false } -sp-finality-tracker = { path = "../../primitives/finality-tracker", default-features = false } -frame-support = { path = "../support", default-features = false } -frame-system = { path = "../system", default-features = false } +sp-inherents = { version = "2.0.0", default-features = false, path = "../../primitives/inherents" } +sp-std = { version = "2.0.0", default-features = false, path = "../../primitives/std" } +sp-runtime = { version = "2.0.0", default-features = false, path = "../../primitives/runtime" } +sp-finality-tracker = { version = "2.0.0", default-features = false, path = "../../primitives/finality-tracker" } +frame-support = { version = "2.0.0", default-features = false, path = "../support" } +frame-system = { version = "2.0.0", default-features = false, path = "../system" } impl-trait-for-tuples = "0.1.3" [dev-dependencies] -sp-core = { path = "../../primitives/core", default-features = false } -sp-io = { path = "../../primitives/io", default-features = false } +sp-core = { version = "2.0.0", default-features = false, path = "../../primitives/core" } +sp-io = { version = "2.0.0", default-features = false, path = "../../primitives/io" } [features] default = ["std"] diff --git a/frame/generic-asset/Cargo.toml b/frame/generic-asset/Cargo.toml index fa05425d11..87f4c9d1cf 100644 --- a/frame/generic-asset/Cargo.toml +++ b/frame/generic-asset/Cargo.toml @@ -7,14 +7,14 @@ edition = "2018" [dependencies] 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 } -sp-runtime = { path = "../../primitives/runtime", default-features = false } -frame-support = { path = "../support", default-features = false } -frame-system = { path = "../system", default-features = false } +sp-std = { version = "2.0.0", default-features = false, path = "../../primitives/std" } +sp-runtime = { version = "2.0.0", default-features = false, path = "../../primitives/runtime" } +frame-support = { version = "2.0.0", default-features = false, path = "../support" } +frame-system = { version = "2.0.0", default-features = false, path = "../system" } [dev-dependencies] -sp-io ={ path = "../../primitives/io" } -sp-core = { path = "../../primitives/core" } +sp-io ={ version = "2.0.0", path = "../../primitives/io" } +sp-core = { version = "2.0.0", path = "../../primitives/core" } [features] default = ["std"] diff --git a/frame/grandpa/Cargo.toml b/frame/grandpa/Cargo.toml index bfb330fcee..ab5b34c91f 100644 --- a/frame/grandpa/Cargo.toml +++ b/frame/grandpa/Cargo.toml @@ -7,18 +7,18 @@ edition = "2018" [dependencies] serde = { version = "1.0.101", optional = true, features = ["derive"] } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-core = { path = "../../primitives/core", default-features = false } -sp-finality-grandpa = { path = "../../primitives/finality-grandpa", default-features = false } -sp-std = { path = "../../primitives/std", default-features = false } -sp-runtime = { path = "../../primitives/runtime", default-features = false } -sp-staking = { path = "../../primitives/staking", default-features = false } -frame-support = { path = "../support", default-features = false } -frame-system = { path = "../system", default-features = false } -pallet-session = { path = "../session", default-features = false } -pallet-finality-tracker = { path = "../finality-tracker", default-features = false } +sp-core = { version = "2.0.0", default-features = false, path = "../../primitives/core" } +sp-finality-grandpa = { version = "2.0.0", default-features = false, path = "../../primitives/finality-grandpa" } +sp-std = { version = "2.0.0", default-features = false, path = "../../primitives/std" } +sp-runtime = { version = "2.0.0", default-features = false, path = "../../primitives/runtime" } +sp-staking = { version = "2.0.0", default-features = false, path = "../../primitives/staking" } +frame-support = { version = "2.0.0", default-features = false, path = "../support" } +frame-system = { version = "2.0.0", default-features = false, path = "../system" } +pallet-session = { version = "2.0.0", default-features = false, path = "../session" } +pallet-finality-tracker = { version = "2.0.0", default-features = false, path = "../finality-tracker" } [dev-dependencies] -sp-io ={ path = "../../primitives/io" } +sp-io ={ version = "2.0.0", path = "../../primitives/io" } [features] default = ["std"] diff --git a/frame/identity/Cargo.toml b/frame/identity/Cargo.toml index 74979dec5d..7962c2a1c6 100644 --- a/frame/identity/Cargo.toml +++ b/frame/identity/Cargo.toml @@ -8,15 +8,15 @@ edition = "2018" 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 } -sp-io = { path = "../../primitives/io", default-features = false } -sp-runtime = { path = "../../primitives/runtime", default-features = false } -frame-support = { path = "../support", default-features = false } -frame-system = { path = "../system", default-features = false } +sp-std = { version = "2.0.0", default-features = false, path = "../../primitives/std" } +sp-io = { version = "2.0.0", default-features = false, path = "../../primitives/io" } +sp-runtime = { version = "2.0.0", default-features = false, path = "../../primitives/runtime" } +frame-support = { version = "2.0.0", default-features = false, path = "../support" } +frame-system = { version = "2.0.0", default-features = false, path = "../system" } [dev-dependencies] -sp-core = { path = "../../primitives/core" } -pallet-balances = { path = "../balances" } +sp-core = { version = "2.0.0", path = "../../primitives/core" } +pallet-balances = { version = "2.0.0", path = "../balances" } [features] default = ["std"] diff --git a/frame/im-online/Cargo.toml b/frame/im-online/Cargo.toml index 2b498c2ae9..5045509c77 100644 --- a/frame/im-online/Cargo.toml +++ b/frame/im-online/Cargo.toml @@ -1,22 +1,22 @@ [package] name = "pallet-im-online" -version = "0.1.0" +version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" [dependencies] -sp-application-crypto = { path = "../../primitives/application-crypto", default-features = false } -pallet-authorship = { path = "../authorship", default-features = false } +sp-application-crypto = { version = "2.0.0", default-features = false, path = "../../primitives/application-crypto" } +pallet-authorship = { version = "2.0.0", default-features = false, path = "../authorship" } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-core = { path = "../../primitives/core", default-features = false } -sp-std = { path = "../../primitives/std", default-features = false } +sp-core = { version = "2.0.0", default-features = false, path = "../../primitives/core" } +sp-std = { version = "2.0.0", default-features = false, path = "../../primitives/std" } serde = { version = "1.0.101", optional = true } -pallet-session = { path = "../session", default-features = false } -sp-io = { path = "../../primitives/io", default-features = false } -sp-runtime = { path = "../../primitives/runtime", default-features = false } -sp-staking = { path = "../../primitives/staking", default-features = false } -frame-support = { path = "../support", default-features = false } -frame-system = { path = "../system", default-features = false } +pallet-session = { version = "2.0.0", default-features = false, path = "../session" } +sp-io = { version = "2.0.0", default-features = false, path = "../../primitives/io" } +sp-runtime = { version = "2.0.0", default-features = false, path = "../../primitives/runtime" } +sp-staking = { version = "2.0.0", default-features = false, path = "../../primitives/staking" } +frame-support = { version = "2.0.0", default-features = false, path = "../support" } +frame-system = { version = "2.0.0", default-features = false, path = "../system" } [features] default = ["std", "pallet-session/historical"] diff --git a/frame/indices/Cargo.toml b/frame/indices/Cargo.toml index 24609622f3..574c2d3eb6 100644 --- a/frame/indices/Cargo.toml +++ b/frame/indices/Cargo.toml @@ -8,13 +8,13 @@ edition = "2018" serde = { version = "1.0.101", optional = true } 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 } -sp-io = { path = "../../primitives/io", default-features = false } -sp-runtime = { path = "../../primitives/runtime", default-features = false } -sp-core = { path = "../../primitives/core", default-features = false } -frame-support = { path = "../support", default-features = false } -frame-system = { path = "../system", default-features = false } +sp-keyring = { version = "2.0.0", optional = true, path = "../../primitives/keyring" } +sp-std = { version = "2.0.0", default-features = false, path = "../../primitives/std" } +sp-io = { version = "2.0.0", default-features = false, path = "../../primitives/io" } +sp-runtime = { version = "2.0.0", default-features = false, path = "../../primitives/runtime" } +sp-core = { version = "2.0.0", default-features = false, path = "../../primitives/core" } +frame-support = { version = "2.0.0", default-features = false, path = "../support" } +frame-system = { version = "2.0.0", default-features = false, path = "../system" } [dev-dependencies] ref_thread_local = "0.0.0" diff --git a/frame/membership/Cargo.toml b/frame/membership/Cargo.toml index c5ffc8ce81..cc45cfb94c 100644 --- a/frame/membership/Cargo.toml +++ b/frame/membership/Cargo.toml @@ -7,14 +7,14 @@ edition = "2018" [dependencies] 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 } -sp-io = { path = "../../primitives/io", default-features = false } -frame-support = { path = "../support", default-features = false } -frame-system = { path = "../system", default-features = false } -sp-runtime = { path = "../../primitives/runtime", default-features = false } +sp-std = { version = "2.0.0", default-features = false, path = "../../primitives/std" } +sp-io = { version = "2.0.0", default-features = false, path = "../../primitives/io" } +frame-support = { version = "2.0.0", default-features = false, path = "../support" } +frame-system = { version = "2.0.0", default-features = false, path = "../system" } +sp-runtime = { version = "2.0.0", default-features = false, path = "../../primitives/runtime" } [dev-dependencies] -sp-core = { path = "../../primitives/core" } +sp-core = { version = "2.0.0", path = "../../primitives/core" } [features] default = ["std"] diff --git a/frame/metadata/Cargo.toml b/frame/metadata/Cargo.toml index b29193ec20..64cf326ff6 100644 --- a/frame/metadata/Cargo.toml +++ b/frame/metadata/Cargo.toml @@ -7,8 +7,8 @@ edition = "2018" [dependencies] 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 = "../../primitives/std", default-features = false } -sp-core = { path = "../../primitives/core", default-features = false } +sp-std = { version = "2.0.0", default-features = false, path = "../../primitives/std" } +sp-core = { version = "2.0.0", default-features = false, path = "../../primitives/core" } [features] default = ["std"] diff --git a/frame/nicks/Cargo.toml b/frame/nicks/Cargo.toml index 55c1afe1b9..0dce684f0d 100644 --- a/frame/nicks/Cargo.toml +++ b/frame/nicks/Cargo.toml @@ -7,15 +7,15 @@ edition = "2018" [dependencies] 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 } -sp-io = { path = "../../primitives/io", default-features = false } -sp-runtime = { path = "../../primitives/runtime", default-features = false } -frame-support = { path = "../support", default-features = false } -frame-system = { path = "../system", default-features = false } +sp-std = { version = "2.0.0", default-features = false, path = "../../primitives/std" } +sp-io = { version = "2.0.0", default-features = false, path = "../../primitives/io" } +sp-runtime = { version = "2.0.0", default-features = false, path = "../../primitives/runtime" } +frame-support = { version = "2.0.0", default-features = false, path = "../support" } +frame-system = { version = "2.0.0", default-features = false, path = "../system" } [dev-dependencies] -sp-core = { path = "../../primitives/core" } -pallet-balances = { path = "../balances" } +sp-core = { version = "2.0.0", path = "../../primitives/core" } +pallet-balances = { version = "2.0.0", path = "../balances" } [features] default = ["std"] diff --git a/frame/offences/Cargo.toml b/frame/offences/Cargo.toml index 72e1f15c56..36d057f4e9 100644 --- a/frame/offences/Cargo.toml +++ b/frame/offences/Cargo.toml @@ -1,22 +1,22 @@ [package] name = "pallet-offences" -version = "1.0.0" +version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" [dependencies] -pallet-balances = { path = "../balances", default-features = false } +pallet-balances = { version = "2.0.0", default-features = false, path = "../balances" } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-std = { path = "../../primitives/std", default-features = false } +sp-std = { version = "2.0.0", default-features = false, path = "../../primitives/std" } serde = { version = "1.0.101", optional = true } -sp-runtime = { path = "../../primitives/runtime", default-features = false } -sp-staking = { path = "../../primitives/staking", default-features = false } -frame-support = { path = "../support", default-features = false } -frame-system = { path = "../system", default-features = false } +sp-runtime = { version = "2.0.0", default-features = false, path = "../../primitives/runtime" } +sp-staking = { version = "2.0.0", default-features = false, path = "../../primitives/staking" } +frame-support = { version = "2.0.0", default-features = false, path = "../support" } +frame-system = { version = "2.0.0", default-features = false, path = "../system" } [dev-dependencies] -sp-io = { path = "../../primitives/io" } -sp-core = { path = "../../primitives/core" } +sp-io = { version = "2.0.0", path = "../../primitives/io" } +sp-core = { version = "2.0.0", path = "../../primitives/core" } [features] default = ["std"] diff --git a/frame/randomness-collective-flip/Cargo.toml b/frame/randomness-collective-flip/Cargo.toml index 131b20c28b..9e25ba4c57 100644 --- a/frame/randomness-collective-flip/Cargo.toml +++ b/frame/randomness-collective-flip/Cargo.toml @@ -7,14 +7,14 @@ edition = "2018" [dependencies] safe-mix = { version = "1.0", default-features = false } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-runtime = { path = "../../primitives/runtime", default-features = false } -frame-support = { path = "../support", default-features = false } -frame-system = { path = "../system", default-features = false } -sp-std = { path = "../../primitives/std", default-features = false } +sp-runtime = { version = "2.0.0", default-features = false, path = "../../primitives/runtime" } +frame-support = { version = "2.0.0", default-features = false, path = "../support" } +frame-system = { version = "2.0.0", default-features = false, path = "../system" } +sp-std = { version = "2.0.0", default-features = false, path = "../../primitives/std" } [dev-dependencies] -sp-core = { path = "../../primitives/core" } -sp-io = { path = "../../primitives/io" } +sp-core = { version = "2.0.0", path = "../../primitives/core" } +sp-io = { version = "2.0.0", path = "../../primitives/io" } [features] default = ["std"] diff --git a/frame/scored-pool/Cargo.toml b/frame/scored-pool/Cargo.toml index ebc5417659..0b4c2768df 100644 --- a/frame/scored-pool/Cargo.toml +++ b/frame/scored-pool/Cargo.toml @@ -1,21 +1,21 @@ [package] name = "pallet-scored-pool" -version = "1.0.0" +version = "2.0.0" authors = ["Parity Technologies "] edition = "2018" [dependencies] codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } serde = { version = "1.0.101", optional = true } -sp-io = { path = "../../primitives/io", default-features = false } -sp-runtime = { path = "../../primitives/runtime", default-features = false } -sp-std = { path = "../../primitives/std", default-features = false } -frame-support = { path = "../support", default-features = false } -frame-system = { path = "../system", default-features = false } +sp-io = { version = "2.0.0", default-features = false, path = "../../primitives/io" } +sp-runtime = { version = "2.0.0", default-features = false, path = "../../primitives/runtime" } +sp-std = { version = "2.0.0", default-features = false, path = "../../primitives/std" } +frame-support = { version = "2.0.0", default-features = false, path = "../support" } +frame-system = { version = "2.0.0", default-features = false, path = "../system" } [dev-dependencies] -pallet-balances = { path = "../balances" } -sp-core = { path = "../../primitives/core" } +pallet-balances = { version = "2.0.0", path = "../balances" } +sp-core = { version = "2.0.0", path = "../../primitives/core" } [features] default = ["std"] diff --git a/frame/session/Cargo.toml b/frame/session/Cargo.toml index d82b8ef144..82047dbd68 100644 --- a/frame/session/Cargo.toml +++ b/frame/session/Cargo.toml @@ -8,19 +8,19 @@ edition = "2018" serde = { version = "1.0.101", optional = true } 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 } -sp-runtime = { path = "../../primitives/runtime", default-features = false } -sp-staking = { path = "../../primitives/staking", default-features = false } -frame-support = { path = "../support", default-features = false } -frame-system = { path = "../system", default-features = false } -pallet-timestamp = { path = "../timestamp", default-features = false } -sp-trie = { path = "../../primitives/trie", default-features = false, optional = true } +sp-std = { version = "2.0.0", default-features = false, path = "../../primitives/std" } +sp-runtime = { version = "2.0.0", default-features = false, path = "../../primitives/runtime" } +sp-staking = { version = "2.0.0", default-features = false, path = "../../primitives/staking" } +frame-support = { version = "2.0.0", default-features = false, path = "../support" } +frame-system = { version = "2.0.0", default-features = false, path = "../system" } +pallet-timestamp = { version = "2.0.0", default-features = false, path = "../timestamp" } +sp-trie = { optional = true, path = "../../primitives/trie", default-features = false } sp-io ={ path = "../../primitives/io", default-features = false } impl-trait-for-tuples = "0.1.3" [dev-dependencies] -sp-core = { path = "../../primitives/core" } -sp-application-crypto = { path = "../../primitives/application-crypto" } +sp-core = { version = "2.0.0", path = "../../primitives/core" } +sp-application-crypto = { version = "2.0.0", path = "../../primitives/application-crypto" } lazy_static = "1.4.0" [features] diff --git a/frame/staking/Cargo.toml b/frame/staking/Cargo.toml index 878acdbce6..8cf6d9f80e 100644 --- a/frame/staking/Cargo.toml +++ b/frame/staking/Cargo.toml @@ -8,23 +8,23 @@ edition = "2018" serde = { version = "1.0.101", optional = true } 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 } -sp-phragmen = { path = "../../primitives/phragmen", default-features = false } +sp-keyring = { version = "2.0.0", optional = true, path = "../../primitives/keyring" } +sp-std = { version = "2.0.0", default-features = false, path = "../../primitives/std" } +sp-phragmen = { version = "2.0.0", default-features = false, path = "../../primitives/phragmen" } sp-io ={ path = "../../primitives/io", default-features = false } -sp-runtime = { path = "../../primitives/runtime", default-features = false } -sp-staking = { path = "../../primitives/staking", default-features = false } -frame-support = { path = "../support", default-features = false } -frame-system = { path = "../system", default-features = false } -pallet-session = { path = "../session", default-features = false, features = ["historical"] } -pallet-authorship = { path = "../authorship", default-features = false } +sp-runtime = { version = "2.0.0", default-features = false, path = "../../primitives/runtime" } +sp-staking = { version = "2.0.0", default-features = false, path = "../../primitives/staking" } +frame-support = { version = "2.0.0", default-features = false, path = "../support" } +frame-system = { version = "2.0.0", default-features = false, path = "../system" } +pallet-session = { version = "2.0.0", features = ["historical"], path = "../session", default-features = false } +pallet-authorship = { version = "2.0.0", default-features = false, path = "../authorship" } [dev-dependencies] -sp-core = { path = "../../primitives/core" } -pallet-balances = { path = "../balances" } -pallet-timestamp = { path = "../timestamp" } -pallet-staking-reward-curve = { path = "../staking/reward-curve"} -substrate-test-utils = { path = "../../test-utils" } +sp-core = { version = "2.0.0", path = "../../primitives/core" } +pallet-balances = { version = "2.0.0", path = "../balances" } +pallet-timestamp = { version = "2.0.0", path = "../timestamp" } +pallet-staking-reward-curve = { version = "2.0.0", path = "../staking/reward-curve" } +substrate-test-utils = { version = "2.0.0", path = "../../test-utils" } [features] equalize = [] diff --git a/frame/staking/reward-curve/Cargo.toml b/frame/staking/reward-curve/Cargo.toml index 530b11f2c3..0353476a95 100644 --- a/frame/staking/reward-curve/Cargo.toml +++ b/frame/staking/reward-curve/Cargo.toml @@ -14,4 +14,4 @@ proc-macro2 = "1.0.6" proc-macro-crate = "0.1.4" [dev-dependencies] -sp-runtime = { path = "../../../primitives/runtime" } +sp-runtime = { version = "2.0.0", path = "../../../primitives/runtime" } diff --git a/frame/sudo/Cargo.toml b/frame/sudo/Cargo.toml index 733e9a7084..c97d04f9c7 100644 --- a/frame/sudo/Cargo.toml +++ b/frame/sudo/Cargo.toml @@ -7,14 +7,14 @@ edition = "2018" [dependencies] 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 } -sp-io = { path = "../../primitives/io", default-features = false } -sp-runtime = { path = "../../primitives/runtime", default-features = false } -frame-support = { path = "../support", default-features = false } -frame-system = { path = "../system", default-features = false } +sp-std = { version = "2.0.0", default-features = false, path = "../../primitives/std" } +sp-io = { version = "2.0.0", default-features = false, path = "../../primitives/io" } +sp-runtime = { version = "2.0.0", default-features = false, path = "../../primitives/runtime" } +frame-support = { version = "2.0.0", default-features = false, path = "../support" } +frame-system = { version = "2.0.0", default-features = false, path = "../system" } [dev-dependencies] -sp-core = { path = "../../primitives/core" } +sp-core = { version = "2.0.0", path = "../../primitives/core" } [features] default = ["std"] diff --git a/frame/support/Cargo.toml b/frame/support/Cargo.toml index ad04964b12..1695375d36 100644 --- a/frame/support/Cargo.toml +++ b/frame/support/Cargo.toml @@ -8,24 +8,24 @@ edition = "2018" log = "0.4" 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 } +frame-metadata = { version = "2.0.0", default-features = false, path = "../metadata" } +sp-std = { version = "2.0.0", default-features = false, path = "../../primitives/std" } sp-io ={ path = "../../primitives/io", default-features = false } -sp-runtime = { path = "../../primitives/runtime", default-features = false } -sp-core = { path = "../../primitives/core", default-features = false } -sp-arithmetic = { path = "../../primitives/arithmetic", default-features = false } -sp-inherents = { path = "../../primitives/inherents", default-features = false } -frame-support-procedural = { path = "./procedural" } +sp-runtime = { version = "2.0.0", default-features = false, path = "../../primitives/runtime" } +sp-core = { version = "2.0.0", default-features = false, path = "../../primitives/core" } +sp-arithmetic = { version = "2.0.0", default-features = false, path = "../../primitives/arithmetic" } +sp-inherents = { version = "2.0.0", default-features = false, path = "../../primitives/inherents" } +frame-support-procedural = { version = "2.0.0", path = "./procedural" } paste = "0.1.6" once_cell = { version = "0.2.4", default-features = false, optional = true } -sp-state-machine = { path = "../../primitives/state-machine", optional = true } +sp-state-machine = { version = "2.0.0", optional = true, path = "../../primitives/state-machine" } bitmask = { version = "0.5.0", default-features = false } impl-trait-for-tuples = "0.1.3" tracing = { version = "0.1.10", optional = true } [dev-dependencies] pretty_assertions = "0.6.1" -frame-system = { path = "../system" } +frame-system = { version = "2.0.0", path = "../system" } [features] default = ["std"] diff --git a/frame/support/procedural/Cargo.toml b/frame/support/procedural/Cargo.toml index 220aea5028..9280289028 100644 --- a/frame/support/procedural/Cargo.toml +++ b/frame/support/procedural/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" proc-macro = true [dependencies] -frame-support-procedural-tools = { path = "./tools" } +frame-support-procedural-tools = { version = "2.0.0", path = "./tools" } proc-macro2 = "1.0.6" quote = "1.0.2" diff --git a/frame/support/procedural/tools/Cargo.toml b/frame/support/procedural/tools/Cargo.toml index 00ac787c57..a9b8f6d4bf 100644 --- a/frame/support/procedural/tools/Cargo.toml +++ b/frame/support/procedural/tools/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -frame-support-procedural-tools-derive = { path = "./derive" } +frame-support-procedural-tools-derive = { version = "2.0.0", path = "./derive" } proc-macro2 = "1.0.6" quote = "1.0.2" syn = { version = "1.0.7", features = ["full", "visit"] } diff --git a/frame/support/test/Cargo.toml b/frame/support/test/Cargo.toml index 8637a582bf..92dc32e478 100644 --- a/frame/support/test/Cargo.toml +++ b/frame/support/test/Cargo.toml @@ -8,11 +8,11 @@ edition = "2018" serde = { version = "1.0.101", default-features = false, features = ["derive"] } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } sp-io ={ path = "../../../primitives/io", default-features = false } -sp-state-machine = { path = "../../../primitives/state-machine", optional = true } -frame-support = { version = "2", path = "../", default-features = false } -sp-inherents = { path = "../../../primitives/inherents", default-features = false } -sp-runtime = { path = "../../../primitives/runtime", default-features = false } -sp-core = { path = "../../../primitives/core", default-features = false } +sp-state-machine = { version = "2.0.0", optional = true, path = "../../../primitives/state-machine" } +frame-support = { version = "2.0.0", default-features = false, path = "../" } +sp-inherents = { version = "2.0.0", default-features = false, path = "../../../primitives/inherents" } +sp-runtime = { version = "2.0.0", default-features = false, path = "../../../primitives/runtime" } +sp-core = { version = "2.0.0", default-features = false, path = "../../../primitives/core" } trybuild = "1.0.17" pretty_assertions = "0.6.1" diff --git a/frame/system/Cargo.toml b/frame/system/Cargo.toml index 1bd0f60d51..227aecee2e 100644 --- a/frame/system/Cargo.toml +++ b/frame/system/Cargo.toml @@ -8,12 +8,12 @@ edition = "2018" 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-core = { path = "../../primitives/core", default-features = false } -sp-std = { path = "../../primitives/std", default-features = false } +sp-core = { version = "2.0.0", default-features = false, path = "../../primitives/core" } +sp-std = { version = "2.0.0", default-features = false, path = "../../primitives/std" } sp-io ={ path = "../../primitives/io", default-features = false } -sp-runtime = { path = "../../primitives/runtime", default-features = false } -sp-version = { path = "../../primitives/version", default-features = false } -frame-support = { path = "../support", default-features = false } +sp-runtime = { version = "2.0.0", default-features = false, path = "../../primitives/runtime" } +sp-version = { version = "2.0.0", default-features = false, path = "../../primitives/version" } +frame-support = { version = "2.0.0", default-features = false, path = "../support" } impl-trait-for-tuples = "0.1.3" [dev-dependencies] diff --git a/frame/system/rpc/runtime-api/Cargo.toml b/frame/system/rpc/runtime-api/Cargo.toml index dfe18b11c2..f9beb848aa 100644 --- a/frame/system/rpc/runtime-api/Cargo.toml +++ b/frame/system/rpc/runtime-api/Cargo.toml @@ -5,8 +5,8 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -sp-api = { path = "../../../../primitives/api", default-features = false } -codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } +sp-api = { version = "2.0.0", default-features = false, path = "../../../../primitives/api" } +codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } [features] default = ["std"] diff --git a/frame/timestamp/Cargo.toml b/frame/timestamp/Cargo.toml index 675efe37b0..354a4740b7 100644 --- a/frame/timestamp/Cargo.toml +++ b/frame/timestamp/Cargo.toml @@ -7,17 +7,17 @@ edition = "2018" [dependencies] 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 } -sp-runtime = { path = "../../primitives/runtime", default-features = false } -sp-inherents = { path = "../../primitives/inherents", default-features = false } -frame-support = { path = "../support", default-features = false } -frame-system = { path = "../system", default-features = false } -sp-timestamp = { path = "../../primitives/timestamp", default-features = false } +sp-std = { version = "2.0.0", default-features = false, path = "../../primitives/std" } +sp-runtime = { version = "2.0.0", default-features = false, path = "../../primitives/runtime" } +sp-inherents = { version = "2.0.0", default-features = false, path = "../../primitives/inherents" } +frame-support = { version = "2.0.0", default-features = false, path = "../support" } +frame-system = { version = "2.0.0", default-features = false, path = "../system" } +sp-timestamp = { version = "2.0.0", default-features = false, path = "../../primitives/timestamp" } impl-trait-for-tuples = "0.1.3" [dev-dependencies] -sp-io ={ path = "../../primitives/io" } -sp-core = { path = "../../primitives/core" } +sp-io ={ version = "2.0.0", path = "../../primitives/io" } +sp-core = { version = "2.0.0", path = "../../primitives/core" } [features] default = ["std"] diff --git a/frame/transaction-payment/Cargo.toml b/frame/transaction-payment/Cargo.toml index 379dfc8d65..ceb1ba9ebb 100644 --- a/frame/transaction-payment/Cargo.toml +++ b/frame/transaction-payment/Cargo.toml @@ -6,16 +6,16 @@ edition = "2018" [dependencies] codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-std = { path = "../../primitives/std", default-features = false } -sp-runtime = { path = "../../primitives/runtime", default-features = false } -frame-support = { path = "../support", default-features = false } -frame-system = { path = "../system", default-features = false } -pallet-transaction-payment-rpc-runtime-api = { path = "./rpc/runtime-api", default-features = false } +sp-std = { version = "2.0.0", default-features = false, path = "../../primitives/std" } +sp-runtime = { version = "2.0.0", default-features = false, path = "../../primitives/runtime" } +frame-support = { version = "2.0.0", default-features = false, path = "../support" } +frame-system = { version = "2.0.0", default-features = false, path = "../system" } +pallet-transaction-payment-rpc-runtime-api = { version = "2.0.0", default-features = false, path = "./rpc/runtime-api" } [dev-dependencies] -sp-io = { path = "../../primitives/io" } -sp-core = { path = "../../primitives/core" } -pallet-balances = { path = "../balances" } +sp-io = { version = "2.0.0", path = "../../primitives/io" } +sp-core = { version = "2.0.0", path = "../../primitives/core" } +pallet-balances = { version = "2.0.0", path = "../balances" } [features] default = ["std"] diff --git a/frame/transaction-payment/rpc/Cargo.toml b/frame/transaction-payment/rpc/Cargo.toml index 087333e80e..f7e886fd0d 100644 --- a/frame/transaction-payment/rpc/Cargo.toml +++ b/frame/transaction-payment/rpc/Cargo.toml @@ -9,9 +9,9 @@ codec = { package = "parity-scale-codec", version = "1.0.0" } jsonrpc-core = "14.0.3" jsonrpc-core-client = "14.0.3" jsonrpc-derive = "14.0.3" -sp-core = { path = "../../../primitives/core" } -sp-rpc = { path = "../../../primitives/rpc" } +sp-core = { version = "2.0.0", path = "../../../primitives/core" } +sp-rpc = { version = "2.0.0", path = "../../../primitives/rpc" } serde = { version = "1.0.101", features = ["derive"] } -sp-runtime = { path = "../../../primitives/runtime" } -sp-blockchain = { path = "../../../primitives/blockchain" } -pallet-transaction-payment-rpc-runtime-api = { path = "./runtime-api" } +sp-runtime = { version = "2.0.0", path = "../../../primitives/runtime" } +sp-blockchain = { version = "2.0.0", path = "../../../primitives/blockchain" } +pallet-transaction-payment-rpc-runtime-api = { version = "2.0.0", path = "./runtime-api" } diff --git a/frame/transaction-payment/rpc/runtime-api/Cargo.toml b/frame/transaction-payment/rpc/runtime-api/Cargo.toml index b5f8c8e876..3cf28bf662 100644 --- a/frame/transaction-payment/rpc/runtime-api/Cargo.toml +++ b/frame/transaction-payment/rpc/runtime-api/Cargo.toml @@ -6,11 +6,11 @@ edition = "2018" [dependencies] serde = { version = "1.0.101", optional = true, features = ["derive"] } -sp-api = { path = "../../../../primitives/api", default-features = false } +sp-api = { version = "2.0.0", default-features = false, path = "../../../../primitives/api" } codec = { package = "parity-scale-codec", version = "1.0.6", default-features = false, features = ["derive"] } -sp-std = { path = "../../../../primitives/std", default-features = false } -sp-runtime = { path = "../../../../primitives/runtime", default-features = false } -frame-support = { path = "../../../support", default-features = false } +sp-std = { version = "2.0.0", default-features = false, path = "../../../../primitives/std" } +sp-runtime = { version = "2.0.0", default-features = false, path = "../../../../primitives/runtime" } +frame-support = { version = "2.0.0", default-features = false, path = "../../../support" } [dev-dependencies] serde_json = "1.0.41" diff --git a/frame/treasury/Cargo.toml b/frame/treasury/Cargo.toml index bd79b4d038..9fd76ddd9c 100644 --- a/frame/treasury/Cargo.toml +++ b/frame/treasury/Cargo.toml @@ -7,15 +7,15 @@ edition = "2018" [dependencies] serde = { version = "1.0.101", optional = true, features = ["derive"] } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-std = { path = "../../primitives/std", default-features = false } -sp-runtime = { path = "../../primitives/runtime", default-features = false } -frame-support = { path = "../support", default-features = false } -frame-system = { path = "../system", default-features = false } -pallet-balances = { path = "../balances", default-features = false } +sp-std = { version = "2.0.0", default-features = false, path = "../../primitives/std" } +sp-runtime = { version = "2.0.0", default-features = false, path = "../../primitives/runtime" } +frame-support = { version = "2.0.0", default-features = false, path = "../support" } +frame-system = { version = "2.0.0", default-features = false, path = "../system" } +pallet-balances = { version = "2.0.0", default-features = false, path = "../balances" } [dev-dependencies] -sp-io ={ path = "../../primitives/io" } -sp-core = { path = "../../primitives/core" } +sp-io ={ version = "2.0.0", path = "../../primitives/io" } +sp-core = { version = "2.0.0", path = "../../primitives/core" } [features] default = ["std"] diff --git a/frame/utility/Cargo.toml b/frame/utility/Cargo.toml index e35927bc62..f74e059e36 100644 --- a/frame/utility/Cargo.toml +++ b/frame/utility/Cargo.toml @@ -7,15 +7,15 @@ edition = "2018" [dependencies] serde = { version = "1.0.101", optional = true } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } -frame-support = { path = "../support", default-features = false } -frame-system = { path = "../system", default-features = false } -sp-runtime = { path = "../../primitives/runtime", default-features = false } -sp-std = { path = "../../primitives/std", default-features = false } -sp-io = { path = "../../primitives/io", default-features = false } +frame-support = { version = "2.0.0", default-features = false, path = "../support" } +frame-system = { version = "2.0.0", default-features = false, path = "../system" } +sp-runtime = { version = "2.0.0", default-features = false, path = "../../primitives/runtime" } +sp-std = { version = "2.0.0", default-features = false, path = "../../primitives/std" } +sp-io = { version = "2.0.0", default-features = false, path = "../../primitives/io" } [dev-dependencies] -sp-core = { path = "../../primitives/core" } -pallet-balances = { path = "../balances" } +sp-core = { version = "2.0.0", path = "../../primitives/core" } +pallet-balances = { version = "2.0.0", path = "../balances" } [features] default = ["std"] diff --git a/primitives/api/Cargo.toml b/primitives/api/Cargo.toml index 0b3a1f2cf9..5085e8faf3 100644 --- a/primitives/api/Cargo.toml +++ b/primitives/api/Cargo.toml @@ -6,15 +6,15 @@ edition = "2018" [dependencies] codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } -sp-api-proc-macro = { path = "proc-macro" } -sp-core = { path = "../core", default-features = false } -sp-std = { path = "../std", default-features = false } -sp-runtime = { path = "../runtime", default-features = false } -sp-version = { path = "../version", default-features = false } -sp-state-machine = { path = "../../primitives/state-machine", optional = true } +sp-api-proc-macro = { version = "2.0.0", path = "proc-macro" } +sp-core = { version = "2.0.0", default-features = false, path = "../core" } +sp-std = { version = "2.0.0", default-features = false, path = "../std" } +sp-runtime = { version = "2.0.0", default-features = false, path = "../runtime" } +sp-version = { version = "2.0.0", default-features = false, path = "../version" } +sp-state-machine = { version = "2.0.0", optional = true, path = "../../primitives/state-machine" } [dev-dependencies] -sp-test-primitives = { path = "../test-primitives" } +sp-test-primitives = { version = "2.0.0", path = "../test-primitives" } [features] default = [ "std" ] diff --git a/primitives/api/test/Cargo.toml b/primitives/api/test/Cargo.toml index 8fdfcc98f1..f1f0dfb50f 100644 --- a/primitives/api/test/Cargo.toml +++ b/primitives/api/test/Cargo.toml @@ -5,20 +5,20 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -sp-api = { path = "../" } -substrate-test-runtime-client = { path = "../../../test-utils/runtime/client" } -sp-version = { path = "../../version" } -sp-runtime = { path = "../../runtime" } -sp-blockchain = { path = "../../blockchain" } -sp-consensus = { path = "../../../primitives/consensus/common" } +sp-api = { version = "2.0.0", path = "../" } +substrate-test-runtime-client = { version = "2.0.0", path = "../../../test-utils/runtime/client" } +sp-version = { version = "2.0.0", path = "../../version" } +sp-runtime = { version = "2.0.0", path = "../../runtime" } +sp-blockchain = { version = "2.0.0", path = "../../blockchain" } +sp-consensus = { version = "0.8", path = "../../../primitives/consensus/common" } codec = { package = "parity-scale-codec", version = "1.0.0" } -sp-state-machine = { path = "../../../primitives/state-machine" } +sp-state-machine = { version = "2.0.0", path = "../../../primitives/state-machine" } trybuild = "1.0.17" rustversion = "1.0.0" [dev-dependencies] criterion = "0.3.0" -substrate-test-runtime-client = { path = "../../../test-utils/runtime/client" } +substrate-test-runtime-client = { version = "2.0.0", path = "../../../test-utils/runtime/client" } [[bench]] name = "bench" diff --git a/primitives/application-crypto/Cargo.toml b/primitives/application-crypto/Cargo.toml index 549c0a5891..f6487ebc29 100644 --- a/primitives/application-crypto/Cargo.toml +++ b/primitives/application-crypto/Cargo.toml @@ -6,11 +6,11 @@ edition = "2018" description = "Provides facilities for generating application specific crypto wrapper types." [dependencies] -sp-core = { path = "../core", default-features = false } +sp-core = { version = "2.0.0", default-features = false, path = "../core" } 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 } -sp-io = { path = "../../primitives/io", default-features = false } +sp-std = { version = "2.0.0", default-features = false, path = "../std" } +sp-io = { version = "2.0.0", default-features = false, path = "../../primitives/io" } [features] default = [ "std" ] diff --git a/primitives/application-crypto/test/Cargo.toml b/primitives/application-crypto/test/Cargo.toml index 85cb5d1163..dabdc1d6e9 100644 --- a/primitives/application-crypto/test/Cargo.toml +++ b/primitives/application-crypto/test/Cargo.toml @@ -7,7 +7,7 @@ description = "Integration tests for application-crypto" publish = false [dependencies] -sp-core = { path = "../../core", default-features = false } -substrate-test-runtime-client = { path = "../../../test-utils/runtime/client" } -sp-runtime = { path = "../../runtime" } -sp-application-crypto = { path = "../" } +sp-core = { version = "2.0.0", default-features = false, path = "../../core" } +substrate-test-runtime-client = { version = "2.0.0", path = "../../../test-utils/runtime/client" } +sp-runtime = { version = "2.0.0", path = "../../runtime" } +sp-application-crypto = { version = "2.0.0", path = "../" } diff --git a/primitives/arithmetic/Cargo.toml b/primitives/arithmetic/Cargo.toml index bc7fd42019..71be14862a 100644 --- a/primitives/arithmetic/Cargo.toml +++ b/primitives/arithmetic/Cargo.toml @@ -8,9 +8,9 @@ edition = "2018" codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } integer-sqrt = "0.1.2" num-traits = { version = "0.2.8", default-features = false } -sp-std = { path = "../std", default-features = false } +sp-std = { version = "2.0.0", default-features = false, path = "../std" } serde = { version = "1.0.101", optional = true, features = ["derive"] } -sp-debug-derive = { path = "../../primitives/debug-derive", default-features = false } +sp-debug-derive = { version = "2.0.0", default-features = false, path = "../../primitives/debug-derive" } [dev-dependencies] primitive-types = "0.6.0" diff --git a/primitives/arithmetic/fuzzer/Cargo.toml b/primitives/arithmetic/fuzzer/Cargo.toml index 6784349394..e8568db370 100644 --- a/primitives/arithmetic/fuzzer/Cargo.toml +++ b/primitives/arithmetic/fuzzer/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -sp-arithmetic = { path = ".." } +sp-arithmetic = { version = "2.0.0", path = ".." } honggfuzz = "0.5" primitive-types = "0.6" num-bigint = "0.2" diff --git a/primitives/authority-discovery/Cargo.toml b/primitives/authority-discovery/Cargo.toml index 241891a48b..516ea413ac 100644 --- a/primitives/authority-discovery/Cargo.toml +++ b/primitives/authority-discovery/Cargo.toml @@ -6,11 +6,11 @@ description = "Authority discovery primitives" edition = "2018" [dependencies] -sp-application-crypto = { path = "../application-crypto", default-features = false } +sp-application-crypto = { version = "2.0.0", default-features = false, path = "../application-crypto" } codec = { package = "parity-scale-codec", default-features = false, version = "1.0.3" } -sp-std = { path = "../std", default-features = false } -sp-api = { path = "../api", default-features = false } -sp-runtime = { path = "../runtime", default-features = false } +sp-std = { version = "2.0.0", default-features = false, path = "../std" } +sp-api = { version = "2.0.0", default-features = false, path = "../api" } +sp-runtime = { version = "2.0.0", default-features = false, path = "../runtime" } [features] default = ["std"] diff --git a/primitives/authorship/Cargo.toml b/primitives/authorship/Cargo.toml index f996a75aae..d8ddbb7a92 100644 --- a/primitives/authorship/Cargo.toml +++ b/primitives/authorship/Cargo.toml @@ -6,9 +6,9 @@ description = "Authorship primitives" edition = "2018" [dependencies] -sp-inherents = { path = "../inherents", default-features = false } -sp-runtime = { path = "../runtime", default-features = false } -sp-std = { path = "../std", default-features = false } +sp-inherents = { version = "2.0.0", default-features = false, path = "../inherents" } +sp-runtime = { version = "2.0.0", default-features = false, path = "../runtime" } +sp-std = { version = "2.0.0", default-features = false, path = "../std" } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } [features] diff --git a/primitives/block-builder/Cargo.toml b/primitives/block-builder/Cargo.toml index 41bedb2fa5..5bbe9ea123 100644 --- a/primitives/block-builder/Cargo.toml +++ b/primitives/block-builder/Cargo.toml @@ -5,11 +5,11 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -sp-runtime = { path = "../runtime", default-features = false } -sp-api = { path = "../api", default-features = false } -sp-std = { path = "../std", default-features = false } +sp-runtime = { version = "2.0.0", default-features = false, path = "../runtime" } +sp-api = { version = "2.0.0", default-features = false, path = "../api" } +sp-std = { version = "2.0.0", default-features = false, path = "../std" } codec = { package = "parity-scale-codec", version = "1.0.6", default-features = false } -sp-inherents = { path = "../inherents", default-features = false } +sp-inherents = { version = "2.0.0", default-features = false, path = "../inherents" } [features] default = [ "std" ] diff --git a/primitives/blockchain/Cargo.toml b/primitives/blockchain/Cargo.toml index 9326ad6e0b..4f3f0d0b5f 100644 --- a/primitives/blockchain/Cargo.toml +++ b/primitives/blockchain/Cargo.toml @@ -10,7 +10,7 @@ lru = "0.4.0" parking_lot = "0.9.0" derive_more = "0.99.2" codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-consensus = { path = "../consensus/common" } -sp-runtime = { path = "../runtime" } -sp-block-builder = { path = "../block-builder" } -sp-state-machine = { path = "../state-machine" } +sp-consensus = { version = "0.8", path = "../consensus/common" } +sp-runtime = { version = "2.0.0", path = "../runtime" } +sp-block-builder = { version = "2.0.0", path = "../block-builder" } +sp-state-machine = { version = "2.0.0", path = "../state-machine" } diff --git a/primitives/consensus/aura/Cargo.toml b/primitives/consensus/aura/Cargo.toml index c84a943779..57958ed851 100644 --- a/primitives/consensus/aura/Cargo.toml +++ b/primitives/consensus/aura/Cargo.toml @@ -1,18 +1,18 @@ [package] name = "sp-consensus-aura" -version = "2.0.0" +version = "0.8.0" authors = ["Parity Technologies "] description = "Primitives for Aura consensus" edition = "2018" [dependencies] -sp-application-crypto = { path = "../../application-crypto", default-features = false } +sp-application-crypto = { version = "2.0.0", default-features = false, path = "../../application-crypto" } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } -sp-std = { path = "../../std", default-features = false } -sp-api = { path = "../../api", default-features = false } -sp-runtime = { path = "../../runtime", default-features = false } -sp-inherents = { path = "../../inherents", default-features = false } -sp-timestamp = { path = "../../timestamp", default-features = false } +sp-std = { version = "2.0.0", default-features = false, path = "../../std" } +sp-api = { version = "2.0.0", default-features = false, path = "../../api" } +sp-runtime = { version = "2.0.0", default-features = false, path = "../../runtime" } +sp-inherents = { version = "2.0.0", default-features = false, path = "../../inherents" } +sp-timestamp = { version = "2.0.0", default-features = false, path = "../../timestamp" } [features] default = ["std"] diff --git a/primitives/consensus/babe/Cargo.toml b/primitives/consensus/babe/Cargo.toml index f994c69671..11c186faa9 100644 --- a/primitives/consensus/babe/Cargo.toml +++ b/primitives/consensus/babe/Cargo.toml @@ -1,20 +1,20 @@ [package] name = "sp-consensus-babe" -version = "2.0.0" +version = "0.8.0" authors = ["Parity Technologies "] description = "Primitives for BABE consensus" edition = "2018" [dependencies] -sp-application-crypto = { path = "../../application-crypto", default-features = false } +sp-application-crypto = { version = "2.0.0", default-features = false, path = "../../application-crypto" } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } -sp-std = { path = "../../std", default-features = false } +sp-std = { version = "2.0.0", default-features = false, path = "../../std" } schnorrkel = { version = "0.8.5", features = ["preaudit_deprecated"], optional = true } -sp-api = { path = "../../api", default-features = false } -sp-consensus = { path = "../common", optional = true } -sp-inherents = { path = "../../inherents", default-features = false } -sp-runtime = { path = "../../runtime", default-features = false } -sp-timestamp = { path = "../../timestamp", default-features = false } +sp-api = { version = "2.0.0", default-features = false, path = "../../api" } +sp-consensus = { version = "0.8", optional = true, path = "../common" } +sp-inherents = { version = "2.0.0", default-features = false, path = "../../inherents" } +sp-runtime = { version = "2.0.0", default-features = false, path = "../../runtime" } +sp-timestamp = { version = "2.0.0", default-features = false, path = "../../timestamp" } [features] default = ["std"] diff --git a/primitives/consensus/common/Cargo.toml b/primitives/consensus/common/Cargo.toml index 9fde4e3df9..768552a8ed 100644 --- a/primitives/consensus/common/Cargo.toml +++ b/primitives/consensus/common/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sp-consensus" -version = "2.0.0" +version = "0.8.0" authors = ["Parity Technologies "] description = "Common utilities for substrate consensus" edition = "2018" @@ -10,17 +10,17 @@ derive_more = "0.99.2" libp2p = { version = "0.13.0", default-features = false } log = "0.4.8" sp-core = { path= "../../core" } -sp-inherents = { path = "../../inherents" } +sp-inherents = { version = "2.0.0", path = "../../inherents" } futures = { version = "0.3.1", features = ["thread-pool"] } futures-timer = "0.4.0" -sp-std = { path = "../../std" } -sp-version = { path = "../../version" } -sp-runtime = { path = "../../runtime" } +sp-std = { version = "2.0.0", path = "../../std" } +sp-version = { version = "2.0.0", path = "../../version" } +sp-runtime = { version = "2.0.0", path = "../../runtime" } codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } parking_lot = "0.9.0" [dev-dependencies] -sp-test-primitives = { path = "../../test-primitives" } +sp-test-primitives = { version = "2.0.0", path = "../../test-primitives" } [features] default = [] diff --git a/primitives/consensus/pow/Cargo.toml b/primitives/consensus/pow/Cargo.toml index 73efe40ec5..12e97890d7 100644 --- a/primitives/consensus/pow/Cargo.toml +++ b/primitives/consensus/pow/Cargo.toml @@ -1,15 +1,15 @@ [package] name = "sp-consensus-pow" -version = "2.0.0" +version = "0.8.0" authors = ["Parity Technologies "] description = "Primitives for Aura consensus" edition = "2018" [dependencies] -sp-api = { path = "../../api", default-features = false } -sp-std = { path = "../../std", default-features = false } -sp-runtime = { path = "../../runtime", default-features = false } -sp-core = { path = "../../core", default-features = false } +sp-api = { version = "2.0.0", default-features = false, path = "../../api" } +sp-std = { version = "2.0.0", default-features = false, path = "../../std" } +sp-runtime = { version = "2.0.0", default-features = false, path = "../../runtime" } +sp-core = { version = "2.0.0", default-features = false, path = "../../core" } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } [features] diff --git a/primitives/core/Cargo.toml b/primitives/core/Cargo.toml index d9e4619fa1..706a9cb276 100644 --- a/primitives/core/Cargo.toml +++ b/primitives/core/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -sp-std = { path = "../std", default-features = false } +sp-std = { version = "2.0.0", default-features = false, path = "../std" } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } rustc-hex = { version = "2.0.1", default-features = false } log = { version = "0.4.8", default-features = false } @@ -26,8 +26,8 @@ zeroize = { version = "1.0.0", default-features = false } lazy_static = { version = "1.4.0", default-features = false, optional = true } parking_lot = { version = "0.9.0", optional = true } sp-debug-derive = { version = "2.0.0", path = "../debug-derive" } -sp-externalities = { path = "../externalities", optional = true } -sp-storage = { path = "../storage", default-features = false } +sp-externalities = { version = "2.0.0", optional = true, path = "../externalities" } +sp-storage = { version = "2.0.0", default-features = false, path = "../storage" } # full crypto ed25519-dalek = { version = "1.0.0-pre.3", default-features = false, features = ["u64_backend", "alloc"], optional = true } @@ -39,10 +39,10 @@ sha2 = { version = "0.8.0", default-features = false, optional = true } hex = { version = "0.4", default-features = false, optional = true } twox-hash = { version = "1.5.0", default-features = false, optional = true } -sp-runtime-interface = { path = "../runtime-interface", default-features = false } +sp-runtime-interface = { version = "2.0.0", default-features = false, path = "../runtime-interface" } [dev-dependencies] -sp-serializer = { path = "../serializer" } +sp-serializer = { version = "2.0.0", path = "../serializer" } pretty_assertions = "0.6.1" hex-literal = "0.2.1" rand = "0.7.2" diff --git a/primitives/externalities/Cargo.toml b/primitives/externalities/Cargo.toml index e9c826a8fe..09ce3253f2 100644 --- a/primitives/externalities/Cargo.toml +++ b/primitives/externalities/Cargo.toml @@ -6,6 +6,6 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -sp-storage = { path = "../storage" } -sp-std = { path = "../std" } +sp-storage = { version = "2.0.0", path = "../storage" } +sp-std = { version = "2.0.0", path = "../std" } environmental = { version = "1.0.2" } diff --git a/primitives/finality-grandpa/Cargo.toml b/primitives/finality-grandpa/Cargo.toml index 6017745180..c2856e524f 100644 --- a/primitives/finality-grandpa/Cargo.toml +++ b/primitives/finality-grandpa/Cargo.toml @@ -5,12 +5,12 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -app-crypto = { package = "sp-application-crypto", path = "../application-crypto", default-features = false } +app-crypto = { version = "2.0.0", default-features = false, package = "sp-application-crypto", path = "../application-crypto" } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-std = { path = "../std", default-features = false } +sp-std = { version = "2.0.0", default-features = false, path = "../std" } serde = { version = "1.0.101", optional = true, features = ["derive"] } -sp-api = { path = "../api", default-features = false } -sp-runtime = { path = "../runtime", default-features = false } +sp-api = { version = "2.0.0", default-features = false, path = "../api" } +sp-runtime = { version = "2.0.0", default-features = false, path = "../runtime" } [features] default = ["std"] diff --git a/primitives/finality-tracker/Cargo.toml b/primitives/finality-tracker/Cargo.toml index 24681bbd1e..3245803945 100644 --- a/primitives/finality-tracker/Cargo.toml +++ b/primitives/finality-tracker/Cargo.toml @@ -6,8 +6,8 @@ edition = "2018" [dependencies] codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } -sp-inherents = { path = "../../primitives/inherents", default-features = false } -sp-std = { path = "../../primitives/std", default-features = false } +sp-inherents = { version = "2.0.0", default-features = false, path = "../../primitives/inherents" } +sp-std = { version = "2.0.0", default-features = false, path = "../../primitives/std" } [features] default = ["std"] diff --git a/primitives/inherents/Cargo.toml b/primitives/inherents/Cargo.toml index f40cf8c7f5..0dc465e288 100644 --- a/primitives/inherents/Cargo.toml +++ b/primitives/inherents/Cargo.toml @@ -6,8 +6,8 @@ edition = "2018" [dependencies] parking_lot = { version = "0.9.0", optional = true } -sp-std = { path = "../std", default-features = false } -sp-core = { path = "../core", default-features = false } +sp-std = { version = "2.0.0", default-features = false, path = "../std" } +sp-core = { version = "2.0.0", default-features = false, path = "../core" } codec = { package = "parity-scale-codec", version = "1.0.6", default-features = false, features = ["derive"] } derive_more = { version = "0.99.2", optional = true } diff --git a/primitives/io/Cargo.toml b/primitives/io/Cargo.toml index b72a6adb8c..a89b2d4c20 100644 --- a/primitives/io/Cargo.toml +++ b/primitives/io/Cargo.toml @@ -7,13 +7,13 @@ edition = "2018" [dependencies] codec = { package = "parity-scale-codec", version = "1.0.6", default-features = false } hash-db = { version = "0.15.2", default-features = false } -sp-core = { path = "../core", default-features = false } -sp-std = { path = "../std", default-features = false } +sp-core = { version = "2.0.0", default-features = false, path = "../core" } +sp-std = { version = "2.0.0", default-features = false, path = "../std" } libsecp256k1 = { version = "0.3.0", optional = true } -sp-state-machine = { path = "../../primitives/state-machine", optional = true } -sp-runtime-interface = { path = "../runtime-interface", default-features = false } -sp-trie = { path = "../../primitives/trie", optional = true } -sp-externalities = { path = "../externalities", optional = true } +sp-state-machine = { version = "2.0.0", optional = true, path = "../../primitives/state-machine" } +sp-runtime-interface = { version = "2.0.0", default-features = false, path = "../runtime-interface" } +sp-trie = { version = "2.0.0", optional = true, path = "../../primitives/trie" } +sp-externalities = { version = "2.0.0", optional = true, path = "../externalities" } log = { version = "0.4.8", optional = true } [features] diff --git a/primitives/keyring/Cargo.toml b/primitives/keyring/Cargo.toml index 7db87f3391..61ebf89ad2 100644 --- a/primitives/keyring/Cargo.toml +++ b/primitives/keyring/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -sp-core = { path = "../core" } -sp-runtime = { path = "../runtime" } +sp-core = { version = "2.0.0", path = "../core" } +sp-runtime = { version = "2.0.0", path = "../runtime" } lazy_static = "1.4.0" strum = { version = "0.16.0", features = ["derive"] } diff --git a/primitives/offchain/Cargo.toml b/primitives/offchain/Cargo.toml index 4b739dc45b..ef6d0a6d2c 100644 --- a/primitives/offchain/Cargo.toml +++ b/primitives/offchain/Cargo.toml @@ -7,8 +7,8 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -sp-api = { path = "../api", default-features = false } -sp-runtime = { path = "../runtime", default-features = false } +sp-api = { version = "2.0.0", default-features = false, path = "../api" } +sp-runtime = { version = "2.0.0", default-features = false, path = "../runtime" } [features] default = ["std"] diff --git a/primitives/phragmen/Cargo.toml b/primitives/phragmen/Cargo.toml index 7637c25f2d..92807376de 100644 --- a/primitives/phragmen/Cargo.toml +++ b/primitives/phragmen/Cargo.toml @@ -6,12 +6,12 @@ edition = "2018" [dependencies] serde = { version = "1.0.101", optional = true, features = ["derive"] } -sp-std = { path = "../std", default-features = false } -sp-runtime = { path = "../../primitives/runtime", default-features = false } +sp-std = { version = "2.0.0", default-features = false, path = "../std" } +sp-runtime = { version = "2.0.0", default-features = false, path = "../../primitives/runtime" } [dev-dependencies] -substrate-test-utils = { path = "../../test-utils" } -sp-io ={ path = "../../primitives/io" } +substrate-test-utils = { version = "2.0.0", path = "../../test-utils" } +sp-io ={ version = "2.0.0", path = "../../primitives/io" } rand = "0.7.2" [features] diff --git a/primitives/rpc/Cargo.toml b/primitives/rpc/Cargo.toml index 09ce69e0c5..33a854e6b7 100644 --- a/primitives/rpc/Cargo.toml +++ b/primitives/rpc/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" [dependencies] serde = { version = "1.0.101", features = ["derive"] } -sp-core = { path = "../core" } +sp-core = { version = "2.0.0", path = "../core" } [dev-dependencies] serde_json = "1.0.41" diff --git a/primitives/runtime-interface/Cargo.toml b/primitives/runtime-interface/Cargo.toml index 5874e66237..cdc94b6a2f 100644 --- a/primitives/runtime-interface/Cargo.toml +++ b/primitives/runtime-interface/Cargo.toml @@ -5,20 +5,20 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -sp-wasm-interface = { path = "../wasm-interface", optional = true } -sp-std = { path = "../std", default-features = false } -sp-runtime-interface-proc-macro = { path = "proc-macro" } -sp-externalities = { path = "../externalities", optional = true } +sp-wasm-interface = { version = "2.0.0", optional = true, path = "../wasm-interface" } +sp-std = { version = "2.0.0", default-features = false, path = "../std" } +sp-runtime-interface-proc-macro = { version = "2.0.0", path = "proc-macro" } +sp-externalities = { version = "2.0.0", optional = true, path = "../externalities" } codec = { package = "parity-scale-codec", version = "1.0.6", default-features = false } environmental = { version = "1.0.2", optional = true } static_assertions = "1.0.0" primitive-types = { version = "0.6.1", default-features = false } [dev-dependencies] -sp-runtime-interface-test-wasm = { path = "test-wasm" } -sp-state-machine = { path = "../../primitives/state-machine" } -sp-core = { path = "../core" } -sp-io = { path = "../io" } +sp-runtime-interface-test-wasm = { version = "2.0.0", path = "test-wasm" } +sp-state-machine = { version = "2.0.0", path = "../../primitives/state-machine" } +sp-core = { version = "2.0.0", path = "../core" } +sp-io = { version = "2.0.0", path = "../io" } rustversion = "1.0.0" trybuild = "1.0.17" diff --git a/primitives/runtime-interface/test-wasm/Cargo.toml b/primitives/runtime-interface/test-wasm/Cargo.toml index d8ed272aa8..b3a400a12d 100644 --- a/primitives/runtime-interface/test-wasm/Cargo.toml +++ b/primitives/runtime-interface/test-wasm/Cargo.toml @@ -6,13 +6,13 @@ edition = "2018" build = "build.rs" [dependencies] -sp-runtime-interface = { path = "../", default-features = false } -sp-std = { path = "../../std", default-features = false } -sp-io = { path = "../../io", default-features = false } -sp-core = { path = "../../core", default-features = false } +sp-runtime-interface = { version = "2.0.0", default-features = false, path = "../" } +sp-std = { version = "2.0.0", default-features = false, path = "../../std" } +sp-io = { version = "2.0.0", default-features = false, path = "../../io" } +sp-core = { version = "2.0.0", default-features = false, path = "../../core" } [build-dependencies] -wasm-builder-runner = { package = "substrate-wasm-builder-runner", version = "1.0.3", path = "../../../utils/wasm-builder-runner" } +wasm-builder-runner = { version = "1.0.3", package = "substrate-wasm-builder-runner", path = "../../../utils/wasm-builder-runner" } [features] default = [ "std" ] diff --git a/primitives/runtime-interface/test/Cargo.toml b/primitives/runtime-interface/test/Cargo.toml index 1e9aea910e..35eb8cb8e1 100644 --- a/primitives/runtime-interface/test/Cargo.toml +++ b/primitives/runtime-interface/test/Cargo.toml @@ -6,9 +6,9 @@ edition = "2018" publish = false [dependencies] -sp-runtime-interface = { path = "../" } -sc-executor = { path = "../../../client/executor" } -sp-runtime-interface-test-wasm = { path = "../test-wasm" } -sp-state-machine = { path = "../../../primitives/state-machine" } -sp-core = { path = "../../core" } -sp-io = { path = "../../io" } +sp-runtime-interface = { version = "2.0.0", path = "../" } +sc-executor = { version = "2.0.0", path = "../../../client/executor" } +sp-runtime-interface-test-wasm = { version = "2.0.0", path = "../test-wasm" } +sp-state-machine = { version = "2.0.0", path = "../../../primitives/state-machine" } +sp-core = { version = "2.0.0", path = "../../core" } +sp-io = { version = "2.0.0", path = "../../io" } diff --git a/primitives/runtime/Cargo.toml b/primitives/runtime/Cargo.toml index 78cbcad6dc..2b3829529d 100644 --- a/primitives/runtime/Cargo.toml +++ b/primitives/runtime/Cargo.toml @@ -7,16 +7,16 @@ edition = "2018" [dependencies] serde = { version = "1.0.101", optional = true, features = ["derive"] } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-core = { path = "../core", default-features = false } -sp-application-crypto = { path = "../application-crypto", default-features = false } -sp-arithmetic = { path = "../arithmetic", default-features = false } -sp-std = { path = "../std", default-features = false } -sp-io = { path = "../io", default-features = false } +sp-core = { version = "2.0.0", default-features = false, path = "../core" } +sp-application-crypto = { version = "2.0.0", default-features = false, path = "../application-crypto" } +sp-arithmetic = { version = "2.0.0", default-features = false, path = "../arithmetic" } +sp-std = { version = "2.0.0", default-features = false, path = "../std" } +sp-io = { version = "2.0.0", default-features = false, path = "../io" } log = { version = "0.4.8", optional = true } paste = "0.1.6" rand = { version = "0.7.2", optional = true } impl-trait-for-tuples = "0.1.3" -sp-inherents = { path = "../inherents", default-features = false } +sp-inherents = { version = "2.0.0", default-features = false, path = "../inherents" } [dev-dependencies] serde_json = "1.0.41" diff --git a/primitives/sandbox/Cargo.toml b/primitives/sandbox/Cargo.toml index d02c115501..ff3b7662cd 100755 --- a/primitives/sandbox/Cargo.toml +++ b/primitives/sandbox/Cargo.toml @@ -6,9 +6,9 @@ edition = "2018" [dependencies] wasmi = { version = "0.6.2", optional = true } -sp-core = { path = "../core", default-features = false } -sp-std = { path = "../std", default-features = false } -sp-io = { path = "../io", default-features = false } +sp-core = { version = "2.0.0", default-features = false, path = "../core" } +sp-std = { version = "2.0.0", default-features = false, path = "../std" } +sp-io = { version = "2.0.0", default-features = false, path = "../io" } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } [dev-dependencies] diff --git a/primitives/session/Cargo.toml b/primitives/session/Cargo.toml index 56a7660c74..b7c72e0c68 100644 --- a/primitives/session/Cargo.toml +++ b/primitives/session/Cargo.toml @@ -5,9 +5,9 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -sp-api = { path = "../api", default-features = false } -sp-std = { path = "../std", default-features = false } -sp-runtime = { path = "../runtime", optional = true } +sp-api = { version = "2.0.0", default-features = false, path = "../api" } +sp-std = { version = "2.0.0", default-features = false, path = "../std" } +sp-runtime = { version = "2.0.0", optional = true, path = "../runtime" } [features] default = [ "std" ] diff --git a/primitives/staking/Cargo.toml b/primitives/staking/Cargo.toml index 2cac41bd40..35725c72e3 100644 --- a/primitives/staking/Cargo.toml +++ b/primitives/staking/Cargo.toml @@ -6,8 +6,8 @@ edition = "2018" [dependencies] codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-runtime = { path = "../runtime", default-features = false } -sp-std = { path = "../std", default-features = false } +sp-runtime = { version = "2.0.0", default-features = false, path = "../runtime" } +sp-std = { version = "2.0.0", default-features = false, path = "../std" } [features] default = ["std"] diff --git a/primitives/state-machine/Cargo.toml b/primitives/state-machine/Cargo.toml index 73e943011c..777830d5ea 100644 --- a/primitives/state-machine/Cargo.toml +++ b/primitives/state-machine/Cargo.toml @@ -11,13 +11,13 @@ parking_lot = "0.9.0" hash-db = "0.15.2" trie-db = "0.16.0" trie-root = "0.15.2" -sp-trie = { path = "../trie" } -sp-core = { path = "../core" } -sp-panic-handler = { path = "../panic-handler" } +sp-trie = { version = "2.0.0", path = "../trie" } +sp-core = { version = "2.0.0", path = "../core" } +sp-panic-handler = { version = "2.0.0", path = "../panic-handler" } codec = { package = "parity-scale-codec", version = "1.0.0" } num-traits = "0.2.8" rand = "0.7.2" -sp-externalities = { path = "../externalities" } +sp-externalities = { version = "2.0.0", path = "../externalities" } [dev-dependencies] hex-literal = "0.2.1" diff --git a/primitives/storage/Cargo.toml b/primitives/storage/Cargo.toml index d3fc7267bf..384519cc1d 100644 --- a/primitives/storage/Cargo.toml +++ b/primitives/storage/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" description = "Storage related primitives" [dependencies] -sp-std = { path = "../std", default-features = false } +sp-std = { version = "2.0.0", default-features = false, path = "../std" } serde = { version = "1.0.101", optional = true, features = ["derive"] } impl-serde = { version = "0.2.3", optional = true } sp-debug-derive = { version = "2.0.0", path = "../debug-derive" } diff --git a/primitives/test-primitives/Cargo.toml b/primitives/test-primitives/Cargo.toml index 1301887241..5c2f2dcc0a 100644 --- a/primitives/test-primitives/Cargo.toml +++ b/primitives/test-primitives/Cargo.toml @@ -5,11 +5,11 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -sp-application-crypto = { path = "../application-crypto", default-features = false } +sp-application-crypto = { version = "2.0.0", default-features = false, path = "../application-crypto" } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-core = { path = "../core", default-features = false } +sp-core = { version = "2.0.0", default-features = false, path = "../core" } serde = { version = "1.0.101", optional = true, features = ["derive"] } -sp-runtime = { path = "../runtime", default-features = false } +sp-runtime = { version = "2.0.0", default-features = false, path = "../runtime" } [features] default = [ diff --git a/primitives/timestamp/Cargo.toml b/primitives/timestamp/Cargo.toml index a11e4bce40..ee86d6e3bc 100644 --- a/primitives/timestamp/Cargo.toml +++ b/primitives/timestamp/Cargo.toml @@ -5,11 +5,11 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -sp-api = { path = "../api", default-features = false } -sp-std = { path = "../std", default-features = false } -sp-runtime = { path = "../runtime", default-features = false } +sp-api = { version = "2.0.0", default-features = false, path = "../api" } +sp-std = { version = "2.0.0", default-features = false, path = "../std" } +sp-runtime = { version = "2.0.0", default-features = false, path = "../runtime" } codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -sp-inherents = { path = "../inherents", default-features = false } +sp-inherents = { version = "2.0.0", default-features = false, path = "../inherents" } impl-trait-for-tuples = "0.1.3" [features] diff --git a/primitives/transaction-pool/Cargo.toml b/primitives/transaction-pool/Cargo.toml index 1bb0139dc0..3a3e15e611 100644 --- a/primitives/transaction-pool/Cargo.toml +++ b/primitives/transaction-pool/Cargo.toml @@ -10,8 +10,8 @@ derive_more = { version = "0.99.2", optional = true } futures = { version = "0.3.1", optional = true } log = { version = "0.4.8", optional = true } serde = { version = "1.0.101", features = ["derive"], optional = true} -sp-api = { path = "../api", default-features = false } -sp-runtime = { path = "../runtime", default-features = false } +sp-api = { version = "2.0.0", default-features = false, path = "../api" } +sp-runtime = { version = "2.0.0", default-features = false, path = "../runtime" } [features] default = [ "std" ] diff --git a/primitives/trie/Cargo.toml b/primitives/trie/Cargo.toml index 974246b0e4..a4ec923950 100644 --- a/primitives/trie/Cargo.toml +++ b/primitives/trie/Cargo.toml @@ -13,12 +13,12 @@ harness = false [dependencies] codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false } -sp-std = { path = "../std", default-features = false } +sp-std = { version = "2.0.0", default-features = false, path = "../std" } hash-db = { version = "0.15.2", default-features = false } trie-db = { version = "0.16.0", default-features = false } trie-root = { version = "0.15.2", default-features = false } memory-db = { version = "0.15.2", default-features = false } -sp-core = { path = "../core", default-features = false } +sp-core = { version = "2.0.0", default-features = false, path = "../core" } [dev-dependencies] trie-bench = "0.17.0" diff --git a/primitives/version/Cargo.toml b/primitives/version/Cargo.toml index 626313a702..fbbf0cfa94 100644 --- a/primitives/version/Cargo.toml +++ b/primitives/version/Cargo.toml @@ -8,8 +8,8 @@ edition = "2018" impl-serde = { version = "0.2.3", optional = true } serde = { version = "1.0.101", optional = true, features = ["derive"] } codec = { package = "parity-scale-codec", version = "1.0.5", default-features = false, features = ["derive"] } -sp-std = { path = "../std", default-features = false } -sp-runtime = { path = "../runtime", default-features = false } +sp-std = { version = "2.0.0", default-features = false, path = "../std" } +sp-runtime = { version = "2.0.0", default-features = false, path = "../runtime" } [features] default = ["std"] diff --git a/test-utils/client/Cargo.toml b/test-utils/client/Cargo.toml index df0bb1738a..05dc41b223 100644 --- a/test-utils/client/Cargo.toml +++ b/test-utils/client/Cargo.toml @@ -5,16 +5,16 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -sc-client-api = { path = "../../client/api" } -sc-client = { path = "../../client/" } -sc-client-db = { path = "../../client/db", features = ["test-helpers"] } -sp-consensus = { path = "../../primitives/consensus/common" } -sc-executor = { path = "../../client/executor" } +sc-client-api = { version = "2.0.0", path = "../../client/api" } +sc-client = { version = "2.0.0", path = "../../client/" } +sc-client-db = { version = "2.0.0", features = ["test-helpers"], path = "../../client/db" } +sp-consensus = { version = "0.8", path = "../../primitives/consensus/common" } +sc-executor = { version = "2.0.0", path = "../../client/executor" } futures = "0.3.1" hash-db = "0.15.2" -sp-keyring = { path = "../../primitives/keyring" } +sp-keyring = { version = "2.0.0", path = "../../primitives/keyring" } codec = { package = "parity-scale-codec", version = "1.0.0" } -sp-core = { path = "../../primitives/core" } -sp-runtime = { path = "../../primitives/runtime" } -sp-blockchain = { path = "../../primitives/blockchain" } -sp-state-machine = { path = "../../primitives/state-machine" } +sp-core = { version = "2.0.0", path = "../../primitives/core" } +sp-runtime = { version = "2.0.0", path = "../../primitives/runtime" } +sp-blockchain = { version = "2.0.0", path = "../../primitives/blockchain" } +sp-state-machine = { version = "2.0.0", path = "../../primitives/state-machine" } diff --git a/test-utils/runtime/Cargo.toml b/test-utils/runtime/Cargo.toml index 66b97ac78e..7d58fe1637 100644 --- a/test-utils/runtime/Cargo.toml +++ b/test-utils/runtime/Cargo.toml @@ -6,44 +6,44 @@ edition = "2018" build = "build.rs" [dependencies] -sp-application-crypto = { path = "../../primitives/application-crypto", default-features = false } -sp-consensus-aura = { path = "../../primitives/consensus/aura", default-features = false } -sp-consensus-babe = { path = "../../primitives/consensus/babe", default-features = false } -sp-block-builder = { path = "../../primitives/block-builder", default-features = false } +sp-application-crypto = { version = "2.0.0", default-features = false, path = "../../primitives/application-crypto" } +sp-consensus-aura = { version = "0.8", default-features = false, path = "../../primitives/consensus/aura" } +sp-consensus-babe = { version = "0.8", default-features = false, path = "../../primitives/consensus/babe" } +sp-block-builder = { version = "2.0.0", default-features = false, path = "../../primitives/block-builder" } cfg-if = "0.1.10" codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } -frame-executive = { path = "../../frame/executive", default-features = false } -sp-inherents = { path = "../../primitives/inherents", default-features = false } -sp-keyring = { path = "../../primitives/keyring", optional = true } +frame-executive = { version = "2.0.0", default-features = false, path = "../../frame/executive" } +sp-inherents = { version = "2.0.0", default-features = false, path = "../../primitives/inherents" } +sp-keyring = { version = "2.0.0", optional = true, path = "../../primitives/keyring" } log = { version = "0.4.8", optional = true } memory-db = { version = "0.15.2", default-features = false } sp-offchain = { path = "../../primitives/offchain", default-features = false} -sp-core = { path = "../../primitives/core", default-features = false } -sp-std = { path = "../../primitives/std", default-features = false } +sp-core = { version = "2.0.0", default-features = false, path = "../../primitives/core" } +sp-std = { version = "2.0.0", default-features = false, path = "../../primitives/std" } sp-runtime-interface = { path = "../../primitives/runtime-interface", default-features = false} -sp-io = { path = "../../primitives/io", default-features = false } -frame-support = { path = "../../frame/support", default-features = false } -sp-version = { path = "../../primitives/version", default-features = false } +sp-io = { version = "2.0.0", default-features = false, path = "../../primitives/io" } +frame-support = { version = "2.0.0", default-features = false, path = "../../frame/support" } +sp-version = { version = "2.0.0", default-features = false, path = "../../primitives/version" } serde = { version = "1.0.101", optional = true, features = ["derive"] } -sp-session = { path = "../../primitives/session", default-features = false } -sp-api = { path = "../../primitives/api", default-features = false } -sp-runtime = { path = "../../primitives/runtime", default-features = false } -pallet-babe = { path = "../../frame/babe", default-features = false } -frame-system = { path = "../../frame/system", default-features = false } -frame-system-rpc-runtime-api = { path = "../../frame/system/rpc/runtime-api", default-features = false } -pallet-timestamp = { path = "../../frame/timestamp", default-features = false } -sc-client = { path = "../../client", optional = true } -sp-trie = { path = "../../primitives/trie", default-features = false } -sp-transaction-pool = { path = "../../primitives/transaction-pool", default-features = false } +sp-session = { version = "2.0.0", default-features = false, path = "../../primitives/session" } +sp-api = { version = "2.0.0", default-features = false, path = "../../primitives/api" } +sp-runtime = { version = "2.0.0", default-features = false, path = "../../primitives/runtime" } +pallet-babe = { version = "2.0.0", default-features = false, path = "../../frame/babe" } +frame-system = { version = "2.0.0", default-features = false, path = "../../frame/system" } +frame-system-rpc-runtime-api = { version = "2.0.0", default-features = false, path = "../../frame/system/rpc/runtime-api" } +pallet-timestamp = { version = "2.0.0", default-features = false, path = "../../frame/timestamp" } +sc-client = { version = "2.0.0", optional = true, path = "../../client" } +sp-trie = { version = "2.0.0", default-features = false, path = "../../primitives/trie" } +sp-transaction-pool = { version = "2.0.0", default-features = false, path = "../../primitives/transaction-pool" } trie-db = { version = "0.16.0", default-features = false } [dev-dependencies] -sc-executor = { path = "../../client/executor" } -substrate-test-runtime-client = { path = "./client" } -sp-state-machine = { path = "../../primitives/state-machine" } +sc-executor = { version = "2.0.0", path = "../../client/executor" } +substrate-test-runtime-client = { version = "2.0.0", path = "./client" } +sp-state-machine = { version = "2.0.0", path = "../../primitives/state-machine" } [build-dependencies] -wasm-builder-runner = { package = "substrate-wasm-builder-runner", path = "../../utils/wasm-builder-runner", version = "1.0.4" } +wasm-builder-runner = { version = "1.0.4", package = "substrate-wasm-builder-runner", path = "../../utils/wasm-builder-runner" } [features] default = [ diff --git a/test-utils/runtime/client/Cargo.toml b/test-utils/runtime/client/Cargo.toml index 2ba3fab8d1..760aa44379 100644 --- a/test-utils/runtime/client/Cargo.toml +++ b/test-utils/runtime/client/Cargo.toml @@ -5,13 +5,13 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -sc-block-builder = { path = "../../../client/block-builder" } -substrate-test-client = { path = "../../client" } -sp-core = { path = "../../../primitives/core" } -substrate-test-runtime = { path = "../../runtime" } -sp-runtime = { path = "../../../primitives/runtime" } -sp-blockchain = { path = "../../../primitives/blockchain" } +sc-block-builder = { version = "2.0.0", path = "../../../client/block-builder" } +substrate-test-client = { version = "2.0.0", path = "../../client" } +sp-core = { version = "2.0.0", path = "../../../primitives/core" } +substrate-test-runtime = { version = "2.0.0", path = "../../runtime" } +sp-runtime = { version = "2.0.0", path = "../../../primitives/runtime" } +sp-blockchain = { version = "2.0.0", path = "../../../primitives/blockchain" } codec = { package = "parity-scale-codec", version = "1.0.0" } -sc-client-api = { path = "../../../client/api" } -sc-client = { path = "../../../client/" } +sc-client-api = { version = "2.0.0", path = "../../../client/api" } +sc-client = { version = "2.0.0", path = "../../../client/" } futures = "0.3.1" diff --git a/utils/frame/rpc/support/Cargo.toml b/utils/frame/rpc/support/Cargo.toml index 272fdb5642..f26a69cc5f 100644 --- a/utils/frame/rpc/support/Cargo.toml +++ b/utils/frame/rpc/support/Cargo.toml @@ -10,10 +10,10 @@ jsonrpc-client-transports = "14" jsonrpc-core = "14" codec = { package = "parity-scale-codec", version = "1" } serde = "1" -frame-support = { path = "../../../../frame/support" } -sp-storage = { path = "../../../../primitives/storage" } -sc-rpc-api = { path = "../../../../client/rpc-api" } +frame-support = { version = "2.0.0", path = "../../../../frame/support" } +sp-storage = { version = "2.0.0", path = "../../../../primitives/storage" } +sc-rpc-api = { version = "2.0.0", path = "../../../../client/rpc-api" } [dev-dependencies] -frame-system = { path = "../../../../frame/system" } +frame-system = { version = "2.0.0", path = "../../../../frame/system" } tokio = "0.1" diff --git a/utils/frame/rpc/system/Cargo.toml b/utils/frame/rpc/system/Cargo.toml index c904bceae0..45e1af6f76 100644 --- a/utils/frame/rpc/system/Cargo.toml +++ b/utils/frame/rpc/system/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -sc-client = { path = "../../../../client/" } +sc-client = { version = "2.0.0", path = "../../../../client/" } codec = { package = "parity-scale-codec", version = "1.0.0" } futures = "0.3.1" jsonrpc-core = "14.0.3" @@ -13,13 +13,13 @@ jsonrpc-core-client = "14.0.3" jsonrpc-derive = "14.0.3" log = "0.4.8" serde = { version = "1.0.101", features = ["derive"] } -sp-runtime = { path = "../../../../primitives/runtime" } -frame-system-rpc-runtime-api = { path = "../../../../frame/system/rpc/runtime-api" } -sp-core = { path = "../../../../primitives/core" } -sp-blockchain = { path = "../../../../primitives/blockchain" } -sp-transaction-pool = { path = "../../../../primitives/transaction-pool" } +sp-runtime = { version = "2.0.0", path = "../../../../primitives/runtime" } +frame-system-rpc-runtime-api = { version = "2.0.0", path = "../../../../frame/system/rpc/runtime-api" } +sp-core = { version = "2.0.0", path = "../../../../primitives/core" } +sp-blockchain = { version = "2.0.0", path = "../../../../primitives/blockchain" } +sp-transaction-pool = { version = "2.0.0", path = "../../../../primitives/transaction-pool" } [dev-dependencies] -substrate-test-runtime-client = { path = "../../../../test-utils/runtime/client" } +substrate-test-runtime-client = { version = "2.0.0", path = "../../../../test-utils/runtime/client" } env_logger = "0.7.0" -sc-transaction-pool = { path = "../../../../client/transaction-pool" } +sc-transaction-pool = { version = "2.0.0", path = "../../../../client/transaction-pool" } diff --git a/utils/grafana-data-source/test/Cargo.toml b/utils/grafana-data-source/test/Cargo.toml index 2ee376be8d..079b49dc86 100644 --- a/utils/grafana-data-source/test/Cargo.toml +++ b/utils/grafana-data-source/test/Cargo.toml @@ -7,7 +7,7 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -grafana-data-source = { path = ".." } +grafana-data-source = { version = "2.0.0", path = ".." } futures = "0.3" futures-timer = "2.0" rand = "0.7" -- GitLab From a8ea665d61dbe79dc245539e5e13116d45189afe Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Tue, 17 Dec 2019 16:49:00 +0100 Subject: [PATCH 152/172] Update Balances Pallet events to help block explorers (#4389) * Dust moves from reserved <-> free if below ED * Add dust information to `ReapedAccount` event * Introduce `BalanceSet` event * More cleanly written `set_balance` logic --- frame/balances/src/lib.rs | 50 +++++++++++++++++++++++++++---------- frame/balances/src/tests.rs | 43 +++++++++++++++++++++++++++++-- 2 files changed, 78 insertions(+), 15 deletions(-) diff --git a/frame/balances/src/lib.rs b/frame/balances/src/lib.rs index 8829964238..e0d54c6020 100644 --- a/frame/balances/src/lib.rs +++ b/frame/balances/src/lib.rs @@ -263,9 +263,11 @@ decl_event!( /// A new account was created. NewAccount(AccountId, Balance), /// An account was reaped. - ReapedAccount(AccountId), + ReapedAccount(AccountId, Balance), /// Transfer succeeded (from, to, value, fees). Transfer(AccountId, AccountId, Balance, Balance), + /// A balance was set by root (who, free, reserved). + BalanceSet(AccountId, Balance, Balance), } ); @@ -456,6 +458,10 @@ decl_module! { ) { ensure_root(origin)?; let who = T::Lookup::lookup(who)?; + let existential_deposit = T::ExistentialDeposit::get(); + + let new_free = if new_free < existential_deposit { Zero::zero() } else { new_free }; + let new_reserved = if new_reserved < existential_deposit { Zero::zero() } else { new_reserved }; let current_free = >::get(&who); if new_free > current_free { @@ -472,6 +478,8 @@ decl_module! { mem::drop(NegativeImbalance::::new(current_reserved - new_reserved)); } Self::set_reserved_balance(&who, new_reserved); + + Self::deposit_event(RawEvent::BalanceSet(who, new_free, new_reserved)); } /// Exactly as `transfer`, except the origin must be root and the source account may be @@ -564,9 +572,9 @@ impl, I: Instance> Module { /// Unregister an account. /// /// This just removes the nonce and leaves an event. - fn reap_account(who: &T::AccountId) { + fn reap_account(who: &T::AccountId, dust: T::Balance) { >::remove(who); - Self::deposit_event(RawEvent::ReapedAccount(who.clone())); + Self::deposit_event(RawEvent::ReapedAccount(who.clone(), dust)); } /// Account's free balance has dropped below existential deposit. Kill its @@ -577,15 +585,23 @@ impl, I: Instance> Module { let dust = >::take(who); >::remove(who); - // underflow should never happen, but if it does, there's not much we can do about it. + T::OnFreeBalanceZero::on_free_balance_zero(who); + + let mut reserved_balance = Self::reserved_balance(who); + if !dust.is_zero() { - T::DustRemoval::on_unbalanced(NegativeImbalance::new(dust)); + if reserved_balance >= T::ExistentialDeposit::get() { + // any individual account cannot cause overflow in balance. + reserved_balance += dust; + Self::set_reserved_balance(who, reserved_balance); + } else { + // underflow should never happen, but if it does, there's not much we can do. + T::DustRemoval::on_unbalanced(NegativeImbalance::new(dust)); + } } - T::OnFreeBalanceZero::on_free_balance_zero(who); - - if Self::reserved_balance(who).is_zero() { - Self::reap_account(who); + if reserved_balance.is_zero() { + Self::reap_account(who, dust); } } @@ -596,13 +612,21 @@ impl, I: Instance> Module { fn on_reserved_too_low(who: &T::AccountId) { let dust = >::take(who); - // underflow should never happen, but it if does, there's nothing to be done here. + let mut free_balance = Self::free_balance(who); + if !dust.is_zero() { - T::DustRemoval::on_unbalanced(NegativeImbalance::new(dust)); + if free_balance >= T::ExistentialDeposit::get() { + // any individual account cannot cause overflow in balance. + free_balance += dust; + Self::set_free_balance(who, free_balance); + } else { + // underflow should never happen, but it if does, there's nothing to be done here. + T::DustRemoval::on_unbalanced(NegativeImbalance::new(dust)); + } } - if Self::free_balance(who).is_zero() { - Self::reap_account(who); + if free_balance.is_zero() { + Self::reap_account(who, dust); } } } diff --git a/frame/balances/src/tests.rs b/frame/balances/src/tests.rs index bf0fa392fc..a58426462d 100644 --- a/frame/balances/src/tests.rs +++ b/frame/balances/src/tests.rs @@ -248,7 +248,7 @@ fn reserved_balance_should_prevent_reclaim_count() { assert_ok!(Balances::reserve(&2, 256 * 19 + 1)); // account 2 becomes mostly reserved assert_eq!(Balances::free_balance(&2), 0); // "free" account deleted." - assert_eq!(Balances::total_balance(&2), 256 * 19 + 1); // reserve still exists. + assert_eq!(Balances::total_balance(&2), 256 * 20); // reserve still exists. assert_eq!(Balances::is_dead_account(&2), false); assert_eq!(System::account_nonce(&2), 1); @@ -257,7 +257,7 @@ fn reserved_balance_should_prevent_reclaim_count() { assert_eq!(Balances::total_balance(&5), 256 * 1 + 0x69); assert_eq!(Balances::is_dead_account(&5), false); - assert!(Balances::slash(&2, 256 * 18 + 2).1.is_zero()); // account 2 gets slashed + assert!(Balances::slash(&2, 256 * 19 + 2).1.is_zero()); // account 2 gets slashed // "reserve" account reduced to 255 (below ED) so account deleted assert_eq!(Balances::total_balance(&2), 0); assert_eq!(System::account_nonce(&2), 0); // nonce zero @@ -769,3 +769,42 @@ fn cannot_set_genesis_value_below_ed() { vesting: vec![], }.assimilate_storage(&mut t).unwrap(); } + +#[test] +fn dust_moves_between_free_and_reserved() { + ExtBuilder::default() + .existential_deposit(100) + .build() + .execute_with(|| { + // Set balance to free and reserved at the existential deposit + assert_ok!(Balances::set_balance(RawOrigin::Root.into(), 1, 100, 100)); + assert_ok!(Balances::set_balance(RawOrigin::Root.into(), 2, 100, 100)); + // Check balance + assert_eq!(Balances::free_balance(1), 100); + assert_eq!(Balances::reserved_balance(1), 100); + assert_eq!(Balances::free_balance(2), 100); + assert_eq!(Balances::reserved_balance(2), 100); + + // Drop 1 free_balance below ED + assert_ok!(Balances::transfer(Some(1).into(), 2, 1)); + // Check balance, the other 99 should move to reserved_balance + assert_eq!(Balances::free_balance(1), 0); + assert_eq!(Balances::reserved_balance(1), 199); + + // Reset accounts + assert_ok!(Balances::set_balance(RawOrigin::Root.into(), 1, 100, 100)); + assert_ok!(Balances::set_balance(RawOrigin::Root.into(), 2, 100, 100)); + + // Drop 2 reserved_balance below ED + Balances::unreserve(&2, 1); + // Check balance, all 100 should move to free_balance + assert_eq!(Balances::free_balance(2), 200); + assert_eq!(Balances::reserved_balance(2), 0); + + // An account with both too little free and reserved is completely killed + assert_ok!(Balances::set_balance(RawOrigin::Root.into(), 1, 99, 99)); + // Check balance is 0 for everything + assert_eq!(Balances::free_balance(1), 0); + assert_eq!(Balances::reserved_balance(1), 0); + }); +} -- GitLab From 16817ab6b6b529ae32fc8151820c15dd1ed00291 Mon Sep 17 00:00:00 2001 From: joe petrowski <25483142+joepetrowski@users.noreply.github.com> Date: Tue, 17 Dec 2019 21:33:11 +0100 Subject: [PATCH 153/172] minor typos in traits docs (#4425) --- frame/system/src/offchain.rs | 4 ++-- primitives/runtime/src/traits.rs | 31 ++++++++++++++++--------------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/frame/system/src/offchain.rs b/frame/system/src/offchain.rs index b6f260d9e7..32cda26af1 100644 --- a/frame/system/src/offchain.rs +++ b/frame/system/src/offchain.rs @@ -56,7 +56,7 @@ impl Signer for AppPublic where } } -/// Creates runtime-specific signed transaction. +/// Creates a runtime-specific signed transaction. pub trait CreateTransaction { /// A `Public` key representing a particular `AccountId`. type Public: IdentifyAccount + Clone; @@ -115,7 +115,7 @@ pub trait SubmitSignedTransaction { } } -/// A trait to submit unsigned transactions in offchain calls. +/// A trait to submit unsigned transactions in off-chain calls. pub trait SubmitUnsignedTransaction { /// Unchecked extrinsic type. type Extrinsic: ExtrinsicT + codec::Encode; diff --git a/primitives/runtime/src/traits.rs b/primitives/runtime/src/traits.rs index 97ff85c986..aee19ea0cc 100644 --- a/primitives/runtime/src/traits.rs +++ b/primitives/runtime/src/traits.rs @@ -49,8 +49,8 @@ impl<'a> Lazy<[u8]> for &'a [u8] { fn get(&mut self) -> &[u8] { &**self } } -/// Some type that is able to be collapsed into an account ID. It is not possible to recreate the original value from -/// the account ID. +/// Some type that is able to be collapsed into an account ID. It is not possible to recreate the +/// original value from the account ID. pub trait IdentifyAccount { /// The account ID that this can be transformed into. type AccountId; @@ -358,7 +358,7 @@ pub trait OffchainWorker { /// This function is being called after every block import (when fully synced). /// /// Implement this and use any of the `Offchain` `sp_io` set of APIs - /// to perform offchain computations, calls and submit transactions + /// to perform off-chain computations, calls and submit transactions /// with results to trigger any on-chain changes. /// Any state alterations are lost and are not persisted. fn offchain_worker(_n: BlockNumber) {} @@ -498,9 +498,9 @@ pub trait RandomnessBeacon { /// # Security /// /// This MUST NOT be used for gambling, as it can be influenced by a - /// malicious validator in the short term. It MAY be used in many + /// malicious validator in the short term. It MAY be used in many /// cryptographic protocols, however, so long as one remembers that this - /// (like everything else on-chain) is public. For example, it can be + /// (like everything else on-chain) is public. For example, it can be /// used where a number is needed that cannot have been chosen by an /// adversary, for purposes such as public-coin zero-knowledge proofs. fn random() -> [u8; 32]; @@ -571,12 +571,12 @@ pub trait Header: Clone + Send + Sync + Codec + Eq + MaybeSerialize + Debug + 's } } -/// Something which fulfills the abstract idea of a Substrate block. It has types for an -/// `Extrinsic` piece of information as well as a `Header`. +/// Something which fulfills the abstract idea of a Substrate block. It has types for +/// `Extrinsic` pieces of information as well as a `Header`. /// /// You can get an iterator over each of the `extrinsics` and retrieve the `header`. pub trait Block: Clone + Send + Sync + Codec + Eq + MaybeSerialize + Debug + 'static { - /// Type of extrinsics. + /// Type for extrinsics. type Extrinsic: Member + Codec + Extrinsic + MaybeSerialize; /// Header type. type Header: Header; @@ -596,7 +596,8 @@ pub trait Block: Clone + Send + Sync + Codec + Eq + MaybeSerialize + Debug + 'st fn hash(&self) -> Self::Hash { <::Hashing as Hash>::hash_of(self.header()) } - /// Create an encoded block from the given `header` and `extrinsics` without requiring to create an instance. + /// Creates an encoded block from the given `header` and `extrinsics` without requiring the + /// creation of an instance. fn encode_from(header: &Self::Header, extrinsics: &[Self::Extrinsic]) -> Vec; } @@ -703,7 +704,7 @@ pub trait SignedExtension: Codec + Debug + Sync + Send + Clone + Eq + PartialEq type Pre: Default; /// An opaque set of information attached to the transaction. This could be constructed anywhere - /// down the line in a runtime. The current substrate runtime uses a struct with the same name + /// down the line in a runtime. The current Substrate runtime uses a struct with the same name /// to represent the dispatch class and weight. type DispatchInfo: Clone; @@ -716,7 +717,7 @@ pub trait SignedExtension: Codec + Debug + Sync + Send + Clone + Eq + PartialEq /// This function can be called frequently by the transaction queue, /// to obtain transaction validity against current state. /// It should perform all checks that determine a valid transaction, - /// that can pay for it's execution and quickly eliminate ones + /// that can pay for its execution and quickly eliminate ones /// that are stale or incorrect. /// /// Make sure to perform the same checks in `pre_dispatch` function. @@ -752,7 +753,7 @@ pub trait SignedExtension: Codec + Debug + Sync + Send + Clone + Eq + PartialEq /// Validate an unsigned transaction for the transaction queue. /// - /// This function can be called frequently by the transaction queue, + /// This function can be called frequently by the transaction queue /// to obtain transaction validity against current state. /// It should perform all checks that determine a valid unsigned transaction, /// and quickly eliminate ones that are stale or incorrect. @@ -790,7 +791,7 @@ pub trait SignedExtension: Codec + Debug + Sync + Send + Clone + Eq + PartialEq /// An error that is returned by a dispatchable function of a module. pub trait ModuleDispatchError { - /// Convert this error to an `u8`. + /// Convert this error to a `u8`. /// /// The `u8` corresponds to the index of the variant in the error enum. fn as_u8(&self) -> u8; @@ -875,10 +876,10 @@ impl SignedExtension for () { /// Also provides information on to whom this information is attributable and an index that allows /// each piece of attributable information to be disambiguated. pub trait Applyable: Sized + Send + Sync { - /// Id of the account that is responsible for this piece of information (sender). + /// ID of the account that is responsible for this piece of information (sender). type AccountId: Member + MaybeDisplay; - /// Type by which we can dispatch. Restricts the UnsignedValidator type. + /// Type by which we can dispatch. Restricts the `UnsignedValidator` type. type Call; /// An opaque set of information attached to the transaction. -- GitLab From 97d653108cb4dfb6a697c1762e1187f1094481cc Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Wed, 18 Dec 2019 12:48:15 +0300 Subject: [PATCH 154/172] Remove incorrect assumption that runners-up were sorted by account (#4429) * Remove incorrect assumption that runners-up were sorted by account * Fix * Update lib.rs --- frame/elections-phragmen/src/lib.rs | 35 +++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index 59856692b5..62bb4ba86d 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -349,15 +349,15 @@ decl_module! { return Ok(()); } - let mut runners_with_stake = Self::runners_up(); - if let Ok(index) = runners_with_stake - .binary_search_by(|(ref r, ref _s)| r.cmp(&who)) + let mut runners_up_with_stake = Self::runners_up(); + if let Some(index) = runners_up_with_stake.iter() + .position(|(ref r, ref _s)| r == &who) { - runners_with_stake.remove(index); + runners_up_with_stake.remove(index); // unreserve the bond T::Currency::unreserve(&who, T::CandidacyBond::get()); // update storage. - >::put(runners_with_stake); + >::put(runners_up_with_stake); // safety guard to make sure we do only one arm. Better to read runners later. return Ok(()); } @@ -373,7 +373,7 @@ decl_module! { return Ok(()); } - return Err("origin is not a candidate, member or a runner."); + return Err("origin is not a candidate, member or a runner up."); } /// Remove a particular member from the set. This is effective immediately and the bond of @@ -1906,6 +1906,27 @@ mod tests { }); } + #[test] + fn runner_up_replacement_works_when_out_of_order() { + ExtBuilder::default().desired_runners_up(2).build().execute_with(|| { + assert_ok!(Elections::submit_candidacy(Origin::signed(5))); + assert_ok!(Elections::submit_candidacy(Origin::signed(4))); + assert_ok!(Elections::submit_candidacy(Origin::signed(3))); + assert_ok!(Elections::submit_candidacy(Origin::signed(2))); + + assert_ok!(Elections::vote(Origin::signed(2), vec![5], 20)); + assert_ok!(Elections::vote(Origin::signed(3), vec![3], 30)); + assert_ok!(Elections::vote(Origin::signed(4), vec![4], 40)); + assert_ok!(Elections::vote(Origin::signed(5), vec![2], 50)); + + System::set_block_number(5); + assert_ok!(Elections::end_block(System::block_number())); + + assert_eq!(Elections::members_ids(), vec![2, 4]); + assert_ok!(Elections::renounce_candidacy(Origin::signed(3))); + }); + } + #[test] fn can_renounce_candidacy_member_with_runners_bond_is_refunded() { ExtBuilder::default().desired_runners_up(2).build().execute_with(|| { @@ -2010,7 +2031,7 @@ mod tests { ExtBuilder::default().build().execute_with(|| { assert_noop!( Elections::renounce_candidacy(Origin::signed(5)), - "origin is not a candidate, member or a runner.", + "origin is not a candidate, member or a runner up.", ); }) } -- GitLab From 6f9d8018dc69eb370f9330f1dc939bcea4080fd3 Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Wed, 18 Dec 2019 12:48:34 +0300 Subject: [PATCH 155/172] Fix the subkey error message (#4428) * Fix the subkey error message * Fix check_benchmarks --- bin/utils/subkey/src/main.rs | 13 ++++++------- client/consensus/uncles/src/lib.rs | 2 -- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/bin/utils/subkey/src/main.rs b/bin/utils/subkey/src/main.rs index 05d22cd57b..88acae9836 100644 --- a/bin/utils/subkey/src/main.rs +++ b/bin/utils/subkey/src/main.rs @@ -362,14 +362,15 @@ fn read_message_from_stdin(should_decode: bool) -> Vec { message } -fn read_required_parameter(matches: &ArgMatches, name: &str) -> T -where +fn read_required_parameter(matches: &ArgMatches, name: &str) -> T where ::Err: std::fmt::Debug, { let str_value = matches .value_of(name) .expect("parameter is required; thus it can't be None; qed"); - str::parse::(str_value).expect("Invalid 'nonce' parameter; expecting an integer.") + str::parse::(str_value).unwrap_or_else(|_| + panic!("Invalid `{}' parameter; expecting an integer.", name) + ) } fn read_genesis_hash(matches: &ArgMatches) -> H256 { @@ -388,8 +389,7 @@ fn read_genesis_hash(matches: &ArgMatches) -> H256 { genesis_hash } -fn read_signature(matches: &ArgMatches) -> SignatureOf -where +fn read_signature(matches: &ArgMatches) -> SignatureOf where SignatureOf: SignatureT, PublicOf: PublicT, { @@ -446,8 +446,7 @@ fn read_account_id(matched_uri: Option<&str>) -> AccountId { fn read_pair( matched_suri: Option<&str>, password: Option<&str>, -) -> ::Pair -where +) -> ::Pair where SignatureOf: SignatureT, PublicOf: PublicT, { diff --git a/client/consensus/uncles/src/lib.rs b/client/consensus/uncles/src/lib.rs index 5839fb0a01..4a7e8dc0d6 100644 --- a/client/consensus/uncles/src/lib.rs +++ b/client/consensus/uncles/src/lib.rs @@ -15,8 +15,6 @@ // along with Substrate. If not, see . //! Uncles functionality for Substrate. -//! -#![deny(warnings)] #![forbid(unsafe_code, missing_docs)] use sp_consensus::SelectChain; -- GitLab From 56b127e7820a8fb30b6e23dc31a52c986e24d8c8 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Wed, 18 Dec 2019 10:50:21 +0100 Subject: [PATCH 156/172] More `decl_error!` migrations (#4427) * Update assets to `decl_error` * Update aura to `decl_error` * Update authority discovery to `decl_error` * Update collective to `decl_error` * Update evm to `decl_error!` * Fix error with replace * Revert "Update authority discovery to `decl_error`" This reverts commit 26e8f3c56656963d847e984c6f2c8e1f88014899. * Revert "Update aura to `decl_error`" This reverts commit 8f17c44ca8375a4a755710aaab7ad4d9522c4376. * Update democracy to `decl_error` * Update finality-tracker to `decl_error` * Update grandpa to `decl_error` * `assert` to `ensure` in dispatchable function --- frame/assets/src/lib.rs | 50 ++++-- frame/collective/src/lib.rs | 61 +++++--- frame/democracy/src/lib.rs | 250 ++++++++++++++++++------------ frame/evm/src/lib.rs | 85 +++++----- frame/finality-tracker/src/lib.rs | 22 ++- frame/grandpa/src/lib.rs | 49 ++++-- 6 files changed, 323 insertions(+), 194 deletions(-) diff --git a/frame/assets/src/lib.rs b/frame/assets/src/lib.rs index 87e74c0c6c..3beb247170 100644 --- a/frame/assets/src/lib.rs +++ b/frame/assets/src/lib.rs @@ -84,7 +84,8 @@ //! ### Simple Code Snippet //! //! ```rust,ignore -//! use frame_support::{decl_module, dispatch}; +//! use pallet_assets as assets; +//! use frame_support::{decl_module, dispatch, ensure}; //! use frame_system::{self as system, ensure_signed}; //! //! pub trait Trait: assets::Trait { } @@ -92,14 +93,15 @@ //! decl_module! { //! pub struct Module for enum Call where origin: T::Origin { //! pub fn issue_token_airdrop(origin) -> dispatch::Result { +//! let sender = ensure_signed(origin).map_err(|e| e.as_str())?; +//! //! const ACCOUNT_ALICE: u64 = 1; //! const ACCOUNT_BOB: u64 = 2; -//! const COUNT_AIRDROP_RECIPIENTS = 2; +//! const COUNT_AIRDROP_RECIPIENTS: u64 = 2; //! const TOKENS_FIXED_SUPPLY: u64 = 100; //! //! ensure!(!COUNT_AIRDROP_RECIPIENTS.is_zero(), "Divide by zero error."); //! -//! let sender = ensure_signed(origin)?; //! let asset_id = Self::next_asset_id(); //! //! >::mutate(|asset_id| *asset_id += 1); @@ -130,8 +132,8 @@ // Ensure we're `no_std` when compiling for Wasm. #![cfg_attr(not(feature = "std"), no_std)] -use frame_support::{Parameter, decl_module, decl_event, decl_storage, ensure}; -use sp_runtime::traits::{Member, SimpleArithmetic, Zero, StaticLookup}; +use frame_support::{Parameter, decl_module, decl_event, decl_storage, decl_error, ensure}; +use sp_runtime::traits::{Member, SimpleArithmetic, Zero, StaticLookup, ModuleDispatchError}; use frame_system::{self as system, ensure_signed}; use sp_runtime::traits::One; @@ -149,12 +151,14 @@ pub trait Trait: frame_system::Trait { decl_module! { pub struct Module for enum Call where origin: T::Origin { + type Error = Error; + fn deposit_event() = default; /// Issue a new class of fungible assets. There are, and will only ever be, `total` /// such assets and they'll all belong to the `origin` initially. It will have an /// identifier `AssetId` instance: this will be specified in the `Issued` event. fn issue(origin, #[compact] total: T::Balance) { - let origin = ensure_signed(origin)?; + let origin = ensure_signed(origin).map_err(|e| e.as_str())?; let id = Self::next_asset_id(); >::mutate(|id| *id += One::one()); @@ -171,12 +175,12 @@ decl_module! { target: ::Source, #[compact] amount: T::Balance ) { - let origin = ensure_signed(origin)?; + let origin = ensure_signed(origin).map_err(|e| e.as_str())?; let origin_account = (id, origin.clone()); let origin_balance = >::get(&origin_account); let target = T::Lookup::lookup(target)?; - ensure!(!amount.is_zero(), "transfer amount should be non-zero"); - ensure!(origin_balance >= amount, "origin account balance must be greater than or equal to the transfer amount"); + ensure!(!amount.is_zero(), Error::AmountZero); + ensure!(origin_balance >= amount, Error::BalanceLow); Self::deposit_event(RawEvent::Transferred(id, origin, target.clone(), amount)); >::insert(origin_account, origin_balance - amount); @@ -185,9 +189,9 @@ decl_module! { /// Destroy any assets of `id` owned by `origin`. fn destroy(origin, #[compact] id: T::AssetId) { - let origin = ensure_signed(origin)?; + let origin = ensure_signed(origin).map_err(|e| e.as_str())?; let balance = >::take((id, &origin)); - ensure!(!balance.is_zero(), "origin balance should be non-zero"); + ensure!(!balance.is_zero(), Error::BalanceZero); >::mutate(id, |total_supply| *total_supply -= balance); Self::deposit_event(RawEvent::Destroyed(id, origin, balance)); @@ -195,7 +199,7 @@ decl_module! { } } -decl_event!( +decl_event! { pub enum Event where ::AccountId, ::Balance, @@ -208,7 +212,19 @@ decl_event!( /// Some assets were destroyed. Destroyed(AssetId, AccountId, Balance), } -); +} + +decl_error! { + pub enum Error { + /// Transfer amount should be non-zero + AmountZero, + /// Account balance must be greater than or equal to the transfer amount + BalanceLow, + /// Balance should be non-zero + BalanceZero, + } + +} decl_storage! { trait Store for Module as Assets { @@ -337,7 +353,7 @@ mod tests { assert_eq!(Assets::balance(0, 2), 50); assert_ok!(Assets::destroy(Origin::signed(1), 0)); assert_eq!(Assets::balance(0, 1), 0); - assert_noop!(Assets::transfer(Origin::signed(1), 0, 1, 50), "origin account balance must be greater than or equal to the transfer amount"); + assert_noop!(Assets::transfer(Origin::signed(1), 0, 1, 50), Error::BalanceLow); }); } @@ -346,7 +362,7 @@ mod tests { new_test_ext().execute_with(|| { assert_ok!(Assets::issue(Origin::signed(1), 100)); assert_eq!(Assets::balance(0, 1), 100); - assert_noop!(Assets::transfer(Origin::signed(1), 0, 2, 0), "transfer amount should be non-zero"); + assert_noop!(Assets::transfer(Origin::signed(1), 0, 2, 0), Error::AmountZero); }); } @@ -355,7 +371,7 @@ mod tests { new_test_ext().execute_with(|| { assert_ok!(Assets::issue(Origin::signed(1), 100)); assert_eq!(Assets::balance(0, 1), 100); - assert_noop!(Assets::transfer(Origin::signed(1), 0, 2, 101), "origin account balance must be greater than or equal to the transfer amount"); + assert_noop!(Assets::transfer(Origin::signed(1), 0, 2, 101), Error::BalanceLow); }); } @@ -373,7 +389,7 @@ mod tests { new_test_ext().execute_with(|| { assert_ok!(Assets::issue(Origin::signed(1), 100)); assert_eq!(Assets::balance(0, 2), 0); - assert_noop!(Assets::destroy(Origin::signed(2), 0), "origin balance should be non-zero"); + assert_noop!(Assets::destroy(Origin::signed(2), 0), Error::BalanceZero); }); } } diff --git a/frame/collective/src/lib.rs b/frame/collective/src/lib.rs index 1fd718bc01..11134c87de 100644 --- a/frame/collective/src/lib.rs +++ b/frame/collective/src/lib.rs @@ -26,12 +26,12 @@ use sp_std::{prelude::*, result}; use sp_core::u32_trait::Value as U32; use sp_runtime::RuntimeDebug; -use sp_runtime::traits::{Hash, EnsureOrigin}; +use sp_runtime::traits::{Hash, EnsureOrigin, ModuleDispatchError}; use frame_support::weights::SimpleDispatchInfo; use frame_support::{ dispatch::{Dispatchable, Parameter}, codec::{Encode, Decode}, traits::{ChangeMembers, InitializeMembers}, decl_module, decl_event, - decl_storage, ensure, + decl_storage, decl_error, ensure, }; use frame_system::{self as system, ensure_signed, ensure_root}; @@ -102,7 +102,7 @@ decl_storage! { } } -decl_event!( +decl_event! { pub enum Event where ::Hash, ::AccountId, @@ -122,13 +122,32 @@ decl_event!( /// A single member did some action; `bool` is true if returned without error. MemberExecuted(Hash, bool), } -); +} + +decl_error! { + pub enum Error { + /// Account is not a member + NotMember, + /// Duplicate proposals not allowed + DuplicateProposal, + /// Proposal must exist + ProposalMissing, + /// Mismatched index + WrongIndex, + /// Duplicate vote ignored + DuplicateVote, + /// Members are already initialized! + AlreadyInitialized, + } +} // Note: this module is not benchmarked. The weights are obtained based on the similarity of the // executed logic with other democracy function. Note that councillor operations are assigned to the // operational class. decl_module! { pub struct Module, I: Instance=DefaultInstance> for enum Call where origin: ::Origin { + type Error = Error; + fn deposit_event() = default; /// Set the collective's membership manually to `new_members`. Be nice to the chain and @@ -137,7 +156,7 @@ decl_module! { /// Requires root origin. #[weight = SimpleDispatchInfo::FixedOperational(100_000)] fn set_members(origin, new_members: Vec) { - ensure_root(origin)?; + ensure_root(origin).map_err(|e| e.as_str())?; let mut new_members = new_members; new_members.sort(); >::mutate(|m| { @@ -151,8 +170,8 @@ decl_module! { /// Origin must be a member of the collective. #[weight = SimpleDispatchInfo::FixedOperational(100_000)] fn execute(origin, proposal: Box<>::Proposal>) { - let who = ensure_signed(origin)?; - ensure!(Self::is_member(&who), "proposer not a member"); + let who = ensure_signed(origin).map_err(|e| e.as_str())?; + ensure!(Self::is_member(&who), Error::NotMember); let proposal_hash = T::Hashing::hash_of(&proposal); let ok = proposal.dispatch(RawOrigin::Member(who).into()).is_ok(); @@ -165,12 +184,12 @@ decl_module! { /// # #[weight = SimpleDispatchInfo::FixedOperational(5_000_000)] fn propose(origin, #[compact] threshold: MemberCount, proposal: Box<>::Proposal>) { - let who = ensure_signed(origin)?; - ensure!(Self::is_member(&who), "proposer not a member"); + let who = ensure_signed(origin).map_err(|e| e.as_str())?; + ensure!(Self::is_member(&who), Error::NotMember); let proposal_hash = T::Hashing::hash_of(&proposal); - ensure!(!>::exists(proposal_hash), "duplicate proposals not allowed"); + ensure!(!>::exists(proposal_hash), Error::DuplicateProposal); if threshold < 2 { let seats = Self::members().len() as MemberCount; @@ -194,11 +213,11 @@ decl_module! { /// # #[weight = SimpleDispatchInfo::FixedOperational(200_000)] fn vote(origin, proposal: T::Hash, #[compact] index: ProposalIndex, approve: bool) { - let who = ensure_signed(origin)?; - ensure!(Self::is_member(&who), "voter not a member"); + let who = ensure_signed(origin).map_err(|e| e.as_str())?; + ensure!(Self::is_member(&who), Error::NotMember); - let mut voting = Self::voting(&proposal).ok_or("proposal must exist")?; - ensure!(voting.index == index, "mismatched index"); + let mut voting = Self::voting(&proposal).ok_or(Error::ProposalMissing)?; + ensure!(voting.index == index, Error::WrongIndex); let position_yes = voting.ayes.iter().position(|a| a == &who); let position_no = voting.nays.iter().position(|a| a == &who); @@ -207,7 +226,7 @@ decl_module! { if position_yes.is_none() { voting.ayes.push(who.clone()); } else { - return Err("duplicate vote ignored") + return Err(Error::DuplicateVote) } if let Some(pos) = position_no { voting.nays.swap_remove(pos); @@ -216,7 +235,7 @@ decl_module! { if position_no.is_none() { voting.nays.push(who.clone()); } else { - return Err("duplicate vote ignored") + return Err(Error::DuplicateVote) } if let Some(pos) = position_yes { voting.ayes.swap_remove(pos); @@ -565,7 +584,7 @@ mod tests { let proposal = make_proposal(42); assert_noop!( Collective::propose(Origin::signed(42), 3, Box::new(proposal.clone())), - "proposer not a member" + Error::NotMember ); }); } @@ -579,7 +598,7 @@ mod tests { assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()))); assert_noop!( Collective::vote(Origin::signed(42), hash.clone(), 0, true), - "voter not a member", + Error::NotMember, ); }); } @@ -593,7 +612,7 @@ mod tests { assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()))); assert_noop!( Collective::vote(Origin::signed(2), hash.clone(), 1, true), - "mismatched index", + Error::WrongIndex, ); }); } @@ -611,7 +630,7 @@ mod tests { ); assert_noop!( Collective::vote(Origin::signed(1), hash.clone(), 0, true), - "duplicate vote ignored", + Error::DuplicateVote, ); assert_ok!(Collective::vote(Origin::signed(1), hash.clone(), 0, false)); assert_eq!( @@ -620,7 +639,7 @@ mod tests { ); assert_noop!( Collective::vote(Origin::signed(1), hash.clone(), 0, false), - "duplicate vote ignored", + Error::DuplicateVote, ); assert_eq!(System::events(), vec![ diff --git a/frame/democracy/src/lib.rs b/frame/democracy/src/lib.rs index ea51c4e1d9..eb9cf819c5 100644 --- a/frame/democracy/src/lib.rs +++ b/frame/democracy/src/lib.rs @@ -22,12 +22,14 @@ use sp_std::prelude::*; use sp_std::{result, convert::TryFrom}; use sp_runtime::{ RuntimeDebug, - traits::{Zero, Bounded, CheckedMul, CheckedDiv, EnsureOrigin, Hash, Dispatchable, Saturating}, + traits::{ + Zero, Bounded, CheckedMul, CheckedDiv, EnsureOrigin, Hash, + Dispatchable, Saturating, ModuleDispatchError, + }, }; -use codec::{Ref, Encode, Decode, Input, Output, Error}; +use codec::{Ref, Encode, Decode, Input, Output}; use frame_support::{ - decl_module, decl_storage, decl_event, ensure, - dispatch, + decl_module, decl_storage, decl_event, decl_error, ensure, Parameter, weights::SimpleDispatchInfo, traits::{ @@ -163,12 +165,12 @@ impl Encode for Vote { impl codec::EncodeLike for Vote {} impl Decode for Vote { - fn decode(input: &mut I) -> core::result::Result { + fn decode(input: &mut I) -> core::result::Result { let b = input.read_byte()?; Ok(Vote { aye: (b & 0b1000_0000) == 0b1000_0000, conviction: Conviction::try_from(b & 0b0111_1111) - .map_err(|_| Error::from("Invalid conviction"))?, + .map_err(|_| codec::Error::from("Invalid conviction"))?, }) } } @@ -320,7 +322,7 @@ decl_storage! { } } -decl_event!( +decl_event! { pub enum Event where Balance = BalanceOf, ::AccountId, @@ -360,10 +362,60 @@ decl_event!( /// A registered preimage was removed and the deposit collected by the reaper (last item). PreimageReaped(Hash, AccountId, Balance, AccountId), } -); +} + +decl_error! { + pub enum Error { + /// Value too low + ValueLow, + /// Proposal does not exist + ProposalMissing, + /// Not a proxy + NotProxy, + /// Unknown index + BadIndex, + /// Cannot cancel the same proposal twice + AlreadyCanceled, + /// Proposal already made + DuplicateProposal, + /// Proposal still blacklisted + ProposalBlacklisted, + /// Next external proposal not simple majority + NotSimpleMajority, + /// Invalid hash + InvalidHash, + /// No external proposal + NoProposal, + /// Identity may not veto a proposal twice + AlreadyVetoed, + /// Already a proxy + AlreadyProxy, + /// Wrong proxy + WrongProxy, + /// Not delegated + NotDelegated, + /// Preimage already noted + DuplicatePreimage, + /// Not imminent + NotImminent, + /// Too early + Early, + /// Imminent + Imminent, + /// Preimage not found + PreimageMissing, + /// Vote given for invalid referendum + ReferendumInvalid, + /// Invalid preimage + PreimageInvalid, + /// No proposals waiting + NoneWaiting, + } +} decl_module! { pub struct Module for enum Call where origin: T::Origin { + type Error = Error; /// The minimum period of locking and the period between a proposal being approved and enacted. /// /// It should generally be a little more than the unstake period to ensure that @@ -402,10 +454,9 @@ decl_module! { proposal_hash: T::Hash, #[compact] value: BalanceOf ) { - let who = ensure_signed(origin)?; - ensure!(value >= T::MinimumDeposit::get(), "value too low"); - T::Currency::reserve(&who, value) - .map_err(|_| "proposer's balance too low")?; + let who = ensure_signed(origin).map_err(|e| e.as_str())?; + ensure!(value >= T::MinimumDeposit::get(), Error::ValueLow); + T::Currency::reserve(&who, value)?; let index = Self::public_prop_count(); PublicPropCount::put(index + 1); @@ -425,11 +476,10 @@ decl_module! { /// # #[weight = SimpleDispatchInfo::FixedNormal(5_000_000)] fn second(origin, #[compact] proposal: PropIndex) { - let who = ensure_signed(origin)?; + let who = ensure_signed(origin).map_err(|e| e.as_str())?; let mut deposit = Self::deposit_of(proposal) - .ok_or("can only second an existing proposal")?; - T::Currency::reserve(&who, deposit.0) - .map_err(|_| "seconder's balance too low")?; + .ok_or(Error::ProposalMissing)?; + T::Currency::reserve(&who, deposit.0)?; deposit.1.push(who); >::insert(proposal, deposit); } @@ -445,8 +495,8 @@ decl_module! { fn vote(origin, #[compact] ref_index: ReferendumIndex, vote: Vote - ) -> dispatch::Result { - let who = ensure_signed(origin)?; + ) -> Result<(), Error> { + let who = ensure_signed(origin).map_err(|e| e.as_str())?; Self::do_vote(who, ref_index, vote) } @@ -461,8 +511,10 @@ decl_module! { fn proxy_vote(origin, #[compact] ref_index: ReferendumIndex, vote: Vote - ) -> dispatch::Result { - let who = Self::proxy(ensure_signed(origin)?).ok_or("not a proxy")?; + ) -> Result<(), Error> { + let who = Self::proxy( + ensure_signed(origin).map_err(|e| e.as_str())? + ).ok_or(Error::NotProxy)?; Self::do_vote(who, ref_index, vote) } @@ -470,11 +522,11 @@ decl_module! { /// referendum. #[weight = SimpleDispatchInfo::FixedOperational(500_000)] fn emergency_cancel(origin, ref_index: ReferendumIndex) { - T::CancellationOrigin::ensure_origin(origin)?; + T::CancellationOrigin::ensure_origin(origin).map_err(|e| Into::<&str>::into(e))?; - let info = Self::referendum_info(ref_index).ok_or("unknown index")?; + let info = Self::referendum_info(ref_index).ok_or(Error::BadIndex)?; let h = info.proposal_hash; - ensure!(!>::exists(h), "cannot cancel the same proposal twice"); + ensure!(!>::exists(h), Error::AlreadyCanceled); >::insert(h, true); Self::clear_referendum(ref_index); @@ -484,10 +536,10 @@ decl_module! { /// referendum. #[weight = SimpleDispatchInfo::FixedNormal(5_000_000)] fn external_propose(origin, proposal_hash: T::Hash) { - T::ExternalOrigin::ensure_origin(origin)?; - ensure!(!>::exists(), "proposal already made"); + T::ExternalOrigin::ensure_origin(origin).map_err(|e| Into::<&str>::into(e))?; + ensure!(!>::exists(), Error::DuplicateProposal); if let Some((until, _)) = >::get(proposal_hash) { - ensure!(>::block_number() >= until, "proposal still blacklisted"); + ensure!(>::block_number() >= until, Error::ProposalBlacklisted); } >::put((proposal_hash, VoteThreshold::SuperMajorityApprove)); } @@ -499,7 +551,7 @@ decl_module! { /// pre-scheduled `external_propose` call. #[weight = SimpleDispatchInfo::FixedNormal(5_000_000)] fn external_propose_majority(origin, proposal_hash: T::Hash) { - T::ExternalMajorityOrigin::ensure_origin(origin)?; + T::ExternalMajorityOrigin::ensure_origin(origin).map_err(|e| Into::<&str>::into(e))?; >::put((proposal_hash, VoteThreshold::SimpleMajority)); } @@ -510,7 +562,7 @@ decl_module! { /// pre-scheduled `external_propose` call. #[weight = SimpleDispatchInfo::FixedNormal(5_000_000)] fn external_propose_default(origin, proposal_hash: T::Hash) { - T::ExternalDefaultOrigin::ensure_origin(origin)?; + T::ExternalDefaultOrigin::ensure_origin(origin).map_err(|e| Into::<&str>::into(e))?; >::put((proposal_hash, VoteThreshold::SuperMajorityAgainst)); } @@ -529,13 +581,13 @@ decl_module! { voting_period: T::BlockNumber, delay: T::BlockNumber ) { - T::FastTrackOrigin::ensure_origin(origin)?; - let (e_proposal_hash, threshold) = >::get().ok_or("no proposal made")?; + T::FastTrackOrigin::ensure_origin(origin).map_err(|e| Into::<&str>::into(e))?; + let (e_proposal_hash, threshold) = >::get().ok_or(Error::ProposalMissing)?; ensure!( threshold != VoteThreshold::SuperMajorityApprove, - "next external proposal not simple majority" + Error::NotSimpleMajority ); - ensure!(proposal_hash == e_proposal_hash, "invalid hash"); + ensure!(proposal_hash == e_proposal_hash, Error::InvalidHash); >::kill(); let now = >::block_number(); @@ -547,19 +599,19 @@ decl_module! { /// Veto and blacklist the external proposal hash. #[weight = SimpleDispatchInfo::FixedNormal(200_000)] fn veto_external(origin, proposal_hash: T::Hash) { - let who = T::VetoOrigin::ensure_origin(origin)?; + let who = T::VetoOrigin::ensure_origin(origin).map_err(|e| Into::<&str>::into(e))?; if let Some((e_proposal_hash, _)) = >::get() { - ensure!(proposal_hash == e_proposal_hash, "unknown proposal"); + ensure!(proposal_hash == e_proposal_hash, Error::ProposalMissing); } else { - Err("no external proposal")?; + Err(Error::NoProposal)?; } let mut existing_vetoers = >::get(&proposal_hash) .map(|pair| pair.1) .unwrap_or_else(Vec::new); let insert_position = existing_vetoers.binary_search(&who) - .err().ok_or("identity may not veto a proposal twice")?; + .err().ok_or(Error::AlreadyVetoed)?; existing_vetoers.insert(insert_position, who.clone()); let until = >::block_number() + T::CooloffPeriod::get(); @@ -572,24 +624,24 @@ decl_module! { /// Remove a referendum. #[weight = SimpleDispatchInfo::FixedOperational(10_000)] fn cancel_referendum(origin, #[compact] ref_index: ReferendumIndex) { - ensure_root(origin)?; + ensure_root(origin).map_err(|e| e.as_str())?; Self::clear_referendum(ref_index); } /// Cancel a proposal queued for enactment. #[weight = SimpleDispatchInfo::FixedOperational(10_000)] fn cancel_queued(origin, which: ReferendumIndex) { - ensure_root(origin)?; + ensure_root(origin).map_err(|e| e.as_str())?; let mut items = >::get(); let original_len = items.len(); items.retain(|i| i.2 != which); - ensure!(items.len() < original_len, "proposal not found"); + ensure!(items.len() < original_len, Error::ProposalMissing); >::put(items); } fn on_initialize(n: T::BlockNumber) { if let Err(e) = Self::begin_block(n) { - sp_runtime::print(e); + sp_runtime::print(e.as_str()); } } @@ -600,8 +652,8 @@ decl_module! { /// # #[weight = SimpleDispatchInfo::FixedNormal(100_000)] fn set_proxy(origin, proxy: T::AccountId) { - let who = ensure_signed(origin)?; - ensure!(!>::exists(&proxy), "already a proxy"); + let who = ensure_signed(origin).map_err(|e| e.as_str())?; + ensure!(!>::exists(&proxy), Error::AlreadyProxy); >::insert(proxy, who) } @@ -612,7 +664,7 @@ decl_module! { /// # #[weight = SimpleDispatchInfo::FixedNormal(100_000)] fn resign_proxy(origin) { - let who = ensure_signed(origin)?; + let who = ensure_signed(origin).map_err(|e| e.as_str())?; >::remove(who); } @@ -623,8 +675,8 @@ decl_module! { /// # #[weight = SimpleDispatchInfo::FixedNormal(100_000)] fn remove_proxy(origin, proxy: T::AccountId) { - let who = ensure_signed(origin)?; - ensure!(&Self::proxy(&proxy).ok_or("not a proxy")? == &who, "wrong proxy"); + let who = ensure_signed(origin).map_err(|e| e.as_str())?; + ensure!(&Self::proxy(&proxy).ok_or(Error::NotProxy)? == &who, Error::WrongProxy); >::remove(proxy); } @@ -635,7 +687,7 @@ decl_module! { /// # #[weight = SimpleDispatchInfo::FixedNormal(500_000)] pub fn delegate(origin, to: T::AccountId, conviction: Conviction) { - let who = ensure_signed(origin)?; + let who = ensure_signed(origin).map_err(|e| e.as_str())?; >::insert(&who, (&to, conviction)); // Currency is locked indefinitely as long as it's delegated. T::Currency::extend_lock( @@ -655,8 +707,8 @@ decl_module! { /// # #[weight = SimpleDispatchInfo::FixedNormal(500_000)] fn undelegate(origin) { - let who = ensure_signed(origin)?; - ensure!(>::exists(&who), "not delegated"); + let who = ensure_signed(origin).map_err(|e| e.as_str())?; + ensure!(>::exists(&who), Error::NotDelegated); let (_, conviction) = >::take(&who); // Indefinite lock is reduced to the maximum voting lock that could be possible. let now = >::block_number(); @@ -674,7 +726,7 @@ decl_module! { /// Veto and blacklist the proposal hash. Must be from Root origin. #[weight = SimpleDispatchInfo::FixedNormal(10_000)] fn clear_public_proposals(origin) { - ensure_root(origin)?; + ensure_root(origin).map_err(|e| e.as_str())?; >::kill(); } @@ -683,9 +735,9 @@ decl_module! { /// in the dispatch queue but does require a deposit, returned once enacted. #[weight = SimpleDispatchInfo::FixedNormal(100_000)] fn note_preimage(origin, encoded_proposal: Vec) { - let who = ensure_signed(origin)?; + let who = ensure_signed(origin).map_err(|e| e.as_str())?; let proposal_hash = T::Hashing::hash(&encoded_proposal[..]); - ensure!(!>::exists(&proposal_hash), "preimage already noted"); + ensure!(!>::exists(&proposal_hash), Error::DuplicatePreimage); let deposit = >::from(encoded_proposal.len() as u32) .saturating_mul(T::PreimageByteDeposit::get()); @@ -701,11 +753,11 @@ decl_module! { /// in the dispatch queue. No deposit is needed. #[weight = SimpleDispatchInfo::FixedNormal(100_000)] fn note_imminent_preimage(origin, encoded_proposal: Vec) { - let who = ensure_signed(origin)?; + let who = ensure_signed(origin).map_err(|e| e.as_str())?; let proposal_hash = T::Hashing::hash(&encoded_proposal[..]); - ensure!(!>::exists(&proposal_hash), "preimage already noted"); + ensure!(!>::exists(&proposal_hash), Error::DuplicatePreimage); let queue = >::get(); - ensure!(queue.iter().any(|item| &item.1 == &proposal_hash), "not imminent"); + ensure!(queue.iter().any(|item| &item.1 == &proposal_hash), Error::NotImminent); let now = >::block_number(); let free = >::zero(); @@ -721,16 +773,16 @@ decl_module! { /// work an additional `EnactmentPeriod` later. #[weight = SimpleDispatchInfo::FixedNormal(10_000)] fn reap_preimage(origin, proposal_hash: T::Hash) { - let who = ensure_signed(origin)?; + let who = ensure_signed(origin).map_err(|e| e.as_str())?; - let (_, old, deposit, then) = >::get(&proposal_hash).ok_or("not found")?; + let (_, old, deposit, then) = >::get(&proposal_hash).ok_or(Error::PreimageMissing)?; let now = >::block_number(); let (voting, enactment) = (T::VotingPeriod::get(), T::EnactmentPeriod::get()); let additional = if who == old { Zero::zero() } else { enactment }; - ensure!(now >= then + voting + additional, "too early"); + ensure!(now >= then + voting + additional, Error::Early); let queue = >::get(); - ensure!(!queue.iter().any(|item| &item.1 == &proposal_hash), "imminent"); + ensure!(!queue.iter().any(|item| &item.1 == &proposal_hash), Error::Imminent); let _ = T::Currency::repatriate_reserved(&old, &who, deposit); >::remove(&proposal_hash); @@ -879,8 +931,8 @@ impl Module { // private. /// Actually enact a vote, if legit. - fn do_vote(who: T::AccountId, ref_index: ReferendumIndex, vote: Vote) -> dispatch::Result { - ensure!(Self::is_active_referendum(ref_index), "vote given for invalid referendum."); + fn do_vote(who: T::AccountId, ref_index: ReferendumIndex, vote: Vote) -> Result<(), Error> { + ensure!(Self::is_active_referendum(ref_index), Error::ReferendumInvalid); if !>::exists((ref_index, &who)) { >::append_or_insert(ref_index, &[&who][..]); } @@ -921,7 +973,7 @@ impl Module { } /// Enact a proposal from a referendum. - fn enact_proposal(proposal_hash: T::Hash, index: ReferendumIndex) -> dispatch::Result { + fn enact_proposal(proposal_hash: T::Hash, index: ReferendumIndex) -> Result<(), Error> { if let Some((encoded_proposal, who, amount, _)) = >::take(&proposal_hash) { if let Ok(proposal) = T::Proposal::decode(&mut &encoded_proposal[..]) { let _ = T::Currency::unreserve(&who, amount); @@ -934,25 +986,25 @@ impl Module { } else { T::Slash::on_unbalanced(T::Currency::slash_reserved(&who, amount).0); Self::deposit_event(RawEvent::PreimageInvalid(proposal_hash, index)); - Err("invalid preimage") + Err(Error::PreimageInvalid) } } else { Self::deposit_event(RawEvent::PreimageMissing(proposal_hash, index)); - Err("missing preimage") + Err(Error::PreimageMissing) } } /// Table the next waiting proposal for a vote. - fn launch_next(now: T::BlockNumber) -> dispatch::Result { + fn launch_next(now: T::BlockNumber) -> Result<(), Error> { if LastTabledWasExternal::take() { Self::launch_public(now).or_else(|_| Self::launch_external(now)) } else { Self::launch_external(now).or_else(|_| Self::launch_public(now)) - }.map_err(|_| "No proposals waiting") + }.map_err(|_| Error::NoneWaiting) } /// Table the waiting external proposal for a vote, if there is one. - fn launch_external(now: T::BlockNumber) -> dispatch::Result { + fn launch_external(now: T::BlockNumber) -> Result<(), Error> { if let Some((proposal, threshold)) = >::take() { LastTabledWasExternal::put(true); Self::deposit_event(RawEvent::ExternalTabled); @@ -964,12 +1016,12 @@ impl Module { ); Ok(()) } else { - Err("No external proposal waiting") + Err(Error::NoneWaiting) } } /// Table the waiting public proposal with the highest backing for a vote. - fn launch_public(now: T::BlockNumber) -> dispatch::Result { + fn launch_public(now: T::BlockNumber) -> Result<(), Error> { let mut public_props = Self::public_props(); if let Some((winner_index, _)) = public_props.iter() .enumerate() @@ -994,7 +1046,7 @@ impl Module { } Ok(()) } else { - Err("No public proposals waiting") + Err(Error::NoneWaiting) } } @@ -1003,7 +1055,7 @@ impl Module { now: T::BlockNumber, index: ReferendumIndex, info: ReferendumInfo - ) -> dispatch::Result { + ) -> Result<(), Error> { let (approve, against, capital) = Self::tally(index); let total_issuance = T::Currency::total_issuance(); let approved = info.threshold.approved(approve, against, capital, total_issuance); @@ -1051,7 +1103,7 @@ impl Module { } /// Current era is ending; we should finish up any proposals. - fn begin_block(now: T::BlockNumber) -> dispatch::Result { + fn begin_block(now: T::BlockNumber) -> Result<(), Error> { // pick out another public referendum if it's time. if (now % T::LaunchPeriod::get()).is_zero() { // Errors come from the queue being empty. we don't really care about that, and even if @@ -1237,13 +1289,13 @@ mod tests { let p = set_balance_proposal(value); let h = BlakeTwo256::hash(&p[..]); match Democracy::note_preimage(Origin::signed(6), p) { - Ok(_) | Err("preimage already noted") => (), + Ok(_) | Err(Error::DuplicatePreimage) => (), Err(x) => panic!(x), } h } - fn propose_set_balance(who: u64, value: u64, delay: u64) -> dispatch::Result { + fn propose_set_balance(who: u64, value: u64, delay: u64) -> Result<(), Error> { Democracy::propose( Origin::signed(who), set_balance_proposal_hash(value), @@ -1251,7 +1303,7 @@ mod tests { ) } - fn propose_set_balance_and_note(who: u64, value: u64, delay: u64) -> dispatch::Result { + fn propose_set_balance_and_note(who: u64, value: u64, delay: u64) -> Result<(), Error> { Democracy::propose( Origin::signed(who), set_balance_proposal_hash_and_note(value), @@ -1297,7 +1349,7 @@ mod tests { PREIMAGE_BYTE_DEPOSIT.with(|v| *v.borrow_mut() = 100); assert_noop!( Democracy::note_preimage(Origin::signed(6), vec![0; 500]), - "not enough free funds" + Error::Other("not enough free funds") ); // fee of 1 is reasonable. PREIMAGE_BYTE_DEPOSIT.with(|v| *v.borrow_mut() = 1); @@ -1332,7 +1384,7 @@ mod tests { next_block(); assert_noop!( Democracy::reap_preimage(Origin::signed(6), set_balance_proposal_hash(2)), - "too early" + Error::Early ); next_block(); assert_ok!(Democracy::reap_preimage(Origin::signed(6), set_balance_proposal_hash(2))); @@ -1348,7 +1400,7 @@ mod tests { System::set_block_number(1); assert_noop!( Democracy::reap_preimage(Origin::signed(5), set_balance_proposal_hash(2)), - "not found" + Error::PreimageMissing ); PREIMAGE_BYTE_DEPOSIT.with(|v| *v.borrow_mut() = 1); @@ -1360,7 +1412,7 @@ mod tests { next_block(); assert_noop!( Democracy::reap_preimage(Origin::signed(5), set_balance_proposal_hash(2)), - "too early" + Error::Early ); next_block(); @@ -1387,7 +1439,7 @@ mod tests { assert_noop!( Democracy::note_imminent_preimage(Origin::signed(7), set_balance_proposal(2)), - "not imminent" + Error::NotImminent ); next_block(); @@ -1411,7 +1463,7 @@ mod tests { next_block(); next_block(); // now imminent. - assert_noop!(Democracy::reap_preimage(Origin::signed(6), h), "imminent"); + assert_noop!(Democracy::reap_preimage(Origin::signed(6), h), Error::Imminent); }); } @@ -1540,7 +1592,7 @@ mod tests { ); assert!(Democracy::referendum_info(r).is_some()); - assert_noop!(Democracy::emergency_cancel(Origin::signed(3), r), "Invalid origin"); + assert_noop!(Democracy::emergency_cancel(Origin::signed(3), r), "Invalid origin".into()); assert_ok!(Democracy::emergency_cancel(Origin::signed(4), r)); assert!(Democracy::referendum_info(r).is_none()); @@ -1553,7 +1605,7 @@ mod tests { 2 ); assert!(Democracy::referendum_info(r).is_some()); - assert_noop!(Democracy::emergency_cancel(Origin::signed(4), r), "cannot cancel the same proposal twice"); + assert_noop!(Democracy::emergency_cancel(Origin::signed(4), r), Error::AlreadyCanceled); }); } @@ -1575,14 +1627,14 @@ mod tests { assert_noop!(Democracy::external_propose( Origin::signed(2), set_balance_proposal_hash(2), - ), "proposal still blacklisted"); + ), Error::ProposalBlacklisted); fast_forward_to(1); // fails as we're still in cooloff period. assert_noop!(Democracy::external_propose( Origin::signed(2), set_balance_proposal_hash(2), - ), "proposal still blacklisted"); + ), Error::ProposalBlacklisted); fast_forward_to(2); // works; as we're out of the cooloff period. @@ -1595,7 +1647,7 @@ mod tests { // 3 can't veto the same thing twice. assert_noop!( Democracy::veto_external(Origin::signed(3), h.clone()), - "identity may not veto a proposal twice" + Error::AlreadyVetoed ); // 4 vetoes. @@ -1608,7 +1660,7 @@ mod tests { assert_noop!(Democracy::external_propose( Origin::signed(2), set_balance_proposal_hash(2), - ), "proposal still blacklisted"); + ), Error::ProposalBlacklisted); // different proposal works fine. assert_ok!(Democracy::external_propose( Origin::signed(2), @@ -1624,7 +1676,7 @@ mod tests { assert_noop!(Democracy::external_propose( Origin::signed(1), set_balance_proposal_hash(2), - ), "Invalid origin"); + ), "Invalid origin".into()); assert_ok!(Democracy::external_propose( Origin::signed(2), set_balance_proposal_hash_and_note(2), @@ -1632,7 +1684,7 @@ mod tests { assert_noop!(Democracy::external_propose( Origin::signed(2), set_balance_proposal_hash(1), - ), "proposal already made"); + ), Error::DuplicateProposal); fast_forward_to(2); assert_eq!( Democracy::referendum_info(0), @@ -1653,7 +1705,7 @@ mod tests { assert_noop!(Democracy::external_propose_majority( Origin::signed(1), set_balance_proposal_hash(2) - ), "Invalid origin"); + ), "Invalid origin".into()); assert_ok!(Democracy::external_propose_majority( Origin::signed(3), set_balance_proposal_hash_and_note(2) @@ -1678,7 +1730,7 @@ mod tests { assert_noop!(Democracy::external_propose_default( Origin::signed(3), set_balance_proposal_hash(2) - ), "Invalid origin"); + ), "Invalid origin".into()); assert_ok!(Democracy::external_propose_default( Origin::signed(1), set_balance_proposal_hash_and_note(2) @@ -1701,12 +1753,12 @@ mod tests { new_test_ext().execute_with(|| { System::set_block_number(0); let h = set_balance_proposal_hash_and_note(2); - assert_noop!(Democracy::fast_track(Origin::signed(5), h, 3, 2), "no proposal made"); + assert_noop!(Democracy::fast_track(Origin::signed(5), h, 3, 2), Error::ProposalMissing); assert_ok!(Democracy::external_propose_majority( Origin::signed(3), set_balance_proposal_hash_and_note(2) )); - assert_noop!(Democracy::fast_track(Origin::signed(1), h, 3, 2), "Invalid origin"); + assert_noop!(Democracy::fast_track(Origin::signed(1), h, 3, 2), "Invalid origin".into()); assert_ok!(Democracy::fast_track(Origin::signed(5), h, 0, 0)); assert_eq!( Democracy::referendum_info(0), @@ -1731,7 +1783,7 @@ mod tests { )); assert_noop!( Democracy::fast_track(Origin::signed(5), h, 3, 2), - "next external proposal not simple majority" + Error::NotSimpleMajority ); }); } @@ -1813,7 +1865,7 @@ mod tests { (6, set_balance_proposal_hash_and_note(2), 0) ]); - assert_noop!(Democracy::cancel_queued(Origin::ROOT, 1), "proposal not found"); + assert_noop!(Democracy::cancel_queued(Origin::ROOT, 1), Error::ProposalMissing); assert_ok!(Democracy::cancel_queued(Origin::ROOT, 0)); assert_eq!(Democracy::dispatch_queue(), vec![]); }); @@ -1827,7 +1879,7 @@ mod tests { assert_eq!(Democracy::proxy(10), Some(1)); // Can't set when already set. - assert_noop!(Democracy::set_proxy(Origin::signed(2), 10), "already a proxy"); + assert_noop!(Democracy::set_proxy(Origin::signed(2), 10), Error::AlreadyProxy); // But this works because 11 isn't proxying. assert_ok!(Democracy::set_proxy(Origin::signed(2), 11)); @@ -1835,7 +1887,7 @@ mod tests { assert_eq!(Democracy::proxy(11), Some(2)); // 2 cannot fire 1's proxy: - assert_noop!(Democracy::remove_proxy(Origin::signed(2), 10), "wrong proxy"); + assert_noop!(Democracy::remove_proxy(Origin::signed(2), 10), Error::WrongProxy); // 1 fires his proxy: assert_ok!(Democracy::remove_proxy(Origin::signed(1), 10)); @@ -2042,7 +2094,7 @@ mod tests { fn proposal_with_deposit_below_minimum_should_not_work() { new_test_ext().execute_with(|| { System::set_block_number(1); - assert_noop!(propose_set_balance(1, 2, 0), "value too low"); + assert_noop!(propose_set_balance(1, 2, 0), Error::ValueLow); }); } @@ -2050,7 +2102,7 @@ mod tests { fn poor_proposer_should_not_work() { new_test_ext().execute_with(|| { System::set_block_number(1); - assert_noop!(propose_set_balance(1, 2, 11), "proposer\'s balance too low"); + assert_noop!(propose_set_balance(1, 2, 11), Error::Other("not enough free funds")); }); } @@ -2059,7 +2111,7 @@ mod tests { new_test_ext().execute_with(|| { System::set_block_number(1); assert_ok!(propose_set_balance_and_note(2, 2, 11)); - assert_noop!(Democracy::second(Origin::signed(1), 0), "seconder\'s balance too low"); + assert_noop!(Democracy::second(Origin::signed(1), 0), Error::Other("not enough free funds")); }); } diff --git a/frame/evm/src/lib.rs b/frame/evm/src/lib.rs index 6215dfaab2..cf973cdd5a 100644 --- a/frame/evm/src/lib.rs +++ b/frame/evm/src/lib.rs @@ -24,13 +24,13 @@ mod backend; pub use crate::backend::{Account, Log, Vicinity, Backend}; use sp_std::{vec::Vec, marker::PhantomData}; -use frame_support::{dispatch, decl_module, decl_storage, decl_event}; +use frame_support::{decl_module, decl_storage, decl_event, decl_error}; use frame_support::weights::{Weight, WeighData, ClassifyDispatch, DispatchClass, PaysFee}; use frame_support::traits::{Currency, WithdrawReason, ExistenceRequirement}; use frame_system::{self as system, ensure_signed}; use sp_runtime::ModuleId; use frame_support::weights::SimpleDispatchInfo; -use sp_runtime::traits::{UniqueSaturatedInto, AccountIdConversion, SaturatedConversion}; +use sp_runtime::traits::{UniqueSaturatedInto, AccountIdConversion, SaturatedConversion, ModuleDispatchError}; use sp_core::{U256, H256, H160}; use evm::{ExitReason, ExitSucceed, ExitError}; use evm::executor::StackExecutor; @@ -137,21 +137,42 @@ decl_storage! { } } -decl_event!( +decl_event! { /// EVM events pub enum Event { /// Ethereum events from contracts. Log(Log), } -); +} + +decl_error! { + pub enum Error { + /// Not enough balance to perform action + BalanceLow, + /// Calculating total fee overflowed + FeeOverflow, + /// Calculating total payment overflowed + PaymentOverflow, + /// Withdraw fee failed + WithdrawFailed, + /// Call failed + ExitReasonFailed, + /// Call reverted + ExitReasonRevert, + /// Call returned VM fatal error + ExitReasonFatal, + } +} decl_module! { pub struct Module for enum Call where origin: T::Origin { + type Error = Error; + fn deposit_event() = default; #[weight = SimpleDispatchInfo::FixedNormal(10_000)] - fn deposit_balance(origin, value: BalanceOf) -> dispatch::Result { - let sender = ensure_signed(origin)?; + fn deposit_balance(origin, value: BalanceOf) { + let sender = ensure_signed(origin).map_err(|e| e.as_str())?; let imbalance = T::Currency::withdraw( &sender, @@ -166,19 +187,17 @@ decl_module! { Accounts::mutate(&address, |account| { account.balance += bvalue; }); - - Ok(()) } #[weight = SimpleDispatchInfo::FixedNormal(10_000)] - fn withdraw_balance(origin, value: BalanceOf) -> dispatch::Result { - let sender = ensure_signed(origin)?; + fn withdraw_balance(origin, value: BalanceOf) { + let sender = ensure_signed(origin).map_err(|e| e.as_str())?; let address = T::ConvertAccountId::convert_account_id(&sender); let bvalue = U256::from(UniqueSaturatedInto::::unique_saturated_into(value)); let mut account = Accounts::get(&address); account.balance = account.balance.checked_sub(bvalue) - .ok_or("Not enough balance to withdraw")?; + .ok_or(Error::BalanceLow)?; let imbalance = T::Currency::withdraw( &Self::account_id(), @@ -190,15 +209,11 @@ decl_module! { Accounts::insert(&address, account); T::Currency::resolve_creating(&sender, imbalance); - - Ok(()) } #[weight = WeightForCallCreate::::default()] - fn call(origin, target: H160, input: Vec, value: U256, gas_limit: u32) - -> dispatch::Result - { - let sender = ensure_signed(origin)?; + fn call(origin, target: H160, input: Vec, value: U256, gas_limit: u32) { + let sender = ensure_signed(origin).map_err(|e| e.as_str())?; let source = T::ConvertAccountId::convert_account_id(&sender); let gas_price = T::FeeCalculator::gas_price(); @@ -216,13 +231,13 @@ decl_module! { ); let total_fee = gas_price.checked_mul(U256::from(gas_limit)) - .ok_or("Calculating total fee overflowed")?; + .ok_or(Error::FeeOverflow)?; if Accounts::get(&source).balance < - value.checked_add(total_fee).ok_or("Calculating total payment overflowed")? + value.checked_add(total_fee).ok_or(Error::PaymentOverflow)? { - return Err("Not enough balance to pay transaction fee") + return Err(Error::BalanceLow) } - executor.withdraw(source, total_fee).map_err(|_| "Withdraw fee failed")?; + executor.withdraw(source, total_fee).map_err(|_| Error::WithdrawFailed)?; let reason = executor.transact_call( source, @@ -234,9 +249,9 @@ decl_module! { let ret = match reason { ExitReason::Succeed(_) => Ok(()), - ExitReason::Error(_) => Err("Execute message call failed"), - ExitReason::Revert(_) => Err("Execute message call reverted"), - ExitReason::Fatal(_) => Err("Execute message call returned VM fatal error"), + ExitReason::Error(_) => Err(Error::ExitReasonFailed), + ExitReason::Revert(_) => Err(Error::ExitReasonRevert), + ExitReason::Fatal(_) => Err(Error::ExitReasonFatal), }; let actual_fee = executor.fee(gas_price); executor.deposit(source, total_fee.saturating_sub(actual_fee)); @@ -244,12 +259,12 @@ decl_module! { let (values, logs) = executor.deconstruct(); backend.apply(values, logs, true); - ret + return ret; } #[weight = WeightForCallCreate::::default()] - fn create(origin, init: Vec, value: U256, gas_limit: u32) -> dispatch::Result { - let sender = ensure_signed(origin)?; + fn create(origin, init: Vec, value: U256, gas_limit: u32) { + let sender = ensure_signed(origin).map_err(|e| e.as_str())?; let source = T::ConvertAccountId::convert_account_id(&sender); let gas_price = T::FeeCalculator::gas_price(); @@ -267,13 +282,13 @@ decl_module! { ); let total_fee = gas_price.checked_mul(U256::from(gas_limit)) - .ok_or("Calculating total fee overflowed")?; + .ok_or(Error::FeeOverflow)?; if Accounts::get(&source).balance < - value.checked_add(total_fee).ok_or("Calculating total payment overflowed")? + value.checked_add(total_fee).ok_or(Error::PaymentOverflow)? { - return Err("Not enough balance to pay transaction fee") + return Err(Error::BalanceLow) } - executor.withdraw(source, total_fee).map_err(|_| "Withdraw fee failed")?; + executor.withdraw(source, total_fee).map_err(|_| Error::WithdrawFailed)?; let reason = executor.transact_create( source, @@ -284,9 +299,9 @@ decl_module! { let ret = match reason { ExitReason::Succeed(_) => Ok(()), - ExitReason::Error(_) => Err("Execute contract creation failed"), - ExitReason::Revert(_) => Err("Execute contract creation reverted"), - ExitReason::Fatal(_) => Err("Execute contract creation returned VM fatal error"), + ExitReason::Error(_) => Err(Error::ExitReasonFailed), + ExitReason::Revert(_) => Err(Error::ExitReasonRevert), + ExitReason::Fatal(_) => Err(Error::ExitReasonFatal), }; let actual_fee = executor.fee(gas_price); executor.deposit(source, total_fee.saturating_sub(actual_fee)); @@ -294,7 +309,7 @@ decl_module! { let (values, logs) = executor.deconstruct(); backend.apply(values, logs, true); - ret + return ret; } } } diff --git a/frame/finality-tracker/src/lib.rs b/frame/finality-tracker/src/lib.rs index 4837a9cf78..7830a2b8f5 100644 --- a/frame/finality-tracker/src/lib.rs +++ b/frame/finality-tracker/src/lib.rs @@ -19,9 +19,9 @@ #![cfg_attr(not(feature = "std"), no_std)] use sp_inherents::{InherentIdentifier, ProvideInherent, InherentData, MakeFatalError}; -use sp_runtime::traits::{One, Zero, SaturatedConversion}; +use sp_runtime::traits::{One, Zero, SaturatedConversion, ModuleDispatchError}; use sp_std::{prelude::*, result, cmp, vec}; -use frame_support::{decl_module, decl_storage}; +use frame_support::{decl_module, decl_storage, decl_error, ensure}; use frame_support::traits::Get; use frame_system::{ensure_none, Trait as SystemTrait}; use sp_finality_tracker::{INHERENT_IDENTIFIER, FinalizedInherentData}; @@ -56,8 +56,18 @@ decl_storage! { } } +decl_error! { + pub enum Error { + /// Final hint must be updated only once in the block + AlreadyUpdated, + /// Finalized height above block number + BadHint, + } +} + decl_module! { pub struct Module for enum Call where origin: T::Origin { + type Error = Error; /// The number of recent samples to keep from this chain. Default is 101. const WindowSize: T::BlockNumber = T::WindowSize::get(); @@ -67,11 +77,11 @@ decl_module! { /// Hint that the author of this block thinks the best finalized /// block is the given number. fn final_hint(origin, #[compact] hint: T::BlockNumber) { - ensure_none(origin)?; - assert!(!::Update::exists(), "Final hint must be updated only once in the block"); - assert!( + ensure_none(origin).map_err(|e| e.as_str())?; + ensure!(!::Update::exists(), Error::AlreadyUpdated); + ensure!( frame_system::Module::::block_number() >= hint, - "Finalized height above block number", + Error::BadHint, ); ::Update::put(hint); } diff --git a/frame/grandpa/src/lib.rs b/frame/grandpa/src/lib.rs index 8c017acc91..eae43affde 100644 --- a/frame/grandpa/src/lib.rs +++ b/frame/grandpa/src/lib.rs @@ -31,10 +31,12 @@ pub use sp_finality_grandpa as fg_primitives; use sp_std::prelude::*; -use codec::{self as codec, Encode, Decode, Error}; -use frame_support::{decl_event, decl_storage, decl_module, dispatch, storage}; +use codec::{self as codec, Encode, Decode}; +use frame_support::{decl_event, decl_storage, decl_module, decl_error, storage}; use sp_runtime::{ - generic::{DigestItem, OpaqueDigestItemId}, traits::Zero, Perbill, + generic::{DigestItem, OpaqueDigestItemId}, + traits::{Zero, ModuleDispatchError}, + Perbill, }; use sp_staking::{ SessionIndex, @@ -82,7 +84,7 @@ pub struct StoredPendingChange { } impl Decode for StoredPendingChange { - fn decode(value: &mut I) -> core::result::Result { + fn decode(value: &mut I) -> core::result::Result { let old = OldStoredPendingChange::decode(value)?; let forced = >::decode(value).unwrap_or(None); @@ -123,7 +125,7 @@ pub enum StoredState { }, } -decl_event!( +decl_event! { pub enum Event { /// New authority set has been applied. NewAuthorities(AuthorityList), @@ -132,7 +134,22 @@ decl_event!( /// Current authority set has been resumed. Resumed, } -); +} + +decl_error! { + pub enum Error { + /// Attempt to signal GRANDPA pause when the authority set isn't live + /// (either paused or already pending pause). + PauseFailed, + /// Attempt to signal GRANDPA resume when the authority set isn't paused + /// (either live or already pending resume). + ResumeFailed, + /// Attempt to signal GRANDPA change with one already pending. + ChangePending, + /// Cannot signal forced change so soon after last. + TooSoon, + } +} decl_storage! { trait Store for Module as GrandpaFinality { @@ -170,11 +187,13 @@ decl_storage! { decl_module! { pub struct Module for enum Call where origin: T::Origin { + type Error = Error; + fn deposit_event() = default; /// Report some misbehavior. fn report_misbehavior(origin, _report: Vec) { - ensure_signed(origin)?; + ensure_signed(origin).map_err(|e| e.as_str())?; // FIXME: https://github.com/paritytech/substrate/issues/1112 } @@ -264,7 +283,7 @@ impl Module { /// Schedule GRANDPA to pause starting in the given number of blocks. /// Cannot be done when already paused. - pub fn schedule_pause(in_blocks: T::BlockNumber) -> dispatch::Result { + pub fn schedule_pause(in_blocks: T::BlockNumber) -> Result<(), Error> { if let StoredState::Live = >::get() { let scheduled_at = >::block_number(); >::put(StoredState::PendingPause { @@ -274,13 +293,12 @@ impl Module { Ok(()) } else { - Err("Attempt to signal GRANDPA pause when the authority set isn't live \ - (either paused or already pending pause).") + Err(Error::PauseFailed) } } /// Schedule a resume of GRANDPA after pausing. - pub fn schedule_resume(in_blocks: T::BlockNumber) -> dispatch::Result { + pub fn schedule_resume(in_blocks: T::BlockNumber) -> Result<(), Error> { if let StoredState::Paused = >::get() { let scheduled_at = >::block_number(); >::put(StoredState::PendingResume { @@ -290,8 +308,7 @@ impl Module { Ok(()) } else { - Err("Attempt to signal GRANDPA resume when the authority set isn't paused \ - (either live or already pending resume).") + Err(Error::ResumeFailed) } } @@ -313,13 +330,13 @@ impl Module { next_authorities: AuthorityList, in_blocks: T::BlockNumber, forced: Option, - ) -> dispatch::Result { + ) -> Result<(), Error> { if !>::exists() { let scheduled_at = >::block_number(); if let Some(_) = forced { if Self::next_forced().map_or(false, |next| next > scheduled_at) { - return Err("Cannot signal forced change so soon after last."); + return Err(Error::TooSoon); } // only allow the next forced change when twice the window has passed since @@ -336,7 +353,7 @@ impl Module { Ok(()) } else { - Err("Attempt to signal GRANDPA change with one already pending.") + Err(Error::ChangePending) } } -- GitLab From df750ba072afecc8c99a9a29b24c323f1c965450 Mon Sep 17 00:00:00 2001 From: Drew Stone Date: Wed, 18 Dec 2019 11:51:24 +0200 Subject: [PATCH 157/172] Add Edgeware network ID to core/crypto and subkey (#4426) * Add linear back-off for aura slot workers * logging * Use slot from header * Get network id for Edgeware and add to subkey --- bin/utils/subkey/src/main.rs | 4 ++-- primitives/core/src/crypto.rs | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/bin/utils/subkey/src/main.rs b/bin/utils/subkey/src/main.rs index 88acae9836..10a2e13170 100644 --- a/bin/utils/subkey/src/main.rs +++ b/bin/utils/subkey/src/main.rs @@ -165,7 +165,7 @@ fn get_app<'a, 'b>() -> App<'a, 'b> { -k, --secp256k1 'Use SECP256k1/ECDSA/BIP39 cryptography' -s, --sr25519 'Use Schnorr/Ristretto x25519/BIP39 cryptography' [network] -n, --network 'Specify a network. One of substrate \ - (default), polkadot, kusama, dothereum, or kulupu' + (default), polkadot, kusama, dothereum, edgeware, or kulupu' [password] -p, --password 'The password for the key' ") .subcommands(vec![ @@ -244,7 +244,7 @@ where let maybe_network: Option = matches.value_of("network").map(|network| { network .try_into() - .expect("Invalid network name: must be polkadot/substrate/kusama/dothereum") + .expect("Invalid network name: must be polkadot/substrate/kusama/dothereum/edgeware") }); if let Some(network) = maybe_network { set_default_ss58_version(network); diff --git a/primitives/core/src/crypto.rs b/primitives/core/src/crypto.rs index 5119203a08..fe3a53c83a 100644 --- a/primitives/core/src/crypto.rs +++ b/primitives/core/src/crypto.rs @@ -268,6 +268,7 @@ pub trait Ss58Codec: Sized + AsMut<[u8]> + AsRef<[u8]> + Default { Ss58AddressFormat::PolkadotAccountDirect => Ok(r), Ss58AddressFormat::KusamaAccountDirect => Ok(r), Ss58AddressFormat::DothereumAccountDirect => Ok(r), + Ss58AddressFormat::EdgewareAccountDirect => Ok(r), v if v == *DEFAULT_VERSION.lock() => Ok(r), _ => Err(PublicError::UnknownVersion), }) @@ -301,6 +302,7 @@ pub trait Ss58Codec: Sized + AsMut<[u8]> + AsRef<[u8]> + Default { Ss58AddressFormat::PolkadotAccountDirect => Ok(r), Ss58AddressFormat::KusamaAccountDirect => Ok(r), Ss58AddressFormat::DothereumAccountDirect => Ok(r), + Ss58AddressFormat::EdgewareAccountDirect => Ok(r), v if v == *DEFAULT_VERSION.lock() => Ok(r), _ => Err(PublicError::UnknownVersion), }) @@ -432,6 +434,8 @@ ss58_address_format!( (20, "dothereum", "Dothereum Para-chain, direct checksum, standard account (*25519).") KulupuAccountDirect => (16, "kulupu", "Kulupu mainnet, direct checksum, standard account (*25519).") + EdgewareAccountDirect => + (7, "edgeware", "Edgeware mainnet, direct checksum, standard account (*25519).") ); /// Set the default "version" (actually, this is a bit of a misnomer and the version byte is @@ -441,6 +445,7 @@ ss58_address_format!( /// Current known "versions" are: /// - 0 direct (payload) checksum for 32-byte *25519 Polkadot addresses. /// - 2 direct (payload) checksum for 32-byte *25519 Kusama addresses. +/// - 7 direct (payload) checksum for 32-byte *25519 Edgeware addresses. /// - 20 direct (payload) checksum for 32-byte *25519 Dothereum addresses. /// - 42 direct (payload) checksum for 32-byte *25519 addresses on any Substrate-based network. #[cfg(feature = "std")] -- GitLab From b4a39f32bedb5e0265da021a1d377f5347070d38 Mon Sep 17 00:00:00 2001 From: Wei Tang Date: Wed, 18 Dec 2019 04:13:47 -0800 Subject: [PATCH 158/172] pallet-evm: default implementation for FeeCalculator and ConvertAccountId and separate gas price (#4424) * Default implementation for FeeCalculator and ConvertAccountId and separate gas price * Styling fixes and some docs addition * TruncateConvertAccountId -> HashTruncateConvertAccountId * Fix compile --- frame/evm/src/lib.rs | 102 ++++++++++++++++++++++++++++++++----------- 1 file changed, 77 insertions(+), 25 deletions(-) diff --git a/frame/evm/src/lib.rs b/frame/evm/src/lib.rs index cf973cdd5a..9adafa3c92 100644 --- a/frame/evm/src/lib.rs +++ b/frame/evm/src/lib.rs @@ -24,14 +24,14 @@ mod backend; pub use crate::backend::{Account, Log, Vicinity, Backend}; use sp_std::{vec::Vec, marker::PhantomData}; -use frame_support::{decl_module, decl_storage, decl_event, decl_error}; +use frame_support::{ensure, decl_module, decl_storage, decl_event, decl_error}; use frame_support::weights::{Weight, WeighData, ClassifyDispatch, DispatchClass, PaysFee}; use frame_support::traits::{Currency, WithdrawReason, ExistenceRequirement}; use frame_system::{self as system, ensure_signed}; use sp_runtime::ModuleId; use frame_support::weights::SimpleDispatchInfo; use sp_runtime::traits::{UniqueSaturatedInto, AccountIdConversion, SaturatedConversion, ModuleDispatchError}; -use sp_core::{U256, H256, H160}; +use sp_core::{U256, H256, H160, Hasher}; use evm::{ExitReason, ExitSucceed, ExitError}; use evm::executor::StackExecutor; use evm::backend::ApplyBackend; @@ -43,8 +43,12 @@ pub type BalanceOf = <::Currency as Currency< U256; + /// Return the minimal required gas price. + fn min_gas_price() -> U256; +} + +impl FeeCalculator for () { + fn min_gas_price() -> U256 { U256::zero() } } /// Trait for converting account ids of `balances` module into @@ -59,6 +63,32 @@ pub trait ConvertAccountId { fn convert_account_id(account_id: &A) -> H160; } +/// Hash and then truncate the account id, taking the last 160-bit as the Ethereum address. +pub struct HashTruncateConvertAccountId(PhantomData); + +impl Default for HashTruncateConvertAccountId { + fn default() -> Self { + Self(PhantomData) + } +} + +impl> ConvertAccountId for HashTruncateConvertAccountId { + fn convert_account_id(account_id: &A) -> H160 { + let account_id = H::hash(account_id.as_ref()); + let account_id_len = account_id.as_ref().len(); + let mut value = [0u8; 20]; + let value_len = value.len(); + + if value_len > account_id_len { + value[(value_len - account_id_len)..].copy_from_slice(account_id.as_ref()); + } else { + value.copy_from_slice(&account_id.as_ref()[(account_id_len - value_len)..]); + } + + H160::from(value) + } +} + /// Custom precompiles to be used by EVM engine. pub trait Precompiles { /// Try to execute the code address as precompile. If the code address is not @@ -83,33 +113,33 @@ impl Precompiles for () { } } -struct WeightForCallCreate(PhantomData); - -impl Default for WeightForCallCreate { - fn default() -> Self { - Self(PhantomData) - } -} +struct WeightForCallCreate; -impl WeighData<(&H160, &Vec, &U256, &u32)> for WeightForCallCreate { - fn weigh_data(&self, (_, _, _, gas_provided): (&H160, &Vec, &U256, &u32)) -> Weight { - F::gas_price().saturated_into::().saturating_mul(*gas_provided) +impl WeighData<(&H160, &Vec, &U256, &u32, &U256)> for WeightForCallCreate { + fn weigh_data( + &self, + (_, _, _, gas_provided, gas_price): (&H160, &Vec, &U256, &u32, &U256) + ) -> Weight { + (*gas_price).saturated_into::().saturating_mul(*gas_provided) } } -impl WeighData<(&Vec, &U256, &u32)> for WeightForCallCreate { - fn weigh_data(&self, (_, _, gas_provided): (&Vec, &U256, &u32)) -> Weight { - F::gas_price().saturated_into::().saturating_mul(*gas_provided) +impl WeighData<(&Vec, &U256, &u32, &U256)> for WeightForCallCreate { + fn weigh_data( + &self, + (_, _, gas_provided, gas_price): (&Vec, &U256, &u32, &U256) + ) -> Weight { + (*gas_price).saturated_into::().saturating_mul(*gas_provided) } } -impl ClassifyDispatch for WeightForCallCreate { +impl ClassifyDispatch for WeightForCallCreate { fn classify_dispatch(&self, _: T) -> DispatchClass { DispatchClass::Normal } } -impl PaysFee for WeightForCallCreate { +impl PaysFee for WeightForCallCreate { fn pays_fee(&self) -> bool { true } @@ -155,6 +185,8 @@ decl_error! { PaymentOverflow, /// Withdraw fee failed WithdrawFailed, + /// Gas price is too low. + GasPriceTooLow, /// Call failed ExitReasonFailed, /// Call reverted @@ -170,6 +202,7 @@ decl_module! { fn deposit_event() = default; + /// Despoit balance from currency/balances module into EVM. #[weight = SimpleDispatchInfo::FixedNormal(10_000)] fn deposit_balance(origin, value: BalanceOf) { let sender = ensure_signed(origin).map_err(|e| e.as_str())?; @@ -189,6 +222,7 @@ decl_module! { }); } + /// Withdraw balance from EVM into currency/balances module. #[weight = SimpleDispatchInfo::FixedNormal(10_000)] fn withdraw_balance(origin, value: BalanceOf) { let sender = ensure_signed(origin).map_err(|e| e.as_str())?; @@ -211,11 +245,20 @@ decl_module! { T::Currency::resolve_creating(&sender, imbalance); } - #[weight = WeightForCallCreate::::default()] - fn call(origin, target: H160, input: Vec, value: U256, gas_limit: u32) { + /// Issue an EVM call operation. This is similar to a message call transaction in Ethereum. + #[weight = WeightForCallCreate] + fn call( + origin, + target: H160, + input: Vec, + value: U256, + gas_limit: u32, + gas_price: U256, + ) { let sender = ensure_signed(origin).map_err(|e| e.as_str())?; + ensure!(gas_price >= T::FeeCalculator::min_gas_price(), Error::GasPriceTooLow); + let source = T::ConvertAccountId::convert_account_id(&sender); - let gas_price = T::FeeCalculator::gas_price(); let vicinity = Vicinity { gas_price, @@ -262,11 +305,20 @@ decl_module! { return ret; } - #[weight = WeightForCallCreate::::default()] - fn create(origin, init: Vec, value: U256, gas_limit: u32) { + /// Issue an EVM create operation. This is similar to a contract creation transaction in + /// Ethereum. + #[weight = WeightForCallCreate] + fn create( + origin, + init: Vec, + value: U256, + gas_limit: u32, + gas_price: U256, + ) { let sender = ensure_signed(origin).map_err(|e| e.as_str())?; + ensure!(gas_price >= T::FeeCalculator::min_gas_price(), Error::GasPriceTooLow); + let source = T::ConvertAccountId::convert_account_id(&sender); - let gas_price = T::FeeCalculator::gas_price(); let vicinity = Vicinity { gas_price, -- GitLab From e3b382caab591f848ac67d0f74a0e35c84f9cea9 Mon Sep 17 00:00:00 2001 From: Weiliang Li Date: Wed, 18 Dec 2019 21:13:59 +0900 Subject: [PATCH 159/172] Add dyn for `slog::SerdeValue` in telemetry (#4435) --- client/telemetry/src/async_record.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/telemetry/src/async_record.rs b/client/telemetry/src/async_record.rs index 209118070e..34b7c1435a 100644 --- a/client/telemetry/src/async_record.rs +++ b/client/telemetry/src/async_record.rs @@ -103,7 +103,7 @@ impl Serializer for ToSendSerializer { Ok(()) } - fn emit_serde(&mut self, key: Key, value: &slog::SerdeValue) -> slog::Result { + fn emit_serde(&mut self, key: Key, value: &dyn slog::SerdeValue) -> slog::Result { let val = value.to_sendable(); take(&mut self.kv, |kv| Box::new((kv, SingleKV(key, val)))); Ok(()) -- GitLab From 496dce565ba1589d4433280719124efd1d3d2e2f Mon Sep 17 00:00:00 2001 From: Robert Habermeier Date: Wed, 18 Dec 2019 14:12:15 +0100 Subject: [PATCH 160/172] RPCs for reserved peers (#4423) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * RPC forwarders for adding reserved peers * implement service side of reserved-peer RPCs * Clean up unnecessary format! invocation Co-Authored-By: Niklas Adolfsson * add some tests for the new RPC methods * remove redundant `data` field Co-Authored-By: Tomasz Drwięga --- client/network/src/service.rs | 14 +++++++++++- client/rpc-api/src/system/error.rs | 7 ++++++ client/rpc-api/src/system/mod.rs | 19 +++++++++++++++- client/rpc/src/system/mod.rs | 36 +++++++++++++++++++++++++++++- client/rpc/src/system/tests.rs | 36 ++++++++++++++++++++++++++++++ client/service/src/lib.rs | 16 +++++++++++++ 6 files changed, 125 insertions(+), 3 deletions(-) diff --git a/client/network/src/service.rs b/client/network/src/service.rs index 3b3a64b41a..d945bb0e26 100644 --- a/client/network/src/service.rs +++ b/client/network/src/service.rs @@ -408,6 +408,17 @@ impl, H: ExHashT> NetworkWorker .map(|(id, info)| (id.clone(), info.clone())) .collect() } + + /// Removes a `PeerId` from the list of reserved peers. + pub fn remove_reserved_peer(&self, peer: PeerId) { + self.service.remove_reserved_peer(peer); + } + + /// Adds a `PeerId` and its address as reserved. The string should encode the address + /// and peer ID of the remote node. + pub fn add_reserved_peer(&self, peer: String) -> Result<(), String> { + self.service.add_reserved_peer(peer) + } } impl, H: ExHashT> NetworkService { @@ -553,7 +564,8 @@ impl, H: ExHashT> NetworkServic self.peerset.remove_reserved_peer(peer); } - /// Adds a `PeerId` and its address as reserved. + /// Adds a `PeerId` and its address as reserved. The string should encode the address + /// and peer ID of the remote node. pub fn add_reserved_peer(&self, peer: String) -> Result<(), String> { let (peer_id, addr) = parse_str_addr(&peer).map_err(|e| format!("{:?}", e))?; self.peerset.add_reserved_peer(peer_id.clone()); diff --git a/client/rpc-api/src/system/error.rs b/client/rpc-api/src/system/error.rs index 32b694e3ac..9ea2a2de0d 100644 --- a/client/rpc-api/src/system/error.rs +++ b/client/rpc-api/src/system/error.rs @@ -28,6 +28,8 @@ pub enum Error { /// Provided block range couldn't be resolved to a list of blocks. #[display(fmt = "Node is not fully functional: {}", _0)] NotHealthy(Health), + /// Peer argument is malformatted. + MalformattedPeerArg(String), } impl std::error::Error for Error {} @@ -43,6 +45,11 @@ impl From for rpc::Error { message: format!("{}", e), data: serde_json::to_value(h).ok(), }, + Error::MalformattedPeerArg(ref e) => rpc::Error { + code :rpc::ErrorCode::ServerError(BASE_ERROR + 2), + message: e.clone(), + data: None, + } } } } diff --git a/client/rpc-api/src/system/mod.rs b/client/rpc-api/src/system/mod.rs index f59fd84c7c..29a92e16b6 100644 --- a/client/rpc-api/src/system/mod.rs +++ b/client/rpc-api/src/system/mod.rs @@ -21,8 +21,10 @@ pub mod helpers; use crate::helpers::Receiver; use jsonrpc_derive::rpc; +use futures::{future::BoxFuture, compat::Compat}; +use std::pin::Pin; -use self::error::Result; +use self::error::{Error, Result}; pub use self::helpers::{Properties, SystemInfo, Health, PeerInfo, NodeRole}; pub use self::gen_client::Client as SystemClient; @@ -65,6 +67,21 @@ pub trait SystemApi { #[rpc(name = "system_networkState", returns = "jsonrpc_core::Value")] fn system_network_state(&self) -> Receiver; + /// Adds a reserved peer. Returns the empty string or an error. The string + /// parameter should encode a `p2p` multiaddr. + /// + /// `/ip4/198.51.100.19/tcp/30333/p2p/QmSk5HQbn6LhUwDiNMseVUjuRYhEtYj4aUZ6WfWoGURpdV` + /// is an example of a valid, passing multiaddr with PeerId attached. + #[rpc(name = "system_addReservedPeer", returns = "()")] + fn system_add_reserved_peer(&self, peer: String) + -> Compat>>; + + /// Remove a reserved peer. Returns the empty string or an error. The string + /// should encode only the PeerId e.g. `QmSk5HQbn6LhUwDiNMseVUjuRYhEtYj4aUZ6WfWoGURpdV`. + #[rpc(name = "system_removeReservedPeer", returns = "()")] + fn system_remove_reserved_peer(&self, peer_id: String) + -> Compat>>; + /// Returns the roles the node is running as. #[rpc(name = "system_nodeRoles", returns = "Vec")] fn system_node_roles(&self) -> Receiver>; diff --git a/client/rpc/src/system/mod.rs b/client/rpc/src/system/mod.rs index 010c56aaef..b6048291aa 100644 --- a/client/rpc/src/system/mod.rs +++ b/client/rpc/src/system/mod.rs @@ -19,9 +19,11 @@ #[cfg(test)] mod tests; +use futures::{future::BoxFuture, FutureExt, TryFutureExt}; use futures::{channel::{mpsc, oneshot}, compat::Compat}; use sc_rpc_api::Receiver; use sp_runtime::traits::{self, Header as HeaderT}; + use self::error::Result; pub use sc_rpc_api::system::*; @@ -42,6 +44,10 @@ pub enum Request { Peers(oneshot::Sender::Number>>>), /// Must return the state of the network. NetworkState(oneshot::Sender), + /// Must return any potential parse error. + NetworkAddReservedPeer(String, oneshot::Sender>), + /// Must return any potential parse error. + NetworkRemoveReservedPeer(String, oneshot::Sender>), /// Must return the node role. NodeRoles(oneshot::Sender>) } @@ -53,7 +59,7 @@ impl System { /// reading from that channel and answering the requests. pub fn new( info: SystemInfo, - send_back: mpsc::UnboundedSender> + send_back: mpsc::UnboundedSender>, ) -> Self { System { info, @@ -97,6 +103,34 @@ impl SystemApi::Number> for Sy Receiver(Compat::new(rx)) } + fn system_add_reserved_peer(&self, peer: String) + -> Compat>> + { + let (tx, rx) = oneshot::channel(); + let _ = self.send_back.unbounded_send(Request::NetworkAddReservedPeer(peer, tx)); + async move { + match rx.await { + Ok(Ok(())) => Ok(()), + Ok(Err(e)) => Err(rpc::Error::from(e)), + Err(_) => Err(rpc::Error::internal_error()), + } + }.boxed().compat() + } + + fn system_remove_reserved_peer(&self, peer: String) + -> Compat>> + { + let (tx, rx) = oneshot::channel(); + let _ = self.send_back.unbounded_send(Request::NetworkRemoveReservedPeer(peer, tx)); + async move { + match rx.await { + Ok(Ok(())) => Ok(()), + Ok(Err(e)) => Err(rpc::Error::from(e)), + Err(_) => Err(rpc::Error::internal_error()), + } + }.boxed().compat() + } + fn system_node_roles(&self) -> Receiver> { let (tx, rx) = oneshot::channel(); let _ = self.send_back.unbounded_send(Request::NodeRoles(tx)); diff --git a/client/rpc/src/system/tests.rs b/client/rpc/src/system/tests.rs index 11e987b2e9..f69882cf38 100644 --- a/client/rpc/src/system/tests.rs +++ b/client/rpc/src/system/tests.rs @@ -80,6 +80,18 @@ fn api>>(sync: T) -> System { peerset: serde_json::Value::Null, }).unwrap()); }, + Request::NetworkAddReservedPeer(peer, sender) => { + let _ = match sc_network::config::parse_str_addr(&peer) { + Ok(_) => sender.send(Ok(())), + Err(s) => sender.send(Err(error::Error::MalformattedPeerArg(s.to_string()))), + }; + }, + Request::NetworkRemoveReservedPeer(peer, sender) => { + let _ = match peer.parse::() { + Ok(_) => sender.send(Ok(())), + Err(s) => sender.send(Err(error::Error::MalformattedPeerArg(s.to_string()))), + }; + } Request::NodeRoles(sender) => { let _ = sender.send(vec![NodeRole::Authority]); } @@ -232,3 +244,27 @@ fn system_node_roles() { vec![NodeRole::Authority] ); } + +#[test] +fn system_network_add_reserved() { + let good_peer_id = "/ip4/198.51.100.19/tcp/30333/p2p/QmSk5HQbn6LhUwDiNMseVUjuRYhEtYj4aUZ6WfWoGURpdV"; + let bad_peer_id = "/ip4/198.51.100.19/tcp/30333"; + let mut runtime = tokio::runtime::current_thread::Runtime::new().unwrap(); + + let good_fut = api(None).system_add_reserved_peer(good_peer_id.into()); + let bad_fut = api(None).system_add_reserved_peer(bad_peer_id.into()); + assert_eq!(runtime.block_on(good_fut), Ok(())); + assert!(runtime.block_on(bad_fut).is_err()); +} + +#[test] +fn system_network_remove_reserved() { + let good_peer_id = "QmSk5HQbn6LhUwDiNMseVUjuRYhEtYj4aUZ6WfWoGURpdV"; + let bad_peer_id = "/ip4/198.51.100.19/tcp/30333/p2p/QmSk5HQbn6LhUwDiNMseVUjuRYhEtYj4aUZ6WfWoGURpdV"; + let mut runtime = tokio::runtime::current_thread::Runtime::new().unwrap(); + + let good_fut = api(None).system_remove_reserved_peer(good_peer_id.into()); + let bad_fut = api(None).system_remove_reserved_peer(bad_peer_id.into()); + assert_eq!(runtime.block_on(good_fut), Ok(())); + assert!(runtime.block_on(bad_fut).is_err()); +} diff --git a/client/service/src/lib.rs b/client/service/src/lib.rs index d23e2a988c..757d3b0bf6 100644 --- a/client/service/src/lib.rs +++ b/client/service/src/lib.rs @@ -429,6 +429,22 @@ fn build_network_future< let _ = sender.send(network_state); } } + sc_rpc::system::Request::NetworkAddReservedPeer(peer_addr, sender) => { + let x = network.add_reserved_peer(peer_addr) + .map_err(sc_rpc::system::error::Error::MalformattedPeerArg); + let _ = sender.send(x); + } + sc_rpc::system::Request::NetworkRemoveReservedPeer(peer_id, sender) => { + let _ = match peer_id.parse::() { + Ok(peer_id) => { + network.remove_reserved_peer(peer_id); + sender.send(Ok(())) + } + Err(e) => sender.send(Err(sc_rpc::system::error::Error::MalformattedPeerArg( + e.to_string(), + ))), + }; + } sc_rpc::system::Request::NodeRoles(sender) => { use sc_rpc::system::NodeRole; -- GitLab From b84a4c6b0bfde5ac7efbd6a8af32c5357b8d406b Mon Sep 17 00:00:00 2001 From: Robert Habermeier Date: Wed, 18 Dec 2019 14:17:13 +0100 Subject: [PATCH 161/172] client: Do not set fork sync request via network-gossip (#4439) The finality-grandpa module needs two sets of functionalities from the network: 1. Everything gossip related, e.g. event_stream, write_notification, ... 2. The ability to set a fork sync request for a specific block hash. Instead of embedding (2) inside of (1) this patch extracts (2) from (1) having finality-grandpa depend on a `Network` that fulfills the `network_gossip::Network` trait and that can set block sync requests. On the one hand this improves the overall structure splitting things that don't logically belong together. On the other hand it does reintroduce a lot of trait bounds within finality-grandpa. --- .../finality-grandpa/src/communication/mod.rs | 51 +++++++++++++++---- .../src/communication/tests.rs | 4 +- client/finality-grandpa/src/environment.rs | 17 ++++--- client/finality-grandpa/src/lib.rs | 29 ++++++----- client/finality-grandpa/src/observer.rs | 18 ++++--- client/network-gossip/src/bridge.rs | 20 +------- client/network-gossip/src/lib.rs | 17 +------ 7 files changed, 82 insertions(+), 74 deletions(-) diff --git a/client/finality-grandpa/src/communication/mod.rs b/client/finality-grandpa/src/communication/mod.rs index c690376193..cfd1bfdbb3 100644 --- a/client/finality-grandpa/src/communication/mod.rs +++ b/client/finality-grandpa/src/communication/mod.rs @@ -34,8 +34,8 @@ use futures03::{compat::Compat, stream::StreamExt, future::FutureExt as _, futur use finality_grandpa::Message::{Prevote, Precommit, PrimaryPropose}; use finality_grandpa::{voter, voter_set::VoterSet}; use log::{debug, trace}; -use sc_network::ReputationChange; -use sc_network_gossip::{GossipEngine, Network}; +use sc_network::{NetworkService, ReputationChange}; +use sc_network_gossip::{GossipEngine, Network as GossipNetwork}; use parity_scale_codec::{Encode, Decode}; use sp_core::Pair; use sp_runtime::traits::{Block as BlockT, Hash as HashT, Header as HeaderT, NumberFor}; @@ -95,6 +95,30 @@ mod benefit { pub(super) const PER_EQUIVOCATION: i32 = 10; } +/// A handle to the network. +/// +/// Something that provides both the capabilities needed for the `gossip_network::Network` trait as +/// well as the ability to set a fork sync request for a particular block. +pub trait Network: GossipNetwork + Clone + Send + 'static { + /// Notifies the sync service to try and sync the given block from the given + /// peers. + /// + /// If the given vector of peers is empty then the underlying implementation + /// should make a best effort to fetch the block from any peers it is + /// connected to (NOTE: this assumption will change in the future #3629). + fn set_sync_fork_request(&self, peers: Vec, hash: Block::Hash, number: NumberFor); +} + +impl Network for Arc> where + B: BlockT, + S: sc_network::specialization::NetworkSpecialization, + H: sc_network::ExHashT, +{ + fn set_sync_fork_request(&self, peers: Vec, hash: B::Hash, number: NumberFor) { + NetworkService::set_sync_fork_request(self, peers, hash, number) + } +} + /// Create a unique topic for a round and set-id combo. pub(crate) fn round_topic(round: RoundNumber, set_id: SetIdNumber) -> B::Hash { <::Hashing as HashT>::hash(format!("{}-{}", set_id, round).as_bytes()) @@ -106,18 +130,19 @@ pub(crate) fn global_topic(set_id: SetIdNumber) -> B::Hash { } /// Bridge between the underlying network service, gossiping consensus messages and Grandpa -pub(crate) struct NetworkBridge { +pub(crate) struct NetworkBridge> { + service: N, gossip_engine: GossipEngine, validator: Arc>, neighbor_sender: periodic::NeighborPacketSender, } -impl NetworkBridge { +impl> NetworkBridge { /// Create a new NetworkBridge to the given NetworkService. Returns the service /// handle. /// On creation it will register previous rounds' votes with the gossip /// service taken from the VoterSetState. - pub(crate) fn new + Clone + Send + 'static>( + pub(crate) fn new( service: N, config: crate::Config, set_state: crate::environment::SharedVoterSetState, @@ -130,7 +155,7 @@ impl NetworkBridge { ); let validator = Arc::new(validator); - let gossip_engine = GossipEngine::new(service, executor, GRANDPA_ENGINE_ID, validator.clone()); + let gossip_engine = GossipEngine::new(service.clone(), executor, GRANDPA_ENGINE_ID, validator.clone()); { // register all previous votes with the gossip service so that they're @@ -173,7 +198,7 @@ impl NetworkBridge { let (rebroadcast_job, neighbor_sender) = periodic::neighbor_packet_worker(gossip_engine.clone()); let reporting_job = report_stream.consume(gossip_engine.clone()); - let bridge = NetworkBridge { gossip_engine, validator, neighbor_sender }; + let bridge = NetworkBridge { service, gossip_engine, validator, neighbor_sender }; let executor = Compat::new(executor); executor.execute(Box::new(rebroadcast_job.select(on_exit.clone().map(Ok).compat()).then(|_| Ok(())))) @@ -356,8 +381,13 @@ impl NetworkBridge { /// If the given vector of peers is empty then the underlying implementation /// should make a best effort to fetch the block from any peers it is /// connected to (NOTE: this assumption will change in the future #3629). - pub(crate) fn set_sync_fork_request(&self, peers: Vec, hash: B::Hash, number: NumberFor) { - self.gossip_engine.set_sync_fork_request(peers, hash, number) + pub(crate) fn set_sync_fork_request( + &self, + peers: Vec, + hash: B::Hash, + number: NumberFor + ) { + Network::set_sync_fork_request(&self.service, peers, hash, number) } } @@ -493,9 +523,10 @@ fn incoming_global( .map_err(|()| Error::Network(format!("Failed to receive message on unbounded stream"))) } -impl Clone for NetworkBridge { +impl> Clone for NetworkBridge { fn clone(&self) -> Self { NetworkBridge { + service: self.service.clone(), gossip_engine: self.gossip_engine.clone(), validator: Arc::clone(&self.validator), neighbor_sender: self.neighbor_sender.clone(), diff --git a/client/finality-grandpa/src/communication/tests.rs b/client/finality-grandpa/src/communication/tests.rs index 4c0223402f..9b5884e857 100644 --- a/client/finality-grandpa/src/communication/tests.rs +++ b/client/finality-grandpa/src/communication/tests.rs @@ -67,7 +67,9 @@ impl sc_network_gossip::Network for TestNetwork { fn announce(&self, block: Hash, _associated_data: Vec) { let _ = self.sender.unbounded_send(Event::Announce(block)); } +} +impl super::Network for TestNetwork { fn set_sync_fork_request( &self, _peers: Vec, @@ -94,7 +96,7 @@ impl sc_network_gossip::ValidatorContext for TestNetwork { } struct Tester { - net_handle: super::NetworkBridge, + net_handle: super::NetworkBridge, gossip_validator: Arc>, events: mpsc::UnboundedReceiver, } diff --git a/client/finality-grandpa/src/environment.rs b/client/finality-grandpa/src/environment.rs index 998e63b6b5..77153554c9 100644 --- a/client/finality-grandpa/src/environment.rs +++ b/client/finality-grandpa/src/environment.rs @@ -56,6 +56,7 @@ use crate::{ use sp_consensus::SelectChain; use crate::authorities::{AuthoritySet, SharedAuthoritySet}; +use crate::communication::Network as NetworkT; use crate::consensus_changes::SharedConsensusChanges; use crate::justification::GrandpaJustification; use crate::until_imported::UntilVoteTargetImported; @@ -376,20 +377,20 @@ impl SharedVoterSetState { } /// The environment we run GRANDPA in. -pub(crate) struct Environment { +pub(crate) struct Environment, RA, SC, VR> { pub(crate) client: Arc>, pub(crate) select_chain: SC, pub(crate) voters: Arc>, pub(crate) config: Config, pub(crate) authority_set: SharedAuthoritySet>, pub(crate) consensus_changes: SharedConsensusChanges>, - pub(crate) network: crate::communication::NetworkBridge, + pub(crate) network: crate::communication::NetworkBridge, pub(crate) set_id: SetId, pub(crate) voter_set_state: SharedVoterSetState, pub(crate) voting_rule: VR, } -impl Environment { +impl, RA, SC, VR> Environment { /// Updates the voter set state using the given closure. The write lock is /// held during evaluation of the closure and the environment's voter set /// state is set to its result if successful. @@ -405,13 +406,14 @@ impl Environment { } } -impl, B, E, RA, SC, VR> +impl, B, E, N, RA, SC, VR> finality_grandpa::Chain> -for Environment +for Environment where Block: 'static, B: Backend + 'static, E: CallExecutor + Send + Sync + 'static, + N: NetworkT + 'static + Send, SC: SelectChain + 'static, VR: VotingRule>, RA: Send + Sync, @@ -554,13 +556,14 @@ pub(crate) fn ancestry, E, RA>( Ok(tree_route.retracted().iter().skip(1).map(|e| e.hash).collect()) } -impl, RA, SC, VR> +impl, N, RA, SC, VR> voter::Environment> -for Environment +for Environment where Block: 'static, B: Backend + 'static, E: CallExecutor + 'static + Send + Sync, + N: NetworkT + 'static + Send, RA: 'static + Send + Sync, SC: SelectChain + 'static, VR: VotingRule>, diff --git a/client/finality-grandpa/src/lib.rs b/client/finality-grandpa/src/lib.rs index 7d3b26a632..b6745baf69 100644 --- a/client/finality-grandpa/src/lib.rs +++ b/client/finality-grandpa/src/lib.rs @@ -90,7 +90,6 @@ mod observer; mod until_imported; mod voting_rule; -pub use sc_network_gossip::Network; pub use finality_proof::FinalityProofProvider; pub use justification::GrandpaJustification; pub use light_import::light_block_import; @@ -103,7 +102,7 @@ use aux_schema::PersistentData; use environment::{Environment, VoterSetState}; use import::GrandpaBlockImport; use until_imported::UntilGlobalMessageBlocksImported; -use communication::NetworkBridge; +use communication::{NetworkBridge, Network as NetworkT}; use sp_finality_grandpa::{AuthorityList, AuthorityPair, AuthoritySignature, SetId}; // Re-export these two because it's just so damn convenient. @@ -276,8 +275,9 @@ pub(crate) trait BlockSyncRequester { fn set_sync_fork_request(&self, peers: Vec, hash: Block::Hash, number: NumberFor); } -impl BlockSyncRequester for NetworkBridge where +impl BlockSyncRequester for NetworkBridge where Block: BlockT, + Network: NetworkT, { fn set_sync_fork_request(&self, peers: Vec, hash: Block::Hash, number: NumberFor) { NetworkBridge::set_sync_fork_request(self, peers, hash, number) @@ -446,11 +446,11 @@ where )) } -fn global_communication, B, E, RA>( +fn global_communication, B, E, N, RA>( set_id: SetId, voters: &Arc>, client: &Arc>, - network: &NetworkBridge, + network: &NetworkBridge, keystore: &Option, ) -> ( impl Stream< @@ -464,6 +464,7 @@ fn global_communication, B, E, RA>( ) where B: Backend, E: CallExecutor + Send + Sync, + N: NetworkT, RA: Send + Sync, NumberFor: BlockNumberOps, { @@ -548,7 +549,7 @@ pub fn run_grandpa_voter, N, RA, SC, VR, X, Sp>( Block::Hash: Ord, B: Backend + 'static, E: CallExecutor + Send + Sync + 'static, - N: Network + Send + Clone + 'static, + N: NetworkT + Send + Sync + Clone + 'static, SC: SelectChain + 'static, VR: VotingRule> + Clone + 'static, NumberFor: BlockNumberOps, @@ -641,15 +642,16 @@ pub fn run_grandpa_voter, N, RA, SC, VR, X, Sp>( /// Future that powers the voter. #[must_use] -struct VoterWork { +struct VoterWork, RA, SC, VR> { voter: Box>> + Send>, - env: Arc>, + env: Arc>, voter_commands_rx: mpsc::UnboundedReceiver>>, } -impl VoterWork +impl VoterWork where Block: BlockT, + N: NetworkT + Sync, NumberFor: BlockNumberOps, RA: 'static + Send + Sync, E: CallExecutor + Send + Sync + 'static, @@ -660,7 +662,7 @@ where fn new( client: Arc>, config: Config, - network: NetworkBridge, + network: NetworkBridge, select_chain: SC, voting_rule: VR, persistent_data: PersistentData, @@ -821,9 +823,10 @@ where } } -impl Future for VoterWork +impl Future for VoterWork where Block: BlockT, + N: NetworkT + Sync, NumberFor: BlockNumberOps, RA: 'static + Send + Sync, E: CallExecutor + Send + Sync + 'static, @@ -880,7 +883,7 @@ pub fn run_grandpa, N, RA, SC, VR, X, Sp>( Block::Hash: Ord, B: Backend + 'static, E: CallExecutor + Send + Sync + 'static, - N: Network + Send + Clone + 'static, + N: NetworkT + Send + Sync + Clone + 'static, SC: SelectChain + 'static, NumberFor: BlockNumberOps, DigestFor: Encode, @@ -906,7 +909,7 @@ pub fn setup_disabled_grandpa, RA, N>( B: Backend + 'static, E: CallExecutor + Send + Sync + 'static, RA: Send + Sync + 'static, - N: Network + Send + Clone + 'static, + N: NetworkT + Send + Clone + 'static, { register_finality_tracker_inherent_data_provider( client, diff --git a/client/finality-grandpa/src/observer.rs b/client/finality-grandpa/src/observer.rs index 350d9d31c0..2cb3c18045 100644 --- a/client/finality-grandpa/src/observer.rs +++ b/client/finality-grandpa/src/observer.rs @@ -32,10 +32,10 @@ use sp_core::{H256, Blake2Hasher}; use crate::{ global_communication, CommandOrError, CommunicationIn, Config, environment, - LinkHalf, Network, Error, aux_schema::PersistentData, VoterCommand, VoterSetState, + LinkHalf, Error, aux_schema::PersistentData, VoterCommand, VoterSetState, }; use crate::authorities::SharedAuthoritySet; -use crate::communication::NetworkBridge; +use crate::communication::{Network as NetworkT, NetworkBridge}; use crate::consensus_changes::SharedConsensusChanges; use sp_finality_grandpa::AuthorityId; @@ -160,7 +160,7 @@ pub fn run_grandpa_observer, N, RA, SC, Sp>( ) -> ::sp_blockchain::Result + Send + 'static> where B: Backend + 'static, E: CallExecutor + Send + Sync + 'static, - N: Network + Send + Clone + 'static, + N: NetworkT + Send + Clone + 'static, SC: SelectChain + 'static, NumberFor: BlockNumberOps, RA: Send + Sync + 'static, @@ -202,18 +202,19 @@ pub fn run_grandpa_observer, N, RA, SC, Sp>( /// Future that powers the observer. #[must_use] -struct ObserverWork, E, Backend, RA> { +struct ObserverWork, N: NetworkT, E, Backend, RA> { observer: Box>> + Send>, client: Arc>, - network: NetworkBridge, + network: NetworkBridge, persistent_data: PersistentData, keystore: Option, voter_commands_rx: mpsc::UnboundedReceiver>>, } -impl ObserverWork +impl ObserverWork where B: BlockT, + N: NetworkT, NumberFor: BlockNumberOps, RA: 'static + Send + Sync, E: CallExecutor + Send + Sync + 'static, @@ -221,7 +222,7 @@ where { fn new( client: Arc>, - network: NetworkBridge, + network: NetworkBridge, persistent_data: PersistentData, keystore: Option, voter_commands_rx: mpsc::UnboundedReceiver>>, @@ -325,9 +326,10 @@ where } } -impl Future for ObserverWork +impl Future for ObserverWork where B: BlockT, + N: NetworkT, NumberFor: BlockNumberOps, RA: 'static + Send + Sync, E: CallExecutor + Send + Sync + 'static, diff --git a/client/network-gossip/src/bridge.rs b/client/network-gossip/src/bridge.rs index 34d2fa6180..70b0f78cf3 100644 --- a/client/network-gossip/src/bridge.rs +++ b/client/network-gossip/src/bridge.rs @@ -24,7 +24,7 @@ use sc_network::{Event, ReputationChange}; use futures::{prelude::*, channel::mpsc, compat::Compat01As03, task::SpawnExt as _}; use libp2p::PeerId; use parking_lot::Mutex; -use sp_runtime::{traits::{Block as BlockT, NumberFor}, ConsensusEngineId}; +use sp_runtime::{traits::Block as BlockT, ConsensusEngineId}; use std::{sync::Arc, time::Duration}; /// Wraps around an implementation of the `Network` crate and provides gossiping capabilities on @@ -234,19 +234,6 @@ impl GossipEngine { pub fn announce(&self, block: B::Hash, associated_data: Vec) { self.inner.lock().context_ext.announce(block, associated_data); } - - /// Notifies the sync service to try and sync the given block from the given - /// peers. - /// - /// If the given vector of peers is empty then the underlying implementation - /// should make a best effort to fetch the block from any peers it is - /// connected to (NOTE: this assumption will change in the future #3629). - /// - /// Note: this method isn't strictly related to gossiping and should eventually be moved - /// somewhere else. - pub fn set_sync_fork_request(&self, peers: Vec, hash: B::Hash, number: NumberFor) { - self.inner.lock().context_ext.set_sync_fork_request(peers, hash, number); - } } impl Clone for GossipEngine { @@ -287,15 +274,10 @@ impl> Context for ContextOverService { trait ContextExt { fn announce(&self, block: B::Hash, associated_data: Vec); - fn set_sync_fork_request(&self, peers: Vec, hash: B::Hash, number: NumberFor); } impl> ContextExt for ContextOverService { fn announce(&self, block: B::Hash, associated_data: Vec) { Network::announce(&self.network, block, associated_data) } - - fn set_sync_fork_request(&self, peers: Vec, hash: B::Hash, number: NumberFor) { - Network::set_sync_fork_request(&self.network, peers, hash, number) - } } diff --git a/client/network-gossip/src/lib.rs b/client/network-gossip/src/lib.rs index 5459123c41..86bc41af4b 100644 --- a/client/network-gossip/src/lib.rs +++ b/client/network-gossip/src/lib.rs @@ -60,7 +60,7 @@ pub use self::state_machine::{Validator, ValidatorContext, ValidationResult}; pub use self::state_machine::DiscardAll; use sc_network::{specialization::NetworkSpecialization, Event, ExHashT, NetworkService, PeerId, ReputationChange}; -use sp_runtime::{traits::{Block as BlockT, NumberFor}, ConsensusEngineId}; +use sp_runtime::{traits::Block as BlockT, ConsensusEngineId}; use std::sync::Arc; mod bridge; @@ -93,17 +93,6 @@ pub trait Network { /// Note: this method isn't strictly related to gossiping and should eventually be moved /// somewhere else. fn announce(&self, block: B::Hash, associated_data: Vec); - - /// Notifies the sync service to try and sync the given block from the given - /// peers. - /// - /// If the given vector of peers is empty then the underlying implementation - /// should make a best effort to fetch the block from any peers it is - /// connected to (NOTE: this assumption will change in the future #3629). - /// - /// Note: this method isn't strictly related to gossiping and should eventually be moved - /// somewhere else. - fn set_sync_fork_request(&self, peers: Vec, hash: B::Hash, number: NumberFor); } impl, H: ExHashT> Network for Arc> { @@ -133,8 +122,4 @@ impl, H: ExHashT> Network for Arc) { NetworkService::announce_block(self, block, associated_data) } - - fn set_sync_fork_request(&self, peers: Vec, hash: B::Hash, number: NumberFor) { - NetworkService::set_sync_fork_request(self, peers, hash, number) - } } -- GitLab From 00bb3829416037432314be67dab60d3e0947d71c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Silva?= Date: Wed, 18 Dec 2019 13:18:29 +0000 Subject: [PATCH 162/172] grandpa: log everything under afg target (#4443) --- client/finality-grandpa/src/authorities.rs | 4 ++-- client/finality-grandpa/src/environment.rs | 10 +++++----- client/finality-grandpa/src/finality_proof.rs | 10 +++++----- client/finality-grandpa/src/import.rs | 6 +++--- client/finality-grandpa/src/light_import.rs | 16 ++++++++-------- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/client/finality-grandpa/src/authorities.rs b/client/finality-grandpa/src/authorities.rs index aa9b850779..2f01ce53b8 100644 --- a/client/finality-grandpa/src/authorities.rs +++ b/client/finality-grandpa/src/authorities.rs @@ -258,7 +258,7 @@ where // check if the given best block is in the same branch as the block that signaled the change. if is_descendent_of(&change.canon_hash, &best_hash)? { // apply this change: make the set canonical - info!(target: "finality", "Applying authority set change forced at block #{:?}", + info!(target: "afg", "Applying authority set change forced at block #{:?}", change.canon_height); telemetry!(CONSENSUS_INFO; "afg.applying_forced_authority_set_change"; "block" => ?change.canon_height @@ -324,7 +324,7 @@ where self.pending_forced_changes.clear(); if let Some(change) = change { - info!(target: "finality", "Applying authority set change scheduled at block #{:?}", + info!(target: "afg", "Applying authority set change scheduled at block #{:?}", change.canon_height); telemetry!(CONSENSUS_INFO; "afg.applying_scheduled_authority_set_change"; "block" => ?change.canon_height diff --git a/client/finality-grandpa/src/environment.rs b/client/finality-grandpa/src/environment.rs index 77153554c9..efc8052ab8 100644 --- a/client/finality-grandpa/src/environment.rs +++ b/client/finality-grandpa/src/environment.rs @@ -1010,8 +1010,8 @@ pub(crate) fn finalize_block, E, RA>( ); if let Err(e) = write_result { - warn!(target: "finality", "Failed to write updated consensus changes to disk. Bailing."); - warn!(target: "finality", "Node is in a potentially inconsistent state."); + warn!(target: "afg", "Failed to write updated consensus changes to disk. Bailing."); + warn!(target: "afg", "Node is in a potentially inconsistent state."); return Err(e.into()); } @@ -1063,7 +1063,7 @@ pub(crate) fn finalize_block, E, RA>( // ideally some handle to a synchronization oracle would be used // to avoid unconditionally notifying. client.apply_finality(import_op, BlockId::Hash(hash), justification, true).map_err(|e| { - warn!(target: "finality", "Error applying finality to block {:?}: {:?}", (hash, number), e); + warn!(target: "afg", "Error applying finality to block {:?}: {:?}", (hash, number), e); e })?; telemetry!(CONSENSUS_INFO; "afg.finalized_blocks_up_to"; @@ -1103,8 +1103,8 @@ pub(crate) fn finalize_block, E, RA>( ); if let Err(e) = write_result { - warn!(target: "finality", "Failed to write updated authority set to disk. Bailing."); - warn!(target: "finality", "Node is in a potentially inconsistent state."); + warn!(target: "afg", "Failed to write updated authority set to disk. Bailing."); + warn!(target: "afg", "Node is in a potentially inconsistent state."); return Err(e.into()); } diff --git a/client/finality-grandpa/src/finality_proof.rs b/client/finality-grandpa/src/finality_proof.rs index 1e17845471..69d4c77e5f 100644 --- a/client/finality-grandpa/src/finality_proof.rs +++ b/client/finality-grandpa/src/finality_proof.rs @@ -167,7 +167,7 @@ impl sc_network::FinalityProofProvider for FinalityProofProvide ) -> Result>, ClientError> { let request: FinalityProofRequest = Decode::decode(&mut &request[..]) .map_err(|e| { - warn!(target: "finality", "Unable to decode finality proof request: {}", e.what()); + warn!(target: "afg", "Unable to decode finality proof request: {}", e.what()); ClientError::Backend(format!("Invalid finality proof request")) })?; match request { @@ -269,7 +269,7 @@ pub(crate) fn prove_finality, B: BlockchainBackend, B: BlockchainBackend, B: BlockchainBackend, B: BlockchainBackend, RA, SC> BlockImport Some(justification) => { self.import_justification(hash, number, justification, needs_justification).unwrap_or_else(|err| { if needs_justification || enacts_consensus_change { - debug!(target: "finality", "Imported block #{} that enacts authority set change with \ + debug!(target: "afg", "Imported block #{} that enacts authority set change with \ invalid justification: {:?}, requesting justification from peers.", number, err); imported_aux.bad_justification = true; imported_aux.needs_justification = true; @@ -482,7 +482,7 @@ impl, RA, SC> BlockImport None => { if needs_justification { trace!( - target: "finality", + target: "afg", "Imported unjustified block #{} that enacts authority set change, waiting for finality for enactment.", number, ); @@ -573,7 +573,7 @@ where match result { Err(CommandOrError::VoterCommand(command)) => { - info!(target: "finality", "Imported justification for block #{} that triggers \ + info!(target: "afg", "Imported justification for block #{} that triggers \ command {}, signaling voter.", number, command); // send the command to the voter diff --git a/client/finality-grandpa/src/light_import.rs b/client/finality-grandpa/src/light_import.rs index 8907ac8226..fe05f6dc46 100644 --- a/client/finality-grandpa/src/light_import.rs +++ b/client/finality-grandpa/src/light_import.rs @@ -263,7 +263,7 @@ fn do_import_block, J>( match justification { Some(justification) => { trace!( - target: "finality", + target: "afg", "Imported block {}{}. Importing justification.", if enacts_consensus_change { " which enacts consensus changes" } else { "" }, hash, @@ -273,7 +273,7 @@ fn do_import_block, J>( }, None if enacts_consensus_change => { trace!( - target: "finality", + target: "afg", "Imported block {} which enacts consensus changes. Requesting finality proof.", hash, ); @@ -393,7 +393,7 @@ fn do_import_justification, J>( let justification = match justification { Err(ClientError::BadJustification(_)) => { trace!( - target: "finality", + target: "afg", "Justification for {} is not valid within current authorities set. Requesting finality proof.", hash, ); @@ -404,7 +404,7 @@ fn do_import_justification, J>( }, Err(e) => { trace!( - target: "finality", + target: "afg", "Justification for {} is not valid. Bailing.", hash, ); @@ -413,7 +413,7 @@ fn do_import_justification, J>( }, Ok(justification) => { trace!( - target: "finality", + target: "afg", "Justification for {} is valid. Finalizing the block.", hash, ); @@ -444,7 +444,7 @@ fn do_finalize_block>( { // finalize the block client.finalize_block(BlockId::Hash(hash), Some(justification), true).map_err(|e| { - warn!(target: "finality", "Error applying finality to block {:?}: {:?}", (hash, number), e); + warn!(target: "afg", "Error applying finality to block {:?}: {:?}", (hash, number), e); ConsensusError::ClientImport(e.to_string()) })?; @@ -532,8 +532,8 @@ fn require_insert_aux( /// Display inconsistency warning. fn on_post_finalization_error(error: ClientError, value_type: &str) -> ConsensusError { - warn!(target: "finality", "Failed to write updated {} to disk. Bailing.", value_type); - warn!(target: "finality", "Node is in a potentially inconsistent state."); + warn!(target: "afg", "Failed to write updated {} to disk. Bailing.", value_type); + warn!(target: "afg", "Node is in a potentially inconsistent state."); ConsensusError::ClientImport(error.to_string()) } -- GitLab From adc8d505a848ac84ff88758caf3ddc92db6fc202 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Silva?= Date: Wed, 18 Dec 2019 13:32:09 +0000 Subject: [PATCH 163/172] grandpa: fix slow gossip test (#4440) --- client/finality-grandpa/src/communication/tests.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/client/finality-grandpa/src/communication/tests.rs b/client/finality-grandpa/src/communication/tests.rs index 9b5884e857..3e99d14de6 100644 --- a/client/finality-grandpa/src/communication/tests.rs +++ b/client/finality-grandpa/src/communication/tests.rs @@ -274,16 +274,25 @@ fn good_commit_leads_to_relay() { let sender_id = id.clone(); let send_message = tester.filter_network_events(move |event| match event { Event::EventStream(sender) => { + // Add the sending peer and send the commit let _ = sender.unbounded_send(NetworkEvent::NotificationStreamOpened { remote: sender_id.clone(), engine_id: GRANDPA_ENGINE_ID, roles: Roles::FULL, }); + let _ = sender.unbounded_send(NetworkEvent::NotificationsReceived { remote: sender_id.clone(), messages: vec![(GRANDPA_ENGINE_ID, commit_to_send.clone().into())], }); + // Add a random peer which will be the recipient of this message + let _ = sender.unbounded_send(NetworkEvent::NotificationStreamOpened { + remote: sc_network::PeerId::random(), + engine_id: GRANDPA_ENGINE_ID, + roles: Roles::FULL, + }); + true } _ => false, -- GitLab From 946d43c27852e8fcb26f2b6f12af66e1bf3c6d85 Mon Sep 17 00:00:00 2001 From: Leo Arias Date: Wed, 18 Dec 2019 14:17:22 -0600 Subject: [PATCH 164/172] Fix typo in comment (#4433) --- frame/treasury/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/treasury/src/lib.rs b/frame/treasury/src/lib.rs index 5574c69d7a..49de399b50 100644 --- a/frame/treasury/src/lib.rs +++ b/frame/treasury/src/lib.rs @@ -25,7 +25,7 @@ //! ## Overview //! //! The Treasury Module itself provides the pot to store funds, and a means for stakeholders to -//! propose, approve, and deny expendatures. The chain will need to provide a method (e.g. +//! propose, approve, and deny expenditures. The chain will need to provide a method (e.g. //! inflation, fees) for collecting funds. //! //! By way of example, the Council could vote to fund the Treasury with a portion of the block -- GitLab From ab4aca33fde8ecd0803771e289e97dec74291e82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Wed, 18 Dec 2019 21:28:25 +0100 Subject: [PATCH 165/172] Document TransactionStatus and fix termination conditions. (#4446) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Document TransactionStatus and fix termination conditions. * Update client/rpc-api/src/author/mod.rs Co-Authored-By: Bastian Köcher --- client/rpc-api/src/author/mod.rs | 3 ++ client/rpc-api/src/system/mod.rs | 15 +++---- client/transaction-pool/graph/src/listener.rs | 2 +- client/transaction-pool/graph/src/pool.rs | 4 +- client/transaction-pool/graph/src/watcher.rs | 10 +++-- primitives/transaction-pool/src/pool.rs | 44 ++++++++++++++++--- 6 files changed, 58 insertions(+), 20 deletions(-) diff --git a/client/rpc-api/src/author/mod.rs b/client/rpc-api/src/author/mod.rs index c2fbe229c1..8d2b51faf8 100644 --- a/client/rpc-api/src/author/mod.rs +++ b/client/rpc-api/src/author/mod.rs @@ -60,6 +60,9 @@ pub trait AuthorApi { ) -> Result>; /// Submit an extrinsic to watch. + /// + /// See [`TransactionStatus`](sp_transaction_pool::TransactionStatus) for details on transaction + /// lifecycle. #[pubsub( subscription = "author_extrinsicUpdate", subscribe, diff --git a/client/rpc-api/src/system/mod.rs b/client/rpc-api/src/system/mod.rs index 29a92e16b6..22c1b3bb2a 100644 --- a/client/rpc-api/src/system/mod.rs +++ b/client/rpc-api/src/system/mod.rs @@ -22,9 +22,8 @@ pub mod helpers; use crate::helpers::Receiver; use jsonrpc_derive::rpc; use futures::{future::BoxFuture, compat::Compat}; -use std::pin::Pin; -use self::error::{Error, Result}; +use self::error::Result as SystemResult; pub use self::helpers::{Properties, SystemInfo, Health, PeerInfo, NodeRole}; pub use self::gen_client::Client as SystemClient; @@ -34,19 +33,19 @@ pub use self::gen_client::Client as SystemClient; pub trait SystemApi { /// Get the node's implementation name. Plain old string. #[rpc(name = "system_name")] - fn system_name(&self) -> Result; + fn system_name(&self) -> SystemResult; /// Get the node implementation's version. Should be a semver string. #[rpc(name = "system_version")] - fn system_version(&self) -> Result; + fn system_version(&self) -> SystemResult; /// Get the chain's type. Given as a string identifier. #[rpc(name = "system_chain")] - fn system_chain(&self) -> Result; + fn system_chain(&self) -> SystemResult; /// Get a custom set of properties as a JSON object, defined in the chain spec. #[rpc(name = "system_properties")] - fn system_properties(&self) -> Result; + fn system_properties(&self) -> SystemResult; /// Return health status of the node. /// @@ -74,13 +73,13 @@ pub trait SystemApi { /// is an example of a valid, passing multiaddr with PeerId attached. #[rpc(name = "system_addReservedPeer", returns = "()")] fn system_add_reserved_peer(&self, peer: String) - -> Compat>>; + -> Compat>>; /// Remove a reserved peer. Returns the empty string or an error. The string /// should encode only the PeerId e.g. `QmSk5HQbn6LhUwDiNMseVUjuRYhEtYj4aUZ6WfWoGURpdV`. #[rpc(name = "system_removeReservedPeer", returns = "()")] fn system_remove_reserved_peer(&self, peer_id: String) - -> Compat>>; + -> Compat>>; /// Returns the roles the node is running as. #[rpc(name = "system_nodeRoles", returns = "Vec")] diff --git a/client/transaction-pool/graph/src/listener.rs b/client/transaction-pool/graph/src/listener.rs index 865255c9c7..a6d65a93ce 100644 --- a/client/transaction-pool/graph/src/listener.rs +++ b/client/transaction-pool/graph/src/listener.rs @@ -103,6 +103,6 @@ impl Listene /// Transaction was pruned from the pool. pub fn pruned(&mut self, header_hash: H2, tx: &H) { debug!(target: "txpool", "[{:?}] Pruned at {:?}", tx, header_hash); - self.fire(tx, |watcher| watcher.finalized(header_hash)) + self.fire(tx, |watcher| watcher.in_block(header_hash)) } } diff --git a/client/transaction-pool/graph/src/pool.rs b/client/transaction-pool/graph/src/pool.rs index bb5f59ef87..4e4224695e 100644 --- a/client/transaction-pool/graph/src/pool.rs +++ b/client/transaction-pool/graph/src/pool.rs @@ -806,7 +806,7 @@ mod tests { // then let mut stream = futures::executor::block_on_stream(watcher.into_stream()); assert_eq!(stream.next(), Some(TransactionStatus::Ready)); - assert_eq!(stream.next(), Some(TransactionStatus::Finalized(H256::from_low_u64_be(2).into()))); + assert_eq!(stream.next(), Some(TransactionStatus::InBlock(H256::from_low_u64_be(2).into()))); assert_eq!(stream.next(), None); } @@ -831,7 +831,7 @@ mod tests { // then let mut stream = futures::executor::block_on_stream(watcher.into_stream()); assert_eq!(stream.next(), Some(TransactionStatus::Ready)); - assert_eq!(stream.next(), Some(TransactionStatus::Finalized(H256::from_low_u64_be(2).into()))); + assert_eq!(stream.next(), Some(TransactionStatus::InBlock(H256::from_low_u64_be(2).into()))); assert_eq!(stream.next(), None); } diff --git a/client/transaction-pool/graph/src/watcher.rs b/client/transaction-pool/graph/src/watcher.rs index f222c8b621..ded849e380 100644 --- a/client/transaction-pool/graph/src/watcher.rs +++ b/client/transaction-pool/graph/src/watcher.rs @@ -84,12 +84,13 @@ impl Sender { /// Some state change (perhaps another extrinsic was included) rendered this extrinsic invalid. pub fn usurped(&mut self, hash: H) { - self.send(TransactionStatus::Usurped(hash)) + self.send(TransactionStatus::Usurped(hash)); + self.finalized = true; } - /// Extrinsic has been finalized in block with given hash. - pub fn finalized(&mut self, hash: H2) { - self.send(TransactionStatus::Finalized(hash)); + /// Extrinsic has been included in block with given hash. + pub fn in_block(&mut self, hash: H2) { + self.send(TransactionStatus::InBlock(hash)); self.finalized = true; } @@ -103,6 +104,7 @@ impl Sender { /// Transaction has been dropped from the pool because of the limit. pub fn dropped(&mut self) { self.send(TransactionStatus::Dropped); + self.finalized = true; } /// The extrinsic has been broadcast to the given peers. diff --git a/primitives/transaction-pool/src/pool.rs b/primitives/transaction-pool/src/pool.rs index 009b9c7863..52a3282f87 100644 --- a/primitives/transaction-pool/src/pool.rs +++ b/primitives/transaction-pool/src/pool.rs @@ -55,6 +55,38 @@ impl PoolStatus { } /// Possible transaction status events. +/// +/// This events are being emitted by `TransactionPool` watchers, +/// which are also exposed over RPC. +/// +/// The status events can be grouped based on their kinds as: +/// 1. Entering/Moving within the pool: +/// - `Future` +/// - `Ready` +/// 2. Inside `Ready` queue: +/// - `Broadcast` +/// 3. Leaving the pool: +/// - `InBlock` +/// - `Invalid` +/// - `Usurped` +/// - `Dropped` +/// +/// The events will always be received in the order described above, however +/// there might be cases where transactions alternate between `Future` and `Ready` +/// pool, and are `Broadcast` in the meantime. +/// +/// There is also only single event causing the transaction to leave the pool. +/// +/// Note that there are conditions that may cause transactions to reappear in the pool. +/// 1. Due to possible forks, the transaction that ends up being in included +/// in one block, may later re-enter the pool or be marked as invalid. +/// 2. Transaction `Dropped` at one point, may later re-enter the pool if some other +/// transactions are removed. +/// 3. `Invalid` transaction may become valid at some point in the future. +/// (Note that runtimes are encouraged to use `UnknownValidity` to inform the pool about +/// such case). +/// +/// However the user needs to re-subscribe to receive such notifications. #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub enum TransactionStatus { @@ -62,15 +94,17 @@ pub enum TransactionStatus { Future, /// Transaction is part of the ready queue. Ready, - /// Transaction has been finalized in block with given hash. - Finalized(BlockHash), - /// Some state change (perhaps another transaction was included) rendered this transaction invalid. - Usurped(Hash), /// The transaction has been broadcast to the given peers. Broadcast(Vec), + /// Transaction has been included in block with given hash. + #[serde(rename = "finalized")] // See #4438 + InBlock(BlockHash), + /// Transaction has been replaced in the pool, by another transaction + /// that provides the same tags. (e.g. same (sender, nonce)). + Usurped(Hash), /// Transaction has been dropped from the pool because of the limit. Dropped, - /// Transaction was detected as invalid. + /// Transaction is no longer valid in the current state. Invalid, } -- GitLab From 7ba240f1d49d856471ed52ca8200fa37563dc87a Mon Sep 17 00:00:00 2001 From: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Date: Thu, 19 Dec 2019 16:24:17 +0800 Subject: [PATCH 166/172] Few extra tests for phragmen (#4451) --- primitives/phragmen/src/tests.rs | 51 ++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/primitives/phragmen/src/tests.rs b/primitives/phragmen/src/tests.rs index eceedb8847..09491b3b90 100644 --- a/primitives/phragmen/src/tests.rs +++ b/primitives/phragmen/src/tests.rs @@ -354,3 +354,54 @@ fn phragmen_linear_equalize() { run_and_compare(candidates, voters, stake_of, 2, 2); } + +#[test] +fn elect_has_no_entry_barrier() { + let candidates = vec![10, 20, 30]; + let voters = vec![ + (1, vec![10]), + (2, vec![20]), + ]; + let stake_of = create_stake_of(&[ + (1, 10), + (2, 10), + ]); + + let PhragmenResult { winners, assignments: _ } = elect::<_, _, _, TestCurrencyToVote>( + 3, + 3, + candidates, + voters, + stake_of, + ).unwrap(); + + // 30 is elected with stake 0. The caller is responsible for stripping this. + assert_eq_uvec!(winners, vec![ + (10, 10), + (20, 10), + (30, 0), + ]); +} + +#[test] +fn minimum_to_elect_is_respected() { + let candidates = vec![10, 20, 30]; + let voters = vec![ + (1, vec![10]), + (2, vec![20]), + ]; + let stake_of = create_stake_of(&[ + (1, 10), + (2, 10), + ]); + + let maybe_result = elect::<_, _, _, TestCurrencyToVote>( + 10, + 10, + candidates, + voters, + stake_of, + ); + + assert!(maybe_result.is_none()); +} -- GitLab From fef0e75290f16b37f7afc5d4ba6d869ca1fcc483 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Thu, 19 Dec 2019 14:01:52 +0100 Subject: [PATCH 167/172] Make `decl_error!` errors usable (#4449) * Make `decl_error!` errors usable This pr implements support for returning errors of different pallets in a pallet. These errors need to be declared with `decl_error!`. The pr changes the following: - Each dispatchable function now returns a `DispatchResult` which is an alias for `Result<(), DispatchError>`. - `DispatchError` is an enum that has 4 variants: - `Other`: For storing string error messages - `CannotLookup`: Variant that is returned when something returns a `sp_runtime::LookupError` - `BadOrigin`: Variant that is returned for any kind of bad origin - `Module`: The error of a specific module. Contains the `index`, `error` and the `message`. The index is the index of the module in `construct_runtime!`. `error` is the index of the error in the error enum declared by `decl_error!`. `message` is the message to the error variant (this will not be encoded). - `construct_runtime!` now creates a new struct `ModuleToIndex`. This struct implements the trait `ModuleToIndex`. - `frame_system::Trait` has a new associated type: `ModuleToIndex` that expects the `ModuleToIndex` generated by `construct_runtime!`. - All error strings returned in any module are being converted now to `DispatchError`. - `BadOrigin` is the default error returned by any type that implements `EnsureOrigin`. * Fix frame system benchmarks --- bin/node-template/runtime/src/lib.rs | 4 + bin/node-template/runtime/src/template.rs | 3 +- bin/node/runtime/src/lib.rs | 1 + frame/assets/src/lib.rs | 29 +-- frame/aura/src/mock.rs | 1 + frame/authority-discovery/src/lib.rs | 1 + frame/authorship/src/lib.rs | 17 +- frame/babe/src/mock.rs | 1 + frame/balances/src/lib.rs | 44 ++-- frame/balances/src/mock.rs | 1 + frame/balances/src/tests.rs | 4 +- frame/collective/src/lib.rs | 41 ++-- frame/contracts/src/exec.rs | 54 ++-- frame/contracts/src/gas.rs | 3 +- frame/contracts/src/lib.rs | 30 +-- frame/contracts/src/tests.rs | 1 + frame/contracts/src/wasm/mod.rs | 5 +- frame/contracts/src/wasm/runtime.rs | 6 +- frame/democracy/src/lib.rs | 232 ++++++++++-------- frame/elections-phragmen/src/lib.rs | 13 +- frame/elections/src/lib.rs | 19 +- frame/elections/src/mock.rs | 1 + frame/elections/src/tests.rs | 5 +- frame/evm/src/lib.rs | 59 ++--- frame/example/src/lib.rs | 7 +- frame/executive/src/lib.rs | 10 +- frame/finality-tracker/src/lib.rs | 13 +- frame/generic-asset/src/lib.rs | 49 ++-- frame/generic-asset/src/mock.rs | 1 + frame/grandpa/src/lib.rs | 24 +- frame/grandpa/src/mock.rs | 1 + frame/identity/src/lib.rs | 30 +-- frame/im-online/src/lib.rs | 2 +- frame/im-online/src/mock.rs | 1 + frame/im-online/src/tests.rs | 5 +- frame/indices/src/mock.rs | 1 + frame/membership/src/lib.rs | 1 + frame/nicks/src/lib.rs | 1 + frame/offences/src/mock.rs | 1 + frame/randomness-collective-flip/src/lib.rs | 3 +- frame/scored-pool/src/lib.rs | 4 +- frame/scored-pool/src/mock.rs | 1 + frame/session/src/lib.rs | 6 +- frame/session/src/mock.rs | 1 + frame/staking/src/lib.rs | 74 +++--- frame/staking/src/mock.rs | 1 + frame/staking/src/tests.rs | 18 +- frame/sudo/src/lib.rs | 22 +- .../procedural/src/construct_runtime/mod.rs | 50 +++- frame/support/procedural/tools/src/lib.rs | 2 +- frame/support/src/dispatch.rs | 55 ++--- frame/support/src/error.rs | 106 ++++---- frame/support/src/lib.rs | 4 +- frame/support/src/metadata.rs | 16 +- frame/support/src/traits.rs | 28 ++- frame/support/test/tests/decl_error.rs | 135 ++++++++++ frame/support/test/tests/instance.rs | 1 + frame/support/test/tests/issue2219.rs | 1 + .../tests/reserved_keyword/on_initialize.rs | 4 +- frame/support/test/tests/system.rs | 3 +- frame/system/benches/bench.rs | 1 + frame/system/src/lib.rs | 35 +-- frame/timestamp/src/lib.rs | 3 +- frame/transaction-payment/src/lib.rs | 1 + frame/treasury/src/lib.rs | 30 +-- frame/utility/src/lib.rs | 14 +- primitives/runtime/src/lib.rs | 104 ++++---- primitives/runtime/src/traits.rs | 31 +-- test-utils/runtime/src/lib.rs | 1 + 69 files changed, 867 insertions(+), 610 deletions(-) create mode 100644 frame/support/test/tests/decl_error.rs diff --git a/bin/node-template/runtime/src/lib.rs b/bin/node-template/runtime/src/lib.rs index 04f9d03363..60d8b7485d 100644 --- a/bin/node-template/runtime/src/lib.rs +++ b/bin/node-template/runtime/src/lib.rs @@ -157,6 +157,10 @@ impl system::Trait for Runtime { type AvailableBlockRatio = AvailableBlockRatio; /// Version of the runtime. type Version = Version; + /// Converts a module to the index of the module in `construct_runtime!`. + /// + /// This type is being generated by `construct_runtime!`. + type ModuleToIndex = ModuleToIndex; } impl aura::Trait for Runtime { diff --git a/bin/node-template/runtime/src/template.rs b/bin/node-template/runtime/src/template.rs index b800eae70c..a64a4c3216 100644 --- a/bin/node-template/runtime/src/template.rs +++ b/bin/node-template/runtime/src/template.rs @@ -40,7 +40,7 @@ decl_module! { // Just a dummy entry point. // function that can be called by the external world as an extrinsics call // takes a parameter of the type `AccountId`, stores it and emits an event - pub fn do_something(origin, something: u32) -> dispatch::Result { + pub fn do_something(origin, something: u32) -> dispatch::DispatchResult { // TODO: You only need this if you want to check it was signed. let who = ensure_signed(origin)?; @@ -106,6 +106,7 @@ mod tests { type MaximumBlockLength = MaximumBlockLength; type AvailableBlockRatio = AvailableBlockRatio; type Version = (); + type ModuleToIndex = (); } impl Trait for Test { type Event = (); diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index e3f3101b37..488b29aa2a 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -125,6 +125,7 @@ impl frame_system::Trait for Runtime { type MaximumBlockLength = MaximumBlockLength; type AvailableBlockRatio = AvailableBlockRatio; type Version = Version; + type ModuleToIndex = (); } impl pallet_utility::Trait for Runtime { diff --git a/frame/assets/src/lib.rs b/frame/assets/src/lib.rs index 3beb247170..94ec8f73df 100644 --- a/frame/assets/src/lib.rs +++ b/frame/assets/src/lib.rs @@ -92,7 +92,7 @@ //! //! decl_module! { //! pub struct Module for enum Call where origin: T::Origin { -//! pub fn issue_token_airdrop(origin) -> dispatch::Result { +//! pub fn issue_token_airdrop(origin) -> dispatch::DispatchResult { //! let sender = ensure_signed(origin).map_err(|e| e.as_str())?; //! //! const ACCOUNT_ALICE: u64 = 1; @@ -133,7 +133,7 @@ #![cfg_attr(not(feature = "std"), no_std)] use frame_support::{Parameter, decl_module, decl_event, decl_storage, decl_error, ensure}; -use sp_runtime::traits::{Member, SimpleArithmetic, Zero, StaticLookup, ModuleDispatchError}; +use sp_runtime::traits::{Member, SimpleArithmetic, Zero, StaticLookup}; use frame_system::{self as system, ensure_signed}; use sp_runtime::traits::One; @@ -151,14 +151,14 @@ pub trait Trait: frame_system::Trait { decl_module! { pub struct Module for enum Call where origin: T::Origin { - type Error = Error; + type Error = Error; fn deposit_event() = default; /// Issue a new class of fungible assets. There are, and will only ever be, `total` /// such assets and they'll all belong to the `origin` initially. It will have an /// identifier `AssetId` instance: this will be specified in the `Issued` event. fn issue(origin, #[compact] total: T::Balance) { - let origin = ensure_signed(origin).map_err(|e| e.as_str())?; + let origin = ensure_signed(origin)?; let id = Self::next_asset_id(); >::mutate(|id| *id += One::one()); @@ -175,12 +175,12 @@ decl_module! { target: ::Source, #[compact] amount: T::Balance ) { - let origin = ensure_signed(origin).map_err(|e| e.as_str())?; + let origin = ensure_signed(origin)?; let origin_account = (id, origin.clone()); let origin_balance = >::get(&origin_account); let target = T::Lookup::lookup(target)?; - ensure!(!amount.is_zero(), Error::AmountZero); - ensure!(origin_balance >= amount, Error::BalanceLow); + ensure!(!amount.is_zero(), Error::::AmountZero); + ensure!(origin_balance >= amount, Error::::BalanceLow); Self::deposit_event(RawEvent::Transferred(id, origin, target.clone(), amount)); >::insert(origin_account, origin_balance - amount); @@ -189,9 +189,9 @@ decl_module! { /// Destroy any assets of `id` owned by `origin`. fn destroy(origin, #[compact] id: T::AssetId) { - let origin = ensure_signed(origin).map_err(|e| e.as_str())?; + let origin = ensure_signed(origin)?; let balance = >::take((id, &origin)); - ensure!(!balance.is_zero(), Error::BalanceZero); + ensure!(!balance.is_zero(), Error::::BalanceZero); >::mutate(id, |total_supply| *total_supply -= balance); Self::deposit_event(RawEvent::Destroyed(id, origin, balance)); @@ -215,7 +215,7 @@ decl_event! { } decl_error! { - pub enum Error { + pub enum Error for Module { /// Transfer amount should be non-zero AmountZero, /// Account balance must be greater than or equal to the transfer amount @@ -293,6 +293,7 @@ mod tests { type AvailableBlockRatio = AvailableBlockRatio; type MaximumBlockLength = MaximumBlockLength; type Version = (); + type ModuleToIndex = (); } impl Trait for Test { type Event = (); @@ -353,7 +354,7 @@ mod tests { assert_eq!(Assets::balance(0, 2), 50); assert_ok!(Assets::destroy(Origin::signed(1), 0)); assert_eq!(Assets::balance(0, 1), 0); - assert_noop!(Assets::transfer(Origin::signed(1), 0, 1, 50), Error::BalanceLow); + assert_noop!(Assets::transfer(Origin::signed(1), 0, 1, 50), Error::::BalanceLow); }); } @@ -362,7 +363,7 @@ mod tests { new_test_ext().execute_with(|| { assert_ok!(Assets::issue(Origin::signed(1), 100)); assert_eq!(Assets::balance(0, 1), 100); - assert_noop!(Assets::transfer(Origin::signed(1), 0, 2, 0), Error::AmountZero); + assert_noop!(Assets::transfer(Origin::signed(1), 0, 2, 0), Error::::AmountZero); }); } @@ -371,7 +372,7 @@ mod tests { new_test_ext().execute_with(|| { assert_ok!(Assets::issue(Origin::signed(1), 100)); assert_eq!(Assets::balance(0, 1), 100); - assert_noop!(Assets::transfer(Origin::signed(1), 0, 2, 101), Error::BalanceLow); + assert_noop!(Assets::transfer(Origin::signed(1), 0, 2, 101), Error::::BalanceLow); }); } @@ -389,7 +390,7 @@ mod tests { new_test_ext().execute_with(|| { assert_ok!(Assets::issue(Origin::signed(1), 100)); assert_eq!(Assets::balance(0, 2), 0); - assert_noop!(Assets::destroy(Origin::signed(2), 0), Error::BalanceZero); + assert_noop!(Assets::destroy(Origin::signed(2), 0), Error::::BalanceZero); }); } } diff --git a/frame/aura/src/mock.rs b/frame/aura/src/mock.rs index 758bb72597..fbab5a421c 100644 --- a/frame/aura/src/mock.rs +++ b/frame/aura/src/mock.rs @@ -60,6 +60,7 @@ impl frame_system::Trait for Test { type AvailableBlockRatio = AvailableBlockRatio; type MaximumBlockLength = MaximumBlockLength; type Version = (); + type ModuleToIndex = (); } impl pallet_timestamp::Trait for Test { diff --git a/frame/authority-discovery/src/lib.rs b/frame/authority-discovery/src/lib.rs index b4abae88dd..065005373f 100644 --- a/frame/authority-discovery/src/lib.rs +++ b/frame/authority-discovery/src/lib.rs @@ -165,6 +165,7 @@ mod tests { type AvailableBlockRatio = AvailableBlockRatio; type MaximumBlockLength = MaximumBlockLength; type Version = (); + type ModuleToIndex = (); } impl_outer_origin! { diff --git a/frame/authorship/src/lib.rs b/frame/authorship/src/lib.rs index 882e8161da..5c2f964220 100644 --- a/frame/authorship/src/lib.rs +++ b/frame/authorship/src/lib.rs @@ -184,12 +184,12 @@ decl_module! { /// Provide a set of uncles. #[weight = SimpleDispatchInfo::FixedOperational(10_000)] - fn set_uncles(origin, new_uncles: Vec) -> dispatch::Result { + fn set_uncles(origin, new_uncles: Vec) -> dispatch::DispatchResult { ensure_none(origin)?; ensure!(new_uncles.len() <= MAX_UNCLES, "Too many uncles"); if ::DidSetUncles::get() { - return Err("Uncles already set in block."); + Err("Uncles already set in block.")? } ::DidSetUncles::put(true); @@ -219,7 +219,7 @@ impl Module { } } - fn verify_and_import_uncles(new_uncles: Vec) -> dispatch::Result { + fn verify_and_import_uncles(new_uncles: Vec) -> dispatch::DispatchResult { let now = >::block_number(); let mut uncles = ::Uncles::get(); @@ -408,6 +408,7 @@ mod tests { type AvailableBlockRatio = AvailableBlockRatio; type MaximumBlockLength = MaximumBlockLength; type Version = (); + type ModuleToIndex = (); } parameter_types! { @@ -565,7 +566,7 @@ mod tests { ); assert_eq!( Authorship::verify_and_import_uncles(vec![uncle_a.clone(), uncle_a.clone()]), - Err("uncle already included"), + Err("uncle already included".into()), ); } @@ -580,7 +581,7 @@ mod tests { assert_eq!( Authorship::verify_and_import_uncles(vec![uncle_a.clone()]), - Err("uncle already included"), + Err("uncle already included".into()), ); } @@ -590,7 +591,7 @@ mod tests { assert_eq!( Authorship::verify_and_import_uncles(vec![uncle_clone]), - Err("uncle already included"), + Err("uncle already included".into()), ); } @@ -599,7 +600,7 @@ mod tests { let unsealed = create_header(3, canon_chain.canon_hash(2), [2; 32].into()); assert_eq!( Authorship::verify_and_import_uncles(vec![unsealed]), - Err("no author"), + Err("no author".into()), ); } @@ -614,7 +615,7 @@ mod tests { assert_eq!( Authorship::verify_and_import_uncles(vec![gen_2]), - Err("uncle not recent enough to be included"), + Err("uncle not recent enough to be included".into()), ); } diff --git a/frame/babe/src/mock.rs b/frame/babe/src/mock.rs index a8acfee291..fb9804dfb7 100644 --- a/frame/babe/src/mock.rs +++ b/frame/babe/src/mock.rs @@ -65,6 +65,7 @@ impl frame_system::Trait for Test { type MaximumBlockWeight = MaximumBlockWeight; type AvailableBlockRatio = AvailableBlockRatio; type MaximumBlockLength = MaximumBlockLength; + type ModuleToIndex = (); } impl_opaque_keys! { diff --git a/frame/balances/src/lib.rs b/frame/balances/src/lib.rs index e0d54c6020..5367d7413b 100644 --- a/frame/balances/src/lib.rs +++ b/frame/balances/src/lib.rs @@ -170,10 +170,9 @@ use frame_support::{ Imbalance, SignedImbalance, ReservableCurrency, Get, VestingCurrency, }, weights::SimpleDispatchInfo, - dispatch::Result, }; use sp_runtime::{ - RuntimeDebug, + RuntimeDebug, DispatchResult, DispatchError, traits::{ Zero, SimpleArithmetic, StaticLookup, Member, CheckedAdd, CheckedSub, MaybeSerializeDeserialize, Saturating, Bounded, @@ -821,6 +820,7 @@ impl, I: Instance> frame_system::Trait for ElevatedTrait { type MaximumBlockLength = T::MaximumBlockLength; type AvailableBlockRatio = T::AvailableBlockRatio; type Version = T::Version; + type ModuleToIndex = T::ModuleToIndex; } impl, I: Instance> Trait for ElevatedTrait { type Balance = T::Balance; @@ -891,11 +891,11 @@ where _amount: T::Balance, reasons: WithdrawReasons, new_balance: T::Balance, - ) -> Result { + ) -> DispatchResult { if reasons.intersects(WithdrawReason::Reserve | WithdrawReason::Transfer) && Self::vesting_balance(who) > new_balance { - return Err("vesting balance too high to send value"); + Err("vesting balance too high to send value")? } let locks = Self::locks(who); if locks.is_empty() { @@ -912,7 +912,7 @@ where { Ok(()) } else { - Err("account liquidity restrictions prevent withdrawal") + Err("account liquidity restrictions prevent withdrawal".into()) } } @@ -921,22 +921,22 @@ where dest: &T::AccountId, value: Self::Balance, existence_requirement: ExistenceRequirement, - ) -> Result { + ) -> DispatchResult { let from_balance = Self::free_balance(transactor); let to_balance = Self::free_balance(dest); let would_create = to_balance.is_zero(); let fee = if would_create { T::CreationFee::get() } else { T::TransferFee::get() }; let liability = match value.checked_add(&fee) { Some(l) => l, - None => return Err("got overflow after adding a fee to value"), + None => Err("got overflow after adding a fee to value")?, }; let new_from_balance = match from_balance.checked_sub(&liability) { - None => return Err("balance too low to send value"), + None => Err("balance too low to send value")?, Some(b) => b, }; if would_create && value < T::ExistentialDeposit::get() { - return Err("value too low to create account"); + Err("value too low to create account")? } Self::ensure_can_withdraw(transactor, value, WithdrawReason::Transfer.into(), new_from_balance)?; @@ -944,13 +944,13 @@ where // but better to be safe than sorry. let new_to_balance = match to_balance.checked_add(&value) { Some(b) => b, - None => return Err("destination balance too high to receive value"), + None => Err("destination balance too high to receive value")?, }; if transactor != dest { if existence_requirement == ExistenceRequirement::KeepAlive { if new_from_balance < Self::minimum_balance() { - return Err("transfer would kill account"); + Err("transfer would kill account")? } } @@ -976,7 +976,7 @@ where value: Self::Balance, reasons: WithdrawReasons, liveness: ExistenceRequirement, - ) -> result::Result { + ) -> result::Result { let old_balance = Self::free_balance(who); if let Some(new_balance) = old_balance.checked_sub(&value) { // if we need to keep the account alive... @@ -986,13 +986,13 @@ where // ...yet is was alive before && old_balance >= T::ExistentialDeposit::get() { - return Err("payment would kill account") + Err("payment would kill account")? } Self::ensure_can_withdraw(who, value, reasons, new_balance)?; Self::set_free_balance(who, new_balance); Ok(NegativeImbalance::new(value)) } else { - Err("too few free funds in account") + Err("too few free funds in account")? } } @@ -1022,9 +1022,9 @@ where fn deposit_into_existing( who: &T::AccountId, value: Self::Balance - ) -> result::Result { + ) -> result::Result { if Self::total_balance(who).is_zero() { - return Err("beneficiary account must pre-exist"); + Err("beneficiary account must pre-exist")? } Self::set_free_balance(who, Self::free_balance(who) + value); Ok(PositiveImbalance::new(value)) @@ -1104,10 +1104,10 @@ where >::get(who) } - fn reserve(who: &T::AccountId, value: Self::Balance) -> result::Result<(), &'static str> { + fn reserve(who: &T::AccountId, value: Self::Balance) -> result::Result<(), DispatchError> { let b = Self::free_balance(who); if b < value { - return Err("not enough free funds") + Err("not enough free funds")? } let new_balance = b - value; Self::ensure_can_withdraw(who, value, WithdrawReason::Reserve.into(), new_balance)?; @@ -1139,9 +1139,9 @@ where slashed: &T::AccountId, beneficiary: &T::AccountId, value: Self::Balance, - ) -> result::Result { + ) -> result::Result { if Self::total_balance(beneficiary).is_zero() { - return Err("beneficiary account must pre-exist"); + Err("beneficiary account must pre-exist")? } let b = Self::reserved_balance(slashed); let slash = cmp::min(b, value); @@ -1250,9 +1250,9 @@ where locked: T::Balance, per_block: T::Balance, starting_block: T::BlockNumber - ) -> Result { + ) -> DispatchResult { if >::exists(who) { - return Err("A vesting schedule already exists for this account."); + Err("A vesting schedule already exists for this account.")? } let vesting_schedule = VestingSchedule { locked, diff --git a/frame/balances/src/mock.rs b/frame/balances/src/mock.rs index 2ae15d977a..c54165d6ec 100644 --- a/frame/balances/src/mock.rs +++ b/frame/balances/src/mock.rs @@ -76,6 +76,7 @@ impl frame_system::Trait for Runtime { type MaximumBlockLength = MaximumBlockLength; type AvailableBlockRatio = AvailableBlockRatio; type Version = (); + type ModuleToIndex = (); } parameter_types! { pub const TransactionBaseFee: u64 = 0; diff --git a/frame/balances/src/tests.rs b/frame/balances/src/tests.rs index a58426462d..fe0df11b3a 100644 --- a/frame/balances/src/tests.rs +++ b/frame/balances/src/tests.rs @@ -18,7 +18,7 @@ use super::*; use mock::{Balances, ExtBuilder, Runtime, System, info_from_weight, CALL}; -use sp_runtime::traits::SignedExtension; +use sp_runtime::traits::{SignedExtension, BadOrigin}; use frame_support::{ assert_noop, assert_ok, assert_err, traits::{LockableCurrency, LockIdentifier, WithdrawReason, WithdrawReasons, @@ -347,7 +347,7 @@ fn force_transfer_works() { let _ = Balances::deposit_creating(&1, 111); assert_noop!( Balances::force_transfer(Some(2).into(), 1, 2, 69), - "RequireRootOrigin", + BadOrigin, ); assert_ok!(Balances::force_transfer(RawOrigin::Root.into(), 1, 2, 69)); assert_eq!(Balances::total_balance(&1), 42); diff --git a/frame/collective/src/lib.rs b/frame/collective/src/lib.rs index 11134c87de..617fb32e4e 100644 --- a/frame/collective/src/lib.rs +++ b/frame/collective/src/lib.rs @@ -26,7 +26,7 @@ use sp_std::{prelude::*, result}; use sp_core::u32_trait::Value as U32; use sp_runtime::RuntimeDebug; -use sp_runtime::traits::{Hash, EnsureOrigin, ModuleDispatchError}; +use sp_runtime::traits::{Hash, EnsureOrigin}; use frame_support::weights::SimpleDispatchInfo; use frame_support::{ dispatch::{Dispatchable, Parameter}, codec::{Encode, Decode}, @@ -125,7 +125,7 @@ decl_event! { } decl_error! { - pub enum Error { + pub enum Error for Module, I: Instance> { /// Account is not a member NotMember, /// Duplicate proposals not allowed @@ -146,7 +146,7 @@ decl_error! { // operational class. decl_module! { pub struct Module, I: Instance=DefaultInstance> for enum Call where origin: ::Origin { - type Error = Error; + type Error = Error; fn deposit_event() = default; @@ -156,7 +156,7 @@ decl_module! { /// Requires root origin. #[weight = SimpleDispatchInfo::FixedOperational(100_000)] fn set_members(origin, new_members: Vec) { - ensure_root(origin).map_err(|e| e.as_str())?; + ensure_root(origin)?; let mut new_members = new_members; new_members.sort(); >::mutate(|m| { @@ -170,8 +170,8 @@ decl_module! { /// Origin must be a member of the collective. #[weight = SimpleDispatchInfo::FixedOperational(100_000)] fn execute(origin, proposal: Box<>::Proposal>) { - let who = ensure_signed(origin).map_err(|e| e.as_str())?; - ensure!(Self::is_member(&who), Error::NotMember); + let who = ensure_signed(origin)?; + ensure!(Self::is_member(&who), Error::::NotMember); let proposal_hash = T::Hashing::hash_of(&proposal); let ok = proposal.dispatch(RawOrigin::Member(who).into()).is_ok(); @@ -184,12 +184,12 @@ decl_module! { /// # #[weight = SimpleDispatchInfo::FixedOperational(5_000_000)] fn propose(origin, #[compact] threshold: MemberCount, proposal: Box<>::Proposal>) { - let who = ensure_signed(origin).map_err(|e| e.as_str())?; - ensure!(Self::is_member(&who), Error::NotMember); + let who = ensure_signed(origin)?; + ensure!(Self::is_member(&who), Error::::NotMember); let proposal_hash = T::Hashing::hash_of(&proposal); - ensure!(!>::exists(proposal_hash), Error::DuplicateProposal); + ensure!(!>::exists(proposal_hash), Error::::DuplicateProposal); if threshold < 2 { let seats = Self::members().len() as MemberCount; @@ -213,11 +213,11 @@ decl_module! { /// # #[weight = SimpleDispatchInfo::FixedOperational(200_000)] fn vote(origin, proposal: T::Hash, #[compact] index: ProposalIndex, approve: bool) { - let who = ensure_signed(origin).map_err(|e| e.as_str())?; - ensure!(Self::is_member(&who), Error::NotMember); + let who = ensure_signed(origin)?; + ensure!(Self::is_member(&who), Error::::NotMember); - let mut voting = Self::voting(&proposal).ok_or(Error::ProposalMissing)?; - ensure!(voting.index == index, Error::WrongIndex); + let mut voting = Self::voting(&proposal).ok_or(Error::::ProposalMissing)?; + ensure!(voting.index == index, Error::::WrongIndex); let position_yes = voting.ayes.iter().position(|a| a == &who); let position_no = voting.nays.iter().position(|a| a == &who); @@ -226,7 +226,7 @@ decl_module! { if position_yes.is_none() { voting.ayes.push(who.clone()); } else { - return Err(Error::DuplicateVote) + Err(Error::::DuplicateVote)? } if let Some(pos) = position_no { voting.nays.swap_remove(pos); @@ -235,7 +235,7 @@ decl_module! { if position_no.is_none() { voting.nays.push(who.clone()); } else { - return Err(Error::DuplicateVote) + Err(Error::::DuplicateVote)? } if let Some(pos) = position_yes { voting.ayes.swap_remove(pos); @@ -430,6 +430,7 @@ mod tests { type MaximumBlockLength = MaximumBlockLength; type AvailableBlockRatio = AvailableBlockRatio; type Version = (); + type ModuleToIndex = (); } impl Trait for Test { type Origin = Origin; @@ -584,7 +585,7 @@ mod tests { let proposal = make_proposal(42); assert_noop!( Collective::propose(Origin::signed(42), 3, Box::new(proposal.clone())), - Error::NotMember + Error::::NotMember ); }); } @@ -598,7 +599,7 @@ mod tests { assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()))); assert_noop!( Collective::vote(Origin::signed(42), hash.clone(), 0, true), - Error::NotMember, + Error::::NotMember, ); }); } @@ -612,7 +613,7 @@ mod tests { assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()))); assert_noop!( Collective::vote(Origin::signed(2), hash.clone(), 1, true), - Error::WrongIndex, + Error::::WrongIndex, ); }); } @@ -630,7 +631,7 @@ mod tests { ); assert_noop!( Collective::vote(Origin::signed(1), hash.clone(), 0, true), - Error::DuplicateVote, + Error::::DuplicateVote, ); assert_ok!(Collective::vote(Origin::signed(1), hash.clone(), 0, false)); assert_eq!( @@ -639,7 +640,7 @@ mod tests { ); assert_noop!( Collective::vote(Origin::signed(1), hash.clone(), 0, false), - Error::DuplicateVote, + Error::::DuplicateVote, ); assert_eq!(System::events(), vec![ diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index c2a20ec4a1..261e4297b7 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -23,7 +23,7 @@ use crate::rent; use sp_std::prelude::*; use sp_runtime::traits::{Bounded, CheckedAdd, CheckedSub, Zero}; use frame_support::{ - storage::unhashed, + storage::unhashed, dispatch::DispatchError, traits::{WithdrawReason, Currency, Time, Randomness}, }; @@ -66,7 +66,7 @@ impl ExecReturnValue { /// non-existent destination contract, etc.). #[cfg_attr(test, derive(sp_runtime::RuntimeDebug))] pub struct ExecError { - pub reason: &'static str, + pub reason: DispatchError, /// This is an allocated buffer that may be reused. The buffer must be cleared explicitly /// before reuse. pub buffer: Vec, @@ -83,7 +83,9 @@ macro_rules! try_or_exec_error { ($e:expr, $buffer:expr) => { match $e { Ok(val) => val, - Err(reason) => return Err($crate::exec::ExecError { reason, buffer: $buffer }), + Err(reason) => return Err( + $crate::exec::ExecError { reason: reason.into(), buffer: $buffer } + ), } } } @@ -336,7 +338,7 @@ where ) -> ExecResult { if self.depth == self.config.max_depth as usize { return Err(ExecError { - reason: "reached maximum depth, cannot make a call", + reason: "reached maximum depth, cannot make a call".into(), buffer: input_data, }); } @@ -346,7 +348,7 @@ where .is_out_of_gas() { return Err(ExecError { - reason: "not enough gas to pay base call fee", + reason: "not enough gas to pay base call fee".into(), buffer: input_data, }); } @@ -359,7 +361,7 @@ where // Calls to dead contracts always fail. if let Some(ContractInfo::Tombstone(_)) = contract_info { return Err(ExecError { - reason: "contract has been evicted", + reason: "contract has been evicted".into(), buffer: input_data, }); }; @@ -404,7 +406,7 @@ where .expect("a nested execution context must have a parent; qed"); if parent.is_live(&dest) { return Err(ExecError { - reason: "contract cannot be destroyed during recursive execution", + reason: "contract cannot be destroyed during recursive execution".into(), buffer: output.data, }); } @@ -428,7 +430,7 @@ where ) -> Result<(T::AccountId, ExecReturnValue), ExecError> { if self.depth == self.config.max_depth as usize { return Err(ExecError { - reason: "reached maximum depth, cannot instantiate", + reason: "reached maximum depth, cannot instantiate".into(), buffer: input_data, }); } @@ -438,7 +440,7 @@ where .is_out_of_gas() { return Err(ExecError { - reason: "not enough gas to pay base instantiate fee", + reason: "not enough gas to pay base instantiate fee".into(), buffer: input_data, }); } @@ -488,7 +490,7 @@ where // Error out if insufficient remaining balance. if nested.overlay.get_balance(&dest) < nested.config.existential_deposit { return Err(ExecError { - reason: "insufficient remaining balance", + reason: "insufficient remaining balance".into(), buffer: output.data, }); } @@ -603,7 +605,7 @@ fn transfer<'a, T: Trait, V: Vm, L: Loader>( dest: &T::AccountId, value: BalanceOf, ctx: &mut ExecutionContext<'a, T, V, L>, -) -> Result<(), &'static str> { +) -> Result<(), DispatchError> { use self::TransferCause::*; use self::TransferFeeKind::*; @@ -637,23 +639,28 @@ fn transfer<'a, T: Trait, V: Vm, L: Loader>( }; if gas_meter.charge(ctx.config, token).is_out_of_gas() { - return Err("not enough gas to pay transfer fee"); + Err("not enough gas to pay transfer fee")? } // We allow balance to go below the existential deposit here: let from_balance = ctx.overlay.get_balance(transactor); let new_from_balance = match from_balance.checked_sub(&value) { Some(b) => b, - None => return Err("balance too low to send value"), + None => Err("balance too low to send value")?, }; if would_create && value < ctx.config.existential_deposit { - return Err("value too low to create account"); + Err("value too low to create account")? } - T::Currency::ensure_can_withdraw(transactor, value, WithdrawReason::Transfer.into(), new_from_balance)?; + T::Currency::ensure_can_withdraw( + transactor, + value, + WithdrawReason::Transfer.into(), + new_from_balance, + )?; let new_to_balance = match to_balance.checked_add(&value) { Some(b) => b, - None => return Err("destination balance too high to receive value"), + None => Err("destination balance too high to receive value")?, }; if transactor != dest { @@ -821,6 +828,7 @@ mod tests { }; use std::{cell::RefCell, rc::Rc, collections::HashMap, marker::PhantomData}; use assert_matches::assert_matches; + use sp_runtime::DispatchError; const ALICE: u64 = 1; const BOB: u64 = 2; @@ -1176,7 +1184,10 @@ mod tests { assert_matches!( result, - Err(ExecError { reason: "balance too low to send value", buffer: _ }) + Err(ExecError { + reason: DispatchError::Other("balance too low to send value"), + buffer: _, + }) ); assert_eq!(ctx.overlay.get_balance(&origin), 0); assert_eq!(ctx.overlay.get_balance(&dest), 0); @@ -1313,7 +1324,10 @@ mod tests { // Verify that we've got proper error and set `reached_bottom`. assert_matches!( r, - Err(ExecError { reason: "reached maximum depth, cannot make a call", buffer: _ }) + Err(ExecError { + reason: DispatchError::Other("reached maximum depth, cannot make a call"), + buffer: _, + }) ); *reached_bottom = true; } else { @@ -1583,7 +1597,7 @@ mod tests { let mut loader = MockLoader::empty(); let dummy_ch = loader.insert( - |_| Err(ExecError { reason: "It's a trap!", buffer: Vec::new() }) + |_| Err(ExecError { reason: "It's a trap!".into(), buffer: Vec::new() }) ); let instantiator_ch = loader.insert({ let dummy_ch = dummy_ch.clone(); @@ -1596,7 +1610,7 @@ mod tests { ctx.gas_meter, vec![] ), - Err(ExecError { reason: "It's a trap!", buffer: _ }) + Err(ExecError { reason: DispatchError::Other("It's a trap!"), buffer: _ }) ); exec_success() diff --git a/frame/contracts/src/gas.rs b/frame/contracts/src/gas.rs index f914aaad1b..af9236e2e5 100644 --- a/frame/contracts/src/gas.rs +++ b/frame/contracts/src/gas.rs @@ -21,6 +21,7 @@ use sp_runtime::traits::{ }; use frame_support::{ traits::{Currency, ExistenceRequirement, Imbalance, OnUnbalanced, WithdrawReason}, StorageValue, + dispatch::DispatchError, }; #[cfg(test)] @@ -201,7 +202,7 @@ impl GasMeter { pub fn buy_gas( transactor: &T::AccountId, gas_limit: Gas, -) -> Result<(GasMeter, NegativeImbalanceOf), &'static str> { +) -> Result<(GasMeter, NegativeImbalanceOf), DispatchError> { // Buy the specified amount of gas. let gas_price = >::gas_price(); let cost = if gas_price.is_zero() { diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index 83f11b1d9f..d1bea0ca98 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -119,7 +119,7 @@ use sp_runtime::{ }, RuntimeDebug, }; -use frame_support::dispatch::{Result, Dispatchable}; +use frame_support::dispatch::{DispatchResult, Dispatchable}; use frame_support::{ Parameter, decl_module, decl_event, decl_storage, storage::child, parameter_types, IsSubType, @@ -539,10 +539,10 @@ decl_module! { /// Updates the schedule for metering contracts. /// /// The schedule must have a greater version than the stored schedule. - pub fn update_schedule(origin, schedule: Schedule) -> Result { + pub fn update_schedule(origin, schedule: Schedule) -> DispatchResult { ensure_root(origin)?; if >::current_schedule().version >= schedule.version { - return Err("new schedule must have a greater version than current"); + Err("new schedule must have a greater version than current")? } Self::deposit_event(RawEvent::ScheduleUpdated(schedule.version)); @@ -557,7 +557,7 @@ decl_module! { origin, #[compact] gas_limit: Gas, code: Vec - ) -> Result { + ) -> DispatchResult { let origin = ensure_signed(origin)?; let (mut gas_meter, imbalance) = gas::buy_gas::(&origin, gas_limit)?; @@ -570,7 +570,7 @@ decl_module! { gas::refund_unused_gas::(&origin, gas_meter, imbalance); - result.map(|_| ()) + result.map(|_| ()).map_err(Into::into) } /// Makes a call to an account, optionally transferring some balance. @@ -586,13 +586,13 @@ decl_module! { #[compact] value: BalanceOf, #[compact] gas_limit: Gas, data: Vec - ) -> Result { + ) -> DispatchResult { let origin = ensure_signed(origin)?; let dest = T::Lookup::lookup(dest)?; Self::bare_call(origin, dest, value, gas_limit, data) .map(|_| ()) - .map_err(|e| e.reason) + .map_err(|e| e.reason.into()) } /// Instantiates a new contract from the `codehash` generated by `put_code`, optionally transferring some balance. @@ -611,7 +611,7 @@ decl_module! { #[compact] gas_limit: Gas, code_hash: CodeHash, data: Vec - ) -> Result { + ) -> DispatchResult { let origin = ensure_signed(origin)?; Self::execute_wasm(origin, gas_limit, |ctx, gas_meter| { @@ -619,7 +619,7 @@ decl_module! { .map(|(_address, output)| output) }) .map(|_| ()) - .map_err(|e| e.reason) + .map_err(|e| e.reason.into()) } /// Allows block producers to claim a small reward for evicting a contract. If a block producer @@ -636,10 +636,10 @@ decl_module! { (Ok(frame_system::RawOrigin::None), Some(aux_sender)) => { (false, aux_sender) }, - _ => return Err( + _ => Err( "Invalid surcharge claim: origin must be signed or \ inherent and auxiliary sender only provided on inherent" - ), + )?, }; // Add some advantage for block producers (who send unsigned extrinsics) by @@ -783,7 +783,7 @@ impl Module { code_hash: CodeHash, rent_allowance: BalanceOf, delta: Vec - ) -> Result { + ) -> DispatchResult { let mut origin_contract = >::get(&origin) .and_then(|c| c.get_alive()) .ok_or("Cannot restore from inexisting or tombstone contract")?; @@ -791,7 +791,7 @@ impl Module { let current_block = >::block_number(); if origin_contract.last_write == Some(current_block) { - return Err("Origin TrieId written in the current block"); + Err("Origin TrieId written in the current block")? } let dest_tombstone = >::get(&dest) @@ -816,7 +816,7 @@ impl Module { origin_contract.child_trie_unique_id(), &blake2_256(key), ); - + (key, value) }) }) @@ -841,7 +841,7 @@ impl Module { ); } - return Err("Tombstones don't match"); + return Err("Tombstones don't match".into()); } origin_contract.storage_size -= key_values_taken.iter() diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 160b1d74dc..7cf86b31c7 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -117,6 +117,7 @@ impl frame_system::Trait for Test { type AvailableBlockRatio = AvailableBlockRatio; type MaximumBlockLength = MaximumBlockLength; type Version = (); + type ModuleToIndex = (); } impl pallet_balances::Trait for Test { type Balance = u64; diff --git a/frame/contracts/src/wasm/mod.rs b/frame/contracts/src/wasm/mod.rs index 472951efb5..28b05fcd1a 100644 --- a/frame/contracts/src/wasm/mod.rs +++ b/frame/contracts/src/wasm/mod.rs @@ -161,6 +161,7 @@ mod tests { use wabt; use hex_literal::hex; use assert_matches::assert_matches; + use sp_runtime::DispatchError; #[derive(Debug, PartialEq, Eq)] struct DispatchEntry(Call); @@ -1429,7 +1430,7 @@ mod tests { MockExt::default(), &mut gas_meter ), - Err(ExecError { reason: "during execution", buffer: _ }) + Err(ExecError { reason: DispatchError::Other("during execution"), buffer: _ }) ); } @@ -1471,7 +1472,7 @@ mod tests { MockExt::default(), &mut gas_meter ), - Err(ExecError { reason: "during execution", buffer: _ }) + Err(ExecError { reason: DispatchError::Other("during execution"), buffer: _ }) ); } diff --git a/frame/contracts/src/wasm/runtime.rs b/frame/contracts/src/wasm/runtime.rs index 98675aa0e4..cbf666dde2 100644 --- a/frame/contracts/src/wasm/runtime.rs +++ b/frame/contracts/src/wasm/runtime.rs @@ -98,7 +98,7 @@ pub(crate) fn to_execution_result( // validated by the code preparation process. However, because panics are really // undesirable in the runtime code, we treat this as a trap for now. Eventually, we might // want to revisit this. - Ok(_) => Err(ExecError { reason: "return type error", buffer: runtime.scratch_buf }), + Ok(_) => Err(ExecError { reason: "return type error".into(), buffer: runtime.scratch_buf }), // `Error::Module` is returned only if instantiation or linking failed (i.e. // wasm binary tried to import a function that is not provided by the host). // This shouldn't happen because validation process ought to reject such binaries. @@ -106,10 +106,10 @@ pub(crate) fn to_execution_result( // Because panics are really undesirable in the runtime code, we treat this as // a trap for now. Eventually, we might want to revisit this. Err(sp_sandbox::Error::Module) => - Err(ExecError { reason: "validation error", buffer: runtime.scratch_buf }), + Err(ExecError { reason: "validation error".into(), buffer: runtime.scratch_buf }), // Any other kind of a trap should result in a failure. Err(sp_sandbox::Error::Execution) | Err(sp_sandbox::Error::OutOfBounds) => - Err(ExecError { reason: "during execution", buffer: runtime.scratch_buf }), + Err(ExecError { reason: "during execution".into(), buffer: runtime.scratch_buf }), } } diff --git a/frame/democracy/src/lib.rs b/frame/democracy/src/lib.rs index eb9cf819c5..3bbe011497 100644 --- a/frame/democracy/src/lib.rs +++ b/frame/democracy/src/lib.rs @@ -21,16 +21,12 @@ use sp_std::prelude::*; use sp_std::{result, convert::TryFrom}; use sp_runtime::{ - RuntimeDebug, - traits::{ - Zero, Bounded, CheckedMul, CheckedDiv, EnsureOrigin, Hash, - Dispatchable, Saturating, ModuleDispatchError, - }, + RuntimeDebug, DispatchResult, + traits::{Zero, Bounded, CheckedMul, CheckedDiv, EnsureOrigin, Hash, Dispatchable, Saturating}, }; use codec::{Ref, Encode, Decode, Input, Output}; use frame_support::{ - decl_module, decl_storage, decl_event, decl_error, ensure, - Parameter, + decl_module, decl_storage, decl_event, decl_error, ensure, Parameter, weights::SimpleDispatchInfo, traits::{ Currency, ReservableCurrency, LockableCurrency, WithdrawReason, LockIdentifier, Get, @@ -365,7 +361,7 @@ decl_event! { } decl_error! { - pub enum Error { + pub enum Error for Module { /// Value too low ValueLow, /// Proposal does not exist @@ -415,7 +411,7 @@ decl_error! { decl_module! { pub struct Module for enum Call where origin: T::Origin { - type Error = Error; + type Error = Error; /// The minimum period of locking and the period between a proposal being approved and enacted. /// /// It should generally be a little more than the unstake period to ensure that @@ -454,8 +450,8 @@ decl_module! { proposal_hash: T::Hash, #[compact] value: BalanceOf ) { - let who = ensure_signed(origin).map_err(|e| e.as_str())?; - ensure!(value >= T::MinimumDeposit::get(), Error::ValueLow); + let who = ensure_signed(origin)?; + ensure!(value >= T::MinimumDeposit::get(), Error::::ValueLow); T::Currency::reserve(&who, value)?; let index = Self::public_prop_count(); @@ -476,9 +472,9 @@ decl_module! { /// # #[weight = SimpleDispatchInfo::FixedNormal(5_000_000)] fn second(origin, #[compact] proposal: PropIndex) { - let who = ensure_signed(origin).map_err(|e| e.as_str())?; + let who = ensure_signed(origin)?; let mut deposit = Self::deposit_of(proposal) - .ok_or(Error::ProposalMissing)?; + .ok_or(Error::::ProposalMissing)?; T::Currency::reserve(&who, deposit.0)?; deposit.1.push(who); >::insert(proposal, deposit); @@ -495,8 +491,8 @@ decl_module! { fn vote(origin, #[compact] ref_index: ReferendumIndex, vote: Vote - ) -> Result<(), Error> { - let who = ensure_signed(origin).map_err(|e| e.as_str())?; + ) -> DispatchResult { + let who = ensure_signed(origin)?; Self::do_vote(who, ref_index, vote) } @@ -511,10 +507,8 @@ decl_module! { fn proxy_vote(origin, #[compact] ref_index: ReferendumIndex, vote: Vote - ) -> Result<(), Error> { - let who = Self::proxy( - ensure_signed(origin).map_err(|e| e.as_str())? - ).ok_or(Error::NotProxy)?; + ) -> DispatchResult { + let who = Self::proxy(ensure_signed(origin)?).ok_or(Error::::NotProxy)?; Self::do_vote(who, ref_index, vote) } @@ -522,11 +516,11 @@ decl_module! { /// referendum. #[weight = SimpleDispatchInfo::FixedOperational(500_000)] fn emergency_cancel(origin, ref_index: ReferendumIndex) { - T::CancellationOrigin::ensure_origin(origin).map_err(|e| Into::<&str>::into(e))?; + T::CancellationOrigin::ensure_origin(origin)?; - let info = Self::referendum_info(ref_index).ok_or(Error::BadIndex)?; + let info = Self::referendum_info(ref_index).ok_or(Error::::BadIndex)?; let h = info.proposal_hash; - ensure!(!>::exists(h), Error::AlreadyCanceled); + ensure!(!>::exists(h), Error::::AlreadyCanceled); >::insert(h, true); Self::clear_referendum(ref_index); @@ -536,10 +530,13 @@ decl_module! { /// referendum. #[weight = SimpleDispatchInfo::FixedNormal(5_000_000)] fn external_propose(origin, proposal_hash: T::Hash) { - T::ExternalOrigin::ensure_origin(origin).map_err(|e| Into::<&str>::into(e))?; - ensure!(!>::exists(), Error::DuplicateProposal); + T::ExternalOrigin::ensure_origin(origin)?; + ensure!(!>::exists(), Error::::DuplicateProposal); if let Some((until, _)) = >::get(proposal_hash) { - ensure!(>::block_number() >= until, Error::ProposalBlacklisted); + ensure!( + >::block_number() >= until, + Error::::ProposalBlacklisted, + ); } >::put((proposal_hash, VoteThreshold::SuperMajorityApprove)); } @@ -551,7 +548,7 @@ decl_module! { /// pre-scheduled `external_propose` call. #[weight = SimpleDispatchInfo::FixedNormal(5_000_000)] fn external_propose_majority(origin, proposal_hash: T::Hash) { - T::ExternalMajorityOrigin::ensure_origin(origin).map_err(|e| Into::<&str>::into(e))?; + T::ExternalMajorityOrigin::ensure_origin(origin)?; >::put((proposal_hash, VoteThreshold::SimpleMajority)); } @@ -562,7 +559,7 @@ decl_module! { /// pre-scheduled `external_propose` call. #[weight = SimpleDispatchInfo::FixedNormal(5_000_000)] fn external_propose_default(origin, proposal_hash: T::Hash) { - T::ExternalDefaultOrigin::ensure_origin(origin).map_err(|e| Into::<&str>::into(e))?; + T::ExternalDefaultOrigin::ensure_origin(origin)?; >::put((proposal_hash, VoteThreshold::SuperMajorityAgainst)); } @@ -581,13 +578,13 @@ decl_module! { voting_period: T::BlockNumber, delay: T::BlockNumber ) { - T::FastTrackOrigin::ensure_origin(origin).map_err(|e| Into::<&str>::into(e))?; - let (e_proposal_hash, threshold) = >::get().ok_or(Error::ProposalMissing)?; + T::FastTrackOrigin::ensure_origin(origin)?; + let (e_proposal_hash, threshold) = >::get().ok_or(Error::::ProposalMissing)?; ensure!( threshold != VoteThreshold::SuperMajorityApprove, - Error::NotSimpleMajority + Error::::NotSimpleMajority, ); - ensure!(proposal_hash == e_proposal_hash, Error::InvalidHash); + ensure!(proposal_hash == e_proposal_hash, Error::::InvalidHash); >::kill(); let now = >::block_number(); @@ -599,19 +596,19 @@ decl_module! { /// Veto and blacklist the external proposal hash. #[weight = SimpleDispatchInfo::FixedNormal(200_000)] fn veto_external(origin, proposal_hash: T::Hash) { - let who = T::VetoOrigin::ensure_origin(origin).map_err(|e| Into::<&str>::into(e))?; + let who = T::VetoOrigin::ensure_origin(origin)?; if let Some((e_proposal_hash, _)) = >::get() { - ensure!(proposal_hash == e_proposal_hash, Error::ProposalMissing); + ensure!(proposal_hash == e_proposal_hash, Error::::ProposalMissing); } else { - Err(Error::NoProposal)?; + Err(Error::::NoProposal)?; } let mut existing_vetoers = >::get(&proposal_hash) .map(|pair| pair.1) .unwrap_or_else(Vec::new); let insert_position = existing_vetoers.binary_search(&who) - .err().ok_or(Error::AlreadyVetoed)?; + .err().ok_or(Error::::AlreadyVetoed)?; existing_vetoers.insert(insert_position, who.clone()); let until = >::block_number() + T::CooloffPeriod::get(); @@ -624,24 +621,24 @@ decl_module! { /// Remove a referendum. #[weight = SimpleDispatchInfo::FixedOperational(10_000)] fn cancel_referendum(origin, #[compact] ref_index: ReferendumIndex) { - ensure_root(origin).map_err(|e| e.as_str())?; + ensure_root(origin)?; Self::clear_referendum(ref_index); } /// Cancel a proposal queued for enactment. #[weight = SimpleDispatchInfo::FixedOperational(10_000)] fn cancel_queued(origin, which: ReferendumIndex) { - ensure_root(origin).map_err(|e| e.as_str())?; + ensure_root(origin)?; let mut items = >::get(); let original_len = items.len(); items.retain(|i| i.2 != which); - ensure!(items.len() < original_len, Error::ProposalMissing); + ensure!(items.len() < original_len, Error::::ProposalMissing); >::put(items); } fn on_initialize(n: T::BlockNumber) { if let Err(e) = Self::begin_block(n) { - sp_runtime::print(e.as_str()); + sp_runtime::print(e); } } @@ -652,8 +649,8 @@ decl_module! { /// # #[weight = SimpleDispatchInfo::FixedNormal(100_000)] fn set_proxy(origin, proxy: T::AccountId) { - let who = ensure_signed(origin).map_err(|e| e.as_str())?; - ensure!(!>::exists(&proxy), Error::AlreadyProxy); + let who = ensure_signed(origin)?; + ensure!(!>::exists(&proxy), Error::::AlreadyProxy); >::insert(proxy, who) } @@ -664,7 +661,7 @@ decl_module! { /// # #[weight = SimpleDispatchInfo::FixedNormal(100_000)] fn resign_proxy(origin) { - let who = ensure_signed(origin).map_err(|e| e.as_str())?; + let who = ensure_signed(origin)?; >::remove(who); } @@ -675,8 +672,11 @@ decl_module! { /// # #[weight = SimpleDispatchInfo::FixedNormal(100_000)] fn remove_proxy(origin, proxy: T::AccountId) { - let who = ensure_signed(origin).map_err(|e| e.as_str())?; - ensure!(&Self::proxy(&proxy).ok_or(Error::NotProxy)? == &who, Error::WrongProxy); + let who = ensure_signed(origin)?; + ensure!( + &Self::proxy(&proxy).ok_or(Error::::NotProxy)? == &who, + Error::::WrongProxy, + ); >::remove(proxy); } @@ -687,7 +687,7 @@ decl_module! { /// # #[weight = SimpleDispatchInfo::FixedNormal(500_000)] pub fn delegate(origin, to: T::AccountId, conviction: Conviction) { - let who = ensure_signed(origin).map_err(|e| e.as_str())?; + let who = ensure_signed(origin)?; >::insert(&who, (&to, conviction)); // Currency is locked indefinitely as long as it's delegated. T::Currency::extend_lock( @@ -707,8 +707,8 @@ decl_module! { /// # #[weight = SimpleDispatchInfo::FixedNormal(500_000)] fn undelegate(origin) { - let who = ensure_signed(origin).map_err(|e| e.as_str())?; - ensure!(>::exists(&who), Error::NotDelegated); + let who = ensure_signed(origin)?; + ensure!(>::exists(&who), Error::::NotDelegated); let (_, conviction) = >::take(&who); // Indefinite lock is reduced to the maximum voting lock that could be possible. let now = >::block_number(); @@ -726,7 +726,7 @@ decl_module! { /// Veto and blacklist the proposal hash. Must be from Root origin. #[weight = SimpleDispatchInfo::FixedNormal(10_000)] fn clear_public_proposals(origin) { - ensure_root(origin).map_err(|e| e.as_str())?; + ensure_root(origin)?; >::kill(); } @@ -735,9 +735,9 @@ decl_module! { /// in the dispatch queue but does require a deposit, returned once enacted. #[weight = SimpleDispatchInfo::FixedNormal(100_000)] fn note_preimage(origin, encoded_proposal: Vec) { - let who = ensure_signed(origin).map_err(|e| e.as_str())?; + let who = ensure_signed(origin)?; let proposal_hash = T::Hashing::hash(&encoded_proposal[..]); - ensure!(!>::exists(&proposal_hash), Error::DuplicatePreimage); + ensure!(!>::exists(&proposal_hash), Error::::DuplicatePreimage); let deposit = >::from(encoded_proposal.len() as u32) .saturating_mul(T::PreimageByteDeposit::get()); @@ -753,11 +753,11 @@ decl_module! { /// in the dispatch queue. No deposit is needed. #[weight = SimpleDispatchInfo::FixedNormal(100_000)] fn note_imminent_preimage(origin, encoded_proposal: Vec) { - let who = ensure_signed(origin).map_err(|e| e.as_str())?; + let who = ensure_signed(origin)?; let proposal_hash = T::Hashing::hash(&encoded_proposal[..]); - ensure!(!>::exists(&proposal_hash), Error::DuplicatePreimage); + ensure!(!>::exists(&proposal_hash), Error::::DuplicatePreimage); let queue = >::get(); - ensure!(queue.iter().any(|item| &item.1 == &proposal_hash), Error::NotImminent); + ensure!(queue.iter().any(|item| &item.1 == &proposal_hash), Error::::NotImminent); let now = >::block_number(); let free = >::zero(); @@ -773,16 +773,17 @@ decl_module! { /// work an additional `EnactmentPeriod` later. #[weight = SimpleDispatchInfo::FixedNormal(10_000)] fn reap_preimage(origin, proposal_hash: T::Hash) { - let who = ensure_signed(origin).map_err(|e| e.as_str())?; + let who = ensure_signed(origin)?; - let (_, old, deposit, then) = >::get(&proposal_hash).ok_or(Error::PreimageMissing)?; + let (_, old, deposit, then) = >::get(&proposal_hash) + .ok_or(Error::::PreimageMissing)?; let now = >::block_number(); let (voting, enactment) = (T::VotingPeriod::get(), T::EnactmentPeriod::get()); let additional = if who == old { Zero::zero() } else { enactment }; - ensure!(now >= then + voting + additional, Error::Early); + ensure!(now >= then + voting + additional, Error::::Early); let queue = >::get(); - ensure!(!queue.iter().any(|item| &item.1 == &proposal_hash), Error::Imminent); + ensure!(!queue.iter().any(|item| &item.1 == &proposal_hash), Error::::Imminent); let _ = T::Currency::repatriate_reserved(&old, &who, deposit); >::remove(&proposal_hash); @@ -931,8 +932,8 @@ impl Module { // private. /// Actually enact a vote, if legit. - fn do_vote(who: T::AccountId, ref_index: ReferendumIndex, vote: Vote) -> Result<(), Error> { - ensure!(Self::is_active_referendum(ref_index), Error::ReferendumInvalid); + fn do_vote(who: T::AccountId, ref_index: ReferendumIndex, vote: Vote) -> DispatchResult { + ensure!(Self::is_active_referendum(ref_index), Error::::ReferendumInvalid); if !>::exists((ref_index, &who)) { >::append_or_insert(ref_index, &[&who][..]); } @@ -959,6 +960,7 @@ impl Module { fn clear_referendum(ref_index: ReferendumIndex) { >::remove(ref_index); + LowestUnbaked::mutate(|i| if *i == ref_index { *i += 1; let end = ReferendumCount::get(); @@ -973,7 +975,7 @@ impl Module { } /// Enact a proposal from a referendum. - fn enact_proposal(proposal_hash: T::Hash, index: ReferendumIndex) -> Result<(), Error> { + fn enact_proposal(proposal_hash: T::Hash, index: ReferendumIndex) -> DispatchResult { if let Some((encoded_proposal, who, amount, _)) = >::take(&proposal_hash) { if let Ok(proposal) = T::Proposal::decode(&mut &encoded_proposal[..]) { let _ = T::Currency::unreserve(&who, amount); @@ -986,25 +988,25 @@ impl Module { } else { T::Slash::on_unbalanced(T::Currency::slash_reserved(&who, amount).0); Self::deposit_event(RawEvent::PreimageInvalid(proposal_hash, index)); - Err(Error::PreimageInvalid) + Err(Error::::PreimageInvalid.into()) } } else { Self::deposit_event(RawEvent::PreimageMissing(proposal_hash, index)); - Err(Error::PreimageMissing) + Err(Error::::PreimageMissing.into()) } } /// Table the next waiting proposal for a vote. - fn launch_next(now: T::BlockNumber) -> Result<(), Error> { + fn launch_next(now: T::BlockNumber) -> DispatchResult { if LastTabledWasExternal::take() { Self::launch_public(now).or_else(|_| Self::launch_external(now)) } else { Self::launch_external(now).or_else(|_| Self::launch_public(now)) - }.map_err(|_| Error::NoneWaiting) + }.map_err(|_| Error::::NoneWaiting.into()) } /// Table the waiting external proposal for a vote, if there is one. - fn launch_external(now: T::BlockNumber) -> Result<(), Error> { + fn launch_external(now: T::BlockNumber) -> DispatchResult { if let Some((proposal, threshold)) = >::take() { LastTabledWasExternal::put(true); Self::deposit_event(RawEvent::ExternalTabled); @@ -1016,12 +1018,12 @@ impl Module { ); Ok(()) } else { - Err(Error::NoneWaiting) + Err(Error::::NoneWaiting)? } } /// Table the waiting public proposal with the highest backing for a vote. - fn launch_public(now: T::BlockNumber) -> Result<(), Error> { + fn launch_public(now: T::BlockNumber) -> DispatchResult { let mut public_props = Self::public_props(); if let Some((winner_index, _)) = public_props.iter() .enumerate() @@ -1046,7 +1048,7 @@ impl Module { } Ok(()) } else { - Err(Error::NoneWaiting) + Err(Error::::NoneWaiting)? } } @@ -1055,7 +1057,7 @@ impl Module { now: T::BlockNumber, index: ReferendumIndex, info: ReferendumInfo - ) -> Result<(), Error> { + ) -> DispatchResult { let (approve, against, capital) = Self::tally(index); let total_issuance = T::Currency::total_issuance(); let approved = info.threshold.approved(approve, against, capital, total_issuance); @@ -1103,7 +1105,7 @@ impl Module { } /// Current era is ending; we should finish up any proposals. - fn begin_block(now: T::BlockNumber) -> Result<(), Error> { + fn begin_block(now: T::BlockNumber) -> DispatchResult { // pick out another public referendum if it's time. if (now % T::LaunchPeriod::get()).is_zero() { // Errors come from the queue being empty. we don't really care about that, and even if @@ -1146,7 +1148,10 @@ mod tests { weights::Weight, }; use sp_core::H256; - use sp_runtime::{traits::{BlakeTwo256, IdentityLookup, Bounded}, testing::Header, Perbill}; + use sp_runtime::{ + traits::{BlakeTwo256, IdentityLookup, Bounded, BadOrigin}, + testing::Header, Perbill, + }; use pallet_balances::BalanceLock; use frame_system::EnsureSignedBy; @@ -1191,6 +1196,7 @@ mod tests { type MaximumBlockLength = MaximumBlockLength; type AvailableBlockRatio = AvailableBlockRatio; type Version = (); + type ModuleToIndex = (); } parameter_types! { pub const ExistentialDeposit: u64 = 0; @@ -1289,13 +1295,14 @@ mod tests { let p = set_balance_proposal(value); let h = BlakeTwo256::hash(&p[..]); match Democracy::note_preimage(Origin::signed(6), p) { - Ok(_) | Err(Error::DuplicatePreimage) => (), + Ok(_) => (), + Err(x) if x == Error::::DuplicatePreimage.into() => (), Err(x) => panic!(x), } h } - fn propose_set_balance(who: u64, value: u64, delay: u64) -> Result<(), Error> { + fn propose_set_balance(who: u64, value: u64, delay: u64) -> DispatchResult { Democracy::propose( Origin::signed(who), set_balance_proposal_hash(value), @@ -1303,7 +1310,7 @@ mod tests { ) } - fn propose_set_balance_and_note(who: u64, value: u64, delay: u64) -> Result<(), Error> { + fn propose_set_balance_and_note(who: u64, value: u64, delay: u64) -> DispatchResult { Democracy::propose( Origin::signed(who), set_balance_proposal_hash_and_note(value), @@ -1349,7 +1356,7 @@ mod tests { PREIMAGE_BYTE_DEPOSIT.with(|v| *v.borrow_mut() = 100); assert_noop!( Democracy::note_preimage(Origin::signed(6), vec![0; 500]), - Error::Other("not enough free funds") + "not enough free funds", ); // fee of 1 is reasonable. PREIMAGE_BYTE_DEPOSIT.with(|v| *v.borrow_mut() = 1); @@ -1384,7 +1391,7 @@ mod tests { next_block(); assert_noop!( Democracy::reap_preimage(Origin::signed(6), set_balance_proposal_hash(2)), - Error::Early + Error::::Early ); next_block(); assert_ok!(Democracy::reap_preimage(Origin::signed(6), set_balance_proposal_hash(2))); @@ -1400,7 +1407,7 @@ mod tests { System::set_block_number(1); assert_noop!( Democracy::reap_preimage(Origin::signed(5), set_balance_proposal_hash(2)), - Error::PreimageMissing + Error::::PreimageMissing ); PREIMAGE_BYTE_DEPOSIT.with(|v| *v.borrow_mut() = 1); @@ -1412,7 +1419,7 @@ mod tests { next_block(); assert_noop!( Democracy::reap_preimage(Origin::signed(5), set_balance_proposal_hash(2)), - Error::Early + Error::::Early ); next_block(); @@ -1439,7 +1446,7 @@ mod tests { assert_noop!( Democracy::note_imminent_preimage(Origin::signed(7), set_balance_proposal(2)), - Error::NotImminent + Error::::NotImminent ); next_block(); @@ -1463,7 +1470,7 @@ mod tests { next_block(); next_block(); // now imminent. - assert_noop!(Democracy::reap_preimage(Origin::signed(6), h), Error::Imminent); + assert_noop!(Democracy::reap_preimage(Origin::signed(6), h), Error::::Imminent); }); } @@ -1592,7 +1599,7 @@ mod tests { ); assert!(Democracy::referendum_info(r).is_some()); - assert_noop!(Democracy::emergency_cancel(Origin::signed(3), r), "Invalid origin".into()); + assert_noop!(Democracy::emergency_cancel(Origin::signed(3), r), BadOrigin); assert_ok!(Democracy::emergency_cancel(Origin::signed(4), r)); assert!(Democracy::referendum_info(r).is_none()); @@ -1605,7 +1612,7 @@ mod tests { 2 ); assert!(Democracy::referendum_info(r).is_some()); - assert_noop!(Democracy::emergency_cancel(Origin::signed(4), r), Error::AlreadyCanceled); + assert_noop!(Democracy::emergency_cancel(Origin::signed(4), r), Error::::AlreadyCanceled); }); } @@ -1627,14 +1634,14 @@ mod tests { assert_noop!(Democracy::external_propose( Origin::signed(2), set_balance_proposal_hash(2), - ), Error::ProposalBlacklisted); + ), Error::::ProposalBlacklisted); fast_forward_to(1); // fails as we're still in cooloff period. assert_noop!(Democracy::external_propose( Origin::signed(2), set_balance_proposal_hash(2), - ), Error::ProposalBlacklisted); + ), Error::::ProposalBlacklisted); fast_forward_to(2); // works; as we're out of the cooloff period. @@ -1647,7 +1654,7 @@ mod tests { // 3 can't veto the same thing twice. assert_noop!( Democracy::veto_external(Origin::signed(3), h.clone()), - Error::AlreadyVetoed + Error::::AlreadyVetoed ); // 4 vetoes. @@ -1660,7 +1667,7 @@ mod tests { assert_noop!(Democracy::external_propose( Origin::signed(2), set_balance_proposal_hash(2), - ), Error::ProposalBlacklisted); + ), Error::::ProposalBlacklisted); // different proposal works fine. assert_ok!(Democracy::external_propose( Origin::signed(2), @@ -1673,10 +1680,13 @@ mod tests { fn external_referendum_works() { new_test_ext().execute_with(|| { System::set_block_number(0); - assert_noop!(Democracy::external_propose( - Origin::signed(1), - set_balance_proposal_hash(2), - ), "Invalid origin".into()); + assert_noop!( + Democracy::external_propose( + Origin::signed(1), + set_balance_proposal_hash(2), + ), + BadOrigin, + ); assert_ok!(Democracy::external_propose( Origin::signed(2), set_balance_proposal_hash_and_note(2), @@ -1684,7 +1694,7 @@ mod tests { assert_noop!(Democracy::external_propose( Origin::signed(2), set_balance_proposal_hash(1), - ), Error::DuplicateProposal); + ), Error::::DuplicateProposal); fast_forward_to(2); assert_eq!( Democracy::referendum_info(0), @@ -1702,10 +1712,13 @@ mod tests { fn external_majority_referendum_works() { new_test_ext().execute_with(|| { System::set_block_number(0); - assert_noop!(Democracy::external_propose_majority( - Origin::signed(1), - set_balance_proposal_hash(2) - ), "Invalid origin".into()); + assert_noop!( + Democracy::external_propose_majority( + Origin::signed(1), + set_balance_proposal_hash(2) + ), + BadOrigin, + ); assert_ok!(Democracy::external_propose_majority( Origin::signed(3), set_balance_proposal_hash_and_note(2) @@ -1727,10 +1740,13 @@ mod tests { fn external_default_referendum_works() { new_test_ext().execute_with(|| { System::set_block_number(0); - assert_noop!(Democracy::external_propose_default( - Origin::signed(3), - set_balance_proposal_hash(2) - ), "Invalid origin".into()); + assert_noop!( + Democracy::external_propose_default( + Origin::signed(3), + set_balance_proposal_hash(2) + ), + BadOrigin, + ); assert_ok!(Democracy::external_propose_default( Origin::signed(1), set_balance_proposal_hash_and_note(2) @@ -1753,12 +1769,12 @@ mod tests { new_test_ext().execute_with(|| { System::set_block_number(0); let h = set_balance_proposal_hash_and_note(2); - assert_noop!(Democracy::fast_track(Origin::signed(5), h, 3, 2), Error::ProposalMissing); + assert_noop!(Democracy::fast_track(Origin::signed(5), h, 3, 2), Error::::ProposalMissing); assert_ok!(Democracy::external_propose_majority( Origin::signed(3), set_balance_proposal_hash_and_note(2) )); - assert_noop!(Democracy::fast_track(Origin::signed(1), h, 3, 2), "Invalid origin".into()); + assert_noop!(Democracy::fast_track(Origin::signed(1), h, 3, 2), BadOrigin); assert_ok!(Democracy::fast_track(Origin::signed(5), h, 0, 0)); assert_eq!( Democracy::referendum_info(0), @@ -1783,7 +1799,7 @@ mod tests { )); assert_noop!( Democracy::fast_track(Origin::signed(5), h, 3, 2), - Error::NotSimpleMajority + Error::::NotSimpleMajority ); }); } @@ -1865,7 +1881,7 @@ mod tests { (6, set_balance_proposal_hash_and_note(2), 0) ]); - assert_noop!(Democracy::cancel_queued(Origin::ROOT, 1), Error::ProposalMissing); + assert_noop!(Democracy::cancel_queued(Origin::ROOT, 1), Error::::ProposalMissing); assert_ok!(Democracy::cancel_queued(Origin::ROOT, 0)); assert_eq!(Democracy::dispatch_queue(), vec![]); }); @@ -1879,7 +1895,7 @@ mod tests { assert_eq!(Democracy::proxy(10), Some(1)); // Can't set when already set. - assert_noop!(Democracy::set_proxy(Origin::signed(2), 10), Error::AlreadyProxy); + assert_noop!(Democracy::set_proxy(Origin::signed(2), 10), Error::::AlreadyProxy); // But this works because 11 isn't proxying. assert_ok!(Democracy::set_proxy(Origin::signed(2), 11)); @@ -1887,7 +1903,7 @@ mod tests { assert_eq!(Democracy::proxy(11), Some(2)); // 2 cannot fire 1's proxy: - assert_noop!(Democracy::remove_proxy(Origin::signed(2), 10), Error::WrongProxy); + assert_noop!(Democracy::remove_proxy(Origin::signed(2), 10), Error::::WrongProxy); // 1 fires his proxy: assert_ok!(Democracy::remove_proxy(Origin::signed(1), 10)); @@ -2094,7 +2110,7 @@ mod tests { fn proposal_with_deposit_below_minimum_should_not_work() { new_test_ext().execute_with(|| { System::set_block_number(1); - assert_noop!(propose_set_balance(1, 2, 0), Error::ValueLow); + assert_noop!(propose_set_balance(1, 2, 0), Error::::ValueLow); }); } @@ -2102,7 +2118,7 @@ mod tests { fn poor_proposer_should_not_work() { new_test_ext().execute_with(|| { System::set_block_number(1); - assert_noop!(propose_set_balance(1, 2, 11), Error::Other("not enough free funds")); + assert_noop!(propose_set_balance(1, 2, 11), "not enough free funds"); }); } @@ -2111,7 +2127,7 @@ mod tests { new_test_ext().execute_with(|| { System::set_block_number(1); assert_ok!(propose_set_balance_and_note(2, 2, 11)); - assert_noop!(Democracy::second(Origin::signed(1), 0), Error::Other("not enough free funds")); + assert_noop!(Democracy::second(Origin::signed(1), 0), "not enough free funds"); }); } diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index 62bb4ba86d..8e93775649 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -83,9 +83,9 @@ #![cfg_attr(not(feature = "std"), no_std)] use sp_std::prelude::*; -use sp_runtime::{print, traits::{Zero, StaticLookup, Bounded, Convert}}; +use sp_runtime::{print, DispatchResult, traits::{Zero, StaticLookup, Bounded, Convert}}; use frame_support::{ - decl_storage, decl_event, ensure, decl_module, dispatch, weights::SimpleDispatchInfo, + decl_storage, decl_event, ensure, decl_module, weights::SimpleDispatchInfo, traits::{ Currency, Get, LockableCurrency, LockIdentifier, ReservableCurrency, WithdrawReasons, ChangeMembers, OnUnbalanced, WithdrawReason @@ -373,7 +373,7 @@ decl_module! { return Ok(()); } - return Err("origin is not a candidate, member or a runner up."); + Err("origin is not a candidate, member or a runner up.")? } /// Remove a particular member from the set. This is effective immediately and the bond of @@ -390,7 +390,7 @@ decl_module! { /// Writes: O(do_phragmen) /// # #[weight = SimpleDispatchInfo::FixedOperational(2_000_000)] - fn remove_member(origin, who: ::Source) -> dispatch::Result { + fn remove_member(origin, who: ::Source) -> DispatchResult { ensure_root(origin)?; let who = T::Lookup::lookup(who)?; @@ -402,7 +402,7 @@ decl_module! { if !had_replacement { Self::do_phragmen(); } - }) + }).map_err(Into::into) } /// What to do at the end of each block. Checks if an election needs to happen or not. @@ -566,7 +566,7 @@ impl Module { /// /// Runs phragmen election and cleans all the previous candidate state. The voter state is NOT /// cleaned and voters must themselves submit a transaction to retract. - fn end_block(block_number: T::BlockNumber) -> dispatch::Result { + fn end_block(block_number: T::BlockNumber) -> DispatchResult { if !Self::term_duration().is_zero() { if (block_number % Self::term_duration()).is_zero() { Self::do_phragmen(); @@ -768,6 +768,7 @@ mod tests { type MaximumBlockLength = MaximumBlockLength; type AvailableBlockRatio = AvailableBlockRatio; type Version = (); + type ModuleToIndex = (); } parameter_types! { diff --git a/frame/elections/src/lib.rs b/frame/elections/src/lib.rs index 5b2bee253c..1435c05951 100644 --- a/frame/elections/src/lib.rs +++ b/frame/elections/src/lib.rs @@ -25,12 +25,11 @@ use sp_std::prelude::*; use sp_runtime::{ - RuntimeDebug, - print, + RuntimeDebug, DispatchResult, print, traits::{Zero, One, StaticLookup, Bounded, Saturating}, }; use frame_support::{ - dispatch::Result, decl_storage, decl_event, ensure, decl_module, + decl_storage, decl_event, ensure, decl_module, weights::SimpleDispatchInfo, traits::{ Currency, ExistenceRequirement, Get, LockableCurrency, LockIdentifier, @@ -346,7 +345,7 @@ decl_module! { #[compact] index: VoteIndex, hint: SetIndex, #[compact] value: BalanceOf - ) -> Result { + ) -> DispatchResult { let who = ensure_signed(origin)?; Self::do_set_approvals(who, votes, index, hint, value) } @@ -363,7 +362,7 @@ decl_module! { #[compact] index: VoteIndex, hint: SetIndex, #[compact] value: BalanceOf - ) -> Result { + ) -> DispatchResult { let who = Self::proxy(ensure_signed(origin)?).ok_or("not a proxy")?; Self::do_set_approvals(who, votes, index, hint, value) } @@ -526,7 +525,7 @@ decl_module! { candidate: ::Source, #[compact] total: BalanceOf, #[compact] index: VoteIndex - ) -> Result { + ) -> DispatchResult { let who = ensure_signed(origin)?; ensure!( !total.is_zero(), @@ -587,7 +586,7 @@ decl_module! { // better safe than sorry. let imbalance = T::Currency::slash(&who, bad_presentation_punishment).0; T::BadPresentation::on_unbalanced(imbalance); - Err(if dupe { "duplicate presentation" } else { "incorrect total" }) + Err(if dupe { "duplicate presentation" } else { "incorrect total" })? } } @@ -714,7 +713,7 @@ impl Module { // Private /// Check there's nothing to do this block - fn end_block(block_number: T::BlockNumber) -> Result { + fn end_block(block_number: T::BlockNumber) -> DispatchResult { if (block_number % T::VotingPeriod::get()).is_zero() { if let Some(number) = Self::next_tally() { if block_number == number { @@ -750,7 +749,7 @@ impl Module { index: VoteIndex, hint: SetIndex, value: BalanceOf, - ) -> Result { + ) -> DispatchResult { let candidates_len = ::Candidates::decode_len().unwrap_or(0_usize); ensure!(!Self::presentation_active(), "no approval changes during presentation period"); @@ -873,7 +872,7 @@ impl Module { /// approved candidates in their place. If the total number of members is less than the desired /// membership a new vote is started. Clears all presented candidates, returning the bond of the /// elected ones. - fn finalize_tally() -> Result { + fn finalize_tally() -> DispatchResult { let (_, coming, expiring): (T::BlockNumber, u32, Vec) = >::take() .ok_or("finalize can only be called after a tally is started.")?; diff --git a/frame/elections/src/mock.rs b/frame/elections/src/mock.rs index de4f263f0e..c53789f7ad 100644 --- a/frame/elections/src/mock.rs +++ b/frame/elections/src/mock.rs @@ -53,6 +53,7 @@ impl frame_system::Trait for Test { type MaximumBlockLength = MaximumBlockLength; type AvailableBlockRatio = AvailableBlockRatio; type Version = (); + type ModuleToIndex = (); } parameter_types! { diff --git a/frame/elections/src/tests.rs b/frame/elections/src/tests.rs index b502c52f8f..d7d7e8718b 100644 --- a/frame/elections/src/tests.rs +++ b/frame/elections/src/tests.rs @@ -1034,7 +1034,10 @@ fn election_double_presentations_should_be_punished() { System::set_block_number(6); assert_ok!(Elections::present_winner(Origin::signed(4), 2, 20, 0)); assert_ok!(Elections::present_winner(Origin::signed(4), 5, 50, 0)); - assert_eq!(Elections::present_winner(Origin::signed(4), 5, 50, 0), Err("duplicate presentation")); + assert_eq!( + Elections::present_winner(Origin::signed(4), 5, 50, 0), + Err("duplicate presentation".into()), + ); assert_ok!(Elections::end_block(System::block_number())); assert_eq!(Elections::members(), vec![(5, 11), (2, 11)]); diff --git a/frame/evm/src/lib.rs b/frame/evm/src/lib.rs index 9adafa3c92..891729e71a 100644 --- a/frame/evm/src/lib.rs +++ b/frame/evm/src/lib.rs @@ -30,8 +30,10 @@ use frame_support::traits::{Currency, WithdrawReason, ExistenceRequirement}; use frame_system::{self as system, ensure_signed}; use sp_runtime::ModuleId; use frame_support::weights::SimpleDispatchInfo; -use sp_runtime::traits::{UniqueSaturatedInto, AccountIdConversion, SaturatedConversion, ModuleDispatchError}; use sp_core::{U256, H256, H160, Hasher}; +use sp_runtime::{ + DispatchResult, traits::{UniqueSaturatedInto, AccountIdConversion, SaturatedConversion}, +}; use evm::{ExitReason, ExitSucceed, ExitError}; use evm::executor::StackExecutor; use evm::backend::ApplyBackend; @@ -176,7 +178,7 @@ decl_event! { } decl_error! { - pub enum Error { + pub enum Error for Module { /// Not enough balance to perform action BalanceLow, /// Calculating total fee overflowed @@ -198,14 +200,14 @@ decl_error! { decl_module! { pub struct Module for enum Call where origin: T::Origin { - type Error = Error; + type Error = Error; fn deposit_event() = default; /// Despoit balance from currency/balances module into EVM. #[weight = SimpleDispatchInfo::FixedNormal(10_000)] fn deposit_balance(origin, value: BalanceOf) { - let sender = ensure_signed(origin).map_err(|e| e.as_str())?; + let sender = ensure_signed(origin)?; let imbalance = T::Currency::withdraw( &sender, @@ -225,13 +227,13 @@ decl_module! { /// Withdraw balance from EVM into currency/balances module. #[weight = SimpleDispatchInfo::FixedNormal(10_000)] fn withdraw_balance(origin, value: BalanceOf) { - let sender = ensure_signed(origin).map_err(|e| e.as_str())?; + let sender = ensure_signed(origin)?; let address = T::ConvertAccountId::convert_account_id(&sender); let bvalue = U256::from(UniqueSaturatedInto::::unique_saturated_into(value)); let mut account = Accounts::get(&address); account.balance = account.balance.checked_sub(bvalue) - .ok_or(Error::BalanceLow)?; + .ok_or(Error::::BalanceLow)?; let imbalance = T::Currency::withdraw( &Self::account_id(), @@ -254,10 +256,9 @@ decl_module! { value: U256, gas_limit: u32, gas_price: U256, - ) { - let sender = ensure_signed(origin).map_err(|e| e.as_str())?; - ensure!(gas_price >= T::FeeCalculator::min_gas_price(), Error::GasPriceTooLow); - + ) -> DispatchResult { + let sender = ensure_signed(origin)?; + ensure!(gas_price >= T::FeeCalculator::min_gas_price(), Error::::GasPriceTooLow); let source = T::ConvertAccountId::convert_account_id(&sender); let vicinity = Vicinity { @@ -274,13 +275,13 @@ decl_module! { ); let total_fee = gas_price.checked_mul(U256::from(gas_limit)) - .ok_or(Error::FeeOverflow)?; + .ok_or(Error::::FeeOverflow)?; if Accounts::get(&source).balance < - value.checked_add(total_fee).ok_or(Error::PaymentOverflow)? + value.checked_add(total_fee).ok_or(Error::::PaymentOverflow)? { - return Err(Error::BalanceLow) + Err(Error::::BalanceLow)? } - executor.withdraw(source, total_fee).map_err(|_| Error::WithdrawFailed)?; + executor.withdraw(source, total_fee).map_err(|_| Error::::WithdrawFailed)?; let reason = executor.transact_call( source, @@ -292,9 +293,9 @@ decl_module! { let ret = match reason { ExitReason::Succeed(_) => Ok(()), - ExitReason::Error(_) => Err(Error::ExitReasonFailed), - ExitReason::Revert(_) => Err(Error::ExitReasonRevert), - ExitReason::Fatal(_) => Err(Error::ExitReasonFatal), + ExitReason::Error(_) => Err(Error::::ExitReasonFailed), + ExitReason::Revert(_) => Err(Error::::ExitReasonRevert), + ExitReason::Fatal(_) => Err(Error::::ExitReasonFatal), }; let actual_fee = executor.fee(gas_price); executor.deposit(source, total_fee.saturating_sub(actual_fee)); @@ -302,7 +303,7 @@ decl_module! { let (values, logs) = executor.deconstruct(); backend.apply(values, logs, true); - return ret; + ret.map_err(Into::into) } /// Issue an EVM create operation. This is similar to a contract creation transaction in @@ -314,9 +315,9 @@ decl_module! { value: U256, gas_limit: u32, gas_price: U256, - ) { - let sender = ensure_signed(origin).map_err(|e| e.as_str())?; - ensure!(gas_price >= T::FeeCalculator::min_gas_price(), Error::GasPriceTooLow); + ) -> DispatchResult { + let sender = ensure_signed(origin)?; + ensure!(gas_price >= T::FeeCalculator::min_gas_price(), Error::::GasPriceTooLow); let source = T::ConvertAccountId::convert_account_id(&sender); @@ -334,13 +335,13 @@ decl_module! { ); let total_fee = gas_price.checked_mul(U256::from(gas_limit)) - .ok_or(Error::FeeOverflow)?; + .ok_or(Error::::FeeOverflow)?; if Accounts::get(&source).balance < - value.checked_add(total_fee).ok_or(Error::PaymentOverflow)? + value.checked_add(total_fee).ok_or(Error::::PaymentOverflow)? { - return Err(Error::BalanceLow) + Err(Error::::BalanceLow)? } - executor.withdraw(source, total_fee).map_err(|_| Error::WithdrawFailed)?; + executor.withdraw(source, total_fee).map_err(|_| Error::::WithdrawFailed)?; let reason = executor.transact_create( source, @@ -351,9 +352,9 @@ decl_module! { let ret = match reason { ExitReason::Succeed(_) => Ok(()), - ExitReason::Error(_) => Err(Error::ExitReasonFailed), - ExitReason::Revert(_) => Err(Error::ExitReasonRevert), - ExitReason::Fatal(_) => Err(Error::ExitReasonFatal), + ExitReason::Error(_) => Err(Error::::ExitReasonFailed), + ExitReason::Revert(_) => Err(Error::::ExitReasonRevert), + ExitReason::Fatal(_) => Err(Error::::ExitReasonFatal), }; let actual_fee = executor.fee(gas_price); executor.deposit(source, total_fee.saturating_sub(actual_fee)); @@ -361,7 +362,7 @@ decl_module! { let (values, logs) = executor.deconstruct(); backend.apply(values, logs, true); - return ret; + ret.map_err(Into::into) } } } diff --git a/frame/example/src/lib.rs b/frame/example/src/lib.rs index d77998c85f..f13a78db56 100644 --- a/frame/example/src/lib.rs +++ b/frame/example/src/lib.rs @@ -255,7 +255,7 @@ use sp_std::marker::PhantomData; use frame_support::{ - dispatch::Result, decl_module, decl_storage, decl_event, + dispatch::DispatchResult, decl_module, decl_storage, decl_event, weights::{SimpleDispatchInfo, DispatchInfo, DispatchClass, ClassifyDispatch, WeighData, Weight, PaysFee}, }; use frame_system::{self as system, ensure_signed, ensure_root}; @@ -460,7 +460,7 @@ decl_module! { // transaction and the latter demonstrates the [`DispatchClass`] of the call. A higher // weight means a larger transaction (less of which can be placed in a single block). #[weight = SimpleDispatchInfo::FixedNormal(10_000)] - fn accumulate_dummy(origin, increase_by: T::Balance) -> Result { + fn accumulate_dummy(origin, increase_by: T::Balance) -> DispatchResult { // This is a public call, so we ensure that the origin is some signed account. let _sender = ensure_signed(origin)?; @@ -543,7 +543,7 @@ decl_module! { impl Module { // Add public immutables and private mutables. #[allow(dead_code)] - fn accumulate_foo(origin: T::Origin, increase_by: T::Balance) -> Result { + fn accumulate_foo(origin: T::Origin, increase_by: T::Balance) -> DispatchResult { let _sender = ensure_signed(origin)?; let prev = >::get(); @@ -685,6 +685,7 @@ mod tests { type MaximumBlockLength = MaximumBlockLength; type AvailableBlockRatio = AvailableBlockRatio; type Version = (); + type ModuleToIndex = (); } parameter_types! { pub const ExistentialDeposit: u64 = 0; diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index 4dfa72f9c6..fd05c410d9 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -415,6 +415,7 @@ mod tests { type AvailableBlockRatio = AvailableBlockRatio; type MaximumBlockLength = MaximumBlockLength; type Version = (); + type ModuleToIndex = (); } parameter_types! { pub const ExistentialDeposit: u64 = 0; @@ -660,14 +661,7 @@ mod tests { t.execute_with(|| { assert_eq!(Executive::validate_transaction(xt.clone()), Ok(Default::default())); - assert_eq!( - Executive::apply_extrinsic(xt), - Ok( - Err( - DispatchError { module: Some(1), error: 0, message: Some("RequireRootOrigin") } - ) - ) - ); + assert_eq!(Executive::apply_extrinsic(xt), Ok(Err(DispatchError::BadOrigin))); }); } diff --git a/frame/finality-tracker/src/lib.rs b/frame/finality-tracker/src/lib.rs index 7830a2b8f5..5fbf2b9531 100644 --- a/frame/finality-tracker/src/lib.rs +++ b/frame/finality-tracker/src/lib.rs @@ -19,7 +19,7 @@ #![cfg_attr(not(feature = "std"), no_std)] use sp_inherents::{InherentIdentifier, ProvideInherent, InherentData, MakeFatalError}; -use sp_runtime::traits::{One, Zero, SaturatedConversion, ModuleDispatchError}; +use sp_runtime::traits::{One, Zero, SaturatedConversion}; use sp_std::{prelude::*, result, cmp, vec}; use frame_support::{decl_module, decl_storage, decl_error, ensure}; use frame_support::traits::Get; @@ -57,7 +57,7 @@ decl_storage! { } decl_error! { - pub enum Error { + pub enum Error for Module { /// Final hint must be updated only once in the block AlreadyUpdated, /// Finalized height above block number @@ -67,7 +67,7 @@ decl_error! { decl_module! { pub struct Module for enum Call where origin: T::Origin { - type Error = Error; + type Error = Error; /// The number of recent samples to keep from this chain. Default is 101. const WindowSize: T::BlockNumber = T::WindowSize::get(); @@ -77,11 +77,11 @@ decl_module! { /// Hint that the author of this block thinks the best finalized /// block is the given number. fn final_hint(origin, #[compact] hint: T::BlockNumber) { - ensure_none(origin).map_err(|e| e.as_str())?; - ensure!(!::Update::exists(), Error::AlreadyUpdated); + ensure_none(origin)?; + ensure!(!::Update::exists(), Error::::AlreadyUpdated); ensure!( frame_system::Module::::block_number() >= hint, - Error::BadHint, + Error::::BadHint, ); ::Update::put(hint); } @@ -260,6 +260,7 @@ mod tests { type AvailableBlockRatio = AvailableBlockRatio; type MaximumBlockLength = MaximumBlockLength; type Version = (); + type ModuleToIndex = (); } parameter_types! { pub const WindowSize: u64 = 11; diff --git a/frame/generic-asset/src/lib.rs b/frame/generic-asset/src/lib.rs index 4ad61af4a7..de63ba2f12 100644 --- a/frame/generic-asset/src/lib.rs +++ b/frame/generic-asset/src/lib.rs @@ -123,7 +123,7 @@ //! # } //! type AssetOf = <::Currency as Currency<::AccountId>>::Balance; //! -//! fn charge_fee(transactor: &T::AccountId, amount: AssetOf) -> dispatch::Result { +//! fn charge_fee(transactor: &T::AccountId, amount: AssetOf) -> dispatch::DispatchResult { //! // ... //! T::Currency::withdraw( //! transactor, @@ -135,7 +135,7 @@ //! Ok(()) //! } //! -//! fn refund_fee(transactor: &T::AccountId, amount: AssetOf) -> dispatch::Result { +//! fn refund_fee(transactor: &T::AccountId, amount: AssetOf) -> dispatch::DispatchResult { //! // ... //! T::Currency::deposit_into_existing(transactor, amount)?; //! // ... @@ -153,7 +153,7 @@ use codec::{Decode, Encode, HasCompact, Input, Output, Error}; -use sp_runtime::RuntimeDebug; +use sp_runtime::{RuntimeDebug, DispatchResult, DispatchError}; use sp_runtime::traits::{ CheckedAdd, CheckedSub, MaybeSerializeDeserialize, Member, One, Saturating, SimpleArithmetic, Zero, Bounded, @@ -325,7 +325,7 @@ decl_module! { fn deposit_event() = default; /// Create a new kind of asset. - fn create(origin, options: AssetOptions) -> dispatch::Result { + fn create(origin, options: AssetOptions) -> dispatch::DispatchResult { let origin = ensure_signed(origin)?; let id = Self::next_asset_id(); @@ -358,7 +358,7 @@ decl_module! { origin, #[compact] asset_id: T::AssetId, new_permission: PermissionLatest - ) -> dispatch::Result { + ) -> dispatch::DispatchResult { let origin = ensure_signed(origin)?; let permissions: PermissionVersions = new_permission.into(); @@ -370,14 +370,14 @@ decl_module! { Ok(()) } else { - Err("Origin does not have enough permission to update permissions.") + Err("Origin does not have enough permission to update permissions.")? } } /// Mints an asset, increases its total issuance. /// The origin must have `mint` permissions. fn mint(origin, #[compact] asset_id: T::AssetId, to: T::AccountId, amount: T::Balance) - -> dispatch::Result + -> dispatch::DispatchResult { let origin = ensure_signed(origin)?; if Self::check_permission(&asset_id, &origin, &PermissionType::Mint) { @@ -395,7 +395,7 @@ decl_module! { Ok(()) } else { - Err("The origin does not have permission to mint an asset.") + Err("The origin does not have permission to mint an asset.")? } } @@ -403,7 +403,7 @@ decl_module! { /// /// The `origin` must have `burn` permissions. fn burn(origin, #[compact] asset_id: T::AssetId, to: T::AccountId, amount: T::Balance) - -> dispatch::Result + -> dispatch::DispatchResult { let origin = ensure_signed(origin)?; @@ -424,7 +424,7 @@ decl_module! { Ok(()) } else { - Err("The origin does not have permission to burn an asset.") + Err("The origin does not have permission to burn an asset.")? } } @@ -434,7 +434,7 @@ decl_module! { origin, asset_id: T::AssetId, options: AssetOptions - ) -> dispatch::Result { + ) -> dispatch::DispatchResult { ensure_root(origin)?; Self::create_asset(Some(asset_id), None, options) } @@ -543,7 +543,7 @@ impl Module { asset_id: Option, from_account: Option, options: AssetOptions, - ) -> dispatch::Result { + ) -> dispatch::DispatchResult { let asset_id = if let Some(asset_id) = asset_id { ensure!(!>::exists(&asset_id), "Asset id already taken."); ensure!(asset_id < Self::next_asset_id(), "Asset id not available."); @@ -576,7 +576,7 @@ impl Module { from: &T::AccountId, to: &T::AccountId, amount: T::Balance - ) -> dispatch::Result { + ) -> dispatch::DispatchResult { let new_balance = Self::free_balance(asset_id, from) .checked_sub(&amount) .ok_or_else(|| "balance too low to send amount")?; @@ -597,7 +597,7 @@ impl Module { from: &T::AccountId, to: &T::AccountId, amount: T::Balance, - ) -> dispatch::Result { + ) -> dispatch::DispatchResult { Self::make_transfer(asset_id, from, to, amount)?; if from != to { @@ -612,13 +612,13 @@ impl Module { /// If the free balance is lower than `amount`, then no funds will be moved and an `Err` will /// be returned. This is different behavior than `unreserve`. pub fn reserve(asset_id: &T::AssetId, who: &T::AccountId, amount: T::Balance) - -> dispatch::Result + -> dispatch::DispatchResult { // Do we need to consider that this is an atomic transaction? let original_reserve_balance = Self::reserved_balance(asset_id, who); let original_free_balance = Self::free_balance(asset_id, who); if original_free_balance < amount { - return Err("not enough free funds"); + Err("not enough free funds")? } let new_reserve_balance = original_reserve_balance + amount; Self::set_reserved_balance(asset_id, who, new_reserve_balance); @@ -751,7 +751,7 @@ impl Module { _amount: T::Balance, reasons: WithdrawReasons, new_balance: T::Balance, - ) -> dispatch::Result { + ) -> dispatch::DispatchResult { if asset_id != &Self::staking_asset_id() { return Ok(()); } @@ -767,7 +767,7 @@ impl Module { { Ok(()) } else { - Err("account liquidity restrictions prevent withdrawal") + Err("account liquidity restrictions prevent withdrawal")? } } @@ -1092,6 +1092,7 @@ impl frame_system::Trait for ElevatedTrait { type AvailableBlockRatio = T::AvailableBlockRatio; type BlockHashCount = T::BlockHashCount; type Version = T::Version; + type ModuleToIndex = (); } impl Trait for ElevatedTrait { type Balance = T::Balance; @@ -1133,7 +1134,7 @@ where dest: &T::AccountId, value: Self::Balance, _: ExistenceRequirement, // no existential deposit policy for generic asset - ) -> dispatch::Result { + ) -> DispatchResult { >::make_transfer(&U::asset_id(), transactor, dest, value) } @@ -1142,7 +1143,7 @@ where amount: Self::Balance, reasons: WithdrawReasons, new_balance: Self::Balance, - ) -> dispatch::Result { + ) -> DispatchResult { >::ensure_can_withdraw(&U::asset_id(), who, amount, reasons, new_balance) } @@ -1151,7 +1152,7 @@ where value: Self::Balance, reasons: WithdrawReasons, _: ExistenceRequirement, // no existential deposit policy for generic asset - ) -> result::Result { + ) -> result::Result { let new_balance = Self::free_balance(who) .checked_sub(&value) .ok_or_else(|| "account has too few funds")?; @@ -1163,7 +1164,7 @@ where fn deposit_into_existing( who: &T::AccountId, value: Self::Balance, - ) -> result::Result { + ) -> result::Result { // No existential deposit rule and creation fee in GA. `deposit_into_existing` is same with `deposit_creating`. Ok(Self::deposit_creating(who, value)) } @@ -1248,7 +1249,7 @@ where >::reserved_balance(&U::asset_id(), &who) } - fn reserve(who: &T::AccountId, value: Self::Balance) -> result::Result<(), &'static str> { + fn reserve(who: &T::AccountId, value: Self::Balance) -> DispatchResult { >::reserve(&U::asset_id(), who, value) } @@ -1268,7 +1269,7 @@ where slashed: &T::AccountId, beneficiary: &T::AccountId, value: Self::Balance, - ) -> result::Result { + ) -> result::Result { Ok(>::repatriate_reserved(&U::asset_id(), slashed, beneficiary, value)) } } diff --git a/frame/generic-asset/src/mock.rs b/frame/generic-asset/src/mock.rs index 90426516c1..09ec8f69fb 100644 --- a/frame/generic-asset/src/mock.rs +++ b/frame/generic-asset/src/mock.rs @@ -61,6 +61,7 @@ impl frame_system::Trait for Test { type AvailableBlockRatio = AvailableBlockRatio; type BlockHashCount = BlockHashCount; type Version = (); + type ModuleToIndex = (); } impl Trait for Test { diff --git a/frame/grandpa/src/lib.rs b/frame/grandpa/src/lib.rs index eae43affde..99777cb893 100644 --- a/frame/grandpa/src/lib.rs +++ b/frame/grandpa/src/lib.rs @@ -34,9 +34,7 @@ use sp_std::prelude::*; use codec::{self as codec, Encode, Decode}; use frame_support::{decl_event, decl_storage, decl_module, decl_error, storage}; use sp_runtime::{ - generic::{DigestItem, OpaqueDigestItemId}, - traits::{Zero, ModuleDispatchError}, - Perbill, + DispatchResult, generic::{DigestItem, OpaqueDigestItemId}, traits::Zero, Perbill, }; use sp_staking::{ SessionIndex, @@ -137,7 +135,7 @@ decl_event! { } decl_error! { - pub enum Error { + pub enum Error for Module { /// Attempt to signal GRANDPA pause when the authority set isn't live /// (either paused or already pending pause). PauseFailed, @@ -187,13 +185,13 @@ decl_storage! { decl_module! { pub struct Module for enum Call where origin: T::Origin { - type Error = Error; + type Error = Error; fn deposit_event() = default; /// Report some misbehavior. fn report_misbehavior(origin, _report: Vec) { - ensure_signed(origin).map_err(|e| e.as_str())?; + ensure_signed(origin)?; // FIXME: https://github.com/paritytech/substrate/issues/1112 } @@ -283,7 +281,7 @@ impl Module { /// Schedule GRANDPA to pause starting in the given number of blocks. /// Cannot be done when already paused. - pub fn schedule_pause(in_blocks: T::BlockNumber) -> Result<(), Error> { + pub fn schedule_pause(in_blocks: T::BlockNumber) -> DispatchResult { if let StoredState::Live = >::get() { let scheduled_at = >::block_number(); >::put(StoredState::PendingPause { @@ -293,12 +291,12 @@ impl Module { Ok(()) } else { - Err(Error::PauseFailed) + Err(Error::::PauseFailed)? } } /// Schedule a resume of GRANDPA after pausing. - pub fn schedule_resume(in_blocks: T::BlockNumber) -> Result<(), Error> { + pub fn schedule_resume(in_blocks: T::BlockNumber) -> DispatchResult { if let StoredState::Paused = >::get() { let scheduled_at = >::block_number(); >::put(StoredState::PendingResume { @@ -308,7 +306,7 @@ impl Module { Ok(()) } else { - Err(Error::ResumeFailed) + Err(Error::::ResumeFailed)? } } @@ -330,13 +328,13 @@ impl Module { next_authorities: AuthorityList, in_blocks: T::BlockNumber, forced: Option, - ) -> Result<(), Error> { + ) -> DispatchResult { if !>::exists() { let scheduled_at = >::block_number(); if let Some(_) = forced { if Self::next_forced().map_or(false, |next| next > scheduled_at) { - return Err(Error::TooSoon); + Err(Error::::TooSoon)? } // only allow the next forced change when twice the window has passed since @@ -353,7 +351,7 @@ impl Module { Ok(()) } else { - Err(Error::ChangePending) + Err(Error::::ChangePending)? } } diff --git a/frame/grandpa/src/mock.rs b/frame/grandpa/src/mock.rs index 20701b11aa..87eadea706 100644 --- a/frame/grandpa/src/mock.rs +++ b/frame/grandpa/src/mock.rs @@ -64,6 +64,7 @@ impl frame_system::Trait for Test { type MaximumBlockLength = MaximumBlockLength; type AvailableBlockRatio = AvailableBlockRatio; type Version = (); + type ModuleToIndex = (); } mod grandpa { diff --git a/frame/identity/src/lib.rs b/frame/identity/src/lib.rs index 2813d6c83b..0957396658 100644 --- a/frame/identity/src/lib.rs +++ b/frame/identity/src/lib.rs @@ -69,9 +69,9 @@ use sp_std::prelude::*; use sp_std::{fmt::Debug, ops::Add, iter::once}; use enumflags2::BitFlags; use codec::{Encode, Decode}; -use sp_runtime::{traits::{StaticLookup, EnsureOrigin, Zero}, RuntimeDebug}; +use sp_runtime::{DispatchResult, traits::{StaticLookup, EnsureOrigin, Zero}, RuntimeDebug}; use frame_support::{ - decl_module, decl_event, decl_storage, ensure, dispatch::Result, + decl_module, decl_event, decl_storage, ensure, traits::{Currency, ReservableCurrency, OnUnbalanced, Get}, weights::SimpleDispatchInfo, }; @@ -423,8 +423,7 @@ decl_module! { fn add_registrar(origin, account: T::AccountId) { T::RegistrarOrigin::try_origin(origin) .map(|_| ()) - .or_else(ensure_root) - .map_err(|_| "bad origin")?; + .or_else(ensure_root)?; let i = >::mutate(|r| { r.push(Some(RegistrarInfo { account, fee: Zero::zero(), fields: Default::default() })); @@ -595,7 +594,7 @@ decl_module! { let item = (reg_index, Judgement::FeePaid(registrar.fee)); match id.judgements.binary_search_by_key(®_index, |x| x.0) { Ok(i) => if id.judgements[i].1.is_sticky() { - return Err("sticky judgement") + Err("sticky judgement")? } else { id.judgements[i] = item }, @@ -636,7 +635,7 @@ decl_module! { let fee = if let Judgement::FeePaid(fee) = id.judgements.remove(pos).1 { fee } else { - return Err("judgement given") + Err("judgement given")? }; let _ = T::Currency::unreserve(&sender, fee); @@ -661,14 +660,14 @@ decl_module! { fn set_fee(origin, #[compact] index: RegistrarIndex, #[compact] fee: BalanceOf, - ) -> Result { + ) -> DispatchResult { let who = ensure_signed(origin)?; >::mutate(|rs| rs.get_mut(index as usize) .and_then(|x| x.as_mut()) .and_then(|r| if r.account == who { r.fee = fee; Some(()) } else { None }) - .ok_or("invalid index") + .ok_or_else(|| "invalid index".into()) ) } @@ -688,14 +687,14 @@ decl_module! { fn set_account_id(origin, #[compact] index: RegistrarIndex, new: T::AccountId, - ) -> Result { + ) -> DispatchResult { let who = ensure_signed(origin)?; >::mutate(|rs| rs.get_mut(index as usize) .and_then(|x| x.as_mut()) .and_then(|r| if r.account == who { r.account = new; Some(()) } else { None }) - .ok_or("invalid index") + .ok_or_else(|| "invalid index".into()) ) } @@ -715,14 +714,14 @@ decl_module! { fn set_fields(origin, #[compact] index: RegistrarIndex, fields: IdentityFields, - ) -> Result { + ) -> DispatchResult { let who = ensure_signed(origin)?; >::mutate(|rs| rs.get_mut(index as usize) .and_then(|x| x.as_mut()) .and_then(|r| if r.account == who { r.fields = fields; Some(()) } else { None }) - .ok_or("invalid index") + .ok_or_else(|| "invalid index".into()) ) } @@ -798,8 +797,7 @@ decl_module! { fn kill_identity(origin, target: ::Source) { T::ForceOrigin::try_origin(origin) .map(|_| ()) - .or_else(ensure_root) - .map_err(|_| "bad origin")?; + .or_else(ensure_root)?; // Figure out who we're meant to be clearing. let target = T::Lookup::lookup(target)?; @@ -822,6 +820,7 @@ decl_module! { mod tests { use super::*; + use sp_runtime::traits::BadOrigin; use frame_support::{assert_ok, assert_noop, impl_outer_origin, parameter_types, weights::Weight}; use sp_core::H256; use frame_system::EnsureSignedBy; @@ -862,6 +861,7 @@ mod tests { type MaximumBlockLength = MaximumBlockLength; type AvailableBlockRatio = AvailableBlockRatio; type Version = (); + type ModuleToIndex = (); } parameter_types! { pub const ExistentialDeposit: u64 = 0; @@ -999,7 +999,7 @@ mod tests { fn killing_slashing_should_work() { new_test_ext().execute_with(|| { assert_ok!(Identity::set_identity(Origin::signed(10), ten())); - assert_noop!(Identity::kill_identity(Origin::signed(1), 10), "bad origin"); + assert_noop!(Identity::kill_identity(Origin::signed(1), 10), BadOrigin); assert_ok!(Identity::kill_identity(Origin::signed(2), 10)); assert_eq!(Identity::identity(10), None); assert_eq!(Balances::free_balance(10), 90); diff --git a/frame/im-online/src/lib.rs b/frame/im-online/src/lib.rs index 64d23dbb5d..d7dfb1c673 100644 --- a/frame/im-online/src/lib.rs +++ b/frame/im-online/src/lib.rs @@ -50,7 +50,7 @@ //! //! decl_module! { //! pub struct Module for enum Call where origin: T::Origin { -//! pub fn is_online(origin, authority_index: u32) -> dispatch::Result { +//! pub fn is_online(origin, authority_index: u32) -> dispatch::DispatchResult { //! let _sender = ensure_signed(origin)?; //! let _is_online = >::is_online(authority_index); //! Ok(()) diff --git a/frame/im-online/src/mock.rs b/frame/im-online/src/mock.rs index 94f91ddc2e..7feed1ecca 100644 --- a/frame/im-online/src/mock.rs +++ b/frame/im-online/src/mock.rs @@ -117,6 +117,7 @@ impl frame_system::Trait for Runtime { type MaximumBlockLength = MaximumBlockLength; type AvailableBlockRatio = AvailableBlockRatio; type Version = (); + type ModuleToIndex = (); } parameter_types! { diff --git a/frame/im-online/src/tests.rs b/frame/im-online/src/tests.rs index 3fbd424421..1b4356aa49 100644 --- a/frame/im-online/src/tests.rs +++ b/frame/im-online/src/tests.rs @@ -111,7 +111,7 @@ fn heartbeat( session_index: u32, authority_index: u32, id: UintAuthorityId, -) -> dispatch::Result { +) -> dispatch::DispatchResult { #[allow(deprecated)] use frame_support::unsigned::ValidateUnsigned; @@ -127,7 +127,8 @@ fn heartbeat( let signature = id.sign(&heartbeat.encode()).unwrap(); #[allow(deprecated)] // Allow ValidateUnsigned - ImOnline::pre_dispatch(&crate::Call::heartbeat(heartbeat.clone(), signature.clone()))?; + ImOnline::pre_dispatch(&crate::Call::heartbeat(heartbeat.clone(), signature.clone())) + .map_err(|e| <&'static str>::from(e))?; ImOnline::heartbeat( Origin::system(frame_system::RawOrigin::None), heartbeat, diff --git a/frame/indices/src/mock.rs b/frame/indices/src/mock.rs index e4ff3d2d77..2a1cb0746f 100644 --- a/frame/indices/src/mock.rs +++ b/frame/indices/src/mock.rs @@ -86,6 +86,7 @@ impl frame_system::Trait for Runtime { type MaximumBlockLength = MaximumBlockLength; type AvailableBlockRatio = AvailableBlockRatio; type Version = (); + type ModuleToIndex = (); } impl Trait for Runtime { type AccountIndex = u64; diff --git a/frame/membership/src/lib.rs b/frame/membership/src/lib.rs index 93fcb479c7..0a7f8ec7fc 100644 --- a/frame/membership/src/lib.rs +++ b/frame/membership/src/lib.rs @@ -259,6 +259,7 @@ mod tests { type MaximumBlockLength = MaximumBlockLength; type AvailableBlockRatio = AvailableBlockRatio; type Version = (); + type ModuleToIndex = (); } parameter_types! { pub const One: u64 = 1; diff --git a/frame/nicks/src/lib.rs b/frame/nicks/src/lib.rs index 1c28146edb..d2f0b4d8c9 100644 --- a/frame/nicks/src/lib.rs +++ b/frame/nicks/src/lib.rs @@ -269,6 +269,7 @@ mod tests { type MaximumBlockLength = MaximumBlockLength; type AvailableBlockRatio = AvailableBlockRatio; type Version = (); + type ModuleToIndex = (); } parameter_types! { pub const ExistentialDeposit: u64 = 0; diff --git a/frame/offences/src/mock.rs b/frame/offences/src/mock.rs index 1175ebaeee..343fdc88fa 100644 --- a/frame/offences/src/mock.rs +++ b/frame/offences/src/mock.rs @@ -88,6 +88,7 @@ impl frame_system::Trait for Runtime { type MaximumBlockLength = MaximumBlockLength; type AvailableBlockRatio = AvailableBlockRatio; type Version = (); + type ModuleToIndex = (); } impl Trait for Runtime { diff --git a/frame/randomness-collective-flip/src/lib.rs b/frame/randomness-collective-flip/src/lib.rs index ff75d6b9b8..8432a86198 100644 --- a/frame/randomness-collective-flip/src/lib.rs +++ b/frame/randomness-collective-flip/src/lib.rs @@ -41,7 +41,7 @@ //! //! decl_module! { //! pub struct Module for enum Call where origin: T::Origin { -//! pub fn random_module_example(origin) -> dispatch::Result { +//! pub fn random_module_example(origin) -> dispatch::DispatchResult { //! let _random_seed = >::random_seed(); //! Ok(()) //! } @@ -188,6 +188,7 @@ mod tests { type AvailableBlockRatio = AvailableBlockRatio; type MaximumBlockLength = MaximumBlockLength; type Version = (); + type ModuleToIndex = (); } type System = frame_system::Module; diff --git a/frame/scored-pool/src/lib.rs b/frame/scored-pool/src/lib.rs index 9703d041d7..65a867df60 100644 --- a/frame/scored-pool/src/lib.rs +++ b/frame/scored-pool/src/lib.rs @@ -61,7 +61,7 @@ //! //! decl_module! { //! pub struct Module for enum Call where origin: T::Origin { -//! pub fn candidate(origin) -> dispatch::Result { +//! pub fn candidate(origin) -> dispatch::DispatchResult { //! let who = ensure_signed(origin)?; //! //! let _ = >::submit_candidacy( @@ -261,7 +261,7 @@ decl_module! { // `None` are always sorted to the end. if let Err(e) = >::append(&[(who.clone(), None)]) { T::Currency::unreserve(&who, deposit); - return Err(e); + Err(e)? } >::insert(&who, true); diff --git a/frame/scored-pool/src/mock.rs b/frame/scored-pool/src/mock.rs index 097d7bc33f..fe873da26a 100644 --- a/frame/scored-pool/src/mock.rs +++ b/frame/scored-pool/src/mock.rs @@ -70,6 +70,7 @@ impl frame_system::Trait for Test { type MaximumBlockLength = MaximumBlockLength; type AvailableBlockRatio = AvailableBlockRatio; type Version = (); + type ModuleToIndex = (); } impl pallet_balances::Trait for Test { diff --git a/frame/session/src/lib.rs b/frame/session/src/lib.rs index aee01dc37f..5b3e4e2aee 100644 --- a/frame/session/src/lib.rs +++ b/frame/session/src/lib.rs @@ -483,14 +483,14 @@ decl_module! { /// - One extra DB entry. /// # #[weight = SimpleDispatchInfo::FixedNormal(150_000)] - fn set_keys(origin, keys: T::Keys, proof: Vec) -> dispatch::Result { + fn set_keys(origin, keys: T::Keys, proof: Vec) -> dispatch::DispatchResult { let who = ensure_signed(origin)?; ensure!(keys.ownership_proof_is_valid(&proof), "invalid ownership proof"); let who = match T::ValidatorIdOf::convert(who) { Some(val_id) => val_id, - None => return Err("no associated validator ID for account."), + None => Err("no associated validator ID for account.")?, }; Self::do_set_keys(&who, keys)?; @@ -631,7 +631,7 @@ impl Module { // perform the set_key operation, checking for duplicates. // does not set `Changed`. - fn do_set_keys(who: &T::ValidatorId, keys: T::Keys) -> dispatch::Result { + fn do_set_keys(who: &T::ValidatorId, keys: T::Keys) -> dispatch::DispatchResult { let old_keys = Self::load_keys(&who); for id in T::Keys::key_ids() { diff --git a/frame/session/src/mock.rs b/frame/session/src/mock.rs index 14fbc46c82..28c84d7374 100644 --- a/frame/session/src/mock.rs +++ b/frame/session/src/mock.rs @@ -174,6 +174,7 @@ impl frame_system::Trait for Test { type AvailableBlockRatio = AvailableBlockRatio; type MaximumBlockLength = MaximumBlockLength; type Version = (); + type ModuleToIndex = (); } impl pallet_timestamp::Trait for Test { diff --git a/frame/staking/src/lib.rs b/frame/staking/src/lib.rs index bc43b54e91..2acbe28a0a 100644 --- a/frame/staking/src/lib.rs +++ b/frame/staking/src/lib.rs @@ -147,7 +147,7 @@ //! decl_module! { //! pub struct Module for enum Call where origin: T::Origin { //! /// Reward a validator. -//! pub fn reward_myself(origin) -> dispatch::Result { +//! pub fn reward_myself(origin) -> dispatch::DispatchResult { //! let reported = ensure_signed(origin)?; //! >::reward_by_ids(vec![(reported, 10)]); //! Ok(()) @@ -272,7 +272,7 @@ use sp_runtime::{ curve::PiecewiseLinear, traits::{ Convert, Zero, One, StaticLookup, CheckedSub, Saturating, Bounded, SaturatedConversion, - SimpleArithmetic, EnsureOrigin, ModuleDispatchError, + SimpleArithmetic, EnsureOrigin, } }; use sp_staking::{ @@ -785,7 +785,7 @@ decl_event!( decl_error! { /// Error for the stacking module. - pub enum Error { + pub enum Error for Module { /// Not a controller account. NotController, /// Not a stash account. @@ -817,7 +817,7 @@ decl_module! { /// Number of eras that staked funds must remain bonded for. const BondingDuration: EraIndex = T::BondingDuration::get(); - type Error = Error; + type Error = Error; fn deposit_event() = default; @@ -853,21 +853,21 @@ decl_module! { #[compact] value: BalanceOf, payee: RewardDestination ) { - let stash = ensure_signed(origin).map_err(|e| e.as_str())?; + let stash = ensure_signed(origin)?; if >::exists(&stash) { - return Err(Error::AlreadyBonded) + Err(Error::::AlreadyBonded)? } let controller = T::Lookup::lookup(controller)?; if >::exists(&controller) { - return Err(Error::AlreadyPaired) + Err(Error::::AlreadyPaired)? } // reject a bond which is considered to be _dust_. if value < T::Currency::minimum_balance() { - return Err(Error::InsufficientValue) + Err(Error::::InsufficientValue)? } // You're auto-bonded forever, here. We might improve this by only bonding when @@ -897,10 +897,10 @@ decl_module! { /// # #[weight = SimpleDispatchInfo::FixedNormal(500_000)] fn bond_extra(origin, #[compact] max_additional: BalanceOf) { - let stash = ensure_signed(origin).map_err(|e| e.as_str())?; + let stash = ensure_signed(origin)?; - let controller = Self::bonded(&stash).ok_or(Error::NotStash)?; - let mut ledger = Self::ledger(&controller).ok_or(Error::NotController)?; + let controller = Self::bonded(&stash).ok_or(Error::::NotStash)?; + let mut ledger = Self::ledger(&controller).ok_or(Error::::NotController)?; let stash_balance = T::Currency::free_balance(&stash); @@ -937,11 +937,11 @@ decl_module! { /// #[weight = SimpleDispatchInfo::FixedNormal(400_000)] fn unbond(origin, #[compact] value: BalanceOf) { - let controller = ensure_signed(origin).map_err(|e| e.as_str())?; - let mut ledger = Self::ledger(&controller).ok_or(Error::NotController)?; + let controller = ensure_signed(origin)?; + let mut ledger = Self::ledger(&controller).ok_or(Error::::NotController)?; ensure!( ledger.unlocking.len() < MAX_UNLOCKING_CHUNKS, - Error::NoMoreChunks + Error::::NoMoreChunks, ); let mut value = value.min(ledger.active); @@ -979,8 +979,8 @@ decl_module! { /// # #[weight = SimpleDispatchInfo::FixedNormal(400_000)] fn withdraw_unbonded(origin) { - let controller = ensure_signed(origin).map_err(|e| e.as_str())?; - let ledger = Self::ledger(&controller).ok_or(Error::NotController)?; + let controller = ensure_signed(origin)?; + let ledger = Self::ledger(&controller).ok_or(Error::::NotController)?; let ledger = ledger.consolidate_unlocked(Self::current_era()); if ledger.unlocking.is_empty() && ledger.active.is_zero() { @@ -1013,8 +1013,8 @@ decl_module! { fn validate(origin, prefs: ValidatorPrefs) { Self::ensure_storage_upgraded(); - let controller = ensure_signed(origin).map_err(|e| e.as_str())?; - let ledger = Self::ledger(&controller).ok_or(Error::NotController)?; + let controller = ensure_signed(origin)?; + let ledger = Self::ledger(&controller).ok_or(Error::::NotController)?; let stash = &ledger.stash; >::remove(stash); >::insert(stash, prefs); @@ -1035,10 +1035,10 @@ decl_module! { fn nominate(origin, targets: Vec<::Source>) { Self::ensure_storage_upgraded(); - let controller = ensure_signed(origin).map_err(|e| e.as_str())?; - let ledger = Self::ledger(&controller).ok_or(Error::NotController)?; + let controller = ensure_signed(origin)?; + let ledger = Self::ledger(&controller).ok_or(Error::::NotController)?; let stash = &ledger.stash; - ensure!(!targets.is_empty(), Error::EmptyTargets); + ensure!(!targets.is_empty(), Error::::EmptyTargets); let targets = targets.into_iter() .take(MAX_NOMINATIONS) .map(|t| T::Lookup::lookup(t)) @@ -1067,8 +1067,8 @@ decl_module! { /// # #[weight = SimpleDispatchInfo::FixedNormal(500_000)] fn chill(origin) { - let controller = ensure_signed(origin).map_err(|e| e.as_str())?; - let ledger = Self::ledger(&controller).ok_or(Error::NotController)?; + let controller = ensure_signed(origin)?; + let ledger = Self::ledger(&controller).ok_or(Error::::NotController)?; Self::chill_stash(&ledger.stash); } @@ -1085,8 +1085,8 @@ decl_module! { /// # #[weight = SimpleDispatchInfo::FixedNormal(500_000)] fn set_payee(origin, payee: RewardDestination) { - let controller = ensure_signed(origin).map_err(|e| e.as_str())?; - let ledger = Self::ledger(&controller).ok_or(Error::NotController)?; + let controller = ensure_signed(origin)?; + let ledger = Self::ledger(&controller).ok_or(Error::::NotController)?; let stash = &ledger.stash; >::insert(stash, payee); } @@ -1104,11 +1104,11 @@ decl_module! { /// # #[weight = SimpleDispatchInfo::FixedNormal(750_000)] fn set_controller(origin, controller: ::Source) { - let stash = ensure_signed(origin).map_err(|e| e.as_str())?; - let old_controller = Self::bonded(&stash).ok_or(Error::NotStash)?; + let stash = ensure_signed(origin)?; + let old_controller = Self::bonded(&stash).ok_or(Error::::NotStash)?; let controller = T::Lookup::lookup(controller)?; if >::exists(&controller) { - return Err(Error::AlreadyPaired) + Err(Error::::AlreadyPaired)? } if controller != old_controller { >::insert(&stash, &controller); @@ -1121,7 +1121,7 @@ decl_module! { /// The ideal number of validators. #[weight = SimpleDispatchInfo::FreeOperational] fn set_validator_count(origin, #[compact] new: u32) { - ensure_root(origin).map_err(|e| e.as_str())?; + ensure_root(origin)?; ValidatorCount::put(new); } @@ -1134,7 +1134,7 @@ decl_module! { /// # #[weight = SimpleDispatchInfo::FreeOperational] fn force_no_eras(origin) { - ensure_root(origin).map_err(|e| e.as_str())?; + ensure_root(origin)?; ForceEra::put(Forcing::ForceNone); } @@ -1146,21 +1146,21 @@ decl_module! { /// # #[weight = SimpleDispatchInfo::FreeOperational] fn force_new_era(origin) { - ensure_root(origin).map_err(|e| e.as_str())?; + ensure_root(origin)?; ForceEra::put(Forcing::ForceNew); } /// Set the validators who cannot be slashed (if any). #[weight = SimpleDispatchInfo::FreeOperational] fn set_invulnerables(origin, validators: Vec) { - ensure_root(origin).map_err(|e| e.as_str())?; + ensure_root(origin)?; >::put(validators); } /// Force a current staker to become completely unstaked, immediately. #[weight = SimpleDispatchInfo::FreeOperational] fn force_unstake(origin, stash: T::AccountId) { - ensure_root(origin).map_err(|e| e.as_str())?; + ensure_root(origin)?; // remove the lock. T::Currency::remove_lock(STAKING_ID, &stash); @@ -1175,7 +1175,7 @@ decl_module! { /// # #[weight = SimpleDispatchInfo::FreeOperational] fn force_new_era_always(origin) { - ensure_root(origin).map_err(|e| e.as_str())?; + ensure_root(origin)?; ForceEra::put(Forcing::ForceAlways); } @@ -1191,7 +1191,7 @@ decl_module! { T::SlashCancelOrigin::try_origin(origin) .map(|_| ()) .or_else(ensure_root) - .map_err(|_| Error::BadOrigin)?; + .map_err(|_| Error::::BadOrigin)?; let mut slash_indices = slash_indices; slash_indices.sort_unstable(); @@ -1201,12 +1201,12 @@ decl_module! { let index = index as usize; // if `index` is not duplicate, `removed` must be <= index. - ensure!(removed <= index, Error::DuplicateIndex); + ensure!(removed <= index, Error::::DuplicateIndex); // all prior removals were from before this index, since the // list is sorted. let index = index - removed; - ensure!(index < unapplied.len(), Error::InvalidSlashIndex); + ensure!(index < unapplied.len(), Error::::InvalidSlashIndex); unapplied.remove(index); } diff --git a/frame/staking/src/mock.rs b/frame/staking/src/mock.rs index 16c587f9be..81066f9dd8 100644 --- a/frame/staking/src/mock.rs +++ b/frame/staking/src/mock.rs @@ -137,6 +137,7 @@ impl frame_system::Trait for Test { type AvailableBlockRatio = AvailableBlockRatio; type MaximumBlockLength = MaximumBlockLength; type Version = (); + type ModuleToIndex = (); } parameter_types! { pub const TransferFee: Balance = 0; diff --git a/frame/staking/src/tests.rs b/frame/staking/src/tests.rs index 33bf860b2c..109f2e086f 100644 --- a/frame/staking/src/tests.rs +++ b/frame/staking/src/tests.rs @@ -18,7 +18,7 @@ use super::*; use mock::*; -use sp_runtime::{assert_eq_error_rate, traits::OnInitialize}; +use sp_runtime::{assert_eq_error_rate, traits::{OnInitialize, BadOrigin}}; use sp_staking::offence::OffenceDetails; use frame_support::{assert_ok, assert_noop, traits::{Currency, ReservableCurrency}}; use substrate_test_utils::assert_eq_uvec; @@ -35,7 +35,7 @@ fn force_unstake_works() { "account liquidity restrictions prevent withdrawal" ); // Force unstake requires root. - assert_noop!(Staking::force_unstake(Origin::signed(11), 11), "RequireRootOrigin".into()); + assert_noop!(Staking::force_unstake(Origin::signed(11), 11), BadOrigin); // We now force them to unstake assert_ok!(Staking::force_unstake(Origin::ROOT, 11)); // No longer bonded. @@ -142,7 +142,7 @@ fn change_controller_works() { assert_noop!( Staking::validate(Origin::signed(10), ValidatorPrefs::default()), - Error::NotController, + Error::::NotController, ); assert_ok!(Staking::validate(Origin::signed(5), ValidatorPrefs::default())); }) @@ -680,10 +680,10 @@ fn double_staking_should_fail() { // 4 = not used so far, 1 stashed => not allowed. assert_noop!( Staking::bond(Origin::signed(1), 4, arbitrary_value, - RewardDestination::default()), Error::AlreadyBonded, + RewardDestination::default()), Error::::AlreadyBonded, ); // 1 = stashed => attempting to nominate should fail. - assert_noop!(Staking::nominate(Origin::signed(1), vec![1]), Error::NotController); + assert_noop!(Staking::nominate(Origin::signed(1), vec![1]), Error::::NotController); // 2 = controller => nominating should work. assert_ok!(Staking::nominate(Origin::signed(2), vec![1])); }); @@ -705,7 +705,7 @@ fn double_controlling_should_fail() { // 2 = controller, 3 stashed (Note that 2 is reused.) => no-op assert_noop!( Staking::bond(Origin::signed(3), 2, arbitrary_value, RewardDestination::default()), - Error::AlreadyPaired, + Error::::AlreadyPaired, ); }); } @@ -1152,11 +1152,11 @@ fn too_many_unbond_calls_should_not_work() { // locked at era 1 until 4 assert_ok!(Staking::unbond(Origin::signed(10), 1)); // can't do more. - assert_noop!(Staking::unbond(Origin::signed(10), 1), Error::NoMoreChunks); + assert_noop!(Staking::unbond(Origin::signed(10), 1), Error::::NoMoreChunks); start_era(3); - assert_noop!(Staking::unbond(Origin::signed(10), 1), Error::NoMoreChunks); + assert_noop!(Staking::unbond(Origin::signed(10), 1), Error::::NoMoreChunks); // free up. assert_ok!(Staking::withdraw_unbonded(Origin::signed(10))); @@ -1422,7 +1422,7 @@ fn bond_with_no_staked_value() { // Can't bond with 1 assert_noop!( Staking::bond(Origin::signed(1), 2, 1, RewardDestination::Controller), - Error::InsufficientValue, + Error::::InsufficientValue, ); // bonded with absolute minimum value possible. assert_ok!(Staking::bond(Origin::signed(1), 2, 5, RewardDestination::Controller)); diff --git a/frame/sudo/src/lib.rs b/frame/sudo/src/lib.rs index b7486edf31..00a1b72a86 100644 --- a/frame/sudo/src/lib.rs +++ b/frame/sudo/src/lib.rs @@ -58,7 +58,7 @@ //! //! decl_module! { //! pub struct Module for enum Call where origin: T::Origin { -//! pub fn privileged_function(origin) -> dispatch::Result { +//! pub fn privileged_function(origin) -> dispatch::DispatchResult { //! ensure_root(origin)?; //! //! // do something... @@ -87,9 +87,7 @@ #![cfg_attr(not(feature = "std"), no_std)] use sp_std::prelude::*; -use sp_runtime::{ - traits::{StaticLookup, Dispatchable, ModuleDispatchError}, DispatchError, -}; +use sp_runtime::{traits::{StaticLookup, Dispatchable}, DispatchError}; use frame_support::{ Parameter, decl_module, decl_event, decl_storage, decl_error, ensure, @@ -108,7 +106,7 @@ pub trait Trait: frame_system::Trait { decl_module! { // Simple declaration of the `Module` type. Lets the macro know what it's working on. pub struct Module for enum Call where origin: T::Origin { - type Error = Error; + type Error = Error; fn deposit_event() = default; @@ -125,8 +123,8 @@ decl_module! { #[weight = SimpleDispatchInfo::FreeOperational] fn sudo(origin, proposal: Box) { // This is a public call, so we ensure that the origin is some signed account. - let sender = ensure_signed(origin).map_err(|e| e.as_str())?; - ensure!(sender == Self::key(), Error::RequireSudo); + let sender = ensure_signed(origin)?; + ensure!(sender == Self::key(), Error::::RequireSudo); let res = match proposal.dispatch(frame_system::RawOrigin::Root.into()) { Ok(_) => true, @@ -151,8 +149,8 @@ decl_module! { /// # fn set_key(origin, new: ::Source) { // This is a public call, so we ensure that the origin is some signed account. - let sender = ensure_signed(origin).map_err(|e| e.as_str())?; - ensure!(sender == Self::key(), Error::RequireSudo); + let sender = ensure_signed(origin)?; + ensure!(sender == Self::key(), Error::::RequireSudo); let new = T::Lookup::lookup(new)?; Self::deposit_event(RawEvent::KeyChanged(Self::key())); @@ -173,8 +171,8 @@ decl_module! { #[weight = SimpleDispatchInfo::FixedOperational(0)] fn sudo_as(origin, who: ::Source, proposal: Box) { // This is a public call, so we ensure that the origin is some signed account. - let sender = ensure_signed(origin).map_err(|e| e.as_str())?; - ensure!(sender == Self::key(), Error::RequireSudo); + let sender = ensure_signed(origin)?; + ensure!(sender == Self::key(), Error::::RequireSudo); let who = T::Lookup::lookup(who)?; @@ -212,7 +210,7 @@ decl_storage! { decl_error! { /// Error for the Sudo module - pub enum Error { + pub enum Error for Module { /// Sender must be the Sudo account RequireSudo, } diff --git a/frame/support/procedural/src/construct_runtime/mod.rs b/frame/support/procedural/src/construct_runtime/mod.rs index 07b7f2cefe..8472542d16 100644 --- a/frame/support/procedural/src/construct_runtime/mod.rs +++ b/frame/support/procedural/src/construct_runtime/mod.rs @@ -24,6 +24,9 @@ use proc_macro2::{Span, TokenStream as TokenStream2}; use quote::quote; use syn::{Ident, Result}; +/// The fixed name of the system module. +const SYSTEM_MODULE_NAME: &str = "System"; + pub fn construct_runtime(input: TokenStream) -> TokenStream { let definition = syn::parse_macro_input!(input as RuntimeDefinition); construct_runtime_parsed(definition) @@ -63,7 +66,7 @@ fn construct_runtime_parsed(definition: RuntimeDefinition) -> Result Result Result( fn decl_all_modules<'a>( runtime: &'a Ident, - system_name: &'a Ident, module_declarations: impl Iterator, ) -> TokenStream2 { let mut types = TokenStream2::new(); @@ -330,22 +335,49 @@ fn decl_all_modules<'a>( names.push(&module_declaration.name); } // Make nested tuple structure like (((Babe, Consensus), Grandpa), ...) - let all_modules = names.iter().fold( - TokenStream2::default(), - |combined, name| quote!((#name, #combined)), - ); + // But ignore the system module. + let all_modules = names.iter() + .filter(|n| **n != SYSTEM_MODULE_NAME) + .fold(TokenStream2::default(), |combined, name| quote!((#name, #combined))); quote!( - pub type System = #system_name::Module<#runtime>; #types type AllModules = ( #all_modules ); ) } +fn decl_module_to_index<'a>( + module_declarations: impl Iterator, + num_modules: usize, + scrate: &TokenStream2, +) -> TokenStream2 { + let names = module_declarations.map(|d| &d.name); + let indices = 0..num_modules; + + quote!( + /// Provides an implementation of `ModuleToIndex` to map a module + /// to its index in the runtime. + pub struct ModuleToIndex; + + impl #scrate::traits::ModuleToIndex for ModuleToIndex { + fn module_to_index() -> Option { + let type_id = #scrate::sp_std::any::TypeId::of::(); + #( + if type_id == #scrate::sp_std::any::TypeId::of::<#names>() { + return Some(#indices) + } + )* + + None + } + } + ) +} + fn find_system_module<'a>( mut module_declarations: impl Iterator, ) -> Option<&'a Ident> { module_declarations - .find(|decl| decl.name == "System") + .find(|decl| decl.name == SYSTEM_MODULE_NAME) .map(|decl| &decl.module) } diff --git a/frame/support/procedural/tools/src/lib.rs b/frame/support/procedural/tools/src/lib.rs index 10d3c4b59b..e1e73af104 100644 --- a/frame/support/procedural/tools/src/lib.rs +++ b/frame/support/procedural/tools/src/lib.rs @@ -47,7 +47,7 @@ pub fn generate_crate_access(unique_id: &str, def_crate: &str) -> TokenStream { /// Generates the hidden includes that are required to make the macro independent from its scope. pub fn generate_hidden_includes(unique_id: &str, def_crate: &str) -> TokenStream { - if ::std::env::var("CARGO_PKG_NAME").unwrap() == def_crate { + if std::env::var("CARGO_PKG_NAME").unwrap() == def_crate { TokenStream::new() } else { let mod_name = generate_hidden_includes_mod_name(unique_id); diff --git a/frame/support/src/dispatch.rs b/frame/support/src/dispatch.rs index ca535a6a3b..6683aaea31 100644 --- a/frame/support/src/dispatch.rs +++ b/frame/support/src/dispatch.rs @@ -27,17 +27,11 @@ pub use crate::weights::{ SimpleDispatchInfo, GetDispatchInfo, DispatchInfo, WeighData, ClassifyDispatch, TransactionPriority, Weight, WeighBlock, PaysFee, }; -pub use sp_runtime::{ - traits::{Dispatchable, DispatchResult, ModuleDispatchError}, - DispatchError, -}; +pub use sp_runtime::{traits::Dispatchable, DispatchError, DispatchResult}; /// A type that cannot be instantiated. pub enum Never {} -/// Result with string error message. This exists for backward compatibility purpose. -pub type Result = DispatchResult<&'static str>; - /// Serializable version of Dispatchable. /// This value can be used as a "function" in an extrinsic. pub trait Callable { @@ -68,14 +62,14 @@ impl Parameter for T where T: Codec + EncodeLike + Clone + Eq + fmt::Debug {} /// /// // Private functions are dispatchable, but not available to other /// // SRML modules. -/// fn my_function(origin, var: u64) -> dispatch::Result { +/// fn my_function(origin, var: u64) -> dispatch::DispatchResult { /// // Your implementation /// Ok(()) /// } /// /// // Public functions are both dispatchable and available to other /// // SRML modules. -/// pub fn my_public_function(origin) -> dispatch::Result { +/// pub fn my_public_function(origin) -> dispatch::DispatchResult { /// // Your implementation /// Ok(()) /// } @@ -95,8 +89,8 @@ impl Parameter for T where T: Codec + EncodeLike + Clone + Eq + fmt::Debug {} /// /// ### Shorthand Example /// -/// The macro automatically expands a shorthand function declaration to return the `Result` type. -/// These functions are the same: +/// The macro automatically expands a shorthand function declaration to return the +/// [`DispatchResult`] type. These functions are the same: /// /// ``` /// # #[macro_use] @@ -106,7 +100,7 @@ impl Parameter for T where T: Codec + EncodeLike + Clone + Eq + fmt::Debug {} /// decl_module! { /// pub struct Module for enum Call where origin: T::Origin { /// -/// fn my_long_function(origin) -> dispatch::Result { +/// fn my_long_function(origin) -> dispatch::DispatchResult { /// // Your implementation /// Ok(()) /// } @@ -130,7 +124,7 @@ impl Parameter for T where T: Codec + EncodeLike + Clone + Eq + fmt::Debug {} /// # use frame_system::{self as system, Trait, ensure_signed, ensure_root}; /// decl_module! { /// pub struct Module for enum Call where origin: T::Origin { -/// fn my_privileged_function(origin) -> dispatch::Result { +/// fn my_privileged_function(origin) -> dispatch::DispatchResult { /// ensure_root(origin)?; /// // Your implementation /// Ok(()) @@ -1043,9 +1037,8 @@ macro_rules! decl_module { #[allow(unreachable_code)] $vis fn $name( $origin: $origin_ty $(, $param: $param_ty )* - ) -> $crate::dispatch::DispatchResult<$error_type> { - use $crate::sp_std::if_std; - if_std! { + ) -> $crate::dispatch::DispatchResult { + $crate::sp_std::if_std! { use $crate::tracing; let span = tracing::span!(tracing::Level::DEBUG, stringify!($name)); let _enter = span.enter(); @@ -1417,8 +1410,7 @@ macro_rules! decl_module { { type Trait = $trait_instance; type Origin = $origin_type; - type Error = $error_type; - fn dispatch(self, _origin: Self::Origin) -> $crate::dispatch::DispatchResult { + fn dispatch(self, _origin: Self::Origin) -> $crate::sp_runtime::DispatchResult { match self { $( $call_type::$fn_name( $( $param_name ),* ) => { @@ -1446,7 +1438,7 @@ macro_rules! decl_module { pub fn dispatch>( d: D, origin: D::Origin - ) -> $crate::dispatch::DispatchResult { + ) -> $crate::sp_runtime::DispatchResult { d.dispatch(origin) } } @@ -1514,11 +1506,10 @@ macro_rules! impl_outer_dispatch { impl $crate::dispatch::Dispatchable for $call_type { type Origin = $origin; type Trait = $call_type; - type Error = $crate::dispatch::DispatchError; fn dispatch( self, origin: $origin, - ) -> $crate::dispatch::DispatchResult<$crate::dispatch::DispatchError> { + ) -> $crate::sp_runtime::DispatchResult { $crate::impl_outer_dispatch! { @DISPATCH_MATCH self @@ -1565,11 +1556,7 @@ macro_rules! impl_outer_dispatch { $origin { $( $generated )* - $call_type::$name(call) => call.dispatch($origin).map_err(|e| { - let mut error: $crate::dispatch::DispatchError = e.into(); - error.module = Some($index); - error - }), + $call_type::$name(call) => call.dispatch($origin), } $index + 1; $( $rest ),* @@ -1895,13 +1882,13 @@ mod tests { } pub mod system { - use super::Result; + use super::*; pub trait Trait { type AccountId; } - pub fn ensure_root(_: R) -> Result { + pub fn ensure_root(_: R) -> DispatchResult { Ok(()) } } @@ -1917,13 +1904,13 @@ mod tests { decl_module! { pub struct Module for enum Call where origin: T::Origin, T::AccountId: From { /// Hi, this is a comment. - fn aux_0(_origin) -> Result { unreachable!() } - fn aux_1(_origin, #[compact] _data: u32,) -> Result { unreachable!() } - fn aux_2(_origin, _data: i32, _data2: String) -> Result { unreachable!() } + fn aux_0(_origin) -> DispatchResult { unreachable!() } + fn aux_1(_origin, #[compact] _data: u32,) -> DispatchResult { unreachable!() } + fn aux_2(_origin, _data: i32, _data2: String) -> DispatchResult { unreachable!() } #[weight = SimpleDispatchInfo::FixedNormal(3)] - fn aux_3(_origin) -> Result { unreachable!() } - fn aux_4(_origin, _data: i32) -> Result { unreachable!() } - fn aux_5(_origin, _data: i32, #[compact] _data2: u32,) -> Result { unreachable!() } + fn aux_3(_origin) -> DispatchResult { unreachable!() } + fn aux_4(_origin, _data: i32) -> DispatchResult { unreachable!() } + fn aux_5(_origin, _data: i32, #[compact] _data2: u32,) -> DispatchResult { unreachable!() } #[weight = SimpleDispatchInfo::FixedNormal(7)] fn on_initialize(n: T::BlockNumber,) { if n.into() == 42 { panic!("on_initialize") } } diff --git a/frame/support/src/error.rs b/frame/support/src/error.rs index d256f0d58b..0120b6da60 100644 --- a/frame/support/src/error.rs +++ b/frame/support/src/error.rs @@ -17,18 +17,19 @@ //! Macro for declaring a module error. #[doc(hidden)] -pub use sp_runtime::traits::LookupError; +pub use sp_runtime::traits::{LookupError, BadOrigin}; +#[doc(hidden)] pub use frame_metadata::{ModuleErrorMetadata, ErrorMetadata, DecodeDifferent}; /// Declare an error type for a runtime module. /// -/// The generated error type inherently has the variants `Other` and `CannotLookup`. `Other` can -/// hold any `&'static str` error message and is present for convenience/backward compatibility. -/// The `CannotLookup` variant indicates that some lookup could not be done. For both variants the -/// error type implements `From<&'static str>` and `From` to make them usable with the -/// try operator. +/// `decl_error!` supports only variants that do not hold any data. The dispatchable +/// functions return [`DispatchResult`](sp_runtime::DispatchResult). The error type +/// implements `From for DispatchResult` to make the error type usable as error +/// in the dispatchable functions. /// -/// `decl_error!` supports only variants that do not hold any data. +/// It is required that the error type is registed in `decl_module!` to make the error +/// exported in the metadata. /// /// # Usage /// @@ -36,7 +37,7 @@ pub use frame_metadata::{ModuleErrorMetadata, ErrorMetadata, DecodeDifferent}; /// # use frame_support::{decl_error, decl_module}; /// decl_error! { /// /// Errors that can occur in my module. -/// pub enum MyError { +/// pub enum MyError for Module { /// /// Hey this is an error message that indicates bla. /// MyCoolErrorMessage, /// /// You are just not cool enough for my module! @@ -44,27 +45,36 @@ pub use frame_metadata::{ModuleErrorMetadata, ErrorMetadata, DecodeDifferent}; /// } /// } /// -/// # use frame_system::{self as system, Trait, ensure_signed}; +/// # use frame_system::{self as system, Trait}; /// -/// // You need to register the error type in `decl_module!` as well. +/// // You need to register the error type in `decl_module!` as well to make the error +/// // exported in the metadata. /// /// decl_module! { /// pub struct Module for enum Call where origin: T::Origin { -/// type Error = MyError; +/// type Error = MyError; /// -/// fn do_something(origin) -> Result<(), MyError> { -/// Err(MyError::YouAreNotCoolEnough) +/// fn do_something(origin) -> frame_support::dispatch::DispatchResult { +/// Err(MyError::::YouAreNotCoolEnough.into()) /// } /// } /// } /// /// # fn main() {} /// ``` +/// +/// For instantiable modules you also need to give the instance generic type and bound to the +/// error declaration. #[macro_export] macro_rules! decl_error { ( $(#[$attr:meta])* - pub enum $error:ident { + pub enum $error:ident + for $module:ident< + $generic:ident: $trait:path + $(, $inst_generic:ident: $instance:path)? + > + { $( $( #[doc = $doc_attr:tt] )* $name:ident @@ -72,33 +82,42 @@ macro_rules! decl_error { $(,)? } ) => { - #[derive(Clone, PartialEq, Eq, $crate::RuntimeDebug)] $(#[$attr])* - pub enum $error { - Other(&'static str), - CannotLookup, + pub enum $error<$generic: $trait $(, $inst_generic: $instance)?> { + #[doc(hidden)] + __Ignore( + $crate::sp_std::marker::PhantomData<($generic $(, $inst_generic)?)>, + $crate::dispatch::Never, + ), $( $( #[doc = $doc_attr] )* $name ),* } - impl $crate::dispatch::ModuleDispatchError for $error { + impl<$generic: $trait $(, $inst_generic: $instance)?> $crate::sp_std::fmt::Debug + for $error<$generic $(, $inst_generic)?> + { + fn fmt(&self, f: &mut $crate::sp_std::fmt::Formatter<'_>) -> $crate::sp_std::fmt::Result { + f.write_str(self.as_str()) + } + } + + impl<$generic: $trait $(, $inst_generic: $instance)?> $error<$generic $(, $inst_generic)?> { fn as_u8(&self) -> u8 { $crate::decl_error! { @GENERATE_AS_U8 self $error {} - 2, + 0, $( $name ),* } } fn as_str(&self) -> &'static str { match self { - $error::Other(err) => err, - $error::CannotLookup => "Can not lookup", + Self::__Ignore(_, _) => unreachable!("`__Ignore` can never be constructed"), $( $error::$name => stringify!($name), )* @@ -106,33 +125,33 @@ macro_rules! decl_error { } } - impl From<&'static str> for $error { - fn from(val: &'static str) -> $error { - $error::Other(val) - } - } - - impl From<$crate::error::LookupError> for $error { - fn from(_: $crate::error::LookupError) -> $error { - $error::CannotLookup - } - } - - impl From<$error> for &'static str { - fn from(err: $error) -> &'static str { - use $crate::dispatch::ModuleDispatchError; + impl<$generic: $trait $(, $inst_generic: $instance)?> From<$error<$generic $(, $inst_generic)?>> + for &'static str + { + fn from(err: $error<$generic $(, $inst_generic)?>) -> &'static str { err.as_str() } } - impl Into<$crate::dispatch::DispatchError> for $error { - fn into(self) -> $crate::dispatch::DispatchError { - use $crate::dispatch::ModuleDispatchError; - $crate::dispatch::DispatchError::new(None, self.as_u8(), Some(self.as_str())) + impl<$generic: $trait $(, $inst_generic: $instance)?> From<$error<$generic $(, $inst_generic)?>> + for $crate::sp_runtime::DispatchError + { + fn from(err: $error<$generic $(, $inst_generic)?>) -> Self { + let index = <$generic::ModuleToIndex as $crate::traits::ModuleToIndex> + ::module_to_index::<$module<$generic $(, $inst_generic)?>>() + .expect("Every active module has an index in the runtime; qed") as u8; + + $crate::sp_runtime::DispatchError::Module { + index, + error: err.as_u8(), + message: Some(err.as_str()), + } } } - impl $crate::error::ModuleErrorMetadata for $error { + impl<$generic: $trait $(, $inst_generic: $instance)?> $crate::error::ModuleErrorMetadata + for $error<$generic $(, $inst_generic)?> + { fn metadata() -> &'static [$crate::error::ErrorMetadata] { &[ $( @@ -174,8 +193,7 @@ macro_rules! decl_error { $index:expr, ) => { match $self { - $error::Other(_) => 0, - $error::CannotLookup => 1, + $error::__Ignore(_, _) => unreachable!("`__Ignore` can never be constructed"), $( $generated )* } } diff --git a/frame/support/src/lib.rs b/frame/support/src/lib.rs index cf6b2472f0..f0357cff2f 100644 --- a/frame/support/src/lib.rs +++ b/frame/support/src/lib.rs @@ -124,7 +124,7 @@ pub use frame_support_procedural::{decl_storage, construct_runtime}; #[macro_export] macro_rules! fail { ( $y:expr ) => {{ - return Err($y); + return Err($y.into()); }} } @@ -168,7 +168,7 @@ macro_rules! assert_noop { #[cfg(feature = "std")] macro_rules! assert_err { ( $x:expr , $y:expr $(,)? ) => { - assert_eq!($x, Err($y)); + assert_eq!($x, Err($y.into())); } } diff --git a/frame/support/src/metadata.rs b/frame/support/src/metadata.rs index c27cc4ac73..ad6a5c797c 100644 --- a/frame/support/src/metadata.rs +++ b/frame/support/src/metadata.rs @@ -240,13 +240,14 @@ mod tests { mod system { use super::*; - pub trait Trait { + pub trait Trait: 'static { const ASSOCIATED_CONST: u64 = 500; type Origin: Into, Self::Origin>> + From>; type AccountId: From + Encode; type BlockNumber: From + Encode; type SomeValue: Get; + type ModuleToIndex: crate::traits::ModuleToIndex; } decl_module! { @@ -286,10 +287,8 @@ mod tests { mod event_module { use crate::dispatch::DispatchResult; - pub trait Trait { - type Origin; + pub trait Trait: super::system::Trait { type Balance; - type BlockNumber; } decl_event!( @@ -302,14 +301,14 @@ mod tests { decl_module! { pub struct Module for enum Call where origin: T::Origin { - type Error = Error; + type Error = Error; - fn aux_0(_origin) -> DispatchResult { unreachable!() } + fn aux_0(_origin) -> DispatchResult { unreachable!() } } } crate::decl_error! { - pub enum Error { + pub enum Error for Module { /// Some user input error UserInputError, /// Something bad happened @@ -372,9 +371,7 @@ mod tests { } impl event_module::Trait for TestRuntime { - type Origin = Origin; type Balance = u32; - type BlockNumber = u32; } impl event_module2::Trait for TestRuntime { @@ -392,6 +389,7 @@ mod tests { type AccountId = u32; type BlockNumber = u32; type SomeValue = SystemValue; + type ModuleToIndex = (); } impl_runtime_metadata!( diff --git a/frame/support/src/traits.rs b/frame/support/src/traits.rs index afc4a4e4f4..379f964d27 100644 --- a/frame/support/src/traits.rs +++ b/frame/support/src/traits.rs @@ -22,7 +22,7 @@ use sp_std::{prelude::*, result, marker::PhantomData, ops::Div, fmt::Debug}; use codec::{FullCodec, Codec, Encode, Decode}; use sp_core::u32_trait::Value as U32; use sp_runtime::{ - ConsensusEngineId, + ConsensusEngineId, DispatchResult, DispatchError, traits::{MaybeSerializeDeserialize, SimpleArithmetic, Saturating}, }; @@ -386,7 +386,7 @@ pub trait Currency { _amount: Self::Balance, reasons: WithdrawReasons, new_balance: Self::Balance, - ) -> result::Result<(), &'static str>; + ) -> DispatchResult; // PUBLIC MUTABLES (DANGEROUS) @@ -399,7 +399,7 @@ pub trait Currency { dest: &AccountId, value: Self::Balance, existence_requirement: ExistenceRequirement, - ) -> result::Result<(), &'static str>; + ) -> DispatchResult; /// Deducts up to `value` from the combined balance of `who`, preferring to deduct from the /// free balance. This function cannot fail. @@ -419,7 +419,7 @@ pub trait Currency { fn deposit_into_existing( who: &AccountId, value: Self::Balance - ) -> result::Result; + ) -> result::Result; /// Similar to deposit_creating, only accepts a `NegativeImbalance` and returns nothing on /// success. @@ -465,7 +465,7 @@ pub trait Currency { value: Self::Balance, reasons: WithdrawReasons, liveness: ExistenceRequirement, - ) -> result::Result; + ) -> result::Result; /// Similar to withdraw, only accepts a `PositiveImbalance` and returns nothing on success. fn settle( @@ -528,7 +528,7 @@ pub trait ReservableCurrency: Currency { /// /// If the free balance is lower than `value`, then no funds will be moved and an `Err` will /// be returned to notify of this. This is different behavior than `unreserve`. - fn reserve(who: &AccountId, value: Self::Balance) -> result::Result<(), &'static str>; + fn reserve(who: &AccountId, value: Self::Balance) -> DispatchResult; /// Moves up to `value` from reserved balance to free balance. This function cannot fail. /// @@ -552,7 +552,7 @@ pub trait ReservableCurrency: Currency { slashed: &AccountId, beneficiary: &AccountId, value: Self::Balance - ) -> result::Result; + ) -> result::Result; } /// An identifier for a lock. Used for disambiguating different locks so that @@ -619,7 +619,7 @@ pub trait VestingCurrency: Currency { locked: Self::Balance, per_block: Self::Balance, starting_block: Self::Moment, - ) -> result::Result<(), &'static str>; + ) -> DispatchResult; /// Remove a vesting schedule for a given account. fn remove_vesting_schedule(who: &AccountId); @@ -777,3 +777,15 @@ pub trait ValidatorRegistration { /// module fn is_registered(id: &ValidatorId) -> bool; } + +/// Something that can convert a given module into the index of the module in the runtime. +/// +/// The index of a module is determined by the position it appears in `construct_runtime!`. +pub trait ModuleToIndex { + /// Convert the given module `M` into an index. + fn module_to_index() -> Option; +} + +impl ModuleToIndex for () { + fn module_to_index() -> Option { Some(0) } +} diff --git a/frame/support/test/tests/decl_error.rs b/frame/support/test/tests/decl_error.rs new file mode 100644 index 0000000000..42a799caad --- /dev/null +++ b/frame/support/test/tests/decl_error.rs @@ -0,0 +1,135 @@ +// Copyright 2019 Parity Technologies (UK) Ltd. +// This file is part of Substrate. + +// Substrate is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Substrate is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Substrate. If not, see . + +#![recursion_limit="128"] + +use sp_runtime::{generic, traits::{BlakeTwo256, Block as _, Verify}, DispatchError}; +use sp_core::{H256, sr25519}; + +mod system; + +pub trait Currency {} + +mod module1 { + use super::*; + + pub trait Trait: system::Trait {} + + frame_support::decl_module! { + pub struct Module, I: Instance = DefaultInstance> for enum Call + where origin: ::Origin + { + pub fn fail(_origin) -> frame_support::dispatch::DispatchResult { + Err(Error::::Something.into()) + } + } + } + + frame_support::decl_error! { + pub enum Error for Module, I: Instance> { + Something + } + } + + frame_support::decl_storage! { + trait Store for Module, I: Instance=DefaultInstance> as Module {} + } +} + +mod module2 { + use super::*; + + pub trait Trait: system::Trait {} + + frame_support::decl_module! { + pub struct Module for enum Call + where origin: ::Origin + { + pub fn fail(_origin) -> frame_support::dispatch::DispatchResult { + Err(Error::::Something.into()) + } + } + } + + frame_support::decl_error! { + pub enum Error for Module { + Something + } + } + + frame_support::decl_storage! { + trait Store for Module as Module {} + } +} + +impl module1::Trait for Runtime {} +impl module1::Trait for Runtime {} +impl module2::Trait for Runtime {} + +pub type Signature = sr25519::Signature; +pub type AccountId = ::Signer; +pub type BlockNumber = u64; +pub type Index = u64; + +impl system::Trait for Runtime { + type Hash = H256; + type Origin = Origin; + type BlockNumber = BlockNumber; + type AccountId = AccountId; + type Event = Event; + type ModuleToIndex = ModuleToIndex; +} + +frame_support::construct_runtime!( + pub enum Runtime where + Block = Block, + NodeBlock = Block, + UncheckedExtrinsic = UncheckedExtrinsic + { + System: system::{Module, Call, Event}, + Module1_1: module1::::{Module, Call, Storage}, + Module2: module2::{Module, Call, Storage}, + Module1_2: module1::::{Module, Call, Storage}, + } +); + +pub type Header = generic::Header; +pub type Block = generic::Block; +pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; + +#[test] +fn check_module1_1_error_type() { + assert_eq!( + Module1_1::fail(system::Origin::::Root.into()), + Err(DispatchError::Module { index: 1, error: 0, message: Some("Something") }), + ); +} + +#[test] +fn check_module1_2_error_type() { + assert_eq!( + Module1_2::fail(system::Origin::::Root.into()), + Err(DispatchError::Module { index: 3, error: 0, message: Some("Something") }), + ); +} + +#[test] +fn check_module2_error_type() { + assert_eq!( + Module2::fail(system::Origin::::Root.into()), + Err(DispatchError::Module { index: 2, error: 0, message: Some("Something") }), + ); +} diff --git a/frame/support/test/tests/instance.rs b/frame/support/test/tests/instance.rs index 835c082a66..cd14736266 100644 --- a/frame/support/test/tests/instance.rs +++ b/frame/support/test/tests/instance.rs @@ -238,6 +238,7 @@ impl system::Trait for Runtime { type BlockNumber = BlockNumber; type AccountId = AccountId; type Event = Event; + type ModuleToIndex = (); } frame_support::construct_runtime!( diff --git a/frame/support/test/tests/issue2219.rs b/frame/support/test/tests/issue2219.rs index 4c9731b498..f6679f3498 100644 --- a/frame/support/test/tests/issue2219.rs +++ b/frame/support/test/tests/issue2219.rs @@ -160,6 +160,7 @@ impl system::Trait for Runtime { type BlockNumber = BlockNumber; type AccountId = AccountId; type Event = Event; + type ModuleToIndex = (); } impl module::Trait for Runtime {} diff --git a/frame/support/test/tests/reserved_keyword/on_initialize.rs b/frame/support/test/tests/reserved_keyword/on_initialize.rs index 9a7ffcf067..e389529bca 100644 --- a/frame/support/test/tests/reserved_keyword/on_initialize.rs +++ b/frame/support/test/tests/reserved_keyword/on_initialize.rs @@ -12,14 +12,14 @@ macro_rules! reserved { pub mod system { use frame_support::dispatch; - pub fn ensure_root(_: R) -> dispatch::Result { + pub fn ensure_root(_: R) -> dispatch::DispatchResult { Ok(()) } } frame_support::decl_module! { pub struct Module for enum Call where origin: T::Origin { - fn $reserved(_origin) -> dispatch::Result { unreachable!() } + fn $reserved(_origin) -> dispatch::DispatchResult { unreachable!() } } } } diff --git a/frame/support/test/tests/system.rs b/frame/support/test/tests/system.rs index e7da24bbab..83786538e6 100644 --- a/frame/support/test/tests/system.rs +++ b/frame/support/test/tests/system.rs @@ -8,6 +8,7 @@ pub trait Trait: 'static + Eq + Clone { type Hash; type AccountId: Encode + EncodeLike + Decode; type Event: From; + type ModuleToIndex: frame_support::traits::ModuleToIndex; } frame_support::decl_module! { @@ -28,7 +29,7 @@ frame_support::decl_event!( ); frame_support::decl_error! { - pub enum Error { + pub enum Error for Module { /// Test error documentation TestError, /// Error documentation diff --git a/frame/system/benches/bench.rs b/frame/system/benches/bench.rs index 5102c56adf..21e9dbb0f2 100644 --- a/frame/system/benches/bench.rs +++ b/frame/system/benches/bench.rs @@ -74,6 +74,7 @@ impl system::Trait for Runtime { type MaximumBlockLength = MaximumBlockLength; type AvailableBlockRatio = AvailableBlockRatio; type Version = (); + type ModuleToIndex = (); } impl module::Trait for Runtime { diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index 1acdc30570..f713811f21 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -75,7 +75,7 @@ //! //! decl_module! { //! pub struct Module for enum Call where origin: T::Origin { -//! pub fn system_module_example(origin) -> dispatch::Result { +//! pub fn system_module_example(origin) -> dispatch::DispatchResult { //! let _sender = ensure_signed(origin)?; //! let _extrinsic_count = >::extrinsic_count(); //! let _parent_hash = >::parent_hash(); @@ -105,7 +105,7 @@ use sp_runtime::{ }, traits::{ self, CheckEqual, SimpleArithmetic, Zero, SignedExtension, Lookup, LookupError, - SimpleBitOps, Hash, Member, MaybeDisplay, EnsureOrigin, SaturatedConversion, + SimpleBitOps, Hash, Member, MaybeDisplay, EnsureOrigin, BadOrigin, SaturatedConversion, MaybeSerialize, MaybeSerializeDeserialize, StaticLookup, One, Bounded, }, }; @@ -113,7 +113,7 @@ use sp_runtime::{ use sp_core::storage::well_known_keys; use frame_support::{ decl_module, decl_event, decl_storage, decl_error, storage, Parameter, - traits::{Contains, Get}, + traits::{Contains, Get, ModuleToIndex}, weights::{Weight, DispatchInfo, DispatchClass, SimpleDispatchInfo}, }; use codec::{Encode, Decode}; @@ -219,6 +219,12 @@ pub trait Trait: 'static + Eq + Clone { /// Get the chain's current version. type Version: Get; + + /// Convert a module to its index in the runtime. + /// + /// Expects the `ModuleToIndex` type that is being generated by `construct_runtime!` in the + /// runtime. For tests it is okay to use `()` as type (returns `0` for each input). + type ModuleToIndex: ModuleToIndex; } pub type DigestOf = generic::Digest<::Hash>; @@ -229,7 +235,7 @@ pub type KeyValue = (Vec, Vec); decl_module! { pub struct Module for enum Call where origin: T::Origin { - type Error = Error; + type Error = Error; /// A big dispatch that will disallow any other transaction to be included. // TODO: this must be preferable available for testing really (not possible at the moment). @@ -319,11 +325,7 @@ decl_event!( decl_error! { /// Error for the System module - pub enum Error { - RequireSignedOrigin, - RequireRootOrigin, - RequireNoOrigin, - } + pub enum Error for Module {} } /// Origin for the System module. @@ -502,32 +504,32 @@ impl EnsureOrigin for EnsureNever { /// Ensure that the origin `o` represents a signed extrinsic (i.e. transaction). /// Returns `Ok` with the account that signed the extrinsic or an `Err` otherwise. -pub fn ensure_signed(o: OuterOrigin) -> Result +pub fn ensure_signed(o: OuterOrigin) -> Result where OuterOrigin: Into, OuterOrigin>> { match o.into() { Ok(RawOrigin::Signed(t)) => Ok(t), - _ => Err(Error::RequireSignedOrigin), + _ => Err(BadOrigin), } } /// Ensure that the origin `o` represents the root. Returns `Ok` or an `Err` otherwise. -pub fn ensure_root(o: OuterOrigin) -> Result<(), Error> +pub fn ensure_root(o: OuterOrigin) -> Result<(), BadOrigin> where OuterOrigin: Into, OuterOrigin>> { match o.into() { Ok(RawOrigin::Root) => Ok(()), - _ => Err(Error::RequireRootOrigin), + _ => Err(BadOrigin), } } /// Ensure that the origin `o` represents an unsigned extrinsic. Returns `Ok` or an `Err` otherwise. -pub fn ensure_none(o: OuterOrigin) -> Result<(), Error> +pub fn ensure_none(o: OuterOrigin) -> Result<(), BadOrigin> where OuterOrigin: Into, OuterOrigin>> { match o.into() { Ok(RawOrigin::None) => Ok(()), - _ => Err(Error::RequireNoOrigin), + _ => Err(BadOrigin), } } @@ -1175,6 +1177,7 @@ mod tests { type AvailableBlockRatio = AvailableBlockRatio; type MaximumBlockLength = MaximumBlockLength; type Version = (); + type ModuleToIndex = (); } impl From for u16 { @@ -1230,7 +1233,7 @@ mod tests { System::initialize(&2, &[0u8; 32].into(), &[0u8; 32].into(), &Default::default()); System::deposit_event(42u16); System::note_applied_extrinsic(&Ok(()), 0, Default::default()); - System::note_applied_extrinsic(&Err(DispatchError::new(Some(1), 2, None)), 0, Default::default()); + System::note_applied_extrinsic(&Err(DispatchError::BadOrigin), 0, Default::default()); System::note_finished_extrinsics(); System::deposit_event(3u16); System::finalize(); diff --git a/frame/timestamp/src/lib.rs b/frame/timestamp/src/lib.rs index f15c0ed627..449e509c23 100644 --- a/frame/timestamp/src/lib.rs +++ b/frame/timestamp/src/lib.rs @@ -69,7 +69,7 @@ //! //! decl_module! { //! pub struct Module for enum Call where origin: T::Origin { -//! pub fn get_time(origin) -> dispatch::Result { +//! pub fn get_time(origin) -> dispatch::DispatchResult { //! let _sender = ensure_signed(origin)?; //! let _now = >::get(); //! Ok(()) @@ -273,6 +273,7 @@ mod tests { type AvailableBlockRatio = AvailableBlockRatio; type MaximumBlockLength = MaximumBlockLength; type Version = (); + type ModuleToIndex = (); } parameter_types! { pub const MinimumPeriod: u64 = 5; diff --git a/frame/transaction-payment/src/lib.rs b/frame/transaction-payment/src/lib.rs index 562e7fe21f..8feb3c6b29 100644 --- a/frame/transaction-payment/src/lib.rs +++ b/frame/transaction-payment/src/lib.rs @@ -291,6 +291,7 @@ mod tests { type MaximumBlockLength = MaximumBlockLength; type AvailableBlockRatio = AvailableBlockRatio; type Version = (); + type ModuleToIndex = (); } parameter_types! { diff --git a/frame/treasury/src/lib.rs b/frame/treasury/src/lib.rs index 49de399b50..ee0e1adc5e 100644 --- a/frame/treasury/src/lib.rs +++ b/frame/treasury/src/lib.rs @@ -66,9 +66,7 @@ use frame_support::traits::{ ReservableCurrency, WithdrawReason }; use sp_runtime::{Permill, ModuleId}; -use sp_runtime::traits::{ - Zero, EnsureOrigin, StaticLookup, AccountIdConversion, Saturating, ModuleDispatchError, -}; +use sp_runtime::traits::{Zero, EnsureOrigin, StaticLookup, AccountIdConversion, Saturating}; use frame_support::weights::SimpleDispatchInfo; use codec::{Encode, Decode}; use frame_system::{self as system, ensure_signed}; @@ -126,7 +124,7 @@ decl_module! { /// Percentage of spare funds (if any) that are burnt per spend period. const Burn: Permill = T::Burn::get(); - type Error = Error; + type Error = Error; fn deposit_event() = default; @@ -145,12 +143,12 @@ decl_module! { #[compact] value: BalanceOf, beneficiary: ::Source ) { - let proposer = ensure_signed(origin).map_err(|e| e.as_str())?; + let proposer = ensure_signed(origin)?; let beneficiary = T::Lookup::lookup(beneficiary)?; let bond = Self::calculate_bond(value); T::Currency::reserve(&proposer, bond) - .map_err(|_| Error::InsufficientProposersBalance)?; + .map_err(|_| Error::::InsufficientProposersBalance)?; let c = Self::proposal_count(); ProposalCount::put(c + 1); @@ -169,7 +167,7 @@ decl_module! { #[weight = SimpleDispatchInfo::FixedOperational(100_000)] fn reject_proposal(origin, #[compact] proposal_id: ProposalIndex) { T::RejectOrigin::ensure_origin(origin).map_err(|e| Into::<&str>::into(e))?; - let proposal = >::take(proposal_id).ok_or(Error::InvalidProposalIndex)?; + let proposal = >::take(proposal_id).ok_or(Error::::InvalidProposalIndex)?; let value = proposal.bond; let imbalance = T::Currency::slash_reserved(&proposal.proposer, value).0; @@ -188,7 +186,7 @@ decl_module! { fn approve_proposal(origin, #[compact] proposal_id: ProposalIndex) { T::ApproveOrigin::ensure_origin(origin).map_err(|e| Into::<&str>::into(e))?; - ensure!(>::exists(proposal_id), Error::InvalidProposalIndex); + ensure!(>::exists(proposal_id), Error::::InvalidProposalIndex); Approvals::mutate(|v| v.push(proposal_id)); } @@ -257,7 +255,7 @@ decl_event!( decl_error! { /// Error for the treasury module. - pub enum Error { + pub enum Error for Module { /// Proposer's balance is too low. InsufficientProposersBalance, /// No proposal at that index. @@ -398,6 +396,7 @@ mod tests { type AvailableBlockRatio = AvailableBlockRatio; type MaximumBlockLength = MaximumBlockLength; type Version = (); + type ModuleToIndex = (); } parameter_types! { pub const ExistentialDeposit: u64 = 1; @@ -484,7 +483,10 @@ mod tests { #[test] fn spend_proposal_fails_when_proposer_poor() { new_test_ext().execute_with(|| { - assert_noop!(Treasury::propose_spend(Origin::signed(2), 100, 3), Error::InsufficientProposersBalance); + assert_noop!( + Treasury::propose_spend(Origin::signed(2), 100, 3), + Error::::InsufficientProposersBalance, + ); }); } @@ -536,21 +538,21 @@ mod tests { assert_ok!(Treasury::propose_spend(Origin::signed(0), 100, 3)); assert_ok!(Treasury::reject_proposal(Origin::ROOT, 0)); - assert_noop!(Treasury::reject_proposal(Origin::ROOT, 0), Error::InvalidProposalIndex); + assert_noop!(Treasury::reject_proposal(Origin::ROOT, 0), Error::::InvalidProposalIndex); }); } #[test] fn reject_non_existant_spend_proposal_fails() { new_test_ext().execute_with(|| { - assert_noop!(Treasury::reject_proposal(Origin::ROOT, 0), Error::InvalidProposalIndex); + assert_noop!(Treasury::reject_proposal(Origin::ROOT, 0), Error::::InvalidProposalIndex); }); } #[test] fn accept_non_existant_spend_proposal_fails() { new_test_ext().execute_with(|| { - assert_noop!(Treasury::approve_proposal(Origin::ROOT, 0), Error::InvalidProposalIndex); + assert_noop!(Treasury::approve_proposal(Origin::ROOT, 0), Error::::InvalidProposalIndex); }); } @@ -561,7 +563,7 @@ mod tests { assert_ok!(Treasury::propose_spend(Origin::signed(0), 100, 3)); assert_ok!(Treasury::reject_proposal(Origin::ROOT, 0)); - assert_noop!(Treasury::approve_proposal(Origin::ROOT, 0), Error::InvalidProposalIndex); + assert_noop!(Treasury::approve_proposal(Origin::ROOT, 0), Error::::InvalidProposalIndex); }); } diff --git a/frame/utility/src/lib.rs b/frame/utility/src/lib.rs index c5400b891e..7f8552c402 100644 --- a/frame/utility/src/lib.rs +++ b/frame/utility/src/lib.rs @@ -68,7 +68,7 @@ mod tests { weights::Weight }; use sp_core::H256; - use sp_runtime::{Perbill, traits::{BlakeTwo256, IdentityLookup}, testing::Header}; + use sp_runtime::{Perbill, traits::{BlakeTwo256, IdentityLookup, BadOrigin}, testing::Header}; impl_outer_origin! { pub enum Origin for Test where system = frame_system {} @@ -108,6 +108,7 @@ mod tests { type MaximumBlockLength = MaximumBlockLength; type AvailableBlockRatio = AvailableBlockRatio; type Version = (); + type ModuleToIndex = (); } parameter_types! { pub const ExistentialDeposit: u64 = 0; @@ -146,10 +147,13 @@ mod tests { new_test_ext().execute_with(|| { assert_eq!(Balances::free_balance(1), 10); assert_eq!(Balances::free_balance(2), 0); - assert_noop!(Utility::batch(Origin::signed(1), vec![ - Call::Balances(pallet_balances::Call::force_transfer(1, 2, 5)), - Call::Balances(pallet_balances::Call::force_transfer(1, 2, 5)) - ]), "RequireRootOrigin"); + assert_noop!( + Utility::batch(Origin::signed(1), vec![ + Call::Balances(pallet_balances::Call::force_transfer(1, 2, 5)), + Call::Balances(pallet_balances::Call::force_transfer(1, 2, 5)) + ]), + BadOrigin, + ); assert_ok!(Utility::batch(Origin::ROOT, vec![ Call::Balances(pallet_balances::Call::force_transfer(1, 2, 5)), Call::Balances(pallet_balances::Call::force_transfer(1, 2, 5)) diff --git a/primitives/runtime/src/lib.rs b/primitives/runtime/src/lib.rs index db039d5b75..986b4bf660 100644 --- a/primitives/runtime/src/lib.rs +++ b/primitives/runtime/src/lib.rs @@ -358,56 +358,76 @@ impl From for DispatchOutcome { } } +/// Result of a module function call; either nothing (functions are only called for "side effects") +/// or an error message. +pub type DispatchResult = sp_std::result::Result<(), DispatchError>; + +/// Reason why a dispatch call failed #[derive(Eq, PartialEq, Clone, Copy, Encode, Decode, RuntimeDebug)] #[cfg_attr(feature = "std", derive(Serialize))] -/// Reason why a dispatch call failed -pub struct DispatchError { - /// Module index, matching the metadata module index - pub module: Option, - /// Module specific error value - pub error: u8, - /// Optional error message. - #[codec(skip)] - pub message: Option<&'static str>, -} - -impl DispatchError { - /// Create a new instance of `DispatchError`. - pub fn new(module: Option, error: u8, message: Option<&'static str>) -> Self { - Self { - module, - error, - message, - } +pub enum DispatchError { + /// Some error occurred. + Other(#[codec(skip)] &'static str), + /// Failed to lookup some data. + CannotLookup, + /// A bad origin. + BadOrigin, + /// A custom error in a module + Module { + /// Module index, matching the metadata module index + index: u8, + /// Module specific error value + error: u8, + /// Optional error message. + #[codec(skip)] + message: Option<&'static str>, + }, +} + +impl From for DispatchError { + fn from(_: crate::traits::LookupError) -> Self { + Self::CannotLookup } } -impl traits::Printable for DispatchError { - fn print(&self) { - "DispatchError".print(); - if let Some(module) = self.module { - module.print(); - } - self.error.print(); - if let Some(msg) = self.message { - msg.print(); - } +impl From for DispatchError { + fn from(_: crate::traits::BadOrigin) -> Self { + Self::BadOrigin } } -impl traits::ModuleDispatchError for &'static str { - fn as_u8(&self) -> u8 { - 0 +impl From<&'static str> for DispatchError { + fn from(err: &'static str) -> DispatchError { + DispatchError::Other(err) } +} - fn as_str(&self) -> &'static str { - self +impl Into<&'static str> for DispatchError { + fn into(self) -> &'static str { + match self { + Self::Other(msg) => msg, + Self::CannotLookup => "Can not lookup", + Self::BadOrigin => "Bad origin", + Self::Module { message, .. } => message.unwrap_or("Unknown module error"), + } } } -impl From<&'static str> for DispatchError { - fn from(err: &'static str) -> DispatchError { - DispatchError::new(None, 0, Some(err)) +impl traits::Printable for DispatchError { + fn print(&self) { + "DispatchError".print(); + match self { + Self::Other(err) => err.print(), + Self::CannotLookup => "Can not lookup".print(), + Self::BadOrigin => "Bad origin".print(), + Self::Module { index, error, message } => { + index.print(); + error.print(); + if let Some(msg) = message { + msg.print(); + } + } + } } } @@ -668,18 +688,18 @@ mod tests { #[test] fn dispatch_error_encoding() { - let error = DispatchError { - module: Some(1), + let error = DispatchError::Module { + index: 1, error: 2, message: Some("error message"), }; let encoded = error.encode(); let decoded = DispatchError::decode(&mut &encoded[..]).unwrap(); - assert_eq!(encoded, vec![1, 1, 2]); + assert_eq!(encoded, vec![3, 1, 2]); assert_eq!( decoded, - DispatchError { - module: Some(1), + DispatchError::Module { + index: 1, error: 2, message: None, }, diff --git a/primitives/runtime/src/traits.rs b/primitives/runtime/src/traits.rs index aee19ea0cc..22cd2814e7 100644 --- a/primitives/runtime/src/traits.rs +++ b/primitives/runtime/src/traits.rs @@ -136,11 +136,11 @@ impl< /// An error type that indicates that the origin is invalid. #[derive(Encode, Decode)] -pub struct InvalidOrigin; +pub struct BadOrigin; -impl From for &'static str { - fn from(_: InvalidOrigin) -> &'static str { - "Invalid origin" +impl From for &'static str { + fn from(_: BadOrigin) -> &'static str { + "Bad origin" } } @@ -149,8 +149,8 @@ pub trait EnsureOrigin { /// A return type. type Success; /// Perform the origin check. - fn ensure_origin(o: OuterOrigin) -> result::Result { - Self::try_origin(o).map_err(|_| InvalidOrigin) + fn ensure_origin(o: OuterOrigin) -> result::Result { + Self::try_origin(o).map_err(|_| BadOrigin) } /// Perform the origin check. fn try_origin(o: OuterOrigin) -> result::Result; @@ -668,10 +668,6 @@ impl Checkable for T { } } -/// Result of a module function call; either nothing (functions are only called for "side effects") -/// or an error message. -pub type DispatchResult = result::Result<(), Error>; - /// A lazy call (module function and argument values) that can be executed via its `dispatch` /// method. pub trait Dispatchable { @@ -681,10 +677,8 @@ pub trait Dispatchable { type Origin; /// ... type Trait; - /// The error type returned by this dispatchable. - type Error: Into; /// Actually dispatch this call and result the result of it. - fn dispatch(self, origin: Self::Origin) -> DispatchResult; + fn dispatch(self, origin: Self::Origin) -> crate::DispatchResult; } /// Means by which a transaction may be extended. This type embodies both the data and the logic @@ -789,17 +783,6 @@ pub trait SignedExtension: Codec + Debug + Sync + Send + Clone + Eq + PartialEq fn post_dispatch(_pre: Self::Pre, _info: Self::DispatchInfo, _len: usize) { } } -/// An error that is returned by a dispatchable function of a module. -pub trait ModuleDispatchError { - /// Convert this error to a `u8`. - /// - /// The `u8` corresponds to the index of the variant in the error enum. - fn as_u8(&self) -> u8; - - /// Convert the error to a `&'static str`. - fn as_str(&self) -> &'static str; -} - #[impl_for_tuples(1, 12)] impl SignedExtension for Tuple { for_tuples!( where #( Tuple: SignedExtension )* ); diff --git a/test-utils/runtime/src/lib.rs b/test-utils/runtime/src/lib.rs index 2a0cfe454f..e3b34881c3 100644 --- a/test-utils/runtime/src/lib.rs +++ b/test-utils/runtime/src/lib.rs @@ -374,6 +374,7 @@ impl frame_system::Trait for Runtime { type MaximumBlockLength = MaximumBlockLength; type AvailableBlockRatio = AvailableBlockRatio; type Version = (); + type ModuleToIndex = (); } impl pallet_timestamp::Trait for Runtime { -- GitLab From 5a8851c4636fdc7a3279c8e870fc54b83b2b1623 Mon Sep 17 00:00:00 2001 From: Ashley Date: Thu, 19 Dec 2019 14:02:07 +0100 Subject: [PATCH 168/172] Update grafana-data-source to tokio 0.2 (#4441) --- Cargo.lock | 123 +++++++++----------- utils/grafana-data-source/Cargo.toml | 6 +- utils/grafana-data-source/src/database.rs | 2 +- utils/grafana-data-source/src/networking.rs | 4 +- utils/grafana-data-source/src/server.rs | 12 +- 5 files changed, 63 insertions(+), 84 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f8afee75dc..46d59553a4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1685,15 +1685,13 @@ dependencies = [ "derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)", "futures-timer 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-util-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "hyper 0.13.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)", + "hyper 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1725,22 +1723,20 @@ dependencies = [ [[package]] name = "h2" -version = "0.2.0-alpha.3" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-sink-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-util-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "string 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-codec 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-sync 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-util 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1854,6 +1850,16 @@ dependencies = [ "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "http" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "http-body" version = "0.1.0" @@ -1867,11 +1873,11 @@ dependencies = [ [[package]] name = "http-body" -version = "0.2.0-alpha.3" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1936,27 +1942,23 @@ dependencies = [ [[package]] name = "hyper" -version = "0.13.0-alpha.4" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-channel-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-util-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "h2 0.2.0-alpha.3 (registry+https://github.com/rust-lang/crates.io-index)", - "http 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", - "http-body 0.2.0-alpha.3 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-channel 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "h2 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "http-body 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "pin-project 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-sync 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tower-make 0.3.0-alpha.2a (registry+https://github.com/rust-lang/crates.io-index)", - "tower-service 0.3.0-alpha.2 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "tower-service 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "want 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -7051,6 +7053,8 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "pin-project-lite 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -7074,18 +7078,6 @@ dependencies = [ "tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "tokio-codec" -version = "0.2.0-alpha.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-sink-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-io 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "tokio-current-thread" version = "0.1.6" @@ -7145,18 +7137,6 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "tokio-io" -version = "0.2.0-alpha.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core-preview 0.3.0-alpha.19 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "pin-project 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "tokio-reactor" version = "0.1.11" @@ -7289,25 +7269,29 @@ dependencies = [ ] [[package]] -name = "toml" -version = "0.5.5" +name = "tokio-util" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-sink 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "pin-project-lite 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "tower-make" -version = "0.3.0-alpha.2a" +name = "toml" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "tokio-io 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tower-service 0.3.0-alpha.2 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tower-service" -version = "0.3.0-alpha.2" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -8258,7 +8242,7 @@ dependencies = [ "checksum globset 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "925aa2cac82d8834e2b2a4415b6f6879757fb5c0928fc445ae76461a12eed8f2" "checksum goblin 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "88a79ef1f0dad46fd78075b6f80f92d97710eddf87b3e18a15a66761e8942672" "checksum h2 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)" = "a5b34c246847f938a410a03c5458c7fee2274436675e76d8b903c08efc29c462" -"checksum h2 0.2.0-alpha.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0f107db1419ef8271686187b1a5d47c6431af4a7f4d98b495e7b7fc249bb0a78" +"checksum h2 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b9433d71e471c1736fd5a61b671fc0b148d7a2992f666c958d03cd8feb3b88d1" "checksum hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d23bd4e7b5eda0d0f3a307e8b381fdc8ba9000f26fbe912250c0a4cc3956364a" "checksum hash256-std-hasher 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)" = "92c171d55b98633f4ed3860808f004099b36c1cc29c42cfc53aa8591b21efcf2" "checksum hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3bae29b6653b3412c2e71e9d486db9f9df5d701941d86683005efb9f2d28e3da" @@ -8273,13 +8257,14 @@ dependencies = [ "checksum hmac 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5dcb5e64cda4c23119ab41ba960d1e170a774c8e4b9d9e6a9bc18aabf5e59695" "checksum hmac-drbg 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c6e570451493f10f6581b48cdd530413b63ea9e780f544bfd3bdcaa0d89d1a7b" "checksum http 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)" = "d6ccf5ede3a895d8856620237b2f02972c1bbc78d2965ad7fe8838d4a0ed41f0" +"checksum http 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b708cc7f06493459026f53b9a61a7a121a5d1ec6238dee58ea4941132b30156b" "checksum http-body 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6741c859c1b2463a423a1dbce98d418e6c3c3fc720fb0d45528657320920292d" -"checksum http-body 0.2.0-alpha.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1f3aef6f3de2bd8585f5b366f3f550b5774500b4764d00cf00f903c95749eec3" +"checksum http-body 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "13d5ff830006f7646652e057693569bfe0d51760c0085a071769d142a205111b" "checksum httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" "checksum humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" "checksum hyper 0.10.16 (registry+https://github.com/rust-lang/crates.io-index)" = "0a0652d9a2609a968c14be1a9ea00bf4b1d64e2e1f53a1b51b6fff3a6e829273" "checksum hyper 0.12.35 (registry+https://github.com/rust-lang/crates.io-index)" = "9dbe6ed1438e1f8ad955a4701e9a944938e9519f6888d12d8558b645e247d5f6" -"checksum hyper 0.13.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)" = "2d05aa523087ac0b9d8b93dd80d5d482a697308ed3b0dca7b0667511a7fa7cdc" +"checksum hyper 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8bf49cfb32edee45d890537d9057d1b02ed55f53b7b6a30bae83a38c9231749e" "checksum hyper-rustls 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)" = "719d85c7df4a7f309a77d145340a063ea929dcb2e025bae46a80345cffec2952" "checksum hyper-tls 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3a800d6aa50af4b5850b2b0f659625ce9504df908e9733b635720483be26174f" "checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" @@ -8555,14 +8540,12 @@ dependencies = [ "checksum tokio 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "bcced6bb623d4bff3739c176c415f13c418f426395c169c9c3cd9a492c715b16" "checksum tokio-buf 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8fb220f46c53859a4b7ec083e41dec9778ff0b1851c0942b211edb89e0ccdc46" "checksum tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5c501eceaf96f0e1793cf26beb63da3d11c738c4a943fdf3746d81d64684c39f" -"checksum tokio-codec 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9f5d22fd1e84bd4045d28813491cb7d7caae34d45c80517c2213f09a85e8787a" "checksum tokio-current-thread 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "d16217cad7f1b840c5a97dfb3c43b0c871fef423a6e8d2118c604e843662a443" "checksum tokio-dns-unofficial 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "82c65483db54eb91b4ef3a9389a3364558590faf30ce473141707c0e16fda975" "checksum tokio-executor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "ca6df436c42b0c3330a82d855d2ef017cd793090ad550a6bc2184f4b933532ab" "checksum tokio-executor 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9ee9ceecf69145923834ea73f32ba40c790fd877b74a7817dd0b089f1eb9c7c8" "checksum tokio-fs 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "3fe6dc22b08d6993916647d108a1a7d15b9cd29c4f4496c62b92c45b5041b7af" "checksum tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "5090db468dad16e1a7a54c8c67280c5e4b544f3d3e018f0b913b400261f85926" -"checksum tokio-io 0.2.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)" = "112784d5543df30660b04a72ca423bfbd90e8bb32f94dcf610f15401218b22c5" "checksum tokio-reactor 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "6732fe6b53c8d11178dcb77ac6d9682af27fc6d4cb87789449152e5377377146" "checksum tokio-rustls 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1df2fa53ac211c136832f530ccb081af9af891af22d685a9493e232c7a359bc2" "checksum tokio-sync 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "d06554cce1ae4a50f42fba8023918afa931413aded705b560e29600ccf7c6d76" @@ -8573,9 +8556,9 @@ dependencies = [ "checksum tokio-tls 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "354b8cd83825b3c20217a9dc174d6a0c67441a2fae5c41bcb1ea6679f6ae0f7c" "checksum tokio-udp 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f02298505547f73e60f568359ef0d016d5acd6e830ab9bc7c4a5b3403440121b" "checksum tokio-uds 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "037ffc3ba0e12a0ab4aca92e5234e0dedeb48fddf6ccd260f1f150a36a9f2445" +"checksum tokio-util 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "571da51182ec208780505a32528fc5512a8fe1443ab960b3f2f3ef093cd16930" "checksum toml 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "01d1404644c8b12b16bfcffa4322403a91a451584daaaa7c28d3152e6cbc98cf" -"checksum tower-make 0.3.0-alpha.2a (registry+https://github.com/rust-lang/crates.io-index)" = "316d47dd40cde4ac5d88110eaf9a10a4e2a68612d9c056cd2aa24e37dcb484cd" -"checksum tower-service 0.3.0-alpha.2 (registry+https://github.com/rust-lang/crates.io-index)" = "63ff37396cd966ce43bea418bfa339f802857495f797dafa00bea5b7221ebdfa" +"checksum tower-service 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e987b6bf443f4b5b3b6f38704195592cca41c5bb7aedd3c3693c7081f8289860" "checksum tracing 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "ff4e4f59e752cb3beb5b61c6d5e11191c7946231ba84faec2902c9efdd8691c5" "checksum tracing-attributes 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a4263b12c3d3c403274493eb805966093b53214124796552d674ca1dd5d27c2b" "checksum tracing-core 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "bc913647c520c959b6d21e35ed8fa6984971deca9f0a2fcb8c51207e0c56af1d" diff --git a/utils/grafana-data-source/Cargo.toml b/utils/grafana-data-source/Cargo.toml index b6503dec6c..76bf7d5988 100644 --- a/utils/grafana-data-source/Cargo.toml +++ b/utils/grafana-data-source/Cargo.toml @@ -8,11 +8,9 @@ edition = "2018" [dependencies] log = "0.4.8" -hyper = { version = "0.13.0-alpha.4", default-features = false, features = ["unstable-stream"] } -tokio-io = "0.2.0-alpha.6" -tokio-executor = "0.2.0-alpha.6" +hyper = { version = "0.13.1", default-features = false, features = ["stream"] } +tokio = "0.2" futures-util = { version = "0.3.1", default-features = false, features = ["io"] } -futures-util-alpha = { package = "futures-util-preview", default-features = false, version = "0.3.0-alpha.19" } serde_json = "1" serde = { version = "1", features = ["derive"] } chrono = { version = "0.4", features = ["serde"] } diff --git a/utils/grafana-data-source/src/database.rs b/utils/grafana-data-source/src/database.rs index 21c6ed5b0b..55b48123fa 100644 --- a/utils/grafana-data-source/src/database.rs +++ b/utils/grafana-data-source/src/database.rs @@ -121,7 +121,7 @@ impl Datapoint { }) } - fn make_absolute(&self, base_timestamp: i64) -> (f32, i64) { + fn make_absolute(self, base_timestamp: i64) -> (f32, i64) { (self.value, base_timestamp + self.delta_timestamp as i64) } } diff --git a/utils/grafana-data-source/src/networking.rs b/utils/grafana-data-source/src/networking.rs index 66362e4e68..f5bbd21d57 100644 --- a/utils/grafana-data-source/src/networking.rs +++ b/utils/grafana-data-source/src/networking.rs @@ -33,7 +33,7 @@ impl hyper::server::accept::Accept for Incoming<'_> { pub struct TcpStream(pub async_std::net::TcpStream); -impl tokio_io::AsyncRead for TcpStream { +impl tokio::io::AsyncRead for TcpStream { fn poll_read( self: Pin<&mut Self>, cx: &mut Context, @@ -44,7 +44,7 @@ impl tokio_io::AsyncRead for TcpStream { } } -impl tokio_io::AsyncWrite for TcpStream { +impl tokio::io::AsyncWrite for TcpStream { fn poll_write( self: Pin<&mut Self>, cx: &mut Context, diff --git a/utils/grafana-data-source/src/server.rs b/utils/grafana-data-source/src/server.rs index 37717fa244..6553a7b9e0 100644 --- a/utils/grafana-data-source/src/server.rs +++ b/utils/grafana-data-source/src/server.rs @@ -17,7 +17,7 @@ use serde::{Serialize, de::DeserializeOwned}; use hyper::{Body, Request, Response, header, service::{service_fn, make_service_fn}, Server}; use chrono::{Duration, Utc}; -use futures_util::{FutureExt, future::{Future, select, Either}}; +use futures_util::{FutureExt, TryStreamExt, future::{Future, select, Either}}; use futures_timer::Delay; use crate::{DATABASE, Error, types::{Target, Query, TimeseriesData, Range}}; @@ -63,9 +63,8 @@ async fn map_request_to_response(req: Request, transformation Res: Serialize, T: Fn(Req) -> Res + Send + Sync + 'static { - use futures_util_alpha::TryStreamExt; - let body = req.into_body() + .map_ok(|bytes| bytes.to_vec()) .try_concat() .await .map_err(Error::Hyper)?; @@ -85,14 +84,13 @@ async fn map_request_to_response(req: Request, transformation pub struct Executor; #[cfg(not(target_os = "unknown"))] -impl tokio_executor::TypedExecutor for Executor +impl hyper::rt::Executor for Executor where T: Future + Send + 'static, T::Output: Send + 'static, { - fn spawn(&mut self, future: T) -> Result<(), tokio_executor::SpawnError> { + fn execute(&self, future: T) { async_std::task::spawn(future); - Ok(()) } } @@ -118,7 +116,7 @@ pub async fn run_server(mut address: std::net::SocketAddr) -> Result<(), Error> address.set_port(0); continue; }, - _ => Err(err)?, + _ => return Err(err.into()), } } }; -- GitLab From 36c7fcfa24f54b06bb4c7a32e7627be35bdd80ef Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Thu, 19 Dec 2019 14:03:00 +0100 Subject: [PATCH 169/172] Fix Fees in Substrate (#4421) * Fix fees * Add comment to explain saturated multiply accumulate * Fix final fee calculation * Fix doc * improve doc * grumble * Update tests * Fix executor tests --- bin/node/executor/src/lib.rs | 12 +-- frame/transaction-payment/src/lib.rs | 133 ++++++++++++++++++++++++--- 2 files changed, 125 insertions(+), 20 deletions(-) diff --git a/bin/node/executor/src/lib.rs b/bin/node/executor/src/lib.rs index e69667c94d..2c90371821 100644 --- a/bin/node/executor/src/lib.rs +++ b/bin/node/executor/src/lib.rs @@ -87,14 +87,14 @@ mod tests { /// Default transfer fee fn transfer_fee(extrinsic: &E, fee_multiplier: Fixed64) -> Balance { - let length_fee = TransactionBaseFee::get() + - TransactionByteFee::get() * - (extrinsic.encode().len() as Balance); + let length_fee = TransactionByteFee::get() * (extrinsic.encode().len() as Balance); let weight = default_transfer_call().get_dispatch_info().weight; let weight_fee = ::WeightToFee::convert(weight); - fee_multiplier.saturated_multiply_accumulate(length_fee + weight_fee) + TransferFee::get() + let base_fee = TransactionBaseFee::get(); + + base_fee + fee_multiplier.saturated_multiply_accumulate(length_fee + weight_fee) + TransferFee::get() } fn default_transfer_call() -> pallet_balances::Call { @@ -537,7 +537,7 @@ mod tests { }, EventRecord { phase: Phase::ApplyExtrinsic(1), - event: Event::pallet_treasury(pallet_treasury::RawEvent::Deposit(1984780231392)), + event: Event::pallet_treasury(pallet_treasury::RawEvent::Deposit(1984788199392)), topics: vec![], }, EventRecord { @@ -561,7 +561,7 @@ mod tests { }, EventRecord { phase: Phase::ApplyExtrinsic(2), - event: Event::pallet_treasury(pallet_treasury::RawEvent::Deposit(1984780231392)), + event: Event::pallet_treasury(pallet_treasury::RawEvent::Deposit(1984788199392)), topics: vec![], }, EventRecord { diff --git a/frame/transaction-payment/src/lib.rs b/frame/transaction-payment/src/lib.rs index 8feb3c6b29..60cd5716d5 100644 --- a/frame/transaction-payment/src/lib.rs +++ b/frame/transaction-payment/src/lib.rs @@ -140,12 +140,17 @@ impl ChargeTransactionPayment { /// Compute the final fee value for a particular transaction. /// /// The final fee is composed of: - /// - _length-fee_: This is the amount paid merely to pay for size of the transaction. - /// - _weight-fee_: This amount is computed based on the weight of the transaction. Unlike + /// - _base_fee_: This is the minimum amount a user pays for a transaction. + /// - _len_fee_: This is the amount paid merely to pay for size of the transaction. + /// - _weight_fee_: This amount is computed based on the weight of the transaction. Unlike /// size-fee, this is not input dependent and reflects the _complexity_ of the execution /// and the time it consumes. + /// - _targeted_fee_adjustment_: This is a multiplier that can tune the final fee based on + /// the congestion of the network. /// - (optional) _tip_: if included in the transaction, it will be added on top. Only signed /// transactions can have a tip. + /// + /// final_fee = base_fee + targeted_fee_adjustment(len_fee + weight_fee) + tip; fn compute_fee( len: u32, info: ::DispatchInfo, @@ -156,9 +161,8 @@ impl ChargeTransactionPayment { { if info.pays_fee { let len = >::from(len); - let base = T::TransactionBaseFee::get(); let per_byte = T::TransactionByteFee::get(); - let len_fee = base.saturating_add(per_byte.saturating_mul(len)); + let len_fee = per_byte.saturating_mul(len); let weight_fee = { // cap the weight to the maximum defined in runtime, otherwise it will be the `Bounded` @@ -167,12 +171,16 @@ impl ChargeTransactionPayment { T::WeightToFee::convert(capped_weight) }; - // everything except for tip - let basic_fee = len_fee.saturating_add(weight_fee); - let fee_update = NextFeeMultiplier::get(); - let adjusted_fee = fee_update.saturated_multiply_accumulate(basic_fee); + // the adjustable part of the fee + let adjustable_fee = len_fee.saturating_add(weight_fee); + let targeted_fee_adjustment = NextFeeMultiplier::get(); + // adjusted_fee = adjustable_fee + (adjustable_fee * targeted_fee_adjustment) + let adjusted_fee = targeted_fee_adjustment.saturated_multiply_accumulate(adjustable_fee); + + let base_fee = T::TransactionBaseFee::get(); + let final_fee = base_fee.saturating_add(adjusted_fee).saturating_add(tip); - adjusted_fee.saturating_add(tip) + final_fee } else { tip } @@ -508,7 +516,7 @@ mod tests { .pre_dispatch(&1, CALL, info_from_weight(3), len) .is_ok() ); - assert_eq!(Balances::free_balance(&1), 100 - 10 - (5 + 10 + 3) * 3 / 2); + assert_eq!(Balances::free_balance(&1), 100 - 10 - 5 - (10 + 3) * 3 / 2); }) } @@ -534,14 +542,111 @@ mod tests { RuntimeDispatchInfo { weight: info.weight, class: info.class, - partial_fee: ( + partial_fee: 5 /* base */ - + len as u64 /* len * 1 */ - + info.weight.min(MaximumBlockWeight::get()) as u64 * 2 /* weight * weight_to_fee */ - ) * 3 / 2 + + ( + len as u64 /* len * 1 */ + + info.weight.min(MaximumBlockWeight::get()) as u64 * 2 /* weight * weight_to_fee */ + ) * 3 / 2 }, ); }); } + + #[test] + fn compute_fee_works_without_multiplier() { + ExtBuilder::default() + .fees(100, 10, 1) + .balance_factor(0) + .build() + .execute_with(|| + { + // Next fee multiplier is zero + assert_eq!(NextFeeMultiplier::get(), Fixed64::from_natural(0)); + + // Tip only, no fees works + let dispatch_info = DispatchInfo { + weight: 0, + class: DispatchClass::Operational, + pays_fee: false, + }; + assert_eq!(ChargeTransactionPayment::::compute_fee(0, dispatch_info, 10), 10); + // No tip, only base fee works + let dispatch_info = DispatchInfo { + weight: 0, + class: DispatchClass::Operational, + pays_fee: true, + }; + assert_eq!(ChargeTransactionPayment::::compute_fee(0, dispatch_info, 0), 100); + // Tip + base fee works + assert_eq!(ChargeTransactionPayment::::compute_fee(0, dispatch_info, 69), 169); + // Len (byte fee) + base fee works + assert_eq!(ChargeTransactionPayment::::compute_fee(42, dispatch_info, 0), 520); + // Weight fee + base fee works + let dispatch_info = DispatchInfo { + weight: 1000, + class: DispatchClass::Operational, + pays_fee: true, + }; + assert_eq!(ChargeTransactionPayment::::compute_fee(0, dispatch_info, 0), 1100); + }); + } + + #[test] + fn compute_fee_works_with_multiplier() { + ExtBuilder::default() + .fees(100, 10, 1) + .balance_factor(0) + .build() + .execute_with(|| + { + // Add a next fee multiplier + NextFeeMultiplier::put(Fixed64::from_rational(1, 2)); // = 1/2 = .5 + // Base fee is unaffected by multiplier + let dispatch_info = DispatchInfo { + weight: 0, + class: DispatchClass::Operational, + pays_fee: true, + }; + assert_eq!(ChargeTransactionPayment::::compute_fee(0, dispatch_info, 0), 100); + + // Everything works together :) + let dispatch_info = DispatchInfo { + weight: 123, + class: DispatchClass::Operational, + pays_fee: true, + }; + // 123 weight, 456 length, 100 base + // adjustable fee = (123 * 1) + (456 * 10) = 4683 + // adjusted fee = (4683 * .5) + 4683 = 7024.5 -> 7024 + // final fee = 100 + 7024 + 789 tip = 7913 + assert_eq!(ChargeTransactionPayment::::compute_fee(456, dispatch_info, 789), 7913); + }); + } + + #[test] + fn compute_fee_does_not_overflow() { + ExtBuilder::default() + .fees(100, 10, 1) + .balance_factor(0) + .build() + .execute_with(|| + { + // Overflow is handled + let dispatch_info = DispatchInfo { + weight: ::max_value(), + class: DispatchClass::Operational, + pays_fee: true, + }; + assert_eq!( + ChargeTransactionPayment::::compute_fee( + ::max_value(), + dispatch_info, + ::max_value() + ), + ::max_value() + ); + }); + } } -- GitLab From 4b7f7770337c1b3069ee4700024b5552366250c7 Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Thu, 19 Dec 2019 17:57:20 +0100 Subject: [PATCH 170/172] Add new event for registering deposits. (#4459) --- frame/balances/src/lib.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frame/balances/src/lib.rs b/frame/balances/src/lib.rs index 5367d7413b..4b53f71898 100644 --- a/frame/balances/src/lib.rs +++ b/frame/balances/src/lib.rs @@ -267,6 +267,8 @@ decl_event!( Transfer(AccountId, AccountId, Balance, Balance), /// A balance was set by root (who, free, reserved). BalanceSet(AccountId, Balance, Balance), + /// Some amount was deposited (e.g. for transaction fees). + Deposit(AccountId, Balance), } ); @@ -587,7 +589,7 @@ impl, I: Instance> Module { T::OnFreeBalanceZero::on_free_balance_zero(who); let mut reserved_balance = Self::reserved_balance(who); - + if !dust.is_zero() { if reserved_balance >= T::ExistentialDeposit::get() { // any individual account cannot cause overflow in balance. -- GitLab From ab217bf3513a8f6c287b33dedc5bce0bd9ec863b Mon Sep 17 00:00:00 2001 From: Stanislav Tkach Date: Thu, 19 Dec 2019 18:57:42 +0200 Subject: [PATCH 171/172] Warn about using --rpc-external and --ws-external options (#4448) * Warn about using --rpc-external and --ws-external options * Apply review comments * Remove links placeholders * Add links to wiki --- client/cli/src/lib.rs | 25 +++++++++++++++++++++++-- client/cli/src/params.rs | 20 ++++++++++++++++++-- 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/client/cli/src/lib.rs b/client/cli/src/lib.rs index c2e11b56ca..41456fc8c4 100644 --- a/client/cli/src/lib.rs +++ b/client/cli/src/lib.rs @@ -890,8 +890,8 @@ where } }); - let rpc_interface: &str = if cli.rpc_external { "0.0.0.0" } else { "127.0.0.1" }; - let ws_interface: &str = if cli.ws_external { "0.0.0.0" } else { "127.0.0.1" }; + let rpc_interface: &str = interface_str(cli.rpc_external, cli.unsafe_rpc_external, cli.validator)?; + let ws_interface: &str = interface_str(cli.ws_external, cli.unsafe_ws_external, cli.validator)?; let grafana_interface: &str = if cli.grafana_external { "0.0.0.0" } else { "127.0.0.1" }; config.rpc_http = Some(parse_address(&format!("{}:{}", rpc_interface, 9933), cli.rpc_port)?); @@ -931,6 +931,27 @@ where Ok(config) } +fn interface_str( + is_external: bool, + is_unsafe_external: bool, + is_validator: bool, +) -> Result<&'static str, error::Error> { + if is_external && is_validator { + return Err(error::Error::Input("--rpc-external and --ws-external options shouldn't be \ + used if the node is running as a validator. Use `--unsafe-rpc-external` if you understand \ + the risks. See the options description for more information.".to_owned())); + } + + if is_external || is_unsafe_external { + log::warn!("It isn't safe to expose RPC publicly without a proxy server that filters \ + available set of RPC methods."); + + Ok("0.0.0.0") + } else { + Ok("127.0.0.1") + } +} + /// Creates a configuration including the database path. pub fn create_config_with_db_path( spec_factory: S, cli: &SharedParams, version: &VersionInfo, diff --git a/client/cli/src/params.rs b/client/cli/src/params.rs index 10be3f0c1b..6cb425bd74 100644 --- a/client/cli/src/params.rs +++ b/client/cli/src/params.rs @@ -438,16 +438,32 @@ pub struct RunCmd { /// Listen to all RPC interfaces. /// - /// Default is local. + /// Default is local. Note: not all RPC methods are safe to be exposed publicly. Use a RPC proxy + /// server to filter out dangerous methods. More details: https://github.com/paritytech/substrate/wiki/Public-RPC. + /// Use `--unsafe-rpc-external` to suppress the warning if you understand the risks. #[structopt(long = "rpc-external")] pub rpc_external: bool, + /// Listen to all RPC interfaces. + /// + /// Same as `--rpc-external`. + #[structopt(long = "unsafe-rpc-external")] + pub unsafe_rpc_external: bool, + /// Listen to all Websocket interfaces. /// - /// Default is local. + /// Default is local. Note: not all RPC methods are safe to be exposed publicly. Use a RPC proxy + /// server to filter out dangerous methods. More details: https://github.com/paritytech/substrate/wiki/Public-RPC. + /// Use `--unsafe-ws-external` to suppress the warning if you understand the risks. #[structopt(long = "ws-external")] pub ws_external: bool, + /// Listen to all Websocket interfaces. + /// + /// Same as `--ws-external`. + #[structopt(long = "unsafe-ws-external")] + pub unsafe_ws_external: bool, + /// Listen to all Grafana data source interfaces. /// /// Default is local. -- GitLab From d8197745e5f559b3fdc9a5c3148c9e531492ba07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Silva?= Date: Thu, 19 Dec 2019 17:38:01 +0000 Subject: [PATCH 172/172] babe: remove unused slot_duration variable (#4461) --- client/consensus/babe/src/lib.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/client/consensus/babe/src/lib.rs b/client/consensus/babe/src/lib.rs index de06f63848..20f06332e2 100644 --- a/client/consensus/babe/src/lib.rs +++ b/client/consensus/babe/src/lib.rs @@ -494,8 +494,6 @@ impl sc_consensus_slots::SimpleSlotWorker for BabeWork slot_lenience, slot_lenience, BACKOFF_STEP); } - let slot_duration = slot_info.duration << (slot_lenience / BACKOFF_STEP); - let slot_lenience = Duration::from_secs(slot_duration); Some(slot_lenience + slot_remaining) } -- GitLab

, P: Pair + Send + Sync + 'static, @@ -661,7 +661,7 @@ fn initialize_authorities_cache(client: &C) -> Result<(), ConsensusErro return Ok(()); } - let map_err = |error| consensus_common::Error::from(consensus_common::Error::ClientImport( + let map_err = |error| sp_consensus::Error::from(sp_consensus::Error::ClientImport( format!( "Error initializing authorities cache: {}", error, @@ -687,7 +687,7 @@ fn authorities(client: &C, at: &BlockId) -> Result, Consensus .and_then(|(_, _, v)| Decode::decode(&mut &v[..]).ok()) ) .or_else(|| AuraApi::authorities(&*client.runtime_api(), at).ok()) - .ok_or_else(|| consensus_common::Error::InvalidAuthoritiesSet.into()) + .ok_or_else(|| sp_consensus::Error::InvalidAuthoritiesSet.into()) } /// The Aura import queue type. @@ -697,12 +697,12 @@ pub type AuraImportQueue = BasicQueue; fn register_aura_inherent_data_provider( inherent_data_providers: &InherentDataProviders, slot_duration: u64, -) -> Result<(), consensus_common::Error> { +) -> Result<(), sp_consensus::Error> { if !inherent_data_providers.has_provider(&INHERENT_IDENTIFIER) { inherent_data_providers .register_provider(InherentDataProvider::new(slot_duration)) .map_err(Into::into) - .map_err(consensus_common::Error::InherentData) + .map_err(sp_consensus::Error::InherentData) } else { Ok(()) } @@ -717,7 +717,7 @@ pub fn import_queue( client: Arc, inherent_data_providers: InherentDataProviders, transaction_pool: Option>, -) -> Result, consensus_common::Error> where +) -> Result, sp_consensus::Error> where B: BlockT, C: 'static + ProvideRuntimeApi + BlockOf + ProvideCache + Send + Sync + AuxStore, C::Api: BlockBuilderApi + AuraApi> + ApiExt, @@ -747,24 +747,23 @@ pub fn import_queue( #[cfg(test)] mod tests { use super::*; - use consensus_common::NoNetwork as DummyOracle; + use sp_consensus::NoNetwork as DummyOracle; use sc_network_test::{Block as TestBlock, *}; use sp_runtime::traits::{Block as BlockT, DigestFor}; use sc_network::config::ProtocolConfig; use parking_lot::Mutex; use tokio::runtime::current_thread; - use keyring::sr25519::Keyring; - use client::BlockchainEvents; - use test_client; - use aura_primitives::sr25519::AuthorityPair; + use sp_keyring::sr25519::Keyring; + use sc_client::BlockchainEvents; + use sp_consensus_aura::sr25519::AuthorityPair; type Error = sp_blockchain::Error; - type TestClient = client::Client< - test_client::Backend, - test_client::Executor, + type TestClient = sc_client::Client< + substrate_test_runtime_client::Backend, + substrate_test_runtime_client::Executor, TestBlock, - test_client::runtime::RuntimeApi + substrate_test_runtime_client::runtime::RuntimeApi >; struct DummyFactory(Arc); @@ -875,7 +874,7 @@ mod tests { let client = peer.client().as_full().expect("full clients are created").clone(); let select_chain = peer.select_chain().expect("full client has a select chain"); let keystore_path = tempfile::tempdir().expect("Creates keystore path"); - let keystore = keystore::Store::open(keystore_path.path(), None).expect("Creates keystore."); + let keystore = sc_keystore::Store::open(keystore_path.path(), None).expect("Creates keystore."); keystore.write().insert_ephemeral_from_seed::(&key.to_seed()) .expect("Creates authority key"); @@ -906,7 +905,7 @@ mod tests { inherent_data_providers, false, keystore, - consensus_common::AlwaysCanAuthor, + sp_consensus::AlwaysCanAuthor, ).expect("Starts aura"); runtime.spawn(aura); @@ -923,7 +922,7 @@ mod tests { #[test] fn authorities_call_works() { - let client = test_client::new(); + let client = substrate_test_runtime_client::new(); assert_eq!(client.info().chain.best_number, 0); assert_eq!(authorities(&client, &BlockId::Number(0)).unwrap(), vec![ diff --git a/client/consensus/babe/Cargo.toml b/client/consensus/babe/Cargo.toml index d03157415a..d9f3eaabb0 100644 --- a/client/consensus/babe/Cargo.toml +++ b/client/consensus/babe/Cargo.toml @@ -7,26 +7,26 @@ edition = "2018" [dependencies] codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } -babe_primitives = { package = "sp-consensus-babe", path = "../../../primitives/consensus/babe" } -primitives = { package = "sp-core", path = "../../../primitives/core" } -app-crypto = { package = "sp-application-crypto", path = "../../../primitives/application-crypto" } +sp-consensus-babe = { path = "../../../primitives/consensus/babe" } +sp-core = { path = "../../../primitives/core" } +sp-application-crypto = { path = "../../../primitives/application-crypto" } num-bigint = "0.2.3" num-rational = "0.2.2" num-traits = "0.2.8" -runtime-version = { package = "sp-version", path = "../../../primitives/version" } +sp-version = { path = "../../../primitives/version" } sp-io = { path = "../../../primitives/io" } -inherents = { package = "sp-inherents", path = "../../../primitives/inherents" } +sp-inherents = { path = "../../../primitives/inherents" } sp-timestamp = { path = "../../../primitives/timestamp" } sc-telemetry = { path = "../../telemetry" } -keystore = { package = "sc-keystore", path = "../../keystore" } -client-api = { package = "sc-client-api", path = "../../api" } -client = { package = "sc-client", path = "../../" } +sc-keystore = { path = "../../keystore" } +sc-client-api = { path = "../../api" } +sc-client = { path = "../../" } sp-api = { path = "../../../primitives/api" } -block-builder-api = { package = "sp-block-builder", path = "../../../primitives/block-builder" } +sp-block-builder = { path = "../../../primitives/block-builder" } sp-blockchain = { path = "../../../primitives/blockchain" } -consensus-common = { package = "sp-consensus", path = "../../../primitives/consensus/common" } -uncles = { package = "sc-consensus-uncles", path = "../uncles" } -slots = { package = "sc-consensus-slots", path = "../slots" } +sp-consensus = { path = "../../../primitives/consensus/common" } +sc-consensus-uncles = { path = "../uncles" } +sc-consensus-slots = { path = "../slots" } sp-runtime = { path = "../../../primitives/runtime" } fork-tree = { path = "../../../utils/fork-tree" } futures = { version = "0.3.1", features = ["compat"] } @@ -41,13 +41,13 @@ pdqselect = "0.1.0" derive_more = "0.99.2" [dev-dependencies] -keyring = { package = "sp-keyring", path = "../../../primitives/keyring" } +sp-keyring = { path = "../../../primitives/keyring" } sc-executor = { path = "../../executor" } sc-network = { path = "../../network" } sc-network-test = { path = "../../network/test" } -service = { package = "sc-service", path = "../../service" } -test-client = { package = "substrate-test-runtime-client", path = "../../../test-utils/runtime/client" } -block-builder = { package = "sc-block-builder", path = "../../block-builder" } +sc-service = { path = "../../service" } +substrate-test-runtime-client = { path = "../../../test-utils/runtime/client" } +sc-block-builder = { path = "../../block-builder" } tokio = "0.1.22" env_logger = "0.7.0" tempfile = "3.1.0" diff --git a/client/consensus/babe/src/authorship.rs b/client/consensus/babe/src/authorship.rs index 93405ff777..52d593c763 100644 --- a/client/consensus/babe/src/authorship.rs +++ b/client/consensus/babe/src/authorship.rs @@ -17,13 +17,13 @@ //! BABE authority selection and slot claiming. use merlin::Transcript; -use babe_primitives::{AuthorityId, BabeAuthorityWeight, BABE_ENGINE_ID, BABE_VRF_PREFIX}; -use babe_primitives::{Epoch, SlotNumber, AuthorityPair, BabePreDigest, BabeConfiguration}; -use primitives::{U256, blake2_256}; +use sp_consensus_babe::{AuthorityId, BabeAuthorityWeight, BABE_ENGINE_ID, BABE_VRF_PREFIX}; +use sp_consensus_babe::{Epoch, SlotNumber, AuthorityPair, BabePreDigest, BabeConfiguration}; +use sp_core::{U256, blake2_256}; use codec::Encode; use schnorrkel::vrf::VRFInOut; -use primitives::Pair; -use keystore::KeyStorePtr; +use sp_core::Pair; +use sc_keystore::KeyStorePtr; /// Calculates the primary selection threshold for a given authority, taking /// into account `c` (`1 - c` represents the probability of a slot being empty). @@ -162,8 +162,8 @@ pub(super) fn claim_slot( } fn get_keypair(q: &AuthorityPair) -> &schnorrkel::Keypair { - use primitives::crypto::IsWrappedBy; - primitives::sr25519::Pair::from_ref(q).as_ref() + use sp_core::crypto::IsWrappedBy; + sp_core::sr25519::Pair::from_ref(q).as_ref() } /// Claim a primary slot if it is our turn. Returns `None` if it is not our turn. diff --git a/client/consensus/babe/src/aux_schema.rs b/client/consensus/babe/src/aux_schema.rs index f90c3e233a..0e37a8b3a5 100644 --- a/client/consensus/babe/src/aux_schema.rs +++ b/client/consensus/babe/src/aux_schema.rs @@ -19,10 +19,10 @@ use log::info; use codec::{Decode, Encode}; -use client_api::backend::AuxStore; +use sc_client_api::backend::AuxStore; use sp_blockchain::{Result as ClientResult, Error as ClientError}; use sp_runtime::traits::Block as BlockT; -use babe_primitives::BabeBlockWeight; +use sp_consensus_babe::BabeBlockWeight; use super::{epoch_changes::EpochChangesFor, SharedEpochChanges}; diff --git a/client/consensus/babe/src/epoch_changes.rs b/client/consensus/babe/src/epoch_changes.rs index 5cb1c4f607..06b459c0f7 100644 --- a/client/consensus/babe/src/epoch_changes.rs +++ b/client/consensus/babe/src/epoch_changes.rs @@ -20,14 +20,14 @@ //! persistent DAG superimposed over the forks of the blockchain. use std::sync::Arc; -use babe_primitives::{Epoch, SlotNumber, NextEpochDescriptor}; +use sp_consensus_babe::{Epoch, SlotNumber, NextEpochDescriptor}; use fork_tree::ForkTree; use parking_lot::{Mutex, MutexGuard}; use sp_runtime::traits::{Block as BlockT, NumberFor, One, Zero}; use codec::{Encode, Decode}; -use client_api::utils::is_descendent_of; +use sc_client_api::utils::is_descendent_of; use sp_blockchain::{HeaderMetadata, HeaderBackend, Error as ClientError}; -use primitives::H256; +use sp_core::H256; use std::ops::Add; /// A builder for `is_descendent_of` functions. diff --git a/client/consensus/babe/src/lib.rs b/client/consensus/babe/src/lib.rs index 84b018ac59..d46486b1d8 100644 --- a/client/consensus/babe/src/lib.rs +++ b/client/consensus/babe/src/lib.rs @@ -58,15 +58,15 @@ #![forbid(unsafe_code)] #![warn(missing_docs)] -pub use babe_primitives::{ +pub use sp_consensus_babe::{ BabeApi, ConsensusLog, BABE_ENGINE_ID, BabePreDigest, SlotNumber, BabeConfiguration, CompatibleDigestItem, }; -pub use consensus_common::SyncOracle; +pub use sp_consensus::SyncOracle; use std::{collections::HashMap, sync::Arc, u64, pin::Pin, time::{Instant, Duration}}; -use babe_primitives; -use consensus_common::{ImportResult, CanAuthorWith}; -use consensus_common::import_queue::{ +use sp_consensus_babe; +use sp_consensus::{ImportResult, CanAuthorWith}; +use sp_consensus::import_queue::{ BoxJustificationImport, BoxFinalityProofImport, }; use sp_runtime::{generic::{BlockId, OpaqueDigestItemId}, Justification}; @@ -74,32 +74,32 @@ use sp_runtime::traits::{ Block as BlockT, Header, DigestItemFor, ProvideRuntimeApi, Zero, }; -use keystore::KeyStorePtr; +use sc_keystore::KeyStorePtr; use parking_lot::Mutex; -use primitives::{Blake2Hasher, H256, Pair}; -use inherents::{InherentDataProviders, InherentData}; +use sp_core::{Blake2Hasher, H256, Pair}; +use sp_inherents::{InherentDataProviders, InherentData}; use sc_telemetry::{telemetry, CONSENSUS_TRACE, CONSENSUS_DEBUG}; -use consensus_common::{ +use sp_consensus::{ self, BlockImport, Environment, Proposer, BlockCheckParams, ForkChoiceStrategy, BlockImportParams, BlockOrigin, Error as ConsensusError, SelectChain, SlotData, }; -use babe_primitives::inherents::BabeInherentData; +use sp_consensus_babe::inherents::BabeInherentData; use sp_timestamp::{TimestampInherentData, InherentType as TimestampInherent}; -use consensus_common::import_queue::{Verifier, BasicQueue, CacheKeyId}; -use client_api::{ +use sp_consensus::import_queue::{Verifier, BasicQueue, CacheKeyId}; +use sc_client_api::{ backend::{AuxStore, Backend}, call_executor::CallExecutor, BlockchainEvents, ProvideUncles, }; -use client::Client; +use sc_client::Client; -use block_builder_api::BlockBuilder as BlockBuilderApi; +use sp_block_builder::BlockBuilder as BlockBuilderApi; -use slots::{CheckedHeader, check_equivocation}; +use sc_consensus_slots::{CheckedHeader, check_equivocation}; use futures::prelude::*; use log::{warn, debug, info, trace}; -use slots::{SlotWorker, SlotInfo, SlotCompatible}; +use sc_consensus_slots::{SlotWorker, SlotInfo, SlotCompatible}; use epoch_changes::descendent_query; use sp_blockchain::{ Result as ClientResult, Error as ClientError, @@ -115,7 +115,7 @@ mod epoch_changes; mod authorship; #[cfg(test)] mod tests; -pub use babe_primitives::{ +pub use sp_consensus_babe::{ AuthorityId, AuthorityPair, AuthoritySignature, Epoch, NextEpochDescriptor, }; pub use epoch_changes::{EpochChanges, EpochChangesFor, SharedEpochChanges}; @@ -130,7 +130,7 @@ enum Error { #[display(fmt = "Multiple BABE epoch change digests, rejecting!")] MultipleEpochChangeDigests, #[display(fmt = "Could not extract timestamp and slot: {:?}", _0)] - Extraction(consensus_common::Error), + Extraction(sp_consensus::Error), #[display(fmt = "Could not fetch epoch at {:?}", _0)] FetchEpoch(B::Hash), #[display(fmt = "Header {:?} rejected: too far in the future", _0)] @@ -172,7 +172,7 @@ enum Error { #[display(fmt = "Checking inherents failed: {}", _0)] CheckInherents(String), Client(sp_blockchain::Error), - Runtime(inherents::Error), + Runtime(sp_inherents::Error), ForkTree(Box>), } @@ -201,7 +201,7 @@ macro_rules! babe_info { // and `super::babe::Config` can be eliminated. // https://github.com/paritytech/substrate/issues/2434 #[derive(Clone)] -pub struct Config(slots::SlotDuration); +pub struct Config(sc_consensus_slots::SlotDuration); impl Config { /// Either fetch the slot duration from disk or compute it from the genesis @@ -210,7 +210,7 @@ impl Config { C: AuxStore + ProvideRuntimeApi, C::Api: BabeApi, { trace!(target: "babe", "Getting slot duration"); - match slots::SlotDuration::get_or_compute(client, |a, b| a.configuration(b)).map(Self) { + match sc_consensus_slots::SlotDuration::get_or_compute(client, |a, b| a.configuration(b)).map(Self) { Ok(s) => Ok(s), Err(s) => { warn!(target: "babe", "Failed to get slot duration"); @@ -289,7 +289,7 @@ pub fn start_babe(BabeParams { can_author_with, }: BabeParams) -> Result< impl futures01::Future, - consensus_common::Error, + sp_consensus::Error, > where B: BlockT, C: ProvideRuntimeApi + ProvideCache + ProvideUncles + BlockchainEvents @@ -300,7 +300,7 @@ pub fn start_babe(BabeParams { E::Proposer: Proposer, >::Create: Unpin + Send + 'static, I: BlockImport + Send + Sync + 'static, - Error: std::error::Error + Send + From<::consensus_common::Error> + From + 'static, + Error: std::error::Error + Send + From<::sp_consensus::Error> + From + 'static, SO: SyncOracle + Send + Sync + Clone, CAW: CanAuthorWith + Send, { @@ -317,14 +317,14 @@ pub fn start_babe(BabeParams { }; register_babe_inherent_data_provider(&inherent_data_providers, config.slot_duration())?; - uncles::register_uncles_inherent_data_provider( + sc_consensus_uncles::register_uncles_inherent_data_provider( client.clone(), select_chain.clone(), &inherent_data_providers, )?; babe_info!("Starting BABE Authorship worker"); - let slot_worker = slots::start_slot_worker( + let slot_worker = sc_consensus_slots::start_slot_worker( config.0, select_chain, worker, @@ -348,7 +348,7 @@ struct BabeWorker { config: Config, } -impl slots::SimpleSlotWorker for BabeWorker where +impl sc_consensus_slots::SimpleSlotWorker for BabeWorker where B: BlockT, C: ProvideRuntimeApi + ProvideCache + HeaderBackend + HeaderMetadata, C::Api: BabeApi, @@ -357,7 +357,7 @@ impl slots::SimpleSlotWorker for BabeWorker>::Create: Unpin + Send + 'static, I: BlockImport + Send + Sync + 'static, SO: SyncOracle + Send + Clone, - Error: std::error::Error + Send + From<::consensus_common::Error> + From + 'static, + Error: std::error::Error + Send + From<::sp_consensus::Error> + From + 'static, { type EpochData = Epoch; type Claim = (BabePreDigest, AuthorityPair); @@ -373,7 +373,7 @@ impl slots::SimpleSlotWorker for BabeWorker Result { + fn epoch_data(&self, parent: &B::Header, slot_number: u64) -> Result { self.epoch_changes.lock().epoch_for_child_of( descendent_query(&*self.client), &parent.hash(), @@ -383,7 +383,7 @@ impl slots::SimpleSlotWorker for BabeWorker usize { @@ -422,7 +422,7 @@ impl slots::SimpleSlotWorker for BabeWorker, Self::Claim, - ) -> consensus_common::BlockImportParams + Send> { + ) -> sp_consensus::BlockImportParams + Send> { Box::new(|header, header_hash, body, (_, pair)| { // sign the pre-sealed hash of the block and then // add it to a digest item. @@ -455,9 +455,9 @@ impl slots::SimpleSlotWorker for BabeWorker Result { + fn proposer(&mut self, block: &B::Header) -> Result { self.env.init(block).map_err(|e| { - consensus_common::Error::ClientImport(format!("{:?}", e)) + sp_consensus::Error::ClientImport(format!("{:?}", e)) }) } @@ -510,12 +510,12 @@ impl SlotWorker for BabeWorker where >::Create: Unpin + Send + 'static, I: BlockImport + Send + Sync + 'static, SO: SyncOracle + Send + Sync + Clone, - Error: std::error::Error + Send + From<::consensus_common::Error> + From + 'static, + Error: std::error::Error + Send + From<::sp_consensus::Error> + From + 'static, { - type OnSlot = Pin> + Send>>; + type OnSlot = Pin> + Send>>; fn on_slot(&mut self, chain_head: B::Header, slot_info: SlotInfo) -> Self::OnSlot { - >::on_slot(self, chain_head, slot_info) + >::on_slot(self, chain_head, slot_info) } } @@ -571,12 +571,12 @@ impl SlotCompatible for TimeSource { fn extract_timestamp_and_slot( &self, data: &InherentData, - ) -> Result<(TimestampInherent, u64, std::time::Duration), consensus_common::Error> { + ) -> Result<(TimestampInherent, u64, std::time::Duration), sp_consensus::Error> { trace!(target: "babe", "extract timestamp"); data.timestamp_inherent_data() .and_then(|t| data.babe_inherent_data().map(|a| (t, a))) .map_err(Into::into) - .map_err(consensus_common::Error::InherentData) + .map_err(sp_consensus::Error::InherentData) .map(|(x, y)| (x, y, self.0.lock().0.take().unwrap_or_default())) } } @@ -592,7 +592,7 @@ pub struct BabeLink { pub struct BabeVerifier { client: Arc>, api: Arc, - inherent_data_providers: inherents::InherentDataProviders, + inherent_data_providers: sp_inherents::InherentDataProviders, config: Config, epoch_changes: SharedEpochChanges, time_source: TimeSource, @@ -818,13 +818,13 @@ pub type BabeImportQueue = BasicQueue; fn register_babe_inherent_data_provider( inherent_data_providers: &InherentDataProviders, slot_duration: u64, -) -> Result<(), consensus_common::Error> { +) -> Result<(), sp_consensus::Error> { debug!(target: "babe", "Registering"); - if !inherent_data_providers.has_provider(&babe_primitives::inherents::INHERENT_IDENTIFIER) { + if !inherent_data_providers.has_provider(&sp_consensus_babe::inherents::INHERENT_IDENTIFIER) { inherent_data_providers - .register_provider(babe_primitives::inherents::InherentDataProvider::new(slot_duration)) + .register_provider(sp_consensus_babe::inherents::InherentDataProvider::new(slot_duration)) .map_err(Into::into) - .map_err(consensus_common::Error::InherentData) + .map_err(sp_consensus::Error::InherentData) } else { Ok(()) } diff --git a/client/consensus/babe/src/tests.rs b/client/consensus/babe/src/tests.rs index 48b58eacd8..8ee4ae22e2 100644 --- a/client/consensus/babe/src/tests.rs +++ b/client/consensus/babe/src/tests.rs @@ -22,10 +22,10 @@ use super::*; use authorship::claim_slot; -use babe_primitives::{AuthorityPair, SlotNumber}; -use block_builder::BlockBuilder; -use consensus_common::NoNetwork as DummyOracle; -use consensus_common::import_queue::{ +use sp_consensus_babe::{AuthorityPair, SlotNumber}; +use sc_block_builder::BlockBuilder; +use sp_consensus::NoNetwork as DummyOracle; +use sp_consensus::import_queue::{ BoxBlockImport, BoxJustificationImport, BoxFinalityProofImport, }; use sc_network_test::*; @@ -33,8 +33,7 @@ use sc_network_test::{Block as TestBlock, PeersClient}; use sc_network::config::{BoxFinalityProofRequestBuilder, ProtocolConfig}; use sp_runtime::{generic::DigestItem, traits::{Block as BlockT, DigestFor}}; use tokio::runtime::current_thread; -use client_api::BlockchainEvents; -use test_client; +use sc_client_api::BlockchainEvents; use log::debug; use std::{time::Duration, cell::RefCell}; @@ -42,11 +41,11 @@ type Item = DigestItem; type Error = sp_blockchain::Error; -type TestClient = client::Client< - test_client::Backend, - test_client::Executor, +type TestClient = sc_client::Client< + substrate_test_runtime_client::Backend, + substrate_test_runtime_client::Executor, TestBlock, - test_client::runtime::RuntimeApi, + substrate_test_runtime_client::runtime::RuntimeApi, >; #[derive(Copy, Clone, PartialEq)] @@ -196,10 +195,10 @@ type TestExtrinsic = ::Extrinsic; pub struct TestVerifier { inner: BabeVerifier< - test_client::Backend, - test_client::Executor, + substrate_test_runtime_client::Backend, + substrate_test_runtime_client::Executor, TestBlock, - test_client::runtime::RuntimeApi, + substrate_test_runtime_client::runtime::RuntimeApi, PeersFullClient, >, mutator: Mutator, @@ -358,7 +357,7 @@ fn run_one_test( let select_chain = peer.select_chain().expect("Full client has select_chain"); let keystore_path = tempfile::tempdir().expect("Creates keystore path"); - let keystore = keystore::Store::open(keystore_path.path(), None).expect("Creates keystore"); + let keystore = sc_keystore::Store::open(keystore_path.path(), None).expect("Creates keystore"); keystore.write().insert_ephemeral_from_seed::(seed).expect("Generates authority key"); keystore_paths.push(keystore_path); @@ -403,7 +402,7 @@ fn run_one_test( force_authoring: false, babe_link: data.link.clone(), keystore, - can_author_with: consensus_common::AlwaysCanAuthor, + can_author_with: sp_consensus::AlwaysCanAuthor, }).expect("Starts babe")); } @@ -483,7 +482,7 @@ fn sig_is_not_pre_digest() { fn can_author_block() { let _ = env_logger::try_init(); let keystore_path = tempfile::tempdir().expect("Creates keystore path"); - let keystore = keystore::Store::open(keystore_path.path(), None).expect("Creates keystore"); + let keystore = sc_keystore::Store::open(keystore_path.path(), None).expect("Creates keystore"); let pair = keystore.write().insert_ephemeral_from_seed::("//Alice") .expect("Generates authority pair"); @@ -634,7 +633,7 @@ fn importing_block_one_sets_genesis_epoch() { #[test] fn importing_epoch_change_block_prunes_tree() { - use client_api::Finalizer; + use sc_client_api::Finalizer; let mut net = BabeTestNet::new(1); diff --git a/client/consensus/babe/src/verification.rs b/client/consensus/babe/src/verification.rs index 353fed808c..0717e81a49 100644 --- a/client/consensus/babe/src/verification.rs +++ b/client/consensus/babe/src/verification.rs @@ -17,10 +17,10 @@ //! Verification for BABE headers. use schnorrkel::vrf::{VRFOutput, VRFProof}; use sp_runtime::{traits::Header, traits::DigestItemFor}; -use primitives::{Pair, Public}; -use babe_primitives::{Epoch, BabePreDigest, CompatibleDigestItem, AuthorityId}; -use babe_primitives::{AuthoritySignature, SlotNumber, AuthorityIndex, AuthorityPair}; -use slots::CheckedHeader; +use sp_core::{Pair, Public}; +use sp_consensus_babe::{Epoch, BabePreDigest, CompatibleDigestItem, AuthorityId}; +use sp_consensus_babe::{AuthoritySignature, SlotNumber, AuthorityIndex, AuthorityPair}; +use sc_consensus_slots::CheckedHeader; use log::{debug, trace}; use super::{find_pre_digest, babe_err, BlockT, Error}; use super::authorship::{make_transcript, calculate_primary_threshold, check_primary_threshold, secondary_slot_author}; diff --git a/client/consensus/pow/Cargo.toml b/client/consensus/pow/Cargo.toml index b4195c0e0e..eeea954f77 100644 --- a/client/consensus/pow/Cargo.toml +++ b/client/consensus/pow/Cargo.toml @@ -7,14 +7,14 @@ edition = "2018" [dependencies] codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } -primitives = { package = "sp-core", path = "../../../primitives/core" } +sp-core = { path = "../../../primitives/core" } sp-blockchain = { path = "../../../primitives/blockchain" } sp-runtime = { path = "../../../primitives/runtime" } -client-api = { package = "sc-client-api", path = "../../api" } -block-builder-api = { package = "sp-block-builder", path = "../../../primitives/block-builder" } -inherents = { package = "sp-inherents", path = "../../../primitives/inherents" } -pow-primitives = { package = "sp-consensus-pow", path = "../../../primitives/consensus/pow" } -consensus-common = { package = "sp-consensus", path = "../../../primitives/consensus/common" } +sc-client-api = { path = "../../api" } +sp-block-builder = { path = "../../../primitives/block-builder" } +sp-inherents = { path = "../../../primitives/inherents" } +sp-consensus-pow = { path = "../../../primitives/consensus/pow" } +sp-consensus = { path = "../../../primitives/consensus/common" } log = "0.4.8" futures = { version = "0.3.1", features = ["compat"] } sp-timestamp = { path = "../../../primitives/timestamp" } diff --git a/client/consensus/pow/src/lib.rs b/client/consensus/pow/src/lib.rs index 087791ce89..b620a78525 100644 --- a/client/consensus/pow/src/lib.rs +++ b/client/consensus/pow/src/lib.rs @@ -32,23 +32,23 @@ use std::sync::Arc; use std::thread; use std::collections::HashMap; -use client_api::{BlockOf, backend::AuxStore}; +use sc_client_api::{BlockOf, backend::AuxStore}; use sp_blockchain::{HeaderBackend, ProvideCache, well_known_cache_keys::Id as CacheKeyId}; -use block_builder_api::BlockBuilder as BlockBuilderApi; +use sp_block_builder::BlockBuilder as BlockBuilderApi; use sp_runtime::{Justification, RuntimeString}; use sp_runtime::generic::{BlockId, Digest, DigestItem}; use sp_runtime::traits::{Block as BlockT, Header as HeaderT, ProvideRuntimeApi}; use sp_timestamp::{TimestampInherentData, InherentError as TIError}; -use pow_primitives::{Seal, TotalDifficulty, POW_ENGINE_ID}; -use primitives::H256; -use inherents::{InherentDataProviders, InherentData}; -use consensus_common::{ +use sp_consensus_pow::{Seal, TotalDifficulty, POW_ENGINE_ID}; +use sp_core::H256; +use sp_inherents::{InherentDataProviders, InherentData}; +use sp_consensus::{ BlockImportParams, BlockOrigin, ForkChoiceStrategy, SyncOracle, Environment, Proposer, SelectChain, Error as ConsensusError, CanAuthorWith, }; -use consensus_common::import_queue::{BoxBlockImport, BasicQueue, Verifier}; +use sp_consensus::import_queue::{BoxBlockImport, BasicQueue, Verifier}; use codec::{Encode, Decode}; -use client_api; +use sc_client_api; use log::*; #[derive(derive_more::Display, Debug)] @@ -74,7 +74,7 @@ pub enum Error { #[display(fmt = "Error with block built on {:?}: {:?}", _0, _1)] BlockBuiltError(B::Hash, ConsensusError), #[display(fmt = "Creating inherents failed: {}", _0)] - CreateInherents(inherents::Error), + CreateInherents(sp_inherents::Error), #[display(fmt = "Checking inherents failed: {}", _0)] CheckInherents(String), Client(sp_blockchain::Error), @@ -151,7 +151,7 @@ pub trait PowAlgorithm { pub struct PowVerifier, C, S, Algorithm> { client: Arc, algorithm: Algorithm, - inherent_data_providers: inherents::InherentDataProviders, + inherent_data_providers: sp_inherents::InherentDataProviders, select_chain: Option, check_inherents_after: <::Header as HeaderT>::Number, } @@ -162,7 +162,7 @@ impl, C, S, Algorithm> PowVerifier { algorithm: Algorithm, check_inherents_after: <::Header as HeaderT>::Number, select_chain: Option, - inherent_data_providers: inherents::InherentDataProviders, + inherent_data_providers: sp_inherents::InherentDataProviders, ) -> Self { Self { client, algorithm, inherent_data_providers, select_chain, check_inherents_after } } @@ -314,12 +314,12 @@ impl, C, S, Algorithm> Verifier for PowVerifier Result<(), consensus_common::Error> { +) -> Result<(), sp_consensus::Error> { if !inherent_data_providers.has_provider(&sp_timestamp::INHERENT_IDENTIFIER) { inherent_data_providers .register_provider(sp_timestamp::InherentDataProvider) .map_err(Into::into) - .map_err(consensus_common::Error::InherentData) + .map_err(sp_consensus::Error::InherentData) } else { Ok(()) } @@ -336,7 +336,7 @@ pub fn import_queue( check_inherents_after: <::Header as HeaderT>::Number, select_chain: Option, inherent_data_providers: InherentDataProviders, -) -> Result, consensus_common::Error> where +) -> Result, sp_consensus::Error> where B: BlockT, C: ProvideRuntimeApi + HeaderBackend + BlockOf + ProvideCache + AuxStore, C: Send + Sync + AuxStore + 'static, @@ -382,7 +382,7 @@ pub fn start_mine, C, Algorithm, E, SO, S, CAW>( mut sync_oracle: SO, build_time: std::time::Duration, select_chain: Option, - inherent_data_providers: inherents::InherentDataProviders, + inherent_data_providers: sp_inherents::InherentDataProviders, can_author_with: CAW, ) where C: HeaderBackend + AuxStore + 'static, @@ -433,7 +433,7 @@ fn mine_loop, C, Algorithm, E, SO, S, CAW>( sync_oracle: &mut SO, build_time: std::time::Duration, select_chain: Option<&S>, - inherent_data_providers: &inherents::InherentDataProviders, + inherent_data_providers: &sp_inherents::InherentDataProviders, can_author_with: &CAW, ) -> Result<(), Error> where C: HeaderBackend + AuxStore, diff --git a/client/consensus/slots/Cargo.toml b/client/consensus/slots/Cargo.toml index 18d9f97b19..01f6bf5251 100644 --- a/client/consensus/slots/Cargo.toml +++ b/client/consensus/slots/Cargo.toml @@ -8,17 +8,17 @@ build = "build.rs" [dependencies] codec = { package = "parity-scale-codec", version = "1.0.0" } -client-api = { package = "sc-client-api", path = "../../api" } -primitives = { package = "sp-core", path = "../../../primitives/core" } +sc-client-api = { path = "../../api" } +sp-core = { path = "../../../primitives/core" } sp-blockchain = { path = "../../../primitives/blockchain" } sp-runtime = { path = "../../../primitives/runtime" } sc-telemetry = { path = "../../telemetry" } -consensus_common = { package = "sp-consensus", path = "../../../primitives/consensus/common" } -inherents = { package = "sp-inherents", path = "../../../primitives/inherents" } +sp-consensus = { path = "../../../primitives/consensus/common" } +sp-inherents = { path = "../../../primitives/inherents" } futures = "0.3.1" futures-timer = "2.0" parking_lot = "0.9.0" log = "0.4.8" [dev-dependencies] -test-client = { package = "substrate-test-runtime-client", path = "../../../test-utils/runtime/client" } +substrate-test-runtime-client = { path = "../../../test-utils/runtime/client" } diff --git a/client/consensus/slots/src/aux_schema.rs b/client/consensus/slots/src/aux_schema.rs index 76f165e8d5..ada9661550 100644 --- a/client/consensus/slots/src/aux_schema.rs +++ b/client/consensus/slots/src/aux_schema.rs @@ -17,7 +17,7 @@ //! Schema for slots in the aux-db. use codec::{Encode, Decode}; -use client_api::backend::AuxStore; +use sc_client_api::backend::AuxStore; use sp_blockchain::{Result as ClientResult, Error as ClientError}; use sp_runtime::traits::Header; @@ -151,10 +151,10 @@ pub fn check_equivocation( #[cfg(test)] mod test { - use primitives::{sr25519, Pair}; - use primitives::hash::H256; + use sp_core::{sr25519, Pair}; + use sp_core::hash::H256; use sp_runtime::testing::{Header as HeaderTest, Digest as DigestTest}; - use test_client; + use substrate_test_runtime_client; use super::{MAX_SLOT_CAPACITY, PRUNING_BOUND, check_equivocation}; @@ -175,7 +175,7 @@ mod test { #[test] fn check_equivocation_works() { - let client = test_client::new(); + let client = substrate_test_runtime_client::new(); let (pair, _seed) = sr25519::Pair::generate(); let public = pair.public(); diff --git a/client/consensus/slots/src/lib.rs b/client/consensus/slots/src/lib.rs index e95974fb92..9010771145 100644 --- a/client/consensus/slots/src/lib.rs +++ b/client/consensus/slots/src/lib.rs @@ -31,23 +31,23 @@ use slots::Slots; pub use aux_schema::{check_equivocation, MAX_SLOT_CAPACITY, PRUNING_BOUND}; use codec::{Decode, Encode}; -use consensus_common::{BlockImport, Proposer, SyncOracle, SelectChain, CanAuthorWith, SlotData}; +use sp_consensus::{BlockImport, Proposer, SyncOracle, SelectChain, CanAuthorWith, SlotData}; use futures::{prelude::*, future::{self, Either}}; use futures_timer::Delay; -use inherents::{InherentData, InherentDataProviders}; +use sp_inherents::{InherentData, InherentDataProviders}; use log::{debug, error, info, warn}; use sp_runtime::generic::BlockId; use sp_runtime::traits::{ApiRef, Block as BlockT, Header, ProvideRuntimeApi}; use std::{fmt::Debug, ops::Deref, pin::Pin, sync::Arc, time::{Instant, Duration}}; use sc_telemetry::{telemetry, CONSENSUS_DEBUG, CONSENSUS_WARN, CONSENSUS_INFO}; use parking_lot::Mutex; -use client_api; +use sc_client_api; /// A worker that should be invoked at every new slot. pub trait SlotWorker { /// The type of the future that will be returned when a new slot is /// triggered. - type OnSlot: Future>; + type OnSlot: Future>; /// Called when a new slot is triggered. fn on_slot(&mut self, chain_head: B::Header, slot_info: SlotInfo) -> Self::OnSlot; @@ -80,7 +80,7 @@ pub trait SimpleSlotWorker { /// Returns the epoch data necessary for authoring. For time-dependent epochs, /// use the provided slot number as a canonical source of time. - fn epoch_data(&self, header: &B::Header, slot_number: u64) -> Result; + fn epoch_data(&self, header: &B::Header, slot_number: u64) -> Result; /// Returns the number of authorities given the epoch data. fn authorities_len(&self, epoch_data: &Self::EpochData) -> usize; @@ -102,7 +102,7 @@ pub trait SimpleSlotWorker { &B::Hash, Vec, Self::Claim, - ) -> consensus_common::BlockImportParams + Send>; + ) -> sp_consensus::BlockImportParams + Send>; /// Whether to force authoring if offline. fn force_authoring(&self) -> bool; @@ -111,7 +111,7 @@ pub trait SimpleSlotWorker { fn sync_oracle(&mut self) -> &mut Self::SyncOracle; /// Returns a `Proposer` to author on top of the given block. - fn proposer(&mut self, block: &B::Header) -> Result; + fn proposer(&mut self, block: &B::Header) -> Result; /// Remaining duration of the slot. fn slot_remaining_duration(&self, slot_info: &SlotInfo) -> Duration { @@ -134,7 +134,7 @@ pub trait SimpleSlotWorker { /// Implements the `on_slot` functionality from `SlotWorker`. fn on_slot(&mut self, chain_head: B::Header, slot_info: SlotInfo) - -> Pin> + Send>> where + -> Pin> + Send>> where Self: Send + Sync, >::Create: Unpin + Send + 'static, { @@ -222,7 +222,7 @@ pub trait SimpleSlotWorker { logs, }, slot_remaining_duration, - ).map_err(|e| consensus_common::Error::ClientImport(format!("{:?}", e))); + ).map_err(|e| sp_consensus::Error::ClientImport(format!("{:?}", e))); let delay: Box + Unpin + Send> = match proposing_remaining_duration { Some(r) => Box::new(Delay::new(r)), None => Box::new(future::pending()), @@ -239,7 +239,7 @@ pub trait SimpleSlotWorker { telemetry!(CONSENSUS_INFO; "slots.discarding_proposal_took_too_long"; "slot" => slot_number, ); - Err(consensus_common::Error::ClientImport("Timeout in the Slots proposer".into())) + Err(sp_consensus::Error::ClientImport("Timeout in the Slots proposer".into())) }, })); @@ -293,7 +293,7 @@ pub trait SlotCompatible { fn extract_timestamp_and_slot( &self, inherent: &InherentData, - ) -> Result<(u64, u64, std::time::Duration), consensus_common::Error>; + ) -> Result<(u64, u64, std::time::Duration), sp_consensus::Error>; /// Get the difference between chain time and local time. Defaults to /// always returning zero. @@ -417,7 +417,7 @@ impl SlotDuration { /// `slot_key` is marked as `'static`, as it should really be a /// compile-time constant. pub fn get_or_compute(client: &C, cb: CB) -> sp_blockchain::Result where - C: client_api::backend::AuxStore, + C: sc_client_api::backend::AuxStore, C: ProvideRuntimeApi, CB: FnOnce(ApiRef, &BlockId) -> sp_blockchain::Result, T: SlotData + Encode + Decode + Debug, diff --git a/client/consensus/slots/src/slots.rs b/client/consensus/slots/src/slots.rs index 640b24ec1c..16d53fc54a 100644 --- a/client/consensus/slots/src/slots.rs +++ b/client/consensus/slots/src/slots.rs @@ -19,9 +19,9 @@ //! This is used instead of `futures_timer::Interval` because it was unreliable. use super::SlotCompatible; -use consensus_common::Error; +use sp_consensus::Error; use futures::{prelude::*, task::Context, task::Poll}; -use inherents::{InherentData, InherentDataProviders}; +use sp_inherents::{InherentData, InherentDataProviders}; use std::{pin::Pin, time::{Duration, Instant}}; use futures_timer::Delay; @@ -135,7 +135,7 @@ impl Stream for Slots { let inherent_data = match self.inherent_data_providers.create_inherent_data() { Ok(id) => id, - Err(err) => return Poll::Ready(Some(Err(consensus_common::Error::InherentData(err)))), + Err(err) => return Poll::Ready(Some(Err(sp_consensus::Error::InherentData(err)))), }; let result = self.timestamp_extractor.extract_timestamp_and_slot(&inherent_data); let (timestamp, slot_num, offset) = match result { diff --git a/client/consensus/uncles/Cargo.toml b/client/consensus/uncles/Cargo.toml index 62fc7476f1..c017358ca4 100644 --- a/client/consensus/uncles/Cargo.toml +++ b/client/consensus/uncles/Cargo.toml @@ -6,10 +6,10 @@ description = "Generic uncle inclusion utilities for consensus" edition = "2018" [dependencies] -client-api = { package = "sc-client-api", path = "../../api" } -primitives = { package = "sp-core", path = "../../../primitives/core" } +sc-client-api = { path = "../../api" } +sp-core = { path = "../../../primitives/core" } sp-runtime = { path = "../../../primitives/runtime" } sp-authorship = { path = "../../../primitives/authorship" } -consensus_common = { package = "sp-consensus", path = "../../../primitives/consensus/common" } -inherents = { package = "sp-inherents", path = "../../../primitives/inherents" } +sp-consensus = { path = "../../../primitives/consensus/common" } +sp-inherents = { path = "../../../primitives/inherents" } log = "0.4.8" diff --git a/client/consensus/uncles/src/lib.rs b/client/consensus/uncles/src/lib.rs index f7b1a8fa84..5839fb0a01 100644 --- a/client/consensus/uncles/src/lib.rs +++ b/client/consensus/uncles/src/lib.rs @@ -19,10 +19,10 @@ #![deny(warnings)] #![forbid(unsafe_code, missing_docs)] -use consensus_common::SelectChain; -use inherents::{InherentDataProviders}; +use sp_consensus::SelectChain; +use sp_inherents::{InherentDataProviders}; use log::warn; -use client_api::ProvideUncles; +use sc_client_api::ProvideUncles; use sp_runtime::traits::{Block as BlockT, Header}; use std::sync::Arc; use sp_authorship; @@ -35,7 +35,7 @@ pub fn register_uncles_inherent_data_provider( client: Arc, select_chain: SC, inherent_data_providers: &InherentDataProviders, -) -> Result<(), consensus_common::Error> where +) -> Result<(), sp_consensus::Error> where B: BlockT, C: ProvideUncles + Send + Sync + 'static, SC: SelectChain + 'static, @@ -60,7 +60,7 @@ pub fn register_uncles_inherent_data_provider( } } })) - .map_err(|err| consensus_common::Error::InherentData(err.into()))?; + .map_err(|err| sp_consensus::Error::InherentData(err.into()))?; } Ok(()) } diff --git a/client/db/Cargo.toml b/client/db/Cargo.toml index c6c256b7eb..20eba6fc13 100644 --- a/client/db/Cargo.toml +++ b/client/db/Cargo.toml @@ -12,21 +12,21 @@ kvdb-rocksdb = { version = "0.2", optional = true } kvdb-memorydb = "0.1.2" linked-hash-map = "0.5.2" hash-db = "0.15.2" -client-api = { package = "sc-client-api", path = "../api" } -primitives = { package = "sp-core", path = "../../primitives/core" } +sc-client-api = { path = "../api" } +sp-core = { path = "../../primitives/core" } sp-runtime = { path = "../../primitives/runtime" } -client = { package = "sc-client", path = "../" } -state-machine = { package = "sp-state-machine", path = "../../primitives/state-machine" } +sc-client = { path = "../" } +sp-state-machine = { path = "../../primitives/state-machine" } codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } -executor = { package = "sc-executor", path = "../executor" } -state_db = { package = "sc-state-db", path = "../state-db" } -trie = { package = "sp-trie", path = "../../primitives/trie" } -consensus_common = { package = "sp-consensus", path = "../../primitives/consensus/common" } +sc-executor = { path = "../executor" } +sc-state-db = { path = "../state-db" } +sp-trie = { path = "../../primitives/trie" } +sp-consensus = { path = "../../primitives/consensus/common" } sp-blockchain = { path = "../../primitives/blockchain" } [dev-dependencies] sp-keyring = { path = "../../primitives/keyring" } -test-client = { package = "substrate-test-runtime-client", path = "../../test-utils/runtime/client" } +substrate-test-runtime-client = { path = "../../test-utils/runtime/client" } env_logger = "0.7.0" quickcheck = "0.9" diff --git a/client/db/src/cache/list_cache.rs b/client/db/src/cache/list_cache.rs index 36219d479a..3760838bdf 100644 --- a/client/db/src/cache/list_cache.rs +++ b/client/db/src/cache/list_cache.rs @@ -724,7 +724,7 @@ fn read_forks>( #[cfg(test)] pub mod tests { - use test_client::runtime::H256; + use substrate_test_runtime_client::runtime::H256; use sp_runtime::testing::{Header, Block as RawBlock, ExtrinsicWrapper}; use sp_runtime::traits::Header as HeaderT; use crate::cache::list_storage::tests::{DummyStorage, FaultyStorage, DummyTransaction}; diff --git a/client/db/src/cache/mod.rs b/client/db/src/cache/mod.rs index 0087d34d19..a25b4e4fd7 100644 --- a/client/db/src/cache/mod.rs +++ b/client/db/src/cache/mod.rs @@ -21,7 +21,7 @@ use parking_lot::RwLock; use kvdb::{KeyValueDB, DBTransaction}; -use client_api::blockchain::{well_known_cache_keys::{self, Id as CacheKeyId}, Cache as BlockchainCache}; +use sc_client_api::blockchain::{well_known_cache_keys::{self, Id as CacheKeyId}, Cache as BlockchainCache}; use sp_blockchain::Result as ClientResult; use codec::{Encode, Decode}; use sp_runtime::generic::BlockId; diff --git a/client/db/src/lib.rs b/client/db/src/lib.rs index a7320ec1c3..8523ff30a3 100644 --- a/client/db/src/lib.rs +++ b/client/db/src/lib.rs @@ -39,9 +39,9 @@ use std::path::PathBuf; use std::io; use std::collections::{HashMap, HashSet}; -use client_api::{execution_extensions::ExecutionExtensions, ForkBlocks}; -use client_api::backend::NewBlockState; -use client_api::backend::{StorageCollection, ChildStorageCollection}; +use sc_client_api::{execution_extensions::ExecutionExtensions, ForkBlocks}; +use sc_client_api::backend::NewBlockState; +use sc_client_api::backend::{StorageCollection, ChildStorageCollection}; use sp_blockchain::{ Result as ClientResult, Error as ClientError, well_known_cache_keys, HeaderBackend, @@ -49,10 +49,10 @@ use sp_blockchain::{ use codec::{Decode, Encode}; use hash_db::{Hasher, Prefix}; use kvdb::{KeyValueDB, DBTransaction}; -use trie::{MemoryDB, PrefixedMemoryDB, prefixed_key}; +use sp_trie::{MemoryDB, PrefixedMemoryDB, prefixed_key}; use parking_lot::{Mutex, RwLock}; -use primitives::{H256, Blake2Hasher, ChangesTrieConfiguration, convert_hash, traits::CodeExecutor}; -use primitives::storage::{well_known_keys, ChildInfo}; +use sp_core::{H256, Blake2Hasher, ChangesTrieConfiguration, convert_hash, traits::CodeExecutor}; +use sp_core::storage::{well_known_keys, ChildInfo}; use sp_runtime::{ generic::{BlockId, DigestItem}, Justification, Storage, BuildStorage, @@ -60,21 +60,21 @@ use sp_runtime::{ use sp_runtime::traits::{ Block as BlockT, Header as HeaderT, NumberFor, Zero, One, SaturatedConversion }; -use executor::RuntimeInfo; -use state_machine::{ +use sc_executor::RuntimeInfo; +use sp_state_machine::{ DBValue, ChangesTrieTransaction, ChangesTrieCacheAction, ChangesTrieBuildCache, backend::Backend as StateBackend, }; use crate::utils::{Meta, db_err, meta_keys, read_db, read_meta}; -use client::leaves::{LeafSet, FinalizationDisplaced}; -use state_db::StateDb; +use sc_client::leaves::{LeafSet, FinalizationDisplaced}; +use sc_state_db::StateDb; use sp_blockchain::{CachedHeaderMetadata, HeaderMetadata, HeaderMetadataCache}; use crate::storage_cache::{CachingState, SharedCache, new_shared_cache}; use log::{trace, debug, warn}; -pub use state_db::PruningMode; +pub use sc_state_db::PruningMode; #[cfg(feature = "test-helpers")] -use client::in_mem::Backend as InMemoryBackend; +use sc_client::in_mem::Backend as InMemoryBackend; const CANONICALIZATION_DELAY: u64 = 4096; const MIN_BLOCKS_TO_KEEP_CHANGES_TRIES_FOR: u32 = 32768; @@ -83,7 +83,7 @@ const MIN_BLOCKS_TO_KEEP_CHANGES_TRIES_FOR: u32 = 32768; const DEFAULT_CHILD_RATIO: (usize, usize) = (1, 10); /// DB-backed patricia trie state, transaction type is an overlay of changes to commit. -pub type DbState = state_machine::TrieBackend>, Blake2Hasher>; +pub type DbState = sp_state_machine::TrieBackend>, Blake2Hasher>; /// Re-export the KVDB trait so that one can pass an implementation of it. pub use kvdb; @@ -239,7 +239,7 @@ impl StateBackend for RefTrackingState { fn as_trie_backend( &mut self, - ) -> Option<&state_machine::TrieBackend> { + ) -> Option<&sp_state_machine::TrieBackend> { self.state.as_trie_backend() } } @@ -278,9 +278,9 @@ pub fn new_client( fork_blocks: ForkBlocks, execution_extensions: ExecutionExtensions, ) -> Result<( - client::Client< + sc_client::Client< Backend, - client::LocalCallExecutor, E>, + sc_client::LocalCallExecutor, E>, Block, RA, >, @@ -294,9 +294,9 @@ pub fn new_client( S: BuildStorage, { let backend = Arc::new(Backend::new(settings, CANONICALIZATION_DELAY)?); - let executor = client::LocalCallExecutor::new(backend.clone(), executor); + let executor = sc_client::LocalCallExecutor::new(backend.clone(), executor); Ok(( - client::Client::new(backend.clone(), executor, genesis_storage, fork_blocks, execution_extensions)?, + sc_client::Client::new(backend.clone(), executor, genesis_storage, fork_blocks, execution_extensions)?, backend, )) } @@ -326,7 +326,7 @@ struct PendingBlock { // wrapper that implements trait required for state_db struct StateMetaDb<'a>(&'a dyn KeyValueDB); -impl<'a> state_db::MetaDb for StateMetaDb<'a> { +impl<'a> sc_state_db::MetaDb for StateMetaDb<'a> { type Error = io::Error; fn get_meta(&self, key: &[u8]) -> Result>, Self::Error> { @@ -379,14 +379,14 @@ impl BlockchainDb { } } -impl client::blockchain::HeaderBackend for BlockchainDb { +impl sc_client::blockchain::HeaderBackend for BlockchainDb { fn header(&self, id: BlockId) -> ClientResult> { utils::read_header(&*self.db, columns::KEY_LOOKUP, columns::HEADER, id) } - fn info(&self) -> client::blockchain::Info { + fn info(&self) -> sc_client::blockchain::Info { let meta = self.meta.read(); - client::blockchain::Info { + sc_client::blockchain::Info { best_hash: meta.best_hash, best_number: meta.best_number, genesis_hash: meta.genesis_hash, @@ -395,7 +395,7 @@ impl client::blockchain::HeaderBackend for BlockchainDb) -> ClientResult { + fn status(&self, id: BlockId) -> ClientResult { let exists = match id { BlockId::Hash(_) => read_db( &*self.db, @@ -406,8 +406,8 @@ impl client::blockchain::HeaderBackend for BlockchainDb n <= self.meta.read().best_number, }; match exists { - true => Ok(client::blockchain::BlockStatus::InChain), - false => Ok(client::blockchain::BlockStatus::Unknown), + true => Ok(sc_client::blockchain::BlockStatus::InChain), + false => Ok(sc_client::blockchain::BlockStatus::Unknown), } } @@ -423,7 +423,7 @@ impl client::blockchain::HeaderBackend for BlockchainDb client::blockchain::Backend for BlockchainDb { +impl sc_client::blockchain::Backend for BlockchainDb { fn body(&self, id: BlockId) -> ClientResult>> { match read_db(&*self.db, columns::KEY_LOOKUP, columns::BODY, id)? { Some(body) => match Decode::decode(&mut &body[..]) { @@ -452,7 +452,7 @@ impl client::blockchain::Backend for BlockchainDb { Ok(self.meta.read().finalized_hash.clone()) } - fn cache(&self) -> Option>> { + fn cache(&self) -> Option>> { None } @@ -465,8 +465,8 @@ impl client::blockchain::Backend for BlockchainDb { } } -impl client::blockchain::ProvideCache for BlockchainDb { - fn cache(&self) -> Option>> { +impl sc_client::blockchain::ProvideCache for BlockchainDb { + fn cache(&self) -> Option>> { None } } @@ -522,7 +522,7 @@ impl BlockImportOperation { } } -impl client_api::backend::BlockImportOperation +impl sc_client_api::backend::BlockImportOperation for BlockImportOperation where Block: BlockT, { type State = CachingState, Block>; @@ -630,7 +630,7 @@ struct StorageDb { pub state_db: StateDb>, } -impl state_machine::Storage for StorageDb { +impl sp_state_machine::Storage for StorageDb { fn get(&self, key: &H256, prefix: Prefix) -> Result, String> { let key = prefixed_key::(key, prefix); self.state_db.get(&key, self).map(|r| r.map(|v| DBValue::from_slice(&v))) @@ -638,7 +638,7 @@ impl state_machine::Storage for StorageDb { } } -impl state_db::NodeDb for StorageDb { +impl sc_state_db::NodeDb for StorageDb { type Error = io::Error; type Key = [u8]; @@ -653,12 +653,12 @@ impl DbGenesisStorage { pub fn new() -> Self { let mut root = H256::default(); let mut mdb = MemoryDB::::default(); - state_machine::TrieDBMut::::new(&mut mdb, &mut root); + sp_state_machine::TrieDBMut::::new(&mut mdb, &mut root); DbGenesisStorage(root) } } -impl state_machine::Storage for DbGenesisStorage { +impl sp_state_machine::Storage for DbGenesisStorage { fn get(&self, _key: &H256, _prefix: Prefix) -> Result, String> { Ok(None) } @@ -700,11 +700,11 @@ impl> DbChangesTrieStorage { None => return, }; - state_machine::prune_changes_tries( + sp_state_machine::prune_changes_tries( config, &*self, min_blocks_to_keep.into(), - &state_machine::ChangesTrieAnchorBlockId { + &sp_state_machine::ChangesTrieAnchorBlockId { hash: convert_hash(&block_hash), number: block_num, }, @@ -712,7 +712,7 @@ impl> DbChangesTrieStorage { } } -impl client_api::backend::PrunableStateChangesTrieStorage +impl sc_client_api::backend::PrunableStateChangesTrieStorage for DbChangesTrieStorage where Block: BlockT, @@ -723,7 +723,7 @@ where best_finalized_block: NumberFor, ) -> NumberFor { match self.min_blocks_to_keep { - Some(min_blocks_to_keep) => state_machine::oldest_non_pruned_changes_trie( + Some(min_blocks_to_keep) => sp_state_machine::oldest_non_pruned_changes_trie( config, min_blocks_to_keep.into(), best_finalized_block, @@ -733,7 +733,7 @@ where } } -impl state_machine::ChangesTrieRootsStorage> +impl sp_state_machine::ChangesTrieRootsStorage> for DbChangesTrieStorage where Block: BlockT, @@ -741,11 +741,11 @@ where fn build_anchor( &self, hash: H256, - ) -> Result>, String> { + ) -> Result>, String> { utils::read_header::(&*self.db, columns::KEY_LOOKUP, columns::HEADER, BlockId::Hash(hash)) .map_err(|e| e.to_string()) .and_then(|maybe_header| maybe_header.map(|header| - state_machine::ChangesTrieAnchorBlockId { + sp_state_machine::ChangesTrieAnchorBlockId { hash, number: *header.number(), } @@ -754,7 +754,7 @@ where fn root( &self, - anchor: &state_machine::ChangesTrieAnchorBlockId>, + anchor: &sp_state_machine::ChangesTrieAnchorBlockId>, block: NumberFor, ) -> Result, String> { // check API requirement: we can't get NEXT block(s) based on anchor @@ -800,12 +800,12 @@ where } } -impl state_machine::ChangesTrieStorage> +impl sp_state_machine::ChangesTrieStorage> for DbChangesTrieStorage where Block: BlockT, { - fn as_roots_storage(&self) -> &dyn state_machine::ChangesTrieRootsStorage> { + fn as_roots_storage(&self) -> &dyn sp_state_machine::ChangesTrieRootsStorage> { self } @@ -870,7 +870,7 @@ impl> Backend { let is_archive_pruning = config.pruning.is_archive(); let blockchain = BlockchainDb::new(db.clone())?; let meta = blockchain.meta.clone(); - let map_e = |e: state_db::Error| ::sp_blockchain::Error::from(format!("State database error: {:?}", e)); + let map_e = |e: sc_state_db::Error| ::sp_blockchain::Error::from(format!("State database error: {:?}", e)); let state_db: StateDb<_, _> = StateDb::new(config.pruning.clone(), &StateMetaDb(&*db)).map_err(map_e)?; let storage_db = StorageDb { db: db.clone(), @@ -904,8 +904,8 @@ impl> Backend { /// Returns in-memory blockchain that contains the same set of blocks that the self. #[cfg(feature = "test-helpers")] pub fn as_in_memory(&self) -> InMemoryBackend { - use client_api::backend::{Backend as ClientBackend, BlockImportOperation}; - use client::blockchain::Backend as BlockchainBackend; + use sc_client_api::backend::{Backend as ClientBackend, BlockImportOperation}; + use sc_client::blockchain::Backend as BlockchainBackend; let inmem = InMemoryBackend::::new(); @@ -965,7 +965,7 @@ impl> Backend { match cached_changes_trie_config.clone() { Some(cached_changes_trie_config) => Ok(cached_changes_trie_config), None => { - use client_api::backend::Backend; + use sc_client_api::backend::Backend; let changes_trie_config = self .state_at(BlockId::Hash(block))? .storage(well_known_keys::CHANGES_TRIE_CONFIG)? @@ -1109,14 +1109,14 @@ impl> Backend { let hash = if new_canonical == number_u64 { hash } else { - ::client::blockchain::HeaderBackend::hash(&self.blockchain, new_canonical.saturated_into())? + ::sc_client::blockchain::HeaderBackend::hash(&self.blockchain, new_canonical.saturated_into())? .expect("existence of block with number `new_canonical` \ implies existence of blocks with all numbers before it; qed") }; trace!(target: "db", "Canonicalize block #{} ({:?})", new_canonical, hash); let commit = self.storage.state_db.canonicalize_block(&hash) - .map_err(|e: state_db::Error| sp_blockchain::Error::from(format!("State database error: {:?}", e)))?; + .map_err(|e: sc_state_db::Error| sp_blockchain::Error::from(format!("State database error: {:?}", e)))?; apply_state_commit(transaction, commit); }; @@ -1190,7 +1190,7 @@ impl> Backend { } let finalized = if operation.commit_state { - let mut changeset: state_db::ChangeSet> = state_db::ChangeSet::default(); + let mut changeset: sc_state_db::ChangeSet> = sc_state_db::ChangeSet::default(); for (key, (val, rc)) in operation.db_updates.drain() { if rc > 0 { changeset.inserted.push((key, val.to_vec())); @@ -1200,7 +1200,7 @@ impl> Backend { } let number_u64 = number.saturated_into::(); let commit = self.storage.state_db.insert_block(&hash, number_u64, &pending_block.header.parent_hash(), changeset) - .map_err(|e: state_db::Error| sp_blockchain::Error::from(format!("State database error: {:?}", e)))?; + .map_err(|e: sc_state_db::Error| sp_blockchain::Error::from(format!("State database error: {:?}", e)))?; apply_state_commit(&mut transaction, commit); // Check if need to finalize. Genesis is always finalized instantly. @@ -1253,7 +1253,7 @@ impl> Backend { }; let cache_update = if let Some(set_head) = operation.set_head { - if let Some(header) = ::client::blockchain::HeaderBackend::header(&self.blockchain, set_head)? { + if let Some(header) = ::sc_client::blockchain::HeaderBackend::header(&self.blockchain, set_head)? { let number = header.number(); let hash = header.hash(); @@ -1336,7 +1336,7 @@ impl> Backend { transaction.put(columns::META, meta_keys::FINALIZED_BLOCK, &lookup_key); let commit = self.storage.state_db.canonicalize_block(&f_hash) - .map_err(|e: state_db::Error| sp_blockchain::Error::from(format!("State database error: {:?}", e)))?; + .map_err(|e: sc_state_db::Error| sp_blockchain::Error::from(format!("State database error: {:?}", e)))?; apply_state_commit(transaction, commit); let changes_trie_config = self.changes_trie_config(parent_hash)?; @@ -1355,7 +1355,7 @@ impl> Backend { } } -fn apply_state_commit(transaction: &mut DBTransaction, commit: state_db::CommitSet>) { +fn apply_state_commit(transaction: &mut DBTransaction, commit: sc_state_db::CommitSet>) { for (key, val) in commit.data.inserted.into_iter() { transaction.put(columns::STATE, &key[..], &val); } @@ -1370,7 +1370,7 @@ fn apply_state_commit(transaction: &mut DBTransaction, commit: state_db::CommitS } } -impl client_api::backend::AuxStore for Backend where Block: BlockT { +impl sc_client_api::backend::AuxStore for Backend where Block: BlockT { fn insert_aux< 'a, 'b: 'a, @@ -1394,7 +1394,7 @@ impl client_api::backend::AuxStore for Backend where Block: BlockT } } -impl client_api::backend::Backend for Backend where Block: BlockT { +impl sc_client_api::backend::Backend for Backend where Block: BlockT { type BlockImportOperation = BlockImportOperation; type Blockchain = BlockchainDb; type State = CachingState, Block>; @@ -1530,7 +1530,7 @@ impl client_api::backend::Backend for Backend } fn state_at(&self, block: BlockId) -> ClientResult { - use client::blockchain::HeaderBackend as BcHeaderBackend; + use sc_client::blockchain::HeaderBackend as BcHeaderBackend; // special case for genesis initialization match block { @@ -1568,7 +1568,7 @@ impl client_api::backend::Backend for Backend if self.is_archive { match self.blockchain.header(BlockId::Hash(hash.clone())) { Ok(Some(header)) => { - state_machine::Storage::get(self.storage.as_ref(), &header.state_root(), (&[], None)).unwrap_or(None).is_some() + sp_state_machine::Storage::get(self.storage.as_ref(), &header.state_root(), (&[], None)).unwrap_or(None).is_some() }, _ => false, } @@ -1590,7 +1590,7 @@ impl client_api::backend::Backend for Backend } } -impl client_api::backend::LocalBackend for Backend +impl sc_client_api::backend::LocalBackend for Backend where Block: BlockT {} /// TODO: remove me in #3201 @@ -1604,15 +1604,13 @@ mod tests { use hash_db::{HashDB, EMPTY_PREFIX}; use super::*; use crate::columns; - use client_api::backend::{Backend as BTrait, BlockImportOperation as Op}; - use client::blockchain::Backend as BLBTrait; + use sc_client_api::backend::{Backend as BTrait, BlockImportOperation as Op}; + use sc_client::blockchain::Backend as BLBTrait; use sp_runtime::testing::{Header, Block as RawBlock, ExtrinsicWrapper}; use sp_runtime::traits::{Hash, BlakeTwo256}; - use state_machine::{TrieMut, TrieDBMut, ChangesTrieRootsStorage, ChangesTrieStorage}; + use sp_state_machine::{TrieMut, TrieDBMut, ChangesTrieRootsStorage, ChangesTrieStorage}; use sp_blockchain::{lowest_common_ancestor, tree_route}; - use test_client; - type Block = RawBlock>; fn prepare_changes(changes: Vec<(Vec, Vec)>) -> (H256, MemoryDB) { @@ -1849,7 +1847,7 @@ mod tests { backend.commit_operation(op).unwrap(); assert_eq!(backend.storage.db.get( columns::STATE, - &trie::prefixed_key::(&key, EMPTY_PREFIX) + &sp_trie::prefixed_key::(&key, EMPTY_PREFIX) ).unwrap().unwrap(), &b"hello"[..]); hash }; @@ -1886,7 +1884,7 @@ mod tests { backend.commit_operation(op).unwrap(); assert_eq!(backend.storage.db.get( columns::STATE, - &trie::prefixed_key::(&key, EMPTY_PREFIX) + &sp_trie::prefixed_key::(&key, EMPTY_PREFIX) ).unwrap().unwrap(), &b"hello"[..]); hash }; @@ -1924,7 +1922,7 @@ mod tests { assert!(backend.storage.db.get( columns::STATE, - &trie::prefixed_key::(&key, EMPTY_PREFIX) + &sp_trie::prefixed_key::(&key, EMPTY_PREFIX) ).unwrap().is_some()); hash }; @@ -1958,7 +1956,7 @@ mod tests { backend.commit_operation(op).unwrap(); assert!(backend.storage.db.get( columns::STATE, - &trie::prefixed_key::(&key, EMPTY_PREFIX) + &sp_trie::prefixed_key::(&key, EMPTY_PREFIX) ).unwrap().is_none()); } @@ -1967,7 +1965,7 @@ mod tests { backend.finalize_block(BlockId::Number(3), None).unwrap(); assert!(backend.storage.db.get( columns::STATE, - &trie::prefixed_key::(&key, EMPTY_PREFIX) + &sp_trie::prefixed_key::(&key, EMPTY_PREFIX) ).unwrap().is_none()); } @@ -1979,7 +1977,7 @@ mod tests { let check_changes = |backend: &Backend, block: u64, changes: Vec<(Vec, Vec)>| { let (changes_root, mut changes_trie_update) = prepare_changes(changes); - let anchor = state_machine::ChangesTrieAnchorBlockId { + let anchor = sp_state_machine::ChangesTrieAnchorBlockId { hash: backend.blockchain().header(BlockId::Number(block)).unwrap().unwrap().hash(), number: block }; @@ -2033,21 +2031,21 @@ mod tests { // branch1: when asking for finalized block hash let (changes1_root, _) = prepare_changes(changes1); - let anchor = state_machine::ChangesTrieAnchorBlockId { hash: block2_1_1, number: 4 }; + let anchor = sp_state_machine::ChangesTrieAnchorBlockId { hash: block2_1_1, number: 4 }; assert_eq!(backend.changes_tries_storage.root(&anchor, 1), Ok(Some(changes1_root))); // branch2: when asking for finalized block hash - let anchor = state_machine::ChangesTrieAnchorBlockId { hash: block2_2_1, number: 4 }; + let anchor = sp_state_machine::ChangesTrieAnchorBlockId { hash: block2_2_1, number: 4 }; assert_eq!(backend.changes_tries_storage.root(&anchor, 1), Ok(Some(changes1_root))); // branch1: when asking for non-finalized block hash (search by traversal) let (changes2_1_0_root, _) = prepare_changes(changes2_1_0); - let anchor = state_machine::ChangesTrieAnchorBlockId { hash: block2_1_1, number: 4 }; + let anchor = sp_state_machine::ChangesTrieAnchorBlockId { hash: block2_1_1, number: 4 }; assert_eq!(backend.changes_tries_storage.root(&anchor, 3), Ok(Some(changes2_1_0_root))); // branch2: when asking for non-finalized block hash (search using canonicalized hint) let (changes2_2_0_root, _) = prepare_changes(changes2_2_0); - let anchor = state_machine::ChangesTrieAnchorBlockId { hash: block2_2_1, number: 4 }; + let anchor = sp_state_machine::ChangesTrieAnchorBlockId { hash: block2_2_1, number: 4 }; assert_eq!(backend.changes_tries_storage.root(&anchor, 3), Ok(Some(changes2_2_0_root))); // finalize first block of branch2 (block2_2_0) @@ -2059,7 +2057,7 @@ mod tests { // branch1: when asking for finalized block of other branch // => result is incorrect (returned for the block of branch1), but this is expected, // because the other fork is abandoned (forked before finalized header) - let anchor = state_machine::ChangesTrieAnchorBlockId { hash: block2_1_1, number: 4 }; + let anchor = sp_state_machine::ChangesTrieAnchorBlockId { hash: block2_1_1, number: 4 }; assert_eq!(backend.changes_tries_storage.root(&anchor, 3), Ok(Some(changes2_2_0_root))); } @@ -2090,7 +2088,7 @@ mod tests { backend.changes_tries_storage.meta.write().finalized_number = 13; // check that roots of all tries are in the columns::CHANGES_TRIE - let anchor = state_machine::ChangesTrieAnchorBlockId { hash: block13, number: 13 }; + let anchor = sp_state_machine::ChangesTrieAnchorBlockId { hash: block13, number: 13 }; fn read_changes_trie_root(backend: &Backend, num: u64) -> H256 { backend.blockchain().header(BlockId::Number(num)).unwrap().unwrap().digest().logs().iter() .find(|i| i.as_changes_trie_root().is_some()).unwrap().as_changes_trie_root().unwrap().clone() @@ -2161,7 +2159,7 @@ mod tests { let block6 = insert_header(&backend, 6, block5, vec![(b"key_at_6".to_vec(), b"val_at_6".to_vec())], Default::default()); // check that roots of all tries are in the columns::CHANGES_TRIE - let anchor = state_machine::ChangesTrieAnchorBlockId { hash: block6, number: 6 }; + let anchor = sp_state_machine::ChangesTrieAnchorBlockId { hash: block6, number: 6 }; fn read_changes_trie_root(backend: &Backend, num: u64) -> H256 { backend.blockchain().header(BlockId::Number(num)).unwrap().unwrap().digest().logs().iter() .find(|i| i.as_changes_trie_root().is_some()).unwrap().as_changes_trie_root().unwrap().clone() @@ -2348,20 +2346,20 @@ mod tests { #[test] fn test_leaves_with_complex_block_tree() { - let backend: Arc> = Arc::new(Backend::new_test(20, 20)); - test_client::trait_tests::test_leaves_for_backend(backend); + let backend: Arc> = Arc::new(Backend::new_test(20, 20)); + substrate_test_runtime_client::trait_tests::test_leaves_for_backend(backend); } #[test] fn test_children_with_complex_block_tree() { - let backend: Arc> = Arc::new(Backend::new_test(20, 20)); - test_client::trait_tests::test_children_for_backend(backend); + let backend: Arc> = Arc::new(Backend::new_test(20, 20)); + substrate_test_runtime_client::trait_tests::test_children_for_backend(backend); } #[test] fn test_blockchain_query_by_number_gets_canonical() { - let backend: Arc> = Arc::new(Backend::new_test(20, 20)); - test_client::trait_tests::test_blockchain_query_by_number_gets_canonical(backend); + let backend: Arc> = Arc::new(Backend::new_test(20, 20)); + substrate_test_runtime_client::trait_tests::test_blockchain_query_by_number_gets_canonical(backend); } #[test] @@ -2390,7 +2388,7 @@ mod tests { #[test] fn test_aux() { - let backend: Backend = Backend::new_test(0, 0); + let backend: Backend = Backend::new_test(0, 0); assert!(backend.get_aux(b"test").unwrap().is_none()); backend.insert_aux(&[(&b"test"[..], &b"hello"[..])], &[]).unwrap(); assert_eq!(b"hello", &backend.get_aux(b"test").unwrap().unwrap()[..]); @@ -2400,7 +2398,7 @@ mod tests { #[test] fn test_finalize_block_with_justification() { - use client::blockchain::{Backend as BlockChainBackend}; + use sc_client::blockchain::{Backend as BlockChainBackend}; let backend = Backend::::new_test(10, 10); diff --git a/client/db/src/light.rs b/client/db/src/light.rs index 9267a96b2f..31ed012622 100644 --- a/client/db/src/light.rs +++ b/client/db/src/light.rs @@ -22,20 +22,20 @@ use parking_lot::RwLock; use kvdb::{KeyValueDB, DBTransaction}; -use client_api::backend::{AuxStore, NewBlockState}; -use client::blockchain::{ +use sc_client_api::backend::{AuxStore, NewBlockState}; +use sc_client::blockchain::{ BlockStatus, Cache as BlockchainCache,Info as BlockchainInfo, }; -use client::cht; +use sc_client::cht; use sp_blockchain::{ CachedHeaderMetadata, HeaderMetadata, HeaderMetadataCache, Error as ClientError, Result as ClientResult, HeaderBackend as BlockchainHeaderBackend, well_known_cache_keys, }; -use client::light::blockchain::Storage as LightBlockchainStorage; +use sc_client::light::blockchain::Storage as LightBlockchainStorage; use codec::{Decode, Encode}; -use primitives::Blake2Hasher; +use sp_core::Blake2Hasher; use sp_runtime::generic::{DigestItem, BlockId}; use sp_runtime::traits::{Block as BlockT, Header as HeaderT, Zero, One, NumberFor}; use crate::cache::{DbCacheSync, DbCache, ComplexBlockId, EntryType as CacheEntryType}; @@ -559,14 +559,14 @@ fn cht_key>(cht_type: u8, block: N) -> ClientResult<[u8; 5]> { #[cfg(test)] pub(crate) mod tests { - use client::cht; + use sc_client::cht; use sp_runtime::generic::DigestItem; use sp_runtime::testing::{H256 as Hash, Header, Block as RawBlock, ExtrinsicWrapper}; use sp_blockchain::{lowest_common_ancestor, tree_route}; use super::*; type Block = RawBlock>; - type AuthorityId = primitives::ed25519::Public; + type AuthorityId = sp_core::ed25519::Public; pub fn default_header(parent: &Hash, number: u64) -> Header { Header { diff --git a/client/db/src/offchain.rs b/client/db/src/offchain.rs index 565e113ddd..44be8b0768 100644 --- a/client/db/src/offchain.rs +++ b/client/db/src/offchain.rs @@ -56,7 +56,7 @@ impl LocalStorage { } } -impl primitives::offchain::OffchainStorage for LocalStorage { +impl sp_core::offchain::OffchainStorage for LocalStorage { fn set(&mut self, prefix: &[u8], key: &[u8], value: &[u8]) { let key: Vec = prefix.iter().chain(key).cloned().collect(); let mut tx = self.db.transaction(); @@ -117,7 +117,7 @@ impl primitives::offchain::OffchainStorage for LocalStorage { #[cfg(test)] mod tests { use super::*; - use primitives::offchain::OffchainStorage; + use sp_core::offchain::OffchainStorage; #[test] fn should_compare_and_set_and_clear_the_locks_map() { diff --git a/client/db/src/storage_cache.rs b/client/db/src/storage_cache.rs index 9053491b17..9f28539e3e 100644 --- a/client/db/src/storage_cache.rs +++ b/client/db/src/storage_cache.rs @@ -22,11 +22,11 @@ use parking_lot::{Mutex, RwLock, RwLockUpgradableReadGuard}; use linked_hash_map::{LinkedHashMap, Entry}; use hash_db::Hasher; use sp_runtime::traits::{Block as BlockT, Header}; -use primitives::hexdisplay::HexDisplay; -use primitives::storage::ChildInfo; -use state_machine::{backend::Backend as StateBackend, TrieBackend}; +use sp_core::hexdisplay::HexDisplay; +use sp_core::storage::ChildInfo; +use sp_state_machine::{backend::Backend as StateBackend, TrieBackend}; use log::trace; -use client_api::backend::{StorageCollection, ChildStorageCollection}; +use sc_client_api::backend::{StorageCollection, ChildStorageCollection}; use std::hash::Hash as StdHash; const STATE_CACHE_BLOCKS: usize = 12; @@ -642,8 +642,8 @@ impl, B: BlockT> StateBackend for CachingState< mod tests { use super::*; use sp_runtime::testing::{H256, Block as RawBlock, ExtrinsicWrapper}; - use state_machine::backend::InMemory; - use primitives::Blake2Hasher; + use sp_state_machine::backend::InMemory; + use sp_core::Blake2Hasher; type Block = RawBlock>; @@ -890,8 +890,8 @@ mod qc { use super::*; use sp_runtime::testing::{H256, Block as RawBlock, ExtrinsicWrapper}; - use state_machine::backend::InMemory; - use primitives::Blake2Hasher; + use sp_state_machine::backend::InMemory; + use sp_core::Blake2Hasher; type Block = RawBlock>; diff --git a/client/db/src/utils.rs b/client/db/src/utils.rs index 5db1ff8d66..c45fe1c064 100644 --- a/client/db/src/utils.rs +++ b/client/db/src/utils.rs @@ -26,7 +26,7 @@ use kvdb_rocksdb::{Database, DatabaseConfig}; use log::debug; use codec::Decode; -use trie::DBValue; +use sp_trie::DBValue; use sp_runtime::generic::BlockId; use sp_runtime::traits::{ Block as BlockT, Header as HeaderT, Zero, diff --git a/client/executor/Cargo.toml b/client/executor/Cargo.toml index 6dc4b46017..ec5f7c2a2c 100644 --- a/client/executor/Cargo.toml +++ b/client/executor/Cargo.toml @@ -8,17 +8,17 @@ edition = "2018" derive_more = "0.99.2" codec = { package = "parity-scale-codec", version = "1.0.0" } 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" } -runtime_version = { package = "sp-version", path = "../../primitives/version" } -panic-handler = { package = "sp-panic-handler", path = "../../primitives/panic-handler" } +sp-core = { path = "../../primitives/core" } +sp-trie = { path = "../../primitives/trie" } +sp-serializer = { path = "../../primitives/serializer" } +sp-version = { path = "../../primitives/version" } +sp-panic-handler = { path = "../../primitives/panic-handler" } wasmi = "0.6.2" parity-wasm = "0.41.0" lazy_static = "1.4.0" -wasm-interface = { package = "sp-wasm-interface", path = "../../primitives/wasm-interface" } -runtime-interface = { package = "sp-runtime-interface", path = "../../primitives/runtime-interface" } -externalities = { package = "sp-externalities", path = "../../primitives/externalities" } +sp-wasm-interface = { path = "../../primitives/wasm-interface" } +sp-runtime-interface = { path = "../../primitives/runtime-interface" } +sp-externalities = { path = "../../primitives/externalities" } parking_lot = "0.9.0" log = "0.4.8" libsecp256k1 = "0.3.2" @@ -36,10 +36,9 @@ wasmtime-runtime = { version = "0.8", optional = true } assert_matches = "1.3.0" wabt = "0.9.2" hex-literal = "0.2.1" -runtime-test = { package = "sc-runtime-test", path = "runtime-test" } -test-runtime = { package = "substrate-test-runtime", path = "../../test-utils/runtime" } -runtime-interface = { package = "sp-runtime-interface", path = "../../primitives/runtime-interface" } -state_machine = { package = "sp-state-machine", path = "../../primitives/state-machine" } +sc-runtime-test = { path = "runtime-test" } +substrate-test-runtime = { path = "../../test-utils/runtime" } +sp-state-machine = { path = "../../primitives/state-machine" } test-case = "0.3.3" [features] diff --git a/client/executor/runtime-test/Cargo.toml b/client/executor/runtime-test/Cargo.toml index 5d781a7249..00e53199a2 100644 --- a/client/executor/runtime-test/Cargo.toml +++ b/client/executor/runtime-test/Cargo.toml @@ -8,13 +8,13 @@ build = "build.rs" [dependencies] sp-std = { path = "../../../primitives/std", default-features = false } sp-io = { path = "../../../primitives/io", default-features = false } -sandbox = { package = "sp-sandbox", path = "../../../primitives/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 } +sp-sandbox = { path = "../../../primitives/sandbox", default-features = false } +sp-core = { path = "../../../primitives/core", default-features = false } +sp-runtime = { path = "../../../primitives/runtime", default-features = false } [build-dependencies] wasm-builder-runner = { package = "substrate-wasm-builder-runner", path = "../../../utils/wasm-builder-runner", version = "1.0.4" } [features] default = [ "std" ] -std = ["sp-io/std", "sandbox/std", "sp-std/std"] +std = ["sp-io/std", "sp-sandbox/std", "sp-std/std"] diff --git a/client/executor/runtime-test/src/lib.rs b/client/executor/runtime-test/src/lib.rs index 7a97aebc90..c49b9e70b4 100644 --- a/client/executor/runtime-test/src/lib.rs +++ b/client/executor/runtime-test/src/lib.rs @@ -16,9 +16,9 @@ use sp_io::{ #[cfg(not(feature = "std"))] use sp_runtime::{print, traits::{BlakeTwo256, Hash}}; #[cfg(not(feature = "std"))] -use primitives::{ed25519, sr25519}; +use sp_core::{ed25519, sr25519}; -primitives::wasm_export_functions! { +sp_core::wasm_export_functions! { fn test_data_in(input: Vec) -> Vec { print("set_storage"); storage::set(b"input", &input); @@ -112,8 +112,8 @@ primitives::wasm_export_functions! { execute_sandboxed( &code, &[ - sandbox::TypedValue::I32(0x12345678), - sandbox::TypedValue::I64(0x1234567887654321), + sp_sandbox::TypedValue::I32(0x12345678), + sp_sandbox::TypedValue::I64(0x1234567887654321), ], ).is_ok() } @@ -122,10 +122,10 @@ primitives::wasm_export_functions! { let ok = match execute_sandboxed( &code, &[ - sandbox::TypedValue::I32(0x1336), + sp_sandbox::TypedValue::I32(0x1336), ] ) { - Ok(sandbox::ReturnValue::Value(sandbox::TypedValue::I32(0x1337))) => true, + Ok(sp_sandbox::ReturnValue::Value(sp_sandbox::TypedValue::I32(0x1337))) => true, _ => false, }; @@ -133,19 +133,19 @@ primitives::wasm_export_functions! { } fn test_sandbox_instantiate(code: Vec) -> u8 { - let env_builder = sandbox::EnvironmentDefinitionBuilder::new(); - let code = match sandbox::Instance::new(&code, &env_builder, &mut ()) { + let env_builder = sp_sandbox::EnvironmentDefinitionBuilder::new(); + let code = match sp_sandbox::Instance::new(&code, &env_builder, &mut ()) { Ok(_) => 0, - Err(sandbox::Error::Module) => 1, - Err(sandbox::Error::Execution) => 2, - Err(sandbox::Error::OutOfBounds) => 3, + Err(sp_sandbox::Error::Module) => 1, + Err(sp_sandbox::Error::Execution) => 2, + Err(sp_sandbox::Error::OutOfBounds) => 3, }; code } fn test_offchain_local_storage() -> bool { - let kind = primitives::offchain::StorageKind::PERSISTENT; + let kind = sp_core::offchain::StorageKind::PERSISTENT; 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())); @@ -161,7 +161,7 @@ primitives::wasm_export_functions! { } fn test_offchain_local_storage_with_none() { - let kind = primitives::offchain::StorageKind::PERSISTENT; + let kind = sp_core::offchain::StorageKind::PERSISTENT; assert_eq!(sp_io::offchain::local_storage_get(kind, b"test"), None); let res = sp_io::offchain::local_storage_compare_and_set(kind, b"test", None, b"value"); @@ -170,7 +170,7 @@ primitives::wasm_export_functions! { } fn test_offchain_http() -> bool { - use primitives::offchain::HttpRequestStatus; + use sp_core::offchain::HttpRequestStatus; let run = || -> Option<()> { let id = sp_io::offchain::http_request_start( "POST", @@ -201,45 +201,45 @@ primitives::wasm_export_functions! { #[cfg(not(feature = "std"))] fn execute_sandboxed( code: &[u8], - args: &[sandbox::TypedValue], -) -> Result { + args: &[sp_sandbox::TypedValue], +) -> Result { struct State { counter: u32, } fn env_assert( _e: &mut State, - args: &[sandbox::TypedValue], - ) -> Result { + args: &[sp_sandbox::TypedValue], + ) -> Result { if args.len() != 1 { - return Err(sandbox::HostError); + return Err(sp_sandbox::HostError); } - let condition = args[0].as_i32().ok_or_else(|| sandbox::HostError)?; + let condition = args[0].as_i32().ok_or_else(|| sp_sandbox::HostError)?; if condition != 0 { - Ok(sandbox::ReturnValue::Unit) + Ok(sp_sandbox::ReturnValue::Unit) } else { - Err(sandbox::HostError) + Err(sp_sandbox::HostError) } } fn env_inc_counter( e: &mut State, - args: &[sandbox::TypedValue], - ) -> Result { + args: &[sp_sandbox::TypedValue], + ) -> Result { if args.len() != 1 { - return Err(sandbox::HostError); + return Err(sp_sandbox::HostError); } - let inc_by = args[0].as_i32().ok_or_else(|| sandbox::HostError)?; + let inc_by = args[0].as_i32().ok_or_else(|| sp_sandbox::HostError)?; e.counter += inc_by as u32; - Ok(sandbox::ReturnValue::Value(sandbox::TypedValue::I32(e.counter as i32))) + Ok(sp_sandbox::ReturnValue::Value(sp_sandbox::TypedValue::I32(e.counter as i32))) } let mut state = State { counter: 0 }; let env_builder = { - let mut env_builder = sandbox::EnvironmentDefinitionBuilder::new(); + let mut env_builder = sp_sandbox::EnvironmentDefinitionBuilder::new(); env_builder.add_host_func("env", "assert", env_assert); env_builder.add_host_func("env", "inc_counter", env_inc_counter); - let memory = match sandbox::Memory::new(1, Some(16)) { + let memory = match sp_sandbox::Memory::new(1, Some(16)) { Ok(m) => m, Err(_) => unreachable!(" Memory::new() can return Err only if parameters are borked; \ @@ -251,8 +251,8 @@ fn execute_sandboxed( env_builder }; - let mut instance = sandbox::Instance::new(code, &env_builder, &mut state)?; + let mut instance = sp_sandbox::Instance::new(code, &env_builder, &mut state)?; let result = instance.invoke("call", args, &mut state); - result.map_err(|_| sandbox::HostError) + result.map_err(|_| sp_sandbox::HostError) } diff --git a/client/executor/src/allocator.rs b/client/executor/src/allocator.rs index 523499db71..88624a0ec2 100644 --- a/client/executor/src/allocator.rs +++ b/client/executor/src/allocator.rs @@ -50,7 +50,7 @@ use crate::error::{Error, Result}; use log::trace; use std::convert::{TryFrom, TryInto}; use std::ops::Range; -use wasm_interface::{Pointer, WordSize}; +use sp_wasm_interface::{Pointer, WordSize}; // The pointers need to be aligned to 8 bytes. This is because the // maximum value type handled by wasm32 is u64. diff --git a/client/executor/src/deprecated_host_interface.rs b/client/executor/src/deprecated_host_interface.rs index f585659d9e..2339dcdf70 100644 --- a/client/executor/src/deprecated_host_interface.rs +++ b/client/executor/src/deprecated_host_interface.rs @@ -18,12 +18,12 @@ use codec::Encode; use std::{convert::TryFrom, str}; -use primitives::{ +use sp_core::{ blake2_128, blake2_256, twox_64, twox_128, twox_256, ed25519, sr25519, keccak_256, Blake2Hasher, Pair, crypto::KeyTypeId, offchain, }; -use trie::{TrieConfiguration, trie_types::Layout}; -use wasm_interface::{ +use sp_trie::{TrieConfiguration, trie_types::Layout}; +use sp_wasm_interface::{ Pointer, WordSize, WritePrimitive, ReadPrimitive, FunctionContext, Result as WResult, }; diff --git a/client/executor/src/error.rs b/client/executor/src/error.rs index 84ae79a789..a15452c48b 100644 --- a/client/executor/src/error.rs +++ b/client/executor/src/error.rs @@ -16,7 +16,7 @@ //! Rust executor possible errors. -use serializer; +use sp_serializer; use wasmi; #[cfg(feature = "wasmtime")] use wasmtime_jit::{ActionError, SetupError}; @@ -28,7 +28,7 @@ pub type Result = std::result::Result; #[derive(Debug, derive_more::Display, derive_more::From)] pub enum Error { /// Unserializable Data - InvalidData(serializer::Error), + InvalidData(sp_serializer::Error), /// Trap occured during execution Trap(wasmi::Trap), /// Wasmi loading/instantiating error diff --git a/client/executor/src/integration_tests/mod.rs b/client/executor/src/integration_tests/mod.rs index f02b532619..24e9e022f7 100644 --- a/client/executor/src/integration_tests/mod.rs +++ b/client/executor/src/integration_tests/mod.rs @@ -18,15 +18,15 @@ mod sandbox; use codec::{Encode, Decode}; use hex_literal::hex; -use primitives::{ +use sp_core::{ Blake2Hasher, blake2_128, blake2_256, ed25519, sr25519, map, Pair, offchain::{OffchainExt, testing}, traits::Externalities, }; -use runtime_test::WASM_BINARY; -use state_machine::TestExternalities as CoreTestExternalities; +use sc_runtime_test::WASM_BINARY; +use sp_state_machine::TestExternalities as CoreTestExternalities; use test_case::test_case; -use trie::{TrieConfiguration, trie_types::Layout}; +use sp_trie::{TrieConfiguration, trie_types::Layout}; use crate::WasmExecutionMethod; @@ -128,7 +128,7 @@ fn storage_should_work(wasm_method: WasmExecutionMethod) { assert_eq!(output, b"all ok!".to_vec().encode()); } - let expected = TestExternalities::new(primitives::storage::Storage { + let expected = TestExternalities::new(sp_core::storage::Storage { top: map![ b"input".to_vec() => b"Hello world".to_vec(), b"foo".to_vec() => b"bar".to_vec(), @@ -165,7 +165,7 @@ fn clear_prefix_should_work(wasm_method: WasmExecutionMethod) { assert_eq!(output, b"all ok!".to_vec().encode()); } - let expected = TestExternalities::new(primitives::storage::Storage { + let expected = TestExternalities::new(sp_core::storage::Storage { top: map![ b"aaa".to_vec() => b"1".to_vec(), b"aab".to_vec() => b"2".to_vec(), @@ -443,7 +443,7 @@ fn ordered_trie_root_should_work(wasm_method: WasmExecutionMethod) { #[test_case(WasmExecutionMethod::Interpreted)] #[cfg_attr(feature = "wasmtime", test_case(WasmExecutionMethod::Compiled))] fn offchain_local_storage_should_work(wasm_method: WasmExecutionMethod) { - use primitives::offchain::OffchainStorage; + use sp_core::offchain::OffchainStorage; let mut ext = TestExternalities::default(); let (offchain, state) = testing::TestOffchainExt::new(); diff --git a/client/executor/src/integration_tests/sandbox.rs b/client/executor/src/integration_tests/sandbox.rs index c18b848acc..f18291da67 100644 --- a/client/executor/src/integration_tests/sandbox.rs +++ b/client/executor/src/integration_tests/sandbox.rs @@ -18,7 +18,7 @@ use super::{TestExternalities, call_in_wasm}; use crate::WasmExecutionMethod; use codec::Encode; -use runtime_test::WASM_BINARY; +use sc_runtime_test::WASM_BINARY; use test_case::test_case; use wabt; diff --git a/client/executor/src/lib.rs b/client/executor/src/lib.rs index 97bdb0e20d..5045874859 100644 --- a/client/executor/src/lib.rs +++ b/client/executor/src/lib.rs @@ -46,12 +46,12 @@ mod integration_tests; pub mod error; pub use wasmi; pub use native_executor::{with_native_environment, NativeExecutor, NativeExecutionDispatch}; -pub use runtime_version::{RuntimeVersion, NativeVersion}; +pub use sp_version::{RuntimeVersion, NativeVersion}; pub use codec::Codec; #[doc(hidden)] -pub use primitives::traits::Externalities; +pub use sp_core::traits::Externalities; #[doc(hidden)] -pub use wasm_interface; +pub use sp_wasm_interface; pub use wasm_runtime::WasmExecutionMethod; /// Call the given `function` in the given wasm `code`. @@ -64,7 +64,7 @@ pub use wasm_runtime::WasmExecutionMethod; /// - `heap_pages`: The number of heap pages to allocate. /// /// Returns the `Vec` that contains the return value of the function. -pub fn call_in_wasm( +pub fn call_in_wasm( function: &str, call_data: &[u8], execution_method: WasmExecutionMethod, @@ -93,7 +93,7 @@ pub trait RuntimeInfo { #[cfg(test)] mod tests { use super::*; - use runtime_test::WASM_BINARY; + use sc_runtime_test::WASM_BINARY; use sp_io::TestExternalities; #[test] diff --git a/client/executor/src/native_executor.rs b/client/executor/src/native_executor.rs index 635acc8716..09e514f603 100644 --- a/client/executor/src/native_executor.rs +++ b/client/executor/src/native_executor.rs @@ -19,17 +19,17 @@ use crate::{ wasm_runtime::{RuntimesCache, WasmExecutionMethod, WasmRuntime}, }; -use runtime_version::{NativeVersion, RuntimeVersion}; +use sp_version::{NativeVersion, RuntimeVersion}; use codec::{Decode, Encode}; -use primitives::{NativeOrEncoded, traits::{CodeExecutor, Externalities}}; +use sp_core::{NativeOrEncoded, traits::{CodeExecutor, Externalities}}; use log::trace; use std::{result, cell::RefCell, panic::{UnwindSafe, AssertUnwindSafe}}; -use wasm_interface::{HostFunctions, Function}; +use sp_wasm_interface::{HostFunctions, Function}; thread_local! { static RUNTIMES_CACHE: RefCell = RefCell::new(RuntimesCache::new()); @@ -43,7 +43,7 @@ pub(crate) fn safe_call(f: F) -> Result { // Substrate uses custom panic hook that terminates process on panic. Disable // termination for the native call. - let _guard = panic_handler::AbortGuard::force_unwind(); + let _guard = sp_panic_handler::AbortGuard::force_unwind(); std::panic::catch_unwind(f).map_err(|_| Error::Runtime) } @@ -53,7 +53,7 @@ pub(crate) fn safe_call(f: F) -> Result pub fn with_native_environment(ext: &mut dyn Externalities, f: F) -> Result where F: UnwindSafe + FnOnce() -> U { - externalities::set_and_run_with_externalities(ext, move || safe_call(f)) + sp_externalities::set_and_run_with_externalities(ext, move || safe_call(f)) } /// Delegate for dispatching a CodeExecutor call. @@ -267,8 +267,8 @@ impl CodeExecutor for NativeExecutor { /// ``` /// sc_executor::native_executor_instance!( /// pub MyExecutor, -/// test_runtime::api::dispatch, -/// test_runtime::native_version, +/// substrate_test_runtime::api::dispatch, +/// substrate_test_runtime::native_version, /// ); /// ``` /// @@ -278,7 +278,7 @@ impl CodeExecutor for NativeExecutor { /// executor aware of the host functions for these interfaces. /// /// ``` -/// # use runtime_interface::runtime_interface; +/// # use sp_runtime_interface::runtime_interface; /// /// #[runtime_interface] /// trait MyInterface { @@ -289,8 +289,8 @@ impl CodeExecutor for NativeExecutor { /// /// sc_executor::native_executor_instance!( /// pub MyExecutor, -/// test_runtime::api::dispatch, -/// test_runtime::native_version, +/// substrate_test_runtime::api::dispatch, +/// substrate_test_runtime::native_version, /// my_interface::HostFunctions, /// ); /// ``` @@ -337,7 +337,7 @@ macro_rules! native_executor_instance { #[cfg(test)] mod tests { use super::*; - use runtime_interface::runtime_interface; + use sp_runtime_interface::runtime_interface; #[runtime_interface] trait MyInterface { @@ -348,8 +348,8 @@ mod tests { native_executor_instance!( pub MyExecutor, - test_runtime::api::dispatch, - test_runtime::native_version, + substrate_test_runtime::api::dispatch, + substrate_test_runtime::native_version, (my_interface::HostFunctions, my_interface::HostFunctions), ); diff --git a/client/executor/src/sandbox.rs b/client/executor/src/sandbox.rs index da71b06672..e0e1780a14 100644 --- a/client/executor/src/sandbox.rs +++ b/client/executor/src/sandbox.rs @@ -21,12 +21,12 @@ use crate::error::{Result, Error}; use std::{collections::HashMap, rc::Rc}; use codec::{Decode, Encode}; -use primitives::sandbox as sandbox_primitives; +use sp_core::sandbox as sandbox_primitives; use wasmi::{ Externals, ImportResolver, MemoryInstance, MemoryRef, Module, ModuleInstance, ModuleRef, RuntimeArgs, RuntimeValue, Trap, TrapKind, memory_units::Pages, }; -use wasm_interface::{Pointer, WordSize}; +use sp_wasm_interface::{Pointer, WordSize}; /// Index of a function inside the supervisor. /// diff --git a/client/executor/src/wasm_runtime.rs b/client/executor/src/wasm_runtime.rs index e033285232..6181a1aab2 100644 --- a/client/executor/src/wasm_runtime.rs +++ b/client/executor/src/wasm_runtime.rs @@ -26,12 +26,12 @@ use log::{trace, warn}; use codec::Decode; -use primitives::{storage::well_known_keys, traits::Externalities}; +use sp_core::{storage::well_known_keys, traits::Externalities}; -use runtime_version::RuntimeVersion; +use sp_version::RuntimeVersion; use std::{collections::hash_map::{Entry, HashMap}, panic::AssertUnwindSafe}; -use wasm_interface::Function; +use sp_wasm_interface::Function; /// The Substrate Wasm runtime. pub trait WasmRuntime { @@ -259,7 +259,7 @@ fn create_versioned_wasm_runtime( #[cfg(test)] mod tests { - use wasm_interface::HostFunctions; + use sp_wasm_interface::HostFunctions; #[test] fn host_functions_are_equal() { diff --git a/client/executor/src/wasm_utils.rs b/client/executor/src/wasm_utils.rs index caa63ddbf2..95b1db65ce 100644 --- a/client/executor/src/wasm_utils.rs +++ b/client/executor/src/wasm_utils.rs @@ -16,28 +16,28 @@ //! Utilities for defining the wasm host environment. -use wasm_interface::{Pointer, WordSize}; +use sp_wasm_interface::{Pointer, WordSize}; /// Converts arguments into respective WASM types. #[macro_export] macro_rules! convert_args { () => ([]); - ( $( $t:ty ),* ) => ( [ $( <$t as $crate::wasm_interface::IntoValue>::VALUE_TYPE, )* ] ); + ( $( $t:ty ),* ) => ( [ $( <$t as $crate::sp_wasm_interface::IntoValue>::VALUE_TYPE, )* ] ); } /// Generates a WASM signature for given list of parameters. #[macro_export] macro_rules! gen_signature { ( ( $( $params: ty ),* ) ) => ( - $crate::wasm_interface::Signature { + $crate::sp_wasm_interface::Signature { args: std::borrow::Cow::Borrowed(&convert_args!( $( $params ),* )[..]), return_value: None, } ); ( ( $( $params: ty ),* ) -> $returns:ty ) => ( - $crate::wasm_interface::Signature { + $crate::sp_wasm_interface::Signature { args: std::borrow::Cow::Borrowed(&convert_args!( $( $params ),* )[..]), - return_value: Some(<$returns as $crate::wasm_interface::IntoValue>::VALUE_TYPE), + return_value: Some(<$returns as $crate::sp_wasm_interface::IntoValue>::VALUE_TYPE), } ); } @@ -63,18 +63,18 @@ macro_rules! gen_functions { struct $name; #[allow(unused)] - impl $crate::wasm_interface::Function for $name { + impl $crate::sp_wasm_interface::Function for $name { fn name(&self) -> &str { stringify!($name) } - fn signature(&self) -> $crate::wasm_interface::Signature { + fn signature(&self) -> $crate::sp_wasm_interface::Signature { gen_signature!( ( $( $params ),* ) $( -> $returns )? ) } fn execute( &self, - context: &mut dyn $crate::wasm_interface::FunctionContext, - args: &mut dyn Iterator, - ) -> ::std::result::Result, String> { + context: &mut dyn $crate::sp_wasm_interface::FunctionContext, + args: &mut dyn Iterator, + ) -> ::std::result::Result, String> { let mut $context = context; marshall! { args, @@ -83,7 +83,7 @@ macro_rules! gen_functions { } } - &$name as &dyn $crate::wasm_interface::Function + &$name as &dyn $crate::sp_wasm_interface::Function }, } $context, @@ -103,7 +103,7 @@ macro_rules! unmarshall_args { $( let $names : $params = $args_iter.next() - .and_then(|val| <$params as $crate::wasm_interface::TryFromValue>::try_from_value(val)) + .and_then(|val| <$params as $crate::sp_wasm_interface::TryFromValue>::try_from_value(val)) .expect( "`$args_iter` comes from an argument of Externals::execute_function; args to an external call always matches the signature of the external; @@ -140,7 +140,7 @@ macro_rules! marshall { unmarshall_args!($body, $args_iter, $( $names : $params ),*) }); let r = body()?; - return Ok(Some($crate::wasm_interface::IntoValue::into_value(r))) + return Ok(Some($crate::sp_wasm_interface::IntoValue::into_value(r))) }); ( $args_iter:ident, ( $( $names:ident : $params:ty ),* ) => $body:tt ) => ({ let body = $crate::wasm_utils::constrain_closure::<(), _>(|| { @@ -162,9 +162,9 @@ macro_rules! impl_wasm_host_interface { )* } ) => ( - impl $crate::wasm_interface::HostFunctions for $interface_name { + impl $crate::sp_wasm_interface::HostFunctions for $interface_name { #[allow(non_camel_case_types)] - fn host_functions() -> Vec<&'static dyn $crate::wasm_interface::Function> { + fn host_functions() -> Vec<&'static dyn $crate::sp_wasm_interface::Function> { gen_functions!( $context, $( $name( $( $names: $params ),* ) $( -> $returns )? { $( $body )* } )* diff --git a/client/executor/src/wasmi_execution.rs b/client/executor/src/wasmi_execution.rs index 2593de68c2..cdead6cee1 100644 --- a/client/executor/src/wasmi_execution.rs +++ b/client/executor/src/wasmi_execution.rs @@ -23,14 +23,14 @@ use wasmi::{ }; use crate::error::{Error, WasmError}; use codec::{Encode, Decode}; -use primitives::{sandbox as sandbox_primitives, traits::Externalities}; +use sp_core::{sandbox as sandbox_primitives, traits::Externalities}; use crate::sandbox; use crate::allocator; use crate::wasm_utils::interpret_runtime_api_result; use crate::wasm_runtime::WasmRuntime; use log::{error, trace}; use parity_wasm::elements::{deserialize_buffer, DataSegment, Instruction, Module as RawModule}; -use wasm_interface::{ +use sp_wasm_interface::{ FunctionContext, Pointer, WordSize, Sandbox, MemoryId, Result as WResult, Function, }; @@ -273,7 +273,7 @@ impl<'a> wasmi::ModuleImportResolver for Resolver<'a> { fn resolve_func(&self, name: &str, signature: &wasmi::Signature) -> std::result::Result { - let signature = wasm_interface::Signature::from(signature); + let signature = sp_wasm_interface::Signature::from(signature); for (function_index, function) in self.0.iter().enumerate() { if name == function.name() { if signature == function.signature() { @@ -364,7 +364,7 @@ fn call_in_wasm_module( let offset = fec.allocate_memory(data.len() as u32)?; fec.write_memory(offset, data)?; - let result = externalities::set_and_run_with_externalities( + let result = sp_externalities::set_and_run_with_externalities( ext, || module_instance.invoke_export( method, diff --git a/client/executor/src/wasmtime/function_executor.rs b/client/executor/src/wasmtime/function_executor.rs index 34a3007689..4db7adc83a 100644 --- a/client/executor/src/wasmtime/function_executor.rs +++ b/client/executor/src/wasmtime/function_executor.rs @@ -25,12 +25,12 @@ use codec::{Decode, Encode}; use cranelift_codegen::ir; use cranelift_codegen::isa::TargetFrontendConfig; use log::trace; -use primitives::sandbox as sandbox_primitives; +use sp_core::sandbox as sandbox_primitives; use std::{cmp, mem, ptr}; use wasmtime_environ::translate_signature; use wasmtime_jit::{ActionError, Compiler}; use wasmtime_runtime::{Export, VMCallerCheckedAnyfunc, VMContext, wasmtime_call_trampoline}; -use wasm_interface::{ +use sp_wasm_interface::{ FunctionContext, MemoryId, Pointer, Result as WResult, Sandbox, Signature, Value, ValueType, WordSize, }; diff --git a/client/executor/src/wasmtime/runtime.rs b/client/executor/src/wasmtime/runtime.rs index 1a7385cc46..6fdf9f0e9e 100644 --- a/client/executor/src/wasmtime/runtime.rs +++ b/client/executor/src/wasmtime/runtime.rs @@ -33,7 +33,7 @@ use std::cell::RefCell; use std::collections::HashMap; use std::convert::TryFrom; use std::rc::Rc; -use wasm_interface::{Pointer, WordSize, Function}; +use sp_wasm_interface::{Pointer, WordSize, Function}; use wasmtime_environ::{Module, translate_signature}; use wasmtime_jit::{ ActionOutcome, ActionError, CodeMemory, CompilationStrategy, CompiledModule, Compiler, Context, @@ -175,7 +175,7 @@ fn call_method( let args = [RuntimeValue::I32(u32::from(data_ptr) as i32), RuntimeValue::I32(data_len as i32)]; // Invoke the function in the runtime. - let outcome = externalities::set_and_run_with_externalities(ext, || { + let outcome = sp_externalities::set_and_run_with_externalities(ext, || { context .invoke(&mut instance, method, &args[..]) .map_err(Error::Wasmtime) diff --git a/client/executor/src/wasmtime/trampoline.rs b/client/executor/src/wasmtime/trampoline.rs index 25b3fefbfa..1251125251 100644 --- a/client/executor/src/wasmtime/trampoline.rs +++ b/client/executor/src/wasmtime/trampoline.rs @@ -26,7 +26,7 @@ use cranelift_codegen::print_errors::pretty_error; use wasmtime_jit::{CodeMemory, Compiler}; use wasmtime_environ::CompiledFunction; use wasmtime_runtime::{VMContext, VMFunctionBody}; -use wasm_interface::{Function, Value, ValueType}; +use sp_wasm_interface::{Function, Value, ValueType}; use std::{cmp, panic::{self, AssertUnwindSafe}, ptr}; use crate::error::{Error, WasmError}; diff --git a/client/executor/src/wasmtime/util.rs b/client/executor/src/wasmtime/util.rs index 874ccc8c85..55cb5ecc50 100644 --- a/client/executor/src/wasmtime/util.rs +++ b/client/executor/src/wasmtime/util.rs @@ -18,7 +18,7 @@ use crate::error::{Error, Result}; use cranelift_codegen::{ir, isa}; use std::ops::Range; -use wasm_interface::{Pointer, Signature, ValueType}; +use sp_wasm_interface::{Pointer, Signature, ValueType}; /// Read data from a slice of memory into a destination buffer. /// diff --git a/client/finality-grandpa/Cargo.toml b/client/finality-grandpa/Cargo.toml index 3b1d57d213..8f4cb2298d 100644 --- a/client/finality-grandpa/Cargo.toml +++ b/client/finality-grandpa/Cargo.toml @@ -12,31 +12,31 @@ futures-timer = "2.0.2" log = "0.4.8" parking_lot = "0.9.0" rand = "0.7.2" -codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] } +parity-scale-codec = { version = "1.0.0", features = ["derive"] } sp-runtime = { path = "../../primitives/runtime" } -consensus_common = { package = "sp-consensus", path = "../../primitives/consensus/common" } -primitives = { package = "sp-core", path = "../../primitives/core" } +sp-consensus = { path = "../../primitives/consensus/common" } +sp-core = { path = "../../primitives/core" } sc-telemetry = { path = "../telemetry" } -keystore = { package = "sc-keystore", path = "../keystore" } +sc-keystore = { path = "../keystore" } serde_json = "1.0.41" -client-api = { package = "sc-client-api", path = "../api" } -client = { package = "sc-client", path = "../" } -inherents = { package = "sp-inherents", path = "../../primitives/inherents" } +sc-client-api = { path = "../api" } +sc-client = { path = "../" } +sp-inherents = { path = "../../primitives/inherents" } sp-blockchain = { path = "../../primitives/blockchain" } -network = { package = "sc-network", path = "../network" } -network-gossip = { package = "sc-network-gossip", path = "../network-gossip" } +sc-network = { path = "../network" } +sc-network-gossip = { path = "../network-gossip" } sp-finality-tracker = { path = "../../primitives/finality-tracker" } -fg_primitives = { package = "sp-finality-grandpa", path = "../../primitives/finality-grandpa" } -grandpa = { package = "finality-grandpa", version = "0.10.1", features = ["derive-codec"] } +sp-finality-grandpa = { path = "../../primitives/finality-grandpa" } +finality-grandpa = { version = "0.10.1", features = ["derive-codec"] } [dev-dependencies] -grandpa = { package = "finality-grandpa", version = "0.10.1", features = ["derive-codec", "test-helpers"] } -network = { package = "sc-network", path = "../network" } +finality-grandpa = { version = "0.10.1", features = ["derive-codec", "test-helpers"] } +sc-network = { path = "../network" } sc-network-test = { path = "../network/test" } -keyring = { package = "sp-keyring", path = "../../primitives/keyring" } -test-client = { package = "substrate-test-runtime-client", path = "../../test-utils/runtime/client"} -babe_primitives = { package = "sp-consensus-babe", path = "../../primitives/consensus/babe" } -state_machine = { package = "sp-state-machine", path = "../../primitives/state-machine" } +sp-keyring = { path = "../../primitives/keyring" } +substrate-test-runtime-client = { path = "../../test-utils/runtime/client"} +sp-consensus-babe = { path = "../../primitives/consensus/babe" } +sp-state-machine = { path = "../../primitives/state-machine" } env_logger = "0.7.0" tokio = "0.1.22" tempfile = "3.1.0" diff --git a/client/finality-grandpa/src/authorities.rs b/client/finality-grandpa/src/authorities.rs index 4bc4e3c7b8..aa9b850779 100644 --- a/client/finality-grandpa/src/authorities.rs +++ b/client/finality-grandpa/src/authorities.rs @@ -18,11 +18,11 @@ use fork_tree::ForkTree; use parking_lot::RwLock; -use grandpa::voter_set::VoterSet; -use codec::{Encode, Decode}; +use finality_grandpa::voter_set::VoterSet; +use parity_scale_codec::{Encode, Decode}; use log::{debug, info}; use sc_telemetry::{telemetry, CONSENSUS_INFO}; -use fg_primitives::{AuthorityId, AuthorityList}; +use sp_finality_grandpa::{AuthorityId, AuthorityList}; use std::cmp::Ord; use std::fmt::Debug; @@ -403,7 +403,7 @@ pub(crate) struct PendingChange { } impl Decode for PendingChange { - fn decode(value: &mut I) -> Result { + fn decode(value: &mut I) -> Result { let next_authorities = Decode::decode(value)?; let delay = Decode::decode(value)?; let canon_height = Decode::decode(value)?; @@ -431,7 +431,7 @@ impl + Clone> PendingChange { #[cfg(test)] mod tests { use super::*; - use primitives::crypto::Public; + use sp_core::crypto::Public; fn static_is_descendent_of(value: bool) -> impl Fn(&A, &A) -> Result diff --git a/client/finality-grandpa/src/aux_schema.rs b/client/finality-grandpa/src/aux_schema.rs index 3e171a9441..63394dcbe1 100644 --- a/client/finality-grandpa/src/aux_schema.rs +++ b/client/finality-grandpa/src/aux_schema.rs @@ -18,14 +18,14 @@ use std::fmt::Debug; use std::sync::Arc; -use codec::{Encode, Decode}; -use client_api::backend::AuxStore; +use parity_scale_codec::{Encode, Decode}; +use sc_client_api::backend::AuxStore; use sp_blockchain::{Result as ClientResult, Error as ClientError}; use fork_tree::ForkTree; -use grandpa::round::State as RoundState; +use finality_grandpa::round::State as RoundState; use sp_runtime::traits::{Block as BlockT, NumberFor}; use log::{info, warn}; -use fg_primitives::{AuthorityList, SetId, RoundNumber}; +use sp_finality_grandpa::{AuthorityList, SetId, RoundNumber}; use crate::authorities::{AuthoritySet, SharedAuthoritySet, PendingChange, DelayKind}; use crate::consensus_changes::{SharedConsensusChanges, ConsensusChanges}; @@ -439,14 +439,14 @@ pub(crate) fn load_authorities(backend: &B) #[cfg(test)] mod test { - use fg_primitives::AuthorityId; - use primitives::H256; - use test_client; + use sp_finality_grandpa::AuthorityId; + use sp_core::H256; + use substrate_test_runtime_client; use super::*; #[test] fn load_decode_from_v0_migrates_data_format() { - let client = test_client::new(); + let client = substrate_test_runtime_client::new(); let authorities = vec![(AuthorityId::default(), 100)]; let set_id = 3; @@ -482,7 +482,7 @@ mod test { ); // should perform the migration - load_persistent::( + load_persistent::( &client, H256::random(), 0, @@ -494,7 +494,7 @@ mod test { Some(2), ); - let PersistentData { authority_set, set_state, .. } = load_persistent::( + let PersistentData { authority_set, set_state, .. } = load_persistent::( &client, H256::random(), 0, @@ -534,7 +534,7 @@ mod test { #[test] fn load_decode_from_v1_migrates_data_format() { - let client = test_client::new(); + let client = substrate_test_runtime_client::new(); let authorities = vec![(AuthorityId::default(), 100)]; let set_id = 3; @@ -572,7 +572,7 @@ mod test { ); // should perform the migration - load_persistent::( + load_persistent::( &client, H256::random(), 0, @@ -584,7 +584,7 @@ mod test { Some(2), ); - let PersistentData { authority_set, set_state, .. } = load_persistent::( + let PersistentData { authority_set, set_state, .. } = load_persistent::( &client, H256::random(), 0, @@ -624,11 +624,11 @@ mod test { #[test] fn write_read_concluded_rounds() { - let client = test_client::new(); + let client = substrate_test_runtime_client::new(); let hash = H256::random(); let round_state = RoundState::genesis((hash, 0)); - let completed_round = CompletedRound:: { + let completed_round = CompletedRound:: { number: 42, state: round_state.clone(), base: round_state.prevote_ghost.unwrap(), @@ -642,7 +642,7 @@ mod test { round_number.using_encoded(|n| key.extend(n)); assert_eq!( - load_decode::<_, CompletedRound::>(&client, &key).unwrap(), + load_decode::<_, CompletedRound::>(&client, &key).unwrap(), Some(completed_round), ); } diff --git a/client/finality-grandpa/src/communication/gossip.rs b/client/finality-grandpa/src/communication/gossip.rs index 6ed70b66ae..2ac6c9cf49 100644 --- a/client/finality-grandpa/src/communication/gossip.rs +++ b/client/finality-grandpa/src/communication/gossip.rs @@ -83,10 +83,10 @@ //! We only send polite messages to peers, use sp_runtime::traits::{NumberFor, Block as BlockT, Zero}; -use network_gossip::{GossipEngine, MessageIntent, ValidatorContext}; -use network::{config::Roles, PeerId, ReputationChange}; -use codec::{Encode, Decode}; -use fg_primitives::AuthorityId; +use sc_network_gossip::{GossipEngine, MessageIntent, ValidatorContext}; +use sc_network::{config::Roles, PeerId, ReputationChange}; +use parity_scale_codec::{Encode, Decode}; +use sp_finality_grandpa::AuthorityId; use sc_telemetry::{telemetry, CONSENSUS_DEBUG}; use log::{trace, debug, warn}; @@ -908,15 +908,15 @@ impl Inner { // too many equivocations (we exceed the fault-tolerance bound). for vote in last_completed_round.votes { match vote.message { - grandpa::Message::Prevote(prevote) => { - prevotes.push(grandpa::SignedPrevote { + finality_grandpa::Message::Prevote(prevote) => { + prevotes.push(finality_grandpa::SignedPrevote { prevote, signature: vote.signature, id: vote.id, }); }, - grandpa::Message::Precommit(precommit) => { - precommits.push(grandpa::SignedPrecommit { + finality_grandpa::Message::Precommit(precommit) => { + precommits.push(finality_grandpa::SignedPrecommit { precommit, signature: vote.signature, id: vote.id, @@ -1280,7 +1280,7 @@ impl GossipValidator { } } -impl network_gossip::Validator for GossipValidator { +impl sc_network_gossip::Validator for GossipValidator { fn new_peer(&self, context: &mut dyn ValidatorContext, who: &PeerId, roles: Roles) { let packet = { let mut inner = self.inner.write(); @@ -1306,7 +1306,7 @@ impl network_gossip::Validator for GossipValidator } fn validate(&self, context: &mut dyn ValidatorContext, who: &PeerId, data: &[u8]) - -> network_gossip::ValidationResult + -> sc_network_gossip::ValidationResult { let (action, broadcast_topics, peer_reply) = self.do_validate(who, data); @@ -1323,15 +1323,15 @@ impl network_gossip::Validator for GossipValidator Action::Keep(topic, cb) => { self.report(who.clone(), cb); context.broadcast_message(topic, data.to_vec(), false); - network_gossip::ValidationResult::ProcessAndKeep(topic) + sc_network_gossip::ValidationResult::ProcessAndKeep(topic) } Action::ProcessAndDiscard(topic, cb) => { self.report(who.clone(), cb); - network_gossip::ValidationResult::ProcessAndDiscard(topic) + sc_network_gossip::ValidationResult::ProcessAndDiscard(topic) } Action::Discard(cb) => { self.report(who.clone(), cb); - network_gossip::ValidationResult::Discard + sc_network_gossip::ValidationResult::Discard } } } @@ -1502,9 +1502,9 @@ impl Future for ReportingTask { mod tests { use super::*; use super::environment::SharedVoterSetState; - use network_gossip::Validator as GossipValidatorT; + use sc_network_gossip::Validator as GossipValidatorT; use sc_network_test::Block; - use primitives::{crypto::Public, H256}; + use sp_core::{crypto::Public, H256}; // some random config (not really needed) fn config() -> crate::Config { @@ -1726,7 +1726,7 @@ mod tests { round: Round(1), set_id: SetId(set_id), message: SignedMessage:: { - message: grandpa::Message::Prevote(grandpa::Prevote { + message: finality_grandpa::Message::Prevote(finality_grandpa::Prevote { target_hash: Default::default(), target_number: 10, }), @@ -1739,7 +1739,7 @@ mod tests { round: Round(1), set_id: SetId(set_id), message: SignedMessage:: { - message: grandpa::Message::Prevote(grandpa::Prevote { + message: finality_grandpa::Message::Prevote(finality_grandpa::Prevote { target_hash: Default::default(), target_number: 10, }), @@ -1770,7 +1770,7 @@ mod tests { let mut inner = val.inner.write(); inner.validate_catch_up_message(&peer, &FullCatchUpMessage { set_id: SetId(set_id), - message: grandpa::CatchUp { + message: finality_grandpa::CatchUp { round_number: 10, prevotes: Default::default(), precommits: Default::default(), @@ -1806,7 +1806,7 @@ mod tests { completed_rounds.push(environment::CompletedRound { number: 2, - state: grandpa::round::State::genesis(Default::default()), + state: finality_grandpa::round::State::genesis(Default::default()), base: Default::default(), votes: Default::default(), }); diff --git a/client/finality-grandpa/src/communication/mod.rs b/client/finality-grandpa/src/communication/mod.rs index e535f85776..c690376193 100644 --- a/client/finality-grandpa/src/communication/mod.rs +++ b/client/finality-grandpa/src/communication/mod.rs @@ -31,13 +31,13 @@ use std::sync::Arc; use futures::{prelude::*, future::Executor as _, sync::mpsc}; use futures03::{compat::Compat, stream::StreamExt, future::FutureExt as _, future::TryFutureExt as _}; -use grandpa::Message::{Prevote, Precommit, PrimaryPropose}; -use grandpa::{voter, voter_set::VoterSet}; +use finality_grandpa::Message::{Prevote, Precommit, PrimaryPropose}; +use finality_grandpa::{voter, voter_set::VoterSet}; use log::{debug, trace}; -use network::ReputationChange; -use network_gossip::{GossipEngine, Network}; -use codec::{Encode, Decode}; -use primitives::Pair; +use sc_network::ReputationChange; +use sc_network_gossip::{GossipEngine, Network}; +use parity_scale_codec::{Encode, Decode}; +use sp_core::Pair; use sp_runtime::traits::{Block as BlockT, Hash as HashT, Header as HeaderT, NumberFor}; use sc_telemetry::{telemetry, CONSENSUS_DEBUG, CONSENSUS_INFO}; @@ -49,7 +49,7 @@ use crate::environment::HasVoted; use gossip::{ GossipMessage, FullCatchUpMessage, FullCommitMessage, VoteMessage, GossipValidator }; -use fg_primitives::{ +use sp_finality_grandpa::{ AuthorityPair, AuthorityId, AuthoritySignature, SetId as SetIdNumber, RoundNumber, }; @@ -59,11 +59,11 @@ mod periodic; #[cfg(test)] mod tests; -pub use fg_primitives::GRANDPA_ENGINE_ID; +pub use sp_finality_grandpa::GRANDPA_ENGINE_ID; // cost scalars for reporting peers. mod cost { - use network::ReputationChange as Rep; + use sc_network::ReputationChange as Rep; pub(super) const PAST_REJECTION: Rep = Rep::new(-50, "Grandpa: Past message"); pub(super) const BAD_SIGNATURE: Rep = Rep::new(-100, "Grandpa: Bad signature"); pub(super) const MALFORMED_CATCH_UP: Rep = Rep::new(-1000, "Grandpa: Malformed cath-up"); @@ -87,7 +87,7 @@ mod cost { // benefit scalars for reporting peers. mod benefit { - use network::ReputationChange as Rep; + use sc_network::ReputationChange as Rep; pub(super) const NEIGHBOR_MESSAGE: Rep = Rep::new(100, "Grandpa: Neighbor message"); pub(super) const ROUND_MESSAGE: Rep = Rep::new(100, "Grandpa: Round message"); pub(super) const BASIC_VALIDATED_CATCH_UP: Rep = Rep::new(200, "Grandpa: Catch-up message"); @@ -356,7 +356,7 @@ impl NetworkBridge { /// If the given vector of peers is empty then the underlying implementation /// should make a best effort to fetch the block from any peers it is /// connected to (NOTE: this assumption will change in the future #3629). - pub(crate) fn set_sync_fork_request(&self, peers: Vec, hash: B::Hash, number: NumberFor) { + pub(crate) fn set_sync_fork_request(&self, peers: Vec, hash: B::Hash, number: NumberFor) { self.gossip_engine.set_sync_fork_request(peers, hash, number) } } @@ -370,7 +370,7 @@ fn incoming_global( ) -> impl Stream, Error = Error> { let process_commit = move | msg: FullCommitMessage, - mut notification: network_gossip::TopicNotification, + mut notification: sc_network_gossip::TopicNotification, gossip_engine: &mut GossipEngine, gossip_validator: &Arc>, voters: &VoterSet, @@ -432,7 +432,7 @@ fn incoming_global( let process_catch_up = move | msg: FullCatchUpMessage, - mut notification: network_gossip::TopicNotification, + mut notification: sc_network_gossip::TopicNotification, gossip_engine: &mut GossipEngine, gossip_validator: &Arc>, voters: &VoterSet, @@ -557,15 +557,15 @@ impl Sink for OutgoingMessages fn start_send(&mut self, mut msg: Message) -> StartSend, Error> { // if we've voted on this round previously under the same key, send that vote instead match &mut msg { - grandpa::Message::PrimaryPropose(ref mut vote) => + finality_grandpa::Message::PrimaryPropose(ref mut vote) => if let Some(propose) = self.has_voted.propose() { *vote = propose.clone(); }, - grandpa::Message::Prevote(ref mut vote) => + finality_grandpa::Message::Prevote(ref mut vote) => if let Some(prevote) = self.has_voted.prevote() { *vote = prevote.clone(); }, - grandpa::Message::Precommit(ref mut vote) => + finality_grandpa::Message::Precommit(ref mut vote) => if let Some(precommit) = self.has_voted.precommit() { *vote = precommit.clone(); }, @@ -660,7 +660,7 @@ fn check_compact_commit( .enumerate() { use crate::communication::gossip::Misbehavior; - use grandpa::Message as GrandpaMessage; + use finality_grandpa::Message as GrandpaMessage; if let Err(()) = check_message_sig::( &GrandpaMessage::Precommit(precommit.clone()), @@ -772,7 +772,7 @@ fn check_catch_up( // check signatures on all contained prevotes. let signatures_checked = check_signatures::( msg.prevotes.iter().map(|vote| { - (grandpa::Message::Prevote(vote.prevote.clone()), &vote.id, &vote.signature) + (finality_grandpa::Message::Prevote(vote.prevote.clone()), &vote.id, &vote.signature) }), msg.round_number, set_id.0, @@ -782,7 +782,7 @@ fn check_catch_up( // check signatures on all contained precommits. let _ = check_signatures::( msg.precommits.iter().map(|vote| { - (grandpa::Message::Precommit(vote.precommit.clone()), &vote.id, &vote.signature) + (finality_grandpa::Message::Precommit(vote.precommit.clone()), &vote.id, &vote.signature) }), msg.round_number, set_id.0, diff --git a/client/finality-grandpa/src/communication/periodic.rs b/client/finality-grandpa/src/communication/periodic.rs index 3f9cc0dd8e..318c84c22c 100644 --- a/client/finality-grandpa/src/communication/periodic.rs +++ b/client/finality-grandpa/src/communication/periodic.rs @@ -18,15 +18,15 @@ use std::time::{Instant, Duration}; -use codec::Encode; +use parity_scale_codec::Encode; use futures::prelude::*; use futures::sync::mpsc; use futures_timer::Delay; use futures03::future::{FutureExt as _, TryFutureExt as _}; use log::{debug, warn}; -use network::PeerId; -use network_gossip::GossipEngine; +use sc_network::PeerId; +use sc_network_gossip::GossipEngine; use sp_runtime::traits::{NumberFor, Block as BlockT}; use super::gossip::{NeighborPacket, GossipMessage}; @@ -47,7 +47,7 @@ impl NeighborPacketSender { /// Send a neighbor packet for the background worker to gossip to peers. pub fn send( &self, - who: Vec, + who: Vec, neighbor_packet: NeighborPacket>, ) { if let Err(err) = self.0.unbounded_send((who, neighbor_packet)) { diff --git a/client/finality-grandpa/src/communication/tests.rs b/client/finality-grandpa/src/communication/tests.rs index 6e80291c40..4c0223402f 100644 --- a/client/finality-grandpa/src/communication/tests.rs +++ b/client/finality-grandpa/src/communication/tests.rs @@ -18,24 +18,24 @@ use futures::sync::mpsc; use futures::prelude::*; -use network::{Event as NetworkEvent, PeerId, config::Roles}; +use sc_network::{Event as NetworkEvent, PeerId, config::Roles}; use sc_network_test::{Block, Hash}; -use network_gossip::Validator; +use sc_network_gossip::Validator; use tokio::runtime::current_thread; use std::sync::Arc; -use keyring::Ed25519Keyring; -use codec::Encode; +use sp_keyring::Ed25519Keyring; +use parity_scale_codec::Encode; use sp_runtime::{ConsensusEngineId, traits::NumberFor}; use std::{pin::Pin, task::{Context, Poll}}; use crate::environment::SharedVoterSetState; -use fg_primitives::{AuthorityList, GRANDPA_ENGINE_ID}; +use sp_finality_grandpa::{AuthorityList, GRANDPA_ENGINE_ID}; use super::gossip::{self, GossipValidator}; use super::{AuthorityId, VoterSet, Round, SetId}; enum Event { EventStream(mpsc::UnboundedSender), - WriteNotification(network::PeerId, Vec), - Report(network::PeerId, network::ReputationChange), + WriteNotification(sc_network::PeerId, Vec), + Report(sc_network::PeerId, sc_network::ReputationChange), Announce(Hash), } @@ -44,7 +44,7 @@ struct TestNetwork { sender: mpsc::UnboundedSender, } -impl network_gossip::Network for TestNetwork { +impl sc_network_gossip::Network for TestNetwork { fn event_stream(&self) -> Box + Send> { let (tx, rx) = mpsc::unbounded(); @@ -52,7 +52,7 @@ impl network_gossip::Network for TestNetwork { Box::new(rx) } - fn report_peer(&self, who: network::PeerId, cost_benefit: network::ReputationChange) { + fn report_peer(&self, who: sc_network::PeerId, cost_benefit: sc_network::ReputationChange) { let _ = self.sender.unbounded_send(Event::Report(who, cost_benefit)); } @@ -70,19 +70,19 @@ impl network_gossip::Network for TestNetwork { fn set_sync_fork_request( &self, - _peers: Vec, + _peers: Vec, _hash: Hash, _number: NumberFor, ) {} } -impl network_gossip::ValidatorContext for TestNetwork { +impl sc_network_gossip::ValidatorContext for TestNetwork { fn broadcast_topic(&mut self, _: Hash, _: bool) { } fn broadcast_message(&mut self, _: Hash, _: Vec, _: bool) { } - fn send_message(&mut self, who: &network::PeerId, data: Vec) { - >::write_notification( + fn send_message(&mut self, who: &sc_network::PeerId, data: Vec) { + >::write_notification( self, who.clone(), GRANDPA_ENGINE_ID, @@ -90,7 +90,7 @@ impl network_gossip::ValidatorContext for TestNetwork { ); } - fn send_topic(&mut self, _: &network::PeerId, _: Hash, _: bool) { } + fn send_topic(&mut self, _: &sc_network::PeerId, _: Hash, _: bool) { } } struct Tester { @@ -132,8 +132,8 @@ fn config() -> crate::Config { fn voter_set_state() -> SharedVoterSetState { use crate::authorities::AuthoritySet; use crate::environment::VoterSetState; - use grandpa::round::State as RoundState; - use primitives::H256; + use finality_grandpa::round::State as RoundState; + use sp_core::H256; let state = RoundState::genesis((H256::zero(), 0)); let base = state.prevote_ghost.unwrap(); @@ -193,11 +193,11 @@ fn make_ids(keys: &[Ed25519Keyring]) -> AuthorityList { struct NoopContext; -impl network_gossip::ValidatorContext for NoopContext { +impl sc_network_gossip::ValidatorContext for NoopContext { fn broadcast_topic(&mut self, _: Hash, _: bool) { } fn broadcast_message(&mut self, _: Hash, _: Vec, _: bool) { } - fn send_message(&mut self, _: &network::PeerId, _: Vec) { } - fn send_topic(&mut self, _: &network::PeerId, _: Hash, _: bool) { } + fn send_message(&mut self, _: &sc_network::PeerId, _: Vec) { } + fn send_topic(&mut self, _: &sc_network::PeerId, _: Hash, _: bool) { } } #[test] @@ -213,9 +213,9 @@ fn good_commit_leads_to_relay() { let target_hash: Hash = [1; 32].into(); let target_number = 500; - let precommit = grandpa::Precommit { target_hash: target_hash.clone(), target_number }; + let precommit = finality_grandpa::Precommit { target_hash: target_hash.clone(), target_number }; let payload = super::localized_payload( - round, set_id, &grandpa::Message::Precommit(precommit.clone()) + round, set_id, &finality_grandpa::Message::Precommit(precommit.clone()) ); let mut precommits = Vec::new(); @@ -224,11 +224,11 @@ fn good_commit_leads_to_relay() { for (i, key) in private.iter().enumerate() { precommits.push(precommit.clone()); - let signature = fg_primitives::AuthoritySignature::from(key.sign(&payload[..])); + let signature = sp_finality_grandpa::AuthoritySignature::from(key.sign(&payload[..])); auth_data.push((signature, public[i].0.clone())) } - grandpa::CompactCommit { + finality_grandpa::CompactCommit { target_hash, target_number, precommits, @@ -242,14 +242,14 @@ fn good_commit_leads_to_relay() { message: commit, }).encode(); - let id = network::PeerId::random(); + let id = sc_network::PeerId::random(); let global_topic = super::global_topic::(set_id); let threads_pool = futures03::executor::ThreadPool::new().unwrap(); let test = make_test_network(&threads_pool).0 .and_then(move |tester| { // register a peer. - tester.gossip_validator.new_peer(&mut NoopContext, &id, network::config::Roles::FULL); + tester.gossip_validator.new_peer(&mut NoopContext, &id, sc_network::config::Roles::FULL); Ok((tester, id)) }) .and_then(move |(tester, id)| { @@ -291,8 +291,8 @@ fn good_commit_leads_to_relay() { let handle_commit = commits_in.into_future() .map(|(item, _)| { match item.unwrap() { - grandpa::voter::CommunicationIn::Commit(_, _, mut callback) => { - callback.run(grandpa::voter::CommitProcessingOutcome::good()); + finality_grandpa::voter::CommunicationIn::Commit(_, _, mut callback) => { + callback.run(finality_grandpa::voter::CommitProcessingOutcome::good()); }, _ => panic!("commit expected"), } @@ -330,9 +330,9 @@ fn bad_commit_leads_to_report() { let target_hash: Hash = [1; 32].into(); let target_number = 500; - let precommit = grandpa::Precommit { target_hash: target_hash.clone(), target_number }; + let precommit = finality_grandpa::Precommit { target_hash: target_hash.clone(), target_number }; let payload = super::localized_payload( - round, set_id, &grandpa::Message::Precommit(precommit.clone()) + round, set_id, &finality_grandpa::Message::Precommit(precommit.clone()) ); let mut precommits = Vec::new(); @@ -341,11 +341,11 @@ fn bad_commit_leads_to_report() { for (i, key) in private.iter().enumerate() { precommits.push(precommit.clone()); - let signature = fg_primitives::AuthoritySignature::from(key.sign(&payload[..])); + let signature = sp_finality_grandpa::AuthoritySignature::from(key.sign(&payload[..])); auth_data.push((signature, public[i].0.clone())) } - grandpa::CompactCommit { + finality_grandpa::CompactCommit { target_hash, target_number, precommits, @@ -359,14 +359,14 @@ fn bad_commit_leads_to_report() { message: commit, }).encode(); - let id = network::PeerId::random(); + let id = sc_network::PeerId::random(); let global_topic = super::global_topic::(set_id); let threads_pool = futures03::executor::ThreadPool::new().unwrap(); let test = make_test_network(&threads_pool).0 .and_then(move |tester| { // register a peer. - tester.gossip_validator.new_peer(&mut NoopContext, &id, network::config::Roles::FULL); + tester.gossip_validator.new_peer(&mut NoopContext, &id, sc_network::config::Roles::FULL); Ok((tester, id)) }) .and_then(move |(tester, id)| { @@ -408,8 +408,8 @@ fn bad_commit_leads_to_report() { let handle_commit = commits_in.into_future() .map(|(item, _)| { match item.unwrap() { - grandpa::voter::CommunicationIn::Commit(_, _, mut callback) => { - callback.run(grandpa::voter::CommitProcessingOutcome::bad()); + finality_grandpa::voter::CommunicationIn::Commit(_, _, mut callback) => { + callback.run(finality_grandpa::voter::CommitProcessingOutcome::bad()); }, _ => panic!("commit expected"), } @@ -435,14 +435,14 @@ fn bad_commit_leads_to_report() { #[test] fn peer_with_higher_view_leads_to_catch_up_request() { - let id = network::PeerId::random(); + let id = sc_network::PeerId::random(); let threads_pool = futures03::executor::ThreadPool::new().unwrap(); let (tester, mut net) = make_test_network(&threads_pool); let test = tester .and_then(move |tester| { // register a peer with authority role. - tester.gossip_validator.new_peer(&mut NoopContext, &id, network::config::Roles::AUTHORITY); + tester.gossip_validator.new_peer(&mut NoopContext, &id, sc_network::config::Roles::AUTHORITY); Ok((tester, id)) }) .and_then(move |(tester, id)| { @@ -459,7 +459,7 @@ fn peer_with_higher_view_leads_to_catch_up_request() { // neighbor packets are always discard match result { - network_gossip::ValidationResult::Discard => {}, + sc_network_gossip::ValidationResult::Discard => {}, _ => panic!("wrong expected outcome from neighbor validation"), } diff --git a/client/finality-grandpa/src/consensus_changes.rs b/client/finality-grandpa/src/consensus_changes.rs index 5f7828f02b..c89335e34c 100644 --- a/client/finality-grandpa/src/consensus_changes.rs +++ b/client/finality-grandpa/src/consensus_changes.rs @@ -15,7 +15,7 @@ // along with Substrate. If not, see . use std::sync::Arc; -use codec::{Encode, Decode}; +use parity_scale_codec::{Encode, Decode}; /// Consensus-related data changes tracker. #[derive(Clone, Debug, Encode, Decode)] diff --git a/client/finality-grandpa/src/environment.rs b/client/finality-grandpa/src/environment.rs index a252668481..998e63b6b5 100644 --- a/client/finality-grandpa/src/environment.rs +++ b/client/finality-grandpa/src/environment.rs @@ -20,28 +20,28 @@ use std::sync::Arc; use std::time::Duration; use log::{debug, warn, info}; -use codec::{Decode, Encode}; +use parity_scale_codec::{Decode, Encode}; use futures::prelude::*; use futures03::future::{FutureExt as _, TryFutureExt as _}; use futures_timer::Delay; use parking_lot::RwLock; use sp_blockchain::{HeaderBackend, Error as ClientError}; -use client_api::{ +use sc_client_api::{ BlockchainEvents, backend::{Backend}, Finalizer, call_executor::CallExecutor, utils::is_descendent_of, }; -use client::{ +use sc_client::{ apply_aux, Client, }; -use grandpa::{ +use finality_grandpa::{ BlockNumberOps, Equivocation, Error as GrandpaError, round::State as RoundState, voter, voter_set::VoterSet, }; -use primitives::{Blake2Hasher, H256, Pair}; +use sp_core::{Blake2Hasher, H256, Pair}; use sp_runtime::generic::BlockId; use sp_runtime::traits::{ Block as BlockT, Header as HeaderT, NumberFor, One, Zero, @@ -53,16 +53,16 @@ use crate::{ PrimaryPropose, SignedMessage, NewAuthoritySet, VoterCommand, }; -use consensus_common::SelectChain; +use sp_consensus::SelectChain; use crate::authorities::{AuthoritySet, SharedAuthoritySet}; use crate::consensus_changes::SharedConsensusChanges; use crate::justification::GrandpaJustification; use crate::until_imported::UntilVoteTargetImported; use crate::voting_rule::VotingRule; -use fg_primitives::{AuthorityId, AuthoritySignature, SetId, RoundNumber}; +use sp_finality_grandpa::{AuthorityId, AuthoritySignature, SetId, RoundNumber}; -type HistoricalVotes = grandpa::HistoricalVotes< +type HistoricalVotes = finality_grandpa::HistoricalVotes< ::Hash, NumberFor, AuthoritySignature, @@ -105,10 +105,10 @@ impl Encode for CompletedRounds { } } -impl codec::EncodeLike for CompletedRounds {} +impl parity_scale_codec::EncodeLike for CompletedRounds {} impl Decode for CompletedRounds { - fn decode(value: &mut I) -> Result { + fn decode(value: &mut I) -> Result { <(Vec>, SetId, Vec)>::decode(value) .map(|(rounds, set_id, voters)| CompletedRounds { rounds: rounds.into(), @@ -406,7 +406,7 @@ impl Environment { } impl, B, E, RA, SC, VR> - grandpa::Chain> + finality_grandpa::Chain> for Environment where Block: 'static, @@ -572,11 +572,11 @@ where // regular round message streams type In = Box, Self::Signature, Self::Id>, + Item = ::finality_grandpa::SignedMessage, Self::Signature, Self::Id>, Error = Self::Error, > + Send>; type Out = Box>, + SinkItem = ::finality_grandpa::Message>, SinkError = Self::Error, > + Send>; @@ -906,7 +906,7 @@ where fn prevote_equivocation( &self, _round: RoundNumber, - equivocation: ::grandpa::Equivocation, Self::Signature> + equivocation: ::finality_grandpa::Equivocation, Self::Signature> ) { warn!(target: "afg", "Detected prevote equivocation in the finality worker: {:?}", equivocation); // nothing yet; this could craft misbehavior reports of some kind. diff --git a/client/finality-grandpa/src/finality_proof.rs b/client/finality-grandpa/src/finality_proof.rs index 0420320e0b..1e17845471 100644 --- a/client/finality-grandpa/src/finality_proof.rs +++ b/client/finality-grandpa/src/finality_proof.rs @@ -39,20 +39,20 @@ use std::sync::Arc; use log::{trace, warn}; use sp_blockchain::{Backend as BlockchainBackend, Error as ClientError, Result as ClientResult}; -use client_api::{ +use sc_client_api::{ backend::Backend, CallExecutor, StorageProof, light::{FetchChecker, RemoteReadRequest}, }; -use client::Client; -use codec::{Encode, Decode}; -use grandpa::BlockNumberOps; +use sc_client::Client; +use parity_scale_codec::{Encode, Decode}; +use finality_grandpa::BlockNumberOps; use sp_runtime::{ Justification, generic::BlockId, traits::{NumberFor, Block as BlockT, Header as HeaderT, One}, }; -use primitives::{H256, Blake2Hasher, storage::StorageKey}; +use sp_core::{H256, Blake2Hasher, storage::StorageKey}; use sc_telemetry::{telemetry, CONSENSUS_INFO}; -use fg_primitives::{AuthorityId, AuthorityList, VersionedAuthorityList, GRANDPA_AUTHORITIES_KEY}; +use sp_finality_grandpa::{AuthorityId, AuthorityList, VersionedAuthorityList, GRANDPA_AUTHORITIES_KEY}; use crate::justification::GrandpaJustification; @@ -154,7 +154,7 @@ impl> FinalityProofProvider } } -impl network::FinalityProofProvider for FinalityProofProvider +impl sc_network::FinalityProofProvider for FinalityProofProvider where Block: BlockT, NumberFor: BlockNumberOps, @@ -580,11 +580,11 @@ impl> ProvableJustification for GrandpaJ #[cfg(test)] pub(crate) mod tests { - use test_client::runtime::{Block, Header, H256}; - use client_api::NewBlockState; - use test_client::client::in_mem::Blockchain as InMemoryBlockchain; + use substrate_test_runtime_client::runtime::{Block, Header, H256}; + use sc_client_api::NewBlockState; + use substrate_test_runtime_client::sc_client::in_mem::Blockchain as InMemoryBlockchain; use super::*; - use primitives::crypto::Public; + use sp_core::crypto::Public; type FinalityProof = super::FinalityProof