diff --git a/Cargo.lock b/Cargo.lock index 349676f92..03036b1b5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -123,9 +123,9 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.56" +version = "0.1.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96cf8829f67d2eab0b2dfa42c5d0ef737e0724e4a82b01b3e292456202b19716" +checksum = "76464446b8bc32758d7e88ee1a804d9914cd9b1cb264c029899680b0be29826f" dependencies = [ "proc-macro2", "quote", @@ -182,6 +182,12 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" +[[package]] +name = "base64ct" +version = "1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea2b2456fd614d856680dcd9fcc660a51a820fa09daef2e49772b56a193c8474" + [[package]] name = "beef" version = "0.5.2" @@ -314,6 +320,15 @@ version = "1.0.73" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" +[[package]] +name = "cfg-expr" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0aacacf4d96c24b2ad6eb8ee6df040e4f27b0d0b39a5710c30091baa830485db" +dependencies = [ + "smallvec", +] + [[package]] name = "cfg-if" version = "1.0.0" @@ -744,7 +759,7 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "frame-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#28f0cb18c96fb82f810f1d9be69fb609fbb7217e" +source = "git+https://github.com/paritytech/substrate?branch=master#7202ca616799a1d78e37ae8ec0093f16c49417c6" dependencies = [ "frame-support", "frame-system", @@ -767,7 +782,7 @@ dependencies = [ [[package]] name = "frame-election-provider-solution-type" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#28f0cb18c96fb82f810f1d9be69fb609fbb7217e" +source = "git+https://github.com/paritytech/substrate?branch=master#7202ca616799a1d78e37ae8ec0093f16c49417c6" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -778,7 +793,7 @@ dependencies = [ [[package]] name = "frame-election-provider-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#28f0cb18c96fb82f810f1d9be69fb609fbb7217e" +source = "git+https://github.com/paritytech/substrate?branch=master#7202ca616799a1d78e37ae8ec0093f16c49417c6" dependencies = [ "frame-election-provider-solution-type", "frame-support", @@ -806,7 +821,7 @@ dependencies = [ [[package]] name = "frame-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#28f0cb18c96fb82f810f1d9be69fb609fbb7217e" +source = "git+https://github.com/paritytech/substrate?branch=master#7202ca616799a1d78e37ae8ec0093f16c49417c6" dependencies = [ "bitflags", "frame-metadata", @@ -831,16 +846,19 @@ dependencies = [ "sp-state-machine 0.12.0 (git+https://github.com/paritytech/substrate?branch=master)", "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=master)", "sp-tracing 5.0.0 (git+https://github.com/paritytech/substrate?branch=master)", + "sp-weights", "tt-call", ] [[package]] name = "frame-support-procedural" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#28f0cb18c96fb82f810f1d9be69fb609fbb7217e" +source = "git+https://github.com/paritytech/substrate?branch=master#7202ca616799a1d78e37ae8ec0093f16c49417c6" dependencies = [ "Inflector", + "cfg-expr", "frame-support-procedural-tools", + "itertools", "proc-macro2", "quote", "syn", @@ -849,7 +867,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#28f0cb18c96fb82f810f1d9be69fb609fbb7217e" +source = "git+https://github.com/paritytech/substrate?branch=master#7202ca616799a1d78e37ae8ec0093f16c49417c6" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate", @@ -861,7 +879,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#28f0cb18c96fb82f810f1d9be69fb609fbb7217e" +source = "git+https://github.com/paritytech/substrate?branch=master#7202ca616799a1d78e37ae8ec0093f16c49417c6" dependencies = [ "proc-macro2", "quote", @@ -871,7 +889,7 @@ dependencies = [ [[package]] name = "frame-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#28f0cb18c96fb82f810f1d9be69fb609fbb7217e" +source = "git+https://github.com/paritytech/substrate?branch=master#7202ca616799a1d78e37ae8ec0093f16c49417c6" dependencies = [ "frame-support", "log", @@ -883,6 +901,7 @@ dependencies = [ "sp-runtime 6.0.0 (git+https://github.com/paritytech/substrate?branch=master)", "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=master)", "sp-version", + "sp-weights", ] [[package]] @@ -1552,6 +1571,12 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71d96e3f3c0b6325d8ccd83c33b28acb183edcb6c67938ba104ec546854b0882" +[[package]] +name = "memory_units" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3" + [[package]] name = "merlin" version = "2.0.1" @@ -1637,6 +1662,17 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-bigint" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + [[package]] name = "num-complex" version = "0.4.2" @@ -1673,7 +1709,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c000134b5dbf44adc5cb772486d335293351644b801551abe8f75c84cfa4aef" dependencies = [ "autocfg", - "num-bigint", + "num-bigint 0.2.6", "num-integer", "num-traits", ] @@ -1685,6 +1721,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" dependencies = [ "autocfg", + "num-bigint 0.4.3", "num-integer", "num-traits", ] @@ -1751,13 +1788,14 @@ checksum = "21326818e99cfe6ce1e524c2a805c189a99b5ae555a35d19f9a284b427d86afa" [[package]] name = "pallet-election-provider-multi-phase" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#28f0cb18c96fb82f810f1d9be69fb609fbb7217e" +source = "git+https://github.com/paritytech/substrate?branch=master#7202ca616799a1d78e37ae8ec0093f16c49417c6" dependencies = [ "frame-benchmarking", "frame-election-provider-support", "frame-support", "frame-system", "log", + "pallet-election-provider-support-benchmarking", "parity-scale-codec", "rand 0.7.3", "scale-info", @@ -1771,10 +1809,23 @@ dependencies = [ "strum", ] +[[package]] +name = "pallet-election-provider-support-benchmarking" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=master#7202ca616799a1d78e37ae8ec0093f16c49417c6" +dependencies = [ + "frame-benchmarking", + "frame-election-provider-support", + "frame-system", + "parity-scale-codec", + "sp-npos-elections", + "sp-runtime 6.0.0 (git+https://github.com/paritytech/substrate?branch=master)", +] + [[package]] name = "pallet-transaction-payment" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#28f0cb18c96fb82f810f1d9be69fb609fbb7217e" +source = "git+https://github.com/paritytech/substrate?branch=master#7202ca616799a1d78e37ae8ec0093f16c49417c6" dependencies = [ "frame-support", "frame-system", @@ -1789,9 +1840,9 @@ dependencies = [ [[package]] name = "parity-scale-codec" -version = "3.1.5" +version = "3.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9182e4a71cae089267ab03e67c99368db7cd877baf50f931e5d6d4b71e195ac0" +checksum = "366e44391a8af4cfd6002ef6ba072bae071a96aafca98d7d448a34c5dca38b6a" dependencies = [ "arrayvec 0.7.2", "bitvec", @@ -1846,6 +1897,12 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be5e13c266502aadf83426d87d81a0f5d1ef45b8027f5a471c360abfe4bfae92" +[[package]] +name = "parity-wasm" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1ad0aff30c1da14b1254fcb2af73e1fa9a28670e584a626f53a369d0e157304" + [[package]] name = "parking_lot" version = "0.12.1" @@ -1925,6 +1982,17 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "pkcs8" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cabda3fb821068a9a4fab19a683eac3af12edf0f34b94a8be53c4972b8149d0" +dependencies = [ + "der", + "spki", + "zeroize", +] + [[package]] name = "ppv-lite86" version = "0.2.16" @@ -2292,13 +2360,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3f6f92acf49d1b98f7a81226834412ada05458b7364277387724a237f062695" [[package]] -name = "scale-decode" +name = "scale-bits" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c70dece385bc3e5918109830d9509806b5d4525fdf594e3463078c529122979e" +checksum = "8dd7aca73785181cc41f0bbe017263e682b585ca660540ba569133901d013ecf" +dependencies = [ + "parity-scale-codec", + "scale-info", + "serde", +] + +[[package]] +name = "scale-decode" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d823d4be477fc33321f93d08fb6c2698273d044f01362dc27573a750deb7c233" dependencies = [ - "bitvec", "parity-scale-codec", + "scale-bits", "scale-info", "thiserror", ] @@ -2331,14 +2410,14 @@ dependencies = [ [[package]] name = "scale-value" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eae8b296b3ebcb3425661e9b612ccc34cb1064483a61dc379c65e6b1463498f1" +checksum = "16a5e7810815bd295da73e4216d1dfbced3c7c7c7054d70fa5f6e4c58123fff4" dependencies = [ - "bitvec", "either", "frame-metadata", "parity-scale-codec", + "scale-bits", "scale-decode", "scale-info", "serde", @@ -2398,6 +2477,7 @@ checksum = "08da66b8b0965a5555b6bd6639e68ccba85e1e2506f5fbb089e93f8a04e1a2d1" dependencies = [ "der", "generic-array 0.14.5", + "pkcs8", "subtle", "zeroize", ] @@ -2640,7 +2720,7 @@ dependencies = [ [[package]] name = "sp-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#28f0cb18c96fb82f810f1d9be69fb609fbb7217e" +source = "git+https://github.com/paritytech/substrate?branch=master#7202ca616799a1d78e37ae8ec0093f16c49417c6" dependencies = [ "hash-db", "log", @@ -2658,7 +2738,7 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#28f0cb18c96fb82f810f1d9be69fb609fbb7217e" +source = "git+https://github.com/paritytech/substrate?branch=master#7202ca616799a1d78e37ae8ec0093f16c49417c6" dependencies = [ "blake2", "proc-macro-crate", @@ -2684,7 +2764,7 @@ dependencies = [ [[package]] name = "sp-application-crypto" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#28f0cb18c96fb82f810f1d9be69fb609fbb7217e" +source = "git+https://github.com/paritytech/substrate?branch=master#7202ca616799a1d78e37ae8ec0093f16c49417c6" dependencies = [ "parity-scale-codec", "scale-info", @@ -2713,7 +2793,7 @@ dependencies = [ [[package]] name = "sp-arithmetic" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#28f0cb18c96fb82f810f1d9be69fb609fbb7217e" +source = "git+https://github.com/paritytech/substrate?branch=master#7202ca616799a1d78e37ae8ec0093f16c49417c6" dependencies = [ "integer-sqrt", "num-traits", @@ -2768,18 +2848,18 @@ dependencies = [ "substrate-bip39", "thiserror", "tiny-bip39", - "wasmi", + "wasmi 0.9.1", "zeroize", ] [[package]] name = "sp-core" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#28f0cb18c96fb82f810f1d9be69fb609fbb7217e" +source = "git+https://github.com/paritytech/substrate?branch=master#7202ca616799a1d78e37ae8ec0093f16c49417c6" dependencies = [ "base58", "bitflags", - "blake2-rfc", + "blake2", "byteorder", "dyn-clonable", "ed25519-zebra", @@ -2814,7 +2894,7 @@ dependencies = [ "substrate-bip39", "thiserror", "tiny-bip39", - "wasmi", + "wasmi 0.13.0", "zeroize", ] @@ -2835,7 +2915,7 @@ dependencies = [ [[package]] name = "sp-core-hashing" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#28f0cb18c96fb82f810f1d9be69fb609fbb7217e" +source = "git+https://github.com/paritytech/substrate?branch=master#7202ca616799a1d78e37ae8ec0093f16c49417c6" dependencies = [ "blake2", "byteorder", @@ -2849,7 +2929,7 @@ dependencies = [ [[package]] name = "sp-core-hashing-proc-macro" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#28f0cb18c96fb82f810f1d9be69fb609fbb7217e" +source = "git+https://github.com/paritytech/substrate?branch=master#7202ca616799a1d78e37ae8ec0093f16c49417c6" dependencies = [ "proc-macro2", "quote", @@ -2871,7 +2951,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#28f0cb18c96fb82f810f1d9be69fb609fbb7217e" +source = "git+https://github.com/paritytech/substrate?branch=master#7202ca616799a1d78e37ae8ec0093f16c49417c6" dependencies = [ "proc-macro2", "quote", @@ -2893,7 +2973,7 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.12.0" -source = "git+https://github.com/paritytech/substrate?branch=master#28f0cb18c96fb82f810f1d9be69fb609fbb7217e" +source = "git+https://github.com/paritytech/substrate?branch=master#7202ca616799a1d78e37ae8ec0093f16c49417c6" dependencies = [ "environmental", "parity-scale-codec", @@ -2904,7 +2984,7 @@ dependencies = [ [[package]] name = "sp-inherents" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#28f0cb18c96fb82f810f1d9be69fb609fbb7217e" +source = "git+https://github.com/paritytech/substrate?branch=master#7202ca616799a1d78e37ae8ec0093f16c49417c6" dependencies = [ "async-trait", "impl-trait-for-tuples", @@ -2944,7 +3024,7 @@ dependencies = [ [[package]] name = "sp-io" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#28f0cb18c96fb82f810f1d9be69fb609fbb7217e" +source = "git+https://github.com/paritytech/substrate?branch=master#7202ca616799a1d78e37ae8ec0093f16c49417c6" dependencies = [ "bytes", "futures", @@ -2987,7 +3067,7 @@ dependencies = [ [[package]] name = "sp-keystore" version = "0.12.0" -source = "git+https://github.com/paritytech/substrate?branch=master#28f0cb18c96fb82f810f1d9be69fb609fbb7217e" +source = "git+https://github.com/paritytech/substrate?branch=master#7202ca616799a1d78e37ae8ec0093f16c49417c6" dependencies = [ "async-trait", "futures", @@ -3003,7 +3083,7 @@ dependencies = [ [[package]] name = "sp-npos-elections" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#28f0cb18c96fb82f810f1d9be69fb609fbb7217e" +source = "git+https://github.com/paritytech/substrate?branch=master#7202ca616799a1d78e37ae8ec0093f16c49417c6" dependencies = [ "parity-scale-codec", "scale-info", @@ -3028,7 +3108,7 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#28f0cb18c96fb82f810f1d9be69fb609fbb7217e" +source = "git+https://github.com/paritytech/substrate?branch=master#7202ca616799a1d78e37ae8ec0093f16c49417c6" dependencies = [ "backtrace", "lazy_static", @@ -3061,7 +3141,7 @@ dependencies = [ [[package]] name = "sp-runtime" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#28f0cb18c96fb82f810f1d9be69fb609fbb7217e" +source = "git+https://github.com/paritytech/substrate?branch=master#7202ca616799a1d78e37ae8ec0093f16c49417c6" dependencies = [ "either", "hash256-std-hasher", @@ -3078,6 +3158,7 @@ dependencies = [ "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=master)", "sp-io 6.0.0 (git+https://github.com/paritytech/substrate?branch=master)", "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=master)", + "sp-weights", ] [[package]] @@ -3101,7 +3182,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#28f0cb18c96fb82f810f1d9be69fb609fbb7217e" +source = "git+https://github.com/paritytech/substrate?branch=master#7202ca616799a1d78e37ae8ec0093f16c49417c6" dependencies = [ "bytes", "impl-trait-for-tuples", @@ -3132,7 +3213,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#28f0cb18c96fb82f810f1d9be69fb609fbb7217e" +source = "git+https://github.com/paritytech/substrate?branch=master#7202ca616799a1d78e37ae8ec0093f16c49417c6" dependencies = [ "Inflector", "proc-macro-crate", @@ -3144,7 +3225,7 @@ dependencies = [ [[package]] name = "sp-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#28f0cb18c96fb82f810f1d9be69fb609fbb7217e" +source = "git+https://github.com/paritytech/substrate?branch=master#7202ca616799a1d78e37ae8ec0093f16c49417c6" dependencies = [ "parity-scale-codec", "scale-info", @@ -3179,7 +3260,7 @@ dependencies = [ [[package]] name = "sp-state-machine" version = "0.12.0" -source = "git+https://github.com/paritytech/substrate?branch=master#28f0cb18c96fb82f810f1d9be69fb609fbb7217e" +source = "git+https://github.com/paritytech/substrate?branch=master#7202ca616799a1d78e37ae8ec0093f16c49417c6" dependencies = [ "hash-db", "log", @@ -3207,7 +3288,7 @@ checksum = "14804d6069ee7a388240b665f17908d98386ffb0b5d39f89a4099fc7a2a4c03f" [[package]] name = "sp-std" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#28f0cb18c96fb82f810f1d9be69fb609fbb7217e" +source = "git+https://github.com/paritytech/substrate?branch=master#7202ca616799a1d78e37ae8ec0093f16c49417c6" [[package]] name = "sp-storage" @@ -3226,7 +3307,7 @@ dependencies = [ [[package]] name = "sp-storage" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#28f0cb18c96fb82f810f1d9be69fb609fbb7217e" +source = "git+https://github.com/paritytech/substrate?branch=master#7202ca616799a1d78e37ae8ec0093f16c49417c6" dependencies = [ "impl-serde", "parity-scale-codec", @@ -3252,7 +3333,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#28f0cb18c96fb82f810f1d9be69fb609fbb7217e" +source = "git+https://github.com/paritytech/substrate?branch=master#7202ca616799a1d78e37ae8ec0093f16c49417c6" dependencies = [ "parity-scale-codec", "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=master)", @@ -3280,7 +3361,7 @@ dependencies = [ [[package]] name = "sp-trie" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#28f0cb18c96fb82f810f1d9be69fb609fbb7217e" +source = "git+https://github.com/paritytech/substrate?branch=master#7202ca616799a1d78e37ae8ec0093f16c49417c6" dependencies = [ "ahash", "hash-db", @@ -3303,11 +3384,11 @@ dependencies = [ [[package]] name = "sp-version" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#28f0cb18c96fb82f810f1d9be69fb609fbb7217e" +source = "git+https://github.com/paritytech/substrate?branch=master#7202ca616799a1d78e37ae8ec0093f16c49417c6" dependencies = [ "impl-serde", "parity-scale-codec", - "parity-wasm", + "parity-wasm 0.45.0", "scale-info", "serde", "sp-core-hashing-proc-macro", @@ -3320,7 +3401,7 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=master#28f0cb18c96fb82f810f1d9be69fb609fbb7217e" +source = "git+https://github.com/paritytech/substrate?branch=master#7202ca616799a1d78e37ae8ec0093f16c49417c6" dependencies = [ "parity-scale-codec", "proc-macro2", @@ -3338,19 +3419,35 @@ dependencies = [ "log", "parity-scale-codec", "sp-std 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "wasmi", + "wasmi 0.9.1", ] [[package]] name = "sp-wasm-interface" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=master#28f0cb18c96fb82f810f1d9be69fb609fbb7217e" +source = "git+https://github.com/paritytech/substrate?branch=master#7202ca616799a1d78e37ae8ec0093f16c49417c6" dependencies = [ "impl-trait-for-tuples", "log", "parity-scale-codec", "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=master)", - "wasmi", + "wasmi 0.13.0", +] + +[[package]] +name = "sp-weights" +version = "4.0.0" +source = "git+https://github.com/paritytech/substrate?branch=master#7202ca616799a1d78e37ae8ec0093f16c49417c6" +dependencies = [ + "impl-trait-for-tuples", + "parity-scale-codec", + "scale-info", + "serde", + "smallvec", + "sp-arithmetic 5.0.0 (git+https://github.com/paritytech/substrate?branch=master)", + "sp-core 6.0.0 (git+https://github.com/paritytech/substrate?branch=master)", + "sp-debug-derive 4.0.0 (git+https://github.com/paritytech/substrate?branch=master)", + "sp-std 4.0.0 (git+https://github.com/paritytech/substrate?branch=master)", ] [[package]] @@ -3359,11 +3456,21 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" +[[package]] +name = "spki" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d01ac02a6ccf3e07db148d2be087da624fea0221a16152ed01f0496a6b0a27" +dependencies = [ + "base64ct", + "der", +] + [[package]] name = "ss58-registry" -version = "1.23.0" +version = "1.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ef98aedad3dc52e10995e7ed15f1279e11d4da35795f5dac7305742d0feb66" +checksum = "b0837b5d62f42082c9d56cd946495ae273a3c68083b637b9153341d5e465146d" dependencies = [ "Inflector", "num-format", @@ -3395,6 +3502,7 @@ dependencies = [ "pin-project-lite", "prometheus", "scale-info", + "scale-value", "serde", "serde_json", "sp-io 6.0.0 (git+https://github.com/paritytech/substrate?branch=master)", @@ -3476,8 +3584,9 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "subxt" -version = "0.23.0" -source = "git+https://github.com/paritytech/subxt#a71223ab4a902c38b7785f42dbf2a2457f960dc8" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a8757ee0e19f87e722577282ab1386c86592a4b13ff963b9c6ec4176348104c" dependencies = [ "bitvec", "derivative", @@ -3502,8 +3611,9 @@ dependencies = [ [[package]] name = "subxt-codegen" -version = "0.23.0" -source = "git+https://github.com/paritytech/subxt#a71223ab4a902c38b7785f42dbf2a2457f960dc8" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb77f93e11e6ff3ff95fe33e3d24c27c342e16feca8ef47759993614ebe90d2c" dependencies = [ "darling", "frame-metadata", @@ -3519,8 +3629,9 @@ dependencies = [ [[package]] name = "subxt-macro" -version = "0.23.0" -source = "git+https://github.com/paritytech/subxt#a71223ab4a902c38b7785f42dbf2a2457f960dc8" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "051cc21d77a54ae944b872eafdf9edfe1d9134fdfcfc3477dc10f763c76564a9" dependencies = [ "darling", "proc-macro-error", @@ -3530,8 +3641,9 @@ dependencies = [ [[package]] name = "subxt-metadata" -version = "0.23.0" -source = "git+https://github.com/paritytech/subxt#a71223ab4a902c38b7785f42dbf2a2457f960dc8" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ed78d80db3a97d55e8b1cfecc1f6f9e21793a589d4e2e5f4fe2d6d5850c2e54" dependencies = [ "frame-metadata", "parity-scale-codec", @@ -4045,11 +4157,22 @@ checksum = "ca00c5147c319a8ec91ec1a0edbec31e566ce2c9cc93b3f9bb86a9efd0eb795d" dependencies = [ "downcast-rs", "libc", - "memory_units", + "memory_units 0.3.0", "num-rational 0.2.4", "num-traits", - "parity-wasm", - "wasmi-validation", + "parity-wasm 0.42.2", + "wasmi-validation 0.4.1", +] + +[[package]] +name = "wasmi" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc13b3c219ca9aafeec59150d80d89851df02e0061bc357b4d66fc55a8d38787" +dependencies = [ + "parity-wasm 0.45.0", + "wasmi-validation 0.5.0", + "wasmi_core", ] [[package]] @@ -4058,7 +4181,29 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "165343ecd6c018fc09ebcae280752702c9a2ef3e6f8d02f1cfcbdb53ef6d7937" dependencies = [ - "parity-wasm", + "parity-wasm 0.42.2", +] + +[[package]] +name = "wasmi-validation" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ff416ad1ff0c42e5a926ed5d5fab74c0f098749aa0ad8b2a34b982ce0e867b" +dependencies = [ + "parity-wasm 0.45.0", +] + +[[package]] +name = "wasmi_core" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0a088e8c4c59c6f2b9eae169bf86328adccc477c00b56d3661e3e9fb397b184" +dependencies = [ + "downcast-rs", + "libm", + "memory_units 0.4.0", + "num-rational 0.4.1", + "num-traits", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index e0f4b5eb0..72fee53fa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,8 @@ tokio = { version = "1.21", features = ["macros", "rt-multi-thread", "sync", "si pin-project-lite = "0.2" # subxt -subxt = { git = "https://github.com/paritytech/subxt" } +subxt = "0.24.0" +scale-value = "0.6.0" # substrate sp-io = { git = "https://github.com/paritytech/substrate", branch = "master" } diff --git a/src/chain.rs b/src/chain.rs index 99233a622..d43016152 100644 --- a/src/chain.rs +++ b/src/chain.rs @@ -6,113 +6,16 @@ // polkadot, that only has `const` and `type`s that are used in the runtime, and we can import // that. +use crate::{prelude::*, static_types}; use codec::{Decode, Encode}; -use jsonrpsee::{core::client::ClientT, rpc_params}; +use frame_support::{traits::ConstU32, weights::Weight, BoundedVec}; use once_cell::sync::OnceCell; use pallet_transaction_payment::RuntimeDispatchInfo; use sp_core::Bytes; +use subxt::rpc::rpc_params; pub static SHARED_CLIENT: OnceCell = OnceCell::new(); -macro_rules! impl_atomic_u32_parameter_types { - ($mod:ident, $name:ident) => { - mod $mod { - use std::sync::atomic::{AtomicU32, Ordering}; - - static VAL: AtomicU32 = AtomicU32::new(0); - - pub struct $name; - impl $name { - pub fn get() -> u32 { - VAL.load(Ordering::SeqCst) - } - } - - impl> frame_support::traits::Get for $name { - fn get() -> I { - I::from(Self::get()) - } - } - - impl $name { - pub fn set(val: u32) { - VAL.store(val, std::sync::atomic::Ordering::SeqCst); - } - } - } - - pub use $mod::$name; - }; -} - -mod max_weight { - use std::sync::atomic::{AtomicU64, Ordering}; - - static VAL: AtomicU64 = AtomicU64::new(0); - - pub struct MaxWeight; - - impl MaxWeight { - pub fn get() -> u64 { - VAL.load(Ordering::SeqCst) - } - } - - impl> frame_support::traits::Get for MaxWeight { - fn get() -> I { - I::from(Self::get()) - } - } - - impl MaxWeight { - pub fn set(val: u64) { - VAL.store(val, std::sync::atomic::Ordering::SeqCst); - } - } -} - -mod db_weight { - use frame_support::weights::RuntimeDbWeight; - use std::sync::atomic::{AtomicU64, Ordering}; - - static READ: AtomicU64 = AtomicU64::new(0); - static WRITE: AtomicU64 = AtomicU64::new(0); - - pub struct DbWeight; - - impl DbWeight { - pub fn get() -> RuntimeDbWeight { - RuntimeDbWeight { - read: READ.load(Ordering::SeqCst), - write: WRITE.load(Ordering::SeqCst), - } - } - - pub fn set(weight: RuntimeDbWeight) { - READ.store(weight.read, Ordering::SeqCst); - WRITE.store(weight.write, Ordering::SeqCst) - } - } - - impl> frame_support::traits::Get for DbWeight { - fn get() -> I { - I::from(Self::get()) - } - } -} - -use crate::prelude::*; -use frame_support::{traits::ConstU32, weights::Weight, BoundedVec}; - -pub mod static_types { - use super::*; - - impl_atomic_u32_parameter_types!(max_length, MaxLength); - impl_atomic_u32_parameter_types!(max_votes_per_voter, MaxVotesPerVoter); - pub use db_weight::DbWeight; - pub use max_weight::MaxWeight; -} - #[cfg(feature = "westend")] pub mod westend { use super::*; @@ -437,7 +340,6 @@ fn get_weight(tx: subxt::tx::StaticTxPayload) -> Weight { let bytes: Bytes = client .rpc() - .client .request( "state_call", rpc_params!["TransactionPaymentCallApi_query_call_info", call_data], diff --git a/src/error.rs b/src/error.rs index 28c39b52b..ae61c71d5 100644 --- a/src/error.rs +++ b/src/error.rs @@ -8,8 +8,6 @@ pub enum Error { RpcError(#[from] jsonrpsee::core::Error), #[error("subxt error: `{0}`")] Subxt(#[from] subxt::Error), - #[error("Codec error: `{0}`")] - Codec(#[from] codec::Error), #[error("Crypto error: `{0:?}`")] Crypto(sp_core::crypto::SecretStringError), #[error("Incorrect phase")] @@ -20,6 +18,14 @@ pub enum Error { AccountDoesNotExists, #[error("Submission with better score already exist")] BetterScoreExist, + #[error("Invalid chain: `{0}`, staking-miner supports only polkadot, kusama and westend")] + InvalidChain(String), #[error("Other error: `{0}`")] Other(String), + #[error("Invalid metadata: {0}")] + InvalidMetadata(String), + #[error("Transaction rejected: {0}")] + TransactionRejected(String), + #[error("Subscription closed")] + SubscriptionClosed, } diff --git a/src/helpers.rs b/src/helpers.rs index ce17eca8c..71b93beae 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -1,6 +1,6 @@ -use crate::{chain, opt::Solver, prelude::*}; +use crate::{chain, opt::Solver, prelude::*, static_types}; use frame_election_provider_support::{PhragMMS, SequentialPhragmen}; -use frame_support::BoundedVec; +use frame_support::{weights::Weight, BoundedVec}; use pallet_election_provider_multi_phase::{SolutionOf, SolutionOrSnapshotSize}; use pin_project_lite::pin_project; use sp_npos_elections::ElectionScore; @@ -89,7 +89,7 @@ macro_rules! helpers_for_runtime { pub async fn [](api: &SubxtClient, hash: Option) -> Result { use crate::chain::[<$runtime>]::{epm::RoundSnapshot, runtime}; - use crate::chain::static_types; + use crate::static_types; let RoundSnapshot { voters, targets } = api .storage().fetch(&runtime::storage().election_provider_multi_phase().snapshot(), hash) @@ -114,43 +114,6 @@ macro_rules! helpers_for_runtime { Ok((voters, targets, desired_targets)) } - - pub fn [](api: &SubxtClient) { - use chain::static_types; - use crate::chain::[<$runtime>]::runtime; - - // maximum weight of the signed submission is exposed from metadata and MUST be this. - let max_weight = api - .constants() - .at(&runtime::constants().election_provider_multi_phase().miner_max_weight()) - .expect("constant `miner_max_weight` must exist") - .ref_time; - let max_length = api - .constants() - .at(&runtime::constants().election_provider_multi_phase().miner_max_length()) - .expect("constant `miner_max_length` must exist"); - let max_votes_per_voter = api - .constants() - .at(&runtime::constants().election_provider_multi_phase().miner_max_votes_per_voter()) - .expect("constant `miner_max_votes_per_voter` must exist"); - let db_weight = api - .constants() - .at(&runtime::constants().system().db_weight()) - .expect("constant `db_weight` must exist"); - - let system_db_weight = - frame_support::weights::RuntimeDbWeight { read: db_weight.read, write: db_weight.write }; - - static_types::DbWeight::set(system_db_weight); - static_types::MaxWeight::set(max_weight); - static_types::MaxLength::set(max_length); - static_types::MaxVotesPerVoter::set(max_votes_per_voter); - - log::debug!(target: LOG_TARGET, "Constant `max_weight`: {:?}", static_types::MaxWeight::get()); - log::debug!(target: LOG_TARGET, "Constant `max_length`: {:?}", static_types::MaxLength::get()); - log::debug!(target: LOG_TARGET, "Constant `max_votes_per_voter`: {:?}", static_types::MaxVotesPerVoter::get()); - log::debug!(target: LOG_TARGET, "Constant `db_weight`: {:?}", static_types::DbWeight::get()); - } } }; } @@ -161,3 +124,78 @@ helpers_for_runtime!(polkadot); helpers_for_runtime!(kusama); #[cfg(feature = "westend")] helpers_for_runtime!(westend); + +#[derive(Copy, Clone, Debug)] +struct EpmConstant { + epm: &'static str, + constant: &'static str, +} + +impl EpmConstant { + const fn new(constant: &'static str) -> Self { + Self { epm: "ElectionProviderMultiPhase", constant } + } + + const fn to_parts(&self) -> (&'static str, &'static str) { + (self.epm, self.constant) + } + + fn to_string(&self) -> String { + format!("{}::{}", self.epm, self.constant) + } +} + +pub(crate) async fn read_metadata_constants(api: &SubxtClient) -> Result<(), Error> { + const SIGNED_MAX_WEIGHT: EpmConstant = EpmConstant::new("SignedMaxWeight"); + const MAX_LENGTH: EpmConstant = EpmConstant::new("MinerMaxLength"); + const MAX_VOTES_PER_VOTER: EpmConstant = EpmConstant::new("MinerMaxVotesPerVoter"); + + let max_weight = read_constant::(api, SIGNED_MAX_WEIGHT)?; + let max_length: u32 = read_constant(api, MAX_LENGTH)?; + let max_votes_per_voter: u32 = read_constant(api, MAX_VOTES_PER_VOTER)?; + + log::trace!( + target: LOG_TARGET, + "updating metadata constant `{}`: {}", + SIGNED_MAX_WEIGHT.to_string(), + max_weight.ref_time() + ); + log::trace!( + target: LOG_TARGET, + "updating metadata constant `{}`: {}", + MAX_LENGTH.to_string(), + max_length + ); + log::trace!( + target: LOG_TARGET, + "updating metadata constant `{}`: {}", + MAX_VOTES_PER_VOTER.to_string(), + max_votes_per_voter + ); + + static_types::MaxWeight::set(max_weight); + static_types::MaxLength::set(max_length); + static_types::MaxVotesPerVoter::set(max_votes_per_voter); + + Ok(()) +} + +fn invalid_metadata_error(item: String, err: E) -> Error { + Error::InvalidMetadata(format!("{} failed: {}", item, err)) +} + +fn read_constant<'a, T: serde::Deserialize<'a>>( + api: &SubxtClient, + constant: EpmConstant, +) -> Result { + let (epm_name, constant) = constant.to_parts(); + + let val = api + .constants() + .at(&subxt::dynamic::constant(epm_name, constant)) + .map_err(|e| invalid_metadata_error(constant.to_string(), e))?; + + scale_value::serde::from_value::<_, T>(val).map_err(|e| { + Error::InvalidMetadata(format!("Decoding `{}` failed {}", std::any::type_name::(), e)) + }) +} diff --git a/src/lib.rs b/src/lib.rs index 33ad44ed8..e2879b5f4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,3 +10,4 @@ pub mod opt; pub mod prelude; pub mod prometheus; pub mod signer; +pub mod static_types; diff --git a/src/main.rs b/src/main.rs index 0a2fbfc55..eeb5132d3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -38,12 +38,14 @@ mod opt; mod prelude; mod prometheus; mod signer; +mod static_types; use clap::Parser; use futures::future::{BoxFuture, FutureExt}; use jsonrpsee::ws_client::WsClientBuilder; use opt::Command; use prelude::*; +use tokio::sync::oneshot; use tracing_subscriber::EnvFilter; #[tokio::main] @@ -82,20 +84,13 @@ async fn main() -> Result<(), Error> { chain::SHARED_CLIENT.set(api.clone()).expect("shared client only set once; qed"); let outcome = any_runtime!(chain, { - tls_update_runtime_constants(&api); + helpers::read_metadata_constants(&api).await?; + + let (tx_upgrade, rx_upgrade) = oneshot::channel::(); // Start a new tokio task to perform the runtime updates in the background. - let update_client = api.subscribe_to_updates(); - tokio::spawn(async move { - match update_client.perform_runtime_updates().await { - Ok(()) => { - crate::prometheus::on_runtime_upgrade(); - }, - Err(e) => { - log::error!(target: LOG_TARGET, "Runtime update failed with result: {:?}", e); - }, - } - }); + // if this fails then the miner will be stopped and has to be re-started. + tokio::spawn(runtime_upgrade_task(api.clone(), tx_upgrade)); let fut = match command { Command::Monitor(cfg) => monitor_cmd(api, cfg).boxed(), @@ -103,7 +98,7 @@ async fn main() -> Result<(), Error> { Command::EmergencySolution(cfg) => emergency_cmd(api, cfg).boxed(), }; - run_command(fut).await + run_command(fut, rx_upgrade).await }); log::info!(target: LOG_TARGET, "round of execution finished. outcome = {:?}", outcome); @@ -111,7 +106,10 @@ async fn main() -> Result<(), Error> { } #[cfg(target_family = "unix")] -async fn run_command(fut: BoxFuture<'_, Result<(), Error>>) -> Result<(), Error> { +async fn run_command( + fut: BoxFuture<'_, Result<(), Error>>, + rx_upgrade: oneshot::Receiver, +) -> Result<(), Error> { use tokio::signal::unix::{signal, SignalKind}; let mut stream_int = signal(SignalKind::interrupt()).map_err(Error::Io)?; @@ -124,19 +122,80 @@ async fn run_command(fut: BoxFuture<'_, Result<(), Error>>) -> Result<(), Error> _ = stream_term.recv() => { Ok(()) } + res = rx_upgrade => { + match res { + Ok(err) => Err(err), + Err(_) => unreachable!("A message is sent before the upgrade task is closed; qed"), + } + }, res = fut => res, } } #[cfg(not(unix))] -async fn run_command(fut: BoxFuture<'_, Result<(), Error>>) -> Result<(), E> { +async fn run_command( + fut: BoxFuture<'_, Result<(), Error>>, + rx_upgrade: oneshot::Receiver, +) -> Result<(), Error> { use tokio::signal::ctrl_c; select! { _ = ctrl_c() => {}, + res = rx_upgrade => { + match res { + Ok(err) => Err(err), + Err(_) => unreachable!("A message is sent before the upgrade task is closed; qed"), + } + }, res = fut => res, } } +/// Runs until the RPC connection fails or updating the metadata failed. +async fn runtime_upgrade_task(api: SubxtClient, tx: oneshot::Sender) { + let updater = api.subscribe_to_updates(); + + let mut update_stream = match updater.runtime_updates().await { + Ok(u) => u, + Err(e) => { + let _ = tx.send(e.into()); + return + }, + }; + + loop { + // if the runtime upgrade subscription fails then try establish a new one and if it fails quit. + let update = match update_stream.next().await { + Some(Ok(update)) => update, + _ => { + log::warn!(target: LOG_TARGET, "Runtime upgrade subscription failed"); + update_stream = match updater.runtime_updates().await { + Ok(u) => u, + Err(e) => { + let _ = tx.send(e.into()); + return + }, + }; + continue + }, + }; + + let version = update.runtime_version().spec_version; + match updater.apply_update(update) { + Ok(()) => { + if let Err(e) = helpers::read_metadata_constants(&api).await { + let _ = tx.send(e.into()); + return + } + prometheus::on_runtime_upgrade(); + log::info!(target: LOG_TARGET, "upgrade to version: {} successful", version); + }, + Err(e) => { + log::warn!(target: LOG_TARGET, "upgrade to version: {} failed: {:?}", version, e); + }, + } + } +} + #[cfg(test)] mod tests { use super::*; diff --git a/src/monitor.rs b/src/monitor.rs index cf3d2e5d6..d1b60eb16 100644 --- a/src/monitor.rs +++ b/src/monitor.rs @@ -11,7 +11,7 @@ use frame_election_provider_support::NposSolution; use pallet_election_provider_multi_phase::{RawSolution, SolutionOf}; use sp_runtime::Perbill; use std::sync::Arc; -use subxt::{rpc::Subscription, tx::TxStatus, Error as SubxtError}; +use subxt::{rpc::Subscription, tx::TxStatus}; use tokio::sync::Mutex; macro_rules! monitor_cmd_for { @@ -343,7 +343,7 @@ macro_rules! monitor_cmd_for { return Err(err.into()); }, None => { - return Err(Error::Other(format!("Submit solution failed; watch_extrinsic at {:?} closed", hash))); + return Err(Error::SubscriptionClosed); }, }; @@ -370,7 +370,7 @@ macro_rules! monitor_cmd_for { return Ok(()); } _ => { - return Err(Error::Other(format!("Stopping listen due to other status {:?}", status))); + return Err(Error::TransactionRejected(format!("{:?}", status))); }, } } @@ -388,28 +388,15 @@ monitor_cmd_for!(kusama); monitor_cmd_for!(westend); fn kill_main_task_if_critical_err(tx: &tokio::sync::mpsc::UnboundedSender, err: Error) { - use jsonrpsee::{core::Error as RpcError, types::error::CallError}; - match err { - Error::Subxt(SubxtError::Rpc(RpcError::Call(CallError::Custom(e)))) => { - const BAD_EXTRINSIC_FORMAT: i32 = 1001; - const VERIFICATION_ERROR: i32 = 1002; - - // Check if the transaction gets fatal errors from `author` RPC. - // It's possible to get other errors such as outdated nonce and similar - // but then it should be possible to try again in the next block or round. - if e.code() == BAD_EXTRINSIC_FORMAT || e.code() == VERIFICATION_ERROR { - let _ = - tx.send(Error::Subxt(SubxtError::Rpc(RpcError::Call(CallError::Custom(e))))); - } - }, - Error::Subxt(SubxtError::Rpc(RpcError::RequestTimeout)) | - Error::Subxt(SubxtError::Rpc(RpcError::Call(CallError::Failed(_)))) => (), - // Regard the rest of subxt errors has fatal (including rpc) - Error::Subxt(e) => { - let _ = tx.send(Error::Subxt(e)); + Error::AlreadySubmitted | + Error::BetterScoreExist | + Error::IncorrectPhase | + Error::TransactionRejected(_) | + Error::SubscriptionClosed => {}, + err => { + let _ = tx.send(err); }, - _ => (), } } diff --git a/src/opt.rs b/src/opt.rs index 08d9872d2..a65d90d3a 100644 --- a/src/opt.rs +++ b/src/opt.rs @@ -41,7 +41,6 @@ macro_rules! any_runtime { $crate::monitor::run_polkadot as monitor_cmd, $crate::dry_run::run_polkadot as dry_run_cmd, $crate::emergency_solution::run_polkadot as emergency_cmd, - $crate::helpers::update_runtime_constants_polkadot as tls_update_runtime_constants, $crate::chain::polkadot::runtime }; $($code)* @@ -60,7 +59,6 @@ macro_rules! any_runtime { $crate::monitor::run_kusama as monitor_cmd, $crate::dry_run::run_kusama as dry_run_cmd, $crate::emergency_solution::run_kusama as emergency_cmd, - $crate::helpers::update_runtime_constants_kusama as tls_update_runtime_constants, $crate::chain::kusama::runtime }; $($code)* @@ -79,7 +77,6 @@ macro_rules! any_runtime { $crate::monitor::run_westend as monitor_cmd, $crate::dry_run::run_westend as dry_run_cmd, $crate::emergency_solution::run_westend as emergency_cmd, - $crate::helpers::update_runtime_constants_westend as tls_update_runtime_constants, $crate::chain::westend::runtime }; $($code)* @@ -183,10 +180,7 @@ impl std::str::FromStr for Chain { "polkadot" => Ok(Self::Polkadot), "kusama" => Ok(Self::Kusama), "westend" => Ok(Self::Westend), - chain => Err(Error::Other(format!( - "expected chain to be polkadot, kusama or westend; got: {}", - chain - ))), + chain => Err(Error::InvalidChain(chain.to_string())), } } } diff --git a/src/prelude.rs b/src/prelude.rs index 63fcf5aa0..f56e91fbf 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -59,4 +59,7 @@ pub type Accuracy = sp_runtime::Perbill; pub use subxt::tx::PolkadotExtrinsicParamsBuilder as ExtrinsicParams; /// Subxt client used by the staking miner on all chains. -pub type SubxtClient = subxt::OnlineClient; +pub type SubxtClient = subxt::OnlineClient; + +/// Config used by the staking-miner +pub type Config = subxt::PolkadotConfig; diff --git a/src/prometheus.rs b/src/prometheus.rs index 6121b1be8..572ba4247 100644 --- a/src/prometheus.rs +++ b/src/prometheus.rs @@ -183,7 +183,7 @@ mod hidden { } pub fn set_weight(weight: Weight) { - SUBMISSION_WEIGHT.set(weight as f64) + SUBMISSION_WEIGHT.set(weight.ref_time() as f64) } pub fn set_score(score: sp_npos_elections::ElectionScore) { diff --git a/src/static_types.rs b/src/static_types.rs new file mode 100644 index 000000000..8f4f8b45f --- /dev/null +++ b/src/static_types.rs @@ -0,0 +1,61 @@ +macro_rules! impl_atomic_u32_parameter_types { + ($mod:ident, $name:ident) => { + mod $mod { + use std::sync::atomic::{AtomicU32, Ordering}; + + static VAL: AtomicU32 = AtomicU32::new(0); + + pub struct $name; + + impl $name { + pub fn get() -> u32 { + VAL.load(Ordering::SeqCst) + } + } + + impl> frame_support::traits::Get for $name { + fn get() -> I { + I::from(Self::get()) + } + } + + impl $name { + pub fn set(val: u32) { + VAL.store(val, std::sync::atomic::Ordering::SeqCst); + } + } + } + + pub use $mod::$name; + }; +} + +mod max_weight { + use frame_support::weights::Weight; + use std::sync::atomic::{AtomicU64, Ordering}; + + static VAL: AtomicU64 = AtomicU64::new(0); + pub struct MaxWeight; + + impl MaxWeight { + pub fn get() -> Weight { + Weight::from_ref_time(VAL.load(Ordering::SeqCst)) + } + } + + impl frame_support::traits::Get for MaxWeight { + fn get() -> Weight { + Self::get() + } + } + + impl MaxWeight { + pub fn set(weight: Weight) { + VAL.store(weight.ref_time(), std::sync::atomic::Ordering::SeqCst); + } + } +} + +impl_atomic_u32_parameter_types!(max_length, MaxLength); +impl_atomic_u32_parameter_types!(max_votes, MaxVotesPerVoter); +pub use max_weight::MaxWeight; diff --git a/tests/monitor.rs b/tests/monitor.rs index 831f735d8..0e5f2b104 100644 --- a/tests/monitor.rs +++ b/tests/monitor.rs @@ -17,10 +17,7 @@ use std::{ process, time::{Duration, Instant}, }; -use subxt::{ - ext::sp_core::Bytes, - rpc::{rpc_params, SubscriptionClientT}, -}; +use subxt::{ext::sp_core::Bytes, rpc::rpc_params}; const MAX_DURATION_FOR_SUBMIT_SOLUTION: Duration = Duration::from_secs(60 * 15); @@ -50,8 +47,6 @@ async fn test_submit_solution(chain: Chain) { let now = Instant::now(); - let mut success = false; - let key = Bytes( runtime::storage() .election_provider_multi_phase() @@ -61,7 +56,6 @@ async fn test_submit_solution(chain: Chain) { let mut sub = api .rpc() - .client .subscribe("state_subscribeStorage", rpc_params![vec![key]], "state_unsubscribeStorage") .await .unwrap();