From bbc123295874e2f674b64ca761729c0b216ee823 Mon Sep 17 00:00:00 2001 From: IvanCholakov Date: Wed, 1 Mar 2023 13:40:45 +0200 Subject: [PATCH] fix: update from v0.9.27 to v0.9.36 v0.9.28 - changes v0.9.29 - changes v0.9.30 - changes v0.9.31 - changes v0.9.37 changes Add indices for calls of ethereum-transactions See: https://github.com/paritytech/substrate/pull/12891 https://github.com/paritytech/substrate/pull/11381 Fixes ethereum-events tests Add indices for calls of ethereum-transactions See: - https://github.com/paritytech/substrate/pull/12891 - https://github.com/paritytech/substrate/pull/11381 Fixes compilation errors of avn-proxy pallet - Cleanups WiP - Adds indices for calls Fixes compilation errors of nft-manager pallet - Cleanup - Adds indices for calls Fixes tests for nft-manager pallet Fixup nft-manager imports Fixes avn-proxy tests Fixes tests on Ethereum Events pallet SYS-3197 - token-manager pallet::call changed SYS-3197 - summary pallet and exact substrate version fix: tests Cleanup warnings and adds call indexes Fixes some of the test in token manager Reverts the interface changes to use Box. Fixes mock, re-introduces some of the tests, and temporarily disables some. Re-enable the rest of token manager tests Fixup: Remove warning Fixes token-manager benchmarks compilation errors Updates and fixes Benchmarks cargo dependencies. Also fixes avn-proxy compilation errors. Adds instructions to run pallet benchmarks fix: updated benchmarks fix: added prod-like benchmarks for parachain-staking Fix staking tests fix: benchmark test for parachain staking fix: add max proof to weights init fix: linting --- Cargo.lock | 1308 +++++++++++------ README.md | 18 + pallets/avn-finality-tracker/Cargo.toml | 23 +- .../avn-finality-tracker/src/benchmarking.rs | 2 +- .../src/default_weights.rs | 16 +- pallets/avn-finality-tracker/src/lib.rs | 45 +- pallets/avn-finality-tracker/src/mock.rs | 16 +- pallets/avn-offence-handler/Cargo.toml | 21 +- .../avn-offence-handler/src/benchmarking.rs | 4 +- .../src/default_weights.rs | 8 +- pallets/avn-offence-handler/src/lib.rs | 9 +- pallets/avn-offence-handler/src/mock.rs | 10 +- pallets/avn-offence-handler/src/tests.rs | 62 +- pallets/avn-proxy/Cargo.toml | 23 +- pallets/avn-proxy/src/benchmarking.rs | 7 +- pallets/avn-proxy/src/default_weights.rs | 12 +- pallets/avn-proxy/src/lib.rs | 47 +- pallets/avn-proxy/src/tests/mock.rs | 58 +- .../src/tests/proxy_tests_no_fees.rs | 14 +- .../src/tests/proxy_tests_with_fees.rs | 26 +- pallets/avn/Cargo.toml | 22 +- pallets/avn/src/tests/mock.rs | 10 +- pallets/ethereum-events/Cargo.toml | 29 +- pallets/ethereum-events/src/benchmarking.rs | 4 +- .../ethereum-events/src/default_weights.rs | 184 +-- pallets/ethereum-events/src/lib.rs | 29 +- pallets/ethereum-events/src/mock.rs | 52 +- pallets/ethereum-events/src/offence.rs | 4 +- .../src/tests/test_challenges.rs | 4 +- .../src/tests/test_ethereum_logs.rs | 158 +- .../src/tests/test_offchain_worker.rs | 40 +- .../src/tests/test_offchain_worker_calls.rs | 8 +- .../src/tests/test_process_event.rs | 5 +- .../test_proxy_signed_add_ethereum_logs.rs | 4 +- .../src/tests/test_set_ethereum_contract.rs | 4 +- .../tests/test_set_event_challenge_period.rs | 9 +- pallets/ethereum-events/src/tests/tests.rs | 5 +- pallets/ethereum-transactions/Cargo.toml | 21 +- .../ethereum-transactions/src/benchmarking.rs | 6 +- .../src/default_weights.rs | 44 +- pallets/ethereum-transactions/src/lib.rs | 12 +- pallets/ethereum-transactions/src/mock.rs | 22 +- .../tests/test_set_publish_root_contract.rs | 8 +- .../ethereum-transactions/src/tests/tests.rs | 10 +- pallets/nft-manager/Cargo.toml | 21 +- pallets/nft-manager/src/batch_nft.rs | 9 +- pallets/nft-manager/src/benchmarking.rs | 58 +- pallets/nft-manager/src/default_weights.rs | 180 +-- pallets/nft-manager/src/lib.rs | 36 +- .../nft-manager/src/tests/batch_nft_tests.rs | 15 +- .../tests/cancel_single_nft_listing_tests.rs | 3 +- pallets/nft-manager/src/tests/mock.rs | 11 +- .../src/tests/open_for_sale_tests.rs | 3 +- ...proxy_signed_cancel_list_fiat_nft_tests.rs | 9 +- ...oxy_signed_list_nft_open_for_sale_tests.rs | 12 +- .../proxy_signed_mint_single_nft_tests.rs | 10 +- .../proxy_signed_transfer_fiat_nft_tests.rs | 11 +- .../src/tests/single_mint_nft_tests.rs | 3 +- .../src/tests/transfer_to_tests.rs | 2 +- pallets/parachain-staking/Cargo.toml | 28 +- pallets/parachain-staking/src/calls.rs | 2 +- pallets/parachain-staking/src/lib.rs | 73 +- pallets/parachain-staking/src/migration.rs | 19 +- .../src/nomination_requests.rs | 7 +- .../parachain-staking/src/proxy_methods.rs | 4 +- .../parachain-staking/src/session_handler.rs | 6 +- .../src/tests/bond_extra_tests.rs | 14 +- pallets/parachain-staking/src/tests/mock.rs | 90 +- .../src/tests/nominate_tests.rs | 10 +- .../tests/schedule_revoke_nomination_tests.rs | 151 +- .../src/tests/schedule_unbond_tests.rs | 220 ++- .../src/tests/test_admin_settings.rs | 4 +- .../src/tests/test_growth.rs | 14 +- pallets/parachain-staking/src/tests/tests.rs | 4 +- pallets/parachain-staking/src/weights.rs | 612 ++++---- pallets/summary/Cargo.toml | 27 +- pallets/summary/src/benchmarking.rs | 10 +- pallets/summary/src/default_weights.rs | 196 +-- pallets/summary/src/lib.rs | 1090 +++++++------- pallets/summary/src/offence.rs | 2 +- pallets/summary/src/tests/mock.rs | 22 +- pallets/summary/src/tests/tests.rs | 29 +- pallets/summary/src/tests/tests_challenge.rs | 14 +- .../summary/src/tests/tests_set_periods.rs | 6 +- pallets/summary/src/tests/tests_slot_logic.rs | 53 +- pallets/summary/src/tests/tests_vote.rs | 42 +- pallets/token-manager/Cargo.toml | 30 +- pallets/token-manager/src/benchmarking.rs | 12 +- pallets/token-manager/src/default_weights.rs | 94 +- pallets/token-manager/src/lib.rs | 31 +- pallets/token-manager/src/mock.rs | 43 +- pallets/token-manager/src/test_avt_tokens.rs | 28 +- .../token-manager/src/test_common_cases.rs | 18 +- pallets/token-manager/src/test_growth.rs | 22 +- .../token-manager/src/test_non_avt_tokens.rs | 52 +- .../src/test_proxying_signed_lower.rs | 67 +- .../src/test_proxying_signed_transfer.rs | 206 +-- pallets/validators-manager/Cargo.toml | 31 +- .../validators-manager/src/benchmarking.rs | 6 +- .../validators-manager/src/default_weights.rs | 140 +- pallets/validators-manager/src/lib.rs | 29 +- pallets/validators-manager/src/mock.rs | 34 +- pallets/validators-manager/src/offence.rs | 2 +- pallets/validators-manager/src/tests.rs | 17 +- .../src/tests_voting_deregistration.rs | 12 +- primitives/avn-common/Cargo.toml | 8 +- 106 files changed, 3615 insertions(+), 2822 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 73cdc3791..2842da216 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -18,7 +18,16 @@ version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b" dependencies = [ - "gimli", + "gimli 0.26.2", +] + +[[package]] +name = "addr2line" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97" +dependencies = [ + "gimli 0.27.2", ] [[package]] @@ -33,16 +42,16 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" dependencies = [ - "getrandom 0.2.7", + "getrandom 0.2.8", "once_cell", "version_check", ] [[package]] name = "aho-corasick" -version = "0.7.19" +version = "0.7.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4f55bd91a0978cbfd91c457a164bab8b4001c833b7f323132c0a4e1922dd44e" +checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" dependencies = [ "memchr", ] @@ -67,9 +76,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.66" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6" +checksum = "224afbd727c3d6e4b90103ece64b8d1b67fbb1973b1046c2281eed3f3803f800" [[package]] name = "approx" @@ -81,19 +90,16 @@ dependencies = [ ] [[package]] -name = "arrayref" -version = "0.3.6" +name = "array-bytes" +version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" +checksum = "f52f63c5c1316a16a4b35eaac8b76a98248961a533f061684cb2a7cb0eafb6c6" [[package]] -name = "arrayvec" -version = "0.4.12" +name = "arrayref" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd9fd44efafa8690358b7408d253adf110036b88f55672a933f01d616ad9b1b9" -dependencies = [ - "nodrop", -] +checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" [[package]] name = "arrayvec" @@ -115,9 +121,9 @@ checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" [[package]] name = "async-trait" -version = "0.1.58" +version = "0.1.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e805d94e6b5001b651426cf4cd446b1ab5f319d27bab5c644f61de0a804360c" +checksum = "b84f9ebcc6c1f5b8cb160f6990096a5c127f423fcb6e1ccc46c370cbdfb75dfc" dependencies = [ "proc-macro2", "quote", @@ -132,16 +138,16 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "backtrace" -version = "0.3.66" +version = "0.3.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cab84319d616cfb654d03394f38ab7e6f0919e181b1b57e1fd15e7fb4077d9a7" +checksum = "233d376d6d185f2a3093e58f283f60f880315b6c60075b01f36b3b85154564ca" dependencies = [ - "addr2line", + "addr2line 0.19.0", "cc", "cfg-if", "libc", "miniz_oxide", - "object", + "object 0.30.3", "rustc-demangle", ] @@ -163,6 +169,21 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" +[[package]] +name = "base64ct" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" + +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + [[package]] name = "bitflags" version = "1.3.2" @@ -183,21 +204,11 @@ dependencies = [ [[package]] name = "blake2" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9cf849ee05b2ee5fba5e36f97ff8ec2533916700fc0758d40d92136a42f3388" -dependencies = [ - "digest 0.10.5", -] - -[[package]] -name = "blake2-rfc" -version = "0.2.18" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d6d530bdd2d52966a6d03b7a964add7ae1a288d25214066fd4b600f0f796400" +checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" dependencies = [ - "arrayvec 0.4.12", - "constant_time_eq", + "digest 0.10.6", ] [[package]] @@ -259,15 +270,15 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.11.1" +version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba" +checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" [[package]] name = "byte-slice-cast" -version = "1.2.1" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87c5fdd0166095e1d463fc6cc01aa8ce547ad77a4e84d42eb6762b084e28067e" +checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" [[package]] name = "byte-tools" @@ -281,11 +292,26 @@ version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +[[package]] +name = "bytes" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" + [[package]] name = "cc" -version = "1.0.73" +version = "1.0.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" + +[[package]] +name = "cfg-expr" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" +checksum = "0aacacf4d96c24b2ad6eb8ee6df040e4f27b0d0b39a5710c30091baa830485db" +dependencies = [ + "smallvec", +] [[package]] name = "cfg-if" @@ -295,9 +321,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.22" +version = "0.4.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfd4d1b31faaa3a89d7934dbded3111da0d2ef28e3ebccdb4f0179f5929d1ef1" +checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" dependencies = [ "iana-time-zone", "num-integer", @@ -317,28 +343,21 @@ dependencies = [ [[package]] name = "console" -version = "0.15.2" +version = "0.15.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c050367d967ced717c04b65d8c619d863ef9292ce0c5760028655a2fb298718c" +checksum = "c3d79fbe8970a77e3e34151cc13d3b3e248aa0faaecb9f6091fa07ebefe5ad60" dependencies = [ "encode_unicode", "lazy_static", "libc", - "terminal_size", - "winapi", + "windows-sys 0.42.0", ] [[package]] name = "const-oid" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4c78c047431fee22c1a7bb92e00ad095a02a983affe4d8a72e2a2c62c1b94f3" - -[[package]] -name = "constant_time_eq" -version = "0.1.5" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" +checksum = "520fbf3c07483f94e3e3ca9d0cfd913d7718ef2483d2cfd91c0d9e91474ab913" [[package]] name = "convert_case" @@ -352,6 +371,15 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" +[[package]] +name = "cpp_demangle" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eeaa953eaad386a53111e47172c2fedba671e5684c8dd601a5f474f4f118710f" +dependencies = [ + "cfg-if", +] + [[package]] name = "cpufeatures" version = "0.2.5" @@ -361,6 +389,24 @@ dependencies = [ "libc", ] +[[package]] +name = "cranelift-entity" +version = "0.88.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87a0f1b2fdc18776956370cf8d9b009ded3f855350c480c1c52142510961f352" +dependencies = [ + "serde", +] + +[[package]] +name = "crc32fast" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +dependencies = [ + "cfg-if", +] + [[package]] name = "crunchy" version = "0.2.2" @@ -369,9 +415,9 @@ checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" [[package]] name = "crypto-bigint" -version = "0.3.2" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03c6a1d5fa1de37e071642dfa44ec552ca5b299adb128fab16138e24b548fd21" +checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" dependencies = [ "generic-array 0.14.6", "rand_core 0.6.4", @@ -386,7 +432,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ "generic-array 0.14.6", - "typenum 1.15.0", + "typenum 1.16.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -437,9 +483,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.80" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b7d4e43b25d3c994662706a1d4fcfc32aaa6afd287502c111b237093bb23f3a" +checksum = "9a140f260e6f3f79013b8bfc65e7ce630c9ab4388c6a89c71e07226f49487b72" dependencies = [ "cc", "cxxbridge-flags", @@ -449,9 +495,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.80" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84f8829ddc213e2c1368e51a2564c552b65a8cb6a28f31e576270ac81d5e5827" +checksum = "da6383f459341ea689374bf0a42979739dc421874f112ff26f829b8040b8e613" dependencies = [ "cc", "codespan-reporting", @@ -464,15 +510,15 @@ dependencies = [ [[package]] name = "cxxbridge-flags" -version = "1.0.80" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e72537424b474af1460806647c41d4b6d35d09ef7fe031c5c2fa5766047cc56a" +checksum = "90201c1a650e95ccff1c8c0bb5a343213bdd317c6e600a93075bca2eff54ec97" [[package]] name = "cxxbridge-macro" -version = "1.0.80" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "309e4fb93eed90e1e14bea0da16b209f81813ba9fc7830c20ed151dd7bc0a4d7" +checksum = "0b75aed41bb2e6367cae39e6326ef817a851db13c13e4f3263714ca3cfb8de56" dependencies = [ "proc-macro2", "quote", @@ -481,11 +527,12 @@ dependencies = [ [[package]] name = "der" -version = "0.5.1" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6919815d73839e7ad218de758883aae3a257ba6759ce7a9992501efbb53d705c" +checksum = "f1a467a65c5e759bce6e65eaf91cc29f466cdc57cb65777bd646872a8a1fd4de" dependencies = [ "const-oid", + "zeroize", ] [[package]] @@ -521,9 +568,9 @@ dependencies = [ [[package]] name = "digest" -version = "0.10.5" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adfbc57365a37acbd2ebf2b64d7e69bb766e2fea813521ed536f5d0520dcf86c" +checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" dependencies = [ "block-buffer 0.10.3", "crypto-common", @@ -559,15 +606,15 @@ dependencies = [ [[package]] name = "dyn-clone" -version = "1.0.9" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f94fa09c2aeea5b8839e414b7b841bf429fd25b9c522116ac97ee87856d88b2" +checksum = "68b0cf012f1230e43cd00ebb729c6bb58707ecfa8ad08b52ef3a4ccd2697fc30" [[package]] name = "ecdsa" -version = "0.13.4" +version = "0.14.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0d69ae62e0ce582d56380743515fefaf1a8c70cec685d9677636d7e30ae9dc9" +checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" dependencies = [ "der", "elliptic-curve", @@ -577,9 +624,9 @@ dependencies = [ [[package]] name = "ed25519" -version = "1.5.2" +version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e9c280362032ea4203659fc489832d0204ef09f247a0506f170dafcac08c369" +checksum = "91cff35c70bba8a626e3185d8cd48cc11b5437e1a5bcd15b9b5fa3c64b6dfee7" dependencies = [ "signature", ] @@ -592,27 +639,40 @@ checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" dependencies = [ "curve25519-dalek 3.2.0", "ed25519", - "rand 0.7.3", - "serde", + "sha2 0.9.9", + "zeroize", +] + +[[package]] +name = "ed25519-zebra" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c24f403d068ad0b359e577a77f92392118be3f3c927538f2bb544a5ecd828c6" +dependencies = [ + "curve25519-dalek 3.2.0", + "hashbrown", + "hex", + "rand_core 0.6.4", "sha2 0.9.9", "zeroize", ] [[package]] name = "either" -version = "1.8.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" +checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" [[package]] name = "elliptic-curve" -version = "0.11.12" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25b477563c2bfed38a3b7a60964c49e058b2510ad3f12ba3483fd8f62c2306d6" +checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" dependencies = [ "base16ct", "crypto-bigint", "der", + "digest 0.10.6", "ff", "generic-array 0.14.6", "group", @@ -650,9 +710,30 @@ dependencies = [ [[package]] name = "environmental" -version = "1.1.3" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e48c92028aaa870e83d51c64e5d4e0b6981b360c522198c23959f219a4e1b15b" + +[[package]] +name = "errno" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" +dependencies = [ + "errno-dragonfly", + "libc", + "winapi", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b91989ae21441195d7d9b9993a2f9295c7e1a8c96255d8b729accddc124797" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] [[package]] name = "ethabi" @@ -673,7 +754,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfb684ac8fa8f6c5759f788862bb22ec6fe3cb392f6bfd08e3c64b603661e3f8" dependencies = [ "crunchy", - "fixed-hash", + "fixed-hash 0.7.0", "tiny-keccak", ] @@ -684,7 +765,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f64b5df66a228d85e4b17e5d6c6aa43b0310898ffe8a85988c4c032357aaabfd" dependencies = [ "ethbloom", - "fixed-hash", + "fixed-hash 0.7.0", "primitive-types 0.9.1", "uint", ] @@ -695,11 +776,17 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" +[[package]] +name = "fallible-iterator" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" + [[package]] name = "ff" -version = "0.11.1" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "131655483be284720a17d74ff97592b8e76576dc25563148601df2d7c9080924" +checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" dependencies = [ "rand_core 0.6.4", "subtle", @@ -710,6 +797,17 @@ name = "fixed-hash" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cfcf0ed7fe52a17a03854ec54a9f76d6d84508d1c0e66bc1793301c73fc8493c" +dependencies = [ + "byteorder", + "rustc-hex", + "static_assertions", +] + +[[package]] +name = "fixed-hash" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" dependencies = [ "byteorder", "rand 0.8.5", @@ -720,18 +818,19 @@ dependencies = [ [[package]] name = "frame-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.27#5bfdbab8ba28523ef10e365627fed64ef2b77cbf" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.36#cb4f2491b00af7d7817f3a54209c26b20faa1f51" dependencies = [ "frame-support", "frame-system", "linregress", "log", "parity-scale-codec", - "paste 1.0.9", + "paste 1.0.12", "scale-info", "serde", "sp-api", "sp-application-crypto", + "sp-core", "sp-io", "sp-runtime", "sp-runtime-interface", @@ -742,7 +841,7 @@ dependencies = [ [[package]] name = "frame-election-provider-solution-type" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.27#5bfdbab8ba28523ef10e365627fed64ef2b77cbf" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.36#cb4f2491b00af7d7817f3a54209c26b20faa1f51" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -753,7 +852,7 @@ dependencies = [ [[package]] name = "frame-election-provider-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.27#5bfdbab8ba28523ef10e365627fed64ef2b77cbf" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.36#cb4f2491b00af7d7817f3a54209c26b20faa1f51" dependencies = [ "frame-election-provider-solution-type", "frame-support", @@ -761,6 +860,7 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-arithmetic", + "sp-core", "sp-npos-elections", "sp-runtime", "sp-std", @@ -781,7 +881,7 @@ dependencies = [ [[package]] name = "frame-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.27#5bfdbab8ba28523ef10e365627fed64ef2b77cbf" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.36#cb4f2491b00af7d7817f3a54209c26b20faa1f51" dependencies = [ "bitflags", "frame-metadata", @@ -791,10 +891,11 @@ dependencies = [ "log", "once_cell", "parity-scale-codec", - "paste 1.0.9", + "paste 1.0.12", "scale-info", "serde", "smallvec", + "sp-api", "sp-arithmetic", "sp-core", "sp-core-hashing-proc-macro", @@ -805,16 +906,19 @@ dependencies = [ "sp-state-machine", "sp-std", "sp-tracing", + "sp-weights", "tt-call", ] [[package]] name = "frame-support-procedural" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.27#5bfdbab8ba28523ef10e365627fed64ef2b77cbf" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.36#cb4f2491b00af7d7817f3a54209c26b20faa1f51" dependencies = [ "Inflector", + "cfg-expr", "frame-support-procedural-tools", + "itertools", "proc-macro2", "quote", "syn", @@ -823,7 +927,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.27#5bfdbab8ba28523ef10e365627fed64ef2b77cbf" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.36#cb4f2491b00af7d7817f3a54209c26b20faa1f51" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate", @@ -835,7 +939,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.27#5bfdbab8ba28523ef10e365627fed64ef2b77cbf" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.36#cb4f2491b00af7d7817f3a54209c26b20faa1f51" dependencies = [ "proc-macro2", "quote", @@ -845,7 +949,7 @@ dependencies = [ [[package]] name = "frame-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.27#5bfdbab8ba28523ef10e365627fed64ef2b77cbf" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.36#cb4f2491b00af7d7817f3a54209c26b20faa1f51" dependencies = [ "frame-support", "log", @@ -857,6 +961,7 @@ dependencies = [ "sp-runtime", "sp-std", "sp-version", + "sp-weights", ] [[package]] @@ -867,9 +972,9 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "futures" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38390104763dc37a5145a53c29c63c1290b5d316d6086ec32c293f6736051bb0" +checksum = "13e2792b0ff0340399d58445b88fd9770e3489eff258a4cbc1523418f12abf84" dependencies = [ "futures-channel", "futures-core", @@ -882,9 +987,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52ba265a92256105f45b719605a571ffe2d1f0fea3807304b522c1d778f79eed" +checksum = "2e5317663a9089767a1ec00a487df42e0ca174b61b4483213ac24448e4664df5" dependencies = [ "futures-core", "futures-sink", @@ -892,15 +997,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04909a7a7e4633ae6c4a9ab280aeb86da1236243a77b694a49eacd659a4bd3ac" +checksum = "ec90ff4d0fe1f57d600049061dc6bb68ed03c7d2fbd697274c41805dcb3f8608" [[package]] name = "futures-executor" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7acc85df6714c176ab5edf386123fafe217be88c0840ec11f199441134a074e2" +checksum = "e8de0a35a6ab97ec8869e32a2473f4b1324459e14c29275d14b10cb1fd19b50e" dependencies = [ "futures-core", "futures-task", @@ -910,15 +1015,15 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00f5fb52a06bdcadeb54e8d3671f8888a39697dcb0b81b23b55174030427f4eb" +checksum = "bfb8371b6fb2aeb2d280374607aeabfc99d95c72edfe51692e42d3d7f0d08531" [[package]] name = "futures-macro" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdfb8ce053d86b91919aad980c220b1fb8401a9394410e1c289ed7e66b61835d" +checksum = "95a73af87da33b5acf53acfebdc339fe592ecf5357ac7c0a7734ab9d8c876a70" dependencies = [ "proc-macro2", "quote", @@ -927,15 +1032,15 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39c15cf1a4aa79df40f1bb462fb39676d0ad9e366c2a33b590d7c66f4f81fcf9" +checksum = "f310820bb3e8cfd46c80db4d7fb8353e15dfff853a127158425f31e0be6c8364" [[package]] name = "futures-task" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ffb393ac5d9a6eaa9d3fdf37ae2776656b706e200c8e16b1bdb227f5198e6ea" +checksum = "dcf79a1bf610b10f42aea489289c5a2c478a786509693b80cd39c44ccd936366" [[package]] name = "futures-timer" @@ -945,9 +1050,9 @@ checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" [[package]] name = "futures-util" -version = "0.3.25" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "197676987abd2f9cadff84926f410af1c183608d36641465df73ae8211dc65d6" +checksum = "9c1d6de3acfef38d2be4b1f543f553131788603495be83da675e180c8d6b7bd1" dependencies = [ "futures-channel", "futures-core", @@ -967,7 +1072,7 @@ version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" dependencies = [ - "typenum 1.15.0", + "typenum 1.16.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -976,7 +1081,7 @@ version = "0.14.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" dependencies = [ - "typenum 1.15.0", + "typenum 1.16.0 (registry+https://github.com/rust-lang/crates.io-index)", "version_check", ] @@ -995,9 +1100,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" +checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" dependencies = [ "cfg-if", "libc", @@ -1009,12 +1114,22 @@ name = "gimli" version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" +dependencies = [ + "fallible-iterator", + "stable_deref_trait", +] + +[[package]] +name = "gimli" +version = "0.27.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad0a93d233ebf96623465aad4046a8d3aa4da22d4f4beba5388838c8a434bbb4" [[package]] name = "group" -version = "0.11.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc5ac374b108929de78460075f3dc439fa66df9d8fc77e8f12caa5165fcf0c89" +checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" dependencies = [ "ff", "rand_core 0.6.4", @@ -1047,9 +1162,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.1.19" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" dependencies = [ "libc", ] @@ -1086,6 +1201,15 @@ dependencies = [ "digest 0.9.0", ] +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest 0.10.6", +] + [[package]] name = "hmac-drbg" version = "0.3.0" @@ -1099,9 +1223,9 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.51" +version = "0.1.53" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5a6ef98976b22b3b7f2f3a806f858cb862044cfa66805aa3ad84cb3d3b785ed" +checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -1132,9 +1256,9 @@ dependencies = [ [[package]] name = "impl-serde" -version = "0.3.2" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4551f042f3438e64dbd6226b20527fc84a6e1fe65688b58746a2f53623f25f5c" +checksum = "ebc88fc67028ae3db0c853baa36269d398d5f45b6982f95549ff5def78c935cd" dependencies = [ "serde", ] @@ -1150,6 +1274,17 @@ dependencies = [ "syn", ] +[[package]] +name = "indexmap" +version = "1.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" +dependencies = [ + "autocfg", + "hashbrown", + "serde", +] + [[package]] name = "integer-sqrt" version = "0.1.5" @@ -1159,38 +1294,56 @@ dependencies = [ "num-traits", ] +[[package]] +name = "io-lifetimes" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ce5ef949d49ee85593fc4d3f3f95ad61657076395cbbce23e2121fc5542074" + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + [[package]] name = "itoa" -version = "1.0.4" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" +checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" [[package]] name = "js-sys" -version = "0.3.60" +version = "0.3.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" +checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730" dependencies = [ "wasm-bindgen", ] [[package]] name = "k256" -version = "0.10.4" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19c3a5e0a0b8450278feda242592512e09f61c72e018b8cd5c859482802daf2d" +checksum = "72c1e0b51e7ec0a97369623508396067a486bd0cbed95a2659a4b863d28cfc8b" dependencies = [ "cfg-if", "ecdsa", "elliptic-curve", - "sec1", + "sha2 0.10.6", ] [[package]] name = "keccak" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9b7d56ba4a8344d6be9729995e6b06f928af29998cdf79fe390cbf6b1fee838" +checksum = "3afef3b6eff9ce9d8ff9b3601125eec7f0c8cbac7abd14f355d053fa56c98768" +dependencies = [ + "cpufeatures", +] [[package]] name = "lazy_static" @@ -1200,15 +1353,15 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.136" +version = "0.2.139" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55edcf6c0bb319052dea84732cf99db461780fd5e8d3eb46ab6ff312ab31f197" +checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" [[package]] name = "libm" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "292a948cd991e376cf75541fe5b97a1081d713c618b4f1b9500f8844e49eb565" +checksum = "348108ab3fba42ec82ff6e9564fc4ca0247bdccdc68dd8af9764bbc79c3c8ffb" [[package]] name = "libsecp256k1" @@ -1226,7 +1379,7 @@ dependencies = [ "rand 0.8.5", "serde", "sha2 0.9.9", - "typenum 1.15.0", + "typenum 1.16.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1260,9 +1413,9 @@ dependencies = [ [[package]] name = "link-cplusplus" -version = "1.0.7" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9272ab7b96c9046fbc5bc56c06c117cb639fe2d509df0c421cad82d2915cf369" +checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5" dependencies = [ "cc", ] @@ -1277,6 +1430,12 @@ dependencies = [ "statrs", ] +[[package]] +name = "linux-raw-sys" +version = "0.0.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4d2456c373231a208ad294c33dc5bff30051eafd954cd4caae83a712b12854d" + [[package]] name = "lock_api" version = "0.4.9" @@ -1296,6 +1455,24 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "lru" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6e8aaa3f231bb4bd57b84b2d5dc3ae7f350265df8aa96492e0bc394a1571909" +dependencies = [ + "hashbrown", +] + +[[package]] +name = "mach" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa" +dependencies = [ + "libc", +] + [[package]] name = "matchers" version = "0.0.1" @@ -1320,22 +1497,30 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +[[package]] +name = "memoffset" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +dependencies = [ + "autocfg", +] + [[package]] name = "memory-db" -version = "0.29.0" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6566c70c1016f525ced45d7b7f97730a2bafb037c788211d0c186ef5b2189f0a" +checksum = "5e0c7cba9ce19ac7ffd2053ac9f49843bbd3f4318feedfd74e85c19d5fb0ba66" dependencies = [ "hash-db", "hashbrown", - "parity-util-mem", ] [[package]] name = "memory_units" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71d96e3f3c0b6325d8ccd83c33b28acb183edcb6c67938ba104ec546854b0882" +checksum = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3" [[package]] name = "merlin" @@ -1351,9 +1536,9 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.5.4" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96590ba8f175222643a85693f33d26e9c8a015f599c216509b1a6894af675d34" +checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" dependencies = [ "adler", ] @@ -1368,12 +1553,12 @@ dependencies = [ "matrixmultiply", "nalgebra-macros", "num-complex", - "num-rational 0.4.1", + "num-rational", "num-traits", "rand 0.8.5", "rand_distr", "simba", - "typenum 1.15.0", + "typenum 1.16.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1388,16 +1573,16 @@ dependencies = [ ] [[package]] -name = "nodrop" -version = "0.1.14" +name = "nohash-hasher" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" +checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" [[package]] name = "num-bigint" -version = "0.2.6" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304" +checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" dependencies = [ "autocfg", "num-integer", @@ -1406,18 +1591,18 @@ dependencies = [ [[package]] name = "num-complex" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ae39348c8bc5fbd7f40c727a9925f03517afd2ab27d46702108b6a7e5414c19" +checksum = "02e0d21255c828d6f128a1e41534206671e8c3ea0c62f32291e808dc82cff17d" dependencies = [ "num-traits", ] [[package]] name = "num-format" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54b862ff8df690cf089058c98b183676a7ed0f974cc08b426800093227cbff3b" +checksum = "a652d9771a63711fd3c3deb670acfbe5c30a4072e664d7a3bf5a9e1056ac72c3" dependencies = [ "arrayvec 0.7.2", "itoa", @@ -1433,18 +1618,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-rational" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c000134b5dbf44adc5cb772486d335293351644b801551abe8f75c84cfa4aef" -dependencies = [ - "autocfg", - "num-bigint", - "num-integer", - "num-traits", -] - [[package]] name = "num-rational" version = "0.4.1" @@ -1452,6 +1625,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" dependencies = [ "autocfg", + "num-bigint", "num-integer", "num-traits", ] @@ -1468,9 +1642,9 @@ dependencies = [ [[package]] name = "num_cpus" -version = "1.13.1" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" +checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" dependencies = [ "hermit-abi", "libc", @@ -1481,15 +1655,27 @@ name = "object" version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53" +dependencies = [ + "crc32fast", + "hashbrown", + "indexmap", + "memchr", +] + +[[package]] +name = "object" +version = "0.30.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea86265d3d3dcb6a27fc51bd29a4bf387fae9d2986b823079d4986af253eb439" dependencies = [ "memchr", ] [[package]] name = "once_cell" -version = "1.15.0" +version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1" +checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" [[package]] name = "opaque-debug" @@ -1506,7 +1692,7 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "pallet-authorship" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.27#5bfdbab8ba28523ef10e365627fed64ef2b77cbf" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.36#cb4f2491b00af7d7817f3a54209c26b20faa1f51" dependencies = [ "frame-support", "frame-system", @@ -1615,7 +1801,7 @@ dependencies = [ [[package]] name = "pallet-balances" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.27#5bfdbab8ba28523ef10e365627fed64ef2b77cbf" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.36#cb4f2491b00af7d7817f3a54209c26b20faa1f51" dependencies = [ "frame-benchmarking", "frame-support", @@ -1735,7 +1921,7 @@ dependencies = [ [[package]] name = "pallet-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.27#5bfdbab8ba28523ef10e365627fed64ef2b77cbf" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.36#cb4f2491b00af7d7817f3a54209c26b20faa1f51" dependencies = [ "frame-support", "frame-system", @@ -1783,7 +1969,7 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.27#5bfdbab8ba28523ef10e365627fed64ef2b77cbf" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.36#cb4f2491b00af7d7817f3a54209c26b20faa1f51" dependencies = [ "frame-benchmarking", "frame-support", @@ -1792,6 +1978,7 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-inherents", + "sp-io", "sp-runtime", "sp-std", "sp-timestamp", @@ -1827,7 +2014,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.27#5bfdbab8ba28523ef10e365627fed64ef2b77cbf" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.36#cb4f2491b00af7d7817f3a54209c26b20faa1f51" dependencies = [ "frame-support", "frame-system", @@ -1874,13 +2061,14 @@ dependencies = [ [[package]] name = "parity-scale-codec" -version = "3.2.1" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "366e44391a8af4cfd6002ef6ba072bae071a96aafca98d7d448a34c5dca38b6a" +checksum = "637935964ff85a605d114591d4d2c13c5d1ba2806dae97cea6bf180238a749ac" dependencies = [ "arrayvec 0.7.2", "bitvec", "byte-slice-cast", + "bytes", "impl-trait-for-tuples", "parity-scale-codec-derive", "serde", @@ -1888,9 +2076,9 @@ dependencies = [ [[package]] name = "parity-scale-codec-derive" -version = "3.1.3" +version = "3.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9299338969a3d2f491d65f140b00ddec470858402f888af98e8642fb5e8965cd" +checksum = "86b26a931f824dd4eca30b3e43bb4f31cd5f0d3a403c5f5ff27106b805bfde7b" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -1898,37 +2086,11 @@ dependencies = [ "syn", ] -[[package]] -name = "parity-util-mem" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c32561d248d352148124f036cac253a644685a21dc9fea383eb4907d7bd35a8f" -dependencies = [ - "cfg-if", - "hashbrown", - "impl-trait-for-tuples", - "parity-util-mem-derive", - "parking_lot", - "primitive-types 0.11.1", - "winapi", -] - -[[package]] -name = "parity-util-mem-derive" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f557c32c6d268a07c921471619c0295f5efad3a0e76d4f97a05c091a51d110b2" -dependencies = [ - "proc-macro2", - "syn", - "synstructure", -] - [[package]] name = "parity-wasm" -version = "0.42.2" +version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be5e13c266502aadf83426d87d81a0f5d1ef45b8027f5a471c360abfe4bfae92" +checksum = "e1ad0aff30c1da14b1254fcb2af73e1fa9a28670e584a626f53a369d0e157304" [[package]] name = "parking_lot" @@ -1942,15 +2104,15 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.4" +version = "0.9.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dc9e0dc2adc1c69d09143aff38d3d30c5c3f0df0dad82e6d25547af174ebec0" +checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" dependencies = [ "cfg-if", "libc", "redox_syscall", "smallvec", - "windows-sys", + "windows-sys 0.45.0", ] [[package]] @@ -1965,9 +2127,9 @@ dependencies = [ [[package]] name = "paste" -version = "1.0.9" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1de2e551fb905ac83f73f7aedf2f0cb4a0da7e35efa24a202a936269f1f18e1" +checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" [[package]] name = "paste-impl" @@ -2012,28 +2174,38 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] -name = "ppv-lite86" -version = "0.2.16" +name = "pkcs8" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" - -[[package]] +checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" +dependencies = [ + "der", + "spki", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] name = "primitive-types" version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06345ee39fbccfb06ab45f3a1a5798d9dafa04cb8921a76d227040003a234b0e" dependencies = [ - "fixed-hash", + "fixed-hash 0.7.0", "uint", ] [[package]] name = "primitive-types" -version = "0.11.1" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e28720988bff275df1f51b171e1b2a18c30d194c4d2b61defdacecd625a5d94a" +checksum = "9f3486ccba82358b11a77516035647c34ba167dfa53312630de83b12bd4f3d66" dependencies = [ - "fixed-hash", + "fixed-hash 0.8.0", "impl-codec", "impl-serde", "scale-info", @@ -2042,13 +2214,12 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "1.2.1" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eda0fc3b0fb7c975631757e14d9049da17374063edb6ebbcbc54d880d4fe94e9" +checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" dependencies = [ "once_cell", - "thiserror", - "toml", + "toml_edit", ] [[package]] @@ -2059,18 +2230,27 @@ checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" [[package]] name = "proc-macro2" -version = "1.0.47" +version = "1.0.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725" +checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6" dependencies = [ "unicode-ident", ] +[[package]] +name = "psm" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5787f7cda34e3033a72192c018bc5883100330f362ef279a8cbccfce8bb4e874" +dependencies = [ + "cc", +] + [[package]] name = "quote" -version = "1.0.21" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" +checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" dependencies = [ "proc-macro2", ] @@ -2141,7 +2321,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.7", + "getrandom 0.2.8", ] [[package]] @@ -2189,18 +2369,18 @@ dependencies = [ [[package]] name = "ref-cast" -version = "1.0.12" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12a733f1746c929b4913fe48f8697fcf9c55e3304ba251a79ffb41adfeaf49c2" +checksum = "a9af2cf09ef80e610097515e80095b7f76660a92743c4185aff5406cd5ce3dd5" dependencies = [ "ref-cast-impl", ] [[package]] name = "ref-cast-impl" -version = "1.0.12" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5887de4a01acafd221861463be6113e6e87275e79804e56779f4cdc131c60368" +checksum = "9c501201393982e275433bc55de7d6ae6f00e7699cd5572c5b57581cd69c881b" dependencies = [ "proc-macro2", "quote", @@ -2209,9 +2389,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.6.0" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" +checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" dependencies = [ "aho-corasick", "memchr", @@ -2229,18 +2409,18 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.27" +version = "0.6.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" +checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" [[package]] name = "rfc6979" -version = "0.1.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96ef608575f6392792f9ecf7890c00086591d29a83910939d430753f7c050525" +checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" dependencies = [ "crypto-bigint", - "hmac 0.11.0", + "hmac 0.12.1", "zeroize", ] @@ -2271,17 +2451,31 @@ dependencies = [ "semver", ] +[[package]] +name = "rustix" +version = "0.35.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "727a1a6d65f786ec22df8a81ca3121107f235970dc1705ed681d3e6e8b9cd5f9" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys", + "windows-sys 0.42.0", +] + [[package]] name = "ryu" -version = "1.0.11" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" +checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" [[package]] name = "scale-info" -version = "2.2.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "333af15b02563b8182cd863f925bd31ef8fa86a0e095d30c091956057d436153" +checksum = "001cf62ece89779fd16105b5f515ad0e5cedcd5440d3dd806bb067978e7c3608" dependencies = [ "bitvec", "cfg-if", @@ -2293,9 +2487,9 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.2.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53f56acbd0743d29ffa08f911ab5397def774ad01bab3786804cf6ee057fb5e1" +checksum = "303959cf613a6f6efd19ed4b4ad5bf79966a13352716299ad532cfb115f4205c" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -2329,27 +2523,29 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "scratch" -version = "1.0.2" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8132065adcfd6e02db789d9285a0deb2f3fcb04002865ab67d5fb103533898" +checksum = "1792db035ce95be60c3f8853017b3999209281c24e2ba5bc8e59bf97a0c590c1" [[package]] name = "sec1" -version = "0.2.1" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08da66b8b0965a5555b6bd6639e68ccba85e1e2506f5fbb089e93f8a04e1a2d1" +checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" dependencies = [ + "base16ct", "der", "generic-array 0.14.6", + "pkcs8", "subtle", "zeroize", ] [[package]] name = "secp256k1" -version = "0.24.0" +version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7649a0b3ffb32636e60c7ce0d70511eda9c52c658cd0634e194d5a19943aeff" +checksum = "6b1629c9c557ef9b293568b338dddfc8208c98a18c59d722a9d53f859d9c9b62" dependencies = [ "secp256k1-sys", ] @@ -2374,24 +2570,24 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.14" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e25dfac463d778e353db5be2449d1cce89bd6fd23c9f1ea21310ce6e5a1b29c4" +checksum = "58bc9567378fc7690d6b2addae4e60ac2eeea07becb2c64b9f218b53865cba2a" [[package]] name = "serde" -version = "1.0.147" +version = "1.0.152" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965" +checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.147" +version = "1.0.152" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f1d362ca8fc9c3e3a7484440752472d68a6caa98f1ab81d99b5dfe517cec852" +checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" dependencies = [ "proc-macro2", "quote", @@ -2400,9 +2596,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.87" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce777b7b150d76b9cf60d28b55f5847135a003f7d7350c6be7a773508ce7d45" +checksum = "1c533a59c9d8a93a09c6ab31f0fd5e5f4dd1b8fc9434804029839884765d04ea" dependencies = [ "itoa", "ryu", @@ -2442,7 +2638,7 @@ checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" dependencies = [ "cfg-if", "cpufeatures", - "digest 0.10.5", + "digest 0.10.6", ] [[package]] @@ -2476,7 +2672,7 @@ version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bdf0c33fae925bdc080598b84bc15c55e7b9a4a43b3c704da051f977469691c9" dependencies = [ - "digest 0.10.5", + "digest 0.10.6", "keccak", ] @@ -2491,11 +2687,11 @@ dependencies = [ [[package]] name = "signature" -version = "1.4.0" +version = "1.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02658e48d89f2bec991f9a78e69cfa4c316f8d6a6c4ec12fae1aeb263d486788" +checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" dependencies = [ - "digest 0.9.0", + "digest 0.10.6", "rand_core 0.6.4", ] @@ -2508,14 +2704,14 @@ dependencies = [ "approx", "num-complex", "num-traits", - "paste 1.0.9", + "paste 1.0.12", ] [[package]] name = "similar" -version = "2.2.0" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62ac7f900db32bf3fd12e0117dd3dc4da74bc52ebaac97f39668446d89694803" +checksum = "420acb44afdae038210c99e69aae24109f32f15500aa708e81d46c9f29d55fcf" dependencies = [ "bstr", "unicode-segmentation", @@ -2542,9 +2738,9 @@ dependencies = [ [[package]] name = "slab" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" dependencies = [ "autocfg", ] @@ -2558,7 +2754,7 @@ checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" [[package]] name = "sp-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.27#5bfdbab8ba28523ef10e365627fed64ef2b77cbf" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.36#cb4f2491b00af7d7817f3a54209c26b20faa1f51" dependencies = [ "hash-db", "log", @@ -2568,6 +2764,7 @@ dependencies = [ "sp-runtime", "sp-state-machine", "sp-std", + "sp-trie", "sp-version", "thiserror", ] @@ -2575,7 +2772,7 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.27#5bfdbab8ba28523ef10e365627fed64ef2b77cbf" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.36#cb4f2491b00af7d7817f3a54209c26b20faa1f51" dependencies = [ "blake2", "proc-macro-crate", @@ -2586,8 +2783,8 @@ dependencies = [ [[package]] name = "sp-application-crypto" -version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.27#5bfdbab8ba28523ef10e365627fed64ef2b77cbf" +version = "7.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.36#cb4f2491b00af7d7817f3a54209c26b20faa1f51" dependencies = [ "parity-scale-codec", "scale-info", @@ -2599,8 +2796,8 @@ dependencies = [ [[package]] name = "sp-arithmetic" -version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.27#5bfdbab8ba28523ef10e365627fed64ef2b77cbf" +version = "6.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.36#cb4f2491b00af7d7817f3a54209c26b20faa1f51" dependencies = [ "integer-sqrt", "num-traits", @@ -2615,7 +2812,7 @@ dependencies = [ [[package]] name = "sp-authorship" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.27#5bfdbab8ba28523ef10e365627fed64ef2b77cbf" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.36#cb4f2491b00af7d7817f3a54209c26b20faa1f51" dependencies = [ "async-trait", "parity-scale-codec", @@ -2646,19 +2843,19 @@ dependencies = [ [[package]] name = "sp-core" -version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.27#5bfdbab8ba28523ef10e365627fed64ef2b77cbf" +version = "7.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.36#cb4f2491b00af7d7817f3a54209c26b20faa1f51" dependencies = [ + "array-bytes", "base58", "bitflags", - "blake2-rfc", + "blake2", "byteorder", "dyn-clonable", - "ed25519-dalek", + "ed25519-zebra", "futures", "hash-db", "hash256-std-hasher", - "hex", "impl-serde", "lazy_static", "libsecp256k1", @@ -2666,9 +2863,8 @@ dependencies = [ "merlin", "num-traits", "parity-scale-codec", - "parity-util-mem", "parking_lot", - "primitive-types 0.11.1", + "primitive-types 0.12.1", "rand 0.7.3", "regex", "scale-info", @@ -2692,12 +2888,12 @@ dependencies = [ [[package]] name = "sp-core-hashing" -version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.27#5bfdbab8ba28523ef10e365627fed64ef2b77cbf" +version = "5.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.36#cb4f2491b00af7d7817f3a54209c26b20faa1f51" dependencies = [ "blake2", "byteorder", - "digest 0.10.5", + "digest 0.10.6", "sha2 0.10.6", "sha3 0.10.6", "sp-std", @@ -2707,7 +2903,7 @@ dependencies = [ [[package]] name = "sp-core-hashing-proc-macro" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.27#5bfdbab8ba28523ef10e365627fed64ef2b77cbf" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.36#cb4f2491b00af7d7817f3a54209c26b20faa1f51" dependencies = [ "proc-macro2", "quote", @@ -2717,8 +2913,8 @@ dependencies = [ [[package]] name = "sp-debug-derive" -version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.27#5bfdbab8ba28523ef10e365627fed64ef2b77cbf" +version = "5.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.36#cb4f2491b00af7d7817f3a54209c26b20faa1f51" dependencies = [ "proc-macro2", "quote", @@ -2727,8 +2923,8 @@ dependencies = [ [[package]] name = "sp-externalities" -version = "0.12.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.27#5bfdbab8ba28523ef10e365627fed64ef2b77cbf" +version = "0.13.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.36#cb4f2491b00af7d7817f3a54209c26b20faa1f51" dependencies = [ "environmental", "parity-scale-codec", @@ -2739,7 +2935,7 @@ dependencies = [ [[package]] name = "sp-inherents" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.27#5bfdbab8ba28523ef10e365627fed64ef2b77cbf" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.36#cb4f2491b00af7d7817f3a54209c26b20faa1f51" dependencies = [ "async-trait", "impl-trait-for-tuples", @@ -2752,9 +2948,11 @@ dependencies = [ [[package]] name = "sp-io" -version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.27#5bfdbab8ba28523ef10e365627fed64ef2b77cbf" +version = "7.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.36#cb4f2491b00af7d7817f3a54209c26b20faa1f51" dependencies = [ + "bytes", + "ed25519-dalek", "futures", "hash-db", "libsecp256k1", @@ -2777,8 +2975,8 @@ dependencies = [ [[package]] name = "sp-keystore" -version = "0.12.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.27#5bfdbab8ba28523ef10e365627fed64ef2b77cbf" +version = "0.13.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.36#cb4f2491b00af7d7817f3a54209c26b20faa1f51" dependencies = [ "async-trait", "futures", @@ -2795,7 +2993,7 @@ dependencies = [ [[package]] name = "sp-npos-elections" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.27#5bfdbab8ba28523ef10e365627fed64ef2b77cbf" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.36#cb4f2491b00af7d7817f3a54209c26b20faa1f51" dependencies = [ "parity-scale-codec", "scale-info", @@ -2808,8 +3006,8 @@ dependencies = [ [[package]] name = "sp-panic-handler" -version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.27#5bfdbab8ba28523ef10e365627fed64ef2b77cbf" +version = "5.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.36#cb4f2491b00af7d7817f3a54209c26b20faa1f51" dependencies = [ "backtrace", "lazy_static", @@ -2818,16 +3016,15 @@ dependencies = [ [[package]] name = "sp-runtime" -version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.27#5bfdbab8ba28523ef10e365627fed64ef2b77cbf" +version = "7.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.36#cb4f2491b00af7d7817f3a54209c26b20faa1f51" dependencies = [ "either", "hash256-std-hasher", "impl-trait-for-tuples", "log", "parity-scale-codec", - "parity-util-mem", - "paste 1.0.9", + "paste 1.0.12", "rand 0.7.3", "scale-info", "serde", @@ -2836,16 +3033,18 @@ dependencies = [ "sp-core", "sp-io", "sp-std", + "sp-weights", ] [[package]] name = "sp-runtime-interface" -version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.27#5bfdbab8ba28523ef10e365627fed64ef2b77cbf" +version = "7.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.36#cb4f2491b00af7d7817f3a54209c26b20faa1f51" dependencies = [ + "bytes", "impl-trait-for-tuples", "parity-scale-codec", - "primitive-types 0.11.1", + "primitive-types 0.12.1", "sp-externalities", "sp-runtime-interface-proc-macro", "sp-std", @@ -2857,8 +3056,8 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" -version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.27#5bfdbab8ba28523ef10e365627fed64ef2b77cbf" +version = "6.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.36#cb4f2491b00af7d7817f3a54209c26b20faa1f51" dependencies = [ "Inflector", "proc-macro-crate", @@ -2870,7 +3069,7 @@ dependencies = [ [[package]] name = "sp-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.27#5bfdbab8ba28523ef10e365627fed64ef2b77cbf" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.36#cb4f2491b00af7d7817f3a54209c26b20faa1f51" dependencies = [ "parity-scale-codec", "scale-info", @@ -2884,18 +3083,19 @@ dependencies = [ [[package]] name = "sp-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.27#5bfdbab8ba28523ef10e365627fed64ef2b77cbf" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.36#cb4f2491b00af7d7817f3a54209c26b20faa1f51" dependencies = [ "parity-scale-codec", "scale-info", + "sp-core", "sp-runtime", "sp-std", ] [[package]] name = "sp-state-machine" -version = "0.12.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.27#5bfdbab8ba28523ef10e365627fed64ef2b77cbf" +version = "0.13.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.36#cb4f2491b00af7d7817f3a54209c26b20faa1f51" dependencies = [ "hash-db", "log", @@ -2916,13 +3116,13 @@ dependencies = [ [[package]] name = "sp-std" -version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.27#5bfdbab8ba28523ef10e365627fed64ef2b77cbf" +version = "5.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.36#cb4f2491b00af7d7817f3a54209c26b20faa1f51" [[package]] name = "sp-storage" -version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.27#5bfdbab8ba28523ef10e365627fed64ef2b77cbf" +version = "7.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.36#cb4f2491b00af7d7817f3a54209c26b20faa1f51" dependencies = [ "impl-serde", "parity-scale-codec", @@ -2935,7 +3135,7 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.27#5bfdbab8ba28523ef10e365627fed64ef2b77cbf" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.36#cb4f2491b00af7d7817f3a54209c26b20faa1f51" dependencies = [ "async-trait", "futures-timer", @@ -2950,8 +3150,8 @@ dependencies = [ [[package]] name = "sp-tracing" -version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.27#5bfdbab8ba28523ef10e365627fed64ef2b77cbf" +version = "6.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.36#cb4f2491b00af7d7817f3a54209c26b20faa1f51" dependencies = [ "parity-scale-codec", "sp-std", @@ -2962,16 +3162,23 @@ dependencies = [ [[package]] name = "sp-trie" -version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.27#5bfdbab8ba28523ef10e365627fed64ef2b77cbf" +version = "7.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.36#cb4f2491b00af7d7817f3a54209c26b20faa1f51" dependencies = [ + "ahash", "hash-db", + "hashbrown", + "lazy_static", + "lru", "memory-db", + "nohash-hasher", "parity-scale-codec", + "parking_lot", "scale-info", "sp-core", "sp-std", "thiserror", + "tracing", "trie-db", "trie-root", ] @@ -2979,7 +3186,7 @@ dependencies = [ [[package]] name = "sp-version" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.27#5bfdbab8ba28523ef10e365627fed64ef2b77cbf" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.36#cb4f2491b00af7d7817f3a54209c26b20faa1f51" dependencies = [ "impl-serde", "parity-scale-codec", @@ -2996,7 +3203,7 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.27#5bfdbab8ba28523ef10e365627fed64ef2b77cbf" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.36#cb4f2491b00af7d7817f3a54209c26b20faa1f51" dependencies = [ "parity-scale-codec", "proc-macro2", @@ -3006,21 +3213,48 @@ dependencies = [ [[package]] name = "sp-wasm-interface" -version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.27#5bfdbab8ba28523ef10e365627fed64ef2b77cbf" +version = "7.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.36#cb4f2491b00af7d7817f3a54209c26b20faa1f51" dependencies = [ "impl-trait-for-tuples", "log", "parity-scale-codec", "sp-std", "wasmi", + "wasmtime", +] + +[[package]] +name = "sp-weights" +version = "4.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.36#cb4f2491b00af7d7817f3a54209c26b20faa1f51" +dependencies = [ + "impl-trait-for-tuples", + "parity-scale-codec", + "scale-info", + "serde", + "smallvec", + "sp-arithmetic", + "sp-core", + "sp-debug-derive", + "sp-std", +] + +[[package]] +name = "spki" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" +dependencies = [ + "base64ct", + "der", ] [[package]] name = "ss58-registry" -version = "1.33.0" +version = "1.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ab7554f8a8b6f8d71cd5a8e6536ef116e2ce0504cf97ebf16311d58065dc8a6" +checksum = "ecf0bd63593ef78eca595a7fc25e9a443ca46fe69fd472f8f09f5245cdcd769d" dependencies = [ "Inflector", "num-format", @@ -3031,6 +3265,12 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + [[package]] name = "static_assertions" version = "1.1.0" @@ -3070,13 +3310,13 @@ source = "git+https://github.com/encointer/substrate-fixed#a4fb461aae6205ffc55be dependencies = [ "parity-scale-codec", "scale-info", - "typenum 1.16.0", + "typenum 1.16.0 (git+https://github.com/encointer/typenum?tag=v1.16.0)", ] [[package]] name = "substrate-test-utils" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.27#5bfdbab8ba28523ef10e365627fed64ef2b77cbf" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.36#cb4f2491b00af7d7817f3a54209c26b20faa1f51" dependencies = [ "futures", "substrate-test-utils-derive", @@ -3086,7 +3326,7 @@ dependencies = [ [[package]] name = "substrate-test-utils-derive" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.27#5bfdbab8ba28523ef10e365627fed64ef2b77cbf" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.36#cb4f2491b00af7d7817f3a54209c26b20faa1f51" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -3102,9 +3342,9 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "syn" -version = "1.0.103" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a864042229133ada95abf3b54fdc62ef5ccabe9515b64717bcb9a1919e59445d" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ "proc-macro2", "quote", @@ -3130,38 +3370,34 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] -name = "termcolor" -version = "1.1.3" +name = "target-lexicon" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" -dependencies = [ - "winapi-util", -] +checksum = "8ae9980cab1db3fceee2f6c6f643d5d8de2997c58ee8d25fb0cc8a9e9e7348e5" [[package]] -name = "terminal_size" -version = "0.1.17" +name = "termcolor" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "633c1a546cee861a1a6d0dc69ebeca693bf4296661ba7852b9d21d159e0506df" +checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" dependencies = [ - "libc", - "winapi", + "winapi-util", ] [[package]] name = "thiserror" -version = "1.0.37" +version = "1.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e" +checksum = "a5ab016db510546d856297882807df8da66a16fb8c4101cb8b30054b0d5b2d9c" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.37" +version = "1.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" +checksum = "5420d42e90af0c38c3290abcca25b9b3bdf379fc9f55c528f53a269d9c9a267e" dependencies = [ "proc-macro2", "quote", @@ -3170,10 +3406,11 @@ dependencies = [ [[package]] name = "thread_local" -version = "1.1.4" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180" +checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" dependencies = [ + "cfg-if", "once_cell", ] @@ -3216,26 +3453,27 @@ dependencies = [ [[package]] name = "tinyvec_macros" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.21.2" +version = "1.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9e03c497dc955702ba729190dc4aac6f2a0ce97f913e5b1b5912fc5039d9099" +checksum = "03201d01c3c27a29c8a5cee5b55a93ddae1ccf6f08f65365c2c918f8c1b76f64" dependencies = [ "autocfg", "pin-project-lite", "tokio-macros", + "windows-sys 0.45.0", ] [[package]] name = "tokio-macros" -version = "1.8.0" +version = "1.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9724f9a975fb987ef7a3cd9be0350edcbe130698af5b8f7a631e23d42d052484" +checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8" dependencies = [ "proc-macro2", "quote", @@ -3243,12 +3481,20 @@ dependencies = [ ] [[package]] -name = "toml" -version = "0.5.9" +name = "toml_datetime" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" +checksum = "3ab8ed2edee10b50132aed5f331333428b011c99402b5a534154ed15746f9622" + +[[package]] +name = "toml_edit" +version = "0.19.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a1eb0622d28f4b9c90adc4ea4b2b46b47663fde9ac5fafcb14a1369d5508825" dependencies = [ - "serde", + "indexmap", + "toml_datetime", + "winnow", ] [[package]] @@ -3329,9 +3575,9 @@ dependencies = [ [[package]] name = "trie-db" -version = "0.23.1" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d32d034c0d3db64b43c31de38e945f15b40cd4ca6d2dcfc26d4798ce8de4ab83" +checksum = "004e1e8f92535694b4cb1444dc5a8073ecf0815e3357f729638b9f8fc4062908" dependencies = [ "hash-db", "hashbrown", @@ -3351,9 +3597,9 @@ dependencies = [ [[package]] name = "tt-call" -version = "1.0.8" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e66dcbec4290c69dd03c57e76c2469ea5c7ce109c6dd4351c13055cf71ea055" +checksum = "f4f195fd851901624eee5a58c4bb2b4f06399148fcd0ed336e6f1cb60a9881df" [[package]] name = "twox-hash" @@ -3362,16 +3608,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ "cfg-if", - "digest 0.10.5", + "digest 0.10.6", "rand 0.8.5", "static_assertions", ] [[package]] name = "typenum" -version = "1.15.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" +checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" [[package]] name = "typenum" @@ -3384,9 +3630,9 @@ dependencies = [ [[package]] name = "uint" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a45526d29728d135c2900b0d30573fe3ee79fceb12ef534c7bb30e810a91b601" +checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" dependencies = [ "byteorder", "crunchy", @@ -3396,9 +3642,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.5" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" +checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" [[package]] name = "unicode-normalization" @@ -3411,9 +3657,9 @@ dependencies = [ [[package]] name = "unicode-segmentation" -version = "1.10.0" +version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fdbf052a0783de01e944a6ce7a8cb939e295b1e7be835a1112c3b9a7f047a5a" +checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" [[package]] name = "unicode-width" @@ -3453,9 +3699,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.83" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" +checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -3463,9 +3709,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.83" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" +checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" dependencies = [ "bumpalo", "log", @@ -3478,9 +3724,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.83" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" +checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3488,9 +3734,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.83" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" +checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" dependencies = [ "proc-macro2", "quote", @@ -3501,34 +3747,174 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.83" +version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" +checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" [[package]] name = "wasmi" -version = "0.9.1" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca00c5147c319a8ec91ec1a0edbec31e566ce2c9cc93b3f9bb86a9efd0eb795d" +checksum = "06c326c93fbf86419608361a2c925a31754cf109da1b8b55737070b4d6669422" dependencies = [ - "downcast-rs", - "libc", - "memory_units", - "num-rational 0.2.4", - "num-traits", "parity-wasm", "wasmi-validation", + "wasmi_core", ] [[package]] name = "wasmi-validation" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "165343ecd6c018fc09ebcae280752702c9a2ef3e6f8d02f1cfcbdb53ef6d7937" +checksum = "91ff416ad1ff0c42e5a926ed5d5fab74c0f098749aa0ad8b2a34b982ce0e867b" dependencies = [ "parity-wasm", ] +[[package]] +name = "wasmi_core" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57d20cb3c59b788653d99541c646c561c9dd26506f25c0cebfe810659c54c6d7" +dependencies = [ + "downcast-rs", + "libm", + "memory_units", + "num-rational", + "num-traits", +] + +[[package]] +name = "wasmparser" +version = "0.89.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab5d3e08b13876f96dd55608d03cd4883a0545884932d5adf11925876c96daef" +dependencies = [ + "indexmap", +] + +[[package]] +name = "wasmtime" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ad5af6ba38311282f2a21670d96e78266e8c8e2f38cbcd52c254df6ccbc7731" +dependencies = [ + "anyhow", + "bincode", + "cfg-if", + "indexmap", + "libc", + "log", + "object 0.29.0", + "once_cell", + "paste 1.0.12", + "psm", + "serde", + "target-lexicon", + "wasmparser", + "wasmtime-environ", + "wasmtime-jit", + "wasmtime-runtime", + "windows-sys 0.36.1", +] + +[[package]] +name = "wasmtime-asm-macros" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45de63ddfc8b9223d1adc8f7b2ee5f35d1f6d112833934ad7ea66e4f4339e597" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "wasmtime-environ" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebb881c61f4f627b5d45c54e629724974f8a8890d455bcbe634330cc27309644" +dependencies = [ + "anyhow", + "cranelift-entity", + "gimli 0.26.2", + "indexmap", + "log", + "object 0.29.0", + "serde", + "target-lexicon", + "thiserror", + "wasmparser", + "wasmtime-types", +] + +[[package]] +name = "wasmtime-jit" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1985c628011fe26adf5e23a5301bdc79b245e0e338f14bb58b39e4e25e4d8681" +dependencies = [ + "addr2line 0.17.0", + "anyhow", + "bincode", + "cfg-if", + "cpp_demangle", + "gimli 0.26.2", + "log", + "object 0.29.0", + "rustc-demangle", + "rustix", + "serde", + "target-lexicon", + "thiserror", + "wasmtime-environ", + "wasmtime-runtime", + "windows-sys 0.36.1", +] + +[[package]] +name = "wasmtime-jit-debug" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f671b588486f5ccec8c5a3dba6b4c07eac2e66ab8c60e6f4e53717c77f709731" +dependencies = [ + "once_cell", +] + +[[package]] +name = "wasmtime-runtime" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee8f92ad4b61736339c29361da85769ebc200f184361959d1792832e592a1afd" +dependencies = [ + "anyhow", + "cc", + "cfg-if", + "indexmap", + "libc", + "log", + "mach", + "memoffset", + "paste 1.0.12", + "rand 0.8.5", + "rustix", + "thiserror", + "wasmtime-asm-macros", + "wasmtime-environ", + "wasmtime-jit-debug", + "windows-sys 0.36.1", +] + +[[package]] +name = "wasmtime-types" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d23d61cb4c46e837b431196dd06abb11731541021916d03476a178b54dc07aeb" +dependencies = [ + "cranelift-entity", + "serde", + "thiserror", + "wasmparser", +] + [[package]] name = "winapi" version = "0.3.9" @@ -3560,6 +3946,19 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-sys" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" +dependencies = [ + "windows_aarch64_msvc 0.36.1", + "windows_i686_gnu 0.36.1", + "windows_i686_msvc 0.36.1", + "windows_x86_64_gnu 0.36.1", + "windows_x86_64_msvc 0.36.1", +] + [[package]] name = "windows-sys" version = "0.42.0" @@ -3567,61 +3966,124 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" dependencies = [ "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", + "windows_aarch64_msvc 0.42.1", + "windows_i686_gnu 0.42.1", + "windows_i686_msvc 0.42.1", + "windows_x86_64_gnu 0.42.1", "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_x86_64_msvc 0.42.1", +] + +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc 0.42.1", + "windows_i686_gnu 0.42.1", + "windows_i686_msvc 0.42.1", + "windows_x86_64_gnu 0.42.1", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc 0.42.1", ] [[package]] name = "windows_aarch64_gnullvm" -version = "0.42.0" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e" +checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" [[package]] name = "windows_aarch64_msvc" -version = "0.42.0" +version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4" +checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" [[package]] name = "windows_i686_gnu" -version = "0.42.0" +version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7" +checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" [[package]] name = "windows_i686_msvc" -version = "0.42.0" +version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246" +checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" [[package]] name = "windows_x86_64_gnu" -version = "0.42.0" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed" +checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" [[package]] name = "windows_x86_64_gnullvm" -version = "0.42.0" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028" +checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" [[package]] name = "windows_x86_64_msvc" -version = "0.42.0" +version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5" +checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" + +[[package]] +name = "winnow" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c95fb4ff192527911dd18eb138ac30908e7165b8944e528b6af93aa4c842d345" +dependencies = [ + "memchr", +] [[package]] name = "wyz" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30b31594f29d27036c383b53b59ed3476874d518f0efb151b27a4c275141390e" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" dependencies = [ "tap", ] @@ -3637,9 +4099,9 @@ dependencies = [ [[package]] name = "zeroize_derive" -version = "1.3.2" +version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f8f187641dad4f680d25c4bfc4225b418165984179f26ca76ec4fb6441d3a17" +checksum = "44bf07cb3e50ea2003396695d58bf46bc9887a1f362260446fad6bc4e79bd36c" dependencies = [ "proc-macro2", "quote", diff --git a/README.md b/README.md index 0b547ee6f..b22ac9bd0 100644 --- a/README.md +++ b/README.md @@ -17,3 +17,21 @@ We welcome contributions but before you devote quite a bit of time to contributi Read our contribution guide [HERE](./CONTRIBUTING.adoc). Note: This repository is managed frequently so you do not need to email/contact us to notify us of your submission. + +## Building and testing the pallets + +To build and test a pallet, navigate to the directory of the pallet in your project by running the following command: +```sh +cd pallets// +``` +Once you're in the pallet directory, use cargo to build and test the pallet by running the following commands: +```sh +# Build the pallet +cargo build + +# Run the unit and integration tests +cargo test + +# Test the benchmark tests +cargo test --features runtime-benchmarks +``` diff --git a/pallets/avn-finality-tracker/Cargo.toml b/pallets/avn-finality-tracker/Cargo.toml index 15b571c80..b371788c6 100644 --- a/pallets/avn-finality-tracker/Cargo.toml +++ b/pallets/avn-finality-tracker/Cargo.toml @@ -12,30 +12,31 @@ codec = { package = "parity-scale-codec", version = "3.0.0", default-features = hex = { version = "0.4.3", default-features = false, features = ["alloc"] } scale-info = { version = "2.0", default-features = false, features = ["derive"] } -sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -sp-io = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -sp-application-crypto = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } +sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +sp-io = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +sp-application-crypto = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } sp-avn-common = { version = "0.12.0", default-features = false, path = "../../primitives/avn-common" } -frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -frame-system = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } +frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +frame-system = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } pallet-avn = { version = "0.12.0", default-features = false, path = "../avn" } # Optional imports serde = { version = "1.0.137", optional = true } -frame-benchmarking = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27", optional = true } +frame-benchmarking = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", optional = true } [dev-dependencies] hex-literal = { version = "0.3.4", default-features = false } parking_lot = { version = "0.12.0" } -pallet-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -substrate-test-utils = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } +pallet-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +substrate-test-utils = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } [features] migrate = [] default = ["std"] std = [ + "frame-benchmarking?/std", "serde", "codec/std", "sp-std/std", @@ -48,7 +49,7 @@ std = [ "pallet-avn/std" ] runtime-benchmarks = [ - "frame-benchmarking", + "frame-benchmarking/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", ] \ No newline at end of file diff --git a/pallets/avn-finality-tracker/src/benchmarking.rs b/pallets/avn-finality-tracker/src/benchmarking.rs index 12122fd06..2ce8bad15 100644 --- a/pallets/avn-finality-tracker/src/benchmarking.rs +++ b/pallets/avn-finality-tracker/src/benchmarking.rs @@ -5,7 +5,7 @@ #![cfg(feature = "runtime-benchmarks")] -use super::*; +use crate::*; use frame_benchmarking::{account, benchmarks, impl_benchmark_test_suite}; use frame_system::RawOrigin; diff --git a/pallets/avn-finality-tracker/src/default_weights.rs b/pallets/avn-finality-tracker/src/default_weights.rs index 52d8c57a9..b808736e6 100644 --- a/pallets/avn-finality-tracker/src/default_weights.rs +++ b/pallets/avn-finality-tracker/src/default_weights.rs @@ -64,11 +64,11 @@ impl WeightInfo for SubstrateWeight { // Storage: AvnFinalityTracker LastFinalisedBlockSubmission (r:0 w:1) /// The range of component `v` is `[3, 10]`. fn submit_latest_finalised_block_number(v: u32, ) -> Weight { - (19_069_000 as Weight) + (Weight::from_ref_time(19_069_000)) // Standard Error: 18_000 - .saturating_add((118_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(118_000)).saturating_mul(v as u64) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(2)) } } @@ -80,10 +80,10 @@ impl WeightInfo for () { // Storage: AvnFinalityTracker LastFinalisedBlockSubmission (r:0 w:1) /// The range of component `v` is `[3, 10]`. fn submit_latest_finalised_block_number(v: u32, ) -> Weight { - (19_069_000 as Weight) + (Weight::from_ref_time(19_069_000)) // Standard Error: 18_000 - .saturating_add((118_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(118_000)).saturating_mul(v as u64) + .saturating_add(RocksDbWeight::get().reads(3)) + .saturating_add(RocksDbWeight::get().writes(2)) } } \ No newline at end of file diff --git a/pallets/avn-finality-tracker/src/lib.rs b/pallets/avn-finality-tracker/src/lib.rs index ff0363f20..443c384fd 100644 --- a/pallets/avn-finality-tracker/src/lib.rs +++ b/pallets/avn-finality-tracker/src/lib.rs @@ -47,6 +47,7 @@ const MAX_VALIDATOR_ACCOUNT_IDS: u32 = 10; pub type AVN = avn::Pallet; #[cfg(test)] +#[path = "mock.rs"] mod mock; mod benchmarking; @@ -65,9 +66,9 @@ pub mod pallet { SendTransactionTypes> + frame_system::Config + avn::Config { /// Overarching event type - type Event: From> - + IsType<::Event> - + Into<::Event>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent> + + Into<::RuntimeEvent>; /// The number of block we can keep the calculated finalised block, before recalculating it /// again. type CacheAge: Get; @@ -131,6 +132,7 @@ pub mod pallet { #[pallet::weight( ::WeightInfo::submit_latest_finalised_block_number(MAX_VALIDATOR_ACCOUNT_IDS) )] + #[pallet::call_index(0)] pub fn submit_latest_finalised_block_number( origin: OriginFor, new_finalised_block_number: T::BlockNumber, @@ -219,9 +221,21 @@ pub mod pallet { } } +#[derive(Encode, Decode, Default, Clone, Copy, PartialEq, Debug, Eq, TypeInfo, MaxEncodedLen)] +pub struct SubmissionData { + pub finalised_block: BlockNumber, + pub submitted_at_block: BlockNumber, +} + +impl SubmissionData { + pub fn new(finalised_block: BlockNumber, submitted_at_block: BlockNumber) -> Self { + return SubmissionData:: { finalised_block, submitted_at_block } + } +} + impl Pallet { - /// This function will only update the finalised block if there are 2/3rd or more submissions - /// from distinct validators + /// This function will only update the finalised block if there are 2/3rd or more + /// submissions from distinct validators pub fn update_latest_finalised_block_if_required() { let quorum = AVN::::calculate_two_third_quorum(); let current_block_number = >::block_number(); @@ -246,7 +260,8 @@ impl Pallet { }); } - // check if there is something wrong with submissions in general and notify via an event + // check if there is something wrong with submissions in general and notify via an + // event if current_block_number - last_finalised_block_submission > T::ReportLatency::get() { Self::deposit_event(Event::::FinalisedBlockUpdateStalled { block: last_finalised_block_submission, @@ -329,9 +344,9 @@ impl Pallet { return } - // send a transaction on chain with the latest finalised block data. We shouldn't have any - // sig re-use issue here because new block number must be > current finalised block - // number + // send a transaction on chain with the latest finalised block data. We shouldn't have + // any sig re-use issue here because new block number must be > current + // finalised block number let signature = this_validator .key .sign(&(UPDATE_FINALISED_BLOCK_NUMBER_CONTEXT, calculated_finalised_block).encode()) @@ -453,15 +468,3 @@ impl FinalisedBlockChecker for Pallet { return Self::latest_finalised_block_number() >= block_number } } - -#[derive(Encode, Decode, Default, Clone, Copy, PartialEq, Debug, Eq, TypeInfo, MaxEncodedLen)] -pub struct SubmissionData { - pub finalised_block: BlockNumber, - pub submitted_at_block: BlockNumber, -} - -impl SubmissionData { - fn new(finalised_block: BlockNumber, submitted_at_block: BlockNumber) -> Self { - return SubmissionData:: { finalised_block, submitted_at_block } - } -} diff --git a/pallets/avn-finality-tracker/src/mock.rs b/pallets/avn-finality-tracker/src/mock.rs index 6e864a402..511b9422c 100644 --- a/pallets/avn-finality-tracker/src/mock.rs +++ b/pallets/avn-finality-tracker/src/mock.rs @@ -11,7 +11,7 @@ use sp_runtime::{ traits::{BlakeTwo256, IdentityLookup}, }; -pub type Extrinsic = TestXt; +pub type Extrinsic = TestXt; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; @@ -34,8 +34,8 @@ parameter_types! { pub const ReportLatency: u64 = 1000; } -impl Config for TestRuntime { - type Event = Event; +impl avn_finality_tracker::Config for TestRuntime { + type RuntimeEvent = RuntimeEvent; type CacheAge = CacheAge; type SubmissionInterval = SubmissionInterval; type ReportLatency = ReportLatency; @@ -51,8 +51,8 @@ impl system::Config for TestRuntime { type BlockWeights = (); type BlockLength = (); type DbWeight = (); - type Origin = Origin; - type Call = Call; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; type Index = u64; type BlockNumber = u64; type Hash = H256; @@ -60,7 +60,7 @@ impl system::Config for TestRuntime { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type Version = (); type PalletInfo = PalletInfo; @@ -83,9 +83,9 @@ impl avn::Config for TestRuntime { impl frame_system::offchain::SendTransactionTypes for TestRuntime where - Call: From, + RuntimeCall: From, { - type OverarchingCall = Call; + type OverarchingCall = RuntimeCall; type Extrinsic = Extrinsic; } diff --git a/pallets/avn-offence-handler/Cargo.toml b/pallets/avn-offence-handler/Cargo.toml index 9fd008199..85a4713fd 100644 --- a/pallets/avn-offence-handler/Cargo.toml +++ b/pallets/avn-offence-handler/Cargo.toml @@ -8,29 +8,30 @@ homepage = "http://www.aventus.io/" repository = "https://github.com/Aventus-Network-Services/avn-parachain/" [dependencies] -frame-system = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } +frame-system = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } sp-avn-common = { version = "0.12.0", default-features = false, path = "../../primitives/avn-common" } -sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -sp-staking = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } +sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +sp-staking = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } pallet-avn = { version = "0.12.0", default-features = false, path = "../avn" } -pallet-session = { default-features = false, features = ["historical"], git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } +pallet-session = { default-features = false, features = ["historical"], git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } # Optional imports for benchmarking -frame-benchmarking = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27", optional = true } +frame-benchmarking = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", optional = true } [dev-dependencies] serde = { version = "1.0.101"} parking_lot = { version = "0.12.0" } -sp-io = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } +sp-io = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } [features] default = ["std"] std = [ + "frame-benchmarking?/std", "codec/std", "frame-support/std", "frame-system/std", @@ -42,7 +43,7 @@ std = [ "pallet-avn/std", ] runtime-benchmarks = [ - "frame-benchmarking", + "frame-benchmarking/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", ] \ No newline at end of file diff --git a/pallets/avn-offence-handler/src/benchmarking.rs b/pallets/avn-offence-handler/src/benchmarking.rs index 53d1ba143..bd396ea93 100644 --- a/pallets/avn-offence-handler/src/benchmarking.rs +++ b/pallets/avn-offence-handler/src/benchmarking.rs @@ -27,9 +27,9 @@ impl_benchmark_test_suite!( crate::mock::TestRuntime, ); -fn assert_last_event(generic_event: ::Event) { +fn assert_last_event(generic_event: ::RuntimeEvent) { let events = frame_system::Pallet::::events(); - let system_event: ::Event = generic_event.into(); + let system_event: ::RuntimeEvent = generic_event.into(); // compare to the last event record let EventRecord { event, .. } = &events[events.len().saturating_sub(1 as usize)]; assert_eq!(event, &system_event); diff --git a/pallets/avn-offence-handler/src/default_weights.rs b/pallets/avn-offence-handler/src/default_weights.rs index 30355b993..db320ce7a 100644 --- a/pallets/avn-offence-handler/src/default_weights.rs +++ b/pallets/avn-offence-handler/src/default_weights.rs @@ -60,8 +60,8 @@ pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { // Storage: AvnOffenceHandler SlashingEnabled (r:0 w:1) fn configure_slashing() -> Weight { - (15_281_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + (Weight::from_ref_time(15_281_000)) + .saturating_add(T::DbWeight::get().writes(1)) } } @@ -69,7 +69,7 @@ impl WeightInfo for SubstrateWeight { impl WeightInfo for () { // Storage: AvnOffenceHandler SlashingEnabled (r:0 w:1) fn configure_slashing() -> Weight { - (15_281_000 as Weight) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + (Weight::from_ref_time(15_281_000)) + .saturating_add(RocksDbWeight::get().writes(1)) } } \ No newline at end of file diff --git a/pallets/avn-offence-handler/src/lib.rs b/pallets/avn-offence-handler/src/lib.rs index d762af8e1..91dc1a74d 100644 --- a/pallets/avn-offence-handler/src/lib.rs +++ b/pallets/avn-offence-handler/src/lib.rs @@ -38,9 +38,9 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config + session::historical::Config { /// The overarching event type. - type Event: From> - + Into<::Event> - + IsType<::Event>; + type RuntimeEvent: From> + + Into<::RuntimeEvent> + + IsType<::RuntimeEvent>; /// A trait responsible for punishing malicious validators type Enforcer: Enforcer<::ValidatorId>; @@ -82,6 +82,7 @@ pub mod pallet { #[pallet::call] impl Pallet { #[pallet::weight(::WeightInfo::configure_slashing())] + #[pallet::call_index(0)] pub fn configure_slashing(origin: OriginFor, enabled: bool) -> DispatchResult { let _sender = ensure_root(origin)?; >::put(enabled); @@ -108,7 +109,7 @@ impl OnOffenceHandler, Weight> f _session: SessionIndex, _disable_strategy: DisableStrategy, ) -> Weight { - let mut consumed_weight: Weight = 0; + let mut consumed_weight: Weight = Weight::from_ref_time(0); let mut add_db_reads_writes = |reads, writes| { consumed_weight += T::DbWeight::get().reads_writes(reads, writes); }; diff --git a/pallets/avn-offence-handler/src/mock.rs b/pallets/avn-offence-handler/src/mock.rs index 49ae13681..c93ed611c 100644 --- a/pallets/avn-offence-handler/src/mock.rs +++ b/pallets/avn-offence-handler/src/mock.rs @@ -40,7 +40,7 @@ frame_support::construct_runtime!( pub type ValidatorId = ::ValidatorId; impl Config for TestRuntime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type Enforcer = Self; type WeightInfo = (); } @@ -78,7 +78,7 @@ impl session::Config for TestRuntime { type Keys = UintAuthorityId; type ShouldEndSession = session::PeriodicSessions; type SessionHandler = (AVN,); - type Event = Event; + type RuntimeEvent = RuntimeEvent; type ValidatorId = u64; type ValidatorIdOf = ConvertInto; type NextSessionRotation = session::PeriodicSessions; @@ -94,8 +94,8 @@ impl system::Config for TestRuntime { type BlockWeights = (); type BlockLength = (); type DbWeight = (); - type Origin = Origin; - type Call = Call; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; type Index = u64; type BlockNumber = u64; type Hash = H256; @@ -103,7 +103,7 @@ impl system::Config for TestRuntime { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type Version = (); type PalletInfo = PalletInfo; diff --git a/pallets/avn-offence-handler/src/tests.rs b/pallets/avn-offence-handler/src/tests.rs index 3d8992451..3485c0283 100644 --- a/pallets/avn-offence-handler/src/tests.rs +++ b/pallets/avn-offence-handler/src/tests.rs @@ -103,17 +103,13 @@ mod on_offence { DisableStrategy::Never, ); - assert!(event_emitted(&mock::Event::AvnOffenceHandler(crate::Event::< - TestRuntime, - >::ReportedOffence { - offender: VALIDATOR_ID_1 - }))); + assert!(event_emitted(&mock::RuntimeEvent::AvnOffenceHandler( + crate::Event::::ReportedOffence { offender: VALIDATOR_ID_1 } + ))); - assert!(event_emitted(&mock::Event::AvnOffenceHandler(crate::Event::< - TestRuntime, - >::ReportedOffence { - offender: VALIDATOR_ID_2 - }))); + assert!(event_emitted(&mock::RuntimeEvent::AvnOffenceHandler( + crate::Event::::ReportedOffence { offender: VALIDATOR_ID_2 } + ))); }); } } @@ -174,17 +170,13 @@ mod on_offence { DisableStrategy::Never, ); - assert!(event_emitted(&mock::Event::AvnOffenceHandler(crate::Event::< - TestRuntime, - >::ReportedOffence { - offender: VALIDATOR_ID_1 - }))); + assert!(event_emitted(&mock::RuntimeEvent::AvnOffenceHandler( + crate::Event::::ReportedOffence { offender: VALIDATOR_ID_1 } + ))); - assert!(event_emitted(&mock::Event::AvnOffenceHandler(crate::Event::< - TestRuntime, - >::ReportedOffence { - offender: VALIDATOR_ID_2 - }))); + assert!(event_emitted(&mock::RuntimeEvent::AvnOffenceHandler( + crate::Event::::ReportedOffence { offender: VALIDATOR_ID_2 } + ))); }); } } @@ -222,11 +214,11 @@ mod on_offence { // action is successful or not assert_eq!( true, - event_emitted(&mock::Event::AvnOffenceHandler( - crate::Event::::ReportedOffence { - offender: VALIDATOR_ID_CAN_CAUSE_SLASH_ERROR - } - )) + event_emitted(&mock::RuntimeEvent::AvnOffenceHandler(crate::Event::< + TestRuntime, + >::ReportedOffence { + offender: VALIDATOR_ID_CAN_CAUSE_SLASH_ERROR + })) ); }); } @@ -262,23 +254,25 @@ mod on_offence { // action is successful or not assert_eq!( true, - event_emitted(&mock::Event::AvnOffenceHandler( - crate::Event::::ReportedOffence { offender: VALIDATOR_ID_1 } - )) + event_emitted(&mock::RuntimeEvent::AvnOffenceHandler(crate::Event::< + TestRuntime, + >::ReportedOffence { + offender: VALIDATOR_ID_1 + })) ); assert_eq!( true, - event_emitted(&mock::Event::AvnOffenceHandler( - crate::Event::::ReportedOffence { - offender: VALIDATOR_ID_CAN_CAUSE_SLASH_ERROR - } - )) + event_emitted(&mock::RuntimeEvent::AvnOffenceHandler(crate::Event::< + TestRuntime, + >::ReportedOffence { + offender: VALIDATOR_ID_CAN_CAUSE_SLASH_ERROR + })) ); }); } } } -pub fn event_emitted(event: &mock::Event) -> bool { +pub fn event_emitted(event: &mock::RuntimeEvent) -> bool { return System::events().iter().any(|a| a.event == *event) } diff --git a/pallets/avn-proxy/Cargo.toml b/pallets/avn-proxy/Cargo.toml index a0f8583cb..7989315f7 100644 --- a/pallets/avn-proxy/Cargo.toml +++ b/pallets/avn-proxy/Cargo.toml @@ -17,21 +17,21 @@ hex-literal = { version = "0.3.4", default-features = false } scale-info = { version = "2.0", default-features = false, features = ["derive"] } sp-avn-common = { version = "0.12.0", default-features = false, path = "../../primitives/avn-common" } -sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -frame-system = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } +sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +frame-system = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } # Optional imports for benchmarking serde = { version = "1.0.137", optional = true } -frame-benchmarking = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27", optional = true } +frame-benchmarking = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", optional = true } [dev-dependencies] -sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -substrate-test-utils = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } +sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +substrate-test-utils = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } pallet-nft-manager = { version = "0.12.0", path = "../nft-manager" } pallet-avn = { version = "0.12.0", path = "../avn" } parking_lot = { version = "0.12.0" } @@ -39,6 +39,7 @@ parking_lot = { version = "0.12.0" } [features] default = ["std"] std = [ + "frame-benchmarking?/std", "serde", "codec/std", "sp-std/std", @@ -48,7 +49,7 @@ std = [ "sp-avn-common/std", ] runtime-benchmarks = [ - "frame-benchmarking", + "frame-benchmarking/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", ] diff --git a/pallets/avn-proxy/src/benchmarking.rs b/pallets/avn-proxy/src/benchmarking.rs index 0dec211c3..e142239aa 100644 --- a/pallets/avn-proxy/src/benchmarking.rs +++ b/pallets/avn-proxy/src/benchmarking.rs @@ -5,16 +5,11 @@ #![cfg(feature = "runtime-benchmarks")] -use super::*; +use super::{pallet::*, *}; use frame_benchmarking::{benchmarks, impl_benchmark_test_suite, whitelisted_caller}; use hex_literal::hex; use sp_core::{sr25519, H256}; -#[cfg(not(feature = "std"))] -extern crate alloc; -#[cfg(not(feature = "std"))] -use alloc::string::{String, ToString}; - use crate::Pallet as AvnProxy; fn get_proof( diff --git a/pallets/avn-proxy/src/default_weights.rs b/pallets/avn-proxy/src/default_weights.rs index 5e42ad351..6570169e0 100644 --- a/pallets/avn-proxy/src/default_weights.rs +++ b/pallets/avn-proxy/src/default_weights.rs @@ -61,9 +61,9 @@ impl WeightInfo for SubstrateWeight { // Storage: AvnProxy PaymentNonces (r:1 w:1) // Storage: System Account (r:1 w:1) fn charge_fee() -> Weight { - (114_288_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + (Weight::from_ref_time(114_288_000)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } } @@ -72,8 +72,8 @@ impl WeightInfo for () { // Storage: AvnProxy PaymentNonces (r:1 w:1) // Storage: System Account (r:1 w:1) fn charge_fee() -> Weight { - (114_288_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + (Weight::from_ref_time(14_288_000)) + .saturating_add(RocksDbWeight::get().reads(2)) + .saturating_add(RocksDbWeight::get().writes(2)) } } \ No newline at end of file diff --git a/pallets/avn-proxy/src/lib.rs b/pallets/avn-proxy/src/lib.rs index 600d9698d..918f1a5c4 100644 --- a/pallets/avn-proxy/src/lib.rs +++ b/pallets/avn-proxy/src/lib.rs @@ -9,11 +9,10 @@ use codec::{Decode, Encode}; use frame_support::{ - dispatch::DispatchResultWithPostInfo, + dispatch::{DispatchResult, DispatchResultWithPostInfo, GetDispatchInfo, PostDispatchInfo}, ensure, + pallet_prelude::ValueQuery, traits::{Currency, ExistenceRequirement, IsSubType}, - weights::{GetDispatchInfo, PostDispatchInfo}, - Parameter, }; use frame_system::{self as system, ensure_signed}; use sp_avn_common::{InnerCallValidator, Proof, CLOSE_BYTES_TAG, OPEN_BYTES_TAG}; @@ -23,7 +22,6 @@ pub use pallet::*; use sp_runtime::{ scale_info::TypeInfo, traits::{Dispatchable, Hash, IdentifyAccount, Member, Verify}, - DispatchResult, }; use sp_std::prelude::*; @@ -32,19 +30,22 @@ pub const PAYMENT_AUTH_CONTEXT: &'static [u8] = b"authorization for proxy paymen #[frame_support::pallet] pub mod pallet { use super::*; - use frame_support::{pallet_prelude::*, Blake2_128Concat}; + use frame_support::{ + pallet_prelude::{DispatchResult, *}, + Blake2_128Concat, + }; use frame_system::pallet_prelude::*; #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type Event: From> - + Into<::Event> - + IsType<::Event>; + type RuntimeEvent: From> + + Into<::RuntimeEvent> + + IsType<::RuntimeEvent>; /// The overarching call type - type Call: Parameter - + Dispatchable + type RuntimeCall: Parameter + + Dispatchable + GetDispatchInfo + From> + IsSubType>; @@ -68,8 +69,8 @@ pub mod pallet { + Ord + PartialOrd + Default - + ProvableProxy<::Call, Self::Signature, Self::AccountId> - + InnerCallValidator::Call>; + + ProvableProxy<::RuntimeCall, Self::Signature, Self::AccountId> + + InnerCallValidator::RuntimeCall>; type WeightInfo: WeightInfo; } @@ -101,14 +102,16 @@ pub mod pallet { #[pallet::call] impl Pallet { - #[pallet::weight(::WeightInfo::charge_fee().saturating_add(call.get_dispatch_info().weight).saturating_add(50_000))] + #[pallet::call_index(0)] + #[pallet::weight(::WeightInfo::charge_fee().saturating_add(call.get_dispatch_info().weight).saturating_add(Weight::from_ref_time(50_000)))] pub fn proxy( origin: OriginFor, - call: Box<::Call>, + call: Box<::RuntimeCall>, payment_info: Option, T::Signature>>>, ) -> DispatchResultWithPostInfo { let relayer = ensure_signed(origin)?; - let mut final_weight = call.get_dispatch_info().weight.saturating_add(50_000); + let mut final_weight = + call.get_dispatch_info().weight.saturating_add(Weight::from_ref_time(50_000)); let proof = ::ProxyConfig::get_proof(&call) .ok_or(Error::::TransactionNotSupported)?; @@ -117,7 +120,7 @@ pub mod pallet { if let Some(payment_info) = payment_info { final_weight = T::WeightInfo::charge_fee() .saturating_add(call.get_dispatch_info().weight) - .saturating_add(50_000); + .saturating_add(Weight::from_ref_time(50_000)); // If the inner call signature does not validate, exit without charging the sender a // fee Self::validate_inner_call_signature(&call)?; @@ -125,7 +128,8 @@ pub mod pallet { } let call_hash: T::Hash = T::Hashing::hash_of(&call); - let sender: T::Origin = frame_system::RawOrigin::Signed(proof.signer.clone()).into(); + let sender: T::RuntimeOrigin = + frame_system::RawOrigin::Signed(proof.signer.clone()).into(); let dispatch_result = call.dispatch(sender).map(|_| ()).map_err(|e| e.error); match dispatch_result { @@ -146,11 +150,11 @@ pub mod pallet { } } -pub type BalanceOf = +pub(crate) type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; impl Pallet { - fn validate_inner_call_signature(call: &Box<::Call>) -> DispatchResult { + fn validate_inner_call_signature(call: &Box<::RuntimeCall>) -> DispatchResult { let inner_call_sig_valid = ::ProxyConfig::signature_is_valid(call); if inner_call_sig_valid == false { return Err(Error::::UnauthorizedProxyTransaction)? @@ -173,7 +177,8 @@ impl Pallet { ) .encode(); - // TODO: centralise wrapped payload signature verification logic in primitives if possible. + // TODO: centralise wrapped payload signature verification logic in primitives if + // possible. let wrapped_encoded_payload: Vec = [OPEN_BYTES_TAG, encoded_payload.as_slice(), CLOSE_BYTES_TAG].concat(); match payment_info.signature.verify(&*wrapped_encoded_payload, &payment_info.payer) { @@ -187,7 +192,7 @@ impl Pallet { } } - fn charge_fee( + pub(crate) fn charge_fee( proof: &Proof, payment_info: PaymentInfo, T::Signature>, ) -> DispatchResult { diff --git a/pallets/avn-proxy/src/tests/mock.rs b/pallets/avn-proxy/src/tests/mock.rs index cb8248bdf..ff233d0fc 100644 --- a/pallets/avn-proxy/src/tests/mock.rs +++ b/pallets/avn-proxy/src/tests/mock.rs @@ -38,8 +38,8 @@ frame_support::construct_runtime!( ); impl Config for TestRuntime { - type Event = mock::Event; - type Call = Call; + type RuntimeEvent = mock::RuntimeEvent; + type RuntimeCall = RuntimeCall; type Currency = Balances; type Public = AccountId; type Signature = Signature; @@ -68,8 +68,8 @@ impl system::Config for TestRuntime { type BlockWeights = (); type BlockLength = (); type DbWeight = (); - type Origin = Origin; - type Call = Call; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; type Index = u64; type BlockNumber = u64; type Hash = H256; @@ -77,7 +77,7 @@ impl system::Config for TestRuntime { type AccountId = AccountId; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type Version = (); type PalletInfo = PalletInfo; @@ -99,7 +99,7 @@ impl pallet_balances::Config for TestRuntime { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type Balance = u128; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; @@ -107,8 +107,8 @@ impl pallet_balances::Config for TestRuntime { } impl pallet_nft_manager::Config for TestRuntime { - type Event = Event; - type Call = Call; + type RuntimeEvent = RuntimeEvent; + type RuntimeCall = RuntimeCall; type ProcessedEventsChecker = (); type Public = AccountId; type Signature = Signature; @@ -133,15 +133,15 @@ impl Default for TestAvnProxyConfig { } } -impl ProvableProxy for TestAvnProxyConfig { - fn get_proof(call: &Call) -> Option> { +impl ProvableProxy for TestAvnProxyConfig { + fn get_proof(call: &RuntimeCall) -> Option> { match call { - Call::System(system::Call::remark { remark: _msg }) => { + RuntimeCall::System(system::Call::remark { remark: _msg }) => { let context: ProxyContext = Default::default(); return Some(context.get_proof()) }, - Call::NftManager(pallet_nft_manager::Call::signed_mint_single_nft { + RuntimeCall::NftManager(pallet_nft_manager::Call::signed_mint_single_nft { proof, unique_external_ref: _, royalties: _, @@ -153,12 +153,12 @@ impl ProvableProxy for TestAvnProxyConfig { } impl InnerCallValidator for TestAvnProxyConfig { - type Call = Call; + type Call = RuntimeCall; fn signature_is_valid(call: &Box) -> bool { match **call { - Call::System(..) => return true, - Call::NftManager(..) => + RuntimeCall::System(..) => return true, + RuntimeCall::NftManager(..) => return pallet_nft_manager::Pallet::::signature_is_valid(call), _ => false, } @@ -260,20 +260,20 @@ impl ProxyContext { } } - pub fn create_valid_inner_call(&self) -> Box<::Call> { - return Box::new(Call::System(SystemCall::remark { remark: vec![] })) + pub fn create_valid_inner_call(&self) -> Box<::RuntimeCall> { + return Box::new(RuntimeCall::System(SystemCall::remark { remark: vec![] })) } - pub fn create_invalid_inner_call(&self) -> Box<::Call> { + pub fn create_invalid_inner_call(&self) -> Box<::RuntimeCall> { let invalid_receiver = TestAccount::new([8u8; 32]); - return Box::new(Call::Balances(BalancesCall::transfer { + return Box::new(RuntimeCall::Balances(BalancesCall::transfer { dest: invalid_receiver.account_id(), value: Default::default(), })) } - pub fn create_proxy_call(&self) -> Box<::Call> { - return Box::new(Call::AvnProxy(AvnProxyCall::proxy { + pub fn create_proxy_call(&self) -> Box<::RuntimeCall> { + return Box::new(RuntimeCall::AvnProxy(AvnProxyCall::proxy { call: self.create_valid_inner_call(), payment_info: None, })) @@ -286,7 +286,7 @@ pub fn proxy_event_emitted( ) -> bool { return System::events().iter().any(|a| { a.event == - Event::AvnProxy(crate::Event::::CallDispatched { + RuntimeEvent::AvnProxy(crate::Event::::CallDispatched { relayer, hash: call_hash, }) @@ -298,7 +298,11 @@ pub fn inner_call_failed_event_emitted( call_hash: ::Hash, ) -> bool { return System::events().iter().any(|a| match a.event { - Event::AvnProxy(crate::Event::::InnerCallFailed { relayer, hash, .. }) => + RuntimeEvent::AvnProxy(crate::Event::::InnerCallFailed { + relayer, + hash, + .. + }) => if relayer == call_relayer && call_hash == hash { return true } else { @@ -329,7 +333,7 @@ pub const SIGNED_MINT_SINGLE_NFT_CONTEXT: &'static [u8] = pub fn create_signed_mint_single_nft_call( context: &ProxyContext, -) -> Box<::Call> { +) -> Box<::RuntimeCall> { let single_nft_data: SingleNftContext = Default::default(); let proof = get_mint_single_nft_proxy_proof(context, &single_nft_data); @@ -339,8 +343,8 @@ pub fn create_signed_mint_single_nft_call( pub fn get_signed_mint_single_nft_call( single_nft_data: &SingleNftContext, proof: &Proof, -) -> Box<::Call> { - return Box::new(crate::mock::Call::NftManager(NftManagerCall::signed_mint_single_nft { +) -> Box<::RuntimeCall> { + return Box::new(crate::mock::RuntimeCall::NftManager(NftManagerCall::signed_mint_single_nft { proof: proof.clone(), unique_external_ref: single_nft_data.unique_external_ref.clone(), royalties: single_nft_data.royalties.clone(), @@ -379,6 +383,6 @@ pub fn single_nft_minted_events_count() -> usize { System::events() .into_iter() .map(|r| r.event) - .filter_map(|e| if let Event::NftManager(inner) = e { Some(inner) } else { None }) + .filter_map(|e| if let RuntimeEvent::NftManager(inner) = e { Some(inner) } else { None }) .count() } diff --git a/pallets/avn-proxy/src/tests/proxy_tests_no_fees.rs b/pallets/avn-proxy/src/tests/proxy_tests_no_fees.rs index c799b71cd..cfc8562f7 100644 --- a/pallets/avn-proxy/src/tests/proxy_tests_no_fees.rs +++ b/pallets/avn-proxy/src/tests/proxy_tests_no_fees.rs @@ -22,7 +22,7 @@ mod proxy_without_fees { assert_eq!(false, proxy_event_emitted(context.relayer.account_id(), call_hash)); assert_ok!(AvnProxy::proxy( - Origin::signed(context.relayer.account_id()), + RuntimeOrigin::signed(context.relayer.account_id()), inner_call, None )); @@ -39,7 +39,7 @@ mod proxy_without_fees { assert_eq!(false, single_nft_minted_events_emitted()); assert_ok!(AvnProxy::proxy( - Origin::signed(context.relayer.account_id()), + RuntimeOrigin::signed(context.relayer.account_id()), inner_call, None )); @@ -56,7 +56,7 @@ mod proxy_without_fees { assert_eq!(false, single_nft_minted_events_emitted()); assert_ok!(AvnProxy::proxy( - Origin::signed(context.relayer.account_id()), + RuntimeOrigin::signed(context.relayer.account_id()), inner_call, None )); @@ -67,7 +67,7 @@ mod proxy_without_fees { let call_hash = Hashing::hash_of(&inner_call_with_duplicate_external_ref); assert_ok!(AvnProxy::proxy( - Origin::signed(context.relayer.account_id()), + RuntimeOrigin::signed(context.relayer.account_id()), inner_call_with_duplicate_external_ref, None )); @@ -106,7 +106,7 @@ mod proxy_without_fees { assert_noop!( AvnProxy::proxy( - Origin::signed(context.relayer.account_id()), + RuntimeOrigin::signed(context.relayer.account_id()), invalid_inner_call, None ), @@ -129,7 +129,7 @@ mod proxy_without_fees { assert_eq!(false, proxy_event_emitted(context.relayer.account_id(), call_hash)); assert_noop!( - AvnProxy::proxy(Origin::signed(invalid_relayer), inner_call, None), + AvnProxy::proxy(RuntimeOrigin::signed(invalid_relayer), inner_call, None), Error::::UnauthorizedProxyTransaction ); }) @@ -145,7 +145,7 @@ mod proxy_without_fees { assert_noop!( AvnProxy::proxy( - Origin::signed(context.relayer.account_id()), + RuntimeOrigin::signed(context.relayer.account_id()), invalid_inner_call, None ), diff --git a/pallets/avn-proxy/src/tests/proxy_tests_with_fees.rs b/pallets/avn-proxy/src/tests/proxy_tests_with_fees.rs index 8b1051802..f9027f57b 100644 --- a/pallets/avn-proxy/src/tests/proxy_tests_with_fees.rs +++ b/pallets/avn-proxy/src/tests/proxy_tests_with_fees.rs @@ -79,7 +79,7 @@ mod charging_fees { assert_eq!(false, single_nft_minted_events_emitted()); assert_ok!(AvnProxy::proxy( - Origin::signed(context.relayer.account_id()), + RuntimeOrigin::signed(context.relayer.account_id()), inner_call, payment_authorisation )); @@ -120,7 +120,7 @@ mod charging_fees { // Dispatch fails assert_ok!(AvnProxy::proxy( - Origin::signed(context.relayer.account_id()), + RuntimeOrigin::signed(context.relayer.account_id()), inner_call, payment_authorisation )); @@ -174,7 +174,7 @@ mod charging_fees { assert_eq!(false, single_nft_minted_events_emitted()); assert_ok!(AvnProxy::proxy( - Origin::signed(context.relayer.account_id()), + RuntimeOrigin::signed(context.relayer.account_id()), inner_call, payment_authorisation )); @@ -223,7 +223,7 @@ mod charging_fees { assert_noop!( AvnProxy::proxy( - Origin::signed(context.relayer.account_id()), + RuntimeOrigin::signed(context.relayer.account_id()), inner_call, Some(Box::new(payment_authorisation)) ), @@ -257,7 +257,7 @@ mod charging_fees { assert_noop!( AvnProxy::proxy( - Origin::signed(context.relayer.account_id()), + RuntimeOrigin::signed(context.relayer.account_id()), inner_call, Some(Box::new(payment_authorisation)) ), @@ -289,7 +289,7 @@ mod charging_fees { assert_noop!( AvnProxy::proxy( - Origin::signed(context.relayer.account_id()), + RuntimeOrigin::signed(context.relayer.account_id()), inner_call, Some(Box::new(payment_authorisation)) ), @@ -322,7 +322,7 @@ mod charging_fees { assert_noop!( AvnProxy::proxy( - Origin::signed(context.relayer.account_id()), + RuntimeOrigin::signed(context.relayer.account_id()), inner_call, Some(Box::new(payment_authorisation)) ), @@ -350,7 +350,7 @@ mod charging_fees { let mut relayer_balance = Balances::free_balance(context.relayer.account_id()); assert_ok!(AvnProxy::proxy( - Origin::signed(context.relayer.account_id()), + RuntimeOrigin::signed(context.relayer.account_id()), inner_call.clone(), payment_authorisation.clone() )); @@ -375,7 +375,7 @@ mod charging_fees { // Replay the same fee signature assert_noop!( AvnProxy::proxy( - Origin::signed(context.relayer.account_id()), + RuntimeOrigin::signed(context.relayer.account_id()), inner_call, payment_authorisation ), @@ -409,7 +409,7 @@ mod charging_fees { assert_noop!( AvnProxy::proxy( - Origin::signed(context.relayer.account_id()), + RuntimeOrigin::signed(context.relayer.account_id()), inner_call, payment_authorisation ), @@ -455,7 +455,7 @@ mod charging_fees { // Mismatching inner call proof and payment authorisation assert_noop!( AvnProxy::proxy( - Origin::signed(context.relayer.account_id()), + RuntimeOrigin::signed(context.relayer.account_id()), original_inner_call.clone(), Some(Box::new(new_payment_authorisation)) ), @@ -465,7 +465,7 @@ mod charging_fees { // Mismatching inner call proof and payment authorisation assert_noop!( AvnProxy::proxy( - Origin::signed(context.relayer.account_id()), + RuntimeOrigin::signed(context.relayer.account_id()), new_inner_call, Some(Box::new(original_payment_authorisation.clone())) ), @@ -478,7 +478,7 @@ mod charging_fees { //Now show that the original proof and original payment authorisation are valid assert_ok!(AvnProxy::proxy( - Origin::signed(context.relayer.account_id()), + RuntimeOrigin::signed(context.relayer.account_id()), original_inner_call, Some(Box::new(original_payment_authorisation)) )); diff --git a/pallets/avn/Cargo.toml b/pallets/avn/Cargo.toml index 5c767c52b..6f949c9c8 100644 --- a/pallets/avn/Cargo.toml +++ b/pallets/avn/Cargo.toml @@ -15,21 +15,21 @@ sp-avn-common = { version = "0.12.0", default-features = false, path = "../../pr hex = { version = "0.4.3", default-features = false, features = ["alloc"] } scale-info = { version = "2.0", default-features = false, features = ["derive"] } -sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -sp-io = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -sp-application-crypto = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -frame-system = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -pallet-session = {features = ["historical"], git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27", default-features = false } +sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +sp-io = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +sp-application-crypto = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +frame-system = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +pallet-session = {features = ["historical"], git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } [dev-dependencies] hex-literal = { version = "0.3.4", default-features = false } parking_lot = { version = "0.12.0" } -pallet-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -substrate-test-utils = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } +pallet-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +substrate-test-utils = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } [features] migrate = [] diff --git a/pallets/avn/src/tests/mock.rs b/pallets/avn/src/tests/mock.rs index 1fcde258e..344469734 100644 --- a/pallets/avn/src/tests/mock.rs +++ b/pallets/avn/src/tests/mock.rs @@ -45,7 +45,7 @@ impl Config for TestRuntime { parameter_types! { pub const BlockHashCount: u64 = 250; - pub const MaximumBlockWeight: Weight = 1024; + pub const MaximumBlockWeight: Weight = Weight::from_ref_time(1024); pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75); pub const ChallengePeriod: u64 = 2; @@ -56,16 +56,16 @@ impl system::Config for TestRuntime { type BlockWeights = (); type BlockLength = (); type DbWeight = (); - type Origin = Origin; + type RuntimeOrigin = RuntimeOrigin; type Index = u64; type BlockNumber = u64; - type Call = Call; + type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = (); + type RuntimeEvent = (); type BlockHashCount = BlockHashCount; type Version = (); type PalletInfo = PalletInfo; @@ -105,7 +105,7 @@ impl session::Config for TestRuntime { type Keys = UintAuthorityId; type ShouldEndSession = session::PeriodicSessions; type SessionHandler = (AVN,); - type Event = (); + type RuntimeEvent = (); type ValidatorId = u64; type ValidatorIdOf = ConvertInto; type NextSessionRotation = session::PeriodicSessions; diff --git a/pallets/ethereum-events/Cargo.toml b/pallets/ethereum-events/Cargo.toml index bfd4a93ee..cc96cb004 100644 --- a/pallets/ethereum-events/Cargo.toml +++ b/pallets/ethereum-events/Cargo.toml @@ -17,32 +17,33 @@ impl-trait-for-tuples = "0.2.2" scale-info = { version = "2.0", default-features = false, features = ["derive"] } sp-avn-common = { version = "0.12.0", default-features = false, path = "../../primitives/avn-common" } -sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -frame-system = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -sp-io = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -sp-staking = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -pallet-session = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -sp-application-crypto = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } +sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +frame-system = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +sp-io = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +sp-staking = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +pallet-session = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +sp-application-crypto = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } pallet-avn = { version = "0.12.0", default-features = false, path = "../avn" } # Optional imports for benchmarking serde = { version = "1.0.137", optional = true } parking_lot = { version = "0.12.0", optional = true } -frame-benchmarking = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27", optional = true } +frame-benchmarking = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", optional = true } [dev-dependencies] -pallet-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -substrate-test-utils = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } +pallet-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +substrate-test-utils = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } pallet-avn-proxy = { version = "0.12.0", default-features = false, path = "../avn-proxy" } [features] migrate = [] default = ["std", "pallet-session/historical"] std = [ + "frame-benchmarking?/std", "serde", "codec/std", "sp-std/std", @@ -58,7 +59,7 @@ std = [ "sp-avn-common/std", ] runtime-benchmarks = [ - "frame-benchmarking", + "frame-benchmarking/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", ] diff --git a/pallets/ethereum-events/src/benchmarking.rs b/pallets/ethereum-events/src/benchmarking.rs index 31f0d402a..e6dc2251b 100644 --- a/pallets/ethereum-events/src/benchmarking.rs +++ b/pallets/ethereum-events/src/benchmarking.rs @@ -130,9 +130,9 @@ fn generate_signature( return signature } -fn assert_last_event(generic_event: ::Event) { +fn assert_last_event(generic_event: ::RuntimeEvent) { let events = frame_system::Pallet::::events(); - let system_event: ::Event = generic_event.into(); + let system_event: ::RuntimeEvent = generic_event.into(); // compare to the last event record let EventRecord { event, .. } = &events[events.len().saturating_sub(1 as usize)]; assert_eq!(event, &system_event); diff --git a/pallets/ethereum-events/src/default_weights.rs b/pallets/ethereum-events/src/default_weights.rs index 56b0229a3..6ec44818d 100644 --- a/pallets/ethereum-events/src/default_weights.rs +++ b/pallets/ethereum-events/src/default_weights.rs @@ -76,13 +76,13 @@ impl WeightInfo for SubstrateWeight { /// The range of component `u` is `[1, 5]`. /// The range of component `e` is `[1, 5]`. fn add_validator_log(u: u32, e: u32, ) -> Weight { - (32_987_000 as Weight) + (Weight::from_ref_time(32_987_000)) // Standard Error: 33_000 - .saturating_add((136_000 as Weight).saturating_mul(u as Weight)) + .saturating_add(Weight::from_ref_time(136_000).saturating_mul(u as u64)) // Standard Error: 33_000 - .saturating_add((363_000 as Weight).saturating_mul(e as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(363_000).saturating_mul(e as u64)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: EthereumEvents ProcessedEvents (r:1 w:0) // Storage: EthereumEvents UncheckedEvents (r:1 w:1) @@ -92,13 +92,13 @@ impl WeightInfo for SubstrateWeight { /// The range of component `u` is `[1, 5]`. /// The range of component `e` is `[1, 5]`. fn add_lift_log(u: u32, e: u32, ) -> Weight { - (32_887_000 as Weight) + (Weight::from_ref_time(32_887_000)) // Standard Error: 27_000 - .saturating_add((117_000 as Weight).saturating_mul(u as Weight)) + .saturating_add(Weight::from_ref_time(117_000).saturating_mul(u as u64)) // Standard Error: 27_000 - .saturating_add((412_000 as Weight).saturating_mul(e as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(412_000).saturating_mul(e as u64)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: EthereumEvents ProcessedEvents (r:1 w:0) // Storage: EthereumEvents UncheckedEvents (r:1 w:1) @@ -107,13 +107,13 @@ impl WeightInfo for SubstrateWeight { /// The range of component `u` is `[1, 5]`. /// The range of component `e` is `[1, 5]`. fn add_ethereum_log(u: u32, e: u32, ) -> Weight { - (29_753_000 as Weight) + (Weight::from_ref_time(29_753_000)) // Standard Error: 35_000 - .saturating_add((170_000 as Weight).saturating_mul(u as Weight)) + .saturating_add(Weight::from_ref_time(170_000).saturating_mul(u as u64)) // Standard Error: 35_000 - .saturating_add((389_000 as Weight).saturating_mul(e as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(389_000).saturating_mul(e as u64)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: EthereumEvents ProxyNonces (r:1 w:1) // Storage: EthereumEvents ProcessedEvents (r:1 w:0) @@ -123,23 +123,23 @@ impl WeightInfo for SubstrateWeight { /// The range of component `u` is `[1, 5]`. /// The range of component `e` is `[1, 5]`. fn signed_add_ethereum_log(u: u32, e: u32, ) -> Weight { - (108_641_000 as Weight) + (Weight::from_ref_time(108_641_000)) // Standard Error: 64_000 - .saturating_add((214_000 as Weight).saturating_mul(u as Weight)) + .saturating_add(Weight::from_ref_time(214_000).saturating_mul(u as u64)) // Standard Error: 64_000 - .saturating_add((540_000 as Weight).saturating_mul(e as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(540_000).saturating_mul(e as u64)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(3)) } // Storage: EthereumEvents NftT1Contracts (r:0 w:1) fn set_ethereum_contract_map_storage() -> Weight { - (5_520_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + (Weight::from_ref_time(5_520_000)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: EthereumEvents ValidatorManagerContractAddress (r:0 w:1) fn set_ethereum_contract_storage() -> Weight { - (4_920_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + (Weight::from_ref_time(4_920_000)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Avn Validators (r:1 w:0) // Storage: EthereumEvents UncheckedEvents (r:1 w:1) @@ -149,13 +149,13 @@ impl WeightInfo for SubstrateWeight { /// The range of component `v` is `[1, 10]`. /// The range of component `u` is `[1, 5]`. fn submit_checkevent_result(v: u32, u: u32, ) -> Weight { - (36_690_000 as Weight) + (Weight::from_ref_time(36_690_000) ) // Standard Error: 39_000 - .saturating_add((339_000 as Weight).saturating_mul(v as Weight)) + .saturating_add(Weight::from_ref_time(339_000).saturating_mul(v as u64)) // Standard Error: 101_000 - .saturating_add((245_000 as Weight).saturating_mul(u as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(245_000).saturating_mul(u as u64)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: Avn Validators (r:1 w:0) // Storage: EthereumEvents EventsPendingChallenge (r:1 w:1) @@ -172,13 +172,13 @@ impl WeightInfo for SubstrateWeight { /// The range of component `v` is `[1, 10]`. /// The range of component `e` is `[1, 5]`. fn process_event_with_successful_challenge(v: u32, e: u32, ) -> Weight { - (90_694_000 as Weight) + (Weight::from_ref_time(90_694_000)) // Standard Error: 48_000 - .saturating_add((492_000 as Weight).saturating_mul(v as Weight)) + .saturating_add(Weight::from_ref_time(492_000).saturating_mul(v as u64)) // Standard Error: 122_000 - .saturating_add((1_352_000 as Weight).saturating_mul(e as Weight)) - .saturating_add(T::DbWeight::get().reads(11 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + .saturating_add(Weight::from_ref_time(1_352_000).saturating_mul(e as u64)) + .saturating_add(T::DbWeight::get().reads(11)) + .saturating_add(T::DbWeight::get().writes(6)) } // Storage: Avn Validators (r:1 w:0) // Storage: EthereumEvents EventsPendingChallenge (r:1 w:1) @@ -195,13 +195,13 @@ impl WeightInfo for SubstrateWeight { /// The range of component `v` is `[1, 10]`. /// The range of component `e` is `[1, 5]`. fn process_event_without_successful_challenge(v: u32, e: u32, ) -> Weight { - (89_650_000 as Weight) + (Weight::from_ref_time(89_650_000)) // Standard Error: 48_000 - .saturating_add((225_000 as Weight).saturating_mul(v as Weight)) + .saturating_add(Weight::from_ref_time(225_000).saturating_mul(v as u64)) // Standard Error: 121_000 - .saturating_add((1_423_000 as Weight).saturating_mul(e as Weight)) - .saturating_add(T::DbWeight::get().reads(11 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + .saturating_add(Weight::from_ref_time(1_423_000).saturating_mul(e as u64)) + .saturating_add(T::DbWeight::get().reads(11)) + .saturating_add(T::DbWeight::get().writes(6)) } // Storage: Avn Validators (r:1 w:0) // Storage: EthereumEvents EventsPendingChallenge (r:1 w:0) @@ -210,18 +210,18 @@ impl WeightInfo for SubstrateWeight { /// The range of component `e` is `[1, 5]`. /// The range of component `c` is `[1, 10]`. fn challenge_event(v: u32, e: u32, _c: u32, ) -> Weight { - (33_830_000 as Weight) + (Weight::from_ref_time(33_830_000)) // Standard Error: 44_000 - .saturating_add((188_000 as Weight).saturating_mul(v as Weight)) + .saturating_add(Weight::from_ref_time(188_000).saturating_mul(v as u64)) // Standard Error: 87_000 - .saturating_add((370_000 as Weight).saturating_mul(e as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(370_000).saturating_mul(e as u64)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: EthereumEvents EventChallengePeriod (r:0 w:1) fn set_event_challenge_period() -> Weight { - (15_192_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + (Weight::from_ref_time(15_192_000)) + .saturating_add(T::DbWeight::get().writes(1)) } } @@ -235,13 +235,13 @@ impl WeightInfo for () { /// The range of component `u` is `[1, 5]`. /// The range of component `e` is `[1, 5]`. fn add_validator_log(u: u32, e: u32, ) -> Weight { - (32_987_000 as Weight) + (Weight::from_ref_time(32_987_000)) // Standard Error: 33_000 - .saturating_add((136_000 as Weight).saturating_mul(u as Weight)) + .saturating_add(Weight::from_ref_time(136_000).saturating_mul(u as u64)) // Standard Error: 33_000 - .saturating_add((363_000 as Weight).saturating_mul(e as Weight)) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(363_000).saturating_mul(e as u64)) + .saturating_add(RocksDbWeight::get().reads(5)) + .saturating_add(RocksDbWeight::get().writes(2)) } // Storage: EthereumEvents ProcessedEvents (r:1 w:0) // Storage: EthereumEvents UncheckedEvents (r:1 w:1) @@ -251,13 +251,13 @@ impl WeightInfo for () { /// The range of component `u` is `[1, 5]`. /// The range of component `e` is `[1, 5]`. fn add_lift_log(u: u32, e: u32, ) -> Weight { - (32_887_000 as Weight) + (Weight::from_ref_time(32_887_000)) // Standard Error: 27_000 - .saturating_add((117_000 as Weight).saturating_mul(u as Weight)) + .saturating_add(Weight::from_ref_time(117_000).saturating_mul(u as u64)) // Standard Error: 27_000 - .saturating_add((412_000 as Weight).saturating_mul(e as Weight)) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(412_000).saturating_mul(e as u64)) + .saturating_add(RocksDbWeight::get().reads(5)) + .saturating_add(RocksDbWeight::get().writes(2)) } // Storage: EthereumEvents ProcessedEvents (r:1 w:0) // Storage: EthereumEvents UncheckedEvents (r:1 w:1) @@ -266,13 +266,13 @@ impl WeightInfo for () { /// The range of component `u` is `[1, 5]`. /// The range of component `e` is `[1, 5]`. fn add_ethereum_log(u: u32, e: u32, ) -> Weight { - (29_753_000 as Weight) + (Weight::from_ref_time(29_753_000)) // Standard Error: 35_000 - .saturating_add((170_000 as Weight).saturating_mul(u as Weight)) + .saturating_add(Weight::from_ref_time(170_000).saturating_mul(u as u64)) // Standard Error: 35_000 - .saturating_add((389_000 as Weight).saturating_mul(e as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(389_000).saturating_mul(e as u64)) + .saturating_add(RocksDbWeight::get().reads(4)) + .saturating_add(RocksDbWeight::get().writes(2)) } // Storage: EthereumEvents ProxyNonces (r:1 w:1) // Storage: EthereumEvents ProcessedEvents (r:1 w:0) @@ -282,23 +282,23 @@ impl WeightInfo for () { /// The range of component `u` is `[1, 5]`. /// The range of component `e` is `[1, 5]`. fn signed_add_ethereum_log(u: u32, e: u32, ) -> Weight { - (108_641_000 as Weight) + (Weight::from_ref_time(108_641_000)) // Standard Error: 64_000 - .saturating_add((214_000 as Weight).saturating_mul(u as Weight)) + .saturating_add(Weight::from_ref_time(214_000).saturating_mul(u as u64)) // Standard Error: 64_000 - .saturating_add((540_000 as Weight).saturating_mul(e as Weight)) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + .saturating_add(Weight::from_ref_time(540_000).saturating_mul(e as u64)) + .saturating_add(RocksDbWeight::get().reads(5)) + .saturating_add(RocksDbWeight::get().writes(3)) } // Storage: EthereumEvents NftT1Contracts (r:0 w:1) fn set_ethereum_contract_map_storage() -> Weight { - (5_520_000 as Weight) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + (Weight::from_ref_time(5_520_000)) + .saturating_add(RocksDbWeight::get().writes(1)) } // Storage: EthereumEvents ValidatorManagerContractAddress (r:0 w:1) fn set_ethereum_contract_storage() -> Weight { - (4_920_000 as Weight) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + (Weight::from_ref_time(4_920_000)) + .saturating_add(RocksDbWeight::get().writes(1)) } // Storage: Avn Validators (r:1 w:0) // Storage: EthereumEvents UncheckedEvents (r:1 w:1) @@ -308,13 +308,13 @@ impl WeightInfo for () { /// The range of component `v` is `[1, 10]`. /// The range of component `u` is `[1, 5]`. fn submit_checkevent_result(v: u32, u: u32, ) -> Weight { - (36_690_000 as Weight) + (Weight::from_ref_time(36_690_000)) // Standard Error: 39_000 - .saturating_add((339_000 as Weight).saturating_mul(v as Weight)) + .saturating_add(Weight::from_ref_time(339_000)).saturating_mul(v as u64) // Standard Error: 101_000 - .saturating_add((245_000 as Weight).saturating_mul(u as Weight)) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(245_000)).saturating_mul(u as u64) + .saturating_add(RocksDbWeight::get().reads(5)) + .saturating_add(RocksDbWeight::get().writes(2)) } // Storage: Avn Validators (r:1 w:0) // Storage: EthereumEvents EventsPendingChallenge (r:1 w:1) @@ -331,13 +331,13 @@ impl WeightInfo for () { /// The range of component `v` is `[1, 10]`. /// The range of component `e` is `[1, 5]`. fn process_event_with_successful_challenge(v: u32, e: u32, ) -> Weight { - (90_694_000 as Weight) + (Weight::from_ref_time(90_694_000)) // Standard Error: 48_000 - .saturating_add((492_000 as Weight).saturating_mul(v as Weight)) + .saturating_add(Weight::from_ref_time(492_000).saturating_mul(v as u64)) // Standard Error: 122_000 - .saturating_add((1_352_000 as Weight).saturating_mul(e as Weight)) - .saturating_add(RocksDbWeight::get().reads(11 as Weight)) - .saturating_add(RocksDbWeight::get().writes(6 as Weight)) + .saturating_add(Weight::from_ref_time(1_352_000).saturating_mul(e as u64)) + .saturating_add(RocksDbWeight::get().reads(11)) + .saturating_add(RocksDbWeight::get().writes(6)) } // Storage: Avn Validators (r:1 w:0) // Storage: EthereumEvents EventsPendingChallenge (r:1 w:1) @@ -354,13 +354,13 @@ impl WeightInfo for () { /// The range of component `v` is `[1, 10]`. /// The range of component `e` is `[1, 5]`. fn process_event_without_successful_challenge(v: u32, e: u32, ) -> Weight { - (89_650_000 as Weight) + (Weight::from_ref_time(89_650_000)) // Standard Error: 48_000 - .saturating_add((225_000 as Weight).saturating_mul(v as Weight)) + .saturating_add(Weight::from_ref_time(225_000 ).saturating_mul(v as u64)) // Standard Error: 121_000 - .saturating_add((1_423_000 as Weight).saturating_mul(e as Weight)) - .saturating_add(RocksDbWeight::get().reads(11 as Weight)) - .saturating_add(RocksDbWeight::get().writes(6 as Weight)) + .saturating_add(Weight::from_ref_time(1_423_000 ).saturating_mul(e as u64)) + .saturating_add(RocksDbWeight::get().reads(11 )) + .saturating_add(RocksDbWeight::get().writes(6 )) } // Storage: Avn Validators (r:1 w:0) // Storage: EthereumEvents EventsPendingChallenge (r:1 w:0) @@ -369,17 +369,17 @@ impl WeightInfo for () { /// The range of component `e` is `[1, 5]`. /// The range of component `c` is `[1, 10]`. fn challenge_event(v: u32, e: u32, _c: u32, ) -> Weight { - (33_830_000 as Weight) + (Weight::from_ref_time(33_830_000)) // Standard Error: 44_000 - .saturating_add((188_000 as Weight).saturating_mul(v as Weight)) + .saturating_add(Weight::from_ref_time(188_000).saturating_mul(v as u64)) // Standard Error: 87_000 - .saturating_add((370_000 as Weight).saturating_mul(e as Weight)) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(370_000).saturating_mul(e as u64)) + .saturating_add(RocksDbWeight::get().reads(3)) + .saturating_add(RocksDbWeight::get().writes(1)) } // Storage: EthereumEvents EventChallengePeriod (r:0 w:1) fn set_event_challenge_period() -> Weight { - (15_192_000 as Weight) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + (Weight::from_ref_time(15_192_000)) + .saturating_add(RocksDbWeight::get().writes(1)) } } \ No newline at end of file diff --git a/pallets/ethereum-events/src/lib.rs b/pallets/ethereum-events/src/lib.rs index 41ab68f11..1d5d81eef 100644 --- a/pallets/ethereum-events/src/lib.rs +++ b/pallets/ethereum-events/src/lib.rs @@ -159,10 +159,10 @@ pub mod pallet { + avn::Config + pallet_session::historical::Config { - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; - type Call: Parameter - + Dispatchable::Origin> + type RuntimeCall: Parameter + + Dispatchable::RuntimeOrigin> + IsSubType> + From>; @@ -419,6 +419,7 @@ pub mod pallet { impl Pallet { /// This extrinsic is being deprecated. Use add_ethereum_log // We need to maintain this till SYS-888 is resolved. After that it can be removed. + #[pallet::call_index(0)] #[pallet::weight( ::WeightInfo::add_validator_log( MAX_NUMBER_OF_UNCHECKED_EVENTS, MAX_NUMBER_OF_EVENTS_PENDING_CHALLENGES @@ -433,6 +434,7 @@ pub mod pallet { /// This extrinsic is being deprecated. Use add_ethereum_log // We need to maintain this till SYS-888 is resolved. After that it can be removed. + #[pallet::call_index(1)] #[pallet::weight( ::WeightInfo::add_lift_log( MAX_NUMBER_OF_UNCHECKED_EVENTS, MAX_NUMBER_OF_EVENTS_PENDING_CHALLENGES @@ -445,6 +447,7 @@ pub mod pallet { return Self::add_event(ValidEvents::Lifted, tx_hash, account_id) } + #[pallet::call_index(2)] #[pallet::weight( ::WeightInfo::submit_checkevent_result( MAX_NUMBER_OF_VALIDATORS_ACCOUNTS, MAX_NUMBER_OF_UNCHECKED_EVENTS @@ -497,6 +500,7 @@ pub mod pallet { Ok(()) } + #[pallet::call_index(3)] #[pallet::weight( ::WeightInfo::process_event_with_successful_challenge( MAX_NUMBER_OF_VALIDATORS_ACCOUNTS, MAX_NUMBER_OF_EVENTS_PENDING_CHALLENGES @@ -613,6 +617,7 @@ pub mod pallet { Ok(Some(final_weight).into()) } + #[pallet::call_index(4)] #[pallet::weight( ::WeightInfo::challenge_event( MAX_NUMBER_OF_VALIDATORS_ACCOUNTS, MAX_NUMBER_OF_EVENTS_PENDING_CHALLENGES, @@ -676,6 +681,7 @@ pub mod pallet { } /// Submits an ethereum transaction hash into the chain + #[pallet::call_index(5)] #[pallet::weight( ::WeightInfo::add_ethereum_log( MAX_NUMBER_OF_UNCHECKED_EVENTS, MAX_NUMBER_OF_EVENTS_PENDING_CHALLENGES @@ -693,6 +699,7 @@ pub mod pallet { } // # + #[pallet::call_index(6)] #[pallet::weight( ::WeightInfo::signed_add_ethereum_log( MAX_NUMBER_OF_UNCHECKED_EVENTS, MAX_NUMBER_OF_EVENTS_PENDING_CHALLENGES @@ -726,6 +733,7 @@ pub mod pallet { } /// Sets the address for ethereum contracts + #[pallet::call_index(7)] #[pallet::weight( ::WeightInfo::set_ethereum_contract_map_storage().max(::WeightInfo::set_ethereum_contract_storage() ))] @@ -748,6 +756,7 @@ pub mod pallet { Ok(()) } + #[pallet::call_index(8)] #[pallet::weight(::WeightInfo::set_event_challenge_period())] pub fn set_event_challenge_period( origin: OriginFor, @@ -810,7 +819,7 @@ pub mod pallet { return migrations::migrate_to_multi_nft_contract::() } - return 0 + return Weight::from_ref_time(0) } } @@ -1612,7 +1621,7 @@ impl Pallet { } fn get_encoded_call_param( - call: &::Call, + call: &::RuntimeCall, ) -> Option<(&Proof, Vec)> { let call = match call.is_sub_type() { Some(call) => call, @@ -1623,12 +1632,12 @@ impl Pallet { Call::signed_add_ethereum_log { proof, event_type, tx_hash } => { let sender_nonce = Self::proxy_nonce(&proof.signer); let encoded_data = Self::encode_signed_add_ethereum_log_params( - proof, - event_type, - tx_hash, + &proof, + &event_type, + &tx_hash, sender_nonce, ); - return Some((proof, encoded_data)) + return Some((&proof, encoded_data)) }, _ => return None, @@ -1649,7 +1658,7 @@ impl ProcessedEventsChecker for Pallet { } impl InnerCallValidator for Pallet { - type Call = ::Call; + type Call = ::RuntimeCall; fn signature_is_valid(call: &Box) -> bool { if let Some((proof, signed_payload)) = Self::get_encoded_call_param(call) { diff --git a/pallets/ethereum-events/src/mock.rs b/pallets/ethereum-events/src/mock.rs index b09a05e3a..c004c7529 100644 --- a/pallets/ethereum-events/src/mock.rs +++ b/pallets/ethereum-events/src/mock.rs @@ -96,10 +96,6 @@ impl TestAccount { } } -pub fn sign(signer: &sr25519::Pair, message_to_sign: &[u8]) -> Signature { - return Signature::from(signer.sign(message_to_sign)) -} - pub const KEY_TYPE: KeyTypeId = KeyTypeId(*b"dumy"); pub const GOOD_STATUS: &str = "0x1"; @@ -114,11 +110,11 @@ pub mod crypto { app_crypto!(sr25519, KEY_TYPE); } -pub type Extrinsic = TestXt; +pub type Extrinsic = TestXt; impl Config for TestRuntime { - type Call = Call; - type Event = Event; + type RuntimeCall = RuntimeCall; + type RuntimeEvent = RuntimeEvent; type ProcessedEventHandler = Self; type MinEthBlockConfirmation = MinEthBlockConfirmation; type ReportInvalidEthereumLog = OffenceHandler; @@ -129,15 +125,15 @@ impl Config for TestRuntime { impl frame_system::offchain::SendTransactionTypes for TestRuntime where - Call: From, + RuntimeCall: From, { - type OverarchingCall = Call; + type OverarchingCall = RuntimeCall; type Extrinsic = Extrinsic; } parameter_types! { pub const BlockHashCount: u64 = 250; - pub const MaximumBlockWeight: Weight = 1024; + pub const MaximumBlockWeight: Weight = Weight::from_ref_time(1024); pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75); pub const MinEthBlockConfirmation: u64 = 2; @@ -148,8 +144,8 @@ impl system::Config for TestRuntime { type BlockWeights = (); type BlockLength = (); type DbWeight = (); - type Origin = Origin; - type Call = Call; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; type Index = u64; type BlockNumber = u64; type Hash = H256; @@ -157,7 +153,7 @@ impl system::Config for TestRuntime { type AccountId = AccountId; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type Version = (); type PalletInfo = PalletInfo; @@ -210,7 +206,7 @@ impl session::Config for TestRuntime { type Keys = UintAuthorityId; type ShouldEndSession = session::PeriodicSessions; type SessionHandler = (AVN,); - type Event = Event; + type RuntimeEvent = RuntimeEvent; type ValidatorId = AccountId; type ValidatorIdOf = ConvertInto; type NextSessionRotation = session::PeriodicSessions; @@ -224,7 +220,7 @@ parameter_types! { impl pallet_balances::Config for TestRuntime { type Balance = u128; type DustRemoval = (); - type Event = Event; + type RuntimeEvent = RuntimeEvent; type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; type MaxLocks = (); @@ -423,14 +419,14 @@ impl EthereumEvents { return AVN::get_validator_for_current_node() } - pub fn event_emitted(event: &Event) -> bool { + pub fn event_emitted(event: &RuntimeEvent) -> bool { return System::events().iter().any(|a| a.event == *event) } } impl pallet_avn_proxy::Config for TestRuntime { - type Event = Event; - type Call = Call; + type RuntimeEvent = RuntimeEvent; + type RuntimeCall = RuntimeCall; type Currency = Balances; type Public = AccountId; type Signature = Signature; @@ -447,25 +443,27 @@ impl Default for TestAvnProxyConfig { } } -impl ProvableProxy for TestAvnProxyConfig { - fn get_proof(call: &Call) -> Option> { +impl ProvableProxy for TestAvnProxyConfig { + fn get_proof(call: &RuntimeCall) -> Option> { match call { - Call::EthereumEvents(pallet_ethereum_events::Call::signed_add_ethereum_log { - proof, - event_type: _, - tx_hash: _, - }) => return Some(proof.clone()), + RuntimeCall::EthereumEvents( + pallet_ethereum_events::Call::signed_add_ethereum_log { + proof, + event_type: _, + tx_hash: _, + }, + ) => return Some(proof.clone()), _ => None, } } } impl InnerCallValidator for TestAvnProxyConfig { - type Call = Call; + type Call = RuntimeCall; fn signature_is_valid(call: &Box) -> bool { match **call { - Call::EthereumEvents(..) => return EthereumEvents::signature_is_valid(call), + RuntimeCall::EthereumEvents(..) => return EthereumEvents::signature_is_valid(call), _ => false, } } diff --git a/pallets/ethereum-events/src/offence.rs b/pallets/ethereum-events/src/offence.rs index d37dd48e7..6bf9acd14 100644 --- a/pallets/ethereum-events/src/offence.rs +++ b/pallets/ethereum-events/src/offence.rs @@ -18,7 +18,7 @@ pub enum EthereumLogOffenceType { IncorrectValidationResultSubmitted, ChallengeAttemptedOnValidResult, } -use crate::Event; +use crate::*; #[derive(PartialEq, Clone, Debug, Encode, Decode)] pub struct InvalidEthereumLogOffence { @@ -53,7 +53,7 @@ impl Offence for InvalidEthereumLogOffence self.session_index } - fn slash_fraction(_offenders: u32, _validator_set_count: u32) -> Perbill { + fn slash_fraction(&self, _offenders_count: u32) -> Perbill { // We don't implement fraction slashes at the moment. Perbill::from_percent(100) } diff --git a/pallets/ethereum-events/src/tests/test_challenges.rs b/pallets/ethereum-events/src/tests/test_challenges.rs index 9748c8510..3dadbd439 100644 --- a/pallets/ethereum-events/src/tests/test_challenges.rs +++ b/pallets/ethereum-events/src/tests/test_challenges.rs @@ -736,7 +736,7 @@ fn test_challenge_valid_challenge_invalid_result() { assert_eq!(EthereumEvents::challenges(challenge.event_id.clone()).len(), 1); assert!(System::events().iter().any(|a| a.event == - mock::Event::EthereumEvents(crate::Event::::EventChallenged { + mock::RuntimeEvent::EthereumEvents(crate::Event::::EventChallenged { eth_event_id: challenge.event_id.clone(), challenger: validator.account_id, challenge_reason: ChallengeReason::IncorrectResult @@ -772,7 +772,7 @@ fn test_challenge_valid_challenge_invalid_event_data() { assert_eq!(EthereumEvents::challenges(challenge.event_id.clone()).len(), 1); assert!(System::events().iter().any(|a| a.event == - mock::Event::EthereumEvents(crate::Event::::EventChallenged { + mock::RuntimeEvent::EthereumEvents(crate::Event::::EventChallenged { eth_event_id: challenge.event_id.clone(), challenger: validator.account_id, challenge_reason: ChallengeReason::IncorrectEventData diff --git a/pallets/ethereum-events/src/tests/test_ethereum_logs.rs b/pallets/ethereum-events/src/tests/test_ethereum_logs.rs index f310e8b0d..5ea570e3d 100644 --- a/pallets/ethereum-events/src/tests/test_ethereum_logs.rs +++ b/pallets/ethereum-events/src/tests/test_ethereum_logs.rs @@ -2,7 +2,10 @@ #![cfg(test)] -use crate::{mock::*, *}; +use crate::{ + mock::{RuntimeOrigin, *}, + *, +}; use frame_support::{assert_noop, assert_ok}; use frame_system::RawOrigin; use sp_avn_common::event_types::{EthEventId, ValidEvents}; @@ -20,7 +23,10 @@ mod test_add_validator_log { assert_eq!(EthereumEvents::ingress_counter(), FIRST_INGRESS_COUNTER - 1); - assert_ok!(EthereumEvents::add_validator_log(Origin::signed(account_id_0()), tx_hash)); + assert_ok!(EthereumEvents::add_validator_log( + RuntimeOrigin::signed(account_id_0()), + tx_hash + )); let validator_event = EthEventId { signature: ValidEvents::AddedValidator.signature(), transaction_hash: tx_hash, @@ -32,14 +38,15 @@ mod test_add_validator_log { 1 ))); - let event = Event::EthereumEvents(crate::Event::::EthereumEventAdded { - eth_event_id: validator_event.clone(), - added_by: account_id_0(), - t1_contract_address: EthereumEvents::get_contract_address_for_non_nft_event( - &ValidEvents::AddedValidator, - ) - .unwrap(), - }); + let event = + RuntimeEvent::EthereumEvents(crate::Event::::EthereumEventAdded { + eth_event_id: validator_event.clone(), + added_by: account_id_0(), + t1_contract_address: EthereumEvents::get_contract_address_for_non_nft_event( + &ValidEvents::AddedValidator, + ) + .unwrap(), + }); assert!(EthereumEvents::event_emitted(&event)); assert_eq!(1, System::events().len()); }); @@ -52,13 +59,16 @@ mod test_add_validator_log { let tx_hash: H256 = H256::from([1u8; 32]); let second_tx_hash: H256 = H256::from([2u8; 32]); - assert_ok!(EthereumEvents::add_validator_log(Origin::signed(signer), tx_hash)); + assert_ok!(EthereumEvents::add_validator_log(RuntimeOrigin::signed(signer), tx_hash)); let validator_event_1 = EthEventId { signature: ValidEvents::AddedValidator.signature(), transaction_hash: tx_hash, }; - assert_ok!(EthereumEvents::add_validator_log(Origin::signed(signer), second_tx_hash)); + assert_ok!(EthereumEvents::add_validator_log( + RuntimeOrigin::signed(signer), + second_tx_hash + )); let validator_event_2 = EthEventId { signature: ValidEvents::AddedValidator.signature(), transaction_hash: second_tx_hash, @@ -98,7 +108,7 @@ mod test_add_validator_log { create_two_successive_events(account_id_0()); let event = - Event::EthereumEvents(crate::Event::::EthereumEventAdded { + RuntimeEvent::EthereumEvents(crate::Event::::EthereumEventAdded { eth_event_id: validator_event_1.clone(), added_by: account_id_0(), t1_contract_address: @@ -110,7 +120,7 @@ mod test_add_validator_log { assert!(EthereumEvents::event_emitted(&event)); let event = - Event::EthereumEvents(crate::Event::::EthereumEventAdded { + RuntimeEvent::EthereumEvents(crate::Event::::EthereumEventAdded { eth_event_id: validator_event_2.clone(), added_by: account_id_0(), t1_contract_address: @@ -132,7 +142,10 @@ mod test_add_validator_log { ext.execute_with(|| { let tx_hash_invalid: H256 = H256::zero(); assert_noop!( - EthereumEvents::add_validator_log(Origin::signed(account_id_0()), tx_hash_invalid), + EthereumEvents::add_validator_log( + RuntimeOrigin::signed(account_id_0()), + tx_hash_invalid + ), Error::::MalformedHash ); // Ensure no events were emitted in avn @@ -155,7 +168,7 @@ mod test_add_validator_log { ); assert_noop!( - EthereumEvents::add_validator_log(Origin::signed(account_id_0()), tx_hash), + EthereumEvents::add_validator_log(RuntimeOrigin::signed(account_id_0()), tx_hash), Error::::DuplicateEvent ); // Ensure no events were emitted in avn @@ -187,7 +200,10 @@ mod test_add_lift_log { let mut ext = ExtBuilder::build_default().with_genesis_config().as_externality(); ext.execute_with(|| { let tx_hash: H256 = H256::random(); - assert_ok!(EthereumEvents::add_lift_log(Origin::signed(account_id_0()), tx_hash)); + assert_ok!(EthereumEvents::add_lift_log( + RuntimeOrigin::signed(account_id_0()), + tx_hash + )); let lift_event = EthEventId { signature: ValidEvents::Lifted.signature(), transaction_hash: tx_hash, @@ -199,14 +215,15 @@ mod test_add_lift_log { 1 ))); - let event = Event::EthereumEvents(crate::Event::::EthereumEventAdded { - eth_event_id: lift_event.clone(), - added_by: account_id_0(), - t1_contract_address: EthereumEvents::get_contract_address_for_non_nft_event( - &ValidEvents::Lifted, - ) - .unwrap(), - }); + let event = + RuntimeEvent::EthereumEvents(crate::Event::::EthereumEventAdded { + eth_event_id: lift_event.clone(), + added_by: account_id_0(), + t1_contract_address: EthereumEvents::get_contract_address_for_non_nft_event( + &ValidEvents::Lifted, + ) + .unwrap(), + }); assert!(EthereumEvents::event_emitted(&event)); assert_eq!(1, System::events().len()); }); @@ -218,7 +235,10 @@ mod test_add_lift_log { ext.execute_with(|| { let tx_hash_invalid: H256 = H256::zero(); assert_noop!( - EthereumEvents::add_lift_log(Origin::signed(account_id_0()), tx_hash_invalid), + EthereumEvents::add_lift_log( + RuntimeOrigin::signed(account_id_0()), + tx_hash_invalid + ), Error::::MalformedHash ); // Ensure no events were emitted in avn @@ -239,7 +259,7 @@ mod test_add_lift_log { DEFAULT_INGRESS_COUNTER, ); assert_noop!( - EthereumEvents::add_lift_log(Origin::signed(account_id_0()), tx_hash), + EthereumEvents::add_lift_log(RuntimeOrigin::signed(account_id_0()), tx_hash), Error::::DuplicateEvent ); // Ensure no events were emitted in avn @@ -263,7 +283,7 @@ mod test_add_ethereum_log { use super::*; struct Context { - origin: Origin, + origin: RuntimeOrigin, tx_hash: H256, nft_event_type: ValidEvents, current_block: BlockNumber, @@ -274,7 +294,7 @@ mod test_add_ethereum_log { impl Default for Context { fn default() -> Self { Context { - origin: Origin::signed(account_id_0()), + origin: RuntimeOrigin::signed(account_id_0()), tx_hash: H256::from([5u8; 32]), nft_event_type: ValidEvents::NftMint, current_block: 1, @@ -336,19 +356,23 @@ mod test_add_ethereum_log { let event; if context.nft_event_type.is_nft_event() { - event = Event::EthereumEvents(crate::Event::::NftEthereumEventAdded { - eth_event_id: ethereum_event.clone(), - account_id: account_id_0(), - }); + event = RuntimeEvent::EthereumEvents( + crate::Event::::NftEthereumEventAdded { + eth_event_id: ethereum_event.clone(), + account_id: account_id_0(), + }, + ); } else { - event = Event::EthereumEvents(crate::Event::::EthereumEventAdded { - eth_event_id: ethereum_event.clone(), - added_by: account_id_0(), - t1_contract_address: EthereumEvents::get_contract_address_for_non_nft_event( - &context.nft_event_type, - ) - .unwrap(), - }); + event = + RuntimeEvent::EthereumEvents(crate::Event::::EthereumEventAdded { + eth_event_id: ethereum_event.clone(), + added_by: account_id_0(), + t1_contract_address: + EthereumEvents::get_contract_address_for_non_nft_event( + &context.nft_event_type, + ) + .unwrap(), + }); } assert!(EthereumEvents::event_emitted(&event)); @@ -401,7 +425,7 @@ mod test_add_ethereum_log { let second_tx_hash: H256 = H256::from([2u8; 32]); assert_ok!(EthereumEvents::add_ethereum_log( - Origin::signed(signer), + RuntimeOrigin::signed(signer), first_event_type.clone(), first_tx_hash )); @@ -411,7 +435,7 @@ mod test_add_ethereum_log { }; assert_ok!(EthereumEvents::add_ethereum_log( - Origin::signed(signer), + RuntimeOrigin::signed(signer), second_event_type.clone(), second_tx_hash )); @@ -459,18 +483,20 @@ mod test_add_ethereum_log { ValidEvents::NftCancelListing, ); - let event = - Event::EthereumEvents(crate::Event::::NftEthereumEventAdded { + let event = RuntimeEvent::EthereumEvents( + crate::Event::::NftEthereumEventAdded { eth_event_id: validator_event_1.clone(), account_id: account_id_0(), - }); + }, + ); assert!(EthereumEvents::event_emitted(&event)); - let event = - Event::EthereumEvents(crate::Event::::NftEthereumEventAdded { + let event = RuntimeEvent::EthereumEvents( + crate::Event::::NftEthereumEventAdded { eth_event_id: validator_event_2.clone(), account_id: account_id_0(), - }); + }, + ); assert!(EthereumEvents::event_emitted(&event)); assert_eq!(2, System::events().len()); @@ -553,14 +579,15 @@ mod add_event { ))); // Check that the event is deposited with correct data - let event = Event::EthereumEvents(crate::Event::::EthereumEventAdded { - eth_event_id: lift_event.clone(), - added_by: account_id, - t1_contract_address: EthereumEvents::get_contract_address_for_non_nft_event( - &ValidEvents::Lifted, - ) - .unwrap(), - }); + let event = + RuntimeEvent::EthereumEvents(crate::Event::::EthereumEventAdded { + eth_event_id: lift_event.clone(), + added_by: account_id, + t1_contract_address: EthereumEvents::get_contract_address_for_non_nft_event( + &ValidEvents::Lifted, + ) + .unwrap(), + }); assert!(EthereumEvents::event_emitted(&event)); assert_eq!(1, System::events().len()); }); @@ -589,14 +616,15 @@ mod add_event { 1 ))); // Check that the event is deposited with correct data - let event = Event::EthereumEvents(crate::Event::::EthereumEventAdded { - eth_event_id: validator_event.clone(), - added_by: account_id, - t1_contract_address: EthereumEvents::get_contract_address_for_non_nft_event( - &ValidEvents::AddedValidator, - ) - .unwrap(), - }); + let event = + RuntimeEvent::EthereumEvents(crate::Event::::EthereumEventAdded { + eth_event_id: validator_event.clone(), + added_by: account_id, + t1_contract_address: EthereumEvents::get_contract_address_for_non_nft_event( + &ValidEvents::AddedValidator, + ) + .unwrap(), + }); assert!(EthereumEvents::event_emitted(&event)); assert_eq!(1, System::events().len()); }); diff --git a/pallets/ethereum-events/src/tests/test_offchain_worker.rs b/pallets/ethereum-events/src/tests/test_offchain_worker.rs index 8cb1247dc..c488e8368 100644 --- a/pallets/ethereum-events/src/tests/test_offchain_worker.rs +++ b/pallets/ethereum-events/src/tests/test_offchain_worker.rs @@ -2,7 +2,11 @@ #![cfg(test)] -use crate::{mock::*, Call, *}; +use crate::{ + mock::{RuntimeOrigin as Origin, *}, + pallet::EventsPendingChallenge, + Call, *, +}; use core::convert::TryInto; use frame_support::{assert_noop, unsigned::ValidateUnsigned}; use frame_system::RawOrigin; @@ -129,7 +133,7 @@ fn submit_checkevent_result_should_return_expected_result_when_input_is_valid() 2 ))); assert!(System::events().iter().any(|a| a.event == - mock::Event::EthereumEvents(crate::Event::::EventValidated { + mock::RuntimeEvent::EthereumEvents(crate::Event::::EventValidated { eth_event_id: mock_data.event_id.clone(), check_result: mock_data.check_result.clone(), validated_by: mock_data.checked_by.clone() @@ -159,7 +163,7 @@ fn submit_checkevent_result_should_return_error_when_request_is_signed() { DispatchError::BadOrigin ); assert!(!System::events().iter().any(|a| a.event == - mock::Event::EthereumEvents(crate::Event::::EventValidated { + mock::RuntimeEvent::EthereumEvents(crate::Event::::EventValidated { eth_event_id: mock_data.event_id.clone(), check_result: mock_data.check_result.clone(), validated_by: mock_data.checked_by.clone() @@ -199,7 +203,7 @@ fn submit_checkevent_result_should_return_error_when_validator_key_is_invalid() Error::::InvalidKey ); assert!(!System::events().iter().any(|a| a.event == - mock::Event::EthereumEvents(crate::Event::::EventValidated { + mock::RuntimeEvent::EthereumEvents(crate::Event::::EventValidated { eth_event_id: mock_data.event_id.clone(), check_result: mock_data.check_result.clone(), validated_by: mock_data.checked_by.clone() @@ -242,7 +246,7 @@ fn submit_checkevent_result_should_return_error_when_event_log_never_been_added( Error::::MissingEventToCheck ); assert!(!System::events().iter().any(|a| a.event == - mock::Event::EthereumEvents(crate::Event::::EventValidated { + mock::RuntimeEvent::EthereumEvents(crate::Event::::EventValidated { eth_event_id: mock_data.event_id.clone(), check_result: mock_data.check_result.clone(), validated_by: mock_data.checked_by.clone() @@ -273,7 +277,7 @@ fn submit_checkevent_result_should_return_error_when_challenge_window_overflow() Error::::Overflow ); assert!(!System::events().iter().any(|a| a.event == - mock::Event::EthereumEvents(crate::Event::::EventValidated { + mock::RuntimeEvent::EthereumEvents(crate::Event::::EventValidated { eth_event_id: mock_data.event_id.clone(), check_result: mock_data.check_result.clone(), validated_by: mock_data.checked_by.clone() @@ -314,16 +318,18 @@ fn process_event_should_return_expected_result_when_challenge_fails() { assert_eq!(EthereumEvents::events_pending_challenge().len(), 0); assert!(>::contains_key(&mock_data.event_id)); assert!(System::events().iter().any(|a| a.event == - mock::Event::EthereumEvents(crate::Event::::EventProcessed { + mock::RuntimeEvent::EthereumEvents(crate::Event::::EventProcessed { eth_event_id: mock_data.event_id.clone(), processor: mock_data.validator.account_id, outcome: true, }))); assert!(!System::events().iter().any(|a| a.event == - mock::Event::EthereumEvents(crate::Event::::ChallengeSucceeded { - eth_event_id: mock_data.event_id.clone(), - check_result: mock_data.check_result.clone() - }))); + mock::RuntimeEvent::EthereumEvents( + crate::Event::::ChallengeSucceeded { + eth_event_id: mock_data.event_id.clone(), + check_result: mock_data.check_result.clone() + } + ))); // TODO [TYPE: test][PRI: medium]: Test // TestRuntime::ProcessedEventHandler::on_event_processed is triggered @@ -382,16 +388,18 @@ fn process_event_should_return_expected_result_when_challenge_is_successful() { assert_eq!(EthereumEvents::events_pending_challenge().len(), 0); assert!(!>::contains_key(&mock_data.event_id)); assert!(System::events().iter().any(|a| a.event == - mock::Event::EthereumEvents(crate::Event::::EventProcessed { + mock::RuntimeEvent::EthereumEvents(crate::Event::::EventProcessed { eth_event_id: mock_data.event_id.clone(), processor: mock_data.validator.account_id, outcome: false, }))); assert!(System::events().iter().any(|a| a.event == - mock::Event::EthereumEvents(crate::Event::::ChallengeSucceeded { - eth_event_id: mock_data.event_id.clone(), - check_result: CheckResult::Invalid - }))); + mock::RuntimeEvent::EthereumEvents( + crate::Event::::ChallengeSucceeded { + eth_event_id: mock_data.event_id.clone(), + check_result: CheckResult::Invalid + } + ))); // TODO [TYPE: test][PRI: high][JIRA: 348]: Test // TestRuntime::ProcessedEventHandler::on_event_processed is triggered Test once if // possible, in a way that handles this todo and the previous one diff --git a/pallets/ethereum-events/src/tests/test_offchain_worker_calls.rs b/pallets/ethereum-events/src/tests/test_offchain_worker_calls.rs index a2e76a106..202b3e05c 100644 --- a/pallets/ethereum-events/src/tests/test_offchain_worker_calls.rs +++ b/pallets/ethereum-events/src/tests/test_offchain_worker_calls.rs @@ -146,7 +146,7 @@ fn check_event_and_submit_result( let tx = Extrinsic::decode(&mut &*tx).unwrap(); assert_eq!(tx.signature, None); match tx.call { - mock::Call::EthereumEvents(crate::Call::submit_checkevent_result { + mock::RuntimeCall::EthereumEvents(crate::Call::submit_checkevent_result { result: check_result, ingress_counter: call_counter, signature: _, @@ -210,7 +210,7 @@ fn test_check_event_and_submit_result_not_found() { let tx = Extrinsic::decode(&mut &*tx).unwrap(); assert_eq!(tx.signature, None); match tx.call { - mock::Call::EthereumEvents(crate::Call::submit_checkevent_result { + mock::RuntimeCall::EthereumEvents(crate::Call::submit_checkevent_result { result, ingress_counter: call_counter, signature: _, @@ -273,7 +273,7 @@ fn test_send_event_ok() { assert_eq!( tx.call, - mock::Call::EthereumEvents(crate::Call::process_event { + mock::RuntimeCall::EthereumEvents(crate::Call::process_event { event_id: event_result.event.event_id, ingress_counter: DEFAULT_INGRESS_COUNTER, validator, @@ -362,7 +362,7 @@ fn test_validate_event_ok() { assert_eq!( tx.call, - mock::Call::EthereumEvents(Call::challenge_event { + mock::RuntimeCall::EthereumEvents(Call::challenge_event { challenge: expected_challenge, ingress_counter: DEFAULT_INGRESS_COUNTER, signature: expected_signature, diff --git a/pallets/ethereum-events/src/tests/test_process_event.rs b/pallets/ethereum-events/src/tests/test_process_event.rs index 3ae308d1d..c755bec84 100644 --- a/pallets/ethereum-events/src/tests/test_process_event.rs +++ b/pallets/ethereum-events/src/tests/test_process_event.rs @@ -1,7 +1,10 @@ #![cfg(test)] use super::test_offchain_worker::MockData; -use crate::{mock::*, *}; +use crate::{ + mock::{RuntimeEvent as Event, *}, + *, +}; use frame_support::{assert_ok, pallet_prelude::DispatchResultWithPostInfo}; use frame_system::RawOrigin; use sp_core::hash::H256; diff --git a/pallets/ethereum-events/src/tests/test_proxy_signed_add_ethereum_logs.rs b/pallets/ethereum-events/src/tests/test_proxy_signed_add_ethereum_logs.rs index 7da005fbf..5f8aa3d9a 100644 --- a/pallets/ethereum-events/src/tests/test_proxy_signed_add_ethereum_logs.rs +++ b/pallets/ethereum-events/src/tests/test_proxy_signed_add_ethereum_logs.rs @@ -11,7 +11,7 @@ mod test_set_ethereum_contract { use super::*; struct Context { - origin: Origin, + origin: RuntimeOrigin, new_contract_address: H160, ethereum_contract: EthereumContracts, } @@ -132,7 +132,7 @@ mod test_set_ethereum_contract { let mut ext = ExtBuilder::build_default().with_genesis_config().as_externality(); ext.execute_with(|| { let context: Context = - Context { origin: Origin::signed(account_id_0()), ..Default::default() }; + Context { origin: RuntimeOrigin::signed(account_id_0()), ..Default::default() }; assert_noop!(context.dispatch_set_ethereum_contract(), BadOrigin); assert_ne!( diff --git a/pallets/ethereum-events/src/tests/test_set_ethereum_contract.rs b/pallets/ethereum-events/src/tests/test_set_ethereum_contract.rs index 7da005fbf..5f8aa3d9a 100644 --- a/pallets/ethereum-events/src/tests/test_set_ethereum_contract.rs +++ b/pallets/ethereum-events/src/tests/test_set_ethereum_contract.rs @@ -11,7 +11,7 @@ mod test_set_ethereum_contract { use super::*; struct Context { - origin: Origin, + origin: RuntimeOrigin, new_contract_address: H160, ethereum_contract: EthereumContracts, } @@ -132,7 +132,7 @@ mod test_set_ethereum_contract { let mut ext = ExtBuilder::build_default().with_genesis_config().as_externality(); ext.execute_with(|| { let context: Context = - Context { origin: Origin::signed(account_id_0()), ..Default::default() }; + Context { origin: RuntimeOrigin::signed(account_id_0()), ..Default::default() }; assert_noop!(context.dispatch_set_ethereum_contract(), BadOrigin); assert_ne!( diff --git a/pallets/ethereum-events/src/tests/test_set_event_challenge_period.rs b/pallets/ethereum-events/src/tests/test_set_event_challenge_period.rs index e8fe6008c..0286cb20c 100644 --- a/pallets/ethereum-events/src/tests/test_set_event_challenge_period.rs +++ b/pallets/ethereum-events/src/tests/test_set_event_challenge_period.rs @@ -1,7 +1,10 @@ // Copyright 2021 Aventus (UK) Ltd. #![cfg(test)] -use crate::{mock::*, *}; +use crate::{ + mock::{RuntimeEvent as Event, *}, + *, +}; use frame_support::{assert_noop, assert_ok}; use frame_system::RawOrigin; use sp_runtime::traits::BadOrigin; @@ -10,7 +13,7 @@ mod test_set_event_challenge_period { use super::*; struct Context { - origin: Origin, + origin: RuntimeOrigin, new_event_challenge_period: BlockNumber, } @@ -86,7 +89,7 @@ mod test_set_event_challenge_period { let mut ext = ExtBuilder::build_default().with_genesis_config().as_externality(); ext.execute_with(|| { let context: Context = - Context { origin: Origin::signed(account_id_0()), ..Default::default() }; + Context { origin: RuntimeOrigin::signed(account_id_0()), ..Default::default() }; assert_noop!(context.dispatch_set_event_challenge_period(), BadOrigin); diff --git a/pallets/ethereum-events/src/tests/tests.rs b/pallets/ethereum-events/src/tests/tests.rs index 461f3d0c2..32ca156a4 100644 --- a/pallets/ethereum-events/src/tests/tests.rs +++ b/pallets/ethereum-events/src/tests/tests.rs @@ -2,7 +2,10 @@ #![cfg(test)] -use crate::{mock::*, *}; +use crate::{ + mock::{RuntimeCall as Call, *}, + *, +}; use codec::Decode; use frame_support::{assert_ok, unsigned::ValidateUnsigned}; use sp_avn_common::event_types::{EthEventId, ValidEvents}; diff --git a/pallets/ethereum-transactions/Cargo.toml b/pallets/ethereum-transactions/Cargo.toml index 21bc56cc2..4495bcc48 100644 --- a/pallets/ethereum-transactions/Cargo.toml +++ b/pallets/ethereum-transactions/Cargo.toml @@ -19,24 +19,25 @@ scale-info = { version = "2.0", default-features = false, features = ["derive"] sp-avn-common = { version = "0.12.0", default-features = false, path = "../../primitives/avn-common" } pallet-avn = { version = "0.12.0", default-features = false, path = "../avn" } -sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -frame-system = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -sp-application-crypto = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -sp-io = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } +sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +frame-system = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +sp-application-crypto = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +sp-io = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } # Optional imports for benchmarking -frame-benchmarking = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27", optional = true } +frame-benchmarking = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", optional = true } [dev-dependencies] -pallet-session = { features = ["historical"], git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27", default-features = false } +pallet-session = { features = ["historical"], git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } [features] migrate = [] default = ["std"] std = [ + "frame-benchmarking?/std", "serde", "codec/std", "sp-std/std", @@ -49,7 +50,7 @@ std = [ "pallet-avn/std", ] runtime-benchmarks = [ - "frame-benchmarking", + "frame-benchmarking/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", ] \ No newline at end of file diff --git a/pallets/ethereum-transactions/src/benchmarking.rs b/pallets/ethereum-transactions/src/benchmarking.rs index 87a36a91a..3eff43a22 100644 --- a/pallets/ethereum-transactions/src/benchmarking.rs +++ b/pallets/ethereum-transactions/src/benchmarking.rs @@ -97,13 +97,13 @@ fn generate_signature( return signature } -fn assert_last_event(generic_event: ::Event) { +fn assert_last_event(generic_event: ::RuntimeEvent) { assert_last_nth_event::(generic_event, 1); } -fn assert_last_nth_event(generic_event: ::Event, n: u32) { +fn assert_last_nth_event(generic_event: ::RuntimeEvent, n: u32) { let events = frame_system::Pallet::::events(); - let system_event: ::Event = generic_event.into(); + let system_event: ::RuntimeEvent = generic_event.into(); // compare to the last event record let EventRecord { event, .. } = &events[events.len().saturating_sub(n as usize)]; assert_eq!(event, &system_event); diff --git a/pallets/ethereum-transactions/src/default_weights.rs b/pallets/ethereum-transactions/src/default_weights.rs index d680bbe76..03daae545 100644 --- a/pallets/ethereum-transactions/src/default_weights.rs +++ b/pallets/ethereum-transactions/src/default_weights.rs @@ -63,14 +63,14 @@ pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { // Storage: EthereumTransactions Nonce (r:0 w:1) fn set_transaction_id() -> Weight { - (4_841_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + (Weight::from_ref_time(4_841_000)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: EthereumTransactions ReservedTransactions (r:1 w:2) fn unreserve_transaction() -> Weight { - (12_201_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + (Weight::from_ref_time(12_201_000)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: Avn Validators (r:1 w:0) // Storage: EthereumTransactions Repository (r:1 w:1) @@ -78,16 +78,16 @@ impl WeightInfo for SubstrateWeight { /// The range of component `v` is `[1, 10]`. /// The range of component `t` is `[1, 1000000]`. fn set_eth_tx_hash_for_dispatched_tx(_v: u32, t: u32, ) -> Weight { - (1_046_680_000 as Weight) + (Weight::from_ref_time(1_046_680_000)) // Standard Error: 0 - .saturating_add((25_000 as Weight).saturating_mul(t as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(25_000).saturating_mul(t as u64)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: EthereumTransactions PublishRootContract (r:0 w:1) fn set_publish_root_contract() -> Weight { - (5_140_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + (Weight::from_ref_time(5_140_000)) + .saturating_add(T::DbWeight::get().writes(1)) } } @@ -95,14 +95,14 @@ impl WeightInfo for SubstrateWeight { impl WeightInfo for () { // Storage: EthereumTransactions Nonce (r:0 w:1) fn set_transaction_id() -> Weight { - (4_841_000 as Weight) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + (Weight::from_ref_time(4_841_000)) + .saturating_add(RocksDbWeight::get().writes(1)) } // Storage: EthereumTransactions ReservedTransactions (r:1 w:2) fn unreserve_transaction() -> Weight { - (12_201_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + (Weight::from_ref_time(12_201_000)) + .saturating_add(RocksDbWeight::get().reads(1)) + .saturating_add(RocksDbWeight::get().writes(2)) } // Storage: Avn Validators (r:1 w:0) // Storage: EthereumTransactions Repository (r:1 w:1) @@ -110,15 +110,15 @@ impl WeightInfo for () { /// The range of component `v` is `[1, 10]`. /// The range of component `t` is `[1, 1000000]`. fn set_eth_tx_hash_for_dispatched_tx(_v: u32, t: u32, ) -> Weight { - (1_046_680_000 as Weight) + (Weight::from_ref_time(1_046_680_000)) // Standard Error: 0 - .saturating_add((25_000 as Weight).saturating_mul(t as Weight)) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(25_000).saturating_mul(t as u64)) + .saturating_add(RocksDbWeight::get().reads(3)) + .saturating_add(RocksDbWeight::get().writes(1)) } // Storage: EthereumTransactions PublishRootContract (r:0 w:1) fn set_publish_root_contract() -> Weight { - (5_140_000 as Weight) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + (Weight::from_ref_time(5_140_000)) + .saturating_add(RocksDbWeight::get().writes(1)) } } \ No newline at end of file diff --git a/pallets/ethereum-transactions/src/lib.rs b/pallets/ethereum-transactions/src/lib.rs index c73db95a2..ea1955318 100644 --- a/pallets/ethereum-transactions/src/lib.rs +++ b/pallets/ethereum-transactions/src/lib.rs @@ -100,11 +100,11 @@ pub mod pallet { pub trait Config: SendTransactionTypes> + frame_system::Config + avn::Config { - type Event: From> - + Into<::Event> - + IsType<::Event>; + type RuntimeEvent: From> + + Into<::RuntimeEvent> + + IsType<::RuntimeEvent>; - type Call: From>; + type RuntimeCall: From>; type AccountToBytesConvert: AccountToBytesConverter; @@ -221,6 +221,7 @@ pub mod pallet { // finalized, and possible in a state where our governance is centralized. // Suggestion: We can wrap it in a build configuration flag for conditional compilation, eg // "allow-sudo-shortcuts" + #[pallet::call_index(0)] #[pallet::weight(::WeightInfo::set_transaction_id())] pub fn set_transaction_id( origin: OriginFor, @@ -231,6 +232,7 @@ pub mod pallet { Ok(()) } + #[pallet::call_index(1)] #[pallet::weight(::WeightInfo::set_eth_tx_hash_for_dispatched_tx(MAX_VALIDATORS, MAX_TXS_PER_ACCOUNT))] pub fn set_eth_tx_hash_for_dispatched_tx( origin: OriginFor, @@ -273,6 +275,7 @@ pub mod pallet { // See SYS-870 & SYS-855 for more information /// Removes a reservation for a transaction that was created with reserve_transaction_id /// Only sudo should call this to repair a network. + #[pallet::call_index(2)] #[pallet::weight(::WeightInfo::unreserve_transaction())] pub fn unreserve_transaction( origin: OriginFor, @@ -291,6 +294,7 @@ pub mod pallet { } /// Sets the address for ethereum contracts + #[pallet::call_index(3)] #[pallet::weight(::WeightInfo::set_publish_root_contract())] pub fn set_publish_root_contract( origin: OriginFor, diff --git a/pallets/ethereum-transactions/src/mock.rs b/pallets/ethereum-transactions/src/mock.rs index df90d16d7..b1a634f7a 100644 --- a/pallets/ethereum-transactions/src/mock.rs +++ b/pallets/ethereum-transactions/src/mock.rs @@ -64,8 +64,8 @@ parameter_types! { } impl Config for TestRuntime { - type Event = Event; - type Call = Call; + type RuntimeEvent = RuntimeEvent; + type RuntimeCall = RuntimeCall; type AccountToBytesConvert = U64To32BytesConverter; type ValidatorManagerContractAddress = TestValidatorManagerContractAddress; type WeightInfo = (); @@ -73,7 +73,7 @@ impl Config for TestRuntime { parameter_types! { pub const BlockHashCount: u64 = 250; - pub const MaximumBlockWeight: Weight = 1024; + pub const MaximumBlockWeight: Weight = Weight::from_ref_time(1024); pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75); pub const ChallengePeriod: u64 = 2; @@ -84,8 +84,8 @@ impl system::Config for TestRuntime { type BlockWeights = (); type BlockLength = (); type DbWeight = (); - type Origin = Origin; - type Call = Call; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; type Index = u64; type BlockNumber = u64; type Hash = H256; @@ -93,7 +93,7 @@ impl system::Config for TestRuntime { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type Version = (); type PalletInfo = PalletInfo; @@ -106,13 +106,13 @@ impl system::Config for TestRuntime { type MaxConsumers = frame_support::traits::ConstU32<16>; } -pub type Extrinsic = TestXt; +pub type Extrinsic = TestXt; impl frame_system::offchain::SendTransactionTypes for TestRuntime where - Call: From, + RuntimeCall: From, { - type OverarchingCall = Call; + type OverarchingCall = RuntimeCall; type Extrinsic = Extrinsic; } @@ -150,7 +150,7 @@ impl session::Config for TestRuntime { type Keys = UintAuthorityId; type ShouldEndSession = session::PeriodicSessions; type SessionHandler = (AVN,); - type Event = Event; + type RuntimeEvent = RuntimeEvent; type ValidatorId = u64; type ValidatorIdOf = ConvertInto; type NextSessionRotation = session::PeriodicSessions; @@ -212,7 +212,7 @@ impl EthereumTransactions { // TODO [TYPE: test refactoring][PRI: medium]: move this to a centralized pallet of test // utilities, when we do that refactoring, and apply it to all emitted system event // assertions. - pub fn event_emitted(event: &Event) -> bool { + pub fn event_emitted(event: &RuntimeEvent) -> bool { return System::events().iter().any(|a| a.event == *event) } diff --git a/pallets/ethereum-transactions/src/tests/test_set_publish_root_contract.rs b/pallets/ethereum-transactions/src/tests/test_set_publish_root_contract.rs index 963b932c3..d49a5405c 100644 --- a/pallets/ethereum-transactions/src/tests/test_set_publish_root_contract.rs +++ b/pallets/ethereum-transactions/src/tests/test_set_publish_root_contract.rs @@ -10,7 +10,7 @@ mod test_set_publish_root_contract { use super::*; struct Context { - origin: Origin, + origin: RuntimeOrigin, new_contract_address: H160, } @@ -70,8 +70,10 @@ mod test_set_publish_root_contract { fn origin_is_not_root() { let mut ext = ExtBuilder::build_default().with_genesis_config().as_externality(); ext.execute_with(|| { - let context: Context = - Context { origin: Origin::signed(Default::default()), ..Default::default() }; + let context: Context = Context { + origin: RuntimeOrigin::signed(Default::default()), + ..Default::default() + }; assert_noop!(context.dispatch_set_publish_root_contract(), BadOrigin); assert_ne!( diff --git a/pallets/ethereum-transactions/src/tests/tests.rs b/pallets/ethereum-transactions/src/tests/tests.rs index 8c32a6dda..ce16484c9 100644 --- a/pallets/ethereum-transactions/src/tests/tests.rs +++ b/pallets/ethereum-transactions/src/tests/tests.rs @@ -471,7 +471,7 @@ mod submit_candidate_for_tier1 { assert_eq!(EthereumTransactions::event_count(), 0); assert_ok!(call_submit_candidate_for_tier1(expected_candidate, context.from)); - let event = mock::Event::EthereumTransactions( + let event = mock::RuntimeEvent::EthereumTransactions( crate::Event::::TransactionReadyToSend { transaction_id: context.tx_id, sender: context.from, @@ -509,7 +509,7 @@ mod set_eth_tx_hash_for_dispatched_tx { } fn call_set_eth_tx_hash_for_dispatched_tx( - origin: Origin, + origin: RuntimeOrigin, tx_id: TransactionId, submitter: AccountId, eth_tx_hash: EthereumTransactionHash, @@ -569,7 +569,7 @@ mod set_eth_tx_hash_for_dispatched_tx { context.hash )); - let event = mock::Event::EthereumTransactions( + let event = mock::RuntimeEvent::EthereumTransactions( crate::Event::::EthereumTransactionHashAdded { transaction_id: context.tx_id, transaction_hash: context.hash, @@ -600,7 +600,7 @@ mod set_eth_tx_hash_for_dispatched_tx { // untouched assert_noop!( call_set_eth_tx_hash_for_dispatched_tx( - Origin::signed(Default::default()), + RuntimeOrigin::signed(Default::default()), context.tx_id, context.submitter, context.hash, @@ -1264,7 +1264,7 @@ mod unreserve_transaction_tests { ); assert_noop!( EthereumTransactions::unreserve_transaction( - Origin::signed(Default::default()), + RuntimeOrigin::signed(Default::default()), context.transaction_type.clone() ), BadOrigin diff --git a/pallets/nft-manager/Cargo.toml b/pallets/nft-manager/Cargo.toml index 0f81e1495..8833612ae 100644 --- a/pallets/nft-manager/Cargo.toml +++ b/pallets/nft-manager/Cargo.toml @@ -14,27 +14,28 @@ targets = ["x86_64-unknown-linux-gnu"] codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false } hex-literal = { version = "0.3.4", default-features = false } scale-info = { version = "2.0", default-features = false, features = ["derive"] } -frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -frame-system = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } +frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +frame-system = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } sp-avn-common = { version = "0.12.0", default-features = false, path = "../../primitives/avn-common" } -sp-io = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } +sp-io = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } pallet-avn = { version = "0.12.0", default-features = false, path = "../avn" } # Optional imports for benchmarking -frame-benchmarking = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27", optional = true } +frame-benchmarking = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", optional = true } [dev-dependencies] serde = { version = "1.0.101" } -substrate-test-utils = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } +substrate-test-utils = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } parking_lot = { version = "0.12.0" } -sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } +sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } [features] default = ['std'] std = [ + "frame-benchmarking?/std", 'codec/std', 'sp-std/std', 'sp-core/std', @@ -46,7 +47,7 @@ std = [ 'sp-avn-common/std', ] runtime-benchmarks = [ - "frame-benchmarking", + "frame-benchmarking/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", ] diff --git a/pallets/nft-manager/src/batch_nft.rs b/pallets/nft-manager/src/batch_nft.rs index 0fa31578c..c8de33673 100644 --- a/pallets/nft-manager/src/batch_nft.rs +++ b/pallets/nft-manager/src/batch_nft.rs @@ -14,8 +14,13 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use crate::*; -use frame_support::dispatch::DispatchError; +use crate::{ + keccak_256, BatchInfoId, BatchOpenForSale, Config, Decode, DispatchResult, Encode, Error, + EthEventId, Event, Nft, NftBatchId, NftBatches, NftEndBatchListingData, NftInfo, NftInfoId, + NftInfos, NftSaleType, NftUniqueId, Nfts, Pallet, ProcessedEventsChecker, Proof, Royalty, Vec, + BATCH_ID_CONTEXT, BATCH_NFT_ID_CONTEXT, H160, U256, +}; +use frame_support::{dispatch::DispatchError, ensure}; use sp_avn_common::event_types::NftMintData; pub const SIGNED_CREATE_BATCH_CONTEXT: &'static [u8] = b"authorization for create batch operation"; diff --git a/pallets/nft-manager/src/benchmarking.rs b/pallets/nft-manager/src/benchmarking.rs index fe531f880..a043fa48f 100644 --- a/pallets/nft-manager/src/benchmarking.rs +++ b/pallets/nft-manager/src/benchmarking.rs @@ -35,13 +35,13 @@ use alloc::string::{String, ToString}; const MNEMONIC: &str = "kiss mule sheriff twice make bike twice improve rate quote draw enough"; -fn assert_last_event(generic_event: ::Event) { +fn assert_last_event(generic_event: ::RuntimeEvent) { assert_last_nth_event::(generic_event, 1); } -fn assert_last_nth_event(generic_event: ::Event, n: u32) { +fn assert_last_nth_event(generic_event: ::RuntimeEvent, n: u32) { let events = frame_system::Pallet::::events(); - let system_event: ::Event = generic_event.into(); + let system_event: ::RuntimeEvent = generic_event.into(); // compare to the last event record let EventRecord { event, .. } = &events[events.len().saturating_sub(n as usize)]; assert_eq!(event, &system_event); @@ -145,7 +145,7 @@ impl MintSingleNft { return self } - fn generate_signed_mint_single_nft(&self) -> ::Call { + fn generate_signed_mint_single_nft(&self) -> ::RuntimeCall { let proof: Proof = get_proof::(self.nft_owner.clone(), self.relayer.clone(), &self.signature); return Call::signed_mint_single_nft { @@ -199,7 +199,7 @@ impl ListNftOpenForSale { return self } - fn generate_signed_list_nft_open_for_sale_call(&self) -> ::Call { + fn generate_signed_list_nft_open_for_sale_call(&self) -> ::RuntimeCall { let proof: Proof = get_proof::(self.nft_owner.clone(), self.relayer.clone(), &self.signature); return Call::signed_list_nft_open_for_sale { @@ -269,7 +269,7 @@ impl TransferFiatNft { return self } - fn generate_signed_transfer_fiat_nft_call(&self) -> ::Call { + fn generate_signed_transfer_fiat_nft_call(&self) -> ::RuntimeCall { let proof: Proof = get_proof::(self.nft_owner.clone(), self.relayer.clone(), &self.signature); return Call::signed_transfer_fiat_nft { @@ -326,7 +326,7 @@ impl CancelListFiatNft { return self } - fn generate_signed_cancel_list_fiat_nft_call(&self) -> ::Call { + fn generate_signed_cancel_list_fiat_nft_call(&self) -> ::RuntimeCall { let proof: Proof = get_proof::(self.nft_owner.clone(), self.relayer.clone(), &self.signature); return Call::signed_cancel_list_fiat_nft { proof, nft_id: self.nft_id }.into() @@ -384,7 +384,7 @@ impl CreateBatch { royalties } - fn generate_signed_create_batch(&self) -> ::Call { + fn generate_signed_create_batch(&self) -> ::RuntimeCall { let proof: Proof = get_proof::(self.creator_account_id.clone(), self.relayer.clone(), &self.signature); return Call::signed_create_batch { @@ -468,7 +468,11 @@ impl MintBatchNft { } } - fn generate_signed_mint_batch_nft(&self, batch_id: U256, index: u64) -> ::Call { + fn generate_signed_mint_batch_nft( + &self, + batch_id: U256, + index: u64, + ) -> ::RuntimeCall { let proof: Proof = get_proof::(self.nft_owner.clone(), self.relayer.clone(), &self.signature); return Call::signed_mint_batch_nft { @@ -515,7 +519,7 @@ impl ListBatch { } } - fn generate_signed_list_batch(&self) -> ::Call { + fn generate_signed_list_batch(&self) -> ::RuntimeCall { let proof: Proof = get_proof::(self.creator_account_id.clone(), self.relayer.clone(), &self.signature); return Call::signed_list_batch_for_sale { @@ -562,7 +566,7 @@ impl EndBatchSale { } } - fn generate_signed_end_batch_sale(&self) -> ::Call { + fn generate_signed_end_batch_sale(&self) -> ::RuntimeCall { let proof: Proof = get_proof::(self.creator_account_id.clone(), self.relayer.clone(), &self.signature); return Call::signed_end_batch_sale { proof, batch_id: self.batch_id }.into() @@ -733,8 +737,8 @@ benchmarks! { proxy_signed_mint_single_nft { let r in 1 .. MAX_NUMBER_OF_ROYALTIES; let mint_nft: MintSingleNft = MintSingleNft::new(r).setup(); - let call: ::Call = mint_nft.generate_signed_mint_single_nft(); - let boxed_call: Box<::Call> = Box::new(call); + let call: ::RuntimeCall = mint_nft.generate_signed_mint_single_nft(); + let boxed_call: Box<::RuntimeCall> = Box::new(call); let call_hash: T::Hash = T::Hashing::hash_of(&boxed_call); }: proxy(RawOrigin::::Signed(mint_nft.relayer.clone()), boxed_call) verify { @@ -761,8 +765,8 @@ benchmarks! { proxy_signed_list_nft_open_for_sale { let open_for_sale: ListNftOpenForSale = ListNftOpenForSale::new().setup(); let original_nonce = Nfts::::get(open_for_sale.nft_id).unwrap().nonce; - let call: ::Call = open_for_sale.generate_signed_list_nft_open_for_sale_call(); - let boxed_call: Box<::Call> = Box::new(call); + let call: ::RuntimeCall = open_for_sale.generate_signed_list_nft_open_for_sale_call(); + let boxed_call: Box<::RuntimeCall> = Box::new(call); let call_hash: T::Hash = T::Hashing::hash_of(&boxed_call); }: proxy(RawOrigin::::Signed(open_for_sale.relayer.clone()), boxed_call) verify { @@ -775,8 +779,8 @@ benchmarks! { proxy_signed_transfer_fiat_nft { let transfer_fiat_nft: TransferFiatNft = TransferFiatNft::new().setup(); let original_nonce = Nfts::::get(transfer_fiat_nft.nft_id).unwrap().nonce; - let call: ::Call = transfer_fiat_nft.generate_signed_transfer_fiat_nft_call(); - let boxed_call: Box<::Call> = Box::new(call); + let call: ::RuntimeCall = transfer_fiat_nft.generate_signed_transfer_fiat_nft_call(); + let boxed_call: Box<::RuntimeCall> = Box::new(call); let call_hash: T::Hash = T::Hashing::hash_of(&boxed_call); }: proxy(RawOrigin::::Signed(transfer_fiat_nft.relayer.clone()), boxed_call) verify { @@ -796,8 +800,8 @@ benchmarks! { proxy_signed_cancel_list_fiat_nft { let cancel_list_fiat_nft: CancelListFiatNft = CancelListFiatNft::new().setup(); let original_nonce = Nfts::::get(cancel_list_fiat_nft.nft_id).unwrap().nonce; - let call: ::Call = cancel_list_fiat_nft.generate_signed_cancel_list_fiat_nft_call(); - let boxed_call: Box<::Call> = Box::new(call); + let call: ::RuntimeCall = cancel_list_fiat_nft.generate_signed_cancel_list_fiat_nft_call(); + let boxed_call: Box<::RuntimeCall> = Box::new(call); let call_hash: T::Hash = T::Hashing::hash_of(&boxed_call); }: proxy(RawOrigin::::Signed(cancel_list_fiat_nft.relayer.clone()), boxed_call) verify { @@ -815,8 +819,8 @@ benchmarks! { proxy_signed_create_batch { let r in 1 .. MAX_NUMBER_OF_ROYALTIES; let batch: CreateBatch = CreateBatch::new(r); - let call: ::Call = batch.generate_signed_create_batch(); - let boxed_call: Box<::Call> = Box::new(call); + let call: ::RuntimeCall = batch.generate_signed_create_batch(); + let boxed_call: Box<::RuntimeCall> = Box::new(call); let call_hash: T::Hash = T::Hashing::hash_of(&boxed_call); let expected_batch_id = generate_batch_id::(>::get()); }: proxy(RawOrigin::::Signed(batch.relayer.clone()), boxed_call) @@ -840,8 +844,8 @@ benchmarks! { proxy_signed_mint_batch_nft { let index = 0u64; let context: MintBatchNft = MintBatchNft::new(); - let call: ::Call = context.generate_signed_mint_batch_nft(context.batch_id, index); - let boxed_call: Box<::Call> = Box::new(call); + let call: ::RuntimeCall = context.generate_signed_mint_batch_nft(context.batch_id, index); + let boxed_call: Box<::RuntimeCall> = Box::new(call); let call_hash: T::Hash = T::Hashing::hash_of(&boxed_call); }: proxy(RawOrigin::::Signed(context.relayer.clone()), boxed_call) verify { @@ -865,8 +869,8 @@ benchmarks! { proxy_signed_list_batch_for_sale { let context: ListBatch = ListBatch::new(); - let call: ::Call = context.generate_signed_list_batch(); - let boxed_call: Box<::Call> = Box::new(call); + let call: ::RuntimeCall = context.generate_signed_list_batch(); + let boxed_call: Box<::RuntimeCall> = Box::new(call); let call_hash: T::Hash = T::Hashing::hash_of(&boxed_call); }: proxy(RawOrigin::::Signed(context.relayer.clone()), boxed_call) verify { @@ -880,8 +884,8 @@ benchmarks! { proxy_signed_end_batch_sale { let context: EndBatchSale = EndBatchSale::new(); - let call: ::Call = context.generate_signed_end_batch_sale(); - let boxed_call: Box<::Call> = Box::new(call); + let call: ::RuntimeCall = context.generate_signed_end_batch_sale(); + let boxed_call: Box<::RuntimeCall> = Box::new(call); let call_hash: T::Hash = T::Hashing::hash_of(&boxed_call); }: proxy(RawOrigin::::Signed(context.relayer.clone()), boxed_call) verify { diff --git a/pallets/nft-manager/src/default_weights.rs b/pallets/nft-manager/src/default_weights.rs index 5c3e47d72..28b4b9324 100644 --- a/pallets/nft-manager/src/default_weights.rs +++ b/pallets/nft-manager/src/default_weights.rs @@ -79,9 +79,9 @@ impl WeightInfo for SubstrateWeight { // Storage: NftManager NftInfos (r:0 w:1) /// The range of component `r` is `[1, 5]`. fn mint_single_nft(_r: u32, ) -> Weight { - (43_962_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + (Weight::from_ref_time(43_962_000)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(6)) } // Storage: NftManager UsedExternalReferences (r:1 w:1) // Storage: NftManager NextSingleNftUniqueId (r:1 w:1) @@ -91,40 +91,40 @@ impl WeightInfo for SubstrateWeight { // Storage: NftManager NftInfos (r:0 w:1) /// The range of component `r` is `[1, 5]`. fn signed_mint_single_nft(r: u32, ) -> Weight { - (119_551_000 as Weight) + (Weight::from_ref_time(119_551_000)) // Standard Error: 107_000 - .saturating_add((197_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + .saturating_add(Weight::from_ref_time(197_000).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(6)) } // Storage: NftManager Nfts (r:1 w:1) // Storage: NftManager NftOpenForSale (r:1 w:1) fn list_nft_open_for_sale() -> Weight { - (28_861_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + (Weight::from_ref_time(28_861_000)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: NftManager Nfts (r:1 w:1) // Storage: NftManager NftOpenForSale (r:1 w:1) fn signed_list_nft_open_for_sale() -> Weight { - (106_103_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + (Weight::from_ref_time(106_103_000)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: NftManager NftOpenForSale (r:1 w:1) // Storage: NftManager Nfts (r:1 w:1) // Storage: NftManager OwnedNfts (r:2 w:2) fn signed_transfer_fiat_nft() -> Weight { - (122_213_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + (Weight::from_ref_time(122_213_000)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(4)) } // Storage: NftManager NftOpenForSale (r:1 w:1) // Storage: NftManager Nfts (r:1 w:1) fn signed_cancel_list_fiat_nft() -> Weight { - (114_953_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + (Weight::from_ref_time(114_953_000)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: NftManager UsedExternalReferences (r:1 w:1) // Storage: NftManager NextSingleNftUniqueId (r:1 w:1) @@ -134,33 +134,33 @@ impl WeightInfo for SubstrateWeight { // Storage: NftManager NftInfos (r:0 w:1) /// The range of component `r` is `[1, 5]`. fn proxy_signed_mint_single_nft(r: u32, ) -> Weight { - (128_067_000 as Weight) + (Weight::from_ref_time(128_067_000)) // Standard Error: 135_000 - .saturating_add((601_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + .saturating_add(Weight::from_ref_time(601_000).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(6)) } // Storage: NftManager Nfts (r:1 w:1) // Storage: NftManager NftOpenForSale (r:1 w:1) fn proxy_signed_list_nft_open_for_sale() -> Weight { - (115_453_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + (Weight::from_ref_time(115_453_000)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: NftManager NftOpenForSale (r:1 w:1) // Storage: NftManager Nfts (r:1 w:1) // Storage: NftManager OwnedNfts (r:2 w:2) fn proxy_signed_transfer_fiat_nft() -> Weight { - (132_334_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + (Weight::from_ref_time(132_334_000)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(4)) } // Storage: NftManager NftOpenForSale (r:1 w:1) // Storage: NftManager Nfts (r:1 w:1) fn proxy_signed_cancel_list_fiat_nft() -> Weight { - (122_423_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + (Weight::from_ref_time(122_423_000)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: NftManager BatchNonces (r:1 w:1) // Storage: NftManager NextSingleNftUniqueId (r:1 w:1) @@ -169,11 +169,11 @@ impl WeightInfo for SubstrateWeight { // Storage: NftManager NftInfos (r:0 w:1) /// The range of component `r` is `[1, 5]`. fn proxy_signed_create_batch(r: u32, ) -> Weight { - (122_325_000 as Weight) + (Weight::from_ref_time(122_325_000)) // Standard Error: 137_000 - .saturating_add((687_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + .saturating_add(Weight::from_ref_time(687_000).saturating_mul(r as u64)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(5)) } // Storage: NftManager BatchInfoId (r:1 w:0) // Storage: NftManager BatchOpenForSale (r:1 w:0) @@ -183,9 +183,9 @@ impl WeightInfo for SubstrateWeight { // Storage: NftManager Nfts (r:1 w:1) // Storage: NftManager OwnedNfts (r:1 w:1) fn proxy_signed_mint_batch_nft() -> Weight { - (152_674_000 as Weight) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) + (Weight::from_ref_time(152_674_000)) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(4)) } // Storage: NftManager BatchInfoId (r:1 w:0) // Storage: NftManager BatchNonces (r:1 w:1) @@ -193,18 +193,18 @@ impl WeightInfo for SubstrateWeight { // Storage: NftManager NftBatches (r:1 w:0) // Storage: NftManager BatchOpenForSale (r:1 w:1) fn proxy_signed_list_batch_for_sale() -> Weight { - (129_444_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + (Weight::from_ref_time(129_444_000)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: NftManager BatchInfoId (r:1 w:0) // Storage: NftManager BatchOpenForSale (r:1 w:1) // Storage: NftManager BatchNonces (r:1 w:1) // Storage: NftManager NftInfos (r:1 w:0) fn proxy_signed_end_batch_sale() -> Weight { - (131_444_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + (Weight::from_ref_time(131_444_000)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(2)) } } @@ -218,9 +218,9 @@ impl WeightInfo for () { // Storage: NftManager NftInfos (r:0 w:1) /// The range of component `r` is `[1, 5]`. fn mint_single_nft(_r: u32, ) -> Weight { - (43_962_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes(6 as Weight)) + (Weight::from_ref_time(43_962_000)) + .saturating_add(RocksDbWeight::get().reads(5)) + .saturating_add(RocksDbWeight::get().writes(6)) } // Storage: NftManager UsedExternalReferences (r:1 w:1) // Storage: NftManager NextSingleNftUniqueId (r:1 w:1) @@ -230,40 +230,40 @@ impl WeightInfo for () { // Storage: NftManager NftInfos (r:0 w:1) /// The range of component `r` is `[1, 5]`. fn signed_mint_single_nft(r: u32, ) -> Weight { - (119_551_000 as Weight) + (Weight::from_ref_time(119_551_000)) // Standard Error: 107_000 - .saturating_add((197_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes(6 as Weight)) + .saturating_add(Weight::from_ref_time(197_000).saturating_mul(r as u64)) + .saturating_add(RocksDbWeight::get().reads(5)) + .saturating_add(RocksDbWeight::get().writes(6)) } // Storage: NftManager Nfts (r:1 w:1) // Storage: NftManager NftOpenForSale (r:1 w:1) fn list_nft_open_for_sale() -> Weight { - (28_861_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + (Weight::from_ref_time(28_861_000)) + .saturating_add(RocksDbWeight::get().reads(2)) + .saturating_add(RocksDbWeight::get().writes(2)) } // Storage: NftManager Nfts (r:1 w:1) // Storage: NftManager NftOpenForSale (r:1 w:1) fn signed_list_nft_open_for_sale() -> Weight { - (106_103_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + (Weight::from_ref_time(106_103_000)) + .saturating_add(RocksDbWeight::get().reads(2)) + .saturating_add(RocksDbWeight::get().writes(2)) } // Storage: NftManager NftOpenForSale (r:1 w:1) // Storage: NftManager Nfts (r:1 w:1) // Storage: NftManager OwnedNfts (r:2 w:2) fn signed_transfer_fiat_nft() -> Weight { - (122_213_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(4 as Weight)) + (Weight::from_ref_time(122_213_000)) + .saturating_add(RocksDbWeight::get().reads(4)) + .saturating_add(RocksDbWeight::get().writes(4)) } // Storage: NftManager NftOpenForSale (r:1 w:1) // Storage: NftManager Nfts (r:1 w:1) fn signed_cancel_list_fiat_nft() -> Weight { - (114_953_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + (Weight::from_ref_time(114_953_000)) + .saturating_add(RocksDbWeight::get().reads(2)) + .saturating_add(RocksDbWeight::get().writes(2)) } // Storage: NftManager UsedExternalReferences (r:1 w:1) // Storage: NftManager NextSingleNftUniqueId (r:1 w:1) @@ -273,33 +273,33 @@ impl WeightInfo for () { // Storage: NftManager NftInfos (r:0 w:1) /// The range of component `r` is `[1, 5]`. fn proxy_signed_mint_single_nft(r: u32, ) -> Weight { - (128_067_000 as Weight) + (Weight::from_ref_time(128_067_000)) // Standard Error: 135_000 - .saturating_add((601_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes(6 as Weight)) + .saturating_add(Weight::from_ref_time(601_000).saturating_mul(r as u64)) + .saturating_add(RocksDbWeight::get().reads(5)) + .saturating_add(RocksDbWeight::get().writes(6)) } // Storage: NftManager Nfts (r:1 w:1) // Storage: NftManager NftOpenForSale (r:1 w:1) fn proxy_signed_list_nft_open_for_sale() -> Weight { - (115_453_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + (Weight::from_ref_time(115_453_000)) + .saturating_add(RocksDbWeight::get().reads(2)) + .saturating_add(RocksDbWeight::get().writes(2)) } // Storage: NftManager NftOpenForSale (r:1 w:1) // Storage: NftManager Nfts (r:1 w:1) // Storage: NftManager OwnedNfts (r:2 w:2) fn proxy_signed_transfer_fiat_nft() -> Weight { - (132_334_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(4 as Weight)) + (Weight::from_ref_time(132_334_000)) + .saturating_add(RocksDbWeight::get().reads(4)) + .saturating_add(RocksDbWeight::get().writes(4)) } // Storage: NftManager NftOpenForSale (r:1 w:1) // Storage: NftManager Nfts (r:1 w:1) fn proxy_signed_cancel_list_fiat_nft() -> Weight { - (122_423_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + (Weight::from_ref_time(122_423_000)) + .saturating_add(RocksDbWeight::get().reads(2)) + .saturating_add(RocksDbWeight::get().writes(2)) } // Storage: NftManager BatchNonces (r:1 w:1) // Storage: NftManager NextSingleNftUniqueId (r:1 w:1) @@ -308,11 +308,11 @@ impl WeightInfo for () { // Storage: NftManager NftInfos (r:0 w:1) /// The range of component `r` is `[1, 5]`. fn proxy_signed_create_batch(r: u32, ) -> Weight { - (122_325_000 as Weight) + (Weight::from_ref_time(122_325_000)) // Standard Error: 137_000 - .saturating_add((687_000 as Weight).saturating_mul(r as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(5 as Weight)) + .saturating_add(Weight::from_ref_time(687_000).saturating_mul(r as u64)) + .saturating_add(RocksDbWeight::get().reads(4)) + .saturating_add(RocksDbWeight::get().writes(5)) } // Storage: NftManager BatchInfoId (r:1 w:0) // Storage: NftManager BatchOpenForSale (r:1 w:0) @@ -322,9 +322,9 @@ impl WeightInfo for () { // Storage: NftManager Nfts (r:1 w:1) // Storage: NftManager OwnedNfts (r:1 w:1) fn proxy_signed_mint_batch_nft() -> Weight { - (152_674_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(7 as Weight)) - .saturating_add(RocksDbWeight::get().writes(4 as Weight)) + (Weight::from_ref_time(152_674_000)) + .saturating_add(RocksDbWeight::get().reads(7)) + .saturating_add(RocksDbWeight::get().writes(4)) } // Storage: NftManager BatchInfoId (r:1 w:0) // Storage: NftManager BatchNonces (r:1 w:1) @@ -332,17 +332,17 @@ impl WeightInfo for () { // Storage: NftManager NftBatches (r:1 w:0) // Storage: NftManager BatchOpenForSale (r:1 w:1) fn proxy_signed_list_batch_for_sale() -> Weight { - (129_444_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + (Weight::from_ref_time(129_444_000)) + .saturating_add(RocksDbWeight::get().reads(5)) + .saturating_add(RocksDbWeight::get().writes(2)) } // Storage: NftManager BatchInfoId (r:1 w:0) // Storage: NftManager BatchOpenForSale (r:1 w:1) // Storage: NftManager BatchNonces (r:1 w:1) // Storage: NftManager NftInfos (r:1 w:0) fn proxy_signed_end_batch_sale() -> Weight { - (131_444_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + (Weight::from_ref_time(131_444_000)) + .saturating_add(RocksDbWeight::get().reads(4)) + .saturating_add(RocksDbWeight::get().writes(2)) } } \ No newline at end of file diff --git a/pallets/nft-manager/src/lib.rs b/pallets/nft-manager/src/lib.rs index cc210df7a..cc1485ffd 100644 --- a/pallets/nft-manager/src/lib.rs +++ b/pallets/nft-manager/src/lib.rs @@ -23,10 +23,11 @@ use core::convert::TryInto; use frame_support::{ dispatch::{ DispatchErrorWithPostInfo, DispatchResult, DispatchResultWithPostInfo, Dispatchable, + PostDispatchInfo, }, ensure, log, traits::{Get, IsSubType}, - weights::{PostDispatchInfo, Weight}, + weights::Weight, Parameter, }; use frame_system::ensure_signed; @@ -87,12 +88,12 @@ pub mod pallet { // Public interface of this pallet #[pallet::config] pub trait Config: frame_system::Config + avn::Config { - type Event: From> - + Into<::Event> - + IsType<::Event>; + type RuntimeEvent: From> + + Into<::RuntimeEvent> + + IsType<::RuntimeEvent>; - type Call: Parameter - + Dispatchable::Origin> + type RuntimeCall: Parameter + + Dispatchable::RuntimeOrigin> + IsSubType> + From>; @@ -315,6 +316,7 @@ pub mod pallet { #[pallet::call] impl Pallet { /// Mint a single NFT + #[pallet::call_index(0)] #[pallet::weight(::WeightInfo::mint_single_nft(MAX_NUMBER_OF_ROYALTIES))] pub fn mint_single_nft( origin: OriginFor, @@ -351,6 +353,7 @@ pub mod pallet { } /// Mint a single NFT signed by nft owner + #[pallet::call_index(1)] #[pallet::weight(::WeightInfo::signed_mint_single_nft(MAX_NUMBER_OF_ROYALTIES))] pub fn signed_mint_single_nft( origin: OriginFor, @@ -400,6 +403,7 @@ pub mod pallet { } /// List an nft open for sale + #[pallet::call_index(2)] #[pallet::weight(::WeightInfo::list_nft_open_for_sale())] pub fn list_nft_open_for_sale( origin: OriginFor, @@ -414,6 +418,7 @@ pub mod pallet { } /// List an nft open for sale by a relayer + #[pallet::call_index(3)] #[pallet::weight(::WeightInfo::signed_list_nft_open_for_sale())] pub fn signed_list_nft_open_for_sale( origin: OriginFor, @@ -438,6 +443,7 @@ pub mod pallet { } /// Transfer a nft open for sale on fiat market to a new owner by a relayer + #[pallet::call_index(4)] #[pallet::weight(::WeightInfo::signed_transfer_fiat_nft())] pub fn signed_transfer_fiat_nft( origin: OriginFor, @@ -478,6 +484,7 @@ pub mod pallet { } /// Cancel a nft open for sale on fiat market by a relayer + #[pallet::call_index(5)] #[pallet::weight(::WeightInfo::signed_cancel_list_fiat_nft())] pub fn signed_cancel_list_fiat_nft( origin: OriginFor, @@ -512,13 +519,14 @@ pub mod pallet { /// /// As a general rule, every function that can be proxied should follow this convention: /// - its first argument (after origin) should be a public verification key and a signature + #[pallet::call_index(6)] #[pallet::weight(::WeightInfo::proxy_signed_list_nft_open_for_sale() .max(::WeightInfo::proxy_signed_mint_single_nft(MAX_NUMBER_OF_ROYALTIES)) .max(::WeightInfo::proxy_signed_transfer_fiat_nft()) .max(::WeightInfo::proxy_signed_cancel_list_fiat_nft()))] pub fn proxy( origin: OriginFor, - call: Box<::Call>, + call: Box<::RuntimeCall>, ) -> DispatchResultWithPostInfo { let relayer = ensure_signed(origin)?; @@ -536,6 +544,7 @@ pub mod pallet { } /// Creates a new batch + #[pallet::call_index(7)] #[pallet::weight(::WeightInfo::proxy_signed_create_batch(MAX_NUMBER_OF_ROYALTIES))] pub fn signed_create_batch( origin: OriginFor, @@ -594,6 +603,7 @@ pub mod pallet { } /// Mints an nft that belongs to a batch + #[pallet::call_index(8)] #[pallet::weight(::WeightInfo::proxy_signed_mint_batch_nft())] pub fn signed_mint_batch_nft( origin: OriginFor, @@ -630,6 +640,7 @@ pub mod pallet { Ok(()) } + #[pallet::call_index(9)] #[pallet::weight(::WeightInfo::proxy_signed_list_batch_for_sale())] pub fn signed_list_batch_for_sale( origin: OriginFor, @@ -674,6 +685,7 @@ pub mod pallet { Ok(()) } + #[pallet::call_index(10)] #[pallet::weight(::WeightInfo::proxy_signed_end_batch_sale())] pub fn signed_end_batch_sale( origin: OriginFor, @@ -719,7 +731,7 @@ pub mod pallet { return migrations::migrate_to_batch_nft::() } - return 0 + return Weight::from_ref_time(0) } } } @@ -973,7 +985,7 @@ impl Pallet { } fn get_dispatch_result_with_post_info( - call: Box<::Call>, + call: Box<::RuntimeCall>, ) -> DispatchResultWithPostInfo { match call.is_sub_type() { Some(call) => { @@ -1056,7 +1068,7 @@ impl Pallet { } fn get_encoded_call_param( - call: &::Call, + call: &::RuntimeCall, ) -> Option<(&Proof, Vec)> { let call = match call.is_sub_type() { Some(call) => call, @@ -1177,7 +1189,7 @@ impl CallDecoder for Pallet { type AccountId = T::AccountId; type Signature = ::Signature; type Error = Error; - type Call = ::Call; + type Call = ::RuntimeCall; fn get_proof( call: &Self::Call, @@ -1202,7 +1214,7 @@ impl CallDecoder for Pallet { } impl InnerCallValidator for Pallet { - type Call = ::Call; + type Call = ::RuntimeCall; fn signature_is_valid(call: &Box) -> bool { if let Some((proof, signed_payload)) = Self::get_encoded_call_param(call) { diff --git a/pallets/nft-manager/src/tests/batch_nft_tests.rs b/pallets/nft-manager/src/tests/batch_nft_tests.rs index bc909e9c4..d7eaf7599 100644 --- a/pallets/nft-manager/src/tests/batch_nft_tests.rs +++ b/pallets/nft-manager/src/tests/batch_nft_tests.rs @@ -17,14 +17,14 @@ #![cfg(test)] use super::*; use crate::{ - mock::{AccountId, Call as MockCall, *}, + mock::{AccountId, RuntimeCall as MockCall, *}, Call, }; use codec::Encode; use frame_support::{assert_noop, assert_ok, error::BadOrigin}; use frame_system::RawOrigin; use hex_literal::hex; -use mock::Event; +use mock::{RuntimeEvent as Event, RuntimeOrigin as Origin}; use sp_core::sr25519::Pair; fn build_proof( @@ -100,7 +100,10 @@ impl Default for CreateBatchContext { } impl CreateBatchContext { - fn create_signed_create_batch_call(&self, nonce: u64) -> Box<::Call> { + fn create_signed_create_batch_call( + &self, + nonce: u64, + ) -> Box<::RuntimeCall> { let proof = self.create_signed_create_batch_proof(nonce); return Box::new(MockCall::NftManager(super::Call::::signed_create_batch { @@ -519,7 +522,7 @@ impl MintBatchNftContext { &self, batch_id: U256, index: u64, - ) -> Box<::Call> { + ) -> Box<::RuntimeCall> { let proof = self.create_signed_mint_batch_nft_proof(batch_id, index); return Box::new(MockCall::NftManager(super::Call::::signed_mint_batch_nft { @@ -1129,7 +1132,7 @@ impl OpenForSaleContext { &self, batch_id: U256, nonce: u64, - ) -> Box<::Call> { + ) -> Box<::RuntimeCall> { let proof = self.create_signed_list_batch_for_sale_proof(batch_id, nonce); return Box::new(MockCall::NftManager( @@ -1565,7 +1568,7 @@ impl EndBatchSaleContext { &self, batch_id: U256, nonce: u64, - ) -> Box<::Call> { + ) -> Box<::RuntimeCall> { let proof = self.create_signed_end_batch_sale_proof(batch_id, nonce); return Box::new(MockCall::NftManager(super::Call::::signed_end_batch_sale { diff --git a/pallets/nft-manager/src/tests/cancel_single_nft_listing_tests.rs b/pallets/nft-manager/src/tests/cancel_single_nft_listing_tests.rs index 2fcfe6e5c..086096e78 100644 --- a/pallets/nft-manager/src/tests/cancel_single_nft_listing_tests.rs +++ b/pallets/nft-manager/src/tests/cancel_single_nft_listing_tests.rs @@ -15,10 +15,9 @@ // along with this program. If not, see . use super::*; -use crate::mock::{AccountId, *}; +use crate::mock::{AccountId, RuntimeEvent as Event, *}; use frame_support::{assert_noop, assert_ok}; use hex_literal::hex; -use mock::Event; use sp_avn_common::event_types::{EthEventId, ValidEvents}; use sp_core::H256; diff --git a/pallets/nft-manager/src/tests/mock.rs b/pallets/nft-manager/src/tests/mock.rs index c8c9207f7..b3eba4e42 100644 --- a/pallets/nft-manager/src/tests/mock.rs +++ b/pallets/nft-manager/src/tests/mock.rs @@ -36,7 +36,6 @@ pub type Signature = sr25519::Signature; pub type AccountId = ::Signer; pub type Hashing = ::Hashing; -//pub type SystemCall = frame_system::Call; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; @@ -54,8 +53,8 @@ frame_support::construct_runtime!( ); impl Config for TestRuntime { - type Event = mock::Event; - type Call = Call; + type RuntimeEvent = mock::RuntimeEvent; + type RuntimeCall = RuntimeCall; type ProcessedEventsChecker = Self; type Public = AccountId; type Signature = Signature; @@ -71,8 +70,8 @@ impl system::Config for TestRuntime { type BlockWeights = (); type BlockLength = (); type DbWeight = (); - type Origin = Origin; - type Call = Call; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; type Index = u64; type BlockNumber = u64; type Hash = H256; @@ -80,7 +79,7 @@ impl system::Config for TestRuntime { type AccountId = AccountId; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type Version = (); type PalletInfo = PalletInfo; diff --git a/pallets/nft-manager/src/tests/open_for_sale_tests.rs b/pallets/nft-manager/src/tests/open_for_sale_tests.rs index 8bea07532..70c607434 100644 --- a/pallets/nft-manager/src/tests/open_for_sale_tests.rs +++ b/pallets/nft-manager/src/tests/open_for_sale_tests.rs @@ -15,11 +15,10 @@ // along with this program. If not, see . use super::*; -use crate::mock::{AccountId, *}; +use crate::mock::{AccountId, RuntimeEvent as Event, RuntimeOrigin as Origin, *}; use frame_support::{assert_noop, assert_ok}; use frame_system::RawOrigin; use hex_literal::hex; -use mock::Event; use sp_runtime::traits::BadOrigin; mod open_for_sale { diff --git a/pallets/nft-manager/src/tests/proxy_signed_cancel_list_fiat_nft_tests.rs b/pallets/nft-manager/src/tests/proxy_signed_cancel_list_fiat_nft_tests.rs index ca560b566..8086a4600 100644 --- a/pallets/nft-manager/src/tests/proxy_signed_cancel_list_fiat_nft_tests.rs +++ b/pallets/nft-manager/src/tests/proxy_signed_cancel_list_fiat_nft_tests.rs @@ -17,7 +17,7 @@ #![cfg(test)] use super::*; use crate::{ - mock::{AccountId, Call as MockCall, Event, *}, + mock::{AccountId, RuntimeCall as MockCall, RuntimeEvent as Event, RuntimeOrigin as Origin, *}, Call, }; use codec::Encode; @@ -73,7 +73,7 @@ impl Context { ::NftOpenForSale::insert(&self.nft_id, NftSaleType::Fiat); } - fn create_signed_cancel_list_fiat_nft_call(&self) -> Box<::Call> { + fn create_signed_cancel_list_fiat_nft_call(&self) -> Box<::RuntimeCall> { let proof = self.create_signed_cancel_list_fiat_nft_proof(); return Box::new(MockCall::NftManager( @@ -102,7 +102,10 @@ impl Context { }) } - fn call_dispatched_event_emitted(&self, call: &Box<::Call>) -> bool { + fn call_dispatched_event_emitted( + &self, + call: &Box<::RuntimeCall>, + ) -> bool { let relayer = TestAccount::new([2u8; 32]); return System::events().iter().any(|a| { a.event == diff --git a/pallets/nft-manager/src/tests/proxy_signed_list_nft_open_for_sale_tests.rs b/pallets/nft-manager/src/tests/proxy_signed_list_nft_open_for_sale_tests.rs index 5453c90a2..074ea0331 100644 --- a/pallets/nft-manager/src/tests/proxy_signed_list_nft_open_for_sale_tests.rs +++ b/pallets/nft-manager/src/tests/proxy_signed_list_nft_open_for_sale_tests.rs @@ -17,14 +17,13 @@ #![cfg(test)] use super::*; use crate::{ - mock::{AccountId, Call as MockCall, *}, + mock::{AccountId, RuntimeCall as MockCall, RuntimeEvent as Event, RuntimeOrigin as Origin, *}, Call, }; use codec::Encode; use frame_support::{assert_err, assert_noop, assert_ok, error::BadOrigin}; use frame_system::RawOrigin; use hex_literal::hex; -use mock::Event; use sp_core::sr25519::Pair; const DEFAULT_NONCE: u64 = 0; @@ -76,7 +75,9 @@ impl Context { ::NftOpenForSale::remove(&self.nft_id); } - fn create_signed_list_nft_open_for_sale_call(&self) -> Box<::Call> { + fn create_signed_list_nft_open_for_sale_call( + &self, + ) -> Box<::RuntimeCall> { let proof = self.create_signed_list_nft_open_for_sale_proof(); return Box::new(MockCall::NftManager( @@ -109,7 +110,10 @@ impl Context { }) } - fn call_dispatched_event_emitted(&self, call: &Box<::Call>) -> bool { + fn call_dispatched_event_emitted( + &self, + call: &Box<::RuntimeCall>, + ) -> bool { let relayer = TestAccount::new([2u8; 32]); return System::events().iter().any(|a| { a.event == diff --git a/pallets/nft-manager/src/tests/proxy_signed_mint_single_nft_tests.rs b/pallets/nft-manager/src/tests/proxy_signed_mint_single_nft_tests.rs index 4650fa1e0..4ae1ddf50 100644 --- a/pallets/nft-manager/src/tests/proxy_signed_mint_single_nft_tests.rs +++ b/pallets/nft-manager/src/tests/proxy_signed_mint_single_nft_tests.rs @@ -17,14 +17,13 @@ #![cfg(test)] use super::*; use crate::{ - mock::{AccountId, Call as MockCall, *}, + mock::{AccountId, RuntimeCall as MockCall, RuntimeEvent as Event, RuntimeOrigin as Origin, *}, Call, }; use codec::Encode; use frame_support::{assert_err, assert_noop, assert_ok, error::BadOrigin}; use frame_system::RawOrigin; use hex_literal::hex; -use mock::Event; use sp_core::sr25519::Pair; fn build_proof( @@ -87,7 +86,7 @@ impl Context { >::remove(&self.unique_external_ref); } - fn create_signed_mint_single_nft_call(&self) -> Box<::Call> { + fn create_signed_mint_single_nft_call(&self) -> Box<::RuntimeCall> { let proof = self.create_signed_mint_single_nft_proof(); return Box::new(MockCall::NftManager(super::Call::::signed_mint_single_nft { @@ -120,7 +119,10 @@ impl Context { }) } - fn call_dispatched_event_emitted(&self, call: &Box<::Call>) -> bool { + fn call_dispatched_event_emitted( + &self, + call: &Box<::RuntimeCall>, + ) -> bool { let relayer = TestAccount::new([2u8; 32]); return System::events().iter().any(|a| { a.event == diff --git a/pallets/nft-manager/src/tests/proxy_signed_transfer_fiat_nft_tests.rs b/pallets/nft-manager/src/tests/proxy_signed_transfer_fiat_nft_tests.rs index a74f3d04d..5575fb4e6 100644 --- a/pallets/nft-manager/src/tests/proxy_signed_transfer_fiat_nft_tests.rs +++ b/pallets/nft-manager/src/tests/proxy_signed_transfer_fiat_nft_tests.rs @@ -17,13 +17,13 @@ #![cfg(test)] use super::*; use crate::{ - mock::{AccountId, Call as MockCall, *}, + mock::{AccountId, RuntimeCall as MockCall, RuntimeOrigin as Origin, *}, Call, }; use codec::Encode; use frame_support::{assert_noop, assert_ok, error::BadOrigin}; use frame_system::RawOrigin; -use mock::Event; +use mock::RuntimeEvent as Event; use sp_core::{sr25519::Pair, H256, U256}; fn build_proof( @@ -82,7 +82,7 @@ impl Context { ::NftOpenForSale::insert(&self.nft_id, NftSaleType::Fiat); } - fn create_signed_transfer_fiat_nft_call(&self) -> Box<::Call> { + fn create_signed_transfer_fiat_nft_call(&self) -> Box<::RuntimeCall> { let proof = self.create_signed_transfer_fiat_nft_proof(); return Box::new(MockCall::NftManager( @@ -118,7 +118,10 @@ impl Context { }) } - fn call_dispatched_event_emitted(&self, call: &Box<::Call>) -> bool { + fn call_dispatched_event_emitted( + &self, + call: &Box<::RuntimeCall>, + ) -> bool { let relayer = TestAccount::new([2u8; 32]); return System::events().iter().any(|a| { a.event == diff --git a/pallets/nft-manager/src/tests/single_mint_nft_tests.rs b/pallets/nft-manager/src/tests/single_mint_nft_tests.rs index 78fdeca33..eb19da86e 100644 --- a/pallets/nft-manager/src/tests/single_mint_nft_tests.rs +++ b/pallets/nft-manager/src/tests/single_mint_nft_tests.rs @@ -16,13 +16,12 @@ use super::*; use crate::{ - mock::{AccountId, *}, + mock::{AccountId, RuntimeEvent as Event, RuntimeOrigin as Origin, *}, nft_data::ROYALTY_RATE_DENOMINATOR, }; use frame_support::{assert_noop, assert_ok}; use frame_system::RawOrigin; use hex_literal::hex; -use mock::Event; use sp_runtime::traits::BadOrigin; mod mint_single_nft { diff --git a/pallets/nft-manager/src/tests/transfer_to_tests.rs b/pallets/nft-manager/src/tests/transfer_to_tests.rs index 9c5ae41b0..177388764 100644 --- a/pallets/nft-manager/src/tests/transfer_to_tests.rs +++ b/pallets/nft-manager/src/tests/transfer_to_tests.rs @@ -18,7 +18,7 @@ use super::*; use crate::mock::{AccountId, *}; use frame_support::{assert_noop, assert_ok}; use hex_literal::hex; -use mock::Event; +use mock::RuntimeEvent as Event; use sp_avn_common::event_types::{EthEventId, ValidEvents}; use sp_core::H256; diff --git a/pallets/parachain-staking/Cargo.toml b/pallets/parachain-staking/Cargo.toml index 51c28eda7..030f96cbe 100644 --- a/pallets/parachain-staking/Cargo.toml +++ b/pallets/parachain-staking/Cargo.toml @@ -10,34 +10,34 @@ log = "0.4" serde = { version = "1.0.101", optional = true } rand = { version = "0.7.2", default-features = false } # Substrate -frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27", optional = true, default-features = false } -frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27", default-features = false } -frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27", default-features = false } +frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", optional = true, default-features = false } +frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } +frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } parity-scale-codec = { version = "3.0.0", default-features = false, features = [ "derive" ] } scale-info = { version = "2.0", default-features = false, features = [ "derive" ] } -sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27", default-features = false } -sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27", default-features = false } -sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } +sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } +sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } sp-avn-common = { version = "0.12.0", default-features = false, path = "../../primitives/avn-common" } -sp-application-crypto = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.27" } +sp-application-crypto = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.36" } substrate-fixed = { git = "https://github.com/encointer/substrate-fixed", default-features = false } -pallet-authorship = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.27" } +pallet-authorship = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.36" } pallet-avn = { version = "0.12.0", default-features = false, path = "../avn" } -pallet-session = {features = ["historical"], git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27", default-features = false } +pallet-session = {features = ["historical"], git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } [dev-dependencies] similar-asserts = "1.1.0" -pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } +pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } pallet-avn-proxy = { version = "0.12.0", default-features = false, path = "../avn-proxy" } [features] default = [ "std" ] std = [ - "frame-benchmarking/std", + "frame-benchmarking?/std", "frame-support/std", "frame-system/std", "parity-scale-codec/std", diff --git a/pallets/parachain-staking/src/calls.rs b/pallets/parachain-staking/src/calls.rs index 2ce28b0af..703f9f74c 100644 --- a/pallets/parachain-staking/src/calls.rs +++ b/pallets/parachain-staking/src/calls.rs @@ -1,5 +1,5 @@ use crate::*; - +use frame_support::ensure; impl Pallet { pub fn call_nominate( nominator: &T::AccountId, diff --git a/pallets/parachain-staking/src/lib.rs b/pallets/parachain-staking/src/lib.rs index a80806479..7fae6b5f7 100644 --- a/pallets/parachain-staking/src/lib.rs +++ b/pallets/parachain-staking/src/lib.rs @@ -92,8 +92,6 @@ mod test_staking_pot; mod tests; use frame_support::pallet; -use pallet_avn::OnGrowthLiftedHandler; -use sp_runtime::DispatchResult; pub use weights::WeightInfo; pub use nomination_requests::{CancelledScheduledRequest, NominationAction, ScheduledRequest}; @@ -111,17 +109,18 @@ pub mod pallet { WeightInfo, }; pub use frame_support::{ + dispatch::{GetDispatchInfo, PostDispatchInfo}, pallet_prelude::*, traits::{ tokens::WithdrawReasons, Currency, ExistenceRequirement, Get, Imbalance, IsSubType, LockIdentifier, LockableCurrency, ReservableCurrency, ValidatorRegistration, }, - transactional, - weights::{GetDispatchInfo, PostDispatchInfo}, - PalletId, + transactional, PalletId, }; pub use frame_system::pallet_prelude::*; - pub use pallet_avn::{CollatorPayoutDustHandler, ProcessedEventsChecker}; + pub use pallet_avn::{ + CollatorPayoutDustHandler, OnGrowthLiftedHandler, ProcessedEventsChecker, + }; pub use sp_avn_common::Proof; pub use sp_runtime::{ traits::{ @@ -153,13 +152,13 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config + pallet_session::Config + pallet_avn::Config { /// The overarching call type. - type Call: Parameter - + Dispatchable + type RuntimeCall: Parameter + + Dispatchable + GetDispatchInfo + From> + IsSubType>; /// Overarching event type - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The currency type type Currency: Currency + ReservableCurrency @@ -185,7 +184,7 @@ pub mod pallet { /// Minimum stake, per collator, that must be maintained by an account that is nominating #[pallet::constant] type MinNominationPerCollator: Get>; - /// Number of eras to wait before we process a new growth period + /// Number of eras to MinNominationPerCollator before we process a new growth period type ErasPerGrowthPeriod: Get; /// Id of the account that will hold funds to be paid as staking reward type RewardPotId: Get; @@ -643,7 +642,7 @@ pub mod pallet { ); candidate_count = candidate_count.saturating_add(1u32); if let Err(error) = >::join_candidates( - T::Origin::from(Some(candidate.clone()).into()), + T::RuntimeOrigin::from(Some(candidate.clone()).into()), balance, candidate_count, ) { @@ -665,7 +664,7 @@ pub mod pallet { let dd_count = if let Some(x) = del_nomination_count.get(nominator) { *x } else { 0u32 }; if let Err(error) = >::nominate( - T::Origin::from(Some(nominator.clone()).into()), + T::RuntimeOrigin::from(Some(nominator.clone()).into()), target.clone(), balance, cd_count, @@ -733,6 +732,7 @@ pub mod pallet { #[pallet::weight(::WeightInfo::set_total_selected())] /// Set the total number of collator candidates selected per era /// - changes are not applied until the start of the next era + #[pallet::call_index(0)] pub fn set_total_selected(origin: OriginFor, new: u32) -> DispatchResultWithPostInfo { frame_system::ensure_root(origin)?; ensure!(new >= T::MinSelectedCandidates::get(), Error::::CannotSetBelowMin); @@ -751,6 +751,7 @@ pub mod pallet { /// Set blocks per era /// - if called with `new` less than length of current era, will transition immediately /// in the next block + #[pallet::call_index(1)] pub fn set_blocks_per_era(origin: OriginFor, new: u32) -> DispatchResultWithPostInfo { frame_system::ensure_root(origin)?; ensure!(new >= T::MinBlocksPerEra::get(), Error::::CannotSetBelowMin); @@ -775,6 +776,7 @@ pub mod pallet { #[pallet::weight(::WeightInfo::join_candidates(*candidate_count))] /// Join the set of collator candidates + #[pallet::call_index(2)] pub fn join_candidates( origin: OriginFor, bond: BalanceOf, @@ -825,6 +827,7 @@ pub mod pallet { #[pallet::weight(::WeightInfo::schedule_leave_candidates(*candidate_count))] /// Request to leave the set of candidates. If successful, the account is immediately /// removed from the candidate pool to prevent selection as a collator. + #[pallet::call_index(3)] pub fn schedule_leave_candidates( origin: OriginFor, candidate_count: u32, @@ -853,6 +856,7 @@ pub mod pallet { ::WeightInfo::execute_leave_candidates(*candidate_nomination_count) )] /// Execute leave candidates request + #[pallet::call_index(4)] pub fn execute_leave_candidates( origin: OriginFor, candidate: T::AccountId, @@ -932,6 +936,7 @@ pub mod pallet { /// Cancel open request to leave candidates /// - only callable by collator account /// - result upon successful call is the candidate is active in the candidate pool + #[pallet::call_index(5)] pub fn cancel_leave_candidates( origin: OriginFor, candidate_count: u32, @@ -957,6 +962,7 @@ pub mod pallet { #[pallet::weight(::WeightInfo::go_offline())] /// Temporarily leave the set of collator candidates without unbonding + #[pallet::call_index(6)] pub fn go_offline(origin: OriginFor) -> DispatchResultWithPostInfo { let collator = ensure_signed(origin)?; let mut state = >::get(&collator).ok_or(Error::::CandidateDNE)?; @@ -973,6 +979,7 @@ pub mod pallet { #[pallet::weight(::WeightInfo::go_online())] /// Rejoin the set of collator candidates if previously had called `go_offline` + #[pallet::call_index(7)] pub fn go_online(origin: OriginFor) -> DispatchResultWithPostInfo { let collator = ensure_signed(origin)?; let mut state = >::get(&collator).ok_or(Error::::CandidateDNE)?; @@ -992,6 +999,7 @@ pub mod pallet { #[pallet::weight(::WeightInfo::candidate_bond_extra())] /// Increase collator candidate self bond by `more` + #[pallet::call_index(8)] pub fn candidate_bond_extra( origin: OriginFor, more: BalanceOf, @@ -1003,6 +1011,7 @@ pub mod pallet { #[pallet::weight(::WeightInfo::signed_candidate_bond_extra())] #[transactional] /// Increase collator candidate self bond by `more` + #[pallet::call_index(9)] pub fn signed_candidate_bond_extra( origin: OriginFor, proof: Proof, @@ -1033,6 +1042,7 @@ pub mod pallet { #[pallet::weight(::WeightInfo::schedule_candidate_unbond())] /// Request by collator candidate to decrease self bond by `less` + #[pallet::call_index(10)] pub fn schedule_candidate_unbond( origin: OriginFor, less: BalanceOf, @@ -1043,6 +1053,7 @@ pub mod pallet { #[pallet::weight(::WeightInfo::execute_candidate_unbond())] /// Execute pending request to adjust the collator candidate self bond + #[pallet::call_index(11)] pub fn execute_candidate_unbond( origin: OriginFor, candidate: T::AccountId, @@ -1054,6 +1065,7 @@ pub mod pallet { #[pallet::weight(::WeightInfo::signed_execute_candidate_unbond())] #[transactional] /// Execute pending request to adjust the collator candidate self bond + #[pallet::call_index(12)] pub fn signed_execute_candidate_unbond( origin: OriginFor, proof: Proof, @@ -1084,6 +1096,7 @@ pub mod pallet { #[pallet::weight(::WeightInfo::cancel_candidate_unbond())] /// Cancel pending request to adjust the collator candidate self bond + #[pallet::call_index(13)] pub fn cancel_candidate_unbond(origin: OriginFor) -> DispatchResultWithPostInfo { let collator = ensure_signed(origin)?; let mut state = >::get(&collator).ok_or(Error::::CandidateDNE)?; @@ -1095,6 +1108,7 @@ pub mod pallet { #[pallet::weight(::WeightInfo::signed_schedule_candidate_unbond())] #[transactional] /// Signed request by collator candidate to decrease self bond by `less` + #[pallet::call_index(14)] pub fn signed_schedule_candidate_unbond( origin: OriginFor, proof: Proof, @@ -1131,6 +1145,7 @@ pub mod pallet { )] /// If caller is not a nominator and not a collator, then join the set of nominators /// If caller is a nominator, then makes nomination to change their nomination state + #[pallet::call_index(15)] pub fn nominate( origin: OriginFor, candidate: T::AccountId, @@ -1153,6 +1168,7 @@ pub mod pallet { T::MaxNominationsPerNominator::get(), T::MaxTopNominationsPerCandidate::get()) )] #[transactional] + #[pallet::call_index(16)] pub fn signed_nominate( origin: OriginFor, proof: Proof, @@ -1185,6 +1201,7 @@ pub mod pallet { /// allowed to exit via a [NominationAction::Revoke] towards all existing nominations. /// Success forbids future nomination requests until the request is invoked or cancelled. #[pallet::weight(::WeightInfo::schedule_leave_nominators())] + #[pallet::call_index(17)] pub fn schedule_leave_nominators(origin: OriginFor) -> DispatchResultWithPostInfo { let nominator = ensure_signed(origin)?; Self::nominator_schedule_revoke_all(nominator) @@ -1192,6 +1209,7 @@ pub mod pallet { #[pallet::weight(::WeightInfo::signed_schedule_leave_nominators())] #[transactional] + #[pallet::call_index(18)] pub fn signed_schedule_leave_nominators( origin: OriginFor, proof: Proof, @@ -1219,6 +1237,7 @@ pub mod pallet { /// Execute the right to exit the set of nominators and revoke all ongoing nominations. #[pallet::weight(::WeightInfo::execute_leave_nominators(*nomination_count))] + #[pallet::call_index(19)] pub fn execute_leave_nominators( origin: OriginFor, nominator: T::AccountId, @@ -1232,6 +1251,7 @@ pub mod pallet { /// Any account can call this extrinsic #[pallet::weight(::WeightInfo::signed_execute_leave_nominators(T::MaxNominationsPerNominator::get()))] #[transactional] + #[pallet::call_index(20)] pub fn signed_execute_leave_nominators( origin: OriginFor, proof: Proof, @@ -1269,6 +1289,7 @@ pub mod pallet { /// Cancel a pending request to exit the set of nominators. Success clears the pending exit /// request (thereby resetting the delay upon another `leave_nominators` call). #[pallet::weight(::WeightInfo::cancel_leave_nominators())] + #[pallet::call_index(21)] pub fn cancel_leave_nominators(origin: OriginFor) -> DispatchResultWithPostInfo { let nominator = ensure_signed(origin)?; Self::nominator_cancel_scheduled_revoke_all(nominator) @@ -1277,6 +1298,7 @@ pub mod pallet { #[pallet::weight(::WeightInfo::schedule_revoke_nomination())] /// Request to revoke an existing nomination. If successful, the nomination is scheduled /// to be allowed to be revoked via the `execute_nomination_request` extrinsic. + #[pallet::call_index(22)] pub fn schedule_revoke_nomination( origin: OriginFor, collator: T::AccountId, @@ -1290,6 +1312,7 @@ pub mod pallet { /// Signed request to revoke an existing nomination. If successful, the nomination is /// scheduled to be allowed to be revoked via the `execute_nomination_request` /// extrinsic. + #[pallet::call_index(23)] pub fn signed_schedule_revoke_nomination( origin: OriginFor, proof: Proof, @@ -1318,6 +1341,7 @@ pub mod pallet { #[pallet::weight(::WeightInfo::bond_extra())] /// Bond more for nominators wrt a specific collator candidate. + #[pallet::call_index(24)] pub fn bond_extra( origin: OriginFor, candidate: T::AccountId, @@ -1330,6 +1354,7 @@ pub mod pallet { /// Bond a maximum of 'extra_amount' amount. #[pallet::weight(::WeightInfo::signed_bond_extra())] #[transactional] + #[pallet::call_index(25)] pub fn signed_bond_extra( origin: OriginFor, proof: Proof, @@ -1389,6 +1414,7 @@ pub mod pallet { #[pallet::weight(::WeightInfo::schedule_nominator_unbond())] /// Request bond less for nominators wrt a specific collator candidate. + #[pallet::call_index(26)] pub fn schedule_nominator_unbond( origin: OriginFor, candidate: T::AccountId, @@ -1400,6 +1426,7 @@ pub mod pallet { #[pallet::weight(::WeightInfo::signed_schedule_nominator_unbond())] #[transactional] + #[pallet::call_index(27)] pub fn signed_schedule_nominator_unbond( origin: OriginFor, proof: Proof, @@ -1451,6 +1478,7 @@ pub mod pallet { #[pallet::weight(::WeightInfo::execute_nominator_unbond())] /// Execute pending request to change an existing nomination + #[pallet::call_index(28)] pub fn execute_nomination_request( origin: OriginFor, nominator: T::AccountId, @@ -1463,6 +1491,7 @@ pub mod pallet { #[pallet::weight(::WeightInfo::signed_execute_nominator_unbond())] #[transactional] /// Execute pending request to change an existing nomination + #[pallet::call_index(29)] pub fn signed_execute_nomination_request( origin: OriginFor, proof: Proof, @@ -1507,6 +1536,7 @@ pub mod pallet { #[pallet::weight(::WeightInfo::cancel_nominator_unbond())] /// Cancel request to change an existing nomination. + #[pallet::call_index(30)] pub fn cancel_nomination_request( origin: OriginFor, candidate: T::AccountId, @@ -1519,6 +1549,7 @@ pub mod pallet { #[pallet::weight( T::DbWeight::get().reads_writes(2 * candidates.len() as u64, candidates.len() as u64) )] + #[pallet::call_index(31)] pub fn hotfix_remove_nomination_requests_exited_candidates( origin: OriginFor, candidates: Vec, @@ -1545,6 +1576,7 @@ pub mod pallet { // TODO: Benchmark me #[pallet::weight(::WeightInfo::set_admin_setting())] + #[pallet::call_index(32)] pub fn set_admin_setting( origin: OriginFor, value: AdminSettings>, @@ -1730,7 +1762,7 @@ pub mod pallet { // don't underflow uint if now < delay { - return 0u64.into() + return Weight::from_ref_time(0u64).into() } let paid_for_era = now.saturating_sub(delay); @@ -1745,7 +1777,7 @@ pub mod pallet { } result.1 // weight consumed by pay_one_collator_reward } else { - 0u64.into() + Weight::from_ref_time(0u64).into() } } @@ -1767,7 +1799,7 @@ pub mod pallet { // 2. we called pay_one_collator_reward when we were actually done with deferred // payouts log::warn!("pay_one_collator_reward called with no > for the era!"); - return (None, 0u64.into()) + return (None, Weight::from_ref_time(0u64).into()) } let reward_pot_account_id = Self::compute_reward_pot_account_id(); @@ -1824,7 +1856,7 @@ pub mod pallet { } else { // Note that we don't clean up storage here; it is cleaned up in // handle_delayed_payouts() - (None, 0u64.into()) + (None, Weight::from_ref_time(0u64).into()) } } @@ -2273,10 +2305,9 @@ pub mod pallet { //TODO: can we ignore this? } } -} - -impl OnGrowthLiftedHandler> for Pallet { - fn on_growth_lifted(amount: BalanceOf, growth_period: u32) -> DispatchResult { - return Self::payout_collators(amount, growth_period) + impl OnGrowthLiftedHandler> for Pallet { + fn on_growth_lifted(amount: BalanceOf, growth_period: u32) -> DispatchResult { + return Self::payout_collators(amount, growth_period) + } } } diff --git a/pallets/parachain-staking/src/migration.rs b/pallets/parachain-staking/src/migration.rs index 2700e30e0..97b095833 100644 --- a/pallets/parachain-staking/src/migration.rs +++ b/pallets/parachain-staking/src/migration.rs @@ -16,7 +16,6 @@ use frame_support::{ traits::{Get, OnRuntimeUpgrade}, weights::Weight, }; -use sp_runtime::traits::Zero; pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); @@ -29,7 +28,7 @@ pub fn enable_staking() -> Weight { let initial_growth_period_index = 0u32; let current_block_number = frame_system::Pallet::::block_number(); - let mut consumed_weight: Weight = 0; + let mut consumed_weight: Weight = Weight::from_ref_time(0); let mut add_weight = |reads, writes, weight: Weight| { consumed_weight += T::DbWeight::get().reads_writes(reads, writes); consumed_weight += weight; @@ -63,12 +62,12 @@ pub fn enable_staking() -> Weight { let mut candidate_count = 0u32; //Reads: [validators] - add_weight(1, 0, 0); + add_weight(1, 0, Weight::from_ref_time(0)); // Initialize the candidates for validator in pallet_avn::Pallet::::validators() { //Reads: [get_collator_stakable_free_balance] - add_weight(1, 0, 0); + add_weight(1, 0, Weight::from_ref_time(0)); assert!( >::get_collator_stakable_free_balance(&validator.account_id) >= @@ -79,7 +78,7 @@ pub fn enable_staking() -> Weight { candidate_count = candidate_count.saturating_add(1u32); if let Err(error) = >::join_candidates( - T::Origin::from(Some(validator.account_id).into()), + T::RuntimeOrigin::from(Some(validator.account_id).into()), initial_min_collator_stake_balance, candidate_count, ) { @@ -96,12 +95,12 @@ pub fn enable_staking() -> Weight { assert!(initial_delay > 0, "Delay must be greater than 0."); //Write: [Delay] - add_weight(0, 1, 0); + add_weight(0, 1, Weight::from_ref_time(0)); >::put(initial_delay); // Set min staking values //Write: [MinCollatorStake, MinTotalNominatorStake, TotalSelected] - add_weight(0, 3, 0); + add_weight(0, 3, Weight::from_ref_time(0)); >::put(initial_min_collator_stake_balance); >::put(to_balance(initial_min_user_stake).expect("Asserted")); >::put(T::MinSelectedCandidates::get()); @@ -116,7 +115,7 @@ pub fn enable_staking() -> Weight { EraInfo::new(intial_era_index, current_block_number.into(), intial_blocks_per_era); //Write: [Era, Staked, Growth] - add_weight(0, 3, 0); + add_weight(0, 3, Weight::from_ref_time(0)); // Set the first era info. >::put(era); // Snapshot total stake @@ -132,13 +131,13 @@ pub fn enable_staking() -> Weight { }); //Write: [STORAGE_VERSION] - add_weight(0, 1, 0); + add_weight(0, 1, Weight::from_ref_time(0)); STORAGE_VERSION.put::>(); log::info!("✅ Migration completed successfully"); // add a bit extra as safety margin for computation - return consumed_weight + 25_000_000_000 + return consumed_weight + Weight::from_ref_time(25_000_000_000) } /// Migration to enable staking pallet diff --git a/pallets/parachain-staking/src/nomination_requests.rs b/pallets/parachain-staking/src/nomination_requests.rs index 13b1634c8..c30446ac0 100644 --- a/pallets/parachain-staking/src/nomination_requests.rs +++ b/pallets/parachain-staking/src/nomination_requests.rs @@ -17,11 +17,8 @@ //! Scheduled requests functionality for nominators use crate::{ - pallet::{ - BalanceOf, CandidateInfo, Config, Delay, Era, EraIndex, Error, Event, - MinTotalNominatorStake, NominationScheduledRequests, NominatorState, Pallet, Total, - }, - Nominator, + BalanceOf, CandidateInfo, Config, Delay, Era, EraIndex, Error, Event, MinTotalNominatorStake, + NominationScheduledRequests, Nominator, NominatorState, Pallet, Total, }; use frame_support::{dispatch::DispatchResultWithPostInfo, ensure, traits::Get, RuntimeDebug}; use parity_scale_codec::{Decode, Encode}; diff --git a/pallets/parachain-staking/src/proxy_methods.rs b/pallets/parachain-staking/src/proxy_methods.rs index 7d38e6788..d1a1ebda8 100644 --- a/pallets/parachain-staking/src/proxy_methods.rs +++ b/pallets/parachain-staking/src/proxy_methods.rs @@ -36,7 +36,7 @@ pub const SIGNED_EXECUTE_CANDIDATE_UNBOND_CONTEXT: &'static [u8] = b"parachain authorization for executing candidate unbond operation"; pub fn get_encoded_call_param( - call: &::Call, + call: &::RuntimeCall, ) -> Option<(&Proof, Vec)> { let call = match call.is_sub_type() { Some(call) => call, @@ -239,7 +239,7 @@ pub fn verify_signature( } impl InnerCallValidator for ParachainStaking { - type Call = ::Call; + type Call = ::RuntimeCall; fn signature_is_valid(call: &Box) -> bool { if let Some((proof, signed_payload)) = get_encoded_call_param::(call) { diff --git a/pallets/parachain-staking/src/session_handler.rs b/pallets/parachain-staking/src/session_handler.rs index 03b833c19..6a0dfb457 100644 --- a/pallets/parachain-staking/src/session_handler.rs +++ b/pallets/parachain-staking/src/session_handler.rs @@ -1,11 +1,11 @@ #![cfg_attr(not(feature = "std"), no_std)] -use super::Config; -use crate::{Era, ForceNewEra, Pallet as ParachainStaking}; +// use super::Config; +use crate::{Config, Era, ForceNewEra, Pallet as ParachainStaking}; use frame_support::{ + dispatch::DispatchClass, pallet_prelude::Weight, traits::{EstimateNextSessionRotation, Get}, - weights::DispatchClass, }; use pallet_session::{self as session, ShouldEndSession}; use sp_runtime::{traits::Saturating, Permill}; diff --git a/pallets/parachain-staking/src/tests/bond_extra_tests.rs b/pallets/parachain-staking/src/tests/bond_extra_tests.rs index 41dcd46ad..794781b12 100644 --- a/pallets/parachain-staking/src/tests/bond_extra_tests.rs +++ b/pallets/parachain-staking/src/tests/bond_extra_tests.rs @@ -6,9 +6,9 @@ use crate::{ assert_event_emitted, assert_last_event, encode_signed_bond_extra_params, encode_signed_candidate_bond_extra_params, mock::{ - build_proof, inner_call_failed_event_emitted, sign, AccountId, AvnProxy, Call as MockCall, - Event as MetaEvent, ExtBuilder, MinNominationPerCollator, Origin, ParachainStaking, - Signature, Staker, Test, TestAccount, + build_proof, inner_call_failed_event_emitted, sign, AccountId, AvnProxy, ExtBuilder, + MinNominationPerCollator, ParachainStaking, RuntimeCall as MockCall, + RuntimeEvent as MetaEvent, RuntimeOrigin as Origin, Signature, Staker, Test, TestAccount, }, Config, Error, Event, Proof, }; @@ -27,7 +27,7 @@ mod proxy_signed_bond_extra { staker: &Staker, sender_nonce: u64, extra_amount: u128, - ) -> Box<::Call> { + ) -> Box<::RuntimeCall> { let proof = create_proof_for_signed_bond_extra(sender_nonce, staker, &extra_amount); return Box::new(MockCall::ParachainStaking(super::super::Call::::signed_bond_extra { @@ -39,7 +39,7 @@ mod proxy_signed_bond_extra { fn create_call_for_bond_extra_from_proof( proof: Proof, extra_amount: u128, - ) -> Box<::Call> { + ) -> Box<::RuntimeCall> { return Box::new(MockCall::ParachainStaking(super::super::Call::::signed_bond_extra { proof, extra_amount, @@ -482,7 +482,7 @@ mod proxy_signed_candidate_bond_extra { staker: &Staker, sender_nonce: u64, extra_amount: u128, - ) -> Box<::Call> { + ) -> Box<::RuntimeCall> { let proof = create_proof_for_signed_candidate_bond_extra(sender_nonce, staker, &extra_amount); @@ -494,7 +494,7 @@ mod proxy_signed_candidate_bond_extra { fn create_call_for_candidate_bond_extra_from_proof( proof: Proof, extra_amount: u128, - ) -> Box<::Call> { + ) -> Box<::RuntimeCall> { return Box::new(MockCall::ParachainStaking( super::super::Call::::signed_candidate_bond_extra { proof, extra_amount }, )) diff --git a/pallets/parachain-staking/src/tests/mock.rs b/pallets/parachain-staking/src/tests/mock.rs index 6611824e8..bd4bb0b0c 100644 --- a/pallets/parachain-staking/src/tests/mock.rs +++ b/pallets/parachain-staking/src/tests/mock.rs @@ -20,12 +20,14 @@ use crate::{ pallet, AwardedPts, Config, Points, Proof, TypeInfo, COLLATOR_LOCK_ID, NOMINATOR_LOCK_ID, }; use frame_support::{ - assert_ok, construct_runtime, parameter_types, + assert_ok, construct_runtime, + dispatch::{DispatchClass, DispatchInfo, PostDispatchInfo}, + parameter_types, traits::{ ConstU8, Currency, Everything, FindAuthor, GenesisBuild, Imbalance, LockIdentifier, OnFinalize, OnInitialize, OnUnbalanced, ValidatorRegistration, }, - weights::{DispatchClass, DispatchInfo, PostDispatchInfo, Weight, WeightToFee as WeightToFeeT}, + weights::{Weight, WeightToFee as WeightToFeeT}, PalletId, }; use frame_system::limits; @@ -70,7 +72,7 @@ construct_runtime!( ); const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); -const MAX_BLOCK_WEIGHT: Weight = 1024; +const MAX_BLOCK_WEIGHT: Weight = Weight::from_ref_time(1024).set_proof_size(u64::MAX); pub static TX_LEN: usize = 1; pub const BASE_FEE: u64 = 12; @@ -107,16 +109,16 @@ pub fn sign(signer: &sr25519::Pair, message_to_sign: &[u8]) -> Signature { parameter_types! { pub const BlockHashCount: u64 = 250; - pub const MaximumBlockWeight: Weight = 1024; + pub const MaximumBlockWeight: Weight = Weight::from_ref_time(1024); pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); pub const SS58Prefix: u8 = 42; pub BlockLength: limits::BlockLength = limits::BlockLength::max_with_normal_ratio(1024, NORMAL_DISPATCH_RATIO); pub RuntimeBlockWeights: limits::BlockWeights = limits::BlockWeights::builder() - .base_block(10) + .base_block(Weight::from_ref_time(10)) .for_class(DispatchClass::all(), |weights| { - weights.base_extrinsic = BASE_FEE; + weights.base_extrinsic = Weight::from_ref_time(BASE_FEE); }) .for_class(DispatchClass::Normal, |weights| { weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAX_BLOCK_WEIGHT); @@ -133,16 +135,16 @@ parameter_types! { impl frame_system::Config for Test { type BaseCallFilter = Everything; type DbWeight = (); - type Origin = Origin; + type RuntimeOrigin = RuntimeOrigin; type Index = u64; type BlockNumber = BlockNumber; - type Call = Call; + type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = AccountId; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type Version = (); type PalletInfo = PalletInfo; @@ -164,7 +166,7 @@ impl pallet_balances::Config for Test { type ReserveIdentifier = [u8; 4]; type MaxLocks = (); type Balance = Balance; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; @@ -195,7 +197,7 @@ parameter_types! { pub const MaxTopNominationsPerCandidate: u32 = 4; pub const MaxBottomNominationsPerCandidate: u32 = 4; pub const MaxNominationsPerNominator: u32 = 10; - pub const MinNominationPerCollator: u128 = 3; + pub const MinNominationPerCollator: u128 = 1; pub const ErasPerGrowthPeriod: u32 = 2; pub const RewardPotId: PalletId = PalletId(*b"av/vamgr"); } @@ -208,8 +210,8 @@ impl ValidatorRegistration for IsRegistered { } impl Config for Test { - type Call = Call; - type Event = Event; + type RuntimeCall = RuntimeCall; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type RewardPaymentDelay = RewardPaymentDelay; type MinBlocksPerEra = MinBlocksPerEra; @@ -259,7 +261,7 @@ impl OnUnbalanced> for DealWithFees { } impl pallet_transaction_payment::Config for Test { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type OnChargeTransaction = CurrencyAdapter; type LengthToFee = TransactionByteFee; type WeightToFee = WeightToFee; @@ -271,7 +273,8 @@ impl WeightToFeeT for WeightToFee { type Balance = u128; fn weight_to_fee(weight: &Weight) -> Self::Balance { - Self::Balance::saturated_from(*weight).saturating_mul(WEIGHT_TO_FEE.with(|v| *v.borrow())) + Self::Balance::saturated_from(weight.ref_time()) + .saturating_mul(WEIGHT_TO_FEE.with(|v| *v.borrow())) } } @@ -279,7 +282,7 @@ impl WeightToFeeT for TransactionByteFee { type Balance = u128; fn weight_to_fee(weight: &Weight) -> Self::Balance { - Self::Balance::saturated_from(*weight) + Self::Balance::saturated_from(weight.ref_time()) .saturating_mul(TRANSACTION_BYTE_FEE.with(|v| *v.borrow())) } } @@ -297,7 +300,7 @@ impl session::Config for Test { type Keys = UintAuthorityId; type ShouldEndSession = ParachainStaking; type SessionHandler = (AVN,); - type Event = Event; + type RuntimeEvent = RuntimeEvent; type ValidatorId = AccountId; type ValidatorIdOf = ConvertInto; type NextSessionRotation = ParachainStaking; @@ -305,8 +308,8 @@ impl session::Config for Test { } impl avn_proxy::Config for Test { - type Event = Event; - type Call = Call; + type RuntimeEvent = RuntimeEvent; + type RuntimeCall = RuntimeCall; type Currency = Balances; type Public = AccountId; type Signature = Signature; @@ -324,10 +327,10 @@ impl Default for TestAvnProxyConfig { } } -impl ProvableProxy for TestAvnProxyConfig { - fn get_proof(call: &Call) -> Option> { +impl ProvableProxy for TestAvnProxyConfig { + fn get_proof(call: &RuntimeCall) -> Option> { match call { - Call::System(frame_system::Call::remark { remark: _msg }) => { + RuntimeCall::System(frame_system::Call::remark { remark: _msg }) => { let signer_account = TestAccount::new(985); return Some(Proof { signer: signer_account.account_id(), @@ -336,49 +339,49 @@ impl ProvableProxy for TestAvnProxyConfig { }) }, - Call::ParachainStaking(pallet_parachain_staking::Call::signed_nominate { + RuntimeCall::ParachainStaking(pallet_parachain_staking::Call::signed_nominate { proof, targets: _, amount: _, }) => return Some(proof.clone()), - Call::ParachainStaking(pallet_parachain_staking::Call::signed_bond_extra { + RuntimeCall::ParachainStaking(pallet_parachain_staking::Call::signed_bond_extra { proof, extra_amount: _, }) => return Some(proof.clone()), - Call::ParachainStaking( + RuntimeCall::ParachainStaking( pallet_parachain_staking::Call::signed_candidate_bond_extra { proof, extra_amount: _, }, ) => return Some(proof.clone()), - Call::ParachainStaking( + RuntimeCall::ParachainStaking( pallet_parachain_staking::Call::signed_schedule_candidate_unbond { proof, less: _ }, ) => return Some(proof.clone()), - Call::ParachainStaking( + RuntimeCall::ParachainStaking( pallet_parachain_staking::Call::signed_schedule_nominator_unbond { proof, less: _ }, ) => return Some(proof.clone()), - Call::ParachainStaking( + RuntimeCall::ParachainStaking( pallet_parachain_staking::Call::signed_schedule_revoke_nomination { proof, collator: _, }, ) => return Some(proof.clone()), - Call::ParachainStaking( + RuntimeCall::ParachainStaking( pallet_parachain_staking::Call::signed_schedule_leave_nominators { proof }, ) => return Some(proof.clone()), - Call::ParachainStaking( + RuntimeCall::ParachainStaking( pallet_parachain_staking::Call::signed_execute_leave_nominators { proof, nominator: _, }, ) => return Some(proof.clone()), - Call::ParachainStaking( + RuntimeCall::ParachainStaking( pallet_parachain_staking::Call::signed_execute_nomination_request { proof, nominator: _, }, ) => return Some(proof.clone()), - Call::ParachainStaking( + RuntimeCall::ParachainStaking( pallet_parachain_staking::Call::signed_execute_candidate_unbond { proof, candidate: _, @@ -391,12 +394,12 @@ impl ProvableProxy for TestAvnProxyConfig { } impl InnerCallValidator for TestAvnProxyConfig { - type Call = Call; + type Call = RuntimeCall; fn signature_is_valid(call: &Box) -> bool { match **call { - Call::System(..) => return true, - Call::ParachainStaking(..) => return ParachainStaking::signature_is_valid(call), + RuntimeCall::System(..) => return true, + RuntimeCall::ParachainStaking(..) => return ParachainStaking::signature_is_valid(call), _ => false, } } @@ -404,7 +407,10 @@ impl InnerCallValidator for TestAvnProxyConfig { pub fn inner_call_failed_event_emitted(call_dispatch_error: DispatchError) -> bool { return System::events().iter().any(|a| match a.event { - Event::AvnProxy(avn_proxy::Event::::InnerCallFailed { dispatch_error, .. }) => + RuntimeEvent::AvnProxy(avn_proxy::Event::::InnerCallFailed { + dispatch_error, + .. + }) => if dispatch_error == call_dispatch_error { return true } else { @@ -565,7 +571,7 @@ pub(crate) fn roll_to_era_end(era: u64) -> u64 { roll_to(block) } -pub(crate) fn last_event() -> Event { +pub(crate) fn last_event() -> RuntimeEvent { System::events().pop().expect("Event expected").event } @@ -578,7 +584,9 @@ pub(crate) fn events() -> Vec> { System::events() .into_iter() .map(|r| r.event) - .filter_map(|e| if let Event::ParachainStaking(inner) = e { Some(inner) } else { None }) + .filter_map( + |e| if let RuntimeEvent::ParachainStaking(inner) = e { Some(inner) } else { None }, + ) .collect::>() } @@ -713,15 +721,15 @@ pub(crate) fn pay_gas_for_transaction(sender: &AccountId, tip: u128) { let pre = ChargeTransactionPayment::::from(tip) .pre_dispatch( sender, - &Call::System(frame_system::Call::remark { remark: vec![] }), - &DispatchInfo { weight: 1, ..Default::default() }, + &RuntimeCall::System(frame_system::Call::remark { remark: vec![] }), + &DispatchInfo { weight: Weight::from_ref_time(1), ..Default::default() }, TX_LEN, ) .unwrap(); assert_ok!(ChargeTransactionPayment::::post_dispatch( Some(pre), - &DispatchInfo { weight: 1, ..Default::default() }, + &DispatchInfo { weight: Weight::from_ref_time(1), ..Default::default() }, &PostDispatchInfo { actual_weight: None, pays_fee: Default::default() }, TX_LEN, &Ok(()) diff --git a/pallets/parachain-staking/src/tests/nominate_tests.rs b/pallets/parachain-staking/src/tests/nominate_tests.rs index 0bfb824ab..c8eed3aef 100644 --- a/pallets/parachain-staking/src/tests/nominate_tests.rs +++ b/pallets/parachain-staking/src/tests/nominate_tests.rs @@ -5,9 +5,9 @@ use crate::{ assert_event_emitted, assert_last_event, encode_signed_nominate_params, mock::{ - build_proof, inner_call_failed_event_emitted, sign, AccountId, AvnProxy, Call as MockCall, - Event as MetaEvent, ExtBuilder, Origin, ParachainStaking, Signature, Staker, Test, - TestAccount, + build_proof, inner_call_failed_event_emitted, sign, AccountId, AvnProxy, ExtBuilder, + ParachainStaking, RuntimeCall as MockCall, RuntimeEvent as MetaEvent, + RuntimeOrigin as Origin, Signature, Staker, Test, TestAccount, }, Config, Error, Event, NominatorAdded, Proof, StaticLookup, }; @@ -27,7 +27,7 @@ mod proxy_signed_nominate { sender_nonce: u64, targets: Vec<<::Lookup as StaticLookup>::Source>, amount: u128, - ) -> Box<::Call> { + ) -> Box<::RuntimeCall> { let proof = create_proof_for_signed_nominate(sender_nonce, staker, &targets, &amount); return Box::new(MockCall::ParachainStaking(super::super::Call::::signed_nominate { @@ -41,7 +41,7 @@ mod proxy_signed_nominate { proof: Proof, targets: Vec<<::Lookup as StaticLookup>::Source>, amount: u128, - ) -> Box<::Call> { + ) -> Box<::RuntimeCall> { return Box::new(MockCall::ParachainStaking(super::super::Call::::signed_nominate { proof, targets, diff --git a/pallets/parachain-staking/src/tests/schedule_revoke_nomination_tests.rs b/pallets/parachain-staking/src/tests/schedule_revoke_nomination_tests.rs index 9e2e3557e..5cc1ab46d 100644 --- a/pallets/parachain-staking/src/tests/schedule_revoke_nomination_tests.rs +++ b/pallets/parachain-staking/src/tests/schedule_revoke_nomination_tests.rs @@ -8,8 +8,8 @@ use crate::{ encode_signed_schedule_revoke_nomination_params, mock::{ build_proof, inner_call_failed_event_emitted, roll_to, roll_to_era_begin, sign, AccountId, - AvnProxy, Balances, Call as MockCall, Event as MetaEvent, ExtBuilder, Origin, - ParachainStaking, Signature, Staker, Test, TestAccount, + AvnProxy, Balances, ExtBuilder, ParachainStaking, RuntimeCall as MockCall, + RuntimeEvent as MetaEvent, RuntimeOrigin, Signature, Staker, Test, TestAccount, }, Config, Error, Event, Proof, }; @@ -33,7 +33,7 @@ mod proxy_signed_schedule_revoke_nomination { staker: &Staker, sender_nonce: u64, collator: &AccountId, - ) -> Box<::Call> { + ) -> Box<::RuntimeCall> { let proof = create_proof_for_signed_schedule_revoke_nomination(sender_nonce, staker, &collator); @@ -85,7 +85,7 @@ mod proxy_signed_schedule_revoke_nomination { create_call_for_signed_schedule_revoke_nomination(&staker, nonce, &collator_1); assert_ok!(AvnProxy::proxy( - Origin::signed(staker.relayer), + RuntimeOrigin::signed(staker.relayer), revoke_nomination_call, None )); @@ -142,7 +142,7 @@ mod proxy_signed_schedule_revoke_nomination { // Show that we can send a successful transaction if its signed. assert_ok!(ParachainStaking::signed_schedule_revoke_nomination( - Origin::signed(staker.account_id), + RuntimeOrigin::signed(staker.account_id), proof, collator_1 )); @@ -177,7 +177,7 @@ mod proxy_signed_schedule_revoke_nomination { assert_noop!( ParachainStaking::signed_schedule_revoke_nomination( - Origin::signed(staker.account_id), + RuntimeOrigin::signed(staker.account_id), proof.clone(), collator_1 ), @@ -215,7 +215,7 @@ mod proxy_signed_schedule_revoke_nomination { ); assert_noop!( ParachainStaking::signed_schedule_revoke_nomination( - Origin::signed(staker.account_id), + RuntimeOrigin::signed(staker.account_id), proof.clone(), bad_collator ), @@ -251,7 +251,7 @@ mod proxy_signed_schedule_revoke_nomination { ); assert_noop!( ParachainStaking::signed_schedule_revoke_nomination( - Origin::signed(staker.account_id), + RuntimeOrigin::signed(staker.account_id), proof.clone(), collator_2 ), @@ -268,7 +268,7 @@ mod proxy_signed_schedule_leave_nominators { pub fn create_call_for_signed_schedule_leave_nominators( staker: &Staker, sender_nonce: u64, - ) -> Box<::Call> { + ) -> Box<::RuntimeCall> { let proof = create_proof_for_signed_schedule_leave_nominators(sender_nonce, staker); return Box::new(MockCall::ParachainStaking( @@ -314,7 +314,7 @@ mod proxy_signed_schedule_leave_nominators { create_call_for_signed_schedule_leave_nominators(&staker, nonce); assert_ok!(AvnProxy::proxy( - Origin::signed(staker.relayer), + RuntimeOrigin::signed(staker.relayer), leave_nominators_call, None )); @@ -365,7 +365,7 @@ mod proxy_signed_schedule_leave_nominators { // Show that we can send a successful transaction if its signed. assert_ok!(ParachainStaking::signed_schedule_leave_nominators( - Origin::signed(staker.account_id), + RuntimeOrigin::signed(staker.account_id), proof, )); }); @@ -395,7 +395,7 @@ mod proxy_signed_schedule_leave_nominators { create_call_for_signed_schedule_leave_nominators(&staker, bad_nonce); assert_ok!(AvnProxy::proxy( - Origin::signed(staker.relayer), + RuntimeOrigin::signed(staker.relayer), leave_nominators_call, None )); @@ -421,7 +421,11 @@ mod proxy_signed_execute_revoke_all_nomination { let leave_nominators_call = create_call_for_signed_schedule_leave_nominators(&staker, nonce); - assert_ok!(AvnProxy::proxy(Origin::signed(staker.relayer), leave_nominators_call, None)); + assert_ok!(AvnProxy::proxy( + RuntimeOrigin::signed(staker.relayer), + leave_nominators_call, + None + )); return ParachainStaking::proxy_nonce(staker.account_id) } @@ -430,7 +434,7 @@ mod proxy_signed_execute_revoke_all_nomination { staker: &Staker, sender_nonce: u64, nominator: &AccountId, - ) -> Box<::Call> { + ) -> Box<::RuntimeCall> { let proof = create_proof_for_signed_execute_leave_nominators(sender_nonce, staker, nominator); @@ -445,7 +449,7 @@ mod proxy_signed_execute_revoke_all_nomination { fn create_call_for_signed_execute_leave_nominators_from_proof( proof: Proof, nominator: &AccountId, - ) -> Box<::Call> { + ) -> Box<::RuntimeCall> { return Box::new(MockCall::ParachainStaking( super::super::Call::::signed_execute_leave_nominators { proof, @@ -505,7 +509,7 @@ mod proxy_signed_execute_revoke_all_nomination { ); assert_ok!(AvnProxy::proxy( - Origin::signed(random_user.relayer), + RuntimeOrigin::signed(random_user.relayer), execute_leave_nomination_call, None )); @@ -570,7 +574,7 @@ mod proxy_signed_execute_revoke_all_nomination { // Show that we can send a successful transaction if its signed. assert_ok!(ParachainStaking::signed_execute_leave_nominators( - Origin::signed(staker.account_id), + RuntimeOrigin::signed(staker.account_id), proof, staker.account_id )); @@ -610,7 +614,7 @@ mod proxy_signed_execute_revoke_all_nomination { ); assert_ok!(AvnProxy::proxy( - Origin::signed(staker.relayer), + RuntimeOrigin::signed(staker.relayer), execute_leave_nominators_call, None )); @@ -665,7 +669,7 @@ mod proxy_signed_execute_revoke_all_nomination { ); assert_ok!(AvnProxy::proxy( - Origin::signed(staker.relayer), + RuntimeOrigin::signed(staker.relayer), execute_leave_nominators_call, None )); @@ -716,7 +720,7 @@ mod proxy_signed_execute_revoke_all_nomination { ); assert_ok!(AvnProxy::proxy( - Origin::signed(staker.relayer), + RuntimeOrigin::signed(staker.relayer), execute_leave_nominators_call, None )); @@ -746,7 +750,7 @@ fn revoke_nomination_event_emits_correctly() { .build() .execute_with(|| { assert_ok!(ParachainStaking::schedule_revoke_nomination( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id )); assert_last_event!(MetaEvent::ParachainStaking(Event::NominationRevocationScheduled { @@ -757,7 +761,7 @@ fn revoke_nomination_event_emits_correctly() { })); roll_to(10); assert_ok!(ParachainStaking::execute_nomination_request( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id_2, account_id )); @@ -782,12 +786,12 @@ fn can_revoke_nomination_if_revoking_another_nomination() { .build() .execute_with(|| { assert_ok!(ParachainStaking::schedule_revoke_nomination( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id )); // this is an exit implicitly because last nomination revoked assert_ok!(ParachainStaking::schedule_revoke_nomination( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id_3 )); }); @@ -804,10 +808,12 @@ fn nominator_not_allowed_revoke_if_already_leaving() { .with_nominations(vec![(account_id_2, account_id, 10), (account_id_2, account_id_3, 10)]) .build() .execute_with(|| { - assert_ok!(ParachainStaking::schedule_leave_nominators(Origin::signed(account_id_2))); + assert_ok!(ParachainStaking::schedule_leave_nominators(RuntimeOrigin::signed( + account_id_2 + ))); assert_noop!( ParachainStaking::schedule_revoke_nomination( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id_3 ), >::PendingNominationRequestAlreadyExists, @@ -821,7 +827,10 @@ fn cannot_revoke_nomination_if_not_nominator() { let account_id_2 = to_acc_id(2u64); ExtBuilder::default().build().execute_with(|| { assert_noop!( - ParachainStaking::schedule_revoke_nomination(Origin::signed(account_id_2), account_id), + ParachainStaking::schedule_revoke_nomination( + RuntimeOrigin::signed(account_id_2), + account_id + ), Error::::NominatorDNE ); }); @@ -839,7 +848,7 @@ fn cannot_revoke_nomination_that_dne() { .execute_with(|| { assert_noop!( ParachainStaking::schedule_revoke_nomination( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), to_acc_id(3) ), Error::::NominationDNE @@ -860,7 +869,7 @@ fn can_schedule_revoke_nomination_below_min_nominator_stake() { .build() .execute_with(|| { assert_ok!(ParachainStaking::schedule_revoke_nomination( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id )); }); @@ -880,12 +889,12 @@ fn execute_revoke_nomination_emits_exit_event_if_exit_happens() { .build() .execute_with(|| { assert_ok!(ParachainStaking::schedule_revoke_nomination( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id )); roll_to(10); assert_ok!(ParachainStaking::execute_nomination_request( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id_2, account_id )); @@ -913,13 +922,13 @@ fn cannot_execute_revoke_nomination_below_min_nominator_stake() { .build() .execute_with(|| { assert_ok!(ParachainStaking::schedule_revoke_nomination( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id )); roll_to(10); assert_noop!( ParachainStaking::execute_nomination_request( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id_2, account_id ), @@ -927,13 +936,15 @@ fn cannot_execute_revoke_nomination_below_min_nominator_stake() { ); // but nominator can cancel the request and request to leave instead: assert_ok!(ParachainStaking::cancel_nomination_request( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id )); - assert_ok!(ParachainStaking::schedule_leave_nominators(Origin::signed(account_id_2))); + assert_ok!(ParachainStaking::schedule_leave_nominators(RuntimeOrigin::signed( + account_id_2 + ))); roll_to(20); assert_ok!(ParachainStaking::execute_leave_nominators( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id_2, 2 )); @@ -952,12 +963,12 @@ fn revoke_nomination_executes_exit_if_last_nomination() { .build() .execute_with(|| { assert_ok!(ParachainStaking::schedule_revoke_nomination( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id )); roll_to(10); assert_ok!(ParachainStaking::execute_nomination_request( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id_2, account_id )); @@ -985,12 +996,12 @@ fn execute_revoke_nomination_emits_correct_event() { .build() .execute_with(|| { assert_ok!(ParachainStaking::schedule_revoke_nomination( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id )); roll_to(10); assert_ok!(ParachainStaking::execute_nomination_request( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id_2, account_id )); @@ -1015,12 +1026,12 @@ fn execute_revoke_nomination_unreserves_balance() { .execute_with(|| { assert_eq!(ParachainStaking::get_nominator_stakable_free_balance(&account_id_2), 0); assert_ok!(ParachainStaking::schedule_revoke_nomination( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id )); roll_to(10); assert_ok!(ParachainStaking::execute_nomination_request( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id_2, account_id )); @@ -1042,7 +1053,7 @@ fn execute_revoke_nomination_adds_revocation_to_nominator_state() { .iter() .any(|x| x.nominator == account_id_2)); assert_ok!(ParachainStaking::schedule_revoke_nomination( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id )); assert!(ParachainStaking::nomination_scheduled_requests(&account_id) @@ -1062,12 +1073,12 @@ fn execute_revoke_nomination_removes_revocation_from_nominator_state_upon_execut .build() .execute_with(|| { assert_ok!(ParachainStaking::schedule_revoke_nomination( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id )); roll_to(10); assert_ok!(ParachainStaking::execute_nomination_request( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id_2, account_id )); @@ -1088,12 +1099,12 @@ fn execute_revoke_nomination_removes_revocation_from_state_for_single_nomination .build() .execute_with(|| { assert_ok!(ParachainStaking::schedule_revoke_nomination( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id )); roll_to(10); assert_ok!(ParachainStaking::execute_nomination_request( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id_2, account_id )); @@ -1118,12 +1129,12 @@ fn execute_revoke_nomination_decreases_total_staked() { .execute_with(|| { assert_eq!(ParachainStaking::total(), 40); assert_ok!(ParachainStaking::schedule_revoke_nomination( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id )); roll_to(10); assert_ok!(ParachainStaking::execute_nomination_request( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id_2, account_id )); @@ -1143,14 +1154,14 @@ fn execute_revoke_nomination_for_last_nomination_removes_nominator_state() { .execute_with(|| { assert!(ParachainStaking::nominator_state(account_id_2).is_some()); assert_ok!(ParachainStaking::schedule_revoke_nomination( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id )); roll_to(10); // this will be confusing for people // if status is leaving, then execute_nomination_request works if last nomination assert_ok!(ParachainStaking::execute_nomination_request( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id_2, account_id )); @@ -1173,12 +1184,12 @@ fn execute_revoke_nomination_removes_nomination_from_candidate_state() { 1u32 ); assert_ok!(ParachainStaking::schedule_revoke_nomination( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id )); roll_to(10); assert_ok!(ParachainStaking::execute_nomination_request( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id_2, account_id )); @@ -1199,15 +1210,18 @@ fn can_execute_revoke_nomination_for_leaving_candidate() { .with_nominations(vec![(account_id_2, account_id, 10)]) .build() .execute_with(|| { - assert_ok!(ParachainStaking::schedule_leave_candidates(Origin::signed(account_id), 1)); + assert_ok!(ParachainStaking::schedule_leave_candidates( + RuntimeOrigin::signed(account_id), + 1 + )); assert_ok!(ParachainStaking::schedule_revoke_nomination( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id )); roll_to(10); // can execute nomination request for leaving candidate assert_ok!(ParachainStaking::execute_nomination_request( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id_2, account_id )); @@ -1224,15 +1238,18 @@ fn can_execute_leave_candidates_if_revoking_candidate() { .with_nominations(vec![(account_id_2, account_id, 10)]) .build() .execute_with(|| { - assert_ok!(ParachainStaking::schedule_leave_candidates(Origin::signed(account_id), 1)); + assert_ok!(ParachainStaking::schedule_leave_candidates( + RuntimeOrigin::signed(account_id), + 1 + )); assert_ok!(ParachainStaking::schedule_revoke_nomination( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id )); roll_to(10); // revocation executes during execute leave candidates (callable by anyone) assert_ok!(ParachainStaking::execute_leave_candidates( - Origin::signed(account_id), + RuntimeOrigin::signed(account_id), account_id, 1 )); @@ -1254,17 +1271,17 @@ fn nominator_bond_extra_after_revoke_nomination_does_not_effect_exit() { .build() .execute_with(|| { assert_ok!(ParachainStaking::schedule_revoke_nomination( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id )); assert_ok!(ParachainStaking::bond_extra( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id_3, 10 )); roll_to(100); assert_ok!(ParachainStaking::execute_nomination_request( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id_2, account_id )); @@ -1285,7 +1302,7 @@ fn nominator_unbond_after_revoke_nomination_does_not_effect_exit() { .build() .execute_with(|| { assert_ok!(ParachainStaking::schedule_revoke_nomination( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id )); assert_last_event!(MetaEvent::ParachainStaking(Event::NominationRevocationScheduled { @@ -1296,25 +1313,25 @@ fn nominator_unbond_after_revoke_nomination_does_not_effect_exit() { })); assert_noop!( ParachainStaking::schedule_nominator_unbond( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id, 2 ), Error::::PendingNominationRequestAlreadyExists ); assert_ok!(ParachainStaking::schedule_nominator_unbond( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id_3, 2 )); roll_to(10); assert_ok!(ParachainStaking::execute_nomination_request( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id_2, account_id )); assert_ok!(ParachainStaking::execute_nomination_request( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id_2, account_id_3 )); diff --git a/pallets/parachain-staking/src/tests/schedule_unbond_tests.rs b/pallets/parachain-staking/src/tests/schedule_unbond_tests.rs index 93bc68392..a9eed7e70 100644 --- a/pallets/parachain-staking/src/tests/schedule_unbond_tests.rs +++ b/pallets/parachain-staking/src/tests/schedule_unbond_tests.rs @@ -8,8 +8,8 @@ use crate::{ encode_signed_schedule_candidate_unbond_params, encode_signed_schedule_nominator_unbond_params, mock::{ build_proof, inner_call_failed_event_emitted, roll_to, roll_to_era_begin, sign, AccountId, - AvnProxy, Call as MockCall, Event as MetaEvent, ExtBuilder, MinNominationPerCollator, - Origin, ParachainStaking, Signature, Staker, System, Test, TestAccount, + AvnProxy, ExtBuilder, MinNominationPerCollator, ParachainStaking, RuntimeCall as MockCall, + RuntimeEvent as MetaEvent, RuntimeOrigin, Signature, Staker, System, Test, TestAccount, }, Bond, Config, Error, Event, NominationAction, Proof, ScheduledRequest, }; @@ -73,7 +73,7 @@ mod proxy_signed_schedule_nominator_unbond { staker: &Staker, sender_nonce: u64, reduction_amount: u128, - ) -> Box<::Call> { + ) -> Box<::RuntimeCall> { let proof = create_proof_for_signed_schedule_nominator_unbond( sender_nonce, staker, @@ -91,7 +91,7 @@ mod proxy_signed_schedule_nominator_unbond { pub fn create_call_for_signed_schedule_nominator_unbond_proof( proof: Proof, reduction_amount: u128, - ) -> Box<::Call> { + ) -> Box<::RuntimeCall> { return Box::new(MockCall::ParachainStaking( super::super::Call::::signed_schedule_nominator_unbond { proof, @@ -120,7 +120,7 @@ mod proxy_signed_schedule_nominator_unbond { .into_iter() .map(|r| r.event) .filter_map(|e| { - if let crate::mock::Event::ParachainStaking(inner) = e { + if let crate::mock::RuntimeEvent::ParachainStaking(inner) = e { Some(inner) } else { None @@ -189,7 +189,11 @@ mod proxy_signed_schedule_nominator_unbond { nonce, AMOUNT_TO_UNBOND.with(|v| *v.borrow()), ); - assert_ok!(AvnProxy::proxy(Origin::signed(staker.relayer), unbond_call, None)); + assert_ok!(AvnProxy::proxy( + RuntimeOrigin::signed(staker.relayer), + unbond_call, + None + )); assert!(unbond_event_emitted(Staker::default().account_id)); @@ -239,7 +243,7 @@ mod proxy_signed_schedule_nominator_unbond { // Show that we can send a successful transaction if it's signed. assert_ok!(ParachainStaking::signed_schedule_nominator_unbond( - Origin::signed(staker.account_id), + RuntimeOrigin::signed(staker.account_id), proof, amount_to_withdraw )); @@ -273,7 +277,11 @@ mod proxy_signed_schedule_nominator_unbond { amount_to_withdraw, ); - assert_ok!(AvnProxy::proxy(Origin::signed(staker.relayer), unbond_call, None)); + assert_ok!(AvnProxy::proxy( + RuntimeOrigin::signed(staker.relayer), + unbond_call, + None + )); assert_eq!( true, inner_call_failed_event_emitted( @@ -316,7 +324,11 @@ mod proxy_signed_schedule_nominator_unbond { proof, bad_amount_to_withdraw, ); - assert_ok!(AvnProxy::proxy(Origin::signed(staker.relayer), unbond_call, None)); + assert_ok!(AvnProxy::proxy( + RuntimeOrigin::signed(staker.relayer), + unbond_call, + None + )); assert_eq!( true, inner_call_failed_event_emitted( @@ -359,7 +371,11 @@ mod proxy_signed_schedule_nominator_unbond { bad_amount_to_unbond, ); - assert_ok!(AvnProxy::proxy(Origin::signed(staker.relayer), unbond_call, None)); + assert_ok!(AvnProxy::proxy( + RuntimeOrigin::signed(staker.relayer), + unbond_call, + None + )); assert_eq!( true, inner_call_failed_event_emitted( @@ -400,11 +416,16 @@ mod proxy_signed_schedule_nominator_unbond { nonce, bad_amount_to_unbond, ); - - assert_ok!(AvnProxy::proxy(Origin::signed(staker.relayer), unbond_call, None)); + assert_ok!(AvnProxy::proxy( + RuntimeOrigin::signed(staker.relayer), + unbond_call, + None + )); assert_eq!( true, - inner_call_failed_event_emitted(Error::::NominationBelowMin.into()) + inner_call_failed_event_emitted( + Error::::NominatorBondBelowMin.into() + ) ); }); } @@ -418,7 +439,7 @@ mod proxy_signed_schedule_collator_unbond { staker: &Staker, sender_nonce: u64, reduction_amount: u128, - ) -> Box<::Call> { + ) -> Box<::RuntimeCall> { let proof = create_proof_for_signed_schedule_candidate_unbond( sender_nonce, staker, @@ -436,7 +457,7 @@ mod proxy_signed_schedule_collator_unbond { fn create_call_for_signed_schedule_candidate_unbond_proof( proof: Proof, reduction_amount: u128, - ) -> Box<::Call> { + ) -> Box<::RuntimeCall> { return Box::new(MockCall::ParachainStaking( super::super::Call::::signed_schedule_candidate_unbond { proof, @@ -488,7 +509,7 @@ mod proxy_signed_schedule_collator_unbond { ); assert_ok!(AvnProxy::proxy( - Origin::signed(collator_1.relayer), + RuntimeOrigin::signed(collator_1.relayer), candidate_unbond_call, None )); @@ -539,7 +560,7 @@ mod proxy_signed_schedule_collator_unbond { // Show that we can send a successful transaction if its signed. assert_ok!(ParachainStaking::signed_schedule_candidate_unbond( - Origin::signed(collator_1.account_id), + RuntimeOrigin::signed(collator_1.account_id), proof, amount_to_withdraw )); @@ -567,7 +588,7 @@ mod proxy_signed_schedule_collator_unbond { amount_to_withdraw, ); assert_ok!(AvnProxy::proxy( - Origin::signed(collator_1.relayer), + RuntimeOrigin::signed(collator_1.relayer), unbond_call, None )); @@ -608,7 +629,7 @@ mod proxy_signed_schedule_collator_unbond { bad_amount_to_withdraw, ); assert_ok!(AvnProxy::proxy( - Origin::signed(collator_1.relayer), + RuntimeOrigin::signed(collator_1.relayer), unbond_call, None )); @@ -648,7 +669,7 @@ mod proxy_signed_schedule_collator_unbond { ); assert_ok!(AvnProxy::proxy( - Origin::signed(collator_1.relayer), + RuntimeOrigin::signed(collator_1.relayer), unbond_call, None )); @@ -671,7 +692,7 @@ mod signed_execute_nomination_request { let nonce = ParachainStaking::proxy_nonce(staker.account_id); let unbond_call = create_call_for_signed_schedule_nominator_unbond(staker, nonce, *amount); - assert_ok!(AvnProxy::proxy(Origin::signed(staker.relayer), unbond_call, None)); + assert_ok!(AvnProxy::proxy(RuntimeOrigin::signed(staker.relayer), unbond_call, None)); // return updated nonce return ParachainStaking::proxy_nonce(staker.account_id) @@ -681,7 +702,7 @@ mod signed_execute_nomination_request { staker: &Staker, sender_nonce: u64, nominator: AccountId, - ) -> Box<::Call> { + ) -> Box<::RuntimeCall> { let proof = create_proof_for_signed_execute_nomination_request(sender_nonce, staker, &nominator); @@ -751,7 +772,7 @@ mod signed_execute_nomination_request { ); assert_ok!(AvnProxy::proxy( - Origin::signed(random_user.relayer), + RuntimeOrigin::signed(random_user.relayer), execute_unbond_call, None )); @@ -825,7 +846,7 @@ mod signed_execute_nomination_request { // Show that we can send a successful transaction if its signed. assert_ok!(ParachainStaking::signed_execute_nomination_request( - Origin::signed(staker.account_id), + RuntimeOrigin::signed(staker.account_id), proof.clone(), staker.account_id, )); @@ -863,7 +884,7 @@ mod signed_execute_nomination_request { ); assert_ok!(AvnProxy::proxy( - Origin::signed(staker.relayer), + RuntimeOrigin::signed(staker.relayer), execute_unbond_call, None ),); @@ -910,7 +931,7 @@ mod signed_execute_nomination_request { assert_noop!( ParachainStaking::signed_execute_nomination_request( - Origin::signed(staker.account_id), + RuntimeOrigin::signed(staker.account_id), proof.clone(), staker.account_id, ), @@ -930,7 +951,11 @@ mod signed_execute_candidate_unbond { let candidate_unbond_call = create_call_for_signed_schedule_candidate_unbond(candidate, nonce, *amount); - assert_ok!(AvnProxy::proxy(Origin::signed(candidate.relayer), candidate_unbond_call, None)); + assert_ok!(AvnProxy::proxy( + RuntimeOrigin::signed(candidate.relayer), + candidate_unbond_call, + None + )); // return updated nonce return ParachainStaking::proxy_nonce(candidate.account_id) @@ -940,7 +965,7 @@ mod signed_execute_candidate_unbond { staker: &Staker, sender_nonce: u64, candidate: AccountId, - ) -> Box<::Call> { + ) -> Box<::RuntimeCall> { let proof = create_proof_for_signed_execute_candidate_unbond(sender_nonce, staker, &candidate); @@ -1006,7 +1031,7 @@ mod signed_execute_candidate_unbond { ); assert_ok!(AvnProxy::proxy( - Origin::signed(random_user.relayer), + RuntimeOrigin::signed(random_user.relayer), execute_unbond_call, None )); @@ -1079,7 +1104,7 @@ mod signed_execute_candidate_unbond { // Show that we can send a successful transaction if its signed. assert_ok!(ParachainStaking::signed_execute_candidate_unbond( - Origin::signed(collator_1.account_id), + RuntimeOrigin::signed(collator_1.account_id), proof, collator_1.account_id )); @@ -1112,7 +1137,7 @@ mod signed_execute_candidate_unbond { assert_noop!( ParachainStaking::signed_execute_candidate_unbond( - Origin::signed(collator_1.account_id), + RuntimeOrigin::signed(collator_1.account_id), proof.clone(), collator_1.account_id ), @@ -1136,7 +1161,7 @@ fn nominator_unbond_event_emits_correctly() { .build() .execute_with(|| { assert_ok!(ParachainStaking::schedule_nominator_unbond( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id, 5 )); @@ -1160,7 +1185,7 @@ fn nominator_unbond_updates_nominator_state() { .build() .execute_with(|| { assert_ok!(ParachainStaking::schedule_nominator_unbond( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id, 5 )); @@ -1186,10 +1211,12 @@ fn nominator_not_allowed_to_unbond_if_leaving() { .with_nominations(vec![(account_id_2, account_id, 10)]) .build() .execute_with(|| { - assert_ok!(ParachainStaking::schedule_leave_nominators(Origin::signed(account_id_2))); + assert_ok!(ParachainStaking::schedule_leave_nominators(RuntimeOrigin::signed( + account_id_2 + ))); assert_noop!( ParachainStaking::schedule_nominator_unbond( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id, 1 ), @@ -1210,12 +1237,12 @@ fn cannot_nominator_unbond_if_revoking() { .build() .execute_with(|| { assert_ok!(ParachainStaking::schedule_revoke_nomination( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id )); assert_noop!( ParachainStaking::schedule_nominator_unbond( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id, 1 ), @@ -1231,7 +1258,7 @@ fn cannot_nominator_unbond_if_not_nominator() { ExtBuilder::default().build().execute_with(|| { assert_noop!( ParachainStaking::schedule_nominator_unbond( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id, 5 ), @@ -1252,7 +1279,7 @@ fn cannot_nominator_unbond_if_candidate_dne() { .execute_with(|| { assert_noop!( ParachainStaking::schedule_nominator_unbond( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), to_acc_id(3), 5 ), @@ -1274,7 +1301,7 @@ fn cannot_nominator_unbond_if_nomination_dne() { .execute_with(|| { assert_noop!( ParachainStaking::schedule_nominator_unbond( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id_3, 5 ), @@ -1295,7 +1322,7 @@ fn cannot_nominator_unbond_below_min_collator_stk() { .execute_with(|| { assert_noop!( ParachainStaking::schedule_nominator_unbond( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id, 6 ), @@ -1316,7 +1343,7 @@ fn cannot_nominator_unbond_extra_than_total_nomination() { .execute_with(|| { assert_noop!( ParachainStaking::schedule_nominator_unbond( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id, 11 ), @@ -1338,11 +1365,11 @@ fn cannot_nominator_unbond_below_min_nomination() { .execute_with(|| { assert_noop!( ParachainStaking::schedule_nominator_unbond( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id, - 8 + 10 ), - Error::::NominationBelowMin + Error::::NominatorBondBelowMin ); }); } @@ -1357,7 +1384,10 @@ fn schedule_candidate_unbond_event_emits_correctly() { .with_candidates(vec![(account_id, 30)]) .build() .execute_with(|| { - assert_ok!(ParachainStaking::schedule_candidate_unbond(Origin::signed(account_id), 10)); + assert_ok!(ParachainStaking::schedule_candidate_unbond( + RuntimeOrigin::signed(account_id), + 10 + )); assert_last_event!(MetaEvent::ParachainStaking(Event::CandidateBondLessRequested { candidate: account_id, amount_to_decrease: 10, @@ -1374,9 +1404,12 @@ fn cannot_schedule_candidate_unbond_if_request_exists() { .with_candidates(vec![(account_id, 30)]) .build() .execute_with(|| { - assert_ok!(ParachainStaking::schedule_candidate_unbond(Origin::signed(account_id), 5)); + assert_ok!(ParachainStaking::schedule_candidate_unbond( + RuntimeOrigin::signed(account_id), + 5 + )); assert_noop!( - ParachainStaking::schedule_candidate_unbond(Origin::signed(account_id), 5), + ParachainStaking::schedule_candidate_unbond(RuntimeOrigin::signed(account_id), 5), Error::::PendingCandidateRequestAlreadyExists ); }); @@ -1386,7 +1419,7 @@ fn cannot_schedule_candidate_unbond_if_request_exists() { fn cannot_schedule_candidate_unbond_if_not_candidate() { ExtBuilder::default().build().execute_with(|| { assert_noop!( - ParachainStaking::schedule_candidate_unbond(Origin::signed(to_acc_id(6)), 50), + ParachainStaking::schedule_candidate_unbond(RuntimeOrigin::signed(to_acc_id(6)), 50), Error::::CandidateDNE ); }); @@ -1401,7 +1434,7 @@ fn cannot_schedule_candidate_unbond_if_new_total_below_min_candidate_stk() { .build() .execute_with(|| { assert_noop!( - ParachainStaking::schedule_candidate_unbond(Origin::signed(account_id), 21), + ParachainStaking::schedule_candidate_unbond(RuntimeOrigin::signed(account_id), 21), Error::::CandidateBondBelowMin ); }); @@ -1415,8 +1448,14 @@ fn can_schedule_candidate_unbond_if_leaving_candidates() { .with_candidates(vec![(account_id, 30)]) .build() .execute_with(|| { - assert_ok!(ParachainStaking::schedule_leave_candidates(Origin::signed(account_id), 1)); - assert_ok!(ParachainStaking::schedule_candidate_unbond(Origin::signed(account_id), 10)); + assert_ok!(ParachainStaking::schedule_leave_candidates( + RuntimeOrigin::signed(account_id), + 1 + )); + assert_ok!(ParachainStaking::schedule_candidate_unbond( + RuntimeOrigin::signed(account_id), + 10 + )); }); } @@ -1428,15 +1467,18 @@ fn cannot_schedule_candidate_unbond_if_exited_candidates() { .with_candidates(vec![(account_id, 30)]) .build() .execute_with(|| { - assert_ok!(ParachainStaking::schedule_leave_candidates(Origin::signed(account_id), 1)); + assert_ok!(ParachainStaking::schedule_leave_candidates( + RuntimeOrigin::signed(account_id), + 1 + )); roll_to(10); assert_ok!(ParachainStaking::execute_leave_candidates( - Origin::signed(account_id), + RuntimeOrigin::signed(account_id), account_id, 0 )); assert_noop!( - ParachainStaking::schedule_candidate_unbond(Origin::signed(account_id), 10), + ParachainStaking::schedule_candidate_unbond(RuntimeOrigin::signed(account_id), 10), Error::::CandidateDNE ); }); @@ -1451,10 +1493,13 @@ fn execute_candidate_unbond_emits_correct_event() { .with_candidates(vec![(account_id, 50)]) .build() .execute_with(|| { - assert_ok!(ParachainStaking::schedule_candidate_unbond(Origin::signed(account_id), 30)); + assert_ok!(ParachainStaking::schedule_candidate_unbond( + RuntimeOrigin::signed(account_id), + 30 + )); roll_to(10); assert_ok!(ParachainStaking::execute_candidate_unbond( - Origin::signed(account_id), + RuntimeOrigin::signed(account_id), account_id )); assert_last_event!(MetaEvent::ParachainStaking(Event::CandidateBondedLess { @@ -1474,10 +1519,13 @@ fn execute_candidate_unbond_unreserves_balance() { .build() .execute_with(|| { assert_eq!(ParachainStaking::get_collator_stakable_free_balance(&account_id), 0); - assert_ok!(ParachainStaking::schedule_candidate_unbond(Origin::signed(account_id), 10)); + assert_ok!(ParachainStaking::schedule_candidate_unbond( + RuntimeOrigin::signed(account_id), + 10 + )); roll_to(10); assert_ok!(ParachainStaking::execute_candidate_unbond( - Origin::signed(account_id), + RuntimeOrigin::signed(account_id), account_id )); assert_eq!(ParachainStaking::get_collator_stakable_free_balance(&account_id), 10); @@ -1493,10 +1541,13 @@ fn execute_candidate_unbond_decreases_total() { .build() .execute_with(|| { let mut total = ParachainStaking::total(); - assert_ok!(ParachainStaking::schedule_candidate_unbond(Origin::signed(account_id), 10)); + assert_ok!(ParachainStaking::schedule_candidate_unbond( + RuntimeOrigin::signed(account_id), + 10 + )); roll_to(10); assert_ok!(ParachainStaking::execute_candidate_unbond( - Origin::signed(account_id), + RuntimeOrigin::signed(account_id), account_id )); total -= 10; @@ -1515,10 +1566,13 @@ fn execute_candidate_unbond_updates_candidate_state() { let candidate_state = ParachainStaking::candidate_info(account_id).expect("updated => exists"); assert_eq!(candidate_state.bond, 30); - assert_ok!(ParachainStaking::schedule_candidate_unbond(Origin::signed(account_id), 10)); + assert_ok!(ParachainStaking::schedule_candidate_unbond( + RuntimeOrigin::signed(account_id), + 10 + )); roll_to(10); assert_ok!(ParachainStaking::execute_candidate_unbond( - Origin::signed(account_id), + RuntimeOrigin::signed(account_id), account_id )); let candidate_state = @@ -1537,10 +1591,13 @@ fn execute_candidate_unbond_updates_candidate_pool() { .execute_with(|| { assert_eq!(ParachainStaking::candidate_pool().0[0].owner, account_id); assert_eq!(ParachainStaking::candidate_pool().0[0].amount, 30); - assert_ok!(ParachainStaking::schedule_candidate_unbond(Origin::signed(account_id), 10)); + assert_ok!(ParachainStaking::schedule_candidate_unbond( + RuntimeOrigin::signed(account_id), + 10 + )); roll_to(10); assert_ok!(ParachainStaking::execute_candidate_unbond( - Origin::signed(account_id), + RuntimeOrigin::signed(account_id), account_id )); assert_eq!(ParachainStaking::candidate_pool().0[0].owner, account_id); @@ -1562,13 +1619,13 @@ fn execute_nominator_unbond_unreserves_balance() { .execute_with(|| { assert_eq!(ParachainStaking::get_nominator_stakable_free_balance(&account_id_2), 0); assert_ok!(ParachainStaking::schedule_nominator_unbond( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id, 5 )); roll_to(10); assert_ok!(ParachainStaking::execute_nomination_request( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id_2, account_id )); @@ -1588,13 +1645,13 @@ fn execute_nominator_unbond_decreases_total_staked() { .execute_with(|| { assert_eq!(ParachainStaking::total(), 40); assert_ok!(ParachainStaking::schedule_nominator_unbond( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id, 5 )); roll_to(10); assert_ok!(ParachainStaking::execute_nomination_request( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id_2, account_id )); @@ -1617,13 +1674,13 @@ fn execute_nominator_unbond_updates_nominator_state() { 10 ); assert_ok!(ParachainStaking::schedule_nominator_unbond( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id, 5 )); roll_to(10); assert_ok!(ParachainStaking::execute_nomination_request( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id_2, account_id )); @@ -1650,13 +1707,13 @@ fn execute_nominator_unbond_updates_candidate_state() { 10 ); assert_ok!(ParachainStaking::schedule_nominator_unbond( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id, 5 )); roll_to(10); assert_ok!(ParachainStaking::execute_nomination_request( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id_2, account_id )); @@ -1701,13 +1758,13 @@ fn execute_nominator_unbond_updates_just_bottom_nominations() { let pre_call_bottom_nominations = ParachainStaking::bottom_nominations(&account_id) .expect("nominated by all so exists"); assert_ok!(ParachainStaking::schedule_nominator_unbond( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id, 2 )); roll_to(10); assert_ok!(ParachainStaking::execute_nomination_request( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id_2, account_id )); @@ -1783,13 +1840,13 @@ fn execute_nominator_unbond_does_not_delete_bottom_nominations() { let pre_call_bottom_nominations = ParachainStaking::bottom_nominations(&account_id) .expect("nominated by all so exists"); assert_ok!(ParachainStaking::schedule_nominator_unbond( - Origin::signed(account_id_6), + RuntimeOrigin::signed(account_id_6), account_id, 4 )); roll_to(10); assert_ok!(ParachainStaking::execute_nomination_request( - Origin::signed(account_id_6), + RuntimeOrigin::signed(account_id_6), account_id_6, account_id )); @@ -1844,16 +1901,19 @@ fn can_execute_nominator_unbond_for_leaving_candidate() { .with_nominations(vec![(account_id_2, account_id, 15)]) .build() .execute_with(|| { - assert_ok!(ParachainStaking::schedule_leave_candidates(Origin::signed(account_id), 1)); + assert_ok!(ParachainStaking::schedule_leave_candidates( + RuntimeOrigin::signed(account_id), + 1 + )); assert_ok!(ParachainStaking::schedule_nominator_unbond( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id, 5 )); roll_to(10); // can execute bond more nomination request for leaving candidate assert_ok!(ParachainStaking::execute_nomination_request( - Origin::signed(account_id_2), + RuntimeOrigin::signed(account_id_2), account_id_2, account_id )); diff --git a/pallets/parachain-staking/src/tests/test_admin_settings.rs b/pallets/parachain-staking/src/tests/test_admin_settings.rs index e622518f4..1cf00a974 100644 --- a/pallets/parachain-staking/src/tests/test_admin_settings.rs +++ b/pallets/parachain-staking/src/tests/test_admin_settings.rs @@ -1,7 +1,7 @@ #[cfg(test)] use crate::mock::{ - Event as MetaEvent, ExtBuilder, MinNominationPerCollator, Origin, ParachainStaking, Test, - TestAccount, + ExtBuilder, MinNominationPerCollator, ParachainStaking, RuntimeEvent as MetaEvent, + RuntimeOrigin as Origin, Test, TestAccount, }; use crate::{ assert_last_event, AdminSettings, BalanceOf, Delay, Error, Event, MinCollatorStake, diff --git a/pallets/parachain-staking/src/tests/test_growth.rs b/pallets/parachain-staking/src/tests/test_growth.rs index bf5ef6070..506f27725 100644 --- a/pallets/parachain-staking/src/tests/test_growth.rs +++ b/pallets/parachain-staking/src/tests/test_growth.rs @@ -2,8 +2,8 @@ use crate::{ assert_event_emitted, mock::{ get_default_block_per_era, roll_one_block, roll_to_era_begin, set_author, set_reward_pot, - AccountId, Balances, ErasPerGrowthPeriod, ExtBuilder, Origin, ParachainStaking, - RewardPaymentDelay, System, Test, TestAccount, + AccountId, Balances, ErasPerGrowthPeriod, ExtBuilder, ParachainStaking, RewardPaymentDelay, + RuntimeOrigin, System, Test, TestAccount, }, BalanceOf, CollatorScore, EraIndex, Error, Event, Growth, GrowthInfo, GrowthPeriod, GrowthPeriodInfo, ProcessedGrowthPeriods, @@ -57,8 +57,14 @@ fn increase_collator_nomination( collator_2: AccountId, increase_amount: u128, ) { - assert_ok!(ParachainStaking::candidate_bond_extra(Origin::signed(collator_1), increase_amount)); - assert_ok!(ParachainStaking::candidate_bond_extra(Origin::signed(collator_2), increase_amount)); + assert_ok!(ParachainStaking::candidate_bond_extra( + RuntimeOrigin::signed(collator_1), + increase_amount + )); + assert_ok!(ParachainStaking::candidate_bond_extra( + RuntimeOrigin::signed(collator_2), + increase_amount + )); } fn get_expected_block_number(growth_index: u64) -> u64 { diff --git a/pallets/parachain-staking/src/tests/tests.rs b/pallets/parachain-staking/src/tests/tests.rs index 6a987c555..f76094178 100644 --- a/pallets/parachain-staking/src/tests/tests.rs +++ b/pallets/parachain-staking/src/tests/tests.rs @@ -25,8 +25,8 @@ use crate::{ assert_tail_eq, mock::{ roll_one_block, roll_to, roll_to_era_begin, roll_to_era_end, set_author, set_reward_pot, - AccountId, Balances, Event as MetaEvent, ExtBuilder, Origin, ParachainStaking, Test, - TestAccount, + AccountId, Balances, ExtBuilder, ParachainStaking, RuntimeEvent as MetaEvent, + RuntimeOrigin as Origin, Test, TestAccount, }, nomination_requests::{CancelledScheduledRequest, NominationAction, ScheduledRequest}, AtStake, CollatorStatus, Error, Event, NominationScheduledRequests, NominatorAdded, diff --git a/pallets/parachain-staking/src/weights.rs b/pallets/parachain-staking/src/weights.rs index b3d2bb0e5..d61679931 100644 --- a/pallets/parachain-staking/src/weights.rs +++ b/pallets/parachain-staking/src/weights.rs @@ -18,8 +18,8 @@ //! Autogenerated weights for pallet_parachain_staking //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-12-08, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `ip-172-31-4-12`, CPU: `AMD EPYC 7R32` +//! DATE: 2023-03-21, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `ip-10-150-0-139`, CPU: `AMD EPYC 7R32` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -31,9 +31,9 @@ // --execution=wasm // --wasm-execution=compiled // --template -// .maintain/frame-weight-template.hbs +// frame-weight-template.hbs // --pallet -// pallet_parachain-staking +// pallet_parachain_staking // --extrinsic // * // --steps @@ -41,7 +41,7 @@ // --repeat // 20 // --output -// parachain_staking_weights.rs +// ./parachain_stacking_weights.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -99,16 +99,16 @@ impl WeightInfo for SubstrateWeight { // Storage: ParachainStaking TotalSelected (r:1 w:1) // Storage: ParachainStaking Era (r:1 w:0) fn set_total_selected() -> Weight { - (20_382_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(22_640_000) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: ParachainStaking Era (r:1 w:1) // Storage: ParachainStaking TotalSelected (r:1 w:0) fn set_blocks_per_era() -> Weight { - (21_171_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(23_090_000) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: ParachainStaking CandidateInfo (r:1 w:1) // Storage: ParachainStaking NominatorState (r:1 w:0) @@ -122,11 +122,11 @@ impl WeightInfo for SubstrateWeight { // Storage: ParachainStaking TopNominations (r:0 w:1) /// The range of component `x` is `[3, 100]`. fn join_candidates(x: u32, ) -> Weight { - (73_382_000 as Weight) - // Standard Error: 12_000 - .saturating_add((274_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(T::DbWeight::get().reads(8 as Weight)) - .saturating_add(T::DbWeight::get().writes(7 as Weight)) + Weight::from_ref_time(75_088_874) + // Standard Error: 4_075 + .saturating_add(Weight::from_ref_time(220_426).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(7)) } // Storage: ParachainStaking CandidateInfo (r:1 w:1) // Storage: ParachainStaking Era (r:1 w:0) @@ -134,11 +134,11 @@ impl WeightInfo for SubstrateWeight { // Storage: ParachainStaking CandidatePool (r:1 w:1) /// The range of component `x` is `[3, 100]`. fn schedule_leave_candidates(x: u32, ) -> Weight { - (46_301_000 as Weight) - // Standard Error: 11_000 - .saturating_add((202_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(38_569_002) + // Standard Error: 3_054 + .saturating_add(Weight::from_ref_time(160_137).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: ParachainStaking CandidateInfo (r:1 w:1) // Storage: ParachainStaking Era (r:1 w:0) @@ -151,37 +151,37 @@ impl WeightInfo for SubstrateWeight { // Storage: ParachainStaking Total (r:1 w:1) /// The range of component `x` is `[2, 350]`. fn execute_leave_candidates(x: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 127_000 - .saturating_add((37_830_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(x as Weight))) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) - .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(x as Weight))) + Weight::from_ref_time(110_482_000) + // Standard Error: 80_636 + .saturating_add(Weight::from_ref_time(27_361_073).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().writes(4)) + .saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(x.into()))) } // Storage: ParachainStaking CandidateInfo (r:1 w:1) // Storage: ParachainStaking CandidatePool (r:1 w:1) /// The range of component `x` is `[3, 100]`. fn cancel_leave_candidates(x: u32, ) -> Weight { - (31_562_000 as Weight) - // Standard Error: 1_000 - .saturating_add((631_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(34_128_406) + // Standard Error: 3_034 + .saturating_add(Weight::from_ref_time(167_193).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: ParachainStaking CandidateInfo (r:1 w:1) // Storage: ParachainStaking CandidatePool (r:1 w:1) fn go_offline() -> Weight { - (29_513_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(32_781_000) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: ParachainStaking CandidateInfo (r:1 w:1) // Storage: ParachainStaking CandidatePool (r:1 w:1) fn go_online() -> Weight { - (28_972_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(32_671_000) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: ParachainStaking CandidateInfo (r:1 w:1) // Storage: System Account (r:1 w:1) @@ -189,9 +189,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Balances Locks (r:1 w:1) // Storage: ParachainStaking CandidatePool (r:1 w:1) fn candidate_bond_extra() -> Weight { - (50_264_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + Weight::from_ref_time(56_911_000) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(5)) } // Storage: ParachainStaking ProxyNonces (r:1 w:1) // Storage: ParachainStaking CandidateInfo (r:1 w:1) @@ -200,18 +200,18 @@ impl WeightInfo for SubstrateWeight { // Storage: Balances Locks (r:1 w:1) // Storage: ParachainStaking CandidatePool (r:1 w:1) fn signed_candidate_bond_extra() -> Weight { - (136_192_000 as Weight) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + Weight::from_ref_time(141_684_000) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(6)) } // Storage: ParachainStaking CandidateInfo (r:1 w:1) // Storage: ParachainStaking MinCollatorStake (r:1 w:0) // Storage: ParachainStaking Era (r:1 w:0) // Storage: ParachainStaking Delay (r:1 w:0) fn schedule_candidate_unbond() -> Weight { - (32_723_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(36_121_000) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: ParachainStaking ProxyNonces (r:1 w:1) // Storage: ParachainStaking CandidateInfo (r:1 w:1) @@ -219,9 +219,9 @@ impl WeightInfo for SubstrateWeight { // Storage: ParachainStaking Era (r:1 w:0) // Storage: ParachainStaking Delay (r:1 w:0) fn signed_schedule_candidate_unbond() -> Weight { - (116_171_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(118_233_000) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: ParachainStaking CandidateInfo (r:1 w:1) // Storage: ParachainStaking Era (r:1 w:0) @@ -230,9 +230,9 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:1) // Storage: ParachainStaking CandidatePool (r:1 w:1) fn execute_candidate_unbond() -> Weight { - (50_555_000 as Weight) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) + Weight::from_ref_time(65_172_000) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(5)) } // Storage: ParachainStaking ProxyNonces (r:1 w:1) // Storage: ParachainStaking CandidateInfo (r:1 w:1) @@ -242,15 +242,15 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:1) // Storage: ParachainStaking CandidatePool (r:1 w:1) fn signed_execute_candidate_unbond() -> Weight { - (137_013_000 as Weight) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + Weight::from_ref_time(148_673_000) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(6)) } // Storage: ParachainStaking CandidateInfo (r:1 w:1) fn cancel_candidate_unbond() -> Weight { - (20_362_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(27_190_000) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: System Account (r:1 w:1) // Storage: ParachainStaking NominatorState (r:1 w:1) @@ -262,13 +262,13 @@ impl WeightInfo for SubstrateWeight { /// The range of component `x` is `[3, 100]`. /// The range of component `y` is `[2, 300]`. fn nominate(x: u32, y: u32, ) -> Weight { - (100_434_000 as Weight) - // Standard Error: 10_000 - .saturating_add((143_000 as Weight).saturating_mul(x as Weight)) - // Standard Error: 3_000 - .saturating_add((75_000 as Weight).saturating_mul(y as Weight)) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(7 as Weight)) + Weight::from_ref_time(74_579_538) + // Standard Error: 8_120 + .saturating_add(Weight::from_ref_time(405_643).saturating_mul(x.into())) + // Standard Error: 2_664 + .saturating_add(Weight::from_ref_time(153_687).saturating_mul(y.into())) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(7)) } // Storage: ParachainStaking ProxyNonces (r:1 w:1) // Storage: ParachainStaking MinTotalNominatorStake (r:1 w:0) @@ -282,22 +282,22 @@ impl WeightInfo for SubstrateWeight { /// The range of component `x` is `[3, 100]`. /// The range of component `y` is `[2, 300]`. fn signed_nominate(x: u32, _y: u32, ) -> Weight { - (51_970_000 as Weight) - // Standard Error: 85_000 - .saturating_add((51_628_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(x as Weight))) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) - .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(x as Weight))) + Weight::from_ref_time(18_275_633) + // Standard Error: 61_445 + .saturating_add(Weight::from_ref_time(41_204_249).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().writes(4)) + .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(x.into()))) } // Storage: ParachainStaking NominatorState (r:1 w:1) // Storage: ParachainStaking Era (r:1 w:0) // Storage: ParachainStaking Delay (r:1 w:0) // Storage: ParachainStaking NominationScheduledRequests (r:1 w:1) fn schedule_leave_nominators() -> Weight { - (35_411_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(36_371_000) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: ParachainStaking ProxyNonces (r:1 w:1) // Storage: ParachainStaking NominatorState (r:1 w:1) @@ -305,9 +305,9 @@ impl WeightInfo for SubstrateWeight { // Storage: ParachainStaking Delay (r:1 w:0) // Storage: ParachainStaking NominationScheduledRequests (r:1 w:1) fn signed_schedule_leave_nominators() -> Weight { - (120_005_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(118_753_000) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(3)) } // Storage: ParachainStaking NominatorState (r:1 w:1) // Storage: ParachainStaking Era (r:1 w:0) @@ -320,13 +320,13 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:1) /// The range of component `x` is `[2, 100]`. fn execute_leave_nominators(x: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 35_000 - .saturating_add((31_843_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(x as Weight))) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(x as Weight))) + Weight::from_ref_time(87_702_000) + // Standard Error: 38_561 + .saturating_add(Weight::from_ref_time(22_938_197).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().writes(2)) + .saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(x.into()))) } // Storage: ParachainStaking ProxyNonces (r:1 w:1) // Storage: ParachainStaking NominatorState (r:1 w:1) @@ -340,29 +340,29 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:1) /// The range of component `x` is `[2, 100]`. fn signed_execute_leave_nominators(x: u32, ) -> Weight { - (26_623_000 as Weight) - // Standard Error: 39_000 - .saturating_add((32_743_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(x as Weight))) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) - .saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(x as Weight))) + Weight::from_ref_time(84_079_272) + // Standard Error: 33_868 + .saturating_add(Weight::from_ref_time(25_029_439).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().writes(3)) + .saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(x.into()))) } // Storage: ParachainStaking NominatorState (r:1 w:1) // Storage: ParachainStaking NominationScheduledRequests (r:1 w:1) fn cancel_leave_nominators() -> Weight { - (33_202_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(34_751_000) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: ParachainStaking NominatorState (r:1 w:1) // Storage: ParachainStaking NominationScheduledRequests (r:1 w:1) // Storage: ParachainStaking Era (r:1 w:0) // Storage: ParachainStaking Delay (r:1 w:0) fn schedule_revoke_nomination() -> Weight { - (35_303_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(36_271_000) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: ParachainStaking ProxyNonces (r:1 w:1) // Storage: ParachainStaking NominatorState (r:1 w:1) @@ -370,9 +370,9 @@ impl WeightInfo for SubstrateWeight { // Storage: ParachainStaking Era (r:1 w:0) // Storage: ParachainStaking Delay (r:1 w:0) fn signed_schedule_revoke_nomination() -> Weight { - (120_027_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(118_903_000) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(3)) } // Storage: ParachainStaking NominationScheduledRequests (r:1 w:0) // Storage: ParachainStaking NominatorState (r:1 w:1) @@ -383,9 +383,9 @@ impl WeightInfo for SubstrateWeight { // Storage: ParachainStaking CandidatePool (r:1 w:1) // Storage: ParachainStaking Total (r:1 w:1) fn bond_extra() -> Weight { - (68_604_000 as Weight) - .saturating_add(T::DbWeight::get().reads(8 as Weight)) - .saturating_add(T::DbWeight::get().writes(7 as Weight)) + Weight::from_ref_time(76_132_000) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(7)) } // Storage: ParachainStaking ProxyNonces (r:1 w:1) // Storage: System Account (r:1 w:1) @@ -397,9 +397,9 @@ impl WeightInfo for SubstrateWeight { // Storage: ParachainStaking CandidatePool (r:1 w:1) // Storage: ParachainStaking Total (r:1 w:1) fn signed_bond_extra() -> Weight { - (167_640_000 as Weight) - .saturating_add(T::DbWeight::get().reads(9 as Weight)) - .saturating_add(T::DbWeight::get().writes(8 as Weight)) + Weight::from_ref_time(170_175_000) + .saturating_add(T::DbWeight::get().reads(9)) + .saturating_add(T::DbWeight::get().writes(8)) } // Storage: ParachainStaking NominatorState (r:1 w:1) // Storage: ParachainStaking NominationScheduledRequests (r:1 w:1) @@ -407,9 +407,9 @@ impl WeightInfo for SubstrateWeight { // Storage: ParachainStaking Era (r:1 w:0) // Storage: ParachainStaking Delay (r:1 w:0) fn schedule_nominator_unbond() -> Weight { - (36_722_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(38_541_000) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: ParachainStaking ProxyNonces (r:1 w:1) // Storage: ParachainStaking NominatorState (r:1 w:1) @@ -418,9 +418,9 @@ impl WeightInfo for SubstrateWeight { // Storage: ParachainStaking Era (r:1 w:0) // Storage: ParachainStaking Delay (r:1 w:0) fn signed_schedule_nominator_unbond() -> Weight { - (125_557_000 as Weight) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(124_693_000) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(3)) } // Storage: ParachainStaking NominatorState (r:1 w:1) // Storage: ParachainStaking NominationScheduledRequests (r:1 w:1) @@ -432,9 +432,9 @@ impl WeightInfo for SubstrateWeight { // Storage: ParachainStaking CandidatePool (r:1 w:1) // Storage: ParachainStaking Total (r:1 w:1) fn execute_revoke_nomination() -> Weight { - (79_565_000 as Weight) - .saturating_add(T::DbWeight::get().reads(9 as Weight)) - .saturating_add(T::DbWeight::get().writes(8 as Weight)) + Weight::from_ref_time(94_172_000) + .saturating_add(T::DbWeight::get().reads(9)) + .saturating_add(T::DbWeight::get().writes(8)) } // Storage: ParachainStaking NominatorState (r:1 w:1) // Storage: ParachainStaking NominationScheduledRequests (r:1 w:1) @@ -447,9 +447,9 @@ impl WeightInfo for SubstrateWeight { // Storage: ParachainStaking CandidatePool (r:1 w:1) // Storage: ParachainStaking Total (r:1 w:1) fn execute_nominator_unbond() -> Weight { - (71_344_000 as Weight) - .saturating_add(T::DbWeight::get().reads(10 as Weight)) - .saturating_add(T::DbWeight::get().writes(8 as Weight)) + Weight::from_ref_time(87_152_000) + .saturating_add(T::DbWeight::get().reads(10)) + .saturating_add(T::DbWeight::get().writes(8)) } // Storage: ParachainStaking ProxyNonces (r:1 w:1) // Storage: ParachainStaking Era (r:1 w:0) @@ -463,23 +463,23 @@ impl WeightInfo for SubstrateWeight { // Storage: ParachainStaking CandidatePool (r:1 w:1) // Storage: ParachainStaking Total (r:1 w:1) fn signed_execute_nominator_unbond() -> Weight { - (165_410_000 as Weight) - .saturating_add(T::DbWeight::get().reads(11 as Weight)) - .saturating_add(T::DbWeight::get().writes(9 as Weight)) + Weight::from_ref_time(174_184_000) + .saturating_add(T::DbWeight::get().reads(11)) + .saturating_add(T::DbWeight::get().writes(9)) } // Storage: ParachainStaking NominatorState (r:1 w:1) // Storage: ParachainStaking NominationScheduledRequests (r:1 w:1) fn cancel_revoke_nomination() -> Weight { - (25_982_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(32_771_000) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: ParachainStaking NominatorState (r:1 w:1) // Storage: ParachainStaking NominationScheduledRequests (r:1 w:1) fn cancel_nominator_unbond() -> Weight { - (31_192_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(38_461_000) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: ParachainStaking Era (r:1 w:1) // Storage: ParachainStaking Points (r:1 w:0) @@ -502,14 +502,15 @@ impl WeightInfo for SubstrateWeight { /// The range of component `x` is `[8, 20]`. /// The range of component `y` is `[0, 30000]`. fn era_transition_on_initialize(x: u32, y: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 27_446_000 - .saturating_add((218_962_000 as Weight).saturating_mul(x as Weight)) - // Standard Error: 8_000 - .saturating_add((176_000 as Weight).saturating_mul(y as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().reads((11 as Weight).saturating_mul(x as Weight))) - .saturating_add(T::DbWeight::get().writes((8 as Weight).saturating_mul(x as Weight))) + Weight::from_ref_time(799_670_163) + // Standard Error: 11_958_787 + .saturating_add(Weight::from_ref_time(139_781_746).saturating_mul(x.into())) + // Standard Error: 5_042 + .saturating_add(Weight::from_ref_time(133_201).saturating_mul(y.into())) + .saturating_add(T::DbWeight::get().reads(67)) + .saturating_add(T::DbWeight::get().reads((9_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().writes(60)) + .saturating_add(T::DbWeight::get().writes((6_u64).saturating_mul(x.into()))) } // Storage: ParachainStaking DelayedPayouts (r:1 w:0) // Storage: ParachainStaking Points (r:1 w:0) @@ -519,18 +520,18 @@ impl WeightInfo for SubstrateWeight { // Storage: ParachainStaking LockedEraPayout (r:1 w:1) /// The range of component `y` is `[0, 300]`. fn pay_one_collator_reward(y: u32, ) -> Weight { - (35_569_000 as Weight) - // Standard Error: 8_000 - .saturating_add((21_733_000 as Weight).saturating_mul(y as Weight)) - .saturating_add(T::DbWeight::get().reads(8 as Weight)) - .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(y as Weight))) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(y as Weight))) + Weight::from_ref_time(50_108_534) + // Standard Error: 5_472 + .saturating_add(Weight::from_ref_time(18_727_227).saturating_mul(y.into())) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(y.into()))) + .saturating_add(T::DbWeight::get().writes(5)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(y.into()))) } // Storage: ParachainStaking Era (r:1 w:0) fn base_on_initialize() -> Weight { - (3_370_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) + Weight::from_ref_time(6_360_000) + .saturating_add(T::DbWeight::get().reads(1)) } // Storage: ParachainStaking CandidatePool (r:1 w:0) // Storage: ParachainStaking TotalSelected (r:1 w:0) @@ -541,23 +542,23 @@ impl WeightInfo for SubstrateWeight { // Storage: ParachainStaking SelectedCandidates (r:0 w:1) // Storage: ParachainStaking AtStake (r:0 w:20) fn select_top_candidates() -> Weight { - (402_370_000 as Weight) - .saturating_add(T::DbWeight::get().reads(63 as Weight)) - .saturating_add(T::DbWeight::get().writes(21 as Weight)) + Weight::from_ref_time(349_529_000) + .saturating_add(T::DbWeight::get().reads(63)) + .saturating_add(T::DbWeight::get().writes(21)) } // Storage: ParachainStaking Era (r:1 w:0) // Storage: ParachainStaking AwardedPts (r:1 w:1) // Storage: ParachainStaking Points (r:1 w:1) // Storage: System BlockWeight (r:1 w:1) fn note_author() -> Weight { - (14_810_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(16_601_000) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) } // Storage: ParachainStaking Delay (r:0 w:1) fn set_admin_setting() -> Weight { - (16_170_000 as Weight) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(15_981_000) + .saturating_add(T::DbWeight::get().writes(1)) } } @@ -566,16 +567,16 @@ impl WeightInfo for () { // Storage: ParachainStaking TotalSelected (r:1 w:1) // Storage: ParachainStaking Era (r:1 w:0) fn set_total_selected() -> Weight { - (20_382_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(22_640_000) + .saturating_add(RocksDbWeight::get().reads(2)) + .saturating_add(RocksDbWeight::get().writes(1)) } // Storage: ParachainStaking Era (r:1 w:1) // Storage: ParachainStaking TotalSelected (r:1 w:0) fn set_blocks_per_era() -> Weight { - (21_171_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(23_090_000) + .saturating_add(RocksDbWeight::get().reads(2)) + .saturating_add(RocksDbWeight::get().writes(1)) } // Storage: ParachainStaking CandidateInfo (r:1 w:1) // Storage: ParachainStaking NominatorState (r:1 w:0) @@ -589,11 +590,11 @@ impl WeightInfo for () { // Storage: ParachainStaking TopNominations (r:0 w:1) /// The range of component `x` is `[3, 100]`. fn join_candidates(x: u32, ) -> Weight { - (73_382_000 as Weight) - // Standard Error: 12_000 - .saturating_add((274_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(RocksDbWeight::get().reads(8 as Weight)) - .saturating_add(RocksDbWeight::get().writes(7 as Weight)) + Weight::from_ref_time(75_088_874) + // Standard Error: 4_075 + .saturating_add(Weight::from_ref_time(220_426).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(8)) + .saturating_add(RocksDbWeight::get().writes(7)) } // Storage: ParachainStaking CandidateInfo (r:1 w:1) // Storage: ParachainStaking Era (r:1 w:0) @@ -601,11 +602,11 @@ impl WeightInfo for () { // Storage: ParachainStaking CandidatePool (r:1 w:1) /// The range of component `x` is `[3, 100]`. fn schedule_leave_candidates(x: u32, ) -> Weight { - (46_301_000 as Weight) - // Standard Error: 11_000 - .saturating_add((202_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(38_569_002) + // Standard Error: 3_054 + .saturating_add(Weight::from_ref_time(160_137).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(4)) + .saturating_add(RocksDbWeight::get().writes(2)) } // Storage: ParachainStaking CandidateInfo (r:1 w:1) // Storage: ParachainStaking Era (r:1 w:0) @@ -618,37 +619,37 @@ impl WeightInfo for () { // Storage: ParachainStaking Total (r:1 w:1) /// The range of component `x` is `[2, 350]`. fn execute_leave_candidates(x: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 127_000 - .saturating_add((37_830_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(x as Weight))) - .saturating_add(RocksDbWeight::get().writes(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes((3 as Weight).saturating_mul(x as Weight))) + Weight::from_ref_time(110_482_000) + // Standard Error: 80_636 + .saturating_add(Weight::from_ref_time(27_361_073).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(5)) + .saturating_add(RocksDbWeight::get().reads((3_u64).saturating_mul(x.into()))) + .saturating_add(RocksDbWeight::get().writes(4)) + .saturating_add(RocksDbWeight::get().writes((3_u64).saturating_mul(x.into()))) } // Storage: ParachainStaking CandidateInfo (r:1 w:1) // Storage: ParachainStaking CandidatePool (r:1 w:1) /// The range of component `x` is `[3, 100]`. fn cancel_leave_candidates(x: u32, ) -> Weight { - (31_562_000 as Weight) - // Standard Error: 1_000 - .saturating_add((631_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(34_128_406) + // Standard Error: 3_034 + .saturating_add(Weight::from_ref_time(167_193).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(2)) + .saturating_add(RocksDbWeight::get().writes(2)) } // Storage: ParachainStaking CandidateInfo (r:1 w:1) // Storage: ParachainStaking CandidatePool (r:1 w:1) fn go_offline() -> Weight { - (29_513_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(32_781_000) + .saturating_add(RocksDbWeight::get().reads(2)) + .saturating_add(RocksDbWeight::get().writes(2)) } // Storage: ParachainStaking CandidateInfo (r:1 w:1) // Storage: ParachainStaking CandidatePool (r:1 w:1) fn go_online() -> Weight { - (28_972_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(32_671_000) + .saturating_add(RocksDbWeight::get().reads(2)) + .saturating_add(RocksDbWeight::get().writes(2)) } // Storage: ParachainStaking CandidateInfo (r:1 w:1) // Storage: System Account (r:1 w:1) @@ -656,9 +657,9 @@ impl WeightInfo for () { // Storage: Balances Locks (r:1 w:1) // Storage: ParachainStaking CandidatePool (r:1 w:1) fn candidate_bond_extra() -> Weight { - (50_264_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes(5 as Weight)) + Weight::from_ref_time(56_911_000) + .saturating_add(RocksDbWeight::get().reads(5)) + .saturating_add(RocksDbWeight::get().writes(5)) } // Storage: ParachainStaking ProxyNonces (r:1 w:1) // Storage: ParachainStaking CandidateInfo (r:1 w:1) @@ -667,18 +668,18 @@ impl WeightInfo for () { // Storage: Balances Locks (r:1 w:1) // Storage: ParachainStaking CandidatePool (r:1 w:1) fn signed_candidate_bond_extra() -> Weight { - (136_192_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(6 as Weight)) - .saturating_add(RocksDbWeight::get().writes(6 as Weight)) + Weight::from_ref_time(141_684_000) + .saturating_add(RocksDbWeight::get().reads(6)) + .saturating_add(RocksDbWeight::get().writes(6)) } // Storage: ParachainStaking CandidateInfo (r:1 w:1) // Storage: ParachainStaking MinCollatorStake (r:1 w:0) // Storage: ParachainStaking Era (r:1 w:0) // Storage: ParachainStaking Delay (r:1 w:0) fn schedule_candidate_unbond() -> Weight { - (32_723_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(36_121_000) + .saturating_add(RocksDbWeight::get().reads(4)) + .saturating_add(RocksDbWeight::get().writes(1)) } // Storage: ParachainStaking ProxyNonces (r:1 w:1) // Storage: ParachainStaking CandidateInfo (r:1 w:1) @@ -686,9 +687,9 @@ impl WeightInfo for () { // Storage: ParachainStaking Era (r:1 w:0) // Storage: ParachainStaking Delay (r:1 w:0) fn signed_schedule_candidate_unbond() -> Weight { - (116_171_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(118_233_000) + .saturating_add(RocksDbWeight::get().reads(5)) + .saturating_add(RocksDbWeight::get().writes(2)) } // Storage: ParachainStaking CandidateInfo (r:1 w:1) // Storage: ParachainStaking Era (r:1 w:0) @@ -697,9 +698,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:1) // Storage: ParachainStaking CandidatePool (r:1 w:1) fn execute_candidate_unbond() -> Weight { - (50_555_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(6 as Weight)) - .saturating_add(RocksDbWeight::get().writes(5 as Weight)) + Weight::from_ref_time(65_172_000) + .saturating_add(RocksDbWeight::get().reads(6)) + .saturating_add(RocksDbWeight::get().writes(5)) } // Storage: ParachainStaking ProxyNonces (r:1 w:1) // Storage: ParachainStaking CandidateInfo (r:1 w:1) @@ -709,15 +710,15 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:1) // Storage: ParachainStaking CandidatePool (r:1 w:1) fn signed_execute_candidate_unbond() -> Weight { - (137_013_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(7 as Weight)) - .saturating_add(RocksDbWeight::get().writes(6 as Weight)) + Weight::from_ref_time(148_673_000) + .saturating_add(RocksDbWeight::get().reads(7)) + .saturating_add(RocksDbWeight::get().writes(6)) } // Storage: ParachainStaking CandidateInfo (r:1 w:1) fn cancel_candidate_unbond() -> Weight { - (20_362_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(27_190_000) + .saturating_add(RocksDbWeight::get().reads(1)) + .saturating_add(RocksDbWeight::get().writes(1)) } // Storage: System Account (r:1 w:1) // Storage: ParachainStaking NominatorState (r:1 w:1) @@ -729,13 +730,13 @@ impl WeightInfo for () { /// The range of component `x` is `[3, 100]`. /// The range of component `y` is `[2, 300]`. fn nominate(x: u32, y: u32, ) -> Weight { - (100_434_000 as Weight) - // Standard Error: 10_000 - .saturating_add((143_000 as Weight).saturating_mul(x as Weight)) - // Standard Error: 3_000 - .saturating_add((75_000 as Weight).saturating_mul(y as Weight)) - .saturating_add(RocksDbWeight::get().reads(7 as Weight)) - .saturating_add(RocksDbWeight::get().writes(7 as Weight)) + Weight::from_ref_time(74_579_538) + // Standard Error: 8_120 + .saturating_add(Weight::from_ref_time(405_643).saturating_mul(x.into())) + // Standard Error: 2_664 + .saturating_add(Weight::from_ref_time(153_687).saturating_mul(y.into())) + .saturating_add(RocksDbWeight::get().reads(7)) + .saturating_add(RocksDbWeight::get().writes(7)) } // Storage: ParachainStaking ProxyNonces (r:1 w:1) // Storage: ParachainStaking MinTotalNominatorStake (r:1 w:0) @@ -749,22 +750,22 @@ impl WeightInfo for () { /// The range of component `x` is `[3, 100]`. /// The range of component `y` is `[2, 300]`. fn signed_nominate(x: u32, _y: u32, ) -> Weight { - (51_970_000 as Weight) - // Standard Error: 85_000 - .saturating_add((51_628_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(RocksDbWeight::get().reads(6 as Weight)) - .saturating_add(RocksDbWeight::get().reads((2 as Weight).saturating_mul(x as Weight))) - .saturating_add(RocksDbWeight::get().writes(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes((2 as Weight).saturating_mul(x as Weight))) + Weight::from_ref_time(18_275_633) + // Standard Error: 61_445 + .saturating_add(Weight::from_ref_time(41_204_249).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(6)) + .saturating_add(RocksDbWeight::get().reads((2_u64).saturating_mul(x.into()))) + .saturating_add(RocksDbWeight::get().writes(4)) + .saturating_add(RocksDbWeight::get().writes((2_u64).saturating_mul(x.into()))) } // Storage: ParachainStaking NominatorState (r:1 w:1) // Storage: ParachainStaking Era (r:1 w:0) // Storage: ParachainStaking Delay (r:1 w:0) // Storage: ParachainStaking NominationScheduledRequests (r:1 w:1) fn schedule_leave_nominators() -> Weight { - (35_411_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(36_371_000) + .saturating_add(RocksDbWeight::get().reads(4)) + .saturating_add(RocksDbWeight::get().writes(2)) } // Storage: ParachainStaking ProxyNonces (r:1 w:1) // Storage: ParachainStaking NominatorState (r:1 w:1) @@ -772,9 +773,9 @@ impl WeightInfo for () { // Storage: ParachainStaking Delay (r:1 w:0) // Storage: ParachainStaking NominationScheduledRequests (r:1 w:1) fn signed_schedule_leave_nominators() -> Weight { - (120_005_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(118_753_000) + .saturating_add(RocksDbWeight::get().reads(5)) + .saturating_add(RocksDbWeight::get().writes(3)) } // Storage: ParachainStaking NominatorState (r:1 w:1) // Storage: ParachainStaking Era (r:1 w:0) @@ -787,13 +788,13 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:1) /// The range of component `x` is `[2, 100]`. fn execute_leave_nominators(x: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 35_000 - .saturating_add((31_843_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(x as Weight))) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes((3 as Weight).saturating_mul(x as Weight))) + Weight::from_ref_time(87_702_000) + // Standard Error: 38_561 + .saturating_add(Weight::from_ref_time(22_938_197).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(3)) + .saturating_add(RocksDbWeight::get().reads((3_u64).saturating_mul(x.into()))) + .saturating_add(RocksDbWeight::get().writes(2)) + .saturating_add(RocksDbWeight::get().writes((3_u64).saturating_mul(x.into()))) } // Storage: ParachainStaking ProxyNonces (r:1 w:1) // Storage: ParachainStaking NominatorState (r:1 w:1) @@ -807,29 +808,29 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:1) /// The range of component `x` is `[2, 100]`. fn signed_execute_leave_nominators(x: u32, ) -> Weight { - (26_623_000 as Weight) - // Standard Error: 39_000 - .saturating_add((32_743_000 as Weight).saturating_mul(x as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(x as Weight))) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes((3 as Weight).saturating_mul(x as Weight))) + Weight::from_ref_time(84_079_272) + // Standard Error: 33_868 + .saturating_add(Weight::from_ref_time(25_029_439).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(4)) + .saturating_add(RocksDbWeight::get().reads((3_u64).saturating_mul(x.into()))) + .saturating_add(RocksDbWeight::get().writes(3)) + .saturating_add(RocksDbWeight::get().writes((3_u64).saturating_mul(x.into()))) } // Storage: ParachainStaking NominatorState (r:1 w:1) // Storage: ParachainStaking NominationScheduledRequests (r:1 w:1) fn cancel_leave_nominators() -> Weight { - (33_202_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(34_751_000) + .saturating_add(RocksDbWeight::get().reads(2)) + .saturating_add(RocksDbWeight::get().writes(2)) } // Storage: ParachainStaking NominatorState (r:1 w:1) // Storage: ParachainStaking NominationScheduledRequests (r:1 w:1) // Storage: ParachainStaking Era (r:1 w:0) // Storage: ParachainStaking Delay (r:1 w:0) fn schedule_revoke_nomination() -> Weight { - (35_303_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(36_271_000) + .saturating_add(RocksDbWeight::get().reads(4)) + .saturating_add(RocksDbWeight::get().writes(2)) } // Storage: ParachainStaking ProxyNonces (r:1 w:1) // Storage: ParachainStaking NominatorState (r:1 w:1) @@ -837,9 +838,9 @@ impl WeightInfo for () { // Storage: ParachainStaking Era (r:1 w:0) // Storage: ParachainStaking Delay (r:1 w:0) fn signed_schedule_revoke_nomination() -> Weight { - (120_027_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(118_903_000) + .saturating_add(RocksDbWeight::get().reads(5)) + .saturating_add(RocksDbWeight::get().writes(3)) } // Storage: ParachainStaking NominationScheduledRequests (r:1 w:0) // Storage: ParachainStaking NominatorState (r:1 w:1) @@ -850,9 +851,9 @@ impl WeightInfo for () { // Storage: ParachainStaking CandidatePool (r:1 w:1) // Storage: ParachainStaking Total (r:1 w:1) fn bond_extra() -> Weight { - (68_604_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(8 as Weight)) - .saturating_add(RocksDbWeight::get().writes(7 as Weight)) + Weight::from_ref_time(76_132_000) + .saturating_add(RocksDbWeight::get().reads(8)) + .saturating_add(RocksDbWeight::get().writes(7)) } // Storage: ParachainStaking ProxyNonces (r:1 w:1) // Storage: System Account (r:1 w:1) @@ -864,9 +865,9 @@ impl WeightInfo for () { // Storage: ParachainStaking CandidatePool (r:1 w:1) // Storage: ParachainStaking Total (r:1 w:1) fn signed_bond_extra() -> Weight { - (167_640_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(9 as Weight)) - .saturating_add(RocksDbWeight::get().writes(8 as Weight)) + Weight::from_ref_time(170_175_000) + .saturating_add(RocksDbWeight::get().reads(9)) + .saturating_add(RocksDbWeight::get().writes(8)) } // Storage: ParachainStaking NominatorState (r:1 w:1) // Storage: ParachainStaking NominationScheduledRequests (r:1 w:1) @@ -874,9 +875,9 @@ impl WeightInfo for () { // Storage: ParachainStaking Era (r:1 w:0) // Storage: ParachainStaking Delay (r:1 w:0) fn schedule_nominator_unbond() -> Weight { - (36_722_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(38_541_000) + .saturating_add(RocksDbWeight::get().reads(5)) + .saturating_add(RocksDbWeight::get().writes(2)) } // Storage: ParachainStaking ProxyNonces (r:1 w:1) // Storage: ParachainStaking NominatorState (r:1 w:1) @@ -885,9 +886,9 @@ impl WeightInfo for () { // Storage: ParachainStaking Era (r:1 w:0) // Storage: ParachainStaking Delay (r:1 w:0) fn signed_schedule_nominator_unbond() -> Weight { - (125_557_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(6 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(124_693_000) + .saturating_add(RocksDbWeight::get().reads(6)) + .saturating_add(RocksDbWeight::get().writes(3)) } // Storage: ParachainStaking NominatorState (r:1 w:1) // Storage: ParachainStaking NominationScheduledRequests (r:1 w:1) @@ -899,9 +900,9 @@ impl WeightInfo for () { // Storage: ParachainStaking CandidatePool (r:1 w:1) // Storage: ParachainStaking Total (r:1 w:1) fn execute_revoke_nomination() -> Weight { - (79_565_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(9 as Weight)) - .saturating_add(RocksDbWeight::get().writes(8 as Weight)) + Weight::from_ref_time(94_172_000) + .saturating_add(RocksDbWeight::get().reads(9)) + .saturating_add(RocksDbWeight::get().writes(8)) } // Storage: ParachainStaking NominatorState (r:1 w:1) // Storage: ParachainStaking NominationScheduledRequests (r:1 w:1) @@ -914,9 +915,9 @@ impl WeightInfo for () { // Storage: ParachainStaking CandidatePool (r:1 w:1) // Storage: ParachainStaking Total (r:1 w:1) fn execute_nominator_unbond() -> Weight { - (71_344_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(10 as Weight)) - .saturating_add(RocksDbWeight::get().writes(8 as Weight)) + Weight::from_ref_time(87_152_000) + .saturating_add(RocksDbWeight::get().reads(10)) + .saturating_add(RocksDbWeight::get().writes(8)) } // Storage: ParachainStaking ProxyNonces (r:1 w:1) // Storage: ParachainStaking Era (r:1 w:0) @@ -930,23 +931,23 @@ impl WeightInfo for () { // Storage: ParachainStaking CandidatePool (r:1 w:1) // Storage: ParachainStaking Total (r:1 w:1) fn signed_execute_nominator_unbond() -> Weight { - (165_410_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(11 as Weight)) - .saturating_add(RocksDbWeight::get().writes(9 as Weight)) + Weight::from_ref_time(174_184_000) + .saturating_add(RocksDbWeight::get().reads(11)) + .saturating_add(RocksDbWeight::get().writes(9)) } // Storage: ParachainStaking NominatorState (r:1 w:1) // Storage: ParachainStaking NominationScheduledRequests (r:1 w:1) fn cancel_revoke_nomination() -> Weight { - (25_982_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(32_771_000) + .saturating_add(RocksDbWeight::get().reads(2)) + .saturating_add(RocksDbWeight::get().writes(2)) } // Storage: ParachainStaking NominatorState (r:1 w:1) // Storage: ParachainStaking NominationScheduledRequests (r:1 w:1) fn cancel_nominator_unbond() -> Weight { - (31_192_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(38_461_000) + .saturating_add(RocksDbWeight::get().reads(2)) + .saturating_add(RocksDbWeight::get().writes(2)) } // Storage: ParachainStaking Era (r:1 w:1) // Storage: ParachainStaking Points (r:1 w:0) @@ -969,14 +970,15 @@ impl WeightInfo for () { /// The range of component `x` is `[8, 20]`. /// The range of component `y` is `[0, 30000]`. fn era_transition_on_initialize(x: u32, y: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 27_446_000 - .saturating_add((218_962_000 as Weight).saturating_mul(x as Weight)) - // Standard Error: 8_000 - .saturating_add((176_000 as Weight).saturating_mul(y as Weight)) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().reads((11 as Weight).saturating_mul(x as Weight))) - .saturating_add(RocksDbWeight::get().writes((8 as Weight).saturating_mul(x as Weight))) + Weight::from_ref_time(799_670_163) + // Standard Error: 11_958_787 + .saturating_add(Weight::from_ref_time(139_781_746).saturating_mul(x.into())) + // Standard Error: 5_042 + .saturating_add(Weight::from_ref_time(133_201).saturating_mul(y.into())) + .saturating_add(RocksDbWeight::get().reads(67)) + .saturating_add(RocksDbWeight::get().reads((9_u64).saturating_mul(x.into()))) + .saturating_add(RocksDbWeight::get().writes(60)) + .saturating_add(RocksDbWeight::get().writes((6_u64).saturating_mul(x.into()))) } // Storage: ParachainStaking DelayedPayouts (r:1 w:0) // Storage: ParachainStaking Points (r:1 w:0) @@ -986,18 +988,18 @@ impl WeightInfo for () { // Storage: ParachainStaking LockedEraPayout (r:1 w:1) /// The range of component `y` is `[0, 300]`. fn pay_one_collator_reward(y: u32, ) -> Weight { - (35_569_000 as Weight) - // Standard Error: 8_000 - .saturating_add((21_733_000 as Weight).saturating_mul(y as Weight)) - .saturating_add(RocksDbWeight::get().reads(8 as Weight)) - .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(y as Weight))) - .saturating_add(RocksDbWeight::get().writes(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(y as Weight))) + Weight::from_ref_time(50_108_534) + // Standard Error: 5_472 + .saturating_add(Weight::from_ref_time(18_727_227).saturating_mul(y.into())) + .saturating_add(RocksDbWeight::get().reads(8)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(y.into()))) + .saturating_add(RocksDbWeight::get().writes(5)) + .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(y.into()))) } // Storage: ParachainStaking Era (r:1 w:0) fn base_on_initialize() -> Weight { - (3_370_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) + Weight::from_ref_time(6_360_000) + .saturating_add(RocksDbWeight::get().reads(1)) } // Storage: ParachainStaking CandidatePool (r:1 w:0) // Storage: ParachainStaking TotalSelected (r:1 w:0) @@ -1008,22 +1010,22 @@ impl WeightInfo for () { // Storage: ParachainStaking SelectedCandidates (r:0 w:1) // Storage: ParachainStaking AtStake (r:0 w:20) fn select_top_candidates() -> Weight { - (402_370_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(63 as Weight)) - .saturating_add(RocksDbWeight::get().writes(21 as Weight)) + Weight::from_ref_time(349_529_000) + .saturating_add(RocksDbWeight::get().reads(63)) + .saturating_add(RocksDbWeight::get().writes(21)) } // Storage: ParachainStaking Era (r:1 w:0) // Storage: ParachainStaking AwardedPts (r:1 w:1) // Storage: ParachainStaking Points (r:1 w:1) // Storage: System BlockWeight (r:1 w:1) fn note_author() -> Weight { - (14_810_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(16_601_000) + .saturating_add(RocksDbWeight::get().reads(4)) + .saturating_add(RocksDbWeight::get().writes(3)) } // Storage: ParachainStaking Delay (r:0 w:1) fn set_admin_setting() -> Weight { - (16_170_000 as Weight) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + Weight::from_ref_time(15_981_000) + .saturating_add(RocksDbWeight::get().writes(1)) } } \ No newline at end of file diff --git a/pallets/summary/Cargo.toml b/pallets/summary/Cargo.toml index ac8bb3f3a..039ee4aff 100644 --- a/pallets/summary/Cargo.toml +++ b/pallets/summary/Cargo.toml @@ -19,29 +19,30 @@ sp-avn-common = { version = "0.12.0", default-features = false, path = "../../pr pallet-ethereum-transactions = { version = "0.12.0", default-features = false, path = "../ethereum-transactions" } pallet-avn = { version = "0.12.0", path = "../avn", default-features = false } -sp-std = {default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -sp-runtime = {default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -sp-core = {default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -sp-io = {default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -sp-application-crypto = {default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -frame-support = {default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -frame-system = {default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -sp-staking = {default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -pallet-session = {default-features = false, features = ["historical"], git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } +sp-std = {default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +sp-runtime = {default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +sp-core = {default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +sp-io = {default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +sp-application-crypto = {default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +frame-support = {default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +frame-system = {default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +sp-staking = {default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +pallet-session = {default-features = false, features = ["historical"], git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } # Optional imports for benchmarking -frame-benchmarking = {default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27", optional = true } +frame-benchmarking = {default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", optional = true } [dev-dependencies] -substrate-test-utils = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } +substrate-test-utils = {git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } parking_lot = { version = "0.12.0" } -pallet-session = {features = ["historical"], git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27", default-features = false } +pallet-session = {features = ["historical"], git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } assert_matches = "1.3.0" [features] migrate = [] default = ["std"] std = [ + "frame-benchmarking?/std", "serde", "codec/std", "sp-std/std", @@ -57,7 +58,7 @@ std = [ "pallet-ethereum-transactions/std" ] runtime-benchmarks = [ - "frame-benchmarking", + "frame-benchmarking/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", ] \ No newline at end of file diff --git a/pallets/summary/src/benchmarking.rs b/pallets/summary/src/benchmarking.rs index 62e49e897..8a572fc35 100644 --- a/pallets/summary/src/benchmarking.rs +++ b/pallets/summary/src/benchmarking.rs @@ -182,21 +182,21 @@ fn generate_signature( return signature } -fn assert_last_event(generic_event: ::Event) { +fn assert_last_event(generic_event: ::RuntimeEvent) { assert_last_nth_event::(generic_event, 1); } -fn assert_last_nth_event(generic_event: ::Event, n: u32) { +fn assert_last_nth_event(generic_event: ::RuntimeEvent, n: u32) { let events = frame_system::Pallet::::events(); - let system_event: ::Event = generic_event.into(); + let system_event: ::RuntimeEvent = generic_event.into(); // compare to the last event record let EventRecord { event, .. } = &events[events.len().saturating_sub(n as usize)]; assert_eq!(event, &system_event); } -fn assert_event_exists(generic_event: ::Event) { +fn assert_event_exists(generic_event: ::RuntimeEvent) { let all_emitted_events = frame_system::Pallet::::events(); - let summary_event: ::Event = generic_event.into(); + let summary_event: ::RuntimeEvent = generic_event.into(); assert_eq!( true, diff --git a/pallets/summary/src/default_weights.rs b/pallets/summary/src/default_weights.rs index 2db63ed7c..6b634bc76 100644 --- a/pallets/summary/src/default_weights.rs +++ b/pallets/summary/src/default_weights.rs @@ -71,8 +71,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Summary VotingPeriod (r:0 w:1) // Storage: Summary SchedulePeriod (r:0 w:1) fn set_periods() -> Weight { - (16_781_000 as Weight) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(16_781_000) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: Summary TotalIngresses (r:1 w:1) // Storage: Avn Validators (r:1 w:0) @@ -87,11 +87,11 @@ impl WeightInfo for SubstrateWeight { /// The range of component `v` is `[3, 10]`. /// The range of component `r` is `[1, 2]`. fn record_summary_calculation(v: u32, _r: u32, ) -> Weight { - (62_440_000 as Weight) + Weight::from_ref_time(62_440_000) // Standard Error: 38_000 - .saturating_add((242_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(10 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + .saturating_add(Weight::from_ref_time(242_000).saturating_mul(v as u64)) + .saturating_add(T::DbWeight::get().reads(10)) + .saturating_add(T::DbWeight::get().writes(6)) } // Storage: Summary Roots (r:1 w:1) // Storage: Avn Validators (r:1 w:0) @@ -111,15 +111,15 @@ impl WeightInfo for SubstrateWeight { /// The range of component `v` is `[3, 10]`. /// The range of component `o` is `[1, 2]`. fn approve_root_with_end_voting(v: u32, o: u32, ) -> Weight { - (202_079_000 as Weight) + Weight::from_ref_time(202_079_000) // Standard Error: 268_000 - .saturating_add((1_240_000 as Weight).saturating_mul(v as Weight)) + .saturating_add(Weight::from_ref_time(1_240_000).saturating_mul(v as u64)) // Standard Error: 2_224_000 - .saturating_add((19_374_000 as Weight).saturating_mul(o as Weight)) - .saturating_add(T::DbWeight::get().reads(11 as Weight)) - .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(o as Weight))) - .saturating_add(T::DbWeight::get().writes(7 as Weight)) - .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(o as Weight))) + .saturating_add(Weight::from_ref_time(19_374_000).saturating_mul(o as u64)) + .saturating_add(T::DbWeight::get().reads(11)) + .saturating_add(T::DbWeight::get().reads(2).saturating_mul(o as u64)) + .saturating_add(T::DbWeight::get().writes(7)) + .saturating_add(T::DbWeight::get().writes(2).saturating_mul(o as u64)) } // Storage: Summary Roots (r:1 w:0) // Storage: Avn Validators (r:1 w:0) @@ -129,11 +129,11 @@ impl WeightInfo for SubstrateWeight { // Storage: AvnFinalityTracker LatestFinalisedBlock (r:1 w:0) /// The range of component `v` is `[3, 10]`. fn approve_root_without_end_voting(v: u32, ) -> Weight { - (124_198_000 as Weight) + Weight::from_ref_time(124_198_000) // Standard Error: 67_000 - .saturating_add((508_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(508_000).saturating_mul(v as u64)) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Avn Validators (r:1 w:0) // Storage: Summary VotesRepository (r:1 w:1) @@ -149,15 +149,15 @@ impl WeightInfo for SubstrateWeight { /// The range of component `v` is `[3, 10]`. /// The range of component `o` is `[1, 2]`. fn reject_root_with_end_voting(v: u32, o: u32, ) -> Weight { - (146_663_000 as Weight) + Weight::from_ref_time(146_663_000) // Standard Error: 126_000 - .saturating_add((1_208_000 as Weight).saturating_mul(v as Weight)) + .saturating_add(Weight::from_ref_time(1_208_000).saturating_mul(v as u64)) // Standard Error: 1_049_000 - .saturating_add((20_910_000 as Weight).saturating_mul(o as Weight)) - .saturating_add(T::DbWeight::get().reads(11 as Weight)) - .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(o as Weight))) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) - .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(o as Weight))) + .saturating_add(Weight::from_ref_time(20_910_000).saturating_mul(o as u64)) + .saturating_add(T::DbWeight::get().reads(11)) + .saturating_add(T::DbWeight::get().reads(2).saturating_mul(o as u64)) + .saturating_add(T::DbWeight::get().writes(6)) + .saturating_add(T::DbWeight::get().writes(2).saturating_mul(o as u64)) } // Storage: Avn Validators (r:1 w:0) // Storage: Summary VotesRepository (r:1 w:1) @@ -166,11 +166,11 @@ impl WeightInfo for SubstrateWeight { // Storage: AvnFinalityTracker LatestFinalisedBlock (r:1 w:0) /// The range of component `v` is `[3, 10]`. fn reject_root_without_end_voting(v: u32, ) -> Weight { - (53_317_000 as Weight) + Weight::from_ref_time(53_317_000) // Standard Error: 18_000 - .saturating_add((146_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(146_000).saturating_mul(v as u64)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Summary VotesRepository (r:1 w:0) // Storage: Summary Roots (r:1 w:1) @@ -188,13 +188,13 @@ impl WeightInfo for SubstrateWeight { // Storage: Summary NextBlockToProcess (r:0 w:1) /// The range of component `o` is `[1, 2]`. fn end_voting_period_with_rejected_valid_votes(o: u32, ) -> Weight { - (92_154_000 as Weight) + Weight::from_ref_time(92_154_000) // Standard Error: 617_000 - .saturating_add((15_202_000 as Weight).saturating_mul(o as Weight)) - .saturating_add(T::DbWeight::get().reads(10 as Weight)) - .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(o as Weight))) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) - .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(o as Weight))) + .saturating_add(Weight::from_ref_time(15_202_000).saturating_mul(o as u64)) + .saturating_add(T::DbWeight::get().reads(10)) + .saturating_add(T::DbWeight::get().reads(2).saturating_mul(o as u64)) + .saturating_add(T::DbWeight::get().writes(6)) + .saturating_add(T::DbWeight::get().writes(2).saturating_mul(o as u64)) } // Storage: Summary VotesRepository (r:1 w:0) // Storage: Summary Roots (r:1 w:0) @@ -209,13 +209,13 @@ impl WeightInfo for SubstrateWeight { // Storage: AvnOffenceHandler SlashingEnabled (r:1 w:0) /// The range of component `o` is `[1, 2]`. fn end_voting_period_with_approved_invalid_votes(o: u32, ) -> Weight { - (117_661_000 as Weight) + Weight::from_ref_time(117_661_000) // Standard Error: 1_307_000 - .saturating_add((17_536_000 as Weight).saturating_mul(o as Weight)) - .saturating_add(T::DbWeight::get().reads(11 as Weight)) - .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(o as Weight))) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) - .saturating_add(T::DbWeight::get().writes((2 as Weight).saturating_mul(o as Weight))) + .saturating_add(Weight::from_ref_time(17_536_000).saturating_mul(o as u64)) + .saturating_add(T::DbWeight::get().reads(11)) + .saturating_add(T::DbWeight::get().reads(2).saturating_mul(o as u64)) + .saturating_add(T::DbWeight::get().writes(5)) + .saturating_add(T::DbWeight::get().writes(2).saturating_mul(o as u64)) } // Storage: Summary NextSlotAtBlock (r:1 w:1) // Storage: Summary CurrentSlotsValidator (r:1 w:1) @@ -230,9 +230,9 @@ impl WeightInfo for SubstrateWeight { // Storage: AvnOffenceHandler SlashingEnabled (r:1 w:0) // Storage: Summary SchedulePeriod (r:1 w:0) fn advance_slot_with_offence() -> Weight { - (93_875_000 as Weight) - .saturating_add(T::DbWeight::get().reads(12 as Weight)) - .saturating_add(T::DbWeight::get().writes(7 as Weight)) + Weight::from_ref_time(93_875_000) + .saturating_add(T::DbWeight::get().reads(12)) + .saturating_add(T::DbWeight::get().writes(7)) } // Storage: Summary NextSlotAtBlock (r:1 w:1) // Storage: Summary CurrentSlotsValidator (r:1 w:1) @@ -241,9 +241,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Avn Validators (r:1 w:0) // Storage: Summary SchedulePeriod (r:1 w:0) fn advance_slot_without_offence() -> Weight { - (38_122_000 as Weight) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(38_122_000) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(3)) } // Storage: Summary CurrentSlot (r:1 w:1) // Storage: Summary CurrentSlotsValidator (r:1 w:1) @@ -258,9 +258,9 @@ impl WeightInfo for SubstrateWeight { // Storage: Summary SlotOfLastPublishedSummary (r:1 w:0) // Storage: Summary SchedulePeriod (r:1 w:0) fn add_challenge() -> Weight { - (103_435_000 as Weight) - .saturating_add(T::DbWeight::get().reads(12 as Weight)) - .saturating_add(T::DbWeight::get().writes(7 as Weight)) + Weight::from_ref_time(103_435_000) + .saturating_add(T::DbWeight::get().reads(12)) + .saturating_add(T::DbWeight::get().writes(7)) } } @@ -269,8 +269,8 @@ impl WeightInfo for () { // Storage: Summary VotingPeriod (r:0 w:1) // Storage: Summary SchedulePeriod (r:0 w:1) fn set_periods() -> Weight { - (16_781_000 as Weight) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(16_781_000) + .saturating_add(RocksDbWeight::get().writes(2)) } // Storage: Summary TotalIngresses (r:1 w:1) // Storage: Avn Validators (r:1 w:0) @@ -285,11 +285,11 @@ impl WeightInfo for () { /// The range of component `v` is `[3, 10]`. /// The range of component `r` is `[1, 2]`. fn record_summary_calculation(v: u32, _r: u32, ) -> Weight { - (62_440_000 as Weight) + Weight::from_ref_time(62_440_000) // Standard Error: 38_000 - .saturating_add((242_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(RocksDbWeight::get().reads(10 as Weight)) - .saturating_add(RocksDbWeight::get().writes(6 as Weight)) + .saturating_add(Weight::from_ref_time(242_000).saturating_mul(v as u64)) + .saturating_add(RocksDbWeight::get().reads(10)) + .saturating_add(RocksDbWeight::get().writes(6)) } // Storage: Summary Roots (r:1 w:1) // Storage: Avn Validators (r:1 w:0) @@ -309,15 +309,15 @@ impl WeightInfo for () { /// The range of component `v` is `[3, 10]`. /// The range of component `o` is `[1, 2]`. fn approve_root_with_end_voting(v: u32, o: u32, ) -> Weight { - (202_079_000 as Weight) + Weight::from_ref_time(202_079_000) // Standard Error: 268_000 - .saturating_add((1_240_000 as Weight).saturating_mul(v as Weight)) + .saturating_add(Weight::from_ref_time(1_240_000).saturating_mul(v as u64)) // Standard Error: 2_224_000 - .saturating_add((19_374_000 as Weight).saturating_mul(o as Weight)) - .saturating_add(RocksDbWeight::get().reads(11 as Weight)) - .saturating_add(RocksDbWeight::get().reads((2 as Weight).saturating_mul(o as Weight))) - .saturating_add(RocksDbWeight::get().writes(7 as Weight)) - .saturating_add(RocksDbWeight::get().writes((2 as Weight).saturating_mul(o as Weight))) + .saturating_add(Weight::from_ref_time(19_374_000).saturating_mul(o as u64)) + .saturating_add(RocksDbWeight::get().reads(11)) + .saturating_add(RocksDbWeight::get().reads(2).saturating_mul(o as u64)) + .saturating_add(RocksDbWeight::get().writes(7)) + .saturating_add(RocksDbWeight::get().writes(2).saturating_mul(o as u64)) } // Storage: Summary Roots (r:1 w:0) // Storage: Avn Validators (r:1 w:0) @@ -327,11 +327,11 @@ impl WeightInfo for () { // Storage: AvnFinalityTracker LatestFinalisedBlock (r:1 w:0) /// The range of component `v` is `[3, 10]`. fn approve_root_without_end_voting(v: u32, ) -> Weight { - (124_198_000 as Weight) + Weight::from_ref_time(124_198_000) // Standard Error: 67_000 - .saturating_add((508_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(RocksDbWeight::get().reads(6 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(508_000).saturating_mul(v as u64)) + .saturating_add(RocksDbWeight::get().reads(6)) + .saturating_add(RocksDbWeight::get().writes(1)) } // Storage: Avn Validators (r:1 w:0) // Storage: Summary VotesRepository (r:1 w:1) @@ -347,15 +347,15 @@ impl WeightInfo for () { /// The range of component `v` is `[3, 10]`. /// The range of component `o` is `[1, 2]`. fn reject_root_with_end_voting(v: u32, o: u32, ) -> Weight { - (146_663_000 as Weight) + Weight::from_ref_time(146_663_000) // Standard Error: 126_000 - .saturating_add((1_208_000 as Weight).saturating_mul(v as Weight)) + .saturating_add(Weight::from_ref_time(1_208_000).saturating_mul(v as u64)) // Standard Error: 1_049_000 - .saturating_add((20_910_000 as Weight).saturating_mul(o as Weight)) - .saturating_add(RocksDbWeight::get().reads(11 as Weight)) - .saturating_add(RocksDbWeight::get().reads((2 as Weight).saturating_mul(o as Weight))) - .saturating_add(RocksDbWeight::get().writes(6 as Weight)) - .saturating_add(RocksDbWeight::get().writes((2 as Weight).saturating_mul(o as Weight))) + .saturating_add(Weight::from_ref_time(20_910_000).saturating_mul(o as u64)) + .saturating_add(RocksDbWeight::get().reads(11)) + .saturating_add(RocksDbWeight::get().reads(2).saturating_mul(o as u64)) + .saturating_add(RocksDbWeight::get().writes(6)) + .saturating_add(RocksDbWeight::get().writes(2).saturating_mul(o as u64)) } // Storage: Avn Validators (r:1 w:0) // Storage: Summary VotesRepository (r:1 w:1) @@ -364,11 +364,11 @@ impl WeightInfo for () { // Storage: AvnFinalityTracker LatestFinalisedBlock (r:1 w:0) /// The range of component `v` is `[3, 10]`. fn reject_root_without_end_voting(v: u32, ) -> Weight { - (53_317_000 as Weight) + Weight::from_ref_time(53_317_000) // Standard Error: 18_000 - .saturating_add((146_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(146_000).saturating_mul(v as u64)) + .saturating_add(RocksDbWeight::get().reads(5)) + .saturating_add(RocksDbWeight::get().writes(1)) } // Storage: Summary VotesRepository (r:1 w:0) // Storage: Summary Roots (r:1 w:1) @@ -386,13 +386,13 @@ impl WeightInfo for () { // Storage: Summary NextBlockToProcess (r:0 w:1) /// The range of component `o` is `[1, 2]`. fn end_voting_period_with_rejected_valid_votes(o: u32, ) -> Weight { - (92_154_000 as Weight) + Weight::from_ref_time(92_154_000) // Standard Error: 617_000 - .saturating_add((15_202_000 as Weight).saturating_mul(o as Weight)) - .saturating_add(RocksDbWeight::get().reads(10 as Weight)) - .saturating_add(RocksDbWeight::get().reads((2 as Weight).saturating_mul(o as Weight))) - .saturating_add(RocksDbWeight::get().writes(6 as Weight)) - .saturating_add(RocksDbWeight::get().writes((2 as Weight).saturating_mul(o as Weight))) + .saturating_add(Weight::from_ref_time(15_202_000).saturating_mul(o as u64)) + .saturating_add(RocksDbWeight::get().reads(10)) + .saturating_add(RocksDbWeight::get().reads(2).saturating_mul(o as u64)) + .saturating_add(RocksDbWeight::get().writes(6)) + .saturating_add(RocksDbWeight::get().writes(2).saturating_mul(o as u64)) } // Storage: Summary VotesRepository (r:1 w:0) // Storage: Summary Roots (r:1 w:0) @@ -407,13 +407,13 @@ impl WeightInfo for () { // Storage: AvnOffenceHandler SlashingEnabled (r:1 w:0) /// The range of component `o` is `[1, 2]`. fn end_voting_period_with_approved_invalid_votes(o: u32, ) -> Weight { - (117_661_000 as Weight) + Weight::from_ref_time(117_661_000) // Standard Error: 1_307_000 - .saturating_add((17_536_000 as Weight).saturating_mul(o as Weight)) - .saturating_add(RocksDbWeight::get().reads(11 as Weight)) - .saturating_add(RocksDbWeight::get().reads((2 as Weight).saturating_mul(o as Weight))) - .saturating_add(RocksDbWeight::get().writes(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes((2 as Weight).saturating_mul(o as Weight))) + .saturating_add(Weight::from_ref_time(17_536_000).saturating_mul(o as u64)) + .saturating_add(RocksDbWeight::get().reads(11)) + .saturating_add(RocksDbWeight::get().reads(2).saturating_mul(o as u64)) + .saturating_add(RocksDbWeight::get().writes(5)) + .saturating_add(RocksDbWeight::get().writes(2).saturating_mul(o as u64)) } // Storage: Summary NextSlotAtBlock (r:1 w:1) // Storage: Summary CurrentSlotsValidator (r:1 w:1) @@ -428,9 +428,9 @@ impl WeightInfo for () { // Storage: AvnOffenceHandler SlashingEnabled (r:1 w:0) // Storage: Summary SchedulePeriod (r:1 w:0) fn advance_slot_with_offence() -> Weight { - (93_875_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(12 as Weight)) - .saturating_add(RocksDbWeight::get().writes(7 as Weight)) + Weight::from_ref_time(93_875_000) + .saturating_add(RocksDbWeight::get().reads(12)) + .saturating_add(RocksDbWeight::get().writes(7)) } // Storage: Summary NextSlotAtBlock (r:1 w:1) // Storage: Summary CurrentSlotsValidator (r:1 w:1) @@ -439,9 +439,9 @@ impl WeightInfo for () { // Storage: Avn Validators (r:1 w:0) // Storage: Summary SchedulePeriod (r:1 w:0) fn advance_slot_without_offence() -> Weight { - (38_122_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(6 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(38_122_000) + .saturating_add(RocksDbWeight::get().reads(6)) + .saturating_add(RocksDbWeight::get().writes(3)) } // Storage: Summary CurrentSlot (r:1 w:1) // Storage: Summary CurrentSlotsValidator (r:1 w:1) @@ -456,8 +456,8 @@ impl WeightInfo for () { // Storage: Summary SlotOfLastPublishedSummary (r:1 w:0) // Storage: Summary SchedulePeriod (r:1 w:0) fn add_challenge() -> Weight { - (103_435_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(12 as Weight)) - .saturating_add(RocksDbWeight::get().writes(7 as Weight)) + Weight::from_ref_time(103_435_000) + .saturating_add(RocksDbWeight::get().reads(12)) + .saturating_add(RocksDbWeight::get().writes(7)) } } \ No newline at end of file diff --git a/pallets/summary/src/lib.rs b/pallets/summary/src/lib.rs index 940b88b0e..04aeecacf 100644 --- a/pallets/summary/src/lib.rs +++ b/pallets/summary/src/lib.rs @@ -103,9 +103,9 @@ pub mod pallet { + avn::Config + pallet_session::historical::Config { - type Event: From> - + Into<::Event> - + IsType<::Event>; + type RuntimeEvent: From> + + Into<::RuntimeEvent> + + IsType<::RuntimeEvent>; /// A period (in block number) to detect when a validator failed to advance the current slot /// number @@ -365,6 +365,7 @@ pub mod pallet { #[pallet::call] impl Pallet { #[pallet::weight( ::WeightInfo::set_periods())] + #[pallet::call_index(0)] pub fn set_periods( origin: OriginFor, schedule_period_in_blocks: T::BlockNumber, @@ -394,6 +395,7 @@ pub mod pallet { MAX_VALIDATOR_ACCOUNT_IDS, MAX_NUMBER_OF_ROOT_DATA_PER_RANGE ))] + #[pallet::call_index(1)] pub fn record_summary_calculation( origin: OriginFor, new_block_number: T::BlockNumber, @@ -467,6 +469,7 @@ pub mod pallet { #[pallet::weight( ::WeightInfo::approve_root_with_end_voting(MAX_VALIDATOR_ACCOUNT_IDS, MAX_OFFENDERS).max( ::WeightInfo::approve_root_without_end_voting(MAX_VALIDATOR_ACCOUNT_IDS) ))] + #[pallet::call_index(2)] pub fn approve_root( origin: OriginFor, root_id: RootId, @@ -508,6 +511,7 @@ pub mod pallet { #[pallet::weight( ::WeightInfo::reject_root_with_end_voting(MAX_VALIDATOR_ACCOUNT_IDS, MAX_OFFENDERS).max( ::WeightInfo::reject_root_without_end_voting(MAX_VALIDATOR_ACCOUNT_IDS) ))] + #[pallet::call_index(3)] pub fn reject_root( origin: OriginFor, root_id: RootId, @@ -530,6 +534,7 @@ pub mod pallet { #[pallet::weight( ::WeightInfo::end_voting_period_with_rejected_valid_votes(MAX_OFFENDERS).max( ::WeightInfo::end_voting_period_with_approved_invalid_votes(MAX_OFFENDERS) ))] + #[pallet::call_index(4)] pub fn end_voting_period( origin: OriginFor, root_id: RootId, @@ -548,6 +553,7 @@ pub mod pallet { #[pallet::weight( ::WeightInfo::advance_slot_with_offence().max( ::WeightInfo::advance_slot_without_offence() ))] + #[pallet::call_index(5)] pub fn advance_slot( origin: OriginFor, validator: Validator<::AuthorityId, T::AccountId>, @@ -562,6 +568,7 @@ pub mod pallet { } #[pallet::weight( ::WeightInfo::add_challenge())] + #[pallet::call_index(6)] pub fn add_challenge( origin: OriginFor, challenge: SummaryChallenge, @@ -665,7 +672,7 @@ pub mod pallet { )); } - return T::DbWeight::get().writes(weight_write_counter as Weight) + return T::DbWeight::get().writes(weight_write_counter as u64) } } @@ -721,630 +728,645 @@ pub mod pallet { } } } -} - -impl Pallet { - fn validate_schedule_period(schedule_period_in_blocks: T::BlockNumber) -> DispatchResult { - ensure!( - schedule_period_in_blocks >= MIN_SCHEDULE_PERIOD.into(), - Error::::SchedulePeriodIsTooShort - ); - - Ok(()) - } + impl Pallet { + fn validate_schedule_period(schedule_period_in_blocks: T::BlockNumber) -> DispatchResult { + ensure!( + schedule_period_in_blocks >= MIN_SCHEDULE_PERIOD.into(), + Error::::SchedulePeriodIsTooShort + ); - fn validate_voting_period( - voting_period_in_blocks: T::BlockNumber, - schedule_period_in_blocks: T::BlockNumber, - ) -> DispatchResult { - ensure!( - voting_period_in_blocks >= T::FinalityReportLatency::get(), - Error::::VotingPeriodIsLessThanFinalityReportLatency - ); - ensure!( - voting_period_in_blocks >= MIN_VOTING_PERIOD.into(), - Error::::VotingPeriodIsTooShort - ); - ensure!( - voting_period_in_blocks < schedule_period_in_blocks, - Error::::VotingPeriodIsEqualOrLongerThanSchedulePeriod - ); - ensure!( - voting_period_in_blocks <= MAX_VOTING_PERIOD.into(), - Error::::VotingPeriodIsTooLong - ); - Ok(()) - } + Ok(()) + } - pub fn grace_period_elapsed(block_number: T::BlockNumber) -> bool { - let diff = safe_sub_block_numbers::( - block_number, - Self::block_number_for_next_slot(), - ) - .unwrap_or(0u32.into()); - return diff > T::AdvanceSlotGracePeriod::get() - } + fn validate_voting_period( + voting_period_in_blocks: T::BlockNumber, + schedule_period_in_blocks: T::BlockNumber, + ) -> DispatchResult { + ensure!( + voting_period_in_blocks >= T::FinalityReportLatency::get(), + Error::::VotingPeriodIsLessThanFinalityReportLatency + ); + ensure!( + voting_period_in_blocks >= MIN_VOTING_PERIOD.into(), + Error::::VotingPeriodIsTooShort + ); + ensure!( + voting_period_in_blocks < schedule_period_in_blocks, + Error::::VotingPeriodIsEqualOrLongerThanSchedulePeriod + ); + ensure!( + voting_period_in_blocks <= MAX_VOTING_PERIOD.into(), + Error::::VotingPeriodIsTooLong + ); + Ok(()) + } - // Check if this validator is allowed - // the slot's validator is challenged if it does not advance the slot inside the challenge - // window. But this challenge will be checked later than when it was submitted, so it is - // possible storage has changed by then. To prevent the validator escape the challenge, we - // can allow it this change only inside the challenge window. Other validators can however - // move the slot after the challenge window. - pub fn validator_can_advance_slot( - validator: &Validator<::AuthorityId, T::AccountId>, - ) -> DispatchResult { - let current_block_number = >::block_number(); - ensure!( - current_block_number >= Self::block_number_for_next_slot(), - Error::::TooEarlyToAdvance - ); - - let current_slot_validator = - Self::slot_validator().ok_or(Error::::CurrentSlotValidatorNotFound)?; - - if Self::grace_period_elapsed(current_block_number) { - if validator.account_id == current_slot_validator { - return Err(Error::::GracePeriodElapsed)? - } - } else { - if validator.account_id != current_slot_validator { - return Err(Error::::WrongValidator)? - } + pub fn grace_period_elapsed(block_number: T::BlockNumber) -> bool { + let diff = safe_sub_block_numbers::( + block_number, + Self::block_number_for_next_slot(), + ) + .unwrap_or(0u32.into()); + return diff > T::AdvanceSlotGracePeriod::get() } - Ok(()) - } + // Check if this validator is allowed + // the slot's validator is challenged if it does not advance the slot inside the challenge + // window. But this challenge will be checked later than when it was submitted, so it is + // possible storage has changed by then. To prevent the validator escape the challenge, we + // can allow it this change only inside the challenge window. Other validators can however + // move the slot after the challenge window. + pub fn validator_can_advance_slot( + validator: &Validator<::AuthorityId, T::AccountId>, + ) -> DispatchResult { + let current_block_number = >::block_number(); + ensure!( + current_block_number >= Self::block_number_for_next_slot(), + Error::::TooEarlyToAdvance + ); - pub fn update_slot_number( - validator: Validator<::AuthorityId, T::AccountId>, - ) -> DispatchResult { - Self::validator_can_advance_slot(&validator)?; - // QUESTION: should we slash a validator who tries to advance the slot when it is not their - // turn? This code is always called inside an unsigned transaction, so in consensus. - // We can raise offences here. - Self::register_offence_if_no_summary_created_in_slot(&validator); - - let new_slot_number = - safe_add_block_numbers::(Self::current_slot(), 1u32.into()) - .map_err(|_| Error::::Overflow)?; - - let new_validator_account_id = AVN::::calculate_primary_validator(new_slot_number)?; - - let next_slot_start_block = safe_add_block_numbers::( - Self::block_number_for_next_slot(), - Self::schedule_period(), - ) - .map_err(|_| Error::::Overflow)?; - - >::put(new_slot_number); - >::put(new_validator_account_id.clone()); - >::put(next_slot_start_block); - - Self::deposit_event(Event::::SlotAdvanced { - advanced_by: validator.account_id, - new_slot: new_slot_number, - slot_validator: new_validator_account_id, - slot_end: next_slot_start_block, - }); - - Ok(()) - } + let current_slot_validator = + Self::slot_validator().ok_or(Error::::CurrentSlotValidatorNotFound)?; - pub fn get_root_voting_session( - root_id: &RootId, - ) -> Box> { - return Box::new(RootVotingSession::::new(root_id)) - as Box> - } + if Self::grace_period_elapsed(current_block_number) { + if validator.account_id == current_slot_validator { + return Err(Error::::GracePeriodElapsed)? + } + } else { + if validator.account_id != current_slot_validator { + return Err(Error::::WrongValidator)? + } + } - // This can be called by other validators to verify the root hash - pub fn compute_root_hash( - from_block: T::BlockNumber, - to_block: T::BlockNumber, - ) -> Result { - let from_block_number: u32 = TryInto::::try_into(from_block) - .map_err(|_| Error::::ErrorConvertingBlockNumber)?; - let to_block_number: u32 = TryInto::::try_into(to_block) - .map_err(|_| Error::::ErrorConvertingBlockNumber)?; - - let mut url_path = "roothash/".to_string(); - url_path.push_str(&from_block_number.to_string()); - url_path.push_str(&"/".to_string()); - url_path.push_str(&to_block_number.to_string()); - - let response = AVN::::get_data_from_service(url_path); - - if let Err(e) = response { - log::error!("💔️ Error getting summary data from external service: {:?}", e); - return Err(Error::::ErrorGettingSummaryDataFromService)? + Ok(()) } - let root_hash = Self::validate_response(response.expect("checked for error"))?; - log::trace!(target: "avn", "🥽 Calculated root hash {:?} for range [{:?}, {:?}]", &root_hash, &from_block_number, &to_block_number); - - return Ok(root_hash) - } + pub fn update_slot_number( + validator: Validator<::AuthorityId, T::AccountId>, + ) -> DispatchResult { + Self::validator_can_advance_slot(&validator)?; + // QUESTION: should we slash a validator who tries to advance the slot when it is not + // their turn? This code is always called inside an unsigned transaction, so + // in consensus. We can raise offences here. + Self::register_offence_if_no_summary_created_in_slot(&validator); + + let new_slot_number = + safe_add_block_numbers::(Self::current_slot(), 1u32.into()) + .map_err(|_| Error::::Overflow)?; - fn create_root_lock_name(block_number: T::BlockNumber) -> OcwLock::PersistentId { - let mut name = b"create_summary::".to_vec(); - name.extend_from_slice(&mut block_number.encode()); - name - } + let new_validator_account_id = AVN::::calculate_primary_validator(new_slot_number)?; - pub fn convert_data_to_eth_compatible_encoding( - root_data: &RootData, - ) -> Result { - let eth_description = EthAbiHelper::generate_ethereum_description_for_signature_request( - &T::AccountToBytesConvert::into_bytes( - root_data.added_by.as_ref().ok_or(Error::::CurrentSlotValidatorNotFound)?, - ), - &EthTransactionType::PublishRoot(PublishRootData::new( - *root_data.root_hash.as_fixed_bytes(), - )), - match root_data.tx_id { - None => EMPTY_ROOT_TRANSACTION_ID, - _ => *root_data - .tx_id - .as_ref() - .expect("Non-Empty roots have a reserved TransactionId"), - }, - ) - .map_err(|_| Error::::InvalidRoot)?; - - Ok(hex::encode(EthAbiHelper::generate_eth_abi_encoding_for_params_only(ð_description))) - } + let next_slot_start_block = safe_add_block_numbers::( + Self::block_number_for_next_slot(), + Self::schedule_period(), + ) + .map_err(|_| Error::::Overflow)?; - pub fn sign_root_for_ethereum( - root_id: &RootId, - ) -> Result<(String, ecdsa::Signature), DispatchError> { - let root_data = Self::try_get_root_data(&root_id)?; - let data = Self::convert_data_to_eth_compatible_encoding(&root_data)?; - return Ok((data.clone(), AVN::::request_ecdsa_signature_from_external_service(&data)?)) - } + >::put(new_slot_number); + >::put(new_validator_account_id.clone()); + >::put(next_slot_start_block); - // TODO [Low Priority] Review if the lock period should be configurable - fn lock_till_request_expires() -> OcwOperationExpiration { - let avn_service_expiry_in_millisec = 300_000 as u32; - let avn_block_generation_in_millisec = 3_000 as u32; - let delay = 10 as u32; - let lock_expiration_in_blocks = - avn_service_expiry_in_millisec / avn_block_generation_in_millisec + delay; - return OcwOperationExpiration::Custom(lock_expiration_in_blocks) - } + Self::deposit_event(Event::::SlotAdvanced { + advanced_by: validator.account_id, + new_slot: new_slot_number, + slot_validator: new_validator_account_id, + slot_end: next_slot_start_block, + }); - fn advance_slot_if_required( - block_number: T::BlockNumber, - this_validator: &Validator<::AuthorityId, T::AccountId>, - ) { - let current_slot_validator = Self::slot_validator(); - if current_slot_validator.is_none() { - log::error!( - "💔 Current slot validator is not found. Cannot advance slot for block: {:?}", - block_number - ); - return + Ok(()) } - if this_validator.account_id == current_slot_validator.expect("Checked for none") && - block_number >= Self::block_number_for_next_slot() - { - let result = Self::dispatch_advance_slot(this_validator); + pub fn get_root_voting_session( + root_id: &RootId, + ) -> Box> { + return Box::new(RootVotingSession::::new(root_id)) + as Box> + } - if let Err(e) = result { - log::warn!("💔️ Error starting a new summary creation slot: {:?}", e); + // This can be called by other validators to verify the root hash + pub fn compute_root_hash( + from_block: T::BlockNumber, + to_block: T::BlockNumber, + ) -> Result { + let from_block_number: u32 = TryInto::::try_into(from_block) + .map_err(|_| Error::::ErrorConvertingBlockNumber)?; + let to_block_number: u32 = TryInto::::try_into(to_block) + .map_err(|_| Error::::ErrorConvertingBlockNumber)?; + + let mut url_path = "roothash/".to_string(); + url_path.push_str(&from_block_number.to_string()); + url_path.push_str(&"/".to_string()); + url_path.push_str(&to_block_number.to_string()); + + let response = AVN::::get_data_from_service(url_path); + + if let Err(e) = response { + log::error!("💔️ Error getting summary data from external service: {:?}", e); + return Err(Error::::ErrorGettingSummaryDataFromService)? } + + let root_hash = Self::validate_response(response.expect("checked for error"))?; + log::trace!(target: "avn", "🥽 Calculated root hash {:?} for range [{:?}, {:?}]", &root_hash, &from_block_number, &to_block_number); + + return Ok(root_hash) } - } - // called from OCW - no storage changes allowed here - fn process_summary_if_required( - block_number: T::BlockNumber, - this_validator: &Validator<::AuthorityId, T::AccountId>, - ) { - let target_block = Self::get_target_block(); - if target_block.is_err() { - log::error!("💔️ Error getting target block."); - return + pub fn create_root_lock_name(block_number: T::BlockNumber) -> OcwLock::PersistentId { + let mut name = b"create_summary::".to_vec(); + name.extend_from_slice(&mut block_number.encode()); + name } - let last_block_in_range = target_block.expect("Valid block number"); - let root_lock_name = Self::create_root_lock_name(last_block_in_range); - let expiration = Self::lock_till_request_expires(); + pub fn convert_data_to_eth_compatible_encoding( + root_data: &RootData, + ) -> Result { + let eth_description = + EthAbiHelper::generate_ethereum_description_for_signature_request( + &T::AccountToBytesConvert::into_bytes( + root_data + .added_by + .as_ref() + .ok_or(Error::::CurrentSlotValidatorNotFound)?, + ), + &EthTransactionType::PublishRoot(PublishRootData::new( + *root_data.root_hash.as_fixed_bytes(), + )), + match root_data.tx_id { + None => EMPTY_ROOT_TRANSACTION_ID, + _ => *root_data + .tx_id + .as_ref() + .expect("Non-Empty roots have a reserved TransactionId"), + }, + ) + .map_err(|_| Error::::InvalidRoot)?; - if Self::can_process_summary(block_number, last_block_in_range, this_validator) && - OcwLock::set_lock_with_expiry(block_number, expiration, root_lock_name.clone()) - .is_ok() - { - log::warn!( - "ℹ️ Processing summary for range {:?} - {:?}. Slot {:?}", - Self::get_next_block_to_process(), - last_block_in_range, - Self::current_slot() - ); + Ok(hex::encode(EthAbiHelper::generate_eth_abi_encoding_for_params_only( + ð_description, + ))) + } - let summary = Self::process_summary(last_block_in_range, this_validator); + pub fn sign_root_for_ethereum( + root_id: &RootId, + ) -> Result<(String, ecdsa::Signature), DispatchError> { + let root_data = Self::try_get_root_data(&root_id)?; + let data = Self::convert_data_to_eth_compatible_encoding(&root_data)?; + return Ok(( + data.clone(), + AVN::::request_ecdsa_signature_from_external_service(&data)?, + )) + } + + // TODO [Low Priority] Review if the lock period should be configurable + pub fn lock_till_request_expires() -> OcwOperationExpiration { + let avn_service_expiry_in_millisec = 300_000 as u32; + let avn_block_generation_in_millisec = 3_000 as u32; + let delay = 10 as u32; + let lock_expiration_in_blocks = + avn_service_expiry_in_millisec / avn_block_generation_in_millisec + delay; + return OcwOperationExpiration::Custom(lock_expiration_in_blocks) + } - if let Err(e) = summary { - log::warn!("💔️ Error processing summary: {:?}", e); + pub fn advance_slot_if_required( + block_number: T::BlockNumber, + this_validator: &Validator<::AuthorityId, T::AccountId>, + ) { + let current_slot_validator = Self::slot_validator(); + if current_slot_validator.is_none() { + log::error!( + "💔 Current slot validator is not found. Cannot advance slot for block: {:?}", + block_number + ); + return } - // Ignore the remove storage lock error as the lock will be unlocked after the - // expiration period - match OcwLock::remove_storage_lock(block_number, expiration, root_lock_name) { - Ok(_) => {}, - Err(e) => { - log::warn!("💔️ Error removing root lock: {:?}", e); - }, + if this_validator.account_id == current_slot_validator.expect("Checked for none") && + block_number >= Self::block_number_for_next_slot() + { + let result = Self::dispatch_advance_slot(this_validator); + + if let Err(e) = result { + log::warn!("💔️ Error starting a new summary creation slot: {:?}", e); + } } } - } - fn register_offence_if_no_summary_created_in_slot( - reporter: &Validator, - ) { - if Self::last_summary_slot() < Self::current_slot() { - let maybe_current_slot_validator = Self::slot_validator(); - if maybe_current_slot_validator.is_none() { - log::error!("💔 Current slot validator is not found. Unable to register offence"); + // called from OCW - no storage changes allowed here + pub fn process_summary_if_required( + block_number: T::BlockNumber, + this_validator: &Validator<::AuthorityId, T::AccountId>, + ) { + let target_block = Self::get_target_block(); + if target_block.is_err() { + log::error!("💔️ Error getting target block."); return } - let current_slot_validator = maybe_current_slot_validator.expect("Checked for none"); + let last_block_in_range = target_block.expect("Valid block number"); - create_and_report_summary_offence::( - &reporter.account_id, - &vec![current_slot_validator.clone()], - SummaryOffenceType::NoSummaryCreated, - ); + let root_lock_name = Self::create_root_lock_name(last_block_in_range); + let expiration = Self::lock_till_request_expires(); - Self::deposit_event(Event::::SummaryNotPublishedOffence { - challengee: current_slot_validator, - void_slot: Self::current_slot(), - last_published: Self::last_summary_slot(), - end_vote: Self::block_number_for_next_slot(), - }); - } - } + if Self::can_process_summary(block_number, last_block_in_range, this_validator) && + OcwLock::set_lock_with_expiry(block_number, expiration, root_lock_name.clone()) + .is_ok() + { + log::warn!( + "ℹ️ Processing summary for range {:?} - {:?}. Slot {:?}", + Self::get_next_block_to_process(), + last_block_in_range, + Self::current_slot() + ); - // called from OCW - no storage changes allowed here - fn can_process_summary( - current_block_number: T::BlockNumber, - last_block_in_range: T::BlockNumber, - this_validator: &Validator<::AuthorityId, T::AccountId>, - ) -> bool { - if OcwLock::is_locked(&Self::create_root_lock_name(last_block_in_range)) { - return false + let summary = Self::process_summary(last_block_in_range, this_validator); + + if let Err(e) = summary { + log::warn!("💔️ Error processing summary: {:?}", e); + } + + // Ignore the remove storage lock error as the lock will be unlocked after the + // expiration period + match OcwLock::remove_storage_lock(block_number, expiration, root_lock_name) { + Ok(_) => {}, + Err(e) => { + log::warn!("💔️ Error removing root lock: {:?}", e); + }, + } + } } - let target_block_with_buffer = - safe_add_block_numbers(last_block_in_range, T::MinBlockAge::get()); + fn register_offence_if_no_summary_created_in_slot( + reporter: &Validator, + ) { + if Self::last_summary_slot() < Self::current_slot() { + let maybe_current_slot_validator = Self::slot_validator(); + if maybe_current_slot_validator.is_none() { + log::error!( + "💔 Current slot validator is not found. Unable to register offence" + ); + return + } + let current_slot_validator = + maybe_current_slot_validator.expect("Checked for none"); - if target_block_with_buffer.is_err() { - log::warn!( - "💔️ Error checking if we can process a summary for blocks {:?} to {:?}", - current_block_number, - last_block_in_range - ); + create_and_report_summary_offence::( + &reporter.account_id, + &vec![current_slot_validator.clone()], + SummaryOffenceType::NoSummaryCreated, + ); - return false + Self::deposit_event(Event::::SummaryNotPublishedOffence { + challengee: current_slot_validator, + void_slot: Self::current_slot(), + last_published: Self::last_summary_slot(), + end_vote: Self::block_number_for_next_slot(), + }); + } } - let target_block_with_buffer = target_block_with_buffer.expect("Already checked"); - let root_range = RootRange::new(Self::get_next_block_to_process(), last_block_in_range); + // called from OCW - no storage changes allowed here + fn can_process_summary( + current_block_number: T::BlockNumber, + last_block_in_range: T::BlockNumber, + this_validator: &Validator<::AuthorityId, T::AccountId>, + ) -> bool { + if OcwLock::is_locked(&Self::create_root_lock_name(last_block_in_range)) { + return false + } - let current_slot_validator = Self::slot_validator(); - let is_slot_validator = current_slot_validator.is_some() && - this_validator.account_id == current_slot_validator.expect("checked for none"); - let slot_is_active = current_block_number < Self::block_number_for_next_slot(); - let blocks_are_old_enough = current_block_number > target_block_with_buffer; + let target_block_with_buffer = + safe_add_block_numbers(last_block_in_range, T::MinBlockAge::get()); - return is_slot_validator && - slot_is_active && - blocks_are_old_enough && - Self::summary_is_neither_pending_nor_approved(&root_range) - } + if target_block_with_buffer.is_err() { + log::warn!( + "💔️ Error checking if we can process a summary for blocks {:?} to {:?}", + current_block_number, + last_block_in_range + ); - // called from OCW - no storage changes allowed here - fn process_summary( - last_block_in_range: T::BlockNumber, - validator: &Validator<::AuthorityId, T::AccountId>, - ) -> DispatchResult { - let root_hash = - Self::compute_root_hash(Self::get_next_block_to_process(), last_block_in_range)?; - Self::record_summary(last_block_in_range, root_hash, validator)?; + return false + } + let target_block_with_buffer = target_block_with_buffer.expect("Already checked"); - Ok(()) - } + let root_range = RootRange::new(Self::get_next_block_to_process(), last_block_in_range); - // called from OCW - no storage changes allowed here - fn record_summary( - last_processed_block_number: T::BlockNumber, - root_hash: H256, - validator: &Validator<::AuthorityId, T::AccountId>, - ) -> DispatchResult { - let ingress_counter = Self::get_ingress_counter() + 1; // default value in storage is 0, so first root_hash has counter 1 - - let signature = validator - .key - .sign( - &( - UPDATE_BLOCK_NUMBER_CONTEXT, + let current_slot_validator = Self::slot_validator(); + let is_slot_validator = current_slot_validator.is_some() && + this_validator.account_id == current_slot_validator.expect("checked for none"); + let slot_is_active = current_block_number < Self::block_number_for_next_slot(); + let blocks_are_old_enough = current_block_number > target_block_with_buffer; + + return is_slot_validator && + slot_is_active && + blocks_are_old_enough && + Self::summary_is_neither_pending_nor_approved(&root_range) + } + + // called from OCW - no storage changes allowed here + pub fn process_summary( + last_block_in_range: T::BlockNumber, + validator: &Validator<::AuthorityId, T::AccountId>, + ) -> DispatchResult { + let root_hash = + Self::compute_root_hash(Self::get_next_block_to_process(), last_block_in_range)?; + Self::record_summary(last_block_in_range, root_hash, validator)?; + + Ok(()) + } + + // called from OCW - no storage changes allowed here + fn record_summary( + last_processed_block_number: T::BlockNumber, + root_hash: H256, + validator: &Validator<::AuthorityId, T::AccountId>, + ) -> DispatchResult { + let ingress_counter = Self::get_ingress_counter() + 1; // default value in storage is 0, so first root_hash has counter 1 + + let signature = validator + .key + .sign( + &( + UPDATE_BLOCK_NUMBER_CONTEXT, + root_hash, + ingress_counter, + last_processed_block_number, + ) + .encode(), + ) + .ok_or(Error::::ErrorSigning)?; + + log::trace!( + target: "avn", + "🖊️ Worker records summary calculation: {:?} last processed block {:?} ingress: {:?}]", + &root_hash, + &last_processed_block_number, + &ingress_counter + ); + + SubmitTransaction::>::submit_unsigned_transaction( + Call::record_summary_calculation { + new_block_number: last_processed_block_number, root_hash, ingress_counter, - last_processed_block_number, - ) - .encode(), + validator: validator.clone(), + signature, + } + .into(), ) - .ok_or(Error::::ErrorSigning)?; - - log::trace!( - target: "avn", - "🖊️ Worker records summary calculation: {:?} last processed block {:?} ingress: {:?}]", - &root_hash, - &last_processed_block_number, - &ingress_counter - ); - - SubmitTransaction::>::submit_unsigned_transaction( - Call::record_summary_calculation { - new_block_number: last_processed_block_number, - root_hash, - ingress_counter, - validator: validator.clone(), - signature, - } - .into(), - ) - .map_err(|_| Error::::ErrorSubmittingTransaction)?; - - Ok(()) - } - - fn dispatch_advance_slot( - validator: &Validator<::AuthorityId, T::AccountId>, - ) -> DispatchResult { - let signature = validator - .key - .sign(&(ADVANCE_SLOT_CONTEXT, Self::current_slot()).encode()) - .ok_or(Error::::ErrorSigning)?; + .map_err(|_| Error::::ErrorSubmittingTransaction)?; - SubmitTransaction::>::submit_unsigned_transaction( - Call::advance_slot { validator: validator.clone(), signature }.into(), - ) - .map_err(|_| Error::::ErrorSubmittingTransaction)?; + Ok(()) + } - Ok(()) - } + fn dispatch_advance_slot( + validator: &Validator<::AuthorityId, T::AccountId>, + ) -> DispatchResult { + let signature = validator + .key + .sign(&(ADVANCE_SLOT_CONTEXT, Self::current_slot()).encode()) + .ok_or(Error::::ErrorSigning)?; - fn get_target_block() -> Result> { - let end_block_number = safe_add_block_numbers::( - Self::get_next_block_to_process(), - Self::schedule_period(), - ) - .map_err(|_| Error::::Overflow)?; + SubmitTransaction::>::submit_unsigned_transaction( + Call::advance_slot { validator: validator.clone(), signature }.into(), + ) + .map_err(|_| Error::::ErrorSubmittingTransaction)?; - if Self::get_next_block_to_process() == 0u32.into() { - return Ok(end_block_number) + Ok(()) } - Ok(safe_sub_block_numbers::(end_block_number, 1u32.into()) - .map_err(|_| Error::::Overflow)?) - } + pub fn get_target_block() -> Result> { + let end_block_number = safe_add_block_numbers::( + Self::get_next_block_to_process(), + Self::schedule_period(), + ) + .map_err(|_| Error::::Overflow)?; - fn validate_response(response: Vec) -> Result> { - if response.len() != 64 { - log::error!("❌ Root hash is not valid: {:?}", response); - return Err(Error::::InvalidRootHashLength)? - } + if Self::get_next_block_to_process() == 0u32.into() { + return Ok(end_block_number) + } - let root_hash = core::str::from_utf8(&response); - if let Err(e) = root_hash { - log::error!("❌ Error converting root hash bytes to string: {:?}", e); - return Err(Error::::InvalidUTF8Bytes)? + Ok(safe_sub_block_numbers::(end_block_number, 1u32.into()) + .map_err(|_| Error::::Overflow)?) } - let mut data: [u8; 32] = [0; 32]; - hex::decode_to_slice(root_hash.expect("Checked for error"), &mut data[..]) - .map_err(|_| Error::::InvalidHexString)?; + fn validate_response(response: Vec) -> Result> { + if response.len() != 64 { + log::error!("❌ Root hash is not valid: {:?}", response); + return Err(Error::::InvalidRootHashLength)? + } - return Ok(H256::from_slice(&data)) - } + let root_hash = core::str::from_utf8(&response); + if let Err(e) = root_hash { + log::error!("❌ Error converting root hash bytes to string: {:?}", e); + return Err(Error::::InvalidUTF8Bytes)? + } + + let mut data: [u8; 32] = [0; 32]; + hex::decode_to_slice(root_hash.expect("Checked for error"), &mut data[..]) + .map_err(|_| Error::::InvalidHexString)?; - fn end_voting(reporter: T::AccountId, root_id: &RootId) -> DispatchResult { - let voting_session = Self::get_root_voting_session(&root_id); + return Ok(H256::from_slice(&data)) + } - ensure!(voting_session.is_valid(), Error::::VotingSessionIsNotValid); + pub fn end_voting( + reporter: T::AccountId, + root_id: &RootId, + ) -> DispatchResult { + let voting_session = Self::get_root_voting_session(&root_id); - let vote = Self::get_vote(root_id); - ensure!(Self::can_end_vote(&vote), Error::::ErrorEndingVotingPeriod); + ensure!(voting_session.is_valid(), Error::::VotingSessionIsNotValid); - let root_is_approved = vote.is_approved(); + let vote = Self::get_vote(root_id); + ensure!(Self::can_end_vote(&vote), Error::::ErrorEndingVotingPeriod); - let root_data = Self::try_get_root_data(&root_id)?; - if root_is_approved { - if root_data.root_hash != Self::empty_root() { - let result = - T::CandidateTransactionSubmitter::submit_candidate_transaction_to_tier1( - EthTransactionType::PublishRoot(PublishRootData::new( - *root_data.root_hash.as_fixed_bytes(), - )), - *root_data.tx_id.as_ref().expect("Non empty roots have valid hash"), - root_data.added_by.ok_or(Error::::CurrentSlotValidatorNotFound)?, - voting_session.state()?.confirmations, - ); + let root_is_approved = vote.is_approved(); - if let Err(result) = result { - log::error!("❌ Error Submitting Tx: {:?}", result); - Err(result)? + let root_data = Self::try_get_root_data(&root_id)?; + if root_is_approved { + if root_data.root_hash != Self::empty_root() { + let result = + T::CandidateTransactionSubmitter::submit_candidate_transaction_to_tier1( + EthTransactionType::PublishRoot(PublishRootData::new( + *root_data.root_hash.as_fixed_bytes(), + )), + *root_data.tx_id.as_ref().expect("Non empty roots have valid hash"), + root_data.added_by.ok_or(Error::::CurrentSlotValidatorNotFound)?, + voting_session.state()?.confirmations, + ); + + if let Err(result) = result { + log::error!("❌ Error Submitting Tx: {:?}", result); + Err(result)? + } + // There are a couple possible reasons for failure. + // 1. We fail before sending to T1: likely a bug on our part + // 2. Quorum mismatch. There is no guarantee that between accepting a root and + // submitting it to T1, the tier2 session hasn't changed and with it + // the quorum, making ethereum-transactions reject it + // In either case, we should not slash anyone. } - // There are a couple possible reasons for failure. - // 1. We fail before sending to T1: likely a bug on our part - // 2. Quorum mismatch. There is no guarantee that between accepting a root and - // submitting it to T1, the tier2 session hasn't changed and with it - // the quorum, making ethereum-transactions reject it - // In either case, we should not slash anyone. - } - // If we get here, then we did not get an error when submitting to T1. + // If we get here, then we did not get an error when submitting to T1. - create_and_report_summary_offence::( - &reporter, - &vote.nays, - SummaryOffenceType::RejectedValidRoot, - ); + create_and_report_summary_offence::( + &reporter, + &vote.nays, + SummaryOffenceType::RejectedValidRoot, + ); - let next_block_to_process = - safe_add_block_numbers::(root_id.range.to_block, 1u32.into()) - .map_err(|_| Error::::Overflow)?; + let next_block_to_process = + safe_add_block_numbers::(root_id.range.to_block, 1u32.into()) + .map_err(|_| Error::::Overflow)?; + + >::put(next_block_to_process); + >::mutate(root_id.range, root_id.ingress_counter, |root| { + root.is_validated = true + }); + >::put(Self::current_slot()); + + Self::deposit_event(Event::::SummaryRootValidated { + root_hash: root_data.root_hash, + ingress_counter: root_id.ingress_counter, + block_range: root_id.range, + }); + } else { + // We didn't get enough votes to approve this root - >::put(next_block_to_process); - >::mutate(root_id.range, root_id.ingress_counter, |root| { - root.is_validated = true - }); - >::put(Self::current_slot()); + let root_creator = + root_data.added_by.ok_or(Error::::CurrentSlotValidatorNotFound)?; + create_and_report_summary_offence::( + &reporter, + &vec![root_creator], + SummaryOffenceType::CreatedInvalidRoot, + ); - Self::deposit_event(Event::::SummaryRootValidated { - root_hash: root_data.root_hash, - ingress_counter: root_id.ingress_counter, - block_range: root_id.range, - }); - } else { - // We didn't get enough votes to approve this root + create_and_report_summary_offence::( + &reporter, + &vote.ayes, + SummaryOffenceType::ApprovedInvalidRoot, + ); + } - let root_creator = - root_data.added_by.ok_or(Error::::CurrentSlotValidatorNotFound)?; - create_and_report_summary_offence::( - &reporter, - &vec![root_creator], - SummaryOffenceType::CreatedInvalidRoot, - ); + >::remove(root_id.range); + + // When we get here, the root's voting session has ended and it has been removed from + // PendingApproval If the root was approved, it is now marked as validated. + // Otherwise, it stays false. If there was an error when submitting to T1, none of + // this happened and it is still pending and not validated. In either case, the whole + // voting history remains in storage + + // NOTE: when SYS-152 work is added here, root_range could exist several times in the + // voting history, since a root_range that is rejected must eventually be + // submitted again. But at any given time, there should be a single instance + // of root_range in the PendingApproval queue. It is possible to keep + // several instances of root_range in the Roots repository. But that should + // not change the logic in this area: we should still validate an approved + // (root_range, counter) and remove this pair from PendingApproval if no + // errors occur. + + Self::deposit_event(Event::::VotingEnded { + root_id: *root_id, + vote_approved: root_is_approved, + }); - create_and_report_summary_offence::( - &reporter, - &vote.ayes, - SummaryOffenceType::ApprovedInvalidRoot, - ); + Ok(()) } - >::remove(root_id.range); - - // When we get here, the root's voting session has ended and it has been removed from - // PendingApproval If the root was approved, it is now marked as validated. - // Otherwise, it stays false. If there was an error when submitting to T1, none of - // this happened and it is still pending and not validated. In either case, the whole - // voting history remains in storage - - // NOTE: when SYS-152 work is added here, root_range could exist several times in the voting - // history, since a root_range that is rejected must eventually be submitted again. - // But at any given time, there should be a single instance of root_range in the - // PendingApproval queue. It is possible to keep several instances of root_range in - // the Roots repository. But that should not change the logic in this area: we - // should still validate an approved (root_range, counter) and remove this pair from - // PendingApproval if no errors occur. - - Self::deposit_event(Event::::VotingEnded { - root_id: *root_id, - vote_approved: root_is_approved, - }); + fn can_end_vote(vote: &VotingSessionData) -> bool { + return vote.has_outcome() || + >::block_number() >= vote.end_of_voting_period + } - Ok(()) - } + fn record_summary_validate_unsigned( + _source: TransactionSource, + call: &Call, + ) -> TransactionValidity { + if let Call::record_summary_calculation { + new_block_number, + root_hash, + ingress_counter, + validator, + signature, + } = call + { + let current_slot_validator = Self::slot_validator(); + if current_slot_validator.is_none() || + validator.account_id != current_slot_validator.expect("checked for none") + { + return InvalidTransaction::Custom(ERROR_CODE_VALIDATOR_IS_NOT_PRIMARY).into() + } - fn can_end_vote(vote: &VotingSessionData) -> bool { - return vote.has_outcome() || - >::block_number() >= vote.end_of_voting_period - } + let signed_data = + &(UPDATE_BLOCK_NUMBER_CONTEXT, root_hash, ingress_counter, new_block_number); + if !AVN::::signature_is_valid(signed_data, &validator, signature) { + return InvalidTransaction::BadProof.into() + }; - fn record_summary_validate_unsigned( - _source: TransactionSource, - call: &Call, - ) -> TransactionValidity { - if let Call::record_summary_calculation { - new_block_number, - root_hash, - ingress_counter, - validator, - signature, - } = call - { - let current_slot_validator = Self::slot_validator(); - if current_slot_validator.is_none() || - validator.account_id != current_slot_validator.expect("checked for none") - { - return InvalidTransaction::Custom(ERROR_CODE_VALIDATOR_IS_NOT_PRIMARY).into() + return ValidTransaction::with_tag_prefix("Summary") + .priority(TransactionPriority::max_value()) + .and_provides(vec![ + (UPDATE_BLOCK_NUMBER_CONTEXT, root_hash, ingress_counter).encode() + ]) + .longevity(64_u64) + .propagate(true) + .build() } - let signed_data = - &(UPDATE_BLOCK_NUMBER_CONTEXT, root_hash, ingress_counter, new_block_number); - if !AVN::::signature_is_valid(signed_data, &validator, signature) { - return InvalidTransaction::BadProof.into() - }; - - return ValidTransaction::with_tag_prefix("Summary") - .priority(TransactionPriority::max_value()) - .and_provides(vec![ - (UPDATE_BLOCK_NUMBER_CONTEXT, root_hash, ingress_counter).encode() - ]) - .longevity(64_u64) - .propagate(true) - .build() + return InvalidTransaction::Call.into() } - return InvalidTransaction::Call.into() - } + fn advance_slot_validate_unsigned( + _source: TransactionSource, + call: &Call, + ) -> TransactionValidity { + if let Call::advance_slot { validator, signature } = call { + let current_slot_validator = Self::slot_validator(); + if current_slot_validator.is_none() || + validator.account_id != current_slot_validator.expect("checked for none") + { + return InvalidTransaction::Custom(ERROR_CODE_VALIDATOR_IS_NOT_PRIMARY).into() + } - fn advance_slot_validate_unsigned( - _source: TransactionSource, - call: &Call, - ) -> TransactionValidity { - if let Call::advance_slot { validator, signature } = call { - let current_slot_validator = Self::slot_validator(); - if current_slot_validator.is_none() || - validator.account_id != current_slot_validator.expect("checked for none") - { - return InvalidTransaction::Custom(ERROR_CODE_VALIDATOR_IS_NOT_PRIMARY).into() - } + // QUESTION: slash here? If we check the signature validity first, then fail the + // check for slot_validator we would prove someone tried to advance + // the slot outside their turn. Should this be slashable? - // QUESTION: slash here? If we check the signature validity first, then fail the check - // for slot_validator we would prove someone tried to advance the slot - // outside their turn. Should this be slashable? + let current_slot = Self::current_slot(); + let signed_data = &(ADVANCE_SLOT_CONTEXT, current_slot); + if !AVN::::signature_is_valid(signed_data, &validator, signature) { + return InvalidTransaction::BadProof.into() + }; - let current_slot = Self::current_slot(); - let signed_data = &(ADVANCE_SLOT_CONTEXT, current_slot); - if !AVN::::signature_is_valid(signed_data, &validator, signature) { - return InvalidTransaction::BadProof.into() - }; + return ValidTransaction::with_tag_prefix("Summary") + .priority(TransactionPriority::max_value()) + .and_provides(vec![(ADVANCE_SLOT_CONTEXT, current_slot).encode()]) + .longevity(64_u64) + .propagate(true) + .build() + } - return ValidTransaction::with_tag_prefix("Summary") - .priority(TransactionPriority::max_value()) - .and_provides(vec![(ADVANCE_SLOT_CONTEXT, current_slot).encode()]) - .longevity(64_u64) - .propagate(true) - .build() + return InvalidTransaction::Call.into() } - return InvalidTransaction::Call.into() - } + fn empty_root() -> H256 { + return H256::from_slice(&[0; 32]) + } - fn empty_root() -> H256 { - return H256::from_slice(&[0; 32]) - } + fn summary_is_neither_pending_nor_approved(root_range: &RootRange) -> bool { + let has_been_approved = + >::iter_prefix_values(root_range).any(|root| root.is_validated); + let is_pending = >::contains_key(root_range); - fn summary_is_neither_pending_nor_approved(root_range: &RootRange) -> bool { - let has_been_approved = - >::iter_prefix_values(root_range).any(|root| root.is_validated); - let is_pending = >::contains_key(root_range); + return !is_pending && !has_been_approved + } - return !is_pending && !has_been_approved - } + pub fn try_get_root_data( + root_id: &RootId, + ) -> Result, Error> { + if >::contains_key(root_id.range, root_id.ingress_counter) { + return Ok(>::get(root_id.range, root_id.ingress_counter)) + } - fn try_get_root_data( - root_id: &RootId, - ) -> Result, Error> { - if >::contains_key(root_id.range, root_id.ingress_counter) { - return Ok(>::get(root_id.range, root_id.ingress_counter)) + Err(Error::::RootDataNotFound)? } - - Err(Error::::RootDataNotFound)? } } diff --git a/pallets/summary/src/offence.rs b/pallets/summary/src/offence.rs index 3a3f73c36..7966eb58b 100644 --- a/pallets/summary/src/offence.rs +++ b/pallets/summary/src/offence.rs @@ -58,7 +58,7 @@ impl Offence for SummaryOffence { self.session_index } - fn slash_fraction(_offenders: u32, _validator_set_count: u32) -> Perbill { + fn slash_fraction(&self, _offenders: u32) -> Perbill { // We don't implement fraction slashes at the moment. Perbill::from_percent(100) } diff --git a/pallets/summary/src/tests/mock.rs b/pallets/summary/src/tests/mock.rs index b8324d317..9511ae4ac 100644 --- a/pallets/summary/src/tests/mock.rs +++ b/pallets/summary/src/tests/mock.rs @@ -33,7 +33,7 @@ use std::{cell::RefCell, convert::From, sync::Arc}; pub const APPROVE_ROOT: bool = true; pub const REJECT_ROOT: bool = false; -pub type Extrinsic = TestXt; +pub type Extrinsic = TestXt; pub type AccountId = ::AccountId; pub type BlockNumber = ::BlockNumber; @@ -137,7 +137,7 @@ impl Summary { >::put(ingress_counter); } - pub fn emitted_event(event: &Event) -> bool { + pub fn emitted_event(event: &RuntimeEvent) -> bool { return System::events().iter().any(|a| a.event == *event) } @@ -147,9 +147,9 @@ impl Summary { .any(|e| Self::event_matches_offence_type(&e.event, offence_type.clone())) } - pub fn event_matches_offence_type(event: &Event, this_type: SummaryOffenceType) -> bool { + pub fn event_matches_offence_type(event: &RuntimeEvent, this_type: SummaryOffenceType) -> bool { return matches!(event, - mock::Event::Summary( + mock::RuntimeEvent::Summary( crate::Event::::SummaryOffenceReported{ offence_type, .. } ) if this_type == *offence_type @@ -281,7 +281,7 @@ thread_local! { } impl Config for TestRuntime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type AdvanceSlotGracePeriod = AdvanceSlotGracePeriod; type MinBlockAge = MinBlockAge; type CandidateTransactionSubmitter = Self; @@ -293,9 +293,9 @@ impl Config for TestRuntime { impl system::offchain::SendTransactionTypes for TestRuntime where - Call: From, + RuntimeCall: From, { - type OverarchingCall = Call; + type OverarchingCall = RuntimeCall; type Extrinsic = Extrinsic; } @@ -308,8 +308,8 @@ impl system::Config for TestRuntime { type BlockWeights = (); type BlockLength = (); type DbWeight = (); - type Origin = Origin; - type Call = Call; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; type Index = u64; type BlockNumber = u64; type Hash = H256; @@ -317,7 +317,7 @@ impl system::Config for TestRuntime { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type Version = (); type PalletInfo = PalletInfo; @@ -427,7 +427,7 @@ impl session::Config for TestRuntime { type Keys = UintAuthorityId; type ShouldEndSession = session::PeriodicSessions; type SessionHandler = (AVN,); - type Event = Event; + type RuntimeEvent = RuntimeEvent; type ValidatorId = u64; type ValidatorIdOf = ConvertInto; type NextSessionRotation = session::PeriodicSessions; diff --git a/pallets/summary/src/tests/tests.rs b/pallets/summary/src/tests/tests.rs index 8cf884dcf..156a95918 100644 --- a/pallets/summary/src/tests/tests.rs +++ b/pallets/summary/src/tests/tests.rs @@ -2,7 +2,10 @@ #![cfg(test)] -use crate::{mock::*, system}; +use crate::{ + mock::{Summary, *}, + system, +}; use codec::alloc::sync::Arc; use frame_support::assert_noop; use pallet_avn::vote::VotingSessionData; @@ -29,7 +32,7 @@ fn get_unsigned_record_summary_calculation_call_from_chain( let tx = Extrinsic::decode(&mut &*tx).unwrap(); assert_eq!(tx.signature, None); match tx.call { - mock::Call::Summary(inner_tx) => inner_tx, + mock::RuntimeCall::Summary(inner_tx) => inner_tx, _ => unreachable!(), } } @@ -546,7 +549,7 @@ mod process_summary { assert_eq!( tx.call, - mock::Call::Summary(crate::Call::record_summary_calculation { + mock::RuntimeCall::Summary(crate::Call::record_summary_calculation { new_block_number: context.last_block_in_range, root_hash: context.root_hash_h256, ingress_counter: expected_ingress_counter, @@ -951,12 +954,14 @@ pub mod record_summary_calculation { assert!(record_summary_calculation_is_ok(&context)); assert!(System::events().iter().any(|a| a.event == - mock::Event::Summary(crate::Event::::SummaryCalculated { - from: context.next_block_to_process, - to: context.last_block_in_range, - root_hash: context.root_hash_h256, - submitter: context.validator.account_id - }))); + mock::RuntimeEvent::Summary( + crate::Event::::SummaryCalculated { + from: context.next_block_to_process, + to: context.last_block_in_range, + root_hash: context.root_hash_h256, + submitter: context.validator.account_id + } + ))); }); } } @@ -979,7 +984,7 @@ pub mod record_summary_calculation { assert_noop!( Summary::record_summary_calculation( - Origin::signed(Default::default()), + RuntimeOrigin::signed(Default::default()), context.last_block_in_range, context.root_hash_h256, context.root_id.ingress_counter, @@ -1377,7 +1382,7 @@ mod if_process_summary_is_called_a_second_time { assert_eq!(Summary::last_summary_slot(), Summary::current_slot()); assert!(System::events().iter().any(|a| a.event == - mock::Event::Summary(crate::Event::::VotingEnded { + mock::RuntimeEvent::Summary(crate::Event::::VotingEnded { root_id: context.root_id, vote_approved: true }))); @@ -1393,7 +1398,7 @@ mod if_process_summary_is_called_a_second_time { assert_eq!(Summary::last_summary_slot(), previous_summary_slot_before_voting); assert!(System::events().iter().any(|a| a.event == - mock::Event::Summary(crate::Event::::VotingEnded { + mock::RuntimeEvent::Summary(crate::Event::::VotingEnded { root_id: context.root_id, vote_approved: false }))); diff --git a/pallets/summary/src/tests/tests_challenge.rs b/pallets/summary/src/tests/tests_challenge.rs index af1728dd9..9294b7024 100644 --- a/pallets/summary/src/tests/tests_challenge.rs +++ b/pallets/summary/src/tests/tests_challenge.rs @@ -131,7 +131,7 @@ pub fn take_transaction_from_pool(pool_state: &Arc>) -> crate: let tx = Extrinsic::decode(&mut &*tx).unwrap(); assert_eq!(tx.signature, None); match tx.call { - mock::Call::Summary(inner_tx) => inner_tx, + mock::RuntimeCall::Summary(inner_tx) => inner_tx, _ => unreachable!(), } } @@ -255,7 +255,7 @@ mod challenge_slot_if_required { let new_slot_start = Summary::block_number_for_next_slot(); let slot_advanced_event = - mock::Event::Summary(crate::Event::::SlotAdvanced { + mock::RuntimeEvent::Summary(crate::Event::::SlotAdvanced { advanced_by: validator.account_id, new_slot: new_slot_number, slot_validator: new_validator, @@ -284,7 +284,7 @@ mod challenge_slot_if_required { assert_ok!(call_add_challenge(challenge.clone(), &validator, signature)); let add_challenge_event = - mock::Event::Summary(crate::Event::::ChallengeAdded { + mock::RuntimeEvent::Summary(crate::Event::::ChallengeAdded { challenge_reason: challenge.challenge_reason.clone(), challenger: challenge.challenger, challengee: challenge.challengee, @@ -524,7 +524,7 @@ mod signature_in { let tx = Extrinsic::decode(&mut &*tx).unwrap(); match tx.call { - mock::Call::Summary(inner_tx) => { + mock::RuntimeCall::Summary(inner_tx) => { assert_ok!(Summary::validate_unsigned(TransactionSource::Local, &inner_tx)); }, _ => unreachable!(), @@ -554,7 +554,7 @@ mod signature_in { let tx = Extrinsic::decode(&mut &*tx).unwrap(); match tx.call { - mock::Call::Summary(crate::Call::add_challenge { + mock::RuntimeCall::Summary(crate::Call::add_challenge { challenge, validator, signature, @@ -599,7 +599,7 @@ mod signature_in { let non_validator = get_non_validator(); match tx.call { - mock::Call::Summary(crate::Call::add_challenge { + mock::RuntimeCall::Summary(crate::Call::add_challenge { challenge, validator: _, signature, @@ -641,7 +641,7 @@ mod signature_in { let bad_context = "bad context"; match tx.call { - mock::Call::Summary(crate::Call::add_challenge { + mock::RuntimeCall::Summary(crate::Call::add_challenge { challenge, validator, signature, diff --git a/pallets/summary/src/tests/tests_set_periods.rs b/pallets/summary/src/tests/tests_set_periods.rs index 6bda94da6..051ee8c2a 100644 --- a/pallets/summary/src/tests/tests_set_periods.rs +++ b/pallets/summary/src/tests/tests_set_periods.rs @@ -10,7 +10,7 @@ mod test_set_periods { use super::*; struct Context { - origin: Origin, + origin: RuntimeOrigin, schedule_period: BlockNumber, new_schedule_period: BlockNumber, voting_period: BlockNumber, @@ -105,7 +105,7 @@ mod test_set_periods { .as_externality(); ext.execute_with(|| { let context: Context = Context { - origin: Origin::signed(Default::default()), + origin: RuntimeOrigin::signed(Default::default()), ..Default::default() }; @@ -161,7 +161,7 @@ mod test_set_periods { .as_externality(); ext.execute_with(|| { let context: Context = Context { - origin: Origin::signed(Default::default()), + origin: RuntimeOrigin::signed(Default::default()), ..Default::default() }; diff --git a/pallets/summary/src/tests/tests_slot_logic.rs b/pallets/summary/src/tests/tests_slot_logic.rs index bd616ed55..75a633685 100644 --- a/pallets/summary/src/tests/tests_slot_logic.rs +++ b/pallets/summary/src/tests/tests_slot_logic.rs @@ -109,7 +109,7 @@ mod advance_slot { let tx = Extrinsic::decode(&mut &*tx).unwrap(); assert_eq!(tx.signature, None); match tx.call { - mock::Call::Summary(inner_tx) => inner_tx, + mock::RuntimeCall::Summary(inner_tx) => inner_tx, _ => unreachable!(), } } @@ -336,12 +336,13 @@ mod advance_slot { let new_validator = Summary::slot_validator().unwrap(); let new_slot_start = Summary::block_number_for_next_slot(); - let event = mock::Event::Summary(crate::Event::::SlotAdvanced { - advanced_by: validator.account_id, - new_slot: new_slot_number, - slot_validator: new_validator, - slot_end: new_slot_start, - }); + let event = + mock::RuntimeEvent::Summary(crate::Event::::SlotAdvanced { + advanced_by: validator.account_id, + new_slot: new_slot_number, + slot_validator: new_validator, + slot_end: new_slot_start, + }); assert!(Summary::emitted_event(&event)); }); @@ -396,7 +397,7 @@ mod advance_slot { assert_noop!( Summary::advance_slot( - Origin::signed(Default::default()), + RuntimeOrigin::signed(Default::default()), validator.clone(), signature ), @@ -549,7 +550,7 @@ mod signature_in { let tx = Extrinsic::decode(&mut &*tx).unwrap(); match tx.call { - mock::Call::Summary(inner_tx) => { + mock::RuntimeCall::Summary(inner_tx) => { assert_ok!(Summary::validate_unsigned(TransactionSource::Local, &inner_tx)); }, _ => unreachable!(), @@ -580,7 +581,10 @@ mod signature_in { let tx = Extrinsic::decode(&mut &*tx).unwrap(); match tx.call { - mock::Call::Summary(crate::Call::advance_slot { validator, signature }) => { + mock::RuntimeCall::Summary(crate::Call::advance_slot { + validator, + signature, + }) => { let data = &(ADVANCE_SLOT_CONTEXT, context.slot_number); let signature_is_valid = data.using_encoded(|encoded_data| { @@ -620,7 +624,7 @@ mod signature_in { let tx = Extrinsic::decode(&mut &*tx).unwrap(); match tx.call { - mock::Call::Summary(crate::Call::advance_slot { + mock::RuntimeCall::Summary(crate::Call::advance_slot { validator: _, signature, }) => { @@ -660,7 +664,10 @@ mod signature_in { let tx = Extrinsic::decode(&mut &*tx).unwrap(); match tx.call { - mock::Call::Summary(crate::Call::advance_slot { validator, signature }) => { + mock::RuntimeCall::Summary(crate::Call::advance_slot { + validator, + signature, + }) => { let data = &("WRONG CONTEXT", context.slot_number); let signature_is_valid = data.using_encoded(|encoded_data| { @@ -697,7 +704,10 @@ mod signature_in { let tx = Extrinsic::decode(&mut &*tx).unwrap(); match tx.call { - mock::Call::Summary(crate::Call::advance_slot { validator, signature }) => { + mock::RuntimeCall::Summary(crate::Call::advance_slot { + validator, + signature, + }) => { let data = &(ADVANCE_SLOT_CONTEXT, context.slot_number + 1); let signature_is_valid = data.using_encoded(|encoded_data| { @@ -798,7 +808,7 @@ mod cases_for_no_summary_created_offences { assert_ok!(call_advance_slot(&validator, signature)); - let offence_event = mock::Event::Summary( + let offence_event = mock::RuntimeEvent::Summary( crate::Event::::SummaryNotPublishedOffence { challengee: validator.account_id, void_slot: context.slot_number, @@ -811,11 +821,12 @@ mod cases_for_no_summary_created_offences { let offenders = vec![Summary::create_mock_identification_tuple(validator.account_id)]; - let offence_reported_event = - mock::Event::Summary(crate::Event::::SummaryOffenceReported { + let offence_reported_event = mock::RuntimeEvent::Summary( + crate::Event::::SummaryOffenceReported { offence_type: SummaryOffenceType::NoSummaryCreated, offenders, - }); + }, + ); assert_eq!(true, Summary::emitted_event(&offence_reported_event)); let new_slot_number = Summary::current_slot(); @@ -823,7 +834,7 @@ mod cases_for_no_summary_created_offences { let new_slot_start = Summary::block_number_for_next_slot(); let slot_advanced_event = - mock::Event::Summary(crate::Event::::SlotAdvanced { + mock::RuntimeEvent::Summary(crate::Event::::SlotAdvanced { advanced_by: validator.account_id, new_slot: new_slot_number, slot_validator: new_validator, @@ -946,7 +957,7 @@ mod cases_for_no_summary_created_offences { assert_ok!(call_advance_slot(&validator, signature)); - let event = mock::Event::Summary( + let event = mock::RuntimeEvent::Summary( crate::Event::::SummaryNotPublishedOffence { challengee: validator.account_id, void_slot: context.slot_number, @@ -1242,8 +1253,8 @@ mod cases_for_no_summary_created_offences { } } -fn event_is_a_not_published_offence(e: &mock::Event) -> bool { - if let mock::Event::Summary(crate::Event::::SummaryNotPublishedOffence { +fn event_is_a_not_published_offence(e: &mock::RuntimeEvent) -> bool { + if let mock::RuntimeEvent::Summary(crate::Event::::SummaryNotPublishedOffence { .. }) = &e { diff --git a/pallets/summary/src/tests/tests_vote.rs b/pallets/summary/src/tests/tests_vote.rs index 924115842..eb6059cfe 100644 --- a/pallets/summary/src/tests/tests_vote.rs +++ b/pallets/summary/src/tests/tests_vote.rs @@ -95,7 +95,7 @@ mod approve_root { assert_eq!(Summary::get_vote(context.root_id).nays.is_empty(), true); assert!(System::events().iter().any(|a| a.event == - mock::Event::Summary(crate::Event::::VoteAdded { + mock::RuntimeEvent::Summary(crate::Event::::VoteAdded { voter: context.validator.account_id, root_id: context.root_id, agree_vote: true @@ -139,7 +139,7 @@ mod approve_root { ); assert!(System::events().iter().any(|a| a.event == - mock::Event::Summary(crate::Event::::VoteAdded { + mock::RuntimeEvent::Summary(crate::Event::::VoteAdded { voter: second_validator.account_id, root_id: context.root_id, agree_vote: true @@ -180,7 +180,7 @@ mod approve_root { assert_eq!(Summary::get_vote(context.root_id).nays.is_empty(), true); assert!(System::events().iter().any(|a| a.event == - mock::Event::Summary(crate::Event::::VoteAdded { + mock::RuntimeEvent::Summary(crate::Event::::VoteAdded { voter: second_validator.account_id, root_id: context.root_id, agree_vote: true @@ -226,7 +226,7 @@ mod approve_root { ); assert!(System::events().iter().any(|a| a.event == - mock::Event::Summary(crate::Event::::VoteAdded { + mock::RuntimeEvent::Summary(crate::Event::::VoteAdded { voter: third_validator.account_id, root_id: context.root_id, agree_vote: true @@ -252,7 +252,7 @@ mod approve_root { assert_noop!( Summary::approve_root( - Origin::signed(Default::default()), + RuntimeOrigin::signed(Default::default()), context.root_id, context.validator, context.approval_signature, @@ -462,7 +462,7 @@ mod reject_root { ); assert!(System::events().iter().any(|a| a.event == - mock::Event::Summary(crate::Event::::VoteAdded { + mock::RuntimeEvent::Summary(crate::Event::::VoteAdded { voter: context.validator.account_id, root_id: context.root_id, agree_vote: false @@ -502,7 +502,7 @@ mod reject_root { ); assert!(System::events().iter().any(|a| a.event == - mock::Event::Summary(crate::Event::::VoteAdded { + mock::RuntimeEvent::Summary(crate::Event::::VoteAdded { voter: second_validator.account_id, root_id: context.root_id, agree_vote: false @@ -539,7 +539,7 @@ mod reject_root { ); assert!(System::events().iter().any(|a| a.event == - mock::Event::Summary(crate::Event::::VoteAdded { + mock::RuntimeEvent::Summary(crate::Event::::VoteAdded { voter: second_validator.account_id, root_id: context.root_id, agree_vote: false @@ -581,7 +581,7 @@ mod reject_root { ); assert!(System::events().iter().any(|a| a.event == - mock::Event::Summary(crate::Event::::VoteAdded { + mock::RuntimeEvent::Summary(crate::Event::::VoteAdded { voter: third_validator.account_id, root_id: context.root_id, agree_vote: false @@ -607,7 +607,7 @@ mod reject_root { assert_noop!( Summary::reject_root( - Origin::signed(Default::default()), + RuntimeOrigin::signed(Default::default()), context.root_id, context.validator, context.record_summary_calculation_signature @@ -868,7 +868,7 @@ mod cast_votes_if_required { assert_eq!( tx.call, - mock::Call::Summary(crate::Call::approve_root { + mock::RuntimeCall::Summary(crate::Call::approve_root { root_id: context.root_id, validator: second_validator.clone(), approval_signature: context.approval_signature.clone(), @@ -912,7 +912,7 @@ mod cast_votes_if_required { assert_eq!( tx.call, - mock::Call::Summary(crate::Call::reject_root { + mock::RuntimeCall::Summary(crate::Call::reject_root { root_id: context.root_id, validator: second_validator.clone(), signature: get_signature_for_reject_cast_vote( @@ -960,14 +960,16 @@ mod end_voting_period { assert_eq!(Summary::last_summary_slot(), Summary::current_slot()); assert!(System::events().iter().any(|a| a.event == - mock::Event::Summary(crate::Event::::SummaryRootValidated { - block_range: context.root_id.range, - root_hash: context.root_hash_h256, - ingress_counter: context.root_id.ingress_counter - }))); + mock::RuntimeEvent::Summary( + crate::Event::::SummaryRootValidated { + block_range: context.root_id.range, + root_hash: context.root_hash_h256, + ingress_counter: context.root_id.ingress_counter + } + ))); assert!(System::events().iter().any(|a| a.event == - mock::Event::Summary(crate::Event::::VotingEnded { + mock::RuntimeEvent::Summary(crate::Event::::VotingEnded { root_id: context.root_id, vote_approved: true }))); @@ -1002,7 +1004,7 @@ mod end_voting_period { assert_eq!(Summary::last_summary_slot(), previous_slot); assert!(System::events().iter().any(|a| a.event == - mock::Event::Summary(crate::Event::::VotingEnded { + mock::RuntimeEvent::Summary(crate::Event::::VotingEnded { root_id: context.root_id, vote_approved: false }))); @@ -1025,7 +1027,7 @@ mod end_voting_period { assert_noop!( Summary::end_voting_period( - Origin::signed(Default::default()), + RuntimeOrigin::signed(Default::default()), context.root_id, context.validator.clone(), context.record_summary_calculation_signature.clone(), diff --git a/pallets/token-manager/Cargo.toml b/pallets/token-manager/Cargo.toml index 237b01403..6b6550d3a 100644 --- a/pallets/token-manager/Cargo.toml +++ b/pallets/token-manager/Cargo.toml @@ -18,29 +18,30 @@ pallet-avn = { version = "0.12.0", default-features = false, path = "../avn" } hex-literal = { version = "0.3.4", default-features = false } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } sp-avn-common = { version = "0.12.0", default-features = false, path = "../../primitives/avn-common" } -sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -frame-system = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -sp-application-crypto = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.27" } +sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +frame-system = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +sp-application-crypto = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.36" } # Optional imports for benchmarking serde = { version = "1.0.137", optional = true } -frame-benchmarking = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27", optional = true } +frame-benchmarking = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", optional = true } [dev-dependencies] -sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -substrate-test-utils = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } +sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +substrate-test-utils = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } pallet-parachain-staking = { version = "3.0.0", path = "../parachain-staking" } -pallet-session = { features = ["historical"], git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27", default-features = false } +pallet-session = { features = ["historical"], git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } [features] default = ["std"] std = [ + "frame-benchmarking?/std", "serde", "codec/std", "sp-std/std", @@ -49,9 +50,10 @@ std = [ "frame-system/std", "sp-avn-common/std", "pallet-avn/std", + "sp-application-crypto/std", ] runtime-benchmarks = [ - "frame-benchmarking", + "frame-benchmarking/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", ] diff --git a/pallets/token-manager/src/benchmarking.rs b/pallets/token-manager/src/benchmarking.rs index eee6a84af..5208064a6 100644 --- a/pallets/token-manager/src/benchmarking.rs +++ b/pallets/token-manager/src/benchmarking.rs @@ -40,13 +40,13 @@ type SignerId = app_sr25519::Public; pub const AVT_TOKEN_CONTRACT: H160 = H160(hex!("dB1Cff52f66195f0a5Bd3db91137db98cfc54AE6")); -fn assert_last_event(generic_event: ::Event) { +fn assert_last_event(generic_event: ::RuntimeEvent) { assert_last_nth_event::(generic_event, 1); } -fn assert_last_nth_event(generic_event: ::Event, n: u32) { +fn assert_last_nth_event(generic_event: ::RuntimeEvent, n: u32) { let events = frame_system::Pallet::::events(); - let system_event: ::Event = generic_event.into(); + let system_event: ::RuntimeEvent = generic_event.into(); // compare to the last event record let EventRecord { event, .. } = &events[events.len().saturating_sub(n as usize)]; assert_eq!(event, &system_event); @@ -86,7 +86,7 @@ impl Transfer { return self } - fn generate_signed_transfer_call(&self, signature: &[u8]) -> ::Call { + fn generate_signed_transfer_call(&self, signature: &[u8]) -> ::RuntimeCall { let proof: Proof = self.get_proof(&self.relayer, signature); return Call::signed_transfer { proof, @@ -183,8 +183,8 @@ benchmarks! { let signature = &hex!("a6350211fcdf1d7f0c79bf0a9c296de17449ca88a899f0cd19a70b07513fc107b7d34249dba71d4761ceeec2ed6bc1305defeb96418e6869e6b6199ed0de558e"); let token_id = H160(hex!("1414141414141414141414141414141414141414")); let transfer: Transfer = Transfer::new(token_id).setup(); - let call: ::Call = transfer.generate_signed_transfer_call(signature); - let boxed_call: Box<::Call> = Box::new(call); + let call: ::RuntimeCall = transfer.generate_signed_transfer_call(signature); + let boxed_call: Box<::RuntimeCall> = Box::new(call); let call_hash: T::Hash = T::Hashing::hash_of(&boxed_call); }: proxy(RawOrigin::::Signed(transfer.relayer.clone()), boxed_call) verify { diff --git a/pallets/token-manager/src/default_weights.rs b/pallets/token-manager/src/default_weights.rs index 7645036bf..ea9aaf6bd 100644 --- a/pallets/token-manager/src/default_weights.rs +++ b/pallets/token-manager/src/default_weights.rs @@ -18,8 +18,8 @@ //! Autogenerated weights for pallet_token_manager //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-12-08, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `ip-172-31-4-12`, CPU: `AMD EPYC 7R32` +//! DATE: 2023-03-21, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `ip-10-150-0-139`, CPU: `AMD EPYC 7R32` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: @@ -31,9 +31,9 @@ // --execution=wasm // --wasm-execution=compiled // --template -// .maintain/frame-weight-template.hbs +// frame-weight-template.hbs // --pallet -// pallet_token-manager +// pallet_token_manager // --extrinsic // * // --steps @@ -41,7 +41,7 @@ // --repeat // 20 // --output -// token_manager_weights.rs +// ./token_manager_weights.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -68,59 +68,59 @@ impl WeightInfo for SubstrateWeight { // Storage: TokenManager AVTTokenContract (r:1 w:0) // Storage: TokenManager Balances (r:2 w:2) fn proxy_with_non_avt_token() -> Weight { - (121_496_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(194_795_000) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) } // Storage: TokenManager Nonces (r:1 w:1) // Storage: TokenManager AVTTokenContract (r:1 w:0) // Storage: TokenManager Balances (r:2 w:2) fn signed_transfer() -> Weight { - (112_427_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(183_614_000) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) } // Storage: TokenManager LowerAccountId (r:1 w:0) // Storage: TokenManager AVTTokenContract (r:1 w:0) // Storage: System Account (r:1 w:1) // Storage: TokenManager Nonces (r:1 w:1) fn lower_avt_token() -> Weight { - (45_483_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(48_131_000) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: TokenManager LowerAccountId (r:1 w:0) // Storage: TokenManager AVTTokenContract (r:1 w:0) // Storage: TokenManager Balances (r:1 w:1) // Storage: TokenManager Nonces (r:1 w:1) fn lower_non_avt_token() -> Weight { - (33_882_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(33_241_000) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: TokenManager Nonces (r:1 w:1) // Storage: TokenManager LowerAccountId (r:1 w:0) // Storage: TokenManager AVTTokenContract (r:1 w:0) // Storage: System Account (r:1 w:1) fn signed_lower_avt_token() -> Weight { - (120_897_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(196_994_000) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: TokenManager Nonces (r:1 w:1) // Storage: TokenManager LowerAccountId (r:1 w:0) // Storage: TokenManager AVTTokenContract (r:1 w:0) // Storage: TokenManager Balances (r:1 w:1) fn signed_lower_non_avt_token() -> Weight { - (110_426_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(182_295_000) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: System Account (r:2 w:2) fn transfer_from_treasury() -> Weight { - (44_672_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(43_991_000) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } } @@ -130,58 +130,58 @@ impl WeightInfo for () { // Storage: TokenManager AVTTokenContract (r:1 w:0) // Storage: TokenManager Balances (r:2 w:2) fn proxy_with_non_avt_token() -> Weight { - (121_496_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(194_795_000) + .saturating_add(RocksDbWeight::get().reads(4)) + .saturating_add(RocksDbWeight::get().writes(3)) } // Storage: TokenManager Nonces (r:1 w:1) // Storage: TokenManager AVTTokenContract (r:1 w:0) // Storage: TokenManager Balances (r:2 w:2) fn signed_transfer() -> Weight { - (112_427_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + Weight::from_ref_time(183_614_000) + .saturating_add(RocksDbWeight::get().reads(4)) + .saturating_add(RocksDbWeight::get().writes(3)) } // Storage: TokenManager LowerAccountId (r:1 w:0) // Storage: TokenManager AVTTokenContract (r:1 w:0) // Storage: System Account (r:1 w:1) // Storage: TokenManager Nonces (r:1 w:1) fn lower_avt_token() -> Weight { - (45_483_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(48_131_000) + .saturating_add(RocksDbWeight::get().reads(4)) + .saturating_add(RocksDbWeight::get().writes(2)) } // Storage: TokenManager LowerAccountId (r:1 w:0) // Storage: TokenManager AVTTokenContract (r:1 w:0) // Storage: TokenManager Balances (r:1 w:1) // Storage: TokenManager Nonces (r:1 w:1) fn lower_non_avt_token() -> Weight { - (33_882_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(33_241_000) + .saturating_add(RocksDbWeight::get().reads(4)) + .saturating_add(RocksDbWeight::get().writes(2)) } // Storage: TokenManager Nonces (r:1 w:1) // Storage: TokenManager LowerAccountId (r:1 w:0) // Storage: TokenManager AVTTokenContract (r:1 w:0) // Storage: System Account (r:1 w:1) fn signed_lower_avt_token() -> Weight { - (120_897_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(196_994_000) + .saturating_add(RocksDbWeight::get().reads(4)) + .saturating_add(RocksDbWeight::get().writes(2)) } // Storage: TokenManager Nonces (r:1 w:1) // Storage: TokenManager LowerAccountId (r:1 w:0) // Storage: TokenManager AVTTokenContract (r:1 w:0) // Storage: TokenManager Balances (r:1 w:1) fn signed_lower_non_avt_token() -> Weight { - (110_426_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(182_295_000) + .saturating_add(RocksDbWeight::get().reads(4)) + .saturating_add(RocksDbWeight::get().writes(2)) } // Storage: System Account (r:2 w:2) fn transfer_from_treasury() -> Weight { - (44_672_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + Weight::from_ref_time(43_991_000) + .saturating_add(RocksDbWeight::get().reads(2)) + .saturating_add(RocksDbWeight::get().writes(2)) } } \ No newline at end of file diff --git a/pallets/token-manager/src/lib.rs b/pallets/token-manager/src/lib.rs index 6ca9a0c5c..80347c7a2 100644 --- a/pallets/token-manager/src/lib.rs +++ b/pallets/token-manager/src/lib.rs @@ -21,10 +21,9 @@ use codec::{Decode, Encode}; use core::convert::{TryFrom, TryInto}; use frame_support::{ - dispatch::{DispatchResult, DispatchResultWithPostInfo}, + dispatch::{DispatchResult, DispatchResultWithPostInfo, GetDispatchInfo}, ensure, log, traits::{Currency, ExistenceRequirement, Get, Imbalance, IsSubType, WithdrawReasons}, - weights::GetDispatchInfo, PalletId, Parameter, }; use frame_system::ensure_signed; @@ -84,6 +83,8 @@ pub const SIGNED_LOWER_CONTEXT: &'static [u8] = b"authorization for lower operat pub const OPEN_BYTES_TAG: &'static [u8] = b""; pub const CLOSE_BYTES_TAG: &'static [u8] = b""; +pub use pallet::*; + #[frame_support::pallet] pub mod pallet { use super::*; @@ -94,13 +95,13 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config + avn::Config { /// The overarching event type. - type Event: From> - + Into<::Event> - + IsType<::Event>; + type RuntimeEvent: From> + + Into<::RuntimeEvent> + + IsType<::RuntimeEvent>; /// The overarching call type. - type Call: Parameter - + Dispatchable::Origin> + type RuntimeCall: Parameter + + Dispatchable::RuntimeOrigin> + IsSubType> + From> + GetDispatchInfo; @@ -265,8 +266,12 @@ pub mod pallet { /// a sender. As a general rule, every function that can be proxied should follow /// this convention: /// - its first argument (after origin) should be a public verification key and a signature + #[pallet::call_index(0)] #[pallet::weight(::WeightInfo::proxy_with_non_avt_token().saturating_add(call.get_dispatch_info().weight))] - pub fn proxy(origin: OriginFor, call: Box<::Call>) -> DispatchResult { + pub fn proxy( + origin: OriginFor, + call: Box<::RuntimeCall>, + ) -> DispatchResult { let relayer = ensure_signed(origin)?; let proof = Self::get_proof(&*call)?; @@ -281,6 +286,7 @@ pub mod pallet { } /// Transfer an amount of token with token_id from sender to receiver with a proof + #[pallet::call_index(1)] #[pallet::weight(::WeightInfo::signed_transfer())] pub fn signed_transfer( origin: OriginFor, @@ -321,6 +327,7 @@ pub mod pallet { /// Lower an amount of token from tier2 to tier1 #[pallet::weight(::WeightInfo::lower_avt_token().max(::WeightInfo::lower_non_avt_token()))] + #[pallet::call_index(2)] pub fn lower( origin: OriginFor, from: T::AccountId, @@ -356,6 +363,7 @@ pub mod pallet { /// Lower an amount of token from tier2 to tier1 by a relayer #[pallet::weight(::WeightInfo::signed_lower_avt_token().max(::WeightInfo::signed_lower_non_avt_token()))] + #[pallet::call_index(3)] pub fn signed_lower( origin: OriginFor, proof: Proof, @@ -407,6 +415,7 @@ pub mod pallet { /// Transfer AVT from the treasury account. The origin must be root. // TODO: benchmark me + #[pallet::call_index(4)] #[pallet::weight(::WeightInfo::transfer_from_treasury())] pub fn transfer_from_treasury( origin: OriginFor, @@ -637,7 +646,7 @@ impl Pallet { } fn get_encoded_call_param( - call: &::Call, + call: &::RuntimeCall, ) -> Option<(&Proof, Vec)> { let call = match call.is_sub_type() { Some(call) => call, @@ -761,7 +770,7 @@ impl CallDecoder for Pallet { type AccountId = T::AccountId; type Signature = ::Signature; type Error = Error; - type Call = ::Call; + type Call = ::RuntimeCall; fn get_proof( call: &Self::Call, @@ -780,7 +789,7 @@ impl CallDecoder for Pallet { } impl InnerCallValidator for Pallet { - type Call = ::Call; + type Call = ::RuntimeCall; fn signature_is_valid(call: &Box) -> bool { if let Some((proof, signed_payload)) = Self::get_encoded_call_param(call) { diff --git a/pallets/token-manager/src/mock.rs b/pallets/token-manager/src/mock.rs index 8c0e5d789..d5d90b57b 100644 --- a/pallets/token-manager/src/mock.rs +++ b/pallets/token-manager/src/mock.rs @@ -17,9 +17,10 @@ use super::*; use crate::{self as token_manager}; use frame_support::{ + dispatch::{DispatchClass, DispatchInfo}, parameter_types, traits::{ConstU8, GenesisBuild}, - weights::{DispatchClass, DispatchInfo, Weight, WeightToFee as WeightToFeeT}, + weights::{Weight, WeightToFee as WeightToFeeT}, PalletId, }; use frame_system::{self as system, limits}; @@ -80,9 +81,9 @@ parameter_types! { pub static TreasuryGrowthPercentage: Perbill = Perbill::from_percent(75); } -impl Config for TestRuntime { - type Event = Event; - type Call = Call; +impl token_manager::Config for TestRuntime { + type RuntimeEvent = RuntimeEvent; + type RuntimeCall = RuntimeCall; type Currency = Balances; type ProcessedEventsChecker = Self; type TokenId = sp_core::H160; @@ -110,16 +111,16 @@ impl sp_runtime::BoundToRuntimeAppPublic for TestRuntime { pub const BASE_FEE: u64 = 12; const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); -const MAX_BLOCK_WEIGHT: Weight = 1024; +const MAX_BLOCK_WEIGHT: Weight = Weight::from_ref_time(1024).set_proof_size(u64::MAX); parameter_types! { pub const BlockHashCount: u64 = 250; // Creating custom runtime block weights similar with substrate/frame/system/src/mock.rs pub BlockLength: limits::BlockLength = limits::BlockLength::max_with_normal_ratio(1024, NORMAL_DISPATCH_RATIO); pub RuntimeBlockWeights: limits::BlockWeights = limits::BlockWeights::builder() - .base_block(10) + .base_block(Weight::from_ref_time(10)) .for_class(DispatchClass::all(), |weights| { - weights.base_extrinsic = BASE_FEE; + weights.base_extrinsic = Weight::from_ref_time(BASE_FEE); }) .for_class(DispatchClass::Normal, |weights| { weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAX_BLOCK_WEIGHT); @@ -139,16 +140,16 @@ impl system::Config for TestRuntime { type BlockWeights = RuntimeBlockWeights; type BlockLength = BlockLength; type DbWeight = (); - type Origin = Origin; - type Call = Call; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; type Index = u64; type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = AccountId; - type Lookup = IdentityLookup; + type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type Version = (); type PalletInfo = PalletInfo; @@ -169,7 +170,7 @@ impl pallet_balances::Config for TestRuntime { type MaxLocks = (); type Balance = u128; type DustRemoval = (); - type Event = Event; + type RuntimeEvent = RuntimeEvent; type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; type MaxReserves = (); @@ -182,7 +183,7 @@ parameter_types! { pub static TransactionByteFee: u128 = 0u128; } impl pallet_transaction_payment::Config for TestRuntime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type OnChargeTransaction = CurrencyAdapter; type LengthToFee = TransactionByteFee; type WeightToFee = WeightToFee; @@ -195,7 +196,7 @@ impl session::Config for TestRuntime { type Keys = UintAuthorityId; type ShouldEndSession = ParachainStaking; type SessionHandler = (AVN,); - type Event = Event; + type RuntimeEvent = RuntimeEvent; type ValidatorId = AccountId; type ValidatorIdOf = ConvertInto; type NextSessionRotation = ParachainStaking; @@ -216,8 +217,8 @@ parameter_types! { } impl parachain_staking::Config for TestRuntime { - type Call = Call; - type Event = Event; + type RuntimeCall = RuntimeCall; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type MinBlocksPerEra = MinBlocksPerEra; type RewardPaymentDelay = RewardPaymentDelay; @@ -240,7 +241,8 @@ impl WeightToFeeT for WeightToFee { type Balance = u128; fn weight_to_fee(weight: &Weight) -> Self::Balance { - Self::Balance::saturated_from(*weight).saturating_mul(WEIGHT_TO_FEE.with(|v| *v.borrow())) + Self::Balance::saturated_from(weight.ref_time()) + .saturating_mul(WEIGHT_TO_FEE.with(|v| *v.borrow())) } } @@ -248,7 +250,7 @@ impl WeightToFeeT for TransactionByteFee { type Balance = u128; fn weight_to_fee(weight: &Weight) -> Self::Balance { - Self::Balance::saturated_from(*weight) + Self::Balance::saturated_from(weight.ref_time()) .saturating_mul(TRANSACTION_BYTE_FEE.with(|v| *v.borrow())) } } @@ -567,7 +569,10 @@ impl MockData { let amount = as TryFrom>::try_from(amount).expect("amount is valid"); let imbalance: PositiveImbalanceOf = - ::Currency::deposit_creating(&account_id, amount); + ::Currency::deposit_creating( + &account_id, + amount, + ); if imbalance.peek() == BalanceOf::::zero() { return false } diff --git a/pallets/token-manager/src/test_avt_tokens.rs b/pallets/token-manager/src/test_avt_tokens.rs index a95f48fb8..c7fae36fe 100644 --- a/pallets/token-manager/src/test_avt_tokens.rs +++ b/pallets/token-manager/src/test_avt_tokens.rs @@ -16,7 +16,7 @@ #![cfg(test)] use crate::{ - mock::{Balances, Event, *}, + mock::{Balances, RuntimeEvent, *}, *, }; use frame_support::{assert_noop, assert_ok}; @@ -43,7 +43,7 @@ fn avn_test_lift_to_zero_balance_account_should_succeed() { assert_eq!(Balances::free_balance(mock_data.receiver_account_id), AMOUNT_123_TOKEN); assert!(System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::AVTLifted { + RuntimeEvent::TokenManager(crate::Event::::AVTLifted { recipient: mock_data.receiver_account_id, amount: AMOUNT_123_TOKEN, eth_tx_hash: mock_event.event_id.transaction_hash @@ -70,7 +70,7 @@ fn avn_test_lift_to_non_zero_balance_account_should_succeed() { assert_eq!(Balances::free_balance(mock_data.receiver_account_id), new_balance); assert!(System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::AVTLifted { + RuntimeEvent::TokenManager(crate::Event::::AVTLifted { recipient: mock_data.receiver_account_id, amount: AMOUNT_123_TOKEN, eth_tx_hash: mock_event.event_id.transaction_hash @@ -96,7 +96,7 @@ fn avn_test_lift_max_balance_to_zero_balance_account_should_succeed() { assert_eq!(Balances::free_balance(mock_data.receiver_account_id), u128_max_amount); assert!(System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::AVTLifted { + RuntimeEvent::TokenManager(crate::Event::::AVTLifted { recipient: mock_data.receiver_account_id, amount: u128_max_amount, eth_tx_hash: mock_event.event_id.transaction_hash @@ -122,7 +122,7 @@ fn avn_test_lift_max_balance_to_non_zero_balance_account_should_return_deposit_f assert_eq!(Balances::free_balance(mock_data.receiver_account_id), balance_before); assert!(!System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::AVTLifted { + RuntimeEvent::TokenManager(crate::Event::::AVTLifted { recipient: mock_data.receiver_account_id, amount: u128_max_amount, eth_tx_hash: mock_event.event_id.transaction_hash @@ -144,7 +144,7 @@ fn avn_test_lower_all_avt_token_succeed() { let amount = from_account_balance_before; assert_ok!(TokenManager::lower( - Origin::signed(from_account_id), + RuntimeOrigin::signed(from_account_id), from_account_id, AVT_TOKEN_CONTRACT, amount, @@ -152,7 +152,7 @@ fn avn_test_lower_all_avt_token_succeed() { )); assert_eq!(Balances::free_balance(from_account_id), from_account_balance_before - amount); assert!(System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::TokenLowered { + RuntimeEvent::TokenManager(crate::Event::::TokenLowered { token_id: AVT_TOKEN_CONTRACT, sender: from_account_id, recipient: to_account_id, @@ -176,7 +176,7 @@ fn avn_test_lower_some_avt_token_succeed() { let amount = from_account_balance_before / 2; assert_ok!(TokenManager::lower( - Origin::signed(from_account_id), + RuntimeOrigin::signed(from_account_id), from_account_id, AVT_TOKEN_CONTRACT, amount, @@ -184,7 +184,7 @@ fn avn_test_lower_some_avt_token_succeed() { )); assert_eq!(Balances::free_balance(from_account_id), from_account_balance_before - amount); assert!(System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::TokenLowered { + RuntimeEvent::TokenManager(crate::Event::::TokenLowered { token_id: AVT_TOKEN_CONTRACT, sender: from_account_id, recipient: to_account_id, @@ -208,7 +208,7 @@ fn avn_test_lower_avt_token_should_fail_when_sender_does_not_have_enough_avt_tok assert_noop!( TokenManager::lower( - Origin::signed(from_account_id), + RuntimeOrigin::signed(from_account_id), from_account_id, AVT_TOKEN_CONTRACT, amount, @@ -235,7 +235,7 @@ fn avn_test_avt_token_total_lowered_amount_greater_than_balance_max_value_ok() { let t1_recipient = H160(hex!("0000000000000000000000000000000000000001")); assert_ok!(TokenManager::lower( - Origin::signed(from_account_id), + RuntimeOrigin::signed(from_account_id), from_account_id, AVT_TOKEN_CONTRACT, amount, @@ -243,7 +243,7 @@ fn avn_test_avt_token_total_lowered_amount_greater_than_balance_max_value_ok() { )); assert_eq!(Balances::free_balance(from_account_id), from_account_balance_before - amount); assert!(System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::TokenLowered { + RuntimeEvent::TokenManager(crate::Event::::TokenLowered { token_id: AVT_TOKEN_CONTRACT, sender: from_account_id, recipient: to_account_id, @@ -257,7 +257,7 @@ fn avn_test_avt_token_total_lowered_amount_greater_than_balance_max_value_ok() { from_account_balance_before = Balances::free_balance(from_account_id); assert_ok!(TokenManager::lower( - Origin::signed(from_account_id), + RuntimeOrigin::signed(from_account_id), from_account_id, AVT_TOKEN_CONTRACT, amount, @@ -265,7 +265,7 @@ fn avn_test_avt_token_total_lowered_amount_greater_than_balance_max_value_ok() { )); assert_eq!(Balances::free_balance(from_account_id), from_account_balance_before - amount); assert!(System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::TokenLowered { + RuntimeEvent::TokenManager(crate::Event::::TokenLowered { token_id: AVT_TOKEN_CONTRACT, sender: from_account_id, recipient: to_account_id, diff --git a/pallets/token-manager/src/test_common_cases.rs b/pallets/token-manager/src/test_common_cases.rs index 8f4ae21bf..e369afd26 100644 --- a/pallets/token-manager/src/test_common_cases.rs +++ b/pallets/token-manager/src/test_common_cases.rs @@ -16,7 +16,7 @@ #![cfg(test)] use crate::{ - mock::{Balances, Event, *}, + mock::{Balances, RuntimeEvent, *}, *, }; use frame_support::{assert_noop, assert_ok}; @@ -55,13 +55,13 @@ fn avn_test_lift_ignored_when_event_type_does_not_match() { ); assert!(!System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::AVTLifted { + RuntimeEvent::TokenManager(crate::Event::::AVTLifted { recipient: mock_data.receiver_account_id, amount: AMOUNT_123_TOKEN, eth_tx_hash: mock_event.event_id.transaction_hash }))); assert!(!System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::TokenLifted { + RuntimeEvent::TokenManager(crate::Event::::TokenLifted { token_id: NON_AVT_TOKEN_ID, recipient: mock_data.receiver_account_id, token_balance: mock_data.token_balance_123_tokens, @@ -98,13 +98,13 @@ fn avn_test_lift_zero_amount_should_fail() { let token_balance_zero_tokens = MockData::get_token_balance(zero_amount); assert!(!System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::AVTLifted { + RuntimeEvent::TokenManager(crate::Event::::AVTLifted { recipient: mock_data.receiver_account_id, amount: zero_amount, eth_tx_hash: mock_event.event_id.transaction_hash }))); assert!(!System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::TokenLifted { + RuntimeEvent::TokenManager(crate::Event::::TokenLifted { token_id: NON_AVT_TOKEN_ID, recipient: mock_data.receiver_account_id, token_balance: token_balance_zero_tokens, @@ -141,13 +141,13 @@ fn avn_test_lift_should_fail_when_event_is_not_in_processed_events() { ); assert!(!System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::AVTLifted { + RuntimeEvent::TokenManager(crate::Event::::AVTLifted { recipient: mock_data.receiver_account_id, amount: AMOUNT_123_TOKEN, eth_tx_hash: mock_event.event_id.transaction_hash }))); assert!(!System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::TokenLifted { + RuntimeEvent::TokenManager(crate::Event::::TokenLifted { token_id: NON_AVT_TOKEN_ID, recipient: mock_data.receiver_account_id, token_balance: mock_data.token_balance_123_tokens, @@ -186,7 +186,7 @@ fn avn_test_lower_should_fail_when_sender_does_not_own_from_account() { assert_noop!( TokenManager::lower( - Origin::signed(sender), + RuntimeOrigin::signed(sender), from_account_id, NON_AVT_TOKEN_ID, 100, @@ -206,7 +206,7 @@ fn avn_test_lower_should_fail_when_amount_is_zero() { assert_noop!( TokenManager::lower( - Origin::signed(from_account_id), + RuntimeOrigin::signed(from_account_id), from_account_id, NON_AVT_TOKEN_ID, 0, diff --git a/pallets/token-manager/src/test_growth.rs b/pallets/token-manager/src/test_growth.rs index 3e1937bda..83548a56a 100644 --- a/pallets/token-manager/src/test_growth.rs +++ b/pallets/token-manager/src/test_growth.rs @@ -16,7 +16,7 @@ #![cfg(test)] use crate::{ - mock::{Balances, Event, *}, + mock::{Balances, RuntimeEvent, *}, EventData::LogAvtGrowthLifted, *, }; @@ -67,7 +67,7 @@ mod lifted_growth_processed_correctly { // Check expected event has been emitted assert!(System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::AVTGrowthLifted { + RuntimeEvent::TokenManager(crate::Event::::AVTGrowthLifted { treasury_share: expected_treasury_share, collators_share: lifted_amount - expected_treasury_share, eth_tx_hash: growth_eth_event.event_id.transaction_hash @@ -99,7 +99,7 @@ mod lifted_growth_processed_correctly { // Check expected event has been emitted assert!(System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::AVTGrowthLifted { + RuntimeEvent::TokenManager(crate::Event::::AVTGrowthLifted { treasury_share: expected_treasury_share, collators_share: lifted_amount - expected_treasury_share, eth_tx_hash: growth_eth_event.event_id.transaction_hash @@ -249,7 +249,7 @@ mod transfering_from_treasury_works { let transfer_amount = new_treasury_balance - 1; assert_ok!(TokenManager::transfer_from_treasury( - Origin::root(), + RuntimeOrigin::root(), recipient, transfer_amount )); @@ -262,10 +262,12 @@ mod transfering_from_treasury_works { // Check expected event has been emitted assert!(System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::AvtTransferredFromTreasury { - recipient, - amount: transfer_amount, - }))); + RuntimeEvent::TokenManager( + crate::Event::::AvtTransferredFromTreasury { + recipient, + amount: transfer_amount, + } + ))); }); } } @@ -312,7 +314,7 @@ mod transfering_from_treasury_fails { assert_noop!( TokenManager::transfer_from_treasury( - Origin::signed(recipient), + RuntimeOrigin::signed(recipient), recipient, treasury_balance - 1 ), @@ -336,7 +338,7 @@ mod transfering_from_treasury_fails { assert_noop!( TokenManager::transfer_from_treasury( - Origin::root(), + RuntimeOrigin::root(), recipient, treasury_balance + 1 ), diff --git a/pallets/token-manager/src/test_non_avt_tokens.rs b/pallets/token-manager/src/test_non_avt_tokens.rs index 0ee3e2c47..57065fcaa 100644 --- a/pallets/token-manager/src/test_non_avt_tokens.rs +++ b/pallets/token-manager/src/test_non_avt_tokens.rs @@ -16,7 +16,7 @@ #![cfg(test)] use crate::{ - mock::{Event, *}, + mock::{RuntimeEvent, *}, *, }; use frame_support::{assert_noop, assert_ok}; @@ -51,7 +51,7 @@ fn avn_test_lift_to_zero_balance_account_should_succeed() { ); assert!(System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::TokenLifted { + RuntimeEvent::TokenManager(crate::Event::::TokenLifted { token_id: NON_AVT_TOKEN_ID, recipient: mock_data.receiver_account_id, token_balance: mock_data.token_balance_123_tokens, @@ -83,7 +83,7 @@ fn avn_test_lift_to_non_zero_balance_account_should_succeed() { assert_eq!(new_token_balance, expected_token_balance); assert!(System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::TokenLifted { + RuntimeEvent::TokenManager(crate::Event::::TokenLifted { token_id: NON_AVT_TOKEN_ID, recipient: mock_data.receiver_account_id, token_balance: mock_data.token_balance_123_tokens, @@ -120,7 +120,7 @@ fn avn_test_lift_max_balance_to_zero_balance_account_should_succeed() { let token_balance_u128_max_amount = MockData::get_token_balance(u128_max_amount); assert!(System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::TokenLifted { + RuntimeEvent::TokenManager(crate::Event::::TokenLifted { token_id: NON_AVT_TOKEN_ID, recipient: mock_data.receiver_account_id, token_balance: token_balance_u128_max_amount, @@ -154,7 +154,7 @@ fn avn_test_lift_max_balance_to_non_zero_balance_account_should_fail_with_overfl let token_balance_u128_max_amount = MockData::get_token_balance(u128_max_amount); assert!(!System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::TokenLifted { + RuntimeEvent::TokenManager(crate::Event::::TokenLifted { token_id: NON_AVT_TOKEN_ID, recipient: mock_data.receiver_account_id, token_balance: token_balance_u128_max_amount, @@ -209,7 +209,7 @@ fn avn_test_signed_transfer_with_valid_input_should_succeed() { assert_eq!(System::events().len(), 0); assert_ok!(TokenManager::signed_transfer( - Origin::signed(sender_account_id), + RuntimeOrigin::signed(sender_account_id), proof, sender_account_id, recipient_account_id, @@ -236,7 +236,7 @@ fn avn_test_signed_transfer_with_valid_input_should_succeed() { ); assert!(System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::TokenTransferred { + RuntimeEvent::TokenManager(crate::Event::::TokenTransferred { token_id: NON_AVT_TOKEN_ID, sender: sender_account_id, recipient: recipient_account_id, @@ -292,7 +292,7 @@ fn avn_test_signed_transfer_of_0_token_should_succeed() { assert_eq!(System::events().len(), 0); assert_ok!(TokenManager::signed_transfer( - Origin::signed(sender_account_id), + RuntimeOrigin::signed(sender_account_id), proof, sender_account_id, recipient_account_id, @@ -319,7 +319,7 @@ fn avn_test_signed_transfer_of_0_token_should_succeed() { ); assert!(System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::TokenTransferred { + RuntimeEvent::TokenManager(crate::Event::::TokenTransferred { token_id: NON_AVT_TOKEN_ID, sender: sender_account_id, recipient: recipient_account_id, @@ -370,7 +370,7 @@ fn avn_test_self_signed_transfer_should_succeed() { assert_eq!(System::events().len(), 0); assert_ok!(TokenManager::signed_transfer( - Origin::signed(sender_account_id), + RuntimeOrigin::signed(sender_account_id), proof, sender_account_id, recipient_account_id, @@ -393,7 +393,7 @@ fn avn_test_self_signed_transfer_should_succeed() { ); assert!(System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::TokenTransferred { + RuntimeEvent::TokenManager(crate::Event::::TokenTransferred { token_id: NON_AVT_TOKEN_ID, sender: sender_account_id, recipient: recipient_account_id, @@ -445,7 +445,7 @@ fn avn_test_self_signed_transfer_of_0_token_should_succeed() { assert_eq!(System::events().len(), 0); assert_ok!(TokenManager::signed_transfer( - Origin::signed(sender_account_id), + RuntimeOrigin::signed(sender_account_id), proof, sender_account_id, recipient_account_id, @@ -468,7 +468,7 @@ fn avn_test_self_signed_transfer_of_0_token_should_succeed() { ); assert!(System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::TokenTransferred { + RuntimeEvent::TokenManager(crate::Event::::TokenTransferred { token_id: NON_AVT_TOKEN_ID, sender: sender_account_id, recipient: recipient_account_id, @@ -516,7 +516,7 @@ fn avn_test_signed_transfer_fails_when_nonce_is_less_than_account_nonce() { assert_eq!(System::events().len(), 0); assert_noop!( TokenManager::signed_transfer( - Origin::signed(sender_account_id), + RuntimeOrigin::signed(sender_account_id), proof, sender_account_id, recipient_account_id, @@ -567,7 +567,7 @@ fn avn_test_signed_transfer_fails_when_nonce_is_more_than_account_nonce() { assert_eq!(System::events().len(), 0); assert_noop!( TokenManager::signed_transfer( - Origin::signed(sender_account_id), + RuntimeOrigin::signed(sender_account_id), proof, sender_account_id, recipient_account_id, @@ -629,7 +629,7 @@ fn avn_test_signed_transfer_fails_when_sender_has_insufficient_fund() { assert_noop!( TokenManager::signed_transfer( - Origin::signed(sender_account_id), + RuntimeOrigin::signed(sender_account_id), proof, sender_account_id, recipient_account_id, @@ -703,7 +703,7 @@ fn avn_test_signed_transfer_fails_when_amount_causes_balance_overflow() { assert_noop!( TokenManager::signed_transfer( - Origin::signed(sender_account_id), + RuntimeOrigin::signed(sender_account_id), proof, sender_account_id, recipient_account_id, @@ -751,7 +751,7 @@ fn avn_test_lower_all_non_avt_token_succeed() { let amount = from_account_balance_before; assert_ok!(TokenManager::lower( - Origin::signed(from_account_id), + RuntimeOrigin::signed(from_account_id), from_account_id, NON_AVT_TOKEN_ID, amount, @@ -762,7 +762,7 @@ fn avn_test_lower_all_non_avt_token_succeed() { from_account_balance_before - amount ); assert!(System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::TokenLowered { + RuntimeEvent::TokenManager(crate::Event::::TokenLowered { token_id: NON_AVT_TOKEN_ID, sender: from_account_id, recipient: to_account_id, @@ -784,7 +784,7 @@ fn avn_test_lower_some_non_avt_token_succeed() { let amount = from_account_balance_before / 2; assert_ok!(TokenManager::lower( - Origin::signed(from_account_id), + RuntimeOrigin::signed(from_account_id), from_account_id, NON_AVT_TOKEN_ID, amount, @@ -795,7 +795,7 @@ fn avn_test_lower_some_non_avt_token_succeed() { from_account_balance_before - amount ); assert!(System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::TokenLowered { + RuntimeEvent::TokenManager(crate::Event::::TokenLowered { token_id: NON_AVT_TOKEN_ID, sender: from_account_id, recipient: to_account_id, @@ -819,7 +819,7 @@ fn avn_test_lower_non_avt_token_should_fail_when_sender_does_not_have_enough_tok assert_noop!( TokenManager::lower( - Origin::signed(from_account_id), + RuntimeOrigin::signed(from_account_id), from_account_id, NON_AVT_TOKEN_ID, amount, @@ -845,7 +845,7 @@ fn avn_test_non_avt_token_total_lowered_amount_greater_than_balance_max_value_ok let mut amount = from_account_balance_before; assert_ok!(TokenManager::lower( - Origin::signed(from_account_id), + RuntimeOrigin::signed(from_account_id), from_account_id, NON_AVT_TOKEN_ID, amount, @@ -856,7 +856,7 @@ fn avn_test_non_avt_token_total_lowered_amount_greater_than_balance_max_value_ok from_account_balance_before - amount ); assert!(System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::TokenLowered { + RuntimeEvent::TokenManager(crate::Event::::TokenLowered { token_id: NON_AVT_TOKEN_ID, sender: from_account_id, recipient: to_account_id, @@ -871,7 +871,7 @@ fn avn_test_non_avt_token_total_lowered_amount_greater_than_balance_max_value_ok ::Balances::get((NON_AVT_TOKEN_ID, from_account_id)); assert_ok!(TokenManager::lower( - Origin::signed(from_account_id), + RuntimeOrigin::signed(from_account_id), from_account_id, NON_AVT_TOKEN_ID, amount, @@ -882,7 +882,7 @@ fn avn_test_non_avt_token_total_lowered_amount_greater_than_balance_max_value_ok from_account_balance_before - amount ); assert!(System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::TokenLowered { + RuntimeEvent::TokenManager(crate::Event::::TokenLowered { token_id: NON_AVT_TOKEN_ID, sender: from_account_id, recipient: to_account_id, diff --git a/pallets/token-manager/src/test_proxying_signed_lower.rs b/pallets/token-manager/src/test_proxying_signed_lower.rs index e13b64095..429822a67 100644 --- a/pallets/token-manager/src/test_proxying_signed_lower.rs +++ b/pallets/token-manager/src/test_proxying_signed_lower.rs @@ -17,12 +17,13 @@ #![cfg(test)] use crate::{ self as token_manager, - mock::{Balances, Call as MockCall, Event, *}, + mock::{Balances, RuntimeCall as MockCall, RuntimeEvent, *}, Call, *, }; use codec::Encode; use frame_support::{assert_err, assert_noop, assert_ok}; use hex_literal::hex; +use pallet_parachain_staking::Weight; use pallet_transaction_payment::ChargeTransactionPayment; use sp_core::{sr25519, Pair}; use sp_runtime::{ @@ -62,20 +63,20 @@ fn default_t1_recipient() -> H160 { fn pay_gas_and_proxy_call( relayer: &AccountId, - outer_call: &::Call, - inner_call: Box<::Call>, + outer_call: &::RuntimeCall, + inner_call: Box<::RuntimeCall>, ) -> DispatchResult { // See: /primitives/runtime/src/traits.rs for more details as SignedExtension>::pre_dispatch( ChargeTransactionPayment::from(0), // we do not pay any tip relayer, outer_call, - &info_from_weight(1), + &info_from_weight(Weight::from_ref_time(1)), TX_LEN, ) .map_err(|e| <&'static str>::from(e))?; - return TokenManager::proxy(Origin::signed(*relayer), inner_call) + return TokenManager::proxy(RuntimeOrigin::signed(*relayer), inner_call) } fn pay_gas_and_call_lower_directly( @@ -84,19 +85,19 @@ fn pay_gas_and_call_lower_directly( amount: ::TokenBalance, t1_recipient: H160, proof: Proof, - call: &::Call, + call: &::RuntimeCall, ) -> DispatchResultWithPostInfo { as SignedExtension>::pre_dispatch( ChargeTransactionPayment::from(0), sender, call, - &info_from_weight(1), + &info_from_weight(Weight::from_ref_time(1)), TX_LEN, ) .map_err(|e| <&'static str>::from(e))?; return TokenManager::signed_lower( - Origin::signed(*sender), + RuntimeOrigin::signed(*sender), proof, *sender, token_id, @@ -174,19 +175,19 @@ fn create_proof_for_signed_lower( return build_proof(from, relayer, signature) } -fn check_proxy_lower_default_call_succeed(call: Box<::Call>) { +fn check_proxy_lower_default_call_succeed(call: Box<::RuntimeCall>) { let call_hash = Hashing::hash_of(&call); - assert_ok!(TokenManager::proxy(Origin::signed(default_relayer()), call)); + assert_ok!(TokenManager::proxy(RuntimeOrigin::signed(default_relayer()), call)); assert_eq!(System::events().len(), 2); assert!(System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::CallDispatched { + RuntimeEvent::TokenManager(crate::Event::::CallDispatched { relayer: default_relayer(), call_hash }))); assert!(System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::TokenLowered { + RuntimeEvent::TokenManager(crate::Event::::TokenLowered { token_id: NON_AVT_TOKEN_ID, sender: default_sender(), recipient: default_receiver_account_id(), @@ -238,7 +239,7 @@ mod proxy_signed_lower { t1_recipient, })); - assert_ok!(TokenManager::proxy(Origin::signed(relayer), call.clone())); + assert_ok!(TokenManager::proxy(RuntimeOrigin::signed(relayer), call.clone())); assert_eq!( ::Balances::get((NON_AVT_TOKEN_ID, sender)), @@ -266,11 +267,11 @@ mod proxy_signed_lower { })); assert_eq!(System::events().len(), 0); - assert_ok!(TokenManager::proxy(Origin::signed(relayer), call.clone())); + assert_ok!(TokenManager::proxy(RuntimeOrigin::signed(relayer), call.clone())); let call_hash = Hashing::hash_of(&call); assert!(System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::CallDispatched { + RuntimeEvent::TokenManager(crate::Event::::CallDispatched { relayer, call_hash }))); @@ -279,7 +280,7 @@ mod proxy_signed_lower { // that lower was called. In this case we will check that the // Lowered signal was emitted. assert!(System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::TokenLowered { + RuntimeEvent::TokenManager(crate::Event::::TokenLowered { token_id: NON_AVT_TOKEN_ID, sender, recipient: recipient_account_id, @@ -309,7 +310,7 @@ mod proxy_signed_lower { let call_hash = Hashing::hash_of(&call); assert_eq!(System::events().len(), 0); - assert_ok!(TokenManager::proxy(Origin::signed(relayer), call)); + assert_ok!(TokenManager::proxy(RuntimeOrigin::signed(relayer), call)); assert_eq!( ::Balances::get((NON_AVT_TOKEN_ID, sender)), @@ -317,12 +318,12 @@ mod proxy_signed_lower { ); assert!(System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::CallDispatched { + RuntimeEvent::TokenManager(crate::Event::::CallDispatched { relayer, call_hash }))); assert!(System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::TokenLowered { + RuntimeEvent::TokenManager(crate::Event::::TokenLowered { token_id: NON_AVT_TOKEN_ID, sender, recipient: recipient_account_id, @@ -356,7 +357,7 @@ mod proxy_signed_lower { )); assert_err!( - TokenManager::proxy(Origin::signed(relayer), call), + TokenManager::proxy(RuntimeOrigin::signed(relayer), call), Error::::UnauthorizedSignedLowerTransaction ); @@ -387,7 +388,7 @@ mod proxy_signed_lower { assert_eq!(System::events().len(), 0); assert_err!( - TokenManager::proxy(Origin::signed(relayer), call), + TokenManager::proxy(RuntimeOrigin::signed(relayer), call), Error::::UnauthorizedSignedLowerTransaction ); @@ -434,7 +435,7 @@ mod proxy_signed_lower { })); assert_err!( - TokenManager::proxy(Origin::signed(relayer), call), + TokenManager::proxy(RuntimeOrigin::signed(relayer), call), Error::::UnauthorizedSignedLowerTransaction ); assert_eq!(System::events().len(), 0); @@ -482,7 +483,7 @@ mod proxy_signed_lower { })); assert_err!( - TokenManager::proxy(Origin::signed(relayer), call), + TokenManager::proxy(RuntimeOrigin::signed(relayer), call), Error::::SenderNotValid ); assert_eq!(System::events().len(), 0); @@ -522,7 +523,7 @@ mod proxy_signed_lower { })); assert_err!( - TokenManager::proxy(Origin::signed(relayer), call.clone()), + TokenManager::proxy(RuntimeOrigin::signed(relayer), call.clone()), Error::::UnauthorizedProxyTransaction ); assert_eq!(System::events().len(), 0); @@ -569,7 +570,7 @@ mod proxy_signed_lower { })); assert_err!( - TokenManager::proxy(Origin::signed(relayer), call), + TokenManager::proxy(RuntimeOrigin::signed(relayer), call), Error::::UnauthorizedSignedLowerTransaction ); assert_eq!(System::events().len(), 0); @@ -620,7 +621,7 @@ mod proxy_signed_lower { t1_recipient, })); assert_err!( - TokenManager::proxy(Origin::signed(relayer), call), + TokenManager::proxy(RuntimeOrigin::signed(relayer), call), Error::::UnauthorizedSignedLowerTransaction ); @@ -662,7 +663,7 @@ mod signed_lower { let proof = create_proof_for_signed_lower_with_nonce(NON_ZERO_NONCE); assert_ok!(TokenManager::signed_lower( - Origin::signed(sender), + RuntimeOrigin::signed(sender), proof, sender, NON_AVT_TOKEN_ID, @@ -688,7 +689,7 @@ mod signed_lower { assert_eq!(System::events().len(), 0); assert_ok!(TokenManager::signed_lower( - Origin::signed(sender), + RuntimeOrigin::signed(sender), proof, sender, NON_AVT_TOKEN_ID, @@ -697,7 +698,7 @@ mod signed_lower { )); assert!(System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::TokenLowered { + RuntimeEvent::TokenManager(crate::Event::::TokenLowered { token_id: NON_AVT_TOKEN_ID, sender, recipient: recipient_account_id, @@ -792,13 +793,13 @@ mod fees { // Check the effects of the transaction let call_hash = Hashing::hash_of(&inner_call); assert!(System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::CallDispatched { + RuntimeEvent::TokenManager(crate::Event::::CallDispatched { relayer, call_hash }))); assert!(System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::TokenLowered { + RuntimeEvent::TokenManager(crate::Event::::TokenLowered { token_id: NON_AVT_TOKEN_ID, sender, recipient: recipient_account_id, @@ -868,7 +869,7 @@ mod fees { DEFAULT_AMOUNT ); assert!(System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::TokenLowered { + RuntimeEvent::TokenManager(crate::Event::::TokenLowered { token_id: NON_AVT_TOKEN_ID, sender, recipient: recipient_account_id, @@ -1018,7 +1019,7 @@ mod wrapped_signature_verification { t1_recipient, })); - assert_ok!(TokenManager::proxy(Origin::signed(relayer), call.clone())); + assert_ok!(TokenManager::proxy(RuntimeOrigin::signed(relayer), call.clone())); assert_eq!(::Balances::get((token, sender)), amount); }); diff --git a/pallets/token-manager/src/test_proxying_signed_transfer.rs b/pallets/token-manager/src/test_proxying_signed_transfer.rs index 376e50cb0..78778576f 100644 --- a/pallets/token-manager/src/test_proxying_signed_transfer.rs +++ b/pallets/token-manager/src/test_proxying_signed_transfer.rs @@ -17,11 +17,12 @@ #![cfg(test)] use crate::{ self as token_manager, - mock::{Balances, Event, *}, + mock::{Balances, RuntimeEvent, *}, *, }; use codec::Encode; use frame_support::{assert_err, assert_noop, assert_ok}; +use pallet_parachain_staking::Weight; use pallet_transaction_payment::ChargeTransactionPayment; use sp_core::{sr25519, Pair}; use sp_runtime::{ @@ -56,20 +57,20 @@ fn default_relayer() -> AccountId { fn pay_gas_and_proxy_call( relayer: &AccountId, - outer_call: &::Call, - inner_call: Box<::Call>, + outer_call: &::RuntimeCall, + inner_call: Box<::RuntimeCall>, ) -> DispatchResult { // See: /primitives/runtime/src/traits.rs for more details as SignedExtension>::pre_dispatch( ChargeTransactionPayment::from(0), // we do not pay any tip relayer, outer_call, - &info_from_weight(1), + &info_from_weight(Weight::from_ref_time(1)), TX_LEN, ) .map_err(|e| <&'static str>::from(e))?; - return TokenManager::proxy(Origin::signed(*relayer), inner_call) + return TokenManager::proxy(RuntimeOrigin::signed(*relayer), inner_call) } fn pay_gas_and_call_transfer_directly( @@ -78,19 +79,19 @@ fn pay_gas_and_call_transfer_directly( token_id: ::TokenId, amount: ::TokenBalance, proof: Proof, - call: &::Call, + call: &::RuntimeCall, ) -> DispatchResult { as SignedExtension>::pre_dispatch( ChargeTransactionPayment::from(0), sender, call, - &info_from_weight(1), + &info_from_weight(Weight::from_ref_time(1)), TX_LEN, ) .map_err(|e| <&'static str>::from(e))?; return TokenManager::signed_transfer( - Origin::signed(*sender), + RuntimeOrigin::signed(*sender), proof, *sender, *receiver, @@ -170,18 +171,18 @@ fn create_proof_for_signed_transfer( return build_proof(from, relayer, signature) } -fn check_proxy_transfer_default_call_succeed(call: Box<::Call>) { +fn check_proxy_transfer_default_call_succeed(call: Box<::RuntimeCall>) { let call_hash = Hashing::hash_of(&call); - assert_ok!(TokenManager::proxy(Origin::signed(default_relayer()), call)); + assert_ok!(TokenManager::proxy(RuntimeOrigin::signed(default_relayer()), call)); assert_eq!(System::events().len(), 2); assert!(System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::CallDispatched { + RuntimeEvent::TokenManager(crate::Event::::CallDispatched { relayer: default_relayer(), call_hash }))); assert!(System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::TokenTransferred { + RuntimeEvent::TokenManager(crate::Event::::TokenTransferred { token_id: NON_AVT_TOKEN_ID, sender: default_sender(), recipient: default_receiver(), @@ -200,18 +201,19 @@ fn avn_test_proxy_signed_transfer_succeeds() { setup(&sender, NON_ZERO_NONCE); let proof = create_proof_for_signed_transfer_with_nonce(NON_ZERO_NONCE); - let call = - Box::new(mock::Call::TokenManager(super::Call::::signed_transfer { + let call = Box::new(mock::RuntimeCall::TokenManager( + super::Call::::signed_transfer { proof, from: sender, to: recipient, token_id: NON_AVT_TOKEN_ID, amount: DEFAULT_AMOUNT, - })); + }, + )); let call_hash = Hashing::hash_of(&call); assert_eq!(System::events().len(), 0); - assert_ok!(TokenManager::proxy(Origin::signed(relayer), call)); + assert_ok!(TokenManager::proxy(RuntimeOrigin::signed(relayer), call)); assert_eq!( ::Balances::get((NON_AVT_TOKEN_ID, sender)), @@ -223,7 +225,7 @@ fn avn_test_proxy_signed_transfer_succeeds() { ); assert!(System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::CallDispatched { + RuntimeEvent::TokenManager(crate::Event::::CallDispatched { relayer, call_hash }))); @@ -232,7 +234,7 @@ fn avn_test_proxy_signed_transfer_succeeds() { // transfer was called. In this case we will check that the Transferred signal was // emitted. assert!(System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::TokenTransferred { + RuntimeEvent::TokenManager(crate::Event::::TokenTransferred { token_id: NON_AVT_TOKEN_ID, sender, recipient, @@ -268,18 +270,19 @@ fn avt_proxy_signed_transfer_succeeds() { &key_pair_for_account_with_100_avt(), ); - let call = - Box::new(mock::Call::TokenManager(super::Call::::signed_transfer { + let call = Box::new(mock::RuntimeCall::TokenManager( + super::Call::::signed_transfer { proof, from: sender, to: recipient, token_id: AVT_TOKEN_CONTRACT, amount: DEFAULT_AMOUNT, - })); + }, + )); let call_hash = Hashing::hash_of(&call); assert_eq!(System::events().len(), 0); - assert_ok!(TokenManager::proxy(Origin::signed(relayer), call)); + assert_ok!(TokenManager::proxy(RuntimeOrigin::signed(relayer), call)); // Show that we have transferred not created or removed avt from the system assert_eq!(init_total_avt_issuance, Balances::total_issuance()); @@ -293,7 +296,7 @@ fn avt_proxy_signed_transfer_succeeds() { // Check for events assert!(System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::CallDispatched { + RuntimeEvent::TokenManager(crate::Event::::CallDispatched { relayer, call_hash }))); @@ -302,7 +305,7 @@ fn avt_proxy_signed_transfer_succeeds() { // transfer was called. In this case we will check that the Transferred signal was // emitted. assert!(System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::TokenTransferred { + RuntimeEvent::TokenManager(crate::Event::::TokenTransferred { token_id: AVT_TOKEN_CONTRACT, sender, recipient, @@ -323,7 +326,7 @@ fn avn_test_direct_signed_transfer_succeeds() { assert_eq!(System::events().len(), 0); assert_ok!(TokenManager::signed_transfer( - Origin::signed(sender), + RuntimeOrigin::signed(sender), proof, sender, recipient, @@ -340,7 +343,7 @@ fn avn_test_direct_signed_transfer_succeeds() { DEFAULT_AMOUNT ); assert!(System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::TokenTransferred { + RuntimeEvent::TokenManager(crate::Event::::TokenTransferred { token_id: NON_AVT_TOKEN_ID, sender, recipient, @@ -378,7 +381,7 @@ fn avt_direct_signed_transfer_succeeds() { assert_eq!(System::events().len(), 0); assert_ok!(TokenManager::signed_transfer( - Origin::signed(sender), + RuntimeOrigin::signed(sender), proof, sender, recipient, @@ -394,7 +397,7 @@ fn avt_direct_signed_transfer_succeeds() { assert_eq!(NON_ZERO_NONCE + 1, ::Nonces::get(sender)); assert!(System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::TokenTransferred { + RuntimeEvent::TokenManager(crate::Event::::TokenTransferred { token_id: AVT_TOKEN_CONTRACT, sender, recipient, @@ -414,18 +417,19 @@ fn avn_test_proxy_signed_transfer_succeeds_with_nonce_zero() { default_setup(); let proof = create_default_proof_for_signed_transfer(); - let call = - Box::new(mock::Call::TokenManager(super::Call::::signed_transfer { + let call = Box::new(mock::RuntimeCall::TokenManager( + super::Call::::signed_transfer { proof, from: sender, to: recipient, token_id: NON_AVT_TOKEN_ID, amount: DEFAULT_AMOUNT, - })); + }, + )); let call_hash = Hashing::hash_of(&call); assert_eq!(System::events().len(), 0); - assert_ok!(TokenManager::proxy(Origin::signed(relayer), call)); + assert_ok!(TokenManager::proxy(RuntimeOrigin::signed(relayer), call)); assert_eq!( ::Balances::get((NON_AVT_TOKEN_ID, sender)), @@ -437,12 +441,12 @@ fn avn_test_proxy_signed_transfer_succeeds_with_nonce_zero() { ); assert!(System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::CallDispatched { + RuntimeEvent::TokenManager(crate::Event::::CallDispatched { relayer, call_hash }))); assert!(System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::TokenTransferred { + RuntimeEvent::TokenManager(crate::Event::::TokenTransferred { token_id: NON_AVT_TOKEN_ID, sender, recipient, @@ -465,17 +469,18 @@ fn avn_test_proxy_signed_transfer_fails_for_mismatching_proof_nonce() { for bad_nonce in bad_nonces.iter() { let proof = create_proof_for_signed_transfer_with_nonce(*bad_nonce); - let call = - Box::new(mock::Call::TokenManager(super::Call::::signed_transfer { + let call = Box::new(mock::RuntimeCall::TokenManager( + super::Call::::signed_transfer { proof, from: sender, to: recipient, token_id: NON_AVT_TOKEN_ID, amount: DEFAULT_AMOUNT, - })); + }, + )); assert_err!( - TokenManager::proxy(Origin::signed(relayer), call), + TokenManager::proxy(RuntimeOrigin::signed(relayer), call), Error::::UnauthorizedSignedTransferTransaction ); @@ -497,24 +502,25 @@ fn avn_test_proxy_signed_transfer_fails_with_mismatched_proof_other_amount() { default_setup(); let proof = create_default_proof_for_signed_transfer(); - let call = - Box::new(mock::Call::TokenManager(super::Call::::signed_transfer { + let call = Box::new(mock::RuntimeCall::TokenManager( + super::Call::::signed_transfer { proof: proof.clone(), from: sender, to: recipient, token_id: NON_AVT_TOKEN_ID, amount: mismatching_amount, - })); + }, + )); assert_eq!(System::events().len(), 0); assert_err!( - TokenManager::proxy(Origin::signed(relayer), call), + TokenManager::proxy(RuntimeOrigin::signed(relayer), call), Error::::UnauthorizedSignedTransferTransaction ); // Show that it works with the correct input let proof = create_default_proof_for_signed_transfer(); - check_proxy_transfer_default_call_succeed(Box::new(mock::Call::TokenManager( + check_proxy_transfer_default_call_succeed(Box::new(mock::RuntimeCall::TokenManager( super::Call::::signed_transfer { proof, from: sender, @@ -547,24 +553,25 @@ fn avn_test_proxy_signed_transfer_fails_with_mismatched_proof_other_keys() { &other_sender_keys, ); - let call = - Box::new(mock::Call::TokenManager(super::Call::::signed_transfer { + let call = Box::new(mock::RuntimeCall::TokenManager( + super::Call::::signed_transfer { proof: mismatching_proof, from: sender, to: recipient, token_id: NON_AVT_TOKEN_ID, amount: DEFAULT_AMOUNT, - })); + }, + )); assert_err!( - TokenManager::proxy(Origin::signed(relayer), call), + TokenManager::proxy(RuntimeOrigin::signed(relayer), call), Error::::UnauthorizedSignedTransferTransaction ); assert_eq!(System::events().len(), 0); // Show that it works with the correct input let proof = create_default_proof_for_signed_transfer(); - check_proxy_transfer_default_call_succeed(Box::new(mock::Call::TokenManager( + check_proxy_transfer_default_call_succeed(Box::new(mock::RuntimeCall::TokenManager( super::Call::::signed_transfer { proof, from: sender, @@ -598,24 +605,25 @@ fn avn_test_proxy_signed_transfer_fails_with_mismatched_proof_other_sender() { &sender_keys, ); - let call = - Box::new(mock::Call::TokenManager(super::Call::::signed_transfer { + let call = Box::new(mock::RuntimeCall::TokenManager( + super::Call::::signed_transfer { proof: mismatching_proof, from: sender, to: recipient, token_id: NON_AVT_TOKEN_ID, amount: DEFAULT_AMOUNT, - })); + }, + )); assert_err!( - TokenManager::proxy(Origin::signed(relayer), call), + TokenManager::proxy(RuntimeOrigin::signed(relayer), call), Error::::SenderNotValid ); assert_eq!(System::events().len(), 0); // Show that it works with the correct input let proof = create_default_proof_for_signed_transfer(); - check_proxy_transfer_default_call_succeed(Box::new(mock::Call::TokenManager( + check_proxy_transfer_default_call_succeed(Box::new(mock::RuntimeCall::TokenManager( super::Call::::signed_transfer { proof, from: sender, @@ -639,24 +647,25 @@ fn avn_test_proxy_signed_transfer_fails_with_mismatched_proof_other_relayer() { default_setup(); let mismatching_proof = create_proof_for_signed_transfer_with_relayer(&other_relayer); - let call = - Box::new(mock::Call::TokenManager(super::Call::::signed_transfer { + let call = Box::new(mock::RuntimeCall::TokenManager( + super::Call::::signed_transfer { proof: mismatching_proof, from: sender, to: recipient, token_id: NON_AVT_TOKEN_ID, amount: DEFAULT_AMOUNT, - })); + }, + )); assert_err!( - TokenManager::proxy(Origin::signed(relayer), call.clone()), + TokenManager::proxy(RuntimeOrigin::signed(relayer), call.clone()), Error::::UnauthorizedProxyTransaction ); assert_eq!(System::events().len(), 0); // Show that it works with the correct input let proof = create_default_proof_for_signed_transfer(); - check_proxy_transfer_default_call_succeed(Box::new(mock::Call::TokenManager( + check_proxy_transfer_default_call_succeed(Box::new(mock::RuntimeCall::TokenManager( super::Call::::signed_transfer { proof, from: sender, @@ -690,24 +699,25 @@ fn avn_test_proxy_signed_transfer_fails_with_mismatched_proof_other_recipient() &sender_keys, ); - let call = - Box::new(mock::Call::TokenManager(super::Call::::signed_transfer { + let call = Box::new(mock::RuntimeCall::TokenManager( + super::Call::::signed_transfer { proof: mismatching_proof, from: sender, to: recipient, token_id: NON_AVT_TOKEN_ID, amount: DEFAULT_AMOUNT, - })); + }, + )); assert_err!( - TokenManager::proxy(Origin::signed(relayer), call), + TokenManager::proxy(RuntimeOrigin::signed(relayer), call), Error::::UnauthorizedSignedTransferTransaction ); assert_eq!(System::events().len(), 0); // Show that it works with the correct input let proof = create_default_proof_for_signed_transfer(); - check_proxy_transfer_default_call_succeed(Box::new(mock::Call::TokenManager( + check_proxy_transfer_default_call_succeed(Box::new(mock::RuntimeCall::TokenManager( super::Call::::signed_transfer { proof, from: sender, @@ -741,24 +751,25 @@ fn avn_test_proxy_signed_transfer_fails_with_mismatched_proof_other_token_id() { &sender_keys, ); - let call = - Box::new(mock::Call::TokenManager(super::Call::::signed_transfer { + let call = Box::new(mock::RuntimeCall::TokenManager( + super::Call::::signed_transfer { proof: mismatching_proof, from: sender, to: recipient, token_id: NON_AVT_TOKEN_ID, amount: DEFAULT_AMOUNT, - })); + }, + )); assert_err!( - TokenManager::proxy(Origin::signed(relayer), call), + TokenManager::proxy(RuntimeOrigin::signed(relayer), call), Error::::UnauthorizedSignedTransferTransaction ); assert_eq!(System::events().len(), 0); // Show that it works with the correct input let proof = create_default_proof_for_signed_transfer(); - check_proxy_transfer_default_call_succeed(Box::new(mock::Call::TokenManager( + check_proxy_transfer_default_call_succeed(Box::new(mock::RuntimeCall::TokenManager( super::Call::::signed_transfer { proof, from: sender, @@ -795,16 +806,17 @@ fn avn_test_proxy_signed_transfer_fails_with_mismatched_proof_other_context() { let mismatching_proof = Proof { signer: sender, relayer, signature: alternative_signature }; - let call = - Box::new(mock::Call::TokenManager(super::Call::::signed_transfer { + let call = Box::new(mock::RuntimeCall::TokenManager( + super::Call::::signed_transfer { proof: mismatching_proof, from: sender, to: recipient, token_id: NON_AVT_TOKEN_ID, amount: DEFAULT_AMOUNT, - })); + }, + )); assert_err!( - TokenManager::proxy(Origin::signed(relayer), call), + TokenManager::proxy(RuntimeOrigin::signed(relayer), call), Error::::UnauthorizedSignedTransferTransaction ); @@ -812,7 +824,7 @@ fn avn_test_proxy_signed_transfer_fails_with_mismatched_proof_other_context() { // Show that it works with the correct input let proof = create_default_proof_for_signed_transfer(); - check_proxy_transfer_default_call_succeed(Box::new(mock::Call::TokenManager( + check_proxy_transfer_default_call_succeed(Box::new(mock::RuntimeCall::TokenManager( super::Call::::signed_transfer { proof, from: sender, @@ -828,9 +840,10 @@ fn avn_test_proxy_signed_transfer_fails_with_mismatched_proof_other_context() { fn avn_test_unsupported_proxy_call() { let mut ext = ExtBuilder::build_default().as_externality(); ext.execute_with(|| { - let call = Box::new(mock::Call::System(frame_system::Call::remark { remark: vec![] })); + let call = + Box::new(mock::RuntimeCall::System(frame_system::Call::remark { remark: vec![] })); assert_noop!( - TokenManager::proxy(Origin::signed(default_sender()), call), + TokenManager::proxy(RuntimeOrigin::signed(default_sender()), call), Error::::TransactionNotSupported ); }); @@ -846,14 +859,15 @@ fn avn_test_get_proof_succeeds_for_valid_cases() { let recipient = default_receiver(); let proof = create_default_proof_for_signed_transfer(); - let call = - Box::new(mock::Call::TokenManager(super::Call::::signed_transfer { + let call = Box::new(mock::RuntimeCall::TokenManager( + super::Call::::signed_transfer { proof: proof.clone(), from: sender, to: recipient, token_id: NON_AVT_TOKEN_ID, amount: DEFAULT_AMOUNT, - })); + }, + )); let result = TokenManager::get_proof(&call); assert!(result.is_ok()); @@ -865,7 +879,7 @@ fn avn_test_get_proof_succeeds_for_valid_cases() { fn avn_test_get_proof_fails_for_invalid_calls() { let mut ext = ExtBuilder::build_default().as_externality(); ext.execute_with(|| { - let invalid_call = mock::Call::System(frame_system::Call::remark { remark: vec![] }); + let invalid_call = mock::RuntimeCall::System(frame_system::Call::remark { remark: vec![] }); assert!(matches!( TokenManager::get_proof(&invalid_call), @@ -898,16 +912,18 @@ fn avn_test_proxy_gas_costs_paid_correctly() { assert_eq!(::Balances::get((NON_AVT_TOKEN_ID, recipient)), 0); // Prepare the calls - let inner_call = - Box::new(mock::Call::TokenManager(super::Call::::signed_transfer { + let inner_call = Box::new(mock::RuntimeCall::TokenManager( + super::Call::::signed_transfer { proof: proof.clone(), from: sender, to: recipient, token_id: NON_AVT_TOKEN_ID, amount: DEFAULT_AMOUNT, - })); - let outer_call = - &mock::Call::TokenManager(token_manager::Call::proxy { call: inner_call.clone() }); + }, + )); + let outer_call = &mock::RuntimeCall::TokenManager(token_manager::Call::proxy { + call: inner_call.clone(), + }); // Pay fees and submit the transaction assert_ok!(pay_gas_and_proxy_call(&relayer, outer_call, inner_call.clone())); @@ -915,13 +931,13 @@ fn avn_test_proxy_gas_costs_paid_correctly() { // Check the effects of the transaction let call_hash = Hashing::hash_of(&inner_call); assert!(System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::CallDispatched { + RuntimeEvent::TokenManager(crate::Event::::CallDispatched { relayer, call_hash }))); assert!(System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::TokenTransferred { + RuntimeEvent::TokenManager(crate::Event::::TokenTransferred { token_id: NON_AVT_TOKEN_ID, sender, recipient, @@ -972,7 +988,7 @@ fn avn_test_regular_call_gas_costs_paid_correctly() { assert_eq!(::Balances::get((NON_AVT_TOKEN_ID, recipient)), 0); assert_eq!(System::events().len(), 0); - let call = &mock::Call::TokenManager(token_manager::Call::signed_transfer { + let call = &mock::RuntimeCall::TokenManager(token_manager::Call::signed_transfer { proof: proof.clone(), from: sender, to: recipient, @@ -1000,7 +1016,7 @@ fn avn_test_regular_call_gas_costs_paid_correctly() { DEFAULT_AMOUNT ); assert!(System::events().iter().any(|a| a.event == - Event::TokenManager(crate::Event::::TokenTransferred { + RuntimeEvent::TokenManager(crate::Event::::TokenTransferred { token_id: NON_AVT_TOKEN_ID, sender, recipient, @@ -1029,16 +1045,18 @@ fn avn_test_proxy_insufficient_avt() { ); // Prepare the calls - let inner_call = - Box::new(mock::Call::TokenManager(super::Call::::signed_transfer { + let inner_call = Box::new(mock::RuntimeCall::TokenManager( + super::Call::::signed_transfer { proof: proof.clone(), from: sender, to: recipient, token_id: NON_AVT_TOKEN_ID, amount: DEFAULT_AMOUNT, - })); - let outer_call = - &mock::Call::TokenManager(token_manager::Call::proxy { call: inner_call.clone() }); + }, + )); + let outer_call = &mock::RuntimeCall::TokenManager(token_manager::Call::proxy { + call: inner_call.clone(), + }); // Pay fees and submit the transaction. // Gas fee for this tx is (BASE_FEE + TX_LEN): 12 + 1 = 13 AVT @@ -1069,7 +1087,7 @@ fn avn_test_regular_insufficient_avt() { ); assert_eq!(::Balances::get((NON_AVT_TOKEN_ID, recipient)), 0); - let call = &mock::Call::TokenManager(token_manager::Call::signed_transfer { + let call = &mock::RuntimeCall::TokenManager(token_manager::Call::signed_transfer { proof: proof.clone(), from: sender, to: recipient, diff --git a/pallets/validators-manager/Cargo.toml b/pallets/validators-manager/Cargo.toml index b86e36047..d5220d87c 100644 --- a/pallets/validators-manager/Cargo.toml +++ b/pallets/validators-manager/Cargo.toml @@ -19,35 +19,36 @@ sp-avn-common = { version = "0.12.0", default-features = false, path = "../../pr pallet-ethereum-transactions = { version = "0.12.0", default-features = false, path = "../ethereum-transactions" } pallet-avn = { version = "0.12.0", default-features = false, path = "../avn" } -sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -frame-system = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -pallet-session = { features = ["historical"], git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27", default-features = false } -sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -sp-io = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -sp-application-crypto = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -sp-staking = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } +sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +frame-system = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +pallet-session = { features = ["historical"], git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false } +sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +sp-io = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +sp-application-crypto = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +sp-staking = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } hex-literal = { version = "0.3.4", default-features = false } #Staking pallet-parachain-staking = { version = "3.0.0", path = "../parachain-staking", default-features = false } # Optional imports for benchmarking -frame-benchmarking = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27", optional = true } +frame-benchmarking = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", optional = true } [dev-dependencies] -frame-election-provider-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -pallet-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -substrate-test-utils = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } +frame-election-provider-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +pallet-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +substrate-test-utils = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } parking_lot = { version = "0.12.0" } -pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } +pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } pallet-avn-proxy = { version = "0.12.0", default-features = false, path = "../avn-proxy" } [features] migrate = [] default = ["std", "pallet-session/historical"] std = [ + "frame-benchmarking?/std", "serde", "codec/std", "sp-std/std", @@ -64,7 +65,7 @@ std = [ "pallet-parachain-staking/std" ] runtime-benchmarks = [ - "frame-benchmarking", + "frame-benchmarking/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", ] diff --git a/pallets/validators-manager/src/benchmarking.rs b/pallets/validators-manager/src/benchmarking.rs index b8afa231e..a7f93b1b5 100644 --- a/pallets/validators-manager/src/benchmarking.rs +++ b/pallets/validators-manager/src/benchmarking.rs @@ -195,13 +195,13 @@ fn generate_ecdsa_signature(msg: u8) -> ecdsa::Signature return ecdsa::Signature::from_slice(&signature_bytes).unwrap().into() } -fn assert_last_event(generic_event: ::Event) { +fn assert_last_event(generic_event: ::RuntimeEvent) { assert_last_nth_event::(generic_event, 1); } -fn assert_last_nth_event(generic_event: ::Event, n: u32) { +fn assert_last_nth_event(generic_event: ::RuntimeEvent, n: u32) { let events = frame_system::Pallet::::events(); - let system_event: ::Event = generic_event.into(); + let system_event: ::RuntimeEvent = generic_event.into(); // Compare to the last event record let EventRecord { event, .. } = &events[events.len().saturating_sub(n as usize)]; assert_eq!(event, &system_event); diff --git a/pallets/validators-manager/src/default_weights.rs b/pallets/validators-manager/src/default_weights.rs index e238ec276..74276b034 100644 --- a/pallets/validators-manager/src/default_weights.rs +++ b/pallets/validators-manager/src/default_weights.rs @@ -84,9 +84,9 @@ impl WeightInfo for SubstrateWeight { // Storage: ParachainStaking TopNominations (r:0 w:1) // Storage: AvnOffenceHandler ReportedOffenders (r:0 w:1) fn add_collator() -> Weight { - (109_557_000 as Weight) - .saturating_add(T::DbWeight::get().reads(14 as Weight)) - .saturating_add(T::DbWeight::get().writes(14 as Weight)) + Weight::from_ref_time(109_557_000) + .saturating_add(T::DbWeight::get().reads(14)) + .saturating_add(T::DbWeight::get().writes(14)) } // Storage: ParachainStaking CandidatePool (r:1 w:1) // Storage: ParachainStaking CandidateInfo (r:1 w:1) @@ -100,11 +100,11 @@ impl WeightInfo for SubstrateWeight { // Storage: EthereumTransactions Nonce (r:1 w:1) /// The range of component `v` is `[3, 10]`. fn remove_validator(v: u32, ) -> Weight { - (78_427_000 as Weight) + Weight::from_ref_time(78_427_000) // Standard Error: 54_000 - .saturating_add((3_752_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(10 as Weight)) - .saturating_add(T::DbWeight::get().writes(7 as Weight)) + .saturating_add(Weight::from_ref_time(3_752_000).saturating_mul(v as u64)) + .saturating_add(T::DbWeight::get().reads(10)) + .saturating_add(T::DbWeight::get().writes(7)) } // Storage: ValidatorsManager ValidatorActions (r:2 w:1) // Storage: Avn Validators (r:1 w:0) @@ -117,11 +117,11 @@ impl WeightInfo for SubstrateWeight { // Storage: EthereumTransactions DispatchedAvnTxIds (r:1 w:1) /// The range of component `v` is `[3, 10]`. fn approve_action_with_end_voting(v: u32, ) -> Weight { - (202_157_000 as Weight) + Weight::from_ref_time(202_157_000) // Standard Error: 172_000 - .saturating_add((5_229_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(10 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) + .saturating_add(Weight::from_ref_time(5_229_000).saturating_mul(v as u64)) + .saturating_add(T::DbWeight::get().reads(10)) + .saturating_add(T::DbWeight::get().writes(6)) } // Storage: ValidatorsManager ValidatorActions (r:2 w:0) // Storage: Avn Validators (r:1 w:0) @@ -131,11 +131,11 @@ impl WeightInfo for SubstrateWeight { // Storage: AvnFinalityTracker LatestFinalisedBlock (r:1 w:0) /// The range of component `v` is `[3, 10]`. fn approve_action_without_end_voting(v: u32, ) -> Weight { - (132_775_000 as Weight) + Weight::from_ref_time(132_775_000) // Standard Error: 173_000 - .saturating_add((4_706_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(4_706_000).saturating_mul(v as u64)) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Avn Validators (r:1 w:0) // Storage: ValidatorsManager VotesRepository (r:1 w:1) @@ -143,11 +143,11 @@ impl WeightInfo for SubstrateWeight { // Storage: AvnFinalityTracker LatestFinalisedBlock (r:1 w:0) /// The range of component `v` is `[3, 10]`. fn reject_action_with_end_voting(v: u32, ) -> Weight { - (79_068_000 as Weight) + Weight::from_ref_time(79_068_000) // Standard Error: 80_000 - .saturating_add((3_719_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(3_719_000).saturating_mul(v as u64)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: Avn Validators (r:1 w:0) // Storage: ValidatorsManager VotesRepository (r:1 w:1) @@ -155,11 +155,11 @@ impl WeightInfo for SubstrateWeight { // Storage: AvnFinalityTracker LatestFinalisedBlock (r:1 w:0) /// The range of component `v` is `[3, 10]`. fn reject_action_without_end_voting(v: u32, ) -> Weight { - (54_662_000 as Weight) + Weight::from_ref_time(54_662_000) // Standard Error: 248_000 - .saturating_add((3_278_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(3_278_000).saturating_mul(v as u64)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: ValidatorsManager VotesRepository (r:1 w:0) // Storage: ValidatorsManager PendingApprovals (r:1 w:1) @@ -177,13 +177,13 @@ impl WeightInfo for SubstrateWeight { // Storage: AvnOffenceHandler ReportedOffenders (r:1 w:0) /// The range of component `o` is `[1, 2]`. fn end_voting_period_with_rejected_valid_actions(o: u32, ) -> Weight { - (156_901_000 as Weight) + Weight::from_ref_time(156_901_000) // Standard Error: 1_757_000 - .saturating_add((14_042_000 as Weight).saturating_mul(o as Weight)) - .saturating_add(T::DbWeight::get().reads(12 as Weight)) - .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(o as Weight))) - .saturating_add(T::DbWeight::get().writes(7 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(o as Weight))) + .saturating_add(Weight::from_ref_time(14_042_000).saturating_mul(o as u64)) + .saturating_add(T::DbWeight::get().reads(12)) + .saturating_add(T::DbWeight::get().reads(2).saturating_mul(o as u64)) + .saturating_add(T::DbWeight::get().writes(7)) + .saturating_add(T::DbWeight::get().writes(1).saturating_mul(o as u64)) } // Storage: ValidatorsManager VotesRepository (r:1 w:0) // Storage: ValidatorsManager PendingApprovals (r:1 w:1) @@ -196,13 +196,13 @@ impl WeightInfo for SubstrateWeight { // Storage: AvnOffenceHandler ReportedOffenders (r:1 w:0) /// The range of component `o` is `[1, 2]`. fn end_voting_period_with_approved_invalid_actions(o: u32, ) -> Weight { - (108_271_000 as Weight) + Weight::from_ref_time(108_271_000) // Standard Error: 2_002_000 - .saturating_add((11_908_000 as Weight).saturating_mul(o as Weight)) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().reads((2 as Weight).saturating_mul(o as Weight))) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) - .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(o as Weight))) + .saturating_add(Weight::from_ref_time(11_908_000).saturating_mul(o as u64)) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().reads(2).saturating_mul(o as u64)) + .saturating_add(T::DbWeight::get().writes(3)) + .saturating_add(T::DbWeight::get().writes(1).saturating_mul(o as u64)) } } @@ -227,9 +227,9 @@ impl WeightInfo for () { // Storage: ParachainStaking TopNominations (r:0 w:1) // Storage: AvnOffenceHandler ReportedOffenders (r:0 w:1) fn add_collator() -> Weight { - (109_557_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(14 as Weight)) - .saturating_add(RocksDbWeight::get().writes(14 as Weight)) + Weight::from_ref_time(109_557_000) + .saturating_add(RocksDbWeight::get().reads(14)) + .saturating_add(RocksDbWeight::get().writes(14)) } // Storage: ParachainStaking CandidatePool (r:1 w:1) // Storage: ParachainStaking CandidateInfo (r:1 w:1) @@ -243,11 +243,11 @@ impl WeightInfo for () { // Storage: EthereumTransactions Nonce (r:1 w:1) /// The range of component `v` is `[3, 10]`. fn remove_validator(v: u32, ) -> Weight { - (78_427_000 as Weight) + Weight::from_ref_time(78_427_000) // Standard Error: 54_000 - .saturating_add((3_752_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(RocksDbWeight::get().reads(10 as Weight)) - .saturating_add(RocksDbWeight::get().writes(7 as Weight)) + .saturating_add(Weight::from_ref_time(3_752_000).saturating_mul(v as u64)) + .saturating_add(RocksDbWeight::get().reads(10)) + .saturating_add(RocksDbWeight::get().writes(7)) } // Storage: ValidatorsManager ValidatorActions (r:2 w:1) // Storage: Avn Validators (r:1 w:0) @@ -260,11 +260,11 @@ impl WeightInfo for () { // Storage: EthereumTransactions DispatchedAvnTxIds (r:1 w:1) /// The range of component `v` is `[3, 10]`. fn approve_action_with_end_voting(v: u32, ) -> Weight { - (202_157_000 as Weight) + Weight::from_ref_time(202_157_000) // Standard Error: 172_000 - .saturating_add((5_229_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(RocksDbWeight::get().reads(10 as Weight)) - .saturating_add(RocksDbWeight::get().writes(6 as Weight)) + .saturating_add(Weight::from_ref_time(5_229_000).saturating_mul(v as u64)) + .saturating_add(RocksDbWeight::get().reads(10)) + .saturating_add(RocksDbWeight::get().writes(6)) } // Storage: ValidatorsManager ValidatorActions (r:2 w:0) // Storage: Avn Validators (r:1 w:0) @@ -274,11 +274,11 @@ impl WeightInfo for () { // Storage: AvnFinalityTracker LatestFinalisedBlock (r:1 w:0) /// The range of component `v` is `[3, 10]`. fn approve_action_without_end_voting(v: u32, ) -> Weight { - (132_775_000 as Weight) + Weight::from_ref_time(132_775_000) // Standard Error: 173_000 - .saturating_add((4_706_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(RocksDbWeight::get().reads(7 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(4_706_000).saturating_mul(v as u64)) + .saturating_add(RocksDbWeight::get().reads(7)) + .saturating_add(RocksDbWeight::get().writes(1)) } // Storage: Avn Validators (r:1 w:0) // Storage: ValidatorsManager VotesRepository (r:1 w:1) @@ -286,11 +286,11 @@ impl WeightInfo for () { // Storage: AvnFinalityTracker LatestFinalisedBlock (r:1 w:0) /// The range of component `v` is `[3, 10]`. fn reject_action_with_end_voting(v: u32, ) -> Weight { - (79_068_000 as Weight) + Weight::from_ref_time(79_068_000) // Standard Error: 80_000 - .saturating_add((3_719_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) + .saturating_add(Weight::from_ref_time(3_719_000).saturating_mul(v as u64)) + .saturating_add(RocksDbWeight::get().reads(4)) + .saturating_add(RocksDbWeight::get().writes(2)) } // Storage: Avn Validators (r:1 w:0) // Storage: ValidatorsManager VotesRepository (r:1 w:1) @@ -298,11 +298,11 @@ impl WeightInfo for () { // Storage: AvnFinalityTracker LatestFinalisedBlock (r:1 w:0) /// The range of component `v` is `[3, 10]`. fn reject_action_without_end_voting(v: u32, ) -> Weight { - (54_662_000 as Weight) + Weight::from_ref_time(54_662_000) // Standard Error: 248_000 - .saturating_add((3_278_000 as Weight).saturating_mul(v as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) + .saturating_add(Weight::from_ref_time(3_278_000).saturating_mul(v as u64)) + .saturating_add(RocksDbWeight::get().reads(4)) + .saturating_add(RocksDbWeight::get().writes(1)) } // Storage: ValidatorsManager VotesRepository (r:1 w:0) // Storage: ValidatorsManager PendingApprovals (r:1 w:1) @@ -320,13 +320,13 @@ impl WeightInfo for () { // Storage: AvnOffenceHandler ReportedOffenders (r:1 w:0) /// The range of component `o` is `[1, 2]`. fn end_voting_period_with_rejected_valid_actions(o: u32, ) -> Weight { - (156_901_000 as Weight) + Weight::from_ref_time(156_901_000) // Standard Error: 1_757_000 - .saturating_add((14_042_000 as Weight).saturating_mul(o as Weight)) - .saturating_add(RocksDbWeight::get().reads(12 as Weight)) - .saturating_add(RocksDbWeight::get().reads((2 as Weight).saturating_mul(o as Weight))) - .saturating_add(RocksDbWeight::get().writes(7 as Weight)) - .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(o as Weight))) + .saturating_add(Weight::from_ref_time(14_042_000).saturating_mul(o as u64)) + .saturating_add(RocksDbWeight::get().reads(12)) + .saturating_add(RocksDbWeight::get().reads(2).saturating_mul(o as u64)) + .saturating_add(RocksDbWeight::get().writes(7)) + .saturating_add(RocksDbWeight::get().writes(1).saturating_mul(o as u64)) } // Storage: ValidatorsManager VotesRepository (r:1 w:0) // Storage: ValidatorsManager PendingApprovals (r:1 w:1) @@ -339,12 +339,12 @@ impl WeightInfo for () { // Storage: AvnOffenceHandler ReportedOffenders (r:1 w:0) /// The range of component `o` is `[1, 2]`. fn end_voting_period_with_approved_invalid_actions(o: u32, ) -> Weight { - (108_271_000 as Weight) + Weight::from_ref_time(108_271_000) // Standard Error: 2_002_000 - .saturating_add((11_908_000 as Weight).saturating_mul(o as Weight)) - .saturating_add(RocksDbWeight::get().reads(7 as Weight)) - .saturating_add(RocksDbWeight::get().reads((2 as Weight).saturating_mul(o as Weight))) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(o as Weight))) + .saturating_add(Weight::from_ref_time(11_908_000).saturating_mul(o as u64)) + .saturating_add(RocksDbWeight::get().reads(7)) + .saturating_add(RocksDbWeight::get().reads(2).saturating_mul(o as u64)) + .saturating_add(RocksDbWeight::get().writes(3)) + .saturating_add(RocksDbWeight::get().writes(1).saturating_mul(o as u64)) } } \ No newline at end of file diff --git a/pallets/validators-manager/src/lib.rs b/pallets/validators-manager/src/lib.rs index d5c11cd12..7a2b99af2 100644 --- a/pallets/validators-manager/src/lib.rs +++ b/pallets/validators-manager/src/lib.rs @@ -17,7 +17,7 @@ use frame_system::{self as system, ensure_none, offchain::SendTransactionTypes, use pallet_session::{self as session, Config as SessionConfig}; use sp_runtime::{ scale_info::TypeInfo, - traits::{Convert, Member, Zero}, + traits::{Convert, Member}, transaction_validity::{InvalidTransaction, TransactionSource, TransactionValidity}, DispatchError, }; @@ -82,9 +82,9 @@ pub mod pallet { + pallet_session::historical::Config { /// Overarching event type - type Event: From> - + Into<::Event> - + IsType<::Event>; + type RuntimeEvent: From> + + Into<::RuntimeEvent> + + IsType<::RuntimeEvent>; /// A trait that allows to subscribe to notifications triggered when ethereum event /// processes an event type ProcessedEventsChecker: ProcessedEventsChecker; @@ -242,6 +242,7 @@ pub mod pallet { /// This will call the `join_candidates` method in the parachain_staking pallet. /// [transactional]: this makes `add_validator` behave like an ethereum transaction (atomic tx). No need to use VFWL. /// see here for more info: https://github.com/paritytech/substrate/issues/10806 + #[pallet::call_index(0)] #[pallet::weight(::WeightInfo::add_collator())] #[transactional] pub fn add_collator( @@ -273,7 +274,7 @@ pub mod pallet { .or_else(|| Some(parachain_staking::Pallet::::min_collator_stake())) .expect("has default value"); let register_as_candidate_weight = parachain_staking::Pallet::::join_candidates( - ::Origin::from(RawOrigin::Signed( + ::RuntimeOrigin::from(RawOrigin::Signed( collator_account_id.clone(), )), bond, @@ -292,11 +293,12 @@ pub mod pallet { .or_else(|| Some(Weight::zero())) .expect("Has default value") .saturating_add(T::DbWeight::get().reads_writes(0, 2)) - .saturating_add(40_000_000), + .saturating_add(Weight::from_ref_time(40_000_000)), ) .into()) } + #[pallet::call_index(1)] #[pallet::weight(::WeightInfo::remove_validator(MAX_VALIDATOR_ACCOUNT_IDS))] #[transactional] pub fn remove_validator( @@ -309,7 +311,7 @@ pub mod pallet { let candidate_count = parachain_staking::Pallet::::candidate_pool().0.len() as u32; let resign_as_candidate_weight = parachain_staking::Pallet::::schedule_leave_candidates( - ::Origin::from(RawOrigin::Signed( + ::RuntimeOrigin::from(RawOrigin::Signed( collator_account_id.clone(), )), candidate_count, @@ -330,11 +332,12 @@ pub mod pallet { .actual_weight .or_else(|| Some(Weight::zero())) .expect("Has default value") - .saturating_add(40_000_000), + .saturating_add(Weight::from_ref_time(40_000_000)), ) .into()) } + #[pallet::call_index(2)] #[pallet::weight( ::WeightInfo::approve_action_with_end_voting(MAX_VALIDATOR_ACCOUNT_IDS))] pub fn approve_validator_action( origin: OriginFor, @@ -374,6 +377,7 @@ pub mod pallet { Ok(()) } + #[pallet::call_index(3)] #[pallet::weight( ::WeightInfo::reject_action_with_end_voting(MAX_VALIDATOR_ACCOUNT_IDS))] pub fn reject_validator_action( origin: OriginFor, @@ -396,6 +400,7 @@ pub mod pallet { Ok(()) } + #[pallet::call_index(4)] #[pallet::weight( ::WeightInfo::end_voting_period_with_rejected_valid_actions(MAX_OFFENDERS) .max(::WeightInfo::end_voting_period_with_approved_invalid_actions(MAX_OFFENDERS)))] pub fn end_voting_period( @@ -878,7 +883,9 @@ impl Pallet { // Remove collator from parachain_staking pallet let candidate_count = parachain_staking::Pallet::::candidate_pool().0.len() as u32; parachain_staking::Pallet::::schedule_leave_candidates( - ::Origin::from(RawOrigin::Signed(slashed_validator.clone())), + ::RuntimeOrigin::from(RawOrigin::Signed( + slashed_validator.clone(), + )), candidate_count, ) .map_err(|e| { @@ -991,7 +998,9 @@ impl Pallet { let staking_state = staking_state.expect("Checked for none already"); let result = parachain_staking::Pallet::::execute_leave_candidates( - ::Origin::from(RawOrigin::Signed(action_account_id.clone())), + ::RuntimeOrigin::from(RawOrigin::Signed( + action_account_id.clone(), + )), action_account_id.clone(), staking_state.nomination_count, ); diff --git a/pallets/validators-manager/src/mock.rs b/pallets/validators-manager/src/mock.rs index 21e774f37..43e13bf68 100644 --- a/pallets/validators-manager/src/mock.rs +++ b/pallets/validators-manager/src/mock.rs @@ -74,7 +74,7 @@ const MOCK_T2_PUBLIC_KEY_BYTES: [u8; 32] = [ 151, 4, 182, ]; -pub type Extrinsic = TestXt; +pub type Extrinsic = TestXt; pub type BlockNumber = ::BlockNumber; pub type ValidatorId = ::ValidatorId; pub type FullIdentification = AccountId; @@ -191,7 +191,7 @@ impl ValidatorManager { }); } - pub fn event_emitted(event: &Event) -> bool { + pub fn event_emitted(event: &RuntimeEvent) -> bool { return System::events().iter().any(|a| a.event == *event) } @@ -205,9 +205,12 @@ impl ValidatorManager { .any(|e| Self::event_matches_offence_type(&e.event, offence_type.clone())) } - pub fn event_matches_offence_type(event: &Event, this_type: ValidatorOffenceType) -> bool { + pub fn event_matches_offence_type( + event: &RuntimeEvent, + this_type: ValidatorOffenceType, + ) -> bool { return matches!(event, - Event::ValidatorManager( + RuntimeEvent::ValidatorManager( crate::Event::::OffenceReported{ offence_type, offenders: _ } ) if this_type == *offence_type @@ -267,7 +270,7 @@ parameter_types! { } impl Config for TestRuntime { - type Event = Event; + type RuntimeEvent = RuntimeEvent; type ProcessedEventsChecker = Self; type VotingPeriod = VotingPeriod; type AccountToBytesConvert = AVN; @@ -279,9 +282,9 @@ impl Config for TestRuntime { impl system::offchain::SendTransactionTypes for TestRuntime where - Call: From, + RuntimeCall: From, { - type OverarchingCall = Call; + type OverarchingCall = RuntimeCall; type Extrinsic = Extrinsic; } @@ -294,8 +297,8 @@ impl system::Config for TestRuntime { type BlockWeights = (); type BlockLength = (); type DbWeight = (); - type Origin = Origin; - type Call = Call; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; type Index = u64; type BlockNumber = u64; type Hash = H256; @@ -303,7 +306,7 @@ impl system::Config for TestRuntime { type AccountId = AccountId; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type Version = (); type PalletInfo = PalletInfo; @@ -333,7 +336,7 @@ impl balances::Config for TestRuntime { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type Balance = u128; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; @@ -398,6 +401,9 @@ impl CandidateTransactionSubmitter for TestRuntime { }); return Ok(value) } + // #[cfg(feature = "runtime-benchmarks")] + // fn set_transaction_id(candidate_type: &EthTransactionType, id: TransactionId) { + // } } impl session::Config for TestRuntime { @@ -405,7 +411,7 @@ impl session::Config for TestRuntime { type Keys = UintAuthorityId; type ShouldEndSession = ParachainStaking; type SessionHandler = (AVN,); - type Event = Event; + type RuntimeEvent = RuntimeEvent; type ValidatorId = AccountId; type ValidatorIdOf = ConvertInto; type NextSessionRotation = ParachainStaking; @@ -431,8 +437,8 @@ parameter_types! { } impl parachain_staking::Config for TestRuntime { - type Call = Call; - type Event = Event; + type RuntimeCall = RuntimeCall; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type MinBlocksPerEra = MinBlocksPerEra; type RewardPaymentDelay = RewardPaymentDelay; diff --git a/pallets/validators-manager/src/offence.rs b/pallets/validators-manager/src/offence.rs index 56e15482d..88b547975 100644 --- a/pallets/validators-manager/src/offence.rs +++ b/pallets/validators-manager/src/offence.rs @@ -54,7 +54,7 @@ impl Offence for ValidatorOffence { self.session_index } - fn slash_fraction(_offenders: u32, _validator_set_count: u32) -> Perbill { + fn slash_fraction(&self, _offenders: u32) -> Perbill { // We don't implement fraction slashes at the moment. Perbill::from_percent(100) } diff --git a/pallets/validators-manager/src/tests.rs b/pallets/validators-manager/src/tests.rs index a6e87f621..cb5db7460 100644 --- a/pallets/validators-manager/src/tests.rs +++ b/pallets/validators-manager/src/tests.rs @@ -149,7 +149,7 @@ mod register_validator { assert_eq!( true, System::events().iter().any(|a| a.event == - mock::Event::ValidatorManager( + mock::RuntimeEvent::ValidatorManager( crate::Event::::ValidatorRegistered { validator_id: context.new_validator_id, eth_key: context.validator_eth_public_key.clone() @@ -160,7 +160,7 @@ mod register_validator { assert_eq!( false, System::events().iter().any(|a| a.event == - mock::Event::ValidatorManager( + mock::RuntimeEvent::ValidatorManager( crate::Event::::ValidatorActivationStarted { validator_id: context.new_validator_id } @@ -205,7 +205,7 @@ mod register_validator { assert_eq!( true, System::events().iter().any(|a| a.event == - mock::Event::ValidatorManager( + mock::RuntimeEvent::ValidatorManager( crate::Event::::ValidatorActivationStarted { validator_id: context.new_validator_id } @@ -256,7 +256,7 @@ mod remove_validator_public { //Event emitted as expected assert!(System::events().iter().any(|a| a.event == - mock::Event::ValidatorManager( + mock::RuntimeEvent::ValidatorManager( crate::Event::::ValidatorDeregistered { validator_id: context.new_validator_id } @@ -318,7 +318,7 @@ mod remove_validator_public { let num_events = System::events().len(); assert_noop!( ValidatorManager::remove_validator( - Origin::signed(validator_id_3()), + RuntimeOrigin::signed(validator_id_3()), validator_id_3() ), BadOrigin @@ -484,13 +484,14 @@ mod remove_slashed_validator { .is_some() ); - let event = - mock::Event::ValidatorManager(crate::Event::::ValidatorSlashed { + let event = mock::RuntimeEvent::ValidatorManager( + crate::Event::::ValidatorSlashed { action_id: ActionId { action_account_id: offender_validator_id, ingress_counter, }, - }); + }, + ); assert_eq!(true, ValidatorManager::event_emitted(&event)); // It takes 2 session for validators to be updated diff --git a/pallets/validators-manager/src/tests_voting_deregistration.rs b/pallets/validators-manager/src/tests_voting_deregistration.rs index 26354e9fc..93c5ce68d 100644 --- a/pallets/validators-manager/src/tests_voting_deregistration.rs +++ b/pallets/validators-manager/src/tests_voting_deregistration.rs @@ -138,7 +138,7 @@ fn vote_added_event_is_emitted_successfully( ) -> bool { System::events().iter().any(|a| { a.event == - mock::Event::ValidatorManager(crate::Event::::VoteAdded { + mock::RuntimeEvent::ValidatorManager(crate::Event::::VoteAdded { voter_id: *voter_account_id, action_id: *action_id, approve: is_approve, @@ -303,7 +303,7 @@ mod approve_vote { assert_noop!( ValidatorManager::approve_validator_action( - Origin::signed(validator_id_3()), + RuntimeOrigin::signed(validator_id_3()), context.action_id, context.validator, approval_signature, @@ -595,7 +595,7 @@ mod reject_vote { assert_noop!( ValidatorManager::reject_validator_action( - Origin::signed(validator_id_3()), + RuntimeOrigin::signed(validator_id_3()), context.action_id, context.validator, context.record_deregister_validator_calculation_signature @@ -844,7 +844,7 @@ mod end_voting_period { assert_ok!(end_voting_period(&context)); assert!(System::events().iter().any(|a| a.event == - mock::Event::ValidatorManager( + mock::RuntimeEvent::ValidatorManager( crate::Event::::VotingEnded { action_id: context.action_id, vote_approved: true @@ -897,7 +897,7 @@ mod end_voting_period { assert_ok!(end_voting_period(&context)); assert!(System::events().iter().any(|a| a.event == - mock::Event::ValidatorManager( + mock::RuntimeEvent::ValidatorManager( crate::Event::::VotingEnded { action_id: context.action_id, vote_approved: false @@ -922,7 +922,7 @@ mod end_voting_period { assert_noop!( ValidatorManager::end_voting_period( - Origin::signed(validator_id_3()), + RuntimeOrigin::signed(validator_id_3()), context.action_id.clone(), context.validator.clone(), context.record_deregister_validator_calculation_signature.clone(), diff --git a/primitives/avn-common/Cargo.toml b/primitives/avn-common/Cargo.toml index 848961d22..05b40b0ed 100644 --- a/primitives/avn-common/Cargo.toml +++ b/primitives/avn-common/Cargo.toml @@ -18,10 +18,10 @@ hex-literal = { version = "0.3.4", default-features = false } impl-trait-for-tuples = "0.2.2" codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false, features = ["derive"] } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } -sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } -sp-io = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" } +sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } +sp-io = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" } serde = { version = "1.0.101", optional = true, features = ["derive"] } log = { version = "0.4.8", optional = true, features = ["std"] }