From 81d732b783e8575b63ee02bee409e4ae8c7a13a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Mon, 8 May 2023 16:19:38 +0200 Subject: [PATCH 01/17] Re-enable `node-cli` tests in CI and fix them (#14093) With the recent change of re-running flaky tests this should be fine! --- scripts/ci/gitlab/pipeline/test.yml | 2 -- test-utils/cli/src/lib.rs | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/ci/gitlab/pipeline/test.yml b/scripts/ci/gitlab/pipeline/test.yml index 29f21bfe59e72..6e86a01b4d54f 100644 --- a/scripts/ci/gitlab/pipeline/test.yml +++ b/scripts/ci/gitlab/pipeline/test.yml @@ -216,7 +216,6 @@ test-linux-stable: - rusty-cachier snapshot create # this job runs all tests in former runtime-benchmarks, frame-staking and wasmtime tests # tests are partitioned by nextest and executed in parallel on $CI_NODE_TOTAL runners - # node-cli is excluded until https://github.com/paritytech/substrate/issues/11321 fixed - echo "Node index - ${CI_NODE_INDEX}. Total amount - ${CI_NODE_TOTAL}" - time cargo nextest run --workspace --locked @@ -224,7 +223,6 @@ test-linux-stable: --verbose --features runtime-benchmarks --manifest-path ./bin/node/cli/Cargo.toml - --exclude node-cli --partition count:${CI_NODE_INDEX}/${CI_NODE_TOTAL} # we need to update cache only from one job - if [ ${CI_NODE_INDEX} == 1 ]; then rusty-cachier cache upload; fi diff --git a/test-utils/cli/src/lib.rs b/test-utils/cli/src/lib.rs index f225cc135a2ae..526bc1f3776e1 100644 --- a/test-utils/cli/src/lib.rs +++ b/test-utils/cli/src/lib.rs @@ -64,7 +64,7 @@ pub fn start_node() -> Child { Command::new(cargo_bin("substrate")) .stdout(process::Stdio::piped()) .stderr(process::Stdio::piped()) - .args(&["--dev", "--tmp", "--ws-port=45789", "--no-hardware-benchmarks"]) + .args(&["--dev", "--tmp", "--rpc-port=45789", "--no-hardware-benchmarks"]) .spawn() .unwrap() } From 33d94c2d26f18272f103f831c40e35895a273ca9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Mon, 8 May 2023 16:42:17 +0200 Subject: [PATCH 02/17] sc-informant: Do not show `Block history` if doing major sync (#14094) After warp syncing a node it still downloads the block history. If the node is stopped and then started later while downloading the block history, the node first needs to do a major sync to sync to the tip of the chain. Before informant was showing `Block history` as sync state, while we actually were doing a major sync. This pr is fixing this. --- client/informant/src/display.rs | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/client/informant/src/display.rs b/client/informant/src/display.rs index 2f101307229da..722cf56d778d6 100644 --- a/client/informant/src/display.rs +++ b/client/informant/src/display.rs @@ -98,25 +98,36 @@ impl InformantDisplay { let (level, status, target) = match (sync_status.state, sync_status.state_sync, sync_status.warp_sync) { + // Do not set status to "Block history" when we are doing a major sync. + // + // A node could for example have been warp synced to the tip of the chain and + // shutdown. At the next start we still need to download the block history, but + // first will sync to the tip of the chain. ( - _, + sync_status, _, Some(WarpSyncProgress { phase: WarpSyncPhase::DownloadingBlocks(n), .. }), - ) => ("⏩", "Block history".into(), format!(", #{}", n)), + ) if !sync_status.is_major_syncing() => ("⏩", "Block history".into(), format!(", #{}", n)), ( _, _, Some(WarpSyncProgress { phase: WarpSyncPhase::AwaitingTargetBlock, .. }), ) => ("⏩", "Waiting for pending target block".into(), "".into()), - (_, _, Some(warp)) => ( - "⏩", - "Warping".into(), - format!( - ", {}, {:.2} Mib", + // Handle all phases besides the two phases we already handle above. + (_, _, Some(warp)) + if !matches!( warp.phase, - (warp.total_bytes as f32) / (1024f32 * 1024f32) + WarpSyncPhase::AwaitingTargetBlock | WarpSyncPhase::DownloadingBlocks(_) + ) => + ( + "⏩", + "Warping".into(), + format!( + ", {}, {:.2} Mib", + warp.phase, + (warp.total_bytes as f32) / (1024f32 * 1024f32) + ), ), - ), (_, Some(state), _) => ( "⚙️ ", "Downloading state".into(), From dc398dee295ee97f3a71e7d4c1a9444d6c2ce5b8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 May 2023 16:28:00 +0000 Subject: [PATCH 03/17] Bump cfg-expr from 0.10.3 to 0.15.1 (#14092) Bumps [cfg-expr](https://github.com/EmbarkStudios/cfg-expr) from 0.10.3 to 0.15.1. - [Release notes](https://github.com/EmbarkStudios/cfg-expr/releases) - [Changelog](https://github.com/EmbarkStudios/cfg-expr/blob/main/CHANGELOG.md) - [Commits](https://github.com/EmbarkStudios/cfg-expr/compare/0.10.3...0.15.1) --- updated-dependencies: - dependency-name: cfg-expr dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- frame/support/procedural/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b8e42c10316eb..e9bc2a99677a2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -912,9 +912,9 @@ dependencies = [ [[package]] name = "cfg-expr" -version = "0.10.3" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0aacacf4d96c24b2ad6eb8ee6df040e4f27b0d0b39a5710c30091baa830485db" +checksum = "c8790cf1286da485c72cf5fc7aeba308438800036ec67d89425924c4807268c9" dependencies = [ "smallvec", ] diff --git a/frame/support/procedural/Cargo.toml b/frame/support/procedural/Cargo.toml index 1a17924b40e2e..8e18376ba3288 100644 --- a/frame/support/procedural/Cargo.toml +++ b/frame/support/procedural/Cargo.toml @@ -17,7 +17,7 @@ proc-macro = true [dependencies] derive-syn-parse = "0.1.5" Inflector = "0.11.4" -cfg-expr = "0.10.3" +cfg-expr = "0.15.1" itertools = "0.10.3" proc-macro2 = "1.0.56" quote = "1.0.26" From 00a7ee7094d92fded19ae7588a9668afed42c269 Mon Sep 17 00:00:00 2001 From: Sebastian Kunert Date: Mon, 8 May 2023 22:31:39 +0200 Subject: [PATCH 04/17] Remove manual implementation (#14096) --- primitives/runtime/src/curve.rs | 33 ++------------------------------- 1 file changed, 2 insertions(+), 31 deletions(-) diff --git a/primitives/runtime/src/curve.rs b/primitives/runtime/src/curve.rs index 7cea92293b4a0..2fc032cfafe2d 100644 --- a/primitives/runtime/src/curve.rs +++ b/primitives/runtime/src/curve.rs @@ -22,9 +22,10 @@ use crate::{ Perbill, }; use core::ops::Sub; +use scale_info::TypeInfo; /// Piecewise Linear function in [0, 1] -> [0, 1]. -#[derive(PartialEq, Eq, sp_core::RuntimeDebug)] +#[derive(PartialEq, Eq, sp_core::RuntimeDebug, TypeInfo)] pub struct PiecewiseLinear<'a> { /// Array of points. Must be in order from the lowest abscissas to the highest. pub points: &'a [(Perbill, Perbill)], @@ -32,36 +33,6 @@ pub struct PiecewiseLinear<'a> { pub maximum: Perbill, } -// This can be replaced with -// #[derive(scale_info::TypeInfo)] -// #[scale_info(skip_type_params(S))] -// again once this issue is fixed in the rust compiler: https://github.com/rust-lang/rust/issues/96956 -// Tracking issues: https://github.com/paritytech/substrate/issues/11915 -impl scale_info::TypeInfo for PiecewiseLinear<'static> { - type Identity = Self; - fn type_info() -> ::scale_info::Type { - scale_info::Type::builder() - .path(scale_info::Path::new("PiecewiseLinear", "sp_runtime::curve")) - .type_params(crate::Vec::new()) - .docs(&["Piecewise Linear function in [0, 1] -> [0, 1]."]) - .composite( - scale_info::build::Fields::named() - .field(|f| { - f.ty::<&'static[(Perbill, Perbill)]>() - .name("points") - .type_name("&'static[(Perbill, Perbill)]") - .docs(&["Array of points. Must be in order from the lowest abscissas to the highest."]) - }) - .field(|f| { - f.ty::() - .name("maximum") - .type_name("Perbill") - .docs(&["The maximum value that can be returned."]) - }), - ) - } -} - fn abs_sub + Clone>(a: N, b: N) -> N where { a.clone().max(b.clone()) - a.min(b) } From ab8330cd421027d0ebfd613111702fd4fa5e9487 Mon Sep 17 00:00:00 2001 From: Sebastian Kunert Date: Mon, 8 May 2023 22:32:01 +0200 Subject: [PATCH 05/17] Remove manual implementation (#14096) From f0c14f387baba0688afa9422a9bc24068d431716 Mon Sep 17 00:00:00 2001 From: Qinxuan Chen Date: Tue, 9 May 2023 17:22:55 +0800 Subject: [PATCH 06/17] frame-support-test: migrate tests from `decl_*` macros to the new `pallet` macros (#12445) * frame-support: migrate some tests from decl macros to new pallet attribute macros * Remove useless type alias * Remove useless type alias * frame-support-test: migrate old decl_macros to new pallet attribute macros * fmt Signed-off-by: Oliver Tale-Yazdi * Fix tests Signed-off-by: Oliver Tale-Yazdi * Fix features Signed-off-by: Oliver Tale-Yazdi * Remove deprecated stuff Signed-off-by: Oliver Tale-Yazdi * Update UI tests Signed-off-by: Oliver Tale-Yazdi * Fix UI test Signed-off-by: Oliver Tale-Yazdi * Fix test Signed-off-by: Oliver Tale-Yazdi * Update UI tests Signed-off-by: Oliver Tale-Yazdi * Cleanup Signed-off-by: Oliver Tale-Yazdi --------- Signed-off-by: Oliver Tale-Yazdi Co-authored-by: Oliver Tale-Yazdi Co-authored-by: parity-processbot <> --- frame/benchmarking/src/tests.rs | 7 - frame/benchmarking/src/tests_instance.rs | 1 - frame/collective/src/tests.rs | 2 - frame/executive/src/lib.rs | 12 - frame/support/test/compile_pass/Cargo.toml | 4 +- frame/support/test/compile_pass/src/lib.rs | 12 +- frame/support/test/pallet/src/lib.rs | 7 +- frame/support/test/src/lib.rs | 121 ++- frame/support/test/src/pallet_version.rs | 29 - .../test/tests/benchmark_ui/invalid_origin.rs | 2 +- .../tests/benchmark_ui/invalid_origin.stderr | 8 - frame/support/test/tests/construct_runtime.rs | 430 +++++---- .../old_unsupported_pallet_decl.rs | 26 - .../old_unsupported_pallet_decl.stderr | 31 - .../undefined_event_part.stderr | 4 +- .../undefined_origin_part.stderr | 4 +- frame/support/test/tests/decl_module_ui.rs | 32 - ...served_keyword_two_times_integrity_test.rs | 7 - ...ed_keyword_two_times_integrity_test.stderr | 19 - ...eserved_keyword_two_times_on_initialize.rs | 13 - ...ved_keyword_two_times_on_initialize.stderr | 13 - frame/support/test/tests/decl_storage.rs | 881 ------------------ frame/support/test/tests/decl_storage_ui.rs | 32 - .../tests/decl_storage_ui/config_duplicate.rs | 31 - .../decl_storage_ui/config_duplicate.stderr | 5 - .../decl_storage_ui/config_get_duplicate.rs | 31 - .../config_get_duplicate.stderr | 5 - .../tests/decl_storage_ui/get_duplicate.rs | 31 - .../decl_storage_ui/get_duplicate.stderr | 5 - frame/support/test/tests/final_keys.rs | 276 ++++-- frame/support/test/tests/genesisconfig.rs | 82 +- frame/support/test/tests/instance.rs | 350 +++---- frame/support/test/tests/issue2219.rs | 174 ++-- frame/support/test/tests/origin.rs | 208 +++-- .../test/tests/pallet_compatibility.rs | 371 -------- .../tests/pallet_compatibility_instance.rs | 371 -------- frame/support/test/tests/pallet_instance.rs | 10 +- .../tests/pallet_with_name_trait_is_valid.rs | 158 ---- frame/support/test/tests/storage_layers.rs | 72 +- .../support/test/tests/storage_transaction.rs | 115 ++- frame/support/test/tests/system.rs | 81 -- 41 files changed, 1112 insertions(+), 2961 deletions(-) delete mode 100644 frame/support/test/src/pallet_version.rs delete mode 100644 frame/support/test/tests/construct_runtime_ui/old_unsupported_pallet_decl.rs delete mode 100644 frame/support/test/tests/construct_runtime_ui/old_unsupported_pallet_decl.stderr delete mode 100644 frame/support/test/tests/decl_module_ui.rs delete mode 100644 frame/support/test/tests/decl_module_ui/reserved_keyword_two_times_integrity_test.rs delete mode 100644 frame/support/test/tests/decl_module_ui/reserved_keyword_two_times_integrity_test.stderr delete mode 100644 frame/support/test/tests/decl_module_ui/reserved_keyword_two_times_on_initialize.rs delete mode 100644 frame/support/test/tests/decl_module_ui/reserved_keyword_two_times_on_initialize.stderr delete mode 100644 frame/support/test/tests/decl_storage.rs delete mode 100644 frame/support/test/tests/decl_storage_ui.rs delete mode 100644 frame/support/test/tests/decl_storage_ui/config_duplicate.rs delete mode 100644 frame/support/test/tests/decl_storage_ui/config_duplicate.stderr delete mode 100644 frame/support/test/tests/decl_storage_ui/config_get_duplicate.rs delete mode 100644 frame/support/test/tests/decl_storage_ui/config_get_duplicate.stderr delete mode 100644 frame/support/test/tests/decl_storage_ui/get_duplicate.rs delete mode 100644 frame/support/test/tests/decl_storage_ui/get_duplicate.stderr delete mode 100644 frame/support/test/tests/pallet_compatibility.rs delete mode 100644 frame/support/test/tests/pallet_compatibility_instance.rs delete mode 100644 frame/support/test/tests/pallet_with_name_trait_is_valid.rs delete mode 100644 frame/support/test/tests/system.rs diff --git a/frame/benchmarking/src/tests.rs b/frame/benchmarking/src/tests.rs index 80b631bb73668..7e240ee04903a 100644 --- a/frame/benchmarking/src/tests.rs +++ b/frame/benchmarking/src/tests.rs @@ -45,28 +45,21 @@ mod pallet_test { } #[pallet::storage] - #[pallet::getter(fn value)] pub(crate) type Value = StorageValue<_, u32, OptionQuery>; #[pallet::call] impl Pallet { - #[pallet::call_index(0)] - #[pallet::weight(0)] pub fn set_value(origin: OriginFor, n: u32) -> DispatchResult { let _sender = ensure_signed(origin)?; Value::::put(n); Ok(()) } - #[pallet::call_index(1)] - #[pallet::weight(0)] pub fn dummy(origin: OriginFor, _n: u32) -> DispatchResult { let _sender = ensure_none(origin)?; Ok(()) } - #[pallet::call_index(2)] - #[pallet::weight(0)] pub fn always_error(_origin: OriginFor) -> DispatchResult { return Err("I always fail".into()) } diff --git a/frame/benchmarking/src/tests_instance.rs b/frame/benchmarking/src/tests_instance.rs index 92d78b9ecbbe1..d017fc679875e 100644 --- a/frame/benchmarking/src/tests_instance.rs +++ b/frame/benchmarking/src/tests_instance.rs @@ -49,7 +49,6 @@ mod pallet_test { } #[pallet::storage] - #[pallet::getter(fn value)] pub(crate) type Value, I: 'static = ()> = StorageValue<_, u32, OptionQuery>; #[pallet::event] diff --git a/frame/collective/src/tests.rs b/frame/collective/src/tests.rs index 1165ebcec2287..99aa7a57e1604 100644 --- a/frame/collective/src/tests.rs +++ b/frame/collective/src/tests.rs @@ -68,8 +68,6 @@ mod mock_democracy { #[pallet::call] impl Pallet { - #[pallet::call_index(0)] - #[pallet::weight(0)] pub fn external_propose_majority(origin: OriginFor) -> DispatchResult { T::ExternalMajorityOrigin::ensure_origin(origin)?; Self::deposit_event(Event::::ExternalProposed); diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index aad1de11d2c7b..fd76fefadff4b 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -735,51 +735,39 @@ mod tests { #[pallet::call] impl Pallet { - #[pallet::call_index(0)] - #[pallet::weight(100)] pub fn some_function(origin: OriginFor) -> DispatchResult { // NOTE: does not make any different. frame_system::ensure_signed(origin)?; Ok(()) } - #[pallet::call_index(1)] #[pallet::weight((200, DispatchClass::Operational))] pub fn some_root_operation(origin: OriginFor) -> DispatchResult { frame_system::ensure_root(origin)?; Ok(()) } - #[pallet::call_index(2)] - #[pallet::weight(0)] pub fn some_unsigned_message(origin: OriginFor) -> DispatchResult { frame_system::ensure_none(origin)?; Ok(()) } - #[pallet::call_index(3)] - #[pallet::weight(0)] pub fn allowed_unsigned(origin: OriginFor) -> DispatchResult { frame_system::ensure_root(origin)?; Ok(()) } - #[pallet::call_index(4)] - #[pallet::weight(0)] pub fn unallowed_unsigned(origin: OriginFor) -> DispatchResult { frame_system::ensure_root(origin)?; Ok(()) } - #[pallet::call_index(5)] #[pallet::weight((0, DispatchClass::Mandatory))] pub fn inherent_call(origin: OriginFor) -> DispatchResult { frame_system::ensure_none(origin)?; Ok(()) } - #[pallet::call_index(6)] - #[pallet::weight(0)] pub fn calculate_storage_root(_origin: OriginFor) -> DispatchResult { let root = sp_io::storage::root(sp_runtime::StateVersion::V1); sp_io::storage::set("storage_root".as_bytes(), &root); diff --git a/frame/support/test/compile_pass/Cargo.toml b/frame/support/test/compile_pass/Cargo.toml index 4466c24d64f15..353847b4b2b7c 100644 --- a/frame/support/test/compile_pass/Cargo.toml +++ b/frame/support/test/compile_pass/Cargo.toml @@ -14,7 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } -frame-support = { version = "4.0.0-dev", default-features = false, path = "../../" } +renamed-frame-support = { package = "frame-support", version = "4.0.0-dev", default-features = false, path = "../../" } frame-system = { version = "4.0.0-dev", default-features = false, path = "../../../system" } sp-core = { version = "7.0.0", default-features = false, path = "../../../../primitives/core" } sp-runtime = { version = "7.0.0", default-features = false, path = "../../../../primitives/runtime" } @@ -24,7 +24,7 @@ sp-version = { version = "5.0.0", default-features = false, path = "../../../../ default = ["std"] std = [ "codec/std", - "frame-support/std", + "renamed-frame-support/std", "frame-system/std", "scale-info/std", "sp-core/std", diff --git a/frame/support/test/compile_pass/src/lib.rs b/frame/support/test/compile_pass/src/lib.rs index 7e9fdaff27b03..4eaa657b1e486 100644 --- a/frame/support/test/compile_pass/src/lib.rs +++ b/frame/support/test/compile_pass/src/lib.rs @@ -16,15 +16,13 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +//! Test that `construct_runtime!` also works when `frame-support` is renamed in the `Cargo.toml`. + #![cfg_attr(not(feature = "std"), no_std)] -// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256. -#![recursion_limit = "256"] -//! This crate tests that `construct_runtime!` expands the pallet parts -//! correctly even when frame-support is renamed in Cargo.toml -use frame_support::{ +use renamed_frame_support::{ construct_runtime, parameter_types, - traits::{ConstU16, ConstU32, ConstU64}, + traits::{ConstU16, ConstU32, ConstU64, Everything}, }; use sp_core::{sr25519, H256}; use sp_runtime::{ @@ -54,7 +52,7 @@ parameter_types! { } impl frame_system::Config for Runtime { - type BaseCallFilter = frame_support::traits::Everything; + type BaseCallFilter = Everything; type BlockWeights = (); type BlockLength = (); type Index = u128; diff --git a/frame/support/test/pallet/src/lib.rs b/frame/support/test/pallet/src/lib.rs index 82f12ea954614..2dfc94d83187a 100644 --- a/frame/support/test/pallet/src/lib.rs +++ b/frame/support/test/pallet/src/lib.rs @@ -15,7 +15,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -//! Testing pallet macro +//! A basic pallet that can be used to test `construct_runtime!`. // Ensure docs are propagated properly by the macros. #![warn(missing_docs)] @@ -24,10 +24,7 @@ pub use pallet::*; #[frame_support::pallet] pub mod pallet { - #[allow(unused_imports)] use frame_support::pallet_prelude::*; - #[allow(unused_imports)] - use frame_system::pallet_prelude::*; #[pallet::pallet] pub struct Pallet(_); @@ -37,7 +34,7 @@ pub mod pallet { /// I'm the documentation #[pallet::storage] - pub type Value = StorageValue; + pub type Value = StorageValue<_, u32>; #[pallet::genesis_config] #[cfg_attr(feature = "std", derive(Default))] diff --git a/frame/support/test/src/lib.rs b/frame/support/test/src/lib.rs index c0b025380dd45..5dccc88471a7b 100644 --- a/frame/support/test/src/lib.rs +++ b/frame/support/test/src/lib.rs @@ -15,48 +15,113 @@ // See the License for the specific language governing permissions and // limitations under the License. -//! Test crate for frame_support. Allow to make use of `frame_support::decl_storage`. -//! See tests directory. +//! Minimal pallet without `frame_system::Config`-super trait. // Make sure we fail compilation on warnings #![warn(missing_docs)] #![deny(warnings)] -/// The configuration trait -pub trait Config: 'static { - /// The runtime origin type. - type RuntimeOrigin: codec::Codec + codec::EncodeLike + Default + scale_info::TypeInfo; - /// The block number type. - type BlockNumber: codec::Codec + codec::EncodeLike + Default + scale_info::TypeInfo; - /// The information about the pallet setup in the runtime. - type PalletInfo: frame_support::traits::PalletInfo; - /// The db weights. - type DbWeight: frame_support::traits::Get; -} +pub use frame_support::dispatch::RawOrigin; -frame_support::decl_module! { - /// Some test module - pub struct Module for enum Call where origin: T::RuntimeOrigin, system=self {} -} +pub use self::pallet::*; + +#[frame_support::pallet(dev_mode)] +pub mod pallet { + use super::*; + use crate::{self as frame_system, pallet_prelude::*}; + use frame_support::pallet_prelude::*; -/// A PalletInfo implementation which just panics. -pub struct PanicPalletInfo; + #[pallet::pallet] + pub struct Pallet(_); -impl frame_support::traits::PalletInfo for PanicPalletInfo { - fn index() -> Option { - unimplemented!("PanicPalletInfo mustn't be triggered by tests"); + /// The configuration trait + #[pallet::config] + #[pallet::disable_frame_system_supertrait_check] + pub trait Config: 'static + Eq + Clone { + /// The block number type. + type BlockNumber: Parameter + Member + Default + MaybeSerializeDeserialize + MaxEncodedLen; + /// The account type. + type AccountId: Parameter + Member + MaxEncodedLen; + /// The basic call filter to use in Origin. + type BaseCallFilter: frame_support::traits::Contains; + /// The runtime origin type. + type RuntimeOrigin: Into, Self::RuntimeOrigin>> + + From>; + /// The runtime call type. + type RuntimeCall; + /// The runtime event type. + type RuntimeEvent: Parameter + + Member + + IsType<::RuntimeEvent> + + From>; + /// The information about the pallet setup in the runtime. + type PalletInfo: frame_support::traits::PalletInfo; + /// The db weights. + type DbWeight: Get; } - fn name() -> Option<&'static str> { - unimplemented!("PanicPalletInfo mustn't be triggered by tests"); + + #[pallet::call] + impl Pallet { + /// A noop call. + pub fn noop(_origin: OriginFor) -> DispatchResult { + Ok(()) + } } - fn module_name() -> Option<&'static str> { - unimplemented!("PanicPalletInfo mustn't be triggered by tests"); + + impl Pallet { + /// A empty method. + pub fn deposit_event(_event: impl Into) {} } - fn crate_version() -> Option { - unimplemented!("PanicPalletInfo mustn't be triggered by tests"); + + /// The origin type. + #[pallet::origin] + pub type Origin = RawOrigin<::AccountId>; + + /// The error type. + #[pallet::error] + pub enum Error { + /// Test error documentation + TestError, + /// Error documentation + /// with multiple lines + AnotherError, + /// Required by construct_runtime + CallFiltered, + } + + /// The event type. + #[pallet::event] + pub enum Event { + /// The extrinsic is successful + ExtrinsicSuccess, + /// The extrinsic is failed + ExtrinsicFailed, + /// The ignored error + Ignore(::BlockNumber), } } +/// Ensure that the origin `o` represents the root. Returns `Ok` or an `Err` otherwise. +pub fn ensure_root(o: OuterOrigin) -> Result<(), &'static str> +where + OuterOrigin: Into, OuterOrigin>>, +{ + o.into().map(|_| ()).map_err(|_| "bad origin: expected to be a root origin") +} + +/// Same semantic as [`frame_system`]. +// Note: we cannot use [`frame_system`] here since the pallet does not depend on +// [`frame_system::Config`]. +pub mod pallet_prelude { + pub use crate::ensure_root; + + /// Type alias for the `Origin` associated type of system config. + pub type OriginFor = ::RuntimeOrigin; + + /// Type alias for the `BlockNumber` associated type of system config. + pub type BlockNumberFor = ::BlockNumber; +} + /// Provides an implementation of [`frame_support::traits::Randomness`] that should only be used in /// tests! pub struct TestRandomness(sp_std::marker::PhantomData); diff --git a/frame/support/test/src/pallet_version.rs b/frame/support/test/src/pallet_version.rs deleted file mode 100644 index b015699685a44..0000000000000 --- a/frame/support/test/src/pallet_version.rs +++ /dev/null @@ -1,29 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use frame_support::{crate_to_pallet_version, traits::PalletVersion}; - -#[test] -fn ensure_that_current_pallet_version_is_correct() { - let expected = PalletVersion { - major: env!("CARGO_PKG_VERSION_MAJOR").parse().unwrap(), - minor: env!("CARGO_PKG_VERSION_MINOR").parse().unwrap(), - patch: env!("CARGO_PKG_VERSION_PATCH").parse().unwrap(), - }; - - assert_eq!(expected, crate_to_pallet_version!()) -} diff --git a/frame/support/test/tests/benchmark_ui/invalid_origin.rs b/frame/support/test/tests/benchmark_ui/invalid_origin.rs index 81cfc39790969..cfb00e88c00c0 100644 --- a/frame/support/test/tests/benchmark_ui/invalid_origin.rs +++ b/frame/support/test/tests/benchmark_ui/invalid_origin.rs @@ -10,7 +10,7 @@ mod benches { #[benchmark] fn bench() { #[extrinsic_call] - thing(1); + noop(1); } } diff --git a/frame/support/test/tests/benchmark_ui/invalid_origin.stderr b/frame/support/test/tests/benchmark_ui/invalid_origin.stderr index 1818442b679a2..115a8206f58a3 100644 --- a/frame/support/test/tests/benchmark_ui/invalid_origin.stderr +++ b/frame/support/test/tests/benchmark_ui/invalid_origin.stderr @@ -1,11 +1,3 @@ -error[E0599]: no variant or associated item named `new_call_variant_thing` found for enum `frame_support_test::Call` in the current scope - --> tests/benchmark_ui/invalid_origin.rs:6:1 - | -6 | #[benchmarks] - | ^^^^^^^^^^^^^ variant or associated item not found in `Call` - | - = note: this error originates in the attribute macro `benchmarks` (in Nightly builds, run with -Z macro-backtrace for more info) - error[E0277]: the trait bound `::RuntimeOrigin: From<{integer}>` is not satisfied --> tests/benchmark_ui/invalid_origin.rs:6:1 | diff --git a/frame/support/test/tests/construct_runtime.rs b/frame/support/test/tests/construct_runtime.rs index d0b31d71a6fcb..85e790095eb31 100644 --- a/frame/support/test/tests/construct_runtime.rs +++ b/frame/support/test/tests/construct_runtime.rs @@ -24,234 +24,233 @@ use codec::MaxEncodedLen; use frame_support::{parameter_types, traits::PalletInfo as _}; use scale_info::TypeInfo; -use sp_core::{sr25519, H256}; +use sp_core::sr25519; use sp_runtime::{ generic, traits::{BlakeTwo256, Verify}, DispatchError, ModuleError, }; -mod system; - -pub trait Currency {} - parameter_types! { pub static IntegrityTestExec: u32 = 0; } +#[frame_support::pallet(dev_mode)] mod module1 { - use super::*; + use self::frame_system::pallet_prelude::*; + use frame_support::pallet_prelude::*; + use frame_support_test as frame_system; - pub trait Config: system::Config {} + #[pallet::pallet] + pub struct Pallet(_); - frame_support::decl_module! { - pub struct Module, I: Instance = DefaultInstance> for enum Call - where origin: ::RuntimeOrigin, system=system - { - #[weight = 0] - pub fn fail(_origin) -> frame_support::dispatch::DispatchResult { - Err(Error::::Something.into()) - } - } + #[pallet::config] + pub trait Config: frame_system::Config { + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; } - #[derive( - Clone, PartialEq, Eq, Debug, codec::Encode, codec::Decode, TypeInfo, MaxEncodedLen, - )] - pub struct Origin(pub core::marker::PhantomData<(T, I)>); - - frame_support::decl_event! { - pub enum Event where - ::AccountId - { - A(AccountId), + #[pallet::call] + impl, I: 'static> Pallet { + pub fn fail(_origin: OriginFor) -> DispatchResult { + Err(Error::::Something.into()) } } - frame_support::decl_error! { - pub enum Error for Module, I: Instance> { - Something - } + #[pallet::origin] + #[derive(Clone, PartialEq, Eq, RuntimeDebug, Encode, Decode, MaxEncodedLen, TypeInfo)] + #[scale_info(skip_type_params(I))] + pub struct Origin(pub PhantomData<(T, I)>); + + #[pallet::event] + pub enum Event, I: 'static = ()> { + A(::AccountId), } - frame_support::decl_storage! { - trait Store for Module, I: Instance=DefaultInstance> as Module {} + #[pallet::error] + pub enum Error { + Something, } } +#[frame_support::pallet(dev_mode)] mod module2 { + use self::frame_system::pallet_prelude::*; use super::*; + use frame_support::pallet_prelude::*; + use frame_support_test as frame_system; - pub trait Config: system::Config {} + #[pallet::pallet] + pub struct Pallet(_); - frame_support::decl_module! { - pub struct Module for enum Call - where origin: ::RuntimeOrigin, system=system - { - #[weight = 0] - pub fn fail(_origin) -> frame_support::dispatch::DispatchResult { - Err(Error::::Something.into()) - } + #[pallet::config] + pub trait Config: frame_system::Config { + type RuntimeEvent: From> + IsType<::RuntimeEvent>; + } - fn integrity_test() { - IntegrityTestExec::mutate(|i| *i += 1); - } + #[pallet::hooks] + impl Hooks> for Pallet { + fn integrity_test() { + IntegrityTestExec::mutate(|i| *i += 1); } } - #[derive( - Clone, PartialEq, Eq, Debug, codec::Encode, codec::Decode, TypeInfo, MaxEncodedLen, - )] - pub struct Origin; - - frame_support::decl_event! { - pub enum Event { - A, + #[pallet::call] + impl Pallet { + pub fn fail(_origin: OriginFor) -> DispatchResult { + Err(Error::::Something.into()) } } - frame_support::decl_error! { - pub enum Error for Module { - Something - } + #[pallet::origin] + #[derive(Clone, PartialEq, Eq, RuntimeDebug, Encode, Decode, MaxEncodedLen, TypeInfo)] + pub struct Origin; + + #[pallet::event] + pub enum Event { + A, } - frame_support::decl_storage! { - trait Store for Module as Module {} + #[pallet::error] + pub enum Error { + Something, } } mod nested { use super::*; + #[frame_support::pallet(dev_mode)] pub mod module3 { + use self::frame_system::pallet_prelude::*; use super::*; + use frame_support::pallet_prelude::*; + use frame_support_test as frame_system; + + #[pallet::pallet] + pub struct Pallet(_); - pub trait Config: system::Config {} + #[pallet::config] + pub trait Config: frame_system::Config { + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; + } - frame_support::decl_module! { - pub struct Module for enum Call - where origin: ::RuntimeOrigin, system=system - { - #[weight = 0] - pub fn fail(_origin) -> frame_support::dispatch::DispatchResult { - Err(Error::::Something.into()) - } + #[pallet::hooks] + impl Hooks> for Pallet { + fn integrity_test() { + IntegrityTestExec::mutate(|i| *i += 1); + } + } - fn integrity_test() { - IntegrityTestExec::mutate(|i| *i += 1); - } + #[pallet::call] + impl Pallet { + pub fn fail(_origin: OriginFor) -> DispatchResult { + Err(Error::::Something.into()) } } - #[derive( - Clone, PartialEq, Eq, Debug, codec::Encode, codec::Decode, TypeInfo, MaxEncodedLen, - )] + #[pallet::origin] + #[derive(Clone, PartialEq, Eq, RuntimeDebug, Encode, Decode, MaxEncodedLen, TypeInfo)] pub struct Origin; - frame_support::decl_event! { - pub enum Event { - A, - } + #[pallet::event] + pub enum Event { + A, } - frame_support::decl_error! { - pub enum Error for Module { - Something - } + #[pallet::error] + pub enum Error { + Something, } - frame_support::decl_storage! { - trait Store for Module as Module {} - add_extra_genesis { - build(|_config| {}) - } + #[pallet::genesis_config] + #[derive(Default)] + pub struct GenesisConfig {} + + #[pallet::genesis_build] + impl GenesisBuild for GenesisConfig { + fn build(&self) {} } } } +#[frame_support::pallet(dev_mode)] pub mod module3 { + use self::frame_system::pallet_prelude::*; use super::*; + use frame_support::pallet_prelude::*; + use frame_support_test as frame_system; - pub trait Config: system::Config {} + #[pallet::pallet] + pub struct Pallet(_); - frame_support::decl_module! { - pub struct Module for enum Call - where origin: ::RuntimeOrigin, system=system - { - #[weight = 0] - pub fn fail(_origin) -> frame_support::dispatch::DispatchResult { - Err(Error::::Something.into()) - } - #[weight = 0] - pub fn aux_1(_origin, #[compact] _data: u32) -> frame_support::dispatch::DispatchResult { - unreachable!() - } - #[weight = 0] - pub fn aux_2(_origin, _data: i32, #[compact] _data2: u32) -> frame_support::dispatch::DispatchResult { - unreachable!() - } - #[weight = 0] - fn aux_3(_origin, _data: i32, _data2: String) -> frame_support::dispatch::DispatchResult { - unreachable!() - } - #[weight = 3] - fn aux_4(_origin) -> frame_support::dispatch::DispatchResult { unreachable!() } - #[weight = (5, frame_support::dispatch::DispatchClass::Operational)] - fn operational(_origin) { unreachable!() } + #[pallet::config] + pub trait Config: frame_system::Config { + type RuntimeEvent: From> + IsType<::RuntimeEvent>; + } + + #[pallet::call] + impl Pallet { + pub fn fail(_origin: OriginFor) -> DispatchResult { + Err(Error::::Something.into()) + } + pub fn aux_1(_origin: OriginFor, #[pallet::compact] _data: u32) -> DispatchResult { + unreachable!() + } + pub fn aux_2( + _origin: OriginFor, + _data: i32, + #[pallet::compact] _data2: u32, + ) -> DispatchResult { + unreachable!() + } + #[pallet::weight(0)] + pub fn aux_3(_origin: OriginFor, _data: i32, _data2: String) -> DispatchResult { + unreachable!() + } + #[pallet::weight(3)] + pub fn aux_4(_origin: OriginFor) -> DispatchResult { + unreachable!() + } + #[pallet::weight((5, DispatchClass::Operational))] + pub fn operational(_origin: OriginFor) -> DispatchResult { + unreachable!() } } - #[derive( - Clone, PartialEq, Eq, Debug, codec::Encode, codec::Decode, TypeInfo, MaxEncodedLen, - )] - pub struct Origin(pub core::marker::PhantomData); + #[pallet::origin] + #[derive(Clone, PartialEq, Eq, RuntimeDebug, Encode, Decode, MaxEncodedLen, TypeInfo)] + pub struct Origin(pub PhantomData); - frame_support::decl_event! { - pub enum Event { - A, - } + #[pallet::event] + pub enum Event { + A, } - frame_support::decl_error! { - pub enum Error for Module { - Something - } + #[pallet::error] + pub enum Error { + Something, } - frame_support::decl_storage! { - trait Store for Module as Module {} - add_extra_genesis { - build(|_config| {}) - } + #[pallet::genesis_config] + #[derive(Default)] + pub struct GenesisConfig {} + + #[pallet::genesis_build] + impl GenesisBuild for GenesisConfig { + fn build(&self) {} } } -impl module1::Config for Runtime {} -impl module2::Config for Runtime {} -impl nested::module3::Config for Runtime {} -impl module3::Config for Runtime {} - +pub type BlockNumber = u64; pub type Signature = sr25519::Signature; pub type AccountId = ::Signer; -pub type BlockNumber = u64; -pub type Index = u64; - -fn test_pub() -> AccountId { - AccountId::from_raw([0; 32]) -} +pub type Header = generic::Header; +pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; +pub type Block = generic::Block; -impl system::Config for Runtime { - type BaseCallFilter = frame_support::traits::Everything; - type Hash = H256; - type RuntimeOrigin = RuntimeOrigin; - type BlockNumber = BlockNumber; - type AccountId = AccountId; - type RuntimeEvent = RuntimeEvent; - type PalletInfo = PalletInfo; - type RuntimeCall = RuntimeCall; - type DbWeight = (); -} +use frame_support_test as system; frame_support::construct_runtime!( pub struct Runtime where @@ -261,12 +260,12 @@ frame_support::construct_runtime!( { System: system::{Pallet, Call, Event, Origin} = 30, Module1_1: module1::::{Pallet, Call, Storage, Event, Origin}, - Module2: module2::{Pallet, Call, Storage, Event, Origin}, + Module2: module2::{Pallet, Call, Storage, Event, Origin}, Module1_2: module1::::{Pallet, Call, Storage, Event, Origin}, - NestedModule3: nested::module3::{Pallet, Call, Config, Storage, Event, Origin}, - Module3: self::module3::{Pallet, Call, Config, Storage, Event, Origin}, - Module1_3: module1::::{Pallet, Storage} = 6, - Module1_4: module1::::{Pallet, Call} = 3, + NestedModule3: nested::module3::{Pallet, Call, Config, Storage, Event, Origin}, + Module3: self::module3::{Pallet, Call, Config, Storage, Event, Origin}, + Module1_3: module1::::{Pallet, Storage, Event } = 6, + Module1_4: module1::::{Pallet, Call, Event } = 3, Module1_5: module1::::{Pallet, Event}, Module1_6: module1::::{Pallet, Call, Storage, Event, Origin} = 1, Module1_7: module1::::{Pallet, Call, Storage, Event, Origin}, @@ -275,9 +274,57 @@ frame_support::construct_runtime!( } ); -pub type Header = generic::Header; -pub type Block = generic::Block; -pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; +impl frame_support_test::Config for Runtime { + type BlockNumber = BlockNumber; + type AccountId = AccountId; + type BaseCallFilter = frame_support::traits::Everything; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type PalletInfo = PalletInfo; + type DbWeight = (); +} + +impl module1::Config for Runtime { + type RuntimeEvent = RuntimeEvent; +} +impl module1::Config for Runtime { + type RuntimeEvent = RuntimeEvent; +} +impl module1::Config for Runtime { + type RuntimeEvent = RuntimeEvent; +} +impl module1::Config for Runtime { + type RuntimeEvent = RuntimeEvent; +} +impl module1::Config for Runtime { + type RuntimeEvent = RuntimeEvent; +} +impl module1::Config for Runtime { + type RuntimeEvent = RuntimeEvent; +} +impl module1::Config for Runtime { + type RuntimeEvent = RuntimeEvent; +} +impl module1::Config for Runtime { + type RuntimeEvent = RuntimeEvent; +} +impl module1::Config for Runtime { + type RuntimeEvent = RuntimeEvent; +} +impl module2::Config for Runtime { + type RuntimeEvent = RuntimeEvent; +} +impl nested::module3::Config for Runtime { + type RuntimeEvent = RuntimeEvent; +} +impl module3::Config for Runtime { + type RuntimeEvent = RuntimeEvent; +} + +fn test_pub() -> AccountId { + AccountId::from_raw([0; 32]) +} #[test] fn check_modules_error_type() { @@ -471,12 +518,12 @@ fn call_codec() { #[test] fn call_compact_attr() { use codec::Encode; - let call: module3::Call = module3::Call::aux_1 { _data: 1 }; + let call: module3::Call = module3::Call::aux_1 { data: 1 }; let encoded = call.encode(); assert_eq!(2, encoded.len()); assert_eq!(vec![1, 4], encoded); - let call: module3::Call = module3::Call::aux_2 { _data: 1, _data2: 2 }; + let call: module3::Call = module3::Call::aux_2 { data: 1, data2: 2 }; let encoded = call.encode(); assert_eq!(6, encoded.len()); assert_eq!(vec![2, 1, 0, 0, 0, 8], encoded); @@ -491,7 +538,7 @@ fn call_encode_is_correct_and_decode_works() { let decoded = module3::Call::::decode(&mut &encoded[..]).unwrap(); assert_eq!(decoded, call); - let call: module3::Call = module3::Call::aux_3 { _data: 32, _data2: "hello".into() }; + let call: module3::Call = module3::Call::aux_3 { data: 32, data2: "hello".into() }; let encoded = call.encode(); assert_eq!(vec![3, 32, 0, 0, 0, 20, 104, 101, 108, 108, 111], encoded); let decoded = module3::Call::::decode(&mut &encoded[..]).unwrap(); @@ -594,70 +641,70 @@ fn test_metadata() { calls: Some(meta_type::>().into()), event: Some(meta_type::>().into()), constants: vec![], - error: None, + error: Some(meta_type::>().into()), index: 30, }, PalletMetadata { name: "Module1_1", - storage: Some(PalletStorageMetadata { prefix: "Instance1Module", entries: vec![] }), + storage: Some(PalletStorageMetadata { prefix: "Module1_1", entries: vec![] }), calls: Some(meta_type::>().into()), event: Some(meta_type::>().into()), constants: vec![], - error: None, + error: Some(meta_type::>().into()), index: 31, }, PalletMetadata { name: "Module2", - storage: Some(PalletStorageMetadata { prefix: "Module", entries: vec![] }), + storage: Some(PalletStorageMetadata { prefix: "Module2", entries: vec![] }), calls: Some(meta_type::>().into()), - event: Some(meta_type::().into()), + event: Some(meta_type::>().into()), constants: vec![], - error: None, + error: Some(meta_type::>().into()), index: 32, }, PalletMetadata { name: "Module1_2", - storage: Some(PalletStorageMetadata { prefix: "Instance2Module", entries: vec![] }), + storage: Some(PalletStorageMetadata { prefix: "Module1_2", entries: vec![] }), calls: Some(meta_type::>().into()), event: Some(meta_type::>().into()), constants: vec![], - error: None, + error: Some(meta_type::>().into()), index: 33, }, PalletMetadata { name: "NestedModule3", - storage: Some(PalletStorageMetadata { prefix: "Module", entries: vec![] }), + storage: Some(PalletStorageMetadata { prefix: "NestedModule3", entries: vec![] }), calls: Some(meta_type::>().into()), - event: Some(meta_type::().into()), + event: Some(meta_type::>().into()), constants: vec![], - error: None, + error: Some(meta_type::>().into()), index: 34, }, PalletMetadata { name: "Module3", - storage: Some(PalletStorageMetadata { prefix: "Module", entries: vec![] }), + storage: Some(PalletStorageMetadata { prefix: "Module3", entries: vec![] }), calls: Some(meta_type::>().into()), - event: Some(meta_type::().into()), + event: Some(meta_type::>().into()), constants: vec![], - error: None, + error: Some(meta_type::>().into()), index: 35, }, PalletMetadata { name: "Module1_3", - storage: Some(PalletStorageMetadata { prefix: "Instance3Module", entries: vec![] }), + storage: Some(PalletStorageMetadata { prefix: "Module1_3", entries: vec![] }), calls: None, - event: None, + event: Some(meta_type::>().into()), constants: vec![], - error: None, + error: Some(meta_type::>().into()), index: 6, }, PalletMetadata { name: "Module1_4", storage: None, calls: Some(meta_type::>().into()), - event: None, + event: Some(meta_type::>().into()), constants: vec![], - error: None, + error: Some(meta_type::>().into()), index: 3, }, PalletMetadata { @@ -666,45 +713,43 @@ fn test_metadata() { calls: None, event: Some(meta_type::>().into()), constants: vec![], - error: None, + error: Some(meta_type::>().into()), index: 4, }, PalletMetadata { name: "Module1_6", - storage: Some(PalletStorageMetadata { prefix: "Instance6Module", entries: vec![] }), + storage: Some(PalletStorageMetadata { prefix: "Module1_6", entries: vec![] }), calls: Some(meta_type::>().into()), event: Some(meta_type::>().into()), constants: vec![], - error: None, + error: Some(meta_type::>().into()), index: 1, }, PalletMetadata { name: "Module1_7", - storage: Some(PalletStorageMetadata { prefix: "Instance7Module", entries: vec![] }), + storage: Some(PalletStorageMetadata { prefix: "Module1_7", entries: vec![] }), calls: Some(meta_type::>().into()), - event: Some(PalletEventMetadata { - ty: meta_type::>(), - }), + event: Some(meta_type::>().into()), constants: vec![], - error: None, + error: Some(meta_type::>().into()), index: 2, }, PalletMetadata { name: "Module1_8", - storage: Some(PalletStorageMetadata { prefix: "Instance8Module", entries: vec![] }), + storage: Some(PalletStorageMetadata { prefix: "Module1_8", entries: vec![] }), calls: Some(meta_type::>().into()), event: Some(meta_type::>().into()), constants: vec![], - error: None, + error: Some(meta_type::>().into()), index: 12, }, PalletMetadata { name: "Module1_9", - storage: Some(PalletStorageMetadata { prefix: "Instance9Module", entries: vec![] }), + storage: Some(PalletStorageMetadata { prefix: "Module1_9", entries: vec![] }), calls: Some(meta_type::>().into()), event: Some(meta_type::>().into()), constants: vec![], - error: None, + error: Some(meta_type::>().into()), index: 13, }, ]; @@ -722,6 +767,7 @@ fn test_metadata() { let expected_metadata: RuntimeMetadataPrefixed = RuntimeMetadataLastVersion::new(pallets, extrinsic, meta_type::()).into(); let actual_metadata = Runtime::metadata(); + pretty_assertions::assert_eq!(actual_metadata, expected_metadata); } diff --git a/frame/support/test/tests/construct_runtime_ui/old_unsupported_pallet_decl.rs b/frame/support/test/tests/construct_runtime_ui/old_unsupported_pallet_decl.rs deleted file mode 100644 index 477ca3cc088a2..0000000000000 --- a/frame/support/test/tests/construct_runtime_ui/old_unsupported_pallet_decl.rs +++ /dev/null @@ -1,26 +0,0 @@ -use frame_support::construct_runtime; - -mod pallet_old { - pub trait Config: frame_system::Config {} - - decl_storage! { - trait Store for Module as Example {} - } - - decl_module! { - pub struct Module for enum Call where origin: T::RuntimeOrigin {} - } - -} -construct_runtime! { - pub struct Runtime where - UncheckedExtrinsic = UncheckedExtrinsic, - Block = Block, - NodeBlock = Block, - { - System: frame_system, - OldPallet: pallet_old, - } -} - -fn main() {} diff --git a/frame/support/test/tests/construct_runtime_ui/old_unsupported_pallet_decl.stderr b/frame/support/test/tests/construct_runtime_ui/old_unsupported_pallet_decl.stderr deleted file mode 100644 index b1338e8920f41..0000000000000 --- a/frame/support/test/tests/construct_runtime_ui/old_unsupported_pallet_decl.stderr +++ /dev/null @@ -1,31 +0,0 @@ -error[E0433]: failed to resolve: could not find `tt_default_parts` in `pallet_old` - --> tests/construct_runtime_ui/old_unsupported_pallet_decl.rs:15:1 - | -15 | / construct_runtime! { -16 | | pub struct Runtime where -17 | | UncheckedExtrinsic = UncheckedExtrinsic, -18 | | Block = Block, -... | -23 | | } -24 | | } - | |_^ could not find `tt_default_parts` in `pallet_old` - | - = note: this error originates in the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: cannot find macro `decl_storage` in this scope - --> tests/construct_runtime_ui/old_unsupported_pallet_decl.rs:6:2 - | -6 | decl_storage! { - | ^^^^^^^^^^^^ - | - = help: consider importing this macro: - frame_support::decl_storage - -error: cannot find macro `decl_module` in this scope - --> tests/construct_runtime_ui/old_unsupported_pallet_decl.rs:10:2 - | -10 | decl_module! { - | ^^^^^^^^^^^ - | - = help: consider importing this macro: - frame_support::decl_module diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_event_part.stderr b/frame/support/test/tests/construct_runtime_ui/undefined_event_part.stderr index 1ca64f381b005..daf027a5080cb 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_event_part.stderr +++ b/frame/support/test/tests/construct_runtime_ui/undefined_event_part.stderr @@ -28,7 +28,9 @@ error[E0412]: cannot find type `Event` in module `pallet` | |_^ not found in `pallet` | = note: this error originates in the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) -help: consider importing this enum +help: consider importing one of these items + | +1 | use frame_support_test::Event; | 1 | use frame_system::Event; | diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.stderr b/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.stderr index dbade9fed2cff..3e4326d3f7372 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.stderr +++ b/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.stderr @@ -28,7 +28,9 @@ error[E0412]: cannot find type `Origin` in module `pallet` | |_^ not found in `pallet` | = note: this error originates in the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) -help: consider importing this type alias +help: consider importing one of these items + | +1 | use frame_support_test::Origin; | 1 | use frame_system::Origin; | diff --git a/frame/support/test/tests/decl_module_ui.rs b/frame/support/test/tests/decl_module_ui.rs deleted file mode 100644 index 296ae3e586f54..0000000000000 --- a/frame/support/test/tests/decl_module_ui.rs +++ /dev/null @@ -1,32 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#[rustversion::attr(not(stable), ignore)] -#[cfg(not(feature = "disable-ui-tests"))] -#[test] -fn decl_module_ui() { - // Only run the ui tests when `RUN_UI_TESTS` is set. - if std::env::var("RUN_UI_TESTS").is_err() { - return - } - - // As trybuild is using `cargo check`, we don't need the real WASM binaries. - std::env::set_var("SKIP_WASM_BUILD", "1"); - - let t = trybuild::TestCases::new(); - t.compile_fail("tests/decl_module_ui/*.rs"); -} diff --git a/frame/support/test/tests/decl_module_ui/reserved_keyword_two_times_integrity_test.rs b/frame/support/test/tests/decl_module_ui/reserved_keyword_two_times_integrity_test.rs deleted file mode 100644 index 0f662b96e2b13..0000000000000 --- a/frame/support/test/tests/decl_module_ui/reserved_keyword_two_times_integrity_test.rs +++ /dev/null @@ -1,7 +0,0 @@ -frame_support::decl_module! { - pub struct Module for enum Call where origin: T::RuntimeOrigin, system=self { - fn integrity_test() {} - - fn integrity_test() {} - } -} diff --git a/frame/support/test/tests/decl_module_ui/reserved_keyword_two_times_integrity_test.stderr b/frame/support/test/tests/decl_module_ui/reserved_keyword_two_times_integrity_test.stderr deleted file mode 100644 index 4212707599d41..0000000000000 --- a/frame/support/test/tests/decl_module_ui/reserved_keyword_two_times_integrity_test.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error: `integrity_test` can only be passed once as input. - --> tests/decl_module_ui/reserved_keyword_two_times_integrity_test.rs:1:1 - | -1 | / frame_support::decl_module! { -2 | | pub struct Module for enum Call where origin: T::RuntimeOrigin, system=self { -3 | | fn integrity_test() {} -4 | | -5 | | fn integrity_test() {} -6 | | } -7 | | } - | |_^ - | - = note: this error originates in the macro `$crate::decl_module` which comes from the expansion of the macro `frame_support::decl_module` (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0601]: `main` function not found in crate `$CRATE` - --> tests/decl_module_ui/reserved_keyword_two_times_integrity_test.rs:7:2 - | -7 | } - | ^ consider adding a `main` function to `$DIR/tests/decl_module_ui/reserved_keyword_two_times_integrity_test.rs` diff --git a/frame/support/test/tests/decl_module_ui/reserved_keyword_two_times_on_initialize.rs b/frame/support/test/tests/decl_module_ui/reserved_keyword_two_times_on_initialize.rs deleted file mode 100644 index ea0746b1c501c..0000000000000 --- a/frame/support/test/tests/decl_module_ui/reserved_keyword_two_times_on_initialize.rs +++ /dev/null @@ -1,13 +0,0 @@ -frame_support::decl_module! { - pub struct Module for enum Call where origin: T::RuntimeOrigin, system=self { - fn on_initialize() -> Weight { - 0 - } - - fn on_initialize() -> Weight { - 0 - } - } -} - -fn main() {} diff --git a/frame/support/test/tests/decl_module_ui/reserved_keyword_two_times_on_initialize.stderr b/frame/support/test/tests/decl_module_ui/reserved_keyword_two_times_on_initialize.stderr deleted file mode 100644 index 94bde853e4cc8..0000000000000 --- a/frame/support/test/tests/decl_module_ui/reserved_keyword_two_times_on_initialize.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error: `on_initialize` can only be passed once as input. - --> tests/decl_module_ui/reserved_keyword_two_times_on_initialize.rs:1:1 - | -1 | / frame_support::decl_module! { -2 | | pub struct Module for enum Call where origin: T::RuntimeOrigin, system=self { -3 | | fn on_initialize() -> Weight { -4 | | 0 -... | -10 | | } -11 | | } - | |_^ - | - = note: this error originates in the macro `$crate::decl_module` which comes from the expansion of the macro `frame_support::decl_module` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/frame/support/test/tests/decl_storage.rs b/frame/support/test/tests/decl_storage.rs deleted file mode 100644 index bee1dc83d5589..0000000000000 --- a/frame/support/test/tests/decl_storage.rs +++ /dev/null @@ -1,881 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#[cfg(test)] -// Do not complain about unused `dispatch` and `dispatch_aux`. -#[allow(dead_code)] -mod tests { - use frame_support::metadata_ir::*; - use sp_io::TestExternalities; - - frame_support::decl_module! { - pub struct Module for enum Call where origin: T::RuntimeOrigin, system=frame_support_test {} - } - - pub trait Config: frame_support_test::Config { - type Origin2: codec::Codec - + codec::EncodeLike - + Default - + codec::MaxEncodedLen - + scale_info::TypeInfo; - } - - frame_support::decl_storage! { - generate_storage_info - trait Store for Module as TestStorage { - // non-getters: pub / $default - - /// Hello, this is doc! - U32: Option; - pub PUBU32: Option; - U32MYDEF: Option; - pub PUBU32MYDEF: Option; - - // getters: pub / $default - // we need at least one type which uses T, otherwise GenesisConfig will complain. - GETU32 get(fn u32_getter): T::Origin2; - pub PUBGETU32 get(fn pub_u32_getter): u32; - GETU32WITHCONFIG get(fn u32_getter_with_config) config(): u32; - pub PUBGETU32WITHCONFIG get(fn pub_u32_getter_with_config) config(): u32; - GETU32MYDEF get(fn u32_getter_mydef): Option; - pub PUBGETU32MYDEF get(fn pub_u32_getter_mydef) config(): u32 = 3; - GETU32WITHCONFIGMYDEF get(fn u32_getter_with_config_mydef) config(): u32 = 2; - pub PUBGETU32WITHCONFIGMYDEF get(fn pub_u32_getter_with_config_mydef) config(): u32 = 1; - PUBGETU32WITHCONFIGMYDEFOPT get(fn pub_u32_getter_with_config_mydef_opt) config(): Option; - - GetU32WithBuilder get(fn u32_with_builder) build(|_| 1): u32; - GetOptU32WithBuilderSome get(fn opt_u32_with_builder_some) build(|_| Some(1)): Option; - GetOptU32WithBuilderNone get(fn opt_u32_with_builder_none) build(|_| None): Option; - - // map non-getters: pub / $default - MAPU32 max_values(3): map hasher(blake2_128_concat) u32 => Option<[u8; 4]>; - pub PUBMAPU32: map hasher(blake2_128_concat) u32 => Option<[u8; 4]>; - - // map getters: pub / $default - GETMAPU32 get(fn map_u32_getter): map hasher(blake2_128_concat) u32 => [u8; 4]; - pub PUBGETMAPU32 get(fn pub_map_u32_getter): map hasher(blake2_128_concat) u32 => [u8; 4]; - GETMAPU32MYDEF get(fn map_u32_getter_mydef): - map hasher(blake2_128_concat) u32 => [u8; 4] = *b"mapd"; - pub PUBGETMAPU32MYDEF get(fn pub_map_u32_getter_mydef): - map hasher(blake2_128_concat) u32 => [u8; 4] = *b"pubm"; - - DOUBLEMAP max_values(3): double_map - hasher(blake2_128_concat) u32, hasher(blake2_128_concat) u32 => Option<[u8; 4]>; - - DOUBLEMAP2: double_map - hasher(blake2_128_concat) u32, hasher(blake2_128_concat) u32 => Option<[u8; 4]>; - - COMPLEXTYPE1: (::std::option::Option,); - COMPLEXTYPE2: ([[(u16, Option<()>); 32]; 12], u32); - COMPLEXTYPE3: [u32; 25]; - - NMAP: nmap hasher(blake2_128_concat) u32, hasher(twox_64_concat) u16 => u8; - NMAP2: nmap hasher(blake2_128_concat) u32 => u8; - } - add_extra_genesis { - build(|_| {}); - } - } - - struct TraitImpl {} - - impl frame_support_test::Config for TraitImpl { - type RuntimeOrigin = u32; - type BlockNumber = u32; - type PalletInfo = frame_support_test::PanicPalletInfo; - type DbWeight = (); - } - - impl Config for TraitImpl { - type Origin2 = u32; - } - - fn expected_metadata() -> PalletStorageMetadataIR { - PalletStorageMetadataIR { - prefix: "TestStorage", - entries: vec![ - StorageEntryMetadataIR { - name: "U32", - modifier: StorageEntryModifierIR::Optional, - ty: StorageEntryTypeIR::Plain(scale_info::meta_type::()), - default: vec![0], - docs: vec![" Hello, this is doc!"], - }, - StorageEntryMetadataIR { - name: "PUBU32", - modifier: StorageEntryModifierIR::Optional, - ty: StorageEntryTypeIR::Plain(scale_info::meta_type::()), - default: vec![0], - docs: vec![], - }, - StorageEntryMetadataIR { - name: "U32MYDEF", - modifier: StorageEntryModifierIR::Optional, - ty: StorageEntryTypeIR::Plain(scale_info::meta_type::()), - default: vec![0], - docs: vec![], - }, - StorageEntryMetadataIR { - name: "PUBU32MYDEF", - modifier: StorageEntryModifierIR::Optional, - ty: StorageEntryTypeIR::Plain(scale_info::meta_type::()), - default: vec![0], - docs: vec![], - }, - StorageEntryMetadataIR { - name: "GETU32", - modifier: StorageEntryModifierIR::Default, - ty: StorageEntryTypeIR::Plain(scale_info::meta_type::()), - default: vec![0, 0, 0, 0], - docs: vec![], - }, - StorageEntryMetadataIR { - name: "PUBGETU32", - modifier: StorageEntryModifierIR::Default, - ty: StorageEntryTypeIR::Plain(scale_info::meta_type::()), - default: vec![0, 0, 0, 0], - docs: vec![], - }, - StorageEntryMetadataIR { - name: "GETU32WITHCONFIG", - modifier: StorageEntryModifierIR::Default, - ty: StorageEntryTypeIR::Plain(scale_info::meta_type::()), - default: vec![0, 0, 0, 0], - docs: vec![], - }, - StorageEntryMetadataIR { - name: "PUBGETU32WITHCONFIG", - modifier: StorageEntryModifierIR::Default, - ty: StorageEntryTypeIR::Plain(scale_info::meta_type::()), - default: vec![0, 0, 0, 0], - docs: vec![], - }, - StorageEntryMetadataIR { - name: "GETU32MYDEF", - modifier: StorageEntryModifierIR::Optional, - ty: StorageEntryTypeIR::Plain(scale_info::meta_type::()), - default: vec![0], - docs: vec![], - }, - StorageEntryMetadataIR { - name: "PUBGETU32MYDEF", - modifier: StorageEntryModifierIR::Default, - ty: StorageEntryTypeIR::Plain(scale_info::meta_type::()), - default: vec![3, 0, 0, 0], - docs: vec![], - }, - StorageEntryMetadataIR { - name: "GETU32WITHCONFIGMYDEF", - modifier: StorageEntryModifierIR::Default, - ty: StorageEntryTypeIR::Plain(scale_info::meta_type::()), - default: vec![2, 0, 0, 0], - docs: vec![], - }, - StorageEntryMetadataIR { - name: "PUBGETU32WITHCONFIGMYDEF", - modifier: StorageEntryModifierIR::Default, - ty: StorageEntryTypeIR::Plain(scale_info::meta_type::()), - default: vec![1, 0, 0, 0], - docs: vec![], - }, - StorageEntryMetadataIR { - name: "PUBGETU32WITHCONFIGMYDEFOPT", - modifier: StorageEntryModifierIR::Optional, - ty: StorageEntryTypeIR::Plain(scale_info::meta_type::()), - default: vec![0], - docs: vec![], - }, - StorageEntryMetadataIR { - name: "GetU32WithBuilder", - modifier: StorageEntryModifierIR::Default, - ty: StorageEntryTypeIR::Plain(scale_info::meta_type::()), - default: vec![0, 0, 0, 0], - docs: vec![], - }, - StorageEntryMetadataIR { - name: "GetOptU32WithBuilderSome", - modifier: StorageEntryModifierIR::Optional, - ty: StorageEntryTypeIR::Plain(scale_info::meta_type::()), - default: vec![0], - docs: vec![], - }, - StorageEntryMetadataIR { - name: "GetOptU32WithBuilderNone", - modifier: StorageEntryModifierIR::Optional, - ty: StorageEntryTypeIR::Plain(scale_info::meta_type::()), - default: vec![0], - docs: vec![], - }, - StorageEntryMetadataIR { - name: "MAPU32", - modifier: StorageEntryModifierIR::Optional, - ty: StorageEntryTypeIR::Map { - hashers: vec![StorageHasherIR::Blake2_128Concat], - key: scale_info::meta_type::(), - value: scale_info::meta_type::<[u8; 4]>(), - }, - default: vec![0], - docs: vec![], - }, - StorageEntryMetadataIR { - name: "PUBMAPU32", - modifier: StorageEntryModifierIR::Optional, - ty: StorageEntryTypeIR::Map { - hashers: vec![StorageHasherIR::Blake2_128Concat], - key: scale_info::meta_type::(), - value: scale_info::meta_type::<[u8; 4]>(), - }, - default: vec![0], - docs: vec![], - }, - StorageEntryMetadataIR { - name: "GETMAPU32", - modifier: StorageEntryModifierIR::Default, - ty: StorageEntryTypeIR::Map { - hashers: vec![StorageHasherIR::Blake2_128Concat], - key: scale_info::meta_type::(), - value: scale_info::meta_type::<[u8; 4]>(), - }, - default: vec![0, 0, 0, 0], - docs: vec![], - }, - StorageEntryMetadataIR { - name: "PUBGETMAPU32", - modifier: StorageEntryModifierIR::Default, - ty: StorageEntryTypeIR::Map { - hashers: vec![StorageHasherIR::Blake2_128Concat], - key: scale_info::meta_type::(), - value: scale_info::meta_type::<[u8; 4]>(), - }, - default: vec![0, 0, 0, 0], - docs: vec![], - }, - StorageEntryMetadataIR { - name: "GETMAPU32MYDEF", - modifier: StorageEntryModifierIR::Default, - ty: StorageEntryTypeIR::Map { - hashers: vec![StorageHasherIR::Blake2_128Concat], - key: scale_info::meta_type::(), - value: scale_info::meta_type::<[u8; 4]>(), - }, - default: vec![109, 97, 112, 100], // "map" - docs: vec![], - }, - StorageEntryMetadataIR { - name: "PUBGETMAPU32MYDEF", - modifier: StorageEntryModifierIR::Default, - ty: StorageEntryTypeIR::Map { - hashers: vec![StorageHasherIR::Blake2_128Concat], - key: scale_info::meta_type::(), - value: scale_info::meta_type::<[u8; 4]>(), - }, - default: vec![112, 117, 98, 109], // "pubmap" - docs: vec![], - }, - StorageEntryMetadataIR { - name: "DOUBLEMAP", - modifier: StorageEntryModifierIR::Optional, - ty: StorageEntryTypeIR::Map { - hashers: vec![ - StorageHasherIR::Blake2_128Concat, - StorageHasherIR::Blake2_128Concat, - ], - key: scale_info::meta_type::<(u32, u32)>(), - value: scale_info::meta_type::<[u8; 4]>(), - }, - default: vec![0], - docs: vec![], - }, - StorageEntryMetadataIR { - name: "DOUBLEMAP2", - modifier: StorageEntryModifierIR::Optional, - ty: StorageEntryTypeIR::Map { - hashers: vec![ - StorageHasherIR::Blake2_128Concat, - StorageHasherIR::Blake2_128Concat, - ], - key: scale_info::meta_type::<(u32, u32)>(), - value: scale_info::meta_type::<[u8; 4]>(), - }, - default: vec![0], - docs: vec![], - }, - StorageEntryMetadataIR { - name: "COMPLEXTYPE1", - modifier: StorageEntryModifierIR::Default, - ty: StorageEntryTypeIR::Plain(scale_info::meta_type::<(Option,)>()), - default: vec![0], - docs: vec![], - }, - StorageEntryMetadataIR { - name: "COMPLEXTYPE2", - modifier: StorageEntryModifierIR::Default, - ty: StorageEntryTypeIR::Plain(scale_info::meta_type::<( - [[(u16, Option<()>); 32]; 12], - u32, - )>()), - default: [0u8; 1156].to_vec(), - docs: vec![], - }, - StorageEntryMetadataIR { - name: "COMPLEXTYPE3", - modifier: StorageEntryModifierIR::Default, - ty: StorageEntryTypeIR::Plain(scale_info::meta_type::<[u32; 25]>()), - default: [0u8; 100].to_vec(), - docs: vec![], - }, - StorageEntryMetadataIR { - name: "NMAP", - modifier: StorageEntryModifierIR::Default, - ty: StorageEntryTypeIR::Map { - key: scale_info::meta_type::<(u32, u16)>(), - hashers: vec![ - StorageHasherIR::Blake2_128Concat, - StorageHasherIR::Twox64Concat, - ], - value: scale_info::meta_type::(), - }, - default: vec![0], - docs: vec![], - }, - StorageEntryMetadataIR { - name: "NMAP2", - modifier: StorageEntryModifierIR::Default, - ty: StorageEntryTypeIR::Map { - key: scale_info::meta_type::(), - hashers: vec![StorageHasherIR::Blake2_128Concat], - value: scale_info::meta_type::(), - }, - default: vec![0], - docs: vec![], - }, - ], - } - } - - #[test] - fn storage_info() { - use frame_support::{ - storage::storage_prefix as prefix, - traits::{StorageInfo, StorageInfoTrait}, - }; - - pretty_assertions::assert_eq!( - >::storage_info(), - vec![ - StorageInfo { - pallet_name: b"TestStorage".to_vec(), - storage_name: b"U32".to_vec(), - prefix: prefix(b"TestStorage", b"U32").to_vec(), - max_values: Some(1), - max_size: Some(4), - }, - StorageInfo { - pallet_name: b"TestStorage".to_vec(), - storage_name: b"PUBU32".to_vec(), - prefix: prefix(b"TestStorage", b"PUBU32").to_vec(), - max_values: Some(1), - max_size: Some(4), - }, - StorageInfo { - pallet_name: b"TestStorage".to_vec(), - storage_name: b"U32MYDEF".to_vec(), - prefix: prefix(b"TestStorage", b"U32MYDEF").to_vec(), - max_values: Some(1), - max_size: Some(4), - }, - StorageInfo { - pallet_name: b"TestStorage".to_vec(), - storage_name: b"PUBU32MYDEF".to_vec(), - prefix: prefix(b"TestStorage", b"PUBU32MYDEF").to_vec(), - max_values: Some(1), - max_size: Some(4), - }, - StorageInfo { - pallet_name: b"TestStorage".to_vec(), - storage_name: b"GETU32".to_vec(), - prefix: prefix(b"TestStorage", b"GETU32").to_vec(), - max_values: Some(1), - max_size: Some(4), - }, - StorageInfo { - pallet_name: b"TestStorage".to_vec(), - storage_name: b"PUBGETU32".to_vec(), - prefix: prefix(b"TestStorage", b"PUBGETU32").to_vec(), - max_values: Some(1), - max_size: Some(4), - }, - StorageInfo { - pallet_name: b"TestStorage".to_vec(), - storage_name: b"GETU32WITHCONFIG".to_vec(), - prefix: prefix(b"TestStorage", b"GETU32WITHCONFIG").to_vec(), - max_values: Some(1), - max_size: Some(4), - }, - StorageInfo { - pallet_name: b"TestStorage".to_vec(), - storage_name: b"PUBGETU32WITHCONFIG".to_vec(), - prefix: prefix(b"TestStorage", b"PUBGETU32WITHCONFIG").to_vec(), - max_values: Some(1), - max_size: Some(4), - }, - StorageInfo { - pallet_name: b"TestStorage".to_vec(), - storage_name: b"GETU32MYDEF".to_vec(), - prefix: prefix(b"TestStorage", b"GETU32MYDEF").to_vec(), - max_values: Some(1), - max_size: Some(4), - }, - StorageInfo { - pallet_name: b"TestStorage".to_vec(), - storage_name: b"PUBGETU32MYDEF".to_vec(), - prefix: prefix(b"TestStorage", b"PUBGETU32MYDEF").to_vec(), - max_values: Some(1), - max_size: Some(4), - }, - StorageInfo { - pallet_name: b"TestStorage".to_vec(), - storage_name: b"GETU32WITHCONFIGMYDEF".to_vec(), - prefix: prefix(b"TestStorage", b"GETU32WITHCONFIGMYDEF").to_vec(), - max_values: Some(1), - max_size: Some(4), - }, - StorageInfo { - pallet_name: b"TestStorage".to_vec(), - storage_name: b"PUBGETU32WITHCONFIGMYDEF".to_vec(), - prefix: prefix(b"TestStorage", b"PUBGETU32WITHCONFIGMYDEF").to_vec(), - max_values: Some(1), - max_size: Some(4), - }, - StorageInfo { - pallet_name: b"TestStorage".to_vec(), - storage_name: b"PUBGETU32WITHCONFIGMYDEFOPT".to_vec(), - prefix: prefix(b"TestStorage", b"PUBGETU32WITHCONFIGMYDEFOPT").to_vec(), - max_values: Some(1), - max_size: Some(4), - }, - StorageInfo { - pallet_name: b"TestStorage".to_vec(), - storage_name: b"GetU32WithBuilder".to_vec(), - prefix: prefix(b"TestStorage", b"GetU32WithBuilder").to_vec(), - max_values: Some(1), - max_size: Some(4), - }, - StorageInfo { - pallet_name: b"TestStorage".to_vec(), - storage_name: b"GetOptU32WithBuilderSome".to_vec(), - prefix: prefix(b"TestStorage", b"GetOptU32WithBuilderSome").to_vec(), - max_values: Some(1), - max_size: Some(4), - }, - StorageInfo { - pallet_name: b"TestStorage".to_vec(), - storage_name: b"GetOptU32WithBuilderNone".to_vec(), - prefix: prefix(b"TestStorage", b"GetOptU32WithBuilderNone").to_vec(), - max_values: Some(1), - max_size: Some(4), - }, - StorageInfo { - pallet_name: b"TestStorage".to_vec(), - storage_name: b"MAPU32".to_vec(), - prefix: prefix(b"TestStorage", b"MAPU32").to_vec(), - max_values: Some(3), - max_size: Some(8 + 16), - }, - StorageInfo { - pallet_name: b"TestStorage".to_vec(), - storage_name: b"PUBMAPU32".to_vec(), - prefix: prefix(b"TestStorage", b"PUBMAPU32").to_vec(), - max_values: None, - max_size: Some(8 + 16), - }, - StorageInfo { - pallet_name: b"TestStorage".to_vec(), - storage_name: b"GETMAPU32".to_vec(), - prefix: prefix(b"TestStorage", b"GETMAPU32").to_vec(), - max_values: None, - max_size: Some(8 + 16), - }, - StorageInfo { - pallet_name: b"TestStorage".to_vec(), - storage_name: b"PUBGETMAPU32".to_vec(), - prefix: prefix(b"TestStorage", b"PUBGETMAPU32").to_vec(), - max_values: None, - max_size: Some(8 + 16), - }, - StorageInfo { - pallet_name: b"TestStorage".to_vec(), - storage_name: b"GETMAPU32MYDEF".to_vec(), - prefix: prefix(b"TestStorage", b"GETMAPU32MYDEF").to_vec(), - max_values: None, - max_size: Some(8 + 16), - }, - StorageInfo { - pallet_name: b"TestStorage".to_vec(), - storage_name: b"PUBGETMAPU32MYDEF".to_vec(), - prefix: prefix(b"TestStorage", b"PUBGETMAPU32MYDEF").to_vec(), - max_values: None, - max_size: Some(8 + 16), - }, - StorageInfo { - pallet_name: b"TestStorage".to_vec(), - storage_name: b"DOUBLEMAP".to_vec(), - prefix: prefix(b"TestStorage", b"DOUBLEMAP").to_vec(), - max_values: Some(3), - max_size: Some(12 + 16 + 16), - }, - StorageInfo { - pallet_name: b"TestStorage".to_vec(), - storage_name: b"DOUBLEMAP2".to_vec(), - prefix: prefix(b"TestStorage", b"DOUBLEMAP2").to_vec(), - max_values: None, - max_size: Some(12 + 16 + 16), - }, - StorageInfo { - pallet_name: b"TestStorage".to_vec(), - storage_name: b"COMPLEXTYPE1".to_vec(), - prefix: prefix(b"TestStorage", b"COMPLEXTYPE1").to_vec(), - max_values: Some(1), - max_size: Some(5), - }, - StorageInfo { - pallet_name: b"TestStorage".to_vec(), - storage_name: b"COMPLEXTYPE2".to_vec(), - prefix: prefix(b"TestStorage", b"COMPLEXTYPE2").to_vec(), - max_values: Some(1), - max_size: Some(1156), - }, - StorageInfo { - pallet_name: b"TestStorage".to_vec(), - storage_name: b"COMPLEXTYPE3".to_vec(), - prefix: prefix(b"TestStorage", b"COMPLEXTYPE3").to_vec(), - max_values: Some(1), - max_size: Some(100), - }, - StorageInfo { - pallet_name: b"TestStorage".to_vec(), - storage_name: b"NMAP".to_vec(), - prefix: prefix(b"TestStorage", b"NMAP").to_vec(), - max_values: None, - max_size: Some(16 + 4 + 8 + 2 + 1), - }, - StorageInfo { - pallet_name: b"TestStorage".to_vec(), - storage_name: b"NMAP2".to_vec(), - prefix: prefix(b"TestStorage", b"NMAP2").to_vec(), - max_values: None, - max_size: Some(16 + 4 + 1), - }, - ], - ); - } - - #[test] - fn store_metadata() { - let metadata = Module::::storage_metadata(); - pretty_assertions::assert_eq!(expected_metadata(), metadata); - } - - #[test] - fn check_genesis_config() { - let config = GenesisConfig::default(); - assert_eq!(config.u32_getter_with_config, 0u32); - assert_eq!(config.pub_u32_getter_with_config, 0u32); - - assert_eq!(config.pub_u32_getter_mydef, 3u32); - assert_eq!(config.u32_getter_with_config_mydef, 2u32); - assert_eq!(config.pub_u32_getter_with_config_mydef, 1u32); - assert_eq!(config.pub_u32_getter_with_config_mydef_opt, 0u32); - } - - #[test] - fn check_builder_config() { - let config = GenesisConfig::default(); - let storage = config.build_storage().unwrap(); - TestExternalities::from(storage).execute_with(|| { - assert_eq!(Module::::u32_with_builder(), 1); - assert_eq!(Module::::opt_u32_with_builder_some(), Some(1)); - assert_eq!(Module::::opt_u32_with_builder_none(), None); - }) - } -} - -#[cfg(test)] -#[allow(dead_code)] -mod test2 { - pub trait Config: frame_support_test::Config {} - - frame_support::decl_module! { - pub struct Module for enum Call where origin: T::RuntimeOrigin, system=frame_support_test {} - } - - type PairOf = (T, T); - - frame_support::decl_storage! { - trait Store for Module as TestStorage { - SingleDef : u32; - PairDef : PairOf; - Single : Option; - Pair : (u32, u32); - } - add_extra_genesis { - config(_marker) : ::std::marker::PhantomData; - config(extra_field) : u32 = 32; - build(|_| {}); - } - } - - struct TraitImpl {} - - impl frame_support_test::Config for TraitImpl { - type RuntimeOrigin = u32; - type BlockNumber = u32; - type PalletInfo = frame_support_test::PanicPalletInfo; - type DbWeight = (); - } - - impl Config for TraitImpl {} - - #[test] - fn storage_info() { - use frame_support::{ - storage::storage_prefix as prefix, - traits::{StorageInfo, StorageInfoTrait}, - }; - pretty_assertions::assert_eq!( - >::storage_info(), - vec![ - StorageInfo { - pallet_name: b"TestStorage".to_vec(), - storage_name: b"SingleDef".to_vec(), - prefix: prefix(b"TestStorage", b"SingleDef").to_vec(), - max_values: Some(1), - max_size: None, - }, - StorageInfo { - pallet_name: b"TestStorage".to_vec(), - storage_name: b"PairDef".to_vec(), - prefix: prefix(b"TestStorage", b"PairDef").to_vec(), - max_values: Some(1), - max_size: None, - }, - StorageInfo { - pallet_name: b"TestStorage".to_vec(), - storage_name: b"Single".to_vec(), - prefix: prefix(b"TestStorage", b"Single").to_vec(), - max_values: Some(1), - max_size: None, - }, - StorageInfo { - pallet_name: b"TestStorage".to_vec(), - storage_name: b"Pair".to_vec(), - prefix: prefix(b"TestStorage", b"Pair").to_vec(), - max_values: Some(1), - max_size: None, - }, - ], - ); - } -} - -#[cfg(test)] -#[allow(dead_code)] -mod test3 { - pub trait Config: frame_support_test::Config {} - - frame_support::decl_module! { - pub struct Module for enum Call where origin: T::RuntimeOrigin, system=frame_support_test {} - } - frame_support::decl_storage! { - trait Store for Module as Test { - Foo get(fn foo) config(initial_foo): u32; - } - } - - type PairOf = (T, T); - - struct TraitImpl {} - - impl frame_support_test::Config for TraitImpl { - type RuntimeOrigin = u32; - type BlockNumber = u32; - type PalletInfo = frame_support_test::PanicPalletInfo; - type DbWeight = (); - } - - impl Config for TraitImpl {} -} - -#[cfg(test)] -#[allow(dead_code)] -mod test_append_and_len { - use codec::{Decode, Encode}; - use sp_io::TestExternalities; - - pub trait Config: frame_support_test::Config {} - - frame_support::decl_module! { - pub struct Module for enum Call where origin: T::RuntimeOrigin, system=frame_support_test {} - } - - #[derive(PartialEq, Eq, Clone, Encode, Decode, scale_info::TypeInfo)] - struct NoDef(u32); - - frame_support::decl_storage! { - trait Store for Module as Test { - NoDefault: Option; - - JustVec: Vec; - JustVecWithDefault: Vec = vec![6, 9]; - OptionVec: Option>; - - MapVec: map hasher(blake2_128_concat) u32 => Vec; - MapVecWithDefault: map hasher(blake2_128_concat) u32 => Vec = vec![6, 9]; - OptionMapVec: map hasher(blake2_128_concat) u32 => Option>; - - DoubleMapVec: double_map hasher(blake2_128_concat) u32, hasher(blake2_128_concat) u32 => Vec; - DoubleMapVecWithDefault: double_map hasher(blake2_128_concat) u32, hasher(blake2_128_concat) u32 => Vec = vec![6, 9]; - OptionDoubleMapVec: double_map hasher(blake2_128_concat) u32, hasher(blake2_128_concat) u32 => Option>; - } - } - - struct Test {} - - impl frame_support_test::Config for Test { - type RuntimeOrigin = u32; - type BlockNumber = u32; - type PalletInfo = frame_support_test::PanicPalletInfo; - type DbWeight = (); - } - - impl Config for Test {} - - #[test] - fn default_for_option() { - TestExternalities::default().execute_with(|| { - assert_eq!(OptionVec::get(), None); - assert!(JustVec::get().is_empty()); - }); - } - - #[test] - fn append_works() { - TestExternalities::default().execute_with(|| { - for val in &[1, 2, 3, 4, 5] { - MapVec::append(1, val); - } - assert_eq!(MapVec::get(1), vec![1, 2, 3, 4, 5]); - - MapVec::remove(1); - MapVec::append(1, 1); - assert_eq!(MapVec::get(1), vec![1]); - - for val in &[1, 2, 3, 4, 5] { - JustVec::append(val); - } - assert_eq!(JustVec::get(), vec![1, 2, 3, 4, 5]); - - JustVec::kill(); - JustVec::append(1); - assert_eq!(JustVec::get(), vec![1]); - }); - } - - #[test] - fn append_overwrites_invalid_data() { - TestExternalities::default().execute_with(|| { - let key = JustVec::hashed_key(); - // Set it to some invalid value. - frame_support::storage::unhashed::put_raw(&key, b"1"); - assert!(JustVec::get().is_empty()); - assert_eq!(frame_support::storage::unhashed::get_raw(&key), Some(b"1".to_vec())); - - JustVec::append(1); - JustVec::append(2); - assert_eq!(JustVec::get(), vec![1, 2]); - }); - } - - #[test] - fn append_overwrites_default() { - TestExternalities::default().execute_with(|| { - assert_eq!(JustVecWithDefault::get(), vec![6, 9]); - JustVecWithDefault::append(1); - assert_eq!(JustVecWithDefault::get(), vec![1]); - - assert_eq!(MapVecWithDefault::get(0), vec![6, 9]); - MapVecWithDefault::append(0, 1); - assert_eq!(MapVecWithDefault::get(0), vec![1]); - - assert_eq!(OptionVec::get(), None); - OptionVec::append(1); - assert_eq!(OptionVec::get(), Some(vec![1])); - }); - } - - #[test] - fn len_works() { - TestExternalities::default().execute_with(|| { - JustVec::put(&vec![1, 2, 3, 4]); - OptionVec::put(&vec![1, 2, 3, 4, 5]); - MapVec::insert(1, &vec![1, 2, 3, 4, 5, 6]); - DoubleMapVec::insert(0, 1, &vec![1, 2]); - - assert_eq!(JustVec::decode_len().unwrap(), 4); - assert_eq!(OptionVec::decode_len().unwrap(), 5); - assert_eq!(MapVec::decode_len(1).unwrap(), 6); - assert_eq!(DoubleMapVec::decode_len(0, 1).unwrap(), 2); - }); - } - - // `decode_len` should always return `None` for default assigments - // in `decl_storage!`. - #[test] - fn len_works_ignores_default_assignment() { - TestExternalities::default().execute_with(|| { - // vec - assert!(JustVec::get().is_empty()); - assert_eq!(JustVec::decode_len(), None); - - assert_eq!(JustVecWithDefault::get(), vec![6, 9]); - assert_eq!(JustVecWithDefault::decode_len(), None); - - assert_eq!(OptionVec::get(), None); - assert_eq!(OptionVec::decode_len(), None); - - // map - assert!(MapVec::get(0).is_empty()); - assert_eq!(MapVec::decode_len(0), None); - - assert_eq!(MapVecWithDefault::get(0), vec![6, 9]); - assert_eq!(MapVecWithDefault::decode_len(0), None); - - assert_eq!(OptionMapVec::get(0), None); - assert_eq!(OptionMapVec::decode_len(0), None); - - // Double map - assert!(DoubleMapVec::get(0, 0).is_empty()); - assert_eq!(DoubleMapVec::decode_len(0, 1), None); - - assert_eq!(DoubleMapVecWithDefault::get(0, 0), vec![6, 9]); - assert_eq!(DoubleMapVecWithDefault::decode_len(0, 1), None); - - assert_eq!(OptionDoubleMapVec::get(0, 0), None); - assert_eq!(OptionDoubleMapVec::decode_len(0, 1), None); - }); - } -} diff --git a/frame/support/test/tests/decl_storage_ui.rs b/frame/support/test/tests/decl_storage_ui.rs deleted file mode 100644 index 1414c8a994520..0000000000000 --- a/frame/support/test/tests/decl_storage_ui.rs +++ /dev/null @@ -1,32 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#[rustversion::attr(not(stable), ignore)] -#[cfg(not(feature = "disable-ui-tests"))] -#[test] -fn decl_storage_ui() { - // Only run the ui tests when `RUN_UI_TESTS` is set. - if std::env::var("RUN_UI_TESTS").is_err() { - return - } - - // As trybuild is using `cargo check`, we don't need the real WASM binaries. - std::env::set_var("SKIP_WASM_BUILD", "1"); - - let t = trybuild::TestCases::new(); - t.compile_fail("tests/decl_storage_ui/*.rs"); -} diff --git a/frame/support/test/tests/decl_storage_ui/config_duplicate.rs b/frame/support/test/tests/decl_storage_ui/config_duplicate.rs deleted file mode 100644 index a6e1bfad5836b..0000000000000 --- a/frame/support/test/tests/decl_storage_ui/config_duplicate.rs +++ /dev/null @@ -1,31 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -pub trait Config: frame_support_test::Config {} - -frame_support::decl_module! { - pub struct Module for enum Call where origin: T::RuntimeOrigin, system=frame_support_test {} -} - -frame_support::decl_storage!{ - trait Store for Module as FinalKeysNone { - pub Value config(value): u32; - pub Value2 config(value): u32; - } -} - -fn main() {} diff --git a/frame/support/test/tests/decl_storage_ui/config_duplicate.stderr b/frame/support/test/tests/decl_storage_ui/config_duplicate.stderr deleted file mode 100644 index f6303f277b56b..0000000000000 --- a/frame/support/test/tests/decl_storage_ui/config_duplicate.stderr +++ /dev/null @@ -1,5 +0,0 @@ -error: `config()`/`get()` with the same name already defined. - --> $DIR/config_duplicate.rs:27:21 - | -27 | pub Value2 config(value): u32; - | ^^^^^ diff --git a/frame/support/test/tests/decl_storage_ui/config_get_duplicate.rs b/frame/support/test/tests/decl_storage_ui/config_get_duplicate.rs deleted file mode 100644 index c40dd0e44f11b..0000000000000 --- a/frame/support/test/tests/decl_storage_ui/config_get_duplicate.rs +++ /dev/null @@ -1,31 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -pub trait Config: frame_support_test::Config {} - -frame_support::decl_module! { - pub struct Module for enum Call where origin: T::RuntimeOrigin, system=frame_support_test {} -} - -frame_support::decl_storage!{ - trait Store for Module as FinalKeysNone { - pub Value get(fn value) config(): u32; - pub Value2 config(value): u32; - } -} - -fn main() {} diff --git a/frame/support/test/tests/decl_storage_ui/config_get_duplicate.stderr b/frame/support/test/tests/decl_storage_ui/config_get_duplicate.stderr deleted file mode 100644 index 9377b718c0660..0000000000000 --- a/frame/support/test/tests/decl_storage_ui/config_get_duplicate.stderr +++ /dev/null @@ -1,5 +0,0 @@ -error: `config()`/`get()` with the same name already defined. - --> $DIR/config_get_duplicate.rs:27:21 - | -27 | pub Value2 config(value): u32; - | ^^^^^ diff --git a/frame/support/test/tests/decl_storage_ui/get_duplicate.rs b/frame/support/test/tests/decl_storage_ui/get_duplicate.rs deleted file mode 100644 index 23c89d276ef39..0000000000000 --- a/frame/support/test/tests/decl_storage_ui/get_duplicate.rs +++ /dev/null @@ -1,31 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -pub trait Config: frame_support_test::Config {} - -frame_support::decl_module! { - pub struct Module for enum Call where origin: T::RuntimeOrigin, system=frame_support_test {} -} - -frame_support::decl_storage!{ - trait Store for Module as FinalKeysNone { - pub Value get(fn value) config(): u32; - pub Value2 get(fn value) config(): u32; - } -} - -fn main() {} diff --git a/frame/support/test/tests/decl_storage_ui/get_duplicate.stderr b/frame/support/test/tests/decl_storage_ui/get_duplicate.stderr deleted file mode 100644 index 0039b10fb43b6..0000000000000 --- a/frame/support/test/tests/decl_storage_ui/get_duplicate.stderr +++ /dev/null @@ -1,5 +0,0 @@ -error: `config()`/`get()` with the same name already defined. - --> $DIR/get_duplicate.rs:27:21 - | -27 | pub Value2 get(fn value) config(): u32; - | ^^^^^ diff --git a/frame/support/test/tests/final_keys.rs b/frame/support/test/tests/final_keys.rs index 9e1d6c0876740..610f6532c52d0 100644 --- a/frame/support/test/tests/final_keys.rs +++ b/frame/support/test/tests/final_keys.rs @@ -16,65 +16,166 @@ // limitations under the License. use codec::Encode; -use frame_support::{ - storage::unhashed, StorageDoubleMap, StorageMap, StoragePrefixedMap, StorageValue, -}; +use frame_support::{storage::unhashed, StoragePrefixedMap}; +use sp_core::sr25519; use sp_io::{ hashing::{blake2_128, twox_128, twox_64}, TestExternalities, }; +use sp_runtime::{ + generic, + traits::{BlakeTwo256, Verify}, +}; +#[frame_support::pallet] mod no_instance { - pub trait Config: frame_support_test::Config {} - - frame_support::decl_module! { - pub struct Module for enum Call where origin: T::RuntimeOrigin, system=frame_support_test {} + use super::*; + use frame_support::pallet_prelude::*; + use frame_support_test as frame_system; + + #[pallet::pallet] + pub struct Pallet(PhantomData); + + #[pallet::config] + pub trait Config: frame_system::Config {} + + #[pallet::call] + impl Pallet {} + + #[pallet::storage] + pub type Value = StorageValue<_, u32, ValueQuery>; + + #[pallet::storage] + pub type Map = StorageMap<_, Blake2_128Concat, u32, u32, ValueQuery>; + #[pallet::storage] + pub type Map2 = StorageMap<_, Twox64Concat, u32, u32, ValueQuery>; + + #[pallet::storage] + pub type DoubleMap = + StorageDoubleMap<_, Blake2_128Concat, u32, Blake2_128Concat, u32, u32, ValueQuery>; + #[pallet::storage] + pub type DoubleMap2 = + StorageDoubleMap<_, Twox64Concat, u32, Twox64Concat, u32, u32, ValueQuery>; + + #[pallet::storage] + #[pallet::getter(fn test_generic_value)] + pub type TestGenericValue = StorageValue<_, T::BlockNumber, OptionQuery>; + #[pallet::storage] + #[pallet::getter(fn foo2)] + pub type TestGenericDoubleMap = StorageDoubleMap< + _, + Blake2_128Concat, + u32, + Blake2_128Concat, + T::BlockNumber, + u32, + ValueQuery, + >; + + #[pallet::genesis_config] + pub struct GenesisConfig { + pub value: u32, + pub test_generic_value: T::BlockNumber, + pub test_generic_double_map: Vec<(u32, T::BlockNumber, u32)>, } - frame_support::decl_storage! { - trait Store for Module as FinalKeysNone { - pub Value config(value): u32; - - pub Map: map hasher(blake2_128_concat) u32 => u32; - pub Map2: map hasher(twox_64_concat) u32 => u32; - - pub DoubleMap: double_map hasher(blake2_128_concat) u32, hasher(blake2_128_concat) u32 => u32; - pub DoubleMap2: double_map hasher(twox_64_concat) u32, hasher(twox_64_concat) u32 => u32; + impl Default for GenesisConfig { + fn default() -> Self { + Self { + value: Default::default(), + test_generic_value: Default::default(), + test_generic_double_map: Default::default(), + } + } + } - pub TestGenericValue get(fn test_generic_value) config(): Option; - pub TestGenericDoubleMap get(fn foo2) config(test_generic_double_map): - double_map hasher(blake2_128_concat) u32, hasher(blake2_128_concat) T::BlockNumber => Option; + #[pallet::genesis_build] + impl GenesisBuild for GenesisConfig { + fn build(&self) { + >::put(self.value); + >::put(&self.test_generic_value); + for (k1, k2, v) in &self.test_generic_double_map { + >::insert(k1, k2, v); + } } } } +#[frame_support::pallet] mod instance { - pub trait Config: frame_support_test::Config {} - - frame_support::decl_module! { - pub struct Module, I: Instance = DefaultInstance> - for enum Call where origin: T::RuntimeOrigin, system=frame_support_test {} + use super::*; + use frame_support::pallet_prelude::*; + use frame_support_test as frame_system; + + #[pallet::pallet] + pub struct Pallet(PhantomData<(T, I)>); + + #[pallet::config] + pub trait Config: frame_system::Config {} + + #[pallet::call] + impl, I: 'static> Pallet {} + + #[pallet::storage] + pub type Value, I: 'static = ()> = StorageValue<_, u32, ValueQuery>; + + #[pallet::storage] + pub type Map, I: 'static = ()> = + StorageMap<_, Blake2_128Concat, u32, u32, ValueQuery>; + #[pallet::storage] + pub type Map2, I: 'static = ()> = + StorageMap<_, Twox64Concat, u32, u32, ValueQuery>; + + #[pallet::storage] + pub type DoubleMap, I: 'static = ()> = + StorageDoubleMap<_, Blake2_128Concat, u32, Blake2_128Concat, u32, u32, ValueQuery>; + #[pallet::storage] + pub type DoubleMap2, I: 'static = ()> = + StorageDoubleMap<_, Twox64Concat, u32, Twox64Concat, u32, u32, ValueQuery>; + + #[pallet::storage] + #[pallet::getter(fn test_generic_value)] + pub type TestGenericValue, I: 'static = ()> = + StorageValue<_, T::BlockNumber, OptionQuery>; + #[pallet::storage] + #[pallet::getter(fn foo2)] + pub type TestGenericDoubleMap, I: 'static = ()> = StorageDoubleMap< + _, + Blake2_128Concat, + u32, + Blake2_128Concat, + T::BlockNumber, + u32, + ValueQuery, + >; + + #[pallet::genesis_config] + pub struct GenesisConfig, I: 'static = ()> { + pub value: u32, + pub test_generic_value: T::BlockNumber, + pub test_generic_double_map: Vec<(u32, T::BlockNumber, u32)>, + pub phantom: PhantomData, } - frame_support::decl_storage! { - trait Store for Module, I: Instance = DefaultInstance> - as FinalKeysSome - { - pub Value config(value): u32; - - pub Map: map hasher(blake2_128_concat) u32 => u32; - pub Map2: map hasher(twox_64_concat) u32 => u32; - - pub DoubleMap: double_map hasher(blake2_128_concat) u32, hasher(blake2_128_concat) u32 => u32; - pub DoubleMap2: double_map hasher(twox_64_concat) u32, hasher(twox_64_concat) u32 => u32; - - pub TestGenericValue get(fn test_generic_value) config(): Option; - pub TestGenericDoubleMap get(fn foo2) config(test_generic_double_map): - double_map hasher(blake2_128_concat) u32, hasher(blake2_128_concat) T::BlockNumber => Option; + impl, I: 'static> Default for GenesisConfig { + fn default() -> Self { + Self { + value: Default::default(), + test_generic_value: Default::default(), + test_generic_double_map: Default::default(), + phantom: Default::default(), + } } - add_extra_genesis { - // See `decl_storage` limitation. - config(phantom): core::marker::PhantomData; + } + + #[pallet::genesis_build] + impl, I: 'static> GenesisBuild for GenesisConfig { + fn build(&self) { + >::put(self.value); + >::put(&self.test_generic_value); + for (k1, k2, v) in &self.test_generic_double_map { + >::insert(k1, k2, v); + } } } } @@ -91,107 +192,144 @@ fn blake2_128_concat(d: &[u8]) -> Vec { v } +pub type BlockNumber = u32; +pub type Signature = sr25519::Signature; +pub type AccountId = ::Signer; +pub type Header = generic::Header; +pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; +pub type Block = generic::Block; + +frame_support::construct_runtime!( + pub enum Runtime + where + Block = Block, + NodeBlock = Block, + UncheckedExtrinsic = UncheckedExtrinsic, + { + System: frame_support_test, + FinalKeysNone: no_instance, + FinalKeysSome: instance, + Instance2FinalKeysSome: instance::, + } +); + +impl frame_support_test::Config for Runtime { + type BlockNumber = BlockNumber; + type AccountId = AccountId; + type BaseCallFilter = frame_support::traits::Everything; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type PalletInfo = PalletInfo; + type DbWeight = (); +} + +impl no_instance::Config for Runtime {} + +impl instance::Config for Runtime {} +impl instance::Config for Runtime {} + #[test] fn final_keys_no_instance() { TestExternalities::default().execute_with(|| { - no_instance::Value::put(1); + >::put(1); let k = [twox_128(b"FinalKeysNone"), twox_128(b"Value")].concat(); assert_eq!(unhashed::get::(&k), Some(1u32)); - no_instance::Map::insert(1, 2); + >::insert(1, 2); let mut k = [twox_128(b"FinalKeysNone"), twox_128(b"Map")].concat(); k.extend(1u32.using_encoded(blake2_128_concat)); assert_eq!(unhashed::get::(&k), Some(2u32)); - assert_eq!(&k[..32], &::final_prefix()); + assert_eq!(&k[..32], &>::final_prefix()); - no_instance::Map2::insert(1, 2); + >::insert(1, 2); let mut k = [twox_128(b"FinalKeysNone"), twox_128(b"Map2")].concat(); k.extend(1u32.using_encoded(twox_64_concat)); assert_eq!(unhashed::get::(&k), Some(2u32)); - assert_eq!(&k[..32], &::final_prefix()); + assert_eq!(&k[..32], &>::final_prefix()); - no_instance::DoubleMap::insert(&1, &2, &3); + >::insert(&1, &2, &3); let mut k = [twox_128(b"FinalKeysNone"), twox_128(b"DoubleMap")].concat(); k.extend(1u32.using_encoded(blake2_128_concat)); k.extend(2u32.using_encoded(blake2_128_concat)); assert_eq!(unhashed::get::(&k), Some(3u32)); - assert_eq!(&k[..32], &::final_prefix()); + assert_eq!(&k[..32], &>::final_prefix()); - no_instance::DoubleMap2::insert(&1, &2, &3); + >::insert(&1, &2, &3); let mut k = [twox_128(b"FinalKeysNone"), twox_128(b"DoubleMap2")].concat(); k.extend(1u32.using_encoded(twox_64_concat)); k.extend(2u32.using_encoded(twox_64_concat)); assert_eq!(unhashed::get::(&k), Some(3u32)); - assert_eq!(&k[..32], &::final_prefix()); + assert_eq!(&k[..32], &>::final_prefix()); }); } #[test] fn final_keys_default_instance() { TestExternalities::default().execute_with(|| { - >::put(1); + >::put(1); let k = [twox_128(b"FinalKeysSome"), twox_128(b"Value")].concat(); assert_eq!(unhashed::get::(&k), Some(1u32)); - >::insert(1, 2); + >::insert(1, 2); let mut k = [twox_128(b"FinalKeysSome"), twox_128(b"Map")].concat(); k.extend(1u32.using_encoded(blake2_128_concat)); assert_eq!(unhashed::get::(&k), Some(2u32)); - assert_eq!(&k[..32], &>::final_prefix()); + assert_eq!(&k[..32], &>::final_prefix()); - >::insert(1, 2); + >::insert(1, 2); let mut k = [twox_128(b"FinalKeysSome"), twox_128(b"Map2")].concat(); k.extend(1u32.using_encoded(twox_64_concat)); assert_eq!(unhashed::get::(&k), Some(2u32)); - assert_eq!(&k[..32], &>::final_prefix()); + assert_eq!(&k[..32], &>::final_prefix()); - >::insert(&1, &2, &3); + >::insert(&1, &2, &3); let mut k = [twox_128(b"FinalKeysSome"), twox_128(b"DoubleMap")].concat(); k.extend(1u32.using_encoded(blake2_128_concat)); k.extend(2u32.using_encoded(blake2_128_concat)); assert_eq!(unhashed::get::(&k), Some(3u32)); - assert_eq!(&k[..32], &>::final_prefix()); + assert_eq!(&k[..32], &>::final_prefix()); - >::insert(&1, &2, &3); + >::insert(&1, &2, &3); let mut k = [twox_128(b"FinalKeysSome"), twox_128(b"DoubleMap2")].concat(); k.extend(1u32.using_encoded(twox_64_concat)); k.extend(2u32.using_encoded(twox_64_concat)); assert_eq!(unhashed::get::(&k), Some(3u32)); - assert_eq!(&k[..32], &>::final_prefix()); + assert_eq!(&k[..32], &>::final_prefix()); }); } #[test] fn final_keys_instance_2() { TestExternalities::default().execute_with(|| { - >::put(1); + >::put(1); let k = [twox_128(b"Instance2FinalKeysSome"), twox_128(b"Value")].concat(); assert_eq!(unhashed::get::(&k), Some(1u32)); - >::insert(1, 2); + >::insert(1, 2); let mut k = [twox_128(b"Instance2FinalKeysSome"), twox_128(b"Map")].concat(); k.extend(1u32.using_encoded(blake2_128_concat)); assert_eq!(unhashed::get::(&k), Some(2u32)); - assert_eq!(&k[..32], &>::final_prefix()); + assert_eq!(&k[..32], &>::final_prefix()); - >::insert(1, 2); + >::insert(1, 2); let mut k = [twox_128(b"Instance2FinalKeysSome"), twox_128(b"Map2")].concat(); k.extend(1u32.using_encoded(twox_64_concat)); assert_eq!(unhashed::get::(&k), Some(2u32)); - assert_eq!(&k[..32], &>::final_prefix()); + assert_eq!(&k[..32], &>::final_prefix()); - >::insert(&1, &2, &3); + >::insert(&1, &2, &3); let mut k = [twox_128(b"Instance2FinalKeysSome"), twox_128(b"DoubleMap")].concat(); k.extend(1u32.using_encoded(blake2_128_concat)); k.extend(2u32.using_encoded(blake2_128_concat)); assert_eq!(unhashed::get::(&k), Some(3u32)); - assert_eq!(&k[..32], &>::final_prefix()); + assert_eq!(&k[..32], &>::final_prefix()); - >::insert(&1, &2, &3); + >::insert(&1, &2, &3); let mut k = [twox_128(b"Instance2FinalKeysSome"), twox_128(b"DoubleMap2")].concat(); k.extend(1u32.using_encoded(twox_64_concat)); k.extend(2u32.using_encoded(twox_64_concat)); assert_eq!(unhashed::get::(&k), Some(3u32)); - assert_eq!(&k[..32], &>::final_prefix()); + assert_eq!(&k[..32], &>::final_prefix()); }); } diff --git a/frame/support/test/tests/genesisconfig.rs b/frame/support/test/tests/genesisconfig.rs index 869641df87060..48904baf1ad62 100644 --- a/frame/support/test/tests/genesisconfig.rs +++ b/frame/support/test/tests/genesisconfig.rs @@ -15,30 +15,86 @@ // See the License for the specific language governing permissions and // limitations under the License. -pub trait Config: frame_support_test::Config {} +use sp_core::sr25519; +use sp_runtime::{ + generic, + traits::{BlakeTwo256, Verify}, +}; -frame_support::decl_module! { - pub struct Module for enum Call where origin: T::RuntimeOrigin, system=frame_support_test {} -} +#[frame_support::pallet] +pub mod pallet { + use super::*; + use frame_support::pallet_prelude::*; + use frame_support_test as frame_system; + + #[pallet::pallet] + pub struct Pallet(PhantomData); + + #[pallet::config] + pub trait Config: frame_system::Config {} -frame_support::decl_storage! { - trait Store for Module as Test { - pub AppendableDM config(t): double_map hasher(identity) u32, hasher(identity) T::BlockNumber => Vec; + #[pallet::call] + impl Pallet {} + + #[pallet::storage] + #[pallet::unbounded] + pub type AppendableDM = + StorageDoubleMap<_, Identity, u32, Identity, T::BlockNumber, Vec>; + + #[pallet::genesis_config] + pub struct GenesisConfig { + pub t: Vec<(u32, T::BlockNumber, Vec)>, + } + + impl Default for GenesisConfig { + fn default() -> Self { + Self { t: Default::default() } + } + } + + #[pallet::genesis_build] + impl GenesisBuild for GenesisConfig { + fn build(&self) { + for (k1, k2, v) in &self.t { + >::insert(k1, k2, v); + } + } } } -struct Test; +pub type BlockNumber = u32; +pub type Signature = sr25519::Signature; +pub type AccountId = ::Signer; +pub type Header = generic::Header; +pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; +pub type Block = generic::Block; + +frame_support::construct_runtime!( + pub enum Test + where + Block = Block, + NodeBlock = Block, + UncheckedExtrinsic = UncheckedExtrinsic, + { + System: frame_support_test, + MyPallet: pallet, + } +); impl frame_support_test::Config for Test { - type BlockNumber = u32; - type RuntimeOrigin = (); - type PalletInfo = frame_support_test::PanicPalletInfo; + type BlockNumber = BlockNumber; + type AccountId = AccountId; + type BaseCallFilter = frame_support::traits::Everything; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type PalletInfo = PalletInfo; type DbWeight = (); } -impl Config for Test {} +impl pallet::Config for Test {} #[test] fn init_genesis_config() { - GenesisConfig::::default(); + pallet::GenesisConfig::::default(); } diff --git a/frame/support/test/tests/instance.rs b/frame/support/test/tests/instance.rs index 9b08e175b1ca8..5d17a40f8c408 100644 --- a/frame/support/test/tests/instance.rs +++ b/frame/support/test/tests/instance.rs @@ -17,111 +17,111 @@ #![recursion_limit = "128"] -use codec::{Codec, Decode, Encode, EncodeLike, MaxEncodedLen}; use frame_support::{ inherent::{InherentData, InherentIdentifier, MakeFatalError, ProvideInherent}, metadata_ir::{ PalletStorageMetadataIR, StorageEntryMetadataIR, StorageEntryModifierIR, StorageEntryTypeIR, StorageHasherIR, }, - traits::{ConstU32, Get}, - Parameter, StorageDoubleMap, StorageMap, StorageValue, + traits::ConstU32, }; -use scale_info::TypeInfo; -use sp_core::{sr25519, H256}; +use sp_core::sr25519; use sp_runtime::{ generic, traits::{BlakeTwo256, Verify}, BuildStorage, }; -mod system; - pub trait Currency {} // Test for: // * No default instance // * Origin, Inherent, Event +#[frame_support::pallet(dev_mode)] mod module1 { + use self::frame_system::pallet_prelude::*; use super::*; - use sp_std::ops::Add; + use frame_support::pallet_prelude::*; + use frame_support_test as frame_system; - pub trait Config: system::Config - where - ::BlockNumber: From, - { - type RuntimeEvent: From> + Into<::RuntimeEvent>; + #[pallet::pallet] + pub struct Pallet(_); + + #[pallet::config] + pub trait Config: frame_system::Config { + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; type RuntimeOrigin: From>; type SomeParameter: Get; - type GenericType: Default + Clone + Codec + EncodeLike + TypeInfo; + type GenericType: Parameter + Member + MaybeSerializeDeserialize + Default + MaxEncodedLen; } - frame_support::decl_module! { - pub struct Module, I: Instance> for enum Call where - origin: ::RuntimeOrigin, - system = system, - T::BlockNumber: From - { - fn offchain_worker() {} + #[pallet::call] + impl, I: 'static> Pallet { + #[pallet::weight(0)] + pub fn one(origin: OriginFor) -> DispatchResult { + ensure_root(origin)?; + Self::deposit_event(Event::AnotherVariant(3)); + Ok(()) + } + } - fn deposit_event() = default; + #[pallet::storage] + #[pallet::getter(fn value)] + pub type Value, I: 'static = ()> = StorageValue<_, T::GenericType, ValueQuery>; - #[weight = 0] - fn one(origin) { - system::ensure_root(origin)?; - Self::deposit_event(RawEvent::AnotherVariant(3)); - } - } + #[pallet::storage] + #[pallet::getter(fn map)] + pub type Map, I: 'static = ()> = StorageMap<_, Identity, u32, u64, ValueQuery>; + + #[pallet::genesis_config] + pub struct GenesisConfig, I: 'static = ()> { + pub value: >::GenericType, + pub test: ::BlockNumber, } - frame_support::decl_storage! { - trait Store for Module, I: Instance> as Module1 where - T::BlockNumber: From + std::fmt::Display - { - pub Value config(value): T::GenericType; - pub Map: map hasher(identity) u32 => u64; + impl, I: 'static> Default for GenesisConfig { + fn default() -> Self { + Self { value: Default::default(), test: Default::default() } } + } - add_extra_genesis { - config(test) : T::BlockNumber; - build(|config: &Self| { - println!("{}", config.test); - }); + #[pallet::genesis_build] + impl, I: 'static> GenesisBuild for GenesisConfig + where + T::BlockNumber: std::fmt::Display, + { + fn build(&self) { + >::put(self.value.clone()); + println!("{}", self.test); } } - frame_support::decl_error! { - pub enum Error for Module, I: Instance> where - T::BlockNumber: From, - T::BlockNumber: Add, - T::AccountId: AsRef<[u8]>, - { - /// Test - Test, - } + #[pallet::error] + pub enum Error { + /// Test + Test, } - frame_support::decl_event! { - pub enum Event where Phantom = std::marker::PhantomData { - _Phantom(Phantom), - AnotherVariant(u32), - } + #[pallet::event] + #[pallet::generate_deposit(pub(super) fn deposit_event)] + pub enum Event, I: 'static = ()> { + _Phantom(PhantomData), + AnotherVariant(u32), } - #[derive( - PartialEq, Eq, Clone, sp_runtime::RuntimeDebug, Encode, Decode, TypeInfo, MaxEncodedLen, - )] - pub enum Origin, I> - where - T::BlockNumber: From, - { + #[pallet::origin] + #[derive(Clone, PartialEq, Eq, RuntimeDebug, Encode, Decode, MaxEncodedLen, TypeInfo)] + #[scale_info(skip_type_params(I))] + pub enum Origin { Members(u32), - _Phantom(std::marker::PhantomData<(T, I)>), + _Phantom(PhantomData<(T, I)>), } pub const INHERENT_IDENTIFIER: InherentIdentifier = *b"12345678"; - impl, I: Instance> ProvideInherent for Module + #[pallet::inherent] + impl, I: 'static> ProvideInherent for Pallet where T::BlockNumber: From, { @@ -133,10 +133,7 @@ mod module1 { unimplemented!(); } - fn check_inherent( - _: &Self::Call, - _: &InherentData, - ) -> std::result::Result<(), Self::Error> { + fn check_inherent(_: &Self::Call, _: &InherentData) -> Result<(), Self::Error> { unimplemented!(); } @@ -149,51 +146,88 @@ mod module1 { // Test for: // * default instance // * use of no_genesis_config_phantom_data +#[frame_support::pallet] mod module2 { use super::*; + use frame_support::pallet_prelude::*; + use frame_support_test as frame_system; - pub trait Config: system::Config { - type Amount: Parameter + Default; - type RuntimeEvent: From> + Into<::RuntimeEvent>; + #[pallet::pallet] + pub struct Pallet(PhantomData<(T, I)>); + + #[pallet::config] + pub trait Config: frame_system::Config { + type Amount: Parameter + MaybeSerializeDeserialize + Default + MaxEncodedLen; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; type RuntimeOrigin: From>; } - impl, I: Instance> Currency for Module {} + impl, I: 'static> Currency for Pallet {} - frame_support::decl_module! { - pub struct Module, I: Instance=DefaultInstance> for enum Call where - origin: ::RuntimeOrigin, - system = system - { - fn deposit_event() = default; - } + #[pallet::call] + impl, I: 'static> Pallet {} + + #[pallet::storage] + pub type Value, I: 'static = ()> = StorageValue<_, T::Amount, ValueQuery>; + + #[pallet::storage] + pub type Map, I: 'static = ()> = StorageMap<_, Identity, u64, u64, ValueQuery>; + + #[pallet::storage] + pub type DoubleMap, I: 'static = ()> = + StorageDoubleMap<_, Identity, u64, Identity, u64, u64, ValueQuery>; + + #[pallet::genesis_config] + pub struct GenesisConfig, I: 'static = ()> { + pub value: T::Amount, + pub map: Vec<(u64, u64)>, + pub double_map: Vec<(u64, u64, u64)>, } - frame_support::decl_storage! { - trait Store for Module, I: Instance=DefaultInstance> as Module2 { - pub Value config(value): T::Amount; - pub Map config(map): map hasher(identity) u64 => u64; - pub DoubleMap config(double_map): double_map hasher(identity) u64, hasher(identity) u64 => u64; + impl, I: 'static> Default for GenesisConfig { + fn default() -> Self { + Self { + value: Default::default(), + map: Default::default(), + double_map: Default::default(), + } } } - frame_support::decl_event! { - pub enum Event where Amount = >::Amount { - Variant(Amount), + #[pallet::genesis_build] + impl, I: 'static> GenesisBuild for GenesisConfig + where + T::BlockNumber: std::fmt::Display, + { + fn build(&self) { + >::put(self.value.clone()); + for (k, v) in &self.map { + >::insert(k, v); + } + for (k1, k2, v) in &self.double_map { + >::insert(k1, k2, v); + } } } - #[derive( - PartialEq, Eq, Clone, sp_runtime::RuntimeDebug, Encode, Decode, TypeInfo, MaxEncodedLen, - )] - pub enum Origin, I = DefaultInstance> { + #[pallet::event] + pub enum Event, I: 'static = ()> { + Variant(T::Amount), + } + + #[pallet::origin] + #[derive(Clone, PartialEq, Eq, RuntimeDebug, Encode, Decode, MaxEncodedLen, TypeInfo)] + #[scale_info(skip_type_params(I))] + pub enum Origin { Members(u32), - _Phantom(std::marker::PhantomData<(T, I)>), + _Phantom(PhantomData<(T, I)>), } pub const INHERENT_IDENTIFIER: InherentIdentifier = *b"12345678"; - impl, I: Instance> ProvideInherent for Module { + #[pallet::inherent] + impl, I: 'static> ProvideInherent for Pallet { type Call = Call; type Error = MakeFatalError<()>; const INHERENT_IDENTIFIER: InherentIdentifier = INHERENT_IDENTIFIER; @@ -202,10 +236,7 @@ mod module2 { unimplemented!(); } - fn check_inherent( - _call: &Self::Call, - _data: &InherentData, - ) -> std::result::Result<(), Self::Error> { + fn check_inherent(_call: &Self::Call, _data: &InherentData) -> Result<(), Self::Error> { unimplemented!(); } @@ -217,19 +248,70 @@ mod module2 { // Test for: // * Depends on multiple instances of a module with instances +#[frame_support::pallet] mod module3 { use super::*; + use frame_support::pallet_prelude::*; + use frame_support_test as frame_system; + + #[pallet::pallet] + pub struct Pallet(PhantomData<(T, I)>); - pub trait Config: - module2::Config + module2::Config + system::Config + #[pallet::config] + pub trait Config: + frame_system::Config + module2::Config + module2::Config { type Currency: Currency; type Currency2: Currency; } - frame_support::decl_module! { - pub struct Module for enum Call where origin: ::RuntimeOrigin, system=system {} + #[pallet::call] + impl, I: 'static> Pallet {} +} + +pub type BlockNumber = u32; +pub type Signature = sr25519::Signature; +pub type AccountId = ::Signer; +pub type Header = generic::Header; +pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; +pub type Block = generic::Block; + +frame_support::construct_runtime!( + pub enum Runtime where + Block = Block, + NodeBlock = Block, + UncheckedExtrinsic = UncheckedExtrinsic + { + System: frame_support_test::{Pallet, Call, Event}, + Module1_1: module1::::{ + Pallet, Call, Storage, Event, Config, Origin, Inherent + }, + Module1_2: module1::::{ + Pallet, Call, Storage, Event, Config, Origin, Inherent + }, + Module2: module2::{Pallet, Call, Storage, Event, Config, Origin, Inherent}, + Module2_1: module2::::{ + Pallet, Call, Storage, Event, Config, Origin, Inherent + }, + Module2_2: module2::::{ + Pallet, Call, Storage, Event, Config, Origin, Inherent + }, + Module2_3: module2::::{ + Pallet, Call, Storage, Event, Config, Origin, Inherent + }, + Module3: module3::{Pallet, Call}, } +); + +impl frame_support_test::Config for Runtime { + type BlockNumber = BlockNumber; + type AccountId = AccountId; + type BaseCallFilter = frame_support::traits::Everything; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type PalletInfo = PalletInfo; + type DbWeight = (); } impl module1::Config for Runtime { @@ -269,54 +351,6 @@ impl module3::Config for Runtime { type Currency2 = Module2_3; } -pub type Signature = sr25519::Signature; -pub type AccountId = ::Signer; -pub type BlockNumber = u64; -pub type Index = u64; - -impl system::Config for Runtime { - type BaseCallFilter = frame_support::traits::Everything; - type Hash = H256; - type RuntimeOrigin = RuntimeOrigin; - type BlockNumber = BlockNumber; - type AccountId = AccountId; - type RuntimeEvent = RuntimeEvent; - type PalletInfo = PalletInfo; - type RuntimeCall = RuntimeCall; - type DbWeight = (); -} - -frame_support::construct_runtime!( - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic - { - System: system::{Pallet, Call, Event}, - Module1_1: module1::::{ - Pallet, Call, Storage, Event, Config, Origin, Inherent - }, - Module1_2: module1::::{ - Pallet, Call, Storage, Event, Config, Origin, Inherent - }, - Module2: module2::{Pallet, Call, Storage, Event, Config, Origin, Inherent}, - Module2_1: module2::::{ - Pallet, Call, Storage, Event, Config, Origin, Inherent - }, - Module2_2: module2::::{ - Pallet, Call, Storage, Event, Config, Origin, Inherent - }, - Module2_3: module2::::{ - Pallet, Call, Storage, Event, Config, Origin, Inherent - }, - Module3: module3::{Pallet, Call}, - } -); - -pub type Header = generic::Header; -pub type Block = generic::Block; -pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; - fn new_test_ext() -> sp_io::TestExternalities { GenesisConfig { module_1_1: module1::GenesisConfig { value: 3, test: 2 }, @@ -350,14 +384,14 @@ fn storage_instance_independence() { module2::Value::::put(0); module2::Value::::put(0); module2::Value::::put(0); - module2::Map::::insert(0, 0); - module2::Map::::insert(0, 0); - module2::Map::::insert(0, 0); - module2::Map::::insert(0, 0); - module2::DoubleMap::::insert(&0, &0, &0); - module2::DoubleMap::::insert(&0, &0, &0); - module2::DoubleMap::::insert(&0, &0, &0); - module2::DoubleMap::::insert(&0, &0, &0); + module2::Map::::insert(0, 0); + module2::Map::::insert(0, 0); + module2::Map::::insert(0, 0); + module2::Map::::insert(0, 0); + module2::DoubleMap::::insert(&0, &0, &0); + module2::DoubleMap::::insert(&0, &0, &0); + module2::DoubleMap::::insert(&0, &0, &0); + module2::DoubleMap::::insert(&0, &0, &0); }); // 12 storage values. assert_eq!(storage.top.len(), 12); @@ -367,8 +401,8 @@ fn storage_instance_independence() { fn storage_with_instance_basic_operation() { new_test_ext().execute_with(|| { type Value = module2::Value; - type Map = module2::Map; - type DoubleMap = module2::DoubleMap; + type Map = module2::Map; + type DoubleMap = module2::DoubleMap; assert_eq!(Value::exists(), true); assert_eq!(Value::get(), 4); @@ -412,7 +446,7 @@ fn storage_with_instance_basic_operation() { fn expected_metadata() -> PalletStorageMetadataIR { PalletStorageMetadataIR { - prefix: "Instance2Module2", + prefix: "Module2_2", entries: vec![ StorageEntryMetadataIR { name: "Value", diff --git a/frame/support/test/tests/issue2219.rs b/frame/support/test/tests/issue2219.rs index ce16c402da0fd..ff3e0bd951873 100644 --- a/frame/support/test/tests/issue2219.rs +++ b/frame/support/test/tests/issue2219.rs @@ -15,32 +15,28 @@ // See the License for the specific language governing permissions and // limitations under the License. -use frame_support::{ - codec::{Decode, Encode}, - scale_info::TypeInfo, - sp_runtime::{ - generic, - traits::{BlakeTwo256, Verify}, - }, +use sp_core::{sr25519, ConstU64}; +use sp_runtime::{ + generic, + traits::{BlakeTwo256, Verify}, }; -use serde::{Deserialize, Serialize}; -use sp_core::{sr25519, H256}; - -mod system; +#[frame_support::pallet] mod module { use super::*; + use frame_support::pallet_prelude::*; + use frame_support_test as frame_system; pub type Request = - (::AccountId, Role, ::BlockNumber); + (::AccountId, Role, ::BlockNumber); pub type Requests = Vec>; - #[derive(Encode, Decode, Copy, Clone, Eq, PartialEq, Debug, TypeInfo)] + #[derive(Copy, Clone, Eq, PartialEq, Debug, Encode, Decode, MaxEncodedLen, TypeInfo)] pub enum Role { Storage, } - #[derive(Encode, Decode, Copy, Clone, Eq, PartialEq, Debug, TypeInfo)] + #[derive(Copy, Clone, Eq, PartialEq, Debug, Encode, Decode, MaxEncodedLen, TypeInfo)] pub struct RoleParameters { // minimum actors to maintain - if role is unstaking // and remaining actors would be less that this value - prevent or punish for unstaking @@ -83,102 +79,108 @@ mod module { } } - pub trait Config: system::Config + TypeInfo {} - - frame_support::decl_module! { - pub struct Module for enum Call where origin: T::RuntimeOrigin, system=system {} - } - - #[derive(Encode, Decode, Copy, Clone, Serialize, Deserialize)] - pub struct Data { - pub data: T::BlockNumber, - } - - impl Default for Data { - fn default() -> Self { - Self { data: T::BlockNumber::default() } - } + #[pallet::pallet] + pub struct Pallet(PhantomData); + + #[pallet::config] + pub trait Config: frame_system::Config + TypeInfo {} + + #[pallet::call] + impl Pallet {} + + /// requirements to enter and maintain status in roles + #[pallet::storage] + #[pallet::getter(fn parameters)] + pub type Parameters = + StorageMap<_, Blake2_128Concat, Role, RoleParameters, OptionQuery>; + + /// the roles members can enter into + #[pallet::storage] + #[pallet::getter(fn available_roles)] + #[pallet::unbounded] + pub type AvailableRoles = StorageValue<_, Vec, ValueQuery>; + + /// Actors list + #[pallet::storage] + #[pallet::getter(fn actor_account_ids)] + #[pallet::unbounded] + pub type ActorAccountIds = StorageValue<_, Vec>; + + /// actor accounts associated with a role + #[pallet::storage] + #[pallet::getter(fn account_ids_by_role)] + #[pallet::unbounded] + pub type AccountIdsByRole = StorageMap<_, Blake2_128Concat, Role, Vec>; + + /// tokens locked until given block number + #[pallet::storage] + #[pallet::getter(fn bondage)] + pub type Bondage = StorageMap<_, Blake2_128Concat, T::AccountId, T::BlockNumber>; + + /// First step before enter a role is registering intent with a new account/key. + /// This is done by sending a role_entry_request() from the new account. + /// The member must then send a stake() transaction to approve the request and enter the desired + /// role. The account making the request will be bonded and must have + /// sufficient balance to cover the minimum stake for the role. + /// Bonding only occurs after successful entry into a role. + #[pallet::storage] + #[pallet::getter(fn role_entry_requests)] + #[pallet::unbounded] + pub type RoleEntryRequests = StorageValue<_, Requests>; + + /// Entry request expires after this number of blocks + #[pallet::storage] + #[pallet::getter(fn request_life_time)] + pub type RequestLifeTime = StorageValue<_, u64, ValueQuery, ConstU64<0>>; + + #[pallet::genesis_config] + #[derive(Default)] + pub struct GenesisConfig { + pub enable_storage_role: bool, + pub request_life_time: u64, } - frame_support::decl_storage! { - trait Store for Module as Actors { - /// requirements to enter and maintain status in roles - pub Parameters get(fn parameters) build(|config: &GenesisConfig| { - if config.enable_storage_role { - let storage_params: RoleParameters = Default::default(); - vec![(Role::Storage, storage_params)] - } else { - vec![] - } - }): map hasher(blake2_128_concat) Role => Option>; - - /// the roles members can enter into - pub AvailableRoles get(fn available_roles) build(|config: &GenesisConfig| { - if config.enable_storage_role { - vec![(Role::Storage)] - } else { - vec![] - } - }): Vec; - - /// Actors list - pub ActorAccountIds get(fn actor_account_ids) : Vec; - - /// actor accounts associated with a role - pub AccountIdsByRole get(fn account_ids_by_role): - map hasher(blake2_128_concat) Role => Vec; - - /// tokens locked until given block number - pub Bondage get(fn bondage): - map hasher(blake2_128_concat) T::AccountId => T::BlockNumber; - - /// First step before enter a role is registering intent with a new account/key. - /// This is done by sending a role_entry_request() from the new account. - /// The member must then send a stake() transaction to approve the request and enter the desired role. - /// The account making the request will be bonded and must have - /// sufficient balance to cover the minimum stake for the role. - /// Bonding only occurs after successful entry into a role. - pub RoleEntryRequests get(fn role_entry_requests) : Requests; - - /// Entry request expires after this number of blocks - pub RequestLifeTime get(fn request_life_time) config(request_life_time) : u64 = 0; - } - add_extra_genesis { - config(enable_storage_role): bool; + #[pallet::genesis_build] + impl GenesisBuild for GenesisConfig { + fn build(&self) { + if self.enable_storage_role { + >::insert(Role::Storage, >::default()); + >::put(vec![Role::Storage]); + } + >::put(self.request_life_time); } } } +pub type BlockNumber = u64; pub type Signature = sr25519::Signature; pub type AccountId = ::Signer; -pub type BlockNumber = u64; -pub type Index = u64; pub type Header = generic::Header; -pub type Block = generic::Block; pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; +pub type Block = generic::Block; -impl system::Config for Runtime { - type BaseCallFilter = frame_support::traits::Everything; - type Hash = H256; - type RuntimeOrigin = RuntimeOrigin; +impl frame_support_test::Config for Runtime { type BlockNumber = BlockNumber; type AccountId = AccountId; + type BaseCallFilter = frame_support::traits::Everything; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; - type RuntimeCall = RuntimeCall; type DbWeight = (); } impl module::Config for Runtime {} frame_support::construct_runtime!( - pub struct Runtime where + pub struct Runtime + where Block = Block, NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + UncheckedExtrinsic = UncheckedExtrinsic, { - System: system::{Pallet, Call, Event}, - Module: module::{Pallet, Call, Storage, Config}, + System: frame_support_test, + Module: module, } ); diff --git a/frame/support/test/tests/origin.rs b/frame/support/test/tests/origin.rs index 996b996c8c49c..47451157b352c 100644 --- a/frame/support/test/tests/origin.rs +++ b/frame/support/test/tests/origin.rs @@ -19,120 +19,124 @@ #![recursion_limit = "128"] -use codec::MaxEncodedLen; use frame_support::traits::{Contains, OriginTrait}; -use scale_info::TypeInfo; -use sp_core::{sr25519, H256}; use sp_runtime::{generic, traits::BlakeTwo256}; -mod system; - mod nested { - use super::*; - + #[frame_support::pallet(dev_mode)] pub mod module { + use self::frame_system::pallet_prelude::*; + use frame_support::pallet_prelude::*; + use frame_support_test as frame_system; - use super::*; + #[pallet::pallet] + pub struct Pallet(_); - pub trait Config: system::Config {} + #[pallet::config] + pub trait Config: frame_system::Config { + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; + } - frame_support::decl_module! { - pub struct Module for enum Call - where origin: ::RuntimeOrigin, system=system - { - #[weight = 0] - pub fn fail(_origin) -> frame_support::dispatch::DispatchResult { - Err(Error::::Something.into()) - } + #[pallet::call] + impl Pallet { + pub fn fail(_origin: OriginFor) -> DispatchResult { + Err(Error::::Something.into()) } } - #[derive( - Clone, PartialEq, Eq, Debug, codec::Encode, codec::Decode, TypeInfo, MaxEncodedLen, - )] + #[pallet::origin] + #[derive(Clone, PartialEq, Eq, RuntimeDebug, Encode, Decode, MaxEncodedLen, TypeInfo)] pub struct Origin; - frame_support::decl_event! { - pub enum Event { - A, - } + #[pallet::event] + pub enum Event { + A, } - frame_support::decl_error! { - pub enum Error for Module { - Something - } + #[pallet::error] + pub enum Error { + Something, } - frame_support::decl_storage! { - trait Store for Module as Module {} - add_extra_genesis { - build(|_config| {}) - } + #[pallet::genesis_config] + #[derive(Default)] + pub struct GenesisConfig {} + + #[pallet::genesis_build] + impl GenesisBuild for GenesisConfig { + fn build(&self) {} } } } +#[frame_support::pallet(dev_mode)] pub mod module { - use super::*; + use self::frame_system::pallet_prelude::*; + use frame_support::pallet_prelude::*; + use frame_support_test as frame_system; - pub trait Config: system::Config {} + #[pallet::pallet] + pub struct Pallet(_); - frame_support::decl_module! { - pub struct Module for enum Call - where origin: ::RuntimeOrigin, system=system - { - #[weight = 0] - pub fn fail(_origin) -> frame_support::dispatch::DispatchResult { - Err(Error::::Something.into()) - } - #[weight = 0] - pub fn aux_1(_origin, #[compact] _data: u32) -> frame_support::dispatch::DispatchResult { - unreachable!() - } - #[weight = 0] - pub fn aux_2(_origin, _data: i32, #[compact] _data2: u32) -> frame_support::dispatch::DispatchResult { - unreachable!() - } - #[weight = 0] - fn aux_3(_origin, _data: i32, _data2: String) -> frame_support::dispatch::DispatchResult { - unreachable!() - } - #[weight = 3] - fn aux_4(_origin) -> frame_support::dispatch::DispatchResult { unreachable!() } - #[weight = (5, frame_support::dispatch::DispatchClass::Operational)] - fn operational(_origin) { unreachable!() } + #[pallet::config] + pub trait Config: frame_system::Config { + type RuntimeEvent: From> + IsType<::RuntimeEvent>; + } + + #[pallet::call] + impl Pallet { + pub fn fail(_origin: OriginFor) -> DispatchResult { + Err(Error::::Something.into()) + } + pub fn aux_1(_origin: OriginFor, #[pallet::compact] _data: u32) -> DispatchResult { + unreachable!() + } + pub fn aux_2( + _origin: OriginFor, + _data: i32, + #[pallet::compact] _data2: u32, + ) -> DispatchResult { + unreachable!() + } + #[pallet::weight(0)] + pub fn aux_3(_origin: OriginFor, _data: i32, _data2: String) -> DispatchResult { + unreachable!() + } + #[pallet::weight(3)] + pub fn aux_4(_origin: OriginFor) -> DispatchResult { + unreachable!() + } + #[pallet::weight((5, DispatchClass::Operational))] + pub fn operational(_origin: OriginFor) -> DispatchResult { + unreachable!() } } - #[derive( - Clone, PartialEq, Eq, Debug, codec::Encode, codec::Decode, TypeInfo, MaxEncodedLen, - )] - pub struct Origin(pub core::marker::PhantomData); + #[pallet::origin] + #[derive(Clone, PartialEq, Eq, RuntimeDebug, Encode, Decode, MaxEncodedLen, TypeInfo)] + pub struct Origin(pub PhantomData); - frame_support::decl_event! { - pub enum Event { - A, - } + #[pallet::event] + pub enum Event { + A, } - frame_support::decl_error! { - pub enum Error for Module { - Something - } + #[pallet::error] + pub enum Error { + Something, } - frame_support::decl_storage! { - trait Store for Module as Module {} - add_extra_genesis { - build(|_config| {}) - } + #[pallet::genesis_config] + #[derive(Default)] + pub struct GenesisConfig {} + + #[pallet::genesis_build] + impl GenesisBuild for GenesisConfig { + fn build(&self) {} } } -impl nested::module::Config for RuntimeOriginTest {} -impl module::Config for RuntimeOriginTest {} - pub struct BaseCallFilter; impl Contains for BaseCallFilter { fn contains(c: &RuntimeCall) -> bool { @@ -143,17 +147,11 @@ impl Contains for BaseCallFilter { } } -impl system::Config for RuntimeOriginTest { - type BaseCallFilter = BaseCallFilter; - type Hash = H256; - type RuntimeOrigin = RuntimeOrigin; - type BlockNumber = BlockNumber; - type AccountId = u32; - type RuntimeEvent = RuntimeEvent; - type PalletInfo = PalletInfo; - type RuntimeCall = RuntimeCall; - type DbWeight = (); -} +pub type BlockNumber = u32; +pub type AccountId = u32; +pub type Header = generic::Header; +pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; +pub type Block = generic::Block; frame_support::construct_runtime!( pub enum RuntimeOriginTest where @@ -161,17 +159,29 @@ frame_support::construct_runtime!( NodeBlock = Block, UncheckedExtrinsic = UncheckedExtrinsic { - System: system::{Pallet, Event, Origin}, - NestedModule: nested::module::{Pallet, Origin, Call}, - Module: module::{Pallet, Origin, Call}, + System: frame_support_test, + NestedModule: nested::module, + Module: module, } ); -pub type Signature = sr25519::Signature; -pub type BlockNumber = u64; -pub type Header = generic::Header; -pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; -pub type Block = generic::Block; +impl frame_support_test::Config for RuntimeOriginTest { + type BlockNumber = BlockNumber; + type AccountId = AccountId; + type BaseCallFilter = BaseCallFilter; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type PalletInfo = PalletInfo; + type DbWeight = (); +} + +impl nested::module::Config for RuntimeOriginTest { + type RuntimeEvent = RuntimeEvent; +} +impl module::Config for RuntimeOriginTest { + type RuntimeEvent = RuntimeEvent; +} #[test] fn origin_default_filter() { @@ -199,7 +209,7 @@ fn origin_default_filter() { // Now test for root origin and filters: let mut origin = RuntimeOrigin::from(Some(0)); origin.set_caller_from(RuntimeOrigin::root()); - assert!(matches!(origin.caller, OriginCaller::system(system::RawOrigin::Root))); + assert!(matches!(origin.caller, OriginCaller::system(frame_support_test::RawOrigin::Root))); // Root origin bypass all filter. assert_eq!(origin.filter_call(&accepted_call), true); diff --git a/frame/support/test/tests/pallet_compatibility.rs b/frame/support/test/tests/pallet_compatibility.rs deleted file mode 100644 index 610316ecf1a6f..0000000000000 --- a/frame/support/test/tests/pallet_compatibility.rs +++ /dev/null @@ -1,371 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Old macros don't support the flag `no-metadata-docs` so the result differs when the feature is -// activated. -#![cfg(not(feature = "no-metadata-docs"))] - -use frame_support::traits::{ConstU32, ConstU64}; - -pub trait SomeAssociation { - type A: frame_support::dispatch::Parameter + Default; -} -impl SomeAssociation for u64 { - type A = u64; -} - -mod pallet_old { - use super::SomeAssociation; - use frame_support::{ - decl_error, decl_event, decl_module, decl_storage, traits::Get, weights::Weight, Parameter, - }; - use frame_system::ensure_root; - - pub trait Config: frame_system::Config { - type SomeConst: Get; - type Balance: Parameter - + codec::HasCompact - + From - + Into - + Default - + SomeAssociation; - type RuntimeEvent: From> + Into<::RuntimeEvent>; - } - - decl_storage! { - trait Store for Module as Example { - /// Some documentation - Dummy get(fn dummy) config(): Option; - Bar get(fn bar) config(): map hasher(blake2_128_concat) T::AccountId => T::Balance; - Foo get(fn foo) config(): T::Balance = 3.into(); - Double get(fn double): double_map - hasher(blake2_128_concat) u32, - hasher(twox_64_concat) u64 - => ::A; - } - } - - decl_event!( - pub enum Event - where - Balance = ::Balance, - { - /// Dummy event, just here so there's a generic type that's used. - Dummy(Balance), - } - ); - - decl_module! { - pub struct Module for enum Call where origin: T::RuntimeOrigin { - type Error = Error; - fn deposit_event() = default; - const SomeConst: T::Balance = T::SomeConst::get(); - - #[weight = >::into(new_value.clone())] - fn set_dummy(origin, #[compact] new_value: T::Balance) { - ensure_root(origin)?; - - >::put(&new_value); - Self::deposit_event(RawEvent::Dummy(new_value)); - } - - fn on_initialize(_n: T::BlockNumber) -> Weight { - >::put(T::Balance::from(10)); - Weight::from_parts(10, 0) - } - - fn on_finalize(_n: T::BlockNumber) { - >::put(T::Balance::from(11)); - } - } - } - - decl_error! { - pub enum Error for Module { - /// Some wrong behavior - Wrong, - } - } -} - -#[frame_support::pallet] -pub mod pallet { - use super::SomeAssociation; - use frame_support::{pallet_prelude::*, scale_info}; - use frame_system::{ensure_root, pallet_prelude::*}; - - #[pallet::config] - pub trait Config: frame_system::Config { - type Balance: Parameter - + codec::HasCompact - + From - + Into - + Default - + MaybeSerializeDeserialize - + SomeAssociation - + scale_info::StaticTypeInfo; - #[pallet::constant] - type SomeConst: Get; - type RuntimeEvent: From> + IsType<::RuntimeEvent>; - } - - #[pallet::pallet] - #[pallet::without_storage_info] - pub struct Pallet(_); - - #[pallet::hooks] - impl Hooks for Pallet { - fn on_initialize(_n: T::BlockNumber) -> Weight { - >::put(T::Balance::from(10)); - Weight::from_parts(10, 0) - } - - fn on_finalize(_n: T::BlockNumber) { - >::put(T::Balance::from(11)); - } - } - - #[pallet::call] - impl Pallet { - #[pallet::call_index(0)] - #[pallet::weight(>::into(new_value.clone()))] - pub fn set_dummy( - origin: OriginFor, - #[pallet::compact] new_value: T::Balance, - ) -> DispatchResultWithPostInfo { - ensure_root(origin)?; - - >::put(&new_value); - Self::deposit_event(Event::Dummy(new_value)); - - Ok(().into()) - } - } - - #[pallet::error] - pub enum Error { - /// Some wrong behavior - Wrong, - } - - #[pallet::event] - #[pallet::generate_deposit(fn deposit_event)] - pub enum Event { - /// Dummy event, just here so there's a generic type that's used. - Dummy(T::Balance), - } - - #[pallet::storage] - /// Some documentation - type Dummy = StorageValue<_, T::Balance, OptionQuery>; - - #[pallet::storage] - type Bar = StorageMap<_, Blake2_128Concat, T::AccountId, T::Balance, ValueQuery>; - - #[pallet::type_value] - pub fn OnFooEmpty() -> T::Balance { - 3.into() - } - #[pallet::storage] - type Foo = StorageValue<_, T::Balance, ValueQuery, OnFooEmpty>; - - #[pallet::storage] - type Double = StorageDoubleMap< - _, - Blake2_128Concat, - u32, - Twox64Concat, - u64, - ::A, - ValueQuery, - >; - - #[pallet::genesis_config] - pub struct GenesisConfig { - dummy: Option, - bar: Vec<(T::AccountId, T::Balance)>, - foo: T::Balance, - } - - impl Default for GenesisConfig { - fn default() -> Self { - GenesisConfig { - dummy: Default::default(), - bar: Default::default(), - foo: OnFooEmpty::::get(), - } - } - } - - #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { - fn build(&self) { - if let Some(dummy) = self.dummy.as_ref() { - >::put(dummy); - } - for (k, v) in &self.bar { - >::insert(k, v); - } - >::put(&self.foo); - } - } -} - -impl frame_system::Config for Runtime { - type BaseCallFilter = frame_support::traits::Everything; - type RuntimeOrigin = RuntimeOrigin; - type Index = u64; - type BlockNumber = u32; - type RuntimeCall = RuntimeCall; - type Hash = sp_runtime::testing::H256; - type Hashing = sp_runtime::traits::BlakeTwo256; - type AccountId = u64; - type Lookup = sp_runtime::traits::IdentityLookup; - type Header = Header; - type RuntimeEvent = RuntimeEvent; - type BlockHashCount = ConstU32<250>; - type BlockWeights = (); - type BlockLength = (); - type DbWeight = (); - type Version = (); - type PalletInfo = PalletInfo; - type AccountData = (); - type OnNewAccount = (); - type OnKilledAccount = (); - type SystemWeightInfo = (); - type SS58Prefix = (); - type OnSetCode = (); - type MaxConsumers = ConstU32<16>; -} -impl pallet::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type SomeConst = ConstU64<10>; - type Balance = u64; -} -impl pallet_old::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type SomeConst = ConstU64<10>; - type Balance = u64; -} - -pub type Header = sp_runtime::generic::Header; -pub type Block = sp_runtime::generic::Block; -pub type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic; - -frame_support::construct_runtime!( - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic - { - System: frame_system::{Pallet, Call, Event}, - // NOTE: name Example here is needed in order to have same module prefix - Example: pallet::{Pallet, Call, Event, Config, Storage}, - PalletOld: pallet_old::{Pallet, Call, Event, Config, Storage}, - } -); - -#[cfg(test)] -mod test { - use super::{pallet, pallet_old, Runtime}; - use codec::{Decode, Encode}; - use scale_info::{form::PortableForm, Variant}; - - #[test] - fn metadata() { - let metadata = Runtime::metadata(); - let (pallets, types) = match metadata.1 { - frame_support::metadata::RuntimeMetadata::V14(metadata) => - (metadata.pallets, metadata.types), - _ => unreachable!(), - }; - - let assert_meta_types = |ty_id1, ty_id2| { - let ty1 = types.resolve(ty_id1).map(|ty| ty.type_def.clone()); - let ty2 = types.resolve(ty_id2).map(|ty| ty.type_def.clone()); - pretty_assertions::assert_eq!(ty1, ty2); - }; - - let get_enum_variants = |ty_id| match types.resolve(ty_id).map(|ty| ty.type_def.clone()) { - Some(ty) => match ty { - scale_info::TypeDef::Variant(var) => var.variants, - _ => panic!("Expected variant type"), - }, - _ => panic!("No type found"), - }; - - let assert_enum_variants = |vs1: &[Variant], - vs2: &[Variant]| { - assert_eq!(vs1.len(), vs2.len()); - for i in 0..vs1.len() { - let v1 = &vs2[i]; - let v2 = &vs2[i]; - assert_eq!(v1.fields.len(), v2.fields.len()); - for f in 0..v1.fields.len() { - let f1 = &v1.fields[f]; - let f2 = &v2.fields[f]; - pretty_assertions::assert_eq!(f1.name, f2.name); - pretty_assertions::assert_eq!(f1.ty, f2.ty); - } - } - }; - - pretty_assertions::assert_eq!(pallets[1].storage, pallets[2].storage); - - let calls1 = pallets[1].calls.as_ref().unwrap(); - let calls2 = pallets[2].calls.as_ref().unwrap(); - assert_meta_types(calls1.ty.id, calls2.ty.id); - - // event: check variants and fields but ignore the type name which will be different - let event1_variants = get_enum_variants(pallets[1].event.as_ref().unwrap().ty.id); - let event2_variants = get_enum_variants(pallets[2].event.as_ref().unwrap().ty.id); - assert_enum_variants(&event1_variants, &event2_variants); - - let err1 = get_enum_variants(pallets[1].error.as_ref().unwrap().ty.id) - .iter() - .filter(|v| v.name == "__Ignore") - .cloned() - .collect::>(); - let err2 = get_enum_variants(pallets[2].error.as_ref().unwrap().ty.id) - .iter() - .filter(|v| v.name == "__Ignore") - .cloned() - .collect::>(); - assert_enum_variants(&err1, &err2); - - pretty_assertions::assert_eq!(pallets[1].constants, pallets[2].constants); - } - - #[test] - fn types() { - assert_eq!( - pallet_old::Event::::decode( - &mut &pallet::Event::::Dummy(10).encode()[..] - ) - .unwrap(), - pallet_old::Event::::Dummy(10), - ); - - assert_eq!( - pallet_old::Call::::decode( - &mut &pallet::Call::::set_dummy { new_value: 10 }.encode()[..] - ) - .unwrap(), - pallet_old::Call::::set_dummy { new_value: 10 }, - ); - } -} diff --git a/frame/support/test/tests/pallet_compatibility_instance.rs b/frame/support/test/tests/pallet_compatibility_instance.rs deleted file mode 100644 index 73014d99657c9..0000000000000 --- a/frame/support/test/tests/pallet_compatibility_instance.rs +++ /dev/null @@ -1,371 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Old macros don't support the flag `no-metadata-docs` so the result differs when the feature is -// activated. -#![cfg(not(feature = "no-metadata-docs"))] - -use frame_support::traits::{ConstU32, ConstU64}; - -mod pallet_old { - use frame_support::{ - decl_error, decl_event, decl_module, decl_storage, traits::Get, weights::Weight, Parameter, - }; - use frame_system::ensure_root; - - pub trait Config: frame_system::Config { - type SomeConst: Get; - type Balance: Parameter + codec::HasCompact + From + Into + Default; - type RuntimeEvent: From> + Into<::RuntimeEvent>; - } - - decl_storage! { - trait Store for Module, I: Instance = DefaultInstance> as Example { - /// Some documentation - Dummy get(fn dummy) config(): Option; - Bar get(fn bar) config(): map hasher(blake2_128_concat) T::AccountId => T::Balance; - Foo get(fn foo) config(): T::Balance = 3.into(); - Double get(fn double): - double_map hasher(blake2_128_concat) u32, hasher(twox_64_concat) u64 => u16; - } - } - - decl_event!( - pub enum Event - where - Balance = >::Balance, - { - /// Dummy event, just here so there's a generic type that's used. - Dummy(Balance), - } - ); - - decl_module! { - pub struct Module, I: Instance = DefaultInstance> for enum Call - where origin: T::RuntimeOrigin - { - type Error = Error; - fn deposit_event() = default; - const SomeConst: T::Balance = T::SomeConst::get(); - - #[weight = >::into(new_value.clone())] - fn set_dummy(origin, #[compact] new_value: T::Balance) { - ensure_root(origin)?; - - >::put(&new_value); - Self::deposit_event(RawEvent::Dummy(new_value)); - } - - fn on_initialize(_n: T::BlockNumber) -> Weight { - >::put(T::Balance::from(10)); - Weight::from_parts(10, 0) - } - - fn on_finalize(_n: T::BlockNumber) { - >::put(T::Balance::from(11)); - } - } - } - - decl_error! { - pub enum Error for Module, I: Instance> { - /// Some wrong behavior - Wrong, - } - } -} - -#[frame_support::pallet] -pub mod pallet { - use frame_support::{pallet_prelude::*, scale_info}; - use frame_system::{ensure_root, pallet_prelude::*}; - - #[pallet::config] - pub trait Config: frame_system::Config { - type Balance: Parameter - + codec::HasCompact - + From - + Into - + Default - + MaybeSerializeDeserialize - + scale_info::StaticTypeInfo; - #[pallet::constant] - type SomeConst: Get; - type RuntimeEvent: From> - + IsType<::RuntimeEvent>; - } - - #[pallet::pallet] - #[pallet::without_storage_info] - pub struct Pallet(PhantomData<(T, I)>); - - #[pallet::hooks] - impl, I: 'static> Hooks for Pallet { - fn on_initialize(_n: T::BlockNumber) -> Weight { - >::put(T::Balance::from(10)); - Weight::from_parts(10, 0) - } - - fn on_finalize(_n: T::BlockNumber) { - >::put(T::Balance::from(11)); - } - } - - #[pallet::call] - impl, I: 'static> Pallet { - #[pallet::call_index(0)] - #[pallet::weight(>::into(new_value.clone()))] - pub fn set_dummy( - origin: OriginFor, - #[pallet::compact] new_value: T::Balance, - ) -> DispatchResultWithPostInfo { - ensure_root(origin)?; - - >::put(&new_value); - Self::deposit_event(Event::Dummy(new_value)); - - Ok(().into()) - } - } - - #[pallet::error] - pub enum Error { - /// Some wrong behavior - Wrong, - } - - #[pallet::event] - #[pallet::generate_deposit(fn deposit_event)] - pub enum Event, I: 'static = ()> { - /// Dummy event, just here so there's a generic type that's used. - Dummy(T::Balance), - } - - #[pallet::storage] - /// Some documentation - type Dummy, I: 'static = ()> = StorageValue<_, T::Balance, OptionQuery>; - - #[pallet::storage] - type Bar, I: 'static = ()> = - StorageMap<_, Blake2_128Concat, T::AccountId, T::Balance, ValueQuery>; - - #[pallet::storage] - type Foo, I: 'static = ()> = - StorageValue<_, T::Balance, ValueQuery, OnFooEmpty>; - #[pallet::type_value] - pub fn OnFooEmpty, I: 'static>() -> T::Balance { - 3.into() - } - - #[pallet::storage] - type Double = - StorageDoubleMap<_, Blake2_128Concat, u32, Twox64Concat, u64, u16, ValueQuery>; - - #[pallet::genesis_config] - pub struct GenesisConfig, I: 'static = ()> { - dummy: Option, - bar: Vec<(T::AccountId, T::Balance)>, - foo: T::Balance, - } - - impl, I: 'static> Default for GenesisConfig { - fn default() -> Self { - GenesisConfig { - dummy: Default::default(), - bar: Default::default(), - foo: OnFooEmpty::::get(), - } - } - } - - #[pallet::genesis_build] - impl, I: 'static> GenesisBuild for GenesisConfig { - fn build(&self) { - if let Some(dummy) = self.dummy.as_ref() { - >::put(dummy); - } - for (k, v) in &self.bar { - >::insert(k, v); - } - >::put(&self.foo); - } - } -} - -impl frame_system::Config for Runtime { - type BlockWeights = (); - type BlockLength = (); - type DbWeight = (); - type BaseCallFilter = frame_support::traits::Everything; - type RuntimeOrigin = RuntimeOrigin; - type Index = u64; - type BlockNumber = u32; - type RuntimeCall = RuntimeCall; - type Hash = sp_runtime::testing::H256; - type Hashing = sp_runtime::traits::BlakeTwo256; - type AccountId = u64; - type Lookup = sp_runtime::traits::IdentityLookup; - type Header = Header; - type RuntimeEvent = RuntimeEvent; - type BlockHashCount = ConstU32<250>; - type Version = (); - type PalletInfo = PalletInfo; - type AccountData = (); - type OnNewAccount = (); - type OnKilledAccount = (); - type SystemWeightInfo = (); - type SS58Prefix = (); - type OnSetCode = (); - type MaxConsumers = ConstU32<16>; -} -impl pallet::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type SomeConst = ConstU64<10>; - type Balance = u64; -} -impl pallet::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type SomeConst = ConstU64<10>; - type Balance = u64; -} -impl pallet::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type SomeConst = ConstU64<10>; - type Balance = u64; -} -impl pallet_old::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type SomeConst = ConstU64<10>; - type Balance = u64; -} -impl pallet_old::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type SomeConst = ConstU64<10>; - type Balance = u64; -} -impl pallet_old::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type SomeConst = ConstU64<10>; - type Balance = u64; -} - -pub type Header = sp_runtime::generic::Header; -pub type Block = sp_runtime::generic::Block; -pub type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic; - -frame_support::construct_runtime!( - pub struct Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic - { - System: frame_system::{Pallet, Call, Event}, - Example: pallet::{Pallet, Call, Event, Config, Storage}, - PalletOld: pallet_old::{Pallet, Call, Event, Config, Storage}, - Instance2Example: pallet::::{Pallet, Call, Event, Config, Storage}, - PalletOld2: pallet_old::::{Pallet, Call, Event, Config, Storage}, - Instance3Example: pallet::::{Pallet, Call, Event, Config, Storage}, - PalletOld3: pallet_old::::{Pallet, Call, Event, Config, Storage}, - } -); - -#[cfg(test)] -mod test { - use super::{pallet, pallet_old, Runtime}; - use codec::{Decode, Encode}; - use scale_info::{form::PortableForm, Variant}; - - #[test] - fn metadata() { - let metadata = Runtime::metadata(); - let (pallets, types) = match metadata.1 { - frame_support::metadata::RuntimeMetadata::V14(metadata) => - (metadata.pallets, metadata.types), - _ => unreachable!(), - }; - - let get_enum_variants = |ty_id| match types.resolve(ty_id).map(|ty| ty.type_def.clone()) { - Some(ty) => match ty { - scale_info::TypeDef::Variant(var) => var.variants, - _ => panic!("Expected variant type"), - }, - _ => panic!("No type found"), - }; - - let assert_enum_variants = |vs1: &[Variant], - vs2: &[Variant]| { - assert_eq!(vs1.len(), vs2.len()); - for i in 0..vs1.len() { - let v1 = &vs2[i]; - let v2 = &vs2[i]; - assert_eq!(v1.fields.len(), v2.fields.len()); - for f in 0..v1.fields.len() { - let f1 = &v1.fields[f]; - let f2 = &v2.fields[f]; - pretty_assertions::assert_eq!(f1.name, f2.name); - pretty_assertions::assert_eq!(f1.ty, f2.ty); - } - } - }; - - for i in vec![1, 3, 5].into_iter() { - pretty_assertions::assert_eq!(pallets[i].storage, pallets[i + 1].storage); - - let call1_variants = get_enum_variants(pallets[i].calls.as_ref().unwrap().ty.id); - let call2_variants = get_enum_variants(pallets[i + 1].calls.as_ref().unwrap().ty.id); - assert_enum_variants(&call1_variants, &call2_variants); - - // event: check variants and fields but ignore the type name which will be different - let event1_variants = get_enum_variants(pallets[i].event.as_ref().unwrap().ty.id); - let event2_variants = get_enum_variants(pallets[i + 1].event.as_ref().unwrap().ty.id); - assert_enum_variants(&event1_variants, &event2_variants); - - let err1 = get_enum_variants(pallets[i].error.as_ref().unwrap().ty.id) - .iter() - .filter(|v| v.name == "__Ignore") - .cloned() - .collect::>(); - let err2 = get_enum_variants(pallets[i + 1].error.as_ref().unwrap().ty.id) - .iter() - .filter(|v| v.name == "__Ignore") - .cloned() - .collect::>(); - assert_enum_variants(&err1, &err2); - - pretty_assertions::assert_eq!(pallets[i].constants, pallets[i + 1].constants); - } - } - - #[test] - fn types() { - assert_eq!( - pallet_old::Event::::decode( - &mut &pallet::Event::::Dummy(10).encode()[..] - ) - .unwrap(), - pallet_old::Event::::Dummy(10), - ); - - assert_eq!( - pallet_old::Call::::decode( - &mut &pallet::Call::::set_dummy { new_value: 10 }.encode()[..] - ) - .unwrap(), - pallet_old::Call::::set_dummy { new_value: 10 }, - ); - } -} diff --git a/frame/support/test/tests/pallet_instance.rs b/frame/support/test/tests/pallet_instance.rs index 241492a596993..0747753289af0 100644 --- a/frame/support/test/tests/pallet_instance.rs +++ b/frame/support/test/tests/pallet_instance.rs @@ -18,21 +18,23 @@ use frame_support::{ dispatch::{DispatchClass, DispatchInfo, GetDispatchInfo, Pays, UnfilteredDispatchable}, pallet_prelude::ValueQuery, + parameter_types, storage::unhashed, traits::{ConstU32, GetCallName, OnFinalize, OnGenesis, OnInitialize, OnRuntimeUpgrade}, + weights::Weight, }; use sp_io::{ hashing::{blake2_128, twox_128, twox_64}, TestExternalities, }; use sp_runtime::{DispatchError, ModuleError}; +use sp_std::any::TypeId; #[frame_support::pallet(dev_mode)] pub mod pallet { - use codec::MaxEncodedLen; - use frame_support::{pallet_prelude::*, parameter_types, scale_info}; + use super::*; + use frame_support::pallet_prelude::*; use frame_system::pallet_prelude::*; - use sp_std::any::TypeId; type BalanceOf = >::Balance; @@ -346,8 +348,6 @@ frame_support::construct_runtime!( } ); -use frame_support::weights::Weight; - #[test] fn call_expand() { let call_foo = pallet::Call::::foo { foo: 3 }; diff --git a/frame/support/test/tests/pallet_with_name_trait_is_valid.rs b/frame/support/test/tests/pallet_with_name_trait_is_valid.rs deleted file mode 100644 index 8cd3c79cc6c08..0000000000000 --- a/frame/support/test/tests/pallet_with_name_trait_is_valid.rs +++ /dev/null @@ -1,158 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -pub trait Trait: frame_system::Config { - type Balance: frame_support::dispatch::Parameter; - /// The overarching event type. - type RuntimeEvent: From> + Into<::RuntimeEvent>; -} - -frame_support::decl_storage! { - trait Store for Module as Example { - Dummy get(fn dummy) config(): Option; - } -} - -frame_support::decl_event!( - pub enum Event - where - B = ::Balance, - { - Dummy(B), - } -); - -frame_support::decl_error!( - pub enum Error for Module { - Dummy, - } -); - -frame_support::decl_module! { - pub struct Module for enum Call where origin: T::RuntimeOrigin { - fn deposit_event() = default; - type Error = Error; - const Foo: u32 = u32::MAX; - - #[weight = 0] - fn accumulate_dummy(_origin, _increase_by: T::Balance) { - unimplemented!(); - } - - fn on_initialize(_n: T::BlockNumber) -> frame_support::weights::Weight { - frame_support::weights::Weight::zero() - } - } -} - -impl sp_runtime::traits::ValidateUnsigned for Module { - type Call = Call; - - fn validate_unsigned( - _source: sp_runtime::transaction_validity::TransactionSource, - _call: &Self::Call, - ) -> sp_runtime::transaction_validity::TransactionValidity { - unimplemented!(); - } -} - -pub const INHERENT_IDENTIFIER: frame_support::inherent::InherentIdentifier = *b"12345678"; - -impl frame_support::inherent::ProvideInherent for Module { - type Call = Call; - type Error = frame_support::inherent::MakeFatalError<()>; - const INHERENT_IDENTIFIER: frame_support::inherent::InherentIdentifier = INHERENT_IDENTIFIER; - - fn create_inherent(_data: &frame_support::inherent::InherentData) -> Option { - unimplemented!(); - } - - fn check_inherent( - _: &Self::Call, - _: &frame_support::inherent::InherentData, - ) -> std::result::Result<(), Self::Error> { - unimplemented!(); - } - - fn is_inherent(_call: &Self::Call) -> bool { - unimplemented!(); - } -} - -#[cfg(test)] -mod tests { - use crate as pallet_test; - - use frame_support::traits::ConstU64; - - type SignedExtra = ( - frame_system::CheckEra, - frame_system::CheckNonce, - frame_system::CheckWeight, - ); - type TestBlock = sp_runtime::generic::Block; - type TestHeader = sp_runtime::generic::Header; - type TestUncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic< - ::AccountId, - ::RuntimeCall, - (), - SignedExtra, - >; - - frame_support::construct_runtime!( - pub struct Runtime where - Block = TestBlock, - NodeBlock = TestBlock, - UncheckedExtrinsic = TestUncheckedExtrinsic - { - System: frame_system::{Pallet, Call, Config, Storage, Event}, - PalletTest: pallet_test::{Pallet, Call, Storage, Event, Config, ValidateUnsigned, Inherent}, - } - ); - - impl frame_system::Config for Runtime { - type BaseCallFilter = frame_support::traits::Everything; - type RuntimeOrigin = RuntimeOrigin; - type Index = u64; - type BlockNumber = u64; - type Hash = sp_core::H256; - type RuntimeCall = RuntimeCall; - type Hashing = sp_runtime::traits::BlakeTwo256; - type AccountId = u64; - type Lookup = sp_runtime::traits::IdentityLookup; - type Header = TestHeader; - type RuntimeEvent = (); - type BlockHashCount = ConstU64<250>; - type DbWeight = (); - type BlockWeights = (); - type BlockLength = (); - type Version = (); - type PalletInfo = PalletInfo; - type AccountData = (); - type OnNewAccount = (); - type OnKilledAccount = (); - type SystemWeightInfo = (); - type SS58Prefix = (); - type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; - } - - impl pallet_test::Trait for Runtime { - type Balance = u32; - type RuntimeEvent = (); - } -} diff --git a/frame/support/test/tests/storage_layers.rs b/frame/support/test/tests/storage_layers.rs index 82174bf9d7141..3e306834869bb 100644 --- a/frame/support/test/tests/storage_layers.rs +++ b/frame/support/test/tests/storage_layers.rs @@ -16,7 +16,7 @@ // limitations under the License. use frame_support::{ - assert_noop, assert_ok, dispatch::DispatchResult, pallet_prelude::ConstU32, + assert_noop, assert_ok, dispatch::DispatchResult, ensure, pallet_prelude::ConstU32, storage::with_storage_layer, }; use pallet::*; @@ -24,7 +24,8 @@ use sp_io::TestExternalities; #[frame_support::pallet(dev_mode)] pub mod pallet { - use frame_support::{ensure, pallet_prelude::*}; + use super::*; + use frame_support::pallet_prelude::*; use frame_system::pallet_prelude::*; #[pallet::pallet] @@ -56,48 +57,29 @@ pub mod pallet { } } -pub mod decl_pallet { - pub trait Config: frame_system::Config {} - - frame_support::decl_module! { - pub struct Module for enum Call where origin: T::RuntimeOrigin { - #[weight = 0] - pub fn set_value(_origin, value: u32) { - DeclValue::put(value); - frame_support::ensure!(value != 1, "Revert!"); - } - } - } - - frame_support::decl_storage! { - trait Store for Module as StorageTransactions { - pub DeclValue: u32; - } - } -} - -pub type BlockNumber = u64; +pub type BlockNumber = u32; pub type Index = u64; -pub type Header = sp_runtime::generic::Header; -pub type Block = sp_runtime::generic::Block; +pub type AccountId = u64; +pub type Header = sp_runtime::generic::Header; pub type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic; +pub type Block = sp_runtime::generic::Block; impl frame_system::Config for Runtime { + type BaseCallFilter = frame_support::traits::Everything; type BlockWeights = (); type BlockLength = (); - type DbWeight = (); - type BaseCallFilter = frame_support::traits::Everything; type RuntimeOrigin = RuntimeOrigin; - type Index = u64; - type BlockNumber = u32; type RuntimeCall = RuntimeCall; + type Index = Index; + type BlockNumber = BlockNumber; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; - type AccountId = u64; + type AccountId = AccountId; type Lookup = sp_runtime::traits::IdentityLookup; type Header = Header; type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU32<250>; + type DbWeight = (); type Version = (); type PalletInfo = PalletInfo; type AccountData = (); @@ -109,19 +91,17 @@ impl frame_system::Config for Runtime { type MaxConsumers = ConstU32<16>; } -impl pallet::Config for Runtime {} - -impl decl_pallet::Config for Runtime {} +impl Config for Runtime {} frame_support::construct_runtime!( - pub struct Runtime where + pub struct Runtime + where Block = Block, NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic + UncheckedExtrinsic = UncheckedExtrinsic, { System: frame_system, MyPallet: pallet, - DeclPallet: decl_pallet::{Call, Storage}, } ); @@ -264,23 +244,3 @@ fn storage_layer_in_pallet_call() { assert_noop!(call2.dispatch(RuntimeOrigin::signed(0)), Error::::Revert); }); } - -#[test] -fn storage_layer_in_decl_pallet_call() { - TestExternalities::default().execute_with(|| { - use frame_support::StorageValue; - use sp_runtime::traits::Dispatchable; - - let call1 = RuntimeCall::DeclPallet(decl_pallet::Call::set_value { value: 2 }); - assert_ok!(call1.dispatch(RuntimeOrigin::signed(0))); - assert_eq!(decl_pallet::DeclValue::get(), 2); - - let call2 = RuntimeCall::DeclPallet(decl_pallet::Call::set_value { value: 1 }); - assert_noop!(call2.dispatch(RuntimeOrigin::signed(0)), "Revert!"); - // Calling the function directly also works with storage layers. - assert_noop!( - decl_pallet::Module::::set_value(RuntimeOrigin::signed(1), 1), - "Revert!" - ); - }); -} diff --git a/frame/support/test/tests/storage_transaction.rs b/frame/support/test/tests/storage_transaction.rs index 769ecb29a8db2..5fc4ba7cca6d9 100644 --- a/frame/support/test/tests/storage_transaction.rs +++ b/frame/support/test/tests/storage_transaction.rs @@ -20,46 +20,86 @@ use frame_support::{ assert_noop, assert_ok, assert_storage_noop, - dispatch::{DispatchError, DispatchResult}, + dispatch::DispatchResult, storage::{with_transaction, TransactionOutcome::*}, - transactional, StorageMap, StorageValue, + transactional, }; +use sp_core::sr25519; use sp_io::TestExternalities; -use sp_runtime::TransactionOutcome; -use sp_std::result; +use sp_runtime::{ + generic, + traits::{BlakeTwo256, Verify}, + TransactionOutcome, +}; + +pub use self::pallet::*; + +#[frame_support::pallet] +pub mod pallet { + use self::frame_system::pallet_prelude::*; + use super::*; + use frame_support::pallet_prelude::*; + use frame_support_test as frame_system; -pub trait Config: frame_support_test::Config {} + #[pallet::pallet] + #[pallet::generate_store(pub (super) trait Store)] + pub struct Pallet(_); -frame_support::decl_module! { - pub struct Module for enum Call where origin: T::RuntimeOrigin, system=frame_support_test { - #[weight = 0] + #[pallet::config] + pub trait Config: frame_system::Config {} + + #[pallet::call] + impl Pallet { + #[pallet::weight(0)] #[transactional] - fn value_commits(_origin, v: u32) { - Value::set(v); + pub fn value_commits(_origin: OriginFor, v: u32) -> DispatchResult { + >::set(v); + Ok(()) } - #[weight = 0] + #[pallet::weight(0)] #[transactional] - fn value_rollbacks(_origin, v: u32) -> DispatchResult { - Value::set(v); + pub fn value_rollbacks(_origin: OriginFor, v: u32) -> DispatchResult { + >::set(v); Err(DispatchError::Other("nah")) } } -} -frame_support::decl_storage! { - trait Store for Module as StorageTransactions { - pub Value: u32; - pub Map: map hasher(twox_64_concat) String => u32; - } + #[pallet::storage] + pub type Value = StorageValue<_, u32, ValueQuery>; + + #[pallet::storage] + #[pallet::unbounded] + pub type Map = StorageMap<_, Twox64Concat, String, u32, ValueQuery>; } -struct Runtime; +pub type BlockNumber = u32; +pub type Signature = sr25519::Signature; +pub type AccountId = ::Signer; +pub type Header = generic::Header; +pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; +pub type Block = generic::Block; + +frame_support::construct_runtime!( + pub enum Runtime + where + Block = Block, + NodeBlock = Block, + UncheckedExtrinsic = UncheckedExtrinsic, + { + System: frame_support_test, + MyPallet: pallet, + } +); impl frame_support_test::Config for Runtime { - type RuntimeOrigin = u32; - type BlockNumber = u32; - type PalletInfo = frame_support_test::PanicPalletInfo; + type BlockNumber = BlockNumber; + type AccountId = AccountId; + type BaseCallFilter = frame_support::traits::Everything; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type PalletInfo = PalletInfo; type DbWeight = (); } @@ -68,6 +108,9 @@ impl Config for Runtime {} #[test] fn storage_transaction_basic_commit() { TestExternalities::default().execute_with(|| { + type Value = pallet::Value; + type Map = pallet::Map; + assert_eq!(Value::get(), 0); assert!(!Map::contains_key("val0")); @@ -87,6 +130,9 @@ fn storage_transaction_basic_commit() { #[test] fn storage_transaction_basic_rollback() { TestExternalities::default().execute_with(|| { + type Value = pallet::Value; + type Map = pallet::Map; + assert_eq!(Value::get(), 0); assert_eq!(Map::get("val0"), 0); @@ -119,6 +165,9 @@ fn storage_transaction_basic_rollback() { #[test] fn storage_transaction_rollback_then_commit() { TestExternalities::default().execute_with(|| { + type Value = pallet::Value; + type Map = pallet::Map; + Value::set(1); Map::insert("val1", 1); @@ -162,6 +211,9 @@ fn storage_transaction_rollback_then_commit() { #[test] fn storage_transaction_commit_then_rollback() { TestExternalities::default().execute_with(|| { + type Value = pallet::Value; + type Map = pallet::Map; + Value::set(1); Map::insert("val1", 1); @@ -204,19 +256,21 @@ fn storage_transaction_commit_then_rollback() { #[test] fn transactional_annotation() { + type Value = pallet::Value; + fn set_value(v: u32) -> DispatchResult { Value::set(v); Ok(()) } #[transactional] - fn value_commits(v: u32) -> result::Result { + fn value_commits(v: u32) -> Result { set_value(v)?; Ok(v) } #[transactional] - fn value_rollbacks(v: u32) -> result::Result { + fn value_rollbacks(v: u32) -> Result { set_value(v)?; Err("nah")?; Ok(v) @@ -229,14 +283,3 @@ fn transactional_annotation() { assert_noop!(value_rollbacks(3), "nah"); }); } - -#[test] -fn transactional_annotation_in_decl_module() { - TestExternalities::default().execute_with(|| { - let origin = 0; - assert_ok!(>::value_commits(origin, 2)); - assert_eq!(Value::get(), 2); - - assert_noop!(>::value_rollbacks(origin, 3), "nah"); - }); -} diff --git a/frame/support/test/tests/system.rs b/frame/support/test/tests/system.rs deleted file mode 100644 index 1a938ad4e80db..0000000000000 --- a/frame/support/test/tests/system.rs +++ /dev/null @@ -1,81 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use frame_support::{ - codec::{Decode, Encode, EncodeLike}, - traits::Get, - weights::RuntimeDbWeight, -}; - -pub trait Config: 'static + Eq + Clone { - type RuntimeOrigin: Into, Self::RuntimeOrigin>> - + From>; - - type BaseCallFilter: frame_support::traits::Contains; - type BlockNumber: Decode + Encode + EncodeLike + Clone + Default + scale_info::TypeInfo; - type Hash; - type AccountId: Encode + EncodeLike + Decode + scale_info::TypeInfo; - type RuntimeCall; - type RuntimeEvent: From>; - type PalletInfo: frame_support::traits::PalletInfo; - type DbWeight: Get; -} - -frame_support::decl_module! { - pub struct Module for enum Call where origin: T::RuntimeOrigin, system=self { - #[weight = 0] - fn noop(_origin) {} - } -} - -impl Module { - pub fn deposit_event(_event: impl Into) {} -} - -frame_support::decl_event!( - pub enum Event - where - BlockNumber = ::BlockNumber, - { - ExtrinsicSuccess, - ExtrinsicFailed, - Ignore(BlockNumber), - } -); - -frame_support::decl_error! { - pub enum Error for Module { - /// Test error documentation - TestError, - /// Error documentation - /// with multiple lines - AnotherError, - // Required by construct_runtime - CallFiltered, - } -} - -pub use frame_support::dispatch::RawOrigin; -pub type Origin = RawOrigin<::AccountId>; - -#[allow(dead_code)] -pub fn ensure_root(o: OuterOrigin) -> Result<(), &'static str> -where - OuterOrigin: Into, OuterOrigin>>, -{ - o.into().map(|_| ()).map_err(|_| "bad origin: expected to be a root origin") -} From 65e7ab604d109e316a69b8801c3b182a7fa46bcb Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Tue, 9 May 2023 20:28:58 +0800 Subject: [PATCH 07/17] Emit events related to asset mutations (#14099) * Emit events related to asset mutations * Fixes * Improve unit tests * cargo fmt --- frame/assets/src/impl_fungibles.rs | 33 +++++++++++++++++++++++++++++- frame/assets/src/tests.rs | 29 ++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/frame/assets/src/impl_fungibles.rs b/frame/assets/src/impl_fungibles.rs index 7bec884f4c56b..893d74b6aa306 100644 --- a/frame/assets/src/impl_fungibles.rs +++ b/frame/assets/src/impl_fungibles.rs @@ -81,7 +81,38 @@ impl, I: 'static> fungibles::Inspect<::AccountId } } -impl, I: 'static> fungibles::Mutate<::AccountId> for Pallet {} +impl, I: 'static> fungibles::Mutate<::AccountId> for Pallet { + fn done_mint_into( + asset_id: Self::AssetId, + beneficiary: &::AccountId, + amount: Self::Balance, + ) { + Self::deposit_event(Event::Issued { asset_id, owner: beneficiary.clone(), amount }) + } + + fn done_burn_from( + asset_id: Self::AssetId, + target: &::AccountId, + balance: Self::Balance, + ) { + Self::deposit_event(Event::Burned { asset_id, owner: target.clone(), balance }); + } + + fn done_transfer( + asset_id: Self::AssetId, + source: &::AccountId, + dest: &::AccountId, + amount: Self::Balance, + ) { + Self::deposit_event(Event::Transferred { + asset_id, + from: source.clone(), + to: dest.clone(), + amount, + }); + } +} + impl, I: 'static> fungibles::Balanced<::AccountId> for Pallet { diff --git a/frame/assets/src/tests.rs b/frame/assets/src/tests.rs index 009d0180f36bc..9eb1107aa5209 100644 --- a/frame/assets/src/tests.rs +++ b/frame/assets/src/tests.rs @@ -52,9 +52,18 @@ fn transfer_should_never_burn() { while System::inc_consumers(&2).is_ok() {} let _ = System::dec_consumers(&2); + let _ = System::dec_consumers(&2); // Exactly one consumer ref remaining. + assert_eq!(System::consumers(&2), 1); let _ = >::transfer(0, &1, &2, 50, Protect); + System::assert_has_event(RuntimeEvent::Assets(crate::Event::Transferred { + asset_id: 0, + from: 1, + to: 2, + amount: 50, + })); + assert_eq!(Assets::balance(0, 1), 50); assert_eq!(Assets::balance(0, 1) + Assets::balance(0, 2), 100); }); } @@ -65,11 +74,26 @@ fn basic_minting_should_work() { assert_ok!(Assets::force_create(RuntimeOrigin::root(), 0, 1, true, 1)); assert_ok!(Assets::force_create(RuntimeOrigin::root(), 1, 1, true, 1)); assert_ok!(Assets::mint(RuntimeOrigin::signed(1), 0, 1, 100)); + System::assert_last_event(RuntimeEvent::Assets(crate::Event::Issued { + asset_id: 0, + owner: 1, + amount: 100, + })); assert_eq!(Assets::balance(0, 1), 100); assert_ok!(Assets::mint(RuntimeOrigin::signed(1), 0, 2, 100)); + System::assert_last_event(RuntimeEvent::Assets(crate::Event::Issued { + asset_id: 0, + owner: 2, + amount: 100, + })); assert_eq!(Assets::balance(0, 2), 100); assert_eq!(asset_ids(), vec![0, 1, 999]); assert_ok!(Assets::mint(RuntimeOrigin::signed(1), 1, 1, 100)); + System::assert_last_event(RuntimeEvent::Assets(crate::Event::Issued { + asset_id: 1, + owner: 1, + amount: 100, + })); assert_eq!(Assets::account_balances(1), vec![(0, 100), (999, 100), (1, 100)]); }); } @@ -1133,6 +1157,11 @@ fn burning_asset_balance_with_positive_balance_should_work() { assert_ok!(Assets::mint(RuntimeOrigin::signed(1), 0, 1, 100)); assert_eq!(Assets::balance(0, 1), 100); assert_ok!(Assets::burn(RuntimeOrigin::signed(1), 0, 1, u64::MAX)); + System::assert_last_event(RuntimeEvent::Assets(crate::Event::Burned { + asset_id: 0, + owner: 1, + balance: 100, + })); assert_eq!(Assets::balance(0, 1), 0); }); } From 2a148e38a191d12d0e5b76d72845a844b7cad543 Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Tue, 9 May 2023 16:28:47 +0200 Subject: [PATCH 08/17] Deprecate Pallet `decl_*` Macros (#13705) * Deprecate decl_ macros Signed-off-by: Oliver Tale-Yazdi * Allow deprecated in tests Signed-off-by: Oliver Tale-Yazdi * Revert "Allow deprecated in tests" This reverts commit ce36080f9bb4079e9069af8ee02e0954753ae412. * Deprecate all Signed-off-by: Oliver Tale-Yazdi * Push missing files Signed-off-by: Oliver Tale-Yazdi * fmt Signed-off-by: Oliver Tale-Yazdi * Move decl_module to own file Otherwise i have to spam allow(deprecated) for all recursive calls. Signed-off-by: Oliver Tale-Yazdi * Revert "Move decl_module to own file" This reverts commit 543a31185cda708d417127d6cb89cdc0c31d1f34. * Fix tests Signed-off-by: Oliver Tale-Yazdi --------- Signed-off-by: Oliver Tale-Yazdi --- frame/support/procedural/src/lib.rs | 2 ++ frame/support/src/dispatch.rs | 3 +++ frame/support/src/error.rs | 2 ++ frame/support/src/event.rs | 2 ++ 4 files changed, 9 insertions(+) diff --git a/frame/support/procedural/src/lib.rs b/frame/support/procedural/src/lib.rs index 33d9ce9473e59..abfa21b331b0e 100644 --- a/frame/support/procedural/src/lib.rs +++ b/frame/support/procedural/src/lib.rs @@ -296,6 +296,8 @@ fn counter_prefix(prefix: &str) -> String { /// } /// ``` #[proc_macro] +#[deprecated(note = "Will be removed soon; use the attribute `#[pallet]` macro instead. + For more info, see: ")] pub fn decl_storage(input: TokenStream) -> TokenStream { storage::decl_storage_impl(input) } diff --git a/frame/support/src/dispatch.rs b/frame/support/src/dispatch.rs index db9405245ffd0..071fb7c9d5aaf 100644 --- a/frame/support/src/dispatch.rs +++ b/frame/support/src/dispatch.rs @@ -879,6 +879,8 @@ impl PaysFee for (u64, Pays) { /// in an externalities-provided environment. Implement /// [`IntegrityTest`](./trait.IntegrityTest.html) trait. #[macro_export] +#[deprecated(note = "Will be removed soon; use the attribute `#[pallet]` macro instead. + For more info, see: ")] macro_rules! decl_module { // Entry point #1. ( @@ -3197,6 +3199,7 @@ macro_rules! __check_reserved_fn_name { #[cfg(test)] // Do not complain about unused `dispatch` and `dispatch_aux`. #[allow(dead_code)] +#[allow(deprecated)] mod tests { use super::*; use crate::{ diff --git a/frame/support/src/error.rs b/frame/support/src/error.rs index 72d13dfcef164..fa711389abe18 100644 --- a/frame/support/src/error.rs +++ b/frame/support/src/error.rs @@ -67,6 +67,8 @@ pub use sp_runtime::traits::{BadOrigin, LookupError}; /// For instantiable modules you also need to give the instance generic type and bound to the /// error declaration. #[macro_export] +#[deprecated(note = "Will be removed soon; use the attribute `#[pallet]` macro instead. + For more info, see: ")] macro_rules! decl_error { ( $(#[$attr:meta])* diff --git a/frame/support/src/event.rs b/frame/support/src/event.rs index ce9e0dbb70a46..ba3e5a2750b63 100644 --- a/frame/support/src/event.rs +++ b/frame/support/src/event.rs @@ -101,6 +101,8 @@ /// # fn main() {} /// ``` #[macro_export] +#[deprecated(note = "Will be removed soon; use the attribute `#[pallet]` macro instead. + For more info, see: ")] macro_rules! decl_event { ( $(#[$attr:meta])* From 0dff96ee91462956ea0020bc62e74ee85c90813e Mon Sep 17 00:00:00 2001 From: PG Herveou Date: Tue, 9 May 2023 17:24:41 +0200 Subject: [PATCH 09/17] Add non_camel_case_types for storage_alias (#14104) --- frame/support/procedural/src/storage_alias.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/frame/support/procedural/src/storage_alias.rs b/frame/support/procedural/src/storage_alias.rs index 7699568721788..b44a7ee997fe2 100644 --- a/frame/support/procedural/src/storage_alias.rs +++ b/frame/support/procedural/src/storage_alias.rs @@ -626,6 +626,7 @@ fn generate_storage_instance( // Implement `StorageInstance` trait. let code = quote! { + #[allow(non_camel_case_types)] #visibility struct #name< #impl_generics >( #crate_::sp_std::marker::PhantomData<(#type_generics)> ) #where_clause; From c014d4a876b1b9db9affabfc19ba1707831c8c3f Mon Sep 17 00:00:00 2001 From: Mira Ressel Date: Tue, 9 May 2023 17:38:57 +0200 Subject: [PATCH 10/17] Move back to ci-linux:production image after upgrade (#14105) There are still a bunch of open questions on how to handle image pinning; in the meantime, let's keep using the production tag. --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 39ac5204fddde..cc950865ce07e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -48,7 +48,7 @@ variables: CARGO_INCREMENTAL: 0 DOCKER_OS: "debian:bullseye" ARCH: "x86_64" - CI_IMAGE: "paritytech/ci-linux@sha256:f6cdc1e289e40f3eb1f93efb11f961d4f0e51f4c2adf80b31300ab5b35ef1386" # staging 2023-05-02 + CI_IMAGE: "paritytech/ci-linux:production" BUILDAH_IMAGE: "quay.io/buildah/stable:v1.29" BUILDAH_COMMAND: "buildah --storage-driver overlay2" RELENG_SCRIPTS_BRANCH: "master" From e92613d9a4f4e85b57a2dd891765c407f0ad2549 Mon Sep 17 00:00:00 2001 From: drskalman <35698397+drskalman@users.noreply.github.com> Date: Tue, 9 May 2023 21:09:43 +0000 Subject: [PATCH 11/17] BLS Core Crypto attempt #2 (#13618) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Cherry pick all crypto related changes from pull-request #13311 applied to master's head * Import some stuff just if 'full_crypto' is on * Remove copyright year * Cleanup * First generic BLS draft * Finalize generic implementation * Restore tests * Fix rust docs * Fix after master merge * Fix after master merge * Use double bls with G1 as signature group and verify individual signatures using DLEQ proof. * Fix inclusions and types used within substrate * Remove unused cruft * Restore usage of upstream crates * Fix test * Reduce the diff by aligning Cargo.lock to master * Application-crypto provides bls381 * Implement bls381 for local keystore * Use new generic keystore features * import DoublePublickey[Scheme] from the bls-like root to be less confusing. * fix compilation * Apply suggestions from code review Co-authored-by: Robert Hambrock * Clean leftovers * - update bls test vector after applying spec change recommendation. - send message as ref. * Different hard junction ids for different bls12 types * update to new bls-like * bls-like → w3f-bls * Make clippy happy * update test vector after replacing hash and crop with hash to field. * cargo fmt * account for #13972 * hide BLS behind "bls_non_production" feature flag * Remove Cargo.lock entries duplicated in merge * add bls377 to primitives/keystore and client/keystore add bls377 to primitives/application-crypto/ add bls_non_production to primitives/keystore and client/keystore bump up w3f-bls version * rename feature `bls_non_production` to `bls-experimental` --------- Co-authored-by: Davide Galassi Co-authored-by: André Silva Co-authored-by: Robert Hambrock --- Cargo.lock | 1380 +++++++++++-------- client/keystore/Cargo.toml | 9 +- client/keystore/src/local.rs | 62 +- primitives/application-crypto/src/bls377.rs | 28 + primitives/application-crypto/src/bls381.rs | 28 + primitives/application-crypto/src/lib.rs | 4 + primitives/core/Cargo.toml | 7 + primitives/core/src/bls.rs | 675 +++++++++ primitives/core/src/hexdisplay.rs | 2 +- primitives/core/src/lib.rs | 5 + primitives/core/src/testing.rs | 4 + primitives/keystore/Cargo.toml | 4 + primitives/keystore/src/lib.rs | 86 +- primitives/keystore/src/testing.rs | 50 + 14 files changed, 1730 insertions(+), 614 deletions(-) create mode 100644 primitives/application-crypto/src/bls377.rs create mode 100644 primitives/application-crypto/src/bls381.rs create mode 100644 primitives/core/src/bls.rs diff --git a/Cargo.lock b/Cargo.lock index e9bc2a99677a2..3c6c2496963b5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -42,7 +42,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fc95d1bdb8e6666b2b217308eeeb09f2d6728d104be3e31916cc74d15420331" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", ] [[package]] @@ -51,18 +51,18 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b613b8e1e3cf911a086f53f03bf286f52fd7a7258e4fa606f0ef220d39d8877" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", "rand_core 0.6.4", ] [[package]] name = "aead" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c192eb8f11fc081b0fe4259ba5af04217d4e0faddd02417310a927911abd7c8" +checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" dependencies = [ "crypto-common", - "generic-array 0.14.6", + "generic-array 0.14.7", ] [[package]] @@ -95,7 +95,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "433cfd6710c9986c576a25ca913c39d66a6474107b406f34f91d4a8923395241" dependencies = [ "cfg-if", - "cipher 0.4.3", + "cipher 0.4.4", "cpufeatures", ] @@ -119,9 +119,9 @@ version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "82e1366e0c69c9f927b1fa5ce2c7bf9eafc8f9268c0b9800729e8b267612447c" dependencies = [ - "aead 0.5.1", + "aead 0.5.2", "aes 0.8.2", - "cipher 0.4.3", + "cipher 0.4.4", "ctr 0.9.2", "ghash 0.5.0", "subtle", @@ -153,7 +153,7 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" dependencies = [ - "getrandom 0.2.8", + "getrandom 0.2.9", "once_cell", "version_check", ] @@ -165,7 +165,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" dependencies = [ "cfg-if", - "getrandom 0.2.8", + "getrandom 0.2.9", "once_cell", "version_check", ] @@ -179,6 +179,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "aho-corasick" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67fc08ce920c31afb70f013dcce1bfc3a3195de6a228474e45e1f145b36f8d04" +dependencies = [ + "memchr", +] + [[package]] name = "android_system_properties" version = "0.1.5" @@ -209,7 +218,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" dependencies = [ - "anstyle 1.0.0", + "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", @@ -218,12 +227,6 @@ dependencies = [ "utf8parse", ] -[[package]] -name = "anstyle" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23ea9e81bd02e310c216d080f6223c179012256e5151c41db88d12c88a1684d2" - [[package]] name = "anstyle" version = "1.0.0" @@ -254,15 +257,15 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" dependencies = [ - "anstyle 1.0.0", + "anstyle", "windows-sys 0.48.0", ] [[package]] name = "anyhow" -version = "1.0.69" +version = "1.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "224afbd727c3d6e4b90103ece64b8d1b67fbb1973b1046c2281eed3f3803f800" +checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" [[package]] name = "approx" @@ -285,6 +288,135 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bddcadddf5e9015d310179a59bb28c4d4b9920ad0f11e8e14dbadf654890c9a6" +[[package]] +name = "ark-bls12-377" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb00293ba84f51ce3bd026bd0de55899c4e68f0a39a5728cebae3a73ffdc0a4f" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-std", +] + +[[package]] +name = "ark-bls12-381" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c775f0d12169cba7aae4caeb547bb6a50781c7449a8aa53793827c9ec4abf488" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-serialize", + "ark-std", +] + +[[package]] +name = "ark-ec" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "defd9a439d56ac24968cca0571f598a61bc8c55f71d50a89cda591cb750670ba" +dependencies = [ + "ark-ff", + "ark-poly", + "ark-serialize", + "ark-std", + "derivative", + "hashbrown 0.13.2", + "itertools", + "num-traits", + "zeroize", +] + +[[package]] +name = "ark-ff" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec847af850f44ad29048935519032c33da8aa03340876d351dfab5660d2966ba" +dependencies = [ + "ark-ff-asm", + "ark-ff-macros", + "ark-serialize", + "ark-std", + "derivative", + "digest 0.10.6", + "itertools", + "num-bigint", + "num-traits", + "paste", + "rustc_version 0.4.0", + "zeroize", +] + +[[package]] +name = "ark-ff-asm" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ed4aa4fe255d0bc6d79373f7e31d2ea147bcf486cba1be5ba7ea85abdb92348" +dependencies = [ + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-ff-macros" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" +dependencies = [ + "num-bigint", + "num-traits", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-poly" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d320bfc44ee185d899ccbadfa8bc31aab923ce1558716e1997a1e74057fe86bf" +dependencies = [ + "ark-ff", + "ark-serialize", + "ark-std", + "derivative", + "hashbrown 0.13.2", +] + +[[package]] +name = "ark-serialize" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" +dependencies = [ + "ark-serialize-derive", + "ark-std", + "digest 0.10.6", + "num-bigint", +] + +[[package]] +name = "ark-serialize-derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae3281bc6d0fd7e549af32b52511e1302185bd688fd3359fa36423346ff682ea" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-std" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" +dependencies = [ + "num-traits", + "rand 0.8.5", +] + [[package]] name = "array-bytes" version = "4.2.0" @@ -299,9 +431,9 @@ checksum = "d9b1c5a481ec30a5abd8dfbd94ab5cf1bb4e9a66be7f1b3b322f2f1170c200fd" [[package]] name = "arrayref" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" +checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" [[package]] name = "arrayvec" @@ -328,14 +460,14 @@ dependencies = [ "num-traits", "rusticata-macros", "thiserror", - "time 0.3.20", + "time 0.3.21", ] [[package]] name = "asn1-rs" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf6690c370453db30743b373a60ba498fc0d6d83b11f4abfd87a84a075db5dd4" +checksum = "7f6fd5ddaf0351dff5b8da21b2fb4ff8e08ddd02857f0bf69c47639106c0fff0" dependencies = [ "asn1-rs-derive 0.4.0", "asn1-rs-impl", @@ -344,7 +476,7 @@ dependencies = [ "num-traits", "rusticata-macros", "thiserror", - "time 0.3.20", + "time 0.3.21", ] [[package]] @@ -384,20 +516,20 @@ dependencies = [ [[package]] name = "asn1_der" -version = "0.7.5" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e22d1f4b888c298a027c99dc9048015fac177587de20fc30232a057dfbe24a21" +checksum = "155a5a185e42c6b77ac7b88a15143d930a9e9727a5b7b77eed417404ab15c247" [[package]] name = "assert_cmd" -version = "2.0.10" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0b2340f55d9661d76793b2bfc2eb0e62689bd79d067a95707ea762afd5e9dd" +checksum = "86d6b683edf8d1119fe420a94f8a7e389239666aa72e65495d91c00462510151" dependencies = [ - "anstyle 0.3.5", + "anstyle", "bstr", "doc-comment", - "predicates 3.0.2", + "predicates 3.0.3", "predicates-core", "predicates-tree", "wait-timeout", @@ -422,32 +554,31 @@ dependencies = [ [[package]] name = "async-io" -version = "1.12.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c374dda1ed3e7d8f0d9ba58715f924862c63eae6849c92d3a18e7fbde9e2794" +checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af" dependencies = [ "async-lock", "autocfg", + "cfg-if", "concurrent-queue", "futures-lite", - "libc", "log", "parking", "polling", + "rustix 0.37.19", "slab", "socket2", "waker-fn", - "windows-sys 0.42.0", ] [[package]] name = "async-lock" -version = "2.6.0" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8101efe8695a6c17e02911402145357e718ac92d3ff88ae8419e84b1707b685" +checksum = "fa24f727524730b077666307f2734b4a1a1c57acb79193127dcc8914d5242dd7" dependencies = [ "event-listener", - "futures-lite", ] [[package]] @@ -458,14 +589,14 @@ checksum = "0e97ce7de6cf12de5d7226c73f5ba9811622f4db3a5b91b55c53e987e5f91cba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.14", + "syn 2.0.15", ] [[package]] name = "async-stream" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad445822218ce64be7a341abfb0b1ea43b5c23aa83902542a4542e78309d8e5e" +checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51" dependencies = [ "async-stream-impl", "futures-core", @@ -474,24 +605,24 @@ dependencies = [ [[package]] name = "async-stream-impl" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4655ae1a7b0cdf149156f780c5bf3f1352bc53cbd9e0a361a7ef7b22947e965" +checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.15", ] [[package]] name = "async-trait" -version = "0.1.64" +version = "0.1.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd7fce9ba8c3c042128ce72d8b2ddbf3a05747efb67ea0313c635e10bda47a2" +checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.15", ] [[package]] @@ -509,9 +640,9 @@ dependencies = [ [[package]] name = "atomic-waker" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "debc29dde2e69f9e47506b525f639ed42300fc014a3e007832592448fa8e4599" +checksum = "1181e1e0d1fce796a03db1ae795d67167da795f9cf4a39c37589e85ef57f26d3" [[package]] name = "atty" @@ -540,7 +671,7 @@ dependencies = [ "cc", "cfg-if", "libc", - "miniz_oxide", + "miniz_oxide 0.6.2", "object 0.30.3", "rustc-demangle", ] @@ -583,9 +714,9 @@ checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "basic-toml" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e819b667739967cd44d308b8c7b71305d8bb0729ac44a248aa08f33d01950b4" +checksum = "5c0de75129aa8d0cceaf750b89013f0e08804d6ec61416da787b35ad0d7cddf1" dependencies = [ "serde", ] @@ -720,7 +851,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", ] [[package]] @@ -729,7 +860,7 @@ version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", ] [[package]] @@ -759,9 +890,9 @@ checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" [[package]] name = "bounded-collections" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a071c348a5ef6da1d3a87166b408170b46002382b1dda83992b5c2208cefb370" +checksum = "e3888522b497857eb606bf51695988dba7096941822c1bcf676e3a929a9ae7a0" dependencies = [ "log", "parity-scale-codec", @@ -777,9 +908,9 @@ checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" [[package]] name = "bstr" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ffdb39cb703212f3c11973452c2861b972f757b021158f3516ba10f2fa8b2c1" +checksum = "c3d4260bcc2e8fc9df1eac4919a720effeb63a3f0952f5bf4944adfa18897f09" dependencies = [ "memchr", "once_cell", @@ -798,9 +929,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.12.0" +version = "3.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" +checksum = "9b1ce199063694f33ffb7dd4e0ee620741495c32833cde5aa08f02a0bf96f0c8" [[package]] name = "byte-slice-cast" @@ -816,9 +947,9 @@ checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" [[package]] name = "bytemuck" -version = "1.13.0" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c041d3eab048880cb0b86b256447da3f18859a163c3b8d8893f4e6368abe6393" +checksum = "17febce684fd15d89027105661fec94afb475cb995fbc59d2865198446ba2eea" [[package]] name = "byteorder" @@ -845,9 +976,9 @@ dependencies = [ [[package]] name = "camino" -version = "1.1.3" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6031a462f977dd38968b6f23378356512feeace69cef817e1a4475108093cec3" +checksum = "c530edf18f37068ac2d977409ed5cd50d53d73bc653c7647b48eb78976ac9ae2" dependencies = [ "serde", ] @@ -869,7 +1000,7 @@ checksum = "eee4243f1f26fc7a42710e7439c149e2b10b05472f88090acce52632f231a73a" dependencies = [ "camino", "cargo-platform", - "semver 1.0.16", + "semver 1.0.17", "serde", "serde_json", "thiserror", @@ -961,7 +1092,7 @@ name = "chain-spec-builder" version = "2.0.0" dependencies = [ "ansi_term", - "clap 4.2.5", + "clap 4.2.7", "node-cli", "rand 0.8.5", "sc-chain-spec", @@ -972,9 +1103,9 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.23" +version = "0.4.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" +checksum = "4e3c5919066adf22df73762e50cffcde3a758f2a848b113b586d1f86728b673b" dependencies = [ "iana-time-zone", "js-sys", @@ -987,9 +1118,9 @@ dependencies = [ [[package]] name = "ciborium" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0c137568cc60b904a7724001b35ce2630fd00d5d84805fbb608ab89509d788f" +checksum = "effd91f6c78e5a4ace8a5d3c0b6bfaec9e2baaef55f3efc00e45fb2e477ee926" dependencies = [ "ciborium-io", "ciborium-ll", @@ -998,15 +1129,15 @@ dependencies = [ [[package]] name = "ciborium-io" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "346de753af073cc87b52b2083a506b38ac176a44cfb05497b622e27be899b369" +checksum = "cdf919175532b369853f5d5e20b26b43112613fd6fe7aee757e35f7a44642656" [[package]] name = "ciborium-ll" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "213030a2b5a4e0c0892b6652260cf6ccac84827b83a85a534e178e3906c4cf1b" +checksum = "defaa24ecc093c77630e6c15e17c51f5e187bf35ee514f4e2d67baaa96dae22b" dependencies = [ "ciborium-io", "half", @@ -1031,7 +1162,7 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "12f8e7987cbd042a63249497f41aed09f8e65add917ea6566effbc56578d6801" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", ] [[package]] @@ -1040,14 +1171,14 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", ] [[package]] name = "cipher" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1873270f8f7942c191139cb8a40fd228da6c3fd2fc376d7e92d47aa14aeb59e" +checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" dependencies = [ "crypto-common", "inout", @@ -1064,9 +1195,9 @@ dependencies = [ [[package]] name = "clang-sys" -version = "1.6.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ed9a53e5d4d9c573ae844bfac6872b159cb1d1585a83b29e7a64b7eef7332a" +checksum = "c688fc74432808e3eb684cae8830a86be1d66a2bd58e1f248ed0960a590baf6f" dependencies = [ "glob", "libc", @@ -1075,9 +1206,9 @@ dependencies = [ [[package]] name = "clap" -version = "3.2.23" +version = "3.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71655c45cb9845d3270c9d6df84ebe72b4dad3c2ba3f7023ad47c144e4e473a5" +checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" dependencies = [ "bitflags", "clap_lex 0.2.4", @@ -1087,9 +1218,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.2.5" +version = "4.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a1f23fa97e1d1641371b51f35535cb26959b8e27ab50d167a8b996b5bada819" +checksum = "34d21f9bf1b425d2968943631ec91202fe5e837264063503708b83013f8fc938" dependencies = [ "clap_builder", "clap_derive", @@ -1098,12 +1229,12 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.2.5" +version = "4.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fdc5d93c358224b4d6867ef1356d740de2303e9892edc06c5340daeccd96bab" +checksum = "914c8c79fb560f238ef6429439a30023c862f7a28e688c58f7203f12b29970bd" dependencies = [ "anstream", - "anstyle 1.0.0", + "anstyle", "bitflags", "clap_lex 0.4.1", "strsim", @@ -1111,11 +1242,11 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.1.4" +version = "4.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501ff0a401473ea1d4c3b125ff95506b62c5bc5768d818634195fbb7c4ad5ff4" +checksum = "1a19591b2ab0e3c04b588a0e04ddde7b9eaa423646d1b4a8092879216bf47473" dependencies = [ - "clap 4.2.5", + "clap 4.2.7", ] [[package]] @@ -1127,7 +1258,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.14", + "syn 2.0.15", ] [[package]] @@ -1174,9 +1305,9 @@ dependencies = [ [[package]] name = "concurrent-queue" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c278839b831783b70278b14df4d45e1beb1aad306c07bb796637de9a0e323e8e" +checksum = "62ec6771ecfa0762d24683ee5a32ad78487a3d3afdc0fb8cae19d2c5deb50b7c" dependencies = [ "crossbeam-utils", ] @@ -1202,9 +1333,15 @@ checksum = "520fbf3c07483f94e3e3ca9d0cfd913d7718ef2483d2cfd91c0d9e91474ab913" [[package]] name = "constant_time_eq" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3ad85c1f65dc7b37604eb0e89748faf0b9653065f2a8ef69f96a687ec1e9279" +checksum = "13418e745008f7349ec7e449155f419a61b92b58a99cc3616942b926825ec76b" + +[[package]] +name = "constcat" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f272d0c4cf831b4fa80ee529c7707f76585986e910e1fbce1d7921970bc1a241" [[package]] name = "core-foundation" @@ -1218,9 +1355,9 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" +checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" [[package]] name = "core2" @@ -1242,9 +1379,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.5" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +checksum = "3e4c1eaa2012c47becbbad2ab175484c2a84d1185b566fb2cc5b8707343dfe58" dependencies = [ "libc", ] @@ -1382,7 +1519,7 @@ dependencies = [ "atty", "cast", "ciborium", - "clap 3.2.23", + "clap 3.2.25", "criterion-plot", "futures", "itertools", @@ -1412,9 +1549,9 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.7" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf2b3e8478797446514c91ef04bafcb59faba183e621ad488df88983cc14128c" +checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" dependencies = [ "cfg-if", "crossbeam-utils", @@ -1465,7 +1602,7 @@ version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", "rand_core 0.6.4", "subtle", "zeroize", @@ -1473,11 +1610,11 @@ dependencies = [ [[package]] name = "crypto-bigint" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c2538c4e68e52548bacb3e83ac549f903d44f011ac9d5abb5e132e67d0808f7" +checksum = "cf4c2f4e1afd912bc40bfd6fed5d9dc1f288e0ba01bfcc835cc5bc3eb13efe15" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", "rand_core 0.6.4", "subtle", "zeroize", @@ -1489,7 +1626,7 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", "rand_core 0.6.4", "typenum", ] @@ -1500,7 +1637,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", "subtle", ] @@ -1510,7 +1647,7 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", "subtle", ] @@ -1539,7 +1676,7 @@ version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" dependencies = [ - "cipher 0.4.3", + "cipher 0.4.4", ] [[package]] @@ -1584,9 +1721,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.91" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86d3488e7665a7a483b57e25bdd90d0aeb2bc7608c8d0346acf2ad3f1caf1d62" +checksum = "f61f1b6389c3fe1c316bf8a4dccc90a38208354b330925bce1f74a6c4756eb93" dependencies = [ "cc", "cxxbridge-flags", @@ -1596,9 +1733,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.91" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48fcaf066a053a41a81dfb14d57d99738b767febb8b735c3016e469fac5da690" +checksum = "12cee708e8962df2aeb38f594aae5d827c022b6460ac71a7a3e2c3c2aae5a07b" dependencies = [ "cc", "codespan-reporting", @@ -1606,31 +1743,31 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn 1.0.109", + "syn 2.0.15", ] [[package]] name = "cxxbridge-flags" -version = "1.0.91" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2ef98b8b717a829ca5603af80e1f9e2e48013ab227b68ef37872ef84ee479bf" +checksum = "7944172ae7e4068c533afbb984114a56c46e9ccddda550499caa222902c7f7bb" [[package]] name = "cxxbridge-macro" -version = "1.0.91" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "086c685979a698443656e5cf7856c95c642295a38599f12fb1ff76fb28d19892" +checksum = "2345488264226bf682893e25de0769f3360aac9957980ec49361b083ddaa5bc5" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.15", ] [[package]] name = "darling" -version = "0.14.3" +version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0808e1bd8671fb44a113a14e13497557533369847788fa2ae912b6ebfce9fa8" +checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850" dependencies = [ "darling_core", "darling_macro", @@ -1638,9 +1775,9 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.14.3" +version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "001d80444f28e193f30c2f293455da62dcf9a6b29918a4253152ae2b1de592cb" +checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0" dependencies = [ "fnv", "ident_case", @@ -1652,9 +1789,9 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.14.3" +version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b36230598a2d5de7ec1c6f51f72d8a99a9208daff41de2084d06e3fd3ea56685" +checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" dependencies = [ "darling_core", "quote", @@ -1700,9 +1837,9 @@ dependencies = [ [[package]] name = "der" -version = "0.7.1" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc906908ea6458456e5eaa160a9c08543ec3d1e6f71e2235cedd660cb65f9df0" +checksum = "05e58dffcdcc8ee7b22f0c1f71a69243d7c2d9ad87b5a14361f2424a1565c219" dependencies = [ "const-oid", "zeroize", @@ -1724,11 +1861,11 @@ dependencies = [ [[package]] name = "der-parser" -version = "8.1.0" +version = "8.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42d4bc9b0db0a0df9ae64634ac5bdefb7afcb534e182275ca0beadbe486701c1" +checksum = "dbd676fbbab537128ef0278adb5576cf363cff6aa22a7b24effe97347cfab61e" dependencies = [ - "asn1-rs 0.5.1", + "asn1-rs 0.5.2", "displaydoc", "nom", "num-bigint", @@ -1736,6 +1873,17 @@ dependencies = [ "rusticata-macros", ] +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "derive-syn-parse" version = "0.1.5" @@ -1816,7 +1964,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", ] [[package]] @@ -1826,6 +1974,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" dependencies = [ "block-buffer 0.10.4", + "const-oid", "crypto-common", "subtle", ] @@ -1873,13 +2022,13 @@ dependencies = [ [[package]] name = "displaydoc" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bf95dc3f046b9da4f2d51833c0d3547d8564ef6910f5c1ed130306a75b92886" +checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.15", ] [[package]] @@ -1908,9 +2057,9 @@ checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" [[package]] name = "dtoa" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c00704156a7de8df8da0911424e30c2049957b0a714542a44e05fe693dd85313" +checksum = "65d09067bfacaa79114679b279d7f5885b53295b1e2cfb4e79c8e4bd3d633169" [[package]] name = "dyn-clonable" @@ -1953,14 +2102,15 @@ dependencies = [ [[package]] name = "ecdsa" -version = "0.16.1" +version = "0.16.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1b0a1222f8072619e8a6b667a854020a03d363738303203c09468b3424a420a" +checksum = "a48e5d537b8a30c0b023116d981b16334be1485af7ca68db3a2b7024cbc957fd" dependencies = [ - "der 0.7.1", - "elliptic-curve 0.13.2", + "der 0.7.5", + "digest 0.10.6", + "elliptic-curve 0.13.4", "rfc6979 0.4.0", - "signature 2.0.0", + "signature 2.1.0", ] [[package]] @@ -2017,7 +2167,7 @@ dependencies = [ "der 0.6.1", "digest 0.10.6", "ff 0.12.1", - "generic-array 0.14.6", + "generic-array 0.14.7", "group 0.12.1", "hkdf", "pem-rfc7468", @@ -2030,19 +2180,19 @@ dependencies = [ [[package]] name = "elliptic-curve" -version = "0.13.2" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ea5a92946e8614bb585254898bb7dd1ddad241ace60c52149e3765e34cc039d" +checksum = "75c71eaa367f2e5d556414a8eea812bc62985c879748d6403edabd9cb03f16e7" dependencies = [ "base16ct 0.2.0", - "crypto-bigint 0.5.1", + "crypto-bigint 0.5.2", "digest 0.10.6", "ff 0.13.0", - "generic-array 0.14.6", + "generic-array 0.14.7", "group 0.13.0", - "pkcs8 0.10.1", + "pkcs8 0.10.2", "rand_core 0.6.4", - "sec1 0.7.1", + "sec1 0.7.2", "subtle", "zeroize", ] @@ -2082,7 +2232,7 @@ checksum = "5e9a1f9f7d83e59740248a6e14ecf93929ade55027844dfcea78beafccc15745" dependencies = [ "proc-macro2", "quote", - "syn 2.0.14", + "syn 2.0.15", ] [[package]] @@ -2119,24 +2269,13 @@ 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" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d6a0976c999d473fe89ad888d5a284e55366d9dc9038b1ba2aa15128c4afa0" +checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" dependencies = [ "errno-dragonfly", "libc", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] @@ -2229,9 +2368,9 @@ dependencies = [ [[package]] name = "fiat-crypto" -version = "0.1.17" +version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a214f5bb88731d436478f3ae1f8a277b62124089ba9fb67f4f93fb100ef73c90" +checksum = "e825f6987101665dea6ec934c09ec6d721de7bc1bf92248e1d5810c8cd636b77" [[package]] name = "file-per-thread-logger" @@ -2245,14 +2384,14 @@ dependencies = [ [[package]] name = "filetime" -version = "0.2.20" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a3de6e8d11b22ff9edc6d916f890800597d60f8b2da1caf2955c274638d6412" +checksum = "5cbc844cecaee9d4443931972e1289c8ff485cb4cc2767cb03ca139ed6885153" dependencies = [ "cfg-if", "libc", "redox_syscall 0.2.16", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] @@ -2292,13 +2431,13 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "flate2" -version = "1.0.25" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8a2db397cb1c8772f31494cb8917e48cd1e64f0fa7efac59fbd741a0a8ce841" +checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743" dependencies = [ "crc32fast", "libz-sys", - "miniz_oxide", + "miniz_oxide 0.7.1", ] [[package]] @@ -2382,7 +2521,7 @@ dependencies = [ "Inflector", "array-bytes 4.2.0", "chrono", - "clap 4.2.5", + "clap 4.2.7", "comfy-table", "frame-benchmarking", "frame-support", @@ -2447,7 +2586,7 @@ dependencies = [ "quote", "scale-info", "sp-arithmetic", - "syn 2.0.14", + "syn 2.0.15", "trybuild", ] @@ -2473,7 +2612,7 @@ dependencies = [ name = "frame-election-solution-type-fuzzer" version = "2.0.0-alpha.5" dependencies = [ - "clap 4.2.5", + "clap 4.2.7", "frame-election-provider-solution-type", "frame-election-provider-support", "frame-support", @@ -2538,7 +2677,7 @@ dependencies = [ "spinners", "substrate-rpc-client", "tokio", - "tracing-subscriber 0.3.16", + "tracing-subscriber 0.3.17", ] [[package]] @@ -2589,7 +2728,7 @@ dependencies = [ "proc-macro-warning", "proc-macro2", "quote", - "syn 2.0.14", + "syn 2.0.15", ] [[package]] @@ -2600,7 +2739,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.14", + "syn 2.0.15", ] [[package]] @@ -2609,7 +2748,7 @@ version = "3.0.0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.14", + "syn 2.0.15", ] [[package]] @@ -2732,13 +2871,12 @@ dependencies = [ [[package]] name = "fs4" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea55201cc351fdb478217c0fb641b59813da9b4efe4c414a9d8f989a657d149" +checksum = "a7f5b6908aecca5812a4569056285e58c666588c9573ee59765bf1d3692699e2" dependencies = [ - "libc", - "rustix 0.35.13", - "winapi", + "rustix 0.37.19", + "windows-sys 0.48.0", ] [[package]] @@ -2804,9 +2942,9 @@ checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" [[package]] name = "futures-lite" -version = "1.12.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7694489acd39452c77daa48516b894c153f192c3578d5a839b62c58099fcbf48" +checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce" dependencies = [ "fastrand", "futures-core", @@ -2825,7 +2963,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.14", + "syn 2.0.15", ] [[package]] @@ -2908,9 +3046,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.14.6" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", @@ -2940,9 +3078,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" dependencies = [ "cfg-if", "libc", @@ -3011,7 +3149,7 @@ version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "029d74589adefde59de1a0c4f4732695c32805624aec7b68d91503d4dba79afc" dependencies = [ - "aho-corasick", + "aho-corasick 0.7.20", "bstr", "fnv", "log", @@ -3042,9 +3180,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.17" +version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66b91535aa35fea1523ad1b86cb6b53c28e0ae566ba4a460f4457e936cad7c6f" +checksum = "17f8a914c2987b688368b5138aa05321db91f4090cf26118185672ad588bce21" dependencies = [ "bytes", "fnv", @@ -3148,6 +3286,12 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "hex-literal" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" + [[package]] name = "hkdf" version = "0.12.3" @@ -3193,7 +3337,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17ea0a1394df5b6574da6e0c1ade9e78868c9fb0a4e5ef4428e32da4676b85b1" dependencies = [ "digest 0.9.0", - "generic-array 0.14.6", + "generic-array 0.14.7", "hmac 0.8.1", ] @@ -3268,9 +3412,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.14.24" +version = "0.14.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e011372fa0b68db8350aa7a248930ecc7839bf46d8485577d69f117a75f164c" +checksum = "ab302d72a6f11a3b910431ff93aae7e773078c769f0a3ef15fb9ec692ed147d4" dependencies = [ "bytes", "futures-channel", @@ -3308,16 +3452,16 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.53" +version = "0.1.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765" +checksum = "0722cd7114b7de04316e7ea5456a0bbb20e4adb46fd27a3697adb812cff0f37c" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "winapi", + "windows 0.48.0", ] [[package]] @@ -3369,9 +3513,9 @@ dependencies = [ [[package]] name = "if-watch" -version = "3.0.0" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba7abdbb86e485125dad06c2691e1e393bf3b08c7b743b43aa162a00fd39062e" +checksum = "a9465340214b296cd17a0009acdb890d6160010b8adf8f78a00d0d7ab270f79f" dependencies = [ "async-io", "core-foundation", @@ -3383,7 +3527,7 @@ dependencies = [ "rtnetlink", "system-configuration", "tokio", - "windows", + "windows 0.34.0", ] [[package]] @@ -3417,9 +3561,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.9.2" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", "hashbrown 0.12.3", @@ -3440,7 +3584,7 @@ checksum = "cef509aa9bc73864d6756f0d34d35504af3cf0844373afe9b8669a5b8005a729" dependencies = [ "console", "number_prefix", - "portable-atomic", + "portable-atomic 0.3.20", "unicode-width", ] @@ -3450,7 +3594,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", ] [[package]] @@ -3492,18 +3636,13 @@ dependencies = [ [[package]] name = "io-lifetimes" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59ce5ef949d49ee85593fc4d3f3f95ad61657076395cbbce23e2121fc5542074" - -[[package]] -name = "io-lifetimes" -version = "1.0.5" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1abeb7a0dd0f8181267ff8adc397075586500b81b28a73e8a0208b00fc170fb3" +checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220" dependencies = [ + "hermit-abi 0.3.1", "libc", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] @@ -3526,20 +3665,20 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.7.1" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30e22bd8629359895450b59ea7a776c850561b96a3b1d31321c1949d9e6c9146" +checksum = "12b6ee2129af8d4fb011108c73d99a1b83a85977f23b82460c0ae2e25bb4b57f" [[package]] name = "is-terminal" -version = "0.4.4" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21b6b32576413a8e69b90e952e4a026476040d81017b80445deda5f2d3921857" +checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" dependencies = [ "hermit-abi 0.3.1", - "io-lifetimes 1.0.5", - "rustix 0.36.8", - "windows-sys 0.45.0", + "io-lifetimes", + "rustix 0.37.19", + "windows-sys 0.48.0", ] [[package]] @@ -3553,9 +3692,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440" +checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" [[package]] name = "jobserver" @@ -3568,9 +3707,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.61" +version = "0.3.62" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730" +checksum = "68c16e1bfd491478ab155fd8b4896b86f9ede344949b641e61501e07c2b8b4d5" dependencies = [ "wasm-bindgen", ] @@ -3721,22 +3860,22 @@ dependencies = [ [[package]] name = "k256" -version = "0.13.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955890845095ccf31ef83ad41a05aabb4d8cc23dc3cac5a9f5c89cf26dd0da75" +checksum = "cadb76004ed8e97623117f3df85b17aaa6626ab0b0831e6573f104df16cd1bcc" dependencies = [ "cfg-if", - "ecdsa 0.16.1", - "elliptic-curve 0.13.2", + "ecdsa 0.16.6", + "elliptic-curve 0.13.4", "once_cell", "sha2 0.10.6", ] [[package]] name = "keccak" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3afef3b6eff9ce9d8ff9b3601125eec7f0c8cbac7abd14f355d053fa56c98768" +checksum = "8f6d5ed8676d904364de097082f4e7d240b571b67989ced0240f08b7f966f940" dependencies = [ "cpufeatures", ] @@ -3910,9 +4049,9 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.140" +version = "0.2.144" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" +checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1" [[package]] name = "libgit2-sys" @@ -3950,14 +4089,14 @@ checksum = "348108ab3fba42ec82ff6e9564fc4ca0247bdccdc68dd8af9764bbc79c3c8ffb" [[package]] name = "libp2p" -version = "0.50.0" +version = "0.50.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e0a0d2f693675f49ded13c5d510c48b78069e23cbd9108d7ccd59f6dc568819" +checksum = "9c7b0104790be871edcf97db9bd2356604984e623a08d825c3f27852290266b8" dependencies = [ "bytes", "futures", "futures-timer", - "getrandom 0.2.8", + "getrandom 0.2.9", "instant", "libp2p-core 0.38.0", "libp2p-dns", @@ -3966,7 +4105,7 @@ dependencies = [ "libp2p-mdns", "libp2p-metrics", "libp2p-mplex", - "libp2p-noise 0.41.0", + "libp2p-noise", "libp2p-ping", "libp2p-quic", "libp2p-request-response", @@ -4018,36 +4157,30 @@ dependencies = [ [[package]] name = "libp2p-core" -version = "0.39.0" +version = "0.39.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881d9a54e97d97cdaa4125d48269d97ca8c40e5fefec6b85b30440dc60cc551f" +checksum = "3c1df63c0b582aa434fb09b2d86897fa2b419ffeccf934b36f87fcedc8e835c2" dependencies = [ - "asn1_der", - "bs58", - "ed25519-dalek", "either", "fnv", "futures", "futures-timer", "instant", + "libp2p-identity", "log", - "multiaddr 0.17.0", + "multiaddr 0.17.1", "multihash 0.17.0", "multistream-select", "once_cell", "parking_lot 0.12.1", "pin-project", - "prost", - "prost-build", + "quick-protobuf", "rand 0.8.5", "rw-stream-sink", - "sec1 0.3.0", - "sha2 0.10.6", "smallvec", "thiserror", "unsigned-varint", "void", - "zeroize", ] [[package]] @@ -4085,6 +4218,24 @@ dependencies = [ "void", ] +[[package]] +name = "libp2p-identity" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e2d584751cecb2aabaa56106be6be91338a60a0f4e420cf2af639204f596fc1" +dependencies = [ + "bs58", + "ed25519-dalek", + "log", + "multiaddr 0.17.1", + "multihash 0.17.0", + "quick-protobuf", + "rand 0.8.5", + "sha2 0.10.6", + "thiserror", + "zeroize", +] + [[package]] name = "libp2p-kad" version = "0.42.1" @@ -4188,29 +4339,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "libp2p-noise" -version = "0.42.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1216f9ec823ac7a2289b954674c54cbce81c9e45920b4fcf173018ede4295246" -dependencies = [ - "bytes", - "curve25519-dalek 3.2.0", - "futures", - "libp2p-core 0.39.0", - "log", - "once_cell", - "prost", - "prost-build", - "rand 0.8.5", - "sha2 0.10.6", - "snow", - "static_assertions", - "thiserror", - "x25519-dalek 1.1.1", - "zeroize", -] - [[package]] name = "libp2p-ping" version = "0.41.0" @@ -4229,15 +4357,15 @@ dependencies = [ [[package]] name = "libp2p-quic" -version = "0.7.0-alpha.2" +version = "0.7.0-alpha" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5971f629ff7519f4d4889a7c981f0dc09c6ad493423cd8a13ee442de241bc8c8" +checksum = "01e7c867e95c8130667b24409d236d37598270e6da69b3baf54213ba31ffca59" dependencies = [ "bytes", "futures", "futures-timer", "if-watch", - "libp2p-core 0.39.0", + "libp2p-core 0.38.0", "libp2p-tls", "log", "parking_lot 0.12.1", @@ -4317,13 +4445,14 @@ dependencies = [ [[package]] name = "libp2p-tls" -version = "0.1.0-alpha.2" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9baf6f6292149e124ee737d9a79dbee783f29473fc368c7faad9d157841078a" +checksum = "ff08d13d0dc66e5e9ba6279c1de417b84fa0d0adc3b03e5732928c180ec02781" dependencies = [ "futures", "futures-rustls", - "libp2p-core 0.39.0", + "libp2p-core 0.39.2", + "libp2p-identity", "rcgen 0.10.0", "ring", "rustls 0.20.8", @@ -4349,9 +4478,9 @@ dependencies = [ [[package]] name = "libp2p-webrtc" -version = "0.4.0-alpha.2" +version = "0.4.0-alpha" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db4401ec550d36f413310ba5d4bf564bb21f89fb1601cadb32b2300f8bc1eb5b" +checksum = "cdb6cd86dd68cba72308ea05de1cebf3ba0ae6e187c40548167955d4e3970f6a" dependencies = [ "async-trait", "asynchronous-codec", @@ -4360,10 +4489,10 @@ dependencies = [ "futures-timer", "hex", "if-watch", - "libp2p-core 0.39.0", - "libp2p-noise 0.42.0", + "libp2p-core 0.38.0", + "libp2p-noise", "log", - "multihash 0.17.0", + "multihash 0.16.3", "prost", "prost-build", "prost-codec", @@ -4476,9 +4605,9 @@ dependencies = [ [[package]] name = "libz-sys" -version = "1.1.8" +version = "1.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9702761c3935f8cc2f101793272e202c72b99da8f4224a19ddcf1279a6450bbf" +checksum = "56ee889ecc9568871456d42f603d6a0ce59ff328d291063a45cbdf0036baf6db" dependencies = [ "cc", "libc", @@ -4519,12 +4648,6 @@ dependencies = [ "nalgebra", ] -[[package]] -name = "linux-raw-sys" -version = "0.0.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4d2456c373231a208ad294c33dc5bff30051eafd954cd4caae83a712b12854d" - [[package]] name = "linux-raw-sys" version = "0.1.4" @@ -4533,9 +4656,9 @@ checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" [[package]] name = "linux-raw-sys" -version = "0.3.1" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d59d8c75012853d2e872fb56bc8a2e53718e2cafe1a4c823143141c6d90c322f" +checksum = "ece97ea872ece730aed82664c424eb4c8291e1ff2480247ccf7409044bc6479f" [[package]] name = "lite-json" @@ -4659,10 +4782,11 @@ checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" [[package]] name = "matrixmultiply" -version = "0.3.2" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "add85d4dd35074e6fedc608f8c8f513a3548619a9024b751949ef0e8e45a4d84" +checksum = "090126dc04f95dc0d1c1c91f61bdd474b3930ca064c1edc8a849da2c6cbe1e77" dependencies = [ + "autocfg", "rawpointer", ] @@ -4683,11 +4807,11 @@ checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "memfd" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b20a59d985586e4a5aef64564ac77299f8586d8be6cf9106a5a40207e8908efb" +checksum = "ffc89ccdc6e10d6907450f753537ebc5c5d3460d2e4e62ea74bd571db62c0f9e" dependencies = [ - "rustix 0.36.8", + "rustix 0.37.19", ] [[package]] @@ -4768,6 +4892,15 @@ dependencies = [ "adler", ] +[[package]] +name = "miniz_oxide" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +dependencies = [ + "adler", +] + [[package]] name = "mio" version = "0.8.6" @@ -4821,9 +4954,9 @@ dependencies = [ [[package]] name = "mockall" -version = "0.11.3" +version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50e4a1c770583dac7ab5e2f6c139153b783a53a1bbee9729613f193e59828326" +checksum = "4c84490118f2ee2d74570d114f3d0493cbf02790df303d2707606c3e14e07c96" dependencies = [ "cfg-if", "downcast", @@ -4836,9 +4969,9 @@ dependencies = [ [[package]] name = "mockall_derive" -version = "0.11.3" +version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "832663583d5fa284ca8810bf7015e46c9fff9622d3cf34bd1eea5003fec06dd0" +checksum = "22ce75669015c4f47b289fd4d4f56e894e4c96003ffdf3ac51313126f94c6cbb" dependencies = [ "cfg-if", "proc-macro2", @@ -4866,13 +4999,14 @@ dependencies = [ [[package]] name = "multiaddr" -version = "0.17.0" +version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b53e0cc5907a5c216ba6584bf74be8ab47d6d6289f72793b2dddbf15dc3bf8c" +checksum = "2b36f567c7099511fa8612bbbb52dda2419ce0bdbacf31714e3a5ffdb766d3bd" dependencies = [ "arrayref", "byteorder", "data-encoding", + "log", "multibase", "multihash 0.17.0", "percent-encoding", @@ -4917,9 +5051,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "835d6ff01d610179fbce3de1694d007e500bf33a7f29689838941d6bf783ae40" dependencies = [ "core2", - "digest 0.10.6", "multihash-derive", - "sha2 0.10.6", "unsigned-varint", ] @@ -4959,9 +5091,9 @@ dependencies = [ [[package]] name = "nalgebra" -version = "0.32.1" +version = "0.32.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6515c882ebfddccaa73ead7320ca28036c4bc84c9bcca3cc0cbba8efe89223a" +checksum = "d68d47bba83f9e2006d117a9a33af1524e655516b8919caac694427a6fb1e511" dependencies = [ "approx", "matrixmultiply", @@ -5048,9 +5180,9 @@ dependencies = [ [[package]] name = "netlink-sys" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "260e21fbb6f3d253a14df90eb0000a6066780a15dd901a7519ce02d77a94985b" +checksum = "6471bf08e7ac0135876a9581bf3217ef0333c191c128d34878079f42ee150411" dependencies = [ "bytes", "futures", @@ -5090,7 +5222,7 @@ name = "node-bench" version = "0.9.0-dev" dependencies = [ "array-bytes 4.2.0", - "clap 4.2.5", + "clap 4.2.7", "derive_more", "fs_extra", "futures", @@ -5127,7 +5259,7 @@ version = "3.0.0-dev" dependencies = [ "array-bytes 4.2.0", "assert_cmd", - "clap 4.2.5", + "clap 4.2.7", "clap_complete", "criterion", "frame-benchmarking-cli", @@ -5252,7 +5384,7 @@ dependencies = [ name = "node-inspect" version = "0.9.0-dev" dependencies = [ - "clap 4.2.5", + "clap 4.2.7", "parity-scale-codec", "sc-cli", "sc-client-api", @@ -5311,7 +5443,7 @@ dependencies = [ name = "node-runtime-generate-bags" version = "3.0.0" dependencies = [ - "clap 4.2.5", + "clap 4.2.7", "generate-bags", "kitchensink-runtime", ] @@ -5320,7 +5452,7 @@ dependencies = [ name = "node-template" version = "4.0.0-dev" dependencies = [ - "clap 4.2.5", + "clap 4.2.7", "frame-benchmarking", "frame-benchmarking-cli", "frame-system", @@ -5603,7 +5735,7 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9bedf36ffb6ba96c2eb7144ef6270557b52e54b20c0a8e1eb2ff99a6c6959bff" dependencies = [ - "asn1-rs 0.5.1", + "asn1-rs 0.5.2", ] [[package]] @@ -5638,9 +5770,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "os_str_bytes" -version = "6.4.1" +version = "6.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee" +checksum = "ceedf44fb00f2d1984b0bc98102627ce622e083e49a5bacdb3e514fa4238e267" [[package]] name = "output_vt100" @@ -6082,7 +6214,7 @@ version = "4.0.0-dev" dependencies = [ "proc-macro2", "quote", - "syn 2.0.14", + "syn 2.0.15", ] [[package]] @@ -7006,7 +7138,7 @@ dependencies = [ "proc-macro2", "quote", "sp-runtime", - "syn 2.0.14", + "syn 2.0.15", ] [[package]] @@ -7290,9 +7422,9 @@ dependencies = [ [[package]] name = "parity-db" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00bfb81cf5c90a222db2fb7b3a7cbf8cc7f38dfb6647aca4d98edf8281f56ed5" +checksum = "bd4572a52711e2ccff02b4973ec7e4a5b5c23387ebbfbd6cd42b34755714cefc" dependencies = [ "blake2", "crc32fast", @@ -7310,9 +7442,9 @@ dependencies = [ [[package]] name = "parity-scale-codec" -version = "3.4.0" +version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "637935964ff85a605d114591d4d2c13c5d1ba2806dae97cea6bf180238a749ac" +checksum = "5ddb756ca205bd108aee3c62c6d3c994e1df84a59b9d6d4a5ea42ee1fd5a9a28" dependencies = [ "arrayvec 0.7.2", "bitvec", @@ -7349,9 +7481,9 @@ checksum = "e1ad0aff30c1da14b1254fcb2af73e1fa9a28670e584a626f53a369d0e157304" [[package]] name = "parking" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" +checksum = "14f2252c834a40ed9bb5422029649578e63aa341ac401f74e719dd1afda8394e" [[package]] name = "parking_lot" @@ -7457,9 +7589,9 @@ checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" [[package]] name = "pest" -version = "2.5.5" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "028accff104c4e513bad663bbcd2ad7cfd5304144404c31ed0a77ac103d00660" +checksum = "e68e84bfb01f0507134eac1e9b410a12ba379d064eab48c50ba4ce329a527b70" dependencies = [ "thiserror", "ucd-trie", @@ -7467,9 +7599,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.5.5" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ac3922aac69a40733080f53c1ce7f91dcf57e1a5f6c52f421fadec7fbdc4b69" +checksum = "6b79d4c71c865a25a4322296122e3924d30bc8ee0834c8bfc8b95f7f054afbfb" dependencies = [ "pest", "pest_generator", @@ -7477,22 +7609,22 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.5.5" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d06646e185566b5961b4058dd107e0a7f56e77c3f484549fb119867773c0f202" +checksum = "6c435bf1076437b851ebc8edc3a18442796b30f1728ffea6262d59bbe28b077e" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.15", ] [[package]] name = "pest_meta" -version = "2.5.5" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6f60b2ba541577e2a0c307c8f39d1439108120eb7903adeb6497fa880c59616" +checksum = "745a452f8eb71e39ffd8ee32b3c5f51d03845f99786fa9b68db6ff509c505411" dependencies = [ "once_cell", "pest", @@ -7559,19 +7691,19 @@ dependencies = [ [[package]] name = "pkcs8" -version = "0.10.1" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d2820d87d2b008616e5c27212dd9e0e694fb4c6b522de06094106813328cb49" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" dependencies = [ - "der 0.7.1", - "spki 0.7.0", + "der 0.7.5", + "spki 0.7.2", ] [[package]] name = "pkg-config" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" +checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" [[package]] name = "platforms" @@ -7615,16 +7747,18 @@ dependencies = [ [[package]] name = "polling" -version = "2.5.2" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22122d5ec4f9fe1b3916419b76be1e80bcb93f618d071d2edf841b137b2a2bd6" +checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" dependencies = [ "autocfg", + "bitflags", "cfg-if", + "concurrent-queue", "libc", "log", - "wepoll-ffi", - "windows-sys 0.42.0", + "pin-project-lite 0.2.9", + "windows-sys 0.48.0", ] [[package]] @@ -7664,9 +7798,18 @@ dependencies = [ [[package]] name = "portable-atomic" -version = "0.3.19" +version = "0.3.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e30165d31df606f5726b090ec7592c308a0eaf61721ff64c9a3018e344a8753e" +dependencies = [ + "portable-atomic 1.3.1", +] + +[[package]] +name = "portable-atomic" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26f6a7b87c2e435a3241addceeeff740ff8b7e76b74c13bf9acb17fa454ea00b" +checksum = "1bbda379e6e462c97ea6afe9f6233619b202bbc4968d7caa6917788d2070a044" [[package]] name = "ppv-lite86" @@ -7690,11 +7833,11 @@ dependencies = [ [[package]] name = "predicates" -version = "3.0.2" +version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c575290b64d24745b6c57a12a31465f0a66f3a4799686a6921526a33b0797965" +checksum = "09963355b9f467184c04017ced4a2ba2d75cbcb4e7462690d388233253d4b1a9" dependencies = [ - "anstyle 0.3.5", + "anstyle", "difflib", "itertools", "predicates-core", @@ -7708,9 +7851,9 @@ checksum = "b794032607612e7abeb4db69adb4e33590fa6cf1149e95fd7cb00e634b92f174" [[package]] name = "predicates-tree" -version = "1.0.7" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54ff541861505aabf6ea722d2131ee980b8276e10a1297b94e896dd8b621850d" +checksum = "368ba315fb8c5052ab692e68a0eefec6ec57b23a36959c14496f0b0df2c0cecf" dependencies = [ "predicates-core", "termtree", @@ -7730,9 +7873,9 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.1.23" +version = "0.1.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e97e3215779627f01ee256d2fad52f3d95e8e1c11e9fc6fd08f7cd455d5d5c78" +checksum = "6c8646e95016a7a6c4adea95bafa8a16baab64b583356217f2c85db4a39d9a86" dependencies = [ "proc-macro2", "syn 1.0.109", @@ -7787,13 +7930,13 @@ dependencies = [ [[package]] name = "proc-macro-warning" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0e25495609acefcaeb5052edad8ac91017c9bc98fc38ef321ed524e50b68bac" +checksum = "0e99670bafb56b9a106419397343bdbc8b8742c3cc449fec6345f86173f47cd4" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.15", ] [[package]] @@ -7844,9 +7987,9 @@ dependencies = [ [[package]] name = "prost" -version = "0.11.8" +version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e48e50df39172a3e7eb17e14642445da64996989bc212b583015435d39a58537" +checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd" dependencies = [ "bytes", "prost-derive", @@ -7854,9 +7997,9 @@ dependencies = [ [[package]] name = "prost-build" -version = "0.11.8" +version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c828f93f5ca4826f97fedcbd3f9a536c16b12cff3dbbb4a007f932bbad95b12" +checksum = "119533552c9a7ffacc21e099c24a0ac8bb19c2a2a3f363de84cd9b844feab270" dependencies = [ "bytes", "heck", @@ -7889,9 +8032,9 @@ dependencies = [ [[package]] name = "prost-derive" -version = "0.11.8" +version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ea9b0f8cbe5e15a8a042d030bd96668db28ecb567ec37d691971ff5731d2b1b" +checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4" dependencies = [ "anyhow", "itertools", @@ -7902,9 +8045,9 @@ dependencies = [ [[package]] name = "prost-types" -version = "0.11.8" +version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "379119666929a1afd7a043aa6cf96fa67a6dce9af60c88095a4686dbce4c9c88" +checksum = "213622a1460818959ac1181aaeb2dc9c7f63df720db7d788b3e24eacd1983e13" dependencies = [ "prost", ] @@ -7924,6 +8067,15 @@ version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" +[[package]] +name = "quick-protobuf" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d6da84cc204722a989e01ba2f6e1e276e190f22263d0cb6ce8526fcdb0d2e1f" +dependencies = [ + "byteorder", +] + [[package]] name = "quickcheck" version = "1.0.3" @@ -7946,9 +8098,9 @@ dependencies = [ [[package]] name = "quinn-proto" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72ef4ced82a24bb281af338b9e8f94429b6eca01b4e66d899f40031f074e74c9" +checksum = "67c10f662eee9c94ddd7135043e544f3c82fa839a1e7b865911331961b53186c" dependencies = [ "bytes", "rand 0.8.5", @@ -7964,9 +8116,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.26" +version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" +checksum = "8f4f29d145265ec1c483c7c654450edde0bfe043d3938d6972630663356d9500" dependencies = [ "proc-macro2", ] @@ -8036,7 +8188,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.8", + "getrandom 0.2.9", ] [[package]] @@ -8075,9 +8227,9 @@ checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" [[package]] name = "rayon" -version = "1.6.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db3a213adf02b3bcfd2d3846bb41cb22857d131789e01df434fb7e7bc0759b7" +checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b" dependencies = [ "either", "rayon-core", @@ -8085,9 +8237,9 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.10.2" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "356a0625f1954f730c0201cdab48611198dc6ce21f4acff55089b5a78e6e835b" +checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d" dependencies = [ "crossbeam-channel", "crossbeam-deque", @@ -8103,7 +8255,7 @@ checksum = "6413f3de1edee53342e6138e75b56d32e7bc6e332b3bd62d497b1929d4cfbcdd" dependencies = [ "pem", "ring", - "time 0.3.20", + "time 0.3.21", "x509-parser 0.13.2", "yasna", ] @@ -8116,7 +8268,7 @@ checksum = "ffbe84efe2f38dea12e9bfc1f65377fdf03e53a18cb3b995faedf7934c7e785b" dependencies = [ "pem", "ring", - "time 0.3.20", + "time 0.3.21", "yasna", ] @@ -8144,29 +8296,29 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ - "getrandom 0.2.8", + "getrandom 0.2.9", "redox_syscall 0.2.16", "thiserror", ] [[package]] name = "ref-cast" -version = "1.0.14" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c78fb8c9293bcd48ef6fce7b4ca950ceaf21210de6e105a883ee280c0f7b9ed" +checksum = "f43faa91b1c8b36841ee70e97188a869d37ae21759da6846d4be66de5bf7b12c" dependencies = [ "ref-cast-impl", ] [[package]] name = "ref-cast-impl" -version = "1.0.14" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f9c0c92af03644e4806106281fe2e068ac5bc0ae74a707266d06ea27bccee5f" +checksum = "8d2275aab483050ab2a7364c1a46604865ee7d6906684e08db0f090acf74f9e7" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.15", ] [[package]] @@ -8183,13 +8335,13 @@ dependencies = [ [[package]] name = "regex" -version = "1.7.3" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b1f693b24f6ac912f4893ef08244d70b6067480d2f1a46e950c9691e6749d1d" +checksum = "af83e617f331cc6ae2da5443c602dfa5af81e517212d9d611a5b3ba1777b5370" dependencies = [ - "aho-corasick", + "aho-corasick 1.0.1", "memchr", - "regex-syntax", + "regex-syntax 0.7.1", ] [[package]] @@ -8198,7 +8350,7 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" dependencies = [ - "regex-syntax", + "regex-syntax 0.6.29", ] [[package]] @@ -8207,6 +8359,12 @@ version = "0.6.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" +[[package]] +name = "regex-syntax" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5996294f19bd3aae0453a862ad728f60e6600695733dd5df01da90c54363a3c" + [[package]] name = "region" version = "3.0.0" @@ -8338,9 +8496,9 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.21" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" [[package]] name = "rustc-hash" @@ -8369,7 +8527,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver 1.0.16", + "semver 1.0.17", ] [[package]] @@ -8383,27 +8541,13 @@ dependencies = [ [[package]] name = "rustix" -version = "0.35.13" +version = "0.36.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "727a1a6d65f786ec22df8a81ca3121107f235970dc1705ed681d3e6e8b9cd5f9" +checksum = "3a38f9520be93aba504e8ca974197f46158de5dcaa9fa04b57c57cd6a679d658" dependencies = [ "bitflags", - "errno 0.2.8", - "io-lifetimes 0.7.5", - "libc", - "linux-raw-sys 0.0.46", - "windows-sys 0.42.0", -] - -[[package]] -name = "rustix" -version = "0.36.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43abb88211988493c1abb44a70efa56ff0ce98f233b7b276146f1f3f7ba9644" -dependencies = [ - "bitflags", - "errno 0.2.8", - "io-lifetimes 1.0.5", + "errno", + "io-lifetimes", "libc", "linux-raw-sys 0.1.4", "windows-sys 0.45.0", @@ -8411,16 +8555,16 @@ dependencies = [ [[package]] name = "rustix" -version = "0.37.7" +version = "0.37.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aae838e49b3d63e9274e1c01833cc8139d3fec468c3b84688c628f44b1ae11d" +checksum = "acf8729d8542766f1b2cf77eb034d52f40d375bb8b615d0b147089946e16613d" dependencies = [ "bitflags", - "errno 0.3.0", - "io-lifetimes 1.0.5", + "errno", + "io-lifetimes", "libc", - "linux-raw-sys 0.3.1", - "windows-sys 0.45.0", + "linux-raw-sys 0.3.7", + "windows-sys 0.48.0", ] [[package]] @@ -8471,9 +8615,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5583e89e108996506031660fe09baa5011b9dd0341b89029313006d1fb508d70" +checksum = "4f3208ce4d8448b3f3e7d168a73f5e0c43a61e32930de3bceeccedb388b6bf06" [[package]] name = "rusty-fork" @@ -8499,9 +8643,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde" +checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" [[package]] name = "safe-mix" @@ -8636,7 +8780,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.14", + "syn 2.0.15", ] [[package]] @@ -8645,7 +8789,7 @@ version = "0.10.0-dev" dependencies = [ "array-bytes 4.2.0", "chrono", - "clap 4.2.5", + "clap 4.2.7", "fdlimit", "futures", "futures-timer", @@ -9184,7 +9328,7 @@ dependencies = [ "once_cell", "parity-scale-codec", "paste", - "rustix 0.36.8", + "rustix 0.36.13", "sc-allocator", "sc-executor-common", "sc-runtime-test", @@ -9216,7 +9360,6 @@ name = "sc-keystore" version = "4.0.0-dev" dependencies = [ "array-bytes 4.2.0", - "async-trait", "parking_lot 0.12.1", "serde_json", "sp-application-crypto", @@ -9806,7 +9949,7 @@ dependencies = [ name = "sc-storage-monitor" version = "0.1.0" dependencies = [ - "clap 4.2.5", + "clap 4.2.7", "fs4", "futures", "log", @@ -9910,7 +10053,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.14", + "syn 2.0.15", ] [[package]] @@ -9978,9 +10121,9 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cfdffd972d76b22f3d7f81c8be34b2296afd3a25e0a547bd9abe340a4dbbe97" +checksum = "dfdef77228a4c05dc94211441595746732131ad7f6530c6c18f045da7b7ab937" dependencies = [ "bitvec", "cfg-if", @@ -9992,9 +10135,9 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61fa974aea2d63dd18a4ec3a49d59af9f34178c73a4f56d2f18205628d00681e" +checksum = "53012eae69e5aa5c14671942a5dd47de59d4cdcff8532a6dd0e081faf1119482" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -10048,9 +10191,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "scratch" -version = "1.0.3" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddccb15bcce173023b3fedd9436f882a0739b8dfb45e4f6b6002bee5929f61b2" +checksum = "1792db035ce95be60c3f8853017b3999209281c24e2ba5bc8e59bf97a0c590c1" [[package]] name = "sct" @@ -10092,7 +10235,7 @@ checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" dependencies = [ "base16ct 0.1.1", "der 0.6.1", - "generic-array 0.14.6", + "generic-array 0.14.7", "pkcs8 0.9.0", "subtle", "zeroize", @@ -10100,14 +10243,14 @@ dependencies = [ [[package]] name = "sec1" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48518a2b5775ba8ca5b46596aae011caa431e6ce7e4a67ead66d92f08884220e" +checksum = "f0aec48e813d6b90b15f0b8948af3c63483992dee44c03e9930b3eebdabe046e" dependencies = [ "base16ct 0.2.0", - "der 0.7.1", - "generic-array 0.14.6", - "pkcs8 0.10.1", + "der 0.7.5", + "generic-array 0.14.7", + "pkcs8 0.10.2", "subtle", "zeroize", ] @@ -10182,9 +10325,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.16" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58bc9567378fc7690d6b2addae4e60ac2eeea07becb2c64b9f218b53865cba2a" +checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" dependencies = [ "serde", ] @@ -10197,29 +10340,29 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.152" +version = "1.0.162" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" +checksum = "71b2f6e1ab5c2b98c05f0f35b236b22e8df7ead6ffbf51d7808da7f8817e7ab6" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.152" +version = "1.0.162" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" +checksum = "a2a0814352fd64b58489904a44ea8d90cb1a91dcb6b4f5ebabc32c8318e93cb6" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.15", ] [[package]] name = "serde_json" -version = "1.0.93" +version = "1.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cad406b69c91885b5107daf2c29572f6c8cdb3c66826821e286c533490c0bc76" +checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" dependencies = [ "itoa", "ryu", @@ -10297,9 +10440,9 @@ dependencies = [ [[package]] name = "sha3" -version = "0.10.6" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdf0c33fae925bdc080598b84bc15c55e7b9a4a43b3c704da051f977469691c9" +checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" dependencies = [ "digest 0.10.6", "keccak", @@ -10341,9 +10484,9 @@ dependencies = [ [[package]] name = "signature" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fe458c98333f9c8152221191a77e2a44e8325d0193484af2e9421a53019e57d" +checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" dependencies = [ "digest 0.10.6", "rand_core 0.6.4", @@ -10351,9 +10494,9 @@ dependencies = [ [[package]] name = "simba" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50582927ed6f77e4ac020c057f37a268fc6aebc29225050365aacbb9deeeddc4" +checksum = "061507c94fc6ab4ba1c9a0305018408e312e17c041eb63bef8aa726fa33aceae" dependencies = [ "approx", "num-complex", @@ -10379,9 +10522,9 @@ dependencies = [ [[package]] name = "slice-group-by" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03b634d87b960ab1a38c4fe143b508576f075e7c978bfad18217645ebfdfa2ec" +checksum = "826167069c09b99d56f31e9ae5c99049e932a98c9dc2dac47645b08dbbf76ba7" [[package]] name = "smallvec" @@ -10470,7 +10613,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.14", + "syn 2.0.15", ] [[package]] @@ -10714,6 +10857,7 @@ dependencies = [ "futures", "hash-db", "hash256-std-hasher", + "hex-literal", "impl-serde", "lazy_static", "libsecp256k1", @@ -10743,6 +10887,7 @@ dependencies = [ "substrate-bip39", "thiserror", "tiny-bip39", + "w3f-bls", "zeroize", ] @@ -10766,7 +10911,7 @@ dependencies = [ "proc-macro2", "quote", "sp-core-hashing", - "syn 2.0.14", + "syn 2.0.15", ] [[package]] @@ -10783,7 +10928,7 @@ version = "5.0.0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.14", + "syn 2.0.15", ] [[package]] @@ -10916,7 +11061,7 @@ dependencies = [ name = "sp-npos-elections-fuzzer" version = "2.0.0-alpha.5" dependencies = [ - "clap 4.2.5", + "clap 4.2.7", "honggfuzz", "parity-scale-codec", "rand 0.8.5", @@ -11011,7 +11156,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.14", + "syn 2.0.15", ] [[package]] @@ -11254,7 +11399,7 @@ dependencies = [ "proc-macro2", "quote", "sp-version", - "syn 2.0.14", + "syn 2.0.15", ] [[package]] @@ -11292,9 +11437,9 @@ checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" [[package]] name = "spin" -version = "0.9.5" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dccf47db1b41fa1573ed27ccf5e08e3ca771cb994f776668c5ebda893b248fc" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" [[package]] name = "spinners" @@ -11319,19 +11464,19 @@ dependencies = [ [[package]] name = "spki" -version = "0.7.0" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0445c905640145c7ea8c1993555957f65e7c46d0535b91ba501bc9bfc85522f" +checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a" dependencies = [ "base64ct", - "der 0.7.1", + "der 0.7.5", ] [[package]] name = "ss58-registry" -version = "1.39.0" +version = "1.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecf0bd63593ef78eca595a7fc25e9a443ca46fe69fd472f8f09f5245cdcd769d" +checksum = "eb47a8ad42e5fc72d5b1eb104a5546937eaf39843499948bb666d6e93c62423b" dependencies = [ "Inflector", "num-format", @@ -11433,7 +11578,7 @@ dependencies = [ name = "subkey" version = "3.0.0" dependencies = [ - "clap 4.2.5", + "clap 4.2.7", "sc-cli", ] @@ -11475,7 +11620,7 @@ dependencies = [ name = "substrate-frame-cli" version = "4.0.0-dev" dependencies = [ - "clap 4.2.5", + "clap 4.2.7", "frame-support", "frame-system", "sc-cli", @@ -11697,7 +11842,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.14", + "syn 2.0.15", ] [[package]] @@ -11753,9 +11898,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.14" +version = "2.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcf316d5356ed6847742d036f8a39c3b8435cac10bd528a4bd461928a6ab34d5" +checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822" dependencies = [ "proc-macro2", "quote", @@ -11803,9 +11948,9 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "target-lexicon" -version = "0.12.6" +version = "0.12.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ae9980cab1db3fceee2f6c6f643d5d8de2997c58ee8d25fb0cc8a9e9e7348e5" +checksum = "fd1ba337640d60c3e96bc6f0638a939b9c9a7f2c316a1598c279828b3d1dc8c5" [[package]] name = "tempfile" @@ -11816,7 +11961,7 @@ dependencies = [ "cfg-if", "fastrand", "redox_syscall 0.3.5", - "rustix 0.37.7", + "rustix 0.37.19", "windows-sys 0.45.0", ] @@ -11831,9 +11976,9 @@ dependencies = [ [[package]] name = "termtree" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95059e91184749cb66be6dc994f67f182b6d897cb3df74a5bf66b5e709295fd8" +checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" [[package]] name = "textwrap" @@ -11843,22 +11988,22 @@ checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" [[package]] name = "thiserror" -version = "1.0.38" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0" +checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.38" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f" +checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.15", ] [[package]] @@ -11909,9 +12054,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.20" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd0cbfecb4d19b5ea75bb31ad904eb5b9fa13f21079c3b92017ebdf4999a5890" +checksum = "8f3403384eaacbca9923fa06940178ac13e4edb725486d70e8e15881d0c836cc" dependencies = [ "itoa", "serde", @@ -11921,15 +12066,15 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" +checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" [[package]] name = "time-macros" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd80a657e71da814b8e5d60d3374fc6d35045062245d80224748ae522dd76f36" +checksum = "372950940a5f07bf38dbe211d7283c9e6d7327df53794992d293e534c733d09b" dependencies = [ "time-core", ] @@ -11989,9 +12134,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.27.0" +version = "1.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0de47a4eecbe11f498978a9b29d792f0d2692d1dd003650c24c76510e3bc001" +checksum = "c3c786bf8134e5a3a166db9b29ab8f48134739014a3eca7bc6bfa95d673b136f" dependencies = [ "autocfg", "bytes", @@ -12003,18 +12148,18 @@ dependencies = [ "signal-hook-registry", "socket2", "tokio-macros", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] name = "tokio-macros" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61a573bdc87985e9d6ddeed1b3d864e8a302c847e40d647746df2f1de209d1ce" +checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.14", + "syn 2.0.15", ] [[package]] @@ -12030,9 +12175,9 @@ dependencies = [ [[package]] name = "tokio-stream" -version = "0.1.12" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fb52b74f05dbf495a8fba459fdc331812b96aa086d9eb78101fa0d4569c3313" +checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" dependencies = [ "futures-core", "pin-project-lite 0.2.9", @@ -12055,9 +12200,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.7" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5427d89453009325de0d8f342c9490009f76e999cb7672d77e46267448f7e6b2" +checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d" dependencies = [ "bytes", "futures-core", @@ -12167,13 +12312,13 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" +checksum = "0f57e3ca2a01450b1a921183a9c9cbfda207fd822cef4ccb00a65402cbba7a74" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.15", ] [[package]] @@ -12242,9 +12387,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6176eae26dd70d0c919749377897b54a9276bd7061339665dd68777926b5a70" +checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77" dependencies = [ "matchers 0.1.0", "nu-ansi-term", @@ -12364,7 +12509,7 @@ version = "0.10.0-dev" dependencies = [ "assert_cmd", "async-trait", - "clap 4.2.5", + "clap 4.2.7", "frame-remote-externalities", "frame-try-runtime", "hex", @@ -12400,9 +12545,9 @@ dependencies = [ [[package]] name = "trybuild" -version = "1.0.77" +version = "1.0.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44da5a6f2164c8e14d3bbc0657d69c5966af9f5f6930d4f600b1f5c4a673413" +checksum = "501dbdbb99861e4ab6b60eb6a7493956a9defb644fd034bc4a5ef27c693c8a3a" dependencies = [ "basic-toml", "dissimilar", @@ -12477,15 +12622,15 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.10" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54675592c1dbefd78cbd98db9bacd89886e1ca50692a0692baefffdeb92dd58" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" -version = "1.0.6" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" +checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" [[package]] name = "unicode-normalization" @@ -12514,7 +12659,7 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f214e8f697e925001e66ec2c6e37a4ef93f0f78c2eed7814394e10c62025b05" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", "subtle", ] @@ -12565,11 +12710,11 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "uuid" -version = "1.3.0" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1674845326ee10d37ca60470760d4288a6f80f304007d92e5c53bab78c9cfd79" +checksum = "4dad5567ad0cf5b760e5665964bec1b47dfd077ba8a2544b513f3556d3d239a2" dependencies = [ - "getrandom 0.2.8", + "getrandom 0.2.9", ] [[package]] @@ -12596,6 +12741,30 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" +[[package]] +name = "w3f-bls" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7335e4c132c28cc43caef6adb339789e599e39adbe78da0c4d547fad48cbc331" +dependencies = [ + "ark-bls12-377", + "ark-bls12-381", + "ark-ec", + "ark-ff", + "ark-serialize", + "ark-serialize-derive", + "arrayref", + "constcat", + "digest 0.10.6", + "rand 0.8.5", + "rand_chacha 0.3.1", + "rand_core 0.6.4", + "sha2 0.10.6", + "sha3", + "thiserror", + "zeroize", +] + [[package]] name = "wait-timeout" version = "0.2.0" @@ -12622,12 +12791,11 @@ checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" [[package]] name = "walkdir" -version = "2.3.2" +version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698" dependencies = [ "same-file", - "winapi", "winapi-util", ] @@ -12661,9 +12829,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.84" +version = "0.2.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" +checksum = "5b6cb788c4e39112fbe1822277ef6fb3c55cd86b95cb3d3c4c1c9597e4ac74b4" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -12671,24 +12839,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.84" +version = "0.2.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" +checksum = "35e522ed4105a9d626d885b35d62501b30d9666283a5c8be12c14a8bdafe7822" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.15", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.34" +version = "0.4.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f219e0d211ba40266969f6dbdd90636da12f75bee4fc9d6c23d1260dadb51454" +checksum = "083abe15c5d88556b77bdf7aef403625be9e327ad37c62c4e4129af740168163" dependencies = [ "cfg-if", "js-sys", @@ -12698,9 +12866,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.84" +version = "0.2.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" +checksum = "358a79a0cb89d21db8120cbfb91392335913e4890665b1a7981d9e956903b434" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -12708,28 +12876,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.84" +version = "0.2.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" +checksum = "4783ce29f09b9d93134d41297aded3a712b7b979e9c6f28c32cb88c973a94869" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.15", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.84" +version = "0.2.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" +checksum = "a901d592cafaa4d711bc324edfaff879ac700b19c3dfd60058d2b445be2691eb" [[package]] name = "wasm-encoder" -version = "0.24.1" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f7d56227d910901ce12dfd19acc40c12687994dfb3f57c90690f80be946ec5" +checksum = "d05d0b6fcd0aeb98adf16e7975331b3c17222aa815148f5b976370ce589d80ef" dependencies = [ "leb128", ] @@ -12824,7 +12992,7 @@ version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e61a7006b0fdf24f6bbe8dcfdad5ca1b350de80061fb2827f31c82fbbb9565a" dependencies = [ - "spin 0.9.5", + "spin 0.9.8", "wasmi_arena", "wasmi_core 0.12.0", "wasmparser-nostd", @@ -12939,7 +13107,7 @@ dependencies = [ "directories-next", "file-per-thread-logger", "log", - "rustix 0.36.8", + "rustix 0.36.13", "serde", "sha2 0.10.6", "toml 0.5.11", @@ -13019,7 +13187,7 @@ checksum = "eed41cbcbf74ce3ff6f1d07d1b707888166dc408d1a880f651268f4f7c9194b2" dependencies = [ "object 0.29.0", "once_cell", - "rustix 0.36.8", + "rustix 0.36.13", ] [[package]] @@ -13050,7 +13218,7 @@ dependencies = [ "memoffset 0.6.5", "paste", "rand 0.8.5", - "rustix 0.36.8", + "rustix 0.36.13", "wasmtime-asm-macros", "wasmtime-environ", "wasmtime-jit-debug", @@ -13071,9 +13239,9 @@ dependencies = [ [[package]] name = "wast" -version = "54.0.1" +version = "57.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d48d9d731d835f4f8dacbb8de7d47be068812cb9877f5c60d408858778d8d2a" +checksum = "6eb0f5ed17ac4421193c7477da05892c2edafd67f9639e3c11a82086416662dc" dependencies = [ "leb128", "memchr", @@ -13083,18 +13251,18 @@ dependencies = [ [[package]] name = "wat" -version = "1.0.60" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1db2e3ed05ea31243761439194bec3af6efbbaf87c4c8667fb879e4f23791a0" +checksum = "ab9ab0d87337c3be2bb6fc5cd331c4ba9fd6bcb4ee85048a0dd59ed9ecf92e53" dependencies = [ "wast", ] [[package]] name = "web-sys" -version = "0.3.61" +version = "0.3.62" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e33b99f4b23ba3eec1a53ac264e35a755f00e966e0065077d6027c0f575b0b97" +checksum = "16b5f940c7edfdc6d12126d98c9ef4d1b3d470011c47c76a6581df47ad9ba721" dependencies = [ "js-sys", "wasm-bindgen", @@ -13155,7 +13323,7 @@ dependencies = [ "sha2 0.10.6", "stun", "thiserror", - "time 0.3.20", + "time 0.3.21", "tokio", "turn", "url", @@ -13199,7 +13367,7 @@ dependencies = [ "byteorder", "ccm", "curve25519-dalek 3.2.0", - "der-parser 8.1.0", + "der-parser 8.2.0", "elliptic-curve 0.12.3", "hkdf", "hmac 0.12.1", @@ -13265,18 +13433,15 @@ dependencies = [ [[package]] name = "webrtc-media" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee2a3c157a040324e5049bcbd644ffc9079e6738fa2cfab2bcff64e5cc4c00d7" +checksum = "f72e1650a8ae006017d1a5280efb49e2610c19ccc3c0905b03b648aee9554991" dependencies = [ "byteorder", "bytes", - "derive_builder", - "displaydoc", "rand 0.8.5", "rtp", "thiserror", - "webrtc-util", ] [[package]] @@ -13341,15 +13506,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "wepoll-ffi" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d743fdedc5c64377b5fc2bc036b01c7fd642205a0d96356034ae3404d49eb7fb" -dependencies = [ - "cc", -] - [[package]] name = "which" version = "4.4.0" @@ -13421,19 +13577,28 @@ dependencies = [ "windows_x86_64_msvc 0.34.0", ] +[[package]] +name = "windows" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" +dependencies = [ + "windows-targets 0.48.0", +] + [[package]] name = "windows-sys" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" dependencies = [ - "windows_aarch64_gnullvm 0.42.1", - "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 0.42.1", - "windows_x86_64_msvc 0.42.1", + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", ] [[package]] @@ -13442,7 +13607,7 @@ version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" dependencies = [ - "windows-targets 0.42.1", + "windows-targets 0.42.2", ] [[package]] @@ -13456,17 +13621,17 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" dependencies = [ - "windows_aarch64_gnullvm 0.42.1", - "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 0.42.1", - "windows_x86_64_msvc 0.42.1", + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", ] [[package]] @@ -13486,9 +13651,9 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" [[package]] name = "windows_aarch64_gnullvm" @@ -13504,9 +13669,9 @@ checksum = "17cffbe740121affb56fad0fc0e421804adf0ae00891205213b5cecd30db881d" [[package]] name = "windows_aarch64_msvc" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" [[package]] name = "windows_aarch64_msvc" @@ -13522,9 +13687,9 @@ checksum = "2564fde759adb79129d9b4f54be42b32c89970c18ebf93124ca8870a498688ed" [[package]] name = "windows_i686_gnu" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" [[package]] name = "windows_i686_gnu" @@ -13540,9 +13705,9 @@ checksum = "9cd9d32ba70453522332c14d38814bceeb747d80b3958676007acadd7e166956" [[package]] name = "windows_i686_msvc" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" [[package]] name = "windows_i686_msvc" @@ -13558,9 +13723,9 @@ checksum = "cfce6deae227ee8d356d19effc141a509cc503dfd1f850622ec4b0f84428e1f4" [[package]] name = "windows_x86_64_gnu" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" [[package]] name = "windows_x86_64_gnu" @@ -13570,9 +13735,9 @@ checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" [[package]] name = "windows_x86_64_gnullvm" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" [[package]] name = "windows_x86_64_gnullvm" @@ -13588,9 +13753,9 @@ checksum = "d19538ccc21819d01deaf88d6a17eae6596a12e9aafdbb97916fb49896d89de9" [[package]] name = "windows_x86_64_msvc" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" [[package]] name = "windows_x86_64_msvc" @@ -13600,9 +13765,9 @@ checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" [[package]] name = "winnow" -version = "0.4.1" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae8970b36c66498d8ff1d66685dc86b91b29db0c7739899012f63a63814b4b28" +checksum = "61de7bac303dc551fe038e2b3cef0f571087a47571ea6e79a87692ac99b99699" dependencies = [ "memchr", ] @@ -13663,7 +13828,7 @@ dependencies = [ "ring", "rusticata-macros", "thiserror", - "time 0.3.20", + "time 0.3.21", ] [[package]] @@ -13672,16 +13837,16 @@ version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e0ecbeb7b67ce215e40e3cc7f2ff902f94a223acf44995934763467e7b1febc8" dependencies = [ - "asn1-rs 0.5.1", + "asn1-rs 0.5.2", "base64 0.13.1", "data-encoding", - "der-parser 8.1.0", + "der-parser 8.2.0", "lazy_static", "nom", "oid-registry 0.6.1", "rusticata-macros", "thiserror", - "time 0.3.20", + "time 0.3.21", ] [[package]] @@ -13706,32 +13871,31 @@ checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" [[package]] name = "yasna" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aed2e7a52e3744ab4d0c05c20aa065258e84c49fd4226f5191b2ed29712710b4" +checksum = "e17bb3549cc1321ae1296b9cdc2698e2b6cb1992adfa19a8c72e5b7a738f44cd" dependencies = [ - "time 0.3.20", + "time 0.3.21", ] [[package]] name = "zeroize" -version = "1.5.7" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c394b5bd0c6f669e7275d9c20aa90ae064cb22e75a1cad54e1b34088034b149f" +checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" dependencies = [ "zeroize_derive", ] [[package]] name = "zeroize_derive" -version = "1.3.3" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44bf07cb3e50ea2003396695d58bf46bc9887a1f362260446fad6bc4e79bd36c" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", - "synstructure", + "syn 2.0.15", ] [[package]] @@ -13774,9 +13938,9 @@ dependencies = [ [[package]] name = "zstd-sys" -version = "2.0.7+zstd.1.5.4" +version = "2.0.8+zstd.1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94509c3ba2fe55294d752b79842c530ccfab760192521df74a081a78d2b3c7f5" +checksum = "5556e6ee25d32df2586c098bbfa278803692a20d0ab9565e049480d52707ec8c" dependencies = [ "cc", "libc", diff --git a/client/keystore/Cargo.toml b/client/keystore/Cargo.toml index 8766ee80157e9..81e047e90ab31 100644 --- a/client/keystore/Cargo.toml +++ b/client/keystore/Cargo.toml @@ -15,7 +15,6 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] array-bytes = "4.1" -async-trait = "0.1.57" parking_lot = "0.12.1" serde_json = "1.0.85" thiserror = "1.0" @@ -25,3 +24,11 @@ sp-keystore = { version = "0.13.0", path = "../../primitives/keystore" } [dev-dependencies] tempfile = "3.1.0" + +[features] +# This feature adds BLS crypto primitives. It should not be used in production since +# the BLS implementation and interface may still be subject to significant change. +bls-experimental = [ + "sp-core/bls-experimental", + "sp-keystore/bls-experimental", +] diff --git a/client/keystore/src/local.rs b/client/keystore/src/local.rs index 1e785113a4f03..4167e486ecf62 100644 --- a/client/keystore/src/local.rs +++ b/client/keystore/src/local.rs @@ -19,6 +19,8 @@ use parking_lot::RwLock; use sp_application_crypto::{AppCrypto, AppPair, IsWrappedBy}; +#[cfg(feature = "bls-experimental")] +use sp_core::{bls377, bls381}; use sp_core::{ crypto::{ByteArray, ExposeSecret, KeyTypeId, Pair as CorePair, SecretString, VrfSecret}, ecdsa, ed25519, sr25519, @@ -134,7 +136,7 @@ impl Keystore for LocalKeystore { /// Generate a new pair compatible with the 'ed25519' signature scheme. /// - /// If the `[seed]` is `Some` then the key will be ephemeral and stored in memory. + /// If `[seed]` is `Some` then the key will be ephemeral and stored in memory. fn sr25519_generate_new( &self, key_type: KeyTypeId, @@ -176,7 +178,7 @@ impl Keystore for LocalKeystore { /// Generate a new pair compatible with the 'sr25519' signature scheme. /// - /// If the `[seed]` is `Some` then the key will be ephemeral and stored in memory. + /// If `[seed]` is `Some` then the key will be ephemeral and stored in memory. fn ed25519_generate_new( &self, key_type: KeyTypeId, @@ -200,7 +202,7 @@ impl Keystore for LocalKeystore { /// Generate a new pair compatible with the 'ecdsa' signature scheme. /// - /// If the `[seed]` is `Some` then the key will be ephemeral and stored in memory. + /// If `[seed]` is `Some` then the key will be ephemeral and stored in memory. fn ecdsa_generate_new( &self, key_type: KeyTypeId, @@ -232,6 +234,60 @@ impl Keystore for LocalKeystore { Ok(sig) } + #[cfg(feature = "bls-experimental")] + fn bls381_public_keys(&self, key_type: KeyTypeId) -> Vec { + self.public_keys::(key_type) + } + + #[cfg(feature = "bls-experimental")] + /// Generate a new pair compatible with the 'bls381' signature scheme. + /// + /// If `[seed]` is `Some` then the key will be ephemeral and stored in memory. + fn bls381_generate_new( + &self, + key_type: KeyTypeId, + seed: Option<&str>, + ) -> std::result::Result { + self.generate_new::(key_type, seed) + } + + #[cfg(feature = "bls-experimental")] + fn bls381_sign( + &self, + key_type: KeyTypeId, + public: &bls381::Public, + msg: &[u8], + ) -> std::result::Result, TraitError> { + self.sign::(key_type, public, msg) + } + + #[cfg(feature = "bls-experimental")] + fn bls377_public_keys(&self, key_type: KeyTypeId) -> Vec { + self.public_keys::(key_type) + } + + #[cfg(feature = "bls-experimental")] + /// Generate a new pair compatible with the 'bls377' signature scheme. + /// + /// If `[seed]` is `Some` then the key will be ephemeral and stored in memory. + fn bls377_generate_new( + &self, + key_type: KeyTypeId, + seed: Option<&str>, + ) -> std::result::Result { + self.generate_new::(key_type, seed) + } + + #[cfg(feature = "bls-experimental")] + fn bls377_sign( + &self, + key_type: KeyTypeId, + public: &bls377::Public, + msg: &[u8], + ) -> std::result::Result, TraitError> { + self.sign::(key_type, public, msg) + } + fn insert( &self, key_type: KeyTypeId, diff --git a/primitives/application-crypto/src/bls377.rs b/primitives/application-crypto/src/bls377.rs new file mode 100644 index 0000000000000..7fbbec5466058 --- /dev/null +++ b/primitives/application-crypto/src/bls377.rs @@ -0,0 +1,28 @@ +// This file is part of Substrate. + +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! BLS12-377 crypto applications. + +pub use sp_core::bls::bls377::*; + +mod app { + crate::app_crypto!(super, sp_core::testing::BLS377); +} + +#[cfg(feature = "full_crypto")] +pub use app::Pair as AppPair; +pub use app::{Public as AppPublic, Signature as AppSignature}; diff --git a/primitives/application-crypto/src/bls381.rs b/primitives/application-crypto/src/bls381.rs new file mode 100644 index 0000000000000..d990f2e14c8e6 --- /dev/null +++ b/primitives/application-crypto/src/bls381.rs @@ -0,0 +1,28 @@ +// This file is part of Substrate. + +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! BLS12-381 crypto applications. + +pub use sp_core::bls::bls381::*; + +mod app { + crate::app_crypto!(super, sp_core::testing::BLS381); +} + +#[cfg(feature = "full_crypto")] +pub use app::Pair as AppPair; +pub use app::{Public as AppPublic, Signature as AppSignature}; diff --git a/primitives/application-crypto/src/lib.rs b/primitives/application-crypto/src/lib.rs index fa92e427aa711..3e8f2f5a77b3a 100644 --- a/primitives/application-crypto/src/lib.rs +++ b/primitives/application-crypto/src/lib.rs @@ -41,6 +41,10 @@ pub use serde; #[doc(hidden)] pub use sp_std::{ops::Deref, vec::Vec}; +#[cfg(feature = "bls-experimental")] +pub mod bls377; +#[cfg(feature = "bls-experimental")] +pub mod bls381; pub mod ecdsa; pub mod ed25519; pub mod sr25519; diff --git a/primitives/core/Cargo.toml b/primitives/core/Cargo.toml index 8eac0996760e3..0c203a03d904d 100644 --- a/primitives/core/Cargo.toml +++ b/primitives/core/Cargo.toml @@ -52,6 +52,8 @@ secp256k1 = { version = "0.24.0", default-features = false, features = ["recover ss58-registry = { version = "1.34.0", default-features = false } sp-core-hashing = { version = "5.0.0", path = "./hashing", default-features = false, optional = true } sp-runtime-interface = { version = "7.0.0", default-features = false, path = "../runtime-interface" } +# bls crypto +w3f-bls = { version = "0.1.3", default-features = false, optional = true} [dev-dependencies] sp-serializer = { version = "4.0.0-dev", path = "../serializer" } @@ -59,6 +61,7 @@ rand = "0.8.5" criterion = "0.4.0" serde_json = "1.0" sp-core-hashing-proc-macro = { version = "5.0.0", path = "./hashing/proc-macro" } +hex-literal = "0.3.4" [[bench]] name = "bench" @@ -125,3 +128,7 @@ full_crypto = [ "sp-core-hashing", "sp-runtime-interface/disable_target_static_assertions", ] + +# This feature adds BLS crypto primitives. It should not be used in production since +# the BLS implementation and interface may still be subject to significant change. +bls-experimental = ["w3f-bls"] diff --git a/primitives/core/src/bls.rs b/primitives/core/src/bls.rs new file mode 100644 index 0000000000000..86db4525fb8ae --- /dev/null +++ b/primitives/core/src/bls.rs @@ -0,0 +1,675 @@ +// This file is part of Substrate. + +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! Simple BLS (Boneh–Lynn–Shacham) Signature API. + +#[cfg(feature = "std")] +use crate::crypto::Ss58Codec; +use crate::crypto::{ByteArray, CryptoType, Derive, Public as TraitPublic, UncheckedFrom}; +#[cfg(feature = "full_crypto")] +use crate::crypto::{DeriveError, DeriveJunction, Pair as TraitPair, SecretStringError}; + +#[cfg(feature = "full_crypto")] +use sp_std::vec::Vec; + +use codec::{Decode, Encode, MaxEncodedLen}; +use scale_info::TypeInfo; +#[cfg(feature = "std")] +use serde::{de, Deserialize, Deserializer, Serialize, Serializer}; +use w3f_bls::{DoublePublicKey, DoubleSignature, EngineBLS, SerializableToBytes, TinyBLS381}; +#[cfg(feature = "full_crypto")] +use w3f_bls::{DoublePublicKeyScheme, Keypair, Message, SecretKey}; + +use sp_runtime_interface::pass_by::PassByInner; +use sp_std::{convert::TryFrom, marker::PhantomData, ops::Deref}; + +/// BLS-377 specialized types +pub mod bls377 { + use crate::crypto::CryptoTypeId; + use w3f_bls::TinyBLS377; + + /// An identifier used to match public keys against BLS12-377 keys + pub const CRYPTO_ID: CryptoTypeId = CryptoTypeId(*b"bls7"); + + /// BLS12-377 key pair. + #[cfg(feature = "full_crypto")] + pub type Pair = super::Pair; + /// BLS12-377 public key. + pub type Public = super::Public; + /// BLS12-377 signature. + pub type Signature = super::Signature; + + impl super::HardJunctionId for TinyBLS377 { + const ID: &'static str = "BLS12377HDKD"; + } +} + +/// BLS-381 specialized types +pub mod bls381 { + use crate::crypto::CryptoTypeId; + use w3f_bls::TinyBLS381; + + /// An identifier used to match public keys against BLS12-381 keys + pub const CRYPTO_ID: CryptoTypeId = CryptoTypeId(*b"bls8"); + + /// BLS12-381 key pair. + #[cfg(feature = "full_crypto")] + pub type Pair = super::Pair; + /// BLS12-381 public key. + pub type Public = super::Public; + /// BLS12-381 signature. + pub type Signature = super::Signature; + + impl super::HardJunctionId for TinyBLS381 { + const ID: &'static str = "BLS12381HDKD"; + } +} + +trait BlsBound: EngineBLS + HardJunctionId + Send + Sync + 'static {} + +impl BlsBound for T {} + +// Secret key serialized size +#[cfg(feature = "full_crypto")] +const SECRET_KEY_SERIALIZED_SIZE: usize = + as SerializableToBytes>::SERIALIZED_BYTES_SIZE; + +// Public key serialized size +const PUBLIC_KEY_SERIALIZED_SIZE: usize = + as SerializableToBytes>::SERIALIZED_BYTES_SIZE; + +// Signature serialized size +const SIGNATURE_SERIALIZED_SIZE: usize = + as SerializableToBytes>::SERIALIZED_BYTES_SIZE; + +/// A secret seed. +/// +/// It's not called a "secret key" because ring doesn't expose the secret keys +/// of the key pair (yeah, dumb); as such we're forced to remember the seed manually if we +/// will need it later (such as for HDKD). +#[cfg(feature = "full_crypto")] +type Seed = [u8; SECRET_KEY_SERIALIZED_SIZE]; + +/// A public key. +#[derive(Copy, Encode, Decode, MaxEncodedLen, TypeInfo)] +#[scale_info(skip_type_params(T))] +pub struct Public { + inner: [u8; PUBLIC_KEY_SERIALIZED_SIZE], + _phantom: PhantomData T>, +} + +impl Clone for Public { + fn clone(&self) -> Self { + Self { inner: self.inner, _phantom: PhantomData } + } +} + +impl PartialEq for Public { + fn eq(&self, other: &Self) -> bool { + self.inner == other.inner + } +} + +impl Eq for Public {} + +impl PartialOrd for Public { + fn partial_cmp(&self, other: &Self) -> Option { + self.inner.partial_cmp(&other.inner) + } +} + +impl Ord for Public { + fn cmp(&self, other: &Self) -> sp_std::cmp::Ordering { + self.inner.cmp(&other.inner) + } +} + +#[cfg(feature = "full_crypto")] +impl sp_std::hash::Hash for Public { + fn hash(&self, state: &mut H) { + self.inner.hash(state) + } +} + +impl ByteArray for Public { + const LEN: usize = PUBLIC_KEY_SERIALIZED_SIZE; +} + +impl PassByInner for Public { + type Inner = [u8; PUBLIC_KEY_SERIALIZED_SIZE]; + + fn into_inner(self) -> Self::Inner { + self.inner + } + + fn inner(&self) -> &Self::Inner { + &self.inner + } + + fn from_inner(inner: Self::Inner) -> Self { + Self { inner, _phantom: PhantomData } + } +} + +impl AsRef<[u8; PUBLIC_KEY_SERIALIZED_SIZE]> for Public { + fn as_ref(&self) -> &[u8; PUBLIC_KEY_SERIALIZED_SIZE] { + &self.inner + } +} + +impl AsRef<[u8]> for Public { + fn as_ref(&self) -> &[u8] { + &self.inner[..] + } +} + +impl AsMut<[u8]> for Public { + fn as_mut(&mut self) -> &mut [u8] { + &mut self.inner[..] + } +} + +impl Deref for Public { + type Target = [u8]; + + fn deref(&self) -> &Self::Target { + &self.inner + } +} + +impl TryFrom<&[u8]> for Public { + type Error = (); + + fn try_from(data: &[u8]) -> Result { + if data.len() != PUBLIC_KEY_SERIALIZED_SIZE { + return Err(()) + } + let mut r = [0u8; PUBLIC_KEY_SERIALIZED_SIZE]; + r.copy_from_slice(data); + Ok(Self::unchecked_from(r)) + } +} + +impl From> for [u8; PUBLIC_KEY_SERIALIZED_SIZE] { + fn from(x: Public) -> Self { + x.inner + } +} + +#[cfg(feature = "full_crypto")] +impl From> for Public { + fn from(x: Pair) -> Self { + x.public() + } +} + +impl UncheckedFrom<[u8; PUBLIC_KEY_SERIALIZED_SIZE]> for Public { + fn unchecked_from(data: [u8; PUBLIC_KEY_SERIALIZED_SIZE]) -> Self { + Public { inner: data, _phantom: PhantomData } + } +} + +#[cfg(feature = "std")] +impl std::str::FromStr for Public { + type Err = crate::crypto::PublicError; + + fn from_str(s: &str) -> Result { + Self::from_ss58check(s) + } +} + +#[cfg(feature = "std")] +impl std::fmt::Display for Public { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + write!(f, "{}", self.to_ss58check()) + } +} + +#[cfg(feature = "std")] +impl sp_std::fmt::Debug for Public { + fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { + let s = self.to_ss58check(); + write!(f, "{} ({}...)", crate::hexdisplay::HexDisplay::from(&self.inner), &s[0..8]) + } +} + +#[cfg(not(feature = "std"))] +impl sp_std::fmt::Debug for Public { + fn fmt(&self, _: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { + Ok(()) + } +} + +#[cfg(feature = "std")] +impl Serialize for Public { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_str(&self.to_ss58check()) + } +} + +#[cfg(feature = "std")] +impl<'de, T: BlsBound> Deserialize<'de> for Public { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + Public::from_ss58check(&String::deserialize(deserializer)?) + .map_err(|e| de::Error::custom(format!("{:?}", e))) + } +} + +impl TraitPublic for Public {} + +impl Derive for Public {} + +impl CryptoType for Public { + #[cfg(feature = "full_crypto")] + type Pair = Pair; +} + +/// A generic BLS signature. +#[derive(Copy, Encode, Decode, MaxEncodedLen, TypeInfo)] +#[scale_info(skip_type_params(T))] +pub struct Signature { + inner: [u8; SIGNATURE_SERIALIZED_SIZE], + _phantom: PhantomData T>, +} + +impl Clone for Signature { + fn clone(&self) -> Self { + Self { inner: self.inner, _phantom: PhantomData } + } +} + +impl PartialEq for Signature { + fn eq(&self, other: &Self) -> bool { + self.inner == other.inner + } +} + +impl Eq for Signature {} + +#[cfg(feature = "full_crypto")] +impl sp_std::hash::Hash for Signature { + fn hash(&self, state: &mut H) { + self.inner.hash(state) + } +} + +impl TryFrom<&[u8]> for Signature { + type Error = (); + + fn try_from(data: &[u8]) -> Result { + if data.len() != SIGNATURE_SERIALIZED_SIZE { + return Err(()) + } + let mut inner = [0u8; SIGNATURE_SERIALIZED_SIZE]; + inner.copy_from_slice(data); + Ok(Signature::unchecked_from(inner)) + } +} + +#[cfg(feature = "std")] +impl Serialize for Signature { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_str(&array_bytes::bytes2hex("", self.as_ref())) + } +} + +#[cfg(feature = "std")] +impl<'de, T> Deserialize<'de> for Signature { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let signature_hex = array_bytes::hex2bytes(&String::deserialize(deserializer)?) + .map_err(|e| de::Error::custom(format!("{:?}", e)))?; + Signature::try_from(signature_hex.as_ref()) + .map_err(|e| de::Error::custom(format!("{:?}", e))) + } +} + +impl From> for [u8; SIGNATURE_SERIALIZED_SIZE] { + fn from(signature: Signature) -> [u8; SIGNATURE_SERIALIZED_SIZE] { + signature.inner + } +} + +impl AsRef<[u8; SIGNATURE_SERIALIZED_SIZE]> for Signature { + fn as_ref(&self) -> &[u8; SIGNATURE_SERIALIZED_SIZE] { + &self.inner + } +} + +impl AsRef<[u8]> for Signature { + fn as_ref(&self) -> &[u8] { + &self.inner[..] + } +} + +impl AsMut<[u8]> for Signature { + fn as_mut(&mut self) -> &mut [u8] { + &mut self.inner[..] + } +} + +impl sp_std::fmt::Debug for Signature { + #[cfg(feature = "std")] + fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { + write!(f, "{}", crate::hexdisplay::HexDisplay::from(&self.inner)) + } + + #[cfg(not(feature = "std"))] + fn fmt(&self, _: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { + Ok(()) + } +} + +impl UncheckedFrom<[u8; SIGNATURE_SERIALIZED_SIZE]> for Signature { + fn unchecked_from(data: [u8; SIGNATURE_SERIALIZED_SIZE]) -> Self { + Signature { inner: data, _phantom: PhantomData } + } +} + +impl CryptoType for Signature { + #[cfg(feature = "full_crypto")] + type Pair = Pair; +} + +/// A key pair. +#[cfg(feature = "full_crypto")] +pub struct Pair(Keypair); + +#[cfg(feature = "full_crypto")] +impl Clone for Pair { + fn clone(&self) -> Self { + Pair(self.0.clone()) + } +} + +trait HardJunctionId { + const ID: &'static str; +} + +/// Derive a single hard junction. +#[cfg(feature = "full_crypto")] +fn derive_hard_junction(secret_seed: &Seed, cc: &[u8; 32]) -> Seed { + (T::ID, secret_seed, cc).using_encoded(sp_core_hashing::blake2_256) +} + +#[cfg(feature = "full_crypto")] +impl Pair {} + +#[cfg(feature = "full_crypto")] +impl TraitPair for Pair { + type Seed = Seed; + type Public = Public; + type Signature = Signature; + + fn from_seed_slice(seed_slice: &[u8]) -> Result { + if seed_slice.len() != SECRET_KEY_SERIALIZED_SIZE { + return Err(SecretStringError::InvalidSeedLength) + } + let secret = w3f_bls::SecretKey::from_seed(seed_slice); + let public = secret.into_public(); + Ok(Pair(w3f_bls::Keypair { secret, public })) + } + + fn derive>( + &self, + path: Iter, + _seed: Option, + ) -> Result<(Self, Option), DeriveError> { + let mut acc: [u8; SECRET_KEY_SERIALIZED_SIZE] = + self.0.secret.to_bytes().try_into().expect( + "Secret key serializer returns a vector of SECRET_KEY_SERIALIZED_SIZE size", + ); + for j in path { + match j { + DeriveJunction::Soft(_cc) => return Err(DeriveError::SoftKeyInPath), + DeriveJunction::Hard(cc) => acc = derive_hard_junction::(&acc, &cc), + } + } + Ok((Self::from_seed(&acc), Some(acc))) + } + + fn public(&self) -> Self::Public { + let mut raw = [0u8; PUBLIC_KEY_SERIALIZED_SIZE]; + let pk = DoublePublicKeyScheme::into_double_public_key(&self.0).to_bytes(); + raw.copy_from_slice(pk.as_slice()); + Self::Public::unchecked_from(raw) + } + + fn sign(&self, message: &[u8]) -> Self::Signature { + let mut mutable_self = self.clone(); + let r: [u8; SIGNATURE_SERIALIZED_SIZE] = + DoublePublicKeyScheme::sign(&mut mutable_self.0, &Message::new(b"", message)) + .to_bytes() + .try_into() + .expect("Signature serializer returns vectors of SIGNATURE_SERIALIZED_SIZE size"); + Self::Signature::unchecked_from(r) + } + + fn verify>(sig: &Self::Signature, message: M, pubkey: &Self::Public) -> bool { + let pubkey_array: [u8; PUBLIC_KEY_SERIALIZED_SIZE] = + match <[u8; PUBLIC_KEY_SERIALIZED_SIZE]>::try_from(pubkey.as_ref()) { + Ok(pk) => pk, + Err(_) => return false, + }; + let public_key = match w3f_bls::double::DoublePublicKey::::from_bytes(&pubkey_array) { + Ok(pk) => pk, + Err(_) => return false, + }; + + let sig_array = match sig.inner[..].try_into() { + Ok(s) => s, + Err(_) => return false, + }; + let sig = match w3f_bls::double::DoubleSignature::from_bytes(sig_array) { + Ok(s) => s, + Err(_) => return false, + }; + + sig.verify(&Message::new(b"", message.as_ref()), &public_key) + } + + /// Get the seed for this key. + fn to_raw_vec(&self) -> Vec { + self.0 + .secret + .to_bytes() + .try_into() + .expect("Secret key serializer returns a vector of SECRET_KEY_SERIALIZED_SIZE size") + } +} + +#[cfg(feature = "full_crypto")] +impl CryptoType for Pair { + type Pair = Pair; +} + +// Test set exercising the BLS12-377 implementation +#[cfg(test)] +mod test { + use super::*; + use crate::crypto::DEV_PHRASE; + use bls377::{Pair, Signature}; + use hex_literal::hex; + + #[test] + fn default_phrase_should_be_used() { + assert_eq!( + Pair::from_string("//Alice///password", None).unwrap().public(), + Pair::from_string(&format!("{}//Alice", DEV_PHRASE), Some("password")) + .unwrap() + .public(), + ); + } + + // Only passes if the seed = (seed mod ScalarField) + #[test] + fn seed_and_derive_should_work() { + let seed = hex!("9d61b19deffd5a60ba844af492ec2cc44449c5697b326919703bac031cae7f00"); + let pair = Pair::from_seed(&seed); + // we are using hash to field so this is not going to work + // assert_eq!(pair.seed(), seed); + let path = vec![DeriveJunction::Hard([0u8; 32])]; + let derived = pair.derive(path.into_iter(), None).ok().unwrap().0; + assert_eq!( + derived.to_raw_vec(), + hex!("a4f2269333b3e87c577aa00c4a2cd650b3b30b2e8c286a47c251279ff3a26e0d") + ); + } + + #[test] + fn test_vector_should_work() { + let pair = Pair::from_seed(&hex!( + "9d61b19deffd5a60ba844af492ec2cc44449c5697b326919703bac031cae7f60" + )); + let public = pair.public(); + assert_eq!( + public, + Public::unchecked_from(hex!( + "7a84ca8ce4c37c93c95ecee6a3c0c9a7b9c225093cf2f12dc4f69cbfb847ef9424a18f5755d5a742247d386ff2aabb806bcf160eff31293ea9616976628f77266c8a8cc1d8753be04197bd6cdd8c5c87a148f782c4c1568d599b48833fd539001e580cff64bbc71850605433fcd051f3afc3b74819786f815ffb5272030a8d03e5df61e6183f8fd8ea85f26defa83400" + )) + ); + let message = b""; + let signature = + hex!("d1e3013161991e142d8751017d4996209c2ff8a9ee160f373733eda3b4b785ba6edce9f45f87104bbe07aa6aa6eb2780aa705efb2c13d3b317d6409d159d23bdc7cdd5c2a832d1551cf49d811d49c901495e527dbd532e3a462335ce2686009104aba7bc11c5b22be78f3198d2727a0b" + ); + let signature = Signature::unchecked_from(signature); + assert!(pair.sign(&message[..]) == signature); + assert!(Pair::verify(&signature, &message[..], &public)); + } + + #[test] + fn test_vector_by_string_should_work() { + let pair = Pair::from_string( + "0x9d61b19deffd5a60ba844af492ec2cc44449c5697b326919703bac031cae7f60", + None, + ) + .unwrap(); + let public = pair.public(); + assert_eq!( + public, + Public::unchecked_from(hex!( + "6dc6be608fab3c6bd894a606be86db346cc170db85c733853a371f3db54ae1b12052c0888d472760c81b537572a26f00db865e5963aef8634f9917571c51b538b564b2a9ceda938c8b930969ee3b832448e08e33a79e9ddd28af419a3ce45300f5dbc768b067781f44f3fe05a19e6b07b1c4196151ec3f8ea37e4f89a8963030d2101e931276bb9ebe1f20102239d780" + )) + ); + let message = b""; + let signature = + hex!("bbb395bbdee1a35930912034f5fde3b36df2835a0536c865501b0675776a1d5931a3bea2e66eff73b2546c6af2061a8019223e4ebbbed661b2538e0f5823f2c708eb89c406beca8fcb53a5c13dbc7c0c42e4cf2be2942bba96ea29297915a06bd2b1b979c0e2ac8fd4ec684a6b5d110c" + ); + let expected_signature = Signature::unchecked_from(signature); + println!("signature is {:?}", pair.sign(&message[..])); + let signature = pair.sign(&message[..]); + assert!(signature == expected_signature); + assert!(Pair::verify(&signature, &message[..], &public)); + } + #[test] + fn generated_pair_should_work() { + let (pair, _) = Pair::generate(); + let public = pair.public(); + let message = b"Something important"; + let signature = pair.sign(&message[..]); + assert!(Pair::verify(&signature, &message[..], &public)); + assert!(!Pair::verify(&signature, b"Something else", &public)); + } + + #[test] + fn seeded_pair_should_work() { + let pair = Pair::from_seed(b"12345678901234567890123456789012"); + let public = pair.public(); + assert_eq!( + public, + Public::unchecked_from( + hex!( + "754d2f2bbfa67df54d7e0e951979a18a1e0f45948857752cc2bac6bbb0b1d05e8e48bcc453920bf0c4bbd5993212480112a1fb433f04d74af0a8b700d93dc957ab3207f8d071e948f5aca1a7632c00bdf6d06be05b43e2e6216dccc8a5d55a0071cb2313cfd60b7e9114619cd17c06843b352f0b607a99122f6651df8f02e1ad3697bd208e62af047ddd7b942ba80080") + ) + ); + let message = + hex!("2f8c6129d816cf51c374bc7f08c3e63ed156cf78aefb4a6550d97b87997977ee00000000000000000200d75a980182b10ab7d54bfed3c964073a0ee172f3daa62325af021a68f707511a4500000000000000" + ); + let signature = pair.sign(&message[..]); + println!("Correct signature: {:?}", signature); + assert!(Pair::verify(&signature, &message[..], &public)); + assert!(!Pair::verify(&signature, "Other message", &public)); + } + + #[test] + fn generate_with_phrase_recovery_possible() { + let (pair1, phrase, _) = Pair::generate_with_phrase(None); + let (pair2, _) = Pair::from_phrase(&phrase, None).unwrap(); + + assert_eq!(pair1.public(), pair2.public()); + } + + #[test] + fn generate_with_password_phrase_recovery_possible() { + let (pair1, phrase, _) = Pair::generate_with_phrase(Some("password")); + let (pair2, _) = Pair::from_phrase(&phrase, Some("password")).unwrap(); + + assert_eq!(pair1.public(), pair2.public()); + } + + #[test] + fn password_does_something() { + let (pair1, phrase, _) = Pair::generate_with_phrase(Some("password")); + let (pair2, _) = Pair::from_phrase(&phrase, None).unwrap(); + + assert_ne!(pair1.public(), pair2.public()); + } + + #[test] + fn ss58check_roundtrip_works() { + let pair = Pair::from_seed(b"12345678901234567890123456789012"); + let public = pair.public(); + let s = public.to_ss58check(); + println!("Correct: {}", s); + let cmp = Public::from_ss58check(&s).unwrap(); + assert_eq!(cmp, public); + } + + #[test] + fn signature_serialization_works() { + let pair = Pair::from_seed(b"12345678901234567890123456789012"); + let message = b"Something important"; + let signature = pair.sign(&message[..]); + let serialized_signature = serde_json::to_string(&signature).unwrap(); + // Signature is 112 bytes, hexify * 2, so 224 chars + 2 quote chars + assert_eq!(serialized_signature.len(), 226); + let signature = serde_json::from_str(&serialized_signature).unwrap(); + assert!(Pair::verify(&signature, &message[..], &pair.public())); + } + + #[test] + fn signature_serialization_doesnt_panic() { + fn deserialize_signature(text: &str) -> Result { + serde_json::from_str(text) + } + assert!(deserialize_signature("Not valid json.").is_err()); + assert!(deserialize_signature("\"Not an actual signature.\"").is_err()); + // Poorly-sized + assert!(deserialize_signature("\"abc123\"").is_err()); + } +} diff --git a/primitives/core/src/hexdisplay.rs b/primitives/core/src/hexdisplay.rs index 9f35e5ec7725f..30e045dfc52ac 100644 --- a/primitives/core/src/hexdisplay.rs +++ b/primitives/core/src/hexdisplay.rs @@ -96,7 +96,7 @@ macro_rules! impl_non_endians { impl_non_endians!( [u8; 1], [u8; 2], [u8; 3], [u8; 4], [u8; 5], [u8; 6], [u8; 7], [u8; 8], [u8; 10], [u8; 12], [u8; 14], [u8; 16], [u8; 20], [u8; 24], [u8; 28], [u8; 32], [u8; 40], [u8; 48], [u8; 56], - [u8; 64], [u8; 65], [u8; 80], [u8; 96], [u8; 112], [u8; 128] + [u8; 64], [u8; 65], [u8; 80], [u8; 96], [u8; 112], [u8; 128], [u8; 144] ); /// Format into ASCII + # + hex, suitable for storage key preimages. diff --git a/primitives/core/src/lib.rs b/primitives/core/src/lib.rs index 04f44631cb21c..f9541b02e2903 100644 --- a/primitives/core/src/lib.rs +++ b/primitives/core/src/lib.rs @@ -55,6 +55,8 @@ pub mod crypto; pub mod hexdisplay; pub use paste; +#[cfg(feature = "bls-experimental")] +pub mod bls; pub mod defer; pub mod ecdsa; pub mod ed25519; @@ -68,6 +70,9 @@ pub mod testing; pub mod traits; pub mod uint; +#[cfg(feature = "bls-experimental")] +pub use bls::{bls377, bls381}; + pub use self::{ hash::{convert_hash, H160, H256, H512}, uint::{U256, U512}, diff --git a/primitives/core/src/testing.rs b/primitives/core/src/testing.rs index 756275aed6f41..6faf4ffa3042a 100644 --- a/primitives/core/src/testing.rs +++ b/primitives/core/src/testing.rs @@ -25,6 +25,10 @@ pub const ED25519: KeyTypeId = KeyTypeId(*b"ed25"); pub const SR25519: KeyTypeId = KeyTypeId(*b"sr25"); /// Key type for generic ECDSA key. pub const ECDSA: KeyTypeId = KeyTypeId(*b"ecds"); +/// Key type for generic BLS12-377 key. +pub const BLS377: KeyTypeId = KeyTypeId(*b"bls7"); +/// Key type for generic BLS12-381 key. +pub const BLS381: KeyTypeId = KeyTypeId(*b"bls8"); /// Macro for exporting functions from wasm in with the expected signature for using it with the /// wasm executor. This is useful for tests where you need to call a function in wasm. diff --git a/primitives/keystore/Cargo.toml b/primitives/keystore/Cargo.toml index 6b0194247219a..a749b95a483b1 100644 --- a/primitives/keystore/Cargo.toml +++ b/primitives/keystore/Cargo.toml @@ -33,3 +33,7 @@ std = [ "sp-core/std", "sp-externalities/std", ] + +# This feature adds BLS crypto primitives. It should not be used in production since +# the BLS implementation and interface may still be subject to significant change. +bls-experimental = ["sp-core/bls-experimental"] diff --git a/primitives/keystore/src/lib.rs b/primitives/keystore/src/lib.rs index d6165088f6b46..1d2a27cb8726c 100644 --- a/primitives/keystore/src/lib.rs +++ b/primitives/keystore/src/lib.rs @@ -19,10 +19,13 @@ pub mod testing; +#[cfg(feature = "bls-experimental")] +use sp_core::{bls377, bls381}; use sp_core::{ crypto::{ByteArray, CryptoTypeId, KeyTypeId}, ecdsa, ed25519, sr25519, }; + use std::sync::Arc; /// Keystore error @@ -171,6 +174,68 @@ pub trait Keystore: Send + Sync { msg: &[u8; 32], ) -> Result, Error>; + #[cfg(feature = "bls-experimental")] + /// Returns all bls12-381 public keys for the given key type. + fn bls381_public_keys(&self, id: KeyTypeId) -> Vec; + + #[cfg(feature = "bls-experimental")] + /// Returns all bls12-377 public keys for the given key type. + fn bls377_public_keys(&self, id: KeyTypeId) -> Vec; + + #[cfg(feature = "bls-experimental")] + /// Generate a new bls381 key pair for the given key type and an optional seed. + /// + /// Returns an `bls381::Public` key of the generated key pair or an `Err` if + /// something failed during key generation. + fn bls381_generate_new( + &self, + key_type: KeyTypeId, + seed: Option<&str>, + ) -> Result; + + #[cfg(feature = "bls-experimental")] + /// Generate a new bls377 key pair for the given key type and an optional seed. + /// + /// Returns an `bls377::Public` key of the generated key pair or an `Err` if + /// something failed during key generation. + fn bls377_generate_new( + &self, + key_type: KeyTypeId, + seed: Option<&str>, + ) -> Result; + + #[cfg(feature = "bls-experimental")] + /// Generate a bls381 signature for a given message. + /// + /// Receives [`KeyTypeId`] and a [`bls381::Public`] key to be able to map + /// them to a private key that exists in the keystore. + /// + /// Returns an [`bls381::Signature`] or `None` in case the given `key_type` + /// and `public` combination doesn't exist in the keystore. + /// An `Err` will be returned if generating the signature itself failed. + fn bls381_sign( + &self, + key_type: KeyTypeId, + public: &bls381::Public, + msg: &[u8], + ) -> Result, Error>; + + #[cfg(feature = "bls-experimental")] + /// Generate a bls377 signature for a given message. + /// + /// Receives [`KeyTypeId`] and a [`bls377::Public`] key to be able to map + /// them to a private key that exists in the keystore. + /// + /// Returns an [`bls377::Signature`] or `None` in case the given `key_type` + /// and `public` combination doesn't exist in the keystore. + /// An `Err` will be returned if generating the signature itself failed. + fn bls377_sign( + &self, + key_type: KeyTypeId, + public: &bls377::Public, + msg: &[u8], + ) -> Result, Error>; + /// Insert a new secret key. fn insert(&self, key_type: KeyTypeId, suri: &str, public: &[u8]) -> Result<(), ()>; @@ -189,7 +254,13 @@ pub trait Keystore: Send + Sync { /// /// The message is signed using the cryptographic primitive specified by `crypto_id`. /// - /// Schemes supported by the default trait implementation: sr25519, ed25519 and ecdsa. + /// Schemes supported by the default trait implementation: + /// - sr25519 + /// - ed25519 + /// - ecdsa + /// - bls381 + /// - bls377 + /// /// To support more schemes you can overwrite this method. /// /// Returns the SCALE encoded signature if key is found and supported, `None` if the key doesn't @@ -217,8 +288,21 @@ pub trait Keystore: Send + Sync { ecdsa::CRYPTO_ID => { let public = ecdsa::Public::from_slice(public) .map_err(|_| Error::ValidationError("Invalid public key format".into()))?; + self.ecdsa_sign(id, &public, msg)?.map(|s| s.encode()) }, + #[cfg(feature = "bls-experimental")] + bls381::CRYPTO_ID => { + let public = bls381::Public::from_slice(public) + .map_err(|_| Error::ValidationError("Invalid public key format".into()))?; + self.bls381_sign(id, &public, msg)?.map(|s| s.encode()) + }, + #[cfg(feature = "bls-experimental")] + bls377::CRYPTO_ID => { + let public = bls377::Public::from_slice(public) + .map_err(|_| Error::ValidationError("Invalid public key format".into()))?; + self.bls377_sign(id, &public, msg)?.map(|s| s.encode()) + }, _ => return Err(Error::KeyNotSupported(id)), }; Ok(signature) diff --git a/primitives/keystore/src/testing.rs b/primitives/keystore/src/testing.rs index dd3254e9371c4..e18931a7af883 100644 --- a/primitives/keystore/src/testing.rs +++ b/primitives/keystore/src/testing.rs @@ -19,6 +19,8 @@ use crate::{Error, Keystore, KeystorePtr}; +#[cfg(feature = "bls-experimental")] +use sp_core::{bls377, bls381}; use sp_core::{ crypto::{ByteArray, KeyTypeId, Pair, VrfSecret}, ecdsa, ed25519, sr25519, @@ -212,6 +214,54 @@ impl Keystore for MemoryKeystore { Ok(sig) } + #[cfg(feature = "bls-experimental")] + fn bls381_public_keys(&self, key_type: KeyTypeId) -> Vec { + self.public_keys::(key_type) + } + + #[cfg(feature = "bls-experimental")] + fn bls381_generate_new( + &self, + key_type: KeyTypeId, + seed: Option<&str>, + ) -> Result { + self.generate_new::(key_type, seed) + } + + #[cfg(feature = "bls-experimental")] + fn bls381_sign( + &self, + key_type: KeyTypeId, + public: &bls381::Public, + msg: &[u8], + ) -> Result, Error> { + self.sign::(key_type, public, msg) + } + + #[cfg(feature = "bls-experimental")] + fn bls377_public_keys(&self, key_type: KeyTypeId) -> Vec { + self.public_keys::(key_type) + } + + #[cfg(feature = "bls-experimental")] + fn bls377_generate_new( + &self, + key_type: KeyTypeId, + seed: Option<&str>, + ) -> Result { + self.generate_new::(key_type, seed) + } + + #[cfg(feature = "bls-experimental")] + fn bls377_sign( + &self, + key_type: KeyTypeId, + public: &bls377::Public, + msg: &[u8], + ) -> Result, Error> { + self.sign::(key_type, public, msg) + } + fn insert(&self, key_type: KeyTypeId, suri: &str, public: &[u8]) -> Result<(), ()> { self.keys .write() From 725208a5b87ae8388f3a9fa6590301c93a8a5c69 Mon Sep 17 00:00:00 2001 From: Koute Date: Wed, 10 May 2023 18:39:43 +0900 Subject: [PATCH 12/17] Remove the `Copy` bound on `CollectionId` in the uniques pallet (#14111) * Remove the `Copy` bound on `CollectionId` in the uniques pallet * Also add `clone`s in benchmarks --- frame/uniques/src/benchmarking.rs | 106 ++++++++++++------------- frame/uniques/src/functions.rs | 17 ++-- frame/uniques/src/impl_nonfungibles.rs | 14 ++-- frame/uniques/src/lib.rs | 44 +++++----- 4 files changed, 96 insertions(+), 85 deletions(-) diff --git a/frame/uniques/src/benchmarking.rs b/frame/uniques/src/benchmarking.rs index 6d17951428bf9..4e63f69281e5d 100644 --- a/frame/uniques/src/benchmarking.rs +++ b/frame/uniques/src/benchmarking.rs @@ -44,7 +44,7 @@ fn create_collection, I: 'static>( T::Currency::make_free_balance_be(&caller, DepositBalanceOf::::max_value()); assert!(Uniques::::force_create( SystemOrigin::Root.into(), - collection, + collection.clone(), caller_lookup.clone(), false, ) @@ -173,26 +173,26 @@ benchmarks_instance_pallet! { for i in 0..a { add_item_attribute::(T::Helper::item(i as u16)); } - let witness = Collection::::get(collection).unwrap().destroy_witness(); - }: _(SystemOrigin::Signed(caller), collection, witness) + let witness = Collection::::get(collection.clone()).unwrap().destroy_witness(); + }: _(SystemOrigin::Signed(caller), collection.clone(), witness) verify { - assert_last_event::(Event::Destroyed { collection }.into()); + assert_last_event::(Event::Destroyed { collection: collection.clone() }.into()); } mint { let (collection, caller, caller_lookup) = create_collection::(); let item = T::Helper::item(0); - }: _(SystemOrigin::Signed(caller.clone()), collection, item, caller_lookup) + }: _(SystemOrigin::Signed(caller.clone()), collection.clone(), item, caller_lookup) verify { - assert_last_event::(Event::Issued { collection, item, owner: caller }.into()); + assert_last_event::(Event::Issued { collection: collection.clone(), item, owner: caller }.into()); } burn { let (collection, caller, caller_lookup) = create_collection::(); let (item, ..) = mint_item::(0); - }: _(SystemOrigin::Signed(caller.clone()), collection, item, Some(caller_lookup)) + }: _(SystemOrigin::Signed(caller.clone()), collection.clone(), item, Some(caller_lookup)) verify { - assert_last_event::(Event::Burned { collection, item, owner: caller }.into()); + assert_last_event::(Event::Burned { collection: collection.clone(), item, owner: caller }.into()); } transfer { @@ -201,9 +201,9 @@ benchmarks_instance_pallet! { let target: T::AccountId = account("target", 0, SEED); let target_lookup = T::Lookup::unlookup(target.clone()); - }: _(SystemOrigin::Signed(caller.clone()), collection, item, target_lookup) + }: _(SystemOrigin::Signed(caller.clone()), collection.clone(), item, target_lookup) verify { - assert_last_event::(Event::Transferred { collection, item, from: caller, to: target }.into()); + assert_last_event::(Event::Transferred { collection: collection.clone(), item, from: caller, to: target }.into()); } redeposit { @@ -212,7 +212,7 @@ benchmarks_instance_pallet! { let items = (0..i).map(|x| mint_item::(x as u16).0).collect::>(); Uniques::::force_item_status( SystemOrigin::Root.into(), - collection, + collection.clone(), caller_lookup.clone(), caller_lookup.clone(), caller_lookup.clone(), @@ -220,9 +220,9 @@ benchmarks_instance_pallet! { true, false, )?; - }: _(SystemOrigin::Signed(caller.clone()), collection, items.clone()) + }: _(SystemOrigin::Signed(caller.clone()), collection.clone(), items.clone()) verify { - assert_last_event::(Event::Redeposited { collection, successful_items: items }.into()); + assert_last_event::(Event::Redeposited { collection: collection.clone(), successful_items: items }.into()); } freeze { @@ -238,28 +238,28 @@ benchmarks_instance_pallet! { let (item, ..) = mint_item::(0); Uniques::::freeze( SystemOrigin::Signed(caller.clone()).into(), - collection, + collection.clone(), item, )?; - }: _(SystemOrigin::Signed(caller.clone()), collection, item) + }: _(SystemOrigin::Signed(caller.clone()), collection.clone(), item) verify { - assert_last_event::(Event::Thawed { collection, item }.into()); + assert_last_event::(Event::Thawed { collection: collection.clone(), item }.into()); } freeze_collection { let (collection, caller, caller_lookup) = create_collection::(); - }: _(SystemOrigin::Signed(caller.clone()), collection) + }: _(SystemOrigin::Signed(caller.clone()), collection.clone()) verify { - assert_last_event::(Event::CollectionFrozen { collection }.into()); + assert_last_event::(Event::CollectionFrozen { collection: collection.clone() }.into()); } thaw_collection { let (collection, caller, caller_lookup) = create_collection::(); let origin = SystemOrigin::Signed(caller.clone()).into(); - Uniques::::freeze_collection(origin, collection)?; - }: _(SystemOrigin::Signed(caller.clone()), collection) + Uniques::::freeze_collection(origin, collection.clone())?; + }: _(SystemOrigin::Signed(caller.clone()), collection.clone()) verify { - assert_last_event::(Event::CollectionThawed { collection }.into()); + assert_last_event::(Event::CollectionThawed { collection: collection.clone() }.into()); } transfer_ownership { @@ -268,10 +268,10 @@ benchmarks_instance_pallet! { let target_lookup = T::Lookup::unlookup(target.clone()); T::Currency::make_free_balance_be(&target, T::Currency::minimum_balance()); let origin = SystemOrigin::Signed(target.clone()).into(); - Uniques::::set_accept_ownership(origin, Some(collection))?; - }: _(SystemOrigin::Signed(caller), collection, target_lookup) + Uniques::::set_accept_ownership(origin, Some(collection.clone()))?; + }: _(SystemOrigin::Signed(caller), collection.clone(), target_lookup) verify { - assert_last_event::(Event::OwnerChanged { collection, new_owner: target }.into()); + assert_last_event::(Event::OwnerChanged { collection: collection.clone(), new_owner: target }.into()); } set_team { @@ -279,10 +279,10 @@ benchmarks_instance_pallet! { let target0 = T::Lookup::unlookup(account("target", 0, SEED)); let target1 = T::Lookup::unlookup(account("target", 1, SEED)); let target2 = T::Lookup::unlookup(account("target", 2, SEED)); - }: _(SystemOrigin::Signed(caller), collection, target0, target1, target2) + }: _(SystemOrigin::Signed(caller), collection.clone(), target0, target1, target2) verify { assert_last_event::(Event::TeamChanged{ - collection, + collection: collection.clone(), issuer: account("target", 0, SEED), admin: account("target", 1, SEED), freezer: account("target", 2, SEED), @@ -294,7 +294,7 @@ benchmarks_instance_pallet! { let origin = T::ForceOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?; let call = Call::::force_item_status { - collection, + collection: collection.clone(), owner: caller_lookup.clone(), issuer: caller_lookup.clone(), admin: caller_lookup.clone(), @@ -304,7 +304,7 @@ benchmarks_instance_pallet! { }; }: { call.dispatch_bypass_filter(origin)? } verify { - assert_last_event::(Event::ItemStatusChanged { collection }.into()); + assert_last_event::(Event::ItemStatusChanged { collection: collection.clone() }.into()); } set_attribute { @@ -314,9 +314,9 @@ benchmarks_instance_pallet! { let (collection, caller, _) = create_collection::(); let (item, ..) = mint_item::(0); add_item_metadata::(item); - }: _(SystemOrigin::Signed(caller), collection, Some(item), key.clone(), value.clone()) + }: _(SystemOrigin::Signed(caller), collection.clone(), Some(item), key.clone(), value.clone()) verify { - assert_last_event::(Event::AttributeSet { collection, maybe_item: Some(item), key, value }.into()); + assert_last_event::(Event::AttributeSet { collection: collection.clone(), maybe_item: Some(item), key, value }.into()); } clear_attribute { @@ -324,9 +324,9 @@ benchmarks_instance_pallet! { let (item, ..) = mint_item::(0); add_item_metadata::(item); let (key, ..) = add_item_attribute::(item); - }: _(SystemOrigin::Signed(caller), collection, Some(item), key.clone()) + }: _(SystemOrigin::Signed(caller), collection.clone(), Some(item), key.clone()) verify { - assert_last_event::(Event::AttributeCleared { collection, maybe_item: Some(item), key }.into()); + assert_last_event::(Event::AttributeCleared { collection: collection.clone(), maybe_item: Some(item), key }.into()); } set_metadata { @@ -334,35 +334,35 @@ benchmarks_instance_pallet! { let (collection, caller, _) = create_collection::(); let (item, ..) = mint_item::(0); - }: _(SystemOrigin::Signed(caller), collection, item, data.clone(), false) + }: _(SystemOrigin::Signed(caller), collection.clone(), item, data.clone(), false) verify { - assert_last_event::(Event::MetadataSet { collection, item, data, is_frozen: false }.into()); + assert_last_event::(Event::MetadataSet { collection: collection.clone(), item, data, is_frozen: false }.into()); } clear_metadata { let (collection, caller, _) = create_collection::(); let (item, ..) = mint_item::(0); add_item_metadata::(item); - }: _(SystemOrigin::Signed(caller), collection, item) + }: _(SystemOrigin::Signed(caller), collection.clone(), item) verify { - assert_last_event::(Event::MetadataCleared { collection, item }.into()); + assert_last_event::(Event::MetadataCleared { collection: collection.clone(), item }.into()); } set_collection_metadata { let data: BoundedVec<_, _> = vec![0u8; T::StringLimit::get() as usize].try_into().unwrap(); let (collection, caller, _) = create_collection::(); - }: _(SystemOrigin::Signed(caller), collection, data.clone(), false) + }: _(SystemOrigin::Signed(caller), collection.clone(), data.clone(), false) verify { - assert_last_event::(Event::CollectionMetadataSet { collection, data, is_frozen: false }.into()); + assert_last_event::(Event::CollectionMetadataSet { collection: collection.clone(), data, is_frozen: false }.into()); } clear_collection_metadata { let (collection, caller, _) = create_collection::(); add_collection_metadata::(); - }: _(SystemOrigin::Signed(caller), collection) + }: _(SystemOrigin::Signed(caller), collection.clone()) verify { - assert_last_event::(Event::CollectionMetadataCleared { collection }.into()); + assert_last_event::(Event::CollectionMetadataCleared { collection: collection.clone() }.into()); } approve_transfer { @@ -370,9 +370,9 @@ benchmarks_instance_pallet! { let (item, ..) = mint_item::(0); let delegate: T::AccountId = account("delegate", 0, SEED); let delegate_lookup = T::Lookup::unlookup(delegate.clone()); - }: _(SystemOrigin::Signed(caller.clone()), collection, item, delegate_lookup) + }: _(SystemOrigin::Signed(caller.clone()), collection.clone(), item, delegate_lookup) verify { - assert_last_event::(Event::ApprovedTransfer { collection, item, owner: caller, delegate }.into()); + assert_last_event::(Event::ApprovedTransfer { collection: collection.clone(), item, owner: caller, delegate }.into()); } cancel_approval { @@ -381,17 +381,17 @@ benchmarks_instance_pallet! { let delegate: T::AccountId = account("delegate", 0, SEED); let delegate_lookup = T::Lookup::unlookup(delegate.clone()); let origin = SystemOrigin::Signed(caller.clone()).into(); - Uniques::::approve_transfer(origin, collection, item, delegate_lookup.clone())?; - }: _(SystemOrigin::Signed(caller.clone()), collection, item, Some(delegate_lookup)) + Uniques::::approve_transfer(origin, collection.clone(), item, delegate_lookup.clone())?; + }: _(SystemOrigin::Signed(caller.clone()), collection.clone(), item, Some(delegate_lookup)) verify { - assert_last_event::(Event::ApprovalCancelled { collection, item, owner: caller, delegate }.into()); + assert_last_event::(Event::ApprovalCancelled { collection: collection.clone(), item, owner: caller, delegate }.into()); } set_accept_ownership { let caller: T::AccountId = whitelisted_caller(); T::Currency::make_free_balance_be(&caller, DepositBalanceOf::::max_value()); let collection = T::Helper::collection(0); - }: _(SystemOrigin::Signed(caller.clone()), Some(collection)) + }: _(SystemOrigin::Signed(caller.clone()), Some(collection.clone())) verify { assert_last_event::(Event::OwnershipAcceptanceChanged { who: caller, @@ -401,10 +401,10 @@ benchmarks_instance_pallet! { set_collection_max_supply { let (collection, caller, _) = create_collection::(); - }: _(SystemOrigin::Signed(caller.clone()), collection, u32::MAX) + }: _(SystemOrigin::Signed(caller.clone()), collection.clone(), u32::MAX) verify { assert_last_event::(Event::CollectionMaxSupplySet { - collection, + collection: collection.clone(), max_supply: u32::MAX, }.into()); } @@ -415,10 +415,10 @@ benchmarks_instance_pallet! { let delegate: T::AccountId = account("delegate", 0, SEED); let delegate_lookup = T::Lookup::unlookup(delegate.clone()); let price = ItemPrice::::from(100u32); - }: _(SystemOrigin::Signed(caller.clone()), collection, item, Some(price), Some(delegate_lookup)) + }: _(SystemOrigin::Signed(caller.clone()), collection.clone(), item, Some(price), Some(delegate_lookup)) verify { assert_last_event::(Event::ItemPriceSet { - collection, + collection: collection.clone(), item, price, whitelisted_buyer: Some(delegate), @@ -432,12 +432,12 @@ benchmarks_instance_pallet! { let buyer_lookup = T::Lookup::unlookup(buyer.clone()); let price = ItemPrice::::from(0u32); let origin = SystemOrigin::Signed(seller.clone()).into(); - Uniques::::set_price(origin, collection, item, Some(price.clone()), Some(buyer_lookup))?; + Uniques::::set_price(origin, collection.clone(), item, Some(price.clone()), Some(buyer_lookup))?; T::Currency::make_free_balance_be(&buyer, DepositBalanceOf::::max_value()); - }: _(SystemOrigin::Signed(buyer.clone()), collection, item, price.clone()) + }: _(SystemOrigin::Signed(buyer.clone()), collection.clone(), item, price.clone()) verify { assert_last_event::(Event::ItemBought { - collection, + collection: collection.clone(), item, price, seller, diff --git a/frame/uniques/src/functions.rs b/frame/uniques/src/functions.rs index 1aa79134dd575..681ad06a84b83 100644 --- a/frame/uniques/src/functions.rs +++ b/frame/uniques/src/functions.rs @@ -37,7 +37,7 @@ impl, I: 'static> Pallet { let collection_details = Collection::::get(&collection).ok_or(Error::::UnknownCollection)?; ensure!(!collection_details.is_frozen, Error::::Frozen); - ensure!(!T::Locker::is_locked(collection, item), Error::::Locked); + ensure!(!T::Locker::is_locked(collection.clone(), item), Error::::Locked); let mut details = Item::::get(&collection, &item).ok_or(Error::::UnknownCollection)?; @@ -74,12 +74,12 @@ impl, I: 'static> Pallet { free_holding: bool, event: Event, ) -> DispatchResult { - ensure!(!Collection::::contains_key(collection), Error::::InUse); + ensure!(!Collection::::contains_key(collection.clone()), Error::::InUse); T::Currency::reserve(&owner, deposit)?; Collection::::insert( - collection, + collection.clone(), CollectionDetails { owner: owner.clone(), issuer: admin.clone(), @@ -104,7 +104,7 @@ impl, I: 'static> Pallet { witness: DestroyWitness, maybe_check_owner: Option, ) -> Result { - Collection::::try_mutate_exists(collection, |maybe_details| { + Collection::::try_mutate_exists(collection.clone(), |maybe_details| { let collection_details = maybe_details.take().ok_or(Error::::UnknownCollection)?; if let Some(check_owner) = maybe_check_owner { @@ -147,7 +147,10 @@ impl, I: 'static> Pallet { owner: T::AccountId, with_details: impl FnOnce(&CollectionDetailsFor) -> DispatchResult, ) -> DispatchResult { - ensure!(!Item::::contains_key(collection, item), Error::::AlreadyExists); + ensure!( + !Item::::contains_key(collection.clone(), item), + Error::::AlreadyExists + ); Collection::::try_mutate( &collection, @@ -189,7 +192,7 @@ impl, I: 'static> Pallet { item: T::ItemId, with_details: impl FnOnce(&CollectionDetailsFor, &ItemDetailsFor) -> DispatchResult, ) -> DispatchResult { - ensure!(!T::Locker::is_locked(collection, item), Error::::Locked); + ensure!(!T::Locker::is_locked(collection.clone(), item), Error::::Locked); let owner = Collection::::try_mutate( &collection, |maybe_collection_details| -> Result { @@ -268,7 +271,7 @@ impl, I: 'static> Pallet { let old_owner = details.owner.clone(); - Self::do_transfer(collection, item, buyer.clone(), |_, _| Ok(()))?; + Self::do_transfer(collection.clone(), item, buyer.clone(), |_, _| Ok(()))?; Self::deposit_event(Event::ItemBought { collection, diff --git a/frame/uniques/src/impl_nonfungibles.rs b/frame/uniques/src/impl_nonfungibles.rs index e8bef4e3f5c74..0ae055a98d8c8 100644 --- a/frame/uniques/src/impl_nonfungibles.rs +++ b/frame/uniques/src/impl_nonfungibles.rs @@ -94,12 +94,16 @@ impl, I: 'static> Create<::AccountId> for Pallet admin: &T::AccountId, ) -> DispatchResult { Self::do_create_collection( - *collection, + collection.clone(), who.clone(), admin.clone(), T::CollectionDeposit::get(), false, - Event::Created { collection: *collection, creator: who.clone(), owner: admin.clone() }, + Event::Created { + collection: collection.clone(), + creator: who.clone(), + owner: admin.clone(), + }, ) } } @@ -126,7 +130,7 @@ impl, I: 'static> Mutate<::AccountId> for Pallet item: &Self::ItemId, who: &T::AccountId, ) -> DispatchResult { - Self::do_mint(*collection, *item, who.clone(), |_| Ok(())) + Self::do_mint(collection.clone(), *item, who.clone(), |_| Ok(())) } fn burn( @@ -134,7 +138,7 @@ impl, I: 'static> Mutate<::AccountId> for Pallet item: &Self::ItemId, maybe_check_owner: Option<&T::AccountId>, ) -> DispatchResult { - Self::do_burn(*collection, *item, |_, d| { + Self::do_burn(collection.clone(), *item, |_, d| { if let Some(check_owner) = maybe_check_owner { if &d.owner != check_owner { return Err(Error::::NoPermission.into()) @@ -151,7 +155,7 @@ impl, I: 'static> Transfer for Pallet { item: &Self::ItemId, destination: &T::AccountId, ) -> DispatchResult { - Self::do_transfer(*collection, *item, destination.clone(), |_, _| Ok(())) + Self::do_transfer(collection.clone(), *item, destination.clone(), |_, _| Ok(())) } } diff --git a/frame/uniques/src/lib.rs b/frame/uniques/src/lib.rs index fd94bd3a9a7e4..72ec02cf1f633 100644 --- a/frame/uniques/src/lib.rs +++ b/frame/uniques/src/lib.rs @@ -96,7 +96,7 @@ pub mod pallet { + IsType<::RuntimeEvent>; /// Identifier for the collection of item. - type CollectionId: Member + Parameter + MaxEncodedLen + Copy; + type CollectionId: Member + Parameter + MaxEncodedLen; /// The type used to identify a unique item within a collection. type ItemId: Member + Parameter + MaxEncodedLen + Copy; @@ -461,7 +461,7 @@ pub mod pallet { let admin = T::Lookup::lookup(admin)?; Self::do_create_collection( - collection, + collection.clone(), owner.clone(), admin.clone(), T::CollectionDeposit::get(), @@ -499,7 +499,7 @@ pub mod pallet { let owner = T::Lookup::lookup(owner)?; Self::do_create_collection( - collection, + collection.clone(), owner.clone(), owner.clone(), Zero::zero(), @@ -799,7 +799,7 @@ pub mod pallet { ) -> DispatchResult { let origin = ensure_signed(origin)?; - Collection::::try_mutate(collection, |maybe_details| { + Collection::::try_mutate(collection.clone(), |maybe_details| { let details = maybe_details.as_mut().ok_or(Error::::UnknownCollection)?; ensure!(origin == details.freezer, Error::::NoPermission); @@ -827,7 +827,7 @@ pub mod pallet { ) -> DispatchResult { let origin = ensure_signed(origin)?; - Collection::::try_mutate(collection, |maybe_details| { + Collection::::try_mutate(collection.clone(), |maybe_details| { let details = maybe_details.as_mut().ok_or(Error::::UnknownCollection)?; ensure!(origin == details.admin, Error::::NoPermission); @@ -862,7 +862,7 @@ pub mod pallet { let acceptable_collection = OwnershipAcceptance::::get(&owner); ensure!(acceptable_collection.as_ref() == Some(&collection), Error::::Unaccepted); - Collection::::try_mutate(collection, |maybe_details| { + Collection::::try_mutate(collection.clone(), |maybe_details| { let details = maybe_details.as_mut().ok_or(Error::::UnknownCollection)?; ensure!(origin == details.owner, Error::::NoPermission); if details.owner == owner { @@ -912,7 +912,7 @@ pub mod pallet { let admin = T::Lookup::lookup(admin)?; let freezer = T::Lookup::lookup(freezer)?; - Collection::::try_mutate(collection, |maybe_details| { + Collection::::try_mutate(collection.clone(), |maybe_details| { let details = maybe_details.as_mut().ok_or(Error::::UnknownCollection)?; ensure!(origin == details.owner, Error::::NoPermission); @@ -1060,7 +1060,7 @@ pub mod pallet { ) -> DispatchResult { T::ForceOrigin::ensure_origin(origin)?; - Collection::::try_mutate(collection, |maybe_item| { + Collection::::try_mutate(collection.clone(), |maybe_item| { let mut item = maybe_item.take().ok_or(Error::::UnknownCollection)?; let old_owner = item.owner; let new_owner = T::Lookup::lookup(owner)?; @@ -1115,12 +1115,13 @@ pub mod pallet { ensure!(check_owner == &collection_details.owner, Error::::NoPermission); } let maybe_is_frozen = match maybe_item { - None => CollectionMetadataOf::::get(collection).map(|v| v.is_frozen), - Some(item) => ItemMetadataOf::::get(collection, item).map(|v| v.is_frozen), + None => CollectionMetadataOf::::get(collection.clone()).map(|v| v.is_frozen), + Some(item) => + ItemMetadataOf::::get(collection.clone(), item).map(|v| v.is_frozen), }; ensure!(!maybe_is_frozen.unwrap_or(false), Error::::Frozen); - let attribute = Attribute::::get((collection, maybe_item, &key)); + let attribute = Attribute::::get((collection.clone(), maybe_item, &key)); if attribute.is_none() { collection_details.attributes.saturating_inc(); } @@ -1140,7 +1141,7 @@ pub mod pallet { } Attribute::::insert((&collection, maybe_item, &key), (&value, deposit)); - Collection::::insert(collection, &collection_details); + Collection::::insert(collection.clone(), &collection_details); Self::deposit_event(Event::AttributeSet { collection, maybe_item, key, value }); Ok(()) } @@ -1177,16 +1178,19 @@ pub mod pallet { ensure!(check_owner == &collection_details.owner, Error::::NoPermission); } let maybe_is_frozen = match maybe_item { - None => CollectionMetadataOf::::get(collection).map(|v| v.is_frozen), - Some(item) => ItemMetadataOf::::get(collection, item).map(|v| v.is_frozen), + None => CollectionMetadataOf::::get(collection.clone()).map(|v| v.is_frozen), + Some(item) => + ItemMetadataOf::::get(collection.clone(), item).map(|v| v.is_frozen), }; ensure!(!maybe_is_frozen.unwrap_or(false), Error::::Frozen); - if let Some((_, deposit)) = Attribute::::take((collection, maybe_item, &key)) { + if let Some((_, deposit)) = + Attribute::::take((collection.clone(), maybe_item, &key)) + { collection_details.attributes.saturating_dec(); collection_details.total_deposit.saturating_reduce(deposit); T::Currency::unreserve(&collection_details.owner, deposit); - Collection::::insert(collection, &collection_details); + Collection::::insert(collection.clone(), &collection_details); Self::deposit_event(Event::AttributeCleared { collection, maybe_item, key }); } Ok(()) @@ -1229,7 +1233,7 @@ pub mod pallet { ensure!(check_owner == &collection_details.owner, Error::::NoPermission); } - ItemMetadataOf::::try_mutate_exists(collection, item, |metadata| { + ItemMetadataOf::::try_mutate_exists(collection.clone(), item, |metadata| { let was_frozen = metadata.as_ref().map_or(false, |m| m.is_frozen); ensure!(maybe_check_owner.is_none() || !was_frozen, Error::::Frozen); @@ -1289,7 +1293,7 @@ pub mod pallet { ensure!(check_owner == &collection_details.owner, Error::::NoPermission); } - ItemMetadataOf::::try_mutate_exists(collection, item, |metadata| { + ItemMetadataOf::::try_mutate_exists(collection.clone(), item, |metadata| { let was_frozen = metadata.as_ref().map_or(false, |m| m.is_frozen); ensure!(maybe_check_owner.is_none() || !was_frozen, Error::::Frozen); @@ -1340,7 +1344,7 @@ pub mod pallet { ensure!(check_owner == &details.owner, Error::::NoPermission); } - CollectionMetadataOf::::try_mutate_exists(collection, |metadata| { + CollectionMetadataOf::::try_mutate_exists(collection.clone(), |metadata| { let was_frozen = metadata.as_ref().map_or(false, |m| m.is_frozen); ensure!(maybe_check_owner.is_none() || !was_frozen, Error::::Frozen); @@ -1396,7 +1400,7 @@ pub mod pallet { ensure!(check_owner == &details.owner, Error::::NoPermission); } - CollectionMetadataOf::::try_mutate_exists(collection, |metadata| { + CollectionMetadataOf::::try_mutate_exists(collection.clone(), |metadata| { let was_frozen = metadata.as_ref().map_or(false, |m| m.is_frozen); ensure!(maybe_check_owner.is_none() || !was_frozen, Error::::Frozen); From 14855e63b879a26f23186ed2a3ec4a8ad8a7c019 Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Wed, 10 May 2023 10:41:46 +0100 Subject: [PATCH 13/17] Timeout only if the referendum is not queued (#14106) * Timeout only if the referendum is not queued * ".git/.scripts/commands/fmt/fmt.sh" --------- Co-authored-by: command-bot <> --- frame/referenda/src/lib.rs | 20 ++++++++++++++------ frame/referenda/src/tests.rs | 2 ++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/frame/referenda/src/lib.rs b/frame/referenda/src/lib.rs index 68837376c5b33..dd352d0af40cb 100644 --- a/frame/referenda/src/lib.rs +++ b/frame/referenda/src/lib.rs @@ -79,7 +79,7 @@ use frame_support::{ }; use scale_info::TypeInfo; use sp_runtime::{ - traits::{AtLeast32BitUnsigned, Dispatchable, One, Saturating, Zero}, + traits::{AtLeast32BitUnsigned, Bounded, Dispatchable, One, Saturating, Zero}, DispatchError, Perbill, }; use sp_std::{fmt::Debug, prelude::*}; @@ -1054,9 +1054,9 @@ impl, I: 'static> Pallet { Some(x) => x, None => return (ReferendumInfo::Ongoing(status), false, ServiceBranch::Fail), }; + // Default the alarm to the end of the world. let timeout = status.submitted + T::UndecidingTimeout::get(); - // Default the alarm to the submission timeout. - let mut alarm = timeout; + let mut alarm = T::BlockNumber::max_value(); let branch; match &mut status.deciding { None => { @@ -1097,11 +1097,12 @@ impl, I: 'static> Pallet { ServiceBranch::Preparing } } else { + alarm = timeout; ServiceBranch::NoDeposit } } // If we didn't move into being decided, then check the timeout. - if status.deciding.is_none() && now >= timeout { + if status.deciding.is_none() && now >= timeout && !status.in_queue { // Too long without being decided - end it. Self::ensure_no_alarm(&mut status); Self::deposit_event(Event::::TimedOut { index, tally: status.tally }); @@ -1186,7 +1187,11 @@ impl, I: 'static> Pallet { }, } - let dirty_alarm = Self::ensure_alarm_at(&mut status, index, alarm); + let dirty_alarm = if alarm < T::BlockNumber::max_value() { + Self::ensure_alarm_at(&mut status, index, alarm) + } else { + Self::ensure_no_alarm(&mut status) + }; (ReferendumInfo::Ongoing(status), dirty_alarm || dirty, branch) } @@ -1210,10 +1215,13 @@ impl, I: 'static> Pallet { } /// Cancel the alarm in `status`, if one exists. - fn ensure_no_alarm(status: &mut ReferendumStatusOf) { + fn ensure_no_alarm(status: &mut ReferendumStatusOf) -> bool { if let Some((_, last_alarm)) = status.alarm.take() { // Incorrect alarm - cancel it. let _ = T::Scheduler::cancel(last_alarm); + true + } else { + false } } diff --git a/frame/referenda/src/tests.rs b/frame/referenda/src/tests.rs index 0a1561d001a7d..39f1945bf4f3b 100644 --- a/frame/referenda/src/tests.rs +++ b/frame/referenda/src/tests.rs @@ -190,6 +190,8 @@ fn queueing_works() { set_balance_proposal_bounded(i), DispatchTime::After(0), )); + } + for i in [1, 2, 4] { assert_ok!(Referenda::place_decision_deposit(RuntimeOrigin::signed(i), i as u32)); // TODO: decision deposit after some initial votes with a non-highest voted coming // first. From 3283a0879e3536ae6e7fe4e02a3b145cf520ffe9 Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Wed, 10 May 2023 12:46:52 +0200 Subject: [PATCH 14/17] Include `node-template-release` in workspace (#14103) * Add node-template-release to workspace Signed-off-by: Oliver Tale-Yazdi * Remove empty workspace Signed-off-by: Oliver Tale-Yazdi * Manually update deps Signed-off-by: Oliver Tale-Yazdi * Update Cargo.lock Signed-off-by: Oliver Tale-Yazdi * Update .gitignore Signed-off-by: Oliver Tale-Yazdi * Update license Signed-off-by: Oliver Tale-Yazdi --------- Signed-off-by: Oliver Tale-Yazdi --- .gitignore | 1 - Cargo.lock | 64 +++++++++++++++++++++ Cargo.toml | 1 + scripts/ci/deny.toml | 1 + scripts/ci/node-template-release/Cargo.toml | 14 ++--- 5 files changed, 72 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index f30103c625fe0..2961fd68fa2e4 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,5 @@ rls*.log .cargo-remote.toml *.bin *.iml -scripts/ci/node-template-release/Cargo.lock bin/node-template/Cargo.lock substrate.code-workspace diff --git a/Cargo.lock b/Cargo.lock index 3c6c2496963b5..17ad4e2a36d12 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3134,6 +3134,8 @@ dependencies = [ "libc", "libgit2-sys", "log", + "openssl-probe", + "openssl-sys", "url", ] @@ -4061,7 +4063,9 @@ checksum = "7f3d95f6b51075fe9810a7ae22c7095f12b98005ab364d8544797a825ce946a4" dependencies = [ "cc", "libc", + "libssh2-sys", "libz-sys", + "openssl-sys", "pkg-config", ] @@ -4603,6 +4607,20 @@ dependencies = [ "libsecp256k1-core", ] +[[package]] +name = "libssh2-sys" +version = "0.2.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b094a36eb4b8b8c8a7b4b8ae43b2944502be3e59cd87687595cf6b0a71b3f4ca" +dependencies = [ + "cc", + "libc", + "libz-sys", + "openssl-sys", + "pkg-config", + "vcpkg", +] + [[package]] name = "libz-sys" version = "1.1.9" @@ -5493,6 +5511,20 @@ dependencies = [ "try-runtime-cli", ] +[[package]] +name = "node-template-release" +version = "3.0.0" +dependencies = [ + "clap 4.2.5", + "flate2", + "fs_extra", + "git2", + "glob", + "tar", + "tempfile", + "toml 0.7.3", +] + [[package]] name = "node-template-runtime" version = "4.0.0-dev" @@ -5768,6 +5800,18 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +[[package]] +name = "openssl-sys" +version = "0.9.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e17f59264b2809d77ae94f0e1ebabc434773f370d6ca667bd223ea10e06cc7e" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "os_str_bytes" version = "6.5.0" @@ -11946,6 +11990,17 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" +[[package]] +name = "tar" +version = "0.4.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b55807c0344e1e6c04d7c965f5289c39a8d94ae23ed5c0b57aabac549f871c6" +dependencies = [ + "filetime", + "libc", + "xattr", +] + [[package]] name = "target-lexicon" version = "0.12.7" @@ -13849,6 +13904,15 @@ dependencies = [ "time 0.3.21", ] +[[package]] +name = "xattr" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d1526bbe5aaeb5eb06885f4d987bcdfa5e23187055de9b83fe00156a821fabc" +dependencies = [ + "libc", +] + [[package]] name = "yamux" version = "0.10.2" diff --git a/Cargo.toml b/Cargo.toml index da5e1d532a970..7563a4a643286 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -236,6 +236,7 @@ members = [ "primitives/version/proc-macro", "primitives/wasm-interface", "primitives/weights", + "scripts/ci/node-template-release", "test-utils", "test-utils/client", "test-utils/derive", diff --git a/scripts/ci/deny.toml b/scripts/ci/deny.toml index 91822c831cc19..408a9e55bc40b 100644 --- a/scripts/ci/deny.toml +++ b/scripts/ci/deny.toml @@ -40,6 +40,7 @@ exceptions = [ { allow = ["GPL-3.0 WITH Classpath-exception-2.0"], name = "node-bench" }, { allow = ["GPL-3.0 WITH Classpath-exception-2.0"], name = "node-cli" }, { allow = ["GPL-3.0 WITH Classpath-exception-2.0"], name = "node-inspect" }, + { allow = ["GPL-3.0 WITH Classpath-exception-2.0"], name = "node-template-release" }, { allow = ["GPL-3.0 WITH Classpath-exception-2.0"], name = "node-testing" }, { allow = ["GPL-3.0 WITH Classpath-exception-2.0"], name = "sc-authority-discovery" }, { allow = ["GPL-3.0 WITH Classpath-exception-2.0"], name = "sc-basic-authorship" }, diff --git a/scripts/ci/node-template-release/Cargo.toml b/scripts/ci/node-template-release/Cargo.toml index 668e0f3f62a7f..aca8d6e1f81da 100644 --- a/scripts/ci/node-template-release/Cargo.toml +++ b/scripts/ci/node-template-release/Cargo.toml @@ -3,7 +3,7 @@ name = "node-template-release" version = "3.0.0" authors = ["Parity Technologies "] edition = "2021" -license = "GPL-3.0" +license = "GPL-3.0 WITH Classpath-exception-2.0" homepage = "https://substrate.io" publish = false @@ -11,13 +11,11 @@ publish = false targets = ["x86_64-unknown-linux-gnu"] [dependencies] -clap = { version = "4.0.9", features = ["derive"] } +clap = { version = "4.2.5", features = ["derive"] } flate2 = "1.0" -fs_extra = "1" -git2 = "0.8" -glob = "0.2" +fs_extra = "1.3" +git2 = "0.16" +glob = "0.3" tar = "0.4" tempfile = "3" -toml = "0.4" - -[workspace] +toml = "0.7" From e2c5a564e5a83e1f63d47a4fa300567901f00afc Mon Sep 17 00:00:00 2001 From: Tsvetomir Dimitrov Date: Wed, 10 May 2023 17:11:30 +0300 Subject: [PATCH 15/17] Bump `kvdb-rocksdb` to 0.19.0 (#14113) --- Cargo.lock | 31 +++++++++++++++++++++---------- bin/node/bench/Cargo.toml | 2 +- client/db/Cargo.toml | 4 ++-- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 17ad4e2a36d12..289e0c2c02b8a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -753,9 +753,9 @@ dependencies = [ [[package]] name = "bindgen" -version = "0.64.0" +version = "0.65.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4243e6031260db77ede97ad86c27e501d646a27ab57b59a574f725d98ab1fb4" +checksum = "cfdf7b466f9a4903edc73f95d6d2bcd5baf8ae620638762244d3f60143643cc5" dependencies = [ "bitflags", "cexpr", @@ -763,12 +763,13 @@ dependencies = [ "lazy_static", "lazycell", "peeking_take_while", + "prettyplease 0.2.4", "proc-macro2", "quote", "regex", "rustc-hash", "shlex", - "syn 1.0.109", + "syn 2.0.15", ] [[package]] @@ -4019,9 +4020,9 @@ dependencies = [ [[package]] name = "kvdb-rocksdb" -version = "0.18.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe7a749456510c45f795e8b04a6a3e0976d0139213ecbf465843830ad55e2217" +checksum = "b644c70b92285f66bfc2032922a79000ea30af7bc2ab31902992a5dcb9b434f6" dependencies = [ "kvdb", "num_cpus", @@ -4546,9 +4547,9 @@ dependencies = [ [[package]] name = "librocksdb-sys" -version = "0.10.0+7.9.2" +version = "0.11.0+8.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fe4d5874f5ff2bc616e55e8c6086d478fcda13faf9495768a4aa1c22042d30b" +checksum = "d3386f101bcb4bd252d8e9d2fb41ec3b0862a15a62b478c355b2982efa469e3e" dependencies = [ "bindgen", "bzip2-sys", @@ -7925,6 +7926,16 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "prettyplease" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ceca8aaf45b5c46ec7ed39fff75f57290368c1846d33d24a122ca81416ab058" +dependencies = [ + "proc-macro2", + "syn 2.0.15", +] + [[package]] name = "primitive-types" version = "0.12.1" @@ -8052,7 +8063,7 @@ dependencies = [ "log", "multimap", "petgraph", - "prettyplease", + "prettyplease 0.1.25", "prost", "prost-types", "regex", @@ -8469,9 +8480,9 @@ dependencies = [ [[package]] name = "rocksdb" -version = "0.20.1" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "015439787fce1e75d55f279078d33ff14b4af5d93d995e8838ee4631301c8a99" +checksum = "bb6f170a4041d50a0ce04b0d2e14916d6ca863ea2e422689a5b694395d299ffe" dependencies = [ "libc", "librocksdb-sys", diff --git a/bin/node/bench/Cargo.toml b/bin/node/bench/Cargo.toml index fa497a2fdd242..2cbe7577faa11 100644 --- a/bin/node/bench/Cargo.toml +++ b/bin/node/bench/Cargo.toml @@ -25,7 +25,7 @@ serde = "1.0.136" serde_json = "1.0.85" derive_more = { version = "0.99.17", default-features = false, features = ["display"] } kvdb = "0.13.0" -kvdb-rocksdb = "0.18.0" +kvdb-rocksdb = "0.19.0" sp-trie = { version = "7.0.0", path = "../../../primitives/trie" } sp-core = { version = "7.0.0", path = "../../../primitives/core" } sp-consensus = { version = "0.10.0-dev", path = "../../../primitives/consensus/common" } diff --git a/client/db/Cargo.toml b/client/db/Cargo.toml index cd3a73dd4dab4..fe164793d7b5f 100644 --- a/client/db/Cargo.toml +++ b/client/db/Cargo.toml @@ -19,7 +19,7 @@ codec = { package = "parity-scale-codec", version = "3.2.2", features = [ hash-db = "0.16.0" kvdb = "0.13.0" kvdb-memorydb = "0.13.0" -kvdb-rocksdb = { version = "0.18.0", optional = true } +kvdb-rocksdb = { version = "0.19.0", optional = true } linked-hash-map = "0.5.4" log = "0.4.17" parity-db = "0.4.6" @@ -37,7 +37,7 @@ sp-trie = { version = "7.0.0", path = "../../primitives/trie" } [dev-dependencies] criterion = "0.4.0" -kvdb-rocksdb = "0.18.0" +kvdb-rocksdb = "0.19.0" rand = "0.8.5" tempfile = "3.1.0" quickcheck = { version = "1.0.3", default-features = false } From 49154cc7b30d2519f03c020bf884b310f8aee4c6 Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Wed, 10 May 2023 22:29:00 +0200 Subject: [PATCH 16/17] Remove `#[pallet::generate_storage_info]` from docs (#14116) * Fix docs Signed-off-by: Oliver Tale-Yazdi * Add UI test Signed-off-by: Oliver Tale-Yazdi --------- Signed-off-by: Oliver Tale-Yazdi --- frame/support/procedural/src/lib.rs | 18 ------------- frame/support/src/lib.rs | 25 +++---------------- .../pallet_ui/pallet_struct_invalid_attr.rs | 15 +++++++++++ .../pallet_struct_invalid_attr.stderr | 5 ++++ 4 files changed, 23 insertions(+), 40 deletions(-) create mode 100644 frame/support/test/tests/pallet_ui/pallet_struct_invalid_attr.rs create mode 100644 frame/support/test/tests/pallet_ui/pallet_struct_invalid_attr.stderr diff --git a/frame/support/procedural/src/lib.rs b/frame/support/procedural/src/lib.rs index abfa21b331b0e..895b09a17e083 100644 --- a/frame/support/procedural/src/lib.rs +++ b/frame/support/procedural/src/lib.rs @@ -869,24 +869,6 @@ pub fn generate_store(_: TokenStream, _: TokenStream) -> TokenStream { pallet_macro_stub() } -/// To generate the full storage info (used for PoV calculation) use the attribute -/// `#[pallet::generate_storage_info]`, e.g.: -/// -/// ```ignore -/// #[pallet::pallet] -/// #[pallet::generate_storage_info] -/// pub struct Pallet(_); -/// ``` -/// -/// This requires all storage items to implement the trait `StorageInfoTrait`, thus all keys -/// and value types must be bound by `MaxEncodedLen`. Individual storages can opt-out from this -/// constraint by using [`#[pallet::unbounded]`](`macro@unbounded`) (see -/// [`#[pallet::storage]`](`macro@storage`) for more info). -#[proc_macro_attribute] -pub fn generate_storage_info(_: TokenStream, _: TokenStream) -> TokenStream { - pallet_macro_stub() -} - /// Because the `pallet::pallet` macro implements `GetStorageVersion`, the current storage /// version needs to be communicated to the macro. This can be done by using the /// `pallet::storage_version` attribute: diff --git a/frame/support/src/lib.rs b/frame/support/src/lib.rs index 138b7b55bf0eb..3cd8378be45d1 100644 --- a/frame/support/src/lib.rs +++ b/frame/support/src/lib.rs @@ -1597,7 +1597,6 @@ pub mod pallet_prelude { /// * [`pallet::constant`](#palletconstant) /// * [`pallet::disable_frame_system_supertrait_check`](#disable_supertrait_check) /// * [`pallet::generate_store($vis trait Store)`](#palletgenerate_storevis-trait-store) -/// * [`pallet::generate_storage_info`](#palletgenerate_storage_info) /// * [`pallet::storage_version`](#palletstorage_version) /// * [`pallet::hooks`](#hooks-pallethooks-optional) /// * [`pallet::call`](#call-palletcall-optional) @@ -1801,24 +1800,6 @@ pub mod pallet_prelude { /// /// Also see [`pallet::generate_store`](`frame_support::pallet_macros::generate_store`). /// -/// # `pallet::generate_storage_info` -/// -/// To generate the full storage info (used for PoV calculation) use the attribute -/// `#[pallet::generate_storage_info]`, e.g.: -/// -/// ```ignore -/// #[pallet::pallet] -/// #[pallet::generate_storage_info] -/// pub struct Pallet(_); -/// ``` -/// -/// This requires all storage items to implement the trait [`traits::StorageInfoTrait`], thus -/// all keys and value types must be bound by [`pallet_prelude::MaxEncodedLen`]. Individual -/// storages can opt-out from this constraint by using `#[pallet::unbounded]` (see -/// `#[pallet::storage]` for more info). -/// -/// Also see [`pallet::generate_storage_info`](`frame_support::pallet_macros::generate_storage_info`) -/// /// # `pallet::storage_version` /// /// Because the [`pallet::pallet`](#pallet-struct-placeholder-palletpallet-mandatory) macro @@ -2903,9 +2884,9 @@ pub mod pallet_macros { pub use frame_support_procedural::{ call_index, compact, composite_enum, config, constant, disable_frame_system_supertrait_check, error, event, extra_constants, generate_deposit, - generate_storage_info, generate_store, genesis_build, genesis_config, getter, hooks, - inherent, origin, storage, storage_prefix, storage_version, type_value, unbounded, - validate_unsigned, weight, whitelist_storage, + generate_store, genesis_build, genesis_config, getter, hooks, inherent, origin, storage, + storage_prefix, storage_version, type_value, unbounded, validate_unsigned, weight, + whitelist_storage, }; } diff --git a/frame/support/test/tests/pallet_ui/pallet_struct_invalid_attr.rs b/frame/support/test/tests/pallet_ui/pallet_struct_invalid_attr.rs new file mode 100644 index 0000000000000..ac52e75a5f489 --- /dev/null +++ b/frame/support/test/tests/pallet_ui/pallet_struct_invalid_attr.rs @@ -0,0 +1,15 @@ +#[frame_support::pallet] +mod pallet { + #[pallet::config] + pub trait Config: frame_system::Config {} + + #[pallet::pallet] + #[pallet::generate_storage_info] // invalid + pub struct Pallet(_); + + #[pallet::call] + impl Pallet {} +} + +fn main() { +} diff --git a/frame/support/test/tests/pallet_ui/pallet_struct_invalid_attr.stderr b/frame/support/test/tests/pallet_ui/pallet_struct_invalid_attr.stderr new file mode 100644 index 0000000000000..301a73c000f07 --- /dev/null +++ b/frame/support/test/tests/pallet_ui/pallet_struct_invalid_attr.stderr @@ -0,0 +1,5 @@ +error: expected one of: `generate_store`, `without_storage_info`, `storage_version` + --> tests/pallet_ui/pallet_struct_invalid_attr.rs:7:12 + | +7 | #[pallet::generate_storage_info] // invalid + | ^^^^^^^^^^^^^^^^^^^^^ From aee8f7641a41971959373d44e2e0e4038b179376 Mon Sep 17 00:00:00 2001 From: Vladimir Istyufeev Date: Thu, 11 May 2023 02:35:24 +0400 Subject: [PATCH 17/17] Bump `Cargo.lock` (#14121) * Bump `Cargo.lock` * Use master Cargo.lock Signed-off-by: Oliver Tale-Yazdi * Update Cargo.lock Signed-off-by: Oliver Tale-Yazdi --------- Signed-off-by: Oliver Tale-Yazdi Co-authored-by: Oliver Tale-Yazdi --- Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 289e0c2c02b8a..0e6e8e847a01b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5516,7 +5516,7 @@ dependencies = [ name = "node-template-release" version = "3.0.0" dependencies = [ - "clap 4.2.5", + "clap 4.2.7", "flate2", "fs_extra", "git2",