diff --git a/substrate/Cargo.lock b/substrate/Cargo.lock index 536354b919..08829f4ae2 100644 --- a/substrate/Cargo.lock +++ b/substrate/Cargo.lock @@ -758,7 +758,7 @@ dependencies = [ "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -798,7 +798,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "fork-tree" version = "0.1.0" dependencies = [ - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1072,7 +1072,7 @@ name = "impl-codec" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1866,7 +1866,7 @@ dependencies = [ "node-executor 0.1.0", "node-primitives 0.1.0", "node-runtime 0.1.0", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", "sr-primitives 0.1.0", "structopt 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1892,7 +1892,7 @@ version = "0.1.0" dependencies = [ "node-primitives 0.1.0", "node-runtime 0.1.0", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", "sr-primitives 0.1.0", "srml-balances 0.1.0", @@ -1920,7 +1920,7 @@ dependencies = [ name = "node-primitives" version = "0.1.0" dependencies = [ - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "pretty_assertions 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1938,7 +1938,7 @@ dependencies = [ "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "integer-sqrt 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "node-primitives 0.1.0", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.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.87 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1982,7 +1982,7 @@ dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "node-executor 0.1.0", "node-template-runtime 0.9.0", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", "substrate-basic-authorship 0.1.0", @@ -2004,7 +2004,7 @@ dependencies = [ name = "node-template-runtime" version = "0.9.0" dependencies = [ - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.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.87 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2141,7 +2141,7 @@ source = "git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7 [[package]] name = "parity-codec" -version = "3.1.0" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2659,7 +2659,7 @@ dependencies = [ "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2999,7 +2999,7 @@ dependencies = [ "environmental 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "hash-db 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 0.1.0", "substrate-primitives 0.1.0", @@ -3015,7 +3015,7 @@ dependencies = [ "integer-sqrt 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3029,7 +3029,7 @@ name = "sr-sandbox" version = "0.1.0" dependencies = [ "assert_matches 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 0.1.0", "substrate-primitives 0.1.0", @@ -3049,7 +3049,7 @@ name = "sr-version" version = "0.1.0" dependencies = [ "impl-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 0.1.0", @@ -3061,7 +3061,7 @@ name = "srml-assets" version = "0.1.0" dependencies = [ "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", "sr-primitives 0.1.0", @@ -3077,7 +3077,7 @@ version = "0.1.0" dependencies = [ "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3099,7 +3099,7 @@ name = "srml-balances" version = "0.1.0" dependencies = [ "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.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.87 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", @@ -3116,7 +3116,7 @@ name = "srml-consensus" version = "0.1.0" dependencies = [ "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", @@ -3134,7 +3134,7 @@ version = "0.1.0" dependencies = [ "assert_matches 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)", "pwasm-utils 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3158,7 +3158,7 @@ name = "srml-council" version = "0.1.0" dependencies = [ "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.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.87 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3177,7 +3177,7 @@ name = "srml-democracy" version = "0.1.0" dependencies = [ "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.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.87 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3195,7 +3195,7 @@ name = "srml-example" version = "0.1.0" dependencies = [ "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", "sr-primitives 0.1.0", @@ -3210,7 +3210,7 @@ name = "srml-executive" version = "0.1.0" dependencies = [ "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", @@ -3229,7 +3229,7 @@ name = "srml-fees" version = "0.1.0" dependencies = [ "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", @@ -3246,7 +3246,7 @@ version = "0.1.0" dependencies = [ "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3263,7 +3263,7 @@ dependencies = [ name = "srml-grandpa" version = "0.1.0" dependencies = [ - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", @@ -3283,7 +3283,7 @@ name = "srml-indices" version = "0.1.0" dependencies = [ "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.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)", @@ -3301,7 +3301,7 @@ dependencies = [ name = "srml-metadata" version = "0.1.0" dependencies = [ - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 0.1.0", @@ -3313,7 +3313,7 @@ name = "srml-session" version = "0.1.0" dependencies = [ "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.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.87 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3332,7 +3332,7 @@ name = "srml-staking" version = "0.1.0" dependencies = [ "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.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.87 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", @@ -3353,7 +3353,7 @@ name = "srml-sudo" version = "0.1.0" dependencies = [ "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", @@ -3372,11 +3372,12 @@ dependencies = [ "bitmask 0.5.0 (git+https://github.com/paritytech/bitmask)", "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "once_cell 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "paste 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "pretty_assertions 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", + "spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", "sr-primitives 0.1.0", "sr-std 0.1.0", @@ -3416,12 +3417,25 @@ dependencies = [ "syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "srml-support-test" +version = "0.1.0" +dependencies = [ + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", + "sr-io 0.1.0", + "srml-support 0.1.0", + "substrate-inherents 0.1.0", + "substrate-primitives 0.1.0", +] + [[package]] name = "srml-system" version = "0.1.0" dependencies = [ "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.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.87 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3437,7 +3451,7 @@ name = "srml-timestamp" version = "0.1.0" dependencies = [ "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", "sr-primitives 0.1.0", @@ -3453,7 +3467,7 @@ name = "srml-treasury" version = "0.1.0" dependencies = [ "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", @@ -3469,7 +3483,7 @@ dependencies = [ name = "srml-upgrade-key" version = "0.1.0" dependencies = [ - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 0.1.0", "sr-std 0.1.0", @@ -3605,7 +3619,7 @@ name = "substrate-basic-authorship" version = "0.1.0" dependencies = [ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 0.1.0", "substrate-client 0.1.0", "substrate-consensus-aura-primitives 0.1.0", @@ -3673,7 +3687,7 @@ dependencies = [ "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)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "sr-api-macros 0.1.0", "sr-primitives 0.1.0", @@ -3701,7 +3715,7 @@ dependencies = [ "kvdb-rocksdb 0.1.4 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "lru-cache 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 0.1.0", "substrate-client 0.1.0", @@ -3722,7 +3736,7 @@ dependencies = [ "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", "sr-primitives 0.1.0", @@ -3759,7 +3773,7 @@ dependencies = [ "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 0.1.0", "substrate-client 0.1.0", @@ -3778,7 +3792,7 @@ dependencies = [ "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 0.1.0", "sr-version 0.1.0", @@ -3796,7 +3810,7 @@ dependencies = [ "exit-future 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "rhododendron 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", @@ -3824,7 +3838,7 @@ dependencies = [ "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3849,7 +3863,7 @@ dependencies = [ "fork-tree 0.1.0", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 0.1.0", @@ -3871,7 +3885,7 @@ dependencies = [ name = "substrate-finality-grandpa-primitives" version = "0.1.0" dependencies = [ - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 0.1.0", "sr-std 0.1.0", "substrate-client 0.1.0", @@ -3882,7 +3896,7 @@ dependencies = [ name = "substrate-inherents" version = "0.1.0" dependencies = [ - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 0.1.0", "sr-std 0.1.0", @@ -3927,7 +3941,7 @@ dependencies = [ "linked_hash_set 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "lru-cache 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3987,7 +4001,7 @@ dependencies = [ "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "impl-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "pretty_assertions 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "primitive-types 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4019,7 +4033,7 @@ dependencies = [ "jsonrpc-derive 10.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-pubsub 10.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (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.87 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4070,7 +4084,7 @@ dependencies = [ "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4117,7 +4131,7 @@ version = "0.1.0" dependencies = [ "env_logger 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-primitives 0.1.0", ] @@ -4130,7 +4144,7 @@ dependencies = [ "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-panic-handler 0.1.0", "substrate-primitives 0.1.0", @@ -4161,7 +4175,7 @@ name = "substrate-test-client" version = "0.1.0" dependencies = [ "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 0.1.0", "substrate-client 0.1.0", "substrate-client-db 0.1.0", @@ -4180,7 +4194,7 @@ dependencies = [ "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", @@ -4206,7 +4220,7 @@ dependencies = [ "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.87 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4221,7 +4235,7 @@ dependencies = [ "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 0.1.0", "substrate-client 0.1.0", @@ -4240,7 +4254,7 @@ dependencies = [ "hex-literal 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hasher 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "memory-db 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-primitives 0.1.0", "trie-bench 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "trie-db 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4619,7 +4633,7 @@ dependencies = [ "hash-db 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hasher 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "memory-db 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "trie-db 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "trie-root 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "trie-standardmap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -5201,7 +5215,7 @@ dependencies = [ "checksum owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37" "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-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "67a4d27831e31e27f1454d6e3d3bb34bcac6bf7ad7032eed0ad0070dc8cf55c1" +"checksum parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "21c9c3a1623c71ed83964ff28cac6126e178920f7646d32c337eacb9152b2907" "checksum parity-codec-derive 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "864e9f66b58c0b38f0d6b511b6576afa2b678ae801b64220553bced57ac12df9" "checksum parity-crypto 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "17b9db194dfbcfe3b398d63d765437a5c7232d59906e203055f0e993f6458ff1" "checksum parity-multiaddr 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "61ae6944d4435d41f4d0f12108c5cbb9207cbb14bc8f2b4984c6e930dc9c8e41" diff --git a/substrate/Cargo.toml b/substrate/Cargo.toml index 699f9a1589..286e93ecae 100644 --- a/substrate/Cargo.toml +++ b/substrate/Cargo.toml @@ -57,6 +57,7 @@ members = [ "srml/support/procedural", "srml/support/procedural/tools", "srml/support/procedural/tools/derive", + "srml/support/test", "srml/assets", "srml/aura", "srml/balances", diff --git a/substrate/core/basic-authorship/Cargo.toml b/substrate/core/basic-authorship/Cargo.toml index cb801b9a13..d173ac66ee 100644 --- a/substrate/core/basic-authorship/Cargo.toml +++ b/substrate/core/basic-authorship/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" [dependencies] log = "0.4" -codec = { package = "parity-codec", version = "3.0" } +codec = { package = "parity-codec", version = "3.2" } runtime_primitives = { package = "sr-primitives", path = "../../core/sr-primitives" } client = { package = "substrate-client", path = "../../core/client" } aura_primitives = { package = "substrate-consensus-aura-primitives", path = "../../core/consensus/aura/primitives" } diff --git a/substrate/core/client/Cargo.toml b/substrate/core/client/Cargo.toml index 495b11b61d..f797d93f1f 100644 --- a/substrate/core/client/Cargo.toml +++ b/substrate/core/client/Cargo.toml @@ -20,7 +20,7 @@ trie = { package = "substrate-trie", path = "../trie", optional = true } substrate-telemetry = { path = "../telemetry", optional = true } hash-db = { version = "0.11", optional = true } kvdb = { git = "https://github.com/paritytech/parity-common", optional = true, rev="b0317f649ab2c665b7987b8475878fc4d2e1f81d" } -parity-codec = { version = "3.1", default-features = false, features = ["derive"] } +parity-codec = { version = "3.2", default-features = false, features = ["derive"] } primitives = { package = "substrate-primitives", path = "../primitives", default-features = false } runtime-primitives = { package = "sr-primitives", path = "../sr-primitives", default-features = false } runtime-version = { package = "sr-version", path = "../sr-version", default-features = false } diff --git a/substrate/core/client/db/Cargo.toml b/substrate/core/client/db/Cargo.toml index 8828eefa4f..97de2cd7cd 100644 --- a/substrate/core/client/db/Cargo.toml +++ b/substrate/core/client/db/Cargo.toml @@ -17,7 +17,7 @@ primitives = { package = "substrate-primitives", path = "../../primitives" } runtime_primitives = { package = "sr-primitives", path = "../../sr-primitives" } client = { package = "substrate-client", path = "../../client" } state-machine = { package = "substrate-state-machine", path = "../../state-machine" } -parity-codec = { version = "3.1", features = ["derive"] } +parity-codec = { version = "3.2", features = ["derive"] } executor = { package = "substrate-executor", path = "../../executor" } state_db = { package = "substrate-state-db", path = "../../state-db" } trie = { package = "substrate-trie", path = "../../trie" } diff --git a/substrate/core/consensus/aura/Cargo.toml b/substrate/core/consensus/aura/Cargo.toml index 10c4122c0e..ca4f139ee4 100644 --- a/substrate/core/consensus/aura/Cargo.toml +++ b/substrate/core/consensus/aura/Cargo.toml @@ -6,7 +6,7 @@ description = "Aura consensus algorithm for substrate" edition = "2018" [dependencies] -parity-codec = "3.1" +parity-codec = "3.2" client = { package = "substrate-client", path = "../../client" } primitives = { package = "substrate-primitives", path = "../../primitives" } runtime_support = { package = "srml-support", path = "../../../srml/support" } diff --git a/substrate/core/consensus/aura/slots/Cargo.toml b/substrate/core/consensus/aura/slots/Cargo.toml index fce628161e..3ad763cc18 100644 --- a/substrate/core/consensus/aura/slots/Cargo.toml +++ b/substrate/core/consensus/aura/slots/Cargo.toml @@ -6,7 +6,7 @@ description = "Generic slots-based utilities for consensus" edition = "2018" [dependencies] -codec = { package = "parity-codec", version = "3.0" } +codec = { package = "parity-codec", version = "3.2" } client = { package = "substrate-client", path = "../../../client" } primitives = { package = "substrate-primitives", path = "../../../primitives" } runtime_primitives = { package = "sr-primitives", path = "../../../sr-primitives" } diff --git a/substrate/core/consensus/common/Cargo.toml b/substrate/core/consensus/common/Cargo.toml index 37184e3c0b..2eaf177874 100644 --- a/substrate/core/consensus/common/Cargo.toml +++ b/substrate/core/consensus/common/Cargo.toml @@ -15,7 +15,7 @@ futures = "0.1" runtime_version = { package = "sr-version", path = "../../sr-version" } runtime_primitives = { package = "sr-primitives", path = "../../sr-primitives" } tokio = "0.1.7" -parity-codec = "3.1" +parity-codec = "3.2" parity-codec-derive = "3.1" [dev-dependencies] diff --git a/substrate/core/consensus/rhd/Cargo.toml b/substrate/core/consensus/rhd/Cargo.toml index 22d847e80e..71b45cf41b 100644 --- a/substrate/core/consensus/rhd/Cargo.toml +++ b/substrate/core/consensus/rhd/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] futures = "0.1.17" -codec = { package = "parity-codec", version = "3.1", features = ["derive"] } +codec = { package = "parity-codec", version = "3.2", features = ["derive"] } primitives = { package = "substrate-primitives", path = "../../primitives" } consensus = { package = "substrate-consensus-common", path = "../common" } client = { package = "substrate-client", path = "../../client" } diff --git a/substrate/core/executor/Cargo.toml b/substrate/core/executor/Cargo.toml index 836386d77d..f34bfbbe91 100644 --- a/substrate/core/executor/Cargo.toml +++ b/substrate/core/executor/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" [dependencies] error-chain = "0.12" -parity-codec = "3.1" +parity-codec = "3.2" runtime_io = { package = "sr-io", path = "../sr-io" } primitives = { package = "substrate-primitives", path = "../primitives" } trie = { package = "substrate-trie", path = "../trie" } diff --git a/substrate/core/executor/wasm/Cargo.lock b/substrate/core/executor/wasm/Cargo.lock index dc1159e8d0..8fa99afc3b 100644 --- a/substrate/core/executor/wasm/Cargo.lock +++ b/substrate/core/executor/wasm/Cargo.lock @@ -44,7 +44,7 @@ name = "impl-codec" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -54,7 +54,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "parity-codec" -version = "3.1.0" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -151,7 +151,7 @@ name = "sr-io" version = "0.1.0" dependencies = [ "hash-db 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 0.1.0", "substrate-primitives 0.1.0", @@ -161,7 +161,7 @@ dependencies = [ name = "sr-sandbox" version = "0.1.0" dependencies = [ - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 0.1.0", "substrate-primitives 0.1.0", @@ -186,7 +186,7 @@ dependencies = [ "byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "hash-db 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "hash256-std-hasher 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "primitive-types 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 0.1.0", @@ -234,7 +234,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum hash256-std-hasher 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f5c13dbac3cc50684760f54af18545c9e80fb75e93a3e586d71ebdc13138f6a4" "checksum impl-codec 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d2050d823639fbeae26b2b5ba09aca8907793117324858070ade0673c49f793b" "checksum nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "9a2228dca57108069a5262f2ed8bd2e82496d2e074a06d1ccc7ce1687b6ae0a2" -"checksum parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "67a4d27831e31e27f1454d6e3d3bb34bcac6bf7ad7032eed0ad0070dc8cf55c1" +"checksum parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "21c9c3a1623c71ed83964ff28cac6126e178920f7646d32c337eacb9152b2907" "checksum parity-codec-derive 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "864e9f66b58c0b38f0d6b511b6576afa2b678ae801b64220553bced57ac12df9" "checksum primitive-types 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "edb92f1ebfc177432c03287b15d48c202e6e2c95993a7af3ba039abb43b1492e" "checksum proc-macro-crate 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4c6cf4e5b00300d151dfffae39f529dfa5188f42eeb14201229aa420d6aad10c" diff --git a/substrate/core/finality-grandpa/Cargo.toml b/substrate/core/finality-grandpa/Cargo.toml index c84e798fe7..070b073b99 100644 --- a/substrate/core/finality-grandpa/Cargo.toml +++ b/substrate/core/finality-grandpa/Cargo.toml @@ -11,7 +11,7 @@ log = "0.4" parking_lot = "0.7.1" tokio = "0.1.7" rand = "0.6" -parity-codec = { version = "3.1", features = ["derive"] } +parity-codec = { version = "3.2", features = ["derive"] } runtime_primitives = { package = "sr-primitives", path = "../sr-primitives" } consensus_common = { package = "substrate-consensus-common", path = "../consensus/common" } substrate-primitives = { path = "../primitives" } diff --git a/substrate/core/finality-grandpa/primitives/Cargo.toml b/substrate/core/finality-grandpa/primitives/Cargo.toml index 3891db8f01..a0bd36eb9a 100644 --- a/substrate/core/finality-grandpa/primitives/Cargo.toml +++ b/substrate/core/finality-grandpa/primitives/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] client = { package = "substrate-client", path = "../../client", default-features = false } substrate-primitives = { path = "../../primitives", default-features = false } -parity-codec = { version = "3.1", default-features = false, features = ["derive"] } +parity-codec = { version = "3.2", default-features = false, features = ["derive"] } sr-primitives = { path = "../../sr-primitives", default-features = false } rstd = { package = "sr-std", path = "../../sr-std", default-features = false } diff --git a/substrate/core/inherents/Cargo.toml b/substrate/core/inherents/Cargo.toml index 2ea3c69a76..d3292095cc 100644 --- a/substrate/core/inherents/Cargo.toml +++ b/substrate/core/inherents/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] parking_lot = { version = "0.7", optional = true } rstd = { package = "sr-std", path = "../sr-std", default-features = false } -parity-codec = { version = "3.1", default-features = false, features = ["derive"] } +parity-codec = { version = "3.2", default-features = false, features = ["derive"] } runtime_primitives = { package = "sr-primitives", path = "../sr-primitives", default-features = false } [features] diff --git a/substrate/core/network/Cargo.toml b/substrate/core/network/Cargo.toml index 4d78eeb602..6e7e8599db 100644 --- a/substrate/core/network/Cargo.toml +++ b/substrate/core/network/Cargo.toml @@ -25,7 +25,7 @@ primitives = { package = "substrate-primitives", path = "../../core/primitives" consensus = { package = "substrate-consensus-common", path = "../../core/consensus/common" } client = { package = "substrate-client", path = "../../core/client" } runtime_primitives = { package = "sr-primitives", path = "../../core/sr-primitives" } -parity-codec = { version = "3.1", features = ["derive"] } +parity-codec = { version = "3.2", features = ["derive"] } network_libp2p = { package = "substrate-network-libp2p", path = "../../core/network-libp2p" } tokio = "0.1.11" keyring = { package = "substrate-keyring", path = "../../core/keyring", optional = true } diff --git a/substrate/core/primitives/Cargo.toml b/substrate/core/primitives/Cargo.toml index 04094ff01e..4c176ef404 100644 --- a/substrate/core/primitives/Cargo.toml +++ b/substrate/core/primitives/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" [dependencies] rstd = { package = "sr-std", path = "../sr-std", default-features = false } -parity-codec = { version = "3.1", default-features = false, features = ["derive"] } +parity-codec = { version = "3.2", default-features = false, features = ["derive"] } rustc-hex = { version = "2.0", default-features = false } serde = { version = "1.0", optional = true } serde_derive = { version = "1.0", optional = true } diff --git a/substrate/core/rpc/Cargo.toml b/substrate/core/rpc/Cargo.toml index 762453f2b7..8998ebe81f 100644 --- a/substrate/core/rpc/Cargo.toml +++ b/substrate/core/rpc/Cargo.toml @@ -11,7 +11,7 @@ jsonrpc-pubsub = "10.0.1" jsonrpc-derive = "10.0.2" log = "0.4" parking_lot = "0.7.1" -parity-codec = "3.1" +parity-codec = "3.2" serde = "1.0" serde_derive = "1.0" serde_json = "1.0" diff --git a/substrate/core/service/Cargo.toml b/substrate/core/service/Cargo.toml index 59fd77a219..353a3a9973 100644 --- a/substrate/core/service/Cargo.toml +++ b/substrate/core/service/Cargo.toml @@ -25,7 +25,7 @@ consensus_common = { package = "substrate-consensus-common", path = "../../core/ network = { package = "substrate-network", path = "../../core/network" } client = { package = "substrate-client", path = "../../core/client" } client_db = { package = "substrate-client-db", path = "../../core/client/db" } -parity-codec = "3.1" +parity-codec = "3.2" substrate-executor = { path = "../../core/executor" } transaction_pool = { package = "substrate-transaction-pool", path = "../../core/transaction-pool" } rpc = { package = "substrate-rpc-servers", path = "../../core/rpc-servers" } diff --git a/substrate/core/sr-io/Cargo.toml b/substrate/core/sr-io/Cargo.toml index fa04c17e3f..811c17e0b1 100644 --- a/substrate/core/sr-io/Cargo.toml +++ b/substrate/core/sr-io/Cargo.toml @@ -11,7 +11,7 @@ rustc_version = "0.2" [dependencies] rstd = { package = "sr-std", path = "../sr-std", default-features = false } primitives = { package = "substrate-primitives", path = "../primitives", default-features = false } -parity-codec = { version = "3.1", default-features = false } +parity-codec = { version = "3.2", default-features = false } hash-db = { version = "0.11", default-features = false } libsecp256k1 = { version = "0.2.1", optional = true } tiny-keccak = { version = "1.4.2", optional = true } diff --git a/substrate/core/sr-primitives/Cargo.toml b/substrate/core/sr-primitives/Cargo.toml index 4ef85b4989..565b9fb1e4 100644 --- a/substrate/core/sr-primitives/Cargo.toml +++ b/substrate/core/sr-primitives/Cargo.toml @@ -9,7 +9,7 @@ num-traits = { version = "0.2", default-features = false } integer-sqrt = { version = "0.1.2" } serde = { version = "1.0", optional = true } serde_derive = { version = "1.0", optional = true } -parity-codec = { version = "3.1", default-features = false, features = ["derive"] } +parity-codec = { version = "3.2", default-features = false, features = ["derive"] } substrate-primitives = { path = "../primitives", default-features = false } rstd = { package = "sr-std", path = "../sr-std", default-features = false } runtime_io = { package = "sr-io", path = "../sr-io", default-features = false } diff --git a/substrate/core/sr-primitives/src/lib.rs b/substrate/core/sr-primitives/src/lib.rs index 0c77b1a468..6df4bdeb78 100644 --- a/substrate/core/sr-primitives/src/lib.rs +++ b/substrate/core/sr-primitives/src/lib.rs @@ -477,6 +477,13 @@ pub fn verify_encoded_lazy(sig: &V, item: &T, signe /// Helper macro for `impl_outer_config` #[macro_export] macro_rules! __impl_outer_config_types { + ( + $concrete:ident $config:ident $snake:ident < $ignore:ident, $instance:path > $( $rest:tt )* + ) => { + #[cfg(any(feature = "std", test))] + pub type $config = $snake::GenesisConfig<$concrete, $instance>; + $crate::__impl_outer_config_types! {$concrete $($rest)*} + }; ( $concrete:ident $config:ident $snake:ident < $ignore:ident > $( $rest:tt )* ) => { @@ -504,12 +511,12 @@ macro_rules! __impl_outer_config_types { macro_rules! impl_outer_config { ( pub struct $main:ident for $concrete:ident { - $( $config:ident => $snake:ident $( < $generic:ident > )*, )* + $( $config:ident => $snake:ident $( < $generic:ident $(, $instance:path)? > )*, )* } ) => { - $crate::__impl_outer_config_types! { $concrete $( $config $snake $( < $generic > )* )* } + $crate::__impl_outer_config_types! { $concrete $( $config $snake $( < $generic $(, $instance)? > )* )* } #[cfg(any(feature = "std", test))] - #[derive(Serialize, Deserialize)] + #[derive($crate::serde_derive::Serialize, $crate::serde_derive::Deserialize)] #[serde(rename_all = "camelCase")] #[serde(deny_unknown_fields)] pub struct $main { @@ -551,7 +558,7 @@ macro_rules! impl_outer_log { ( $(#[$attr:meta])* pub enum $name:ident ($internal:ident: DigestItem<$( $genarg:ty ),*>) for $trait:ident { - $( $module:ident( $( $sitem:ident ),* ) ),* + $( $module:ident $(<$instance:path>)? ( $( $sitem:ident ),* ) ),* } ) => { /// Wrapper for all possible log entries for the `$trait` runtime. Provides binary-compatible @@ -564,13 +571,13 @@ macro_rules! impl_outer_log { /// All possible log entries for the `$trait` runtime. `Encode`/`Decode` implementations /// are auto-generated => it is not binary-compatible with `generic::DigestItem`. - #[derive(Clone, PartialEq, Eq, Encode, Decode)] + #[derive(Clone, PartialEq, Eq, $crate::codec::Encode, $crate::codec::Decode)] #[cfg_attr(feature = "std", derive(Debug, $crate::serde_derive::Serialize))] $(#[$attr])* #[allow(non_camel_case_types)] pub enum InternalLog { $( - $module($module::Log<$trait>), + $module($module::Log<$trait $(, $instance)? >), )* } @@ -648,16 +655,16 @@ macro_rules! impl_outer_log { } $( - impl From<$module::Log<$trait>> for $name { + impl From<$module::Log<$trait $(, $instance)? >> for $name { /// Converts single module log item into `$name`. - fn from(x: $module::Log<$trait>) -> Self { + fn from(x: $module::Log<$trait $(, $instance)? >) -> Self { $name(x.into()) } } - impl From<$module::Log<$trait>> for InternalLog { + impl From<$module::Log<$trait $(, $instance)? >> for InternalLog { /// Converts single module log item into `$internal`. - fn from(x: $module::Log<$trait>) -> Self { + fn from(x: $module::Log<$trait $(, $instance)? >) -> Self { InternalLog::$module(x) } } diff --git a/substrate/core/sr-sandbox/Cargo.toml b/substrate/core/sr-sandbox/Cargo.toml index b48744240e..599e66d663 100755 --- a/substrate/core/sr-sandbox/Cargo.toml +++ b/substrate/core/sr-sandbox/Cargo.toml @@ -12,7 +12,7 @@ rustc_version = "0.2" wasmi = { version = "0.4.3", optional = true } primitives = { package = "substrate-primitives", path = "../primitives", default-features = false } rstd = { package = "sr-std", path = "../sr-std", default-features = false } -codec = { package = "parity-codec", version = "3.0", default-features = false } +codec = { package = "parity-codec", version = "3.2", default-features = false } [dev-dependencies] wabt = "~0.7.4" diff --git a/substrate/core/sr-version/Cargo.toml b/substrate/core/sr-version/Cargo.toml index 5a1e6162f1..cf3062faac 100644 --- a/substrate/core/sr-version/Cargo.toml +++ b/substrate/core/sr-version/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" impl-serde = { version = "0.1", optional = true } serde = { version = "1.0", optional = true } serde_derive = { version = "1.0", optional = true } -parity-codec = { version = "3.1", default-features = false, features = ["derive"] } +parity-codec = { version = "3.2", default-features = false, features = ["derive"] } rstd = { package = "sr-std", path = "../sr-std", default-features = false } runtime_primitives = { package = "sr-primitives", path = "../sr-primitives", default-features = false } diff --git a/substrate/core/state-db/Cargo.toml b/substrate/core/state-db/Cargo.toml index 17cd633518..28d5696928 100644 --- a/substrate/core/state-db/Cargo.toml +++ b/substrate/core/state-db/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" parking_lot = "0.7.1" log = "0.4" primitives = { package = "substrate-primitives", path = "../../core/primitives" } -parity-codec = { version = "3.1", features = ["derive"] } +parity-codec = { version = "3.2", features = ["derive"] } [dev-dependencies] env_logger = "0.6" diff --git a/substrate/core/state-machine/Cargo.toml b/substrate/core/state-machine/Cargo.toml index 9a5c42abf2..61a99f8e94 100644 --- a/substrate/core/state-machine/Cargo.toml +++ b/substrate/core/state-machine/Cargo.toml @@ -16,4 +16,4 @@ trie-root = "0.11" trie = { package = "substrate-trie", path = "../trie" } primitives = { package = "substrate-primitives", path = "../primitives" } panic-handler = { package = "substrate-panic-handler", path = "../panic-handler" } -parity-codec = "3.1" +parity-codec = "3.2" diff --git a/substrate/core/test-client/Cargo.toml b/substrate/core/test-client/Cargo.toml index 821e87da40..5049b2ff9f 100644 --- a/substrate/core/test-client/Cargo.toml +++ b/substrate/core/test-client/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" client = { package = "substrate-client", path = "../client" } client-db = { package = "substrate-client-db", path = "../client/db", features = ["test-helpers"] } futures = { version = "0.1.17" } -parity-codec = "3.1" +parity-codec = "3.2" executor = { package = "substrate-executor", path = "../executor" } consensus = { package = "substrate-consensus-common", path = "../consensus/common" } keyring = { package = "substrate-keyring", path = "../../core/keyring" } diff --git a/substrate/core/test-runtime/Cargo.toml b/substrate/core/test-runtime/Cargo.toml index bddabbe928..812dd4bc28 100644 --- a/substrate/core/test-runtime/Cargo.toml +++ b/substrate/core/test-runtime/Cargo.toml @@ -9,7 +9,7 @@ log = { version = "0.4", optional = true } hex-literal = { version = "0.1.0", optional = true } serde = { version = "1.0", optional = true } serde_derive = { version = "1.0", optional = true } -parity-codec = { version = "3.1", default-features = false, features = ["derive"] } +parity-codec = { version = "3.2", default-features = false, features = ["derive"] } keyring = { package = "substrate-keyring", path = "../keyring", optional = true } substrate-client = { path = "../client", default-features = false } primitives = { package = "substrate-primitives", path = "../primitives", default-features = false } diff --git a/substrate/core/test-runtime/wasm/Cargo.lock b/substrate/core/test-runtime/wasm/Cargo.lock index 0746e5aa81..f933220f0b 100644 --- a/substrate/core/test-runtime/wasm/Cargo.lock +++ b/substrate/core/test-runtime/wasm/Cargo.lock @@ -560,7 +560,7 @@ name = "impl-codec" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -838,7 +838,7 @@ source = "git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7 [[package]] name = "parity-codec" -version = "3.1.0" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1371,7 +1371,7 @@ dependencies = [ "environmental 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "hash-db 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 0.1.0", "substrate-primitives 0.1.0", @@ -1387,7 +1387,7 @@ dependencies = [ "integer-sqrt 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", @@ -1407,7 +1407,7 @@ name = "sr-version" version = "0.1.0" dependencies = [ "impl-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 0.1.0", @@ -1418,7 +1418,7 @@ dependencies = [ name = "srml-executive" version = "0.1.0" dependencies = [ - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", "sr-primitives 0.1.0", @@ -1431,7 +1431,7 @@ dependencies = [ name = "srml-metadata" version = "0.1.0" dependencies = [ - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 0.1.0", @@ -1445,10 +1445,11 @@ dependencies = [ "bitmask 0.5.0 (git+https://github.com/paritytech/bitmask)", "hex-literal 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "once_cell 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "paste 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", "sr-primitives 0.1.0", "sr-std 0.1.0", @@ -1493,7 +1494,7 @@ name = "srml-system" version = "0.1.0" dependencies = [ "hex-literal 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.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.89 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1537,7 +1538,7 @@ dependencies = [ "hex-literal 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "sr-api-macros 0.1.0", "sr-primitives 0.1.0", @@ -1568,7 +1569,7 @@ dependencies = [ "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 0.1.0", "sr-version 0.1.0", @@ -1586,7 +1587,7 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1605,7 +1606,7 @@ dependencies = [ name = "substrate-inherents" version = "0.1.0" dependencies = [ - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 0.1.0", "sr-std 0.1.0", @@ -1640,7 +1641,7 @@ dependencies = [ "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "impl-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "primitive-types 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1674,7 +1675,7 @@ dependencies = [ "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-panic-handler 0.1.0", "substrate-primitives 0.1.0", @@ -1707,7 +1708,7 @@ dependencies = [ "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", @@ -1736,7 +1737,7 @@ version = "0.4.0" dependencies = [ "hash-db 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "memory-db 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "trie-db 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "trie-root 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2260,7 +2261,7 @@ dependencies = [ "checksum openssl-sys 0.9.42 (registry+https://github.com/rust-lang/crates.io-index)" = "cb534d752bf98cf363b473950659ac2546517f9c6be9723771614ab3f03bbc9e" "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-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "67a4d27831e31e27f1454d6e3d3bb34bcac6bf7ad7032eed0ad0070dc8cf55c1" +"checksum parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "21c9c3a1623c71ed83964ff28cac6126e178920f7646d32c337eacb9152b2907" "checksum parity-codec-derive 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "864e9f66b58c0b38f0d6b511b6576afa2b678ae801b64220553bced57ac12df9" "checksum parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)" = "511379a8194230c2395d2f5fa627a5a7e108a9f976656ce723ae68fca4097bfc" "checksum parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ab41b4aed082705d1056416ae4468b6ea99d52599ecf3169b00088d43113e337" diff --git a/substrate/core/test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.compact.wasm b/substrate/core/test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.compact.wasm index 7d348a504e..82ede85903 100644 Binary files a/substrate/core/test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.compact.wasm and b/substrate/core/test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.compact.wasm differ diff --git a/substrate/core/transaction-pool/Cargo.toml b/substrate/core/transaction-pool/Cargo.toml index 4e8c4dd0f6..1286b7bde4 100644 --- a/substrate/core/transaction-pool/Cargo.toml +++ b/substrate/core/transaction-pool/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" error-chain = "0.12" futures = "0.1" log = "0.4" -parity-codec = "3.1" +parity-codec = "3.2" parking_lot = "0.7.1" sr-primitives = { path = "../sr-primitives" } client = { package = "substrate-client", path = "../client" } diff --git a/substrate/core/transaction-pool/graph/Cargo.toml b/substrate/core/transaction-pool/graph/Cargo.toml index cd0e1ec274..98d8493428 100644 --- a/substrate/core/transaction-pool/graph/Cargo.toml +++ b/substrate/core/transaction-pool/graph/Cargo.toml @@ -15,5 +15,5 @@ sr-primitives = { path = "../../sr-primitives" } [dev-dependencies] assert_matches = "1.1" -parity-codec = "3.1" +parity-codec = "3.2" test_runtime = { package = "substrate-test-runtime", path = "../../test-runtime" } diff --git a/substrate/core/trie/Cargo.toml b/substrate/core/trie/Cargo.toml index cf4b18ead0..9d93cbe599 100644 --- a/substrate/core/trie/Cargo.toml +++ b/substrate/core/trie/Cargo.toml @@ -12,7 +12,7 @@ name = "bench" harness = false [dependencies] -codec = { package = "parity-codec", version = "3.0" } +codec = { package = "parity-codec", version = "3.2" } hash-db = { version = "0.11", default-features = false } trie-db = { version = "0.11", optional = true } trie-root = { version = "0.11", default-features = false } diff --git a/substrate/core/util/fork-tree/Cargo.toml b/substrate/core/util/fork-tree/Cargo.toml index 7dfd82991f..4098fb80fa 100644 --- a/substrate/core/util/fork-tree/Cargo.toml +++ b/substrate/core/util/fork-tree/Cargo.toml @@ -5,4 +5,4 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -parity-codec = { version = "3.1", features = ["derive"] } +parity-codec = { version = "3.2", features = ["derive"] } diff --git a/substrate/node-template/Cargo.toml b/substrate/node-template/Cargo.toml index 0c5d15da08..b66fe0e7de 100644 --- a/substrate/node-template/Cargo.toml +++ b/substrate/node-template/Cargo.toml @@ -18,7 +18,7 @@ tokio = "0.1" exit-future = "0.1" parking_lot = "0.7.1" hex-literal = "0.1" -parity-codec = "3.1" +parity-codec = "3.2" trie-root = "0.11.0" sr-io = { path = "../core/sr-io" } substrate-cli = { path = "../core/cli" } diff --git a/substrate/node-template/runtime/Cargo.toml b/substrate/node-template/runtime/Cargo.toml index 066e9da79d..d6cb7ea7f2 100644 --- a/substrate/node-template/runtime/Cargo.toml +++ b/substrate/node-template/runtime/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" serde = { version = "1.0", optional = true } serde_derive = { version = "1.0", optional = true } safe-mix = { version = "1.0", default-features = false } -parity-codec = { version = "3.1", default-features = false, features = ["derive"] } +parity-codec = { version = "3.2", default-features = false, features = ["derive"] } rstd = { package = "sr-std", path = "../../core/sr-std", default_features = false } runtime-io = { package = "sr-io", path = "../../core/sr-io", default_features = false } version = { package = "sr-version", path = "../../core/sr-version", default_features = false } diff --git a/substrate/node-template/runtime/wasm/Cargo.lock b/substrate/node-template/runtime/wasm/Cargo.lock index 98c611de64..dfd1c90fee 100644 --- a/substrate/node-template/runtime/wasm/Cargo.lock +++ b/substrate/node-template/runtime/wasm/Cargo.lock @@ -560,7 +560,7 @@ name = "impl-codec" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -763,7 +763,7 @@ dependencies = [ name = "node-template-runtime" version = "0.9.0" dependencies = [ - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.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.89 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", @@ -872,7 +872,7 @@ source = "git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7 [[package]] name = "parity-codec" -version = "3.1.0" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1405,7 +1405,7 @@ dependencies = [ "environmental 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "hash-db 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 0.1.0", "substrate-primitives 0.1.0", @@ -1421,7 +1421,7 @@ dependencies = [ "integer-sqrt 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", @@ -1441,7 +1441,7 @@ name = "sr-version" version = "0.1.0" dependencies = [ "impl-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 0.1.0", @@ -1453,7 +1453,7 @@ name = "srml-aura" version = "0.1.0" dependencies = [ "hex-literal 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 0.1.0", @@ -1471,7 +1471,7 @@ name = "srml-balances" version = "0.1.0" dependencies = [ "hex-literal 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.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.89 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 0.1.0", @@ -1486,7 +1486,7 @@ name = "srml-consensus" version = "0.1.0" dependencies = [ "hex-literal 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 0.1.0", @@ -1501,7 +1501,7 @@ dependencies = [ name = "srml-executive" version = "0.1.0" dependencies = [ - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", "sr-primitives 0.1.0", @@ -1515,7 +1515,7 @@ name = "srml-fees" version = "0.1.0" dependencies = [ "hex-literal 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", @@ -1531,7 +1531,7 @@ name = "srml-indices" version = "0.1.0" dependencies = [ "hex-literal 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.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.89 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1548,7 +1548,7 @@ dependencies = [ name = "srml-metadata" version = "0.1.0" dependencies = [ - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 0.1.0", @@ -1560,7 +1560,7 @@ name = "srml-session" version = "0.1.0" dependencies = [ "hex-literal 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.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.89 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1577,7 +1577,7 @@ name = "srml-staking" version = "0.1.0" dependencies = [ "hex-literal 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.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.89 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", @@ -1595,7 +1595,7 @@ name = "srml-sudo" version = "0.1.0" dependencies = [ "hex-literal 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 0.1.0", @@ -1612,10 +1612,11 @@ dependencies = [ "bitmask 0.5.0 (git+https://github.com/paritytech/bitmask)", "hex-literal 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "once_cell 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "paste 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", "sr-primitives 0.1.0", "sr-std 0.1.0", @@ -1660,7 +1661,7 @@ name = "srml-system" version = "0.1.0" dependencies = [ "hex-literal 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.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.89 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1676,7 +1677,7 @@ name = "srml-timestamp" version = "0.1.0" dependencies = [ "hex-literal 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 0.1.0", "sr-std 0.1.0", @@ -1718,7 +1719,7 @@ dependencies = [ "hex-literal 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "sr-api-macros 0.1.0", "sr-primitives 0.1.0", @@ -1749,7 +1750,7 @@ dependencies = [ "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 0.1.0", "sr-version 0.1.0", @@ -1767,7 +1768,7 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1786,7 +1787,7 @@ dependencies = [ name = "substrate-inherents" version = "0.1.0" dependencies = [ - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 0.1.0", "sr-std 0.1.0", @@ -1821,7 +1822,7 @@ dependencies = [ "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "impl-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "primitive-types 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1855,7 +1856,7 @@ dependencies = [ "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-panic-handler 0.1.0", "substrate-primitives 0.1.0", @@ -1887,7 +1888,7 @@ version = "0.4.0" dependencies = [ "hash-db 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "memory-db 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "trie-db 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "trie-root 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2411,7 +2412,7 @@ dependencies = [ "checksum openssl-sys 0.9.42 (registry+https://github.com/rust-lang/crates.io-index)" = "cb534d752bf98cf363b473950659ac2546517f9c6be9723771614ab3f03bbc9e" "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-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "67a4d27831e31e27f1454d6e3d3bb34bcac6bf7ad7032eed0ad0070dc8cf55c1" +"checksum parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "21c9c3a1623c71ed83964ff28cac6126e178920f7646d32c337eacb9152b2907" "checksum parity-codec-derive 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "864e9f66b58c0b38f0d6b511b6576afa2b678ae801b64220553bced57ac12df9" "checksum parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)" = "511379a8194230c2395d2f5fa627a5a7e108a9f976656ce723ae68fca4097bfc" "checksum parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ab41b4aed082705d1056416ae4468b6ea99d52599ecf3169b00088d43113e337" diff --git a/substrate/node/cli/Cargo.toml b/substrate/node/cli/Cargo.toml index 8df7e76a54..28fb297e57 100644 --- a/substrate/node/cli/Cargo.toml +++ b/substrate/node/cli/Cargo.toml @@ -12,7 +12,7 @@ tokio = "0.1.7" futures = "0.1" exit-future = "0.1" cli = { package = "substrate-cli", path = "../../core/cli" } -parity-codec = { version = "3.1" } +parity-codec = { version = "3.2" } sr-io = { path = "../../core/sr-io" } client = { package = "substrate-client", path = "../../core/client" } primitives = { package = "substrate-primitives", path = "../../core/primitives" } diff --git a/substrate/node/executor/Cargo.toml b/substrate/node/executor/Cargo.toml index d0e329b264..3e0f618bc7 100644 --- a/substrate/node/executor/Cargo.toml +++ b/substrate/node/executor/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] trie-root = "0.11" -parity-codec = "3.1" +parity-codec = "3.2" runtime_io = { package = "sr-io", path = "../../core/sr-io" } state_machine = { package = "substrate-state-machine", path = "../../core/state-machine" } substrate-executor = { path = "../../core/executor" } diff --git a/substrate/node/primitives/Cargo.toml b/substrate/node/primitives/Cargo.toml index 724eb7d0ab..b7da80c9a8 100644 --- a/substrate/node/primitives/Cargo.toml +++ b/substrate/node/primitives/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] serde = { version = "1.0", optional = true } serde_derive = { version = "1.0", optional = true } -parity-codec = { version = "3.1", default-features = false } +parity-codec = { version = "3.2", default-features = false } parity-codec-derive = { version = "3.1", default-features = false } primitives = { package = "substrate-primitives", path = "../../core/primitives", default-features = false } rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false } diff --git a/substrate/node/runtime/Cargo.toml b/substrate/node/runtime/Cargo.toml index 0c695f5ef1..6a5d334687 100644 --- a/substrate/node/runtime/Cargo.toml +++ b/substrate/node/runtime/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] integer-sqrt = { version = "0.1.2" } safe-mix = { version = "1.0", default-features = false } -parity-codec = { version = "3.1", default-features = false, features = ["derive"] } +parity-codec = { version = "3.2", default-features = false, features = ["derive"] } substrate-primitives = { path = "../../core/primitives", default-features = false } client = { package = "substrate-client", path = "../../core/client", default-features = false } rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false } diff --git a/substrate/node/runtime/src/lib.rs b/substrate/node/runtime/src/lib.rs index ae24c263f7..7ca5c697f6 100644 --- a/substrate/node/runtime/src/lib.rs +++ b/substrate/node/runtime/src/lib.rs @@ -21,9 +21,6 @@ #![recursion_limit="256"] use rstd::prelude::*; -use parity_codec::{Encode, Decode}; -#[cfg(feature = "std")] -use support::{Serialize, Deserialize}; use support::construct_runtime; use substrate_primitives::u32_trait::{_2, _4}; use node_primitives::{ @@ -62,7 +59,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { impl_name: create_runtime_str!("substrate-node"), authoring_version: 10, spec_version: 35, - impl_version: 37, + impl_version: 38, apis: RUNTIME_API_VERSIONS, }; diff --git a/substrate/node/runtime/wasm/Cargo.lock b/substrate/node/runtime/wasm/Cargo.lock index 7c87f49874..6d704abe36 100644 --- a/substrate/node/runtime/wasm/Cargo.lock +++ b/substrate/node/runtime/wasm/Cargo.lock @@ -560,7 +560,7 @@ name = "impl-codec" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -763,7 +763,7 @@ dependencies = [ name = "node-primitives" version = "0.1.0" dependencies = [ - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", @@ -779,7 +779,7 @@ dependencies = [ "hex-literal 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "integer-sqrt 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "node-primitives 0.1.0", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.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.89 (registry+https://github.com/rust-lang/crates.io-index)", @@ -897,7 +897,7 @@ source = "git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7 [[package]] name = "parity-codec" -version = "3.1.0" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1440,7 +1440,7 @@ dependencies = [ "environmental 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "hash-db 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 0.1.0", "substrate-primitives 0.1.0", @@ -1456,7 +1456,7 @@ dependencies = [ "integer-sqrt 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", @@ -1468,7 +1468,7 @@ dependencies = [ name = "sr-sandbox" version = "0.1.0" dependencies = [ - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 0.1.0", "substrate-primitives 0.1.0", @@ -1487,7 +1487,7 @@ name = "sr-version" version = "0.1.0" dependencies = [ "impl-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 0.1.0", @@ -1499,7 +1499,7 @@ name = "srml-aura" version = "0.1.0" dependencies = [ "hex-literal 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 0.1.0", "sr-std 0.1.0", @@ -1516,7 +1516,7 @@ name = "srml-balances" version = "0.1.0" dependencies = [ "hex-literal 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.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.89 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 0.1.0", @@ -1531,7 +1531,7 @@ name = "srml-consensus" version = "0.1.0" dependencies = [ "hex-literal 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 0.1.0", @@ -1546,7 +1546,7 @@ dependencies = [ name = "srml-contract" version = "0.1.0" dependencies = [ - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)", "pwasm-utils 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1567,7 +1567,7 @@ dependencies = [ name = "srml-council" version = "0.1.0" dependencies = [ - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.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.89 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1585,7 +1585,7 @@ name = "srml-democracy" version = "0.1.0" dependencies = [ "hex-literal 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.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.89 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1600,7 +1600,7 @@ dependencies = [ name = "srml-executive" version = "0.1.0" dependencies = [ - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", "sr-primitives 0.1.0", @@ -1614,7 +1614,7 @@ name = "srml-fees" version = "0.1.0" dependencies = [ "hex-literal 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", @@ -1630,7 +1630,7 @@ name = "srml-finality-tracker" version = "0.1.0" dependencies = [ "hex-literal 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 0.1.0", @@ -1644,7 +1644,7 @@ dependencies = [ name = "srml-grandpa" version = "0.1.0" dependencies = [ - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 0.1.0", @@ -1663,7 +1663,7 @@ name = "srml-indices" version = "0.1.0" dependencies = [ "hex-literal 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.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.89 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1680,7 +1680,7 @@ dependencies = [ name = "srml-metadata" version = "0.1.0" dependencies = [ - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 0.1.0", @@ -1692,7 +1692,7 @@ name = "srml-session" version = "0.1.0" dependencies = [ "hex-literal 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.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.89 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1709,7 +1709,7 @@ name = "srml-staking" version = "0.1.0" dependencies = [ "hex-literal 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.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.89 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", @@ -1727,7 +1727,7 @@ name = "srml-sudo" version = "0.1.0" dependencies = [ "hex-literal 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 0.1.0", @@ -1744,10 +1744,11 @@ dependencies = [ "bitmask 0.5.0 (git+https://github.com/paritytech/bitmask)", "hex-literal 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "once_cell 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "paste 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", + "spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 0.1.0", "sr-primitives 0.1.0", "sr-std 0.1.0", @@ -1792,7 +1793,7 @@ name = "srml-system" version = "0.1.0" dependencies = [ "hex-literal 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.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.89 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1808,7 +1809,7 @@ name = "srml-timestamp" version = "0.1.0" dependencies = [ "hex-literal 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 0.1.0", "sr-std 0.1.0", @@ -1822,7 +1823,7 @@ name = "srml-treasury" version = "0.1.0" dependencies = [ "hex-literal 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 0.1.0", @@ -1836,7 +1837,7 @@ dependencies = [ name = "srml-upgrade-key" version = "0.1.0" dependencies = [ - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 0.1.0", "sr-std 0.1.0", @@ -1878,7 +1879,7 @@ dependencies = [ "hex-literal 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "sr-api-macros 0.1.0", "sr-primitives 0.1.0", @@ -1909,7 +1910,7 @@ dependencies = [ "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 0.1.0", "sr-version 0.1.0", @@ -1927,7 +1928,7 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1946,7 +1947,7 @@ dependencies = [ name = "substrate-finality-grandpa-primitives" version = "0.1.0" dependencies = [ - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 0.1.0", "sr-std 0.1.0", "substrate-client 0.1.0", @@ -1957,7 +1958,7 @@ dependencies = [ name = "substrate-inherents" version = "0.1.0" dependencies = [ - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 0.1.0", "sr-std 0.1.0", @@ -1992,7 +1993,7 @@ dependencies = [ "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "impl-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "primitive-types 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2026,7 +2027,7 @@ dependencies = [ "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-panic-handler 0.1.0", "substrate-primitives 0.1.0", @@ -2058,7 +2059,7 @@ version = "0.4.0" dependencies = [ "hash-db 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "memory-db 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "trie-db 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "trie-root 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2582,7 +2583,7 @@ dependencies = [ "checksum openssl-sys 0.9.42 (registry+https://github.com/rust-lang/crates.io-index)" = "cb534d752bf98cf363b473950659ac2546517f9c6be9723771614ab3f03bbc9e" "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-codec 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "67a4d27831e31e27f1454d6e3d3bb34bcac6bf7ad7032eed0ad0070dc8cf55c1" +"checksum parity-codec 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "21c9c3a1623c71ed83964ff28cac6126e178920f7646d32c337eacb9152b2907" "checksum parity-codec-derive 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "864e9f66b58c0b38f0d6b511b6576afa2b678ae801b64220553bced57ac12df9" "checksum parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)" = "511379a8194230c2395d2f5fa627a5a7e108a9f976656ce723ae68fca4097bfc" "checksum parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ab41b4aed082705d1056416ae4468b6ea99d52599ecf3169b00088d43113e337" diff --git a/substrate/node/runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm b/substrate/node/runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm index a4684f21c9..f6ba616469 100644 Binary files a/substrate/node/runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm and b/substrate/node/runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm differ diff --git a/substrate/srml/assets/Cargo.toml b/substrate/srml/assets/Cargo.toml index 621d4a1ac4..f274661e6c 100644 --- a/substrate/srml/assets/Cargo.toml +++ b/substrate/srml/assets/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] hex-literal = "0.1.0" serde = { version = "1.0", optional = true } -parity-codec = { version = "3.1", default-features = false } +parity-codec = { version = "3.2", default-features = false } # Needed for various traits. In our case, `OnFinalise`. primitives = { package = "sr-primitives", path = "../../core/sr-primitives", default-features = false } # Needed for type-safe access to storage DB. diff --git a/substrate/srml/aura/Cargo.toml b/substrate/srml/aura/Cargo.toml index bb8af29e8d..9d1eda38c0 100644 --- a/substrate/srml/aura/Cargo.toml +++ b/substrate/srml/aura/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" [dependencies] hex-literal = "0.1.0" -parity-codec = { version = "3.1", default-features = false, features = ["derive"] } +parity-codec = { version = "3.2", default-features = false, features = ["derive"] } parity-codec-derive = { version = "3.1", default-features = false } serde = { version = "1.0", optional = true } inherents = { package = "substrate-inherents", path = "../../core/inherents", default-features = false } diff --git a/substrate/srml/balances/Cargo.toml b/substrate/srml/balances/Cargo.toml index c8d5d152a3..43759643dd 100644 --- a/substrate/srml/balances/Cargo.toml +++ b/substrate/srml/balances/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" hex-literal = "0.1.0" serde = { version = "1.0", optional = true } safe-mix = { version = "1.0", default-features = false} -parity-codec = { version = "3.1", default-features = false, features = ["derive"] } +parity-codec = { version = "3.2", default-features = false, features = ["derive"] } substrate-keyring = { path = "../../core/keyring", optional = true } rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false } primitives = { package = "sr-primitives", path = "../../core/sr-primitives", default-features = false } diff --git a/substrate/srml/balances/src/lib.rs b/substrate/srml/balances/src/lib.rs index c9b62998fc..ff0493f35f 100644 --- a/substrate/srml/balances/src/lib.rs +++ b/substrate/srml/balances/src/lib.rs @@ -41,7 +41,7 @@ use system::{IsDeadAccount, OnNewAccount, ensure_signed}; mod mock; mod tests; -pub trait Trait: system::Trait { +pub trait Trait: system::Trait { /// The balance of an account. type Balance: Parameter + Member + SimpleArithmetic + Codec + Default + Copy + As + As + MaybeSerializeDebug; @@ -55,7 +55,7 @@ pub trait Trait: system::Trait { type OnNewAccount: OnNewAccount; /// The overarching event type. - type Event: From> + Into<::Event>; + type Event: From> + Into<::Event>; } impl ArithmeticType for Module { @@ -63,9 +63,9 @@ impl ArithmeticType for Module { } decl_event!( - pub enum Event where + pub enum Event where ::AccountId, - ::Balance + >::Balance { /// A new account was created. NewAccount(AccountId, Balance), @@ -107,9 +107,9 @@ pub struct BalanceLock { } decl_storage! { - trait Store for Module as Balances { + trait Store for Module, I: Instance=DefaultInstance> as Balances { /// The total amount of stake on the system. - pub TotalIssuance get(total_issuance) build(|config: &GenesisConfig| { + pub TotalIssuance get(total_issuance) build(|config: &GenesisConfig| { config.balances.iter().fold(Zero::zero(), |acc: T::Balance, &(_, n)| acc + n) }): T::Balance; /// The minimum amount allowed to keep an account open. @@ -120,7 +120,7 @@ decl_storage! { pub CreationFee get(creation_fee) config(): T::Balance; /// Information regarding the vesting of a given account. - pub Vesting get(vesting) build(|config: &GenesisConfig| { + pub Vesting get(vesting) build(|config: &GenesisConfig| { config.vesting.iter().filter_map(|&(ref who, begin, length)| { let begin: u64 = begin.as_(); let length: u64 = length.as_(); @@ -152,7 +152,7 @@ decl_storage! { /// /// `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(free_balance) build(|config: &GenesisConfig| config.balances.clone()): map T::AccountId => T::Balance; + pub FreeBalance get(free_balance) build(|config: &GenesisConfig| config.balances.clone()): map T::AccountId => T::Balance; /// The amount of the balance of a given account that is externally reserved; this can still get /// slashed, but gets slashed last of all. @@ -175,11 +175,12 @@ decl_storage! { config(balances): Vec<(T::AccountId, T::Balance)>; config(vesting): Vec<(T::AccountId, T::BlockNumber, T::BlockNumber)>; // begin, length } + extra_genesis_skip_phantom_data_field; } decl_module! { - pub struct Module for enum Call where origin: T::Origin { - fn deposit_event() = default; + pub struct Module, I: Instance = DefaultInstance> for enum Call where origin: T::Origin { + fn deposit_event() = default; /// Transfer some liquid free balance to another staker. pub fn transfer( @@ -206,7 +207,7 @@ decl_module! { } // For funding methods, see Currency trait -impl Module { +impl, I: Instance> Module { /// Get the amount that is currently being vested and cannot be transfered out of this account. pub fn vesting_balance(who: &T::AccountId) -> T::Balance { @@ -223,11 +224,11 @@ impl Module { /// In that case it will return `AccountKilled`. pub fn set_reserved_balance(who: &T::AccountId, balance: T::Balance) -> UpdateBalanceOutcome { if balance < Self::existential_deposit() { - >::insert(who, balance); + >::insert(who, balance); Self::on_reserved_too_low(who); UpdateBalanceOutcome::AccountKilled } else { - >::insert(who, balance); + >::insert(who, balance); UpdateBalanceOutcome::Updated } } @@ -243,11 +244,11 @@ impl Module { // Commented out for no - but consider it instructive. // assert!(!Self::total_balance(who).is_zero()); if balance < Self::existential_deposit() { - >::insert(who, balance); + >::insert(who, balance); Self::on_free_too_low(who); UpdateBalanceOutcome::AccountKilled } else { - >::insert(who, balance); + >::insert(who, balance); UpdateBalanceOutcome::Updated } } @@ -260,7 +261,7 @@ impl Module { /// /// [`set_free_balance`]: #method.set_free_balance pub fn set_free_balance_creating(who: &T::AccountId, balance: T::Balance) -> UpdateBalanceOutcome { - let ed = >::existential_deposit(); + let ed = >::existential_deposit(); // If the balance is too low, then the account is reaped. // NOTE: There are two balances for every account: `reserved_balance` and // `free_balance`. This contract subsystem only cares about the latter: whenever @@ -275,7 +276,7 @@ impl Module { Self::set_free_balance(who, balance); UpdateBalanceOutcome::AccountKilled } else { - if !>::exists(who) { + if !>::exists(who) { Self::new_account(&who, balance); } Self::set_free_balance(who, balance); @@ -335,8 +336,8 @@ impl Module { /// Kill an account's free portion. fn on_free_too_low(who: &T::AccountId) { Self::decrease_total_stake_by(Self::free_balance(who)); - >::remove(who); - >::remove(who); + >::remove(who); + >::remove(who); T::OnFreeBalanceZero::on_free_balance_zero(who); @@ -348,7 +349,7 @@ impl Module { /// Kill an account's reserved portion. fn on_reserved_too_low(who: &T::AccountId) { Self::decrease_total_stake_by(Self::reserved_balance(who)); - >::remove(who); + >::remove(who); if Self::free_balance(who).is_zero() { Self::reap_account(who); @@ -357,14 +358,14 @@ impl Module { /// Increase TotalIssuance by Value. pub fn increase_total_stake_by(value: T::Balance) { - if let Some(v) = >::total_issuance().checked_add(&value) { - >::put(v); + if let Some(v) = >::total_issuance().checked_add(&value) { + >::put(v); } } /// Decrease TotalIssuance by Value. pub fn decrease_total_stake_by(value: T::Balance) { - if let Some(v) = >::total_issuance().checked_sub(&value) { - >::put(v); + if let Some(v) = >::total_issuance().checked_sub(&value) { + >::put(v); } } @@ -398,7 +399,7 @@ impl Module { } } -impl Currency for Module +impl, I: Instance> Currency for Module where T::Balance: MaybeSerializeDebug { @@ -421,7 +422,7 @@ where } fn total_issuance() -> Self::Balance { - >::get() + >::get() } fn minimum_balance() -> Self::Balance { @@ -429,11 +430,11 @@ where } fn free_balance(who: &T::AccountId) -> Self::Balance { - >::get(who) + >::get(who) } fn reserved_balance(who: &T::AccountId) -> Self::Balance { - >::get(who) + >::get(who) } fn slash(who: &T::AccountId, value: Self::Balance) -> Option { @@ -517,7 +518,7 @@ where } } -impl LockableCurrency for Module +impl, I: Instance> LockableCurrency for Module where T::Balance: MaybeSerializeDebug { @@ -543,7 +544,7 @@ where if let Some(lock) = new_lock { locks.push(lock) } - >::insert(who, locks); + >::insert(who, locks); } fn extend_lock( @@ -573,7 +574,7 @@ where if let Some(lock) = new_lock { locks.push(lock) } - >::insert(who, locks); + >::insert(who, locks); } fn remove_lock( @@ -587,11 +588,11 @@ where } else { None }).collect::>(); - >::insert(who, locks); + >::insert(who, locks); } } -impl TransferAsset for Module { +impl, I: Instance> TransferAsset for Module { type Amount = T::Balance; fn transfer(from: &T::AccountId, to: &T::AccountId, amount: T::Balance) -> Result { @@ -615,7 +616,7 @@ impl TransferAsset for Module { } } -impl IsDeadAccount for Module +impl, I: Instance> IsDeadAccount for Module where T::Balance: MaybeSerializeDebug { diff --git a/substrate/srml/consensus/Cargo.toml b/substrate/srml/consensus/Cargo.toml index 105f978c63..6adeb90d02 100644 --- a/substrate/srml/consensus/Cargo.toml +++ b/substrate/srml/consensus/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" hex-literal = "0.1.0" serde = { version = "1.0", optional = true } serde_derive = { version = "1.0", optional = true } -parity-codec = { version = "3.1", default-features = false, features = ["derive"] } +parity-codec = { version = "3.2", default-features = false, features = ["derive"] } substrate-primitives = { path = "../../core/primitives", default-features = false } inherents = { package = "substrate-inherents", path = "../../core/inherents", default-features = false } rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false } diff --git a/substrate/srml/contract/Cargo.toml b/substrate/srml/contract/Cargo.toml index d0c851e26e..0d373978b0 100644 --- a/substrate/srml/contract/Cargo.toml +++ b/substrate/srml/contract/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" serde = { version = "1.0", optional = true } serde_derive = { version = "1.0", optional = true } pwasm-utils = { version = "0.6.1", default-features = false } -parity-codec = { version = "3.1", default-features = false, features = ["derive"] } +parity-codec = { version = "3.2", default-features = false, features = ["derive"] } parity-wasm = { version = "0.31", default-features = false } substrate-primitives = { path = "../../core/primitives", default-features = false } runtime-primitives = { package = "sr-primitives", path = "../../core/sr-primitives", default-features = false } diff --git a/substrate/srml/council/Cargo.toml b/substrate/srml/council/Cargo.toml index 868ec3bcff..e26003a73e 100644 --- a/substrate/srml/council/Cargo.toml +++ b/substrate/srml/council/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] serde = { version = "1.0", optional = true } safe-mix = { version = "1.0", default-features = false} -parity-codec = { version = "3.1", default-features = false } +parity-codec = { version = "3.2", default-features = false } parity-codec-derive = { version = "3.1", default-features = false } substrate-primitives = { path = "../../core/primitives", default-features = false } rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false } diff --git a/substrate/srml/democracy/Cargo.toml b/substrate/srml/democracy/Cargo.toml index 29b70938f2..890882c485 100644 --- a/substrate/srml/democracy/Cargo.toml +++ b/substrate/srml/democracy/Cargo.toml @@ -9,7 +9,7 @@ hex-literal = "0.1.0" serde = { version = "1.0", optional = true } serde_derive = { version = "1.0", optional = true } safe-mix = { version = "1.0", default-features = false} -parity-codec = { version = "3.1", default-features = false, features = ["derive"] } +parity-codec = { version = "3.2", default-features = false, features = ["derive"] } rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false } runtime_io = { package = "sr-io", path = "../../core/sr-io", default-features = false } primitives = { package = "sr-primitives", path = "../../core/sr-primitives", default-features = false } diff --git a/substrate/srml/example/Cargo.toml b/substrate/srml/example/Cargo.toml index c1cf286346..57abe374c9 100644 --- a/substrate/srml/example/Cargo.toml +++ b/substrate/srml/example/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] hex-literal = "0.1.0" serde = { version = "1.0", optional = true } -parity-codec = { version = "3.1", default-features = false } +parity-codec = { version = "3.2", default-features = false } srml-support = { path = "../support", default-features = false } system = { package = "srml-system", path = "../system", default-features = false } balances = { package = "srml-balances", path = "../balances", default-features = false } diff --git a/substrate/srml/executive/Cargo.toml b/substrate/srml/executive/Cargo.toml index 04f6526666..0165a37bb2 100644 --- a/substrate/srml/executive/Cargo.toml +++ b/substrate/srml/executive/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" [dependencies] serde = { version = "1.0", optional = true } -parity-codec = { version = "3.1", default-features = false } +parity-codec = { version = "3.2", default-features = false } rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false } runtime_io = { package = "sr-io", path = "../../core/sr-io", default-features = false } primitives = { package = "sr-primitives", path = "../../core/sr-primitives", default-features = false } diff --git a/substrate/srml/fees/Cargo.toml b/substrate/srml/fees/Cargo.toml index d29d77c748..2bb4474ce6 100644 --- a/substrate/srml/fees/Cargo.toml +++ b/substrate/srml/fees/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] hex-literal = "0.1.0" serde = { version = "1.0", optional = true } -parity-codec = { version = "3.1", default-features = false } +parity-codec = { version = "3.2", default-features = false } parity-codec-derive = { version = "3.1", default-features = false } primitives = { package = "substrate-primitives", path = "../../core/primitives", default-features = false } rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false } diff --git a/substrate/srml/finality-tracker/Cargo.toml b/substrate/srml/finality-tracker/Cargo.toml index ac30f1e13d..22691e1aa7 100644 --- a/substrate/srml/finality-tracker/Cargo.toml +++ b/substrate/srml/finality-tracker/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" hex-literal = "0.1.0" serde = { version = "1.0", default-features = false } serde_derive = { version = "1.0", optional = true } -parity-codec = { version = "3.1", default-features = false } +parity-codec = { version = "3.2", default-features = false } inherents = { package = "substrate-inherents", path = "../../core/inherents", default-features = false } rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false } primitives = { package = "sr-primitives", path = "../../core/sr-primitives", default-features = false } diff --git a/substrate/srml/grandpa/Cargo.toml b/substrate/srml/grandpa/Cargo.toml index de260b622e..b7cc5dc231 100644 --- a/substrate/srml/grandpa/Cargo.toml +++ b/substrate/srml/grandpa/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" #hex-literal = "0.1.0" serde = { version = "1.0", optional = true } serde_derive = { version = "1.0", optional = true } -parity-codec = { version = "3.1", default-features = false, features = ["derive"] } +parity-codec = { version = "3.2", default-features = false, features = ["derive"] } substrate-primitives = { path = "../../core/primitives", default-features = false } substrate-finality-grandpa-primitives = { path = "../../core/finality-grandpa/primitives", default-features = false } rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false } diff --git a/substrate/srml/indices/Cargo.toml b/substrate/srml/indices/Cargo.toml index 399c7b1bd0..2331f325d1 100644 --- a/substrate/srml/indices/Cargo.toml +++ b/substrate/srml/indices/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" hex-literal = "0.1.0" serde = { version = "1.0", optional = true } safe-mix = { version = "1.0", default-features = false} -parity-codec = { version = "3.1", default-features = false } +parity-codec = { version = "3.2", default-features = false } parity-codec-derive = { version = "3.1", default-features = false } substrate-keyring = { path = "../../core/keyring", optional = true } rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false } diff --git a/substrate/srml/metadata/Cargo.toml b/substrate/srml/metadata/Cargo.toml index 1bbb8a77df..eed5e6b4e3 100644 --- a/substrate/srml/metadata/Cargo.toml +++ b/substrate/srml/metadata/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Parity Technologies "] edition = "2018" [dependencies] -parity-codec = { version = "3.1", default-features = false, features = ["derive"] } +parity-codec = { version = "3.2", default-features = false, features = ["derive"] } serde = { version = "1.0", optional = true } serde_derive = { version = "1.0", optional = true } rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false } diff --git a/substrate/srml/session/Cargo.toml b/substrate/srml/session/Cargo.toml index 8412505d32..84b49b7788 100644 --- a/substrate/srml/session/Cargo.toml +++ b/substrate/srml/session/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" hex-literal = "0.1.0" serde = { version = "1.0", optional = true } safe-mix = { version = "1.0", default-features = false} -parity-codec = { version = "3.1", default-features = false } +parity-codec = { version = "3.2", default-features = false } parity-codec-derive = { version = "3.1", default-features = false } rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false } primitives = { package = "sr-primitives", path = "../../core/sr-primitives", default-features = false } diff --git a/substrate/srml/staking/Cargo.toml b/substrate/srml/staking/Cargo.toml index c548b3a2ef..967cee3391 100644 --- a/substrate/srml/staking/Cargo.toml +++ b/substrate/srml/staking/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" hex-literal = "0.1.0" serde = { version = "1.0", optional = true } safe-mix = { version = "1.0", default-features = false} -parity-codec = { version = "3.1", default-features = false, features = ["derive"] } +parity-codec = { version = "3.2", default-features = false, features = ["derive"] } substrate-keyring = { path = "../../core/keyring", optional = true } rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false } runtime_io = { package = "sr-io", path = "../../core/sr-io", default-features = false } diff --git a/substrate/srml/sudo/Cargo.toml b/substrate/srml/sudo/Cargo.toml index 8473d2fb44..ef0bb59b53 100644 --- a/substrate/srml/sudo/Cargo.toml +++ b/substrate/srml/sudo/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] hex-literal = "0.1.0" serde = { version = "1.0", optional = true } -parity-codec = { version = "3.1", default-features = false } +parity-codec = { version = "3.2", default-features = false } parity-codec-derive = { version = "3.1", default-features = false } sr-std = { path = "../../core/sr-std", default-features = false } sr-primitives = { path = "../../core/sr-primitives", default-features = false } diff --git a/substrate/srml/support/Cargo.toml b/substrate/srml/support/Cargo.toml index 2cc4cfa0c8..357aa0c757 100644 --- a/substrate/srml/support/Cargo.toml +++ b/substrate/srml/support/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" hex-literal = { version = "0.1.0", optional = true } serde = { version = "1.0", optional = true } serde_derive = { version = "1.0", optional = true } -parity-codec = { version = "3.1", default-features = false, features = ["derive"] } +parity-codec = { version = "3.2", default-features = false, features = ["derive"] } srml-metadata = { path = "../metadata", default-features = false } sr-std = { path = "../../core/sr-std", default-features = false } runtime_io = { package = "sr-io", path = "../../core/sr-io", default-features = false } @@ -17,6 +17,7 @@ inherents = { package = "substrate-inherents", path = "../../core/inherents", de srml-support-procedural = { path = "./procedural" } paste = "0.1" once_cell = { version = "0.1.6", default-features = false, optional = true } +spin = "0.5" bitmask = { git = "https://github.com/paritytech/bitmask", default-features = false } [dev-dependencies] diff --git a/substrate/srml/support/procedural/src/lib.rs b/substrate/srml/support/procedural/src/lib.rs index 47aef0fe9f..5464302e29 100644 --- a/substrate/srml/support/procedural/src/lib.rs +++ b/substrate/srml/support/procedural/src/lib.rs @@ -58,6 +58,18 @@ use proc_macro::TokenStream; /// ``` /// or when at least one storage field requires default initialization (both `get` and `config` or `build`). /// This struct can be expose as `Config` by `decl_runtime` macro. +/// +/// ### Module with instances +/// +/// `decl_storage!` macro support building modules with instances with the following syntax: (DefaultInstance type +/// is optionnal) +/// ```nocompile +/// trait Store for Module, I: Instance=DefaultInstance> as Example {} +/// ``` +/// +/// Then the genesis config is generated with two generic parameter `GenesisConfig` +/// and storages are now accessible using two generic parameters like: +/// `>::get()` or `Dummy::::get()` #[proc_macro] pub fn decl_storage(input: TokenStream) -> TokenStream { storage::transformation::decl_storage_impl(input) diff --git a/substrate/srml/support/procedural/src/storage/impls.rs b/substrate/srml/support/procedural/src/storage/impls.rs index 661f6b7a59..efbb9a8d7a 100644 --- a/substrate/srml/support/procedural/src/storage/impls.rs +++ b/substrate/srml/support/procedural/src/storage/impls.rs @@ -17,7 +17,7 @@ use proc_macro2::TokenStream as TokenStream2; use syn; use quote::quote; -use crate::storage::transformation::DeclStorageTypeInfos; +use crate::storage::transformation::{DeclStorageTypeInfos, InstanceOpts}; pub fn option_unwrap(is_option: bool) -> TokenStream2 { if !is_option { @@ -34,9 +34,11 @@ pub(crate) struct Impls<'a, I: Iterator> { pub visibility: &'a syn::Visibility, pub traitinstance: &'a syn::Ident, pub traittype: &'a syn::TypeParamBound, + pub instance_opts: &'a InstanceOpts, pub type_infos: DeclStorageTypeInfos<'a>, pub fielddefault: TokenStream2, pub prefix: String, + pub cratename: &'a syn::Ident, pub name: &'a syn::Ident, pub attrs: I, } @@ -48,11 +50,13 @@ impl<'a, I: Iterator> Impls<'a, I> { visibility, traitinstance, traittype, + instance_opts, type_infos, fielddefault, prefix, name, attrs, + .. } = self; let DeclStorageTypeInfos { typ, value_type, is_option, .. } = type_infos; let option_simple_1 = option_unwrap(is_option); @@ -70,17 +74,32 @@ impl<'a, I: Iterator> Impls<'a, I> { } }; + let InstanceOpts { + comma_instance, + equal_default_instance, + bound_instantiable, + instance, + .. + } = instance_opts; + + let final_prefix = if let Some(instance) = instance { + let method_name = syn::Ident::new(&format!("build_prefix_once_for_{}", name.to_string()), proc_macro2::Span::call_site()); + quote!{ #instance::#method_name(#prefix.as_bytes()) } + } else { + quote!{ #prefix.as_bytes() } + }; + // generator for value quote!{ #( #[ #attrs ] )* - #visibility struct #name<#traitinstance: #traittype>(#scrate::storage::generator::PhantomData<#traitinstance>); + #visibility struct #name<#traitinstance: #traittype, #instance #bound_instantiable #equal_default_instance>(#scrate::storage::generator::PhantomData<(#traitinstance #comma_instance)>); - impl<#traitinstance: #traittype> #scrate::storage::generator::StorageValue<#typ> for #name<#traitinstance> { + impl<#traitinstance: #traittype, #instance #bound_instantiable> #scrate::storage::generator::StorageValue<#typ> for #name<#traitinstance, #instance> { type Query = #value_type; /// Get the storage key. fn key() -> &'static [u8] { - #prefix.as_bytes() + #final_prefix } /// Load the value from the provided storage instance. @@ -113,11 +132,13 @@ impl<'a, I: Iterator> Impls<'a, I> { visibility, traitinstance, traittype, + instance_opts, type_infos, fielddefault, prefix, name, attrs, + .. } = self; let DeclStorageTypeInfos { typ, value_type, is_option, .. } = type_infos; let option_simple_1 = option_unwrap(is_option); @@ -134,22 +155,38 @@ impl<'a, I: Iterator> Impls<'a, I> { } } }; + + let InstanceOpts { + comma_instance, + equal_default_instance, + bound_instantiable, + instance, + .. + } = instance_opts; + + let final_prefix = if let Some(instance) = instance { + let method_name = syn::Ident::new(&format!("build_prefix_once_for_{}", name.to_string()), proc_macro2::Span::call_site()); + quote!{ #instance::#method_name(#prefix.as_bytes()) } + } else { + quote!{ #prefix.as_bytes() } + }; + // generator for map quote!{ #( #[ #attrs ] )* - #visibility struct #name<#traitinstance: #traittype>(#scrate::storage::generator::PhantomData<#traitinstance>); + #visibility struct #name<#traitinstance: #traittype, #instance #bound_instantiable #equal_default_instance>(#scrate::storage::generator::PhantomData<(#traitinstance #comma_instance)>); - impl<#traitinstance: #traittype> #scrate::storage::generator::StorageMap<#kty, #typ> for #name<#traitinstance> { + impl<#traitinstance: #traittype, #instance #bound_instantiable> #scrate::storage::generator::StorageMap<#kty, #typ> for #name<#traitinstance, #instance> { type Query = #value_type; /// Get the prefix key in storage. fn prefix() -> &'static [u8] { - #prefix.as_bytes() + #final_prefix } /// Get the storage key used to fetch a value corresponding to a specific key. fn key_for(x: &#kty) -> #scrate::rstd::vec::Vec { - let mut key = #prefix.as_bytes().to_vec(); + let mut key = >::prefix().to_vec(); #scrate::codec::Encode::encode_to(x, &mut key); key } @@ -185,16 +222,41 @@ impl<'a, I: Iterator> Impls<'a, I> { visibility, traitinstance, traittype, + instance_opts, type_infos, fielddefault, prefix, name, attrs, + .. } = self; + + let InstanceOpts { + comma_instance, + equal_default_instance, + bound_instantiable, + instance, + .. + } = instance_opts; + + let final_prefix = if let Some(instance) = instance { + let method_name = syn::Ident::new(&format!("build_prefix_once_for_{}", name.to_string()), proc_macro2::Span::call_site()); + quote!{ #instance::#method_name(#prefix.as_bytes()) } + } else { + quote!{ #prefix.as_bytes() } + }; + + // make sure to use different prefix for head and elements. + let final_head_key = if let Some(instance) = instance { + let method_name = syn::Ident::new(&format!("build_head_key_once_for_{}", name.to_string()), proc_macro2::Span::call_site()); + quote!{ #instance::#method_name(#prefix.as_bytes()) } + } else { + let final_head_key = format!("head of {}", prefix); + quote!{ #final_head_key.as_bytes() } + }; + let DeclStorageTypeInfos { typ, value_type, is_option, .. } = type_infos; let option_simple_1 = option_unwrap(is_option); - // make sure to use different prefix for head and elements. - let head_key = format!("head of {}", prefix); let name_lowercase = name.to_string().to_lowercase(); let inner_module = syn::Ident::new(&format!("__linked_map_details_for_{}_do_not_use", name_lowercase), name.span()); let linkage = syn::Ident::new(&format!("__LinkageFor{}DoNotUse", name), name.span()); @@ -250,30 +312,22 @@ impl<'a, I: Iterator> Impls<'a, I> { pub _data: #phantom_data, } - impl<'a, S: #scrate::GenericStorage, K, V> Iterator for Enumerator<'a, S, K, V> where - K: 'a + #scrate::codec::Codec, - V: 'a + #scrate::codec::Decode, + impl<'a, S: #scrate::GenericStorage, #traitinstance: #traittype, #instance #bound_instantiable> Iterator for Enumerator<'a, S, #kty, (#typ, #traitinstance, #instance)> + where #traitinstance: 'a { - type Item = (K, V); + type Item = (#kty, #typ); fn next(&mut self) -> Option { let next = self.next.take()?; - let key_for = key_for(&next); - let (val, linkage): (V, Linkage) = self.storage.get(&*key_for) + let key_for = as #scrate::storage::generator::StorageMap<#kty, #typ>>::key_for(&next); + let (val, linkage): (#typ, Linkage<#kty>) = self.storage.get(&*key_for) .expect("previous/next only contain existing entires; we enumerate using next; entry exists; qed"); self.next = linkage.next; Some((next, val)) } } - /// Generate a storage key for given item. - pub(crate) fn key_for(key: &Key) -> #scrate::rstd::vec::Vec { - let mut key_for = #prefix.as_bytes().to_vec(); - #scrate::codec::Encode::encode_to(&key, &mut key_for); - key_for - } - - pub(crate) trait Utils<#traitinstance: #traittype> { + pub(crate) trait Utils<#traitinstance: #traittype, #instance #bound_instantiable> { /// Update linkage when this element is removed. /// /// Takes care of updating previous and next elements points @@ -304,17 +358,17 @@ impl<'a, I: Iterator> Impls<'a, I> { let structure = quote! { #( #[ #attrs ] )* - #visibility struct #name<#traitinstance: #traittype>(#phantom_data<#traitinstance>); + #visibility struct #name<#traitinstance: #traittype, #instance #bound_instantiable #equal_default_instance>(#phantom_data<(#traitinstance #comma_instance)>); - impl<#traitinstance: #traittype> self::#inner_module::Utils<#traitinstance> for #name<#traitinstance> { + impl<#traitinstance: #traittype, #instance #bound_instantiable> self::#inner_module::Utils<#traitinstance, #instance> for #name<#traitinstance, #instance> { fn remove_linkage( linkage: self::#inner_module::Linkage<#kty>, storage: &S, ) { - use self::#inner_module::{key_for, Utils}; + use self::#inner_module::Utils; - let next_key = linkage.next.as_ref().map(|x| key_for(x)); - let prev_key = linkage.previous.as_ref().map(|x| key_for(x)); + let next_key = linkage.next.as_ref().map(|x| #as_map::key_for(x)); + let prev_key = linkage.previous.as_ref().map(|x| #as_map::key_for(x)); if let Some(prev_key) = prev_key { // Retrieve previous element and update `next` @@ -347,12 +401,12 @@ impl<'a, I: Iterator> Impls<'a, I> { storage: &S, key: &#kty, ) -> self::#inner_module::Linkage<#kty> { - use self::#inner_module::{key_for, Utils}; + use self::#inner_module::Utils; if let Some(head) = Self::read_head(storage) { // update previous head predecessor { - let head_key = key_for(&head); + let head_key = #as_map::key_for(&head); let (data, linkage) = Self::read_with_linkage(storage, &*head_key).expect(r#" head is set when first element is inserted and unset when last element is removed; if head is Some then it points to existing key; qed @@ -376,13 +430,13 @@ impl<'a, I: Iterator> Impls<'a, I> { } fn read_head(storage: &S) -> Option<#kty> { - storage.get(#head_key.as_bytes()) + storage.get(#final_head_key) } fn write_head(storage: &S, head: Option<&#kty>) { match head { - Some(head) => storage.put(#head_key.as_bytes(), head), - None => storage.kill(#head_key.as_bytes()), + Some(head) => storage.put(#final_head_key, head), + None => storage.kill(#final_head_key), } } } @@ -393,17 +447,19 @@ impl<'a, I: Iterator> Impls<'a, I> { #structure - impl<#traitinstance: #traittype> #scrate::storage::generator::StorageMap<#kty, #typ> for #name<#traitinstance> { + impl<#traitinstance: #traittype, #instance #bound_instantiable> #scrate::storage::generator::StorageMap<#kty, #typ> for #name<#traitinstance, #instance> { type Query = #value_type; /// Get the prefix key in storage. fn prefix() -> &'static [u8] { - #prefix.as_bytes() + #final_prefix } /// Get the storage key used to fetch a value corresponding to a specific key. - fn key_for(x: &#kty) -> #scrate::rstd::vec::Vec { - self::#inner_module::key_for(x) + fn key_for(key: &#kty) -> #scrate::rstd::vec::Vec { + let mut key_for = #as_map::prefix().to_vec(); + #scrate::codec::Encode::encode_to(&key, &mut key_for); + key_for } /// Load the value associated with the given key from the map. @@ -413,9 +469,9 @@ impl<'a, I: Iterator> Impls<'a, I> { /// Take the value, reading and removing it. fn take(key: &#kty, storage: &S) -> Self::Query { - use self::#inner_module::{Utils, key_for}; + use self::#inner_module::Utils; - let res: Option<(#value_type, self::#inner_module::Linkage<#kty>)> = storage.take(&*key_for(key)); + let res: Option<(#value_type, self::#inner_module::Linkage<#kty>)> = storage.take(&*#as_map::key_for(key)); match res { Some((data, linkage)) => { Self::remove_linkage(linkage, storage); @@ -432,9 +488,9 @@ impl<'a, I: Iterator> Impls<'a, I> { /// Store a value to be associated with the given key from the map. fn insert(key: &#kty, val: &#typ, storage: &S) { - use self::#inner_module::{Utils, key_for}; + use self::#inner_module::Utils; - let key_for = &*key_for(key); + let key_for = &*#as_map::key_for(key); let linkage = match Self::read_with_linkage(storage, key_for) { // overwrite but reuse existing linkage Some((_data, linkage)) => linkage, @@ -446,9 +502,9 @@ impl<'a, I: Iterator> Impls<'a, I> { /// Mutate the value under a key fn mutate R, S: #scrate::GenericStorage>(key: &#kty, f: F, storage: &S) -> R { - use self::#inner_module::{Utils, key_for}; + use self::#inner_module::Utils; - let key_for = &*key_for(key); + let key_for = &*#as_map::key_for(key); let (mut val, linkage) = Self::read_with_linkage(storage, key_for) .map(|(data, linkage)| (data, Some(linkage))) .unwrap_or_else(|| (#fielddefault, None)); @@ -459,7 +515,7 @@ impl<'a, I: Iterator> Impls<'a, I> { } } - impl<#traitinstance: #traittype> #scrate::storage::generator::EnumerableStorageMap<#kty, #typ> for #name<#traitinstance> { + impl<#traitinstance: 'static + #traittype, #instance #bound_instantiable> #scrate::storage::generator::EnumerableStorageMap<#kty, #typ> for #name<#traitinstance, #instance> { fn head(storage: &S) -> Option<#kty> { use self::#inner_module::Utils; @@ -475,7 +531,7 @@ impl<'a, I: Iterator> Impls<'a, I> { #scrate::storage::generator::Box::new(Enumerator { next: Self::read_head(storage), storage, - _data: #phantom_data::<#typ>::default(), + _data: #phantom_data::<(#typ, #traitinstance, #instance)>::default(), }) } } diff --git a/substrate/srml/support/procedural/src/storage/mod.rs b/substrate/srml/support/procedural/src/storage/mod.rs index 4cf8ea216f..7bb547c4f7 100644 --- a/substrate/srml/support/procedural/src/storage/mod.rs +++ b/substrate/srml/support/procedural/src/storage/mod.rs @@ -39,14 +39,20 @@ struct StorageDefinition { pub module_ident: Ident, pub mod_lt_token: Token![<], pub mod_param: syn::GenericParam, + pub mod_instance_param_token: Option, + pub mod_instance: Option, + pub mod_instantiable_token: Option, + pub mod_instantiable: Option, + pub mod_default_instance_token: Option, + pub mod_default_instance: Option, pub mod_gt_token: Token![>], pub as_token: Token![as], pub crate_ident: Ident, pub content: ext::Braces>, pub extra_genesis: Option, + pub extra_genesis_skip_phantom_data_field: Option, } - #[derive(Parse, ToTokens, Debug)] struct SpecificHiddenCrate { pub keyword: ext::CustomToken, @@ -59,6 +65,12 @@ struct AddExtraGenesis { pub content: ext::Braces, } +#[derive(Parse, ToTokens, Debug)] +struct ExtraGenesisSkipPhantomDataField { + pub genesis_phantom_keyword: ext::CustomToken, + pub token: Token![;], +} + #[derive(Parse, ToTokens, Debug)] struct AddExtraGenesisContent { pub lines: ext::Punctuated, @@ -153,3 +165,4 @@ custom_keyword_impl!(AddExtraGenesis, "add_extra_genesis", "storage extra genesi custom_keyword_impl!(DeclStorageGetter, "get", "storage getter"); custom_keyword!(MapKeyword, "map", "map as keyword"); custom_keyword!(LinkedMapKeyword, "linked_map", "linked_map as keyword"); +custom_keyword_impl!(ExtraGenesisSkipPhantomDataField, "extra_genesis_skip_phantom_data_field", "extra_genesis_skip_phantom_data_field as keyword"); diff --git a/substrate/srml/support/procedural/src/storage/transformation.rs b/substrate/srml/support/procedural/src/storage/transformation.rs index fc5ba7b721..c2c7438673 100644 --- a/substrate/srml/support/procedural/src/storage/transformation.rs +++ b/substrate/srml/support/procedural/src/storage/transformation.rs @@ -38,6 +38,8 @@ use quote::quote; use super::*; +const NUMBER_OF_INSTANCE: usize = 16; + // try macro but returning tokenized error macro_rules! try_tok(( $expre : expr ) => { match $expre { @@ -57,11 +59,21 @@ pub fn decl_storage_impl(input: TokenStream) -> TokenStream { ident: storetype, module_ident, mod_param: strait, + mod_instance, + mod_instantiable, + mod_default_instance, crate_ident: cratename, content: ext::Braces { content: storage_lines, ..}, extra_genesis, + extra_genesis_skip_phantom_data_field, .. } = def; + + let instance_opts = match get_instance_opts(mod_instance, mod_instantiable, mod_default_instance) { + Ok(opts) => opts, + Err(err) => return err.to_compile_error().into(), + }; + let hidden_crate_name = hidden_crate.map(|rc| rc.ident.content).map(|i| i.to_string()) .unwrap_or_else(|| "decl_storage".to_string()); let scrate = generate_crate_access(&hidden_crate_name, "srml-support"); @@ -89,13 +101,16 @@ pub fn decl_storage_impl(input: TokenStream) -> TokenStream { &scrate, &traitinstance, &traittype, + &instance_opts, &storage_lines, &extra_genesis, + extra_genesis_skip_phantom_data_field.is_some(), )); let decl_storage_items = decl_storage_items( &scrate, &traitinstance, &traittype, + &instance_opts, &cratename, &storage_lines, ); @@ -104,19 +119,29 @@ pub fn decl_storage_impl(input: TokenStream) -> TokenStream { ); let impl_store_items = impl_store_items( &traitinstance, + &instance_opts.instance, &storage_lines, ); let impl_store_fns = impl_store_fns( &scrate, &traitinstance, + &instance_opts.instance, &storage_lines, ); let (store_default_struct, store_functions_to_metadata) = store_functions_to_metadata( &scrate, &traitinstance, &traittype, + &instance_opts, &storage_lines, ); + + let InstanceOpts { + instance, + bound_instantiable, + .. + } = instance_opts; + let cratename_string = cratename.to_string(); let expanded = quote! { #scrate_decl @@ -125,10 +150,10 @@ pub fn decl_storage_impl(input: TokenStream) -> TokenStream { #decl_store_items } #store_default_struct - impl<#traitinstance: #traittype> #storetype for #module_ident<#traitinstance> { + impl<#traitinstance: #traittype, #instance #bound_instantiable> #storetype for #module_ident<#traitinstance, #instance> { #impl_store_items } - impl<#traitinstance: 'static + #traittype> #module_ident<#traitinstance> { + impl<#traitinstance: 'static + #traittype, #instance #bound_instantiable> #module_ident<#traitinstance, #instance> { #impl_store_fns #[doc(hidden)] pub fn store_metadata() -> #scrate::storage::generator::StorageMetadata { @@ -157,10 +182,20 @@ fn decl_store_extra_genesis( scrate: &TokenStream2, traitinstance: &Ident, traittype: &syn::TypeParamBound, + instance_opts: &InstanceOpts, storage_lines: &ext::Punctuated, extra_genesis: &Option, + extra_genesis_skip_phantom_data_field: bool, ) -> Result { + let InstanceOpts { + comma_instance, + equal_default_instance, + bound_instantiable, + instance, + .. + } = instance_opts; + let mut is_trait_needed = false; let mut has_trait_field = false; let mut serde_complete_bound = std::collections::HashSet::new(); @@ -222,7 +257,7 @@ fn decl_store_extra_genesis( }, }); opt_build = Some(build.as_ref().map(|b| &b.expr.content).map(|b|quote!( #b )) - .unwrap_or_else(|| quote!( (|config: &GenesisConfig<#traitinstance>| config.#ident.clone()) ))); + .unwrap_or_else(|| quote!( (|config: &GenesisConfig<#traitinstance, #instance>| config.#ident.clone()) ))); let fielddefault = default_value.inner.as_ref().map(|d| &d.expr).map(|d| if type_infos.is_option { @@ -246,8 +281,7 @@ fn decl_store_extra_genesis( use #scrate::codec::{Encode, Decode}; let v = (#builder)(&self); - <#name<#traitinstance> as #scrate::storage::generator::StorageValue<#typ>>::put(&v, &storage); - + <#name<#traitinstance, #instance> as #scrate::storage::generator::StorageValue<#typ>>::put(&v, &storage); }} }, DeclStorageTypeInfosKind::Map { key_type, .. } => { @@ -257,7 +291,7 @@ fn decl_store_extra_genesis( let data = (#builder)(&self); for (k, v) in data.into_iter() { - <#name<#traitinstance> as #scrate::storage::generator::StorageMap<#key_type, #typ>>::insert(&k, &v, &storage); + <#name<#traitinstance, #instance> as #scrate::storage::generator::StorageMap<#key_type, #typ>>::insert(&k, &v, &storage); } }} }, @@ -335,24 +369,26 @@ fn decl_store_extra_genesis( || !genesis_extrafields.is_empty() || !builders.is_empty(); Ok(if is_extra_genesis_needed { - let (fparam, sparam, ph_field, ph_default) = if is_trait_needed { - if has_trait_field { + let (fparam_struct, fparam_impl, sparam, ph_field, ph_default) = if is_trait_needed { + if (has_trait_field && instance.is_none()) || extra_genesis_skip_phantom_data_field { // no phantom data required ( - quote!(<#traitinstance: #traittype>), - quote!(<#traitinstance>), + quote!(<#traitinstance: #traittype, #instance #bound_instantiable #equal_default_instance>), + quote!(<#traitinstance: #traittype, #instance #bound_instantiable>), + quote!(<#traitinstance, #instance>), quote!(), quote!(), ) } else { // need phantom data ( - quote!(<#traitinstance: #traittype>), - quote!(<#traitinstance>), + quote!(<#traitinstance: #traittype, #instance #bound_instantiable #equal_default_instance>), + quote!(<#traitinstance: #traittype, #instance #bound_instantiable>), + quote!(<#traitinstance, #instance>), quote!{ #[serde(skip)] - pub _genesis_phantom_data: #scrate::storage::generator::PhantomData<#traitinstance>, + pub _genesis_phantom_data: #scrate::storage::generator::PhantomData<(#traitinstance #comma_instance)>, }, quote!{ _genesis_phantom_data: Default::default(), @@ -361,7 +397,7 @@ fn decl_store_extra_genesis( } } else { // do not even need type parameter - (quote!(), quote!(), quote!(), quote!()) + (quote!(), quote!(), quote!(), quote!(), quote!()) }; quote!{ @@ -370,14 +406,14 @@ fn decl_store_extra_genesis( #[serde(rename_all = "camelCase")] #[serde(deny_unknown_fields)] #serde_bug_bound - pub struct GenesisConfig#fparam { + pub struct GenesisConfig#fparam_struct { #ph_field #config_field #genesis_extrafields } #[cfg(feature = "std")] - impl#fparam Default for GenesisConfig#sparam { + impl#fparam_impl Default for GenesisConfig#sparam { fn default() -> Self { GenesisConfig { #ph_default @@ -388,7 +424,7 @@ fn decl_store_extra_genesis( } #[cfg(feature = "std")] - impl#fparam #scrate::runtime_primitives::BuildStorage for GenesisConfig#sparam { + impl#fparam_impl #scrate::runtime_primitives::BuildStorage for GenesisConfig#sparam { fn assimilate_storage(self, r: &mut #scrate::runtime_primitives::StorageOverlay, c: &mut #scrate::runtime_primitives::ChildrenStorageOverlay) -> ::std::result::Result<(), String> { use #scrate::rstd::{cell::RefCell, marker::PhantomData}; let storage = (RefCell::new(r), PhantomData::::default()); @@ -412,11 +448,96 @@ fn decl_storage_items( scrate: &TokenStream2, traitinstance: &Ident, traittype: &syn::TypeParamBound, + instance_opts: &InstanceOpts, cratename: &Ident, storage_lines: &ext::Punctuated, ) -> TokenStream2 { let mut impls = TokenStream2::new(); + + let InstanceOpts { + instance, + default_instance, + instantiable, + .. + } = instance_opts; + + // Build Instantiable trait + if instance.is_some() { + let mut method_defs = TokenStream2::new(); + let mut method_impls = TokenStream2::new(); + for sline in storage_lines.inner.iter() { + let DeclStorageLine { + storage_type, + name, + .. + } = sline; + + let type_infos = get_type_infos(storage_type); + + let method_name = syn::Ident::new(&format!("build_prefix_once_for_{}", name.to_string()), proc_macro2::Span::call_site()); + + method_defs.extend(quote!{ fn #method_name(prefix: &'static [u8]) -> &'static [u8]; }); + method_impls.extend(quote!{ + fn #method_name(prefix: &'static [u8]) -> &'static [u8] { + static LAZY: #scrate::lazy::Lazy<#scrate::rstd::vec::Vec> = #scrate::lazy::Lazy::INIT; + LAZY.get(|| { + let mut final_prefix = #scrate::rstd::vec::Vec::new(); + final_prefix.extend_from_slice(prefix); + final_prefix.extend_from_slice(Self::INSTANCE_PREFIX.as_bytes()); + final_prefix + }) + } + }); + + if let DeclStorageTypeInfosKind::Map { is_linked: true, .. } = type_infos.kind { + let method_name = syn::Ident::new(&format!("build_head_key_once_for_{}", name.to_string()), proc_macro2::Span::call_site()); + + method_defs.extend(quote!{ fn #method_name(prefix: &'static [u8]) -> &'static [u8]; }); + method_impls.extend(quote!{ + fn #method_name(prefix: &'static [u8]) -> &'static [u8] { + static LAZY: #scrate::lazy::Lazy<#scrate::rstd::vec::Vec> = #scrate::lazy::Lazy::INIT; + LAZY.get(|| { + let mut final_prefix = #scrate::rstd::vec::Vec::new(); + final_prefix.extend_from_slice("head of ".as_bytes()); + final_prefix.extend_from_slice(prefix); + final_prefix.extend_from_slice(Self::INSTANCE_PREFIX.as_bytes()); + final_prefix + }) + } + }); + } + } + + impls.extend(quote! { + pub trait #instantiable: 'static { + const INSTANCE_PREFIX: &'static str; + #method_defs + } + }); + + let instances = (0..NUMBER_OF_INSTANCE) + .map(|i| { + let name = format!("Instance{}", i); + let ident = syn::Ident::new(&name, proc_macro2::Span::call_site()); + (name, ident) + }) + .chain(default_instance.clone().map(|ident| (String::new(), ident))); + + for (prefix, ident) in instances { + impls.extend(quote! { + // Those trait are derived because of wrong bounds for generics + #[cfg_attr(feature = "std", derive(Debug))] + #[derive(Clone, Eq, PartialEq, #scrate::codec::Encode, #scrate::codec::Decode)] + pub struct #ident; + impl #instantiable for #ident { + const INSTANCE_PREFIX: &'static str = #prefix; + #method_impls + } + }); + } + } + for sline in storage_lines.inner.iter() { let DeclStorageLine { attrs, @@ -435,8 +556,10 @@ fn decl_storage_items( let i = impls::Impls { scrate, visibility, + cratename, traitinstance, traittype, + instance_opts, type_infos, fielddefault: default_value.inner.as_ref().map(|d| &d.expr).map(|d| quote!( #d )) .unwrap_or_else(|| quote!{ Default::default() }), @@ -474,13 +597,14 @@ fn decl_store_items( fn impl_store_items( traitinstance: &Ident, + instance: &Option, storage_lines: &ext::Punctuated, ) -> TokenStream2 { storage_lines.inner.iter().map(|sline| &sline.name) .fold(TokenStream2::new(), |mut items, name| { items.extend( quote!( - type #name = #name<#traitinstance>; + type #name = #name<#traitinstance, #instance>; ) ); items @@ -490,6 +614,7 @@ fn impl_store_items( fn impl_store_fns( scrate: &TokenStream2, traitinstance: &Ident, + instance: &Option, storage_lines: &ext::Punctuated, ) -> TokenStream2 { let mut items = TokenStream2::new(); @@ -517,7 +642,7 @@ fn impl_store_fns( quote!{ #( #[ #attrs ] )* pub fn #get_fn() -> #value_type { - <#name<#traitinstance> as #scrate::storage::generator::StorageValue<#typ>> :: get(&#scrate::storage::RuntimeStorage) + <#name<#traitinstance, #instance> as #scrate::storage::generator::StorageValue<#typ>> :: get(&#scrate::storage::RuntimeStorage) } } }, @@ -525,7 +650,7 @@ fn impl_store_fns( quote!{ #( #[ #attrs ] )* pub fn #get_fn>(key: K) -> #value_type { - <#name<#traitinstance> as #scrate::storage::generator::StorageMap<#key_type, #typ>> :: get(key.borrow(), &#scrate::storage::RuntimeStorage) + <#name<#traitinstance, #instance> as #scrate::storage::generator::StorageMap<#key_type, #typ>> :: get(key.borrow(), &#scrate::storage::RuntimeStorage) } } } @@ -540,9 +665,18 @@ fn store_functions_to_metadata ( scrate: &TokenStream2, traitinstance: &Ident, traittype: &syn::TypeParamBound, + instance_opts: &InstanceOpts, storage_lines: &ext::Punctuated, ) -> (TokenStream2, TokenStream2) { + let InstanceOpts { + comma_instance, + equal_default_instance, + bound_instantiable, + instance, + .. + } = instance_opts; + let mut items = TokenStream2::new(); let mut default_getter_struct_def = TokenStream2::new(); for sline in storage_lines.inner.iter() { @@ -613,7 +747,7 @@ fn store_functions_to_metadata ( ty: #stype, default: #scrate::storage::generator::DecodeDifferent::Encode( #scrate::storage::generator::DefaultByteGetter( - &#struct_name::<#traitinstance>(#scrate::rstd::marker::PhantomData) + &#struct_name::<#traitinstance, #instance>(#scrate::rstd::marker::PhantomData) ) ), documentation: #scrate::storage::generator::DecodeDifferent::Encode(&[ #docs ]), @@ -622,12 +756,12 @@ fn store_functions_to_metadata ( items.extend(item); let def_get = quote! { #[doc(hidden)] - pub struct #struct_name<#traitinstance>(pub #scrate::rstd::marker::PhantomData<#traitinstance>); + pub struct #struct_name<#traitinstance, #instance #bound_instantiable #equal_default_instance>(pub #scrate::rstd::marker::PhantomData<(#traitinstance #comma_instance)>); #[cfg(feature = "std")] #[allow(non_upper_case_globals)] static #cache_name: #scrate::once_cell::sync::OnceCell<#scrate::rstd::vec::Vec> = #scrate::once_cell::sync::OnceCell::INIT; #[cfg(feature = "std")] - impl<#traitinstance: #traittype> #scrate::storage::generator::DefaultByte for #struct_name<#traitinstance> { + impl<#traitinstance: #traittype, #instance #bound_instantiable> #scrate::storage::generator::DefaultByte for #struct_name<#traitinstance, #instance> { fn default_byte(&self) -> #scrate::rstd::vec::Vec { use #scrate::codec::Encode; #cache_name.get_or_init(|| { @@ -637,7 +771,7 @@ fn store_functions_to_metadata ( } } #[cfg(not(feature = "std"))] - impl<#traitinstance: #traittype> #scrate::storage::generator::DefaultByte for #struct_name<#traitinstance> { + impl<#traitinstance: #traittype, #instance #bound_instantiable> #scrate::storage::generator::DefaultByte for #struct_name<#traitinstance, #instance> { fn default_byte(&self) -> #scrate::rstd::vec::Vec { use #scrate::codec::Encode; let def_val: #value_type = #default; @@ -708,3 +842,44 @@ fn get_type_infos(storage_type: &DeclStorageType) -> DeclStorageTypeInfos { } } + +#[derive(Default)] +pub(crate) struct InstanceOpts { + pub instance: Option, + pub default_instance: Option, + pub instantiable: Option, + pub comma_instance: TokenStream2, + pub equal_default_instance: TokenStream2, + pub bound_instantiable: TokenStream2, +} + +fn get_instance_opts( + instance: Option, + instantiable: Option, + default_instance: Option, +) -> syn::Result { + + let right_syntax = "Should be $Instance: $Instantiable = $DefaultInstance"; + + match (instance, instantiable, default_instance) { + (Some(instance), Some(instantiable), default_instance_def) => { + let (equal_default_instance, default_instance) = if let Some(default_instance) = default_instance_def { + (quote!{= #default_instance}, Some(default_instance)) + } else { + (quote!{}, None) + }; + Ok(InstanceOpts { + comma_instance: quote!{, #instance}, + equal_default_instance, + bound_instantiable: quote!{: #instantiable}, + instance: Some(instance), + default_instance, + instantiable: Some(instantiable), + }) + }, + (None, None, None) => Ok(Default::default()), + (Some(instance), None, _) => Err(syn::Error::new(instance.span(), format!("Expect instantiable trait bound for instance: {}. {}", instance, right_syntax))), + (None, Some(instantiable), _) => Err(syn::Error::new(instantiable.span(), format!("Expect instance generic for bound instantiable: {}. {}", instantiable, right_syntax))), + (None, _, Some(default_instance)) => Err(syn::Error::new(default_instance.span(), format!("Expect instance generic for default instance: {}. {}", default_instance, right_syntax))), + } +} diff --git a/substrate/srml/support/src/dispatch.rs b/substrate/srml/support/src/dispatch.rs index 0e842a9802..c6151d2390 100644 --- a/substrate/srml/support/src/dispatch.rs +++ b/substrate/srml/support/src/dispatch.rs @@ -91,20 +91,28 @@ impl Parameter for T where T: Codec + Clone + Eq {} /// /// The `on_initialise` and `on_finalise` functions are special, since it can either take no /// parameters, or one parameter, which has the runtime's block number type. +/// +/// ### Module with instances +/// +/// decl_module! support modules with instances with the following syntax: (DefaultInstance type is +/// optionnal) +/// ```nocompile +/// pub struct Module, I: Instance = DefaultInstance> for enum Call where origin: T::Origin {} +/// ``` #[macro_export] macro_rules! decl_module { // Macro transformations (to convert invocations with incomplete parameters to the canonical // form) ( $(#[$attr:meta])* - pub struct $mod_type:ident<$trait_instance:ident: $trait_name:ident> + pub struct $mod_type:ident<$trait_instance:ident: $trait_name:ident$(, I: $instantiable:path $(= $module_default_instance:path)?)?> for enum $call_type:ident where origin: $origin_type:ty { $($t:tt)* } ) => { decl_module!(@normalize $(#[$attr])* - pub struct $mod_type<$trait_instance: $trait_name> + pub struct $mod_type<$trait_instance: $trait_name$(, I: $instantiable $(= $module_default_instance)?)?> for enum $call_type where origin: $origin_type, system = system {} {} @@ -115,14 +123,14 @@ macro_rules! decl_module { }; ( $(#[$attr:meta])* - pub struct $mod_type:ident<$trait_instance:ident: $trait_name:ident> + pub struct $mod_type:ident<$trait_instance:ident: $trait_name:ident$(, I: $instantiable:path $(= $module_default_instance:path)?)?> for enum $call_type:ident where origin: $origin_type:ty, system = $system:ident { $($t:tt)* } ) => { decl_module!(@normalize $(#[$attr])* - pub struct $mod_type<$trait_instance: $trait_name> + pub struct $mod_type<$trait_instance: $trait_name$(, I: $instantiable $(= $module_default_instance)?)?> for enum $call_type where origin: $origin_type, system = $system {} {} @@ -134,21 +142,21 @@ macro_rules! decl_module { (@normalize $(#[$attr:meta])* - pub struct $mod_type:ident<$trait_instance:ident: $trait_name:ident> + pub struct $mod_type:ident<$trait_instance:ident: $trait_name:ident$(, I: $instantiable:path $(= $module_default_instance:path)?)?> for enum $call_type:ident where origin: $origin_type:ty, system = $system:ident {} { $( $on_initialise:tt )* } { $( $on_finalise:tt )* } [ $($t:tt)* ] $(#[doc = $doc_attr:tt])* - $vis:vis fn deposit_event $(<$dpeg:ident>)* () = default; + $vis:vis fn deposit_event $(<$dpeg:ident $(, $dpeg_instance:ident)?>)* () = default; $($rest:tt)* ) => { decl_module!(@normalize $(#[$attr])* - pub struct $mod_type<$trait_instance: $trait_name> + pub struct $mod_type<$trait_instance: $trait_name$(, I: $instantiable $(= $module_default_instance)?)?> for enum $call_type where origin: $origin_type, system = $system - { $vis fn deposit_event $(<$dpeg>)* () = default; } + { $vis fn deposit_event $(<$dpeg $(, $dpeg_instance)?>)* () = default; } { $( $on_initialise )* } { $( $on_finalise )* } [ $($t)* ] @@ -157,23 +165,23 @@ macro_rules! decl_module { }; (@normalize $(#[$attr:meta])* - pub struct $mod_type:ident<$trait_instance:ident: $trait_name:ident> + pub struct $mod_type:ident<$trait_instance:ident: $trait_name:ident$(, I: $instantiable:path $(= $module_default_instance:path)?)?> for enum $call_type:ident where origin: $origin_type:ty, system = $system:ident {} { $( $on_initialise:tt )* } { $( $on_finalise:tt )* } [ $($t:tt)* ] $(#[doc = $doc_attr:tt])* - $vis:vis fn deposit_event $(<$dpeg:ident>)* ( + $vis:vis fn deposit_event $(<$dpeg:ident $(, $dpeg_instance:ident)?>)* ( $($param_name:ident : $param:ty),* ) { $( $impl:tt )* } $($rest:tt)* ) => { decl_module!(@normalize $(#[$attr])* - pub struct $mod_type<$trait_instance: $trait_name> + pub struct $mod_type<$trait_instance: $trait_name$(, I: $instantiable $(= $module_default_instance)?)?> for enum $call_type where origin: $origin_type, system = $system - { $vis fn deposit_event $(<$dpeg>)* ($( $param_name: $param ),* ) { $( $impl )* } } + { $vis fn deposit_event $(<$dpeg $(, $dpeg_instance)?>)* ($( $param_name: $param ),* ) { $( $impl )* } } { $( $on_initialise )* } { $( $on_finalise )* } [ $($t)* ] @@ -182,7 +190,7 @@ macro_rules! decl_module { }; (@normalize $(#[$attr:meta])* - pub struct $mod_type:ident<$trait_instance:ident: $trait_name:ident> + pub struct $mod_type:ident<$trait_instance:ident: $trait_name:ident$(, I: $instantiable:path $(= $module_default_instance:path)?)?> for enum $call_type:ident where origin: $origin_type:ty, system = $system:ident { $( $deposit_event:tt )* } { $( $on_initialise:tt )* } @@ -194,7 +202,7 @@ macro_rules! decl_module { ) => { decl_module!(@normalize $(#[$attr])* - pub struct $mod_type<$trait_instance: $trait_name> + pub struct $mod_type<$trait_instance: $trait_name$(, I: $instantiable $(= $module_default_instance)?)?> for enum $call_type where origin: $origin_type, system = $system { $( $deposit_event )* } { $( $on_initialise )* } @@ -205,7 +213,7 @@ macro_rules! decl_module { }; (@normalize $(#[$attr:meta])* - pub struct $mod_type:ident<$trait_instance:ident: $trait_name:ident> + pub struct $mod_type:ident<$trait_instance:ident: $trait_name:ident$(, I: $instantiable:path $(= $module_default_instance:path)?)?> for enum $call_type:ident where origin: $origin_type:ty, system = $system:ident { $( $deposit_event:tt )* } {} @@ -217,7 +225,7 @@ macro_rules! decl_module { ) => { decl_module!(@normalize $(#[$attr])* - pub struct $mod_type<$trait_instance: $trait_name> + pub struct $mod_type<$trait_instance: $trait_name$(, I: $instantiable $(= $module_default_instance)?)?> for enum $call_type where origin: $origin_type, system = $system { $( $deposit_event )* } { fn on_initialise( $( $param_name : $param ),* ) { $( $impl )* } } @@ -228,7 +236,7 @@ macro_rules! decl_module { }; (@normalize $(#[$attr:meta])* - pub struct $mod_type:ident<$trait_instance:ident: $trait_name:ident> + pub struct $mod_type:ident<$trait_instance:ident: $trait_name:ident$(, $instance:ident: $instantiable:path $(= $module_default_instance:path)?)?> for enum $call_type:ident where origin: $origin_type:ty, system = $system:ident { $( $deposit_event:tt )* } { $( $on_initialise:tt )* } @@ -242,7 +250,7 @@ macro_rules! decl_module { ) => { decl_module!(@normalize $(#[$attr])* - pub struct $mod_type<$trait_instance: $trait_name> + pub struct $mod_type<$trait_instance: $trait_name$(, $instance: $instantiable $(= $module_default_instance)?)?> for enum $call_type where origin: $origin_type, system = $system { $( $deposit_event )* } { $( $on_initialise )* } @@ -253,13 +261,14 @@ macro_rules! decl_module { $fn_vis fn $fn_name( $origin $( , $(#[$codec_attr])* $param_name : $param )* ) $( -> $result )* { $( $impl )* } + { $($instance: $instantiable)? } ] $($rest)* ); }; (@normalize $(#[$attr:meta])* - pub struct $mod_type:ident<$trait_instance:ident: $trait_name:ident> + pub struct $mod_type:ident<$trait_instance:ident: $trait_name:ident$(, I: $instantiable:path $(= $module_default_instance:path)?)?> for enum $call_type:ident where origin: $origin_type:ty, system = $system:ident { $( $deposit_event:tt )* } { $( $on_initialise:tt )* } @@ -279,7 +288,7 @@ macro_rules! decl_module { }; (@normalize $(#[$attr:meta])* - pub struct $mod_type:ident<$trait_instance:ident: $trait_name:ident> + pub struct $mod_type:ident<$trait_instance:ident: $trait_name:ident$(, I: $instantiable:path $(= $module_default_instance:path)?)?> for enum $call_type:ident where origin: $origin_type:ty, system = $system:ident { $( $deposit_event:tt )* } { $( $on_initialise:tt )* } @@ -299,7 +308,7 @@ macro_rules! decl_module { }; (@normalize $(#[$attr:meta])* - pub struct $mod_type:ident<$trait_instance:ident: $trait_name:ident> + pub struct $mod_type:ident<$trait_instance:ident: $trait_name:ident$(, $instance:ident: $instantiable:path $(= $module_default_instance:path)?)?> for enum $call_type:ident where origin: $origin_type:ty, system = $system:ident { $( $deposit_event:tt )* } { $( $on_initialise:tt )* } @@ -313,7 +322,7 @@ macro_rules! decl_module { ) => { decl_module!(@normalize $(#[$attr])* - pub struct $mod_type<$trait_instance: $trait_name> + pub struct $mod_type<$trait_instance: $trait_name$(, $instance: $instantiable $(= $module_default_instance)?)?> for enum $call_type where origin: $origin_type, system = $system { $( $deposit_event )* } { $( $on_initialise )* } @@ -324,13 +333,14 @@ macro_rules! decl_module { $fn_vis fn $fn_name( root $( , $(#[$codec_attr])* $param_name : $param )* ) $( -> $result )* { $( $impl )* } + { $($instance: $instantiable)? } ] $($rest)* ); }; (@normalize $(#[$attr:meta])* - pub struct $mod_type:ident<$trait_instance:ident: $trait_name:ident> + pub struct $mod_type:ident<$trait_instance:ident: $trait_name:ident$(, I: $instantiable:path $(= $module_default_instance:path)?)?> for enum $call_type:ident where origin: $origin_type:ty, system = $system:ident { $( $deposit_event:tt )* } { $( $on_initialise:tt )* } @@ -339,7 +349,7 @@ macro_rules! decl_module { ) => { decl_module!(@imp $(#[$attr])* - pub struct $mod_type<$trait_instance: $trait_name> + pub struct $mod_type<$trait_instance: $trait_name$(, I: $instantiable $(= $module_default_instance)?)?> for enum $call_type where origin: $origin_type, system = $system { $($t)* } @@ -354,62 +364,46 @@ macro_rules! decl_module { (@call root - $mod_type:ident $trait_instance:ident $fn_name:ident $origin:ident $system:ident [ $( $param_name:ident),* ] + $mod_type:ident<$trait_instance:ident $(, $instance:ident)?> $fn_name:ident $origin:ident $system:ident [ $( $param_name:ident),* ] ) => { { $system::ensure_root($origin)?; - <$mod_type<$trait_instance>>::$fn_name( $( $param_name ),* ) + <$mod_type<$trait_instance $(, $instance)?>>::$fn_name( $( $param_name ),* ) } }; (@call $ingore:ident - $mod_type:ident $trait_instance:ident $fn_name:ident $origin:ident $system:ident [ $( $param_name:ident),* ] + $mod_type:ident<$trait_instance:ident $(, $instance:ident)?> $fn_name:ident $origin:ident $system:ident [ $( $param_name:ident),* ] ) => { - <$mod_type<$trait_instance>>::$fn_name( $origin $(, $param_name )* ) + <$mod_type<$trait_instance $(, $instance)?>>::$fn_name( $origin $(, $param_name )* ) }; // no `deposit_event` function wanted (@impl_deposit_event - $module:ident<$trait_instance:ident: $trait_name:ident>; + $module:ident<$trait_instance:ident: $trait_name:ident$(, I: $instantiable:path)?>; $system:ident; ) => {}; - // Non-generic event (@impl_deposit_event - $module:ident<$trait_instance:ident: $trait_name:ident>; + $module:ident<$trait_instance:ident: $trait_name:ident$(, $instance:ident: $instantiable:path)?>; $system:ident; - $vis:vis fn deposit_event() = default; + $vis:vis fn deposit_event$(<$event_trait_instance:ident $(, $event_instance:ident)?>)?() = default; ) => { - impl<$trait_instance: $trait_name> $module<$trait_instance> { - $vis fn deposit_event(event: Event) { + impl<$trait_instance: $trait_name$(, $instance: $instantiable)?> $module<$trait_instance $(, $instance)?> { + $vis fn deposit_event(event: Event$(<$event_trait_instance $(, $event_instance)?>)?) { <$system::Module<$trait_instance>>::deposit_event( - <$trait_instance as $trait_name>::Event::from(event).into() - ); - } - } - }; - - // Generic event - (@impl_deposit_event - $module:ident<$trait_instance:ident: $trait_name:ident>; - $system:ident; - $vis:vis fn deposit_event<$ignore:ident>() = default; - ) => { - impl<$trait_instance: $trait_name> $module<$trait_instance> { - $vis fn deposit_event(event: Event<$trait_instance>) { - <$system::Module<$trait_instance>>::deposit_event( - <$trait_instance as $trait_name>::Event::from(event).into() + <$trait_instance as $trait_name$(<$instance>)?>::Event::from(event).into() ); } } }; (@impl_deposit_event - $module:ident<$trait_instance:ident: $trait_name:ident>; + $module:ident<$trait_instance:ident: $trait_name:ident$(, $instance:ident: $instantiable:path)?>; $system:ident; $vis:vis fn deposit_event($param:ident : $param_ty:ty) { $( $impl:tt )* } ) => { - impl<$trait_instance: $trait_name> $module<$trait_instance> { + impl<$trait_instance: $trait_name$(, $instance: $instantiable)?> $module<$trait_instance $(, $instance)?> { $vis fn deposit_event($param: $param_ty) { $( $impl )* } @@ -417,74 +411,74 @@ macro_rules! decl_module { }; (@impl_on_initialise - $module:ident<$trait_instance:ident: $trait_name:ident>; + $module:ident<$trait_instance:ident: $trait_name:ident$(, $instance:ident: $instantiable:path)?>; fn on_initialise() { $( $impl:tt )* } ) => { - impl<$trait_instance: $trait_name> + impl<$trait_instance: $trait_name$(, $instance: $instantiable)?> $crate::runtime_primitives::traits::OnInitialise<$trait_instance::BlockNumber> - for $module<$trait_instance> + for $module<$trait_instance$(, $instance)?> { fn on_initialise(_block_number_not_used: $trait_instance::BlockNumber) { $( $impl )* } } }; (@impl_on_initialise - $module:ident<$trait_instance:ident: $trait_name:ident>; + $module:ident<$trait_instance:ident: $trait_name:ident$(, $instance:ident: $instantiable:path)?>; fn on_initialise($param:ident : $param_ty:ty) { $( $impl:tt )* } ) => { - impl<$trait_instance: $trait_name> + impl<$trait_instance: $trait_name$(, $instance: $instantiable)?> $crate::runtime_primitives::traits::OnInitialise<$trait_instance::BlockNumber> - for $module<$trait_instance> + for $module<$trait_instance$(, $instance)?> { fn on_initialise($param: $param_ty) { $( $impl )* } } }; (@impl_on_initialise - $module:ident<$trait_instance:ident: $trait_name:ident>; + $module:ident<$trait_instance:ident: $trait_name:ident$(, $instance:ident: $instantiable:path)?>; ) => { - impl<$trait_instance: $trait_name> + impl<$trait_instance: $trait_name$(, $instance: $instantiable)?> $crate::runtime_primitives::traits::OnInitialise<$trait_instance::BlockNumber> - for $module<$trait_instance> + for $module<$trait_instance$(, $instance)?> {} }; (@impl_on_finalise - $module:ident<$trait_instance:ident: $trait_name:ident>; + $module:ident<$trait_instance:ident: $trait_name:ident$(, $instance:ident: $instantiable:path)?>; fn on_finalise() { $( $impl:tt )* } ) => { - impl<$trait_instance: $trait_name> + impl<$trait_instance: $trait_name$(, $instance: $instantiable)?> $crate::runtime_primitives::traits::OnFinalise<$trait_instance::BlockNumber> - for $module<$trait_instance> + for $module<$trait_instance$(, $instance)?> { fn on_finalise(_block_number_not_used: $trait_instance::BlockNumber) { $( $impl )* } } }; (@impl_on_finalise - $module:ident<$trait_instance:ident: $trait_name:ident>; + $module:ident<$trait_instance:ident: $trait_name:ident$(, $instance:ident: $instantiable:path)?>; fn on_finalise($param:ident : $param_ty:ty) { $( $impl:tt )* } ) => { - impl<$trait_instance: $trait_name> + impl<$trait_instance: $trait_name$(, $instance: $instantiable)?> $crate::runtime_primitives::traits::OnFinalise<$trait_instance::BlockNumber> - for $module<$trait_instance> + for $module<$trait_instance$(, $instance)?> { fn on_finalise($param: $param_ty) { $( $impl )* } } }; (@impl_on_finalise - $module:ident<$trait_instance:ident: $trait_name:ident>; + $module:ident<$trait_instance:ident: $trait_name:ident$(, $instance:ident: $instantiable:path)?>; ) => { - impl<$trait_instance: $trait_name> + impl<$trait_instance: $trait_name$(, $instance: $instantiable)?> $crate::runtime_primitives::traits::OnFinalise<$trait_instance::BlockNumber> - for $module<$trait_instance> + for $module<$trait_instance$(, $instance)?> { } }; (@impl_function - $module:ident<$trait_instance:ident: $trait_name:ident>; + $module:ident<$trait_instance:ident: $trait_name:ident$(, $instance:ident: $instantiable:path)?>; $origin_ty:ty; root; $(#[doc = $doc_attr:tt])* @@ -498,7 +492,7 @@ macro_rules! decl_module { }; (@impl_function - $module:ident<$trait_instance:ident: $trait_name:ident>; + $module:ident<$trait_instance:ident: $trait_name:ident$(, $instance:ident: $instantiable:path)?>; $origin_ty:ty; root; $(#[doc = $doc_attr:tt])* @@ -513,7 +507,7 @@ macro_rules! decl_module { }; (@impl_function - $module:ident<$trait_instance:ident: $trait_name:ident>; + $module:ident<$trait_instance:ident: $trait_name:ident$(, $instance:ident: $instantiable:path)?>; $origin_ty:ty; $ignore:ident; $(#[doc = $doc_attr:tt])* @@ -531,7 +525,7 @@ macro_rules! decl_module { }; (@impl_function - $module:ident<$trait_instance:ident: $trait_name:ident>; + $module:ident<$trait_instance:ident: $trait_name:ident$(, $instance:ident: $instantiable:path)?>; $origin_ty:ty; $ignore:ident; $(#[doc = $doc_attr:tt])* @@ -549,13 +543,14 @@ macro_rules! decl_module { (@imp $(#[$attr:meta])* - pub struct $mod_type:ident<$trait_instance:ident: $trait_name:ident> + pub struct $mod_type:ident<$trait_instance:ident: $trait_name:ident$(, $instance:ident: $instantiable:path $(= $module_default_instance:path)?)?> for enum $call_type:ident where origin: $origin_type:ty, system = $system:ident { $( $(#[doc = $doc_attr:tt])* $fn_vis:vis fn $fn_name:ident( $from:ident $( , $(#[$codec_attr:ident])* $param_name:ident : $param:ty)* ) $( -> $result:ty )* { $( $impl:tt )* } + { $($fn_instance:ident: $fn_instantiable:path)? } )* } { $( $deposit_event:tt )* } @@ -569,29 +564,29 @@ macro_rules! decl_module { // serde-derive for when we attempt to derive `Deserialize` on these types, // in a situation where we've imported `srml_support` as another name. #[cfg(feature = "std")] - pub struct $mod_type<$trait_instance: $trait_name>(::std::marker::PhantomData<$trait_instance>); + pub struct $mod_type<$trait_instance: $trait_name $(, $instance: $instantiable $( = $module_default_instance)?)?>(::std::marker::PhantomData<($trait_instance $(, $instance)?)>); // Workaround for https://github.com/rust-lang/rust/issues/26925 . Remove when sorted. #[derive(Clone, Copy, PartialEq, Eq)] #[cfg_attr(feature = "std", derive(Debug))] #[cfg(not(feature = "std"))] - pub struct $mod_type<$trait_instance: $trait_name>(::core::marker::PhantomData<$trait_instance>); + pub struct $mod_type<$trait_instance: $trait_name $(, $instance: $instantiable $( = $module_default_instance)?)?>(::core::marker::PhantomData<($trait_instance $(, $instance)?)>); decl_module! { @impl_on_initialise - $mod_type<$trait_instance: $trait_name>; + $mod_type<$trait_instance: $trait_name $(, $instance: $instantiable)?>; $( $on_initialise )* } decl_module! { @impl_on_finalise - $mod_type<$trait_instance: $trait_name>; + $mod_type<$trait_instance: $trait_name $(, $instance: $instantiable)?>; $( $on_finalise )* } decl_module! { @impl_deposit_event - $mod_type<$trait_instance: $trait_name>; + $mod_type<$trait_instance: $trait_name $(, $instance: $instantiable)?>; $system; $( $deposit_event )* } @@ -599,11 +594,11 @@ macro_rules! decl_module { /// Can also be called using [`Call`]. /// /// [`Call`]: enum.Call.html - impl<$trait_instance: $trait_name> $mod_type<$trait_instance> { + impl<$trait_instance: $trait_name $(, $instance: $instantiable)?> $mod_type<$trait_instance $(, $instance)?> { $( decl_module! { @impl_function - $mod_type<$trait_instance: $trait_name>; + $mod_type<$trait_instance: $trait_name $(, $fn_instance: $fn_instantiable)?>; $origin_type; $from; $(#[doc = $doc_attr])* @@ -616,9 +611,9 @@ macro_rules! decl_module { #[cfg(feature = "std")] $(#[$attr])* - pub enum $call_type<$trait_instance: $trait_name> { + pub enum $call_type<$trait_instance: $trait_name$(, $instance: $instantiable $( = $module_default_instance)?)?> { #[doc(hidden)] - __PhantomItem(::std::marker::PhantomData<$trait_instance>, $crate::dispatch::Never), + __PhantomItem(::std::marker::PhantomData<($trait_instance $(, $instance)?)>, $crate::dispatch::Never), $( #[allow(non_camel_case_types)] $(#[doc = $doc_attr])* @@ -628,9 +623,9 @@ macro_rules! decl_module { #[cfg(not(feature = "std"))] $(#[$attr])* - pub enum $call_type<$trait_instance: $trait_name> { + pub enum $call_type<$trait_instance: $trait_name$(, $instance: $instantiable $( = $module_default_instance)?)?> { #[doc(hidden)] - __PhantomItem(::core::marker::PhantomData<$trait_instance>, $crate::dispatch::Never), + __PhantomItem(::core::marker::PhantomData<($trait_instance $(, $instance)?)>, $crate::dispatch::Never), $( #[allow(non_camel_case_types)] $(#[doc = $doc_attr])* @@ -640,8 +635,8 @@ macro_rules! decl_module { // manual implementation of clone/eq/partialeq because using derive erroneously requires // clone/eq/partialeq from T. - impl<$trait_instance: $trait_name> $crate::dispatch::Clone - for $call_type<$trait_instance> + impl<$trait_instance: $trait_name $(, $instance: $instantiable)?> $crate::dispatch::Clone + for $call_type<$trait_instance $(, $instance)?> { fn clone(&self) -> Self { match *self { @@ -653,8 +648,8 @@ macro_rules! decl_module { } } } - impl<$trait_instance: $trait_name> $crate::dispatch::PartialEq - for $call_type<$trait_instance> + impl<$trait_instance: $trait_name $(, $instance: $instantiable)?> $crate::dispatch::PartialEq + for $call_type<$trait_instance $(, $instance)?> { fn eq(&self, _other: &Self) -> bool { match *self { @@ -675,13 +670,13 @@ macro_rules! decl_module { } } } - impl<$trait_instance: $trait_name> $crate::dispatch::Eq - for $call_type<$trait_instance> + impl<$trait_instance: $trait_name $(, $instance: $instantiable)?> $crate::dispatch::Eq + for $call_type<$trait_instance $(, $instance)?> {} #[cfg(feature = "std")] - impl<$trait_instance: $trait_name> $crate::dispatch::fmt::Debug - for $call_type<$trait_instance> + impl<$trait_instance: $trait_name $(, $instance: $instantiable)?> $crate::dispatch::fmt::Debug + for $call_type<$trait_instance $(, $instance)?> { fn fmt(&self, _f: &mut $crate::dispatch::fmt::Formatter) -> $crate::dispatch::result::Result<(), $crate::dispatch::fmt::Error> { match *self { @@ -697,20 +692,20 @@ macro_rules! decl_module { } } - impl<$trait_instance: $trait_name> $crate::dispatch::Decode for $call_type<$trait_instance> { - fn decode(input: &mut I) -> Option { + impl<$trait_instance: $trait_name $(, $instance: $instantiable)?> $crate::dispatch::Decode for $call_type<$trait_instance $(, $instance)?> { + fn decode(input: &mut Input) -> Option { let _input_id = input.read_byte()?; $crate::__impl_decode!(input; _input_id; 0; $call_type; $( fn $fn_name( $( $(#[$codec_attr on type $param])* $param_name ),* ); )*) } } - impl<$trait_instance: $trait_name> $crate::dispatch::Encode for $call_type<$trait_instance> { + impl<$trait_instance: $trait_name $(, $instance: $instantiable)?> $crate::dispatch::Encode for $call_type<$trait_instance $(, $instance)?> { fn encode_to(&self, _dest: &mut W) { $crate::__impl_encode!(_dest; *self; 0; $call_type; $( fn $fn_name( $( $(#[$codec_attr on type $param])* $param_name ),* ); )*); } } - impl<$trait_instance: $trait_name> $crate::dispatch::Dispatchable - for $call_type<$trait_instance> + impl<$trait_instance: $trait_name $(, $instance: $instantiable)?> $crate::dispatch::Dispatchable + for $call_type<$trait_instance $(, $instance)?> { type Trait = $trait_instance; type Origin = $origin_type; @@ -721,7 +716,7 @@ macro_rules! decl_module { $crate::decl_module!( @call $from - $mod_type $trait_instance $fn_name _origin $system [ $( $param_name ),* ] + $mod_type<$trait_instance $(, $fn_instance)?> $fn_name _origin $system [ $( $param_name ),* ] ) }, )* @@ -729,20 +724,20 @@ macro_rules! decl_module { } } } - impl<$trait_instance: $trait_name> $crate::dispatch::Callable - for $mod_type<$trait_instance> + impl<$trait_instance: $trait_name $(, $instance: $instantiable)?> $crate::dispatch::Callable + for $mod_type<$trait_instance $(, $instance)?> { - type Call = $call_type<$trait_instance>; + type Call = $call_type<$trait_instance $(, $instance)?>; } - impl<$trait_instance: $trait_name> $mod_type<$trait_instance> { + impl<$trait_instance: $trait_name $(, $instance: $instantiable)?> $mod_type<$trait_instance $(, $instance)?> { #[doc(hidden)] pub fn dispatch>(d: D, origin: D::Origin) -> $crate::dispatch::Result { d.dispatch(origin) } } $crate::__dispatch_impl_metadata! { - $mod_type $trait_instance $trait_name $call_type $origin_type + $mod_type<$trait_instance: $trait_name $(, $instance: $instantiable)?> $call_type $origin_type {$( $(#[doc = $doc_attr])* fn $fn_name($from $(, $(#[$codec_attr])* $param_name : $param )*); )*} } } @@ -949,10 +944,10 @@ macro_rules! __impl_outer_dispatch_common { #[doc(hidden)] macro_rules! __dispatch_impl_metadata { ( - $mod_type:ident $trait_instance:ident $trait_name:ident + $mod_type:ident<$trait_instance:ident: $trait_name:ident$(, $instance:ident: $instantiable:path)?> $($rest:tt)* ) => { - impl<$trait_instance: $trait_name> $mod_type<$trait_instance> { + impl<$trait_instance: $trait_name $(, $instance: $instantiable)?> $mod_type<$trait_instance $(, $instance)?> { #[doc(hidden)] pub fn call_functions() -> &'static [$crate::dispatch::FunctionMetadata] { $crate::__call_to_functions!($($rest)*) diff --git a/substrate/srml/support/src/event.rs b/substrate/srml/support/src/event.rs index dc51b66a94..3dc132a490 100644 --- a/substrate/srml/support/src/event.rs +++ b/substrate/srml/support/src/event.rs @@ -88,16 +88,48 @@ pub use srml_metadata::{EventMetadata, DecodeDifferent, OuterEventMetadata, FnEn /// ``` /// /// The syntax for generic events requires the `where`. +/// +/// # Generic Event with Instance Example: +/// +/// ```rust +/// #[macro_use] +/// extern crate srml_support; +/// extern crate parity_codec as codec; +/// #[macro_use] +/// extern crate parity_codec; +/// #[macro_use] +/// extern crate serde_derive; +/// +///# struct DefaultInstance; +///# trait Instance {} +///# impl Instance for DefaultInstance {} +/// trait Trait { +/// type Balance; +/// type Token; +/// } +/// +/// // For module with instances, DefaultInstance is optionnal +/// decl_event!( +/// pub enum Event where +/// ::Balance, +/// ::Token +/// { +/// Message(Balance, Token), +/// } +/// ); +///# fn main() {} +/// ``` #[macro_export] macro_rules! decl_event { ( $(#[$attr:meta])* - pub enum Event<$evt_generic_param:ident> where + pub enum Event<$evt_generic_param:ident $(, $instance:ident $(: $instantiable:ident)? $( = $event_default_instance:path)? )?> where $( $tt:tt )* ) => { $crate::__decl_generic_event!( $( #[ $attr ] )*; $evt_generic_param; + $($instance $( = $event_default_instance)? )?; { $( $tt )* }; ); }; @@ -138,11 +170,13 @@ macro_rules! __decl_generic_event { ( $(#[$attr:meta])*; $event_generic_param:ident; + $($instance:ident $( = $event_default_instance:path)? )?; { $( $tt:tt )* }; ) => { $crate::__decl_generic_event!(@format_generic $( #[ $attr ] )*; $event_generic_param; + $($instance $( = $event_default_instance)? )?; { $( $tt )* }; {}; ); @@ -151,12 +185,14 @@ macro_rules! __decl_generic_event { (@format_generic $(#[$attr:meta])*; $event_generic_param:ident; + $($instance:ident $( = $event_default_instance:path)? )?; { $generic_rename:ident = $generic_type:ty, $($rest:tt)* }; {$( $parsed:tt)*}; ) => { $crate::__decl_generic_event!(@format_generic $( #[ $attr ] )*; $event_generic_param; + $($instance $( = $event_default_instance)? )?; { $($rest)* }; { $($parsed)*, $generic_rename = $generic_type }; ); @@ -165,12 +201,14 @@ macro_rules! __decl_generic_event { (@format_generic $(#[$attr:meta])*; $event_generic_param:ident; + $($instance:ident $( = $event_default_instance:path)? )?; { <$generic:ident as $trait:path>::$trait_type:ident, $($rest:tt)* }; {$($parsed:tt)*}; ) => { $crate::__decl_generic_event!(@format_generic $( #[ $attr ] )*; $event_generic_param; + $($instance $( = $event_default_instance)? )?; { $($rest)* }; { $($parsed)*, $trait_type = <$generic as $trait>::$trait_type }; ); @@ -179,6 +217,7 @@ macro_rules! __decl_generic_event { (@format_generic $(#[$attr:meta])*; $event_generic_param:ident; + $($instance:ident $( = $event_default_instance:path)? )?; { $generic_type:ty, $($rest:tt)* }; {$($parsed:tt)*}; ) => { @@ -188,12 +227,14 @@ macro_rules! __decl_generic_event { (@format_generic $(#[$attr:meta])*; $event_generic_param:ident; + $($instance:ident $( = $event_default_instance:path)? )?; { <$generic:ident as $trait:path>::$trait_type:ident { $( $events:tt )* } }; {$( $parsed:tt)*}; ) => { $crate::__decl_generic_event!(@generate $( #[ $attr ] )*; $event_generic_param; + $($instance $( = $event_default_instance)? )?; { $($events)* }; { $($parsed)*, $trait_type = <$generic as $trait>::$trait_type}; ); @@ -202,12 +243,14 @@ macro_rules! __decl_generic_event { (@format_generic $(#[$attr:meta])*; $event_generic_param:ident; + $($instance:ident $( = $event_default_instance:path)? )?; { $generic_rename:ident = $generic_type:ty { $( $events:tt )* } }; {$( $parsed:tt)*}; ) => { $crate::__decl_generic_event!(@generate $(#[$attr])*; $event_generic_param; + $($instance $( = $event_default_instance)? )?; { $($events)* }; { $($parsed)*, $generic_rename = $generic_type}; ); @@ -216,6 +259,7 @@ macro_rules! __decl_generic_event { (@format_generic $(#[$attr:meta])*; $event_generic_param:ident; + $($instance:ident $( = $event_default_instance:path)? )?; { $generic_type:ty { $( $events:tt )* } }; {$( $parsed:tt)*}; ) => { @@ -224,6 +268,7 @@ macro_rules! __decl_generic_event { (@generate $(#[$attr:meta])*; $event_generic_param:ident; + $($instance:ident $( = $event_default_instance:path)? )?; { $( $events:tt )* }; { ,$( $generic_param:ident = $generic_type:ty ),* }; ) => { @@ -231,20 +276,22 @@ macro_rules! __decl_generic_event { /// /// [`RawEvent`]: enum.RawEvent.html /// [`Trait`]: trait.Trait.html - pub type Event<$event_generic_param> = RawEvent<$( $generic_type ),*>; + pub type Event<$event_generic_param $(, $instance $( = $event_default_instance)? )?> = RawEvent<$( $generic_type ),* $(, $instance)? >; // Workaround for https://github.com/rust-lang/rust/issues/26925 . Remove when sorted. #[derive(Clone, PartialEq, Eq, $crate::codec::Encode, $crate::codec::Decode)] #[cfg_attr(feature = "std", derive(Debug))] $(#[$attr])* - pub enum RawEvent<$( $generic_param ),*> { + pub enum RawEvent<$( $generic_param ),* $(, $instance)? > { + #[doc(hidden)] + $(PhantomData($crate::rstd::marker::PhantomData<$instance>),)? $( $events )* } - impl<$( $generic_param ),*> From> for () { - fn from(_: RawEvent<$( $generic_param ),*>) -> () { () } + impl<$( $generic_param ),* $(, $instance)? > From> for () { + fn from(_: RawEvent<$( $generic_param ),* $(, $instance)?>) -> () { () } } - impl<$( $generic_param ),*> RawEvent<$( $generic_param ),*> { + impl<$( $generic_param ),* $(, $instance)?> RawEvent<$( $generic_param ),* $(, $instance)?> { #[allow(dead_code)] pub fn metadata() -> &'static [$crate::event::EventMetadata] { $crate::__events_to_metadata!(; $( $events )* ) @@ -297,7 +344,7 @@ macro_rules! impl_outer_event { ( $(#[$attr:meta])* pub enum $name:ident for $runtime:ident { - $( $rest:tt $( <$t:ident> )*, )* + $( $rest:tt $( <$t:ident $(, $rest_instance:path)? > )*, )* } ) => { $crate::impl_outer_event!( @@ -305,14 +352,14 @@ macro_rules! impl_outer_event { $name; $runtime; system; - Modules { $( $rest $(<$t>)*, )* }; + Modules { $( $rest $(<$t $(, $rest_instance)? >)*, )* }; ; ); }; ( $(#[$attr:meta])* pub enum $name:ident for $runtime:ident where system = $system:ident { - $( $rest:tt $( <$t:ident> )*, )* + $( $rest:tt $( <$t:ident $(, $rest_instance:path)? > )*, )* } ) => { $crate::impl_outer_event!( @@ -320,7 +367,7 @@ macro_rules! impl_outer_event { $name; $runtime; $system; - Modules { $( $rest $(<$t>)*, )* }; + Modules { $( $rest $(<$t $(, $rest_instance)? >)*, )* }; ; ); }; @@ -330,18 +377,18 @@ macro_rules! impl_outer_event { $runtime:ident; $system:ident; Modules { - $module:ident, - $( $rest:tt $( <$t:ident> )*, )* + $module:ident, + $( $rest:tt $( <$t:ident $(, $rest_instance:path)? > )*, )* }; - $( $module_name:ident::Event $( <$generic_param:ident> )*, )*; + $( $module_name:ident::Event $( <$generic_param:ident $(, $generic_instance:path)? > )*, )*; ) => { $crate::impl_outer_event!( $( #[$attr] )*; $name; $runtime; $system; - Modules { $( $rest $(<$t>)*, )* }; - $( $module_name::Event $( <$generic_param> )*, )* $module::Event<$runtime>,; + Modules { $( $rest $(<$t $(, $rest_instance)? >)*, )* }; + $( $module_name::Event $( <$generic_param $(, $generic_instance)? > )*, )* $module::Event<$runtime $(, $instance)? >,; ); }; ( @@ -351,17 +398,17 @@ macro_rules! impl_outer_event { $system:ident; Modules { $module:ident, - $( $rest:tt, )* + $( $rest:tt )* }; - $( $module_name:ident::Event $( <$generic_param:ident> )*, )*; + $( $module_name:ident::Event $( <$generic_param:ident $(, $generic_instance:path)? > )*, )*; ) => { $crate::impl_outer_event!( $( #[$attr] )*; $name; $runtime; $system; - Modules { $( $rest, )* }; - $( $module_name::Event $( <$generic_param> )*, )* $module::Event,; + Modules { $( $rest )* }; + $( $module_name::Event $( <$generic_param $(, $generic_instance)? > )*, )* $module::Event,; ); }; @@ -373,7 +420,7 @@ macro_rules! impl_outer_event { $runtime:ident; $system:ident; Modules {}; - $( $module_name:ident::Event $( <$generic_param:ident> )*, )*; + $( $module_name:ident::Event $( <$generic_param:ident $(, $generic_instance:path)? > )*, )*; ) => { // Workaround for https://github.com/rust-lang/rust/issues/26925 . Remove when sorted. #[derive(Clone, PartialEq, Eq, $crate::codec::Encode, $crate::codec::Decode)] @@ -383,7 +430,7 @@ macro_rules! impl_outer_event { pub enum $name { system($system::Event), $( - $module_name( $module_name::Event $( <$generic_param> )* ), + $module_name( $module_name::Event $( <$generic_param $(, $generic_instance)? > )* ), )* } impl From<$system::Event> for $name { @@ -392,8 +439,8 @@ macro_rules! impl_outer_event { } } $( - impl From<$module_name::Event $( <$generic_param> )*> for $name { - fn from(x: $module_name::Event $( <$generic_param> )*) -> Self { + impl From<$module_name::Event $( <$generic_param $(, $generic_instance)? > )*> for $name { + fn from(x: $module_name::Event $( <$generic_param $(, $generic_instance)? > )*) -> Self { $name::$module_name(x) } } @@ -402,7 +449,7 @@ macro_rules! impl_outer_event { $runtime; $name; $system; - $( $module_name::Event $( <$generic_param> )*, )*; + $( $module_name::Event $( <$generic_param $(, $generic_instance)? > )*, )*; ); } } @@ -414,7 +461,7 @@ macro_rules! __impl_outer_event_json_metadata { $runtime:ident; $event_name:ident; $system:ident; - $( $module_name:ident::Event $( <$generic_param:ident> )*, )*; + $( $module_name:ident::Event $( <$generic_param:ident $(, $generic_instance:path)? > )*, )*; ) => { impl $runtime { #[allow(dead_code)] @@ -427,7 +474,7 @@ macro_rules! __impl_outer_event_json_metadata { , ( stringify!($module_name), $crate::event::FnEncode( - $module_name::Event $( ::<$generic_param> )* ::metadata + $module_name::Event $( ::<$generic_param $(, $generic_instance)? > )* ::metadata ) ) )* @@ -442,7 +489,7 @@ macro_rules! __impl_outer_event_json_metadata { #[allow(dead_code)] $crate::paste::item!{ pub fn [< __module_events_ $module_name >] () -> &'static [$crate::event::EventMetadata] { - $module_name::Event $( ::<$generic_param> )* ::metadata() + $module_name::Event $( ::<$generic_param $(, $generic_instance)? > )* ::metadata() } } )* diff --git a/substrate/srml/support/src/lib.rs b/substrate/srml/support/src/lib.rs index 7914e7d677..89b14fe2fc 100644 --- a/substrate/srml/support/src/lib.rs +++ b/substrate/srml/support/src/lib.rs @@ -64,6 +64,21 @@ pub use runtime_io::print; #[doc(inline)] pub use srml_support_procedural::decl_storage; +pub mod lazy { + use spin::Once; + + pub struct Lazy(Once); + + impl Lazy { + pub const INIT: Self = Lazy(Once::INIT); + + #[inline(always)] + pub fn get(&'static self, builder: F) -> &T where F: FnOnce() -> T { + self.0.call_once(builder) + } + } +} + #[macro_export] macro_rules! fail { ( $y:expr ) => {{ diff --git a/substrate/srml/support/src/metadata.rs b/substrate/srml/support/src/metadata.rs index 1a919e36f8..d61dbe4352 100644 --- a/substrate/srml/support/src/metadata.rs +++ b/substrate/srml/support/src/metadata.rs @@ -52,17 +52,17 @@ macro_rules! __runtime_modules_to_metadata { ( $runtime: ident; $( $metadata:expr ),*; - $mod:ident::$module:ident $(with)+ $($kw:ident)*, + $mod:ident::$module:ident $( < $instance:ident > )? $(with)+ $($kw:ident)*, $( $rest:tt )* ) => { $crate::__runtime_modules_to_metadata!( $runtime; $( $metadata, )* $crate::metadata::ModuleMetadata { name: $crate::metadata::DecodeDifferent::Encode(stringify!($mod)), - prefix: $crate::__runtime_modules_to_metadata_calls_storagename!($mod, $module, $runtime, $(with $kw)*), - storage: $crate::__runtime_modules_to_metadata_calls_storage!($mod, $module, $runtime, $(with $kw)*), - calls: $crate::__runtime_modules_to_metadata_calls_call!($mod, $module, $runtime, $(with $kw)*), - event: $crate::__runtime_modules_to_metadata_calls_event!($mod, $module, $runtime, $(with $kw)*), + prefix: $crate::__runtime_modules_to_metadata_calls_storagename!($mod, $module $( <$instance> )?, $runtime, $(with $kw)*), + storage: $crate::__runtime_modules_to_metadata_calls_storage!($mod, $module $( <$instance> )?, $runtime, $(with $kw)*), + calls: $crate::__runtime_modules_to_metadata_calls_call!($mod, $module $( <$instance> )?, $runtime, $(with $kw)*), + event: $crate::__runtime_modules_to_metadata_calls_event!($mod, $module $( <$instance> )?, $runtime, $(with $kw)*), }; $( $rest )* ) @@ -81,7 +81,7 @@ macro_rules! __runtime_modules_to_metadata_calls_call { // skip system ( system, - $skip_module: ident, + $skip_module: ident $( <$instance:ident> )?, $skip_runtime: ident, with Call $(with $kws:ident)* @@ -90,29 +90,29 @@ macro_rules! __runtime_modules_to_metadata_calls_call { }; ( $mod: ident, - $module: ident, + $module: ident $( <$instance:ident> )?, $runtime: ident, with Call $(with $kws:ident)* ) => { Some($crate::metadata::DecodeDifferent::Encode( $crate::metadata::FnEncode( - $mod::$module::<$runtime>::call_functions + $mod::$module::<$runtime $(, $mod::$instance )?>::call_functions ) )) }; ( $mod: ident, - $module: ident, + $module: ident $( <$instance:ident> )?, $runtime: ident, with $_:ident $(with $kws:ident)* ) => { - $crate::__runtime_modules_to_metadata_calls_call!( $mod, $module, $runtime, $(with $kws)* ); + $crate::__runtime_modules_to_metadata_calls_call!( $mod, $module $( <$instance> )?, $runtime, $(with $kws)* ); }; ( $mod: ident, - $module: ident, + $module: ident $( <$instance:ident> )?, $runtime: ident, ) => { None @@ -125,7 +125,7 @@ macro_rules! __runtime_modules_to_metadata_calls_call { macro_rules! __runtime_modules_to_metadata_calls_event { ( $mod: ident, - $module: ident, + $module: ident $( <$instance:ident> )?, $runtime: ident, with Event $(with $kws:ident)* @@ -133,23 +133,23 @@ macro_rules! __runtime_modules_to_metadata_calls_event { Some($crate::metadata::DecodeDifferent::Encode( $crate::metadata::FnEncode( $crate::paste::expr!{ - $runtime:: [< __module_events_ $mod >] + $runtime:: [< __module_events_ $mod $(_ $instance)?>] } ) )) }; ( $mod: ident, - $module: ident, + $module: ident $( <$instance:ident> )?, $runtime: ident, with $_:ident $(with $kws:ident)* ) => { - $crate::__runtime_modules_to_metadata_calls_event!( $mod, $module, $runtime, $(with $kws)* ); + $crate::__runtime_modules_to_metadata_calls_event!( $mod, $module $( <$instance> )?, $runtime, $(with $kws)* ); }; ( $mod: ident, - $module: ident, + $module: ident $( <$instance:ident> )?, $runtime: ident, ) => { None @@ -161,29 +161,29 @@ macro_rules! __runtime_modules_to_metadata_calls_event { macro_rules! __runtime_modules_to_metadata_calls_storagename { ( $mod: ident, - $module: ident, + $module: ident $( <$instance:ident> )?, $runtime: ident, with Storage $(with $kws:ident)* ) => { $crate::metadata::DecodeDifferent::Encode( $crate::metadata::FnEncode( - $mod::$module::<$runtime>::store_metadata_name + $mod::$module::<$runtime $(, $mod::$instance )?>::store_metadata_name ) ) }; ( $mod: ident, - $module: ident, + $module: ident $( <$instance:ident> )?, $runtime: ident, with $_:ident $(with $kws:ident)* ) => { - $crate::__runtime_modules_to_metadata_calls_storagename!( $mod, $module, $runtime, $(with $kws)* ); + $crate::__runtime_modules_to_metadata_calls_storagename!( $mod, $module $( <$instance> )?, $runtime, $(with $kws)* ); }; ( $mod: ident, - $module: ident, + $module: ident $( <$instance:ident> )?, $runtime: ident, ) => { $crate::metadata::DecodeDifferent::Encode( @@ -197,29 +197,29 @@ macro_rules! __runtime_modules_to_metadata_calls_storagename { macro_rules! __runtime_modules_to_metadata_calls_storage { ( $mod: ident, - $module: ident, + $module: ident $( <$instance:ident> )?, $runtime: ident, with Storage $(with $kws:ident)* ) => { Some($crate::metadata::DecodeDifferent::Encode( $crate::metadata::FnEncode( - $mod::$module::<$runtime>::store_metadata_functions + $mod::$module::<$runtime $(, $mod::$instance )?>::store_metadata_functions ) )) }; ( $mod: ident, - $module: ident, + $module: ident $( <$instance:ident> )?, $runtime: ident, with $_:ident $(with $kws:ident)* ) => { - $crate::__runtime_modules_to_metadata_calls_storage!( $mod, $module, $runtime, $(with $kws)* ); + $crate::__runtime_modules_to_metadata_calls_storage!( $mod, $module $( <$instance> )?, $runtime, $(with $kws)* ); }; ( $mod: ident, - $module: ident, + $module: ident $( <$instance:ident> )?, $runtime: ident, ) => { None diff --git a/substrate/srml/support/src/origin.rs b/substrate/srml/support/src/origin.rs index 9b76c3ac2b..2d97f218e0 100644 --- a/substrate/srml/support/src/origin.rs +++ b/substrate/srml/support/src/origin.rs @@ -28,34 +28,20 @@ macro_rules! impl_outer_origin { ( $(#[$attr:meta])* pub enum $name:ident for $runtime:ident { - $( $module:ident $( <$generic:ident> )* ),* $(,)* + $( $module:ident $( <$generic:ident $(, $instance:path )? > )? ),* $(,)? } ) => { $crate::impl_outer_origin! { $(#[$attr])* pub enum $name for $runtime where system = system { - $( $module $( <$generic> )*, )* + $( $module $( <$generic $(, $instance )? > )?, )* } } }; - ( - $(#[$attr:meta])* - pub enum $name:ident for $runtime:ident where system = $system:ident {} - ) => { - $crate::impl_outer_origin!( - $( #[$attr] )*; - $name; - $runtime; - $system; - Modules { }; - ; - ); - }; ( $(#[$attr:meta])* pub enum $name:ident for $runtime:ident where system = $system:ident { - $module:ident, - $( $rest_module:ident $( <$rest_generic:ident> )* ),* $(,)* + $( $module:ident $( <$generic:ident $(, $instance:path )?> )? ),* $(,)? } ) => { $crate::impl_outer_origin!( @@ -63,64 +49,30 @@ macro_rules! impl_outer_origin { $name; $runtime; $system; - Modules { $( $rest_module $( <$rest_generic> )*, )* }; - $module; - ); - }; - ( - $(#[$attr:meta])* - pub enum $name:ident for $runtime:ident where system = $system:ident { - $module:ident, - $( $rest_module:ident $( <$rest_generic:ident> )* ),* $(,)* - } - ) => { - $crate::impl_outer_origin!( - $( #[$attr] )*; - $name; - $runtime; - $system; - Modules { $( $rest_module $( <$rest_generic> )*, )* }; - $module<$runtime>; + Modules { $( $module $( <$generic $(, $instance )? > )*, )* }; ); }; + + // Replace generic param with runtime + ( $(#[$attr:meta])*; $name:ident; $runtime:ident; $system:ident; Modules { - $module:ident, - $( $rest_module:ident $( <$rest_generic:ident> )*, )* + $module:ident $( )?, + $( $rest_module:tt )* }; - $( $parsed_module:ident $( <$generic_param:ident> )* ),*; + $( $parsed:tt )* ) => { $crate::impl_outer_origin!( $( #[$attr] )*; $name; $runtime; $system; - Modules { $( $rest_module $( <$rest_generic> )*, )* }; - $( $parsed_module $( <$generic_param> )* ),*, $module; - ); - }; - ( - $(#[$attr:meta])*; - $name:ident; - $runtime:ident; - $system:ident; - Modules { - $module:ident, - $( $rest_module:ident $( <$rest_generic:ident> )*, )* - }; - $( $parsed_module:ident $( <$generic_param:ident> )* ),*; - ) => { - $crate::impl_outer_origin!( - $( #[$attr] )*; - $name; - $runtime; - $system; - Modules { $( $rest_module $( <$rest_generic> )*, )* }; - $( $parsed_module $( <$generic_param> )* ),*, $module<$runtime>; + Modules { $( $rest_module )* }; + $( $parsed )* $module $( <$runtime $(, $instance )? > )?, ); }; @@ -131,8 +83,8 @@ macro_rules! impl_outer_origin { $name:ident; $runtime:ident; $system:ident; - Modules {}; - $( $module:ident $( <$generic_param:ident> )* ),*; + Modules { }; + $( $module:ident $( <$generic_param:ident $(, $generic_instance:path )? > )* ,)* ) => { // Workaround for https://github.com/rust-lang/rust/issues/26925 . Remove when sorted. #[derive(Clone, PartialEq, Eq)] @@ -142,7 +94,7 @@ macro_rules! impl_outer_origin { pub enum $name { system($system::Origin<$runtime>), $( - $module($module::Origin $( <$generic_param> )* ), + $module($module::Origin $( <$generic_param $(, $generic_instance )? > )* ), )* #[allow(dead_code)] Void($crate::Void) @@ -175,13 +127,13 @@ macro_rules! impl_outer_origin { } } $( - impl From<$module::Origin $( <$generic_param> )*> for $name { - fn from(x: $module::Origin $( <$generic_param> )*) -> Self { + impl From<$module::Origin $( <$generic_param $(, $generic_instance )? > )*> for $name { + fn from(x: $module::Origin $( <$generic_param $(, $generic_instance )? > )*) -> Self { $name::$module(x) } } - impl Into )*>> for $name { - fn into(self) -> Option<$module::Origin $( <$generic_param> )*> { + impl Into )*>> for $name { + fn into(self) -> Option<$module::Origin $( <$generic_param $(, $generic_instance )? > )*> { if let $name::$module(l) = self { Some(l) } else { diff --git a/substrate/srml/support/src/runtime.rs b/substrate/srml/support/src/runtime.rs index dd48509451..c575383b26 100644 --- a/substrate/srml/support/src/runtime.rs +++ b/substrate/srml/support/src/runtime.rs @@ -37,6 +37,10 @@ /// System: system, /// Test: test::{default, Log(Test)}, /// 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}, /// } /// ) /// ``` @@ -55,9 +59,9 @@ /// - `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) +/// - `Event` or `Event` (if the event is generic) or `Event` (if also over instance) +/// - `Origin` or `Origin` (if the origin is generic) or `Origin` (if also over instance) +/// - `Config` or `Config` (if the config is generic) or `Config` (if also over instance) /// - `Log( $(IDENT),* )` /// - `Inherent $( (CALL) )*` - If the module provides/can check inherents. The optional parameter /// is for modules that use a `Call` from a different module as @@ -84,155 +88,60 @@ macro_rules! construct_runtime { } ) => { construct_runtime!( - $runtime; - $block; - $node_block; - $uncheckedextrinsic; - $log_internal < $( $log_genarg ),* >; - ; + { + $runtime; + $block; + $node_block; + $uncheckedextrinsic; + $log_internal < $( $log_genarg ),* >; + }; + {}; $( $rest )* ); }; ( - $runtime:ident; - $block:ident; - $node_block:ty; - $uncheckedextrinsic:ident; - $log_internal:ident <$( $log_genarg:ty ),+>; - $( - $expanded_name:ident: $expanded_module:ident::{ - $( - $expanded_modules:ident - $( <$expanded_modules_generic:ident> )* - $( ( $( $expanded_modules_args:ident ),* ) )* - ),* - } - ),*; + { $( $preset:tt )* }; + { $( $expanded:tt )* }; $name:ident: $module:ident, - $( - $rest_name:ident: $rest_module:ident $( - ::{ - $( - $rest_modules:ident - $( <$rest_modules_generic:ident> )* - $( ( $( $rest_modules_args:ident ),* ) )* - ),* - } - )*, - )* + $( $rest:tt )* ) => { construct_runtime!( - $runtime; - $block; - $node_block; - $uncheckedextrinsic; - $log_internal < $( $log_genarg ),* >; - $( - $expanded_name: $expanded_module::{ - $( - $expanded_modules - $( <$expanded_modules_generic> )* - $( ( $( $expanded_modules_args ),* ) )* - ),* - }, - )* $name: $module::{Module, Call, Storage, Event, Config}; - $( - $rest_name: $rest_module $( - ::{ - $( - $rest_modules - $( <$rest_modules_generic> )* - $( ( $( $rest_modules_args ),* ) )* - ),* - } - )*, - )* + { $( $preset )* }; + { $( $expanded )* $name: $module::{Module, Call, Storage, Event, Config}, }; + $( $rest )* ); }; ( - $runtime:ident; - $block:ident; - $node_block:ty; - $uncheckedextrinsic:ident; - $log_internal:ident <$( $log_genarg:ty ),+>; - $( - $expanded_name:ident: $expanded_module:ident::{ - $( - $expanded_modules:ident - $( <$expanded_modules_generic:ident> )* - $( ( $( $expanded_modules_args:ident ),* ) )* - ),* - } - ),*; + { $( $preset:tt )* }; + { $( $expanded:tt )* }; $name:ident: $module:ident::{ default, $( $modules:ident - $( <$modules_generic:ident> )* + $( <$modules_generic:ident $(, $modules_instance:ident)?> )* $( ( $( $modules_args:ident ),* ) )* ),* }, - $( - $rest_name:ident: $rest_module:ident $( - ::{ - $( - $rest_modules:ident - $( <$rest_modules_generic:ident> )* - $( ( $( $rest_modules_args:ident ),* ) )* - ),* - } - )*, - )* + $( $rest:tt )* ) => { construct_runtime!( - $runtime; - $block; - $node_block; - $uncheckedextrinsic; - $log_internal < $( $log_genarg ),* >; - $( - $expanded_name: $expanded_module::{ + { $( $preset )* }; + { + $( $expanded )* + $name: $module::{ + Module, Call, Storage, Event, Config, $( - $expanded_modules - $( <$expanded_modules_generic> )* - $( ( $( $expanded_modules_args ),* ) )* + $modules $( <$modules_generic $(, $modules_instance)?> )* + $( ( $( $modules_args ),* ) )* ),* }, - )* - $name: $module::{ - Module, Call, Storage, Event, Config, - $( - $modules $( <$modules_generic> )* $( ( $( $modules_args ),* ) )* - ),* }; - $( - $rest_name: $rest_module $( - ::{ - $( - $rest_modules - $( <$rest_modules_generic> )* - $( ( $( $rest_modules_args ),* ) )* - ),* - } - )*, - )* + $( $rest )* ); }; ( - $runtime:ident; - $block:ident; - $node_block:ty; - $uncheckedextrinsic:ident; - $log_internal:ident <$( $log_genarg:ty ),+>; - $( - $expanded_name:ident: $expanded_module:ident::{ - $( - $expanded_modules:ident - $( <$expanded_modules_generic:ident> )* - $( ( $( $expanded_modules_args:ident ),* ) )* - ),* - } - ),*; + { $( $preset:tt )* }; + { $( $expanded:tt )* }; $name:ident: $module:ident::{ $( $modules:ident @@ -240,69 +149,70 @@ macro_rules! construct_runtime { $( ( $( $modules_args:ident ),* ) )* ),* }, - $( - $rest_name:ident: $rest_module:ident $( - ::{ - $( - $rest_modules:ident - $( <$rest_modules_generic:ident> )* - $( ( $( $rest_modules_args:ident ),* ) )* - ),* - } - )*, - )* + $( $rest:tt )* ) => { construct_runtime!( - $runtime; - $block; - $node_block; - $uncheckedextrinsic; - $log_internal < $( $log_genarg ),* >; - $( - $expanded_name: $expanded_module::{ + { $( $preset )* }; + { + $( $expanded )* + $name: $module::{ $( - $expanded_modules - $( <$expanded_modules_generic> )* - $( ( $( $expanded_modules_args ),* ) )* + $modules $( <$modules_generic> )* + $( ( $( $modules_args ),* ) )* ),* }, - )* - $name: $module::{ - $( - $modules $( <$modules_generic> )* $( ( $( $modules_args ),* ) )* - ),* }; + $( $rest )* + ); + }; + ( // Instance module: we indicate the generic instance `I` with the full instance path + { $( $preset:tt )* }; + { $( $expanded:tt )* }; + $name:ident: $module:ident ::< $module_instance:ident >::{ $( - $rest_name: $rest_module $( - ::{ - $( - $rest_modules - $( <$rest_modules_generic> )* - $( ( $( $rest_modules_args ),* ) )* - ),* - } - )*, - )* + $modules:ident + $( <$modules_generic:ident $(, $modules_instance:ident )?> )* + $( ( $( $modules_args:ident ),* ) )* + ),* + }, + $( $rest:tt )* + ) => { + construct_runtime!( + { $( $preset )* }; + { + $( $expanded )* + $name: $module::<$module_instance>::{ + $( + $modules $( <$modules_generic $(, $modules_instance=$module::$module_instance)?> )* + $( ( $( $modules_args ),* ) )* + ),* + }, + }; + $( $rest )* ); }; // The main macro expansion that actually renders the Runtime code. ( - $runtime:ident; - $block:ident; - $node_block:ty; - $uncheckedextrinsic:ident; - $log_internal:ident <$( $log_genarg:ty ),+>; - $( - $name:ident: $module:ident::{ - $( - $modules:ident - $( <$modules_generic:ident> )* - $( ( $( $modules_args:ident ),* ) )* - ),* - } - ),*; + { + $runtime:ident; + $block:ident; + $node_block:ty; + $uncheckedextrinsic:ident; + $log_internal:ident <$( $log_genarg:ty ),+>; + }; + { + $( + $name:ident: $module:ident :: $( < $module_instance:ident >:: )? { + $( + $modules:ident + $( <$modules_generic:ident $(, I=$modules_instance:path)?> )* + $( ( $( $modules_args:ident ),* ) )* + ),* + }, + )* + }; ) => { #[derive(Clone, Copy, PartialEq, Eq)] #[cfg_attr(feature = "std", derive(Debug))] @@ -313,54 +223,59 @@ macro_rules! construct_runtime { impl $crate::runtime_primitives::traits::GetRuntimeBlockType for $runtime { type RuntimeBlock = $block; } + $crate::__decl_instance_import!( + $( $( $module < $module_instance > )? )* + ); $crate::__decl_outer_event!( $runtime; $( - $name: $module::{ $( $modules $( <$modules_generic> )* ),* } + $name: $module:: $( < $module_instance >:: )? { $( $modules $( <$modules_generic $(, $modules_instance)?> )* ),* } ),* ); $crate::__decl_outer_origin!( $runtime; $( - $name: $module::{ $( $modules $( <$modules_generic> )* ),* } + $name: $module:: $( < $module_instance >:: )? { $( $modules $( <$modules_generic $(, $modules_instance)?> )* ),* } ),* ); $crate::__decl_all_modules!( $runtime; ; - ; + {}; $( - $name: $module::{ $( $modules $( <$modules_generic> )* ),* } - ),*; + $name: $module:: $( < $module_instance >:: )? { $( $modules ),* }, + )* ); $crate::__decl_outer_dispatch!( $runtime; ; $( - $name: $module::{ $( $modules $( <$modules_generic> )* ),* } + $name: $module::{ $( $modules ),* } ),*; ); $crate::__decl_runtime_metadata!( $runtime; - ; + {}; $( - $name: $module::{ $( $modules )* } + $name: $module:: $( < $module_instance >:: )? { $( $modules )* } )* ); $crate::__decl_outer_log!( $runtime; $log_internal < $( $log_genarg ),* >; - ; + {}; $( - $name: $module::{ $( $modules $( ( $( $modules_args ),* ) )* ),* } - ),*; + $name: $module:: $( < $module_instance >:: )? { $( $modules $( ( $( $modules_args )* ) )* )* } + )* ); $crate::__decl_outer_config!( $runtime; - ; + {}; $( - $name: $module::{ $( $modules $( <$modules_generic> )* ),* } - ),*; + $name: $module:: $( < $module_instance >:: )? { + $( $modules $( <$modules_generic $(, $modules_instance)?> )* ),* + }, + )* ); $crate::__decl_outer_inherent!( $runtime; @@ -392,121 +307,135 @@ macro_rules! __create_decl_macro { macro_rules! $macro_name { ( $runtime:ident; - $d( $name:ident : $module:ident::{ - $d( $modules:ident $d( <$modules_generic:ident> )* ),* + $d( $name:ident : $module:ident:: $d( < $module_instance:ident >:: )? { + $d( $modules:ident $d( <$modules_generic:ident $d(, $modules_instance:path)?> ),* ),* }),* ) => { $d crate::$macro_name!(@inner $runtime; ; - ; + {}; $d( - $name: $module::{ - $d( $modules $d( <$modules_generic> )* ),* - } - ),*; + $name: $module:: $d( < $module_instance >:: )? { + $d( $modules $d( <$modules_generic $d(, $modules_instance)?> )* ),* + }, + )* ); }; (@inner $runtime:ident; ; // there can not be multiple `System`s - $d( $parsed_modules:ident $d( <$parsed_generic:ident> )* ),*; + { $d( $parsed:tt )* }; System: $module:ident::{ - $ingore:ident $d( <$ignor:ident> )* $d(, $modules:ident $d( <$modules_generic:ident> )* )* - } - $d(, $rest_name:ident : $rest_module:ident::{ - $d( $rest_modules:ident $d( <$rest_modules_generic:ident> )* ),* - })*; + $d( $modules:ident $d( <$modules_generic:ident> )* ),* + }, + $d( $rest:tt )* ) => { $d crate::$macro_name!(@inner $runtime; $module; - $d( $parsed_modules $d( <$parsed_generic> )* ),*; - $d( - $rest_name: $rest_module::{ - $d( $rest_modules $d( <$rest_modules_generic> )* ),* - } - ),*; + { $d( $parsed )* }; + $d( $rest )* ); }; (@inner $runtime:ident; - $d( $system:ident )*; - $d( $parsed_modules:ident $d( <$parsed_generic:ident> )* ),*; - $name:ident: $module:ident::{ - $macro_enum_name $d( <$event_gen:ident> )* $d(, $modules:ident $d( <$modules_generic:ident> )* )* - } - $d(, $rest_name:ident : $rest_module:ident::{ - $d( $rest_modules:ident $d( <$rest_modules_generic:ident> )* ),* - })*; + $d( $system:ident )?; + { $d( $parsed:tt )* }; + $name:ident : $module:ident:: < $module_instance:ident >:: { + $macro_enum_name <$event_generic:ident, $event_instance:path> $d(, $ingore:ident $d( <$ignor:ident $d(, $ignore_instance:path)?> )* )* + }, + $d( $rest:tt )* ) => { $d crate::$macro_name!(@inner $runtime; - $d( $system )*; - $d( - $parsed_modules $d( <$parsed_generic> )* , )* - $module $d( <$event_gen> )*; - $d( - $rest_name: $rest_module::{ - $d( $rest_modules $d( <$rest_modules_generic> )* ),* - } - ),*; + $d( $system )?; + { + $d( $parsed )* + $module $module_instance <$event_generic, $event_instance>, + }; + $d( $rest )* ); }; (@inner $runtime:ident; - $d( $system:ident )*; - $d( $parsed_modules:ident $d( <$parsed_generic:ident> )* ),*; - $name:ident: $module:ident::{ - $ingore:ident $d( <$ignor:ident> )* $d(, $modules:ident $d( <$modules_generic:ident> )* )* - } - $d(, $rest_name:ident : $rest_module:ident::{ - $d( $rest_modules:ident $d( <$rest_modules_generic:ident> )* ),* - })*; + $d( $system:ident )?; + { $d( $parsed:tt )* }; + $name:ident : $module:ident:: < $module_instance:ident >:: { + $macro_enum_name $d( <$event_generic:ident> )* $d(, $ingore:ident $d( <$ignor:ident $d(, $ignore_instance:path)?> )* )* + }, + $d( $rest:tt )* + ) => { + compile_error!{concat!{ + "Module `", stringify!{$name}, "` must have `", stringify!{$macro_enum_name}, "`", + " but has `", stringify!{$macro_enum_name} $d(, "<", stringify!{$event_generic}, ">")*, "`", + ": Instantiated modules must have ", stringify!{$macro_enum_name}, + " generic over instance to be able to convert to outer ", stringify!{$macro_enum_name} + }} + }; + (@inner + $runtime:ident; + $d( $system:ident )?; + { $d( $parsed:tt )* }; + $name:ident : $module:ident:: { + $macro_enum_name $d( <$event_generic:ident $d(, $event_instance:path)?> )* $d(, $ingore:ident $d( <$ignor:ident $d(, $ignore_instance:path)?> )* )* + }, + $d( $rest:tt )* ) => { $d crate::$macro_name!(@inner $runtime; - $d( $system )*; - $d( $parsed_modules $d( <$parsed_generic> )* ),*; - $name: $module::{ $d( $modules $d( <$modules_generic> )* ),* } - $d( - , $rest_name: $rest_module::{ - $d( $rest_modules $d( <$rest_modules_generic> )* ),* - } - )*; + $d( $system )?; + { + $d( $parsed )* + $module $d( <$event_generic $d(, $event_instance)?> )*, + }; + $d( $rest )* ); }; (@inner $runtime:ident; - $d( $system:ident )*; - $d( $parsed_modules:ident $d( <$parsed_generic:ident> )* ),*; - $name:ident: $module:ident::{} - $d(, $rest_name:ident : $rest_module:ident::{ - $d( $rest_modules:ident $d( <$rest_modules_generic:ident> )* ),* - })*; + $d( $system:ident )?; + { $d( $parsed:tt )* }; + $name:ident : $module:ident:: $d( < $module_instance:ident >:: )? { + $ingore:ident $d( <$ignor:ident $d(, $ignore_instance:path)?> )* $d(, $modules:ident $d( <$modules_generic:ident $d(, $modules_instance:path)?> )* )* + }, + $d( $rest:tt )* ) => { $d crate::$macro_name!(@inner $runtime; - $d( $system )*; - $d( $parsed_modules $d( <$parsed_generic> )* ),*; - $d( - $rest_name: $rest_module::{ - $d( $rest_modules $d( <$rest_modules_generic> )* ),* - } - ),*; + $d( $system )?; + { $d( $parsed )* }; + $name: $module:: $d( < $module_instance >:: )? { $d( $modules $d( <$modules_generic $d(, $modules_instance)?> )* ),* }, + $d( $rest )* ); }; (@inner $runtime:ident; - $d( $system:ident )+; - $d( $parsed_modules:ident $d( <$parsed_generic:ident> )* ),*; - ; + $d( $system:ident )?; + { $d( $parsed:tt )* }; + $name:ident: $module:ident:: $d( < $module_instance:ident >:: )? {}, + $d( $rest:tt )* ) => { - $d crate::$macro_outer_name! { - pub enum $macro_enum_name for $runtime where system = $d( $system )* { - $d( - $parsed_modules $d( <$parsed_generic> )*, - )* + $d crate::$macro_name!(@inner + $runtime; + $d( $system )?; + { $d( $parsed )* }; + $d( $rest )* + ); + }; + (@inner + $runtime:ident; + $system:ident; + { $d( $parsed_modules:ident $d( $instance:ident )? $d( <$parsed_generic:ident $d(, $parsed_instance_full_path:path)?> )* ,)* }; + ) => { + $d crate::paste::item! { + $d crate::$macro_outer_name! { + + pub enum $macro_enum_name for $runtime where system = $system { + $d( + [< $parsed_modules $d(_ $instance )? >] $d( <$parsed_generic $d(, $parsed_instance_full_path)?> )*, + )* + } } } } @@ -524,99 +453,71 @@ macro_rules! __decl_all_modules { ( $runtime:ident; ; - $( $parsed_modules:ident :: $parsed_name:ident ),*; - System: $module:ident::{ - Module $(, $modules:ident $( <$modules_generic:ident> )* )* - } - $(, $rest_name:ident : $rest_module:ident::{ - $( $rest_modules:ident $( <$rest_modules_generic:ident> )* ),* - })*; + { $( $parsed:tt )* }; + System: $module:ident::{ Module $(, $modules:ident )* }, + $( $rest:tt )* ) => { $crate::__decl_all_modules!( $runtime; $module; - $( $parsed_modules :: $parsed_name ),*; - $( - $rest_name: $rest_module::{ - $( $rest_modules $( <$rest_modules_generic> )* ),* - } - ),*; + { $( $parsed )* }; + $( $rest )* ); }; ( $runtime:ident; - $( $system:ident )*; - $( $parsed_modules:ident :: $parsed_name:ident ),*; - $name:ident: $module:ident::{ - Module $(, $modules:ident $( <$modules_generic:ident> )* )* - } - $(, $rest_name:ident : $rest_module:ident::{ - $( $rest_modules:ident $( <$rest_modules_generic:ident> )* ),* - })*; + $( $system:ident )?; + { $( $parsed:tt )* }; + $name:ident: $module:ident:: $( < $module_instance:ident >:: )? { Module $(, $modules:ident )* }, + $( $rest:tt )* ) => { $crate::__decl_all_modules!( $runtime; - $( $system )*; - $( $parsed_modules :: $parsed_name, )* $module::$name; - $( - $rest_name: $rest_module::{ - $( $rest_modules $( <$rest_modules_generic> )* ),* - } - ),*; + $( $system )?; + { + $( $parsed )* + $module::$name $(<$module_instance>)?, + }; + $( $rest )* ); }; ( $runtime:ident; - $( $system:ident )*; - $( $parsed_modules:ident :: $parsed_name:ident ),*; - $name:ident: $module:ident::{ - $ingore:ident $( <$ignor:ident> )* $(, $modules:ident $( <$modules_generic:ident> )* )* - } - $(, $rest_name:ident : $rest_module:ident::{ - $( $rest_modules:ident $( <$rest_modules_generic:ident> )* ),* - })*; + $( $system:ident )?; + { $( $parsed:tt )* }; + $name:ident: $module:ident:: $( < $module_instance:ident >:: )? { $ingore:ident $(, $modules:ident )* }, + $( $rest:tt )* ) => { $crate::__decl_all_modules!( $runtime; - $( $system )*; - $( $parsed_modules :: $parsed_name ),*; - $name: $module::{ $( $modules $( <$modules_generic> )* ),* } - $( - , $rest_name: $rest_module::{ - $( $rest_modules $( <$rest_modules_generic> )* ),* - } - )*; + $( $system )?; + { $( $parsed )* }; + $name: $module::{ $( $modules ),* }, + $( $rest )* ); }; ( $runtime:ident; - $( $system:ident )*; - $( $parsed_modules:ident :: $parsed_name:ident ),*; - $name:ident: $module:ident::{} - $(, $rest_name:ident : $rest_module:ident::{ - $( $rest_modules:ident $( <$rest_modules_generic:ident> )* ),* - })*; + $( $system:ident )?; + { $( $parsed:tt )* }; + $name:ident: $module:ident:: $( < $module_instance:ident >:: )? {}, + $( $rest:tt )* ) => { $crate::__decl_all_modules!( $runtime; - $( $system )*; - $( $parsed_modules :: $parsed_name ),*; - $( - $rest_name: $rest_module::{ - $( $rest_modules $( <$rest_modules_generic> )* ),* - } - ),*; + $( $system )?; + { $( $parsed )* }; + $( $rest )* ); }; ( $runtime:ident; $system:ident; - $( $parsed_modules:ident :: $parsed_name:ident ),*; - ; + { $( $parsed_module:ident :: $parsed_name:ident $(<$instance:ident>)? ,)*}; ) => { pub type System = system::Module<$runtime>; $( - pub type $parsed_name = $parsed_modules::Module<$runtime>; + pub type $parsed_name = $parsed_module::Module<$runtime $(, $parsed_module::$instance )?>; )* type AllModules = ( $( $parsed_name, )* ); } @@ -726,84 +627,68 @@ macro_rules! __decl_runtime_metadata { // leading is Module : parse ( $runtime:ident; - $( $parsed_modules:ident { $( $withs:ident )* } )*; + { $( $parsed:tt )* }; $( { leading_module: $( $leading_module:ident )* } )? - $name:ident: $module:ident::{ + $name:ident: $module:ident:: $( < $module_instance:ident >:: )? { Module $( $modules:ident )* } - $( $rest_name:ident : $rest_module:ident::{ - $( $rest_modules:ident )* - })* + $( $rest:tt )* ) => { $crate::__decl_runtime_metadata!( $runtime; - $( $parsed_modules { $( $withs )* } )* $module { $( $( $leading_module )* )? $( $modules )* }; - $( - $rest_name: $rest_module::{ - $( $rest_modules )* - } - )* + { + $( $parsed )* + $module $( < $module_instance > )? { $( $( $leading_module )* )? $( $modules )* } + }; + $( $rest )* ); }; // leading isn't Module : put it in leadings ( $runtime:ident; - $( $parsed_modules:ident { $( $withs:ident )* } )*; + { $( $parsed:tt )* }; $( { leading_module: $( $leading_module:ident )* } )? - $name:ident: $module:ident::{ + $name:ident: $module:ident:: $( < $module_instance:ident >:: )? { $other_module:ident $( $modules:ident )* } - $( $rest_name:ident : $rest_module:ident::{ - $( $rest_modules:ident )* - })* + $( $rest:tt )* ) => { $crate::__decl_runtime_metadata!( $runtime; - $( $parsed_modules { $( $withs )* } )*; + { $( $parsed )* }; { leading_module: $( $( $leading_module )* )? $other_module } - $name: $module::{ + $name: $module:: $( < $module_instance >:: )? { $( $modules )* } - $( - $rest_name: $rest_module::{ - $( $rest_modules )* - } - )* + $( $rest )* ); }; // does not contain Module : skip ( $runtime:ident; - $( $parsed_modules:ident { $( $withs:ident )* } )*; + { $( $parsed:tt )* }; $( { leading_module: $( $leading_module:ident )* } )? - $name:ident: $module:ident::{} - $( $rest_name:ident : $rest_module:ident::{ - $( $rest_modules:ident )* - })* + $name:ident: $module:ident:: $( < $module_instance:ident >:: )? {} + $( $rest:tt )* ) => { $crate::__decl_runtime_metadata!( $runtime; - $( $parsed_modules { $( $withs )* } )*; - $( - $rest_name: $rest_module::{ - $( $rest_modules )* - } - )* + { $( $parsed )* }; + $( $rest )* ); }; // end of decl ( $runtime:ident; - $( $parsed_modules:ident { $( $withs:ident )* } )*; + { $( $parsed_modules:ident $( < $module_instance:ident > )? { $( $withs:ident )* } )* }; ) => { $crate::impl_runtime_metadata!( for $runtime with modules - $( $parsed_modules::Module with $( $withs )* , )* + $( $parsed_modules::Module $( < $module_instance > )? with $( $withs )* , )* ); } } - /// A private macro that generates Log enum for the runtime. See impl_outer_log macro. #[macro_export] #[doc(hidden)] @@ -811,80 +696,65 @@ macro_rules! __decl_outer_log { ( $runtime:ident; $log_internal:ident <$( $log_genarg:ty ),+>; - $( $parsed_modules:ident( $( $parsed_args:ident ),* ) ),*; - $name:ident: $module:ident::{ - Log ( $( $args:ident ),* ) $(, $modules:ident $( ( $( $modules_args:ident )* ) )* )* + { $( $parsed:tt )* }; + $name:ident: $module:ident:: $(<$module_instance:ident>::)? { + Log ( $( $args:ident )* ) $( $modules:ident $( ( $( $modules_args:ident )* ) )* )* } - $(, $rest_name:ident : $rest_module:ident::{ - $( $rest_modules:ident $( ( $( $rest_modules_args:ident )* ) )* ),* - })*; + $( $rest:tt )* ) => { $crate::__decl_outer_log!( $runtime; $log_internal < $( $log_genarg ),* >; - $( $parsed_modules ( $( $parsed_args ),* ), )* $module ( $( $args ),* ); - $( - $rest_name: $rest_module::{ - $( $rest_modules $( ( $( $rest_modules_args ),* ) )* ),* - } - ),*; + { $( $parsed )* $module $(<$module_instance>)? ( $( $args )* )}; + $( $rest )* ); }; ( $runtime:ident; $log_internal:ident <$( $log_genarg:ty ),+>; - $( $parsed_modules:ident( $( $parsed_args:ident ),* ) ),*; - $name:ident: $module:ident::{ - $ignore:ident $( ( $( $args_ignore:ident ),* ) )* - $(, $modules:ident $( ( $( $modules_args:ident ),* ) )* )* + { $( $parsed:tt )* }; + $name:ident: $module:ident:: $(<$module_instance:ident>::)? { + $ignore:ident $( ( $( $args_ignore:ident )* ) )* + $( $modules:ident $( ( $( $modules_args:ident )* ) )* )* } - $(, $rest_name:ident : $rest_module:ident::{ - $( $rest_modules:ident $( ( $( $rest_modules_args:ident )* ) )* ),* - })*; + $( $rest:tt )* ) => { $crate::__decl_outer_log!( $runtime; $log_internal < $( $log_genarg ),* >; - $( $parsed_modules ( $( $parsed_args ),* ) ),*; - $name: $module::{ $( $modules $( ( $( $modules_args ),* ) )* ),* } - $( - , $rest_name: $rest_module::{ - $( $rest_modules $( ( $( $rest_modules_args ),* ) )* ),* - } - )*; + { $( $parsed )* }; + $name: $module:: $(<$module_instance>::)? { $( $modules $( ( $( $modules_args )* ) )* )* } + $( $rest )* ); }; ( $runtime:ident; $log_internal:ident <$( $log_genarg:ty ),+>; - $( $parsed_modules:ident( $( $parsed_args:ident ),* ) ),*; - $name:ident: $module:ident::{} - $(, $rest_name:ident : $rest_module:ident::{ - $( $rest_modules:ident $( ( $( $rest_modules_args:ident )* ) )* ),* - })*; + { $( $parsed:tt )* }; + $name:ident: $module:ident:: $(<$module_instance:ident>::)? {} + $( $rest:tt )* ) => { $crate::__decl_outer_log!( $runtime; $log_internal < $( $log_genarg ),* >; - $( $parsed_modules ( $( $parsed_args ),* ) ),*; - $( - $rest_name: $rest_module::{ - $( $rest_modules $( ( $( $rest_modules_args ),* ) )* ),* - } - ),*; + { $( $parsed )* }; + $( $rest )* ); }; ( $runtime:ident; $log_internal:ident <$( $log_genarg:ty ),+>; - $( $parsed_modules:ident( $( $parsed_args:ident ),* ) ),*; - ; + { $( + $parsed_modules:ident $(< $parsed_instance:ident >)? ( $( $parsed_args:ident )* ) + )* }; ) => { - $crate::runtime_primitives::impl_outer_log!( - pub enum Log($log_internal: DigestItem<$( $log_genarg ),*>) for $runtime { - $( $parsed_modules ( $( $parsed_args ),* ) ),* - } - ); + $crate::paste::item! { + $crate::runtime_primitives::impl_outer_log!( + pub enum Log($log_internal: DigestItem<$( $log_genarg ),*>) for $runtime { + $( [< $parsed_modules $(_ $parsed_instance)? >] $(< $parsed_modules::$parsed_instance >)? ( $( $parsed_args ),* ) ),* + } + ); + } }; } @@ -894,93 +764,57 @@ macro_rules! __decl_outer_log { macro_rules! __decl_outer_config { ( $runtime:ident; - $( $parsed_modules:ident :: $parsed_name:ident $( < $parsed_generic:ident > )* ),*; - $name:ident: $module:ident::{ - Config $(, $modules:ident $( <$modules_generic:ident> )* )* - } - $(, $rest_name:ident : $rest_module:ident::{ - $( $rest_modules:ident $( <$rest_modules_generic:ident> )* ),* - })*; + { $( $parsed:tt )* }; + $name:ident: $module:ident:: $( < $module_instance:ident >:: )? { + Config $(< $config_generic:ident $(, $config_instance:path)?>)? $(, $modules:ident $( <$modules_generic:ident $(, $modules_instance:path)?> )* )* + }, + $( $rest:tt )* ) => { $crate::__decl_outer_config!( $runtime; - $( $parsed_modules :: $parsed_name $( < $parsed_generic > )*, )* $module::$name; - $( - $rest_name: $rest_module::{ - $( $rest_modules $( <$rest_modules_generic> )* ),* - } - ),*; + { + $( $parsed )* + $module::$name $( $module_instance )? $(<$config_generic $(, $config_instance)?>)?, + }; + $( $rest )* ); }; ( $runtime:ident; - $( $parsed_modules:ident :: $parsed_name:ident $( < $parsed_generic:ident > )* ),*; - $name:ident: $module:ident::{ - Config $(, $modules:ident $( <$modules_generic:ident> )* )* - } - $(, $rest_name:ident : $rest_module:ident::{ - $( $rest_modules:ident $( <$rest_modules_generic:ident> )* ),* - })*; + { $( $parsed:tt )* }; + $name:ident: $module:ident:: $( < $module_instance:ident >:: )? { + $ingore:ident $( <$ignor:ident $(, $ignore_instance:path)?> )* $(, $modules:ident $( <$modules_generic:ident $(, $modules_instance:path)?> )* )* + }, + $( $rest:tt )* ) => { $crate::__decl_outer_config!( $runtime; - $( $parsed_modules :: $parsed_name $( < $parsed_generic > )*, )* $module::$name; - $( - $rest_name: $rest_module::{ - $( $rest_modules $( <$rest_modules_generic> )* ),* - } - ),*; + { $( $parsed )* }; + $name: $module:: $( < $module_instance >:: )? { $( $modules $( <$modules_generic $(, $modules_instance)?> )* ),* }, + $( $rest )* ); }; ( $runtime:ident; - $( $parsed_modules:ident :: $parsed_name:ident $( < $parsed_generic:ident > )* ),*; - $name:ident: $module:ident::{ - $ingore:ident $( <$ignor:ident> )* $(, $modules:ident $( <$modules_generic:ident> )* )* - } - $(, $rest_name:ident : $rest_module:ident::{ - $( $rest_modules:ident $( <$rest_modules_generic:ident> )* ),* - })*; + { $( $parsed:tt )* }; + $name:ident: $module:ident:: $( < $module_instance:ident >:: )? {}, + $( $rest:tt )* ) => { $crate::__decl_outer_config!( $runtime; - $( $parsed_modules :: $parsed_name $( < $parsed_generic > )*),*; - $name: $module::{ $( $modules $( <$modules_generic> )* ),* } - $( - , $rest_name: $rest_module::{ - $( $rest_modules $( <$rest_modules_generic> )* ),* - } - )*; + { $( $parsed )* }; + $( $rest )* ); }; ( $runtime:ident; - $( $parsed_modules:ident :: $parsed_name:ident $( < $parsed_generic:ident > )* ),*; - $name:ident: $module:ident::{} - $(, $rest_name:ident : $rest_module:ident::{ - $( $rest_modules:ident $( <$rest_modules_generic:ident> )* ),* - })*; - ) => { - $crate::__decl_outer_config!( - $runtime; - $( $parsed_modules :: $parsed_name $( < $parsed_generic > )*),*; - $( - $rest_name: $rest_module::{ - $( $rest_modules $( <$rest_modules_generic> )* ),* - } - ),*; - ); - }; - ( - $runtime:ident; - $( $parsed_modules:ident :: $parsed_name:ident $( < $parsed_generic:ident > )* ),*; - ; + {$( $parsed_modules:ident :: $parsed_name:ident $( $parsed_instance:ident )? $( < $parsed_generic:ident $(, $parsed_instance_full_path:path)? > )* ,)* }; ) => { $crate::paste::item! { $crate::runtime_primitives::impl_outer_config!( pub struct GenesisConfig for $runtime { $( - [< $parsed_name Config >] => $parsed_modules $( < $parsed_generic > )*, + [< $parsed_name Config >] => [< $parsed_modules $( _ $parsed_instance)? >] $( < $parsed_generic $(, $parsed_instance_full_path)? > )*, )* } ); @@ -1102,3 +936,14 @@ macro_rules! __decl_outer_inherent { ); }; } + +#[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 >];)* + } + }; +} diff --git a/substrate/srml/support/test/Cargo.toml b/substrate/srml/support/test/Cargo.toml new file mode 100644 index 0000000000..e1113eb468 --- /dev/null +++ b/substrate/srml/support/test/Cargo.toml @@ -0,0 +1,25 @@ +[package] +name = "srml-support-test" +version = "0.1.0" +authors = ["thiolliere "] +edition = "2018" + +[dev-dependencies] +serde = { version = "1.0", default-features = false } +serde_derive = { version = "1.0" } +parity-codec = { version = "3.2", default-features = false, features = ["derive"] } +runtime_io = { package = "sr-io", path = "../../../core/sr-io", default-features = false } +srml-support = { path = "../", default-features = false } +inherents = { package = "substrate-inherents", path = "../../../core/inherents", default-features = false } +primitives = { package = "substrate-primitives", path = "../../../core/primitives", default-features = false } + +[features] +default = ["std"] +std = [ + "serde/std", + "parity-codec/std", + "runtime_io/std", + "srml-support/std", + "inherents/std", + "primitives/std", +] diff --git a/substrate/srml/support/test/src/lib.rs b/substrate/srml/support/test/src/lib.rs new file mode 100644 index 0000000000..e69de29bb2 diff --git a/substrate/srml/support/test/tests/instance.rs b/substrate/srml/support/test/tests/instance.rs new file mode 100644 index 0000000000..373e3e23d0 --- /dev/null +++ b/substrate/srml/support/test/tests/instance.rs @@ -0,0 +1,457 @@ +// 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"] + +#[cfg(feature = "std")] +use serde_derive::Serialize; +use runtime_io::{with_externalities, Blake2Hasher}; +use srml_support::rstd::prelude::*; +use srml_support::rstd as rstd; +use srml_support::codec::{Encode, Decode}; +use srml_support::runtime_primitives::{generic, BuildStorage}; +use srml_support::runtime_primitives::traits::{BlakeTwo256, Block as _, Verify, Digest}; +use srml_support::{Parameter, construct_runtime, decl_module, decl_storage, decl_event}; +use inherents::{ + ProvideInherent, InherentData, InherentIdentifier, RuntimeString, MakeFatalError +}; +use srml_support::{StorageValue, StorageMap}; +use primitives::{H256, sr25519}; + +pub trait Currency { +} + +// Mock +mod system { + use super::*; + + pub trait Trait: 'static + Eq + Clone { + type Origin: Into>> + From>; + type BlockNumber; + type Digest: Digest; + type Hash; + type AccountId; + type Event: From; + type Log: From> + Into>; + } + + pub type DigestItemOf = <::Digest as Digest>::Item; + + decl_module! { + pub struct Module for enum Call where origin: T::Origin { + pub fn deposit_event(_event: T::Event) { + } + } + } + impl Module { + pub fn deposit_log(_item: ::Item) { + unimplemented!(); + } + } + + decl_event!( + pub enum Event { + ExtrinsicSuccess, + ExtrinsicFailed, + } + ); + + /// Origin for the system module. + #[derive(PartialEq, Eq, Clone)] + #[cfg_attr(feature = "std", derive(Debug))] + pub enum RawOrigin { + Root, + Signed(AccountId), + Inherent, + } + + impl From> for RawOrigin { + fn from(s: Option) -> RawOrigin { + match s { + Some(who) => RawOrigin::Signed(who), + None => RawOrigin::Inherent, + } + } + } + + pub type Origin = RawOrigin<::AccountId>; + + pub type Log = RawLog< + ::Hash, + >; + + #[cfg_attr(feature = "std", derive(Serialize, Debug))] + #[derive(Encode, Decode, PartialEq, Eq, Clone)] + pub enum RawLog { + ChangesTrieRoot(H), + } + + pub fn ensure_root(o: OuterOrigin) -> Result<(), &'static str> + where OuterOrigin: Into>> + { + match o.into() { + Some(RawOrigin::Root) => Ok(()), + _ => Err("bad origin: expected to be a root origin"), + } + } +} + +// Test for: +// * No default instance +// * Custom InstantiableTrait +// * Origin, Inherent, Log, Event +mod module1 { + use super::*; + + pub trait Trait: system::Trait { + type Event: From> + Into<::Event>; + type Origin: From>; + type Log: From> + Into>; + } + + decl_module! { + pub struct Module, I: InstantiableThing> for enum Call where origin: ::Origin { + fn deposit_event() = default; + + fn one() { + Self::deposit_event(RawEvent::AnotherVariant(3)); + Self::deposit_log(RawLog::AmountChange(3)); + } + } + } + + impl, I: InstantiableThing> Module { + /// Deposit one of this module's logs. + fn deposit_log(log: Log) { + >::deposit_log(>::Log::from(log).into()); + } + } + + decl_storage! { + trait Store for Module, I: InstantiableThing> as Module1 { + pub Value config(value): u64; + pub Map: map u32 => u64; + pub LinkedMap: linked_map u32 => u64; + } + } + + decl_event! { + pub enum Event where Phantom = rstd::marker::PhantomData { + _Phantom(Phantom), + AnotherVariant(u32), + } + } + + #[derive(PartialEq, Eq, Clone)] + #[cfg_attr(feature = "std", derive(Debug))] + pub enum Origin, I> { + Members(u32), + _Phantom(rstd::marker::PhantomData<(T, I)>), + } + + pub type Log = RawLog< + T, + I, + >; + + /// A logs in this module. + #[cfg_attr(feature = "std", derive(serde_derive::Serialize, Debug))] + #[derive(parity_codec::Encode, parity_codec::Decode, PartialEq, Eq, Clone)] + pub enum RawLog { + _Phantom(rstd::marker::PhantomData<(T, I)>), + AmountChange(u32), + } + + pub const INHERENT_IDENTIFIER: InherentIdentifier = *b"12345678"; + + impl, I: InstantiableThing> ProvideInherent for Module { + type Call = Call; + type Error = MakeFatalError; + const INHERENT_IDENTIFIER: InherentIdentifier = INHERENT_IDENTIFIER; + + fn create_inherent(_data: &InherentData) -> Option { + unimplemented!(); + } + + fn check_inherent(_call: &Self::Call, _data: &InherentData) -> rstd::result::Result<(), Self::Error> { + unimplemented!(); + } + } +} + +// Test for: +// * default instance +// * use of no_genesis_config_phantom_data +mod module2 { + use super::*; + + pub trait Trait: system::Trait { + type Amount: Parameter + Default; + type Event: From> + Into<::Event>; + type Origin: From>; + type Log: From> + Into>; + } + + impl, I: Instance> Currency for Module {} + + decl_module! { + pub struct Module, I: Instance=DefaultInstance> for enum Call where origin: ::Origin { + fn deposit_event() = default; + } + } + + decl_storage! { + trait Store for Module, I: Instance=DefaultInstance> as Module2 { + pub Value config(value): T::Amount; + pub Map config(map): map u64 => u64; + pub LinkedMap config(linked_map): linked_map u64 => u64; + } + extra_genesis_skip_phantom_data_field; + } + + decl_event! { + pub enum Event where Amount = >::Amount { + Variant(Amount), + } + } + + #[derive(PartialEq, Eq, Clone)] + #[cfg_attr(feature = "std", derive(Debug))] + pub enum Origin, I=DefaultInstance> { + Members(u32), + _Phantom(rstd::marker::PhantomData<(T, I)>), + } + + pub type Log = RawLog< + T, + I, + >; + + /// A logs in this module. + #[cfg_attr(feature = "std", derive(serde_derive::Serialize, Debug))] + #[derive(parity_codec::Encode, parity_codec::Decode, PartialEq, Eq, Clone)] + pub enum RawLog { + _Phantom(rstd::marker::PhantomData<(T, I)>), + AmountChange(u32), + } + + pub const INHERENT_IDENTIFIER: InherentIdentifier = *b"12345678"; + + impl, I: Instance> ProvideInherent for Module { + type Call = Call; + type Error = MakeFatalError; + const INHERENT_IDENTIFIER: InherentIdentifier = INHERENT_IDENTIFIER; + + fn create_inherent(_data: &InherentData) -> Option { + unimplemented!(); + } + + fn check_inherent(_call: &Self::Call, _data: &InherentData) -> rstd::result::Result<(), Self::Error> { + unimplemented!(); + } + } +} + +// Test for: +// * Depends on multiple instances of a module with instances +mod module3 { + use super::*; + + pub trait Trait: module2::Trait + module2::Trait + system::Trait { + type Currency: Currency; + type Currency2: Currency; + } + + decl_module! { + pub struct Module for enum Call where origin: ::Origin { + } + } +} + +impl module1::Trait for Runtime { + type Event = Event; + type Origin = Origin; + type Log = Log; +} +impl module1::Trait for Runtime { + type Event = Event; + type Origin = Origin; + type Log = Log; +} +impl module2::Trait for Runtime { + type Amount = u16; + type Event = Event; + type Origin = Origin; + type Log = Log; +} +impl module2::Trait for Runtime { + type Amount = u32; + type Event = Event; + type Origin = Origin; + type Log = Log; +} +impl module2::Trait for Runtime { + type Amount = u32; + type Event = Event; + type Origin = Origin; + type Log = Log; +} +impl module2::Trait for Runtime { + type Amount = u64; + type Event = Event; + type Origin = Origin; + type Log = Log; +} +impl module3::Trait for Runtime { + type Currency = Module2_2; + type Currency2 = Module2_3; +} + +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 Digest = generic::Digest; + type AccountId = AccountId; + type Event = Event; + type Log = Log; +} + +construct_runtime!( + pub enum Runtime with Log(InternalLog: DigestItem) where + Block = Block, + NodeBlock = Block, + UncheckedExtrinsic = UncheckedExtrinsic + { + System: system::{Module, Call, Event, Log(ChangesTrieRoot)}, + Module1_1: module1::::{Module, Call, Storage, Event, Config, Origin, Log(), Inherent}, + Module1_2: module1::::{Module, Call, Storage, Event, Config, Origin, Log(), Inherent}, + Module2: module2::{Module, Call, Storage, Event, Config, Origin, Log(), Inherent}, + Module2_1: module2::::{Module, Call, Storage, Event, Config, Origin, Log(), Inherent}, + Module2_2: module2::::{Module, Call, Storage, Event, Config, Origin, Log(), Inherent}, + Module2_3: module2::::{Module, Call, Storage, Event, Config, Origin, Log(), Inherent}, + Module3: module3::{Module, Call}, + } +); + +pub type Header = generic::Header; +pub type Block = generic::Block; +pub type UncheckedExtrinsic = generic::UncheckedMortalCompactExtrinsic; + +fn new_test_ext() -> runtime_io::TestExternalities { + GenesisConfig{ + module1_Instance1: Some(module1::GenesisConfig { + value: 3, + .. Default::default() + }), + module1_Instance2: Some(module1::GenesisConfig { + value: 4, + _genesis_phantom_data: Default::default(), + }), + module2: Some(module2::GenesisConfig { + value: 4, + map: vec![], + linked_map: vec![], + }), + module2_Instance1: None, + module2_Instance2: None, + module2_Instance3: None, + }.build_storage().unwrap().0.into() +} + +#[test] +fn storage_instance_independance() { + with_externalities(&mut new_test_ext(), || { + let mut map = rstd::collections::btree_map::BTreeMap::new(); + for key in &[ + module2::Value::::key().to_vec(), + module2::Value::::key().to_vec(), + module2::Value::::key().to_vec(), + module2::Value::::key().to_vec(), + module2::Map::::prefix().to_vec(), + module2::Map::::prefix().to_vec(), + module2::Map::::prefix().to_vec(), + module2::Map::::prefix().to_vec(), + module2::LinkedMap::::prefix().to_vec(), + module2::LinkedMap::::prefix().to_vec(), + module2::LinkedMap::::prefix().to_vec(), + module2::LinkedMap::::prefix().to_vec(), + module2::Map::::key_for(0), + module2::Map::::key_for(0).to_vec(), + module2::Map::::key_for(0).to_vec(), + module2::Map::::key_for(0).to_vec(), + module2::LinkedMap::::key_for(0), + module2::LinkedMap::::key_for(0).to_vec(), + module2::LinkedMap::::key_for(0).to_vec(), + module2::LinkedMap::::key_for(0).to_vec(), + module2::Map::::key_for(1), + module2::Map::::key_for(1).to_vec(), + module2::Map::::key_for(1).to_vec(), + module2::Map::::key_for(1).to_vec(), + module2::LinkedMap::::key_for(1), + module2::LinkedMap::::key_for(1).to_vec(), + module2::LinkedMap::::key_for(1).to_vec(), + module2::LinkedMap::::key_for(1).to_vec(), + ] { + assert!(map.insert(key, ()).is_none()) + } + }); +} + +#[test] +fn storage_with_instance_basic_operation() { + with_externalities(&mut new_test_ext(), || { + type Value = module2::Value; + type Map = module2::Map; + type LinkedMap = module2::LinkedMap; + + assert_eq!(Value::exists(), false); + Value::put(1); + assert_eq!(Value::get(), 1); + assert_eq!(Value::take(), 1); + assert_eq!(Value::get(), 0); + Value::mutate(|a| *a=2); + assert_eq!(Value::get(), 2); + Value::kill(); + assert_eq!(Value::get(), 0); + + let key = 1; + assert_eq!(Map::exists(1), false); + Map::insert(key, 1); + assert_eq!(Map::get(key), 1); + assert_eq!(Map::take(key), 1); + assert_eq!(Map::get(key), 0); + Map::mutate(key, |a| *a=2); + assert_eq!(Map::get(key), 2); + Map::remove(key); + assert_eq!(Map::get(key), 0); + + assert_eq!(LinkedMap::exists(1), false); + LinkedMap::insert(key, 1); + assert_eq!(LinkedMap::get(key), 1); + assert_eq!(LinkedMap::take(key), 1); + assert_eq!(LinkedMap::get(key), 0); + LinkedMap::mutate(key, |a| *a=2); + assert_eq!(LinkedMap::get(key), 2); + LinkedMap::remove(key); + assert_eq!(LinkedMap::get(key), 0); + }); +} diff --git a/substrate/srml/system/Cargo.toml b/substrate/srml/system/Cargo.toml index ea2628a3a2..bd199b97f9 100644 --- a/substrate/srml/system/Cargo.toml +++ b/substrate/srml/system/Cargo.toml @@ -9,7 +9,7 @@ hex-literal = "0.1.0" serde = { version = "1.0", optional = true } serde_derive = { version = "1.0", optional = true } safe-mix = { version = "1.0", default-features = false} -parity-codec = { version = "3.1", default-features = false, features = ["derive"] } +parity-codec = { version = "3.2", default-features = false, features = ["derive"] } substrate-primitives = { path = "../../core/primitives", default-features = false } rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false } runtime_io = { package = "sr-io", path = "../../core/sr-io", default-features = false } diff --git a/substrate/srml/timestamp/Cargo.toml b/substrate/srml/timestamp/Cargo.toml index 0c089b60e6..413c487214 100644 --- a/substrate/srml/timestamp/Cargo.toml +++ b/substrate/srml/timestamp/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] hex-literal = "0.1.0" serde = { version = "1.0", optional = true } -parity-codec = { version = "3.1", default-features = false, features = ["derive"] } +parity-codec = { version = "3.2", default-features = false, features = ["derive"] } rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false } runtime_primitives = { package = "sr-primitives", path = "../../core/sr-primitives", default-features = false } inherents = { package = "substrate-inherents", path = "../../core/inherents", default-features = false } diff --git a/substrate/srml/treasury/Cargo.toml b/substrate/srml/treasury/Cargo.toml index 9bfb4b1725..825fc73532 100644 --- a/substrate/srml/treasury/Cargo.toml +++ b/substrate/srml/treasury/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" hex-literal = "0.1.0" serde = { version = "1.0", optional = true } serde_derive = { version = "1.0", optional = true } -parity-codec = { version = "3.1", default-features = false, features = ["derive"] } +parity-codec = { version = "3.2", default-features = false, features = ["derive"] } rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false } runtime_primitives = { package = "sr-primitives", path = "../../core/sr-primitives", default-features = false } srml-support = { path = "../support", default-features = false } diff --git a/substrate/srml/treasury/src/lib.rs b/substrate/srml/treasury/src/lib.rs index aa0eec6479..f571420593 100644 --- a/substrate/srml/treasury/src/lib.rs +++ b/substrate/srml/treasury/src/lib.rs @@ -36,7 +36,7 @@ type BalanceOf = <::Currency as ArithmeticType>::Type; /// `system::Trait` should always be included in our implied traits. pub trait Trait: system::Trait { /// The staking balance. - type Currency: ArithmeticType + Currency>; + type Currency: ArithmeticType + Currency::Currency as ArithmeticType>::Type>; /// Origin from which approvals must come. type ApproveOrigin: EnsureOrigin; diff --git a/substrate/srml/upgrade-key/Cargo.toml b/substrate/srml/upgrade-key/Cargo.toml index c548798dec..4bdbd6404c 100644 --- a/substrate/srml/upgrade-key/Cargo.toml +++ b/substrate/srml/upgrade-key/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" [dependencies] serde = { version = "1.0", optional = true } -parity-codec = { version = "3.1", default-features = false } +parity-codec = { version = "3.2", default-features = false } sr-std = { path = "../../core/sr-std", default-features = false } sr-primitives = { path = "../../core/sr-primitives", default-features = false } srml-support = { path = "../support", default-features = false }